summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2020-05-24 15:44:22 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2020-05-24 15:44:22 (GMT)
commite9d72bbaa4a4cef256b3d3480ed1136b8651d019 (patch)
tree5b555bb43f3c32b4ff86fe07b3b06f5000ade4d9
parenta48a5b55179978d3f31371c90d9be6eaa6931f17 (diff)
parentad1ded4a7f409e06bd6e1b33da463e6c7cd844af (diff)
downloadtk-e9d72bbaa4a4cef256b3d3480ed1136b8651d019.zip
tk-e9d72bbaa4a4cef256b3d3480ed1136b8651d019.tar.gz
tk-e9d72bbaa4a4cef256b3d3480ed1136b8651d019.tar.bz2
Merge trunk
-rw-r--r--.fossil-settings/ignore-glob1
-rw-r--r--.gitignore28
-rw-r--r--.travis.yml185
-rw-r--r--ChangeLog2
-rw-r--r--ChangeLog.20022
-rw-r--r--README41
-rw-r--r--README.md37
-rw-r--r--changes208
-rw-r--r--compat/stdbool.h37
-rw-r--r--compat/stdint.h919
-rw-r--r--compat/stdlib.h40
-rw-r--r--compat/unistd.h80
-rw-r--r--doc/ConfigWidg.314
-rw-r--r--doc/CrtCmHdlr.32
-rw-r--r--doc/CrtGenHdlr.32
-rw-r--r--doc/CrtItemType.345
-rw-r--r--doc/EventHndlr.32
-rw-r--r--doc/GetScroll.312
-rw-r--r--doc/HandleEvent.32
-rw-r--r--doc/MoveToplev.32
-rw-r--r--doc/NameOfImg.36
-rw-r--r--doc/ParseArgv.312
-rw-r--r--doc/RestrictEv.36
-rw-r--r--doc/SetClassProcs.34
-rw-r--r--doc/SetOptions.321
-rw-r--r--doc/bind.n83
-rw-r--r--doc/canvas.n79
-rw-r--r--doc/colors.n42
-rw-r--r--doc/entry.n19
-rw-r--r--doc/event.n29
-rw-r--r--doc/frame.n25
-rw-r--r--doc/grid.n4
-rw-r--r--doc/keysyms.n3096
-rw-r--r--doc/listbox.n16
-rw-r--r--doc/man.macros267
-rw-r--r--doc/panedwindow.n2
-rw-r--r--doc/photo.n54
-rw-r--r--doc/popup.n2
-rw-r--r--doc/scale.n4
-rw-r--r--doc/scrollbar.n18
-rw-r--r--doc/spinbox.n17
-rw-r--r--doc/text.n44
-rw-r--r--doc/tk4.0.ps6
-rw-r--r--doc/tk_mac.n79
-rw-r--r--doc/toplevel.n34
-rw-r--r--doc/ttk_Geometry.32
-rw-r--r--doc/ttk_button.n2
-rw-r--r--doc/ttk_checkbutton.n2
-rw-r--r--doc/ttk_combobox.n6
-rw-r--r--doc/ttk_entry.n54
-rw-r--r--doc/ttk_frame.n7
-rw-r--r--doc/ttk_intro.n6
-rw-r--r--doc/ttk_label.n2
-rw-r--r--doc/ttk_labelframe.n20
-rw-r--r--doc/ttk_menubutton.n2
-rw-r--r--doc/ttk_notebook.n2
-rw-r--r--doc/ttk_progressbar.n4
-rw-r--r--doc/ttk_radiobutton.n2
-rw-r--r--doc/ttk_scale.n4
-rw-r--r--doc/ttk_scrollbar.n32
-rw-r--r--doc/ttk_spinbox.n8
-rw-r--r--doc/ttk_style.n2
-rw-r--r--doc/ttk_treeview.n61
-rw-r--r--doc/ttk_widget.n85
-rw-r--r--generic/ks_names.h3020
-rwxr-xr-xgeneric/nanosvg.h3088
-rw-r--r--generic/nanosvgrast.h1467
-rw-r--r--generic/tk.decls24
-rw-r--r--generic/tk.h73
-rw-r--r--generic/tk3d.c31
-rw-r--r--generic/tkArgv.c18
-rw-r--r--generic/tkArray.h610
-rw-r--r--generic/tkAtom.c6
-rw-r--r--generic/tkBind.c4778
-rw-r--r--generic/tkBitmap.c52
-rw-r--r--generic/tkBusy.c36
-rw-r--r--generic/tkButton.c476
-rw-r--r--generic/tkButton.h2
-rw-r--r--generic/tkCanvArc.c206
-rw-r--r--generic/tkCanvBmap.c82
-rw-r--r--generic/tkCanvImg.c57
-rw-r--r--generic/tkCanvLine.c239
-rw-r--r--generic/tkCanvPoly.c191
-rw-r--r--generic/tkCanvPs.c46
-rw-r--r--generic/tkCanvText.c148
-rw-r--r--generic/tkCanvUtil.c134
-rw-r--r--generic/tkCanvWind.c71
-rw-r--r--generic/tkCanvas.c367
-rw-r--r--generic/tkCanvas.h2
-rw-r--r--generic/tkClipboard.c41
-rw-r--r--generic/tkCmds.c376
-rw-r--r--generic/tkColor.c24
-rw-r--r--generic/tkConfig.c87
-rw-r--r--generic/tkConsole.c77
-rw-r--r--generic/tkCursor.c30
-rw-r--r--generic/tkDList.h546
-rw-r--r--generic/tkEntry.c533
-rw-r--r--generic/tkError.c2
-rw-r--r--generic/tkEvent.c249
-rw-r--r--generic/tkFileFilter.c34
-rw-r--r--generic/tkFocus.c31
-rw-r--r--generic/tkFont.c87
-rw-r--r--generic/tkFrame.c428
-rw-r--r--generic/tkGC.c16
-rw-r--r--generic/tkGeometry.c69
-rw-r--r--generic/tkGet.c11
-rw-r--r--generic/tkGrab.c56
-rw-r--r--generic/tkGrid.c129
-rw-r--r--generic/tkImage.c52
-rw-r--r--generic/tkImgBmap.c36
-rw-r--r--generic/tkImgGIF.c40
-rw-r--r--generic/tkImgListFormat.c22
-rw-r--r--generic/tkImgPNG.c31
-rw-r--r--generic/tkImgPPM.c15
-rw-r--r--generic/tkImgPhInstance.c72
-rw-r--r--generic/tkImgPhoto.c103
-rw-r--r--generic/tkImgSVGnano.c810
-rw-r--r--generic/tkImgUtil.c2
-rw-r--r--generic/tkInt.decls583
-rw-r--r--generic/tkInt.h164
-rw-r--r--generic/tkIntDecls.h116
-rw-r--r--generic/tkIntPlatDecls.h162
-rw-r--r--generic/tkIntXlibDecls.h603
-rw-r--r--generic/tkListbox.c264
-rw-r--r--generic/tkMacWinMenu.c10
-rw-r--r--generic/tkMain.c71
-rw-r--r--generic/tkMenu.c435
-rw-r--r--generic/tkMenu.h20
-rw-r--r--generic/tkMenuDraw.c77
-rw-r--r--generic/tkMenubutton.c153
-rw-r--r--generic/tkMessage.c126
-rw-r--r--generic/tkObj.c142
-rw-r--r--generic/tkOldConfig.c34
-rw-r--r--generic/tkOldTest.c26
-rw-r--r--generic/tkOption.c75
-rw-r--r--generic/tkPack.c73
-rw-r--r--generic/tkPanedWindow.c160
-rw-r--r--generic/tkPkgConfig.c166
-rw-r--r--generic/tkPlace.c107
-rw-r--r--generic/tkPlatDecls.h43
-rw-r--r--generic/tkPointer.c93
-rw-r--r--generic/tkRectOval.c134
-rw-r--r--generic/tkScale.c406
-rw-r--r--generic/tkScale.h12
-rw-r--r--generic/tkScrollbar.c64
-rw-r--r--generic/tkSelect.c80
-rw-r--r--generic/tkSelect.h2
-rw-r--r--generic/tkSquare.c42
-rw-r--r--generic/tkStubInit.c328
-rw-r--r--generic/tkStubLib.c4
-rw-r--r--generic/tkStyle.c86
-rw-r--r--generic/tkTest.c273
-rw-r--r--generic/tkText.c309
-rw-r--r--generic/tkTextBTree.c303
-rw-r--r--generic/tkTextDisp.c120
-rw-r--r--generic/tkTextImage.c53
-rw-r--r--generic/tkTextIndex.c51
-rw-r--r--generic/tkTextMark.c54
-rw-r--r--generic/tkTextTag.c131
-rw-r--r--generic/tkTextWind.c61
-rw-r--r--generic/tkTrig.c19
-rw-r--r--generic/tkUndo.c10
-rw-r--r--generic/tkUtil.c167
-rw-r--r--generic/tkVisual.c52
-rw-r--r--generic/tkWindow.c170
-rw-r--r--generic/ttk/ttk.decls8
-rw-r--r--generic/ttk/ttkBlink.c10
-rw-r--r--generic/ttk/ttkButton.c136
-rw-r--r--generic/ttk/ttkCache.c34
-rw-r--r--generic/ttk/ttkClamTheme.c305
-rw-r--r--generic/ttk/ttkClassicTheme.c136
-rw-r--r--generic/ttk/ttkDecls.h26
-rw-r--r--generic/ttk/ttkDefaultTheme.c323
-rw-r--r--generic/ttk/ttkElements.c484
-rw-r--r--generic/ttk/ttkEntry.c280
-rw-r--r--generic/ttk/ttkFrame.c69
-rw-r--r--generic/ttk/ttkImage.c35
-rw-r--r--generic/ttk/ttkInit.c57
-rw-r--r--generic/ttk/ttkLabel.c111
-rw-r--r--generic/ttk/ttkLayout.c8
-rw-r--r--generic/ttk/ttkManager.c42
-rw-r--r--generic/ttk/ttkManager.h22
-rw-r--r--generic/ttk/ttkNotebook.c189
-rw-r--r--generic/ttk/ttkPanedwindow.c141
-rw-r--r--generic/ttk/ttkProgress.c73
-rw-r--r--generic/ttk/ttkScale.c56
-rw-r--r--generic/ttk/ttkScroll.c37
-rw-r--r--generic/ttk/ttkScrollbar.c28
-rw-r--r--generic/ttk/ttkSeparator.c14
-rw-r--r--generic/ttk/ttkSquare.c51
-rw-r--r--generic/ttk/ttkState.c6
-rw-r--r--generic/ttk/ttkStubInit.c12
-rw-r--r--generic/ttk/ttkStubLib.c4
-rw-r--r--generic/ttk/ttkTagSet.c35
-rw-r--r--generic/ttk/ttkTheme.c140
-rw-r--r--generic/ttk/ttkTheme.h62
-rw-r--r--generic/ttk/ttkTrace.c23
-rw-r--r--generic/ttk/ttkTrack.c8
-rw-r--r--generic/ttk/ttkTreeview.c305
-rw-r--r--generic/ttk/ttkWidget.c60
-rw-r--r--generic/ttk/ttkWidget.h21
-rw-r--r--library/bgerror.tcl6
-rw-r--r--library/button.tcl24
-rw-r--r--library/clrpick.tcl8
-rw-r--r--library/console.tcl74
-rw-r--r--library/demos/arrow.tcl18
-rw-r--r--library/demos/bind.tcl16
-rw-r--r--library/demos/colors.tcl2
-rw-r--r--library/demos/cscroll.tcl90
-rw-r--r--library/demos/ctext.tcl16
-rw-r--r--library/demos/entry1.tcl2
-rw-r--r--library/demos/entry2.tcl2
-rw-r--r--library/demos/floor.tcl290
-rw-r--r--library/demos/goldberg.tcl12
-rw-r--r--library/demos/image2.tcl2
-rw-r--r--library/demos/items.tcl22
-rw-r--r--library/demos/ixset2
-rw-r--r--library/demos/knightstour.tcl6
-rw-r--r--library/demos/paned1.tcl4
-rw-r--r--library/demos/pendulum.tcl18
-rw-r--r--library/demos/plot.tcl6
-rw-r--r--library/demos/ruler.tcl18
-rw-r--r--library/demos/square4
-rw-r--r--library/demos/tcolor2
-rw-r--r--library/demos/text.tcl8
-rw-r--r--library/demos/toolbar.tcl4
-rw-r--r--library/demos/tree.tcl2
-rw-r--r--library/demos/ttkpane.tcl2
-rw-r--r--library/demos/twind.tcl64
-rw-r--r--library/demos/unicodeout.tcl27
-rw-r--r--library/demos/widget24
-rw-r--r--library/dialog.tcl5
-rw-r--r--library/entry.tcl81
-rw-r--r--library/iconlist.tcl41
-rw-r--r--library/listbox.tcl52
-rw-r--r--library/menu.tcl19
-rw-r--r--library/msgbox.tcl3
-rw-r--r--library/obsolete.tcl2
-rw-r--r--library/scale.tcl8
-rw-r--r--library/scrlbar.tcl69
-rw-r--r--library/spinbox.tcl53
-rw-r--r--library/tearoff.tcl8
-rw-r--r--library/text.tcl128
-rw-r--r--library/tk.tcl109
-rw-r--r--library/tkfbox.tcl2
-rw-r--r--library/ttk/aquaTheme.tcl110
-rw-r--r--library/ttk/button.tcl14
-rw-r--r--library/ttk/combobox.tcl44
-rw-r--r--library/ttk/cursors.tcl59
-rw-r--r--library/ttk/entry.tcl103
-rw-r--r--library/ttk/fonts.tcl12
-rw-r--r--library/ttk/menubutton.tcl150
-rw-r--r--library/ttk/notebook.tcl28
-rw-r--r--library/ttk/panedwindow.tcl15
-rw-r--r--library/ttk/scale.tcl8
-rw-r--r--library/ttk/scrollbar.tcl42
-rw-r--r--library/ttk/sizegrip.tcl2
-rw-r--r--library/ttk/spinbox.tcl12
-rw-r--r--library/ttk/treeview.tcl60
-rw-r--r--library/ttk/utils.tcl87
-rw-r--r--library/ttk/xpTheme.tcl7
-rw-r--r--library/xmfbox.tcl4
-rw-r--r--macosx/GNUmakefile21
-rw-r--r--macosx/README202
-rw-r--r--macosx/Tk.xcode/project.pbxproj2
-rw-r--r--macosx/Tk.xcodeproj/project.pbxproj2
-rw-r--r--macosx/Wish-Info.plist.in158
-rw-r--r--macosx/Wish.sdef9
-rw-r--r--macosx/tkMacOSX.h2
-rw-r--r--macosx/tkMacOSXBitmap.c104
-rw-r--r--macosx/tkMacOSXButton.c725
-rw-r--r--macosx/tkMacOSXClipboard.c39
-rw-r--r--macosx/tkMacOSXColor.c695
-rw-r--r--macosx/tkMacOSXConfig.c4
-rw-r--r--macosx/tkMacOSXConstants.h18
-rw-r--r--macosx/tkMacOSXCursor.c280
-rw-r--r--macosx/tkMacOSXDebug.c2
-rw-r--r--macosx/tkMacOSXDefault.h66
-rw-r--r--macosx/tkMacOSXDialog.c571
-rw-r--r--macosx/tkMacOSXDraw.c652
-rw-r--r--macosx/tkMacOSXEmbed.c87
-rw-r--r--macosx/tkMacOSXEntry.c23
-rw-r--r--macosx/tkMacOSXEvent.c28
-rw-r--r--macosx/tkMacOSXEvent.h23
-rw-r--r--macosx/tkMacOSXFont.c414
-rw-r--r--macosx/tkMacOSXFont.h2
-rw-r--r--macosx/tkMacOSXHLEvents.c434
-rw-r--r--macosx/tkMacOSXImage.c164
-rw-r--r--macosx/tkMacOSXInit.c197
-rw-r--r--macosx/tkMacOSXInt.h22
-rw-r--r--macosx/tkMacOSXKeyEvent.c986
-rw-r--r--macosx/tkMacOSXKeyboard.c937
-rw-r--r--macosx/tkMacOSXKeysyms.h1308
-rw-r--r--macosx/tkMacOSXMenu.c250
-rw-r--r--macosx/tkMacOSXMenubutton.c452
-rw-r--r--macosx/tkMacOSXMenus.c47
-rw-r--r--macosx/tkMacOSXMouseEvent.c307
-rw-r--r--macosx/tkMacOSXNotify.c165
-rw-r--r--macosx/tkMacOSXPort.h66
-rw-r--r--macosx/tkMacOSXPrivate.h169
-rw-r--r--macosx/tkMacOSXRegion.c116
-rw-r--r--macosx/tkMacOSXScale.c110
-rw-r--r--macosx/tkMacOSXScrlbr.c524
-rw-r--r--macosx/tkMacOSXSend.c17
-rw-r--r--macosx/tkMacOSXServices.c165
-rw-r--r--macosx/tkMacOSXSubwindows.c220
-rw-r--r--macosx/tkMacOSXTest.c255
-rw-r--r--macosx/tkMacOSXWindowEvent.c193
-rw-r--r--macosx/tkMacOSXWm.c955
-rw-r--r--macosx/tkMacOSXWm.h2
-rw-r--r--macosx/tkMacOSXXStubs.c641
-rw-r--r--macosx/ttkMacOSXTheme.c2881
-rw-r--r--tests/arc.tcl14
-rw-r--r--tests/bind.test1563
-rw-r--r--tests/bugs.tcl41
-rw-r--r--tests/button.test47
-rw-r--r--tests/canvImg.test68
-rw-r--r--tests/canvPs.test16
-rw-r--r--tests/canvText.test37
-rw-r--r--tests/canvas.test259
-rw-r--r--tests/choosedir.test4
-rw-r--r--tests/clrpick.test4
-rw-r--r--tests/cmap.tcl2
-rw-r--r--tests/constraints.tcl2
-rw-r--r--tests/dialog.test4
-rw-r--r--tests/entry.test70
-rw-r--r--tests/event.test61
-rw-r--r--tests/filebox.test4
-rw-r--r--tests/focus.test26
-rw-r--r--tests/font.test12
-rw-r--r--tests/frame.test821
-rw-r--r--tests/grab.test36
-rw-r--r--tests/grid.test25
-rw-r--r--tests/image.test50
-rw-r--r--tests/imgListFormat.test2
-rw-r--r--tests/imgPhoto.test10
-rw-r--r--tests/imgSVGnano.test220
-rw-r--r--tests/listbox.test69
-rw-r--r--tests/menu.test556
-rw-r--r--tests/menuDraw.test2
-rw-r--r--tests/menubut.test29
-rw-r--r--tests/message.test28
-rw-r--r--tests/msgbox.test4
-rw-r--r--tests/pack.test21
-rw-r--r--tests/pkgconfig.test66
-rw-r--r--tests/place.test21
-rw-r--r--tests/safe.test2
-rw-r--r--tests/scale.test54
-rw-r--r--tests/scrollbar.test144
-rw-r--r--tests/select.test10
-rw-r--r--tests/spinbox.test42
-rw-r--r--tests/text.test33
-rw-r--r--tests/textBTree.test10
-rw-r--r--tests/textDisp.test896
-rw-r--r--tests/textIndex.test8
-rw-r--r--tests/textTag.test57
-rw-r--r--tests/textWind.test9
-rw-r--r--tests/ttk/checkbutton.test2
-rw-r--r--tests/ttk/combobox.test11
-rw-r--r--tests/ttk/entry.test62
-rw-r--r--tests/ttk/notebook.test2
-rw-r--r--tests/ttk/scrollbar.test116
-rw-r--r--tests/ttk/treetags.test25
-rw-r--r--tests/ttk/treeview.test202
-rw-r--r--tests/ttk/ttk.test20
-rw-r--r--tests/unixButton.test2
-rw-r--r--tests/unixEmbed.test91
-rw-r--r--tests/util.test6
-rw-r--r--tests/visual.test10
-rw-r--r--tests/visual_bb.test4
-rwxr-xr-xtests/winDialog.test22
-rw-r--r--tests/winFont.test16
-rw-r--r--tests/winSend.test18
-rw-r--r--tests/winWm.test4
-rw-r--r--tests/winfo.test23
-rw-r--r--tests/wm.test20
-rw-r--r--unix/Makefile.in99
-rw-r--r--unix/README4
-rwxr-xr-xunix/configure745
-rw-r--r--unix/configure.ac88
-rwxr-xr-xunix/installManPage10
-rw-r--r--unix/tcl.m4134
-rw-r--r--unix/tk.pc.in3
-rw-r--r--unix/tk.spec4
-rw-r--r--unix/tkAppInit.c6
-rw-r--r--unix/tkConfig.h.in12
-rw-r--r--unix/tkConfig.sh.in3
-rw-r--r--unix/tkUnix.c5
-rw-r--r--unix/tkUnix3d.c4
-rw-r--r--unix/tkUnixButton.c10
-rw-r--r--unix/tkUnixColor.c28
-rw-r--r--unix/tkUnixConfig.c4
-rw-r--r--unix/tkUnixCursor.c6
-rw-r--r--unix/tkUnixDefault.h17
-rw-r--r--unix/tkUnixDialog.c2
-rw-r--r--unix/tkUnixDraw.c27
-rw-r--r--unix/tkUnixEmbed.c43
-rw-r--r--unix/tkUnixEvent.c87
-rw-r--r--unix/tkUnixFont.c282
-rw-r--r--unix/tkUnixInit.c11
-rw-r--r--unix/tkUnixKey.c51
-rw-r--r--unix/tkUnixMenu.c73
-rw-r--r--unix/tkUnixMenubu.c9
-rw-r--r--unix/tkUnixPort.h64
-rw-r--r--unix/tkUnixRFont.c125
-rw-r--r--unix/tkUnixScale.c93
-rw-r--r--unix/tkUnixScrlbr.c20
-rw-r--r--unix/tkUnixSelect.c59
-rw-r--r--unix/tkUnixSend.c63
-rw-r--r--unix/tkUnixWm.c270
-rw-r--r--win/Makefile.in141
-rw-r--r--win/README2
-rwxr-xr-xwin/configure168
-rw-r--r--win/configure.ac2
-rw-r--r--win/makefile.vc58
-rw-r--r--win/rules.vc293
-rw-r--r--win/stubs.c232
-rw-r--r--win/targets.vc2
-rw-r--r--win/tcl.m449
-rw-r--r--win/tkWin32Dll.c3
-rw-r--r--win/tkWin3d.c2
-rw-r--r--win/tkWinButton.c57
-rw-r--r--win/tkWinClipboard.c54
-rw-r--r--win/tkWinColor.c30
-rw-r--r--win/tkWinCursor.c21
-rw-r--r--win/tkWinDefault.h10
-rw-r--r--win/tkWinDialog.c455
-rw-r--r--win/tkWinDraw.c71
-rw-r--r--win/tkWinEmbed.c32
-rw-r--r--win/tkWinFont.c288
-rw-r--r--win/tkWinImage.c25
-rw-r--r--win/tkWinInit.c35
-rw-r--r--win/tkWinInt.h33
-rw-r--r--win/tkWinKey.c141
-rw-r--r--win/tkWinMenu.c336
-rw-r--r--win/tkWinPixmap.c16
-rw-r--r--win/tkWinPointer.c115
-rw-r--r--win/tkWinPort.h4
-rw-r--r--win/tkWinRegion.c22
-rw-r--r--win/tkWinScrlbr.c27
-rw-r--r--win/tkWinSend.c41
-rw-r--r--win/tkWinSendCom.c67
-rw-r--r--win/tkWinTest.c88
-rw-r--r--win/tkWinWindow.c54
-rw-r--r--win/tkWinWm.c493
-rw-r--r--win/tkWinX.c433
-rw-r--r--win/ttkWinMonitor.c28
-rw-r--r--win/ttkWinTheme.c213
-rw-r--r--win/ttkWinXPTheme.c206
-rw-r--r--win/winMain.c12
-rw-r--r--xlib/X11/DECkeysym.h65
-rw-r--r--xlib/X11/HPkeysym.h164
-rw-r--r--xlib/X11/Sunkeysym.h106
-rw-r--r--xlib/X11/X.h60
-rwxr-xr-xxlib/X11/XF86keysym.h230
-rw-r--r--xlib/X11/Xfuncproto.h195
-rw-r--r--xlib/X11/Xlib.h3051
-rw-r--r--xlib/X11/Xutil.h458
-rw-r--r--xlib/X11/ap_keysym.h51
-rw-r--r--xlib/X11/cursorfont.h34
-rw-r--r--xlib/X11/keysym.h49
-rw-r--r--xlib/X11/keysymdef.h3386
-rw-r--r--xlib/xcolors.c157
-rw-r--r--xlib/xgc.c393
-rw-r--r--xlib/xutil.c8
465 files changed, 52059 insertions, 22258 deletions
diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob
index 4dad6fc..e319620 100644
--- a/.fossil-settings/ignore-glob
+++ b/.fossil-settings/ignore-glob
@@ -18,7 +18,6 @@
*/wish*
*/tktest*
*/versions.vc
-doc/man.macros
win/Debug*
win/Release*
win/nmhlp-out.txt
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d96b03e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,28 @@
+*.a
+*.dll
+*.dylib
+*.exe
+*.exp
+*.lib
+*.o
+*.obj
+*.pdb
+*.res
+*.sl
+*.so
+*/Makefile
+*/config.cache
+*/config.log
+*/config.status
+*/tkConfig.sh
+*/wish*
+*/tktest*
+*/versions.vc
+unix/tk.pc
+unix/tclIndex
+win/Debug*
+win/Release*
+win/*.manifest
+win/nmhlp-out.txt
+win/nmakehlp.out
+
diff --git a/.travis.yml b/.travis.yml
index f2095d0..93162cb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,56 +3,74 @@ language: c
addons:
apt:
packages:
+ - binutils-mingw-w64-i686
+ - binutils-mingw-w64-x86-64
+ - gcc-mingw-w64
+ - gcc-mingw-w64-base
+ - gcc-mingw-w64-i686
+ - gcc-mingw-w64-x86-64
+ - gcc-multilib
- tcl-dev
- libx11-dev
+ homebrew:
+ packages:
+ - tcl-tk
+ casks:
+ - xquartz
+ update: true
matrix:
include:
- - os: linux
- dist: trusty
- compiler: clang
+# Testing on Linux with various compilers
+ - name: "Linux/GCC/Shared"
+ os: linux
+ dist: bionic
+ compiler: gcc
env:
- BUILD_DIR=unix
- - os: linux
- dist: trusty
- compiler: clang
+ - name: "Linux/GCC/Shared/no-xft"
+ os: linux
+ dist: bionic
+ compiler: gcc
env:
- - CFGOPT=--disable-shared
- BUILD_DIR=unix
- - os: linux
- dist: trusty
+ - CFGOPT="--disable-xft"
+ - name: "Linux/GCC/Static"
+ os: linux
+ dist: bionic
compiler: gcc
env:
- BUILD_DIR=unix
- - os: linux
- dist: trusty
+ - CFGOPT="--disable-shared"
+ - name: "Linux/GCC/Debug"
+ os: linux
+ dist: bionic
compiler: gcc
env:
- - CFGOPT=--disable-shared
- BUILD_DIR=unix
- - os: linux
- dist: trusty
- compiler: gcc-4.9
- addons:
- apt:
- sources:
- - ubuntu-toolchain-r-test
- packages:
- - g++-4.9
+ - CFGOPT="--enable-symbols"
+ - name: "Linux/G++/Shared"
+ os: linux
+ dist: bionic
+ compiler: g++
env:
- BUILD_DIR=unix
- - os: linux
- dist: trusty
- compiler: gcc-5
+ - CFGOPT="CC=g++ CFLAGS=-Dregister=dont+use+register"
+# Older versions of GCC...
+ - name: "Linux/GCC 7/Shared"
+ os: linux
+ dist: bionic
+ compiler: gcc-7
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- - g++-5
+ - g++-7
env:
- BUILD_DIR=unix
- - os: linux
- dist: trusty
+ - name: "Linux/GCC 6/Shared"
+ os: linux
+ dist: bionic
compiler: gcc-6
addons:
apt:
@@ -62,23 +80,118 @@ matrix:
- g++-6
env:
- BUILD_DIR=unix
- - os: linux
- dist: trusty
- compiler: gcc-7
+ - name: "Linux/GCC 5/Shared"
+ os: linux
+ dist: bionic
+ compiler: gcc-5
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- - g++-7
+ - g++-5
+ env:
+ - BUILD_DIR=unix
+# Clang
+ - name: "Linux/Clang/Shared"
+ os: linux
+ dist: bionic
+ compiler: clang
+ env:
+ - BUILD_DIR=unix
+ - name: "Linux/Clang/Shared/no-xft"
+ os: linux
+ dist: bionic
+ compiler: clang
+ env:
+ - BUILD_DIR=unix
+ - CFGOPT="--disable-xft"
+ - name: "Linux/Clang/Static"
+ os: linux
+ dist: bionic
+ compiler: clang
+ env:
+ - CFGOPT="--disable-shared"
+ - BUILD_DIR=unix
+ - name: "Linux/Clang/Debug"
+ os: linux
+ dist: bionic
+ compiler: clang
+ env:
+ - BUILD_DIR=unix
+ - CFGOPT="--enable-symbols"
+# Testing on Mac, various styles
+ - name: "macOS/Xcode 11.5/Shared"
+ os: osx
+ osx_image: xcode11.5
env:
- BUILD_DIR=unix
+ - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include"
+ - name: "macOS/Xcode 11.5/Static"
+ os: osx
+ osx_image: xcode11.5
+ env:
+ - BUILD_DIR=unix
+ - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua --disable-shared CFLAGS=-I/usr/local/opt/tcl-tk/include"
+ - name: "macOS/Xcode 11.5/Debug"
+ os: osx
+ osx_image: xcode11.5
+ env:
+ - BUILD_DIR=unix
+ - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua --enable-symbols CFLAGS=-I/usr/local/opt/tcl-tk/include"
+ - name: "macOS/Xcode 11.5/Shared/XQuartz"
+ os: osx
+ osx_image: xcode11.5
+ env:
+ - BUILD_DIR=unix
+ - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --disable-corefoundation --x-includes=/opt/X11/include --x-libraries=/opt/X11/lib CFLAGS=-I/usr/local/opt/tcl-tk/include"
+# Older MacOS versions
+ - name: "macOS/Xcode 11/Shared"
+ os: osx
+ osx_image: xcode11
+ env:
+ - BUILD_DIR=unix
+ - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include"
+ - name: "macOS/Xcode 10/Shared"
+ os: osx
+ osx_image: xcode10.3
+ env:
+ - BUILD_DIR=unix
+ - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include"
+ - name: "macOS/Xcode 9/Shared"
+ os: osx
+ osx_image: xcode9.4
+ env:
+ - BUILD_DIR=unix
+ - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include"
+# Test on Windows with MSVC native
+# - name: "Windows/MSVC/Shared"
+# os: windows
+# compiler: cl
+# env: &vcenv
+# - BUILD_DIR=win
+# - VCDIR="/C/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Auxiliary/Build"
+# before_install: &vcpreinst
+# - PATH="$PATH:$VCDIR"
+# - cd ${BUILD_DIR}
+# install: []
+# script:
+# - cmd.exe //C vcvarsall.bat x64 '&&' nmake '-f' makefile.vc all tktest
before_install:
- - export ERROR_ON_FAILURES=1
+ - |-
+ case $TRAVIS_OS_NAME in
+ windows)
+ choco install -y magicsplat-tcl-tk
+ ;;
+ esac
- cd ${BUILD_DIR}
install:
- - test -n "$NO_DIRECT_CONFIGURE" || ./configure ${CFGOPT}
+ - ./configure ${CFGOPT} --prefix=$HOME || (cat config.log && exit 1)
+before_script:
+ - export ERROR_ON_FAILURES=1
script:
- - make
- # The styles=develop avoids some weird problems on OSX
- #- test -n "$NO_DIRECT_TEST" || make test styles=develop
+ - make all tktest
+cache:
+ directories:
+ - $HOME/AppData/Local/Temp/chocolatey
+ - $HOME/AppData/Local/Apps/Tcl86
diff --git a/ChangeLog b/ChangeLog
index 2c1ca70..f01946a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,6 @@
A NOTE ON THE CHANGELOG:
Starting in early 2011, Tk source code has been under the management of
-fossil, hosted at http://core.tcl-lang.org/tk/ . Fossil presents a "Timeline"
+fossil, hosted at https://core.tcl-lang.org/tk/ . Fossil presents a "Timeline"
view of changes made that is superior in every way to a hand edited log file.
Because of this, many Tk developers are now out of the habit of maintaining
this log file. You may still find useful things in it, but the Timeline is
diff --git a/ChangeLog.2002 b/ChangeLog.2002
index a1ba923..5bfc4f7 100644
--- a/ChangeLog.2002
+++ b/ChangeLog.2002
@@ -5218,7 +5218,7 @@
2000-05-31 Eric Melski <ericm@scriptics.com>
* library/bgerror.tcl: Improved bgerror based on work by Donal
- K. Fellows; no longer dependant on tk_dialog; features a
+ K. Fellows; no longer dependent on tk_dialog; features a
Windows-esque "Details" button, and a customizable extra function
button that allows the user to (for example) save the stack trace
to a file.
diff --git a/README b/README
deleted file mode 100644
index b688c1f..0000000
--- a/README
+++ /dev/null
@@ -1,41 +0,0 @@
-README: Tk
- This is the Tk 8.7a2 source distribution.
- http://sourceforge.net/projects/tcl/files/Tcl/
- You can get any source release of Tk from the URL above.
-
-1. Introduction
----------------
-
-This directory contains the sources and documentation for Tk, an X11
-toolkit implemented with the Tcl scripting language.
-
-For details on features, incompatibilities, and potential problems with
-this release, see the Tcl/Tk 8.7 Web page at
-
- http://www.tcl-lang.org/software/tcltk/8.7.html
-
-or refer to the "changes" file in this directory, which contains a
-historical record of all changes to Tk.
-
-Tk is maintained, enhanced, and distributed freely by the Tcl community.
-Source code development and tracking of bug reports and feature requests
-takes place at:
-
- http://core.tcl-lang.org/tk/
-
-with the Tcl Developer Xchange at:
-
- http://www.tcl-lang.org/
-
-Tk is a freely available open source package. You can do virtually
-anything you like with it, such as modifying it, redistributing it,
-and selling it either in whole or in part. See the file
-"license.terms" for complete information.
-
-2. See Tcl README
------------------
-
-Please see the README file that comes with the associated Tcl release
-for more information. There are pointers there to extensive
-documentation. In addition, there are additional README files
-in the subdirectories of this distribution.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4787aaf
--- /dev/null
+++ b/README.md
@@ -0,0 +1,37 @@
+# README: Tk
+
+This is the **Tk 8.7a4** source distribution.
+
+You can get any source release of Tk from [our distribution
+site](https://sourceforge.net/projects/tcl/files/Tcl/).
+
+
+## <a id="intro">1.</a> Introduction
+
+This directory contains the sources and documentation for Tk, a
+cross-platform GUI toolkit implemented with the Tcl scripting language.
+
+For details on features, incompatibilities, and potential problems with
+this release, see [the Tcl/Tk 8.7 Web page](https://www.tcl.tk/software/tcltk/8.7.html)
+or refer to the "changes" file in this directory, which contains a
+historical record of all changes to Tk.
+
+Tk is maintained, enhanced, and distributed freely by the Tcl community.
+Source code development and tracking of bug reports and feature requests
+takes place at [core.tcl-lang.org](https://core.tcl-lang.org/).
+Tcl/Tk release and mailing list services are [hosted by
+SourceForge](https://sourceforge.net/projects/tcl/)
+with the Tcl Developer Xchange hosted at
+[www.tcl-lang.org](https://www.tcl-lang.org).
+
+Tk is a freely available open source package. You can do virtually
+anything you like with it, such as modifying it, redistributing it,
+and selling it either in whole or in part. See the file
+`license.terms` for complete information.
+
+## <a id="tcl">2.</a> See Tcl README.md
+
+Please see the README.md file that comes with the associated Tcl release
+for more information. There are pointers there to extensive
+documentation. In addition, there are additional README files
+in the subdirectories of this distribution.
diff --git a/changes b/changes
index 319cc6a..f92e083 100644
--- a/changes
+++ b/changes
@@ -7072,7 +7072,7 @@ Many revisions to better support a Cygwin environment (nijtmans)
2013-08-25 (bug fix)[3016181] Cocoa: [destroy $scrollbar] => crash (goddard)
---- Released 8.6.1, September 19, 2013 --- http://core.tcl.tk/tk/ for details
+--- Released 8.6.1, September 19, 2013 --- https://core.tcl-lang.org/tk/ for details
2013-10-27 (bug fix) OSX drawing lags (deily,steffen,walzer)
@@ -7120,7 +7120,7 @@ Many revisions to better support a Cygwin environment (nijtmans)
2014-08-01 (bug fix) OSX font config crash (rob@bitkeeper)
---- Released 8.6.2, August 27, 2014 --- http://core.tcl.tk/tk/ for details
+--- Released 8.6.2, August 27, 2014 --- https://core.tcl-lang.org/tk/ for details
2014-08-27 (bug) Cocoa: Crash after [$button destroy] (walzer)
@@ -7144,7 +7144,7 @@ Many revisions to better support a Cygwin environment (nijtmans)
2014-11-07 (bug)[3529885] [scale] handling of negative resolution (vogel)
---- Released 8.6.3, November 12, 2014 --- http://core.tcl.tk/tk/ for details
+--- Released 8.6.3, November 12, 2014 --- https://core.tcl-lang.org/tk/ for details
2014-11-14 (bug)[d43a10] shimmer-related crash in [tk_getOpenFile] (nadkarni)
@@ -7166,7 +7166,7 @@ Many revisions to better support a Cygwin environment (nijtmans)
Tk Cocoa 2.0: App Store enabled (walzer,culler,desmera,owen,nyberg,reincke)
*** POTENTIAL INCOMPATIBILITY ***
---- Released 8.6.4, March 12, 2015 --- http://core.tcl.tk/tk/ for details
+--- Released 8.6.4, March 12, 2015 --- https://core.tcl-lang.org/tk/ for details
2015-03-10 (bug) Cocoa: premature image free crash (walzer)
@@ -7265,7 +7265,7 @@ Tk Cocoa 2.0: App Store enabled (walzer,culler,desmera,owen,nyberg,reincke)
Tk Cocoa 2.0: More drawing internals refinements (culler,walzer)
---- Released 8.6.5, February 29, 2016 --- http://core.tcl.tk/tk/ for details
+--- Released 8.6.5, February 29, 2016 --- https://core.tcl-lang.org/tk/ for details
2016-03-07 (bug)[3137232] spinbox teardown hygiene (vogel)
@@ -7312,7 +7312,7 @@ Tk Cocoa 2.0: More drawing internals refinements (culler,walzer)
2016-07-21 (bug)[450bb0] Aqua: memory corruption from [tk busy] (porter)
---- Released 8.6.6, July 27, 2016 --- http://core.tcl.tk/tk/ for details
+--- Released 8.6.6, July 27, 2016 --- https://core.tcl-lang.org/tk/ for details
2016-08-23 (bug)[a2abc4] Wrong warp cursor position on 2nd display (vogel)
@@ -7414,7 +7414,30 @@ Tk Cocoa 2.0: More drawing internals refinements (culler,walzer)
2017-08-08 (bug)[4966ca] Scidb race in notebook tab selection (cramer)
---- Released 8.6.7, August 9, 2017 --- http://core.tcl.tk/tk/ for details
+--- Released 8.6.7, August 9, 2017 --- https://core.tcl-lang.org/tk/ for details
+
+Changes to 8.7a1 include all changes to the 8.6 line through 8.6.7,
+plus the following, which focuses on the high-level feature changes
+in this changeset (new minor version) rather than bug fixes:
+
+2016-03-07 (feature)[841280] spinbox autoswap -to/-from to get ordering (vogel)
+
+2016-03-27 (feature)[38dc27] Support <Button-6> & <Button-7> (nijtmans)
+
+2016-08-29 (TIP 449) [text] undo/redo return character range (vogel)
+
+2016-11-02 (feature) Removed undocumented command [tk_getFileType] (vogel)
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2017-02-05 (bug)[c0dbdd] Compatibility fonts shadowed system fonts (vogel)
+
+2017-03-21 (TIP 442) display text in a progressbar (zaumseil)
+
+2017-04-13 \u escaped content in msg files converted to true utf-8 (nijtmans)
+
+2017-08-28 (TIP 166) Extended color notation for alpha channel (bachmann)
+
+--- Released 8.7a1, September 8, 2017 --- http://core.tcl.tk/tk/ for details
2017-08-24 (bug)[f1a3ca] Memory leak in [text] B-tree (edhume3)
@@ -7494,7 +7517,7 @@ Tk Cocoa 2.0: More drawing internals refinements (culler,walzer)
2017-12-18 (bug)[b77626] Make [tk busy -cursor] silent no-op on macOS (vogel)
---- Released 8.6.8, December 22, 2017 --- http://core.tcl.tk/tk/ for details
+--- Released 8.6.8, December 22, 2017 --- https://core.tcl-lang.org/tk/ for details
2017-12-31 (bug)[aa7679] crash using window after master destroyed (vogel)
@@ -7540,7 +7563,7 @@ Tk Cocoa 2.0: More drawing internals refinements (culler,walzer)
2018-07-17 (bug)[1088825] fix frame-2.17,3.9,3.10 on Mac (vogel)
-2018-07-27 (bug)[fabed1] GIF photo support for "deferred clear code" (vogel)
+2018-07-27 (bug)[fbaed1] GIF photo support for "deferred clear code" (vogel)
2018-08-08 (feature) Modern full-screen support on Mac OSX (walzer)
@@ -7568,27 +7591,170 @@ Tk Cocoa 2.0: More drawing internals refinements (culler,walzer)
2018-11-04 (bug)[6b22d4] [treeview] binding fix (ohagan)
-- Released 8.6.9, November 16, 2018 - http://core.tcl-lang.org/tk/ for details -
+- Released 8.6.9, November 16, 2018 - https://core.tcl-lang.org/tk/ for details
-Changes to 8.7a1 include all changes to the 8.6 line through 8.6.7,
+2018-11-19 (bug)[0a9c91] crash in text-11a.22 (vogel)
+
+2018-11-20 (bug)[9705d1] crash activating "Alt" theme (culler)
+
+2018-11-24 (bug)[e3b954] cursor offset at full screen display (culler)
+
+2019-01-04 (bug)[18a4ba] cross-platform [winfo containing] (culler)
+
+2019-01-08 (feature) local grab on Mac OSX (culler)
+
+2019-01-10 (build) 'None', 'ControlMask' symbol conflicts (nijtmans)
+
+2019-01-20 (bug)[509caf] [treeview tag configure] regression (mcdonald,vogel)
+
+2019-01-26 (bug)[3003895] [scale] res rounds and -from (tischler,pieper,vogel)
+
+2019-02-02 (new)[TIP 533] [$mb post x y idx] (culler,vogel)
+
+2019-02-08 (bug)[1529659] embed toplevel blocks outer menu (culler)
+
+2019-02-10 (bug)[8814bd] crash in [NSMenu size] (culler)
+
+2019-02-13 (bug)[b389df] Aqua: mouse position on dual screen (culler)
+
+2019-02-23 (bug)[56a182] Aqua: [tk_getOpenFile] causes off-screen toplevels (culler,walzer)
+
+2019-02-23 (bug)[9771ae] Aqua: workaround incompatible transient window models (culler,walzer)
+
+2019-03-01 (bug)[1951ab] Prevent transient window cycles (crashed on Aqua) (culler,vogel)
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2019-03-04 (bug)[4da219] Incomplete read of multi-image GIF (oehlmann)
+
+2019-03-14 (bug)[609e00] Aqua: wrong coords from MouseWheel binding (vogel,culler)
+
+2019-03-25 (bug)[48c394] Aqua: recompute text layout for empty string (culler)
+
+2019-03-31 (new)[TIP 535] Precision of ::scale widget tick mark values (vogel)
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2019-03-31 (bug)[da3914] [$treeview identify element] failure (ulfalizer,vogel)
+
+2019-04-06 (bug)[897ffe] Prevent cross-manager loops of geom management (culler,vogel)
+
+2019-04-11 (new) Apple Dark Mode support (culler)
+
+2019-04-14 (new) Aqua: Use color names consistent with NSColor (culler)
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2019-04-14 (new) Aqua: [tk::unsupported::MacWindowStyle isdark] (culler)
+
+2019-04-19 (bug)[368fa4] Prevent toggle of hidden treeview indicators (ulfalizer,vogel)
+
+2019-04-24 (bug)[4d2e8d] Aqua: notebook pane redraws (culler)
+
+2019-04-24 (bug)[928652] Apply TIP 533 for ttk::menubutton (culler,vogel)
+
+2019-04-24 (bug)[1001070] X-platform rework of label options -highlight* (seal,culler,vogel)
+
+2019-04-28 (bug)[6286fd] checkbutton handling of -selectcolor (ralfixx)
+
+2019-04-30 (bug)[4f9a99] Win: crash in [style element create] (oehlman,vogel)
+
+2019-05-08 (bug) Ttk scrolling bugs, see tests treeview-9.1, entry-3.[3-6] (vogel)
+
+2019-05-08 (bug)[51b4b1] Aqua: combobox use native ttk scrollbar (bll,vogel)
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2019-05-18 (new)[eb2996] Win: support for horizontal scrolling (chavez,vogel)
+
+2019-05-26 (new)[TIP 541] [combobox current] support "end" index (vogel)
+
+2019-05-26 (bug)[2a6c62] <<TreeviewSelect>> trigger on item delete (vogel)
+
+2019-06-05 (bug)[9ebc6f] Aqua: fix incorrect reports of mouse coords (chavez, culler)
+
+2019-06-14 (bug)[436ad6] Corrected Aqua regressions in [wm manage] (walzer, culler)
+
+2019-06-15 (bug)[75b8fb] Crash with some [event generate]d <ButtonRelease> (leunissen,vogel)
+
+2019-06-15 (new)[TIP 536] New tk::mac::* commands for IPC on Mac OSX (walzer)
+
+2019-07-13 (bug)[4566e2] Aqua: Make default background color of Tk and Ttk agree (walzer,culler)
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2019-07-16 (bug)[5ddeca] Stop app switching exposing withdrawn windows as zombies (culler)
+
+2019-07-25 (new)[1fb7af] Win support for buttons 4 and 5 (chavez,vogel,nijtmans)
+
+2019-08-18 (new) Refactor all MouseWheel bindings (nijtmans)
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2019-08-21 (bug)[c8ccd1] up array key in [text] takes to index 1.0 (ulfalizer,vogel)
+
+2019-08-28 (new)[TIP 532] Tk event loop rewrite to prevent ring overflow (cramer)
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2019-08-28 (bug)[943d5e] Win: embedded widget destruction cancels window resize (nemethi,vogel,nijtmans)
+
+2019-09-12 (bug)[2834776] Stop disabled spinbox from generating <<Increment>> & <<Decrement>> (vogel)
+
+2019-09-24 (bug)[96bce5] Aqua: Prevent crash drawing 1x1 rounded rectangles (bll,culler)
+
+2019-10-03 (bug)[3ed5b6] Win: root window position with highlightthickness>0 (leunissem,vogel,nijtmans)
+
+2019-10-09 (bug)[a01b6f7] Workaround XWayland bug reporting screen width (werner,nijtmans)
+
+2019-10-10 (bug) Aqua: Prevent crash deactivating menu during menu deletion (culler)
+
+2019-10-21 (bug)[aea00b] Aqua: Better handling of resolution changes (chavez, culler)
+
+2019-10-25 (bug)[b82bd4] Fix [style configure -compound] (culler,vogel)
+
+2019-10-27 (bug)[f7a4f7] Aqua: embedded toplevel, forced focus and mouse coords (naaus,culler)
+
+2019-11-13 (new) Win: keycodes Mail, AudioMedia, Launch0, Launch1 (nijtmans)
+
+2019-11-15 (bug)[69b48f] failing test textTag-18.1 (vogel)
+
+2019-11-17 (bug)[c4abd2] panic in stackorder command (culler)
+
+2019-11-17 (bug)[53d280] [wm iconphoto] crash on empty image (culler)
+
+2019-11-17 [90d555] workaround NSFontManager bad selections (culler)
+
+2019-11-19 (new) Partial Emoji support in text displays (nijtmans,culler)
+
+- Released 8.6.10, Nov 21, 2019 - https://core.tcl-lang.org/tk/ for details
+
+Changes to 8.7a3 include all changes to the 8.6 line through 8.6.10,
plus the following, which focuses on the high-level feature changes
in this changeset (new minor version) rather than bug fixes:
-2016-03-07 (feature)[841280] spinbox autoswap -to/-from to get ordering (vogel)
+2017-11-25 [TIP 161] $menu -tearoff default changed to false (roseman,vogel)
+ *** POTENTIAL INCOMPATIBILITY ***
-2016-03-27 (feature)[38dc27] Support <Button-6> & <Button-7> (nijtmans)
+2017-12-07 [TIP 487] End support for pre-XP Windows (nijtmans)
-2016-08-29 (TIP 449) [text] undo/redo return character range (vogel)
+2018-03-04 [TIP 489] New subcommand [$canvas image] (pitcher,vogel)
-2016-11-02 (feature) Removed undocumented command [tk_getFileType] (vogel)
- *** POTENTIAL INCOMPATIBILITY ***
+2018-05-13 [TIP 496] New options -placeholder* for entries (zaumseil,vogel)
-2017-02-05 (bug)[c0dbdd] Compatibility fonts shadowed system fonts (vogel)
+2018-09-23 [TIP 517] New option -activerelief for menus (vogel)
-2017-03-21 (TIP 442) display text in a progressbar (zaumseil)
+2018-11-03 [TIP 512] Deprecate stub for Tk_MainEx() (nijtmans)
-2017-04-13 \u escaped content in msg files converted to true utf-8 (nijtmans)
+2018-11-06 [TIP 415] New option -height for [$canvas create arc] (geard)
-2017-08-28 (TIP 166) Extended color notation for alpha channel (bachmann)
+2018-11-06 [TIP 518] New event <<NoMangedChild>> (oehlmann)
---- Released 8.7a1, September 8, 2017 --- http://core.tcl.tk/tk/ for details
+2019-04-14 [TIP 164] New subcommand [$canvas rotate] (fellows)
+
+2019-04-14 [TIP 507] New photo image format 'svg' (zaumseil)
+
+2019-04-14 [TIP 483] Record more configuration items (cassoff)
+
+2019-04-14 [TIP 482] Record configured directory for demos (cassoff)
+
+2019-05-25 [TIP 262] New frame options -backgroundimage, -tile (fellows)
+
+2019-06-15 [TIP 528] Deprecate Tk_Offset() (nijtmans)
+
+2019-08-19 [TIP 545] Revised options for photo image format 'svg' (oehlmann)
+
+--- Released 8.7a3, November 25, 2019 --- http://core.tcl.tk/tk/ for details
diff --git a/compat/stdbool.h b/compat/stdbool.h
new file mode 100644
index 0000000..6e74c58
--- /dev/null
+++ b/compat/stdbool.h
@@ -0,0 +1,37 @@
+/*===---- stdbool.h - Standard header for booleans -------------------------===
+*
+* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+* See https://llvm.org/LICENSE.txt for license information.
+* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+*
+* Modified for use by pre-C99 compilers. (c) Jan Nijtmans.
+*
+*===-----------------------------------------------------------------------===
+*/
+
+#ifndef __STDBOOL_H
+#define __STDBOOL_H
+
+/* Don't define bool, true, and false in C++, except as a GNU extension. */
+#ifndef __cplusplus
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+#define bool _Bool
+#else
+#define bool unsigned char
+#endif
+#define true 1
+#define false 0
+#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
+/* Define _Bool as a GNU extension. */
+#define _Bool bool
+#if __cplusplus < 201103L
+/* For C++98, define bool, false, true as a GNU extension. */
+#define bool bool
+#define false false
+#define true true
+#endif
+#endif
+
+#define __bool_true_false_are_defined 1
+
+#endif /* __STDBOOL_H */
diff --git a/compat/stdint.h b/compat/stdint.h
new file mode 100644
index 0000000..88383b0
--- /dev/null
+++ b/compat/stdint.h
@@ -0,0 +1,919 @@
+/* A portable stdint.h
+ ****************************************************************************
+ * BSD License:
+ ****************************************************************************
+ *
+ * Copyright (c) 2005-2016 Paul Hsieh
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************
+ *
+ * Version 0.1.16.0
+ *
+ * The ANSI C standard committee, for the C99 standard, specified the
+ * inclusion of a new standard include file called stdint.h. This is
+ * a very useful and long desired include file which contains several
+ * very precise definitions for integer scalar types that is critically
+ * important for making several classes of applications portable
+ * including cryptography, hashing, variable length integer libraries
+ * and so on. But for most developers its likely useful just for
+ * programming sanity.
+ *
+ * The problem is that some compiler vendors chose to ignore the C99
+ * standard and some older compilers have no opportunity to be updated.
+ * Because of this situation, simply including stdint.h in your code
+ * makes it unportable.
+ *
+ * So that's what this file is all about. It's an attempt to build a
+ * single universal include file that works on as many platforms as
+ * possible to deliver what stdint.h is supposed to. Even compilers
+ * that already come with stdint.h can use this file instead without
+ * any loss of functionality. A few things that should be noted about
+ * this file:
+ *
+ * 1) It is not guaranteed to be portable and/or present an identical
+ * interface on all platforms. The extreme variability of the
+ * ANSI C standard makes this an impossibility right from the
+ * very get go. Its really only meant to be useful for the vast
+ * majority of platforms that possess the capability of
+ * implementing usefully and precisely defined, standard sized
+ * integer scalars. Systems which are not intrinsically 2s
+ * complement may produce invalid constants.
+ *
+ * 2) There is an unavoidable use of non-reserved symbols.
+ *
+ * 3) Other standard include files are invoked.
+ *
+ * 4) This file may come in conflict with future platforms that do
+ * include stdint.h. The hope is that one or the other can be
+ * used with no real difference.
+ *
+ * 5) In the current version, if your platform can't represent
+ * int32_t, int16_t and int8_t, it just dumps out with a compiler
+ * error.
+ *
+ * 6) 64 bit integers may or may not be defined. Test for their
+ * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
+ * Note that this is different from the C99 specification which
+ * requires the existence of 64 bit support in the compiler. If
+ * this is not defined for your platform, yet it is capable of
+ * dealing with 64 bits then it is because this file has not yet
+ * been extended to cover all of your system's capabilities.
+ *
+ * 7) (u)intptr_t may or may not be defined. Test for its presence
+ * with the test: #ifdef PTRDIFF_MAX. If this is not defined
+ * for your platform, then it is because this file has not yet
+ * been extended to cover all of your system's capabilities, not
+ * because its optional.
+ *
+ * 8) The following might not been defined even if your platform is
+ * capable of defining it:
+ *
+ * WCHAR_MIN
+ * WCHAR_MAX
+ * (u)int64_t
+ * PTRDIFF_MIN
+ * PTRDIFF_MAX
+ * (u)intptr_t
+ *
+ * 9) The following have not been defined:
+ *
+ * WINT_MIN
+ * WINT_MAX
+ *
+ * 10) The criteria for defining (u)int_least(*)_t isn't clear,
+ * except for systems which don't have a type that precisely
+ * defined 8, 16, or 32 bit types (which this include file does
+ * not support anyways). Default definitions have been given.
+ *
+ * 11) The criteria for defining (u)int_fast(*)_t isn't something I
+ * would trust to any particular compiler vendor or the ANSI C
+ * committee. It is well known that "compatible systems" are
+ * commonly created that have very different performance
+ * characteristics from the systems they are compatible with,
+ * especially those whose vendors make both the compiler and the
+ * system. Default definitions have been given, but its strongly
+ * recommended that users never use these definitions for any
+ * reason (they do *NOT* deliver any serious guarantee of
+ * improved performance -- not in this file, nor any vendor's
+ * stdint.h).
+ *
+ * 12) The following macros:
+ *
+ * PRINTF_INTMAX_MODIFIER
+ * PRINTF_INT64_MODIFIER
+ * PRINTF_INT32_MODIFIER
+ * PRINTF_INT16_MODIFIER
+ * PRINTF_LEAST64_MODIFIER
+ * PRINTF_LEAST32_MODIFIER
+ * PRINTF_LEAST16_MODIFIER
+ * PRINTF_INTPTR_MODIFIER
+ *
+ * are strings which have been defined as the modifiers required
+ * for the "d", "u" and "x" printf formats to correctly output
+ * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
+ * (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
+ * PRINTF_INTPTR_MODIFIER is not defined for some systems which
+ * provide their own stdint.h. PRINTF_INT64_MODIFIER is not
+ * defined if INT64_MAX is not defined. These are an extension
+ * beyond what C99 specifies must be in stdint.h.
+ *
+ * In addition, the following macros are defined:
+ *
+ * PRINTF_INTMAX_HEX_WIDTH
+ * PRINTF_INT64_HEX_WIDTH
+ * PRINTF_INT32_HEX_WIDTH
+ * PRINTF_INT16_HEX_WIDTH
+ * PRINTF_INT8_HEX_WIDTH
+ * PRINTF_INTMAX_DEC_WIDTH
+ * PRINTF_INT64_DEC_WIDTH
+ * PRINTF_INT32_DEC_WIDTH
+ * PRINTF_INT16_DEC_WIDTH
+ * PRINTF_UINT8_DEC_WIDTH
+ * PRINTF_UINTMAX_DEC_WIDTH
+ * PRINTF_UINT64_DEC_WIDTH
+ * PRINTF_UINT32_DEC_WIDTH
+ * PRINTF_UINT16_DEC_WIDTH
+ * PRINTF_UINT8_DEC_WIDTH
+ *
+ * Which specifies the maximum number of characters required to
+ * print the number of that type in either hexadecimal or decimal.
+ * These are an extension beyond what C99 specifies must be in
+ * stdint.h.
+ *
+ * Compilers tested (all with 0 warnings at their highest respective
+ * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
+ * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
+ * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
+ *
+ * This file should be considered a work in progress. Suggestions for
+ * improvements, especially those which increase coverage are strongly
+ * encouraged.
+ *
+ * Acknowledgements
+ *
+ * The following people have made significant contributions to the
+ * development and testing of this file:
+ *
+ * Chris Howie
+ * John Steele Scott
+ * Dave Thorup
+ * John Dill
+ * Florian Wobbe
+ * Christopher Sean Morrison
+ * Mikkel Fahnoe Jorgensen
+ *
+ */
+
+#include <stddef.h>
+#include <limits.h>
+#include <signal.h>
+
+/*
+ * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
+ * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
+ */
+
+#if ((defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
+#include <stdint.h>
+#define _PSTDINT_H_INCLUDED
+# if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__))
+# ifndef PRINTF_INT64_MODIFIER
+# define PRINTF_INT64_MODIFIER "l"
+# endif
+# ifndef PRINTF_INT32_MODIFIER
+# define PRINTF_INT32_MODIFIER ""
+# endif
+# else
+# ifndef PRINTF_INT64_MODIFIER
+# define PRINTF_INT64_MODIFIER "ll"
+# endif
+# ifndef PRINTF_INT32_MODIFIER
+# if (UINT_MAX == UINT32_MAX)
+# define PRINTF_INT32_MODIFIER ""
+# else
+# define PRINTF_INT32_MODIFIER "l"
+# endif
+# endif
+# endif
+# ifndef PRINTF_INT16_MODIFIER
+# define PRINTF_INT16_MODIFIER "h"
+# endif
+# ifndef PRINTF_INTMAX_MODIFIER
+# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
+# endif
+# ifndef PRINTF_INT64_HEX_WIDTH
+# define PRINTF_INT64_HEX_WIDTH "16"
+# endif
+# ifndef PRINTF_UINT64_HEX_WIDTH
+# define PRINTF_UINT64_HEX_WIDTH "16"
+# endif
+# ifndef PRINTF_INT32_HEX_WIDTH
+# define PRINTF_INT32_HEX_WIDTH "8"
+# endif
+# ifndef PRINTF_UINT32_HEX_WIDTH
+# define PRINTF_UINT32_HEX_WIDTH "8"
+# endif
+# ifndef PRINTF_INT16_HEX_WIDTH
+# define PRINTF_INT16_HEX_WIDTH "4"
+# endif
+# ifndef PRINTF_UINT16_HEX_WIDTH
+# define PRINTF_UINT16_HEX_WIDTH "4"
+# endif
+# ifndef PRINTF_INT8_HEX_WIDTH
+# define PRINTF_INT8_HEX_WIDTH "2"
+# endif
+# ifndef PRINTF_UINT8_HEX_WIDTH
+# define PRINTF_UINT8_HEX_WIDTH "2"
+# endif
+# ifndef PRINTF_INT64_DEC_WIDTH
+# define PRINTF_INT64_DEC_WIDTH "19"
+# endif
+# ifndef PRINTF_UINT64_DEC_WIDTH
+# define PRINTF_UINT64_DEC_WIDTH "20"
+# endif
+# ifndef PRINTF_INT32_DEC_WIDTH
+# define PRINTF_INT32_DEC_WIDTH "10"
+# endif
+# ifndef PRINTF_UINT32_DEC_WIDTH
+# define PRINTF_UINT32_DEC_WIDTH "10"
+# endif
+# ifndef PRINTF_INT16_DEC_WIDTH
+# define PRINTF_INT16_DEC_WIDTH "5"
+# endif
+# ifndef PRINTF_UINT16_DEC_WIDTH
+# define PRINTF_UINT16_DEC_WIDTH "5"
+# endif
+# ifndef PRINTF_INT8_DEC_WIDTH
+# define PRINTF_INT8_DEC_WIDTH "3"
+# endif
+# ifndef PRINTF_UINT8_DEC_WIDTH
+# define PRINTF_UINT8_DEC_WIDTH "3"
+# endif
+# ifndef PRINTF_INTMAX_HEX_WIDTH
+# define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
+# endif
+# ifndef PRINTF_UINTMAX_HEX_WIDTH
+# define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
+# endif
+# ifndef PRINTF_INTMAX_DEC_WIDTH
+# define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
+# endif
+# ifndef PRINTF_UINTMAX_DEC_WIDTH
+# define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
+# endif
+
+/*
+ * Something really weird is going on with Open Watcom. Just pull some of
+ * these duplicated definitions from Open Watcom's stdint.h file for now.
+ */
+
+# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
+# if !defined (INT64_C)
+# define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
+# endif
+# if !defined (UINT64_C)
+# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
+# endif
+# if !defined (INT32_C)
+# define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
+# endif
+# if !defined (UINT32_C)
+# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
+# endif
+# if !defined (INT16_C)
+# define INT16_C(x) (x)
+# endif
+# if !defined (UINT16_C)
+# define UINT16_C(x) (x)
+# endif
+# if !defined (INT8_C)
+# define INT8_C(x) (x)
+# endif
+# if !defined (UINT8_C)
+# define UINT8_C(x) (x)
+# endif
+# if !defined (UINT64_MAX)
+# define UINT64_MAX 18446744073709551615ULL
+# endif
+# if !defined (INT64_MAX)
+# define INT64_MAX 9223372036854775807LL
+# endif
+# if !defined (UINT32_MAX)
+# define UINT32_MAX 4294967295UL
+# endif
+# if !defined (INT32_MAX)
+# define INT32_MAX 2147483647L
+# endif
+# if !defined (INTMAX_MAX)
+# define INTMAX_MAX INT64_MAX
+# endif
+# if !defined (INTMAX_MIN)
+# define INTMAX_MIN INT64_MIN
+# endif
+# endif
+#endif
+
+/*
+ * I have no idea what is the truly correct thing to do on older Solaris.
+ * From some online discussions, this seems to be what is being
+ * recommended. For people who actually are developing on older Solaris,
+ * what I would like to know is, does this define all of the relevant
+ * macros of a complete stdint.h? Remember, in pstdint.h 64 bit is
+ * considered optional.
+ */
+
+#if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x420) && !defined(_PSTDINT_H_INCLUDED)
+#include <sys/inttypes.h>
+#define _PSTDINT_H_INCLUDED
+#endif
+
+#ifndef _PSTDINT_H_INCLUDED
+#define _PSTDINT_H_INCLUDED
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t)-1)
+#endif
+
+/*
+ * Deduce the type assignments from limits.h under the assumption that
+ * integer sizes in bits are powers of 2, and follow the ANSI
+ * definitions.
+ */
+
+#ifndef UINT8_MAX
+# define UINT8_MAX 0xff
+#endif
+#if !defined(uint8_t) && !defined(_UINT8_T) && !defined(vxWorks)
+# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
+ typedef unsigned char uint8_t;
+# define UINT8_C(v) ((uint8_t) v)
+# else
+# error "Platform not supported"
+# endif
+#endif
+
+#ifndef INT8_MAX
+# define INT8_MAX 0x7f
+#endif
+#ifndef INT8_MIN
+# define INT8_MIN INT8_C(0x80)
+#endif
+#if !defined(int8_t) && !defined(_INT8_T) && !defined(vxWorks)
+# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
+ typedef signed char int8_t;
+# define INT8_C(v) ((int8_t) v)
+# else
+# error "Platform not supported"
+# endif
+#endif
+
+#ifndef UINT16_MAX
+# define UINT16_MAX 0xffff
+#endif
+#if !defined(uint16_t) && !defined(_UINT16_T) && !defined(vxWorks)
+#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
+ typedef unsigned int uint16_t;
+# ifndef PRINTF_INT16_MODIFIER
+# define PRINTF_INT16_MODIFIER ""
+# endif
+# define UINT16_C(v) ((uint16_t) (v))
+#elif (USHRT_MAX == UINT16_MAX)
+ typedef unsigned short uint16_t;
+# define UINT16_C(v) ((uint16_t) (v))
+# ifndef PRINTF_INT16_MODIFIER
+# define PRINTF_INT16_MODIFIER "h"
+# endif
+#else
+#error "Platform not supported"
+#endif
+#endif
+
+#ifndef INT16_MAX
+# define INT16_MAX 0x7fff
+#endif
+#ifndef INT16_MIN
+# define INT16_MIN INT16_C(0x8000)
+#endif
+#if !defined(int16_t) && !defined(_INT16_T) && !defined(vxWorks)
+#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
+ typedef signed int int16_t;
+# define INT16_C(v) ((int16_t) (v))
+# ifndef PRINTF_INT16_MODIFIER
+# define PRINTF_INT16_MODIFIER ""
+# endif
+#elif (SHRT_MAX == INT16_MAX)
+ typedef signed short int16_t;
+# define INT16_C(v) ((int16_t) (v))
+# ifndef PRINTF_INT16_MODIFIER
+# define PRINTF_INT16_MODIFIER "h"
+# endif
+#else
+#error "Platform not supported"
+#endif
+#endif
+
+#ifndef UINT32_MAX
+# define UINT32_MAX (0xffffffffUL)
+#endif
+#if !defined(uint32_t) && !defined(_UINT32_T) && !defined(vxWorks)
+#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
+ typedef unsigned long uint32_t;
+# define UINT32_C(v) v ## UL
+# ifndef PRINTF_INT32_MODIFIER
+# define PRINTF_INT32_MODIFIER "l"
+# endif
+#elif (UINT_MAX == UINT32_MAX)
+ typedef unsigned int uint32_t;
+# ifndef PRINTF_INT32_MODIFIER
+# define PRINTF_INT32_MODIFIER ""
+# endif
+# define UINT32_C(v) v ## U
+#elif (USHRT_MAX == UINT32_MAX)
+ typedef unsigned short uint32_t;
+# define UINT32_C(v) ((unsigned short) (v))
+# ifndef PRINTF_INT32_MODIFIER
+# define PRINTF_INT32_MODIFIER ""
+# endif
+#else
+#error "Platform not supported"
+#endif
+#endif
+
+#ifndef INT32_MAX
+# define INT32_MAX (0x7fffffffL)
+#endif
+#ifndef INT32_MIN
+# define INT32_MIN INT32_C(0x80000000)
+#endif
+#if !defined(int32_t) && !defined(_INT32_T) && !defined(vxWorks)
+#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
+ typedef signed long int32_t;
+# define INT32_C(v) v ## L
+# ifndef PRINTF_INT32_MODIFIER
+# define PRINTF_INT32_MODIFIER "l"
+# endif
+#elif (INT_MAX == INT32_MAX)
+ typedef signed int int32_t;
+# define INT32_C(v) v
+# ifndef PRINTF_INT32_MODIFIER
+# define PRINTF_INT32_MODIFIER ""
+# endif
+#elif (SHRT_MAX == INT32_MAX)
+ typedef signed short int32_t;
+# define INT32_C(v) ((short) (v))
+# ifndef PRINTF_INT32_MODIFIER
+# define PRINTF_INT32_MODIFIER ""
+# endif
+#else
+#error "Platform not supported"
+#endif
+#endif
+
+/*
+ * The macro stdint_int64_defined is temporarily used to record
+ * whether or not 64 integer support is available. It must be
+ * defined for any 64 integer extensions for new platforms that are
+ * added.
+ */
+
+#undef stdint_int64_defined
+#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
+# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
+# define stdint_int64_defined
+ typedef long long int64_t;
+ typedef unsigned long long uint64_t;
+# define UINT64_C(v) v ## ULL
+# define INT64_C(v) v ## LL
+# ifndef PRINTF_INT64_MODIFIER
+# define PRINTF_INT64_MODIFIER "ll"
+# endif
+# endif
+#endif
+
+#if !defined (stdint_int64_defined)
+# if defined(__GNUC__) && !defined(vxWorks)
+# define stdint_int64_defined
+ __extension__ typedef long long int64_t;
+ __extension__ typedef unsigned long long uint64_t;
+# define UINT64_C(v) v ## ULL
+# define INT64_C(v) v ## LL
+# ifndef PRINTF_INT64_MODIFIER
+# define PRINTF_INT64_MODIFIER "ll"
+# endif
+# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
+# define stdint_int64_defined
+ typedef long long int64_t;
+ typedef unsigned long long uint64_t;
+# define UINT64_C(v) v ## ULL
+# define INT64_C(v) v ## LL
+# ifndef PRINTF_INT64_MODIFIER
+# define PRINTF_INT64_MODIFIER "ll"
+# endif
+# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
+# define stdint_int64_defined
+ typedef __int64 int64_t;
+ typedef unsigned __int64 uint64_t;
+# define UINT64_C(v) v ## UI64
+# define INT64_C(v) v ## I64
+# ifndef PRINTF_INT64_MODIFIER
+# define PRINTF_INT64_MODIFIER "I64"
+# endif
+# endif
+#endif
+
+#if !defined (LONG_LONG_MAX) && defined (INT64_C)
+# define LONG_LONG_MAX INT64_C (9223372036854775807)
+#endif
+#ifndef ULONG_LONG_MAX
+# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
+#endif
+
+#if !defined (INT64_MAX) && defined (INT64_C)
+# define INT64_MAX INT64_C (9223372036854775807)
+#endif
+#if !defined (INT64_MIN) && defined (INT64_C)
+# define INT64_MIN INT64_C (-9223372036854775808)
+#endif
+#if !defined (UINT64_MAX) && defined (INT64_C)
+# define UINT64_MAX UINT64_C (18446744073709551615)
+#endif
+
+/*
+ * Width of hexadecimal for number field.
+ */
+
+#ifndef PRINTF_INT64_HEX_WIDTH
+# define PRINTF_INT64_HEX_WIDTH "16"
+#endif
+#ifndef PRINTF_INT32_HEX_WIDTH
+# define PRINTF_INT32_HEX_WIDTH "8"
+#endif
+#ifndef PRINTF_INT16_HEX_WIDTH
+# define PRINTF_INT16_HEX_WIDTH "4"
+#endif
+#ifndef PRINTF_INT8_HEX_WIDTH
+# define PRINTF_INT8_HEX_WIDTH "2"
+#endif
+#ifndef PRINTF_INT64_DEC_WIDTH
+# define PRINTF_INT64_DEC_WIDTH "19"
+#endif
+#ifndef PRINTF_INT32_DEC_WIDTH
+# define PRINTF_INT32_DEC_WIDTH "10"
+#endif
+#ifndef PRINTF_INT16_DEC_WIDTH
+# define PRINTF_INT16_DEC_WIDTH "5"
+#endif
+#ifndef PRINTF_INT8_DEC_WIDTH
+# define PRINTF_INT8_DEC_WIDTH "3"
+#endif
+#ifndef PRINTF_UINT64_DEC_WIDTH
+# define PRINTF_UINT64_DEC_WIDTH "20"
+#endif
+#ifndef PRINTF_UINT32_DEC_WIDTH
+# define PRINTF_UINT32_DEC_WIDTH "10"
+#endif
+#ifndef PRINTF_UINT16_DEC_WIDTH
+# define PRINTF_UINT16_DEC_WIDTH "5"
+#endif
+#ifndef PRINTF_UINT8_DEC_WIDTH
+# define PRINTF_UINT8_DEC_WIDTH "3"
+#endif
+
+/*
+ * Ok, lets not worry about 128 bit integers for now. Moore's law says
+ * we don't need to worry about that until about 2040 at which point
+ * we'll have bigger things to worry about.
+ */
+
+#ifdef stdint_int64_defined
+ typedef int64_t intmax_t;
+ typedef uint64_t uintmax_t;
+# define INTMAX_MAX INT64_MAX
+# define INTMAX_MIN INT64_MIN
+# define UINTMAX_MAX UINT64_MAX
+# define UINTMAX_C(v) UINT64_C(v)
+# define INTMAX_C(v) INT64_C(v)
+# ifndef PRINTF_INTMAX_MODIFIER
+# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
+# endif
+# ifndef PRINTF_INTMAX_HEX_WIDTH
+# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
+# endif
+# ifndef PRINTF_INTMAX_DEC_WIDTH
+# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
+# endif
+#else
+ typedef int32_t intmax_t;
+ typedef uint32_t uintmax_t;
+# define INTMAX_MAX INT32_MAX
+# define UINTMAX_MAX UINT32_MAX
+# define UINTMAX_C(v) UINT32_C(v)
+# define INTMAX_C(v) INT32_C(v)
+# ifndef PRINTF_INTMAX_MODIFIER
+# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
+# endif
+# ifndef PRINTF_INTMAX_HEX_WIDTH
+# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
+# endif
+# ifndef PRINTF_INTMAX_DEC_WIDTH
+# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
+# endif
+#endif
+
+/*
+ * Because this file currently only supports platforms which have
+ * precise powers of 2 as bit sizes for the default integers, the
+ * least definitions are all trivial. Its possible that a future
+ * version of this file could have different definitions.
+ */
+
+#ifndef stdint_least_defined
+ typedef int8_t int_least8_t;
+ typedef uint8_t uint_least8_t;
+ typedef int16_t int_least16_t;
+ typedef uint16_t uint_least16_t;
+ typedef int32_t int_least32_t;
+ typedef uint32_t uint_least32_t;
+# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
+# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
+# define UINT_LEAST8_MAX UINT8_MAX
+# define INT_LEAST8_MAX INT8_MAX
+# define UINT_LEAST16_MAX UINT16_MAX
+# define INT_LEAST16_MAX INT16_MAX
+# define UINT_LEAST32_MAX UINT32_MAX
+# define INT_LEAST32_MAX INT32_MAX
+# define INT_LEAST8_MIN INT8_MIN
+# define INT_LEAST16_MIN INT16_MIN
+# define INT_LEAST32_MIN INT32_MIN
+# ifdef stdint_int64_defined
+ typedef int64_t int_least64_t;
+ typedef uint64_t uint_least64_t;
+# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
+# define UINT_LEAST64_MAX UINT64_MAX
+# define INT_LEAST64_MAX INT64_MAX
+# define INT_LEAST64_MIN INT64_MIN
+# endif
+#endif
+#undef stdint_least_defined
+
+/*
+ * The ANSI C committee has defined *int*_fast*_t types as well. This,
+ * of course, defies rationality -- you can't know what will be fast
+ * just from the type itself. Even for a given architecture, compatible
+ * implementations might have different performance characteristics.
+ * Developers are warned to stay away from these types when using this
+ * or any other stdint.h.
+ */
+
+typedef int_least8_t int_fast8_t;
+typedef uint_least8_t uint_fast8_t;
+typedef int_least16_t int_fast16_t;
+typedef uint_least16_t uint_fast16_t;
+typedef int_least32_t int_fast32_t;
+typedef uint_least32_t uint_fast32_t;
+#define UINT_FAST8_MAX UINT_LEAST8_MAX
+#define INT_FAST8_MAX INT_LEAST8_MAX
+#define UINT_FAST16_MAX UINT_LEAST16_MAX
+#define INT_FAST16_MAX INT_LEAST16_MAX
+#define UINT_FAST32_MAX UINT_LEAST32_MAX
+#define INT_FAST32_MAX INT_LEAST32_MAX
+#define INT_FAST8_MIN INT_LEAST8_MIN
+#define INT_FAST16_MIN INT_LEAST16_MIN
+#define INT_FAST32_MIN INT_LEAST32_MIN
+#ifdef stdint_int64_defined
+ typedef int_least64_t int_fast64_t;
+ typedef uint_least64_t uint_fast64_t;
+# define UINT_FAST64_MAX UINT_LEAST64_MAX
+# define INT_FAST64_MAX INT_LEAST64_MAX
+# define INT_FAST64_MIN INT_LEAST64_MIN
+#endif
+
+#undef stdint_int64_defined
+
+/*
+ * Whatever piecemeal, per compiler thing we can do about the wchar_t
+ * type limits.
+ */
+
+#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks)
+# include <wchar.h>
+# ifndef WCHAR_MIN
+# define WCHAR_MIN 0
+# endif
+# ifndef WCHAR_MAX
+# define WCHAR_MAX ((wchar_t)-1)
+# endif
+#endif
+
+/*
+ * Whatever piecemeal, per compiler/platform thing we can do about the
+ * (u)intptr_t types and limits.
+ */
+
+#if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T)
+# define STDINT_H_UINTPTR_T_DEFINED
+#endif
+
+#ifndef STDINT_H_UINTPTR_T_DEFINED
+# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__)
+# define stdint_intptr_bits 64
+# elif defined (__WATCOMC__) || defined (__TURBOC__)
+# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
+# define stdint_intptr_bits 16
+# else
+# define stdint_intptr_bits 32
+# endif
+# elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__)
+# define stdint_intptr_bits 32
+# elif defined (__INTEL_COMPILER)
+/* TODO -- what did Intel do about x86-64? */
+# else
+/* #error "This platform might not be supported yet" */
+# endif
+
+# ifdef stdint_intptr_bits
+# define stdint_intptr_glue3_i(a,b,c) a##b##c
+# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
+# ifndef PRINTF_INTPTR_MODIFIER
+# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
+# endif
+# ifndef PTRDIFF_MAX
+# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
+# endif
+# ifndef PTRDIFF_MIN
+# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
+# endif
+# ifndef UINTPTR_MAX
+# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
+# endif
+# ifndef INTPTR_MAX
+# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
+# endif
+# ifndef INTPTR_MIN
+# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
+# endif
+# ifndef INTPTR_C
+# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
+# endif
+# ifndef UINTPTR_C
+# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
+# endif
+ typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
+ typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
+# else
+/* TODO -- This following is likely wrong for some platforms, and does
+ nothing for the definition of uintptr_t. */
+ typedef ptrdiff_t intptr_t;
+# endif
+# define STDINT_H_UINTPTR_T_DEFINED
+#endif
+
+/*
+ * Assumes sig_atomic_t is signed and we have a 2s complement machine.
+ */
+
+#ifndef SIG_ATOMIC_MAX
+# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
+#endif
+
+#endif
+
+#if defined (__TEST_PSTDINT_FOR_CORRECTNESS)
+
+/*
+ * Please compile with the maximum warning settings to make sure macros are
+ * not defined more than once.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define glue3_aux(x,y,z) x ## y ## z
+#define glue3(x,y,z) glue3_aux(x,y,z)
+
+#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0);
+#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0);
+
+#define DECL(us,bits) glue3(DECL,us,) (bits)
+
+#define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits)
+
+#define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; }
+
+#define X_SIZE_MAX ((size_t)-1)
+
+int main () {
+ int err_n = 0;
+ int err_first = 0;
+ DECL(I,8)
+ DECL(U,8)
+ DECL(I,16)
+ DECL(U,16)
+ DECL(I,32)
+ DECL(U,32)
+#ifdef INT64_MAX
+ DECL(I,64)
+ DECL(U,64)
+#endif
+ intmax_t imax = INTMAX_C(0);
+ uintmax_t umax = UINTMAX_C(0);
+ char str0[256], str1[256];
+
+ sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647));
+ if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
+ if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH));
+ sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295));
+ if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
+ if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH));
+#ifdef INT64_MAX
+ sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807));
+ if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
+ if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1)));
+ sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591));
+ if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
+ if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1)));
+#endif
+
+ sprintf (str0, "%d %x\n", 0, ~0);
+
+ sprintf (str1, "%d %x\n", i8, ~0);
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1));
+ sprintf (str1, "%u %x\n", u8, ~0);
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1));
+ sprintf (str1, "%d %x\n", i16, ~0);
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1));
+ sprintf (str1, "%u %x\n", u16, ~0);
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1));
+ sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0);
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1));
+ sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0);
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1));
+#ifdef INT64_MAX
+ sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0);
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1));
+#endif
+ sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0);
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1));
+ sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0);
+ if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1));
+
+ TESTUMAX(8);
+ TESTUMAX(16);
+ TESTUMAX(32);
+#ifdef INT64_MAX
+ TESTUMAX(64);
+#endif
+
+#define STR(v) #v
+#define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v));
+ if (err_n) {
+ printf ("pstdint.h is not correct. Please use sizes below to correct it:\n");
+ }
+
+ Q(int)
+ Q(unsigned)
+ Q(long int)
+ Q(short int)
+ Q(int8_t)
+ Q(int16_t)
+ Q(int32_t)
+#ifdef INT64_MAX
+ Q(int64_t)
+#endif
+
+#if UINT_MAX < X_SIZE_MAX
+ printf ("UINT_MAX < X_SIZE_MAX\n");
+#else
+ printf ("UINT_MAX >= X_SIZE_MAX\n");
+#endif
+ printf ("%" PRINTF_INT64_MODIFIER "u vs %" PRINTF_INT64_MODIFIER "u\n", UINT_MAX, X_SIZE_MAX);
+
+ return EXIT_SUCCESS;
+}
+
+#endif
diff --git a/compat/stdlib.h b/compat/stdlib.h
deleted file mode 100644
index 2c64890..0000000
--- a/compat/stdlib.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * stdlib.h --
- *
- * Declares facilities exported by the "stdlib" portion of the C library.
- * This file isn't complete in the ANSI-C sense; it only declares things
- * that are needed by Tk. This file is needed even on many systems with
- * their own stdlib.h (e.g. SunOS) because not all stdlib.h files declare
- * all the procedures needed here (such as strtod).
- *
- * Copyright (c) 1991 The Regents of the University of California.
- * Copyright (c) 1994-1998 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- */
-
-#ifndef _STDLIB
-#define _STDLIB
-
-#ifndef _TCL
-# include <tcl.h>
-#endif
-
-extern void abort(void);
-extern double atof(const char *string);
-extern int atoi(const char *string);
-extern long atol(const char *string);
-extern char * calloc(unsigned int numElements, unsigned int size);
-extern void exit(int status);
-extern int free(char *blockPtr);
-extern char * getenv(const char *name);
-extern char * malloc(unsigned int numBytes);
-extern void qsort(void *base, int n, int size, int (*compar)(
- const void *element1, const void *element2));
-extern char * realloc(char *ptr, unsigned int numBytes);
-extern double strtod(const char *string, char **endPtr);
-extern long strtol(const char *string, char **endPtr, int base);
-extern unsigned long strtoul(const char *string, char **endPtr, int base);
-
-#endif /* _STDLIB */
diff --git a/compat/unistd.h b/compat/unistd.h
deleted file mode 100644
index be966cc..0000000
--- a/compat/unistd.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * unistd.h --
- *
- * Macros, constants and prototypes for Posix conformance.
- *
- * Copyright 1989 Regents of the University of California Permission to use,
- * copy, modify, and distribute this software and its documentation for any
- * purpose and without fee is hereby granted, provided that the above
- * copyright notice appear in all copies. The University of California makes
- * no representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- */
-
-#ifndef _UNISTD
-#define _UNISTD
-
-#include <sys/types.h>
-#ifndef _TCL
-# include <tcl.h>
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-/*
- * Strict POSIX stuff goes here. Extensions go down below, in the ifndef
- * _POSIX_SOURCE section.
- */
-
-extern void _exit(int status);
-extern int access(const char *path, int mode);
-extern int chdir(const char *path);
-extern int chown(const char *path, uid_t owner, gid_t group);
-extern int close(int fd);
-extern int dup(int oldfd);
-extern int dup2(int oldfd, int newfd);
-extern int execl(const char *path, ...);
-extern int execle(const char *path, ...);
-extern int execlp(const char *file, ...);
-extern int execv(const char *path, char **argv);
-extern int execve(const char *path, char **argv, char **envp);
-extern int execvp(const char *file, char **argv);
-extern pid_t fork(void);
-extern char * getcwd(char *buf, size_t size);
-extern gid_t getegid(void);
-extern uid_t geteuid(void);
-extern gid_t getgid(void);
-extern int getgroups(int bufSize, int *buffer);
-extern pid_t getpid(void);
-extern uid_t getuid(void);
-extern int isatty(int fd);
-extern long lseek(int fd, long offset, int whence);
-extern int pipe(int *fildes);
-extern int read(int fd, char *buf, size_t size);
-extern int setgid(gid_t group);
-extern int setuid(uid_t user);
-extern unsigned sleep(unsigned seconds);
-extern char * ttyname(int fd);
-extern int unlink(const char *path);
-extern int write(int fd, const char *buf, size_t size);
-
-#ifndef _POSIX_SOURCE
-extern char * crypt(const char *, const char *);
-extern int fchown(int fd, uid_t owner, gid_t group);
-extern int flock(int fd, int operation);
-extern int ftruncate(int fd, unsigned long length);
-extern int ioctl(int fd, int request, ...);
-extern int readlink(const char *path, char *buf, int bufsize);
-extern int setegid(gid_t group);
-extern int seteuid(uid_t user);
-extern int setreuid(int ruid, int euid);
-extern int symlink(const char *, const char *);
-extern int ttyslot(void);
-extern int truncate(const char *path, unsigned long length);
-extern int vfork(void);
-#endif /* _POSIX_SOURCE */
-
-#endif /* _UNISTD */
-
diff --git a/doc/ConfigWidg.3 b/doc/ConfigWidg.3
index 92be073..927925c 100644
--- a/doc/ConfigWidg.3
+++ b/doc/ConfigWidg.3
@@ -107,7 +107,7 @@ typedef struct {
const char *\fIdbName\fR;
const char *\fIdbClass\fR;
const char *\fIdefValue\fR;
- int \fIoffset\fR;
+ size_t \fIoffset\fR;
int \fIspecFlags\fR;
const Tk_CustomOption *\fIcustomPtr\fR;
} \fBTk_ConfigSpec\fR;
@@ -161,9 +161,8 @@ contain information relevant to the manager of the widget; its exact
type is unknown to \fBTk_ConfigureWidget\fR. The \fIoffset\fR field
of each \fIspecs\fR entry indicates where in \fIwidgRec\fR to store
the information about this configuration option. You should use the
-\fBTk_Offset\fR macro to generate \fIoffset\fR values (see below for
-a description of \fBTk_Offset\fR). The location indicated by
-\fIwidgRec\fR and \fIoffset\fR will be referred to as the
+\fBoffsetof\fR macro to generate \fIoffset\fR values. The location
+indicated by \fIwidgRec\fR and \fIoffset\fR will be referred to as the
.QW target
in the descriptions below.
.PP
@@ -469,13 +468,6 @@ for which this entry is valid. When calling \fBTk_ConfigureWidget\fR,
\fIflags\fR will have a single one of these bits set to select the
entries for the desired widget type. For a working example of
this feature, see the code in tkButton.c.
-.SH TK_OFFSET
-.PP
-The \fBTk_Offset\fR macro is provided as a safe way of generating
-the \fIoffset\fR values for entries in Tk_ConfigSpec structures.
-It takes two arguments: the name of a type of record, and the
-name of a field in that record. It returns the byte offset of
-the named field in records of the given type.
.SH TK_CONFIGUREINFO
.PP
The \fBTk_ConfigureInfo\fR procedure may be used to obtain
diff --git a/doc/CrtCmHdlr.3 b/doc/CrtCmHdlr.3
index 01c3852..1ba6f63 100644
--- a/doc/CrtCmHdlr.3
+++ b/doc/CrtCmHdlr.3
@@ -31,7 +31,7 @@ drop applications.
The callback to \fIproc\fR will be made by \fBTk_HandleEvent\fR;
this mechanism only works in programs that dispatch events
through \fBTk_HandleEvent\fR (or through other Tk procedures that
-call \fBTk_HandleEvent\fR, such as \fBTk_DoOneEvent\fR or
+call \fBTk_HandleEvent\fR, such as \fBTcl_DoOneEvent\fR or
\fBTk_MainLoop\fR).
.PP
\fIProc\fR should have arguments and result that match the
diff --git a/doc/CrtGenHdlr.3 b/doc/CrtGenHdlr.3
index c2aac03..1d6f3d5 100644
--- a/doc/CrtGenHdlr.3
+++ b/doc/CrtGenHdlr.3
@@ -38,7 +38,7 @@ use with Tk, and so on.
The callback to \fIproc\fR will be made by \fBTk_HandleEvent\fR;
this mechanism only works in programs that dispatch events
through \fBTk_HandleEvent\fR (or through other Tk procedures that
-call \fBTk_HandleEvent\fR, such as \fBTk_DoOneEvent\fR or
+call \fBTk_HandleEvent\fR, such as \fBTcl_DoOneEvent\fR or
\fBTk_MainLoop\fR).
.PP
\fIProc\fR should have arguments and result that match the
diff --git a/doc/CrtItemType.3 b/doc/CrtItemType.3
index f9198f3..cd270f4 100644
--- a/doc/CrtItemType.3
+++ b/doc/CrtItemType.3
@@ -64,7 +64,7 @@ the standard procedures implemented by the type manager:
.CS
typedef struct Tk_ItemType {
const char *\fIname\fR;
- int \fIitemSize\fR;
+ size_t \fIitemSize\fR;
Tk_ItemCreateProc *\fIcreateProc\fR;
const Tk_ConfigSpec *\fIconfigSpecs\fR;
Tk_ItemConfigureProc *\fIconfigProc\fR;
@@ -83,6 +83,9 @@ typedef struct Tk_ItemType {
Tk_ItemInsertProc *\fIinsertProc\fR;
Tk_ItemDCharsProc *\fIdCharsProc\fR;
Tk_ItemType *\fInextPtr\fR;
+.VS "8.7, TIP164"
+ Tk_ItemRotateProc *\fIrotateProc\fR;
+.VE "8.7, TIP164"
} \fBTk_ItemType\fR;
.CE
.PP
@@ -549,6 +552,46 @@ and \fIdeltaX\fR and \fIdeltaY\fR give the amounts that should be
added to each x and y coordinate within the item.
The type manager should adjust the item's coordinates and
update the bounding box in the item's header.
+.SS ROTATEPROC
+.VS "8.7, TIP164"
+.PP
+\fItypePtr\->rotateProc\fR is invoked by Tk to rotate a canvas item
+during the \fBrotate\fR widget command.
+The procedure must match the following prototype:
+.PP
+.CS
+typedef void \fBTk_ItemRotateProc\fR(
+ Tk_Canvas \fIcanvas\fR,
+ Tk_Item *\fIitemPtr\fR,
+ double \fIoriginX\fR,
+ double \fIoriginY\fR,
+ double \fIangleRad\fR);
+.CE
+.PP
+The \fIcanvas\fR and \fIitemPtr\fR arguments have the usual meaning.
+\fIoriginX\fR and \fIoriginY\fR specify an origin relative to which
+the item is to be rotated, and \fIangleRad\fR gives the anticlockwise
+rotation to be applied in radians.
+The item should adjust the coordinates of its control points so that where
+they used to have coordinates \fIx\fR and \fIy\fR, they will have new
+coordinates \fIx\(fm\fR and \fIy\(fm\fR, where
+.PP
+.CS
+\fIrelX\fR = \fIx\fR - \fIoriginX\fR
+\fIrelY\fR = \fIy\fR - \fIoriginY\fR
+\fIx\(fm\fR = \fIoriginX\fR + \fIrelX\fR \(mu cos(\fIangleRad\fR) + \fIrelY\fR \(mu sin(\fIangleRad\fR)
+\fIy\(fm\fR = \fIoriginY\fR \(mi \fIrelX\fR \(mu sin(\fIangleRad\fR) + \fIrelY\fR \(mu cos(\fIangleRad\fR)
+.CE
+.PP
+The control points for an item are not necessarily the coordinates provided to
+the item when it is created (or via the \fItypePtr\->coordProc\fR), but could
+instead be derived from them.
+\fIrotateProc\fR must also update the bounding box in the item's header.
+.PP
+Item types do not need to provide a \fItypePtr\->rotateProc\fR. If the
+\fItypePtr\->rotateProc\fR is NULL, the \fItypePtr\->coordProc\fR will be
+used instead to retrieve and update the list of coordinates.
+.VE "8.7, TIP164"
.SS INDEXPROC
.PP
\fItypePtr\->indexProc\fR is invoked by Tk to translate a string
diff --git a/doc/EventHndlr.3 b/doc/EventHndlr.3
index 8c47e78..a2cbf8d 100644
--- a/doc/EventHndlr.3
+++ b/doc/EventHndlr.3
@@ -38,7 +38,7 @@ by \fImask\fR occurs in the window specified by \fItkwin\fR.
The callback to \fIproc\fR will be made by \fBTk_HandleEvent\fR;
this mechanism only works in programs that dispatch events
through \fBTk_HandleEvent\fR (or through other Tk procedures that
-call \fBTk_HandleEvent\fR, such as \fBTk_DoOneEvent\fR or
+call \fBTk_HandleEvent\fR, such as \fBTcl_DoOneEvent\fR or
\fBTk_MainLoop\fR).
.PP
\fIProc\fR should have arguments and result that match the
diff --git a/doc/GetScroll.3 b/doc/GetScroll.3
index 70145aa..dd12cca 100644
--- a/doc/GetScroll.3
+++ b/doc/GetScroll.3
@@ -15,10 +15,10 @@ Tk_GetScrollInfoObj, Tk_GetScrollInfo \- parse arguments for scrolling commands
\fB#include <tk.h>\fR
.sp
int
-\fBTk_GetScrollInfoObj(\fIinterp, objc, objv, dblPtr, intPtr\fB)\fR
+\fBTk_GetScrollInfoObj(\fIinterp, objc, objv, fractionPtr, stepsPtr\fB)\fR
.sp
int
-\fBTk_GetScrollInfo(\fIinterp, argc, argv, dblPtr, intPtr\fB)\fR
+\fBTk_GetScrollInfo(\fIinterp, argc, argv, fractionPtr, stepsPtr\fB)\fR
.SH ARGUMENTS
.AS "Tcl_Interp" *fractionPtr
.AP Tcl_Interp *interp in
@@ -50,18 +50,18 @@ and parses the words starting with \fIobjv\fR[2].
The words starting with \fIobjv\fR[2] must have one of the following forms:
.CS
\fBmoveto \fIfraction\fR
-\fBscroll \fInumber\fB units\fR
\fBscroll \fInumber\fB pages\fR
+\fBscroll \fInumber\fB units\fR
.CE
.LP
-Any of the \fBmoveto\fR, \fBscroll\fR, \fBunits\fR, and \fBpages\fR
+Any of the \fBmoveto\fR, \fBscroll\fR, \fBpages\fR, and \fBunits\fR
keywords may be abbreviated.
If \fIobjv\fR has the \fBmoveto\fR form, \fBTK_SCROLL_MOVETO\fR
is returned as result and \fI*fractionPtr\fR is filled in with the
\fIfraction\fR argument to the command, which must be a proper real
value.
-If \fIobjv\fR has the \fBscroll\fR form, \fBTK_SCROLL_UNITS\fR
-or \fBTK_SCROLL_PAGES\fR is returned and \fI*stepsPtr\fR is filled
+If \fIobjv\fR has the \fBscroll\fR form, \fBTK_SCROLL_PAGES\fR
+or \fBTK_SCROLL_UNITS\fR is returned and \fI*stepsPtr\fR is filled
in with the \fInumber\fR value, which must be a proper integer.
If an error occurs in parsing the arguments, \fBTK_SCROLL_ERROR\fR
is returned and an error message is left in interpreter
diff --git a/doc/HandleEvent.3 b/doc/HandleEvent.3
index f3072de..af3fde6 100644
--- a/doc/HandleEvent.3
+++ b/doc/HandleEvent.3
@@ -25,7 +25,7 @@ that all unused fields of the structure be set to zero.
.PP
\fBTk_HandleEvent\fR is a lower-level procedure that deals with window
events. It is called by \fBTcl_ServiceEvent\fR (and indirectly by
-\fBTk_DoOneEvent\fR), and in a few other cases within Tk.
+\fBTcl_DoOneEvent\fR), and in a few other cases within Tk.
It makes callbacks to any window event
handlers (created by calls to \fBTk_CreateEventHandler\fR)
that match \fIeventPtr\fR and then returns. In some cases
diff --git a/doc/MoveToplev.3 b/doc/MoveToplev.3
index 20ff120..f67627f 100644
--- a/doc/MoveToplev.3
+++ b/doc/MoveToplev.3
@@ -46,6 +46,6 @@ menus that want to appear at a particular place on the screen.
When \fBTk_MoveToplevelWindow\fR is called it does not immediately
pass on the new desired location to the window manager; it defers
this action until all other outstanding work has been completed,
-using the \fBTk_DoWhenIdle\fR mechanism.
+using the \fBTcl_DoWhenIdle\fR mechanism.
.SH KEYWORDS
position, top-level window, window manager
diff --git a/doc/NameOfImg.3 b/doc/NameOfImg.3
index 38c7ca9..8c191ce 100644
--- a/doc/NameOfImg.3
+++ b/doc/NameOfImg.3
@@ -14,10 +14,10 @@ Tk_NameOfImage \- Return name of image.
\fB#include <tk.h>\fR
.sp
const char *
-\fBTk_NameOfImage\fR(\fItypePtr\fR)
+\fBTk_NameOfImage\fR(\fIimageMaster\fR)
.SH ARGUMENTS
-.AS Tk_ImageMaster *masterPtr
-.AP Tk_ImageMaster *masterPtr in
+.AS Tk_ImageMaster imageMaster
+.AP Tk_ImageMaster imageMaster in
Token for image, which was passed to image manager's \fIcreateProc\fR when
the image was created.
.BE
diff --git a/doc/ParseArgv.3 b/doc/ParseArgv.3
index 4d85d15..727dcfa 100644
--- a/doc/ParseArgv.3
+++ b/doc/ParseArgv.3
@@ -72,8 +72,8 @@ expected; each of its entries has the following structure:
typedef struct {
const char *\fIkey\fR;
int \fItype\fR;
- char *\fIsrc\fR;
- char *\fIdst\fR;
+ void *\fIsrc\fR;
+ void *\fIdst\fR;
const char *\fIhelp\fR;
} \fBTk_ArgvInfo\fR;
.CE
@@ -312,13 +312,13 @@ Boolean exec = FALSE;
* Define option descriptions.
*/
Tk_ArgvInfo argTable[] = {
- {"\-X", TK_ARGV_CONSTANT, (char *) 1, (char *) &debugFlag,
+ {"\-X", TK_ARGV_CONSTANT, (char *) 1, &debugFlag,
"Turn on debugging printfs"},
- {"\-N", TK_ARGV_INT, NULL, (char *) &numReps,
+ {"\-N", TK_ARGV_INT, NULL, &numReps,
"Number of repetitions"},
- {"\-of", TK_ARGV_STRING, NULL, (char *) &fileName,
+ {"\-of", TK_ARGV_STRING, NULL, &fileName,
"Name of file for output"},
- {"x", TK_ARGV_REST, NULL, (char *) &exec,
+ {"x", TK_ARGV_REST, NULL, &exec,
"File to exec, followed by any arguments (must be last argument)."},
{NULL, TK_ARGV_END, NULL, NULL,
NULL}
diff --git a/doc/RestrictEv.3 b/doc/RestrictEv.3
index 103a80b..8b3af07 100644
--- a/doc/RestrictEv.3
+++ b/doc/RestrictEv.3
@@ -30,7 +30,7 @@ Pointer to place to save argument to previous restrict procedure.
.PP
This procedure is useful in certain situations where applications
are only prepared to receive certain X events. After
-\fBTk_RestrictEvents\fR is called, \fBTk_DoOneEvent\fR (and
+\fBTk_RestrictEvents\fR is called, \fBTcl_DoOneEvent\fR (and
hence \fBTk_MainLoop\fR) will filter X input events through
\fIproc\fR. \fIProc\fR indicates whether a
given event is to be processed immediately, deferred until some
@@ -48,7 +48,7 @@ to \fBTk_RestrictEvents\fR; it may be used to provide \fIproc\fR with
information it needs to filter events. The \fIeventPtr\fR points to
an event under consideration. \fIProc\fR returns a restrict action
(enumerated type \fBTk_RestrictAction\fR) that indicates what
-\fBTk_DoOneEvent\fR should do with the event. If the return value is
+\fBTcl_DoOneEvent\fR should do with the event. If the return value is
\fBTK_PROCESS_EVENT\fR, then the event will be handled immediately.
If the return value is \fBTK_DEFER_EVENT\fR, then the event will be
left on the event queue for later processing. If the return value is
@@ -74,6 +74,6 @@ solution in these situations is to call \fBXNextEvent\fR or
\fBXWindowEvent\fR, but these procedures cannot be used because
Tk keeps its own event queue that is separate from the X event
queue. Instead, call \fBTk_RestrictEvents\fR to set up a filter,
-then call \fBTk_DoOneEvent\fR to retrieve the desired event(s).
+then call \fBTcl_DoOneEvent\fR to retrieve the desired event(s).
.SH KEYWORDS
delay, event, filter, restriction
diff --git a/doc/SetClassProcs.3 b/doc/SetClassProcs.3
index a2af479..53f7cce 100644
--- a/doc/SetClassProcs.3
+++ b/doc/SetClassProcs.3
@@ -33,7 +33,7 @@ are used as callbacks in different places.
The structure pointed to by \fIprocs\fR contains the following:
.CS
typedef struct Tk_ClassProcs {
- unsigned int \fIsize\fR;
+ size_t \fIsize\fR;
Tk_ClassWorldChangedProc *\fIworldChangedProc\fR;
Tk_ClassCreateProc *\fIcreateProc\fR;
Tk_ClassModalProc *\fImodalProc\fR;
@@ -56,7 +56,7 @@ The \fIinstanceData\fR parameter passed to the \fIworldChangedProc\fR
will be identical to the \fIinstanceData\fR parameter passed to
\fBTk_SetClassProcs\fR.
.PP
-\fIcreateProc\fR is used to create platform-dependant windows. It is
+\fIcreateProc\fR is used to create platform-dependent windows. It is
invoked by \fBTk_MakeWindowExist\fR. \fIcreateProc\fR should have
arguments and results that match the type \fBTk_ClassCreateProc\fR:
.CS
diff --git a/doc/SetOptions.3 b/doc/SetOptions.3
index 4323f95..cb04655 100644
--- a/doc/SetOptions.3
+++ b/doc/SetOptions.3
@@ -8,7 +8,7 @@
.so man.macros
.BS
.SH NAME
-Tk_CreateOptionTable, Tk_DeleteOptionTable, Tk_InitOptions, Tk_SetOptions, Tk_FreeSavedOptions, Tk_RestoreSavedOptions, Tk_GetOptionValue, Tk_GetOptionInfo, Tk_FreeConfigOptions, Tk_Offset \- process configuration options
+Tk_CreateOptionTable, Tk_DeleteOptionTable, Tk_InitOptions, Tk_SetOptions, Tk_FreeSavedOptions, Tk_RestoreSavedOptions, Tk_GetOptionValue, Tk_GetOptionInfo, Tk_FreeConfigOptions \- process configuration options
.SH SYNOPSIS
.nf
\fB#include <tk.h>\fR
@@ -35,9 +35,6 @@ Tcl_Obj *
\fBTk_GetOptionInfo(\fIinterp, recordPtr, optionTable, namePtr, tkwin\fB)\fR
.sp
\fBTk_FreeConfigOptions(\fIrecordPtr, optionTable, tkwin\fB)\fR
-.sp
-int
-\fBTk_Offset(\fItype, field\fB)\fR
.SH ARGUMENTS
.AS Tk_SavedOptions "*const objv[]" in/out
.AP Tcl_Interp *interp in
@@ -239,12 +236,6 @@ is returned and an error message is left in \fIinterp\fR's result unless
\fBTk_FreeConfigOptions\fR must be invoked when a widget is deleted.
It frees all of the resources associated with any of the configuration
options defined in \fIrecordPtr\fR by \fIoptionTable\fR.
-.PP
-The \fBTk_Offset\fR macro is provided as a safe way of generating the
-\fIobjOffset\fR and \fIinternalOffset\fR values for entries in
-Tk_OptionSpec structures. It takes two arguments: the name of a type
-of record, and the name of a field in that record. It returns the byte
-offset of the named field in records of the given type.
.SH "TEMPLATES"
.PP
The array of Tk_OptionSpec structures passed to \fBTk_CreateOptionTable\fR
@@ -258,8 +249,8 @@ typedef struct {
const char *\fIdbName\fR;
const char *\fIdbClass\fR;
const char *\fIdefValue\fR;
- int \fIobjOffset\fR;
- int \fIinternalOffset\fR;
+ size_t \fIobjOffset\fR;
+ size_t \fIinternalOffset\fR;
int \fIflags\fR;
const void *\fIclientData\fR;
int \fItypeMask\fR;
@@ -281,7 +272,7 @@ value is specified in the option database. The \fIobjOffset\fR and
\fIinternalOffset\fR fields indicate where to store the value of this
option in widget records (more on this below); values for the \fIobjOffset\fR
and \fIinternalOffset\fR fields should always be generated with the
-\fBTk_Offset\fR macro.
+\fBoffsetof\fR macro.
The \fIflags\fR field contains additional information
to control the processing of this configuration option (see below
for details).
@@ -443,7 +434,9 @@ suitable for passing to \fBTcl_GetIndexFromObj\fR. The value must
be one of the strings in the table, or a unique abbreviation of
one of the strings. The internal form is an integer giving the index
into the table of the matching string, like the return value
-from \fBTcl_GetStringFromObj\fR.
+from \fBTcl_GetStringFromObj\fR. This option type supports the
+\fBTK_OPTION_NULL_OK\fR flag; if a NULL value is set, the internal
+representation is set to -1.
.TP
\fBTK_OPTION_SYNONYM\fR
This type is used to provide alternative names for an option (for
diff --git a/doc/bind.n b/doc/bind.n
index 009fd08..871e167 100644
--- a/doc/bind.n
+++ b/doc/bind.n
@@ -70,7 +70,7 @@ event pattern may
take one of three forms. In the simplest case it is a single
printing ASCII character, such as \fBa\fR or \fB[\fR. The character
may not be a space character or the character \fB<\fR. This form of
-pattern matches a \fBKeyPress\fR event for the particular
+pattern matches a \fBKey\fR event for the particular
character. The second form of pattern is longer but more general.
It has the following syntax:
.CS
@@ -168,14 +168,14 @@ couple non-standard X event types that were added to better support
the Macintosh and Windows platforms. Below is a list of all the valid
types; where two names appear together, they are synonyms.
.DS
-.ta \w'\fBButtonPress, Button\0\0\0\fR'u +\w'\fBKeyPress, Key\0\0\0\fR'u
+.ta \w'\fBButton, ButtonPress\0\0\0\fR'u +\w'\fBKey, KeyPress\0\0\0\fR'u
\fBActivate\fR \fBDestroy\fR \fBMap\fR
-\fBButtonPress\fR, \fBButton\fR \fBEnter\fR \fBMapRequest\fR
+\fBButton\fR, \fBButtonPress\fR \fBEnter\fR \fBMapRequest\fR
\fBButtonRelease\fR \fBExpose\fR \fBMotion\fR
\fBCirculate\fR \fBFocusIn\fR \fBMouseWheel\fR
\fBCirculateRequest\fR \fBFocusOut\fR \fBProperty\fR
\fBColormap\fR \fBGravity\fR \fBReparent\fR
-\fBConfigure\fR \fBKeyPress\fR, \fBKey\fR \fBResizeRequest\fR
+\fBConfigure\fR \fBKey\fR, \fBKeyPress\fR \fBResizeRequest\fR
\fBConfigureRequest\fR \fBKeyRelease\fR \fBUnmap\fR
\fBCreate\fR \fBLeave\fR \fBVisibility\fR
\fBDeactivate\fR
@@ -209,21 +209,21 @@ the mouse wheel has moved. The smallest value for which the
system will report is defined by the OS. The sign of the
value determines which direction your widget should scroll. Positive
values should scroll up and negative values should scroll down.
-.IP "\fBKeyPress\fR, \fBKeyRelease\fR" 5
-The \fBKeyPress\fR and \fBKeyRelease\fR events are generated
-whenever a key is pressed or released. \fBKeyPress\fR and \fBKeyRelease\fR
+.IP "\fBKey\fR, \fBKeyRelease\fR" 5
+The \fBKey\fR and \fBKeyRelease\fR events are generated
+whenever a key is pressed or released. \fBKey\fR and \fBKeyRelease\fR
events are sent to the window which currently has the keyboard focus.
-.IP "\fBButtonPress\fR, \fBButtonRelease\fR, \fBMotion\fR" 5
-The \fBButtonPress\fR and \fBButtonRelease\fR events
+.IP "\fBButton\fR, \fBButtonRelease\fR, \fBMotion\fR" 5
+The \fBButton\fR and \fBButtonRelease\fR events
are generated when the user presses or releases a mouse button.
\fBMotion\fR events are generated whenever the pointer is moved.
-\fBButtonPress\fR, \fBButtonRelease\fR, and \fBMotion\fR events are
+\fBButton\fR, \fBButtonRelease\fR, and \fBMotion\fR events are
normally sent to the window containing the pointer.
.RS
.PP
When a mouse button is pressed, the window containing the pointer
automatically obtains a temporary pointer grab.
-Subsequent \fBButtonPress\fR, \fBButtonRelease\fR, and \fBMotion\fR
+Subsequent \fBButton\fR, \fBButtonRelease\fR, and \fBMotion\fR
events will be sent to that window,
regardless of which window contains the pointer,
until all buttons have been released.
@@ -351,7 +351,7 @@ position in the stacking order.
.SS "EVENT DETAILS"
.PP
The last part of a long event specification is \fIdetail\fR. In the
-case of a \fBButtonPress\fR or \fBButtonRelease\fR event, it is the
+case of a \fBButton\fR or \fBButtonRelease\fR event, it is the
number of a button (1\-9). If a button number is given, then only an
event on that particular button will match; if no button number is
given, then an event on any button will match. Note: giving a
@@ -360,10 +360,10 @@ in the first case, it refers to a button being pressed or released,
while in the second it refers to some other button that is already
depressed when the matching event occurs. If a button
number is given then \fItype\fR may be omitted: if will default
-to \fBButtonPress\fR. For example, the specifier \fB<1>\fR
-is equivalent to \fB<ButtonPress\-1>\fR.
+to \fBButton\fR. For example, the specifier \fB<1>\fR
+is equivalent to \fB<Button\-1>\fR.
.PP
-If the event type is \fBKeyPress\fR or \fBKeyRelease\fR, then
+If the event type is \fBKey\fR or \fBKeyRelease\fR, then
\fIdetail\fR may be specified in the form of an X keysym. Keysyms
are textual specifications for particular keys on the keyboard;
they include all the alphanumeric ASCII characters (e.g.
@@ -383,9 +383,9 @@ system.
If necessary, you can use the \fB%K\fR notation described below
to print out the keysym name for a particular key.
If a keysym \fIdetail\fR is given, then the
-\fItype\fR field may be omitted; it will default to \fBKeyPress\fR.
+\fItype\fR field may be omitted; it will default to \fBKey\fR.
For example, \fB<Control\-comma>\fR is equivalent to
-\fB<Control\-KeyPress\-comma>\fR.
+\fB<Control\-Key\-comma>\fR.
.SH "BINDING SCRIPTS AND SUBSTITUTIONS"
.PP
The \fIscript\fR argument to \fBbind\fR is a Tcl script, called the
@@ -421,7 +421,7 @@ in the stacking order, or \fB0\fR if the receiving window is at the
bottom.
.IP \fB%b\fR 5
The number of the button that was pressed or released. Valid only
-for \fBButtonPress\fR and \fBButtonRelease\fR events.
+for \fBButton\fR and \fBButtonRelease\fR events.
.IP \fB%c\fR 5
The \fIcount\fR field from the event. Valid only for \fBExpose\fR events.
Indicates that there are \fIcount\fR pending \fBExpose\fR events which have not
@@ -468,7 +468,7 @@ Indicates the new or requested height of the window.
The \fIwindow\fR field from the event, represented as a hexadecimal
integer. Valid for all event types.
.IP \fB%k\fR 5
-The \fIkeycode\fR field from the event. Valid only for \fBKeyPress\fR
+The \fIkeycode\fR field from the event. Valid only for \fBKey\fR
and \fBKeyRelease\fR events.
.IP \fB%m\fR 5
The \fImode\fR field from the event. The substituted string is one of
@@ -483,8 +483,8 @@ The \fIplace\fR field from the event, substituted as one of the
strings \fBPlaceOnTop\fR or \fBPlaceOnBottom\fR. Valid only
for \fBCirculate\fR and \fBCirculateRequest\fR events.
.IP \fB%s\fR 5
-The \fIstate\fR field from the event. For \fBButtonPress\fR,
-\fBButtonRelease\fR, \fBEnter\fR, \fBKeyPress\fR, \fBKeyRelease\fR,
+The \fIstate\fR field from the event. For \fBButton\fR,
+\fBButtonRelease\fR, \fBEnter\fR, \fBKey\fR, \fBKeyRelease\fR,
\fBLeave\fR, and \fBMotion\fR events, a decimal string
is substituted. For \fBVisibility\fR, one of the strings
\fBVisibilityUnobscured\fR, \fBVisibilityPartiallyObscured\fR,
@@ -506,10 +506,13 @@ Valid only for
\fBResizeRequest\fR, and \fBExpose\fR events.
.IP "\fB%x\fR, \fB%y\fR" 5
The \fIx\fR and \fIy\fR fields from the event.
-For \fBButtonPress\fR, \fBButtonRelease\fR, \fBMotion\fR,
-\fBKeyPress\fR, \fBKeyRelease\fR, and \fBMouseWheel\fR events,
+For \fBButton\fR, \fBButtonRelease\fR, \fBMotion\fR,
+\fBKey\fR, \fBKeyRelease\fR, and \fBMouseWheel\fR events,
\fB%x\fR and \fB%y\fR indicate the position of the mouse pointer
relative to the receiving window.
+For key events on the Macintosh these are the coordinates of the
+mouse at the moment when an X11 KeyEvent is sent to Tk, which could
+be slightly later than the time of the physical press or release.
For \fBEnter\fR and \fBLeave\fR events, the position where the
mouse pointer crossed the window, relative to the receiving window.
For \fBConfigure\fR and \fBCreate\fR requests, the \fIx\fR and \fIy\fR
@@ -517,10 +520,11 @@ coordinates of the window relative to its parent window.
.IP \fB%A\fR 5
Substitutes the UNICODE character corresponding to the event, or
the empty string if the event does not correspond to a UNICODE character
-(e.g. the shift key was pressed). \fBXmbLookupString\fR (or
+(e.g. the shift key was pressed). On X11, \fBXmbLookupString\fR (or
\fBXLookupString\fR when input method support is turned off) does all
the work of translating from the event to a UNICODE character.
-Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events.
+On X11, valid only for \fBKey\fR event. On Windows and macOS/aqua,
+valid only for \fBKey\fR and \fBKeyRelease\fR events.
.IP \fB%B\fR 5
The \fIborder_width\fR field from the event. Valid only for
\fBConfigure\fR, \fBConfigureRequest\fR, and \fBCreate\fR events.
@@ -538,13 +542,13 @@ event, \fB1\fR indicates that it is a
event generated by \fBSendEvent\fR.
.IP \fB%K\fR 5
The keysym corresponding to the event, substituted as a textual
-string. Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events.
+string. Valid only for \fBKey\fR and \fBKeyRelease\fR events.
.IP \fB%M\fR 5
The number of script-based binding patterns matched so far for the
event. Valid for all event types.
.IP \fB%N\fR 5
The keysym corresponding to the event, substituted as a decimal
-number. Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events.
+number. Valid only for \fBKey\fR and \fBKeyRelease\fR events.
.IP \fB%P\fR 5
The name of the property being updated or deleted (which
may be converted to an XAtom using \fBwinfo atom\fR.) Valid
@@ -566,8 +570,8 @@ The \fIx_root\fR and \fIy_root\fR fields from the event.
If a virtual-root window manager is being used then the substituted
values are the corresponding x-coordinate and y-coordinate in the virtual root.
Valid only for
-\fBButtonPress\fR, \fBButtonRelease\fR, \fBKeyPress\fR, \fBKeyRelease\fR,
-and \fBMotion\fR events.
+\fBButton\fR, \fBButtonRelease\fR, \fBEnter\fR, \fBKey\fR,
+\fBKeyRelease\fR, \fBLeave\fR and \fBMotion\fR events.
Same meaning as \fB%x\fR and \fB%y\fR, except relative to the (virtual) root
window.
.LP
@@ -633,16 +637,17 @@ several matching sequences is more specific:
an event pattern that specifies a specific button or key is more specific
than one that does not;
.IP (b)
-a longer sequence (in terms of number
-of events matched) is more specific than a shorter sequence;
+a sequence with the most highest-ordered patterns (in term of highest
+repetition count) is more specific than a sequence with less
+highest-ordered patterns;
.IP (c)
if the modifiers specified in one pattern are a subset of the
modifiers in another pattern, then the pattern with more modifiers
-is more specific.
+is more specific;
.IP (d)
a virtual event whose physical pattern matches the sequence is less
specific than the same physical pattern that is not associated with a
-virtual event.
+virtual event;
.IP (e)
given a sequence that matches two or more virtual events, one
of the virtual events will be chosen, but the order is undefined.
@@ -678,17 +683,17 @@ When a \fIsequence\fR specified in a \fBbind\fR command contains
more than one event pattern, then its script is executed whenever
the recent events (leading up to and including the current event)
match the given sequence. This means, for example, that if button 1 is
-clicked repeatedly the sequence \fB<Double\-ButtonPress\-1>\fR will match
+clicked repeatedly the sequence \fB<Double\-Button\-1>\fR will match
each button press but the first.
If extraneous events that would prevent a match occur in the middle
of an event sequence then the extraneous events are
-ignored unless they are \fBKeyPress\fR or \fBButtonPress\fR events.
-For example, \fB<Double\-ButtonPress\-1>\fR will match a sequence of
+ignored unless they are \fBKey\fR or \fBButton\fR events.
+For example, \fB<Double\-Button\-1>\fR will match a sequence of
presses of button 1, even though there will be \fBButtonRelease\fR
events (and possibly \fBMotion\fR events) between the
-\fBButtonPress\fR events.
-Furthermore, a \fBKeyPress\fR event may be preceded by any number
-of other \fBKeyPress\fR events for modifier keys without the
+\fBButton\fR events.
+Furthermore, a \fBKey\fR event may be preceded by any number
+of other \fBKey\fR events for modifier keys without the
modifier keys preventing a match.
For example, the event sequence \fBaB\fR will match a press of the
\fBa\fR key, a release of the \fBa\fR key, a press of the \fBShift\fR
diff --git a/doc/canvas.n b/doc/canvas.n
index fa7843d..623154f 100644
--- a/doc/canvas.n
+++ b/doc/canvas.n
@@ -220,8 +220,12 @@ for scrolling.
Canvases do not support scaling or rotation of the canvas coordinate
system relative to the window coordinate system.
.PP
-Individual items may be moved or scaled using widget commands
-described below, but they may not be rotated.
+Individual items may be moved, scaled
+.VS "8.7, TIP164"
+or rotated
+.VE "8.7, TIP164"
+using widget commands
+described below.
.PP
Note that the default origin of the canvas's visible area is
coincident with the origin for the whole window as that makes bindings
@@ -466,7 +470,7 @@ defined for \fItagOrId\fR.
.PP
The only events for which bindings may be specified are those related to
the mouse and keyboard (such as \fBEnter\fR, \fBLeave\fR,
-\fBButtonPress\fR, \fBMotion\fR, and \fBKeyPress\fR) or virtual events.
+\fBButton\fR, \fBMotion\fR, and \fBKey\fR) or virtual events.
The handling of events in canvases uses the current item defined in
\fBITEM IDS AND TAGS\fR above. \fBEnter\fR and \fBLeave\fR events
trigger for an
@@ -674,13 +678,12 @@ mapped.
This command returns an empty string.
.TP
\fIpathName \fBimove \fItagOrId index x y\fR
-.VS 8.6
+.
This command causes the \fIindex\fR'th coordinate of each of the items
indicated by \fItagOrId\fR to be relocated to the location (\fIx\fR,\fIy\fR).
Each item interprets \fIindex\fR independently according to the rules
described in \fBINDICES\fR above. Out of the standard set of items, only line
and polygon items may have their coordinates relocated this way.
-.VE 8.6
.TP
\fIpathName \fBindex \fItagOrId index\fR
.
@@ -766,16 +769,16 @@ each point associated with the item.
This command returns an empty string.
.TP
\fIpathName \fBmoveto \fItagOrId xPos yPos\fR
-.VS 8.6
+.
Move the items given by \fItagOrId\fR in the canvas coordinate
-space so that the first coordinate pair of the bottommost item with
+space so that the first coordinate pair (the upper-left corner of the
+bounding box) of the first item (the lowest in the display list) with
tag \fItagOrId\fR is located at
position (\fIxPos\fR,\fIyPos\fR). \fIxPos\fR and \fIyPos\fR may be
the empty string, in which case the corresponding coordinate
will be unchanged. All items matching
\fItagOrId\fR remain in the same positions relative to each other.
This command returns an empty string.
-.VE 8.6
.TP
\fIpathName \fBpostscript \fR?\fIoption value option value ...\fR?
.
@@ -961,7 +964,7 @@ determined by the \fBraise\fR command and \fBlower\fR command, not the
.RE
.TP
\fIpathName \fBrchars \fItagOrId first last string\fR
-.VS 8.6
+.
This command causes the text or coordinates between \fIfirst\fR and \fIlast\fR
for each of the items indicated by \fItagOrId\fR to be replaced by
\fIstring\fR. Each item interprets \fIfirst\fR and \fIlast\fR independently
@@ -970,7 +973,27 @@ set of items, text items support this operation by altering their text as
directed, and line and polygon items support this operation by altering their
coordinate list (in which case \fIstring\fR should be a list of coordinates to
use as a replacement). The other items ignore this operation.
-.VE 8.6
+.TP
+\fIpathName \fBrotate \fItagOrId xOrigin yOrigin angle\fR
+.VS "8.7, TIP164"
+Rotate the coordinates of all of the items given by \fItagOrId\fR in canvas
+coordinate space.
+\fIXOrigin\fR and \fIyOrigin\fR identify the origin for the rotation
+operation and \fIangle\fR identifies the amount to rotate the coordinates
+anticlockwise, in degrees. (Negative values rotate clockwise.)
+This command returns an empty string.
+.RS
+.PP
+Implementation note: not all item types work the same with rotations. In
+particular,\fB bitmap\fR,\fB image\fR,\fB text\fR and\fB window\fR items only
+rotate their anchor points and do not rotate the items themselves about those
+points, and the \fBarc\fR, \fBoval\fR and \fBrectangle\fR types rotate about a
+computed center point instead of moving the bounding box coordinates directly.
+.PP
+Some items (currently \fBarc\fR and\fB text\fR) have angles in their options;
+this command \fIdoes not\fR affect those options.
+.RE
+.VE "8.7, TIP164"
.TP
\fIpathName \fBscale \fItagOrId xOrigin yOrigin xScale yScale\fR
.
@@ -1125,16 +1148,16 @@ total width of the canvas is off-screen to the left.
This command shifts the view in the window left or right according to
\fInumber\fR and \fIwhat\fR.
\fINumber\fR must be an integer.
-\fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation
+\fIWhat\fR must be either \fBpages\fR or \fBunits\fR or an abbreviation
of one of these.
-If \fIwhat\fR is \fBunits\fR, the view adjusts left or right in units
-of the \fBxScrollIncrement\fR option, if it is greater than zero,
-or in units of one-tenth the window's width otherwise.
If \fIwhat is \fBpages\fR then the view
adjusts in units of nine-tenths the window's width.
If \fInumber\fR is negative then information farther to the left
becomes visible; if it is positive then information farther to the right
becomes visible.
+If \fIwhat\fR is \fBunits\fR, the view adjusts left or right in units
+of the \fBxScrollIncrement\fR option, if it is greater than zero,
+or in units of one-tenth the window's width otherwise.
.RE
.TP
\fIpathName \fByview \fI?args\fR?
@@ -1166,15 +1189,15 @@ area is off-screen to the top.
This command adjusts the view in the window up or down according to
\fInumber\fR and \fIwhat\fR.
\fINumber\fR must be an integer.
-\fIWhat\fR must be either \fBunits\fR or \fBpages\fR.
-If \fIwhat\fR is \fBunits\fR, the view adjusts up or down in units
-of the \fByScrollIncrement\fR option, if it is greater than zero,
-or in units of one-tenth the window's height otherwise.
+\fIWhat\fR must be either \fBpages\fR or \fBunits\fR.
If \fIwhat\fR is \fBpages\fR then
the view adjusts in units of nine-tenths the window's height.
If \fInumber\fR is negative then higher information becomes
visible; if it is positive then lower information
becomes visible.
+If \fIwhat\fR is \fBunits\fR, the view adjusts up or down in units
+of the \fByScrollIncrement\fR option, if it is greater than zero,
+or in units of one-tenth the window's height otherwise.
.RE
.SH "OVERVIEW OF ITEM TYPES"
.PP
@@ -1234,10 +1257,10 @@ in the \fBCOORDINATES\fR section above.
Specifies the color to be used to fill item's area.
in its normal, active, and disabled states,
\fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR.
-If \fIcolor\fR is an empty string (the default),
-then the item will not be filled.
For the line item, it specifies the color of the line drawn.
For the text item, it specifies the foreground color of the text.
+If \fIcolor\fR is an empty string (the default for all canvas items
+except line and text), then the item will not be filled.
.TP
\fB\-outline \fIcolor\fR
.TP
@@ -1248,8 +1271,8 @@ For the text item, it specifies the foreground color of the text.
This option specifies the color that should be used to draw the
outline of the item in its normal, active and disabled states.
\fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR.
-This option defaults to \fBblack\fR. If \fIcolor\fR is specified
-as an empty string then no outline is drawn for the item.
+If \fIcolor\fR is specified as an empty string then no outline is drawn
+for the item.
.TP
\fB\-offset \fIoffset\fR
.
@@ -1487,8 +1510,7 @@ disabled states.
Specifies the color to use for each of the bitmap's
.QW 1
valued pixels in its normal, active and disabled states.
-\fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR and
-defaults to \fBblack\fR.
+\fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR.
.SS "IMAGE ITEMS"
.PP
Items of type \fBimage\fR are used to display images on a
@@ -1569,6 +1591,12 @@ ends of the line.
\fBlast\fR (for an arrowhead at the last point of the line), or
\fBboth\fR (for arrowheads at both ends).
This option defaults to \fBnone\fR.
+When requested to draw an arrowhead, Tk internally adjusts the corresponding
+line end point so that the rendered line ends at the neck of the arrowhead
+rather than at its tip so that the line doesn't extend past the edge of the
+arrowhead. This may trigger a \fBLeave\fR event if the mouse is hovering this
+line end. Conversely, when removing an arrowhead Tk adjusts the corresponding
+line point the other way round, which may trigger an \fBEnter\fR event.
.TP
\fB\-arrowshape \fIshape\fR
This option indicates how to draw arrowheads.
@@ -1834,13 +1862,12 @@ The following standard options are supported by text items:
The following extra options are supported for text items:
.TP
\fB\-angle \fIrotationDegrees\fR
-.VS 8.6
+.
\fIRotationDegrees\fR tells how many degrees to rotate the text anticlockwise
about the positioning point for the text; it may have any floating-point value
from 0.0 to 360.0. For example, if \fIrotationDegrees\fR is \fB90\fR, then the
text will be drawn vertically from bottom to top.
This option defaults to \fB0.0\fR.
-.VE 8.6
.TP
\fB\-font \fIfontName\fR
Specifies the font to use for the text item.
diff --git a/doc/colors.n b/doc/colors.n
index dc7007b..9234824 100644
--- a/doc/colors.n
+++ b/doc/colors.n
@@ -784,9 +784,10 @@ YellowGreen 154 205 50
.TP
\fBMac OS X\fR
.
-On Mac OS X, the following additional system colors are available
-(note that the actual color values depend on the currently active OS theme,
-and typically many of these will in fact be patterns rather than pure colors):
+On macOS, the following additional system colors are available.
+This first group contains all colors available in the HIToolbox library.
+(Note that in some cases the actual color values may depend on the
+current Appearance.)
.RS
.DS
systemActiveAreaFill
@@ -900,6 +901,7 @@ systemScrollBarDelimiterActive
systemScrollBarDelimiterInactive
systemSecondaryGroupBoxBackground
systemSecondaryHighlightColor
+systemSelectedTabTextColor
systemSheetBackground
systemSheetBackgroundOpaque
systemSheetBackgroundTransparent
@@ -925,7 +927,41 @@ systemWindowHeaderBackground
systemWindowHeaderInactiveText
.DE
.RE
+.
+The second group of MacOS colors below are based on Apple's "semantic"
+NScolors. On OSX 10.14 (Mojave) and later these colors change value
+when Dark Mode is enabled. However, the change is only observable
+when the Apple window manager is drawing to the screen. So the
+\fBwinfo rgb\fR command will return the color coordinates used in the
+standard Aqua mode, even if Dark Mode has been selected in the system
+preferences. The numbered systemWindowBackgroundColors are used in
+the \fBttk::notebook\fR and \fBttk::labelframe\fR widgets to provide a
+contrasting background. Each numbered color constrasts with its
+predecessor.
+.RS
+.DS
+systemControlAccentColor
+systemControlTextColor
+systemDisabledControlTextColor
+systemLabelColor
+systemLinkColor
+systemSelectedTextBackgroundColor
+systemSelectedTextColor
+systemTextBackgroundColor
+systemTextColor
+systemWindowBackgroundColor
+systemWindowBackgroundColor1
+systemWindowBackgroundColor2
+systemWindowBackgroundColor3
+systemWindowBackgroundColor4
+systemWindowBackgroundColor5
+systemWindowBackgroundColor6
+systemWindowBackgroundColor7
+.DE
+.RE
.TP
+
+
\fBWindows\fR
.
On Windows, the following additional system colors are available
diff --git a/doc/entry.n b/doc/entry.n
index abbf53d..9eea51b 100644
--- a/doc/entry.n
+++ b/doc/entry.n
@@ -404,14 +404,14 @@ way through the text appears at the left edge of the window.
This command shifts the view in the window left or right according to
\fInumber\fR and \fIwhat\fR.
\fINumber\fR must be an integer.
-\fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation
+\fIWhat\fR must be either \fBpages\fR or \fBunits\fR or an abbreviation
of one of these.
-If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by
-\fInumber\fR average-width characters on the display; if it is
-\fBpages\fR then the view adjusts by \fInumber\fR screenfuls.
-If \fInumber\fR is negative then characters farther to the left
-become visible; if it is positive then characters farther to the right
+If \fIwhat\fR is \fBpages\fR then the view adjusts by \fInumber\fR screenfuls.
+If \fInumber\fR is negative then characters farther to the left become
+visible; if it is positive then characters farther to the right
become visible.
+If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by
+\fInumber\fR average-width characters on the display.
.RE
.SH "DEFAULT BINDINGS"
.PP
@@ -449,9 +449,10 @@ insertion cursor in the entry without affecting the selection.
If any normal printing characters are typed in an entry, they are
inserted at the point of the insertion cursor.
.IP [7]
-The view in the entry can be adjusted by dragging with mouse button 2.
-If mouse button 2 is clicked without moving the mouse, the selection
-is copied into the entry at the position of the mouse cursor.
+The view in the entry can be adjusted by dragging with the middle
+mouse button (button 2, or button 3 in TkAqua). If the middle mouse
+button is clicked without moving the mouse, the selection is copied
+into the entry at the position of the mouse cursor.
.IP [8]
If the mouse is dragged out of the entry on the left or right sides
while button 1 is pressed, the entry will automatically scroll to
diff --git a/doc/event.n b/doc/event.n
index 5109794..f4eb426 100644
--- a/doc/event.n
+++ b/doc/event.n
@@ -100,7 +100,7 @@ Corresponds to the \fB%B\fR substitution for binding scripts.
.TP
\fB\-button\fI number\fR
\fINumber\fR must be an integer; it specifies the \fIdetail\fR field
-for a \fBButtonPress\fR or \fBButtonRelease\fR event, overriding
+for a \fBButton\fR or \fBButtonRelease\fR event, overriding
any button number provided in the base \fIevent\fR argument.
Corresponds to the \fB%b\fR substitution for binding scripts.
.TP
@@ -155,7 +155,7 @@ Corresponds to the \fB%h\fR substitution for binding scripts.
\fB\-keycode\fI number\fR
\fINumber\fR must be an integer; it specifies the \fIkeycode\fR
field for the event.
-Valid for \fBKeyPress\fR and \fBKeyRelease\fR events.
+Valid for \fBKey\fR and \fBKeyRelease\fR events.
Corresponds to the \fB%k\fR substitution for binding scripts.
.TP
\fB\-keysym\fI name\fR
@@ -163,7 +163,7 @@ Corresponds to the \fB%k\fR substitution for binding scripts.
\fBspace\fR, or \fBReturn\fR; its corresponding
keycode value is used as the \fIkeycode\fR field for event, overriding
any detail specified in the base \fIevent\fR argument.
-Valid for \fBKeyPress\fR and \fBKeyRelease\fR events.
+Valid for \fBKey\fR and \fBKeyRelease\fR events.
Corresponds to the \fB%K\fR substitution for binding scripts.
.TP
\fB\-mode\fI notify\fR
@@ -189,7 +189,7 @@ Corresponds to the \fB%p\fR substitution for binding scripts.
\fB\-root\fI window\fR
\fIWindow\fR must be either a window path name or an integer window
identifier; it specifies the \fIroot\fR field for the event.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
+Valid for \fBKey\fR, \fBKeyRelease\fR, \fBButton\fR,
\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR
events.
Corresponds to the \fB%R\fR substitution for binding scripts.
@@ -197,14 +197,14 @@ Corresponds to the \fB%R\fR substitution for binding scripts.
\fB\-rootx\fI coord\fR
\fICoord\fR must be a screen distance; it specifies the \fIx_root\fR
field for the event.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
+Valid for \fBKey\fR, \fBKeyRelease\fR, \fBButton\fR,
\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR
events. Corresponds to the \fB%X\fR substitution for binding scripts.
.TP
\fB\-rooty\fI coord\fR
\fICoord\fR must be a screen distance; it specifies the \fIy_root\fR
field for the event.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
+Valid for \fBKey\fR, \fBKeyRelease\fR, \fBButton\fR,
\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR
events.
Corresponds to the \fB%Y\fR substitution for binding scripts.
@@ -221,7 +221,7 @@ Corresponds to the \fB%#\fR substitution for binding scripts.
.TP
\fB\-state\fI state\fR
\fIState\fR specifies the \fIstate\fR field for the event.
-For \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
+For \fBKey\fR, \fBKeyRelease\fR, \fBButtons\fR,
\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR events
it must be an integer value.
For \fBVisibility\fR events it must be one of \fBVisibilityUnobscured\fR,
@@ -233,14 +233,15 @@ Corresponds to the \fB%s\fR substitution for binding scripts.
\fB\-subwindow\fI window\fR
\fIWindow\fR specifies the \fIsubwindow\fR field for the event, either
as a path name for a Tk widget or as an integer window identifier.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
+Valid for \fBKey\fR, \fBKeyRelease\fR, \fBButton\fR,
\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR events.
Similar to \fB%S\fR substitution for binding scripts.
.TP
\fB\-time\fI integer\fR
\fIInteger\fR must be an integer value; it specifies the \fItime\fR field
-for the event.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
+for the event. Additonally the special value \fBcurrent\fR is allowed,
+this value will be substituted by the current event time.
+Valid for \fBKey\fR, \fBKeyRelease\fR, \fBButton\fR,
\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, \fBMotion\fR,
and \fBProperty\fR events.
Corresponds to the \fB%t\fR substitution for binding scripts.
@@ -248,7 +249,7 @@ Corresponds to the \fB%t\fR substitution for binding scripts.
\fB\-warp\fI boolean\fR
\fIboolean\fR must be a boolean value; it specifies whether
the screen pointer should be warped as well.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
+Valid for \fBKey\fR, \fBKeyRelease\fR, \fBButton\fR,
\fBButtonRelease\fR, and \fBMotion\fR events. The pointer will
only warp to a window if it is mapped.
.TP
@@ -281,7 +282,7 @@ be processed in order but at the front of the queue.
\fB\-x\fI coord\fR
\fICoord\fR must be a screen distance; it specifies the \fIx\fR field
for the event.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
+Valid for \fBKey\fR, \fBKeyRelease\fR, \fBButton\fR,
\fBButtonRelease\fR, \fBMotion\fR, \fBEnter\fR, \fBLeave\fR,
\fBExpose\fR, \fBConfigure\fR, \fBGravity\fR, and \fBReparent\fR
events.
@@ -293,7 +294,7 @@ for binding scripts.
\fB\-y\fI coord\fR
\fICoord\fR must be a screen distance; it specifies the \fIy\fR
field for the event.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
+Valid for \fBKey\fR, \fBKeyRelease\fR, \fBButton\fR,
\fBButtonRelease\fR, \fBMotion\fR, \fBEnter\fR, \fBLeave\fR,
\fBExpose\fR, \fBConfigure\fR, \fBGravity\fR, and \fBReparent\fR
events.
@@ -567,7 +568,7 @@ Starting from the preceding example, if the following code is executed:
.PP
.CS
bind Entry <Control-y> {}
-\fBevent add\fR <<Paste>> <Key-F6>
+\fBevent add\fR <<Paste>> <F6>
.CE
.PP
the behavior will change such in two ways. First, the shadowed
diff --git a/doc/frame.n b/doc/frame.n
index 6aa412e..54e8e2f 100644
--- a/doc/frame.n
+++ b/doc/frame.n
@@ -25,6 +25,16 @@ except that its value may also be specified as an empty string.
In this case, the widget will display no background or border, and
no colors will be consumed from its colormap for its background
and border.
+.VS "8.7, TIP262"
+An empty background will disable drawing the background image.
+.OP \-backgroundimage backgroundImage BackgroundImage
+This specifies an image to display on the frame's background within
+the border of the frame (i.e., the image will be clipped by the
+frame's highlight ring and border, if either are present); subwidgets
+of the frame will be drawn on top. The image must have been created
+with the \fBimage create\fR command. If specified as the empty string,
+no image will be displayed.
+.VE "8.7, TIP262"
.OP \-class class Class
Specifies a class for the window.
This class will be used when querying the option database for
@@ -62,6 +72,15 @@ sets the total height of the frame, any \fB\-borderwidth\fR or similar is
not added. Normally \fB\-height\fR should not be used if a propagating
geometry manager, such as \fBgrid\fR or \fBpack\fR, is used within the
frame since the geometry manager will override the height of the frame.
+.OP \-tile tile Tile
+.VS "8.7, TIP262"
+This specifies how to draw the background image (see
+\fB\-backgroundimage\fR) on the frame.
+If true (according to \fBTcl_GetBoolean\fR), the image will be tiled
+to fill the whole frame, with the origin of the first copy of the
+image being the top left of the interior of the frame.
+If false (the default), the image will be centered within the frame.
+.VE "8.7, TIP262"
.OP \-visual visual Visual
Specifies visual information for the new window in any of the
forms accepted by \fBTk_GetVisual\fR.
@@ -91,7 +110,7 @@ path name of the new window.
.PP
A frame is a simple widget. Its primary purpose is to act as a
spacer or container for complex window layouts. The only features
-of a frame are its background color and an optional 3-D border to make the
+of a frame are its background and an optional 3-D border to make the
frame appear raised or sunken.
.SH "WIDGET COMMAND"
.PP
@@ -99,21 +118,25 @@ The \fBframe\fR command creates a new Tcl command whose
name is the same as the path name of the frame's window. This
command may be used to invoke various
operations on the widget. It has the following general form:
+.PP
.CS
\fIpathName option \fR?\fIarg arg ...\fR?
.CE
+.PP
\fIPathName\fR is the name of the command, which is the same as
the frame widget's path name. \fIOption\fR and the \fIarg\fRs
determine the exact behavior of the command. The following
commands are possible for frame widgets:
.TP
\fIpathName \fBcget\fR \fIoption\fR
+.
Returns the current value of the configuration option given
by \fIoption\fR.
\fIOption\fR may have any of the values accepted by the \fBframe\fR
command.
.TP
\fIpathName \fBconfigure\fR ?\fIoption\fR? \fI?value option value ...\fR?
+.
Query or modify the configuration options of the widget.
If no \fIoption\fR is specified, returns a list describing all of
the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
diff --git a/doc/grid.n b/doc/grid.n
index ea72db1..3da8cfb 100644
--- a/doc/grid.n
+++ b/doc/grid.n
@@ -177,7 +177,7 @@ If a slave's cell is larger than its requested dimensions, this
option may be used to position (or stretch) the slave within its cell.
\fIStyle\fR is a string that contains zero or more of the characters
\fBn\fR, \fBs\fR, \fBe\fR or \fBw\fR.
-The string can optionally contains spaces or
+The string can optionally contain spaces or
commas, but they are ignored. Each letter refers to a side (north, south,
east, or west) that the slave will
.QW stick
@@ -457,7 +457,7 @@ widths:
.PP
.CS
button .b \-text "Foo"
-entry .e \-variable foo
+entry .e \-textvariable foo ; set foo "Hello World!"
label .l \-text "This is a fairly long piece of text"
\fBgrid\fR .b .e .l \-sticky ew
diff --git a/doc/keysyms.n b/doc/keysyms.n
index 512c1a6..c4c02fd 100644
--- a/doc/keysyms.n
+++ b/doc/keysyms.n
@@ -18,908 +18,2074 @@ keysyms that will be recognized by Tk. Note that not all keysyms will
be valid on all platforms, and some keysyms are also available on
platforms that have a different native name for that key.
For example, on Unix systems, the presence
-of a particular keysym is dependant on the configuration of the
+of a particular keysym is dependent on the configuration of the
keyboard modifier map. This list shows keysyms along with their
decimal and hexadecimal values.
.PP
.CS
-space 32 0x0020
-exclam 33 0x0021
-quotedbl 34 0x0022
-numbersign 35 0x0023
-dollar 36 0x0024
-percent 37 0x0025
-ampersand 38 0x0026
-quoteright 39 0x0027
-parenleft 40 0x0028
-parenright 41 0x0029
-asterisk 42 0x002a
-plus 43 0x002b
-comma 44 0x002c
-minus 45 0x002d
-period 46 0x002e
-slash 47 0x002f
-0 48 0x0030
-1 49 0x0031
-2 50 0x0032
-3 51 0x0033
-4 52 0x0034
-5 53 0x0035
-6 54 0x0036
-7 55 0x0037
-8 56 0x0038
-9 57 0x0039
-colon 58 0x003a
-semicolon 59 0x003b
-less 60 0x003c
-equal 61 0x003d
-greater 62 0x003e
-question 63 0x003f
-at 64 0x0040
-A 65 0x0041
-B 66 0x0042
-C 67 0x0043
-D 68 0x0044
-E 69 0x0045
-F 70 0x0046
-G 71 0x0047
-H 72 0x0048
-I 73 0x0049
-J 74 0x004a
-K 75 0x004b
-L 76 0x004c
-M 77 0x004d
-N 78 0x004e
-O 79 0x004f
-P 80 0x0050
-Q 81 0x0051
-R 82 0x0052
-S 83 0x0053
-T 84 0x0054
-U 85 0x0055
-V 86 0x0056
-W 87 0x0057
-X 88 0x0058
-Y 89 0x0059
-Z 90 0x005a
-bracketleft 91 0x005b
-backslash 92 0x005c
-bracketright 93 0x005d
-asciicircum 94 0x005e
-underscore 95 0x005f
-quoteleft 96 0x0060
-a 97 0x0061
-b 98 0x0062
-c 99 0x0063
-d 100 0x0064
-e 101 0x0065
-f 102 0x0066
-g 103 0x0067
-h 104 0x0068
-i 105 0x0069
-j 106 0x006a
-k 107 0x006b
-l 108 0x006c
-m 109 0x006d
-n 110 0x006e
-o 111 0x006f
-p 112 0x0070
-q 113 0x0071
-r 114 0x0072
-s 115 0x0073
-t 116 0x0074
-u 117 0x0075
-v 118 0x0076
-w 119 0x0077
-x 120 0x0078
-y 121 0x0079
-z 122 0x007a
-braceleft 123 0x007b
-bar 124 0x007c
-braceright 125 0x007d
-asciitilde 126 0x007e
-nobreakspace 160 0x00a0
-exclamdown 161 0x00a1
-cent 162 0x00a2
-sterling 163 0x00a3
-currency 164 0x00a4
-yen 165 0x00a5
-brokenbar 166 0x00a6
-section 167 0x00a7
-diaeresis 168 0x00a8
-copyright 169 0x00a9
-ordfeminine 170 0x00aa
-guillemotleft 171 0x00ab
-notsign 172 0x00ac
-hyphen 173 0x00ad
-registered 174 0x00ae
-macron 175 0x00af
-degree 176 0x00b0
-plusminus 177 0x00b1
-twosuperior 178 0x00b2
-threesuperior 179 0x00b3
-acute 180 0x00b4
-mu 181 0x00b5
-paragraph 182 0x00b6
-periodcentered 183 0x00b7
-cedilla 184 0x00b8
-onesuperior 185 0x00b9
-masculine 186 0x00ba
-guillemotright 187 0x00bb
-onequarter 188 0x00bc
-onehalf 189 0x00bd
-threequarters 190 0x00be
-questiondown 191 0x00bf
-Agrave 192 0x00c0
-Aacute 193 0x00c1
-Acircumflex 194 0x00c2
-Atilde 195 0x00c3
-Adiaeresis 196 0x00c4
-Aring 197 0x00c5
-AE 198 0x00c6
-Ccedilla 199 0x00c7
-Egrave 200 0x00c8
-Eacute 201 0x00c9
-Ecircumflex 202 0x00ca
-Ediaeresis 203 0x00cb
-Igrave 204 0x00cc
-Iacute 205 0x00cd
-Icircumflex 206 0x00ce
-Idiaeresis 207 0x00cf
-Eth 208 0x00d0
-Ntilde 209 0x00d1
-Ograve 210 0x00d2
-Oacute 211 0x00d3
-Ocircumflex 212 0x00d4
-Otilde 213 0x00d5
-Odiaeresis 214 0x00d6
-multiply 215 0x00d7
-Ooblique 216 0x00d8
-Ugrave 217 0x00d9
-Uacute 218 0x00da
-Ucircumflex 219 0x00db
-Udiaeresis 220 0x00dc
-Yacute 221 0x00dd
-Thorn 222 0x00de
-ssharp 223 0x00df
-agrave 224 0x00e0
-aacute 225 0x00e1
-acircumflex 226 0x00e2
-atilde 227 0x00e3
-adiaeresis 228 0x00e4
-aring 229 0x00e5
-ae 230 0x00e6
-ccedilla 231 0x00e7
-egrave 232 0x00e8
-eacute 233 0x00e9
-ecircumflex 234 0x00ea
-ediaeresis 235 0x00eb
-igrave 236 0x00ec
-iacute 237 0x00ed
-icircumflex 238 0x00ee
-idiaeresis 239 0x00ef
-eth 240 0x00f0
-ntilde 241 0x00f1
-ograve 242 0x00f2
-oacute 243 0x00f3
-ocircumflex 244 0x00f4
-otilde 245 0x00f5
-odiaeresis 246 0x00f6
-division 247 0x00f7
-oslash 248 0x00f8
-ugrave 249 0x00f9
-uacute 250 0x00fa
-ucircumflex 251 0x00fb
-udiaeresis 252 0x00fc
-yacute 253 0x00fd
-thorn 254 0x00fe
-ydiaeresis 255 0x00ff
-Aogonek 417 0x01a1
-breve 418 0x01a2
-Lstroke 419 0x01a3
-Lcaron 421 0x01a5
-Sacute 422 0x01a6
-Scaron 425 0x01a9
-Scedilla 426 0x01aa
-Tcaron 427 0x01ab
-Zacute 428 0x01ac
+space 32 0x20
+exclam 33 0x21
+quotedbl 34 0x22
+numbersign 35 0x23
+dollar 36 0x24
+percent 37 0x25
+ampersand 38 0x26
+apostrophe 39 0x27
+parenleft 40 0x28
+parenright 41 0x29
+asterisk 42 0x2A
+plus 43 0x2B
+comma 44 0x2C
+minus 45 0x2D
+period 46 0x2E
+slash 47 0x2F
+0 48 0x30
+1 49 0x31
+2 50 0x32
+3 51 0x33
+4 52 0x34
+5 53 0x35
+6 54 0x36
+7 55 0x37
+8 56 0x38
+9 57 0x39
+colon 58 0x3A
+semicolon 59 0x3B
+less 60 0x3C
+equal 61 0x3D
+greater 62 0x3E
+question 63 0x3F
+at 64 0x40
+A 65 0x41
+B 66 0x42
+C 67 0x43
+D 68 0x44
+E 69 0x45
+F 70 0x46
+G 71 0x47
+H 72 0x48
+I 73 0x49
+J 74 0x4A
+K 75 0x4B
+L 76 0x4C
+M 77 0x4D
+N 78 0x4E
+O 79 0x4F
+P 80 0x50
+Q 81 0x51
+R 82 0x52
+S 83 0x53
+T 84 0x54
+U 85 0x55
+V 86 0x56
+W 87 0x57
+X 88 0x58
+Y 89 0x59
+Z 90 0x5A
+bracketleft 91 0x5B
+backslash 92 0x5C
+bracketright 93 0x5D
+asciicircum 94 0x5E
+underscore 95 0x5F
+grave 96 0x60
+a 97 0x61
+b 98 0x62
+c 99 0x63
+d 100 0x64
+e 101 0x65
+f 102 0x66
+g 103 0x67
+h 104 0x68
+i 105 0x69
+j 106 0x6A
+k 107 0x6B
+l 108 0x6C
+m 109 0x6D
+n 110 0x6E
+o 111 0x6F
+p 112 0x70
+q 113 0x71
+r 114 0x72
+s 115 0x73
+t 116 0x74
+u 117 0x75
+v 118 0x76
+w 119 0x77
+x 120 0x78
+y 121 0x79
+z 122 0x7A
+braceleft 123 0x7B
+bar 124 0x7C
+braceright 125 0x7D
+asciitilde 126 0x7E
+nobreakspace 160 0xA0
+exclamdown 161 0xA1
+cent 162 0xA2
+sterling 163 0xA3
+currency 164 0xA4
+yen 165 0xA5
+brokenbar 166 0xA6
+section 167 0xA7
+diaeresis 168 0xA8
+copyright 169 0xA9
+ordfeminine 170 0xAA
+guillemotleft 171 0xAB
+notsign 172 0xAC
+hyphen 173 0xAD
+registered 174 0xAE
+macron 175 0xAF
+degree 176 0xB0
+plusminus 177 0xB1
+twosuperior 178 0xB2
+threesuperior 179 0xB3
+acute 180 0xB4
+mu 181 0xB5
+paragraph 182 0xB6
+periodcentered 183 0xB7
+cedilla 184 0xB8
+onesuperior 185 0xB9
+masculine 186 0xBA
+guillemotright 187 0xBB
+onequarter 188 0xBC
+onehalf 189 0xBD
+threequarters 190 0xBE
+questiondown 191 0xBF
+Agrave 192 0xC0
+Aacute 193 0xC1
+Acircumflex 194 0xC2
+Atilde 195 0xC3
+Adiaeresis 196 0xC4
+Aring 197 0xC5
+AE 198 0xC6
+Ccedilla 199 0xC7
+Egrave 200 0xC8
+Eacute 201 0xC9
+Ecircumflex 202 0xCA
+Ediaeresis 203 0xCB
+Igrave 204 0xCC
+Iacute 205 0xCD
+Icircumflex 206 0xCE
+Idiaeresis 207 0xCF
+ETH 208 0xD0
+Ntilde 209 0xD1
+Ograve 210 0xD2
+Oacute 211 0xD3
+Ocircumflex 212 0xD4
+Otilde 213 0xD5
+Odiaeresis 214 0xD6
+multiply 215 0xD7
+Oslash 216 0xD8
+Ugrave 217 0xD9
+Uacute 218 0xDA
+Ucircumflex 219 0xDB
+Udiaeresis 220 0xDC
+Yacute 221 0xDD
+THORN 222 0xDE
+ssharp 223 0xDF
+agrave 224 0xE0
+aacute 225 0xE1
+acircumflex 226 0xE2
+atilde 227 0xE3
+adiaeresis 228 0xE4
+aring 229 0xE5
+ae 230 0xE6
+ccedilla 231 0xE7
+egrave 232 0xE8
+eacute 233 0xE9
+ecircumflex 234 0xEA
+ediaeresis 235 0xEB
+igrave 236 0xEC
+iacute 237 0xED
+icircumflex 238 0xEE
+idiaeresis 239 0xEF
+eth 240 0xF0
+ntilde 241 0xF1
+ograve 242 0xF2
+oacute 243 0xF3
+ocircumflex 244 0xF4
+otilde 245 0xF5
+odiaeresis 246 0xF6
+division 247 0xF7
+oslash 248 0xF8
+ugrave 249 0xF9
+uacute 250 0xFA
+ucircumflex 251 0xFB
+udiaeresis 252 0xFC
+yacute 253 0xFD
+thorn 254 0xFE
+ydiaeresis 255 0xFF
+Aogonek 417 0x1A1
+breve 418 0x1A2
+Lstroke 419 0x1A3
+Lcaron 421 0x1A5
+Sacute 422 0x1A6
+Scaron 425 0x1A9
+Scedilla 426 0x1AA
+Tcaron 427 0x1AB
+Zacute 428 0x1AC
.CE
.CS
-Zcaron 430 0x01ae
-Zabovedot 431 0x01af
-aogonek 433 0x01b1
-ogonek 434 0x01b2
-lstroke 435 0x01b3
-lcaron 437 0x01b5
-sacute 438 0x01b6
-caron 439 0x01b7
-scaron 441 0x01b9
-scedilla 442 0x01ba
-tcaron 443 0x01bb
-zacute 444 0x01bc
-doubleacute 445 0x01bd
-zcaron 446 0x01be
-zabovedot 447 0x01bf
-Racute 448 0x01c0
-Abreve 451 0x01c3
-Cacute 454 0x01c6
-Ccaron 456 0x01c8
-Eogonek 458 0x01ca
-Ecaron 460 0x01cc
-Dcaron 463 0x01cf
-Nacute 465 0x01d1
-Ncaron 466 0x01d2
-Odoubleacute 469 0x01d5
-Rcaron 472 0x01d8
-Uring 473 0x01d9
-Udoubleacute 475 0x01db
-Tcedilla 478 0x01de
-racute 480 0x01e0
-abreve 483 0x01e3
-cacute 486 0x01e6
-ccaron 488 0x01e8
-eogonek 490 0x01ea
-ecaron 492 0x01ec
-dcaron 495 0x01ef
-nacute 497 0x01f1
-ncaron 498 0x01f2
-odoubleacute 501 0x01f5
-rcaron 504 0x01f8
-uring 505 0x01f9
-udoubleacute 507 0x01fb
-tcedilla 510 0x01fe
-abovedot 511 0x01ff
-Hstroke 673 0x02a1
-Hcircumflex 678 0x02a6
-Iabovedot 681 0x02a9
-Gbreve 683 0x02ab
-Jcircumflex 684 0x02ac
-hstroke 689 0x02b1
-hcircumflex 694 0x02b6
-idotless 697 0x02b9
-gbreve 699 0x02bb
-jcircumflex 700 0x02bc
-Cabovedot 709 0x02c5
-Ccircumflex 710 0x02c6
-Gabovedot 725 0x02d5
-Gcircumflex 728 0x02d8
-Ubreve 733 0x02dd
-Scircumflex 734 0x02de
-cabovedot 741 0x02e5
-ccircumflex 742 0x02e6
-gabovedot 757 0x02f5
-gcircumflex 760 0x02f8
-ubreve 765 0x02fd
-scircumflex 766 0x02fe
-kappa 930 0x03a2
-Rcedilla 931 0x03a3
-Itilde 933 0x03a5
-Lcedilla 934 0x03a6
-Emacron 938 0x03aa
-Gcedilla 939 0x03ab
-Tslash 940 0x03ac
-rcedilla 947 0x03b3
-itilde 949 0x03b5
-lcedilla 950 0x03b6
-emacron 954 0x03ba
-gacute 955 0x03bb
-tslash 956 0x03bc
-ENG 957 0x03bd
-eng 959 0x03bf
-Amacron 960 0x03c0
-Iogonek 967 0x03c7
-Eabovedot 972 0x03cc
-Imacron 975 0x03cf
-Ncedilla 977 0x03d1
-Omacron 978 0x03d2
-Kcedilla 979 0x03d3
-Uogonek 985 0x03d9
-Utilde 989 0x03dd
-Umacron 990 0x03de
-amacron 992 0x03e0
-iogonek 999 0x03e7
-eabovedot 1004 0x03ec
-imacron 1007 0x03ef
-ncedilla 1009 0x03f1
-omacron 1010 0x03f2
-kcedilla 1011 0x03f3
-uogonek 1017 0x03f9
-utilde 1021 0x03fd
-umacron 1022 0x03fe
-overline 1150 0x047e
-kana_fullstop 1185 0x04a1
-kana_openingbracket 1186 0x04a2
-kana_closingbracket 1187 0x04a3
-kana_comma 1188 0x04a4
-kana_middledot 1189 0x04a5
-kana_WO 1190 0x04a6
-kana_a 1191 0x04a7
-kana_i 1192 0x04a8
-kana_u 1193 0x04a9
-kana_e 1194 0x04aa
-kana_o 1195 0x04ab
-kana_ya 1196 0x04ac
-kana_yu 1197 0x04ad
-kana_yo 1198 0x04ae
-kana_tu 1199 0x04af
-prolongedsound 1200 0x04b0
-kana_A 1201 0x04b1
-kana_I 1202 0x04b2
-kana_U 1203 0x04b3
-kana_E 1204 0x04b4
-kana_O 1205 0x04b5
-kana_KA 1206 0x04b6
-kana_KI 1207 0x04b7
-kana_KU 1208 0x04b8
-kana_KE 1209 0x04b9
-kana_KO 1210 0x04ba
-kana_SA 1211 0x04bb
-kana_SHI 1212 0x04bc
-kana_SU 1213 0x04bd
-kana_SE 1214 0x04be
-kana_SO 1215 0x04bf
-kana_TA 1216 0x04c0
-kana_TI 1217 0x04c1
-kana_TU 1218 0x04c2
-kana_TE 1219 0x04c3
-kana_TO 1220 0x04c4
-kana_NA 1221 0x04c5
-kana_NI 1222 0x04c6
-kana_NU 1223 0x04c7
-kana_NE 1224 0x04c8
-kana_NO 1225 0x04c9
-kana_HA 1226 0x04ca
-kana_HI 1227 0x04cb
-kana_HU 1228 0x04cc
-kana_HE 1229 0x04cd
-kana_HO 1230 0x04ce
-kana_MA 1231 0x04cf
-kana_MI 1232 0x04d0
-kana_MU 1233 0x04d1
-kana_ME 1234 0x04d2
-kana_MO 1235 0x04d3
-kana_YA 1236 0x04d4
-kana_YU 1237 0x04d5
-kana_YO 1238 0x04d6
-kana_RA 1239 0x04d7
-kana_RI 1240 0x04d8
-kana_RU 1241 0x04d9
-kana_RE 1242 0x04da
-kana_RO 1243 0x04db
-kana_WA 1244 0x04dc
-kana_N 1245 0x04dd
-voicedsound 1246 0x04de
-semivoicedsound 1247 0x04df
-Arabic_comma 1452 0x05ac
-Arabic_semicolon 1467 0x05bb
-Arabic_question_mark 1471 0x05bf
-Arabic_hamza 1473 0x05c1
-Arabic_maddaonalef 1474 0x05c2
-Arabic_hamzaonalef 1475 0x05c3
-Arabic_hamzaonwaw 1476 0x05c4
-Arabic_hamzaunderalef 1477 0x05c5
-Arabic_hamzaonyeh 1478 0x05c6
-Arabic_alef 1479 0x05c7
-Arabic_beh 1480 0x05c8
-Arabic_tehmarbuta 1481 0x05c9
-Arabic_teh 1482 0x05ca
-Arabic_theh 1483 0x05cb
-Arabic_jeem 1484 0x05cc
-Arabic_hah 1485 0x05cd
-Arabic_khah 1486 0x05ce
-Arabic_dal 1487 0x05cf
-Arabic_thal 1488 0x05d0
-Arabic_ra 1489 0x05d1
-Arabic_zain 1490 0x05d2
-Arabic_seen 1491 0x05d3
-Arabic_sheen 1492 0x05d4
-Arabic_sad 1493 0x05d5
-Arabic_dad 1494 0x05d6
-Arabic_tah 1495 0x05d7
-Arabic_zah 1496 0x05d8
-Arabic_ain 1497 0x05d9
-Arabic_ghain 1498 0x05da
-Arabic_tatweel 1504 0x05e0
-Arabic_feh 1505 0x05e1
-Arabic_qaf 1506 0x05e2
-Arabic_kaf 1507 0x05e3
-Arabic_lam 1508 0x05e4
-Arabic_meem 1509 0x05e5
+Zcaron 430 0x1AE
+Zabovedot 431 0x1AF
+aogonek 433 0x1B1
+ogonek 434 0x1B2
+lstroke 435 0x1B3
+lcaron 437 0x1B5
+sacute 438 0x1B6
+caron 439 0x1B7
+scaron 441 0x1B9
+scedilla 442 0x1BA
+tcaron 443 0x1BB
+zacute 444 0x1BC
+doubleacute 445 0x1BD
+zcaron 446 0x1BE
+zabovedot 447 0x1BF
+Racute 448 0x1C0
+Abreve 451 0x1C3
+Lacute 453 0x1C5
+Cacute 454 0x1C6
+Ccaron 456 0x1C8
+Eogonek 458 0x1CA
+Ecaron 460 0x1CC
+Dcaron 463 0x1CF
+Dstroke 464 0x1D0
+Nacute 465 0x1D1
+Ncaron 466 0x1D2
+Odoubleacute 469 0x1D5
+Rcaron 472 0x1D8
+Uring 473 0x1D9
+Udoubleacute 475 0x1DB
+Tcedilla 478 0x1DE
+racute 480 0x1E0
+abreve 483 0x1E3
+lacute 485 0x1E5
+cacute 486 0x1E6
+ccaron 488 0x1E8
+eogonek 490 0x1EA
+ecaron 492 0x1EC
+dcaron 495 0x1EF
+dstroke 496 0x1F0
+nacute 497 0x1F1
+ncaron 498 0x1F2
+odoubleacute 501 0x1F5
+rcaron 504 0x1F8
+uring 505 0x1F9
+udoubleacute 507 0x1FB
+tcedilla 510 0x1FE
+abovedot 511 0x1FF
+Hstroke 673 0x2A1
+Hcircumflex 678 0x2A6
+Iabovedot 681 0x2A9
+Gbreve 683 0x2AB
+Jcircumflex 684 0x2AC
+hstroke 689 0x2B1
+hcircumflex 694 0x2B6
+idotless 697 0x2B9
+gbreve 699 0x2BB
+jcircumflex 700 0x2BC
+Cabovedot 709 0x2C5
+Ccircumflex 710 0x2C6
+Gabovedot 725 0x2D5
+Gcircumflex 728 0x2D8
+Ubreve 733 0x2DD
+Scircumflex 734 0x2DE
+cabovedot 741 0x2E5
+ccircumflex 742 0x2E6
+gabovedot 757 0x2F5
+gcircumflex 760 0x2F8
+ubreve 765 0x2FD
+scircumflex 766 0x2FE
+kra 930 0x3A2
+Rcedilla 931 0x3A3
+Itilde 933 0x3A5
+Lcedilla 934 0x3A6
+Emacron 938 0x3AA
+Gcedilla 939 0x3AB
+Tslash 940 0x3AC
+rcedilla 947 0x3B3
+itilde 949 0x3B5
+lcedilla 950 0x3B6
+emacron 954 0x3BA
+gcedilla 955 0x3BB
+tslash 956 0x3BC
+ENG 957 0x3BD
+eng 959 0x3BF
+Amacron 960 0x3C0
+Iogonek 967 0x3C7
+Eabovedot 972 0x3CC
+Imacron 975 0x3CF
+Ncedilla 977 0x3D1
+Omacron 978 0x3D2
+Kcedilla 979 0x3D3
+Uogonek 985 0x3D9
+Utilde 989 0x3DD
+Umacron 990 0x3DE
+amacron 992 0x3E0
+iogonek 999 0x3E7
+eabovedot 1004 0x3EC
+imacron 1007 0x3EF
+ncedilla 1009 0x3F1
+omacron 1010 0x3F2
+kcedilla 1011 0x3F3
+uogonek 1017 0x3F9
+utilde 1021 0x3FD
+umacron 1022 0x3FE
+overline 1150 0x47E
+kana_fullstop 1185 0x4A1
+kana_openingbracket 1186 0x4A2
+kana_closingbracket 1187 0x4A3
+kana_comma 1188 0x4A4
+kana_conjunctive 1189 0x4A5
+kana_WO 1190 0x4A6
+kana_a 1191 0x4A7
+kana_i 1192 0x4A8
+kana_u 1193 0x4A9
+kana_e 1194 0x4AA
+kana_o 1195 0x4AB
+kana_ya 1196 0x4AC
+kana_yu 1197 0x4AD
+kana_yo 1198 0x4AE
+kana_tsu 1199 0x4AF
+prolongedsound 1200 0x4B0
+kana_A 1201 0x4B1
+kana_I 1202 0x4B2
+kana_U 1203 0x4B3
+kana_E 1204 0x4B4
+kana_O 1205 0x4B5
+kana_KA 1206 0x4B6
+kana_KI 1207 0x4B7
+kana_KU 1208 0x4B8
+kana_KE 1209 0x4B9
+kana_KO 1210 0x4BA
+kana_SA 1211 0x4BB
+kana_SHI 1212 0x4BC
+kana_SU 1213 0x4BD
+kana_SE 1214 0x4BE
+kana_SO 1215 0x4BF
+kana_TA 1216 0x4C0
+kana_CHI 1217 0x4C1
+kana_TSU 1218 0x4C2
+kana_TE 1219 0x4C3
+kana_TO 1220 0x4C4
+kana_NA 1221 0x4C5
+kana_NI 1222 0x4C6
+kana_NU 1223 0x4C7
+kana_NE 1224 0x4C8
+kana_NO 1225 0x4C9
+kana_HA 1226 0x4CA
+kana_HI 1227 0x4CB
+kana_FU 1228 0x4CC
+kana_HE 1229 0x4CD
+kana_HO 1230 0x4CE
+kana_MA 1231 0x4CF
+kana_MI 1232 0x4D0
+kana_MU 1233 0x4D1
+kana_ME 1234 0x4D2
+kana_MO 1235 0x4D3
+kana_YA 1236 0x4D4
+kana_YU 1237 0x4D5
+kana_YO 1238 0x4D6
+kana_RA 1239 0x4D7
+kana_RI 1240 0x4D8
+kana_RU 1241 0x4D9
+kana_RE 1242 0x4DA
+kana_RO 1243 0x4DB
+kana_WA 1244 0x4DC
+kana_N 1245 0x4DD
+voicedsound 1246 0x4DE
+semivoicedsound 1247 0x4DF
+Arabic_comma 1452 0x5AC
+Arabic_semicolon 1467 0x5BB
+Arabic_question_mark 1471 0x5BF
+Arabic_hamza 1473 0x5C1
+Arabic_maddaonalef 1474 0x5C2
+Arabic_hamzaonalef 1475 0x5C3
+Arabic_hamzaonwaw 1476 0x5C4
+Arabic_hamzaunderalef 1477 0x5C5
+Arabic_hamzaonyeh 1478 0x5C6
+Arabic_alef 1479 0x5C7
+Arabic_beh 1480 0x5C8
+Arabic_tehmarbuta 1481 0x5C9
+Arabic_teh 1482 0x5CA
+Arabic_theh 1483 0x5CB
+Arabic_jeem 1484 0x5CC
+Arabic_hah 1485 0x5CD
+Arabic_khah 1486 0x5CE
+Arabic_dal 1487 0x5CF
+Arabic_thal 1488 0x5D0
+Arabic_ra 1489 0x5D1
+Arabic_zain 1490 0x5D2
+Arabic_seen 1491 0x5D3
+Arabic_sheen 1492 0x5D4
+Arabic_sad 1493 0x5D5
+Arabic_dad 1494 0x5D6
+Arabic_tah 1495 0x5D7
+Arabic_zah 1496 0x5D8
+Arabic_ain 1497 0x5D9
+Arabic_ghain 1498 0x5DA
+Arabic_tatweel 1504 0x5E0
+Arabic_feh 1505 0x5E1
+Arabic_qaf 1506 0x5E2
+Arabic_kaf 1507 0x5E3
+Arabic_lam 1508 0x5E4
+Arabic_meem 1509 0x5E5
.CE
.CS
-Arabic_noon 1510 0x05e6
-Arabic_heh 1511 0x05e7
-Arabic_waw 1512 0x05e8
-Arabic_alefmaksura 1513 0x05e9
-Arabic_yeh 1514 0x05ea
-Arabic_fathatan 1515 0x05eb
-Arabic_dammatan 1516 0x05ec
-Arabic_kasratan 1517 0x05ed
-Arabic_fatha 1518 0x05ee
-Arabic_damma 1519 0x05ef
-Arabic_kasra 1520 0x05f0
-Arabic_shadda 1521 0x05f1
-Arabic_sukun 1522 0x05f2
-Serbian_dje 1697 0x06a1
-Macedonia_gje 1698 0x06a2
-Cyrillic_io 1699 0x06a3
-Ukranian_je 1700 0x06a4
-Macedonia_dse 1701 0x06a5
-Ukranian_i 1702 0x06a6
-Ukranian_yi 1703 0x06a7
-Serbian_je 1704 0x06a8
-Serbian_lje 1705 0x06a9
-Serbian_nje 1706 0x06aa
-Serbian_tshe 1707 0x06ab
-Macedonia_kje 1708 0x06ac
-Byelorussian_shortu 1710 0x06ae
-Serbian_dze 1711 0x06af
-numerosign 1712 0x06b0
-Serbian_DJE 1713 0x06b1
-Macedonia_GJE 1714 0x06b2
-Cyrillic_IO 1715 0x06b3
-Ukranian_JE 1716 0x06b4
-Macedonia_DSE 1717 0x06b5
-Ukranian_I 1718 0x06b6
-Ukranian_YI 1719 0x06b7
-Serbian_JE 1720 0x06b8
-Serbian_LJE 1721 0x06b9
-Serbian_NJE 1722 0x06ba
-Serbian_TSHE 1723 0x06bb
-Macedonia_KJE 1724 0x06bc
-Byelorussian_SHORTU 1726 0x06be
-Serbian_DZE 1727 0x06bf
-Cyrillic_yu 1728 0x06c0
-Cyrillic_a 1729 0x06c1
-Cyrillic_be 1730 0x06c2
-Cyrillic_tse 1731 0x06c3
-Cyrillic_de 1732 0x06c4
-Cyrillic_ie 1733 0x06c5
-Cyrillic_ef 1734 0x06c6
-Cyrillic_ghe 1735 0x06c7
-Cyrillic_ha 1736 0x06c8
-Cyrillic_i 1737 0x06c9
-Cyrillic_shorti 1738 0x06ca
-Cyrillic_ka 1739 0x06cb
-Cyrillic_el 1740 0x06cc
-Cyrillic_em 1741 0x06cd
-Cyrillic_en 1742 0x06ce
-Cyrillic_o 1743 0x06cf
-Cyrillic_pe 1744 0x06d0
-Cyrillic_ya 1745 0x06d1
-Cyrillic_er 1746 0x06d2
-Cyrillic_es 1747 0x06d3
-Cyrillic_te 1748 0x06d4
-Cyrillic_u 1749 0x06d5
-Cyrillic_zhe 1750 0x06d6
-Cyrillic_ve 1751 0x06d7
-Cyrillic_softsign 1752 0x06d8
-Cyrillic_yeru 1753 0x06d9
-Cyrillic_ze 1754 0x06da
-Cyrillic_sha 1755 0x06db
-Cyrillic_e 1756 0x06dc
-Cyrillic_shcha 1757 0x06dd
-Cyrillic_che 1758 0x06de
-Cyrillic_hardsign 1759 0x06df
-Cyrillic_YU 1760 0x06e0
-Cyrillic_A 1761 0x06e1
-Cyrillic_BE 1762 0x06e2
-Cyrillic_TSE 1763 0x06e3
-Cyrillic_DE 1764 0x06e4
-Cyrillic_IE 1765 0x06e5
-Cyrillic_EF 1766 0x06e6
-Cyrillic_GHE 1767 0x06e7
-Cyrillic_HA 1768 0x06e8
-Cyrillic_I 1769 0x06e9
-Cyrillic_SHORTI 1770 0x06ea
-Cyrillic_KA 1771 0x06eb
-Cyrillic_EL 1772 0x06ec
-Cyrillic_EM 1773 0x06ed
-Cyrillic_EN 1774 0x06ee
-Cyrillic_O 1775 0x06ef
-Cyrillic_PE 1776 0x06f0
-Cyrillic_YA 1777 0x06f1
-Cyrillic_ER 1778 0x06f2
-Cyrillic_ES 1779 0x06f3
-Cyrillic_TE 1780 0x06f4
-Cyrillic_U 1781 0x06f5
-Cyrillic_ZHE 1782 0x06f6
-Cyrillic_VE 1783 0x06f7
-Cyrillic_SOFTSIGN 1784 0x06f8
-Cyrillic_YERU 1785 0x06f9
-Cyrillic_ZE 1786 0x06fa
-Cyrillic_SHA 1787 0x06fb
-Cyrillic_E 1788 0x06fc
-Cyrillic_SHCHA 1789 0x06fd
-Cyrillic_CHE 1790 0x06fe
-Cyrillic_HARDSIGN 1791 0x06ff
-Greek_ALPHAaccent 1953 0x07a1
-Greek_EPSILONaccent 1954 0x07a2
-Greek_ETAaccent 1955 0x07a3
-Greek_IOTAaccent 1956 0x07a4
-Greek_IOTAdiaeresis 1957 0x07a5
-Greek_IOTAaccentdiaeresis 1958 0x07a6
-Greek_OMICRONaccent 1959 0x07a7
-Greek_UPSILONaccent 1960 0x07a8
-Greek_UPSILONdieresis 1961 0x07a9
-Greek_UPSILONaccentdieresis 1962 0x07aa
-Greek_OMEGAaccent 1963 0x07ab
-Greek_alphaaccent 1969 0x07b1
-Greek_epsilonaccent 1970 0x07b2
-Greek_etaaccent 1971 0x07b3
-Greek_iotaaccent 1972 0x07b4
-Greek_iotadieresis 1973 0x07b5
-Greek_iotaaccentdieresis 1974 0x07b6
-Greek_omicronaccent 1975 0x07b7
-Greek_upsilonaccent 1976 0x07b8
-Greek_upsilondieresis 1977 0x07b9
-Greek_upsilonaccentdieresis 1978 0x07ba
-Greek_omegaaccent 1979 0x07bb
-Greek_ALPHA 1985 0x07c1
-Greek_BETA 1986 0x07c2
-Greek_GAMMA 1987 0x07c3
-Greek_DELTA 1988 0x07c4
-Greek_EPSILON 1989 0x07c5
-Greek_ZETA 1990 0x07c6
-Greek_ETA 1991 0x07c7
-Greek_THETA 1992 0x07c8
-Greek_IOTA 1993 0x07c9
-Greek_KAPPA 1994 0x07ca
-Greek_LAMBDA 1995 0x07cb
-Greek_MU 1996 0x07cc
-Greek_NU 1997 0x07cd
-Greek_XI 1998 0x07ce
-Greek_OMICRON 1999 0x07cf
-Greek_PI 2000 0x07d0
-Greek_RHO 2001 0x07d1
-Greek_SIGMA 2002 0x07d2
-Greek_TAU 2004 0x07d4
-Greek_UPSILON 2005 0x07d5
-Greek_PHI 2006 0x07d6
-Greek_CHI 2007 0x07d7
-Greek_PSI 2008 0x07d8
-Greek_OMEGA 2009 0x07d9
-Greek_alpha 2017 0x07e1
-Greek_beta 2018 0x07e2
-Greek_gamma 2019 0x07e3
-Greek_delta 2020 0x07e4
-Greek_epsilon 2021 0x07e5
-Greek_zeta 2022 0x07e6
-Greek_eta 2023 0x07e7
-Greek_theta 2024 0x07e8
-Greek_iota 2025 0x07e9
-Greek_kappa 2026 0x07ea
-Greek_lambda 2027 0x07eb
-Greek_mu 2028 0x07ec
-Greek_nu 2029 0x07ed
-Greek_xi 2030 0x07ee
-Greek_omicron 2031 0x07ef
-Greek_pi 2032 0x07f0
-Greek_rho 2033 0x07f1
-Greek_sigma 2034 0x07f2
-Greek_finalsmallsigma 2035 0x07f3
-Greek_tau 2036 0x07f4
-Greek_upsilon 2037 0x07f5
-Greek_phi 2038 0x07f6
-Greek_chi 2039 0x07f7
-Greek_psi 2040 0x07f8
-Greek_omega 2041 0x07f9
-leftradical 2209 0x08a1
-topleftradical 2210 0x08a2
-horizconnector 2211 0x08a3
-topintegral 2212 0x08a4
-botintegral 2213 0x08a5
-vertconnector 2214 0x08a6
-topleftsqbracket 2215 0x08a7
-botleftsqbracket 2216 0x08a8
-toprightsqbracket 2217 0x08a9
-botrightsqbracket 2218 0x08aa
-topleftparens 2219 0x08ab
-botleftparens 2220 0x08ac
-toprightparens 2221 0x08ad
-botrightparens 2222 0x08ae
-leftmiddlecurlybrace 2223 0x08af
-rightmiddlecurlybrace 2224 0x08b0
-topleftsummation 2225 0x08b1
-botleftsummation 2226 0x08b2
-topvertsummationconnector 2227 0x08b3
-botvertsummationconnector 2228 0x08b4
-toprightsummation 2229 0x08b5
-botrightsummation 2230 0x08b6
-rightmiddlesummation 2231 0x08b7
+Arabic_noon 1510 0x5E6
+Arabic_ha 1511 0x5E7
+Arabic_waw 1512 0x5E8
+Arabic_alefmaksura 1513 0x5E9
+Arabic_yeh 1514 0x5EA
+Arabic_fathatan 1515 0x5EB
+Arabic_dammatan 1516 0x5EC
+Arabic_kasratan 1517 0x5ED
+Arabic_fatha 1518 0x5EE
+Arabic_damma 1519 0x5EF
+Arabic_kasra 1520 0x5F0
+Arabic_shadda 1521 0x5F1
+Arabic_sukun 1522 0x5F2
+Serbian_dje 1697 0x6A1
+Macedonia_gje 1698 0x6A2
+Cyrillic_io 1699 0x6A3
+Ukrainian_ie 1700 0x6A4
+Macedonia_dse 1701 0x6A5
+Ukrainian_i 1702 0x6A6
+Ukrainian_yi 1703 0x6A7
+Cyrillic_je 1704 0x6A8
+Cyrillic_lje 1705 0x6A9
+Cyrillic_nje 1706 0x6AA
+Serbian_tshe 1707 0x6AB
+Macedonia_kje 1708 0x6AC
+Ukrainian_ghe_with_upturn 1709 0x6AD
+Byelorussian_shortu 1710 0x6AE
+Cyrillic_dzhe 1711 0x6AF
+numerosign 1712 0x6B0
+Serbian_DJE 1713 0x6B1
+Macedonia_GJE 1714 0x6B2
+Cyrillic_IO 1715 0x6B3
+Ukrainian_IE 1716 0x6B4
+Macedonia_DSE 1717 0x6B5
+Ukrainian_I 1718 0x6B6
+Ukrainian_YI 1719 0x6B7
+Cyrillic_JE 1720 0x6B8
+Cyrillic_LJE 1721 0x6B9
+Cyrillic_NJE 1722 0x6BA
+Serbian_TSHE 1723 0x6BB
+Macedonia_KJE 1724 0x6BC
+Ukrainian_GHE_WITH_UPTURN 1725 0x6BD
+Byelorussian_SHORTU 1726 0x6BE
+Cyrillic_DZHE 1727 0x6BF
+Cyrillic_yu 1728 0x6C0
+Cyrillic_a 1729 0x6C1
+Cyrillic_be 1730 0x6C2
+Cyrillic_tse 1731 0x6C3
+Cyrillic_de 1732 0x6C4
+Cyrillic_ie 1733 0x6C5
+Cyrillic_ef 1734 0x6C6
+Cyrillic_ghe 1735 0x6C7
+Cyrillic_ha 1736 0x6C8
+Cyrillic_i 1737 0x6C9
+Cyrillic_shorti 1738 0x6CA
+Cyrillic_ka 1739 0x6CB
+Cyrillic_el 1740 0x6CC
+Cyrillic_em 1741 0x6CD
+Cyrillic_en 1742 0x6CE
+Cyrillic_o 1743 0x6CF
+Cyrillic_pe 1744 0x6D0
+Cyrillic_ya 1745 0x6D1
+Cyrillic_er 1746 0x6D2
+Cyrillic_es 1747 0x6D3
+Cyrillic_te 1748 0x6D4
+Cyrillic_u 1749 0x6D5
+Cyrillic_zhe 1750 0x6D6
+Cyrillic_ve 1751 0x6D7
+Cyrillic_softsign 1752 0x6D8
+Cyrillic_yeru 1753 0x6D9
+Cyrillic_ze 1754 0x6DA
+Cyrillic_sha 1755 0x6DB
+Cyrillic_e 1756 0x6DC
+Cyrillic_shcha 1757 0x6DD
+Cyrillic_che 1758 0x6DE
+Cyrillic_hardsign 1759 0x6DF
+Cyrillic_YU 1760 0x6E0
+Cyrillic_A 1761 0x6E1
+Cyrillic_BE 1762 0x6E2
+Cyrillic_TSE 1763 0x6E3
+Cyrillic_DE 1764 0x6E4
+Cyrillic_IE 1765 0x6E5
+Cyrillic_EF 1766 0x6E6
+Cyrillic_GHE 1767 0x6E7
+Cyrillic_HA 1768 0x6E8
+Cyrillic_I 1769 0x6E9
+Cyrillic_SHORTI 1770 0x6EA
+Cyrillic_KA 1771 0x6EB
+Cyrillic_EL 1772 0x6EC
+Cyrillic_EM 1773 0x6ED
+Cyrillic_EN 1774 0x6EE
+Cyrillic_O 1775 0x6EF
+Cyrillic_PE 1776 0x6F0
+Cyrillic_YA 1777 0x6F1
+Cyrillic_ER 1778 0x6F2
+Cyrillic_ES 1779 0x6F3
+Cyrillic_TE 1780 0x6F4
+Cyrillic_U 1781 0x6F5
+Cyrillic_ZHE 1782 0x6F6
+Cyrillic_VE 1783 0x6F7
+Cyrillic_SOFTSIGN 1784 0x6F8
+Cyrillic_YERU 1785 0x6F9
+Cyrillic_ZE 1786 0x6FA
+Cyrillic_SHA 1787 0x6FB
+Cyrillic_E 1788 0x6FC
+Cyrillic_SHCHA 1789 0x6FD
+Cyrillic_CHE 1790 0x6FE
+Cyrillic_HARDSIGN 1791 0x6FF
+Greek_ALPHAaccent 1953 0x7A1
+Greek_EPSILONaccent 1954 0x7A2
+Greek_ETAaccent 1955 0x7A3
+Greek_IOTAaccent 1956 0x7A4
+Greek_IOTAdieresis 1957 0x7A5
+Greek_OMICRONaccent 1959 0x7A7
+Greek_UPSILONaccent 1960 0x7A8
+Greek_UPSILONdieresis 1961 0x7A9
+Greek_OMEGAaccent 1963 0x7AB
+Greek_accentdieresis 1966 0x7AE
+Greek_horizbar 1967 0x7AF
+Greek_alphaaccent 1969 0x7B1
+Greek_epsilonaccent 1970 0x7B2
+Greek_etaaccent 1971 0x7B3
+Greek_iotaaccent 1972 0x7B4
+Greek_iotadieresis 1973 0x7B5
+Greek_iotaaccentdieresis 1974 0x7B6
+Greek_omicronaccent 1975 0x7B7
+Greek_upsilonaccent 1976 0x7B8
+Greek_upsilondieresis 1977 0x7B9
+Greek_upsilonaccentdieresis 1978 0x7BA
+Greek_omegaaccent 1979 0x7BB
+Greek_ALPHA 1985 0x7C1
+Greek_BETA 1986 0x7C2
+Greek_GAMMA 1987 0x7C3
+Greek_DELTA 1988 0x7C4
+Greek_EPSILON 1989 0x7C5
+Greek_ZETA 1990 0x7C6
+Greek_ETA 1991 0x7C7
+Greek_THETA 1992 0x7C8
+Greek_IOTA 1993 0x7C9
+Greek_KAPPA 1994 0x7CA
+Greek_LAMDA 1995 0x7CB
+Greek_MU 1996 0x7CC
+Greek_NU 1997 0x7CD
+Greek_XI 1998 0x7CE
+Greek_OMICRON 1999 0x7CF
+Greek_PI 2000 0x7D0
+Greek_RHO 2001 0x7D1
+Greek_SIGMA 2002 0x7D2
+Greek_TAU 2004 0x7D4
+Greek_UPSILON 2005 0x7D5
+Greek_PHI 2006 0x7D6
+Greek_CHI 2007 0x7D7
+Greek_PSI 2008 0x7D8
+Greek_OMEGA 2009 0x7D9
+Greek_alpha 2017 0x7E1
+Greek_beta 2018 0x7E2
+Greek_gamma 2019 0x7E3
+Greek_delta 2020 0x7E4
+Greek_epsilon 2021 0x7E5
+Greek_zeta 2022 0x7E6
+Greek_eta 2023 0x7E7
+Greek_theta 2024 0x7E8
+Greek_iota 2025 0x7E9
+Greek_kappa 2026 0x7EA
+Greek_lamda 2027 0x7EB
+Greek_mu 2028 0x7EC
+Greek_nu 2029 0x7ED
+Greek_xi 2030 0x7EE
+Greek_omicron 2031 0x7EF
+Greek_pi 2032 0x7F0
+Greek_rho 2033 0x7F1
+Greek_sigma 2034 0x7F2
+Greek_finalsmallsigma 2035 0x7F3
+Greek_tau 2036 0x7F4
+Greek_upsilon 2037 0x7F5
+Greek_phi 2038 0x7F6
+Greek_chi 2039 0x7F7
+Greek_psi 2040 0x7F8
+Greek_omega 2041 0x7F9
+leftradical 2209 0x8A1
+topleftradical 2210 0x8A2
+horizconnector 2211 0x8A3
+topintegral 2212 0x8A4
+botintegral 2213 0x8A5
+vertconnector 2214 0x8A6
+topleftsqbracket 2215 0x8A7
+botleftsqbracket 2216 0x8A8
+toprightsqbracket 2217 0x8A9
+botrightsqbracket 2218 0x8AA
+topleftparens 2219 0x8AB
+botleftparens 2220 0x8AC
+toprightparens 2221 0x8AD
+botrightparens 2222 0x8AE
+leftmiddlecurlybrace 2223 0x8AF
+rightmiddlecurlybrace 2224 0x8B0
+topleftsummation 2225 0x8B1
+botleftsummation 2226 0x8B2
+topvertsummationconnector 2227 0x8B3
+botvertsummationconnector 2228 0x8B4
+toprightsummation 2229 0x8B5
+botrightsummation 2230 0x8B6
+rightmiddlesummation 2231 0x8B7
.CE
.CS
-lessthanequal 2236 0x08bc
-notequal 2237 0x08bd
-greaterthanequal 2238 0x08be
-integral 2239 0x08bf
-therefore 2240 0x08c0
-variation 2241 0x08c1
-infinity 2242 0x08c2
-nabla 2245 0x08c5
-approximate 2248 0x08c8
-similarequal 2249 0x08c9
-ifonlyif 2253 0x08cd
-implies 2254 0x08ce
-identical 2255 0x08cf
-radical 2262 0x08d6
-includedin 2266 0x08da
-includes 2267 0x08db
-intersection 2268 0x08dc
-union 2269 0x08dd
-logicaland 2270 0x08de
-logicalor 2271 0x08df
-partialderivative 2287 0x08ef
-function 2294 0x08f6
-leftarrow 2299 0x08fb
-uparrow 2300 0x08fc
-rightarrow 2301 0x08fd
-downarrow 2302 0x08fe
-blank 2527 0x09df
-soliddiamond 2528 0x09e0
-checkerboard 2529 0x09e1
-ht 2530 0x09e2
-ff 2531 0x09e3
-cr 2532 0x09e4
-lf 2533 0x09e5
-nl 2536 0x09e8
-vt 2537 0x09e9
-lowrightcorner 2538 0x09ea
-uprightcorner 2539 0x09eb
-upleftcorner 2540 0x09ec
-lowleftcorner 2541 0x09ed
-crossinglines 2542 0x09ee
-horizlinescan1 2543 0x09ef
-horizlinescan3 2544 0x09f0
-horizlinescan5 2545 0x09f1
-horizlinescan7 2546 0x09f2
-horizlinescan9 2547 0x09f3
-leftt 2548 0x09f4
-rightt 2549 0x09f5
-bott 2550 0x09f6
-topt 2551 0x09f7
-vertbar 2552 0x09f8
-emspace 2721 0x0aa1
-enspace 2722 0x0aa2
-em3space 2723 0x0aa3
-em4space 2724 0x0aa4
-digitspace 2725 0x0aa5
-punctspace 2726 0x0aa6
-thinspace 2727 0x0aa7
-hairspace 2728 0x0aa8
-emdash 2729 0x0aa9
-endash 2730 0x0aaa
-signifblank 2732 0x0aac
-ellipsis 2734 0x0aae
-doubbaselinedot 2735 0x0aaf
-onethird 2736 0x0ab0
-twothirds 2737 0x0ab1
-onefifth 2738 0x0ab2
-twofifths 2739 0x0ab3
-threefifths 2740 0x0ab4
-fourfifths 2741 0x0ab5
-onesixth 2742 0x0ab6
-fivesixths 2743 0x0ab7
-careof 2744 0x0ab8
-figdash 2747 0x0abb
-leftanglebracket 2748 0x0abc
-decimalpoint 2749 0x0abd
-rightanglebracket 2750 0x0abe
-marker 2751 0x0abf
-oneeighth 2755 0x0ac3
-threeeighths 2756 0x0ac4
-fiveeighths 2757 0x0ac5
-seveneighths 2758 0x0ac6
-trademark 2761 0x0ac9
-signaturemark 2762 0x0aca
-trademarkincircle 2763 0x0acb
-leftopentriangle 2764 0x0acc
-rightopentriangle 2765 0x0acd
-emopencircle 2766 0x0ace
-emopenrectangle 2767 0x0acf
-leftsinglequotemark 2768 0x0ad0
-rightsinglequotemark 2769 0x0ad1
-leftdoublequotemark 2770 0x0ad2
-rightdoublequotemark 2771 0x0ad3
-prescription 2772 0x0ad4
-minutes 2774 0x0ad6
-seconds 2775 0x0ad7
-latincross 2777 0x0ad9
-hexagram 2778 0x0ada
-filledrectbullet 2779 0x0adb
-filledlefttribullet 2780 0x0adc
-filledrighttribullet 2781 0x0add
-emfilledcircle 2782 0x0ade
-emfilledrect 2783 0x0adf
-enopencircbullet 2784 0x0ae0
-enopensquarebullet 2785 0x0ae1
-openrectbullet 2786 0x0ae2
-opentribulletup 2787 0x0ae3
-opentribulletdown 2788 0x0ae4
-openstar 2789 0x0ae5
-enfilledcircbullet 2790 0x0ae6
-enfilledsqbullet 2791 0x0ae7
-filledtribulletup 2792 0x0ae8
-filledtribulletdown 2793 0x0ae9
-leftpointer 2794 0x0aea
-rightpointer 2795 0x0aeb
-club 2796 0x0aec
-diamond 2797 0x0aed
-heart 2798 0x0aee
-maltesecross 2800 0x0af0
-dagger 2801 0x0af1
-doubledagger 2802 0x0af2
-checkmark 2803 0x0af3
-ballotcross 2804 0x0af4
-musicalsharp 2805 0x0af5
-musicalflat 2806 0x0af6
-malesymbol 2807 0x0af7
-femalesymbol 2808 0x0af8
-telephone 2809 0x0af9
-telephonerecorder 2810 0x0afa
-phonographcopyright 2811 0x0afb
-caret 2812 0x0afc
-singlelowquotemark 2813 0x0afd
-doublelowquotemark 2814 0x0afe
-cursor 2815 0x0aff
-leftcaret 2979 0x0ba3
-rightcaret 2982 0x0ba6
-downcaret 2984 0x0ba8
-upcaret 2985 0x0ba9
-overbar 3008 0x0bc0
-downtack 3010 0x0bc2
-upshoe 3011 0x0bc3
-downstile 3012 0x0bc4
-underbar 3014 0x0bc6
-jot 3018 0x0bca
-quad 3020 0x0bcc
-uptack 3022 0x0bce
-circle 3023 0x0bcf
-upstile 3027 0x0bd3
-downshoe 3030 0x0bd6
-rightshoe 3032 0x0bd8
-leftshoe 3034 0x0bda
-lefttack 3036 0x0bdc
-righttack 3068 0x0bfc
-hebrew_aleph 3296 0x0ce0
-hebrew_beth 3297 0x0ce1
-hebrew_gimmel 3298 0x0ce2
-hebrew_daleth 3299 0x0ce3
-hebrew_he 3300 0x0ce4
-hebrew_waw 3301 0x0ce5
-hebrew_zayin 3302 0x0ce6
-hebrew_het 3303 0x0ce7
-hebrew_teth 3304 0x0ce8
-hebrew_yod 3305 0x0ce9
-hebrew_finalkaph 3306 0x0cea
-hebrew_kaph 3307 0x0ceb
-hebrew_lamed 3308 0x0cec
-hebrew_finalmem 3309 0x0ced
-hebrew_mem 3310 0x0cee
-hebrew_finalnun 3311 0x0cef
-hebrew_nun 3312 0x0cf0
-hebrew_samekh 3313 0x0cf1
-hebrew_ayin 3314 0x0cf2
-hebrew_finalpe 3315 0x0cf3
-hebrew_pe 3316 0x0cf4
-hebrew_finalzadi 3317 0x0cf5
-hebrew_zadi 3318 0x0cf6
-hebrew_kuf 3319 0x0cf7
-hebrew_resh 3320 0x0cf8
-hebrew_shin 3321 0x0cf9
-hebrew_taf 3322 0x0cfa
-BackSpace 65288 0xff08
-Tab 65289 0xff09
-Linefeed 65290 0xff0a
-Clear 65291 0xff0b
-Return 65293 0xff0d
-Pause 65299 0xff13
-Scroll_Lock 65300 0xff14
-Sys_Req 65301 0xff15
-Escape 65307 0xff1b
-Multi_key 65312 0xff20
-Kanji 65313 0xff21
-Home 65360 0xff50
-Left 65361 0xff51
-Up 65362 0xff52
-Right 65363 0xff53
-Down 65364 0xff54
-Prior 65365 0xff55
-Next 65366 0xff56
-End 65367 0xff57
-Begin 65368 0xff58
-Win_L 65371 0xff5b
-Win_R 65372 0xff5c
+lessthanequal 2236 0x8BC
+notequal 2237 0x8BD
+greaterthanequal 2238 0x8BE
+integral 2239 0x8BF
+therefore 2240 0x8C0
+variation 2241 0x8C1
+infinity 2242 0x8C2
+nabla 2245 0x8C5
+approximate 2248 0x8C8
+similarequal 2249 0x8C9
+ifonlyif 2253 0x8CD
+implies 2254 0x8CE
+identical 2255 0x8CF
+radical 2262 0x8D6
+includedin 2266 0x8DA
+includes 2267 0x8DB
+intersection 2268 0x8DC
+union 2269 0x8DD
+logicaland 2270 0x8DE
+logicalor 2271 0x8DF
+partialderivative 2287 0x8EF
+function 2294 0x8F6
+leftarrow 2299 0x8FB
+uparrow 2300 0x8FC
+rightarrow 2301 0x8FD
+downarrow 2302 0x8FE
+blank 2527 0x9DF
+soliddiamond 2528 0x9E0
+checkerboard 2529 0x9E1
+ht 2530 0x9E2
+ff 2531 0x9E3
+cr 2532 0x9E4
+lf 2533 0x9E5
+nl 2536 0x9E8
+vt 2537 0x9E9
+lowrightcorner 2538 0x9EA
+uprightcorner 2539 0x9EB
+upleftcorner 2540 0x9EC
+lowleftcorner 2541 0x9ED
+crossinglines 2542 0x9EE
+horizlinescan1 2543 0x9EF
+horizlinescan3 2544 0x9F0
+horizlinescan5 2545 0x9F1
+horizlinescan7 2546 0x9F2
+horizlinescan9 2547 0x9F3
+leftt 2548 0x9F4
+rightt 2549 0x9F5
+bott 2550 0x9F6
+topt 2551 0x9F7
+vertbar 2552 0x9F8
+emspace 2721 0xAA1
+enspace 2722 0xAA2
+em3space 2723 0xAA3
+em4space 2724 0xAA4
+digitspace 2725 0xAA5
+punctspace 2726 0xAA6
+thinspace 2727 0xAA7
+hairspace 2728 0xAA8
+emdash 2729 0xAA9
+endash 2730 0xAAA
+signifblank 2732 0xAAC
+ellipsis 2734 0xAAE
+doubbaselinedot 2735 0xAAF
+onethird 2736 0xAB0
+twothirds 2737 0xAB1
+onefifth 2738 0xAB2
+twofifths 2739 0xAB3
+threefifths 2740 0xAB4
+fourfifths 2741 0xAB5
+onesixth 2742 0xAB6
+fivesixths 2743 0xAB7
+careof 2744 0xAB8
+figdash 2747 0xABB
+leftanglebracket 2748 0xABC
+decimalpoint 2749 0xABD
+rightanglebracket 2750 0xABE
+marker 2751 0xABF
+oneeighth 2755 0xAC3
+threeeighths 2756 0xAC4
+fiveeighths 2757 0xAC5
+seveneighths 2758 0xAC6
+trademark 2761 0xAC9
+signaturemark 2762 0xACA
+trademarkincircle 2763 0xACB
+leftopentriangle 2764 0xACC
+rightopentriangle 2765 0xACD
+emopencircle 2766 0xACE
+emopenrectangle 2767 0xACF
+leftsinglequotemark 2768 0xAD0
+rightsinglequotemark 2769 0xAD1
+leftdoublequotemark 2770 0xAD2
+rightdoublequotemark 2771 0xAD3
+prescription 2772 0xAD4
+permille 2773 0xAD5
+minutes 2774 0xAD6
+seconds 2775 0xAD7
+latincross 2777 0xAD9
+hexagram 2778 0xADA
+filledrectbullet 2779 0xADB
+filledlefttribullet 2780 0xADC
+filledrighttribullet 2781 0xADD
+emfilledcircle 2782 0xADE
+emfilledrect 2783 0xADF
+enopencircbullet 2784 0xAE0
+enopensquarebullet 2785 0xAE1
+openrectbullet 2786 0xAE2
+opentribulletup 2787 0xAE3
+opentribulletdown 2788 0xAE4
+openstar 2789 0xAE5
+enfilledcircbullet 2790 0xAE6
+enfilledsqbullet 2791 0xAE7
+filledtribulletup 2792 0xAE8
+filledtribulletdown 2793 0xAE9
+leftpointer 2794 0xAEA
+rightpointer 2795 0xAEB
+club 2796 0xAEC
+diamond 2797 0xAED
+heart 2798 0xAEE
+maltesecross 2800 0xAF0
+dagger 2801 0xAF1
+doubledagger 2802 0xAF2
+checkmark 2803 0xAF3
+ballotcross 2804 0xAF4
+musicalsharp 2805 0xAF5
+musicalflat 2806 0xAF6
+malesymbol 2807 0xAF7
+femalesymbol 2808 0xAF8
+telephone 2809 0xAF9
+telephonerecorder 2810 0xAFA
+phonographcopyright 2811 0xAFB
+caret 2812 0xAFC
+singlelowquotemark 2813 0xAFD
+doublelowquotemark 2814 0xAFE
+cursor 2815 0xAFF
+leftcaret 2979 0xBA3
+rightcaret 2982 0xBA6
+downcaret 2984 0xBA8
+upcaret 2985 0xBA9
+overbar 3008 0xBC0
+downtack 3010 0xBC2
+upshoe 3011 0xBC3
+downstile 3012 0xBC4
+underbar 3014 0xBC6
+jot 3018 0xBCA
+quad 3020 0xBCC
+uptack 3022 0xBCE
+circle 3023 0xBCF
+upstile 3027 0xBD3
+downshoe 3030 0xBD6
+rightshoe 3032 0xBD8
+leftshoe 3034 0xBDA
+lefttack 3036 0xBDC
+righttack 3068 0xBFC
+hebrew_doublelowline 3295 0xCDF
+hebrew_aleph 3296 0xCE0
+hebrew_bet 3297 0xCE1
+hebrew_gimel 3298 0xCE2
+hebrew_dalet 3299 0xCE3
+hebrew_he 3300 0xCE4
+hebrew_waw 3301 0xCE5
+hebrew_zain 3302 0xCE6
+hebrew_chet 3303 0xCE7
+hebrew_tet 3304 0xCE8
+hebrew_yod 3305 0xCE9
+hebrew_finalkaph 3306 0xCEA
+hebrew_kaph 3307 0xCEB
+hebrew_lamed 3308 0xCEC
+hebrew_finalmem 3309 0xCED
+hebrew_mem 3310 0xCEE
+hebrew_finalnun 3311 0xCEF
+hebrew_nun 3312 0xCF0
+hebrew_samech 3313 0xCF1
+hebrew_ayin 3314 0xCF2
+hebrew_finalpe 3315 0xCF3
+hebrew_pe 3316 0xCF4
+hebrew_finalzade 3317 0xCF5
+hebrew_zade 3318 0xCF6
+hebrew_qoph 3319 0xCF7
+hebrew_resh 3320 0xCF8
+hebrew_shin 3321 0xCF9
+hebrew_taw 3322 0xCFA
+Thai_kokai 3489 0xDA1
+Thai_khokhai 3490 0xDA2
+Thai_khokhuat 3491 0xDA3
+Thai_khokhwai 3492 0xDA4
+Thai_khokhon 3493 0xDA5
+Thai_khorakhang 3494 0xDA6
+Thai_ngongu 3495 0xDA7
+Thai_chochan 3496 0xDA8
+Thai_choching 3497 0xDA9
+Thai_chochang 3498 0xDAA
+Thai_soso 3499 0xDAB
+Thai_chochoe 3500 0xDAC
+Thai_yoying 3501 0xDAD
+Thai_dochada 3502 0xDAE
+Thai_topatak 3503 0xDAF
+Thai_thothan 3504 0xDB0
+Thai_thonangmontho 3505 0xDB1
+Thai_thophuthao 3506 0xDB2
+Thai_nonen 3507 0xDB3
+Thai_dodek 3508 0xDB4
+Thai_totao 3509 0xDB5
+Thai_thothung 3510 0xDB6
+Thai_thothahan 3511 0xDB7
+Thai_thothong 3512 0xDB8
+Thai_nonu 3513 0xDB9
+Thai_bobaimai 3514 0xDBA
+Thai_popla 3515 0xDBB
+Thai_phophung 3516 0xDBC
+Thai_fofa 3517 0xDBD
+Thai_phophan 3518 0xDBE
+Thai_fofan 3519 0xDBF
+Thai_phosamphao 3520 0xDC0
+Thai_moma 3521 0xDC1
+Thai_yoyak 3522 0xDC2
+Thai_rorua 3523 0xDC3
+Thai_ru 3524 0xDC4
+Thai_loling 3525 0xDC5
+Thai_lu 3526 0xDC6
+Thai_wowaen 3527 0xDC7
+Thai_sosala 3528 0xDC8
+Thai_sorusi 3529 0xDC9
+Thai_sosua 3530 0xDCA
+Thai_hohip 3531 0xDCB
+Thai_lochula 3532 0xDCC
+Thai_oang 3533 0xDCD
+Thai_honokhuk 3534 0xDCE
+Thai_paiyannoi 3535 0xDCF
+Thai_saraa 3536 0xDD0
+Thai_maihanakat 3537 0xDD1
+Thai_saraaa 3538 0xDD2
+Thai_saraam 3539 0xDD3
+Thai_sarai 3540 0xDD4
+Thai_saraii 3541 0xDD5
+Thai_saraue 3542 0xDD6
+Thai_sarauee 3543 0xDD7
+Thai_sarau 3544 0xDD8
+Thai_sarauu 3545 0xDD9
+Thai_phinthu 3546 0xDDA
+Thai_maihanakat_maitho 3550 0xDDE
+Thai_baht 3551 0xDDF
+Thai_sarae 3552 0xDE0
+Thai_saraae 3553 0xDE1
+Thai_sarao 3554 0xDE2
+Thai_saraaimaimuan 3555 0xDE3
+Thai_saraaimaimalai 3556 0xDE4
+Thai_lakkhangyao 3557 0xDE5
+Thai_maiyamok 3558 0xDE6
+Thai_maitaikhu 3559 0xDE7
+Thai_maiek 3560 0xDE8
+Thai_maitho 3561 0xDE9
+Thai_maitri 3562 0xDEA
+Thai_maichattawa 3563 0xDEB
+Thai_thanthakhat 3564 0xDEC
+Thai_nikhahit 3565 0xDED
+Thai_leksun 3568 0xDF0
+Thai_leknung 3569 0xDF1
+Thai_leksong 3570 0xDF2
+Thai_leksam 3571 0xDF3
+Thai_leksi 3572 0xDF4
+Thai_lekha 3573 0xDF5
+Thai_lekhok 3574 0xDF6
+Thai_lekchet 3575 0xDF7
+Thai_lekpaet 3576 0xDF8
+Thai_lekkao 3577 0xDF9
+Hangul_Kiyeog 3745 0xEA1
+Hangul_SsangKiyeog 3746 0xEA2
+Hangul_KiyeogSios 3747 0xEA3
+Hangul_Nieun 3748 0xEA4
+Hangul_NieunJieuj 3749 0xEA5
+Hangul_NieunHieuh 3750 0xEA6
+Hangul_Dikeud 3751 0xEA7
+Hangul_SsangDikeud 3752 0xEA8
+Hangul_Rieul 3753 0xEA9
+Hangul_RieulKiyeog 3754 0xEAA
+Hangul_RieulMieum 3755 0xEAB
+Hangul_RieulPieub 3756 0xEAC
+Hangul_RieulSios 3757 0xEAD
+Hangul_RieulTieut 3758 0xEAE
+Hangul_RieulPhieuf 3759 0xEAF
+Hangul_RieulHieuh 3760 0xEB0
+Hangul_Mieum 3761 0xEB1
+Hangul_Pieub 3762 0xEB2
+Hangul_SsangPieub 3763 0xEB3
+Hangul_PieubSios 3764 0xEB4
+Hangul_Sios 3765 0xEB5
+Hangul_SsangSios 3766 0xEB6
+Hangul_Ieung 3767 0xEB7
+Hangul_Jieuj 3768 0xEB8
+Hangul_SsangJieuj 3769 0xEB9
+Hangul_Cieuc 3770 0xEBA
+Hangul_Khieuq 3771 0xEBB
+Hangul_Tieut 3772 0xEBC
+Hangul_Phieuf 3773 0xEBD
+Hangul_Hieuh 3774 0xEBE
+Hangul_A 3775 0xEBF
+Hangul_AE 3776 0xEC0
+Hangul_YA 3777 0xEC1
+Hangul_YAE 3778 0xEC2
+Hangul_EO 3779 0xEC3
+Hangul_E 3780 0xEC4
+Hangul_YEO 3781 0xEC5
+Hangul_YE 3782 0xEC6
+Hangul_O 3783 0xEC7
+Hangul_WA 3784 0xEC8
+Hangul_WAE 3785 0xEC9
+Hangul_OE 3786 0xECA
+Hangul_YO 3787 0xECB
+Hangul_U 3788 0xECC
+Hangul_WEO 3789 0xECD
+Hangul_WE 3790 0xECE
+Hangul_WI 3791 0xECF
+Hangul_YU 3792 0xED0
+Hangul_EU 3793 0xED1
+Hangul_YI 3794 0xED2
+Hangul_I 3795 0xED3
+Hangul_J_Kiyeog 3796 0xED4
+Hangul_J_SsangKiyeog 3797 0xED5
+Hangul_J_KiyeogSios 3798 0xED6
+Hangul_J_Nieun 3799 0xED7
+Hangul_J_NieunJieuj 3800 0xED8
+Hangul_J_NieunHieuh 3801 0xED9
+Hangul_J_Dikeud 3802 0xEDA
+Hangul_J_Rieul 3803 0xEDB
+Hangul_J_RieulKiyeog 3804 0xEDC
+Hangul_J_RieulMieum 3805 0xEDD
+Hangul_J_RieulPieub 3806 0xEDE
+Hangul_J_RieulSios 3807 0xEDF
+Hangul_J_RieulTieut 3808 0xEE0
+Hangul_J_RieulPhieuf 3809 0xEE1
+Hangul_J_RieulHieuh 3810 0xEE2
+Hangul_J_Mieum 3811 0xEE3
+Hangul_J_Pieub 3812 0xEE4
+Hangul_J_PieubSios 3813 0xEE5
+Hangul_J_Sios 3814 0xEE6
+Hangul_J_SsangSios 3815 0xEE7
+Hangul_J_Ieung 3816 0xEE8
+Hangul_J_Jieuj 3817 0xEE9
+Hangul_J_Cieuc 3818 0xEEA
+Hangul_J_Khieuq 3819 0xEEB
+Hangul_J_Tieut 3820 0xEEC
+Hangul_J_Phieuf 3821 0xEED
+Hangul_J_Hieuh 3822 0xEEE
+Hangul_RieulYeorinHieuh 3823 0xEEF
+Hangul_SunkyeongeumMieum 3824 0xEF0
+Hangul_SunkyeongeumPieub 3825 0xEF1
+Hangul_PanSios 3826 0xEF2
+Hangul_KkogjiDalrinIeung 3827 0xEF3
+Hangul_SunkyeongeumPhieuf 3828 0xEF4
+Hangul_YeorinHieuh 3829 0xEF5
+Hangul_AraeA 3830 0xEF6
+Hangul_AraeAE 3831 0xEF7
+Hangul_J_PanSios 3832 0xEF8
+Hangul_J_KkogjiDalrinIeung 3833 0xEF9
+Hangul_J_YeorinHieuh 3834 0xEFA
+Korean_Won 3839 0xEFF
+OE 5052 0x13BC
+oe 5053 0x13BD
+Ydiaeresis 5054 0x13BE
+EuroSign 8364 0x20AC
+3270_Duplicate 64769 0xFD01
+3270_FieldMark 64770 0xFD02
+3270_Right2 64771 0xFD03
+3270_Left2 64772 0xFD04
+3270_BackTab 64773 0xFD05
+3270_EraseEOF 64774 0xFD06
+3270_EraseInput 64775 0xFD07
+3270_Reset 64776 0xFD08
+3270_Quit 64777 0xFD09
+3270_PA1 64778 0xFD0A
+3270_PA2 64779 0xFD0B
+3270_PA3 64780 0xFD0C
+3270_Test 64781 0xFD0D
+3270_Attn 64782 0xFD0E
+3270_CursorBlink 64783 0xFD0F
+3270_AltCursor 64784 0xFD10
+3270_KeyClick 64785 0xFD11
+3270_Jump 64786 0xFD12
+3270_Ident 64787 0xFD13
+3270_Rule 64788 0xFD14
+3270_Copy 64789 0xFD15
+3270_Play 64790 0xFD16
+3270_Setup 64791 0xFD17
+3270_Record 64792 0xFD18
+3270_ChangeScreen 64793 0xFD19
+3270_DeleteWord 64794 0xFD1A
+3270_ExSelect 64795 0xFD1B
+3270_CursorSelect 64796 0xFD1C
+3270_PrintScreen 64797 0xFD1D
+3270_Enter 64798 0xFD1E
+ISO_Lock 65025 0xFE01
+ISO_Level2_Latch 65026 0xFE02
+ISO_Level3_Shift 65027 0xFE03
+ISO_Level3_Latch 65028 0xFE04
+ISO_Level3_Lock 65029 0xFE05
+ISO_Group_Latch 65030 0xFE06
+ISO_Group_Lock 65031 0xFE07
+ISO_Next_Group 65032 0xFE08
+ISO_Next_Group_Lock 65033 0xFE09
+ISO_Prev_Group 65034 0xFE0A
+ISO_Prev_Group_Lock 65035 0xFE0B
+ISO_First_Group 65036 0xFE0C
+ISO_First_Group_Lock 65037 0xFE0D
+ISO_Last_Group 65038 0xFE0E
+ISO_Last_Group_Lock 65039 0xFE0F
+ISO_Level5_Shift 65041 0xFE11
+ISO_Level5_Latch 65042 0xFE12
+ISO_Level5_Lock 65043 0xFE13
+ISO_Left_Tab 65056 0xFE20
+ISO_Move_Line_Up 65057 0xFE21
+ISO_Move_Line_Down 65058 0xFE22
+ISO_Partial_Line_Up 65059 0xFE23
+ISO_Partial_Line_Down 65060 0xFE24
+ISO_Partial_Space_Left 65061 0xFE25
+ISO_Partial_Space_Right 65062 0xFE26
+ISO_Set_Margin_Left 65063 0xFE27
+ISO_Set_Margin_Right 65064 0xFE28
+ISO_Release_Margin_Left 65065 0xFE29
+ISO_Release_Margin_Right 65066 0xFE2A
+ISO_Release_Both_Margins 65067 0xFE2B
+ISO_Fast_Cursor_Left 65068 0xFE2C
+ISO_Fast_Cursor_Right 65069 0xFE2D
+ISO_Fast_Cursor_Up 65070 0xFE2E
+ISO_Fast_Cursor_Down 65071 0xFE2F
+ISO_Continuous_Underline 65072 0xFE30
+ISO_Discontinuous_Underline 65073 0xFE31
+ISO_Emphasize 65074 0xFE32
+ISO_Center_Object 65075 0xFE33
+ISO_Enter 65076 0xFE34
+dead_grave 65104 0xFE50
+dead_acute 65105 0xFE51
+dead_circumflex 65106 0xFE52
+dead_tilde 65107 0xFE53
+dead_macron 65108 0xFE54
+dead_breve 65109 0xFE55
+dead_abovedot 65110 0xFE56
+dead_diaeresis 65111 0xFE57
+dead_abovering 65112 0xFE58
+dead_doubleacute 65113 0xFE59
+dead_caron 65114 0xFE5A
+dead_cedilla 65115 0xFE5B
+dead_ogonek 65116 0xFE5C
+dead_iota 65117 0xFE5D
+dead_voiced_sound 65118 0xFE5E
+dead_semivoiced_sound 65119 0xFE5F
+dead_belowdot 65120 0xFE60
+dead_hook 65121 0xFE61
+dead_horn 65122 0xFE62
+dead_stroke 65123 0xFE63
+dead_abovecomma 65124 0xFE64
+dead_abovereversedcomma 65125 0xFE65
+dead_doublegrave 65126 0xFE66
+dead_belowring 65127 0xFE67
+dead_belowmacron 65128 0xFE68
+dead_belowcircumflex 65129 0xFE69
+dead_belowtilde 65130 0xFE6A
+dead_belowbreve 65131 0xFE6B
+dead_belowdiaeresis 65132 0xFE6C
+dead_invertedbreve 65133 0xFE6D
+dead_belowcomma 65134 0xFE6E
+dead_currency 65135 0xFE6F
+AccessX_Enable 65136 0xFE70
+AccessX_Feedback_Enable 65137 0xFE71
+RepeatKeys_Enable 65138 0xFE72
+SlowKeys_Enable 65139 0xFE73
+BounceKeys_Enable 65140 0xFE74
+StickyKeys_Enable 65141 0xFE75
+MouseKeys_Enable 65142 0xFE76
+MouseKeys_Accel_Enable 65143 0xFE77
+Overlay1_Enable 65144 0xFE78
+Overlay2_Enable 65145 0xFE79
+AudibleBell_Enable 65146 0xFE7A
+dead_a 65152 0xFE80
+dead_A 65153 0xFE81
+dead_e 65154 0xFE82
+dead_E 65155 0xFE83
+dead_i 65156 0xFE84
+dead_I 65157 0xFE85
+dead_o 65158 0xFE86
+dead_O 65159 0xFE87
+dead_u 65160 0xFE88
+dead_U 65161 0xFE89
+dead_small_schwa 65162 0xFE8A
+dead_capital_schwa 65163 0xFE8B
+dead_greek 65164 0xFE8C
+dead_lowline 65168 0xFE90
+dead_aboveverticalline 65169 0xFE91
+dead_belowverticalline 65170 0xFE92
+dead_longsolidusoverlay 65171 0xFE93
+ch 65184 0xFEA0
+Ch 65185 0xFEA1
+CH 65186 0xFEA2
+c_h 65187 0xFEA3
+C_h 65188 0xFEA4
+C_H 65189 0xFEA5
+First_Virtual_Screen 65232 0xFED0
+Prev_Virtual_Screen 65233 0xFED1
+Next_Virtual_Screen 65234 0xFED2
+Last_Virtual_Screen 65236 0xFED4
+Terminate_Server 65237 0xFED5
+Pointer_Left 65248 0xFEE0
+Pointer_Right 65249 0xFEE1
+Pointer_Up 65250 0xFEE2
+Pointer_Down 65251 0xFEE3
+Pointer_UpLeft 65252 0xFEE4
+Pointer_UpRight 65253 0xFEE5
+Pointer_DownLeft 65254 0xFEE6
+Pointer_DownRight 65255 0xFEE7
+Pointer_Button_Dflt 65256 0xFEE8
+Pointer_Button1 65257 0xFEE9
+Pointer_Button2 65258 0xFEEA
+Pointer_Button3 65259 0xFEEB
+Pointer_Button4 65260 0xFEEC
+Pointer_Button5 65261 0xFEED
+Pointer_DblClick_Dflt 65262 0xFEEE
+Pointer_DblClick1 65263 0xFEEF
+Pointer_DblClick2 65264 0xFEF0
+Pointer_DblClick3 65265 0xFEF1
+Pointer_DblClick4 65266 0xFEF2
+Pointer_DblClick5 65267 0xFEF3
+Pointer_Drag_Dflt 65268 0xFEF4
+Pointer_Drag1 65269 0xFEF5
+Pointer_Drag2 65270 0xFEF6
+Pointer_Drag3 65271 0xFEF7
+Pointer_Drag4 65272 0xFEF8
+Pointer_EnableKeys 65273 0xFEF9
+Pointer_Accelerate 65274 0xFEFA
+Pointer_DfltBtnNext 65275 0xFEFB
+Pointer_DfltBtnPrev 65276 0xFEFC
+Pointer_Drag5 65277 0xFEFD
+BackSpace 65288 0xFF08
+Tab 65289 0xFF09
+Linefeed 65290 0xFF0A
+Clear 65291 0xFF0B
+Return 65293 0xFF0D
+Pause 65299 0xFF13
+Scroll_Lock 65300 0xFF14
+Sys_Req 65301 0xFF15
+Escape 65307 0xFF1B
+Multi_key 65312 0xFF20
+Kanji 65313 0xFF21
+Muhenkan 65314 0xFF22
+Henkan_Mode 65315 0xFF23
+Romaji 65316 0xFF24
+Hiragana 65317 0xFF25
+Katakana 65318 0xFF26
+Hiragana_Katakana 65319 0xFF27
+Zenkaku 65320 0xFF28
+Hankaku 65321 0xFF29
+Zenkaku_Hankaku 65322 0xFF2A
+Touroku 65323 0xFF2B
+Massyo 65324 0xFF2C
+Kana_Lock 65325 0xFF2D
+Kana_Shift 65326 0xFF2E
+Eisu_Shift 65327 0xFF2F
+Eisu_toggle 65328 0xFF30
+Hangul 65329 0xFF31
+Hangul_Start 65330 0xFF32
+Hangul_End 65331 0xFF33
+Hangul_Hanja 65332 0xFF34
+Hangul_Jamo 65333 0xFF35
+Hangul_Romaja 65334 0xFF36
+Codeinput 65335 0xFF37
+Hangul_Jeonja 65336 0xFF38
+Hangul_Banja 65337 0xFF39
+Hangul_PreHanja 65338 0xFF3A
+Hangul_PostHanja 65339 0xFF3B
+SingleCandidate 65340 0xFF3C
+MultipleCandidate 65341 0xFF3D
+PreviousCandidate 65342 0xFF3E
+Hangul_Special 65343 0xFF3F
+Home 65360 0xFF50
+Left 65361 0xFF51
+Up 65362 0xFF52
+Right 65363 0xFF53
+Down 65364 0xFF54
+Prior 65365 0xFF55
+Next 65366 0xFF56
+End 65367 0xFF57
+Begin 65368 0xFF58
+Win_L 65371 0xFF5B
+Win_R 65372 0xFF5C
.CE
.CS
-App 65373 0xff5d
-Select 65376 0xff60
-Print 65377 0xff61
-Execute 65378 0xff62
-Insert 65379 0xff63
-Undo 65381 0xff65
-Redo 65382 0xff66
-Menu 65383 0xff67
-Find 65384 0xff68
-Cancel 65385 0xff69
-Help 65386 0xff6a
-Break 65387 0xff6b
-Hebrew_switch 65406 0xff7e
-Num_Lock 65407 0xff7f
-KP_Space 65408 0xff80
-KP_Tab 65417 0xff89
-KP_Enter 65421 0xff8d
-KP_F1 65425 0xff91
-KP_F2 65426 0xff92
-KP_F3 65427 0xff93
-KP_F4 65428 0xff94
-KP_Multiply 65450 0xffaa
-KP_Add 65451 0xffab
-KP_Separator 65452 0xffac
-KP_Subtract 65453 0xffad
-KP_Decimal 65454 0xffae
-KP_Divide 65455 0xffaf
-KP_0 65456 0xffb0
-KP_1 65457 0xffb1
-KP_2 65458 0xffb2
-KP_3 65459 0xffb3
-KP_4 65460 0xffb4
-KP_5 65461 0xffb5
-KP_6 65462 0xffb6
-KP_7 65463 0xffb7
-KP_8 65464 0xffb8
-KP_9 65465 0xffb9
-KP_Equal 65469 0xffbd
-F1 65470 0xffbe
-F2 65471 0xffbf
-F3 65472 0xffc0
-F4 65473 0xffc1
-F5 65474 0xffc2
-F6 65475 0xffc3
-F7 65476 0xffc4
-F8 65477 0xffc5
-F9 65478 0xffc6
-F10 65479 0xffc7
-L1 65480 0xffc8
-L2 65481 0xffc9
-L3 65482 0xffca
-L4 65483 0xffcb
-L5 65484 0xffcc
-L6 65485 0xffcd
-L7 65486 0xffce
-L8 65487 0xffcf
-L9 65488 0xffd0
-L10 65489 0xffd1
-R1 65490 0xffd2
-R2 65491 0xffd3
-R3 65492 0xffd4
-R4 65493 0xffd5
-R5 65494 0xffd6
-R6 65495 0xffd7
-R7 65496 0xffd8
-R8 65497 0xffd9
-R9 65498 0xffda
-R10 65499 0xffdb
-R11 65500 0xffdc
-R12 65501 0xffdd
-F33 65502 0xffde
-R14 65503 0xffdf
-R15 65504 0xffe0
-Shift_L 65505 0xffe1
-Shift_R 65506 0xffe2
-Control_L 65507 0xffe3
-Control_R 65508 0xffe4
-Caps_Lock 65509 0xffe5
-Shift_Lock 65510 0xffe6
-Meta_L 65511 0xffe7
-Meta_R 65512 0xffe8
-Alt_L 65513 0xffe9
-Alt_R 65514 0xffea
-Super_L 65515 0xffeb
-Super_R 65516 0xffec
-Hyper_L 65517 0xffed
-Hyper_R 65518 0xffee
-Delete 65535 0xffff
+App 65373 0xFF5D
+Select 65376 0xFF60
+Print 65377 0xFF61
+Execute 65378 0xFF62
+Insert 65379 0xFF63
+Undo 65381 0xFF65
+Redo 65382 0xFF66
+Menu 65383 0xFF67
+Find 65384 0xFF68
+Cancel 65385 0xFF69
+Help 65386 0xFF6A
+Break 65387 0xFF6B
+Mode_switch 65406 0xFF7E
+Num_Lock 65407 0xFF7F
+KP_Space 65408 0xFF80
+KP_Tab 65417 0xFF89
+KP_Enter 65421 0xFF8D
+KP_F1 65425 0xFF91
+KP_F2 65426 0xFF92
+KP_F3 65427 0xFF93
+KP_F4 65428 0xFF94
+KP_Home 65429 0xFF95
+KP_Left 65430 0xFF96
+KP_Up 65431 0xFF97
+KP_Right 65432 0xFF98
+KP_Down 65433 0xFF99
+KP_Prior 65434 0xFF9A
+KP_Next 65435 0xFF9B
+KP_End 65436 0xFF9C
+KP_Begin 65437 0xFF9D
+KP_Insert 65438 0xFF9E
+KP_Delete 65439 0xFF9F
+KP_Multiply 65450 0xFFAA
+KP_Add 65451 0xFFAB
+KP_Separator 65452 0xFFAC
+KP_Subtract 65453 0xFFAD
+KP_Decimal 65454 0xFFAE
+KP_Divide 65455 0xFFAF
+KP_0 65456 0xFFB0
+KP_1 65457 0xFFB1
+KP_2 65458 0xFFB2
+KP_3 65459 0xFFB3
+KP_4 65460 0xFFB4
+KP_5 65461 0xFFB5
+KP_6 65462 0xFFB6
+KP_7 65463 0xFFB7
+KP_8 65464 0xFFB8
+KP_9 65465 0xFFB9
+KP_Equal 65469 0xFFBD
+F1 65470 0xFFBE
+F2 65471 0xFFBF
+F3 65472 0xFFC0
+F4 65473 0xFFC1
+F5 65474 0xFFC2
+F6 65475 0xFFC3
+F7 65476 0xFFC4
+F8 65477 0xFFC5
+F9 65478 0xFFC6
+F10 65479 0xFFC7
+F11 65480 0xFFC8
+F12 65481 0xFFC9
+F13 65482 0xFFCA
+F14 65483 0xFFCB
+F15 65484 0xFFCC
+F16 65485 0xFFCD
+F17 65486 0xFFCE
+F18 65487 0xFFCF
+F19 65488 0xFFD0
+F20 65489 0xFFD1
+F21 65490 0xFFD2
+F22 65491 0xFFD3
+F23 65492 0xFFD4
+F24 65493 0xFFD5
+F25 65494 0xFFD6
+F26 65495 0xFFD7
+F27 65496 0xFFD8
+F28 65497 0xFFD9
+F29 65498 0xFFDA
+F30 65499 0xFFDB
+F31 65500 0xFFDC
+F32 65501 0xFFDD
+F33 65502 0xFFDE
+F34 65503 0xFFDF
+F35 65504 0xFFE0
+Shift_L 65505 0xFFE1
+Shift_R 65506 0xFFE2
+Control_L 65507 0xFFE3
+Control_R 65508 0xFFE4
+Caps_Lock 65509 0xFFE5
+Shift_Lock 65510 0xFFE6
+Meta_L 65511 0xFFE7
+Meta_R 65512 0xFFE8
+Alt_L 65513 0xFFE9
+Alt_R 65514 0xFFEA
+Super_L 65515 0xFFEB
+Super_R 65516 0xFFEC
+Hyper_L 65517 0xFFED
+Hyper_R 65518 0xFFEE
+braille_dot_1 65521 0xFFF1
+braille_dot_2 65522 0xFFF2
+braille_dot_3 65523 0xFFF3
+braille_dot_4 65524 0xFFF4
+braille_dot_5 65525 0xFFF5
+braille_dot_6 65526 0xFFF6
+braille_dot_7 65527 0xFFF7
+braille_dot_8 65528 0xFFF8
+braille_dot_9 65529 0xFFF9
+braille_dot_10 65530 0xFFFA
+Delete 65535 0xFFFF
+Ibreve 16777516 0x100012C
+ibreve 16777517 0x100012D
+Wcircumflex 16777588 0x1000174
+wcircumflex 16777589 0x1000175
+Ycircumflex 16777590 0x1000176
+ycircumflex 16777591 0x1000177
+SCHWA 16777615 0x100018F
+Obarred 16777631 0x100019F
+Ohorn 16777632 0x10001A0
+ohorn 16777633 0x10001A1
+Uhorn 16777647 0x10001AF
+uhorn 16777648 0x10001B0
+Zstroke 16777653 0x10001B5
+zstroke 16777654 0x10001B6
+EZH 16777655 0x10001B7
+Ocaron 16777681 0x10001D1
+ocaron 16777682 0x10001D2
+Gcaron 16777702 0x10001E6
+gcaron 16777703 0x10001E7
+schwa 16777817 0x1000259
+obarred 16777845 0x1000275
+ezh 16777874 0x1000292
+Cyrillic_GHE_bar 16778386 0x1000492
+Cyrillic_ghe_bar 16778387 0x1000493
+Cyrillic_ZHE_descender 16778390 0x1000496
+Cyrillic_zhe_descender 16778391 0x1000497
+Cyrillic_KA_descender 16778394 0x100049A
+Cyrillic_ka_descender 16778395 0x100049B
+Cyrillic_KA_vertstroke 16778396 0x100049C
+Cyrillic_ka_vertstroke 16778397 0x100049D
+Cyrillic_EN_descender 16778402 0x10004A2
+Cyrillic_en_descender 16778403 0x10004A3
+Cyrillic_U_straight 16778414 0x10004AE
+Cyrillic_u_straight 16778415 0x10004AF
+Cyrillic_U_straight_bar 16778416 0x10004B0
+Cyrillic_u_straight_bar 16778417 0x10004B1
+Cyrillic_HA_descender 16778418 0x10004B2
+Cyrillic_ha_descender 16778419 0x10004B3
+Cyrillic_CHE_descender 16778422 0x10004B6
+Cyrillic_che_descender 16778423 0x10004B7
+Cyrillic_CHE_vertstroke 16778424 0x10004B8
+Cyrillic_che_vertstroke 16778425 0x10004B9
+Cyrillic_SHHA 16778426 0x10004BA
+Cyrillic_shha 16778427 0x10004BB
+Cyrillic_SCHWA 16778456 0x10004D8
+Cyrillic_schwa 16778457 0x10004D9
+Cyrillic_I_macron 16778466 0x10004E2
+Cyrillic_i_macron 16778467 0x10004E3
+Cyrillic_O_bar 16778472 0x10004E8
+Cyrillic_o_bar 16778473 0x10004E9
+Cyrillic_U_macron 16778478 0x10004EE
+Cyrillic_u_macron 16778479 0x10004EF
+Armenian_AYB 16778545 0x1000531
+Armenian_BEN 16778546 0x1000532
+Armenian_GIM 16778547 0x1000533
+Armenian_DA 16778548 0x1000534
+Armenian_YECH 16778549 0x1000535
+Armenian_ZA 16778550 0x1000536
+Armenian_E 16778551 0x1000537
+Armenian_AT 16778552 0x1000538
+Armenian_TO 16778553 0x1000539
+Armenian_ZHE 16778554 0x100053A
+Armenian_INI 16778555 0x100053B
+Armenian_LYUN 16778556 0x100053C
+Armenian_KHE 16778557 0x100053D
+Armenian_TSA 16778558 0x100053E
+Armenian_KEN 16778559 0x100053F
+Armenian_HO 16778560 0x1000540
+Armenian_DZA 16778561 0x1000541
+Armenian_GHAT 16778562 0x1000542
+Armenian_TCHE 16778563 0x1000543
+Armenian_MEN 16778564 0x1000544
+Armenian_HI 16778565 0x1000545
+Armenian_NU 16778566 0x1000546
+Armenian_SHA 16778567 0x1000547
+Armenian_VO 16778568 0x1000548
+Armenian_CHA 16778569 0x1000549
+Armenian_PE 16778570 0x100054A
+Armenian_JE 16778571 0x100054B
+Armenian_RA 16778572 0x100054C
+Armenian_SE 16778573 0x100054D
+Armenian_VEV 16778574 0x100054E
+Armenian_TYUN 16778575 0x100054F
+Armenian_RE 16778576 0x1000550
+Armenian_TSO 16778577 0x1000551
+Armenian_VYUN 16778578 0x1000552
+Armenian_PYUR 16778579 0x1000553
+Armenian_KE 16778580 0x1000554
+Armenian_O 16778581 0x1000555
+Armenian_FE 16778582 0x1000556
+Armenian_apostrophe 16778586 0x100055A
+Armenian_accent 16778587 0x100055B
+Armenian_exclam 16778588 0x100055C
+Armenian_separation_mark 16778589 0x100055D
+Armenian_question 16778590 0x100055E
+Armenian_ayb 16778593 0x1000561
+Armenian_ben 16778594 0x1000562
+Armenian_gim 16778595 0x1000563
+Armenian_da 16778596 0x1000564
+Armenian_yech 16778597 0x1000565
+Armenian_za 16778598 0x1000566
+Armenian_e 16778599 0x1000567
+Armenian_at 16778600 0x1000568
+Armenian_to 16778601 0x1000569
+Armenian_zhe 16778602 0x100056A
+Armenian_ini 16778603 0x100056B
+Armenian_lyun 16778604 0x100056C
+Armenian_khe 16778605 0x100056D
+Armenian_tsa 16778606 0x100056E
+Armenian_ken 16778607 0x100056F
+Armenian_ho 16778608 0x1000570
+Armenian_dza 16778609 0x1000571
+Armenian_ghat 16778610 0x1000572
+Armenian_tche 16778611 0x1000573
+Armenian_men 16778612 0x1000574
+Armenian_hi 16778613 0x1000575
+Armenian_nu 16778614 0x1000576
+Armenian_sha 16778615 0x1000577
+Armenian_vo 16778616 0x1000578
+Armenian_cha 16778617 0x1000579
+Armenian_pe 16778618 0x100057A
+Armenian_je 16778619 0x100057B
+Armenian_ra 16778620 0x100057C
+Armenian_se 16778621 0x100057D
+Armenian_vev 16778622 0x100057E
+Armenian_tyun 16778623 0x100057F
+Armenian_re 16778624 0x1000580
+Armenian_tso 16778625 0x1000581
+Armenian_vyun 16778626 0x1000582
+Armenian_pyur 16778627 0x1000583
+Armenian_ke 16778628 0x1000584
+Armenian_o 16778629 0x1000585
+Armenian_fe 16778630 0x1000586
+Armenian_ligature_ew 16778631 0x1000587
+Armenian_full_stop 16778633 0x1000589
+Armenian_hyphen 16778634 0x100058A
+Arabic_madda_above 16778835 0x1000653
+Arabic_hamza_above 16778836 0x1000654
+Arabic_hamza_below 16778837 0x1000655
+Arabic_0 16778848 0x1000660
+Arabic_1 16778849 0x1000661
+Arabic_2 16778850 0x1000662
+Arabic_3 16778851 0x1000663
+Arabic_4 16778852 0x1000664
+Arabic_5 16778853 0x1000665
+Arabic_6 16778854 0x1000666
+Arabic_7 16778855 0x1000667
+Arabic_8 16778856 0x1000668
+Arabic_9 16778857 0x1000669
+Arabic_percent 16778858 0x100066A
+Arabic_superscript_alef 16778864 0x1000670
+Arabic_tteh 16778873 0x1000679
+Arabic_peh 16778878 0x100067E
+Arabic_tcheh 16778886 0x1000686
+Arabic_ddal 16778888 0x1000688
+Arabic_rreh 16778897 0x1000691
+Arabic_jeh 16778904 0x1000698
+Arabic_veh 16778916 0x10006A4
+Arabic_keheh 16778921 0x10006A9
+Arabic_gaf 16778927 0x10006AF
+Arabic_noon_ghunna 16778938 0x10006BA
+Arabic_heh_doachashmee 16778942 0x10006BE
+Arabic_heh_goal 16778945 0x10006C1
+Farsi_yeh 16778956 0x10006CC
+Arabic_yeh_baree 16778962 0x10006D2
+Arabic_fullstop 16778964 0x10006D4
+Farsi_0 16778992 0x10006F0
+Farsi_1 16778993 0x10006F1
+Farsi_2 16778994 0x10006F2
+Farsi_3 16778995 0x10006F3
+Farsi_4 16778996 0x10006F4
+Farsi_5 16778997 0x10006F5
+Farsi_6 16778998 0x10006F6
+Farsi_7 16778999 0x10006F7
+Farsi_8 16779000 0x10006F8
+Farsi_9 16779001 0x10006F9
+Sinh_ng 16780674 0x1000D82
+Sinh_h2 16780675 0x1000D83
+Sinh_a 16780677 0x1000D85
+Sinh_aa 16780678 0x1000D86
+Sinh_ae 16780679 0x1000D87
+Sinh_aee 16780680 0x1000D88
+Sinh_i 16780681 0x1000D89
+Sinh_ii 16780682 0x1000D8A
+Sinh_u 16780683 0x1000D8B
+Sinh_uu 16780684 0x1000D8C
+Sinh_ri 16780685 0x1000D8D
+Sinh_rii 16780686 0x1000D8E
+Sinh_lu 16780687 0x1000D8F
+Sinh_luu 16780688 0x1000D90
+Sinh_e 16780689 0x1000D91
+Sinh_ee 16780690 0x1000D92
+Sinh_ai 16780691 0x1000D93
+Sinh_o 16780692 0x1000D94
+Sinh_oo 16780693 0x1000D95
+Sinh_au 16780694 0x1000D96
+Sinh_ka 16780698 0x1000D9A
+Sinh_kha 16780699 0x1000D9B
+Sinh_ga 16780700 0x1000D9C
+Sinh_gha 16780701 0x1000D9D
+Sinh_ng2 16780702 0x1000D9E
+Sinh_nga 16780703 0x1000D9F
+Sinh_ca 16780704 0x1000DA0
+Sinh_cha 16780705 0x1000DA1
+Sinh_ja 16780706 0x1000DA2
+Sinh_jha 16780707 0x1000DA3
+Sinh_nya 16780708 0x1000DA4
+Sinh_jnya 16780709 0x1000DA5
+Sinh_nja 16780710 0x1000DA6
+Sinh_tta 16780711 0x1000DA7
+Sinh_ttha 16780712 0x1000DA8
+Sinh_dda 16780713 0x1000DA9
+Sinh_ddha 16780714 0x1000DAA
+Sinh_nna 16780715 0x1000DAB
+Sinh_ndda 16780716 0x1000DAC
+Sinh_tha 16780717 0x1000DAD
+Sinh_thha 16780718 0x1000DAE
+Sinh_dha 16780719 0x1000DAF
+Sinh_dhha 16780720 0x1000DB0
+Sinh_na 16780721 0x1000DB1
+Sinh_ndha 16780723 0x1000DB3
+Sinh_pa 16780724 0x1000DB4
+Sinh_pha 16780725 0x1000DB5
+Sinh_ba 16780726 0x1000DB6
+Sinh_bha 16780727 0x1000DB7
+Sinh_ma 16780728 0x1000DB8
+Sinh_mba 16780729 0x1000DB9
+Sinh_ya 16780730 0x1000DBA
+Sinh_ra 16780731 0x1000DBB
+Sinh_la 16780733 0x1000DBD
+Sinh_va 16780736 0x1000DC0
+Sinh_sha 16780737 0x1000DC1
+Sinh_ssha 16780738 0x1000DC2
+Sinh_sa 16780739 0x1000DC3
+Sinh_ha 16780740 0x1000DC4
+Sinh_lla 16780741 0x1000DC5
+Sinh_fa 16780742 0x1000DC6
+Sinh_al 16780746 0x1000DCA
+Sinh_aa2 16780751 0x1000DCF
+Sinh_ae2 16780752 0x1000DD0
+Sinh_aee2 16780753 0x1000DD1
+Sinh_i2 16780754 0x1000DD2
+Sinh_ii2 16780755 0x1000DD3
+Sinh_u2 16780756 0x1000DD4
+Sinh_uu2 16780758 0x1000DD6
+Sinh_ru2 16780760 0x1000DD8
+Sinh_e2 16780761 0x1000DD9
+Sinh_ee2 16780762 0x1000DDA
+Sinh_ai2 16780763 0x1000DDB
+Sinh_o2 16780764 0x1000DDC
+Sinh_oo2 16780765 0x1000DDD
+Sinh_au2 16780766 0x1000DDE
+Sinh_lu2 16780767 0x1000DDF
+Sinh_ruu2 16780786 0x1000DF2
+Sinh_luu2 16780787 0x1000DF3
+Sinh_kunddaliya 16780788 0x1000DF4
+Georgian_an 16781520 0x10010D0
+Georgian_ban 16781521 0x10010D1
+Georgian_gan 16781522 0x10010D2
+Georgian_don 16781523 0x10010D3
+Georgian_en 16781524 0x10010D4
+Georgian_vin 16781525 0x10010D5
+Georgian_zen 16781526 0x10010D6
+Georgian_tan 16781527 0x10010D7
+Georgian_in 16781528 0x10010D8
+Georgian_kan 16781529 0x10010D9
+Georgian_las 16781530 0x10010DA
+Georgian_man 16781531 0x10010DB
+Georgian_nar 16781532 0x10010DC
+Georgian_on 16781533 0x10010DD
+Georgian_par 16781534 0x10010DE
+Georgian_zhar 16781535 0x10010DF
+Georgian_rae 16781536 0x10010E0
+Georgian_san 16781537 0x10010E1
+Georgian_tar 16781538 0x10010E2
+Georgian_un 16781539 0x10010E3
+Georgian_phar 16781540 0x10010E4
+Georgian_khar 16781541 0x10010E5
+Georgian_ghan 16781542 0x10010E6
+Georgian_qar 16781543 0x10010E7
+Georgian_shin 16781544 0x10010E8
+Georgian_chin 16781545 0x10010E9
+Georgian_can 16781546 0x10010EA
+Georgian_jil 16781547 0x10010EB
+Georgian_cil 16781548 0x10010EC
+Georgian_char 16781549 0x10010ED
+Georgian_xan 16781550 0x10010EE
+Georgian_jhan 16781551 0x10010EF
+Georgian_hae 16781552 0x10010F0
+Georgian_he 16781553 0x10010F1
+Georgian_hie 16781554 0x10010F2
+Georgian_we 16781555 0x10010F3
+Georgian_har 16781556 0x10010F4
+Georgian_hoe 16781557 0x10010F5
+Georgian_fi 16781558 0x10010F6
+Babovedot 16784898 0x1001E02
+babovedot 16784899 0x1001E03
+Dabovedot 16784906 0x1001E0A
+dabovedot 16784907 0x1001E0B
+Fabovedot 16784926 0x1001E1E
+fabovedot 16784927 0x1001E1F
+Lbelowdot 16784950 0x1001E36
+lbelowdot 16784951 0x1001E37
+Mabovedot 16784960 0x1001E40
+mabovedot 16784961 0x1001E41
+Pabovedot 16784982 0x1001E56
+pabovedot 16784983 0x1001E57
+Sabovedot 16784992 0x1001E60
+sabovedot 16784993 0x1001E61
+Tabovedot 16785002 0x1001E6A
+tabovedot 16785003 0x1001E6B
+Wgrave 16785024 0x1001E80
+wgrave 16785025 0x1001E81
+Wacute 16785026 0x1001E82
+wacute 16785027 0x1001E83
+Wdiaeresis 16785028 0x1001E84
+wdiaeresis 16785029 0x1001E85
+Xabovedot 16785034 0x1001E8A
+xabovedot 16785035 0x1001E8B
+Abelowdot 16785056 0x1001EA0
+abelowdot 16785057 0x1001EA1
+Ahook 16785058 0x1001EA2
+ahook 16785059 0x1001EA3
+Acircumflexacute 16785060 0x1001EA4
+acircumflexacute 16785061 0x1001EA5
+Acircumflexgrave 16785062 0x1001EA6
+acircumflexgrave 16785063 0x1001EA7
+Acircumflexhook 16785064 0x1001EA8
+acircumflexhook 16785065 0x1001EA9
+Acircumflextilde 16785066 0x1001EAA
+acircumflextilde 16785067 0x1001EAB
+Acircumflexbelowdot 16785068 0x1001EAC
+acircumflexbelowdot 16785069 0x1001EAD
+Abreveacute 16785070 0x1001EAE
+abreveacute 16785071 0x1001EAF
+Abrevegrave 16785072 0x1001EB0
+abrevegrave 16785073 0x1001EB1
+Abrevehook 16785074 0x1001EB2
+abrevehook 16785075 0x1001EB3
+Abrevetilde 16785076 0x1001EB4
+abrevetilde 16785077 0x1001EB5
+Abrevebelowdot 16785078 0x1001EB6
+abrevebelowdot 16785079 0x1001EB7
+Ebelowdot 16785080 0x1001EB8
+ebelowdot 16785081 0x1001EB9
+Ehook 16785082 0x1001EBA
+ehook 16785083 0x1001EBB
+Etilde 16785084 0x1001EBC
+etilde 16785085 0x1001EBD
+Ecircumflexacute 16785086 0x1001EBE
+ecircumflexacute 16785087 0x1001EBF
+Ecircumflexgrave 16785088 0x1001EC0
+ecircumflexgrave 16785089 0x1001EC1
+Ecircumflexhook 16785090 0x1001EC2
+ecircumflexhook 16785091 0x1001EC3
+Ecircumflextilde 16785092 0x1001EC4
+ecircumflextilde 16785093 0x1001EC5
+Ecircumflexbelowdot 16785094 0x1001EC6
+ecircumflexbelowdot 16785095 0x1001EC7
+Ihook 16785096 0x1001EC8
+ihook 16785097 0x1001EC9
+Ibelowdot 16785098 0x1001ECA
+ibelowdot 16785099 0x1001ECB
+Obelowdot 16785100 0x1001ECC
+obelowdot 16785101 0x1001ECD
+Ohook 16785102 0x1001ECE
+ohook 16785103 0x1001ECF
+Ocircumflexacute 16785104 0x1001ED0
+ocircumflexacute 16785105 0x1001ED1
+Ocircumflexgrave 16785106 0x1001ED2
+ocircumflexgrave 16785107 0x1001ED3
+Ocircumflexhook 16785108 0x1001ED4
+ocircumflexhook 16785109 0x1001ED5
+Ocircumflextilde 16785110 0x1001ED6
+ocircumflextilde 16785111 0x1001ED7
+Ocircumflexbelowdot 16785112 0x1001ED8
+ocircumflexbelowdot 16785113 0x1001ED9
+Ohornacute 16785114 0x1001EDA
+ohornacute 16785115 0x1001EDB
+Ohorngrave 16785116 0x1001EDC
+ohorngrave 16785117 0x1001EDD
+Ohornhook 16785118 0x1001EDE
+ohornhook 16785119 0x1001EDF
+Ohorntilde 16785120 0x1001EE0
+ohorntilde 16785121 0x1001EE1
+Ohornbelowdot 16785122 0x1001EE2
+ohornbelowdot 16785123 0x1001EE3
+Ubelowdot 16785124 0x1001EE4
+ubelowdot 16785125 0x1001EE5
+Uhook 16785126 0x1001EE6
+uhook 16785127 0x1001EE7
+Uhornacute 16785128 0x1001EE8
+uhornacute 16785129 0x1001EE9
+Uhorngrave 16785130 0x1001EEA
+uhorngrave 16785131 0x1001EEB
+Uhornhook 16785132 0x1001EEC
+uhornhook 16785133 0x1001EED
+Uhorntilde 16785134 0x1001EEE
+uhorntilde 16785135 0x1001EEF
+Uhornbelowdot 16785136 0x1001EF0
+uhornbelowdot 16785137 0x1001EF1
+Ygrave 16785138 0x1001EF2
+ygrave 16785139 0x1001EF3
+Ybelowdot 16785140 0x1001EF4
+ybelowdot 16785141 0x1001EF5
+Yhook 16785142 0x1001EF6
+yhook 16785143 0x1001EF7
+Ytilde 16785144 0x1001EF8
+ytilde 16785145 0x1001EF9
+zerosuperior 16785520 0x1002070
+foursuperior 16785524 0x1002074
+fivesuperior 16785525 0x1002075
+sixsuperior 16785526 0x1002076
+sevensuperior 16785527 0x1002077
+eightsuperior 16785528 0x1002078
+ninesuperior 16785529 0x1002079
+zerosubscript 16785536 0x1002080
+onesubscript 16785537 0x1002081
+twosubscript 16785538 0x1002082
+threesubscript 16785539 0x1002083
+foursubscript 16785540 0x1002084
+fivesubscript 16785541 0x1002085
+sixsubscript 16785542 0x1002086
+sevensubscript 16785543 0x1002087
+eightsubscript 16785544 0x1002088
+ninesubscript 16785545 0x1002089
+EcuSign 16785568 0x10020A0
+ColonSign 16785569 0x10020A1
+CruzeiroSign 16785570 0x10020A2
+FFrancSign 16785571 0x10020A3
+LiraSign 16785572 0x10020A4
+MillSign 16785573 0x10020A5
+NairaSign 16785574 0x10020A6
+PesetaSign 16785575 0x10020A7
+RupeeSign 16785576 0x10020A8
+WonSign 16785577 0x10020A9
+NewSheqelSign 16785578 0x10020AA
+DongSign 16785579 0x10020AB
+partdifferential 16785922 0x1002202
+emptyset 16785925 0x1002205
+elementof 16785928 0x1002208
+notelementof 16785929 0x1002209
+containsas 16785931 0x100220B
+squareroot 16785946 0x100221A
+cuberoot 16785947 0x100221B
+fourthroot 16785948 0x100221C
+dintegral 16785964 0x100222C
+tintegral 16785965 0x100222D
+because 16785973 0x1002235
+notapproxeq 16785991 0x1002247
+approxeq 16785992 0x1002248
+notidentical 16786018 0x1002262
+stricteq 16786019 0x1002263
+braille_blank 16787456 0x1002800
+braille_dots_1 16787457 0x1002801
+braille_dots_2 16787458 0x1002802
+braille_dots_12 16787459 0x1002803
+braille_dots_3 16787460 0x1002804
+braille_dots_13 16787461 0x1002805
+braille_dots_23 16787462 0x1002806
+braille_dots_123 16787463 0x1002807
+braille_dots_4 16787464 0x1002808
+braille_dots_14 16787465 0x1002809
+braille_dots_24 16787466 0x100280A
+braille_dots_124 16787467 0x100280B
+braille_dots_34 16787468 0x100280C
+braille_dots_134 16787469 0x100280D
+braille_dots_234 16787470 0x100280E
+braille_dots_1234 16787471 0x100280F
+braille_dots_5 16787472 0x1002810
+braille_dots_15 16787473 0x1002811
+braille_dots_25 16787474 0x1002812
+braille_dots_125 16787475 0x1002813
+braille_dots_35 16787476 0x1002814
+braille_dots_135 16787477 0x1002815
+braille_dots_235 16787478 0x1002816
+braille_dots_1235 16787479 0x1002817
+braille_dots_45 16787480 0x1002818
+braille_dots_145 16787481 0x1002819
+braille_dots_245 16787482 0x100281A
+braille_dots_1245 16787483 0x100281B
+braille_dots_345 16787484 0x100281C
+braille_dots_1345 16787485 0x100281D
+braille_dots_2345 16787486 0x100281E
+braille_dots_12345 16787487 0x100281F
+braille_dots_6 16787488 0x1002820
+braille_dots_16 16787489 0x1002821
+braille_dots_26 16787490 0x1002822
+braille_dots_126 16787491 0x1002823
+braille_dots_36 16787492 0x1002824
+braille_dots_136 16787493 0x1002825
+braille_dots_236 16787494 0x1002826
+braille_dots_1236 16787495 0x1002827
+braille_dots_46 16787496 0x1002828
+braille_dots_146 16787497 0x1002829
+braille_dots_246 16787498 0x100282A
+braille_dots_1246 16787499 0x100282B
+braille_dots_346 16787500 0x100282C
+braille_dots_1346 16787501 0x100282D
+braille_dots_2346 16787502 0x100282E
+braille_dots_12346 16787503 0x100282F
+braille_dots_56 16787504 0x1002830
+braille_dots_156 16787505 0x1002831
+braille_dots_256 16787506 0x1002832
+braille_dots_1256 16787507 0x1002833
+braille_dots_356 16787508 0x1002834
+braille_dots_1356 16787509 0x1002835
+braille_dots_2356 16787510 0x1002836
+braille_dots_12356 16787511 0x1002837
+braille_dots_456 16787512 0x1002838
+braille_dots_1456 16787513 0x1002839
+braille_dots_2456 16787514 0x100283A
+braille_dots_12456 16787515 0x100283B
+braille_dots_3456 16787516 0x100283C
+braille_dots_13456 16787517 0x100283D
+braille_dots_23456 16787518 0x100283E
+braille_dots_123456 16787519 0x100283F
+braille_dots_7 16787520 0x1002840
+braille_dots_17 16787521 0x1002841
+braille_dots_27 16787522 0x1002842
+braille_dots_127 16787523 0x1002843
+braille_dots_37 16787524 0x1002844
+braille_dots_137 16787525 0x1002845
+braille_dots_237 16787526 0x1002846
+braille_dots_1237 16787527 0x1002847
+braille_dots_47 16787528 0x1002848
+braille_dots_147 16787529 0x1002849
+braille_dots_247 16787530 0x100284A
+braille_dots_1247 16787531 0x100284B
+braille_dots_347 16787532 0x100284C
+braille_dots_1347 16787533 0x100284D
+braille_dots_2347 16787534 0x100284E
+braille_dots_12347 16787535 0x100284F
+braille_dots_57 16787536 0x1002850
+braille_dots_157 16787537 0x1002851
+braille_dots_257 16787538 0x1002852
+braille_dots_1257 16787539 0x1002853
+braille_dots_357 16787540 0x1002854
+braille_dots_1357 16787541 0x1002855
+braille_dots_2357 16787542 0x1002856
+braille_dots_12357 16787543 0x1002857
+braille_dots_457 16787544 0x1002858
+braille_dots_1457 16787545 0x1002859
+braille_dots_2457 16787546 0x100285A
+braille_dots_12457 16787547 0x100285B
+braille_dots_3457 16787548 0x100285C
+braille_dots_13457 16787549 0x100285D
+braille_dots_23457 16787550 0x100285E
+braille_dots_123457 16787551 0x100285F
+braille_dots_67 16787552 0x1002860
+braille_dots_167 16787553 0x1002861
+braille_dots_267 16787554 0x1002862
+braille_dots_1267 16787555 0x1002863
+braille_dots_367 16787556 0x1002864
+braille_dots_1367 16787557 0x1002865
+braille_dots_2367 16787558 0x1002866
+braille_dots_12367 16787559 0x1002867
+braille_dots_467 16787560 0x1002868
+braille_dots_1467 16787561 0x1002869
+braille_dots_2467 16787562 0x100286A
+braille_dots_12467 16787563 0x100286B
+braille_dots_3467 16787564 0x100286C
+braille_dots_13467 16787565 0x100286D
+braille_dots_23467 16787566 0x100286E
+braille_dots_123467 16787567 0x100286F
+braille_dots_567 16787568 0x1002870
+braille_dots_1567 16787569 0x1002871
+braille_dots_2567 16787570 0x1002872
+braille_dots_12567 16787571 0x1002873
+braille_dots_3567 16787572 0x1002874
+braille_dots_13567 16787573 0x1002875
+braille_dots_23567 16787574 0x1002876
+braille_dots_123567 16787575 0x1002877
+braille_dots_4567 16787576 0x1002878
+braille_dots_14567 16787577 0x1002879
+braille_dots_24567 16787578 0x100287A
+braille_dots_124567 16787579 0x100287B
+braille_dots_34567 16787580 0x100287C
+braille_dots_134567 16787581 0x100287D
+braille_dots_234567 16787582 0x100287E
+braille_dots_1234567 16787583 0x100287F
+braille_dots_8 16787584 0x1002880
+braille_dots_18 16787585 0x1002881
+braille_dots_28 16787586 0x1002882
+braille_dots_128 16787587 0x1002883
+braille_dots_38 16787588 0x1002884
+braille_dots_138 16787589 0x1002885
+braille_dots_238 16787590 0x1002886
+braille_dots_1238 16787591 0x1002887
+braille_dots_48 16787592 0x1002888
+braille_dots_148 16787593 0x1002889
+braille_dots_248 16787594 0x100288A
+braille_dots_1248 16787595 0x100288B
+braille_dots_348 16787596 0x100288C
+braille_dots_1348 16787597 0x100288D
+braille_dots_2348 16787598 0x100288E
+braille_dots_12348 16787599 0x100288F
+braille_dots_58 16787600 0x1002890
+braille_dots_158 16787601 0x1002891
+braille_dots_258 16787602 0x1002892
+braille_dots_1258 16787603 0x1002893
+braille_dots_358 16787604 0x1002894
+braille_dots_1358 16787605 0x1002895
+braille_dots_2358 16787606 0x1002896
+braille_dots_12358 16787607 0x1002897
+braille_dots_458 16787608 0x1002898
+braille_dots_1458 16787609 0x1002899
+braille_dots_2458 16787610 0x100289A
+braille_dots_12458 16787611 0x100289B
+braille_dots_3458 16787612 0x100289C
+braille_dots_13458 16787613 0x100289D
+braille_dots_23458 16787614 0x100289E
+braille_dots_123458 16787615 0x100289F
+braille_dots_68 16787616 0x10028A0
+braille_dots_168 16787617 0x10028A1
+braille_dots_268 16787618 0x10028A2
+braille_dots_1268 16787619 0x10028A3
+braille_dots_368 16787620 0x10028A4
+braille_dots_1368 16787621 0x10028A5
+braille_dots_2368 16787622 0x10028A6
+braille_dots_12368 16787623 0x10028A7
+braille_dots_468 16787624 0x10028A8
+braille_dots_1468 16787625 0x10028A9
+braille_dots_2468 16787626 0x10028AA
+braille_dots_12468 16787627 0x10028AB
+braille_dots_3468 16787628 0x10028AC
+braille_dots_13468 16787629 0x10028AD
+braille_dots_23468 16787630 0x10028AE
+braille_dots_123468 16787631 0x10028AF
+braille_dots_568 16787632 0x10028B0
+braille_dots_1568 16787633 0x10028B1
+braille_dots_2568 16787634 0x10028B2
+braille_dots_12568 16787635 0x10028B3
+braille_dots_3568 16787636 0x10028B4
+braille_dots_13568 16787637 0x10028B5
+braille_dots_23568 16787638 0x10028B6
+braille_dots_123568 16787639 0x10028B7
+braille_dots_4568 16787640 0x10028B8
+braille_dots_14568 16787641 0x10028B9
+braille_dots_24568 16787642 0x10028BA
+braille_dots_124568 16787643 0x10028BB
+braille_dots_34568 16787644 0x10028BC
+braille_dots_134568 16787645 0x10028BD
+braille_dots_234568 16787646 0x10028BE
+braille_dots_1234568 16787647 0x10028BF
+braille_dots_78 16787648 0x10028C0
+braille_dots_178 16787649 0x10028C1
+braille_dots_278 16787650 0x10028C2
+braille_dots_1278 16787651 0x10028C3
+braille_dots_378 16787652 0x10028C4
+braille_dots_1378 16787653 0x10028C5
+braille_dots_2378 16787654 0x10028C6
+braille_dots_12378 16787655 0x10028C7
+braille_dots_478 16787656 0x10028C8
+braille_dots_1478 16787657 0x10028C9
+braille_dots_2478 16787658 0x10028CA
+braille_dots_12478 16787659 0x10028CB
+braille_dots_3478 16787660 0x10028CC
+braille_dots_13478 16787661 0x10028CD
+braille_dots_23478 16787662 0x10028CE
+braille_dots_123478 16787663 0x10028CF
+braille_dots_578 16787664 0x10028D0
+braille_dots_1578 16787665 0x10028D1
+braille_dots_2578 16787666 0x10028D2
+braille_dots_12578 16787667 0x10028D3
+braille_dots_3578 16787668 0x10028D4
+braille_dots_13578 16787669 0x10028D5
+braille_dots_23578 16787670 0x10028D6
+braille_dots_123578 16787671 0x10028D7
+braille_dots_4578 16787672 0x10028D8
+braille_dots_14578 16787673 0x10028D9
+braille_dots_24578 16787674 0x10028DA
+braille_dots_124578 16787675 0x10028DB
+braille_dots_34578 16787676 0x10028DC
+braille_dots_134578 16787677 0x10028DD
+braille_dots_234578 16787678 0x10028DE
+braille_dots_1234578 16787679 0x10028DF
+braille_dots_678 16787680 0x10028E0
+braille_dots_1678 16787681 0x10028E1
+braille_dots_2678 16787682 0x10028E2
+braille_dots_12678 16787683 0x10028E3
+braille_dots_3678 16787684 0x10028E4
+braille_dots_13678 16787685 0x10028E5
+braille_dots_23678 16787686 0x10028E6
+braille_dots_123678 16787687 0x10028E7
+braille_dots_4678 16787688 0x10028E8
+braille_dots_14678 16787689 0x10028E9
+braille_dots_24678 16787690 0x10028EA
+braille_dots_124678 16787691 0x10028EB
+braille_dots_34678 16787692 0x10028EC
+braille_dots_134678 16787693 0x10028ED
+braille_dots_234678 16787694 0x10028EE
+braille_dots_1234678 16787695 0x10028EF
+braille_dots_5678 16787696 0x10028F0
+braille_dots_15678 16787697 0x10028F1
+braille_dots_25678 16787698 0x10028F2
+braille_dots_125678 16787699 0x10028F3
+braille_dots_35678 16787700 0x10028F4
+braille_dots_135678 16787701 0x10028F5
+braille_dots_235678 16787702 0x10028F6
+braille_dots_1235678 16787703 0x10028F7
+braille_dots_45678 16787704 0x10028F8
+braille_dots_145678 16787705 0x10028F9
+braille_dots_245678 16787706 0x10028FA
+braille_dots_1245678 16787707 0x10028FB
+braille_dots_345678 16787708 0x10028FC
+braille_dots_1345678 16787709 0x10028FD
+braille_dots_2345678 16787710 0x10028FE
+braille_dots_12345678 16787711 0x10028FF
+SunFA_Grave 268828416 0x1005FF00
+SunFA_Circum 268828417 0x1005FF01
+SunFA_Tilde 268828418 0x1005FF02
+SunFA_Acute 268828419 0x1005FF03
+SunFA_Diaeresis 268828420 0x1005FF04
+SunFA_Cedilla 268828421 0x1005FF05
+SunF36 268828432 0x1005FF10
+SunF37 268828433 0x1005FF11
+SunSys_Req 268828512 0x1005FF60
+SunProps 268828528 0x1005FF70
+SunFront 268828529 0x1005FF71
+SunCopy 268828530 0x1005FF72
+SunOpen 268828531 0x1005FF73
+SunPaste 268828532 0x1005FF74
+SunCut 268828533 0x1005FF75
+SunPowerSwitch 268828534 0x1005FF76
+SunAudioLowerVolume 268828535 0x1005FF77
+SunAudioMute 268828536 0x1005FF78
+SunAudioRaiseVolume 268828537 0x1005FF79
+SunVideoDegauss 268828538 0x1005FF7A
+SunVideoLowerBrightness 268828539 0x1005FF7B
+SunVideoRaiseBrightness 268828540 0x1005FF7C
+SunPowerSwitchShift 268828541 0x1005FF7D
+XF86Switch_VT_1 269024769 0x1008FE01
+XF86Switch_VT_2 269024770 0x1008FE02
+XF86Switch_VT_3 269024771 0x1008FE03
+XF86Switch_VT_4 269024772 0x1008FE04
+XF86Switch_VT_5 269024773 0x1008FE05
+XF86Switch_VT_6 269024774 0x1008FE06
+XF86Switch_VT_7 269024775 0x1008FE07
+XF86Switch_VT_8 269024776 0x1008FE08
+XF86Switch_VT_9 269024777 0x1008FE09
+XF86Switch_VT_10 269024778 0x1008FE0A
+XF86Switch_VT_11 269024779 0x1008FE0B
+XF86Switch_VT_12 269024780 0x1008FE0C
+XF86Ungrab 269024800 0x1008FE20
+XF86ClearGrab 269024801 0x1008FE21
+XF86Next_VMode 269024802 0x1008FE22
+XF86Prev_VMode 269024803 0x1008FE23
+XF86LogWindowTree 269024804 0x1008FE24
+XF86LogGrabInfo 269024805 0x1008FE25
+XF86ModeLock 269025025 0x1008FF01
+XF86MonBrightnessUp 269025026 0x1008FF02
+XF86MonBrightnessDown 269025027 0x1008FF03
+XF86KbdLightOnOff 269025028 0x1008FF04
+XF86KbdBrightnessUp 269025029 0x1008FF05
+XF86KbdBrightnessDown 269025030 0x1008FF06
+XF86MonBrightnessCycle 269025031 0x1008FF07
+XF86Standby 269025040 0x1008FF10
XF86AudioLowerVolume 269025041 0x1008FF11
XF86AudioMute 269025042 0x1008FF12
XF86AudioRaiseVolume 269025043 0x1008FF13
@@ -927,6 +2093,156 @@ XF86AudioPlay 269025044 0x1008FF14
XF86AudioStop 269025045 0x1008FF15
XF86AudioPrev 269025046 0x1008FF16
XF86AudioNext 269025047 0x1008FF17
+XF86HomePage 269025048 0x1008FF18
+XF86Mail 269025049 0x1008FF19
+XF86Start 269025050 0x1008FF1A
+XF86Search 269025051 0x1008FF1B
+XF86AudioRecord 269025052 0x1008FF1C
+XF86Calculator 269025053 0x1008FF1D
+XF86Memo 269025054 0x1008FF1E
+XF86ToDoList 269025055 0x1008FF1F
+XF86Calendar 269025056 0x1008FF20
+XF86PowerDown 269025057 0x1008FF21
+XF86ContrastAdjust 269025058 0x1008FF22
+XF86RockerUp 269025059 0x1008FF23
+XF86RockerDown 269025060 0x1008FF24
+XF86RockerEnter 269025061 0x1008FF25
+XF86Back 269025062 0x1008FF26
+XF86Forward 269025063 0x1008FF27
+XF86Stop 269025064 0x1008FF28
+XF86Refresh 269025065 0x1008FF29
+XF86PowerOff 269025066 0x1008FF2A
+XF86WakeUp 269025067 0x1008FF2B
+XF86Eject 269025068 0x1008FF2C
+XF86ScreenSaver 269025069 0x1008FF2D
+XF86WWW 269025070 0x1008FF2E
+XF86Sleep 269025071 0x1008FF2F
+XF86Favorites 269025072 0x1008FF30
+XF86AudioPause 269025073 0x1008FF31
+XF86AudioMedia 269025074 0x1008FF32
+XF86MyComputer 269025075 0x1008FF33
+XF86VendorHome 269025076 0x1008FF34
+XF86LightBulb 269025077 0x1008FF35
+XF86Shop 269025078 0x1008FF36
+XF86History 269025079 0x1008FF37
+XF86OpenURL 269025080 0x1008FF38
+XF86AddFavorite 269025081 0x1008FF39
+XF86HotLinks 269025082 0x1008FF3A
+XF86BrightnessAdjust 269025083 0x1008FF3B
+XF86Finance 269025084 0x1008FF3C
+XF86Community 269025085 0x1008FF3D
+XF86AudioRewind 269025086 0x1008FF3E
+XF86BackForward 269025087 0x1008FF3F
+XF86Launch0 269025088 0x1008FF40
+XF86Launch1 269025089 0x1008FF41
+XF86Launch2 269025090 0x1008FF42
+XF86Launch3 269025091 0x1008FF43
+XF86Launch4 269025092 0x1008FF44
+XF86Launch5 269025093 0x1008FF45
+XF86Launch6 269025094 0x1008FF46
+XF86Launch7 269025095 0x1008FF47
+XF86Launch8 269025096 0x1008FF48
+XF86Launch9 269025097 0x1008FF49
+XF86LaunchA 269025098 0x1008FF4A
+XF86LaunchB 269025099 0x1008FF4B
+XF86LaunchC 269025100 0x1008FF4C
+XF86LaunchD 269025101 0x1008FF4D
+XF86LaunchE 269025102 0x1008FF4E
+XF86LaunchF 269025103 0x1008FF4F
+XF86ApplicationLeft 269025104 0x1008FF50
+XF86ApplicationRight 269025105 0x1008FF51
+XF86Book 269025106 0x1008FF52
+XF86CD 269025107 0x1008FF53
+XF86Calculater 269025108 0x1008FF54
+XF86Clear 269025109 0x1008FF55
+XF86Close 269025110 0x1008FF56
+XF86Copy 269025111 0x1008FF57
+XF86Cut 269025112 0x1008FF58
+XF86Display 269025113 0x1008FF59
+XF86DOS 269025114 0x1008FF5A
+XF86Documents 269025115 0x1008FF5B
+XF86Excel 269025116 0x1008FF5C
+XF86Explorer 269025117 0x1008FF5D
+XF86Game 269025118 0x1008FF5E
+XF86Go 269025119 0x1008FF5F
+XF86iTouch 269025120 0x1008FF60
+XF86LogOff 269025121 0x1008FF61
+XF86Market 269025122 0x1008FF62
+XF86Meeting 269025123 0x1008FF63
+XF86MenuKB 269025125 0x1008FF65
+XF86MenuPB 269025126 0x1008FF66
+XF86MySites 269025127 0x1008FF67
+XF86New 269025128 0x1008FF68
+XF86News 269025129 0x1008FF69
+XF86OfficeHome 269025130 0x1008FF6A
+XF86Open 269025131 0x1008FF6B
+XF86Option 269025132 0x1008FF6C
+XF86Paste 269025133 0x1008FF6D
+XF86Phone 269025134 0x1008FF6E
+XF86Q 269025136 0x1008FF70
+XF86Reply 269025138 0x1008FF72
+XF86Reload 269025139 0x1008FF73
+XF86RotateWindows 269025140 0x1008FF74
+XF86RotationPB 269025141 0x1008FF75
+XF86RotationKB 269025142 0x1008FF76
+XF86Save 269025143 0x1008FF77
+XF86ScrollUp 269025144 0x1008FF78
+XF86ScrollDown 269025145 0x1008FF79
+XF86ScrollClick 269025146 0x1008FF7A
+XF86Send 269025147 0x1008FF7B
+XF86Spell 269025148 0x1008FF7C
+XF86SplitScreen 269025149 0x1008FF7D
+XF86Support 269025150 0x1008FF7E
+XF86TaskPane 269025151 0x1008FF7F
+XF86Terminal 269025152 0x1008FF80
+XF86Tools 269025153 0x1008FF81
+XF86Travel 269025154 0x1008FF82
+XF86UserPB 269025156 0x1008FF84
+XF86User1KB 269025157 0x1008FF85
+XF86User2KB 269025158 0x1008FF86
+XF86Video 269025159 0x1008FF87
+XF86WheelButton 269025160 0x1008FF88
+XF86Word 269025161 0x1008FF89
+XF86Xfer 269025162 0x1008FF8A
+XF86ZoomIn 269025163 0x1008FF8B
+XF86ZoomOut 269025164 0x1008FF8C
+XF86Away 269025165 0x1008FF8D
+XF86Messenger 269025166 0x1008FF8E
+XF86WebCam 269025167 0x1008FF8F
+XF86MailForward 269025168 0x1008FF90
+XF86Pictures 269025169 0x1008FF91
+XF86Music 269025170 0x1008FF92
+XF86Battery 269025171 0x1008FF93
+XF86Bluetooth 269025172 0x1008FF94
+XF86WLAN 269025173 0x1008FF95
+XF86UWB 269025174 0x1008FF96
+XF86AudioForward 269025175 0x1008FF97
+XF86AudioRepeat 269025176 0x1008FF98
+XF86AudioRandomPlay 269025177 0x1008FF99
+XF86Subtitle 269025178 0x1008FF9A
+XF86AudioCycleTrack 269025179 0x1008FF9B
+XF86CycleAngle 269025180 0x1008FF9C
+XF86FrameBack 269025181 0x1008FF9D
+XF86FrameForward 269025182 0x1008FF9E
+XF86Time 269025183 0x1008FF9F
+XF86Select 269025184 0x1008FFA0
+XF86View 269025185 0x1008FFA1
+XF86TopMenu 269025186 0x1008FFA2
+XF86Red 269025187 0x1008FFA3
+XF86Green 269025188 0x1008FFA4
+XF86Yellow 269025189 0x1008FFA5
+XF86Blue 269025190 0x1008FFA6
+XF86Suspend 269025191 0x1008FFA7
+XF86Hibernate 269025192 0x1008FFA8
+XF86TouchpadToggle 269025193 0x1008FFA9
+XF86TouchpadOn 269025200 0x1008FFB0
+XF86TouchpadOff 269025201 0x1008FFB1
+XF86AudioMicMute 269025202 0x1008FFB2
+XF86Keyboard 269025203 0x1008FFB3
+XF86WWAN 269025204 0x1008FFB4
+XF86RFKill 269025205 0x1008FFB5
+XF86AudioPreset 269025206 0x1008FFB6
+XF86RotationLockToggle 269025207 0x1008FFB7
.CE
.SH "SEE ALSO"
bind(n), event(n)
diff --git a/doc/listbox.n b/doc/listbox.n
index 66b75b9..ef3ae1c 100644
--- a/doc/listbox.n
+++ b/doc/listbox.n
@@ -384,15 +384,16 @@ total width of the listbox text is off-screen to the left.
This command shifts the view in the window left or right according to
\fInumber\fR and \fIwhat\fR.
\fINumber\fR must be an integer.
-\fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation
+\fIWhat\fR must be either \fBpages\fR or \fBunits\fR or an abbreviation
of one of these.
-If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by
-\fInumber\fR character units (the width of the \fB0\fR character)
-on the display; if it is \fBpages\fR then the view adjusts by
+If \fIwhat\fR is \fBpages\fR then the view adjusts by
\fInumber\fR screenfuls.
If \fInumber\fR is negative then characters farther to the left
become visible; if it is positive then characters farther to the right
become visible.
+If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by
+\fInumber\fR character units (the width of the \fB0\fR character)
+on the display.
.RE
.TP
\fIpathName \fByview \fR?\fIargs\fR?
@@ -431,13 +432,14 @@ way through the listbox, and so on.
This command adjusts the view in the window up or down according to
\fInumber\fR and \fIwhat\fR.
\fINumber\fR must be an integer.
-\fIWhat\fR must be either \fBunits\fR or \fBpages\fR.
-If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by
-\fInumber\fR lines; if it is \fBpages\fR then
+\fIWhat\fR must be either \fBpages\fR or \fBunits\fR.
+If \fIwhat\fR is \fBpages\fR then
the view adjusts by \fInumber\fR screenfuls.
If \fInumber\fR is negative then earlier elements
become visible; if it is positive then later elements
become visible.
+If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by
+\fInumber\fR lines.
.RE
.SH "DEFAULT BINDINGS"
.PP
diff --git a/doc/man.macros b/doc/man.macros
new file mode 100644
index 0000000..ddd073d
--- /dev/null
+++ b/doc/man.macros
@@ -0,0 +1,267 @@
+.\" The -*- nroff -*- definitions below are for supplemental macros used
+.\" in Tcl/Tk manual entries.
+.\"
+.\" .AP type name in/out ?indent?
+.\" Start paragraph describing an argument to a library procedure.
+.\" type is type of argument (int, etc.), in/out is either "in", "out",
+.\" or "in/out" to describe whether procedure reads or modifies arg,
+.\" and indent is equivalent to second arg of .IP (shouldn't ever be
+.\" needed; use .AS below instead)
+.\"
+.\" .AS ?type? ?name?
+.\" Give maximum sizes of arguments for setting tab stops. Type and
+.\" name are examples of largest possible arguments that will be passed
+.\" to .AP later. If args are omitted, default tab stops are used.
+.\"
+.\" .BS
+.\" Start box enclosure. From here until next .BE, everything will be
+.\" enclosed in one large box.
+.\"
+.\" .BE
+.\" End of box enclosure.
+.\"
+.\" .CS
+.\" Begin code excerpt.
+.\"
+.\" .CE
+.\" End code excerpt.
+.\"
+.\" .VS ?version? ?br?
+.\" Begin vertical sidebar, for use in marking newly-changed parts
+.\" of man pages. The first argument is ignored and used for recording
+.\" the version when the .VS was added, so that the sidebars can be
+.\" found and removed when they reach a certain age. If another argument
+.\" is present, then a line break is forced before starting the sidebar.
+.\"
+.\" .VE
+.\" End of vertical sidebar.
+.\"
+.\" .DS
+.\" Begin an indented unfilled display.
+.\"
+.\" .DE
+.\" End of indented unfilled display.
+.\"
+.\" .SO ?manpage?
+.\" Start of list of standard options for a Tk widget. The manpage
+.\" argument defines where to look up the standard options; if
+.\" omitted, defaults to "options". The options follow on successive
+.\" lines, in three columns separated by tabs.
+.\"
+.\" .SE
+.\" End of list of standard options for a Tk widget.
+.\"
+.\" .OP cmdName dbName dbClass
+.\" Start of description of a specific option. cmdName gives the
+.\" option's name as specified in the class command, dbName gives
+.\" the option's name in the option database, and dbClass gives
+.\" the option's class in the option database.
+.\"
+.\" .UL arg1 arg2
+.\" Print arg1 underlined, then print arg2 normally.
+.\"
+.\" .QW arg1 ?arg2?
+.\" Print arg1 in quotes, then arg2 normally (for trailing punctuation).
+.\"
+.\" .PQ arg1 ?arg2?
+.\" Print an open parenthesis, arg1 in quotes, then arg2 normally
+.\" (for trailing punctuation) and then a closing parenthesis.
+.\"
+.\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
+.if t .wh -1.3i ^B
+.nr ^l \n(.l
+.ad b
+.\" # Start an argument description
+.de AP
+.ie !"\\$4"" .TP \\$4
+.el \{\
+. ie !"\\$2"" .TP \\n()Cu
+. el .TP 15
+.\}
+.ta \\n()Au \\n()Bu
+.ie !"\\$3"" \{\
+\&\\$1 \\fI\\$2\\fP (\\$3)
+.\".b
+.\}
+.el \{\
+.br
+.ie !"\\$2"" \{\
+\&\\$1 \\fI\\$2\\fP
+.\}
+.el \{\
+\&\\fI\\$1\\fP
+.\}
+.\}
+..
+.\" # define tabbing values for .AP
+.de AS
+.nr )A 10n
+.if !"\\$1"" .nr )A \\w'\\$1'u+3n
+.nr )B \\n()Au+15n
+.\"
+.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
+.nr )C \\n()Bu+\\w'(in/out)'u+2n
+..
+.AS Tcl_Interp Tcl_CreateInterp in/out
+.\" # BS - start boxed text
+.\" # ^y = starting y location
+.\" # ^b = 1
+.de BS
+.br
+.mk ^y
+.nr ^b 1u
+.if n .nf
+.if n .ti 0
+.if n \l'\\n(.lu\(ul'
+.if n .fi
+..
+.\" # BE - end boxed text (draw box now)
+.de BE
+.nf
+.ti 0
+.mk ^t
+.ie n \l'\\n(^lu\(ul'
+.el \{\
+.\" Draw four-sided box normally, but don't draw top of
+.\" box if the box started on an earlier page.
+.ie !\\n(^b-1 \{\
+\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
+.\}
+.el \}\
+\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
+.\}
+.\}
+.fi
+.br
+.nr ^b 0
+..
+.\" # VS - start vertical sidebar
+.\" # ^Y = starting y location
+.\" # ^v = 1 (for troff; for nroff this doesn't matter)
+.de VS
+.if !"\\$2"" .br
+.mk ^Y
+.ie n 'mc \s12\(br\s0
+.el .nr ^v 1u
+..
+.\" # VE - end of vertical sidebar
+.de VE
+.ie n 'mc
+.el \{\
+.ev 2
+.nf
+.ti 0
+.mk ^t
+\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
+.sp -1
+.fi
+.ev
+.\}
+.nr ^v 0
+..
+.\" # Special macro to handle page bottom: finish off current
+.\" # box/sidebar if in box/sidebar mode, then invoked standard
+.\" # page bottom macro.
+.de ^B
+.ev 2
+'ti 0
+'nf
+.mk ^t
+.if \\n(^b \{\
+.\" Draw three-sided box if this is the box's first page,
+.\" draw two sides but no top otherwise.
+.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
+.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
+.\}
+.if \\n(^v \{\
+.nr ^x \\n(^tu+1v-\\n(^Yu
+\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
+.\}
+.bp
+'fi
+.ev
+.if \\n(^b \{\
+.mk ^y
+.nr ^b 2
+.\}
+.if \\n(^v \{\
+.mk ^Y
+.\}
+..
+.\" # DS - begin display
+.de DS
+.RS
+.nf
+.sp
+..
+.\" # DE - end display
+.de DE
+.fi
+.RE
+.sp
+..
+.\" # SO - start of list of standard options
+.de SO
+'ie '\\$1'' .ds So \\fBoptions\\fR
+'el .ds So \\fB\\$1\\fR
+.SH "STANDARD OPTIONS"
+.LP
+.nf
+.ta 5.5c 11c
+.ft B
+..
+.\" # SE - end of list of standard options
+.de SE
+.fi
+.ft R
+.LP
+See the \\*(So manual entry for details on the standard options.
+..
+.\" # OP - start of full description for a single option
+.de OP
+.LP
+.nf
+.ta 4c
+Command-Line Name: \\fB\\$1\\fR
+Database Name: \\fB\\$2\\fR
+Database Class: \\fB\\$3\\fR
+.fi
+.IP
+..
+.\" # CS - begin code excerpt
+.de CS
+.RS
+.nf
+.ta .25i .5i .75i 1i
+..
+.\" # CE - end code excerpt
+.de CE
+.fi
+.RE
+..
+.\" # UL - underline word
+.de UL
+\\$1\l'|0\(ul'\\$2
+..
+.\" # QW - apply quotation marks to word
+.de QW
+.ie '\\*(lq'"' ``\\$1''\\$2
+.\"" fix emacs highlighting
+.el \\*(lq\\$1\\*(rq\\$2
+..
+.\" # PQ - apply parens and quotation marks to word
+.de PQ
+.ie '\\*(lq'"' (``\\$1''\\$2)\\$3
+.\"" fix emacs highlighting
+.el (\\*(lq\\$1\\*(rq\\$2)\\$3
+..
+.\" # QR - quoted range
+.de QR
+.ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3
+.\"" fix emacs highlighting
+.el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3
+..
+.\" # MT - "empty" string
+.de MT
+.QW ""
+..
diff --git a/doc/panedwindow.n b/doc/panedwindow.n
index 40997a9..9fc2b72 100644
--- a/doc/panedwindow.n
+++ b/doc/panedwindow.n
@@ -331,7 +331,7 @@ fill, and the containing toplevel is resized), space is added to the final
(rightmost or bottommost) pane in the window.
.PP
Unlike slave windows managed by e.g. pack or grid, the panes managed by a
-panedwindow do not change width or height to accomodate changes in the
+panedwindow do not change width or height to accommodate changes in the
requested widths or heights of the panes, once these have become mapped.
Therefore it may be advisable, particularly when creating layouts
interactively, to not add a pane to the panedwindow widget until after the
diff --git a/doc/photo.n b/doc/photo.n
index d875098..2673985 100644
--- a/doc/photo.n
+++ b/doc/photo.n
@@ -551,6 +551,60 @@ an additional alpha filtering for the overall image, which allows the
background on which the image is displayed to show through. This
usually also has the effect of desaturating the image. The
\fIalphaValue\fR must be between 0.0 and 1.0.
+.TP
+\fBsvg \-dpi\fI dpiValue\fB \-scale\fI scaleValue\fB \-scaletowidth \fI width\fB \-scaletoheight\fI height\fR
+.
+\fIdpiValue\fR is used in conversion between given coordinates and
+screen resolution. The value must be greater than 0 and the default
+value is 96.
+\fIscaleValue\fR is used to scale the resulting image. The value must
+be greater than 0 and the default value is 1.
+\fIwidth\fR and \fIheight\fR are the width or height that the image
+will be adjusted to. Only one parameter among \fB\-scale\fR,
+\fB\-scaletowidth\fR and \fB\-scaletoheight\fR can be given at a time
+and the aspect ratio of the original image is always preserved.
+The svg format supports a wide range of SVG features, but the
+full SVG standard is not available, for instance the 'text' feature
+is missing and silently ignored when reading the SVG data.
+The supported SVG features are:
+.
+.RS
+\fB elements:\fR g, path, rect, circle, ellipse, line, polyline, polygon,
+linearGradient, radialGradient, stop, defs, svg, style
+.PP
+\fB attributes:\fR width, height, viewBox,
+preserveAspectRatio with none, xMin, xMid, xMax, yMin, yMid, yMax, slice
+.PP
+\fB gradient attributes:\fR gradientUnits with objectBoundingBox,
+gradientTransform, cx, cy, r fx, fy x1, y1, x2, y2
+spreadMethod with pad, reflect or repeat,
+xlink:href
+.PP
+\fB poly attributes: \fR points
+.PP
+\fB line attributes: \fR x1, y1, x2, y2
+.PP
+\fB ellipse attributes: \fR cx, cy, rx, ry
+.PP
+\fB circle attributes: \fR cx, cy, r
+.PP
+\fB rectangle attributes: \fR x, y, width, height, rx, ry
+.PP
+\fB path attributes: \fR d with m, M, l, L, h, H, v, V, c, C, s, S, q, Q, t, T, a, A, z, Z
+.PP
+\fB style attributes: \fR display with none, visibility, hidden, visible,
+fill with nonzero and evenodd, opacity, fill-opacity,
+stroke, stroke-width, stroke-dasharray, stroke-dashoffset, stroke-opacity,
+stroke-linecap with butt, round and square,
+stroke-linejoin with miter, round and bevel, stroke-miterlimit
+fill-rule, font-size,
+transform with matrix, translate, scale, rotate, skewX and skewY,
+stop-color, stop-opacity, offset, id, class
+.RE
+.
+Currently only SVG images reading and conversion into (pixel-based
+format) photos is supported: Tk does not (yet) support bundling photo
+images in SVG vector graphics.
.VE 8.6
.VS 8.7
.SH "COLOR FORMATS"
diff --git a/doc/popup.n b/doc/popup.n
index 6e6fd95..9543750 100644
--- a/doc/popup.n
+++ b/doc/popup.n
@@ -38,7 +38,7 @@ $m add command \-label "Example 2" \-command bell
pack [label .l \-text "Click me!"]
# Arrange for the menu to pop up when the label is clicked
-bind .l <1> {\fBtk_popup\fR .popupMenu %X %Y}
+bind .l <Button-1> {\fBtk_popup\fR .popupMenu %X %Y}
.CE
.SH "SEE ALSO"
bind(n), menu(n), tk_optionMenu(n)
diff --git a/doc/scale.n b/doc/scale.n
index 6b960ce..d6407a0 100644
--- a/doc/scale.n
+++ b/doc/scale.n
@@ -55,7 +55,7 @@ it is the scale's width.
.OP \-resolution resolution Resolution
A real value specifying the resolution for the scale.
If this value is greater than zero then the scale's value will always be
-rounded to an even multiple of this value, as will tick marks and
+rounded to an even multiple of this value, as will
the endpoints of the scale. If the value is less than zero then no
rounding occurs. Defaults to 1 (i.e., the value will be integral).
.OP \-showvalue showValue ShowValue
@@ -78,7 +78,7 @@ specified by the \fB\-activebackground\fR option.
.OP \-tickinterval tickInterval TickInterval
Must be a real value.
Determines the spacing between numerical
-tick marks displayed below or to the left of the slider.
+tick marks displayed below or to the left of the slider. The values will all be displayed with the same number of decimal places, which will be enough to ensure they are all accurate to within 20% of a tick interval.
If 0, no tick marks will be displayed.
.OP \-to to To
Specifies a real value corresponding
diff --git a/doc/scrollbar.n b/doc/scrollbar.n
index 4b1d4ba..5a062ce 100644
--- a/doc/scrollbar.n
+++ b/doc/scrollbar.n
@@ -215,15 +215,6 @@ document. 1.0 refers to the end of the document, 0.333
refers to a point one-third of the way through the document,
and so on.
.TP
-\fIprefix \fBscroll \fInumber \fBunits\fR
-.
-The widget should adjust its view by \fInumber\fR units.
-The units are defined in whatever way makes sense for the widget,
-such as characters or lines in a text widget.
-\fINumber\fR is either 1, which means one unit should scroll off
-the top or left of the window, or \-1, which means that one unit
-should scroll off the bottom or right of the window.
-.TP
\fIprefix \fBscroll \fInumber \fBpages\fR
.
The widget should adjust its view by \fInumber\fR pages.
@@ -233,6 +224,15 @@ is a slight overlap between the old and new views.
\fINumber\fR is either 1, which means the next page should
become visible, or \-1, which means that the previous page should
become visible.
+.TP
+\fIprefix \fBscroll \fInumber \fBunits\fR
+.
+The widget should adjust its view by \fInumber\fR units.
+The units are defined in whatever way makes sense for the widget,
+such as characters or lines in a text widget.
+\fINumber\fR is either 1, which means one unit should scroll off
+the top or left of the window, or \-1, which means that one unit
+should scroll off the bottom or right of the window.
.SH "OLD COMMAND SYNTAX"
.PP
In versions of Tk before 4.0, the \fBset\fR and \fBget\fR widget
diff --git a/doc/spinbox.n b/doc/spinbox.n
index f2b1ff2..39961aa 100644
--- a/doc/spinbox.n
+++ b/doc/spinbox.n
@@ -471,14 +471,14 @@ way through the text appears at the left edge of the window.
This command shifts the view in the window left or right according to
\fInumber\fR and \fIwhat\fR.
\fINumber\fR must be an integer.
-\fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation
+\fIWhat\fR must be either \fBpages\fR or \fBunits\fR or an abbreviation
of one of these.
-If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by
-\fInumber\fR average-width characters on the display; if it is
-\fBpages\fR then the view adjusts by \fInumber\fR screenfuls.
-If \fInumber\fR is negative then characters farther to the left
+If \fIwhat\fR is \fBpages\fR then the view adjusts by \fInumber\fR
+screenfuls. If \fInumber\fR is negative then characters farther to the left
become visible; if it is positive then characters farther to the right
become visible.
+If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by
+\fInumber\fR average-width characters on the display.
.RE
.SH "DEFAULT BINDINGS"
.PP
@@ -517,9 +517,10 @@ insertion cursor in the spinbox without affecting the selection.
If any normal printing characters are typed in a spinbox, they are
inserted at the point of the insertion cursor.
.IP [7]
-The view in the spinbox can be adjusted by dragging with mouse button 2.
-If mouse button 2 is clicked without moving the mouse, the selection
-is copied into the spinbox at the position of the mouse cursor.
+The view in the spinbox can be adjusted by dragging with the middle
+mouse button (button 2, or button 3 in TkAqua). If the middle mouse
+button is clicked without moving the mouse, the selection is copied
+into the spinbox at the position of the mouse cursor.
.IP [8]
If the mouse is dragged out of the spinbox on the left or right sides
while button 1 is pressed, the spinbox will automatically scroll to
diff --git a/doc/text.n b/doc/text.n
index 250dff7..8915f71 100644
--- a/doc/text.n
+++ b/doc/text.n
@@ -1733,8 +1733,8 @@ all the sequences for which bindings have been defined for \fItagName\fR.
.RS
.PP
The only events for which bindings may be specified are those related to the
-mouse and keyboard (such as \fBEnter\fR, \fBLeave\fR, \fBButtonPress\fR,
-\fBMotion\fR, and \fBKeyPress\fR) or virtual events. Event bindings for a text
+mouse and keyboard (such as \fBEnter\fR, \fBLeave\fR, \fBButton\fR,
+\fBMotion\fR, and \fBKey\fR) or virtual events. Event bindings for a text
widget use the \fBcurrent\fR mark described under \fBMARKS\fR above. An
\fBEnter\fR event triggers for a tag when the tag first becomes present on the
current character, and a \fBLeave\fR event triggers for a tag when it ceases
@@ -1930,18 +1930,18 @@ and 1.
\fIpathName \fBxview scroll \fInumber what\fR
.
This command shifts the view in the window left or right according to
-\fInumber\fR and \fIwhat\fR. \fIWhat\fR must be \fBunits\fR, \fBpages\fR or
-\fBpixels\fR. If \fIwhat\fR is \fBunits\fR or \fBpages\fR then \fInumber\fR
-must be an integer, otherwise number may be specified in any of the forms
-acceptable to \fBTk_GetPixels\fR, such as
+\fInumber\fR and \fIwhat\fR. \fIWhat\fR must be \fBpages\fR,
+\fBpixels\fR, or \fBunits\fR. If \fIwhat\fR is \fBpages\fR or
+\fBunits\fR then \fInumber\fR must be an integer, otherwise number may be
+specified in any of the forms acceptable to \fBTk_GetPixels\fR, such as
.QW 2.0c
or
.QW 1i
(the result is rounded to the nearest integer value. If no units are given,
-pixels are assumed). If \fIwhat\fR is \fBunits\fR, the view adjusts left or
-right by \fInumber\fR average-width characters on the display; if it is
-\fBpages\fR then the view adjusts by \fInumber\fR screenfuls; if it is
-\fBpixels\fR then the view adjusts by \fInumber\fR pixels. If \fInumber\fR is
+pixels are assumed). If \fIwhat\fR is \fBpages\fR then the view adjusts by
+\fInumber\fR screenfuls; if it is \fBpixels\fR then the view adjusts by
+\fInumber\fR pixels; if it is \fBunits\fR, the view adjusts left or
+right by \fInumber\fR average-width characters on the display. If \fInumber\fR is
negative then characters farther to the left become visible; if it is positive
then characters farther to the right become visible.
.RE
@@ -1978,10 +1978,10 @@ the bottom of the window, and some other pixel is at the top.
\fIpathName \fByview scroll \fInumber what\fR
.
This command adjust the view in the window up or down according to
-\fInumber\fR and \fIwhat\fR. \fIWhat\fR must be \fBunits\fR, \fBpages\fR or
-\fBpixels\fR. If \fIwhat\fR is \fBunits\fR or \fBpages\fR then \fInumber\fR
-must be an integer, otherwise number may be specified in any of the forms
-acceptable to \fBTk_GetPixels\fR, such as
+\fInumber\fR and \fIwhat\fR. \fIWhat\fR must be \fBpages\fR,
+\fBpixels\fR, or \fBunits\fR. If \fIwhat\fR is \fBunits\fR or \fBpages\fR then
+\fInumber\fR must be an integer, otherwise number may be specified in any of
+the forms acceptable to \fBTk_GetPixels\fR, such as
.QW 2.0c
or
.QW 1i
@@ -2027,10 +2027,11 @@ integer. This command used to be used for scrolling, but now it is obsolete.
.SH BINDINGS
.PP
Tk automatically creates class bindings for texts that give them the following
-default behavior. In the descriptions below,
+default behavior.
+In the descriptions below,
.QW word
-is dependent on the value of the \fBtcl_wordchars\fR variable. See
-\fBtclvars\fR(n).
+is dependent on the value of
+the \fBtcl_wordchars\fR variable. See \fBtclvars\fR(n).
.IP [1]
Clicking mouse button 1 positions the insertion cursor just before the
character underneath the mouse cursor, sets the input focus to this widget,
@@ -2059,10 +2060,11 @@ insertion cursor without affecting the selection.
If any normal printing characters are typed, they are inserted at the point of
the insertion cursor.
.IP [7]
-The view in the widget can be adjusted by dragging with mouse button 2. If
-mouse button 2 is clicked without moving the mouse, the selection is copied
-into the text at the position of the mouse cursor. The Insert key also inserts
-the selection, but at the position of the insertion cursor.
+The view in the widget can be adjusted by dragging with the middle mouse
+button (button 2, or button 3 in TkAqua). If the middle mouse button is
+clicked without moving the mouse, the selection is copied into the text at the
+position of the mouse cursor. The Insert key also inserts the selection,
+but at the position of the insertion cursor.
.IP [8]
If the mouse is dragged out of the widget while button 1 is pressed, the entry
will automatically scroll to make more text visible (if there is more text
diff --git a/doc/tk4.0.ps b/doc/tk4.0.ps
index 5b71d92..5b0b675 100644
--- a/doc/tk4.0.ps
+++ b/doc/tk4.0.ps
@@ -1384,7 +1384,7 @@ V
3 F
( takes precedence over a binding on) 270.54 567.89 T
5 F
-(<KeyPress>.) 416.24 567.89 T
+(<Key>.) 416.24 567.89 T
3 F
-0.26 (The mechanism for con\337ict resolution is similar in Tk 4.0 except that one binding can) 170.1 555.89 P
-0.35 (trigger for) 152.1 543.78 P
@@ -1578,7 +1578,7 @@ V
(tion of them. If you wish for a binding not to trigger when a modi\336er is present, you can) 152.1 596.33 T
(just de\336ne an empty binding for that modi\336er combination. For example,) 152.1 584.33 T
5 9 Q
-(bind .b <Control-ButtonPress-1> {# this script is a no-op}) 179.1 570 T
+(bind .b <Control-Button-1> {# this script is a no-op}) 179.1 570 T
3 10 Q
(creates a binding that will trigger on mouse button presses when the) 152.1 556.33 T
5 F
@@ -1587,7 +1587,7 @@ V
( key is) 468.34 556.33 T
-0.22 (down. If there is also a) 152.1 544.33 P
5 F
--0.52 (<ButtonPress-1>) 244.35 544.33 P
+-0.52 (<Button-1>) 244.35 544.33 P
3 F
-0.22 ( binding for) 334.3 544.33 P
5 F
diff --git a/doc/tk_mac.n b/doc/tk_mac.n
index a1ad758..a4206a9 100644
--- a/doc/tk_mac.n
+++ b/doc/tk_mac.n
@@ -13,6 +13,8 @@
tk::mac \- Access Mac-Specific Functionality on OS X from Tk
.SH SYNOPSIS
.nf
+\fB::tk::mac::DoScriptFile\fR
+\fB::tk::mac::DoScriptText\fR
\fB::tk::mac::ShowPreferences\fR
\fB::tk::mac::OpenApplication\fR
\fB::tk::mac::ReopenApplication\fR
@@ -22,6 +24,9 @@ tk::mac \- Access Mac-Specific Functionality on OS X from Tk
\fB::tk::mac::OnHide\fR
\fB::tk::mac::OnShow\fR
\fB::tk::mac::ShowHelp\fR
+\fB::tk::mac::PerformService\fR
+\fB::tk::mac::LaunchURL \fIURL...\fR
+\fB::tk::mac::GetAppPath\fR
\fB::tk::mac::standardAboutPanel\fR
@@ -30,6 +35,7 @@ tk::mac \- Access Mac-Specific Functionality on OS X from Tk
\fB::tk::mac::antialiasedtext \fInumber\fR
\fB::tk::mac::useThemedToplevel \fIboolean\fR
+
\fB::tk::mac::iconBitmap \fIname width height \-kind value\fR
.fi
.BE
@@ -40,6 +46,20 @@ events that applications should respond to. These events are mapped by Tk to
calls to commands in the \fB::tk::mac\fR namespace; unless otherwise noted, if
the command is absent, no action will be taken.
.TP
+\fB::tk::mac::DoScriptFile\fR
+.
+The default Apple Event handler for AEDoScriptHandler. This command
+executes a Tcl file when an AppleScript sends a
+.QW "do script"
+command to Wish with a file path as a parameter.
+.TP
+\fB::tk::mac::DoScriptText\fR
+.
+The default Apple Event handler for AEDoScriptHandler. This command
+executes Tcl code when an AppleScript sends a
+.QW "do script"
+command to Wish with Tcl code or a Tcl procedure as a parameter.
+.TP
\fB::tk::mac::ShowPreferences\fR
.
The default Apple Event handler for kAEShowPreferences,
@@ -61,7 +81,7 @@ proc ::tk::mac::ShowPreferences {} {
\fB::tk::mac::OpenApplication\fR
.
If a proc of this name is defined, this proc fill fire when your application
-is intially opened. It is the default Apple Event handler for
+is initially opened. It is the default Apple Event handler for
kAEOpenApplication,
.QW oapp .
.TP
@@ -110,9 +130,8 @@ proc ::tk::mac::OpenDocument {args} {
If a proc of this name is defined it is the default Apple Event handler for
kAEPrintDocuments,
.QW pdoc ,
-the Apple Event sent when your application is asked to print one or more
-documents (e.g., via the Print menu item in the Finder). It works the same
-way as \fBtk::mac::OpenDocument\fR in terms of arguments.
+the Apple Event sent when your application is asked to print a
+document. It takes a single absolute file path as an argument.
.TP
\fB::tk::mac::Quit\fR
.
@@ -141,7 +160,57 @@ Customizes behavior of Apple Help menu; if this procedure is not defined, the
platform-specific standard Help menu item
.QW "YourApp Help"
performs the default Cocoa action of showing the Help Book configured in the
-application's Info.plist (or displaying an alert if no Help Book is set).
+application's Info.plist (or displaying an alert if no Help Book is
+set).
+.TP
+\fB::tk::mac::PerformService\fR
+.
+Executes a Tcl procedure called from the macOS
+.QW Services
+menu in the Application menu item. The
+.QW Services
+menu item allows for inter-application communication; data from one
+application, such as selected text, can be sent to another application
+for processing, for example to Safari as a search item for Google, or
+to TextEdit to be appended to a file. An example of the proc is below,
+and should be rewritten in an application script for customization:
+.RS
+.PP
+.CS
+proc ::tk::mac::PerformService {} {
+ set data [clipboard get]
+ $w insert end $data
+}
+.CE
+.RE
+Note that the mechanism for retrieving the data is from the clipboard;
+there is no other supported way to obtain the data. If the Services
+process is not desired, the NSServices keys can be deleted from
+the application's Info.plist file. The underlying code supporting this
+command also allows the text, entry and ttk::entry widgets to access
+services from other applications via the Services menu. The NSPortName
+key in Wish's Info.plist file is currently set as
+.QW "Wish"
+; if a developer changes the name of the Wish executable to something
+ else, this key should be modified with the same name.
+.TP
+\fB::tk::mac::LaunchURL \fIURL...\fR
+.
+If defined, launches a URL within Tk. This would be used if a Tk
+application wants to handle a URL itself, such as displaying data from
+an RSS feed, rather than launching a default application to handle the
+URL, although it can defined as such. Wish includes a stub URL scheme
+of
+.QW foo://
+in the CFBundleURLSchemes key of its Info.plist file; this should be customized for the specific URL
+scheme the developer wants to support.
+.TP
+\fB::tk::mac::GetAppPath\fR
+.
+Returns the current applications's file path.
+.TP
+
+
.SH "ADDITIONAL DIALOGS"
.PP
The Aqua/Mac OS X defines additional dialogs that applications should
diff --git a/doc/toplevel.n b/doc/toplevel.n
index 31f241c..c56e035 100644
--- a/doc/toplevel.n
+++ b/doc/toplevel.n
@@ -25,6 +25,17 @@ except that its value may also be specified as an empty string.
In this case, the widget will display no background or border, and
no colors will be consumed from its colormap for its background
and border.
+.VS "8.7, TIP262"
+An empty background will disable drawing the background image.
+.OP \-backgroundimage backgroundImage BackgroundImage
+This specifies an image to display on the toplevel's background within
+the border of the toplevel (i.e., the image will be clipped by the
+toplevel's highlight ring and border, if either are present) on top of
+the background;
+subwidgets of the toplevel will be drawn on top. The image must have
+been created with the \fBimage create\fR command. If specified as the
+empty string, no image will be displayed.
+.VE "8.7, TIP262"
.OP \-class class Class
Specifies a class for the window.
This class will be used when querying the option database for
@@ -71,6 +82,15 @@ Defaults to the same screen as its parent.
This option is special in that it may not be specified via the option
database, and it may not be modified with the \fBconfigure\fR
widget command.
+.OP \-tile tile Tile
+.VS "8.7, TIP262"
+This specifies how to draw the background image (see
+\fB\-backgroundimage\fR) on the toplevel.
+If true (according to \fBTcl_GetBoolean\fR), the image will be tiled
+to fill the whole toplevel, with the origin of the first copy of the
+image being the top left of the interior of the toplevel.
+If false (the default), the image will be centered within the toplevel.
+.VE "8.7, TIP262"
.OP \-use use Use
This option is used for embedding. If the value is not an empty string,
it must be the window identifier of a container window, specified as
@@ -104,12 +124,12 @@ to configure aspects of the toplevel such as its background color
and relief. The \fBtoplevel\fR command returns the
path name of the new window.
.PP
-A toplevel is similar to a frame except that it is created as a
+A toplevel is similar to a \fBframe\fR except that it is created as a
top-level window: its X parent is the root window of a screen
-rather than the logical parent from its path name. The primary
+rather than the logical parent from its Tk path name. The primary
purpose of a toplevel is to serve as a container for dialog boxes
and other collections of widgets. The only visible features
-of a toplevel are its background color and an optional 3-D border
+of a toplevel are its background and an optional 3-D border
to make the toplevel appear raised or sunken.
.SH "WIDGET COMMAND"
.PP
@@ -117,21 +137,25 @@ The \fBtoplevel\fR command creates a new Tcl command whose
name is the same as the path name of the toplevel's window. This
command may be used to invoke various
operations on the widget. It has the following general form:
+.PP
.CS
\fIpathName option \fR?\fIarg arg ...\fR?
.CE
+.PP
\fIPathName\fR is the name of the command, which is the same as
the toplevel widget's path name. \fIOption\fR and the \fIarg\fRs
determine the exact behavior of the command. The following
commands are possible for toplevel widgets:
.TP
\fIpathName \fBcget \fIoption\fR
+.
Returns the current value of the configuration option given
by \fIoption\fR.
\fIOption\fR may have any of the values accepted by the \fBtoplevel\fR
command.
.TP
\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
+.
Query or modify the configuration options of the widget.
If no \fIoption\fR is specified, returns a list describing all of
the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
@@ -148,8 +172,10 @@ command.
.PP
When a new toplevel is created, it has no default event bindings:
toplevels are not intended to be interactive.
+.PP
+Be aware that bindings on toplevels may receive events from subwidgets.
.SH "SEE ALSO"
-frame(n)
+bind(n), bindtags(n), frame(n), wm(n)
.SH KEYWORDS
toplevel, widget
'\" Local Variables:
diff --git a/doc/ttk_Geometry.3 b/doc/ttk_Geometry.3
index 61015c5..09d59e0 100644
--- a/doc/ttk_Geometry.3
+++ b/doc/ttk_Geometry.3
@@ -212,7 +212,7 @@ See \fBTk_GetPixelsFromObj(3)\fR for the syntax of length specifications.
.PP
\fBTtk_GetBorderFromObj\fR is the same as \fBTtk_GetPaddingFromObj\fR
except that the lengths are specified as integers
-(i.e., resolution-dependant values like \fI3m\fR are not allowed).
+(i.e., resolution-dependent values like \fI3m\fR are not allowed).
.PP
\fBTtk_GetStickyFromObj\fR converts the string in \fIobjPtr\fR
to a \fIsticky\fR bitmask. The string contains zero or more
diff --git a/doc/ttk_button.n b/doc/ttk_button.n
index 2b091ad..eb40d9d 100644
--- a/doc/ttk_button.n
+++ b/doc/ttk_button.n
@@ -72,6 +72,8 @@ are:
.br
\fB\-bordercolor\fP \fIcolor\fP
.br
+\fB\-compound\fP \fIcompound\fP
+.br
\fB\-darkcolor\fP \fIcolor\fP
.br
\fB\-foreground\fP \fIcolor\fP
diff --git a/doc/ttk_checkbutton.n b/doc/ttk_checkbutton.n
index a18a886..c78dc0e 100644
--- a/doc/ttk_checkbutton.n
+++ b/doc/ttk_checkbutton.n
@@ -80,6 +80,8 @@ are:
.PP
\fB\-background\fP \fIcolor\fP
.br
+\fB\-compound\fP \fIcompound\fP
+.br
\fB\-foreground\fP \fIcolor\fP
.br
\fB\-indicatorbackground\fP \fIcolor\fP
diff --git a/doc/ttk_combobox.n b/doc/ttk_combobox.n
index 37acf19..3ec3e77 100644
--- a/doc/ttk_combobox.n
+++ b/doc/ttk_combobox.n
@@ -67,7 +67,9 @@ The following subcommands are possible for combobox widgets:
.TP
\fIpathName \fBcurrent\fR ?\fInewIndex\fR?
If \fInewIndex\fR is supplied, sets the combobox value
-to the element at position \fInewIndex\fR in the list of \fB\-values\fR.
+to the element at position \fInewIndex\fR in the list of \fB\-values\fR
+(in addition to integers, the \fBend\fR index is supported and indicates
+the last element of the list).
Otherwise, returns the index of the current value in the list of
\fB\-values\fR or \fB\-1\fR if the current value does not appear in the list.
.TP
@@ -124,6 +126,8 @@ are:
.PP
\fB\-arrowcolor\fP \fIcolor\fP
.br
+\fB\-arrowsize\fP \fIamount\fP
+.br
\fB\-background\fP \fIcolor\fP
.br
\fB\-bordercolor\fP \fIcolor\fP
diff --git a/doc/ttk_entry.n b/doc/ttk_entry.n
index 10557b0..552700a 100644
--- a/doc/ttk_entry.n
+++ b/doc/ttk_entry.n
@@ -222,52 +222,13 @@ by the \fB\-validate\fR option.
Returns 0 if validation fails, 1 if it succeeds.
Sets or clears the \fBinvalid\fR state accordingly.
See \fBVALIDATION\fR below for more details.
-.TP
-\fIpathName \fBxview \fIargs\fR
-This command is used to query and change the horizontal position of the
-text in the widget's window. It can take any of the following
-forms:
-.RS
-.TP
-\fIpathName \fBxview\fR
-Returns a list containing two elements.
-Each element is a real fraction between 0 and 1; together they describe
-the horizontal span that is visible in the window.
-For example, if the first element is .2 and the second element is .6,
-20% of the entry's text is off-screen to the left, the middle 40% is visible
-in the window, and 40% of the text is off-screen to the right.
-These are the same values passed to scrollbars via the \fB\-xscrollcommand\fR
-option.
-.TP
-\fIpathName \fBxview\fR \fIindex\fR
-Adjusts the view in the window so that the character given by \fIindex\fR
-is displayed at the left edge of the window.
-.TP
-\fIpathName \fBxview moveto\fI fraction\fR
-Adjusts the view in the window so that the character \fIfraction\fR of the
-way through the text appears at the left edge of the window.
-\fIFraction\fR must be a fraction between 0 and 1.
-.TP
-\fIpathName \fBxview scroll \fInumber what\fR
-This command shifts the view in the window left or right according to
-\fInumber\fR and \fIwhat\fR.
-\fINumber\fR must be an integer.
-\fIWhat\fR must be either \fBunits\fR or \fBpages\fR.
-'\" or an abbreviation of one of these, but we don't document that.
-If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by
-\fInumber\fR average-width characters on the display; if it is
-\fBpages\fR then the view adjusts by \fInumber\fR screenfuls.
-If \fInumber\fR is negative then characters farther to the left
-become visible; if it is positive then characters farther to the right
-become visible.
-.RE
.PP
The entry widget also supports the following generic \fBttk::widget\fR
widget subcommands (see \fIttk::widget(n)\fR for details):
.DS
.ta 5.5c 11c
\fBcget\fR \fBconfigure\fR \fBidentify\fR
-\fBinstate\fR \fBstate\fR
+\fBinstate\fR \fBstate\fR \fBxview\fR
.DE
.SH VALIDATION
.PP
@@ -392,9 +353,10 @@ insert cursor in the entry without affecting the selection.
If any normal printing characters are typed in an entry, they are
inserted at the point of the insert cursor.
.IP \0\(bu 4
-The view in the entry can be adjusted by dragging with mouse button 2.
-If mouse button 2 is clicked without moving the mouse, the selection
-is copied into the entry at the position of the mouse cursor.
+The view in the entry can be adjusted by dragging with the middle
+mouse button (button 2, or button 3 in TkAqua). If the middle mouse
+button is clicked without moving the mouse, the selection is copied
+into the entry at the position of the mouse cursor.
.IP \0\(bu 4
If the mouse is dragged out of the entry on the left or right sides
while button 1 is pressed, the entry will automatically scroll to
@@ -472,7 +434,9 @@ are:
.PP
\fB\-background\fP \fIcolor\fP
.RS
-When using the aqua theme (Mac OS X), changes the \fB\-fieldbackground\fP.
+For backwards compatibility, when using the aqua theme (for macOS), this
+option behaves as an alias for the \fB\-fieldbackground\fP provided that no
+value is specified for \fB\-fieldbackground\fP. Otherwise it is ignored.
.RE
\fB\-bordercolor\fP \fIcolor\fP
.br
@@ -480,8 +444,6 @@ When using the aqua theme (Mac OS X), changes the \fB\-fieldbackground\fP.
.br
\fB\-fieldbackground\fP \fIcolor\fP
.RS
-Does not work with the aqua theme (Mac OS X).
-.br
Some themes use a graphical background and their field background colors cannot be changed.
.RE
\fB\-foreground\fP \fIcolor\fP
diff --git a/doc/ttk_frame.n b/doc/ttk_frame.n
index 8702592..b02035e 100644
--- a/doc/ttk_frame.n
+++ b/doc/ttk_frame.n
@@ -23,6 +23,7 @@ together.
.SH "WIDGET-SPECIFIC OPTIONS"
.OP \-borderwidth borderWidth BorderWidth
The desired width of the widget border. Defaults to 0.
+May be ignored depending on the theme used.
.OP \-relief relief Relief
One of the standard Tk border styles:
\fBflat\fR, \fBgroove\fR, \fBraised\fR, \fBridge\fR,
@@ -53,11 +54,17 @@ The class name for a \fBttk::frame\fP is \fBTFrame\fP.
are:
.PP
\fB\-background\fP \fIcolor\fP
+.br
+\fB\-relief\fP \fIrelief\fP
.PP
Some options are only available for specific themes.
.PP
See the \fBttk::style\fP manual page for information on how to configure
ttk styles.
+.SH BINDINGS
+.PP
+When a new \fBttk::frame\fR is created, it has no default event bindings;
+\fBttk::frame\fRs are not intended to be interactive.
.SH "SEE ALSO"
ttk::widget(n), ttk::labelframe(n), frame(n)
.SH "KEYWORDS"
diff --git a/doc/ttk_intro.n b/doc/ttk_intro.n
index bc3cd69..3b399ee 100644
--- a/doc/ttk_intro.n
+++ b/doc/ttk_intro.n
@@ -13,7 +13,7 @@ ttk::intro \- Introduction to the Tk theme engine
.SH "OVERVIEW"
.PP
The Tk themed widget set is based on a revised and enhanced version
-of TIP #48 (http://tip.tcl.tk/48) specified style engine.
+of TIP #48 (https://tip.tcl-lang.org/48) specified style engine.
The main concepts are described below.
The basic idea is to separate, to the extent possible,
the code implementing a widget's behavior from
@@ -60,7 +60,7 @@ For example, the \fBtext\fR element
(which displays a text string) has
\fB\-text\fR, \fB\-font\fR, \fB\-foreground\fR, \fB\-background\fR,
\fB\-underline\fR, and \fB\-width\fR options.
-The value of an element option is taken from:
+The value of an element option is taken from (in precedence order):
.IP \(bu
an option of the same name and type in the widget containing the element;
.IP \(bu
@@ -121,7 +121,7 @@ widget are:
.CS
bind TButton <Enter> { %W state active }
bind TButton <Leave> { %W state !active }
-bind TButton <ButtonPress-1> { %W state pressed }
+bind TButton <Button-1> { %W state pressed }
bind TButton <Button1-Leave> { %W state !pressed }
bind TButton <Button1-Enter> { %W state pressed }
bind TButton <ButtonRelease-1> \e
diff --git a/doc/ttk_label.n b/doc/ttk_label.n
index 8553a08..1b25f9f 100644
--- a/doc/ttk_label.n
+++ b/doc/ttk_label.n
@@ -56,6 +56,8 @@ are:
.PP
\fB\-background\fP \fIcolor\fP
.br
+\fB\-compound\fP \fIcompound\fP
+.br
\fB\-foreground\fP \fIcolor\fP
.br
\fB\-font\fP \fIfont\fP
diff --git a/doc/ttk_labelframe.n b/doc/ttk_labelframe.n
index 12f0b89..9e42781 100644
--- a/doc/ttk_labelframe.n
+++ b/doc/ttk_labelframe.n
@@ -30,6 +30,10 @@ another widget.
.\" XXX: \fBflat\fR, \fBgroove\fR, \fBraised\fR, \fBridge\fR,
.\" XXX: \fBsolid\fR, or \fBsunken\fR.
.\" XXX: Default is theme-dependent.
+.OP \-height height Height
+If specified, the widget's requested height in pixels.
+(See \fIttk::frame(n)\fR for further notes on \fB\-width\fR and
+\fB\-height\fR).
.OP \-labelanchor labelAnchor LabelAnchor
Specifies where to place the label.
Allowed values are (clockwise from the top upper left corner):
@@ -40,6 +44,12 @@ The default value is theme-dependent.
.\" and specifies which side the label should be placed on;
.\" the remaining characters specify how the label is aligned on that side.
.\" NOTE: Now allows other values as well; leave this undocumented for now
+.OP \-labelwidget labelWidget LabelWidget
+The name of a widget to use for the label.
+If set, overrides the \fB\-text\fR option.
+The \fB\-labelwidget\fR must be a child of the \fBlabelframe\fR widget
+or one of the \fBlabelframe\fR's ancestors, and must belong to the
+same top-level widget as the \fBlabelframe\fR.
.OP \-text text Text
Specifies the text of the label.
.OP \-underline underline Underline
@@ -48,18 +58,8 @@ underline in the text string.
The underlined character is used for mnemonic activation.
Mnemonic activation for a \fBttk::labelframe\fR
sets the keyboard focus to the first child of the \fBttk::labelframe\fR widget.
-.OP \-labelwidget labelWidget LabelWidget
-The name of a widget to use for the label.
-If set, overrides the \fB\-text\fR option.
-The \fB\-labelwidget\fR must be a child of the \fBlabelframe\fR widget
-or one of the \fBlabelframe\fR's ancestors, and must belong to the
-same top-level widget as the \fBlabelframe\fR.
.OP \-width width Width
If specified, the widget's requested width in pixels.
-.OP \-height height Height
-If specified, the widget's requested height in pixels.
-(See \fIttk::frame(n)\fR for further notes on \fB\-width\fR and
-\fB\-height\fR).
.SH "WIDGET COMMAND"
.PP
Supports the standard widget commands
diff --git a/doc/ttk_menubutton.n b/doc/ttk_menubutton.n
index 76d3829..0d80c1e 100644
--- a/doc/ttk_menubutton.n
+++ b/doc/ttk_menubutton.n
@@ -58,6 +58,8 @@ are:
.br
\fB\-background\fP \fIcolor\fP
.br
+\fB\-compound\fP \fIcompound\fP
+.br
\fB\-foreground\fP \fIcolor\fP
.br
\fB\-font\fP \fIfont\fP
diff --git a/doc/ttk_notebook.n b/doc/ttk_notebook.n
index 19416b5..ae32a44 100644
--- a/doc/ttk_notebook.n
+++ b/doc/ttk_notebook.n
@@ -242,6 +242,8 @@ are:
.br
\fB\-bordercolor\fP \fIcolor\fP
.br
+\fB\-compound\fP \fIcompound\fP
+.br
\fB\-expand\fP \fIpadding\fP
.RS
Defines how much the tab grows in size. Usually used with the
diff --git a/doc/ttk_progressbar.n b/doc/ttk_progressbar.n
index b0d5615..df469b6 100644
--- a/doc/ttk_progressbar.n
+++ b/doc/ttk_progressbar.n
@@ -57,9 +57,11 @@ In \fIindeterminate\fR mode, it is interpreted modulo \fB\-maximum\fR;
that is, the progress bar completes one
.QW cycle
when the \fB\-value\fR increases by \fB\-maximum\fR.
+If \fB\-variable\fR is set to an existing variable, specifying \fB\-value\fR
+has no effect (the variable value takes precedence).
.OP \-variable variable Variable
The name of a global Tcl variable which is linked to the \fB\-value\fR.
-If specified, the \fB\-value\fR of the progress bar is
+If specified to an existing variable, the \fB\-value\fR of the progress bar is
automatically set to the value of the variable whenever
the latter is modified.
.SH "WIDGET COMMAND"
diff --git a/doc/ttk_radiobutton.n b/doc/ttk_radiobutton.n
index 1344ae2..2dc84be 100644
--- a/doc/ttk_radiobutton.n
+++ b/doc/ttk_radiobutton.n
@@ -77,6 +77,8 @@ are:
.PP
\fB\-background\fP \fIcolor\fP
.br
+\fB\-compound\fP \fIcompound\fP
+.br
\fB\-foreground\fP \fIcolor\fP
.br
\fB\-indicatorbackground\fP \fIcolor\fP
diff --git a/doc/ttk_scale.n b/doc/ttk_scale.n
index 4e16999..aa851b9 100644
--- a/doc/ttk_scale.n
+++ b/doc/ttk_scale.n
@@ -42,6 +42,8 @@ Specifies a real value corresponding to the right or bottom end of the scale.
This value may be either less than or greater than the \fB\-from\fR option.
.OP \-value value Value
Specifies the current floating-point value of the variable.
+If \fB\-variable\fR is set to an existing variable, specifying \fB\-value\fR
+has no effect (the variable value takes precedence).
.OP \-variable variable Variable
Specifies the name of a global variable to link to the scale. Whenever the
value of the variable changes, the scale will update to reflect this value.
@@ -93,7 +95,7 @@ corresponding to the current value of the \fB\-value\fR option if \fIvalue\fR
is omitted.
.SH "STYLING OPTIONS"
.PP
-The class name for a \fBttk::scale\fP is \fBTProgressbar\fP.
+The class name for a \fBttk::scale\fP is \fBTScale\fP.
.PP
Dynamic states: \fBactive\fP.
.PP
diff --git a/doc/ttk_scrollbar.n b/doc/ttk_scrollbar.n
index 49681a1..08c7f52 100644
--- a/doc/ttk_scrollbar.n
+++ b/doc/ttk_scrollbar.n
@@ -76,7 +76,7 @@ Modify or query the widget state; see \fIttk::widget(n)\fR.
.SH "INTERNAL COMMANDS"
.PP
The following widget commands are used internally
-by the TScrollbar widget class bindings.
+by the \fBTScrollbar\fP widget class bindings.
.TP
\fIpathName \fBdelta \fIdeltaX deltaY\fR
Returns a real number indicating the fractional change in
@@ -118,14 +118,6 @@ document. 1.0 refers to the end of the document, 0.333
refers to a point one-third of the way through the document,
and so on.
.TP
-\fIprefix \fBscroll \fInumber \fBunits\fR
-The widget should adjust its view by \fInumber\fR units.
-The units are defined in whatever way makes sense for the widget,
-such as characters or lines in a text widget.
-\fINumber\fR is either 1, which means one unit should scroll off
-the top or left of the window, or \-1, which means that one unit
-should scroll off the bottom or right of the window.
-.TP
\fIprefix \fBscroll \fInumber \fBpages\fR
The widget should adjust its view by \fInumber\fR pages.
It is up to the widget to define the meaning of a page; typically
@@ -134,6 +126,14 @@ is a slight overlap between the old and new views.
\fINumber\fR is either 1, which means the next page should
become visible, or \-1, which means that the previous page should
become visible.
+.TP
+\fIprefix \fBscroll \fInumber \fBunits\fR
+The widget should adjust its view by \fInumber\fR units.
+The units are defined in whatever way makes sense for the widget,
+such as characters or lines in a text widget.
+\fINumber\fR is either 1, which means one unit should scroll off
+the top or left of the window, or \-1, which means that one unit
+should scroll off the bottom or right of the window.
.SH "WIDGET STATES"
.PP
The scrollbar automatically sets the \fBdisabled\fR state bit.
@@ -153,6 +153,7 @@ grid $f.vsb \-row 0 \-column 1 \-sticky nsew
grid $f.hsb \-row 1 \-column 0 \-sticky nsew
grid columnconfigure $f 0 \-weight 1
grid rowconfigure $f 0 \-weight 1
+pack $f
.CE
.SH "STYLING OPTIONS"
.PP
@@ -160,20 +161,25 @@ The class name for a \fBttk::scrollbar\fP is \fBTScrollbar\fP.
.PP
Dynamic states: \fBactive\fP, \fBdisabled\fP.
.PP
-\fBTScrollbar\fP styling options configurable with \fBttk::style\fP
-are:
+\fBTScrollbar\fP (or more specifically \fBVertical.TScrollbar\fP and
+\fBHorizontal.TScrollbar\fP) styling options that are configurable with
+\fBttk::style\fP are:
.PP
\fB\-arrowcolor\fP \fIcolor\fP
.br
+\fB\-arrowsize\fP \fIamount\fP
+.br
\fB\-background\fP \fIcolor\fP
.br
\fB\-bordercolor\fP \fIcolor\fP
.br
-\fB\-darkcolor\fP \fIcolor\fP
+\fB\-darkcolor\fP \fIcolor\fP (color of the dark part of the 3D relief)
.br
\fB\-foreground\fP \fIcolor\fP
.br
-\fB\-lightcolor\fP \fIcolor\fP
+\fB\-gripcount\fP \fIcount\fP (number of lines on the thumb)
+.br
+\fB\-lightcolor\fP \fIcolor\fP (color of the light part of the 3D relief)
.br
\fB\-troughcolor\fP \fIcolor\fP
.PP
diff --git a/doc/ttk_spinbox.n b/doc/ttk_spinbox.n
index 980fd75..c18f987 100644
--- a/doc/ttk_spinbox.n
+++ b/doc/ttk_spinbox.n
@@ -95,16 +95,16 @@ are:
.br
\fB\-background\fP \fIcolor\fP
.RS
-When using the aqua theme (Mac OS X), changes the \fB\-fieldbackground\fP.
+For backwards compatibility, when using the aqua theme (for macOS), this
+option behaves as an alias for the \fB\-fieldbackground\fP provided that no
+value is specified for \fB\-fieldbackground\fP. Otherwise it is ignored.
.RE
\fB\-bordercolor\fP \fIcolor\fP
.br
\fB\-darkcolor\fP \fIcolor\fP
.br
\fB\-fieldbackground\fP \fIcolor\fP
-.RS
-Does not work with the aqua theme (Mac OS X).
-.RE
+.br
\fB\-foreground\fP \fIcolor\fP
.br
\fB\-lightcolor\fP \fIcolor\fP
diff --git a/doc/ttk_style.n b/doc/ttk_style.n
index 985e3cd..db80d95 100644
--- a/doc/ttk_style.n
+++ b/doc/ttk_style.n
@@ -15,7 +15,7 @@ ttk::style \- Manipulate style database
.SH NOTES
.PP
See also the Tcl'2004 conference presentation,
-available at http://tktable.sourceforge.net/tile/tile-tcl2004.pdf
+available at https://tktable.sourceforge.net/tile/tile-tcl2004.pdf
.SH DEFINITIONS
.PP
Each widget is assigned a \fIstyle\fR,
diff --git a/doc/ttk_treeview.n b/doc/ttk_treeview.n
index 96565a3..a126dd2 100644
--- a/doc/ttk_treeview.n
+++ b/doc/ttk_treeview.n
@@ -133,25 +133,29 @@ The column name. This is a read-only option.
For example, [\fI$pathname \fBcolumn #\fIn \fB\-id\fR]
returns the data column associated with display column #\fIn\fR.
.TP
-\fB\-anchor\fR
+\fB\-anchor \fIanchor\fR
Specifies how the text in this column should be aligned
-with respect to the cell. One of
+with respect to the cell. \fIAnchor\fR is one of
\fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR,
\fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, or \fBcenter\fR.
.TP
-\fB\-minwidth\fR
+\fB\-minwidth \fIminwidth\fR
The minimum width of the column in pixels.
The treeview widget will not make the column any smaller than
\fB\-minwidth\fR when the widget is resized or the user drags a
+column separator. Default is 20 pixels.
+.TP
+\fB\-stretch \fIboolean\fR
+Specifies whether or not the column width should be adjusted
+when the widget is resized or the user drags a column separator.
+\fIBoolean\fR may have any of the forms accepted by \fBTcl_GetBoolean\fR.
+By default columns are stretchable.
+.TP
+\fB\-width \fIwidth\fR
+The width of the column in pixels. Default is 200 pixels. The specified
+column width may be changed by Tk in order to honor \fB\-stretch\fR
+and/or \fB\-minwidth\fR, or when the widget is resized or the user drags a
column separator.
-.TP
-\fB\-stretch\fR
-Specifies whether or not the column's width should be adjusted
-when the widget is resized.
-.TP
-\fB\-width \fIw\fR
-The width of the column in pixels. Default is something reasonable,
-probably 200 or so.
.PP
Use \fIpathname column #0\fR to configure the tree column.
.RE
@@ -231,7 +235,7 @@ A data cell.
Returns the item ID of the item at position \fIy\fR.
.TP
\fIpathname \fBidentify column \fIx y\fR
-Returns the data column identifier of the cell at position \fIx\fR.
+Returns the display column identifier of the cell at position \fIx\fR.
The tree column has ID \fB#0\fR.
.TP
\fIpathname \fBidentify element \fIx y\fR
@@ -340,6 +344,11 @@ Modify or query the widget state; see \fIttk::widget(n)\fR.
\fIpathName \fBtag \fIargs...\fR
.RS
.TP
+\fIpathName \fBtag add \fItag items\fR
+Adds the specified \fItag\fR to each of the listed \fIitems\fR.
+If \fItag\fR is already present for a particular item,
+then the \fB\-tags\fR for that item are unchanged.
+.TP
\fIpathName \fBtag bind \fItagName \fR?\fIsequence\fR? ?\fIscript\fR?
Add a Tk binding script for the event sequence \fIsequence\fR
to the tag \fItagName\fR. When an X event is delivered to an item,
@@ -347,9 +356,9 @@ binding scripts for each of the item's \fB\-tags\fR are evaluated
in order as per \fIbindtags(n)\fR.
.RS
.PP
-\fB<KeyPress>\fR, \fB<KeyRelease>\fR, and virtual events
+\fB<Key>\fR, \fB<KeyRelease>\fR, and virtual events
are sent to the focus item.
-\fB<ButtonPress>\fR, \fB<ButtonRelease>\fR, and \fB<Motion>\fR events
+\fB<Button>\fR, \fB<ButtonRelease>\fR, and \fB<Motion>\fR events
are sent to the item under the mouse pointer.
No other event types are supported.
.PP
@@ -368,6 +377,12 @@ With no additional arguments,
returns a dictionary of the option settings for \fItagName\fR.
See \fBTAG OPTIONS\fR for the list of available options.
.TP
+\fIpathName \fBtag delete \fItagName\fR
+Deletes all tag information for the \fItagName\fR argument. The
+command removes the tag from all items in the widget and also deletes any
+other information associated with the tag, such as bindings and display
+information. The command returns an empty string.
+.TP
\fIpathName \fBtag has \fItagName\fR ?\fIitem\fR?
If \fIitem\fR is specified, returns 1 or 0
depending on whether the specified item has the named tag.
@@ -377,23 +392,19 @@ the specified tag.
\fIpathName \fBtag names\fR
Returns a list of all tags used by the widget.
.TP
-\fIpathName \fBtag add \fItag items\fR
-Adds the specified \fItag\fR to each of the listed \fIitems\fR.
-If \fItag\fR is already present for a particular item,
-then the \fB\-tags\fR for that item are unchanged.
-.TP
\fIpathName \fBtag remove \fItag\fR ?\fIitems\fR?
Removes the specified \fItag\fR from each of the listed \fIitems\fR.
If \fIitems\fR is omitted, removes \fItag\fR from each item in the tree.
If \fItag\fR is not present for a particular item,
then the \fB\-tags\fR for that item are unchanged.
.RE
-.TP
-\fIpathName \fBxview \fIargs\fR
-Standard command for horizontal scrolling; see \fIwidget(n)\fR.
-.TP
-\fIpathName \fByview \fIargs\fR
-Standard command for vertical scrolling; see \fIttk::widget(n)\fR.
+.PP
+The treeview widget also supports the following generic \fBttk::widget\fR
+widget subcommands (see \fIttk::widget(n)\fR for details):
+.DS
+.ta 5.5c 11c
+\fBxview\fR \fByview\fR
+.DE
.SH "ITEM OPTIONS"
.PP
The following item options may be specified for items
diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n
index 9e9f3db..73affdd 100644
--- a/doc/ttk_widget.n
+++ b/doc/ttk_widget.n
@@ -80,6 +80,9 @@ See also \fB\-justify\fR (for widgets supporting this option).
.OP \-compound compound Compound
Specifies how to display the image relative to the text,
in the case both \fB\-text\fR and \fB\-image\fR are present.
+If set to the empty string (the default), the rules described in the
+"Elements" section of \fIttk::intro(n)\fR explain which value is actually
+used.
Valid values are:
.RS
.IP text
@@ -94,7 +97,7 @@ Display text centered on top of image.
.IP right
Display image above, below, left of, or right of the text, respectively.
.IP none
-The default; display the image if present, otherwise the text.
+Display the image if present, otherwise the text.
.RE
.OP \-font font Font
Font to use for the text displayed by the widget.
@@ -224,6 +227,86 @@ will restore \fIpathName\fR to the original state.
If \fIstateSpec\fR is not specified,
returns a list of the currently-enabled state flags.
.RE
+.TP
+\fIpathName \fBxview \fIargs\fR
+This command is used to query and change the horizontal position of the
+content in the widget's window. It can take any of the following
+forms:
+.RS
+.TP
+\fIpathName \fBxview\fR
+Returns a list containing two elements.
+Each element is a real fraction between 0 and 1; together they describe
+the horizontal span that is visible in the window.
+For example, if the first element is .2 and the second element is .6,
+20% of the widget's content is off-screen to the left, the middle 40% is visible
+in the window, and 40% of the content is off-screen to the right.
+These are the same values passed to scrollbars via the \fB\-xscrollcommand\fR
+option.
+.TP
+\fIpathName \fBxview\fR \fIindex\fR
+Adjusts the view in the window so that the content given by \fIindex\fR
+is displayed at the left edge of the window.
+.TP
+\fIpathName \fBxview moveto\fI fraction\fR
+Adjusts the view in the window so that the character \fIfraction\fR of the
+way through the content appears at the left edge of the window.
+\fIFraction\fR must be a fraction between 0 and 1.
+.TP
+\fIpathName \fBxview scroll \fInumber what\fR
+This command shifts the view in the window left or right according to
+\fInumber\fR and \fIwhat\fR.
+\fINumber\fR must be an integer.
+\fIWhat\fR must be either \fBpages\fR or \fBunits\fR.
+'\" or an abbreviation of one of these, but we don't document that.
+If \fIwhat\fR is
+\fBpages\fR then the view adjusts by \fInumber\fR screenfuls.
+If \fInumber\fR is negative then characters farther to the left
+become visible; if it is positive then characters farther to the right
+become visible.
+If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by
+\fInumber\fR average-width characters on the display.
+.RE
+.TP
+\fIpathName \fByview \fIargs\fR
+This command is used to query and change the vertical position of the
+content in the widget's window. It can take any of the following
+forms:
+.RS
+.TP
+\fIpathName \fByview\fR
+Returns a list containing two elements.
+Each element is a real fraction between 0 and 1; together they describe
+the vertical span that is visible in the window.
+For example, if the first element is .2 and the second element is .6,
+20% of the widget's content is off-screen to the top, the middle 40% is visible
+in the window, and 40% of the content is off-screen to the bottom.
+These are the same values passed to scrollbars via the \fB\-yscrollcommand\fR
+option.
+.TP
+\fIpathName \fByview\fR \fIindex\fR
+Adjusts the view in the window so that the content given by \fIindex\fR
+is displayed at the top edge of the window.
+.TP
+\fIpathName \fByview moveto\fI fraction\fR
+Adjusts the view in the window so that the item \fIfraction\fR of the
+way through the content appears at the top edge of the window.
+\fIFraction\fR must be a fraction between 0 and 1.
+.TP
+\fIpathName \fByview scroll \fInumber what\fR
+This command shifts the view in the window up or down according to
+\fInumber\fR and \fIwhat\fR.
+\fINumber\fR must be an integer.
+\fIWhat\fR must be either \fBpages\fR or \fBunits\fR.
+'\" or an abbreviation of one of these, but we don't document that.
+If \fIwhat\fR is
+\fBpages\fR then the view adjusts by \fInumber\fR screenfuls.
+If \fInumber\fR is negative then items farther to the top
+become visible; if it is positive then items farther to the bottom
+become visible.
+If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by
+\fInumber\fR average-width characters on the display.
+.RE
.SH "WIDGET STATES"
The widget state is a bitmap of independent state flags.
Widget state flags include:
diff --git a/generic/ks_names.h b/generic/ks_names.h
index 9f49130..7d11cae 100644
--- a/generic/ks_names.h
+++ b/generic/ks_names.h
@@ -4,11 +4,11 @@
* Note that this should be done manually only, because in some cases
* keysymdefs.h defines the same integer for multiple keysyms, e.g.:
*
- * #define XK_Greek_LAMDA 0x7cb
- * #define XK_Greek_LAMBDA 0x7cb
+ * #define XK_Greek_LAMDA 0x7CB
+ * #define XK_Greek_LAMBDA 0x7CB
*
- * #define XK_Cyrillic_DZHE 0x6bf
- * #define XK_Serbian_DZE 0x6bf (deprecated)
+ * #define XK_Cyrillic_DZHE 0x6BF
+ * #define XK_Serbian_DZE 0x6BF (deprecated)
*
*/
{ "BackSpace", 0xFF08 },
@@ -22,14 +22,39 @@
{ "Escape", 0xFF1B },
{ "Delete", 0xFFFF },
{ "Multi_key", 0xFF20 },
+{ "Codeinput", 0xFF37 },
+{ "SingleCandidate", 0xFF3C },
+{ "MultipleCandidate", 0xFF3D },
+{ "PreviousCandidate", 0xFF3E },
{ "Kanji", 0xFF21 },
+{ "Muhenkan", 0xFF22 },
+{ "Henkan_Mode", 0xFF23 },
+{ "Henkan", 0xFF23 },
+{ "Romaji", 0xFF24 },
+{ "Hiragana", 0xFF25 },
+{ "Katakana", 0xFF26 },
+{ "Hiragana_Katakana", 0xFF27 },
+{ "Zenkaku", 0xFF28 },
+{ "Hankaku", 0xFF29 },
+{ "Zenkaku_Hankaku", 0xFF2A },
+{ "Touroku", 0xFF2B },
+{ "Massyo", 0xFF2C },
+{ "Kana_Lock", 0xFF2D },
+{ "Kana_Shift", 0xFF2E },
+{ "Eisu_Shift", 0xFF2F },
+{ "Eisu_toggle", 0xFF30 },
+{ "Kanji_Bangou", 0xFF37 },
+{ "Zen_Koho", 0xFF3D },
+{ "Mae_Koho", 0xFF3E },
{ "Home", 0xFF50 },
{ "Left", 0xFF51 },
{ "Up", 0xFF52 },
{ "Right", 0xFF53 },
{ "Down", 0xFF54 },
{ "Prior", 0xFF55 },
+{ "Page_Up", 0xFF55 },
{ "Next", 0xFF56 },
+{ "Page_Down", 0xFF56 },
{ "End", 0xFF57 },
{ "Begin", 0xFF58 },
{ "Win_L", 0xFF5B },
@@ -56,6 +81,19 @@
{ "KP_F2", 0xFF92 },
{ "KP_F3", 0xFF93 },
{ "KP_F4", 0xFF94 },
+{ "KP_Home", 0xFF95 },
+{ "KP_Left", 0xFF96 },
+{ "KP_Up", 0xFF97 },
+{ "KP_Right", 0xFF98 },
+{ "KP_Down", 0xFF99 },
+{ "KP_Prior", 0xFF9A },
+{ "KP_Page_Up", 0xFF9A },
+{ "KP_Next", 0xFF9B },
+{ "KP_Page_Down", 0xFF9B },
+{ "KP_End", 0xFF9C },
+{ "KP_Begin", 0xFF9D },
+{ "KP_Insert", 0xFF9E },
+{ "KP_Delete", 0xFF9F },
{ "KP_Equal", 0xFFBD },
{ "KP_Multiply", 0xFFAA },
{ "KP_Add", 0xFFAB },
@@ -147,789 +185,2014 @@
{ "Super_R", 0xFFEC },
{ "Hyper_L", 0xFFED },
{ "Hyper_R", 0xFFEE },
-{ "space", 0x020 },
-{ "exclam", 0x021 },
-{ "quotedbl", 0x022 },
-{ "numbersign", 0x023 },
-{ "dollar", 0x024 },
-{ "percent", 0x025 },
-{ "ampersand", 0x026 },
-{ "quoteright", 0x027 },
-{ "parenleft", 0x028 },
-{ "parenright", 0x029 },
-{ "asterisk", 0x02a },
-{ "plus", 0x02b },
-{ "comma", 0x02c },
-{ "minus", 0x02d },
-{ "period", 0x02e },
-{ "slash", 0x02f },
-{ "0", 0x030 },
-{ "1", 0x031 },
-{ "2", 0x032 },
-{ "3", 0x033 },
-{ "4", 0x034 },
-{ "5", 0x035 },
-{ "6", 0x036 },
-{ "7", 0x037 },
-{ "8", 0x038 },
-{ "9", 0x039 },
-{ "colon", 0x03a },
-{ "semicolon", 0x03b },
-{ "less", 0x03c },
-{ "equal", 0x03d },
-{ "greater", 0x03e },
-{ "question", 0x03f },
-{ "at", 0x040 },
-{ "A", 0x041 },
-{ "B", 0x042 },
-{ "C", 0x043 },
-{ "D", 0x044 },
-{ "E", 0x045 },
-{ "F", 0x046 },
-{ "G", 0x047 },
-{ "H", 0x048 },
-{ "I", 0x049 },
-{ "J", 0x04a },
-{ "K", 0x04b },
-{ "L", 0x04c },
-{ "M", 0x04d },
-{ "N", 0x04e },
-{ "O", 0x04f },
-{ "P", 0x050 },
-{ "Q", 0x051 },
-{ "R", 0x052 },
-{ "S", 0x053 },
-{ "T", 0x054 },
-{ "U", 0x055 },
-{ "V", 0x056 },
-{ "W", 0x057 },
-{ "X", 0x058 },
-{ "Y", 0x059 },
-{ "Z", 0x05a },
-{ "bracketleft", 0x05b },
-{ "backslash", 0x05c },
-{ "bracketright", 0x05d },
-{ "asciicircum", 0x05e },
-{ "underscore", 0x05f },
-{ "quoteleft", 0x060 },
-{ "a", 0x061 },
-{ "b", 0x062 },
-{ "c", 0x063 },
-{ "d", 0x064 },
-{ "e", 0x065 },
-{ "f", 0x066 },
-{ "g", 0x067 },
-{ "h", 0x068 },
-{ "i", 0x069 },
-{ "j", 0x06a },
-{ "k", 0x06b },
-{ "l", 0x06c },
-{ "m", 0x06d },
-{ "n", 0x06e },
-{ "o", 0x06f },
-{ "p", 0x070 },
-{ "q", 0x071 },
-{ "r", 0x072 },
-{ "s", 0x073 },
-{ "t", 0x074 },
-{ "u", 0x075 },
-{ "v", 0x076 },
-{ "w", 0x077 },
-{ "x", 0x078 },
-{ "y", 0x079 },
-{ "z", 0x07a },
-{ "braceleft", 0x07b },
-{ "bar", 0x07c },
-{ "braceright", 0x07d },
-{ "asciitilde", 0x07e },
-{ "nobreakspace", 0x0a0 },
-{ "exclamdown", 0x0a1 },
-{ "cent", 0x0a2 },
-{ "sterling", 0x0a3 },
-{ "currency", 0x0a4 },
-{ "yen", 0x0a5 },
-{ "brokenbar", 0x0a6 },
-{ "section", 0x0a7 },
-{ "diaeresis", 0x0a8 },
-{ "copyright", 0x0a9 },
-{ "ordfeminine", 0x0aa },
-{ "guillemotleft", 0x0ab },
-{ "notsign", 0x0ac },
-{ "hyphen", 0x0ad },
-{ "registered", 0x0ae },
-{ "macron", 0x0af },
-{ "degree", 0x0b0 },
-{ "plusminus", 0x0b1 },
-{ "twosuperior", 0x0b2 },
-{ "threesuperior", 0x0b3 },
-{ "acute", 0x0b4 },
-{ "mu", 0x0b5 },
-{ "paragraph", 0x0b6 },
-{ "periodcentered", 0x0b7 },
-{ "cedilla", 0x0b8 },
-{ "onesuperior", 0x0b9 },
-{ "masculine", 0x0ba },
-{ "guillemotright", 0x0bb },
-{ "onequarter", 0x0bc },
-{ "onehalf", 0x0bd },
-{ "threequarters", 0x0be },
-{ "questiondown", 0x0bf },
-{ "Agrave", 0x0c0 },
-{ "Aacute", 0x0c1 },
-{ "Acircumflex", 0x0c2 },
-{ "Atilde", 0x0c3 },
-{ "Adiaeresis", 0x0c4 },
-{ "Aring", 0x0c5 },
-{ "AE", 0x0c6 },
-{ "Ccedilla", 0x0c7 },
-{ "Egrave", 0x0c8 },
-{ "Eacute", 0x0c9 },
-{ "Ecircumflex", 0x0ca },
-{ "Ediaeresis", 0x0cb },
-{ "Igrave", 0x0cc },
-{ "Iacute", 0x0cd },
-{ "Icircumflex", 0x0ce },
-{ "Idiaeresis", 0x0cf },
-{ "Eth", 0x0d0 },
-{ "Ntilde", 0x0d1 },
-{ "Ograve", 0x0d2 },
-{ "Oacute", 0x0d3 },
-{ "Ocircumflex", 0x0d4 },
-{ "Otilde", 0x0d5 },
-{ "Odiaeresis", 0x0d6 },
-{ "multiply", 0x0d7 },
-{ "Ooblique", 0x0d8 },
-{ "Ugrave", 0x0d9 },
-{ "Uacute", 0x0da },
-{ "Ucircumflex", 0x0db },
-{ "Udiaeresis", 0x0dc },
-{ "Yacute", 0x0dd },
-{ "Thorn", 0x0de },
-{ "ssharp", 0x0df },
-{ "agrave", 0x0e0 },
-{ "aacute", 0x0e1 },
-{ "acircumflex", 0x0e2 },
-{ "atilde", 0x0e3 },
-{ "adiaeresis", 0x0e4 },
-{ "aring", 0x0e5 },
-{ "ae", 0x0e6 },
-{ "ccedilla", 0x0e7 },
-{ "egrave", 0x0e8 },
-{ "eacute", 0x0e9 },
-{ "ecircumflex", 0x0ea },
-{ "ediaeresis", 0x0eb },
-{ "igrave", 0x0ec },
-{ "iacute", 0x0ed },
-{ "icircumflex", 0x0ee },
-{ "idiaeresis", 0x0ef },
-{ "eth", 0x0f0 },
-{ "ntilde", 0x0f1 },
-{ "ograve", 0x0f2 },
-{ "oacute", 0x0f3 },
-{ "ocircumflex", 0x0f4 },
-{ "otilde", 0x0f5 },
-{ "odiaeresis", 0x0f6 },
-{ "division", 0x0f7 },
-{ "oslash", 0x0f8 },
-{ "ugrave", 0x0f9 },
-{ "uacute", 0x0fa },
-{ "ucircumflex", 0x0fb },
-{ "udiaeresis", 0x0fc },
-{ "yacute", 0x0fd },
-{ "thorn", 0x0fe },
-{ "ydiaeresis", 0x0ff },
-{ "Aogonek", 0x1a1 },
-{ "breve", 0x1a2 },
-{ "Lstroke", 0x1a3 },
-{ "Lcaron", 0x1a5 },
-{ "Sacute", 0x1a6 },
-{ "Scaron", 0x1a9 },
-{ "Scedilla", 0x1aa },
-{ "Tcaron", 0x1ab },
-{ "Zacute", 0x1ac },
-{ "Zcaron", 0x1ae },
-{ "Zabovedot", 0x1af },
-{ "aogonek", 0x1b1 },
-{ "ogonek", 0x1b2 },
-{ "lstroke", 0x1b3 },
-{ "lcaron", 0x1b5 },
-{ "sacute", 0x1b6 },
-{ "caron", 0x1b7 },
-{ "scaron", 0x1b9 },
-{ "scedilla", 0x1ba },
-{ "tcaron", 0x1bb },
-{ "zacute", 0x1bc },
-{ "doubleacute", 0x1bd },
-{ "zcaron", 0x1be },
-{ "zabovedot", 0x1bf },
-{ "Racute", 0x1c0 },
-{ "Abreve", 0x1c3 },
-{ "Cacute", 0x1c6 },
-{ "Ccaron", 0x1c8 },
-{ "Eogonek", 0x1ca },
-{ "Ecaron", 0x1cc },
-{ "Dcaron", 0x1cf },
-{ "Nacute", 0x1d1 },
-{ "Ncaron", 0x1d2 },
-{ "Odoubleacute", 0x1d5 },
-{ "Rcaron", 0x1d8 },
-{ "Uring", 0x1d9 },
-{ "Udoubleacute", 0x1db },
-{ "Tcedilla", 0x1de },
-{ "racute", 0x1e0 },
-{ "abreve", 0x1e3 },
-{ "cacute", 0x1e6 },
-{ "ccaron", 0x1e8 },
-{ "eogonek", 0x1ea },
-{ "ecaron", 0x1ec },
-{ "dcaron", 0x1ef },
-{ "nacute", 0x1f1 },
-{ "ncaron", 0x1f2 },
-{ "odoubleacute", 0x1f5 },
-{ "udoubleacute", 0x1fb },
-{ "rcaron", 0x1f8 },
-{ "uring", 0x1f9 },
-{ "tcedilla", 0x1fe },
-{ "abovedot", 0x1ff },
-{ "Hstroke", 0x2a1 },
-{ "Hcircumflex", 0x2a6 },
-{ "Iabovedot", 0x2a9 },
-{ "Gbreve", 0x2ab },
-{ "Jcircumflex", 0x2ac },
-{ "hstroke", 0x2b1 },
-{ "hcircumflex", 0x2b6 },
-{ "idotless", 0x2b9 },
-{ "gbreve", 0x2bb },
-{ "jcircumflex", 0x2bc },
-{ "Cabovedot", 0x2c5 },
-{ "Ccircumflex", 0x2c6 },
-{ "Gabovedot", 0x2d5 },
-{ "Gcircumflex", 0x2d8 },
-{ "Ubreve", 0x2dd },
-{ "Scircumflex", 0x2de },
-{ "cabovedot", 0x2e5 },
-{ "ccircumflex", 0x2e6 },
-{ "gabovedot", 0x2f5 },
-{ "gcircumflex", 0x2f8 },
-{ "ubreve", 0x2fd },
-{ "scircumflex", 0x2fe },
-{ "kappa", 0x3a2 },
-{ "Rcedilla", 0x3a3 },
-{ "Itilde", 0x3a5 },
-{ "Lcedilla", 0x3a6 },
-{ "Emacron", 0x3aa },
-{ "Gcedilla", 0x3ab },
-{ "Tslash", 0x3ac },
-{ "rcedilla", 0x3b3 },
-{ "itilde", 0x3b5 },
-{ "lcedilla", 0x3b6 },
-{ "emacron", 0x3ba },
-{ "gacute", 0x3bb },
-{ "tslash", 0x3bc },
-{ "ENG", 0x3bd },
-{ "eng", 0x3bf },
-{ "Amacron", 0x3c0 },
-{ "Iogonek", 0x3c7 },
-{ "Eabovedot", 0x3cc },
-{ "Imacron", 0x3cf },
-{ "Ncedilla", 0x3d1 },
-{ "Omacron", 0x3d2 },
-{ "Kcedilla", 0x3d3 },
-{ "Uogonek", 0x3d9 },
-{ "Utilde", 0x3dd },
-{ "Umacron", 0x3de },
-{ "amacron", 0x3e0 },
-{ "iogonek", 0x3e7 },
-{ "eabovedot", 0x3ec },
-{ "imacron", 0x3ef },
-{ "ncedilla", 0x3f1 },
-{ "omacron", 0x3f2 },
-{ "kcedilla", 0x3f3 },
-{ "uogonek", 0x3f9 },
-{ "utilde", 0x3fd },
-{ "umacron", 0x3fe },
-{ "overline", 0x47e },
-{ "kana_fullstop", 0x4a1 },
-{ "kana_openingbracket", 0x4a2 },
-{ "kana_closingbracket", 0x4a3 },
-{ "kana_comma", 0x4a4 },
-{ "kana_middledot", 0x4a5 },
-{ "kana_WO", 0x4a6 },
-{ "kana_a", 0x4a7 },
-{ "kana_i", 0x4a8 },
-{ "kana_u", 0x4a9 },
-{ "kana_e", 0x4aa },
-{ "kana_o", 0x4ab },
-{ "kana_ya", 0x4ac },
-{ "kana_yu", 0x4ad },
-{ "kana_yo", 0x4ae },
-{ "kana_tu", 0x4af },
-{ "prolongedsound", 0x4b0 },
-{ "kana_A", 0x4b1 },
-{ "kana_I", 0x4b2 },
-{ "kana_U", 0x4b3 },
-{ "kana_E", 0x4b4 },
-{ "kana_O", 0x4b5 },
-{ "kana_KA", 0x4b6 },
-{ "kana_KI", 0x4b7 },
-{ "kana_KU", 0x4b8 },
-{ "kana_KE", 0x4b9 },
-{ "kana_KO", 0x4ba },
-{ "kana_SA", 0x4bb },
-{ "kana_SHI", 0x4bc },
-{ "kana_SU", 0x4bd },
-{ "kana_SE", 0x4be },
-{ "kana_SO", 0x4bf },
-{ "kana_TA", 0x4c0 },
-{ "kana_TI", 0x4c1 },
-{ "kana_TU", 0x4c2 },
-{ "kana_TE", 0x4c3 },
-{ "kana_TO", 0x4c4 },
-{ "kana_NA", 0x4c5 },
-{ "kana_NI", 0x4c6 },
-{ "kana_NU", 0x4c7 },
-{ "kana_NE", 0x4c8 },
-{ "kana_NO", 0x4c9 },
-{ "kana_HA", 0x4ca },
-{ "kana_HI", 0x4cb },
-{ "kana_HU", 0x4cc },
-{ "kana_HE", 0x4cd },
-{ "kana_HO", 0x4ce },
-{ "kana_MA", 0x4cf },
-{ "kana_MI", 0x4d0 },
-{ "kana_MU", 0x4d1 },
-{ "kana_ME", 0x4d2 },
-{ "kana_MO", 0x4d3 },
-{ "kana_YA", 0x4d4 },
-{ "kana_YU", 0x4d5 },
-{ "kana_YO", 0x4d6 },
-{ "kana_RA", 0x4d7 },
-{ "kana_RI", 0x4d8 },
-{ "kana_RU", 0x4d9 },
-{ "kana_RE", 0x4da },
-{ "kana_RO", 0x4db },
-{ "kana_WA", 0x4dc },
-{ "kana_N", 0x4dd },
-{ "voicedsound", 0x4de },
-{ "semivoicedsound", 0x4df },
+{ "ISO_Lock", 0xFE01 },
+{ "ISO_Level2_Latch", 0xFE02 },
+{ "ISO_Level3_Shift", 0xFE03 },
+{ "ISO_Level3_Latch", 0xFE04 },
+{ "ISO_Level3_Lock", 0xFE05 },
+{ "ISO_Level5_Shift", 0xFE11 },
+{ "ISO_Level5_Latch", 0xFE12 },
+{ "ISO_Level5_Lock", 0xFE13 },
+{ "ISO_Group_Shift", 0xFF7E },
+{ "ISO_Group_Latch", 0xFE06 },
+{ "ISO_Group_Lock", 0xFE07 },
+{ "ISO_Next_Group", 0xFE08 },
+{ "ISO_Next_Group_Lock", 0xFE09 },
+{ "ISO_Prev_Group", 0xFE0A },
+{ "ISO_Prev_Group_Lock", 0xFE0B },
+{ "ISO_First_Group", 0xFE0C },
+{ "ISO_First_Group_Lock", 0xFE0D },
+{ "ISO_Last_Group", 0xFE0E },
+{ "ISO_Last_Group_Lock", 0xFE0F },
+{ "ISO_Left_Tab", 0xFE20 },
+{ "ISO_Move_Line_Up", 0xFE21 },
+{ "ISO_Move_Line_Down", 0xFE22 },
+{ "ISO_Partial_Line_Up", 0xFE23 },
+{ "ISO_Partial_Line_Down", 0xFE24 },
+{ "ISO_Partial_Space_Left", 0xFE25 },
+{ "ISO_Partial_Space_Right", 0xFE26 },
+{ "ISO_Set_Margin_Left", 0xFE27 },
+{ "ISO_Set_Margin_Right", 0xFE28 },
+{ "ISO_Release_Margin_Left", 0xFE29 },
+{ "ISO_Release_Margin_Right", 0xFE2A },
+{ "ISO_Release_Both_Margins", 0xFE2B },
+{ "ISO_Fast_Cursor_Left", 0xFE2C },
+{ "ISO_Fast_Cursor_Right", 0xFE2D },
+{ "ISO_Fast_Cursor_Up", 0xFE2E },
+{ "ISO_Fast_Cursor_Down", 0xFE2F },
+{ "ISO_Continuous_Underline", 0xFE30 },
+{ "ISO_Discontinuous_Underline", 0xFE31 },
+{ "ISO_Emphasize", 0xFE32 },
+{ "ISO_Center_Object", 0xFE33 },
+{ "ISO_Enter", 0xFE34 },
+{ "dead_grave", 0xFE50 },
+{ "dead_acute", 0xFE51 },
+{ "dead_circumflex", 0xFE52 },
+{ "dead_tilde", 0xFE53 },
+{ "dead_perispomeni", 0xFE53 },
+{ "dead_macron", 0xFE54 },
+{ "dead_breve", 0xFE55 },
+{ "dead_abovedot", 0xFE56 },
+{ "dead_diaeresis", 0xFE57 },
+{ "dead_abovering", 0xFE58 },
+{ "dead_doubleacute", 0xFE59 },
+{ "dead_caron", 0xFE5A },
+{ "dead_cedilla", 0xFE5B },
+{ "dead_ogonek", 0xFE5C },
+{ "dead_iota", 0xFE5D },
+{ "dead_voiced_sound", 0xFE5E },
+{ "dead_semivoiced_sound", 0xFE5F },
+{ "dead_belowdot", 0xFE60 },
+{ "dead_hook", 0xFE61 },
+{ "dead_horn", 0xFE62 },
+{ "dead_stroke", 0xFE63 },
+{ "dead_abovecomma", 0xFE64 },
+{ "dead_psili", 0xFE64 },
+{ "dead_abovereversedcomma", 0xFE65 },
+{ "dead_dasia", 0xFE65 },
+{ "dead_doublegrave", 0xFE66 },
+{ "dead_belowring", 0xFE67 },
+{ "dead_belowmacron", 0xFE68 },
+{ "dead_belowcircumflex", 0xFE69 },
+{ "dead_belowtilde", 0xFE6A },
+{ "dead_belowbreve", 0xFE6B },
+{ "dead_belowdiaeresis", 0xFE6C },
+{ "dead_invertedbreve", 0xFE6D },
+{ "dead_belowcomma", 0xFE6E },
+{ "dead_currency", 0xFE6F },
+{ "dead_lowline", 0xFE90 },
+{ "dead_aboveverticalline", 0xFE91 },
+{ "dead_belowverticalline", 0xFE92 },
+{ "dead_longsolidusoverlay", 0xFE93 },
+{ "dead_a", 0xFE80 },
+{ "dead_A", 0xFE81 },
+{ "dead_e", 0xFE82 },
+{ "dead_E", 0xFE83 },
+{ "dead_i", 0xFE84 },
+{ "dead_I", 0xFE85 },
+{ "dead_o", 0xFE86 },
+{ "dead_O", 0xFE87 },
+{ "dead_u", 0xFE88 },
+{ "dead_U", 0xFE89 },
+{ "dead_small_schwa", 0xFE8A },
+{ "dead_capital_schwa", 0xFE8B },
+{ "dead_greek", 0xFE8C },
+{ "First_Virtual_Screen", 0xFED0 },
+{ "Prev_Virtual_Screen", 0xFED1 },
+{ "Next_Virtual_Screen", 0xFED2 },
+{ "Last_Virtual_Screen", 0xFED4 },
+{ "Terminate_Server", 0xFED5 },
+{ "AccessX_Enable", 0xFE70 },
+{ "AccessX_Feedback_Enable", 0xFE71 },
+{ "RepeatKeys_Enable", 0xFE72 },
+{ "SlowKeys_Enable", 0xFE73 },
+{ "BounceKeys_Enable", 0xFE74 },
+{ "StickyKeys_Enable", 0xFE75 },
+{ "MouseKeys_Enable", 0xFE76 },
+{ "MouseKeys_Accel_Enable", 0xFE77 },
+{ "Overlay1_Enable", 0xFE78 },
+{ "Overlay2_Enable", 0xFE79 },
+{ "AudibleBell_Enable", 0xFE7A },
+{ "Pointer_Left", 0xFEE0 },
+{ "Pointer_Right", 0xFEE1 },
+{ "Pointer_Up", 0xFEE2 },
+{ "Pointer_Down", 0xFEE3 },
+{ "Pointer_UpLeft", 0xFEE4 },
+{ "Pointer_UpRight", 0xFEE5 },
+{ "Pointer_DownLeft", 0xFEE6 },
+{ "Pointer_DownRight", 0xFEE7 },
+{ "Pointer_Button_Dflt", 0xFEE8 },
+{ "Pointer_Button1", 0xFEE9 },
+{ "Pointer_Button2", 0xFEEA },
+{ "Pointer_Button3", 0xFEEB },
+{ "Pointer_Button4", 0xFEEC },
+{ "Pointer_Button5", 0xFEED },
+{ "Pointer_DblClick_Dflt", 0xFEEE },
+{ "Pointer_DblClick1", 0xFEEF },
+{ "Pointer_DblClick2", 0xFEF0 },
+{ "Pointer_DblClick3", 0xFEF1 },
+{ "Pointer_DblClick4", 0xFEF2 },
+{ "Pointer_DblClick5", 0xFEF3 },
+{ "Pointer_Drag_Dflt", 0xFEF4 },
+{ "Pointer_Drag1", 0xFEF5 },
+{ "Pointer_Drag2", 0xFEF6 },
+{ "Pointer_Drag3", 0xFEF7 },
+{ "Pointer_Drag4", 0xFEF8 },
+{ "Pointer_Drag5", 0xFEFD },
+{ "Pointer_EnableKeys", 0xFEF9 },
+{ "Pointer_Accelerate", 0xFEFA },
+{ "Pointer_DfltBtnNext", 0xFEFB },
+{ "Pointer_DfltBtnPrev", 0xFEFC },
+{ "ch", 0xFEA0 },
+{ "Ch", 0xFEA1 },
+{ "CH", 0xFEA2 },
+{ "c_h", 0xFEA3 },
+{ "C_h", 0xFEA4 },
+{ "C_H", 0xFEA5 },
+{ "3270_Duplicate", 0xFD01 },
+{ "3270_FieldMark", 0xFD02 },
+{ "3270_Right2", 0xFD03 },
+{ "3270_Left2", 0xFD04 },
+{ "3270_BackTab", 0xFD05 },
+{ "3270_EraseEOF", 0xFD06 },
+{ "3270_EraseInput", 0xFD07 },
+{ "3270_Reset", 0xFD08 },
+{ "3270_Quit", 0xFD09 },
+{ "3270_PA1", 0xFD0A },
+{ "3270_PA2", 0xFD0B },
+{ "3270_PA3", 0xFD0C },
+{ "3270_Test", 0xFD0D },
+{ "3270_Attn", 0xFD0E },
+{ "3270_CursorBlink", 0xFD0F },
+{ "3270_AltCursor", 0xFD10 },
+{ "3270_KeyClick", 0xFD11 },
+{ "3270_Jump", 0xFD12 },
+{ "3270_Ident", 0xFD13 },
+{ "3270_Rule", 0xFD14 },
+{ "3270_Copy", 0xFD15 },
+{ "3270_Play", 0xFD16 },
+{ "3270_Setup", 0xFD17 },
+{ "3270_Record", 0xFD18 },
+{ "3270_ChangeScreen", 0xFD19 },
+{ "3270_DeleteWord", 0xFD1A },
+{ "3270_ExSelect", 0xFD1B },
+{ "3270_CursorSelect", 0xFD1C },
+{ "3270_PrintScreen", 0xFD1D },
+{ "3270_Enter", 0xFD1E },
+{ "space", 0x20 },
+{ "exclam", 0x21 },
+{ "quotedbl", 0x22 },
+{ "numbersign", 0x23 },
+{ "dollar", 0x24 },
+{ "percent", 0x25 },
+{ "ampersand", 0x26 },
+{ "apostrophe", 0x27 },
+{ "quoteright", 0x27 },
+{ "parenleft", 0x28 },
+{ "parenright", 0x29 },
+{ "asterisk", 0x2A },
+{ "plus", 0x2B },
+{ "comma", 0x2C },
+{ "minus", 0x2D },
+{ "period", 0x2E },
+{ "slash", 0x2F },
+{ "0", 0x30 },
+{ "1", 0x31 },
+{ "2", 0x32 },
+{ "3", 0x33 },
+{ "4", 0x34 },
+{ "5", 0x35 },
+{ "6", 0x36 },
+{ "7", 0x37 },
+{ "8", 0x38 },
+{ "9", 0x39 },
+{ "colon", 0x3A },
+{ "semicolon", 0x3B },
+{ "less", 0x3C },
+{ "equal", 0x3D },
+{ "greater", 0x3E },
+{ "question", 0x3F },
+{ "at", 0x40 },
+{ "A", 0x41 },
+{ "B", 0x42 },
+{ "C", 0x43 },
+{ "D", 0x44 },
+{ "E", 0x45 },
+{ "F", 0x46 },
+{ "G", 0x47 },
+{ "H", 0x48 },
+{ "I", 0x49 },
+{ "J", 0x4A },
+{ "K", 0x4B },
+{ "L", 0x4C },
+{ "M", 0x4D },
+{ "N", 0x4E },
+{ "O", 0x4F },
+{ "P", 0x50 },
+{ "Q", 0x51 },
+{ "R", 0x52 },
+{ "S", 0x53 },
+{ "T", 0x54 },
+{ "U", 0x55 },
+{ "V", 0x56 },
+{ "W", 0x57 },
+{ "X", 0x58 },
+{ "Y", 0x59 },
+{ "Z", 0x5A },
+{ "bracketleft", 0x5B },
+{ "backslash", 0x5C },
+{ "bracketright", 0x5D },
+{ "asciicircum", 0x5E },
+{ "underscore", 0x5F },
+{ "grave", 0x60 },
+{ "quoteleft", 0x60 },
+{ "a", 0x61 },
+{ "b", 0x62 },
+{ "c", 0x63 },
+{ "d", 0x64 },
+{ "e", 0x65 },
+{ "f", 0x66 },
+{ "g", 0x67 },
+{ "h", 0x68 },
+{ "i", 0x69 },
+{ "j", 0x6A },
+{ "k", 0x6B },
+{ "l", 0x6C },
+{ "m", 0x6D },
+{ "n", 0x6E },
+{ "o", 0x6F },
+{ "p", 0x70 },
+{ "q", 0x71 },
+{ "r", 0x72 },
+{ "s", 0x73 },
+{ "t", 0x74 },
+{ "u", 0x75 },
+{ "v", 0x76 },
+{ "w", 0x77 },
+{ "x", 0x78 },
+{ "y", 0x79 },
+{ "z", 0x7A },
+{ "braceleft", 0x7B },
+{ "bar", 0x7C },
+{ "braceright", 0x7D },
+{ "asciitilde", 0x7E },
+{ "nobreakspace", 0xA0 },
+{ "exclamdown", 0xA1 },
+{ "cent", 0xA2 },
+{ "sterling", 0xA3 },
+{ "currency", 0xA4 },
+{ "yen", 0xA5 },
+{ "brokenbar", 0xA6 },
+{ "section", 0xA7 },
+{ "diaeresis", 0xA8 },
+{ "copyright", 0xA9 },
+{ "ordfeminine", 0xAA },
+{ "guillemotleft", 0xAB },
+{ "notsign", 0xAC },
+{ "hyphen", 0xAD },
+{ "registered", 0xAE },
+{ "macron", 0xAF },
+{ "degree", 0xB0 },
+{ "plusminus", 0xB1 },
+{ "twosuperior", 0xB2 },
+{ "threesuperior", 0xB3 },
+{ "acute", 0xB4 },
+{ "mu", 0xB5 },
+{ "paragraph", 0xB6 },
+{ "periodcentered", 0xB7 },
+{ "cedilla", 0xB8 },
+{ "onesuperior", 0xB9 },
+{ "masculine", 0xBA },
+{ "guillemotright", 0xBB },
+{ "onequarter", 0xBC },
+{ "onehalf", 0xBD },
+{ "threequarters", 0xBE },
+{ "questiondown", 0xBF },
+{ "Agrave", 0xC0 },
+{ "Aacute", 0xC1 },
+{ "Acircumflex", 0xC2 },
+{ "Atilde", 0xC3 },
+{ "Adiaeresis", 0xC4 },
+{ "Aring", 0xC5 },
+{ "AE", 0xC6 },
+{ "Ccedilla", 0xC7 },
+{ "Egrave", 0xC8 },
+{ "Eacute", 0xC9 },
+{ "Ecircumflex", 0xCA },
+{ "Ediaeresis", 0xCB },
+{ "Igrave", 0xCC },
+{ "Iacute", 0xCD },
+{ "Icircumflex", 0xCE },
+{ "Idiaeresis", 0xCF },
+{ "ETH", 0xD0 },
+{ "Eth", 0xD0 },
+{ "Ntilde", 0xD1 },
+{ "Ograve", 0xD2 },
+{ "Oacute", 0xD3 },
+{ "Ocircumflex", 0xD4 },
+{ "Otilde", 0xD5 },
+{ "Odiaeresis", 0xD6 },
+{ "multiply", 0xD7 },
+{ "Oslash", 0xD8 },
+#ifndef TK_NO_DEPRECATED
+{ "Ooblique", 0xD8 },
+#endif
+{ "Ugrave", 0xD9 },
+{ "Uacute", 0xDA },
+{ "Ucircumflex", 0xDB },
+{ "Udiaeresis", 0xDC },
+{ "Yacute", 0xDD },
+{ "THORN", 0xDE },
+{ "Thorn", 0xDE },
+{ "ssharp", 0xDF },
+{ "agrave", 0xE0 },
+{ "aacute", 0xE1 },
+{ "acircumflex", 0xE2 },
+{ "atilde", 0xE3 },
+{ "adiaeresis", 0xE4 },
+{ "aring", 0xE5 },
+{ "ae", 0xE6 },
+{ "ccedilla", 0xE7 },
+{ "egrave", 0xE8 },
+{ "eacute", 0xE9 },
+{ "ecircumflex", 0xEA },
+{ "ediaeresis", 0xEB },
+{ "igrave", 0xEC },
+{ "iacute", 0xED },
+{ "icircumflex", 0xEE },
+{ "idiaeresis", 0xEF },
+{ "eth", 0xF0 },
+{ "ntilde", 0xF1 },
+{ "ograve", 0xF2 },
+{ "oacute", 0xF3 },
+{ "ocircumflex", 0xF4 },
+{ "otilde", 0xF5 },
+{ "odiaeresis", 0xF6 },
+{ "division", 0xF7 },
+{ "oslash", 0xF8 },
+#ifndef TK_NO_DEPRECATED
+{ "ooblique", 0xF8 },
+#endif
+{ "ugrave", 0xF9 },
+{ "uacute", 0xFA },
+{ "ucircumflex", 0xFB },
+{ "udiaeresis", 0xFC },
+{ "yacute", 0xFD },
+{ "thorn", 0xFE },
+{ "ydiaeresis", 0xFF },
+{ "Aogonek", 0x1A1 },
+{ "breve", 0x1A2 },
+{ "Lstroke", 0x1A3 },
+{ "Lcaron", 0x1A5 },
+{ "Sacute", 0x1A6 },
+{ "Scaron", 0x1A9 },
+{ "Scedilla", 0x1AA },
+{ "Tcaron", 0x1AB },
+{ "Zacute", 0x1AC },
+{ "Zcaron", 0x1AE },
+{ "Zabovedot", 0x1AF },
+{ "aogonek", 0x1B1 },
+{ "ogonek", 0x1B2 },
+{ "lstroke", 0x1B3 },
+{ "lcaron", 0x1B5 },
+{ "sacute", 0x1B6 },
+{ "caron", 0x1B7 },
+{ "scaron", 0x1B9 },
+{ "scedilla", 0x1BA },
+{ "tcaron", 0x1BB },
+{ "zacute", 0x1BC },
+{ "doubleacute", 0x1BD },
+{ "zcaron", 0x1BE },
+{ "zabovedot", 0x1BF },
+{ "Racute", 0x1C0 },
+{ "Abreve", 0x1C3 },
+{ "Lacute", 0x1C5 },
+{ "Cacute", 0x1C6 },
+{ "Ccaron", 0x1C8 },
+{ "Eogonek", 0x1CA },
+{ "Ecaron", 0x1CC },
+{ "Dcaron", 0x1CF },
+{ "Dstroke", 0x1D0 },
+{ "Nacute", 0x1D1 },
+{ "Ncaron", 0x1D2 },
+{ "Odoubleacute", 0x1D5 },
+{ "Rcaron", 0x1D8 },
+{ "Uring", 0x1D9 },
+{ "Udoubleacute", 0x1DB },
+{ "Tcedilla", 0x1DE },
+{ "racute", 0x1E0 },
+{ "abreve", 0x1E3 },
+{ "lacute", 0x1E5 },
+{ "cacute", 0x1E6 },
+{ "ccaron", 0x1E8 },
+{ "eogonek", 0x1EA },
+{ "ecaron", 0x1EC },
+{ "dcaron", 0x1EF },
+{ "dstroke", 0x1F0 },
+{ "nacute", 0x1F1 },
+{ "ncaron", 0x1F2 },
+{ "odoubleacute", 0x1F5 },
+{ "rcaron", 0x1F8 },
+{ "uring", 0x1F9 },
+{ "udoubleacute", 0x1FB },
+{ "tcedilla", 0x1FE },
+{ "abovedot", 0x1FF },
+{ "Hstroke", 0x2A1 },
+{ "Hcircumflex", 0x2A6 },
+{ "Iabovedot", 0x2A9 },
+{ "Gbreve", 0x2AB },
+{ "Jcircumflex", 0x2AC },
+{ "hstroke", 0x2B1 },
+{ "hcircumflex", 0x2B6 },
+{ "idotless", 0x2B9 },
+{ "gbreve", 0x2BB },
+{ "jcircumflex", 0x2BC },
+{ "Cabovedot", 0x2C5 },
+{ "Ccircumflex", 0x2C6 },
+{ "Gabovedot", 0x2D5 },
+{ "Gcircumflex", 0x2D8 },
+{ "Ubreve", 0x2DD },
+{ "Scircumflex", 0x2DE },
+{ "cabovedot", 0x2E5 },
+{ "ccircumflex", 0x2E6 },
+{ "gabovedot", 0x2F5 },
+{ "gcircumflex", 0x2F8 },
+{ "ubreve", 0x2FD },
+{ "scircumflex", 0x2FE },
+{ "kra", 0x3A2 },
+#ifndef TK_NO_DEPRECATED
+{ "kappa", 0x3A2 },
+#endif
+{ "Rcedilla", 0x3A3 },
+{ "Itilde", 0x3A5 },
+{ "Lcedilla", 0x3A6 },
+{ "Emacron", 0x3AA },
+{ "Gcedilla", 0x3AB },
+{ "Tslash", 0x3AC },
+{ "rcedilla", 0x3B3 },
+{ "itilde", 0x3B5 },
+{ "lcedilla", 0x3B6 },
+{ "emacron", 0x3BA },
+{ "gcedilla", 0x3BB },
+#ifndef TK_NO_DEPRECATED
+{ "gacute", 0x3BB },
+#endif
+{ "tslash", 0x3BC },
+{ "ENG", 0x3BD },
+{ "eng", 0x3BF },
+{ "Amacron", 0x3C0 },
+{ "Iogonek", 0x3C7 },
+{ "Eabovedot", 0x3CC },
+{ "Imacron", 0x3CF },
+{ "Ncedilla", 0x3D1 },
+{ "Omacron", 0x3D2 },
+{ "Kcedilla", 0x3D3 },
+{ "Uogonek", 0x3D9 },
+{ "Utilde", 0x3DD },
+{ "Umacron", 0x3DE },
+{ "amacron", 0x3E0 },
+{ "iogonek", 0x3E7 },
+{ "eabovedot", 0x3EC },
+{ "imacron", 0x3EF },
+{ "ncedilla", 0x3F1 },
+{ "omacron", 0x3F2 },
+{ "kcedilla", 0x3F3 },
+{ "uogonek", 0x3F9 },
+{ "utilde", 0x3FD },
+{ "umacron", 0x3FE },
+{ "Wcircumflex", 0x1000174 },
+{ "wcircumflex", 0x1000175 },
+{ "Ycircumflex", 0x1000176 },
+{ "ycircumflex", 0x1000177 },
+{ "Babovedot", 0x1001E02 },
+{ "babovedot", 0x1001E03 },
+{ "Dabovedot", 0x1001E0A },
+{ "dabovedot", 0x1001E0B },
+{ "Fabovedot", 0x1001E1E },
+{ "fabovedot", 0x1001E1F },
+{ "Mabovedot", 0x1001E40 },
+{ "mabovedot", 0x1001E41 },
+{ "Pabovedot", 0x1001E56 },
+{ "pabovedot", 0x1001E57 },
+{ "Sabovedot", 0x1001E60 },
+{ "sabovedot", 0x1001E61 },
+{ "Tabovedot", 0x1001E6A },
+{ "tabovedot", 0x1001E6B },
+{ "Wgrave", 0x1001E80 },
+{ "wgrave", 0x1001E81 },
+{ "Wacute", 0x1001E82 },
+{ "wacute", 0x1001E83 },
+{ "Wdiaeresis", 0x1001E84 },
+{ "wdiaeresis", 0x1001E85 },
+{ "Ygrave", 0x1001EF2 },
+{ "ygrave", 0x1001EF3 },
+{ "OE", 0x13BC },
+{ "oe", 0x13BD },
+{ "Ydiaeresis", 0x13BE },
+{ "overline", 0x47E },
+{ "kana_fullstop", 0x4A1 },
+{ "kana_openingbracket", 0x4A2 },
+{ "kana_closingbracket", 0x4A3 },
+{ "kana_comma", 0x4A4 },
+{ "kana_conjunctive", 0x4A5 },
+#ifndef TK_NO_DEPRECATED
+{ "kana_middledot", 0x4A5 },
+#endif
+{ "kana_WO", 0x4A6 },
+{ "kana_a", 0x4A7 },
+{ "kana_i", 0x4A8 },
+{ "kana_u", 0x4A9 },
+{ "kana_e", 0x4AA },
+{ "kana_o", 0x4AB },
+{ "kana_ya", 0x4AC },
+{ "kana_yu", 0x4AD },
+{ "kana_yo", 0x4AE },
+{ "kana_tsu", 0x4AF },
+#ifndef TK_NO_DEPRECATED
+{ "kana_tu", 0x4AF },
+#endif
+{ "prolongedsound", 0x4B0 },
+{ "kana_A", 0x4B1 },
+{ "kana_I", 0x4B2 },
+{ "kana_U", 0x4B3 },
+{ "kana_E", 0x4B4 },
+{ "kana_O", 0x4B5 },
+{ "kana_KA", 0x4B6 },
+{ "kana_KI", 0x4B7 },
+{ "kana_KU", 0x4B8 },
+{ "kana_KE", 0x4B9 },
+{ "kana_KO", 0x4BA },
+{ "kana_SA", 0x4BB },
+{ "kana_SHI", 0x4BC },
+{ "kana_SU", 0x4BD },
+{ "kana_SE", 0x4BE },
+{ "kana_SO", 0x4BF },
+{ "kana_TA", 0x4C0 },
+{ "kana_CHI", 0x4C1 },
+#ifndef TK_NO_DEPRECATED
+{ "kana_TI", 0x4C1 },
+#endif
+{ "kana_TSU", 0x4C2 },
+#ifndef TK_NO_DEPRECATED
+{ "kana_TU", 0x4C2 },
+#endif
+{ "kana_TE", 0x4C3 },
+{ "kana_TO", 0x4C4 },
+{ "kana_NA", 0x4C5 },
+{ "kana_NI", 0x4C6 },
+{ "kana_NU", 0x4C7 },
+{ "kana_NE", 0x4C8 },
+{ "kana_NO", 0x4C9 },
+{ "kana_HA", 0x4CA },
+{ "kana_HI", 0x4CB },
+{ "kana_FU", 0x4CC },
+#ifndef TK_NO_DEPRECATED
+{ "kana_HU", 0x4CC },
+#endif
+{ "kana_HE", 0x4CD },
+{ "kana_HO", 0x4CE },
+{ "kana_MA", 0x4CF },
+{ "kana_MI", 0x4D0 },
+{ "kana_MU", 0x4D1 },
+{ "kana_ME", 0x4D2 },
+{ "kana_MO", 0x4D3 },
+{ "kana_YA", 0x4D4 },
+{ "kana_YU", 0x4D5 },
+{ "kana_YO", 0x4D6 },
+{ "kana_RA", 0x4D7 },
+{ "kana_RI", 0x4D8 },
+{ "kana_RU", 0x4D9 },
+{ "kana_RE", 0x4DA },
+{ "kana_RO", 0x4DB },
+{ "kana_WA", 0x4DC },
+{ "kana_N", 0x4DD },
+{ "voicedsound", 0x4DE },
+{ "semivoicedsound", 0x4DF },
{ "kana_switch", 0xFF7E },
-{ "Arabic_comma", 0x5ac },
-{ "Arabic_semicolon", 0x5bb },
-{ "Arabic_question_mark", 0x5bf },
-{ "Arabic_hamza", 0x5c1 },
-{ "Arabic_maddaonalef", 0x5c2 },
-{ "Arabic_hamzaonalef", 0x5c3 },
-{ "Arabic_hamzaonwaw", 0x5c4 },
-{ "Arabic_hamzaunderalef", 0x5c5 },
-{ "Arabic_hamzaonyeh", 0x5c6 },
-{ "Arabic_alef", 0x5c7 },
-{ "Arabic_beh", 0x5c8 },
-{ "Arabic_tehmarbuta", 0x5c9 },
-{ "Arabic_teh", 0x5ca },
-{ "Arabic_theh", 0x5cb },
-{ "Arabic_jeem", 0x5cc },
-{ "Arabic_hah", 0x5cd },
-{ "Arabic_khah", 0x5ce },
-{ "Arabic_dal", 0x5cf },
-{ "Arabic_thal", 0x5d0 },
-{ "Arabic_ra", 0x5d1 },
-{ "Arabic_zain", 0x5d2 },
-{ "Arabic_seen", 0x5d3 },
-{ "Arabic_sheen", 0x5d4 },
-{ "Arabic_sad", 0x5d5 },
-{ "Arabic_dad", 0x5d6 },
-{ "Arabic_tah", 0x5d7 },
-{ "Arabic_zah", 0x5d8 },
-{ "Arabic_ain", 0x5d9 },
-{ "Arabic_ghain", 0x5da },
-{ "Arabic_tatweel", 0x5e0 },
-{ "Arabic_feh", 0x5e1 },
-{ "Arabic_qaf", 0x5e2 },
-{ "Arabic_kaf", 0x5e3 },
-{ "Arabic_lam", 0x5e4 },
-{ "Arabic_meem", 0x5e5 },
-{ "Arabic_noon", 0x5e6 },
-{ "Arabic_heh", 0x5e7 },
-{ "Arabic_waw", 0x5e8 },
-{ "Arabic_alefmaksura", 0x5e9 },
-{ "Arabic_yeh", 0x5ea },
-{ "Arabic_fathatan", 0x5eb },
-{ "Arabic_dammatan", 0x5ec },
-{ "Arabic_kasratan", 0x5ed },
-{ "Arabic_fatha", 0x5ee },
-{ "Arabic_damma", 0x5ef },
-{ "Arabic_kasra", 0x5f0 },
-{ "Arabic_shadda", 0x5f1 },
-{ "Arabic_sukun", 0x5f2 },
+{ "Farsi_0", 0x10006F0 },
+{ "Farsi_1", 0x10006F1 },
+{ "Farsi_2", 0x10006F2 },
+{ "Farsi_3", 0x10006F3 },
+{ "Farsi_4", 0x10006F4 },
+{ "Farsi_5", 0x10006F5 },
+{ "Farsi_6", 0x10006F6 },
+{ "Farsi_7", 0x10006F7 },
+{ "Farsi_8", 0x10006F8 },
+{ "Farsi_9", 0x10006F9 },
+{ "Arabic_percent", 0x100066A },
+{ "Arabic_superscript_alef", 0x1000670 },
+{ "Arabic_tteh", 0x1000679 },
+{ "Arabic_peh", 0x100067E },
+{ "Arabic_tcheh", 0x1000686 },
+{ "Arabic_ddal", 0x1000688 },
+{ "Arabic_rreh", 0x1000691 },
+{ "Arabic_comma", 0x5AC },
+{ "Arabic_fullstop", 0x10006D4 },
+{ "Arabic_0", 0x1000660 },
+{ "Arabic_1", 0x1000661 },
+{ "Arabic_2", 0x1000662 },
+{ "Arabic_3", 0x1000663 },
+{ "Arabic_4", 0x1000664 },
+{ "Arabic_5", 0x1000665 },
+{ "Arabic_6", 0x1000666 },
+{ "Arabic_7", 0x1000667 },
+{ "Arabic_8", 0x1000668 },
+{ "Arabic_9", 0x1000669 },
+{ "Arabic_semicolon", 0x5BB },
+{ "Arabic_question_mark", 0x5BF },
+{ "Arabic_hamza", 0x5C1 },
+{ "Arabic_maddaonalef", 0x5C2 },
+{ "Arabic_hamzaonalef", 0x5C3 },
+{ "Arabic_hamzaonwaw", 0x5C4 },
+{ "Arabic_hamzaunderalef", 0x5C5 },
+{ "Arabic_hamzaonyeh", 0x5C6 },
+{ "Arabic_alef", 0x5C7 },
+{ "Arabic_beh", 0x5C8 },
+{ "Arabic_tehmarbuta", 0x5C9 },
+{ "Arabic_teh", 0x5CA },
+{ "Arabic_theh", 0x5CB },
+{ "Arabic_jeem", 0x5CC },
+{ "Arabic_hah", 0x5CD },
+{ "Arabic_khah", 0x5CE },
+{ "Arabic_dal", 0x5CF },
+{ "Arabic_thal", 0x5D0 },
+{ "Arabic_ra", 0x5D1 },
+{ "Arabic_zain", 0x5D2 },
+{ "Arabic_seen", 0x5D3 },
+{ "Arabic_sheen", 0x5D4 },
+{ "Arabic_sad", 0x5D5 },
+{ "Arabic_dad", 0x5D6 },
+{ "Arabic_tah", 0x5D7 },
+{ "Arabic_zah", 0x5D8 },
+{ "Arabic_ain", 0x5D9 },
+{ "Arabic_ghain", 0x5DA },
+{ "Arabic_tatweel", 0x5E0 },
+{ "Arabic_feh", 0x5E1 },
+{ "Arabic_qaf", 0x5E2 },
+{ "Arabic_kaf", 0x5E3 },
+{ "Arabic_lam", 0x5E4 },
+{ "Arabic_meem", 0x5E5 },
+{ "Arabic_noon", 0x5E6 },
+{ "Arabic_ha", 0x5E7 },
+#ifndef TK_NO_DEPRECATED
+{ "Arabic_heh", 0x5E7 },
+#endif
+{ "Arabic_waw", 0x5E8 },
+{ "Arabic_alefmaksura", 0x5E9 },
+{ "Arabic_yeh", 0x5EA },
+{ "Arabic_fathatan", 0x5EB },
+{ "Arabic_dammatan", 0x5EC },
+{ "Arabic_kasratan", 0x5ED },
+{ "Arabic_fatha", 0x5EE },
+{ "Arabic_damma", 0x5EF },
+{ "Arabic_kasra", 0x5F0 },
+{ "Arabic_shadda", 0x5F1 },
+{ "Arabic_sukun", 0x5F2 },
+{ "Arabic_madda_above", 0x1000653 },
+{ "Arabic_hamza_above", 0x1000654 },
+{ "Arabic_hamza_below", 0x1000655 },
+{ "Arabic_jeh", 0x1000698 },
+{ "Arabic_veh", 0x10006A4 },
+{ "Arabic_keheh", 0x10006A9 },
+{ "Arabic_gaf", 0x10006AF },
+{ "Arabic_noon_ghunna", 0x10006BA },
+{ "Arabic_heh_doachashmee", 0x10006BE },
+{ "Farsi_yeh", 0x10006CC },
+{ "Arabic_farsi_yeh", 0x10006CC },
+{ "Arabic_yeh_baree", 0x10006D2 },
+{ "Arabic_heh_goal", 0x10006C1 },
{ "Arabic_switch", 0xFF7E },
-{ "Serbian_dje", 0x6a1 },
-{ "Macedonia_gje", 0x6a2 },
-{ "Cyrillic_io", 0x6a3 },
-{ "Ukranian_je", 0x6a4 },
-{ "Macedonia_dse", 0x6a5 },
-{ "Ukranian_i", 0x6a6 },
-{ "Ukranian_yi", 0x6a7 },
-{ "Serbian_je", 0x6a8 },
-{ "Serbian_lje", 0x6a9 },
-{ "Serbian_nje", 0x6aa },
-{ "Serbian_tshe", 0x6ab },
-{ "Macedonia_kje", 0x6ac },
-{ "Byelorussian_shortu", 0x6ae },
-{ "Serbian_dze", 0x6af },
-{ "numerosign", 0x6b0 },
-{ "Serbian_DJE", 0x6b1 },
-{ "Macedonia_GJE", 0x6b2 },
-{ "Cyrillic_IO", 0x6b3 },
-{ "Ukranian_JE", 0x6b4 },
-{ "Macedonia_DSE", 0x6b5 },
-{ "Ukranian_I", 0x6b6 },
-{ "Ukranian_YI", 0x6b7 },
-{ "Serbian_JE", 0x6b8 },
-{ "Serbian_LJE", 0x6b9 },
-{ "Serbian_NJE", 0x6ba },
-{ "Serbian_TSHE", 0x6bb },
-{ "Macedonia_KJE", 0x6bc },
-{ "Byelorussian_SHORTU", 0x6be },
-{ "Serbian_DZE", 0x6bf },
-{ "Cyrillic_yu", 0x6c0 },
-{ "Cyrillic_a", 0x6c1 },
-{ "Cyrillic_be", 0x6c2 },
-{ "Cyrillic_tse", 0x6c3 },
-{ "Cyrillic_de", 0x6c4 },
-{ "Cyrillic_ie", 0x6c5 },
-{ "Cyrillic_ef", 0x6c6 },
-{ "Cyrillic_ghe", 0x6c7 },
-{ "Cyrillic_ha", 0x6c8 },
-{ "Cyrillic_i", 0x6c9 },
-{ "Cyrillic_shorti", 0x6ca },
-{ "Cyrillic_ka", 0x6cb },
-{ "Cyrillic_el", 0x6cc },
-{ "Cyrillic_em", 0x6cd },
-{ "Cyrillic_en", 0x6ce },
-{ "Cyrillic_o", 0x6cf },
-{ "Cyrillic_pe", 0x6d0 },
-{ "Cyrillic_ya", 0x6d1 },
-{ "Cyrillic_er", 0x6d2 },
-{ "Cyrillic_es", 0x6d3 },
-{ "Cyrillic_te", 0x6d4 },
-{ "Cyrillic_u", 0x6d5 },
-{ "Cyrillic_zhe", 0x6d6 },
-{ "Cyrillic_ve", 0x6d7 },
-{ "Cyrillic_softsign", 0x6d8 },
-{ "Cyrillic_yeru", 0x6d9 },
-{ "Cyrillic_ze", 0x6da },
-{ "Cyrillic_sha", 0x6db },
-{ "Cyrillic_e", 0x6dc },
-{ "Cyrillic_shcha", 0x6dd },
-{ "Cyrillic_che", 0x6de },
-{ "Cyrillic_hardsign", 0x6df },
-{ "Cyrillic_YU", 0x6e0 },
-{ "Cyrillic_A", 0x6e1 },
-{ "Cyrillic_BE", 0x6e2 },
-{ "Cyrillic_TSE", 0x6e3 },
-{ "Cyrillic_DE", 0x6e4 },
-{ "Cyrillic_IE", 0x6e5 },
-{ "Cyrillic_EF", 0x6e6 },
-{ "Cyrillic_GHE", 0x6e7 },
-{ "Cyrillic_HA", 0x6e8 },
-{ "Cyrillic_I", 0x6e9 },
-{ "Cyrillic_SHORTI", 0x6ea },
-{ "Cyrillic_KA", 0x6eb },
-{ "Cyrillic_EL", 0x6ec },
-{ "Cyrillic_EM", 0x6ed },
-{ "Cyrillic_EN", 0x6ee },
-{ "Cyrillic_O", 0x6ef },
-{ "Cyrillic_PE", 0x6f0 },
-{ "Cyrillic_YA", 0x6f1 },
-{ "Cyrillic_ER", 0x6f2 },
-{ "Cyrillic_ES", 0x6f3 },
-{ "Cyrillic_TE", 0x6f4 },
-{ "Cyrillic_U", 0x6f5 },
-{ "Cyrillic_ZHE", 0x6f6 },
-{ "Cyrillic_VE", 0x6f7 },
-{ "Cyrillic_SOFTSIGN", 0x6f8 },
-{ "Cyrillic_YERU", 0x6f9 },
-{ "Cyrillic_ZE", 0x6fa },
-{ "Cyrillic_SHA", 0x6fb },
-{ "Cyrillic_E", 0x6fc },
-{ "Cyrillic_SHCHA", 0x6fd },
-{ "Cyrillic_CHE", 0x6fe },
-{ "Cyrillic_HARDSIGN", 0x6ff },
-{ "Greek_ALPHAaccent", 0x7a1 },
-{ "Greek_EPSILONaccent", 0x7a2 },
-{ "Greek_ETAaccent", 0x7a3 },
-{ "Greek_IOTAaccent", 0x7a4 },
-{ "Greek_IOTAdiaeresis", 0x7a5 },
-{ "Greek_IOTAaccentdiaeresis", 0x7a6 },
-{ "Greek_OMICRONaccent", 0x7a7 },
-{ "Greek_UPSILONaccent", 0x7a8 },
-{ "Greek_UPSILONdieresis", 0x7a9 },
-{ "Greek_UPSILONaccentdieresis", 0x7aa },
-{ "Greek_OMEGAaccent", 0x7ab },
-{ "Greek_alphaaccent", 0x7b1 },
-{ "Greek_epsilonaccent", 0x7b2 },
-{ "Greek_etaaccent", 0x7b3 },
-{ "Greek_iotaaccent", 0x7b4 },
-{ "Greek_iotadieresis", 0x7b5 },
-{ "Greek_iotaaccentdieresis", 0x7b6 },
-{ "Greek_omicronaccent", 0x7b7 },
-{ "Greek_upsilonaccent", 0x7b8 },
-{ "Greek_upsilondieresis", 0x7b9 },
-{ "Greek_upsilonaccentdieresis", 0x7ba },
-{ "Greek_omegaaccent", 0x7bb },
-{ "Greek_ALPHA", 0x7c1 },
-{ "Greek_BETA", 0x7c2 },
-{ "Greek_GAMMA", 0x7c3 },
-{ "Greek_DELTA", 0x7c4 },
-{ "Greek_EPSILON", 0x7c5 },
-{ "Greek_ZETA", 0x7c6 },
-{ "Greek_ETA", 0x7c7 },
-{ "Greek_THETA", 0x7c8 },
-{ "Greek_IOTA", 0x7c9 },
-{ "Greek_KAPPA", 0x7ca },
-{ "Greek_LAMBDA", 0x7cb },
-{ "Greek_MU", 0x7cc },
-{ "Greek_NU", 0x7cd },
-{ "Greek_XI", 0x7ce },
-{ "Greek_OMICRON", 0x7cf },
-{ "Greek_PI", 0x7d0 },
-{ "Greek_RHO", 0x7d1 },
-{ "Greek_SIGMA", 0x7d2 },
-{ "Greek_TAU", 0x7d4 },
-{ "Greek_UPSILON", 0x7d5 },
-{ "Greek_PHI", 0x7d6 },
-{ "Greek_CHI", 0x7d7 },
-{ "Greek_PSI", 0x7d8 },
-{ "Greek_OMEGA", 0x7d9 },
-{ "Greek_alpha", 0x7e1 },
-{ "Greek_beta", 0x7e2 },
-{ "Greek_gamma", 0x7e3 },
-{ "Greek_delta", 0x7e4 },
-{ "Greek_epsilon", 0x7e5 },
-{ "Greek_zeta", 0x7e6 },
-{ "Greek_eta", 0x7e7 },
-{ "Greek_theta", 0x7e8 },
-{ "Greek_iota", 0x7e9 },
-{ "Greek_kappa", 0x7ea },
-{ "Greek_lambda", 0x7eb },
-{ "Greek_mu", 0x7ec },
-{ "Greek_nu", 0x7ed },
-{ "Greek_xi", 0x7ee },
-{ "Greek_omicron", 0x7ef },
-{ "Greek_pi", 0x7f0 },
-{ "Greek_rho", 0x7f1 },
-{ "Greek_sigma", 0x7f2 },
-{ "Greek_finalsmallsigma", 0x7f3 },
-{ "Greek_tau", 0x7f4 },
-{ "Greek_upsilon", 0x7f5 },
-{ "Greek_phi", 0x7f6 },
-{ "Greek_chi", 0x7f7 },
-{ "Greek_psi", 0x7f8 },
-{ "Greek_omega", 0x7f9 },
+{ "Cyrillic_GHE_bar", 0x1000492 },
+{ "Cyrillic_ghe_bar", 0x1000493 },
+{ "Cyrillic_ZHE_descender", 0x1000496 },
+{ "Cyrillic_zhe_descender", 0x1000497 },
+{ "Cyrillic_KA_descender", 0x100049A },
+{ "Cyrillic_ka_descender", 0x100049B },
+{ "Cyrillic_KA_vertstroke", 0x100049C },
+{ "Cyrillic_ka_vertstroke", 0x100049D },
+{ "Cyrillic_EN_descender", 0x10004A2 },
+{ "Cyrillic_en_descender", 0x10004A3 },
+{ "Cyrillic_U_straight", 0x10004AE },
+{ "Cyrillic_u_straight", 0x10004AF },
+{ "Cyrillic_U_straight_bar", 0x10004B0 },
+{ "Cyrillic_u_straight_bar", 0x10004B1 },
+{ "Cyrillic_HA_descender", 0x10004B2 },
+{ "Cyrillic_ha_descender", 0x10004B3 },
+{ "Cyrillic_CHE_descender", 0x10004B6 },
+{ "Cyrillic_che_descender", 0x10004B7 },
+{ "Cyrillic_CHE_vertstroke", 0x10004B8 },
+{ "Cyrillic_che_vertstroke", 0x10004B9 },
+{ "Cyrillic_SHHA", 0x10004BA },
+{ "Cyrillic_shha", 0x10004BB },
+{ "Cyrillic_SCHWA", 0x10004D8 },
+{ "Cyrillic_schwa", 0x10004D9 },
+{ "Cyrillic_I_macron", 0x10004E2 },
+{ "Cyrillic_i_macron", 0x10004E3 },
+{ "Cyrillic_O_bar", 0x10004E8 },
+{ "Cyrillic_o_bar", 0x10004E9 },
+{ "Cyrillic_U_macron", 0x10004EE },
+{ "Cyrillic_u_macron", 0x10004EF },
+{ "Serbian_dje", 0x6A1 },
+{ "Macedonia_gje", 0x6A2 },
+{ "Cyrillic_io", 0x6A3 },
+{ "Ukrainian_ie", 0x6A4 },
+#ifndef TK_NO_DEPRECATED
+{ "Ukranian_je", 0x6A4 },
+#endif
+{ "Macedonia_dse", 0x6A5 },
+{ "Ukrainian_i", 0x6A6 },
+#ifndef TK_NO_DEPRECATED
+{ "Ukranian_i", 0x6A6 },
+#endif
+{ "Ukrainian_yi", 0x6A7 },
+#ifndef TK_NO_DEPRECATED
+{ "Ukranian_yi", 0x6A7 },
+#endif
+{ "Cyrillic_je", 0x6A8 },
+#ifndef TK_NO_DEPRECATED
+{ "Serbian_je", 0x6A8 },
+#endif
+{ "Cyrillic_lje", 0x6A9 },
+#ifndef TK_NO_DEPRECATED
+{ "Serbian_lje", 0x6A9 },
+#endif
+{ "Cyrillic_nje", 0x6AA },
+#ifndef TK_NO_DEPRECATED
+{ "Serbian_nje", 0x6AA },
+#endif
+{ "Serbian_tshe", 0x6AB },
+{ "Macedonia_kje", 0x6AC },
+{ "Ukrainian_ghe_with_upturn", 0x6AD },
+{ "Byelorussian_shortu", 0x6AE },
+{ "Cyrillic_dzhe", 0x6AF },
+#ifndef TK_NO_DEPRECATED
+{ "Serbian_dze", 0x6AF },
+#endif
+{ "numerosign", 0x6B0 },
+{ "Serbian_DJE", 0x6B1 },
+{ "Macedonia_GJE", 0x6B2 },
+{ "Cyrillic_IO", 0x6B3 },
+{ "Ukrainian_IE", 0x6B4 },
+#ifndef TK_NO_DEPRECATED
+{ "Ukranian_JE", 0x6B4 },
+#endif
+{ "Macedonia_DSE", 0x6B5 },
+{ "Ukrainian_I", 0x6B6 },
+#ifndef TK_NO_DEPRECATED
+{ "Ukranian_I", 0x6B6 },
+#endif
+{ "Ukrainian_YI", 0x6B7 },
+#ifndef TK_NO_DEPRECATED
+{ "Ukranian_YI", 0x6B7 },
+#endif
+{ "Cyrillic_JE", 0x6B8 },
+#ifndef TK_NO_DEPRECATED
+{ "Serbian_JE", 0x6B8 },
+#endif
+{ "Cyrillic_LJE", 0x6B9 },
+#ifndef TK_NO_DEPRECATED
+{ "Serbian_LJE", 0x6B9 },
+#endif
+{ "Cyrillic_NJE", 0x6BA },
+#ifndef TK_NO_DEPRECATED
+{ "Serbian_NJE", 0x6BA },
+#endif
+{ "Serbian_TSHE", 0x6BB },
+{ "Macedonia_KJE", 0x6BC },
+{ "Ukrainian_GHE_WITH_UPTURN", 0x6BD },
+{ "Byelorussian_SHORTU", 0x6BE },
+{ "Cyrillic_DZHE", 0x6BF },
+#ifndef TK_NO_DEPRECATED
+{ "Serbian_DZE", 0x6BF },
+#endif
+{ "Cyrillic_yu", 0x6C0 },
+{ "Cyrillic_a", 0x6C1 },
+{ "Cyrillic_be", 0x6C2 },
+{ "Cyrillic_tse", 0x6C3 },
+{ "Cyrillic_de", 0x6C4 },
+{ "Cyrillic_ie", 0x6C5 },
+{ "Cyrillic_ef", 0x6C6 },
+{ "Cyrillic_ghe", 0x6C7 },
+{ "Cyrillic_ha", 0x6C8 },
+{ "Cyrillic_i", 0x6C9 },
+{ "Cyrillic_shorti", 0x6CA },
+{ "Cyrillic_ka", 0x6CB },
+{ "Cyrillic_el", 0x6CC },
+{ "Cyrillic_em", 0x6CD },
+{ "Cyrillic_en", 0x6CE },
+{ "Cyrillic_o", 0x6CF },
+{ "Cyrillic_pe", 0x6D0 },
+{ "Cyrillic_ya", 0x6D1 },
+{ "Cyrillic_er", 0x6D2 },
+{ "Cyrillic_es", 0x6D3 },
+{ "Cyrillic_te", 0x6D4 },
+{ "Cyrillic_u", 0x6D5 },
+{ "Cyrillic_zhe", 0x6D6 },
+{ "Cyrillic_ve", 0x6D7 },
+{ "Cyrillic_softsign", 0x6D8 },
+{ "Cyrillic_yeru", 0x6D9 },
+{ "Cyrillic_ze", 0x6DA },
+{ "Cyrillic_sha", 0x6DB },
+{ "Cyrillic_e", 0x6DC },
+{ "Cyrillic_shcha", 0x6DD },
+{ "Cyrillic_che", 0x6DE },
+{ "Cyrillic_hardsign", 0x6DF },
+{ "Cyrillic_YU", 0x6E0 },
+{ "Cyrillic_A", 0x6E1 },
+{ "Cyrillic_BE", 0x6E2 },
+{ "Cyrillic_TSE", 0x6E3 },
+{ "Cyrillic_DE", 0x6E4 },
+{ "Cyrillic_IE", 0x6E5 },
+{ "Cyrillic_EF", 0x6E6 },
+{ "Cyrillic_GHE", 0x6E7 },
+{ "Cyrillic_HA", 0x6E8 },
+{ "Cyrillic_I", 0x6E9 },
+{ "Cyrillic_SHORTI", 0x6EA },
+{ "Cyrillic_KA", 0x6EB },
+{ "Cyrillic_EL", 0x6EC },
+{ "Cyrillic_EM", 0x6ED },
+{ "Cyrillic_EN", 0x6EE },
+{ "Cyrillic_O", 0x6EF },
+{ "Cyrillic_PE", 0x6F0 },
+{ "Cyrillic_YA", 0x6F1 },
+{ "Cyrillic_ER", 0x6F2 },
+{ "Cyrillic_ES", 0x6F3 },
+{ "Cyrillic_TE", 0x6F4 },
+{ "Cyrillic_U", 0x6F5 },
+{ "Cyrillic_ZHE", 0x6F6 },
+{ "Cyrillic_VE", 0x6F7 },
+{ "Cyrillic_SOFTSIGN", 0x6F8 },
+{ "Cyrillic_YERU", 0x6F9 },
+{ "Cyrillic_ZE", 0x6FA },
+{ "Cyrillic_SHA", 0x6FB },
+{ "Cyrillic_E", 0x6FC },
+{ "Cyrillic_SHCHA", 0x6FD },
+{ "Cyrillic_CHE", 0x6FE },
+{ "Cyrillic_HARDSIGN", 0x6FF },
+{ "Greek_ALPHAaccent", 0x7A1 },
+{ "Greek_EPSILONaccent", 0x7A2 },
+{ "Greek_ETAaccent", 0x7A3 },
+{ "Greek_IOTAaccent", 0x7A4 },
+{ "Greek_IOTAdieresis", 0x7A5 },
+{ "Greek_IOTAdiaeresis", 0x7A5 },
+{ "Greek_IOTAaccentdiaeresis", 0x7A6 },
+{ "Greek_OMICRONaccent", 0x7A7 },
+{ "Greek_UPSILONaccent", 0x7A8 },
+{ "Greek_UPSILONdieresis", 0x7A9 },
+{ "Greek_UPSILONaccentdieresis", 0x7AA },
+{ "Greek_OMEGAaccent", 0x7AB },
+{ "Greek_accentdieresis", 0x7AE },
+{ "Greek_horizbar", 0x7AF },
+{ "Greek_alphaaccent", 0x7B1 },
+{ "Greek_epsilonaccent", 0x7B2 },
+{ "Greek_etaaccent", 0x7B3 },
+{ "Greek_iotaaccent", 0x7B4 },
+{ "Greek_iotadieresis", 0x7B5 },
+{ "Greek_iotaaccentdieresis", 0x7B6 },
+{ "Greek_omicronaccent", 0x7B7 },
+{ "Greek_upsilonaccent", 0x7B8 },
+{ "Greek_upsilondieresis", 0x7B9 },
+{ "Greek_upsilonaccentdieresis", 0x7BA },
+{ "Greek_omegaaccent", 0x7BB },
+{ "Greek_ALPHA", 0x7C1 },
+{ "Greek_BETA", 0x7C2 },
+{ "Greek_GAMMA", 0x7C3 },
+{ "Greek_DELTA", 0x7C4 },
+{ "Greek_EPSILON", 0x7C5 },
+{ "Greek_ZETA", 0x7C6 },
+{ "Greek_ETA", 0x7C7 },
+{ "Greek_THETA", 0x7C8 },
+{ "Greek_IOTA", 0x7C9 },
+{ "Greek_KAPPA", 0x7CA },
+{ "Greek_LAMDA", 0x7CB },
+{ "Greek_LAMBDA", 0x7CB },
+{ "Greek_MU", 0x7CC },
+{ "Greek_NU", 0x7CD },
+{ "Greek_XI", 0x7CE },
+{ "Greek_OMICRON", 0x7CF },
+{ "Greek_PI", 0x7D0 },
+{ "Greek_RHO", 0x7D1 },
+{ "Greek_SIGMA", 0x7D2 },
+{ "Greek_TAU", 0x7D4 },
+{ "Greek_UPSILON", 0x7D5 },
+{ "Greek_PHI", 0x7D6 },
+{ "Greek_CHI", 0x7D7 },
+{ "Greek_PSI", 0x7D8 },
+{ "Greek_OMEGA", 0x7D9 },
+{ "Greek_alpha", 0x7E1 },
+{ "Greek_beta", 0x7E2 },
+{ "Greek_gamma", 0x7E3 },
+{ "Greek_delta", 0x7E4 },
+{ "Greek_epsilon", 0x7E5 },
+{ "Greek_zeta", 0x7E6 },
+{ "Greek_eta", 0x7E7 },
+{ "Greek_theta", 0x7E8 },
+{ "Greek_iota", 0x7E9 },
+{ "Greek_kappa", 0x7EA },
+{ "Greek_lamda", 0x7EB },
+{ "Greek_lambda", 0x7EB },
+{ "Greek_mu", 0x7EC },
+{ "Greek_nu", 0x7ED },
+{ "Greek_xi", 0x7EE },
+{ "Greek_omicron", 0x7EF },
+{ "Greek_pi", 0x7F0 },
+{ "Greek_rho", 0x7F1 },
+{ "Greek_sigma", 0x7F2 },
+{ "Greek_finalsmallsigma", 0x7F3 },
+{ "Greek_tau", 0x7F4 },
+{ "Greek_upsilon", 0x7F5 },
+{ "Greek_phi", 0x7F6 },
+{ "Greek_chi", 0x7F7 },
+{ "Greek_psi", 0x7F8 },
+{ "Greek_omega", 0x7F9 },
{ "Greek_switch", 0xFF7E },
-{ "leftradical", 0x8a1 },
-{ "topleftradical", 0x8a2 },
-{ "horizconnector", 0x8a3 },
-{ "topintegral", 0x8a4 },
-{ "botintegral", 0x8a5 },
-{ "vertconnector", 0x8a6 },
-{ "topleftsqbracket", 0x8a7 },
-{ "botleftsqbracket", 0x8a8 },
-{ "toprightsqbracket", 0x8a9 },
-{ "botrightsqbracket", 0x8aa },
-{ "topleftparens", 0x8ab },
-{ "botleftparens", 0x8ac },
-{ "toprightparens", 0x8ad },
-{ "botrightparens", 0x8ae },
-{ "leftmiddlecurlybrace", 0x8af },
-{ "rightmiddlecurlybrace", 0x8b0 },
-{ "topleftsummation", 0x8b1 },
-{ "botleftsummation", 0x8b2 },
-{ "topvertsummationconnector", 0x8b3 },
-{ "botvertsummationconnector", 0x8b4 },
-{ "toprightsummation", 0x8b5 },
-{ "botrightsummation", 0x8b6 },
-{ "rightmiddlesummation", 0x8b7 },
-{ "lessthanequal", 0x8bc },
-{ "notequal", 0x8bd },
-{ "greaterthanequal", 0x8be },
-{ "integral", 0x8bf },
-{ "therefore", 0x8c0 },
-{ "variation", 0x8c1 },
-{ "infinity", 0x8c2 },
-{ "nabla", 0x8c5 },
-{ "approximate", 0x8c8 },
-{ "similarequal", 0x8c9 },
-{ "ifonlyif", 0x8cd },
-{ "implies", 0x8ce },
-{ "identical", 0x8cf },
-{ "radical", 0x8d6 },
-{ "includedin", 0x8da },
-{ "includes", 0x8db },
-{ "intersection", 0x8dc },
-{ "union", 0x8dd },
-{ "logicaland", 0x8de },
-{ "logicalor", 0x8df },
-{ "partialderivative", 0x8ef },
-{ "function", 0x8f6 },
-{ "leftarrow", 0x8fb },
-{ "uparrow", 0x8fc },
-{ "rightarrow", 0x8fd },
-{ "downarrow", 0x8fe },
-{ "blank", 0x9df },
-{ "soliddiamond", 0x9e0 },
-{ "checkerboard", 0x9e1 },
-{ "ht", 0x9e2 },
-{ "ff", 0x9e3 },
-{ "cr", 0x9e4 },
-{ "lf", 0x9e5 },
-{ "nl", 0x9e8 },
-{ "vt", 0x9e9 },
-{ "lowrightcorner", 0x9ea },
-{ "uprightcorner", 0x9eb },
-{ "upleftcorner", 0x9ec },
-{ "lowleftcorner", 0x9ed },
-{ "crossinglines", 0x9ee },
-{ "horizlinescan1", 0x9ef },
-{ "horizlinescan3", 0x9f0 },
-{ "horizlinescan5", 0x9f1 },
-{ "horizlinescan7", 0x9f2 },
-{ "horizlinescan9", 0x9f3 },
-{ "leftt", 0x9f4 },
-{ "rightt", 0x9f5 },
-{ "bott", 0x9f6 },
-{ "topt", 0x9f7 },
-{ "vertbar", 0x9f8 },
-{ "emspace", 0xaa1 },
-{ "enspace", 0xaa2 },
-{ "em3space", 0xaa3 },
-{ "em4space", 0xaa4 },
-{ "digitspace", 0xaa5 },
-{ "punctspace", 0xaa6 },
-{ "thinspace", 0xaa7 },
-{ "hairspace", 0xaa8 },
-{ "emdash", 0xaa9 },
-{ "endash", 0xaaa },
-{ "signifblank", 0xaac },
-{ "ellipsis", 0xaae },
-{ "doubbaselinedot", 0xaaf },
-{ "onethird", 0xab0 },
-{ "twothirds", 0xab1 },
-{ "onefifth", 0xab2 },
-{ "twofifths", 0xab3 },
-{ "threefifths", 0xab4 },
-{ "fourfifths", 0xab5 },
-{ "onesixth", 0xab6 },
-{ "fivesixths", 0xab7 },
-{ "careof", 0xab8 },
-{ "figdash", 0xabb },
-{ "leftanglebracket", 0xabc },
-{ "decimalpoint", 0xabd },
-{ "rightanglebracket", 0xabe },
-{ "marker", 0xabf },
-{ "oneeighth", 0xac3 },
-{ "threeeighths", 0xac4 },
-{ "fiveeighths", 0xac5 },
-{ "seveneighths", 0xac6 },
-{ "trademark", 0xac9 },
-{ "signaturemark", 0xaca },
-{ "trademarkincircle", 0xacb },
-{ "leftopentriangle", 0xacc },
-{ "rightopentriangle", 0xacd },
-{ "emopencircle", 0xace },
-{ "emopenrectangle", 0xacf },
-{ "leftsinglequotemark", 0xad0 },
-{ "rightsinglequotemark", 0xad1 },
-{ "leftdoublequotemark", 0xad2 },
-{ "rightdoublequotemark", 0xad3 },
-{ "prescription", 0xad4 },
-{ "minutes", 0xad6 },
-{ "seconds", 0xad7 },
-{ "latincross", 0xad9 },
-{ "hexagram", 0xada },
-{ "filledrectbullet", 0xadb },
-{ "filledlefttribullet", 0xadc },
-{ "filledrighttribullet", 0xadd },
-{ "emfilledcircle", 0xade },
-{ "emfilledrect", 0xadf },
-{ "enopencircbullet", 0xae0 },
-{ "enopensquarebullet", 0xae1 },
-{ "openrectbullet", 0xae2 },
-{ "opentribulletup", 0xae3 },
-{ "opentribulletdown", 0xae4 },
-{ "openstar", 0xae5 },
-{ "enfilledcircbullet", 0xae6 },
-{ "enfilledsqbullet", 0xae7 },
-{ "filledtribulletup", 0xae8 },
-{ "filledtribulletdown", 0xae9 },
-{ "leftpointer", 0xaea },
-{ "rightpointer", 0xaeb },
-{ "club", 0xaec },
-{ "diamond", 0xaed },
-{ "heart", 0xaee },
-{ "maltesecross", 0xaf0 },
-{ "dagger", 0xaf1 },
-{ "doubledagger", 0xaf2 },
-{ "checkmark", 0xaf3 },
-{ "ballotcross", 0xaf4 },
-{ "musicalsharp", 0xaf5 },
-{ "musicalflat", 0xaf6 },
-{ "malesymbol", 0xaf7 },
-{ "femalesymbol", 0xaf8 },
-{ "telephone", 0xaf9 },
-{ "telephonerecorder", 0xafa },
-{ "phonographcopyright", 0xafb },
-{ "caret", 0xafc },
-{ "singlelowquotemark", 0xafd },
-{ "doublelowquotemark", 0xafe },
-{ "cursor", 0xaff },
-{ "leftcaret", 0xba3 },
-{ "rightcaret", 0xba6 },
-{ "downcaret", 0xba8 },
-{ "upcaret", 0xba9 },
-{ "overbar", 0xbc0 },
-{ "downtack", 0xbc2 },
-{ "upshoe", 0xbc3 },
-{ "downstile", 0xbc4 },
-{ "underbar", 0xbc6 },
-{ "jot", 0xbca },
-{ "quad", 0xbcc },
-{ "uptack", 0xbce },
-{ "circle", 0xbcf },
-{ "upstile", 0xbd3 },
-{ "downshoe", 0xbd6 },
-{ "rightshoe", 0xbd8 },
-{ "leftshoe", 0xbda },
-{ "lefttack", 0xbdc },
-{ "righttack", 0xbfc },
-{ "hebrew_aleph", 0xce0 },
-{ "hebrew_beth", 0xce1 },
-{ "hebrew_gimmel", 0xce2 },
-{ "hebrew_daleth", 0xce3 },
-{ "hebrew_he", 0xce4 },
-{ "hebrew_waw", 0xce5 },
-{ "hebrew_zayin", 0xce6 },
-{ "hebrew_het", 0xce7 },
-{ "hebrew_teth", 0xce8 },
-{ "hebrew_yod", 0xce9 },
-{ "hebrew_finalkaph", 0xcea },
-{ "hebrew_kaph", 0xceb },
-{ "hebrew_lamed", 0xcec },
-{ "hebrew_finalmem", 0xced },
-{ "hebrew_mem", 0xcee },
-{ "hebrew_finalnun", 0xcef },
-{ "hebrew_nun", 0xcf0 },
-{ "hebrew_samekh", 0xcf1 },
-{ "hebrew_ayin", 0xcf2 },
-{ "hebrew_finalpe", 0xcf3 },
-{ "hebrew_pe", 0xcf4 },
-{ "hebrew_finalzadi", 0xcf5 },
-{ "hebrew_zadi", 0xcf6 },
-{ "hebrew_kuf", 0xcf7 },
-{ "hebrew_resh", 0xcf8 },
-{ "hebrew_shin", 0xcf9 },
-{ "hebrew_taf", 0xcfa },
+{ "leftradical", 0x8A1 },
+{ "topleftradical", 0x8A2 },
+{ "horizconnector", 0x8A3 },
+{ "topintegral", 0x8A4 },
+{ "botintegral", 0x8A5 },
+{ "vertconnector", 0x8A6 },
+{ "topleftsqbracket", 0x8A7 },
+{ "botleftsqbracket", 0x8A8 },
+{ "toprightsqbracket", 0x8A9 },
+{ "botrightsqbracket", 0x8AA },
+{ "topleftparens", 0x8AB },
+{ "botleftparens", 0x8AC },
+{ "toprightparens", 0x8AD },
+{ "botrightparens", 0x8AE },
+{ "leftmiddlecurlybrace", 0x8AF },
+{ "rightmiddlecurlybrace", 0x8B0 },
+{ "topleftsummation", 0x8B1 },
+{ "botleftsummation", 0x8B2 },
+{ "topvertsummationconnector", 0x8B3 },
+{ "botvertsummationconnector", 0x8B4 },
+{ "toprightsummation", 0x8B5 },
+{ "botrightsummation", 0x8B6 },
+{ "rightmiddlesummation", 0x8B7 },
+{ "lessthanequal", 0x8BC },
+{ "notequal", 0x8BD },
+{ "greaterthanequal", 0x8BE },
+{ "integral", 0x8BF },
+{ "therefore", 0x8C0 },
+{ "variation", 0x8C1 },
+{ "infinity", 0x8C2 },
+{ "nabla", 0x8C5 },
+{ "approximate", 0x8C8 },
+{ "similarequal", 0x8C9 },
+{ "ifonlyif", 0x8CD },
+{ "implies", 0x8CE },
+{ "identical", 0x8CF },
+{ "radical", 0x8D6 },
+{ "includedin", 0x8DA },
+{ "includes", 0x8DB },
+{ "intersection", 0x8DC },
+{ "union", 0x8DD },
+{ "logicaland", 0x8DE },
+{ "logicalor", 0x8DF },
+{ "partialderivative", 0x8EF },
+{ "function", 0x8F6 },
+{ "leftarrow", 0x8FB },
+{ "uparrow", 0x8FC },
+{ "rightarrow", 0x8FD },
+{ "downarrow", 0x8FE },
+{ "blank", 0x9DF },
+{ "soliddiamond", 0x9E0 },
+{ "checkerboard", 0x9E1 },
+{ "ht", 0x9E2 },
+{ "ff", 0x9E3 },
+{ "cr", 0x9E4 },
+{ "lf", 0x9E5 },
+{ "nl", 0x9E8 },
+{ "vt", 0x9E9 },
+{ "lowrightcorner", 0x9EA },
+{ "uprightcorner", 0x9EB },
+{ "upleftcorner", 0x9EC },
+{ "lowleftcorner", 0x9ED },
+{ "crossinglines", 0x9EE },
+{ "horizlinescan1", 0x9EF },
+{ "horizlinescan3", 0x9F0 },
+{ "horizlinescan5", 0x9F1 },
+{ "horizlinescan7", 0x9F2 },
+{ "horizlinescan9", 0x9F3 },
+{ "leftt", 0x9F4 },
+{ "rightt", 0x9F5 },
+{ "bott", 0x9F6 },
+{ "topt", 0x9F7 },
+{ "vertbar", 0x9F8 },
+{ "emspace", 0xAA1 },
+{ "enspace", 0xAA2 },
+{ "em3space", 0xAA3 },
+{ "em4space", 0xAA4 },
+{ "digitspace", 0xAA5 },
+{ "punctspace", 0xAA6 },
+{ "thinspace", 0xAA7 },
+{ "hairspace", 0xAA8 },
+{ "emdash", 0xAA9 },
+{ "endash", 0xAAA },
+{ "signifblank", 0xAAC },
+{ "ellipsis", 0xAAE },
+{ "doubbaselinedot", 0xAAF },
+{ "onethird", 0xAB0 },
+{ "twothirds", 0xAB1 },
+{ "onefifth", 0xAB2 },
+{ "twofifths", 0xAB3 },
+{ "threefifths", 0xAB4 },
+{ "fourfifths", 0xAB5 },
+{ "onesixth", 0xAB6 },
+{ "fivesixths", 0xAB7 },
+{ "careof", 0xAB8 },
+{ "figdash", 0xABB },
+{ "leftanglebracket", 0xABC },
+{ "decimalpoint", 0xABD },
+{ "rightanglebracket", 0xABE },
+{ "marker", 0xABF },
+{ "oneeighth", 0xAC3 },
+{ "threeeighths", 0xAC4 },
+{ "fiveeighths", 0xAC5 },
+{ "seveneighths", 0xAC6 },
+{ "trademark", 0xAC9 },
+{ "signaturemark", 0xACA },
+{ "trademarkincircle", 0xACB },
+{ "leftopentriangle", 0xACC },
+{ "rightopentriangle", 0xACD },
+{ "emopencircle", 0xACE },
+{ "emopenrectangle", 0xACF },
+{ "leftsinglequotemark", 0xAD0 },
+{ "rightsinglequotemark", 0xAD1 },
+{ "leftdoublequotemark", 0xAD2 },
+{ "rightdoublequotemark", 0xAD3 },
+{ "prescription", 0xAD4 },
+{ "permille", 0xAD5 },
+{ "minutes", 0xAD6 },
+{ "seconds", 0xAD7 },
+{ "latincross", 0xAD9 },
+{ "hexagram", 0xADA },
+{ "filledrectbullet", 0xADB },
+{ "filledlefttribullet", 0xADC },
+{ "filledrighttribullet", 0xADD },
+{ "emfilledcircle", 0xADE },
+{ "emfilledrect", 0xADF },
+{ "enopencircbullet", 0xAE0 },
+{ "enopensquarebullet", 0xAE1 },
+{ "openrectbullet", 0xAE2 },
+{ "opentribulletup", 0xAE3 },
+{ "opentribulletdown", 0xAE4 },
+{ "openstar", 0xAE5 },
+{ "enfilledcircbullet", 0xAE6 },
+{ "enfilledsqbullet", 0xAE7 },
+{ "filledtribulletup", 0xAE8 },
+{ "filledtribulletdown", 0xAE9 },
+{ "leftpointer", 0xAEA },
+{ "rightpointer", 0xAEB },
+{ "club", 0xAEC },
+{ "diamond", 0xAED },
+{ "heart", 0xAEE },
+{ "maltesecross", 0xAF0 },
+{ "dagger", 0xAF1 },
+{ "doubledagger", 0xAF2 },
+{ "checkmark", 0xAF3 },
+{ "ballotcross", 0xAF4 },
+{ "musicalsharp", 0xAF5 },
+{ "musicalflat", 0xAF6 },
+{ "malesymbol", 0xAF7 },
+{ "femalesymbol", 0xAF8 },
+{ "telephone", 0xAF9 },
+{ "telephonerecorder", 0xAFA },
+{ "phonographcopyright", 0xAFB },
+{ "caret", 0xAFC },
+{ "singlelowquotemark", 0xAFD },
+{ "doublelowquotemark", 0xAFE },
+{ "cursor", 0xAFF },
+{ "leftcaret", 0xBA3 },
+{ "rightcaret", 0xBA6 },
+{ "downcaret", 0xBA8 },
+{ "upcaret", 0xBA9 },
+{ "overbar", 0xBC0 },
+{ "downtack", 0xBC2 },
+{ "upshoe", 0xBC3 },
+{ "downstile", 0xBC4 },
+{ "underbar", 0xBC6 },
+{ "jot", 0xBCA },
+{ "quad", 0xBCC },
+{ "uptack", 0xBCE },
+{ "circle", 0xBCF },
+{ "upstile", 0xBD3 },
+{ "downshoe", 0xBD6 },
+{ "rightshoe", 0xBD8 },
+{ "leftshoe", 0xBDA },
+{ "lefttack", 0xBDC },
+{ "righttack", 0xBFC },
+{ "hebrew_doublelowline", 0xCDF },
+{ "hebrew_aleph", 0xCE0 },
+{ "hebrew_bet", 0xCE1 },
+#ifndef TK_NO_DEPRECATED
+{ "hebrew_beth", 0xCE1 },
+#endif
+{ "hebrew_gimel", 0xCE2 },
+#ifndef TK_NO_DEPRECATED
+{ "hebrew_gimmel", 0xCE2 },
+#endif
+{ "hebrew_dalet", 0xCE3 },
+#ifndef TK_NO_DEPRECATED
+{ "hebrew_daleth", 0xCE3 },
+#endif
+{ "hebrew_he", 0xCE4 },
+{ "hebrew_waw", 0xCE5 },
+{ "hebrew_zain", 0xCE6 },
+#ifndef TK_NO_DEPRECATED
+{ "hebrew_zayin", 0xCE6 },
+#endif
+{ "hebrew_chet", 0xCE7 },
+#ifndef TK_NO_DEPRECATED
+{ "hebrew_het", 0xCE7 },
+#endif
+{ "hebrew_tet", 0xCE8 },
+#ifndef TK_NO_DEPRECATED
+{ "hebrew_teth", 0xCE8 },
+#endif
+{ "hebrew_yod", 0xCE9 },
+{ "hebrew_finalkaph", 0xCEA },
+{ "hebrew_kaph", 0xCEB },
+{ "hebrew_lamed", 0xCEC },
+{ "hebrew_finalmem", 0xCED },
+{ "hebrew_mem", 0xCEE },
+{ "hebrew_finalnun", 0xCEF },
+{ "hebrew_nun", 0xCF0 },
+{ "hebrew_samech", 0xCF1 },
+#ifndef TK_NO_DEPRECATED
+{ "hebrew_samekh", 0xCF1 },
+#endif
+{ "hebrew_ayin", 0xCF2 },
+{ "hebrew_finalpe", 0xCF3 },
+{ "hebrew_pe", 0xCF4 },
+{ "hebrew_finalzade", 0xCF5 },
+#ifndef TK_NO_DEPRECATED
+{ "hebrew_finalzadi", 0xCF5 },
+#endif
+{ "hebrew_zade", 0xCF6 },
+#ifndef TK_NO_DEPRECATED
+{ "hebrew_zadi", 0xCF6 },
+#endif
+{ "hebrew_qoph", 0xCF7 },
+#ifndef TK_NO_DEPRECATED
+{ "hebrew_kuf", 0xCF7 },
+#endif
+{ "hebrew_resh", 0xCF8 },
+{ "hebrew_shin", 0xCF9 },
+{ "hebrew_taw", 0xCFA },
+#ifndef TK_NO_DEPRECATED
+{ "hebrew_taf", 0xCFA },
+#endif
{ "Hebrew_switch", 0xFF7E },
+{ "Thai_kokai", 0xDA1 },
+{ "Thai_khokhai", 0xDA2 },
+{ "Thai_khokhuat", 0xDA3 },
+{ "Thai_khokhwai", 0xDA4 },
+{ "Thai_khokhon", 0xDA5 },
+{ "Thai_khorakhang", 0xDA6 },
+{ "Thai_ngongu", 0xDA7 },
+{ "Thai_chochan", 0xDA8 },
+{ "Thai_choching", 0xDA9 },
+{ "Thai_chochang", 0xDAA },
+{ "Thai_soso", 0xDAB },
+{ "Thai_chochoe", 0xDAC },
+{ "Thai_yoying", 0xDAD },
+{ "Thai_dochada", 0xDAE },
+{ "Thai_topatak", 0xDAF },
+{ "Thai_thothan", 0xDB0 },
+{ "Thai_thonangmontho", 0xDB1 },
+{ "Thai_thophuthao", 0xDB2 },
+{ "Thai_nonen", 0xDB3 },
+{ "Thai_dodek", 0xDB4 },
+{ "Thai_totao", 0xDB5 },
+{ "Thai_thothung", 0xDB6 },
+{ "Thai_thothahan", 0xDB7 },
+{ "Thai_thothong", 0xDB8 },
+{ "Thai_nonu", 0xDB9 },
+{ "Thai_bobaimai", 0xDBA },
+{ "Thai_popla", 0xDBB },
+{ "Thai_phophung", 0xDBC },
+{ "Thai_fofa", 0xDBD },
+{ "Thai_phophan", 0xDBE },
+{ "Thai_fofan", 0xDBF },
+{ "Thai_phosamphao", 0xDC0 },
+{ "Thai_moma", 0xDC1 },
+{ "Thai_yoyak", 0xDC2 },
+{ "Thai_rorua", 0xDC3 },
+{ "Thai_ru", 0xDC4 },
+{ "Thai_loling", 0xDC5 },
+{ "Thai_lu", 0xDC6 },
+{ "Thai_wowaen", 0xDC7 },
+{ "Thai_sosala", 0xDC8 },
+{ "Thai_sorusi", 0xDC9 },
+{ "Thai_sosua", 0xDCA },
+{ "Thai_hohip", 0xDCB },
+{ "Thai_lochula", 0xDCC },
+{ "Thai_oang", 0xDCD },
+{ "Thai_honokhuk", 0xDCE },
+{ "Thai_paiyannoi", 0xDCF },
+{ "Thai_saraa", 0xDD0 },
+{ "Thai_maihanakat", 0xDD1 },
+{ "Thai_saraaa", 0xDD2 },
+{ "Thai_saraam", 0xDD3 },
+{ "Thai_sarai", 0xDD4 },
+{ "Thai_saraii", 0xDD5 },
+{ "Thai_saraue", 0xDD6 },
+{ "Thai_sarauee", 0xDD7 },
+{ "Thai_sarau", 0xDD8 },
+{ "Thai_sarauu", 0xDD9 },
+{ "Thai_phinthu", 0xDDA },
+{ "Thai_maihanakat_maitho", 0xDDE },
+{ "Thai_baht", 0xDDF },
+{ "Thai_sarae", 0xDE0 },
+{ "Thai_saraae", 0xDE1 },
+{ "Thai_sarao", 0xDE2 },
+{ "Thai_saraaimaimuan", 0xDE3 },
+{ "Thai_saraaimaimalai", 0xDE4 },
+{ "Thai_lakkhangyao", 0xDE5 },
+{ "Thai_maiyamok", 0xDE6 },
+{ "Thai_maitaikhu", 0xDE7 },
+{ "Thai_maiek", 0xDE8 },
+{ "Thai_maitho", 0xDE9 },
+{ "Thai_maitri", 0xDEA },
+{ "Thai_maichattawa", 0xDEB },
+{ "Thai_thanthakhat", 0xDEC },
+{ "Thai_nikhahit", 0xDED },
+{ "Thai_leksun", 0xDF0 },
+{ "Thai_leknung", 0xDF1 },
+{ "Thai_leksong", 0xDF2 },
+{ "Thai_leksam", 0xDF3 },
+{ "Thai_leksi", 0xDF4 },
+{ "Thai_lekha", 0xDF5 },
+{ "Thai_lekhok", 0xDF6 },
+{ "Thai_lekchet", 0xDF7 },
+{ "Thai_lekpaet", 0xDF8 },
+{ "Thai_lekkao", 0xDF9 },
+{ "Hangul", 0xFF31 },
+{ "Hangul_Start", 0xFF32 },
+{ "Hangul_End", 0xFF33 },
+{ "Hangul_Hanja", 0xFF34 },
+{ "Hangul_Jamo", 0xFF35 },
+{ "Hangul_Romaja", 0xFF36 },
+{ "Hangul_Codeinput", 0xFF37 },
+{ "Hangul_Jeonja", 0xFF38 },
+{ "Hangul_Banja", 0xFF39 },
+{ "Hangul_PreHanja", 0xFF3A },
+{ "Hangul_PostHanja", 0xFF3B },
+{ "Hangul_SingleCandidate", 0xFF3C },
+{ "Hangul_MultipleCandidate", 0xFF3D },
+{ "Hangul_PreviousCandidate", 0xFF3E },
+{ "Hangul_Special", 0xFF3F },
+{ "Hangul_switch", 0xFF7E },
+{ "Hangul_Kiyeog", 0xEA1 },
+{ "Hangul_SsangKiyeog", 0xEA2 },
+{ "Hangul_KiyeogSios", 0xEA3 },
+{ "Hangul_Nieun", 0xEA4 },
+{ "Hangul_NieunJieuj", 0xEA5 },
+{ "Hangul_NieunHieuh", 0xEA6 },
+{ "Hangul_Dikeud", 0xEA7 },
+{ "Hangul_SsangDikeud", 0xEA8 },
+{ "Hangul_Rieul", 0xEA9 },
+{ "Hangul_RieulKiyeog", 0xEAA },
+{ "Hangul_RieulMieum", 0xEAB },
+{ "Hangul_RieulPieub", 0xEAC },
+{ "Hangul_RieulSios", 0xEAD },
+{ "Hangul_RieulTieut", 0xEAE },
+{ "Hangul_RieulPhieuf", 0xEAF },
+{ "Hangul_RieulHieuh", 0xEB0 },
+{ "Hangul_Mieum", 0xEB1 },
+{ "Hangul_Pieub", 0xEB2 },
+{ "Hangul_SsangPieub", 0xEB3 },
+{ "Hangul_PieubSios", 0xEB4 },
+{ "Hangul_Sios", 0xEB5 },
+{ "Hangul_SsangSios", 0xEB6 },
+{ "Hangul_Ieung", 0xEB7 },
+{ "Hangul_Jieuj", 0xEB8 },
+{ "Hangul_SsangJieuj", 0xEB9 },
+{ "Hangul_Cieuc", 0xEBA },
+{ "Hangul_Khieuq", 0xEBB },
+{ "Hangul_Tieut", 0xEBC },
+{ "Hangul_Phieuf", 0xEBD },
+{ "Hangul_Hieuh", 0xEBE },
+{ "Hangul_A", 0xEBF },
+{ "Hangul_AE", 0xEC0 },
+{ "Hangul_YA", 0xEC1 },
+{ "Hangul_YAE", 0xEC2 },
+{ "Hangul_EO", 0xEC3 },
+{ "Hangul_E", 0xEC4 },
+{ "Hangul_YEO", 0xEC5 },
+{ "Hangul_YE", 0xEC6 },
+{ "Hangul_O", 0xEC7 },
+{ "Hangul_WA", 0xEC8 },
+{ "Hangul_WAE", 0xEC9 },
+{ "Hangul_OE", 0xECA },
+{ "Hangul_YO", 0xECB },
+{ "Hangul_U", 0xECC },
+{ "Hangul_WEO", 0xECD },
+{ "Hangul_WE", 0xECE },
+{ "Hangul_WI", 0xECF },
+{ "Hangul_YU", 0xED0 },
+{ "Hangul_EU", 0xED1 },
+{ "Hangul_YI", 0xED2 },
+{ "Hangul_I", 0xED3 },
+{ "Hangul_J_Kiyeog", 0xED4 },
+{ "Hangul_J_SsangKiyeog", 0xED5 },
+{ "Hangul_J_KiyeogSios", 0xED6 },
+{ "Hangul_J_Nieun", 0xED7 },
+{ "Hangul_J_NieunJieuj", 0xED8 },
+{ "Hangul_J_NieunHieuh", 0xED9 },
+{ "Hangul_J_Dikeud", 0xEDA },
+{ "Hangul_J_Rieul", 0xEDB },
+{ "Hangul_J_RieulKiyeog", 0xEDC },
+{ "Hangul_J_RieulMieum", 0xEDD },
+{ "Hangul_J_RieulPieub", 0xEDE },
+{ "Hangul_J_RieulSios", 0xEDF },
+{ "Hangul_J_RieulTieut", 0xEE0 },
+{ "Hangul_J_RieulPhieuf", 0xEE1 },
+{ "Hangul_J_RieulHieuh", 0xEE2 },
+{ "Hangul_J_Mieum", 0xEE3 },
+{ "Hangul_J_Pieub", 0xEE4 },
+{ "Hangul_J_PieubSios", 0xEE5 },
+{ "Hangul_J_Sios", 0xEE6 },
+{ "Hangul_J_SsangSios", 0xEE7 },
+{ "Hangul_J_Ieung", 0xEE8 },
+{ "Hangul_J_Jieuj", 0xEE9 },
+{ "Hangul_J_Cieuc", 0xEEA },
+{ "Hangul_J_Khieuq", 0xEEB },
+{ "Hangul_J_Tieut", 0xEEC },
+{ "Hangul_J_Phieuf", 0xEED },
+{ "Hangul_J_Hieuh", 0xEEE },
+{ "Hangul_RieulYeorinHieuh", 0xEEF },
+{ "Hangul_SunkyeongeumMieum", 0xEF0 },
+{ "Hangul_SunkyeongeumPieub", 0xEF1 },
+{ "Hangul_PanSios", 0xEF2 },
+{ "Hangul_KkogjiDalrinIeung", 0xEF3 },
+{ "Hangul_SunkyeongeumPhieuf", 0xEF4 },
+{ "Hangul_YeorinHieuh", 0xEF5 },
+{ "Hangul_AraeA", 0xEF6 },
+{ "Hangul_AraeAE", 0xEF7 },
+{ "Hangul_J_PanSios", 0xEF8 },
+{ "Hangul_J_KkogjiDalrinIeung", 0xEF9 },
+{ "Hangul_J_YeorinHieuh", 0xEFA },
+{ "Korean_Won", 0xEFF },
+{ "Armenian_ligature_ew", 0x1000587 },
+{ "Armenian_full_stop", 0x1000589 },
+{ "Armenian_verjaket", 0x1000589 },
+{ "Armenian_separation_mark", 0x100055D },
+{ "Armenian_but", 0x100055D },
+{ "Armenian_hyphen", 0x100058A },
+{ "Armenian_yentamna", 0x100058A },
+{ "Armenian_exclam", 0x100055C },
+{ "Armenian_amanak", 0x100055C },
+{ "Armenian_accent", 0x100055B },
+{ "Armenian_shesht", 0x100055B },
+{ "Armenian_question", 0x100055E },
+{ "Armenian_paruyk", 0x100055E },
+{ "Armenian_AYB", 0x1000531 },
+{ "Armenian_ayb", 0x1000561 },
+{ "Armenian_BEN", 0x1000532 },
+{ "Armenian_ben", 0x1000562 },
+{ "Armenian_GIM", 0x1000533 },
+{ "Armenian_gim", 0x1000563 },
+{ "Armenian_DA", 0x1000534 },
+{ "Armenian_da", 0x1000564 },
+{ "Armenian_YECH", 0x1000535 },
+{ "Armenian_yech", 0x1000565 },
+{ "Armenian_ZA", 0x1000536 },
+{ "Armenian_za", 0x1000566 },
+{ "Armenian_E", 0x1000537 },
+{ "Armenian_e", 0x1000567 },
+{ "Armenian_AT", 0x1000538 },
+{ "Armenian_at", 0x1000568 },
+{ "Armenian_TO", 0x1000539 },
+{ "Armenian_to", 0x1000569 },
+{ "Armenian_ZHE", 0x100053A },
+{ "Armenian_zhe", 0x100056A },
+{ "Armenian_INI", 0x100053B },
+{ "Armenian_ini", 0x100056B },
+{ "Armenian_LYUN", 0x100053C },
+{ "Armenian_lyun", 0x100056C },
+{ "Armenian_KHE", 0x100053D },
+{ "Armenian_khe", 0x100056D },
+{ "Armenian_TSA", 0x100053E },
+{ "Armenian_tsa", 0x100056E },
+{ "Armenian_KEN", 0x100053F },
+{ "Armenian_ken", 0x100056F },
+{ "Armenian_HO", 0x1000540 },
+{ "Armenian_ho", 0x1000570 },
+{ "Armenian_DZA", 0x1000541 },
+{ "Armenian_dza", 0x1000571 },
+{ "Armenian_GHAT", 0x1000542 },
+{ "Armenian_ghat", 0x1000572 },
+{ "Armenian_TCHE", 0x1000543 },
+{ "Armenian_tche", 0x1000573 },
+{ "Armenian_MEN", 0x1000544 },
+{ "Armenian_men", 0x1000574 },
+{ "Armenian_HI", 0x1000545 },
+{ "Armenian_hi", 0x1000575 },
+{ "Armenian_NU", 0x1000546 },
+{ "Armenian_nu", 0x1000576 },
+{ "Armenian_SHA", 0x1000547 },
+{ "Armenian_sha", 0x1000577 },
+{ "Armenian_VO", 0x1000548 },
+{ "Armenian_vo", 0x1000578 },
+{ "Armenian_CHA", 0x1000549 },
+{ "Armenian_cha", 0x1000579 },
+{ "Armenian_PE", 0x100054A },
+{ "Armenian_pe", 0x100057A },
+{ "Armenian_JE", 0x100054B },
+{ "Armenian_je", 0x100057B },
+{ "Armenian_RA", 0x100054C },
+{ "Armenian_ra", 0x100057C },
+{ "Armenian_SE", 0x100054D },
+{ "Armenian_se", 0x100057D },
+{ "Armenian_VEV", 0x100054E },
+{ "Armenian_vev", 0x100057E },
+{ "Armenian_TYUN", 0x100054F },
+{ "Armenian_tyun", 0x100057F },
+{ "Armenian_RE", 0x1000550 },
+{ "Armenian_re", 0x1000580 },
+{ "Armenian_TSO", 0x1000551 },
+{ "Armenian_tso", 0x1000581 },
+{ "Armenian_VYUN", 0x1000552 },
+{ "Armenian_vyun", 0x1000582 },
+{ "Armenian_PYUR", 0x1000553 },
+{ "Armenian_pyur", 0x1000583 },
+{ "Armenian_KE", 0x1000554 },
+{ "Armenian_ke", 0x1000584 },
+{ "Armenian_O", 0x1000555 },
+{ "Armenian_o", 0x1000585 },
+{ "Armenian_FE", 0x1000556 },
+{ "Armenian_fe", 0x1000586 },
+{ "Armenian_apostrophe", 0x100055A },
+{ "Georgian_an", 0x10010D0 },
+{ "Georgian_ban", 0x10010D1 },
+{ "Georgian_gan", 0x10010D2 },
+{ "Georgian_don", 0x10010D3 },
+{ "Georgian_en", 0x10010D4 },
+{ "Georgian_vin", 0x10010D5 },
+{ "Georgian_zen", 0x10010D6 },
+{ "Georgian_tan", 0x10010D7 },
+{ "Georgian_in", 0x10010D8 },
+{ "Georgian_kan", 0x10010D9 },
+{ "Georgian_las", 0x10010DA },
+{ "Georgian_man", 0x10010DB },
+{ "Georgian_nar", 0x10010DC },
+{ "Georgian_on", 0x10010DD },
+{ "Georgian_par", 0x10010DE },
+{ "Georgian_zhar", 0x10010DF },
+{ "Georgian_rae", 0x10010E0 },
+{ "Georgian_san", 0x10010E1 },
+{ "Georgian_tar", 0x10010E2 },
+{ "Georgian_un", 0x10010E3 },
+{ "Georgian_phar", 0x10010E4 },
+{ "Georgian_khar", 0x10010E5 },
+{ "Georgian_ghan", 0x10010E6 },
+{ "Georgian_qar", 0x10010E7 },
+{ "Georgian_shin", 0x10010E8 },
+{ "Georgian_chin", 0x10010E9 },
+{ "Georgian_can", 0x10010EA },
+{ "Georgian_jil", 0x10010EB },
+{ "Georgian_cil", 0x10010EC },
+{ "Georgian_char", 0x10010ED },
+{ "Georgian_xan", 0x10010EE },
+{ "Georgian_jhan", 0x10010EF },
+{ "Georgian_hae", 0x10010F0 },
+{ "Georgian_he", 0x10010F1 },
+{ "Georgian_hie", 0x10010F2 },
+{ "Georgian_we", 0x10010F3 },
+{ "Georgian_har", 0x10010F4 },
+{ "Georgian_hoe", 0x10010F5 },
+{ "Georgian_fi", 0x10010F6 },
+{ "Xabovedot", 0x1001E8A },
+{ "Ibreve", 0x100012C },
+{ "Zstroke", 0x10001B5 },
+{ "Gcaron", 0x10001E6 },
+{ "Ocaron", 0x10001D1 },
+{ "Obarred", 0x100019F },
+{ "xabovedot", 0x1001E8B },
+{ "ibreve", 0x100012D },
+{ "zstroke", 0x10001B6 },
+{ "gcaron", 0x10001E7 },
+{ "ocaron", 0x10001D2 },
+{ "obarred", 0x1000275 },
+{ "SCHWA", 0x100018F },
+{ "schwa", 0x1000259 },
+{ "EZH", 0x10001B7 },
+{ "ezh", 0x1000292 },
+{ "Lbelowdot", 0x1001E36 },
+{ "lbelowdot", 0x1001E37 },
+{ "Abelowdot", 0x1001EA0 },
+{ "abelowdot", 0x1001EA1 },
+{ "Ahook", 0x1001EA2 },
+{ "ahook", 0x1001EA3 },
+{ "Acircumflexacute", 0x1001EA4 },
+{ "acircumflexacute", 0x1001EA5 },
+{ "Acircumflexgrave", 0x1001EA6 },
+{ "acircumflexgrave", 0x1001EA7 },
+{ "Acircumflexhook", 0x1001EA8 },
+{ "acircumflexhook", 0x1001EA9 },
+{ "Acircumflextilde", 0x1001EAA },
+{ "acircumflextilde", 0x1001EAB },
+{ "Acircumflexbelowdot", 0x1001EAC },
+{ "acircumflexbelowdot", 0x1001EAD },
+{ "Abreveacute", 0x1001EAE },
+{ "abreveacute", 0x1001EAF },
+{ "Abrevegrave", 0x1001EB0 },
+{ "abrevegrave", 0x1001EB1 },
+{ "Abrevehook", 0x1001EB2 },
+{ "abrevehook", 0x1001EB3 },
+{ "Abrevetilde", 0x1001EB4 },
+{ "abrevetilde", 0x1001EB5 },
+{ "Abrevebelowdot", 0x1001EB6 },
+{ "abrevebelowdot", 0x1001EB7 },
+{ "Ebelowdot", 0x1001EB8 },
+{ "ebelowdot", 0x1001EB9 },
+{ "Ehook", 0x1001EBA },
+{ "ehook", 0x1001EBB },
+{ "Etilde", 0x1001EBC },
+{ "etilde", 0x1001EBD },
+{ "Ecircumflexacute", 0x1001EBE },
+{ "ecircumflexacute", 0x1001EBF },
+{ "Ecircumflexgrave", 0x1001EC0 },
+{ "ecircumflexgrave", 0x1001EC1 },
+{ "Ecircumflexhook", 0x1001EC2 },
+{ "ecircumflexhook", 0x1001EC3 },
+{ "Ecircumflextilde", 0x1001EC4 },
+{ "ecircumflextilde", 0x1001EC5 },
+{ "Ecircumflexbelowdot", 0x1001EC6 },
+{ "ecircumflexbelowdot", 0x1001EC7 },
+{ "Ihook", 0x1001EC8 },
+{ "ihook", 0x1001EC9 },
+{ "Ibelowdot", 0x1001ECA },
+{ "ibelowdot", 0x1001ECB },
+{ "Obelowdot", 0x1001ECC },
+{ "obelowdot", 0x1001ECD },
+{ "Ohook", 0x1001ECE },
+{ "ohook", 0x1001ECF },
+{ "Ocircumflexacute", 0x1001ED0 },
+{ "ocircumflexacute", 0x1001ED1 },
+{ "Ocircumflexgrave", 0x1001ED2 },
+{ "ocircumflexgrave", 0x1001ED3 },
+{ "Ocircumflexhook", 0x1001ED4 },
+{ "ocircumflexhook", 0x1001ED5 },
+{ "Ocircumflextilde", 0x1001ED6 },
+{ "ocircumflextilde", 0x1001ED7 },
+{ "Ocircumflexbelowdot", 0x1001ED8 },
+{ "ocircumflexbelowdot", 0x1001ED9 },
+{ "Ohornacute", 0x1001EDA },
+{ "ohornacute", 0x1001EDB },
+{ "Ohorngrave", 0x1001EDC },
+{ "ohorngrave", 0x1001EDD },
+{ "Ohornhook", 0x1001EDE },
+{ "ohornhook", 0x1001EDF },
+{ "Ohorntilde", 0x1001EE0 },
+{ "ohorntilde", 0x1001EE1 },
+{ "Ohornbelowdot", 0x1001EE2 },
+{ "ohornbelowdot", 0x1001EE3 },
+{ "Ubelowdot", 0x1001EE4 },
+{ "ubelowdot", 0x1001EE5 },
+{ "Uhook", 0x1001EE6 },
+{ "uhook", 0x1001EE7 },
+{ "Uhornacute", 0x1001EE8 },
+{ "uhornacute", 0x1001EE9 },
+{ "Uhorngrave", 0x1001EEA },
+{ "uhorngrave", 0x1001EEB },
+{ "Uhornhook", 0x1001EEC },
+{ "uhornhook", 0x1001EED },
+{ "Uhorntilde", 0x1001EEE },
+{ "uhorntilde", 0x1001EEF },
+{ "Uhornbelowdot", 0x1001EF0 },
+{ "uhornbelowdot", 0x1001EF1 },
+{ "Ybelowdot", 0x1001EF4 },
+{ "ybelowdot", 0x1001EF5 },
+{ "Yhook", 0x1001EF6 },
+{ "yhook", 0x1001EF7 },
+{ "Ytilde", 0x1001EF8 },
+{ "ytilde", 0x1001EF9 },
+{ "Ohorn", 0x10001A0 },
+{ "ohorn", 0x10001A1 },
+{ "Uhorn", 0x10001AF },
+{ "uhorn", 0x10001B0 },
+{ "EcuSign", 0x10020A0 },
+{ "ColonSign", 0x10020A1 },
+{ "CruzeiroSign", 0x10020A2 },
+{ "FFrancSign", 0x10020A3 },
+{ "LiraSign", 0x10020A4 },
+{ "MillSign", 0x10020A5 },
+{ "NairaSign", 0x10020A6 },
+{ "PesetaSign", 0x10020A7 },
+{ "RupeeSign", 0x10020A8 },
+{ "WonSign", 0x10020A9 },
+{ "NewSheqelSign", 0x10020AA },
+{ "DongSign", 0x10020AB },
+{ "EuroSign", 0x20AC },
+{ "zerosuperior", 0x1002070 },
+{ "foursuperior", 0x1002074 },
+{ "fivesuperior", 0x1002075 },
+{ "sixsuperior", 0x1002076 },
+{ "sevensuperior", 0x1002077 },
+{ "eightsuperior", 0x1002078 },
+{ "ninesuperior", 0x1002079 },
+{ "zerosubscript", 0x1002080 },
+{ "onesubscript", 0x1002081 },
+{ "twosubscript", 0x1002082 },
+{ "threesubscript", 0x1002083 },
+{ "foursubscript", 0x1002084 },
+{ "fivesubscript", 0x1002085 },
+{ "sixsubscript", 0x1002086 },
+{ "sevensubscript", 0x1002087 },
+{ "eightsubscript", 0x1002088 },
+{ "ninesubscript", 0x1002089 },
+{ "partdifferential", 0x1002202 },
+{ "emptyset", 0x1002205 },
+{ "elementof", 0x1002208 },
+{ "notelementof", 0x1002209 },
+{ "containsas", 0x100220B },
+{ "squareroot", 0x100221A },
+{ "cuberoot", 0x100221B },
+{ "fourthroot", 0x100221C },
+{ "dintegral", 0x100222C },
+{ "tintegral", 0x100222D },
+{ "because", 0x1002235 },
+{ "approxeq", 0x1002248 },
+{ "notapproxeq", 0x1002247 },
+{ "notidentical", 0x1002262 },
+{ "stricteq", 0x1002263 },
+{ "braille_dot_1", 0xFFF1 },
+{ "braille_dot_2", 0xFFF2 },
+{ "braille_dot_3", 0xFFF3 },
+{ "braille_dot_4", 0xFFF4 },
+{ "braille_dot_5", 0xFFF5 },
+{ "braille_dot_6", 0xFFF6 },
+{ "braille_dot_7", 0xFFF7 },
+{ "braille_dot_8", 0xFFF8 },
+{ "braille_dot_9", 0xFFF9 },
+{ "braille_dot_10", 0xFFFA },
+{ "braille_blank", 0x1002800 },
+{ "braille_dots_1", 0x1002801 },
+{ "braille_dots_2", 0x1002802 },
+{ "braille_dots_12", 0x1002803 },
+{ "braille_dots_3", 0x1002804 },
+{ "braille_dots_13", 0x1002805 },
+{ "braille_dots_23", 0x1002806 },
+{ "braille_dots_123", 0x1002807 },
+{ "braille_dots_4", 0x1002808 },
+{ "braille_dots_14", 0x1002809 },
+{ "braille_dots_24", 0x100280A },
+{ "braille_dots_124", 0x100280B },
+{ "braille_dots_34", 0x100280C },
+{ "braille_dots_134", 0x100280D },
+{ "braille_dots_234", 0x100280E },
+{ "braille_dots_1234", 0x100280F },
+{ "braille_dots_5", 0x1002810 },
+{ "braille_dots_15", 0x1002811 },
+{ "braille_dots_25", 0x1002812 },
+{ "braille_dots_125", 0x1002813 },
+{ "braille_dots_35", 0x1002814 },
+{ "braille_dots_135", 0x1002815 },
+{ "braille_dots_235", 0x1002816 },
+{ "braille_dots_1235", 0x1002817 },
+{ "braille_dots_45", 0x1002818 },
+{ "braille_dots_145", 0x1002819 },
+{ "braille_dots_245", 0x100281A },
+{ "braille_dots_1245", 0x100281B },
+{ "braille_dots_345", 0x100281C },
+{ "braille_dots_1345", 0x100281D },
+{ "braille_dots_2345", 0x100281E },
+{ "braille_dots_12345", 0x100281F },
+{ "braille_dots_6", 0x1002820 },
+{ "braille_dots_16", 0x1002821 },
+{ "braille_dots_26", 0x1002822 },
+{ "braille_dots_126", 0x1002823 },
+{ "braille_dots_36", 0x1002824 },
+{ "braille_dots_136", 0x1002825 },
+{ "braille_dots_236", 0x1002826 },
+{ "braille_dots_1236", 0x1002827 },
+{ "braille_dots_46", 0x1002828 },
+{ "braille_dots_146", 0x1002829 },
+{ "braille_dots_246", 0x100282A },
+{ "braille_dots_1246", 0x100282B },
+{ "braille_dots_346", 0x100282C },
+{ "braille_dots_1346", 0x100282D },
+{ "braille_dots_2346", 0x100282E },
+{ "braille_dots_12346", 0x100282F },
+{ "braille_dots_56", 0x1002830 },
+{ "braille_dots_156", 0x1002831 },
+{ "braille_dots_256", 0x1002832 },
+{ "braille_dots_1256", 0x1002833 },
+{ "braille_dots_356", 0x1002834 },
+{ "braille_dots_1356", 0x1002835 },
+{ "braille_dots_2356", 0x1002836 },
+{ "braille_dots_12356", 0x1002837 },
+{ "braille_dots_456", 0x1002838 },
+{ "braille_dots_1456", 0x1002839 },
+{ "braille_dots_2456", 0x100283A },
+{ "braille_dots_12456", 0x100283B },
+{ "braille_dots_3456", 0x100283C },
+{ "braille_dots_13456", 0x100283D },
+{ "braille_dots_23456", 0x100283E },
+{ "braille_dots_123456", 0x100283F },
+{ "braille_dots_7", 0x1002840 },
+{ "braille_dots_17", 0x1002841 },
+{ "braille_dots_27", 0x1002842 },
+{ "braille_dots_127", 0x1002843 },
+{ "braille_dots_37", 0x1002844 },
+{ "braille_dots_137", 0x1002845 },
+{ "braille_dots_237", 0x1002846 },
+{ "braille_dots_1237", 0x1002847 },
+{ "braille_dots_47", 0x1002848 },
+{ "braille_dots_147", 0x1002849 },
+{ "braille_dots_247", 0x100284A },
+{ "braille_dots_1247", 0x100284B },
+{ "braille_dots_347", 0x100284C },
+{ "braille_dots_1347", 0x100284D },
+{ "braille_dots_2347", 0x100284E },
+{ "braille_dots_12347", 0x100284F },
+{ "braille_dots_57", 0x1002850 },
+{ "braille_dots_157", 0x1002851 },
+{ "braille_dots_257", 0x1002852 },
+{ "braille_dots_1257", 0x1002853 },
+{ "braille_dots_357", 0x1002854 },
+{ "braille_dots_1357", 0x1002855 },
+{ "braille_dots_2357", 0x1002856 },
+{ "braille_dots_12357", 0x1002857 },
+{ "braille_dots_457", 0x1002858 },
+{ "braille_dots_1457", 0x1002859 },
+{ "braille_dots_2457", 0x100285A },
+{ "braille_dots_12457", 0x100285B },
+{ "braille_dots_3457", 0x100285C },
+{ "braille_dots_13457", 0x100285D },
+{ "braille_dots_23457", 0x100285E },
+{ "braille_dots_123457", 0x100285F },
+{ "braille_dots_67", 0x1002860 },
+{ "braille_dots_167", 0x1002861 },
+{ "braille_dots_267", 0x1002862 },
+{ "braille_dots_1267", 0x1002863 },
+{ "braille_dots_367", 0x1002864 },
+{ "braille_dots_1367", 0x1002865 },
+{ "braille_dots_2367", 0x1002866 },
+{ "braille_dots_12367", 0x1002867 },
+{ "braille_dots_467", 0x1002868 },
+{ "braille_dots_1467", 0x1002869 },
+{ "braille_dots_2467", 0x100286A },
+{ "braille_dots_12467", 0x100286B },
+{ "braille_dots_3467", 0x100286C },
+{ "braille_dots_13467", 0x100286D },
+{ "braille_dots_23467", 0x100286E },
+{ "braille_dots_123467", 0x100286F },
+{ "braille_dots_567", 0x1002870 },
+{ "braille_dots_1567", 0x1002871 },
+{ "braille_dots_2567", 0x1002872 },
+{ "braille_dots_12567", 0x1002873 },
+{ "braille_dots_3567", 0x1002874 },
+{ "braille_dots_13567", 0x1002875 },
+{ "braille_dots_23567", 0x1002876 },
+{ "braille_dots_123567", 0x1002877 },
+{ "braille_dots_4567", 0x1002878 },
+{ "braille_dots_14567", 0x1002879 },
+{ "braille_dots_24567", 0x100287A },
+{ "braille_dots_124567", 0x100287B },
+{ "braille_dots_34567", 0x100287C },
+{ "braille_dots_134567", 0x100287D },
+{ "braille_dots_234567", 0x100287E },
+{ "braille_dots_1234567", 0x100287F },
+{ "braille_dots_8", 0x1002880 },
+{ "braille_dots_18", 0x1002881 },
+{ "braille_dots_28", 0x1002882 },
+{ "braille_dots_128", 0x1002883 },
+{ "braille_dots_38", 0x1002884 },
+{ "braille_dots_138", 0x1002885 },
+{ "braille_dots_238", 0x1002886 },
+{ "braille_dots_1238", 0x1002887 },
+{ "braille_dots_48", 0x1002888 },
+{ "braille_dots_148", 0x1002889 },
+{ "braille_dots_248", 0x100288A },
+{ "braille_dots_1248", 0x100288B },
+{ "braille_dots_348", 0x100288C },
+{ "braille_dots_1348", 0x100288D },
+{ "braille_dots_2348", 0x100288E },
+{ "braille_dots_12348", 0x100288F },
+{ "braille_dots_58", 0x1002890 },
+{ "braille_dots_158", 0x1002891 },
+{ "braille_dots_258", 0x1002892 },
+{ "braille_dots_1258", 0x1002893 },
+{ "braille_dots_358", 0x1002894 },
+{ "braille_dots_1358", 0x1002895 },
+{ "braille_dots_2358", 0x1002896 },
+{ "braille_dots_12358", 0x1002897 },
+{ "braille_dots_458", 0x1002898 },
+{ "braille_dots_1458", 0x1002899 },
+{ "braille_dots_2458", 0x100289A },
+{ "braille_dots_12458", 0x100289B },
+{ "braille_dots_3458", 0x100289C },
+{ "braille_dots_13458", 0x100289D },
+{ "braille_dots_23458", 0x100289E },
+{ "braille_dots_123458", 0x100289F },
+{ "braille_dots_68", 0x10028A0 },
+{ "braille_dots_168", 0x10028A1 },
+{ "braille_dots_268", 0x10028A2 },
+{ "braille_dots_1268", 0x10028A3 },
+{ "braille_dots_368", 0x10028A4 },
+{ "braille_dots_1368", 0x10028A5 },
+{ "braille_dots_2368", 0x10028A6 },
+{ "braille_dots_12368", 0x10028A7 },
+{ "braille_dots_468", 0x10028A8 },
+{ "braille_dots_1468", 0x10028A9 },
+{ "braille_dots_2468", 0x10028AA },
+{ "braille_dots_12468", 0x10028AB },
+{ "braille_dots_3468", 0x10028AC },
+{ "braille_dots_13468", 0x10028AD },
+{ "braille_dots_23468", 0x10028AE },
+{ "braille_dots_123468", 0x10028AF },
+{ "braille_dots_568", 0x10028B0 },
+{ "braille_dots_1568", 0x10028B1 },
+{ "braille_dots_2568", 0x10028B2 },
+{ "braille_dots_12568", 0x10028B3 },
+{ "braille_dots_3568", 0x10028B4 },
+{ "braille_dots_13568", 0x10028B5 },
+{ "braille_dots_23568", 0x10028B6 },
+{ "braille_dots_123568", 0x10028B7 },
+{ "braille_dots_4568", 0x10028B8 },
+{ "braille_dots_14568", 0x10028B9 },
+{ "braille_dots_24568", 0x10028BA },
+{ "braille_dots_124568", 0x10028BB },
+{ "braille_dots_34568", 0x10028BC },
+{ "braille_dots_134568", 0x10028BD },
+{ "braille_dots_234568", 0x10028BE },
+{ "braille_dots_1234568", 0x10028BF },
+{ "braille_dots_78", 0x10028C0 },
+{ "braille_dots_178", 0x10028C1 },
+{ "braille_dots_278", 0x10028C2 },
+{ "braille_dots_1278", 0x10028C3 },
+{ "braille_dots_378", 0x10028C4 },
+{ "braille_dots_1378", 0x10028C5 },
+{ "braille_dots_2378", 0x10028C6 },
+{ "braille_dots_12378", 0x10028C7 },
+{ "braille_dots_478", 0x10028C8 },
+{ "braille_dots_1478", 0x10028C9 },
+{ "braille_dots_2478", 0x10028CA },
+{ "braille_dots_12478", 0x10028CB },
+{ "braille_dots_3478", 0x10028CC },
+{ "braille_dots_13478", 0x10028CD },
+{ "braille_dots_23478", 0x10028CE },
+{ "braille_dots_123478", 0x10028CF },
+{ "braille_dots_578", 0x10028D0 },
+{ "braille_dots_1578", 0x10028D1 },
+{ "braille_dots_2578", 0x10028D2 },
+{ "braille_dots_12578", 0x10028D3 },
+{ "braille_dots_3578", 0x10028D4 },
+{ "braille_dots_13578", 0x10028D5 },
+{ "braille_dots_23578", 0x10028D6 },
+{ "braille_dots_123578", 0x10028D7 },
+{ "braille_dots_4578", 0x10028D8 },
+{ "braille_dots_14578", 0x10028D9 },
+{ "braille_dots_24578", 0x10028DA },
+{ "braille_dots_124578", 0x10028DB },
+{ "braille_dots_34578", 0x10028DC },
+{ "braille_dots_134578", 0x10028DD },
+{ "braille_dots_234578", 0x10028DE },
+{ "braille_dots_1234578", 0x10028DF },
+{ "braille_dots_678", 0x10028E0 },
+{ "braille_dots_1678", 0x10028E1 },
+{ "braille_dots_2678", 0x10028E2 },
+{ "braille_dots_12678", 0x10028E3 },
+{ "braille_dots_3678", 0x10028E4 },
+{ "braille_dots_13678", 0x10028E5 },
+{ "braille_dots_23678", 0x10028E6 },
+{ "braille_dots_123678", 0x10028E7 },
+{ "braille_dots_4678", 0x10028E8 },
+{ "braille_dots_14678", 0x10028E9 },
+{ "braille_dots_24678", 0x10028EA },
+{ "braille_dots_124678", 0x10028EB },
+{ "braille_dots_34678", 0x10028EC },
+{ "braille_dots_134678", 0x10028ED },
+{ "braille_dots_234678", 0x10028EE },
+{ "braille_dots_1234678", 0x10028EF },
+{ "braille_dots_5678", 0x10028F0 },
+{ "braille_dots_15678", 0x10028F1 },
+{ "braille_dots_25678", 0x10028F2 },
+{ "braille_dots_125678", 0x10028F3 },
+{ "braille_dots_35678", 0x10028F4 },
+{ "braille_dots_135678", 0x10028F5 },
+{ "braille_dots_235678", 0x10028F6 },
+{ "braille_dots_1235678", 0x10028F7 },
+{ "braille_dots_45678", 0x10028F8 },
+{ "braille_dots_145678", 0x10028F9 },
+{ "braille_dots_245678", 0x10028FA },
+{ "braille_dots_1245678", 0x10028FB },
+{ "braille_dots_345678", 0x10028FC },
+{ "braille_dots_1345678", 0x10028FD },
+{ "braille_dots_2345678", 0x10028FE },
+{ "braille_dots_12345678", 0x10028FF },
+{ "Sinh_ng", 0x1000D82 },
+{ "Sinh_h2", 0x1000D83 },
+{ "Sinh_a", 0x1000D85 },
+{ "Sinh_aa", 0x1000D86 },
+{ "Sinh_ae", 0x1000D87 },
+{ "Sinh_aee", 0x1000D88 },
+{ "Sinh_i", 0x1000D89 },
+{ "Sinh_ii", 0x1000D8A },
+{ "Sinh_u", 0x1000D8B },
+{ "Sinh_uu", 0x1000D8C },
+{ "Sinh_ri", 0x1000D8D },
+{ "Sinh_rii", 0x1000D8E },
+{ "Sinh_lu", 0x1000D8F },
+{ "Sinh_luu", 0x1000D90 },
+{ "Sinh_e", 0x1000D91 },
+{ "Sinh_ee", 0x1000D92 },
+{ "Sinh_ai", 0x1000D93 },
+{ "Sinh_o", 0x1000D94 },
+{ "Sinh_oo", 0x1000D95 },
+{ "Sinh_au", 0x1000D96 },
+{ "Sinh_ka", 0x1000D9A },
+{ "Sinh_kha", 0x1000D9B },
+{ "Sinh_ga", 0x1000D9C },
+{ "Sinh_gha", 0x1000D9D },
+{ "Sinh_ng2", 0x1000D9E },
+{ "Sinh_nga", 0x1000D9F },
+{ "Sinh_ca", 0x1000DA0 },
+{ "Sinh_cha", 0x1000DA1 },
+{ "Sinh_ja", 0x1000DA2 },
+{ "Sinh_jha", 0x1000DA3 },
+{ "Sinh_nya", 0x1000DA4 },
+{ "Sinh_jnya", 0x1000DA5 },
+{ "Sinh_nja", 0x1000DA6 },
+{ "Sinh_tta", 0x1000DA7 },
+{ "Sinh_ttha", 0x1000DA8 },
+{ "Sinh_dda", 0x1000DA9 },
+{ "Sinh_ddha", 0x1000DAA },
+{ "Sinh_nna", 0x1000DAB },
+{ "Sinh_ndda", 0x1000DAC },
+{ "Sinh_tha", 0x1000DAD },
+{ "Sinh_thha", 0x1000DAE },
+{ "Sinh_dha", 0x1000DAF },
+{ "Sinh_dhha", 0x1000DB0 },
+{ "Sinh_na", 0x1000DB1 },
+{ "Sinh_ndha", 0x1000DB3 },
+{ "Sinh_pa", 0x1000DB4 },
+{ "Sinh_pha", 0x1000DB5 },
+{ "Sinh_ba", 0x1000DB6 },
+{ "Sinh_bha", 0x1000DB7 },
+{ "Sinh_ma", 0x1000DB8 },
+{ "Sinh_mba", 0x1000DB9 },
+{ "Sinh_ya", 0x1000DBA },
+{ "Sinh_ra", 0x1000DBB },
+{ "Sinh_la", 0x1000DBD },
+{ "Sinh_va", 0x1000DC0 },
+{ "Sinh_sha", 0x1000DC1 },
+{ "Sinh_ssha", 0x1000DC2 },
+{ "Sinh_sa", 0x1000DC3 },
+{ "Sinh_ha", 0x1000DC4 },
+{ "Sinh_lla", 0x1000DC5 },
+{ "Sinh_fa", 0x1000DC6 },
+{ "Sinh_al", 0x1000DCA },
+{ "Sinh_aa2", 0x1000DCF },
+{ "Sinh_ae2", 0x1000DD0 },
+{ "Sinh_aee2", 0x1000DD1 },
+{ "Sinh_i2", 0x1000DD2 },
+{ "Sinh_ii2", 0x1000DD3 },
+{ "Sinh_u2", 0x1000DD4 },
+{ "Sinh_uu2", 0x1000DD6 },
+{ "Sinh_ru2", 0x1000DD8 },
+{ "Sinh_e2", 0x1000DD9 },
+{ "Sinh_ee2", 0x1000DDA },
+{ "Sinh_ai2", 0x1000DDB },
+{ "Sinh_o2", 0x1000DDC },
+{ "Sinh_oo2", 0x1000DDD },
+{ "Sinh_au2", 0x1000DDE },
+{ "Sinh_lu2", 0x1000DDF },
+{ "Sinh_ruu2", 0x1000DF2 },
+{ "Sinh_luu2", 0x1000DF3 },
+{ "Sinh_kunddaliya", 0x1000DF4 },
+{ "XF86ModeLock", 0x1008FF01 },
+{ "XF86MonBrightnessUp", 0x1008FF02 },
+{ "XF86MonBrightnessDown", 0x1008FF03 },
+{ "XF86KbdLightOnOff", 0x1008FF04 },
+{ "XF86KbdBrightnessUp", 0x1008FF05 },
+{ "XF86KbdBrightnessDown", 0x1008FF06 },
+{ "XF86MonBrightnessCycle", 0x1008FF07 },
+{ "XF86Standby", 0x1008FF10 },
{ "XF86AudioLowerVolume", 0x1008FF11 },
{ "XF86AudioMute", 0x1008FF12 },
{ "XF86AudioRaiseVolume", 0x1008FF13 },
@@ -937,3 +2200,194 @@
{ "XF86AudioStop", 0x1008FF15 },
{ "XF86AudioPrev", 0x1008FF16 },
{ "XF86AudioNext", 0x1008FF17 },
+{ "XF86HomePage", 0x1008FF18 },
+{ "XF86Mail", 0x1008FF19 },
+{ "XF86Start", 0x1008FF1A },
+{ "XF86Search", 0x1008FF1B },
+{ "XF86AudioRecord", 0x1008FF1C },
+{ "XF86Calculator", 0x1008FF1D },
+{ "XF86Memo", 0x1008FF1E },
+{ "XF86ToDoList", 0x1008FF1F },
+{ "XF86Calendar", 0x1008FF20 },
+{ "XF86PowerDown", 0x1008FF21 },
+{ "XF86ContrastAdjust", 0x1008FF22 },
+{ "XF86RockerUp", 0x1008FF23 },
+{ "XF86RockerDown", 0x1008FF24 },
+{ "XF86RockerEnter", 0x1008FF25 },
+{ "XF86Back", 0x1008FF26 },
+{ "XF86Forward", 0x1008FF27 },
+{ "XF86Stop", 0x1008FF28 },
+{ "XF86Refresh", 0x1008FF29 },
+{ "XF86PowerOff", 0x1008FF2A },
+{ "XF86WakeUp", 0x1008FF2B },
+{ "XF86Eject", 0x1008FF2C },
+{ "XF86ScreenSaver", 0x1008FF2D },
+{ "XF86WWW", 0x1008FF2E },
+{ "XF86Sleep", 0x1008FF2F },
+{ "XF86Favorites", 0x1008FF30 },
+{ "XF86AudioPause", 0x1008FF31 },
+{ "XF86AudioMedia", 0x1008FF32 },
+{ "XF86MyComputer", 0x1008FF33 },
+{ "XF86VendorHome", 0x1008FF34 },
+{ "XF86LightBulb", 0x1008FF35 },
+{ "XF86Shop", 0x1008FF36 },
+{ "XF86History", 0x1008FF37 },
+{ "XF86OpenURL", 0x1008FF38 },
+{ "XF86AddFavorite", 0x1008FF39 },
+{ "XF86HotLinks", 0x1008FF3A },
+{ "XF86BrightnessAdjust", 0x1008FF3B },
+{ "XF86Finance", 0x1008FF3C },
+{ "XF86Community", 0x1008FF3D },
+{ "XF86AudioRewind", 0x1008FF3E },
+{ "XF86BackForward", 0x1008FF3F },
+{ "XF86Launch0", 0x1008FF40 },
+{ "XF86Launch1", 0x1008FF41 },
+{ "XF86Launch2", 0x1008FF42 },
+{ "XF86Launch3", 0x1008FF43 },
+{ "XF86Launch4", 0x1008FF44 },
+{ "XF86Launch5", 0x1008FF45 },
+{ "XF86Launch6", 0x1008FF46 },
+{ "XF86Launch7", 0x1008FF47 },
+{ "XF86Launch8", 0x1008FF48 },
+{ "XF86Launch9", 0x1008FF49 },
+{ "XF86LaunchA", 0x1008FF4A },
+{ "XF86LaunchB", 0x1008FF4B },
+{ "XF86LaunchC", 0x1008FF4C },
+{ "XF86LaunchD", 0x1008FF4D },
+{ "XF86LaunchE", 0x1008FF4E },
+{ "XF86LaunchF", 0x1008FF4F },
+{ "XF86ApplicationLeft", 0x1008FF50 },
+{ "XF86ApplicationRight", 0x1008FF51 },
+{ "XF86Book", 0x1008FF52 },
+{ "XF86CD", 0x1008FF53 },
+{ "XF86Calculater", 0x1008FF54 },
+{ "XF86Clear", 0x1008FF55 },
+{ "XF86Close", 0x1008FF56 },
+{ "XF86Copy", 0x1008FF57 },
+{ "XF86Cut", 0x1008FF58 },
+{ "XF86Display", 0x1008FF59 },
+{ "XF86DOS", 0x1008FF5A },
+{ "XF86Documents", 0x1008FF5B },
+{ "XF86Excel", 0x1008FF5C },
+{ "XF86Explorer", 0x1008FF5D },
+{ "XF86Game", 0x1008FF5E },
+{ "XF86Go", 0x1008FF5F },
+{ "XF86iTouch", 0x1008FF60 },
+{ "XF86LogOff", 0x1008FF61 },
+{ "XF86Market", 0x1008FF62 },
+{ "XF86Meeting", 0x1008FF63 },
+{ "XF86MenuKB", 0x1008FF65 },
+{ "XF86MenuPB", 0x1008FF66 },
+{ "XF86MySites", 0x1008FF67 },
+{ "XF86New", 0x1008FF68 },
+{ "XF86News", 0x1008FF69 },
+{ "XF86OfficeHome", 0x1008FF6A },
+{ "XF86Open", 0x1008FF6B },
+{ "XF86Option", 0x1008FF6C },
+{ "XF86Paste", 0x1008FF6D },
+{ "XF86Phone", 0x1008FF6E },
+{ "XF86Q", 0x1008FF70 },
+{ "XF86Reply", 0x1008FF72 },
+{ "XF86Reload", 0x1008FF73 },
+{ "XF86RotateWindows", 0x1008FF74 },
+{ "XF86RotationPB", 0x1008FF75 },
+{ "XF86RotationKB", 0x1008FF76 },
+{ "XF86Save", 0x1008FF77 },
+{ "XF86ScrollUp", 0x1008FF78 },
+{ "XF86ScrollDown", 0x1008FF79 },
+{ "XF86ScrollClick", 0x1008FF7A },
+{ "XF86Send", 0x1008FF7B },
+{ "XF86Spell", 0x1008FF7C },
+{ "XF86SplitScreen", 0x1008FF7D },
+{ "XF86Support", 0x1008FF7E },
+{ "XF86TaskPane", 0x1008FF7F },
+{ "XF86Terminal", 0x1008FF80 },
+{ "XF86Tools", 0x1008FF81 },
+{ "XF86Travel", 0x1008FF82 },
+{ "XF86UserPB", 0x1008FF84 },
+{ "XF86User1KB", 0x1008FF85 },
+{ "XF86User2KB", 0x1008FF86 },
+{ "XF86Video", 0x1008FF87 },
+{ "XF86WheelButton", 0x1008FF88 },
+{ "XF86Word", 0x1008FF89 },
+{ "XF86Xfer", 0x1008FF8A },
+{ "XF86ZoomIn", 0x1008FF8B },
+{ "XF86ZoomOut", 0x1008FF8C },
+{ "XF86Away", 0x1008FF8D },
+{ "XF86Messenger", 0x1008FF8E },
+{ "XF86WebCam", 0x1008FF8F },
+{ "XF86MailForward", 0x1008FF90 },
+{ "XF86Pictures", 0x1008FF91 },
+{ "XF86Music", 0x1008FF92 },
+{ "XF86Battery", 0x1008FF93 },
+{ "XF86Bluetooth", 0x1008FF94 },
+{ "XF86WLAN", 0x1008FF95 },
+{ "XF86UWB", 0x1008FF96 },
+{ "XF86AudioForward", 0x1008FF97 },
+{ "XF86AudioRepeat", 0x1008FF98 },
+{ "XF86AudioRandomPlay", 0x1008FF99 },
+{ "XF86Subtitle", 0x1008FF9A },
+{ "XF86AudioCycleTrack", 0x1008FF9B },
+{ "XF86CycleAngle", 0x1008FF9C },
+{ "XF86FrameBack", 0x1008FF9D },
+{ "XF86FrameForward", 0x1008FF9E },
+{ "XF86Time", 0x1008FF9F },
+{ "XF86Select", 0x1008FFA0 },
+{ "XF86View", 0x1008FFA1 },
+{ "XF86TopMenu", 0x1008FFA2 },
+{ "XF86Red", 0x1008FFA3 },
+{ "XF86Green", 0x1008FFA4 },
+{ "XF86Yellow", 0x1008FFA5 },
+{ "XF86Blue", 0x1008FFA6 },
+{ "XF86Suspend", 0x1008FFA7 },
+{ "XF86Hibernate", 0x1008FFA8 },
+{ "XF86TouchpadToggle", 0x1008FFA9 },
+{ "XF86TouchpadOn", 0x1008FFB0 },
+{ "XF86TouchpadOff", 0x1008FFB1 },
+{ "XF86AudioMicMute", 0x1008FFB2 },
+{ "XF86Keyboard", 0x1008FFB3 },
+{ "XF86WWAN", 0x1008FFB4 },
+{ "XF86RFKill", 0x1008FFB5 },
+{ "XF86AudioPreset", 0x1008FFB6 },
+{ "XF86RotationLockToggle", 0x1008FFB7 },
+{ "XF86Switch_VT_1", 0x1008FE01 },
+{ "XF86Switch_VT_2", 0x1008FE02 },
+{ "XF86Switch_VT_3", 0x1008FE03 },
+{ "XF86Switch_VT_4", 0x1008FE04 },
+{ "XF86Switch_VT_5", 0x1008FE05 },
+{ "XF86Switch_VT_6", 0x1008FE06 },
+{ "XF86Switch_VT_7", 0x1008FE07 },
+{ "XF86Switch_VT_8", 0x1008FE08 },
+{ "XF86Switch_VT_9", 0x1008FE09 },
+{ "XF86Switch_VT_10", 0x1008FE0A },
+{ "XF86Switch_VT_11", 0x1008FE0B },
+{ "XF86Switch_VT_12", 0x1008FE0C },
+{ "XF86Ungrab", 0x1008FE20 },
+{ "XF86ClearGrab", 0x1008FE21 },
+{ "XF86Next_VMode", 0x1008FE22 },
+{ "XF86Prev_VMode", 0x1008FE23 },
+{ "XF86LogWindowTree", 0x1008FE24 },
+{ "XF86LogGrabInfo", 0x1008FE25 },
+{ "SunFA_Grave", 0x1005FF00 },
+{ "SunFA_Circum", 0x1005FF01 },
+{ "SunFA_Tilde", 0x1005FF02 },
+{ "SunFA_Acute", 0x1005FF03 },
+{ "SunFA_Diaeresis", 0x1005FF04 },
+{ "SunFA_Cedilla", 0x1005FF05 },
+{ "SunF36", 0x1005FF10 },
+{ "SunF37", 0x1005FF11 },
+{ "SunSys_Req", 0x1005FF60 },
+{ "SunProps", 0x1005FF70 },
+{ "SunFront", 0x1005FF71 },
+{ "SunCopy", 0x1005FF72 },
+{ "SunOpen", 0x1005FF73 },
+{ "SunPaste", 0x1005FF74 },
+{ "SunCut", 0x1005FF75 },
+{ "SunPowerSwitch", 0x1005FF76 },
+{ "SunAudioLowerVolume", 0x1005FF77 },
+{ "SunAudioMute", 0x1005FF78 },
+{ "SunAudioRaiseVolume", 0x1005FF79 },
+{ "SunVideoDegauss", 0x1005FF7A },
+{ "SunVideoLowerBrightness", 0x1005FF7B },
+{ "SunVideoRaiseBrightness", 0x1005FF7C },
+{ "SunPowerSwitchShift", 0x1005FF7D },
diff --git a/generic/nanosvg.h b/generic/nanosvg.h
new file mode 100755
index 0000000..7bb13d2
--- /dev/null
+++ b/generic/nanosvg.h
@@ -0,0 +1,3088 @@
+/*
+ * Copyright (c) 2013-14 Mikko Mononen memon@inside.org
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ *
+ * The SVG parser is based on Anti-Grain Geometry 2.4 SVG example
+ * Copyright (C) 2002-2004 Maxim Shemanarev (McSeem) (http://www.antigrain.com/)
+ *
+ * Arc calculation code based on canvg (https://code.google.com/p/canvg/)
+ *
+ * Bounding box calculation based on http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
+ *
+ */
+
+#ifndef NANOSVG_H
+#define NANOSVG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// NanoSVG is a simple stupid single-header-file SVG parse. The output of the parser is a list of cubic bezier shapes.
+//
+// The library suits well for anything from rendering scalable icons in your editor application to prototyping a game.
+//
+// NanoSVG supports a wide range of SVG features, but something may be missing, feel free to create a pull request!
+//
+// The shapes in the SVG images are transformed by the viewBox and converted to specified units.
+// That is, you should get the same looking data as your designed in your favorite app.
+//
+// NanoSVG can return the paths in few different units. For example if you want to render an image, you may choose
+// to get the paths in pixels, or if you are feeding the data into a CNC-cutter, you may want to use millimeters.
+//
+// The units passed to NanoVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'.
+// DPI (dots-per-inch) controls how the unit conversion is done.
+//
+// If you don't know or care about the units stuff, "px" and 96 should get you going.
+
+
+/* Example Usage:
+ // Load
+ NSVGImage* image;
+ image = nsvgParseFromFile("test.svg", "px", 96);
+ printf("size: %f x %f\n", image->width, image->height);
+ // Use...
+ for (NSVGshape *shape = image->shapes; shape != NULL; shape = shape->next) {
+ for (NSVGpath *path = shape->paths; path != NULL; path = path->next) {
+ for (int i = 0; i < path->npts-1; i += 3) {
+ float* p = &path->pts[i*2];
+ drawCubicBez(p[0],p[1], p[2],p[3], p[4],p[5], p[6],p[7]);
+ }
+ }
+ }
+ // Delete
+ nsvgDelete(image);
+*/
+
+#ifndef NANOSVG_SCOPE
+#define NANOSVG_SCOPE
+#endif
+
+#ifndef NANOSVG_malloc
+#define NANOSVG_malloc malloc
+#endif
+
+#ifndef NANOSVG_realloc
+#define NANOSVG_realloc realloc
+#endif
+
+#ifndef NANOSVG_free
+#define NANOSVG_free free
+#endif
+
+// float emulation for MS VC6++ compiler
+#if (_MSC_VER == 1200)
+#define tanf(a) (float)tan(a)
+#define cosf(a) (float)cos(a)
+#define sinf(a) (float)sin(a)
+#define sqrtf(a) (float)sqrt(a)
+#define fabsf(a) (float)fabs(a)
+#define acosf(a) (float)acos(a)
+#define atan2f(a,b) (float)atan2(a,b)
+#define ceilf(a) (float)ceil(a)
+#define fmodf(a,b) (float)fmod(a,b)
+#define floorf(a) (float)floor(a)
+#endif
+// float emulation for MS VC8++ compiler
+#if (_MSC_VER == 1400)
+#define fabsf(a) (float)fabs(a)
+#endif
+
+enum NSVGpaintType {
+ NSVG_PAINT_NONE = 0,
+ NSVG_PAINT_COLOR = 1,
+ NSVG_PAINT_LINEAR_GRADIENT = 2,
+ NSVG_PAINT_RADIAL_GRADIENT = 3
+};
+
+enum NSVGspreadType {
+ NSVG_SPREAD_PAD = 0,
+ NSVG_SPREAD_REFLECT = 1,
+ NSVG_SPREAD_REPEAT = 2
+};
+
+enum NSVGlineJoin {
+ NSVG_JOIN_MITER = 0,
+ NSVG_JOIN_ROUND = 1,
+ NSVG_JOIN_BEVEL = 2
+};
+
+enum NSVGlineCap {
+ NSVG_CAP_BUTT = 0,
+ NSVG_CAP_ROUND = 1,
+ NSVG_CAP_SQUARE = 2
+};
+
+enum NSVGfillRule {
+ NSVG_FILLRULE_NONZERO = 0,
+ NSVG_FILLRULE_EVENODD = 1
+};
+
+enum NSVGflags {
+ NSVG_FLAGS_VISIBLE = 0x01
+};
+
+typedef struct NSVGgradientStop {
+ unsigned int color;
+ float offset;
+} NSVGgradientStop;
+
+typedef struct NSVGgradient {
+ float xform[6];
+ char spread;
+ float fx, fy;
+ int nstops;
+ NSVGgradientStop stops[1];
+} NSVGgradient;
+
+typedef struct NSVGpaint {
+ char type;
+ union {
+ unsigned int color;
+ NSVGgradient* gradient;
+ };
+} NSVGpaint;
+
+typedef struct NSVGpath
+{
+ float* pts; // Cubic bezier points: x0,y0, [cpx1,cpx1,cpx2,cpy2,x1,y1], ...
+ int npts; // Total number of bezier points.
+ char closed; // Flag indicating if shapes should be treated as closed.
+ float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy].
+ struct NSVGpath* next; // Pointer to next path, or NULL if last element.
+} NSVGpath;
+
+typedef struct NSVGshape
+{
+ char id[64]; // Optional 'id' attr of the shape or its group
+ NSVGpaint fill; // Fill paint
+ NSVGpaint stroke; // Stroke paint
+ float opacity; // Opacity of the shape.
+ float strokeWidth; // Stroke width (scaled).
+ float strokeDashOffset; // Stroke dash offset (scaled).
+ float strokeDashArray[8]; // Stroke dash array (scaled).
+ char strokeDashCount; // Number of dash values in dash array.
+ char strokeLineJoin; // Stroke join type.
+ char strokeLineCap; // Stroke cap type.
+ float miterLimit; // Miter limit
+ char fillRule; // Fill rule, see NSVGfillRule.
+ unsigned char flags; // Logical or of NSVG_FLAGS_* flags
+ float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy].
+ NSVGpath* paths; // Linked list of paths in the image.
+ struct NSVGshape* next; // Pointer to next shape, or NULL if last element.
+} NSVGshape;
+
+typedef struct NSVGimage
+{
+ float width; // Width of the image.
+ float height; // Height of the image.
+ NSVGshape* shapes; // Linked list of shapes in the image.
+} NSVGimage;
+
+// Parses SVG file from a file, returns SVG image as paths.
+NANOSVG_SCOPE NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi);
+
+// Parses SVG file from a null terminated string, returns SVG image as paths.
+// Important note: changes the string.
+NANOSVG_SCOPE NSVGimage* nsvgParse(char* input, const char* units, float dpi);
+
+// Deletes list of paths.
+NANOSVG_SCOPE void nsvgDelete(NSVGimage* image);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // NANOSVG_H
+
+#ifdef NANOSVG_IMPLEMENTATION
+
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+
+#define NSVG_PI (3.14159265358979323846264338327f)
+#define NSVG_KAPPA90 (0.5522847493f) // Length proportional to radius of a cubic bezier handle for 90deg arcs.
+
+#define NSVG_ALIGN_MIN 0
+#define NSVG_ALIGN_MID 1
+#define NSVG_ALIGN_MAX 2
+#define NSVG_ALIGN_NONE 0
+#define NSVG_ALIGN_MEET 1
+#define NSVG_ALIGN_SLICE 2
+
+#define NSVG_NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) ); } while(0)
+#define NSVG_RGB(r, g, b) (((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16))
+
+#ifdef _MSC_VER
+ #pragma warning (disable: 4996) // Switch off security warnings
+ #pragma warning (disable: 4100) // Switch off unreferenced formal parameter warnings
+ #ifdef __cplusplus
+ #define NSVG_INLINE inline
+ #else
+ #define NSVG_INLINE
+ #endif
+ #if !defined(strtoll) // old MSVC versions do not have strtoll()
+ #define strtoll _strtoi64
+ #endif
+#else
+ #define NSVG_INLINE inline
+#endif
+
+
+static int nsvg__isspace(char c)
+{
+ return strchr(" \t\n\v\f\r", c) != 0;
+}
+
+static int nsvg__isdigit(char c)
+{
+ return c >= '0' && c <= '9';
+}
+
+static int nsvg__isnum(char c)
+{
+ return strchr("0123456789+-.eE", c) != 0;
+}
+
+static NSVG_INLINE float nsvg__minf(float a, float b) { return a < b ? a : b; }
+static NSVG_INLINE float nsvg__maxf(float a, float b) { return a > b ? a : b; }
+
+
+// Simple XML parser
+
+#define NSVG_XML_TAG 1
+#define NSVG_XML_CONTENT 2
+#define NSVG_XML_MAX_ATTRIBS 256
+
+static void nsvg__parseContent(char* s,
+ void (*contentCb)(void* ud, const char* s),
+ void* ud)
+{
+ // Trim start white spaces
+ while (*s && nsvg__isspace(*s)) s++;
+ if (!*s) return;
+
+ if (contentCb)
+ (*contentCb)(ud, s);
+}
+
+static void nsvg__parseElement(char* s,
+ void (*startelCb)(void* ud, const char* el, const char** attr),
+ void (*endelCb)(void* ud, const char* el),
+ void* ud)
+{
+ const char* attr[NSVG_XML_MAX_ATTRIBS];
+ int nattr = 0;
+ char* name;
+ int start = 0;
+ int end = 0;
+ char quote;
+
+ // Skip white space after the '<'
+ while (*s && nsvg__isspace(*s)) s++;
+
+ // Check if the tag is end tag
+ if (*s == '/') {
+ s++;
+ end = 1;
+ } else {
+ start = 1;
+ }
+
+ // Skip comments, data and preprocessor stuff.
+ if (!*s || *s == '?' || *s == '!')
+ return;
+
+ // Get tag name
+ name = s;
+ while (*s && !nsvg__isspace(*s)) s++;
+ if (*s) { *s++ = '\0'; }
+
+ // Get attribs
+ while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS-3) {
+ char* name = NULL;
+ char* value = NULL;
+
+ // Skip white space before the attrib name
+ while (*s && nsvg__isspace(*s)) s++;
+ if (!*s) break;
+ if (*s == '/') {
+ end = 1;
+ break;
+ }
+ name = s;
+ // Find end of the attrib name.
+ while (*s && !nsvg__isspace(*s) && *s != '=') s++;
+ if (*s) { *s++ = '\0'; }
+ // Skip until the beginning of the value.
+ while (*s && *s != '\"' && *s != '\'') s++;
+ if (!*s) break;
+ quote = *s;
+ s++;
+ // Store value and find the end of it.
+ value = s;
+ while (*s && *s != quote) s++;
+ if (*s) { *s++ = '\0'; }
+
+ // Store only well formed attributes
+ if (name && value) {
+ attr[nattr++] = name;
+ attr[nattr++] = value;
+ }
+ }
+
+ // List terminator
+ attr[nattr++] = 0;
+ attr[nattr++] = 0;
+
+ // Call callbacks.
+ if (start && startelCb)
+ (*startelCb)(ud, name, attr);
+ if (end && endelCb)
+ (*endelCb)(ud, name);
+}
+
+NANOSVG_SCOPE
+int nsvg__parseXML(char* input,
+ void (*startelCb)(void* ud, const char* el, const char** attr),
+ void (*endelCb)(void* ud, const char* el),
+ void (*contentCb)(void* ud, const char* s),
+ void* ud)
+{
+ char* s = input;
+ char* mark = s;
+ int state = NSVG_XML_CONTENT;
+ while (*s) {
+ if (*s == '<' && state == NSVG_XML_CONTENT) {
+ // Start of a tag
+ *s++ = '\0';
+ nsvg__parseContent(mark, contentCb, ud);
+ mark = s;
+ state = NSVG_XML_TAG;
+ } else if (*s == '>' && state == NSVG_XML_TAG) {
+ // Start of a content or new tag.
+ *s++ = '\0';
+ nsvg__parseContent(mark, contentCb, ud);
+ nsvg__parseElement(mark, startelCb, endelCb, ud);
+ mark = s;
+ state = NSVG_XML_CONTENT;
+ } else {
+ s++;
+ }
+ }
+
+ return 1;
+}
+
+
+/* Simple SVG parser. */
+
+#define NSVG_MAX_ATTR 128
+
+enum NSVGgradientUnits {
+ NSVG_USER_SPACE = 0,
+ NSVG_OBJECT_SPACE = 1
+};
+
+#define NSVG_MAX_DASHES 8
+
+enum NSVGunits {
+ NSVG_UNITS_USER,
+ NSVG_UNITS_PX,
+ NSVG_UNITS_PT,
+ NSVG_UNITS_PC,
+ NSVG_UNITS_MM,
+ NSVG_UNITS_CM,
+ NSVG_UNITS_IN,
+ NSVG_UNITS_PERCENT,
+ NSVG_UNITS_EM,
+ NSVG_UNITS_EX
+};
+
+enum NSVGvisible {
+ NSVG_VIS_DISPLAY = 1,
+ NSVG_VIS_VISIBLE = 2
+};
+
+typedef struct NSVGcoordinate {
+ float value;
+ int units;
+} NSVGcoordinate;
+
+typedef struct NSVGlinearData {
+ NSVGcoordinate x1, y1, x2, y2;
+} NSVGlinearData;
+
+typedef struct NSVGradialData {
+ NSVGcoordinate cx, cy, r, fx, fy;
+} NSVGradialData;
+
+typedef struct NSVGgradientData
+{
+ char id[64];
+ char ref[64];
+ char type;
+ union {
+ NSVGlinearData linear;
+ NSVGradialData radial;
+ };
+ char spread;
+ char units;
+ float xform[6];
+ int nstops;
+ NSVGgradientStop* stops;
+ struct NSVGgradientData* next;
+} NSVGgradientData;
+
+typedef struct NSVGattrib
+{
+ char id[64];
+ float xform[6];
+ unsigned int fillColor;
+ unsigned int strokeColor;
+ float opacity;
+ float fillOpacity;
+ float strokeOpacity;
+ char fillGradient[64];
+ char strokeGradient[64];
+ float strokeWidth;
+ float strokeDashOffset;
+ float strokeDashArray[NSVG_MAX_DASHES];
+ int strokeDashCount;
+ char strokeLineJoin;
+ char strokeLineCap;
+ float miterLimit;
+ char fillRule;
+ float fontSize;
+ unsigned int stopColor;
+ float stopOpacity;
+ float stopOffset;
+ char hasFill;
+ char hasStroke;
+ char visible;
+} NSVGattrib;
+
+typedef struct NSVGstyles
+{
+ char* name;
+ char* description;
+ struct NSVGstyles* next;
+} NSVGstyles;
+
+typedef struct NSVGparser
+{
+ NSVGattrib attr[NSVG_MAX_ATTR];
+ int attrHead;
+ float* pts;
+ int npts;
+ int cpts;
+ NSVGpath* plist;
+ NSVGimage* image;
+ NSVGstyles* styles;
+ NSVGgradientData* gradients;
+ NSVGshape* shapesTail;
+ float viewMinx, viewMiny, viewWidth, viewHeight;
+ int alignX, alignY, alignType;
+ float dpi;
+ char pathFlag;
+ char defsFlag;
+ char styleFlag;
+} NSVGparser;
+
+static void nsvg__xformIdentity(float* t)
+{
+ t[0] = 1.0f; t[1] = 0.0f;
+ t[2] = 0.0f; t[3] = 1.0f;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformSetTranslation(float* t, float tx, float ty)
+{
+ t[0] = 1.0f; t[1] = 0.0f;
+ t[2] = 0.0f; t[3] = 1.0f;
+ t[4] = tx; t[5] = ty;
+}
+
+static void nsvg__xformSetScale(float* t, float sx, float sy)
+{
+ t[0] = sx; t[1] = 0.0f;
+ t[2] = 0.0f; t[3] = sy;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformSetSkewX(float* t, float a)
+{
+ t[0] = 1.0f; t[1] = 0.0f;
+ t[2] = tanf(a); t[3] = 1.0f;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformSetSkewY(float* t, float a)
+{
+ t[0] = 1.0f; t[1] = tanf(a);
+ t[2] = 0.0f; t[3] = 1.0f;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformSetRotation(float* t, float a)
+{
+ float cs = cosf(a), sn = sinf(a);
+ t[0] = cs; t[1] = sn;
+ t[2] = -sn; t[3] = cs;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformMultiply(float* t, float* s)
+{
+ float t0 = t[0] * s[0] + t[1] * s[2];
+ float t2 = t[2] * s[0] + t[3] * s[2];
+ float t4 = t[4] * s[0] + t[5] * s[2] + s[4];
+ t[1] = t[0] * s[1] + t[1] * s[3];
+ t[3] = t[2] * s[1] + t[3] * s[3];
+ t[5] = t[4] * s[1] + t[5] * s[3] + s[5];
+ t[0] = t0;
+ t[2] = t2;
+ t[4] = t4;
+}
+
+static void nsvg__xformInverse(float* inv, float* t)
+{
+ double invdet, det = (double)t[0] * t[3] - (double)t[2] * t[1];
+ if (det > -1e-6 && det < 1e-6) {
+ nsvg__xformIdentity(t);
+ return;
+ }
+ invdet = 1.0 / det;
+ inv[0] = (float)(t[3] * invdet);
+ inv[2] = (float)(-t[2] * invdet);
+ inv[4] = (float)(((double)t[2] * t[5] - (double)t[3] * t[4]) * invdet);
+ inv[1] = (float)(-t[1] * invdet);
+ inv[3] = (float)(t[0] * invdet);
+ inv[5] = (float)(((double)t[1] * t[4] - (double)t[0] * t[5]) * invdet);
+}
+
+static void nsvg__xformPremultiply(float* t, float* s)
+{
+ float s2[6];
+ memcpy(s2, s, sizeof(float)*6);
+ nsvg__xformMultiply(s2, t);
+ memcpy(t, s2, sizeof(float)*6);
+}
+
+static void nsvg__xformPoint(float* dx, float* dy, float x, float y, float* t)
+{
+ *dx = x*t[0] + y*t[2] + t[4];
+ *dy = x*t[1] + y*t[3] + t[5];
+}
+
+static void nsvg__xformVec(float* dx, float* dy, float x, float y, float* t)
+{
+ *dx = x*t[0] + y*t[2];
+ *dy = x*t[1] + y*t[3];
+}
+
+#define NSVG_EPSILON (1e-12)
+
+static int nsvg__ptInBounds(float* pt, float* bounds)
+{
+ return pt[0] >= bounds[0] && pt[0] <= bounds[2] && pt[1] >= bounds[1] && pt[1] <= bounds[3];
+}
+
+
+static double nsvg__evalBezier(double t, double p0, double p1, double p2, double p3)
+{
+ double it = 1.0-t;
+ return it*it*it*p0 + 3.0*it*it*t*p1 + 3.0*it*t*t*p2 + t*t*t*p3;
+}
+
+static void nsvg__curveBounds(float* bounds, float* curve)
+{
+ int i, j, count;
+ double roots[2], a, b, c, b2ac, t, v;
+ float* v0 = &curve[0];
+ float* v1 = &curve[2];
+ float* v2 = &curve[4];
+ float* v3 = &curve[6];
+
+ // Start the bounding box by end points
+ bounds[0] = nsvg__minf(v0[0], v3[0]);
+ bounds[1] = nsvg__minf(v0[1], v3[1]);
+ bounds[2] = nsvg__maxf(v0[0], v3[0]);
+ bounds[3] = nsvg__maxf(v0[1], v3[1]);
+
+ // Bezier curve fits inside the convex hull of it's control points.
+ // If control points are inside the bounds, we're done.
+ if (nsvg__ptInBounds(v1, bounds) && nsvg__ptInBounds(v2, bounds))
+ return;
+
+ // Add bezier curve inflection points in X and Y.
+ for (i = 0; i < 2; i++) {
+ a = -3.0 * v0[i] + 9.0 * v1[i] - 9.0 * v2[i] + 3.0 * v3[i];
+ b = 6.0 * v0[i] - 12.0 * v1[i] + 6.0 * v2[i];
+ c = 3.0 * v1[i] - 3.0 * v0[i];
+ count = 0;
+ if (fabs(a) < NSVG_EPSILON) {
+ if (fabs(b) > NSVG_EPSILON) {
+ t = -c / b;
+ if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
+ roots[count++] = t;
+ }
+ } else {
+ b2ac = b*b - 4.0*c*a;
+ if (b2ac > NSVG_EPSILON) {
+ t = (-b + sqrt(b2ac)) / (2.0 * a);
+ if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
+ roots[count++] = t;
+ t = (-b - sqrt(b2ac)) / (2.0 * a);
+ if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
+ roots[count++] = t;
+ }
+ }
+ for (j = 0; j < count; j++) {
+ v = nsvg__evalBezier(roots[j], v0[i], v1[i], v2[i], v3[i]);
+ bounds[0+i] = nsvg__minf(bounds[0+i], (float)v);
+ bounds[2+i] = nsvg__maxf(bounds[2+i], (float)v);
+ }
+ }
+}
+
+static NSVGparser* nsvg__createParser(void)
+{
+ NSVGparser* p;
+ p = (NSVGparser*)NANOSVG_malloc(sizeof(NSVGparser));
+ if (p == NULL) goto error;
+ memset(p, 0, sizeof(NSVGparser));
+
+ p->image = (NSVGimage*)NANOSVG_malloc(sizeof(NSVGimage));
+ if (p->image == NULL) goto error;
+ memset(p->image, 0, sizeof(NSVGimage));
+
+ // Init style
+ nsvg__xformIdentity(p->attr[0].xform);
+ memset(p->attr[0].id, 0, sizeof p->attr[0].id);
+ p->attr[0].fillColor = NSVG_RGB(0,0,0);
+ p->attr[0].strokeColor = NSVG_RGB(0,0,0);
+ p->attr[0].opacity = 1;
+ p->attr[0].fillOpacity = 1;
+ p->attr[0].strokeOpacity = 1;
+ p->attr[0].stopOpacity = 1;
+ p->attr[0].strokeWidth = 1;
+ p->attr[0].strokeLineJoin = NSVG_JOIN_MITER;
+ p->attr[0].strokeLineCap = NSVG_CAP_BUTT;
+ p->attr[0].miterLimit = 4;
+ p->attr[0].fillRule = NSVG_FILLRULE_NONZERO;
+ p->attr[0].hasFill = 1;
+ p->attr[0].visible = NSVG_VIS_DISPLAY | NSVG_VIS_VISIBLE;
+
+ return p;
+
+error:
+ if (p) {
+ if (p->image) NANOSVG_free(p->image);
+ NANOSVG_free(p);
+ }
+ return NULL;
+}
+
+static void nsvg__deleteStyles(NSVGstyles* style) {
+ while (style) {
+ NSVGstyles *next = style->next;
+ if (style->name!= NULL)
+ NANOSVG_free(style->name);
+ if (style->description != NULL)
+ NANOSVG_free(style->description);
+ NANOSVG_free(style);
+ style = next;
+ }
+}
+
+static void nsvg__deletePaths(NSVGpath* path)
+{
+ while (path) {
+ NSVGpath *next = path->next;
+ if (path->pts != NULL)
+ NANOSVG_free(path->pts);
+ NANOSVG_free(path);
+ path = next;
+ }
+}
+
+static void nsvg__deletePaint(NSVGpaint* paint)
+{
+ if (paint->type == NSVG_PAINT_LINEAR_GRADIENT || paint->type == NSVG_PAINT_RADIAL_GRADIENT)
+ NANOSVG_free(paint->gradient);
+}
+
+static void nsvg__deleteGradientData(NSVGgradientData* grad)
+{
+ NSVGgradientData* next;
+ while (grad != NULL) {
+ next = grad->next;
+ NANOSVG_free(grad->stops);
+ NANOSVG_free(grad);
+ grad = next;
+ }
+}
+
+static void nsvg__deleteParser(NSVGparser* p)
+{
+ if (p != NULL) {
+ nsvg__deleteStyles(p->styles);
+ nsvg__deletePaths(p->plist);
+ nsvg__deleteGradientData(p->gradients);
+ nsvgDelete(p->image);
+ NANOSVG_free(p->pts);
+ NANOSVG_free(p);
+ }
+}
+
+static void nsvg__resetPath(NSVGparser* p)
+{
+ p->npts = 0;
+}
+
+static void nsvg__addPoint(NSVGparser* p, float x, float y)
+{
+ if (p->npts+1 > p->cpts) {
+ p->cpts = p->cpts ? p->cpts*2 : 8;
+ p->pts = (float*)NANOSVG_realloc(p->pts, p->cpts*2*sizeof(float));
+ if (!p->pts) return;
+ }
+ p->pts[p->npts*2+0] = x;
+ p->pts[p->npts*2+1] = y;
+ p->npts++;
+}
+
+static void nsvg__moveTo(NSVGparser* p, float x, float y)
+{
+ if (p->npts > 0) {
+ p->pts[(p->npts-1)*2+0] = x;
+ p->pts[(p->npts-1)*2+1] = y;
+ } else {
+ nsvg__addPoint(p, x, y);
+ }
+}
+
+static void nsvg__lineTo(NSVGparser* p, float x, float y)
+{
+ float px,py, dx,dy;
+ if (p->npts > 0) {
+ px = p->pts[(p->npts-1)*2+0];
+ py = p->pts[(p->npts-1)*2+1];
+ dx = x - px;
+ dy = y - py;
+ nsvg__addPoint(p, px + dx/3.0f, py + dy/3.0f);
+ nsvg__addPoint(p, x - dx/3.0f, y - dy/3.0f);
+ nsvg__addPoint(p, x, y);
+ }
+}
+
+static void nsvg__cubicBezTo(NSVGparser* p, float cpx1, float cpy1, float cpx2, float cpy2, float x, float y)
+{
+ nsvg__addPoint(p, cpx1, cpy1);
+ nsvg__addPoint(p, cpx2, cpy2);
+ nsvg__addPoint(p, x, y);
+}
+
+static NSVGattrib* nsvg__getAttr(NSVGparser* p)
+{
+ return &p->attr[p->attrHead];
+}
+
+static void nsvg__pushAttr(NSVGparser* p)
+{
+ if (p->attrHead < NSVG_MAX_ATTR-1) {
+ p->attrHead++;
+ memcpy(&p->attr[p->attrHead], &p->attr[p->attrHead-1], sizeof(NSVGattrib));
+ }
+}
+
+static void nsvg__popAttr(NSVGparser* p)
+{
+ if (p->attrHead > 0)
+ p->attrHead--;
+}
+
+static float nsvg__actualOrigX(NSVGparser* p)
+{
+ return p->viewMinx;
+}
+
+static float nsvg__actualOrigY(NSVGparser* p)
+{
+ return p->viewMiny;
+}
+
+static float nsvg__actualWidth(NSVGparser* p)
+{
+ return p->viewWidth;
+}
+
+static float nsvg__actualHeight(NSVGparser* p)
+{
+ return p->viewHeight;
+}
+
+static float nsvg__actualLength(NSVGparser* p)
+{
+ float w = nsvg__actualWidth(p), h = nsvg__actualHeight(p);
+ return sqrtf(w*w + h*h) / sqrtf(2.0f);
+}
+
+static float nsvg__convertToPixels(NSVGparser* p, NSVGcoordinate c, float orig, float length)
+{
+ NSVGattrib* attr = nsvg__getAttr(p);
+ switch (c.units) {
+ case NSVG_UNITS_USER: return c.value;
+ case NSVG_UNITS_PX: return c.value;
+ case NSVG_UNITS_PT: return c.value / 72.0f * p->dpi;
+ case NSVG_UNITS_PC: return c.value / 6.0f * p->dpi;
+ case NSVG_UNITS_MM: return c.value / 25.4f * p->dpi;
+ case NSVG_UNITS_CM: return c.value / 2.54f * p->dpi;
+ case NSVG_UNITS_IN: return c.value * p->dpi;
+ case NSVG_UNITS_EM: return c.value * attr->fontSize;
+ case NSVG_UNITS_EX: return c.value * attr->fontSize * 0.52f; // x-height of Helvetica.
+ case NSVG_UNITS_PERCENT: return orig + c.value / 100.0f * length;
+ default: return c.value;
+ }
+ return c.value;
+}
+
+static NSVGgradientData* nsvg__findGradientData(NSVGparser* p, const char* id)
+{
+ NSVGgradientData* grad = p->gradients;
+ while (grad) {
+ if (strcmp(grad->id, id) == 0)
+ return grad;
+ grad = grad->next;
+ }
+ return NULL;
+}
+
+static NSVGgradient* nsvg__createGradient(NSVGparser* p, const char* id, const float* localBounds, char* paintType)
+{
+ NSVGattrib* attr = nsvg__getAttr(p);
+ NSVGgradientData* data = NULL;
+ NSVGgradientData* ref = NULL;
+ NSVGgradientStop* stops = NULL;
+ NSVGgradient* grad;
+ float ox, oy, sw, sh, sl;
+ int nstops = 0;
+
+ data = nsvg__findGradientData(p, id);
+ if (data == NULL) return NULL;
+
+ // TODO: use ref to fill in all unset values too.
+ ref = data;
+ while (ref != NULL) {
+ if (stops == NULL && ref->stops != NULL) {
+ stops = ref->stops;
+ nstops = ref->nstops;
+ break;
+ }
+ ref = nsvg__findGradientData(p, ref->ref);
+ }
+ if (stops == NULL) return NULL;
+
+ grad = (NSVGgradient*)NANOSVG_malloc(sizeof(NSVGgradient) + sizeof(NSVGgradientStop)*(nstops-1));
+ if (grad == NULL) return NULL;
+
+ // The shape width and height.
+ if (data->units == NSVG_OBJECT_SPACE) {
+ ox = localBounds[0];
+ oy = localBounds[1];
+ sw = localBounds[2] - localBounds[0];
+ sh = localBounds[3] - localBounds[1];
+ } else {
+ ox = nsvg__actualOrigX(p);
+ oy = nsvg__actualOrigY(p);
+ sw = nsvg__actualWidth(p);
+ sh = nsvg__actualHeight(p);
+ }
+ sl = sqrtf(sw*sw + sh*sh) / sqrtf(2.0f);
+
+ if (data->type == NSVG_PAINT_LINEAR_GRADIENT) {
+ float x1, y1, x2, y2, dx, dy;
+ x1 = nsvg__convertToPixels(p, data->linear.x1, ox, sw);
+ y1 = nsvg__convertToPixels(p, data->linear.y1, oy, sh);
+ x2 = nsvg__convertToPixels(p, data->linear.x2, ox, sw);
+ y2 = nsvg__convertToPixels(p, data->linear.y2, oy, sh);
+ // Calculate transform aligned to the line
+ dx = x2 - x1;
+ dy = y2 - y1;
+ grad->xform[0] = dy; grad->xform[1] = -dx;
+ grad->xform[2] = dx; grad->xform[3] = dy;
+ grad->xform[4] = x1; grad->xform[5] = y1;
+ } else {
+ float cx, cy, fx, fy, r;
+ cx = nsvg__convertToPixels(p, data->radial.cx, ox, sw);
+ cy = nsvg__convertToPixels(p, data->radial.cy, oy, sh);
+ fx = nsvg__convertToPixels(p, data->radial.fx, ox, sw);
+ fy = nsvg__convertToPixels(p, data->radial.fy, oy, sh);
+ r = nsvg__convertToPixels(p, data->radial.r, 0, sl);
+ // Calculate transform aligned to the circle
+ grad->xform[0] = r; grad->xform[1] = 0;
+ grad->xform[2] = 0; grad->xform[3] = r;
+ grad->xform[4] = cx; grad->xform[5] = cy;
+ grad->fx = fx / r;
+ grad->fy = fy / r;
+ }
+
+ nsvg__xformMultiply(grad->xform, data->xform);
+ nsvg__xformMultiply(grad->xform, attr->xform);
+
+ grad->spread = data->spread;
+ memcpy(grad->stops, stops, nstops*sizeof(NSVGgradientStop));
+ grad->nstops = nstops;
+
+ *paintType = data->type;
+
+ return grad;
+}
+
+static float nsvg__getAverageScale(float* t)
+{
+ float sx = sqrtf(t[0]*t[0] + t[2]*t[2]);
+ float sy = sqrtf(t[1]*t[1] + t[3]*t[3]);
+ return (sx + sy) * 0.5f;
+}
+
+static void nsvg__getLocalBounds(float* bounds, NSVGshape *shape, float* xform)
+{
+ NSVGpath* path;
+ float curve[4*2], curveBounds[4];
+ int i, first = 1;
+ for (path = shape->paths; path != NULL; path = path->next) {
+ nsvg__xformPoint(&curve[0], &curve[1], path->pts[0], path->pts[1], xform);
+ for (i = 0; i < path->npts-1; i += 3) {
+ nsvg__xformPoint(&curve[2], &curve[3], path->pts[(i+1)*2], path->pts[(i+1)*2+1], xform);
+ nsvg__xformPoint(&curve[4], &curve[5], path->pts[(i+2)*2], path->pts[(i+2)*2+1], xform);
+ nsvg__xformPoint(&curve[6], &curve[7], path->pts[(i+3)*2], path->pts[(i+3)*2+1], xform);
+ nsvg__curveBounds(curveBounds, curve);
+ if (first) {
+ bounds[0] = curveBounds[0];
+ bounds[1] = curveBounds[1];
+ bounds[2] = curveBounds[2];
+ bounds[3] = curveBounds[3];
+ first = 0;
+ } else {
+ bounds[0] = nsvg__minf(bounds[0], curveBounds[0]);
+ bounds[1] = nsvg__minf(bounds[1], curveBounds[1]);
+ bounds[2] = nsvg__maxf(bounds[2], curveBounds[2]);
+ bounds[3] = nsvg__maxf(bounds[3], curveBounds[3]);
+ }
+ curve[0] = curve[6];
+ curve[1] = curve[7];
+ }
+ }
+}
+
+static void nsvg__addShape(NSVGparser* p)
+{
+ NSVGattrib* attr = nsvg__getAttr(p);
+ float scale = 1.0f;
+ NSVGshape* shape;
+ NSVGpath* path;
+ int i;
+
+ if (p->plist == NULL)
+ return;
+
+ shape = (NSVGshape*)NANOSVG_malloc(sizeof(NSVGshape));
+ if (shape == NULL) goto error;
+ memset(shape, 0, sizeof(NSVGshape));
+
+ memcpy(shape->id, attr->id, sizeof shape->id);
+ scale = nsvg__getAverageScale(attr->xform);
+ shape->strokeWidth = attr->strokeWidth * scale;
+ shape->strokeDashOffset = attr->strokeDashOffset * scale;
+ shape->strokeDashCount = (char)attr->strokeDashCount;
+ for (i = 0; i < attr->strokeDashCount; i++)
+ shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale;
+ shape->strokeLineJoin = attr->strokeLineJoin;
+ shape->strokeLineCap = attr->strokeLineCap;
+ shape->miterLimit = attr->miterLimit;
+ shape->fillRule = attr->fillRule;
+ shape->opacity = attr->opacity;
+
+ shape->paths = p->plist;
+ p->plist = NULL;
+
+ // Calculate shape bounds
+ shape->bounds[0] = shape->paths->bounds[0];
+ shape->bounds[1] = shape->paths->bounds[1];
+ shape->bounds[2] = shape->paths->bounds[2];
+ shape->bounds[3] = shape->paths->bounds[3];
+ for (path = shape->paths->next; path != NULL; path = path->next) {
+ shape->bounds[0] = nsvg__minf(shape->bounds[0], path->bounds[0]);
+ shape->bounds[1] = nsvg__minf(shape->bounds[1], path->bounds[1]);
+ shape->bounds[2] = nsvg__maxf(shape->bounds[2], path->bounds[2]);
+ shape->bounds[3] = nsvg__maxf(shape->bounds[3], path->bounds[3]);
+ }
+
+ // Set fill
+ if (attr->hasFill == 0) {
+ shape->fill.type = NSVG_PAINT_NONE;
+ } else if (attr->hasFill == 1) {
+ shape->fill.type = NSVG_PAINT_COLOR;
+ shape->fill.color = attr->fillColor;
+ shape->fill.color |= (unsigned int)(attr->fillOpacity*255) << 24;
+ } else if (attr->hasFill == 2) {
+ float inv[6], localBounds[4];
+ nsvg__xformInverse(inv, attr->xform);
+ nsvg__getLocalBounds(localBounds, shape, inv);
+ shape->fill.gradient = nsvg__createGradient(p, attr->fillGradient, localBounds, &shape->fill.type);
+ if (shape->fill.gradient == NULL) {
+ shape->fill.type = NSVG_PAINT_NONE;
+ }
+ }
+
+ // Set stroke
+ if (attr->hasStroke == 0) {
+ shape->stroke.type = NSVG_PAINT_NONE;
+ } else if (attr->hasStroke == 1) {
+ shape->stroke.type = NSVG_PAINT_COLOR;
+ shape->stroke.color = attr->strokeColor;
+ shape->stroke.color |= (unsigned int)(attr->strokeOpacity*255) << 24;
+ } else if (attr->hasStroke == 2) {
+ float inv[6], localBounds[4];
+ nsvg__xformInverse(inv, attr->xform);
+ nsvg__getLocalBounds(localBounds, shape, inv);
+ shape->stroke.gradient = nsvg__createGradient(p, attr->strokeGradient, localBounds, &shape->stroke.type);
+ if (shape->stroke.gradient == NULL)
+ shape->stroke.type = NSVG_PAINT_NONE;
+ }
+
+ // Set flags
+ shape->flags = ((attr->visible & NSVG_VIS_DISPLAY) && (attr->visible & NSVG_VIS_VISIBLE) ? NSVG_FLAGS_VISIBLE : 0x00);
+
+ // Add to tail
+ if (p->image->shapes == NULL)
+ p->image->shapes = shape;
+ else
+ p->shapesTail->next = shape;
+ p->shapesTail = shape;
+
+ return;
+
+error:
+ if (shape) NANOSVG_free(shape);
+}
+
+static void nsvg__addPath(NSVGparser* p, char closed)
+{
+ NSVGattrib* attr = nsvg__getAttr(p);
+ NSVGpath* path = NULL;
+ float bounds[4];
+ float* curve;
+ int i;
+
+ if (p->npts < 4)
+ return;
+
+ if (closed)
+ nsvg__lineTo(p, p->pts[0], p->pts[1]);
+
+ path = (NSVGpath*)NANOSVG_malloc(sizeof(NSVGpath));
+ if (path == NULL) goto error;
+ memset(path, 0, sizeof(NSVGpath));
+
+ path->pts = (float*)NANOSVG_malloc(p->npts*2*sizeof(float));
+ if (path->pts == NULL) goto error;
+ path->closed = closed;
+ path->npts = p->npts;
+
+ // Transform path.
+ for (i = 0; i < p->npts; ++i)
+ nsvg__xformPoint(&path->pts[i*2], &path->pts[i*2+1], p->pts[i*2], p->pts[i*2+1], attr->xform);
+
+ // Find bounds
+ for (i = 0; i < path->npts-1; i += 3) {
+ curve = &path->pts[i*2];
+ nsvg__curveBounds(bounds, curve);
+ if (i == 0) {
+ path->bounds[0] = bounds[0];
+ path->bounds[1] = bounds[1];
+ path->bounds[2] = bounds[2];
+ path->bounds[3] = bounds[3];
+ } else {
+ path->bounds[0] = nsvg__minf(path->bounds[0], bounds[0]);
+ path->bounds[1] = nsvg__minf(path->bounds[1], bounds[1]);
+ path->bounds[2] = nsvg__maxf(path->bounds[2], bounds[2]);
+ path->bounds[3] = nsvg__maxf(path->bounds[3], bounds[3]);
+ }
+ }
+
+ path->next = p->plist;
+ p->plist = path;
+
+ return;
+
+error:
+ if (path != NULL) {
+ if (path->pts != NULL) NANOSVG_free(path->pts);
+ NANOSVG_free(path);
+ }
+}
+
+// We roll our own string to float because the std library one uses locale and messes things up.
+static double nsvg__atof(const char* s)
+{
+ char* cur = (char*)s;
+ char* end = NULL;
+ double res = 0.0, sign = 1.0;
+#if (_MSC_VER == 1200)
+ __int64 intPart = 0, fracPart = 0;
+#else
+ long long intPart = 0, fracPart = 0;
+#endif
+ char hasIntPart = 0, hasFracPart = 0;
+
+ // Parse optional sign
+ if (*cur == '+') {
+ cur++;
+ } else if (*cur == '-') {
+ sign = -1;
+ cur++;
+ }
+
+ // Parse integer part
+ if (nsvg__isdigit(*cur)) {
+ // Parse digit sequence
+#if (_MSC_VER == 1200)
+ intPart = strtol(cur, &end, 10);
+#else
+ intPart = strtoll(cur, &end, 10);
+#endif
+ if (cur != end) {
+ res = (double)intPart;
+ hasIntPart = 1;
+ cur = end;
+ }
+ }
+
+ // Parse fractional part.
+ if (*cur == '.') {
+ cur++; // Skip '.'
+ if (nsvg__isdigit(*cur)) {
+ // Parse digit sequence
+#if (_MSC_VER == 1200)
+ fracPart = strtol(cur, &end, 10);
+#else
+ fracPart = strtoll(cur, &end, 10);
+#endif
+ if (cur != end) {
+ res += (double)fracPart / pow(10.0, (double)(end - cur));
+ hasFracPart = 1;
+ cur = end;
+ }
+ }
+ }
+
+ // A valid number should have integer or fractional part.
+ if (!hasIntPart && !hasFracPart)
+ return 0.0;
+
+ // Parse optional exponent
+ if (*cur == 'e' || *cur == 'E') {
+ int expPart = 0;
+ cur++; // skip 'E'
+ expPart = strtol(cur, &end, 10); // Parse digit sequence with sign
+ if (cur != end) {
+ res *= pow(10.0, (double)expPart);
+ }
+ }
+
+ return res * sign;
+}
+
+
+static const char* nsvg__parseNumber(const char* s, char* it, const int size)
+{
+ const int last = size-1;
+ int i = 0;
+
+ // sign
+ if (*s == '-' || *s == '+') {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ // integer part
+ while (*s && nsvg__isdigit(*s)) {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ if (*s == '.') {
+ // decimal point
+ if (i < last) it[i++] = *s;
+ s++;
+ // fraction part
+ while (*s && nsvg__isdigit(*s)) {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ }
+ // exponent
+ if (*s == 'e' || *s == 'E') {
+ if (i < last) it[i++] = *s;
+ s++;
+ if (*s == '-' || *s == '+') {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ while (*s && nsvg__isdigit(*s)) {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ }
+ it[i] = '\0';
+
+ return s;
+}
+
+static const char* nsvg__getNextPathItem(const char* s, char* it)
+{
+ it[0] = '\0';
+ // Skip white spaces and commas
+ while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
+ if (!*s) return s;
+ if (*s == '-' || *s == '+' || *s == '.' || nsvg__isdigit(*s)) {
+ s = nsvg__parseNumber(s, it, 64);
+ } else {
+ // Parse command
+ it[0] = *s++;
+ it[1] = '\0';
+ return s;
+ }
+
+ return s;
+}
+
+static unsigned int nsvg__parseColorHex(const char* str)
+{
+ unsigned int c = 0, r = 0, g = 0, b = 0;
+ int n = 0;
+ str++; // skip #
+ // Calculate number of characters.
+ while(str[n] && !nsvg__isspace(str[n]))
+ n++;
+ if (n == 6) {
+ sscanf(str, "%x", &c);
+ } else if (n == 3) {
+ sscanf(str, "%x", &c);
+ c = (c&0xf) | ((c&0xf0) << 4) | ((c&0xf00) << 8);
+ c |= c<<4;
+ }
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = c & 0xff;
+ return NSVG_RGB(r,g,b);
+}
+
+static unsigned int nsvg__parseColorRGB(const char* str)
+{
+ int r = -1, g = -1, b = -1;
+ char s1[32]="", s2[32]="";
+ sscanf(str + 4, "%d%[%%, \t]%d%[%%, \t]%d", &r, s1, &g, s2, &b);
+ if (strchr(s1, '%')) {
+ return NSVG_RGB((r*255)/100,(g*255)/100,(b*255)/100);
+ } else {
+ return NSVG_RGB(r,g,b);
+ }
+}
+
+typedef struct NSVGNamedColor {
+ const char* name;
+ unsigned int color;
+} NSVGNamedColor;
+
+NSVGNamedColor nsvg__colors[] = {
+
+ { "red", NSVG_RGB(255, 0, 0) },
+ { "green", NSVG_RGB( 0, 128, 0) },
+ { "blue", NSVG_RGB( 0, 0, 255) },
+ { "yellow", NSVG_RGB(255, 255, 0) },
+ { "cyan", NSVG_RGB( 0, 255, 255) },
+ { "magenta", NSVG_RGB(255, 0, 255) },
+ { "black", NSVG_RGB( 0, 0, 0) },
+ { "grey", NSVG_RGB(128, 128, 128) },
+ { "gray", NSVG_RGB(128, 128, 128) },
+ { "white", NSVG_RGB(255, 255, 255) },
+
+#ifdef NANOSVG_ALL_COLOR_KEYWORDS
+ { "aliceblue", NSVG_RGB(240, 248, 255) },
+ { "antiquewhite", NSVG_RGB(250, 235, 215) },
+ { "aqua", NSVG_RGB( 0, 255, 255) },
+ { "aquamarine", NSVG_RGB(127, 255, 212) },
+ { "azure", NSVG_RGB(240, 255, 255) },
+ { "beige", NSVG_RGB(245, 245, 220) },
+ { "bisque", NSVG_RGB(255, 228, 196) },
+ { "blanchedalmond", NSVG_RGB(255, 235, 205) },
+ { "blueviolet", NSVG_RGB(138, 43, 226) },
+ { "brown", NSVG_RGB(165, 42, 42) },
+ { "burlywood", NSVG_RGB(222, 184, 135) },
+ { "cadetblue", NSVG_RGB( 95, 158, 160) },
+ { "chartreuse", NSVG_RGB(127, 255, 0) },
+ { "chocolate", NSVG_RGB(210, 105, 30) },
+ { "coral", NSVG_RGB(255, 127, 80) },
+ { "cornflowerblue", NSVG_RGB(100, 149, 237) },
+ { "cornsilk", NSVG_RGB(255, 248, 220) },
+ { "crimson", NSVG_RGB(220, 20, 60) },
+ { "darkblue", NSVG_RGB( 0, 0, 139) },
+ { "darkcyan", NSVG_RGB( 0, 139, 139) },
+ { "darkgoldenrod", NSVG_RGB(184, 134, 11) },
+ { "darkgray", NSVG_RGB(169, 169, 169) },
+ { "darkgreen", NSVG_RGB( 0, 100, 0) },
+ { "darkgrey", NSVG_RGB(169, 169, 169) },
+ { "darkkhaki", NSVG_RGB(189, 183, 107) },
+ { "darkmagenta", NSVG_RGB(139, 0, 139) },
+ { "darkolivegreen", NSVG_RGB( 85, 107, 47) },
+ { "darkorange", NSVG_RGB(255, 140, 0) },
+ { "darkorchid", NSVG_RGB(153, 50, 204) },
+ { "darkred", NSVG_RGB(139, 0, 0) },
+ { "darksalmon", NSVG_RGB(233, 150, 122) },
+ { "darkseagreen", NSVG_RGB(143, 188, 143) },
+ { "darkslateblue", NSVG_RGB( 72, 61, 139) },
+ { "darkslategray", NSVG_RGB( 47, 79, 79) },
+ { "darkslategrey", NSVG_RGB( 47, 79, 79) },
+ { "darkturquoise", NSVG_RGB( 0, 206, 209) },
+ { "darkviolet", NSVG_RGB(148, 0, 211) },
+ { "deeppink", NSVG_RGB(255, 20, 147) },
+ { "deepskyblue", NSVG_RGB( 0, 191, 255) },
+ { "dimgray", NSVG_RGB(105, 105, 105) },
+ { "dimgrey", NSVG_RGB(105, 105, 105) },
+ { "dodgerblue", NSVG_RGB( 30, 144, 255) },
+ { "firebrick", NSVG_RGB(178, 34, 34) },
+ { "floralwhite", NSVG_RGB(255, 250, 240) },
+ { "forestgreen", NSVG_RGB( 34, 139, 34) },
+ { "fuchsia", NSVG_RGB(255, 0, 255) },
+ { "gainsboro", NSVG_RGB(220, 220, 220) },
+ { "ghostwhite", NSVG_RGB(248, 248, 255) },
+ { "gold", NSVG_RGB(255, 215, 0) },
+ { "goldenrod", NSVG_RGB(218, 165, 32) },
+ { "greenyellow", NSVG_RGB(173, 255, 47) },
+ { "honeydew", NSVG_RGB(240, 255, 240) },
+ { "hotpink", NSVG_RGB(255, 105, 180) },
+ { "indianred", NSVG_RGB(205, 92, 92) },
+ { "indigo", NSVG_RGB( 75, 0, 130) },
+ { "ivory", NSVG_RGB(255, 255, 240) },
+ { "khaki", NSVG_RGB(240, 230, 140) },
+ { "lavender", NSVG_RGB(230, 230, 250) },
+ { "lavenderblush", NSVG_RGB(255, 240, 245) },
+ { "lawngreen", NSVG_RGB(124, 252, 0) },
+ { "lemonchiffon", NSVG_RGB(255, 250, 205) },
+ { "lightblue", NSVG_RGB(173, 216, 230) },
+ { "lightcoral", NSVG_RGB(240, 128, 128) },
+ { "lightcyan", NSVG_RGB(224, 255, 255) },
+ { "lightgoldenrodyellow", NSVG_RGB(250, 250, 210) },
+ { "lightgray", NSVG_RGB(211, 211, 211) },
+ { "lightgreen", NSVG_RGB(144, 238, 144) },
+ { "lightgrey", NSVG_RGB(211, 211, 211) },
+ { "lightpink", NSVG_RGB(255, 182, 193) },
+ { "lightsalmon", NSVG_RGB(255, 160, 122) },
+ { "lightseagreen", NSVG_RGB( 32, 178, 170) },
+ { "lightskyblue", NSVG_RGB(135, 206, 250) },
+ { "lightslategray", NSVG_RGB(119, 136, 153) },
+ { "lightslategrey", NSVG_RGB(119, 136, 153) },
+ { "lightsteelblue", NSVG_RGB(176, 196, 222) },
+ { "lightyellow", NSVG_RGB(255, 255, 224) },
+ { "lime", NSVG_RGB( 0, 255, 0) },
+ { "limegreen", NSVG_RGB( 50, 205, 50) },
+ { "linen", NSVG_RGB(250, 240, 230) },
+ { "maroon", NSVG_RGB(128, 0, 0) },
+ { "mediumaquamarine", NSVG_RGB(102, 205, 170) },
+ { "mediumblue", NSVG_RGB( 0, 0, 205) },
+ { "mediumorchid", NSVG_RGB(186, 85, 211) },
+ { "mediumpurple", NSVG_RGB(147, 112, 219) },
+ { "mediumseagreen", NSVG_RGB( 60, 179, 113) },
+ { "mediumslateblue", NSVG_RGB(123, 104, 238) },
+ { "mediumspringgreen", NSVG_RGB( 0, 250, 154) },
+ { "mediumturquoise", NSVG_RGB( 72, 209, 204) },
+ { "mediumvioletred", NSVG_RGB(199, 21, 133) },
+ { "midnightblue", NSVG_RGB( 25, 25, 112) },
+ { "mintcream", NSVG_RGB(245, 255, 250) },
+ { "mistyrose", NSVG_RGB(255, 228, 225) },
+ { "moccasin", NSVG_RGB(255, 228, 181) },
+ { "navajowhite", NSVG_RGB(255, 222, 173) },
+ { "navy", NSVG_RGB( 0, 0, 128) },
+ { "oldlace", NSVG_RGB(253, 245, 230) },
+ { "olive", NSVG_RGB(128, 128, 0) },
+ { "olivedrab", NSVG_RGB(107, 142, 35) },
+ { "orange", NSVG_RGB(255, 165, 0) },
+ { "orangered", NSVG_RGB(255, 69, 0) },
+ { "orchid", NSVG_RGB(218, 112, 214) },
+ { "palegoldenrod", NSVG_RGB(238, 232, 170) },
+ { "palegreen", NSVG_RGB(152, 251, 152) },
+ { "paleturquoise", NSVG_RGB(175, 238, 238) },
+ { "palevioletred", NSVG_RGB(219, 112, 147) },
+ { "papayawhip", NSVG_RGB(255, 239, 213) },
+ { "peachpuff", NSVG_RGB(255, 218, 185) },
+ { "peru", NSVG_RGB(205, 133, 63) },
+ { "pink", NSVG_RGB(255, 192, 203) },
+ { "plum", NSVG_RGB(221, 160, 221) },
+ { "powderblue", NSVG_RGB(176, 224, 230) },
+ { "purple", NSVG_RGB(128, 0, 128) },
+ { "rosybrown", NSVG_RGB(188, 143, 143) },
+ { "royalblue", NSVG_RGB( 65, 105, 225) },
+ { "saddlebrown", NSVG_RGB(139, 69, 19) },
+ { "salmon", NSVG_RGB(250, 128, 114) },
+ { "sandybrown", NSVG_RGB(244, 164, 96) },
+ { "seagreen", NSVG_RGB( 46, 139, 87) },
+ { "seashell", NSVG_RGB(255, 245, 238) },
+ { "sienna", NSVG_RGB(160, 82, 45) },
+ { "silver", NSVG_RGB(192, 192, 192) },
+ { "skyblue", NSVG_RGB(135, 206, 235) },
+ { "slateblue", NSVG_RGB(106, 90, 205) },
+ { "slategray", NSVG_RGB(112, 128, 144) },
+ { "slategrey", NSVG_RGB(112, 128, 144) },
+ { "snow", NSVG_RGB(255, 250, 250) },
+ { "springgreen", NSVG_RGB( 0, 255, 127) },
+ { "steelblue", NSVG_RGB( 70, 130, 180) },
+ { "tan", NSVG_RGB(210, 180, 140) },
+ { "teal", NSVG_RGB( 0, 128, 128) },
+ { "thistle", NSVG_RGB(216, 191, 216) },
+ { "tomato", NSVG_RGB(255, 99, 71) },
+ { "turquoise", NSVG_RGB( 64, 224, 208) },
+ { "violet", NSVG_RGB(238, 130, 238) },
+ { "wheat", NSVG_RGB(245, 222, 179) },
+ { "whitesmoke", NSVG_RGB(245, 245, 245) },
+ { "yellowgreen", NSVG_RGB(154, 205, 50) },
+#endif
+};
+
+static unsigned int nsvg__parseColorName(const char* str)
+{
+ int i, ncolors = sizeof(nsvg__colors) / sizeof(NSVGNamedColor);
+
+ for (i = 0; i < ncolors; i++) {
+ if (strcmp(nsvg__colors[i].name, str) == 0) {
+ return nsvg__colors[i].color;
+ }
+ }
+
+ return NSVG_RGB(128, 128, 128);
+}
+
+static unsigned int nsvg__parseColor(const char* str)
+{
+ size_t len = 0;
+ while(*str == ' ') ++str;
+ len = strlen(str);
+ if (len >= 1 && *str == '#')
+ return nsvg__parseColorHex(str);
+ else if (len >= 4 && str[0] == 'r' && str[1] == 'g' && str[2] == 'b' && str[3] == '(')
+ return nsvg__parseColorRGB(str);
+ return nsvg__parseColorName(str);
+}
+
+static float nsvg__parseOpacity(const char* str)
+{
+ float val = 0;
+ sscanf(str, "%f", &val);
+ if (val < 0.0f) val = 0.0f;
+ if (val > 1.0f) val = 1.0f;
+ return val;
+}
+
+static float nsvg__parseMiterLimit(const char* str)
+{
+ float val = 0;
+ sscanf(str, "%f", &val);
+ if (val < 0.0f) val = 0.0f;
+ return val;
+}
+
+static int nsvg__parseUnits(const char* units)
+{
+ if (units[0] == 'p' && units[1] == 'x')
+ return NSVG_UNITS_PX;
+ else if (units[0] == 'p' && units[1] == 't')
+ return NSVG_UNITS_PT;
+ else if (units[0] == 'p' && units[1] == 'c')
+ return NSVG_UNITS_PC;
+ else if (units[0] == 'm' && units[1] == 'm')
+ return NSVG_UNITS_MM;
+ else if (units[0] == 'c' && units[1] == 'm')
+ return NSVG_UNITS_CM;
+ else if (units[0] == 'i' && units[1] == 'n')
+ return NSVG_UNITS_IN;
+ else if (units[0] == '%')
+ return NSVG_UNITS_PERCENT;
+ else if (units[0] == 'e' && units[1] == 'm')
+ return NSVG_UNITS_EM;
+ else if (units[0] == 'e' && units[1] == 'x')
+ return NSVG_UNITS_EX;
+ return NSVG_UNITS_USER;
+}
+
+static NSVGcoordinate nsvg__parseCoordinateRaw(const char* str)
+{
+ NSVGcoordinate coord = {0, NSVG_UNITS_USER};
+ char units[32]="";
+ sscanf(str, "%f%s", &coord.value, units);
+ coord.units = nsvg__parseUnits(units);
+ return coord;
+}
+
+static NSVGcoordinate nsvg__coord(float v, int units)
+{
+ NSVGcoordinate coord = {v, units};
+ return coord;
+}
+
+static float nsvg__parseCoordinate(NSVGparser* p, const char* str, float orig, float length)
+{
+ NSVGcoordinate coord = nsvg__parseCoordinateRaw(str);
+ return nsvg__convertToPixels(p, coord, orig, length);
+}
+
+static int nsvg__parseTransformArgs(const char* str, float* args, int maxNa, int* na)
+{
+ const char* end;
+ const char* ptr;
+ char it[64];
+
+ *na = 0;
+ ptr = str;
+ while (*ptr && *ptr != '(') ++ptr;
+ if (*ptr == 0)
+ return 1;
+ end = ptr;
+ while (*end && *end != ')') ++end;
+ if (*end == 0)
+ return 1;
+
+ while (ptr < end) {
+ if (*ptr == '-' || *ptr == '+' || *ptr == '.' || nsvg__isdigit(*ptr)) {
+ if (*na >= maxNa) return 0;
+ ptr = nsvg__parseNumber(ptr, it, 64);
+ args[(*na)++] = (float)nsvg__atof(it);
+ } else {
+ ++ptr;
+ }
+ }
+ return (int)(end - str);
+}
+
+
+static int nsvg__parseMatrix(float* xform, const char* str)
+{
+ float t[6];
+ int na = 0;
+ int len = nsvg__parseTransformArgs(str, t, 6, &na);
+ if (na != 6) return len;
+ memcpy(xform, t, sizeof(float)*6);
+ return len;
+}
+
+static int nsvg__parseTranslate(float* xform, const char* str)
+{
+ float args[2];
+ float t[6];
+ int na = 0;
+ int len = nsvg__parseTransformArgs(str, args, 2, &na);
+ if (na == 1) args[1] = 0.0;
+
+ nsvg__xformSetTranslation(t, args[0], args[1]);
+ memcpy(xform, t, sizeof(float)*6);
+ return len;
+}
+
+static int nsvg__parseScale(float* xform, const char* str)
+{
+ float args[2];
+ int na = 0;
+ float t[6];
+ int len = nsvg__parseTransformArgs(str, args, 2, &na);
+ if (na == 1) args[1] = args[0];
+ nsvg__xformSetScale(t, args[0], args[1]);
+ memcpy(xform, t, sizeof(float)*6);
+ return len;
+}
+
+static int nsvg__parseSkewX(float* xform, const char* str)
+{
+ float args[1];
+ int na = 0;
+ float t[6];
+ int len = nsvg__parseTransformArgs(str, args, 1, &na);
+ nsvg__xformSetSkewX(t, args[0]/180.0f*NSVG_PI);
+ memcpy(xform, t, sizeof(float)*6);
+ return len;
+}
+
+static int nsvg__parseSkewY(float* xform, const char* str)
+{
+ float args[1];
+ int na = 0;
+ float t[6];
+ int len = nsvg__parseTransformArgs(str, args, 1, &na);
+ nsvg__xformSetSkewY(t, args[0]/180.0f*NSVG_PI);
+ memcpy(xform, t, sizeof(float)*6);
+ return len;
+}
+
+static int nsvg__parseRotate(float* xform, const char* str)
+{
+ float args[3];
+ int na = 0;
+ float m[6];
+ float t[6];
+ int len = nsvg__parseTransformArgs(str, args, 3, &na);
+ if (na == 1)
+ args[1] = args[2] = 0.0f;
+ nsvg__xformIdentity(m);
+
+ if (na > 1) {
+ nsvg__xformSetTranslation(t, -args[1], -args[2]);
+ nsvg__xformMultiply(m, t);
+ }
+
+ nsvg__xformSetRotation(t, args[0]/180.0f*NSVG_PI);
+ nsvg__xformMultiply(m, t);
+
+ if (na > 1) {
+ nsvg__xformSetTranslation(t, args[1], args[2]);
+ nsvg__xformMultiply(m, t);
+ }
+
+ memcpy(xform, m, sizeof(float)*6);
+
+ return len;
+}
+
+static void nsvg__parseTransform(float* xform, const char* str)
+{
+ float t[6];
+ nsvg__xformIdentity(xform);
+ while (*str)
+ {
+ if (strncmp(str, "matrix", 6) == 0)
+ str += nsvg__parseMatrix(t, str);
+ else if (strncmp(str, "translate", 9) == 0)
+ str += nsvg__parseTranslate(t, str);
+ else if (strncmp(str, "scale", 5) == 0)
+ str += nsvg__parseScale(t, str);
+ else if (strncmp(str, "rotate", 6) == 0)
+ str += nsvg__parseRotate(t, str);
+ else if (strncmp(str, "skewX", 5) == 0)
+ str += nsvg__parseSkewX(t, str);
+ else if (strncmp(str, "skewY", 5) == 0)
+ str += nsvg__parseSkewY(t, str);
+ else{
+ ++str;
+ continue;
+ }
+
+ nsvg__xformPremultiply(xform, t);
+ }
+}
+
+static void nsvg__parseUrl(char* id, const char* str)
+{
+ int i = 0;
+ str += 4; // "url(";
+ if (*str == '#')
+ str++;
+ while (i < 63 && *str != ')') {
+ id[i] = *str++;
+ i++;
+ }
+ id[i] = '\0';
+}
+
+static char nsvg__parseLineCap(const char* str)
+{
+ if (strcmp(str, "butt") == 0)
+ return NSVG_CAP_BUTT;
+ else if (strcmp(str, "round") == 0)
+ return NSVG_CAP_ROUND;
+ else if (strcmp(str, "square") == 0)
+ return NSVG_CAP_SQUARE;
+ // TODO: handle inherit.
+ return NSVG_CAP_BUTT;
+}
+
+static char nsvg__parseLineJoin(const char* str)
+{
+ if (strcmp(str, "miter") == 0)
+ return NSVG_JOIN_MITER;
+ else if (strcmp(str, "round") == 0)
+ return NSVG_JOIN_ROUND;
+ else if (strcmp(str, "bevel") == 0)
+ return NSVG_JOIN_BEVEL;
+ // TODO: handle inherit.
+ return NSVG_JOIN_MITER;
+}
+
+static char nsvg__parseFillRule(const char* str)
+{
+ if (strcmp(str, "nonzero") == 0)
+ return NSVG_FILLRULE_NONZERO;
+ else if (strcmp(str, "evenodd") == 0)
+ return NSVG_FILLRULE_EVENODD;
+ // TODO: handle inherit.
+ return NSVG_FILLRULE_NONZERO;
+}
+
+static const char* nsvg__getNextDashItem(const char* s, char* it)
+{
+ int n = 0;
+ it[0] = '\0';
+ // Skip white spaces and commas
+ while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
+ // Advance until whitespace, comma or end.
+ while (*s && (!nsvg__isspace(*s) && *s != ',')) {
+ if (n < 63)
+ it[n++] = *s;
+ s++;
+ }
+ it[n++] = '\0';
+ return s;
+}
+
+static int nsvg__parseStrokeDashArray(NSVGparser* p, const char* str, float* strokeDashArray)
+{
+ char item[64];
+ int count = 0, i;
+ float sum = 0.0f;
+
+ // Handle "none"
+ if (str[0] == 'n')
+ return 0;
+
+ // Parse dashes
+ while (*str) {
+ str = nsvg__getNextDashItem(str, item);
+ if (!*item) break;
+ if (count < NSVG_MAX_DASHES)
+ strokeDashArray[count++] = fabsf(nsvg__parseCoordinate(p, item, 0.0f, nsvg__actualLength(p)));
+ }
+
+ for (i = 0; i < count; i++)
+ sum += strokeDashArray[i];
+ if (sum <= 1e-6f)
+ count = 0;
+
+ return count;
+}
+
+static void nsvg__parseStyle(NSVGparser* p, const char* str);
+
+static int nsvg__parseAttr(NSVGparser* p, const char* name, const char* value)
+{
+ float xform[6];
+ NSVGattrib* attr = nsvg__getAttr(p);
+ if (!attr) return 0;
+
+ if (strcmp(name, "style") == 0) {
+ nsvg__parseStyle(p, value);
+ } else if (strcmp(name, "display") == 0) {
+ if (strcmp(value, "none") == 0)
+ attr->visible &= ~NSVG_VIS_DISPLAY;
+ // Don't reset ->visible on display:inline, one display:none hides the whole subtree
+
+ } else if (strcmp(name, "visibility") == 0) {
+ if (strcmp(value, "hidden") == 0) {
+ attr->visible &= ~NSVG_VIS_VISIBLE;
+ } else if (strcmp(value, "visible") == 0) {
+ attr->visible |= NSVG_VIS_VISIBLE;
+ }
+ } else if (strcmp(name, "fill") == 0) {
+ if (strcmp(value, "none") == 0) {
+ attr->hasFill = 0;
+ } else if (strncmp(value, "url(", 4) == 0) {
+ attr->hasFill = 2;
+ nsvg__parseUrl(attr->fillGradient, value);
+ } else {
+ attr->hasFill = 1;
+ attr->fillColor = nsvg__parseColor(value);
+ }
+ } else if (strcmp(name, "opacity") == 0) {
+ attr->opacity = nsvg__parseOpacity(value);
+ } else if (strcmp(name, "fill-opacity") == 0) {
+ attr->fillOpacity = nsvg__parseOpacity(value);
+ } else if (strcmp(name, "stroke") == 0) {
+ if (strcmp(value, "none") == 0) {
+ attr->hasStroke = 0;
+ } else if (strncmp(value, "url(", 4) == 0) {
+ attr->hasStroke = 2;
+ nsvg__parseUrl(attr->strokeGradient, value);
+ } else {
+ attr->hasStroke = 1;
+ attr->strokeColor = nsvg__parseColor(value);
+ }
+ } else if (strcmp(name, "stroke-width") == 0) {
+ attr->strokeWidth = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
+ } else if (strcmp(name, "stroke-dasharray") == 0) {
+ attr->strokeDashCount = nsvg__parseStrokeDashArray(p, value, attr->strokeDashArray);
+ } else if (strcmp(name, "stroke-dashoffset") == 0) {
+ attr->strokeDashOffset = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
+ } else if (strcmp(name, "stroke-opacity") == 0) {
+ attr->strokeOpacity = nsvg__parseOpacity(value);
+ } else if (strcmp(name, "stroke-linecap") == 0) {
+ attr->strokeLineCap = nsvg__parseLineCap(value);
+ } else if (strcmp(name, "stroke-linejoin") == 0) {
+ attr->strokeLineJoin = nsvg__parseLineJoin(value);
+ } else if (strcmp(name, "stroke-miterlimit") == 0) {
+ attr->miterLimit = nsvg__parseMiterLimit(value);
+ } else if (strcmp(name, "fill-rule") == 0) {
+ attr->fillRule = nsvg__parseFillRule(value);
+ } else if (strcmp(name, "font-size") == 0) {
+ attr->fontSize = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
+ } else if (strcmp(name, "transform") == 0) {
+ nsvg__parseTransform(xform, value);
+ nsvg__xformPremultiply(attr->xform, xform);
+ } else if (strcmp(name, "stop-color") == 0) {
+ attr->stopColor = nsvg__parseColor(value);
+ } else if (strcmp(name, "stop-opacity") == 0) {
+ attr->stopOpacity = nsvg__parseOpacity(value);
+ } else if (strcmp(name, "offset") == 0) {
+ attr->stopOffset = nsvg__parseCoordinate(p, value, 0.0f, 1.0f);
+ } else if (strcmp(name, "id") == 0) {
+ strncpy(attr->id, value, 63);
+ attr->id[63] = '\0';
+ } else if (strcmp(name, "class") == 0) {
+ NSVGstyles* style = p->styles;
+ while (style) {
+ if (strcmp(style->name + 1, value) == 0) {
+ break;
+ }
+ style = style->next;
+ }
+ if (style) {
+ nsvg__parseStyle(p, style->description);
+ }
+ } else {
+ return 0;
+ }
+ return 1;
+}
+
+static int nsvg__parseNameValue(NSVGparser* p, const char* start, const char* end)
+{
+ const char* str;
+ const char* val;
+ char name[512];
+ char value[512];
+ int n;
+
+ str = start;
+ while (str < end && *str != ':') ++str;
+
+ val = str;
+
+ // Right Trim
+ while (str > start && (*str == ':' || nsvg__isspace(*str))) --str;
+ ++str;
+
+ n = (int)(str - start);
+ if (n > 511) n = 511;
+ if (n) memcpy(name, start, n);
+ name[n] = 0;
+
+ while (val < end && (*val == ':' || nsvg__isspace(*val))) ++val;
+
+ n = (int)(end - val);
+ if (n > 511) n = 511;
+ if (n) memcpy(value, val, n);
+ value[n] = 0;
+
+ return nsvg__parseAttr(p, name, value);
+}
+
+static void nsvg__parseStyle(NSVGparser* p, const char* str)
+{
+ const char* start;
+ const char* end;
+
+ while (*str) {
+ // Left Trim
+ while(*str && nsvg__isspace(*str)) ++str;
+ start = str;
+ while(*str && *str != ';') ++str;
+ end = str;
+
+ // Right Trim
+ while (end > start && (*end == ';' || nsvg__isspace(*end))) --end;
+ ++end;
+
+ nsvg__parseNameValue(p, start, end);
+ if (*str) ++str;
+ }
+}
+
+static void nsvg__parseAttribs(NSVGparser* p, const char** attr)
+{
+ int i;
+ for (i = 0; attr[i]; i += 2)
+ {
+ if (strcmp(attr[i], "style") == 0)
+ nsvg__parseStyle(p, attr[i + 1]);
+ else
+ nsvg__parseAttr(p, attr[i], attr[i + 1]);
+ }
+}
+
+static int nsvg__getArgsPerElement(char cmd)
+{
+ switch (cmd) {
+ case 'v':
+ case 'V':
+ case 'h':
+ case 'H':
+ return 1;
+ case 'm':
+ case 'M':
+ case 'l':
+ case 'L':
+ case 't':
+ case 'T':
+ return 2;
+ case 'q':
+ case 'Q':
+ case 's':
+ case 'S':
+ return 4;
+ case 'c':
+ case 'C':
+ return 6;
+ case 'a':
+ case 'A':
+ return 7;
+ }
+ return 0;
+}
+
+static void nsvg__pathMoveTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
+{
+ if (rel) {
+ *cpx += args[0];
+ *cpy += args[1];
+ } else {
+ *cpx = args[0];
+ *cpy = args[1];
+ }
+ nsvg__moveTo(p, *cpx, *cpy);
+}
+
+static void nsvg__pathLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
+{
+ if (rel) {
+ *cpx += args[0];
+ *cpy += args[1];
+ } else {
+ *cpx = args[0];
+ *cpy = args[1];
+ }
+ nsvg__lineTo(p, *cpx, *cpy);
+}
+
+static void nsvg__pathHLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
+{
+ if (rel)
+ *cpx += args[0];
+ else
+ *cpx = args[0];
+ nsvg__lineTo(p, *cpx, *cpy);
+}
+
+static void nsvg__pathVLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
+{
+ if (rel)
+ *cpy += args[0];
+ else
+ *cpy = args[0];
+ nsvg__lineTo(p, *cpx, *cpy);
+}
+
+static void nsvg__pathCubicBezTo(NSVGparser* p, float* cpx, float* cpy,
+ float* cpx2, float* cpy2, float* args, int rel)
+{
+ float x2, y2, cx1, cy1, cx2, cy2;
+
+ if (rel) {
+ cx1 = *cpx + args[0];
+ cy1 = *cpy + args[1];
+ cx2 = *cpx + args[2];
+ cy2 = *cpy + args[3];
+ x2 = *cpx + args[4];
+ y2 = *cpy + args[5];
+ } else {
+ cx1 = args[0];
+ cy1 = args[1];
+ cx2 = args[2];
+ cy2 = args[3];
+ x2 = args[4];
+ y2 = args[5];
+ }
+
+ nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
+
+ *cpx2 = cx2;
+ *cpy2 = cy2;
+ *cpx = x2;
+ *cpy = y2;
+}
+
+static void nsvg__pathCubicBezShortTo(NSVGparser* p, float* cpx, float* cpy,
+ float* cpx2, float* cpy2, float* args, int rel)
+{
+ float x1, y1, x2, y2, cx1, cy1, cx2, cy2;
+
+ x1 = *cpx;
+ y1 = *cpy;
+ if (rel) {
+ cx2 = *cpx + args[0];
+ cy2 = *cpy + args[1];
+ x2 = *cpx + args[2];
+ y2 = *cpy + args[3];
+ } else {
+ cx2 = args[0];
+ cy2 = args[1];
+ x2 = args[2];
+ y2 = args[3];
+ }
+
+ cx1 = 2*x1 - *cpx2;
+ cy1 = 2*y1 - *cpy2;
+
+ nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
+
+ *cpx2 = cx2;
+ *cpy2 = cy2;
+ *cpx = x2;
+ *cpy = y2;
+}
+
+static void nsvg__pathQuadBezTo(NSVGparser* p, float* cpx, float* cpy,
+ float* cpx2, float* cpy2, float* args, int rel)
+{
+ float x1, y1, x2, y2, cx, cy;
+ float cx1, cy1, cx2, cy2;
+
+ x1 = *cpx;
+ y1 = *cpy;
+ if (rel) {
+ cx = *cpx + args[0];
+ cy = *cpy + args[1];
+ x2 = *cpx + args[2];
+ y2 = *cpy + args[3];
+ } else {
+ cx = args[0];
+ cy = args[1];
+ x2 = args[2];
+ y2 = args[3];
+ }
+
+ // Convert to cubic bezier
+ cx1 = x1 + 2.0f/3.0f*(cx - x1);
+ cy1 = y1 + 2.0f/3.0f*(cy - y1);
+ cx2 = x2 + 2.0f/3.0f*(cx - x2);
+ cy2 = y2 + 2.0f/3.0f*(cy - y2);
+
+ nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
+
+ *cpx2 = cx;
+ *cpy2 = cy;
+ *cpx = x2;
+ *cpy = y2;
+}
+
+static void nsvg__pathQuadBezShortTo(NSVGparser* p, float* cpx, float* cpy,
+ float* cpx2, float* cpy2, float* args, int rel)
+{
+ float x1, y1, x2, y2, cx, cy;
+ float cx1, cy1, cx2, cy2;
+
+ x1 = *cpx;
+ y1 = *cpy;
+ if (rel) {
+ x2 = *cpx + args[0];
+ y2 = *cpy + args[1];
+ } else {
+ x2 = args[0];
+ y2 = args[1];
+ }
+
+ cx = 2*x1 - *cpx2;
+ cy = 2*y1 - *cpy2;
+
+ // Convert to cubix bezier
+ cx1 = x1 + 2.0f/3.0f*(cx - x1);
+ cy1 = y1 + 2.0f/3.0f*(cy - y1);
+ cx2 = x2 + 2.0f/3.0f*(cx - x2);
+ cy2 = y2 + 2.0f/3.0f*(cy - y2);
+
+ nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
+
+ *cpx2 = cx;
+ *cpy2 = cy;
+ *cpx = x2;
+ *cpy = y2;
+}
+
+static float nsvg__sqr(float x) { return x*x; }
+static float nsvg__vmag(float x, float y) { return sqrtf(x*x + y*y); }
+
+static float nsvg__vecrat(float ux, float uy, float vx, float vy)
+{
+ return (ux*vx + uy*vy) / (nsvg__vmag(ux,uy) * nsvg__vmag(vx,vy));
+}
+
+static float nsvg__vecang(float ux, float uy, float vx, float vy)
+{
+ float r = nsvg__vecrat(ux,uy, vx,vy);
+ if (r < -1.0f) r = -1.0f;
+ if (r > 1.0f) r = 1.0f;
+ return ((ux*vy < uy*vx) ? -1.0f : 1.0f) * acosf(r);
+}
+
+static void nsvg__pathArcTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
+{
+ // Ported from canvg (https://code.google.com/p/canvg/)
+ float rx, ry, rotx;
+ float x1, y1, x2, y2, cx, cy, dx, dy, d;
+ float x1p, y1p, cxp, cyp, s, sa, sb;
+ float ux, uy, vx, vy, a1, da;
+ float x, y, tanx, tany, a, px = 0, py = 0, ptanx = 0, ptany = 0, t[6];
+ float sinrx, cosrx;
+ int fa, fs;
+ int i, ndivs;
+ float hda, kappa;
+
+ rx = fabsf(args[0]); // y radius
+ ry = fabsf(args[1]); // x radius
+ rotx = args[2] / 180.0f * NSVG_PI; // x rotation angle
+ fa = fabsf(args[3]) > 1e-6 ? 1 : 0; // Large arc
+ fs = fabsf(args[4]) > 1e-6 ? 1 : 0; // Sweep direction
+ x1 = *cpx; // start point
+ y1 = *cpy;
+ if (rel) { // end point
+ x2 = *cpx + args[5];
+ y2 = *cpy + args[6];
+ } else {
+ x2 = args[5];
+ y2 = args[6];
+ }
+
+ dx = x1 - x2;
+ dy = y1 - y2;
+ d = sqrtf(dx*dx + dy*dy);
+ if (d < 1e-6f || rx < 1e-6f || ry < 1e-6f) {
+ // The arc degenerates to a line
+ nsvg__lineTo(p, x2, y2);
+ *cpx = x2;
+ *cpy = y2;
+ return;
+ }
+
+ sinrx = sinf(rotx);
+ cosrx = cosf(rotx);
+
+ // Convert to center point parameterization.
+ // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
+ // 1) Compute x1', y1'
+ x1p = cosrx * dx / 2.0f + sinrx * dy / 2.0f;
+ y1p = -sinrx * dx / 2.0f + cosrx * dy / 2.0f;
+ d = nsvg__sqr(x1p)/nsvg__sqr(rx) + nsvg__sqr(y1p)/nsvg__sqr(ry);
+ if (d > 1) {
+ d = sqrtf(d);
+ rx *= d;
+ ry *= d;
+ }
+ // 2) Compute cx', cy'
+ s = 0.0f;
+ sa = nsvg__sqr(rx)*nsvg__sqr(ry) - nsvg__sqr(rx)*nsvg__sqr(y1p) - nsvg__sqr(ry)*nsvg__sqr(x1p);
+ sb = nsvg__sqr(rx)*nsvg__sqr(y1p) + nsvg__sqr(ry)*nsvg__sqr(x1p);
+ if (sa < 0.0f) sa = 0.0f;
+ if (sb > 0.0f)
+ s = sqrtf(sa / sb);
+ if (fa == fs)
+ s = -s;
+ cxp = s * rx * y1p / ry;
+ cyp = s * -ry * x1p / rx;
+
+ // 3) Compute cx,cy from cx',cy'
+ cx = (x1 + x2)/2.0f + cosrx*cxp - sinrx*cyp;
+ cy = (y1 + y2)/2.0f + sinrx*cxp + cosrx*cyp;
+
+ // 4) Calculate theta1, and delta theta.
+ ux = (x1p - cxp) / rx;
+ uy = (y1p - cyp) / ry;
+ vx = (-x1p - cxp) / rx;
+ vy = (-y1p - cyp) / ry;
+ a1 = nsvg__vecang(1.0f,0.0f, ux,uy); // Initial angle
+ da = nsvg__vecang(ux,uy, vx,vy); // Delta angle
+
+// if (vecrat(ux,uy,vx,vy) <= -1.0f) da = NSVG_PI;
+// if (vecrat(ux,uy,vx,vy) >= 1.0f) da = 0;
+
+ if (fs == 0 && da > 0)
+ da -= 2 * NSVG_PI;
+ else if (fs == 1 && da < 0)
+ da += 2 * NSVG_PI;
+
+ // Approximate the arc using cubic spline segments.
+ t[0] = cosrx; t[1] = sinrx;
+ t[2] = -sinrx; t[3] = cosrx;
+ t[4] = cx; t[5] = cy;
+
+ // Split arc into max 90 degree segments.
+ // The loop assumes an iteration per end point (including start and end), this +1.
+ ndivs = (int)(fabsf(da) / (NSVG_PI*0.5f) + 1.0f);
+ hda = (da / (float)ndivs) / 2.0f;
+ kappa = fabsf(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda));
+ if (da < 0.0f)
+ kappa = -kappa;
+
+ for (i = 0; i <= ndivs; i++) {
+ a = a1 + da * ((float)i/(float)ndivs);
+ dx = cosf(a);
+ dy = sinf(a);
+ nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); // position
+ nsvg__xformVec(&tanx, &tany, -dy*rx * kappa, dx*ry * kappa, t); // tangent
+ if (i > 0)
+ nsvg__cubicBezTo(p, px+ptanx,py+ptany, x-tanx, y-tany, x, y);
+ px = x;
+ py = y;
+ ptanx = tanx;
+ ptany = tany;
+ }
+
+ *cpx = x2;
+ *cpy = y2;
+}
+
+static void nsvg__parsePath(NSVGparser* p, const char** attr)
+{
+ const char* s = NULL;
+ char cmd = '\0';
+ float args[10];
+ int nargs;
+ int rargs = 0;
+ float cpx, cpy, cpx2, cpy2;
+ const char* tmp[4];
+ char closedFlag;
+ int i;
+ char item[64];
+
+ for (i = 0; attr[i]; i += 2) {
+ if (strcmp(attr[i], "d") == 0) {
+ s = attr[i + 1];
+ } else {
+ tmp[0] = attr[i];
+ tmp[1] = attr[i + 1];
+ tmp[2] = 0;
+ tmp[3] = 0;
+ nsvg__parseAttribs(p, tmp);
+ }
+ }
+
+ if (s) {
+ nsvg__resetPath(p);
+ cpx = 0; cpy = 0;
+ cpx2 = 0; cpy2 = 0;
+ closedFlag = 0;
+ nargs = 0;
+
+ while (*s) {
+ s = nsvg__getNextPathItem(s, item);
+ if (!*item) break;
+ if (nsvg__isnum(item[0])) {
+ if (nargs < 10)
+ args[nargs++] = (float)nsvg__atof(item);
+ if (nargs >= rargs) {
+ switch (cmd) {
+ case 'm':
+ case 'M':
+ nsvg__pathMoveTo(p, &cpx, &cpy, args, cmd == 'm' ? 1 : 0);
+ // Moveto can be followed by multiple coordinate pairs,
+ // which should be treated as linetos.
+ cmd = (cmd == 'm') ? 'l' : 'L';
+ rargs = nsvg__getArgsPerElement(cmd);
+ cpx2 = cpx; cpy2 = cpy;
+ break;
+ case 'l':
+ case 'L':
+ nsvg__pathLineTo(p, &cpx, &cpy, args, cmd == 'l' ? 1 : 0);
+ cpx2 = cpx; cpy2 = cpy;
+ break;
+ case 'H':
+ case 'h':
+ nsvg__pathHLineTo(p, &cpx, &cpy, args, cmd == 'h' ? 1 : 0);
+ cpx2 = cpx; cpy2 = cpy;
+ break;
+ case 'V':
+ case 'v':
+ nsvg__pathVLineTo(p, &cpx, &cpy, args, cmd == 'v' ? 1 : 0);
+ cpx2 = cpx; cpy2 = cpy;
+ break;
+ case 'C':
+ case 'c':
+ nsvg__pathCubicBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'c' ? 1 : 0);
+ break;
+ case 'S':
+ case 's':
+ nsvg__pathCubicBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 's' ? 1 : 0);
+ break;
+ case 'Q':
+ case 'q':
+ nsvg__pathQuadBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'q' ? 1 : 0);
+ break;
+ case 'T':
+ case 't':
+ nsvg__pathQuadBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 't' ? 1 : 0);
+ break;
+ case 'A':
+ case 'a':
+ nsvg__pathArcTo(p, &cpx, &cpy, args, cmd == 'a' ? 1 : 0);
+ cpx2 = cpx; cpy2 = cpy;
+ break;
+ default:
+ if (nargs >= 2) {
+ cpx = args[nargs-2];
+ cpy = args[nargs-1];
+ cpx2 = cpx; cpy2 = cpy;
+ }
+ break;
+ }
+ nargs = 0;
+ }
+ } else {
+ cmd = item[0];
+ rargs = nsvg__getArgsPerElement(cmd);
+ if (cmd == 'M' || cmd == 'm') {
+ // Commit path.
+ if (p->npts > 0)
+ nsvg__addPath(p, closedFlag);
+ // Start new subpath.
+ nsvg__resetPath(p);
+ closedFlag = 0;
+ nargs = 0;
+ } else if (cmd == 'Z' || cmd == 'z') {
+ closedFlag = 1;
+ // Commit path.
+ if (p->npts > 0) {
+ // Move current point to first point
+ cpx = p->pts[0];
+ cpy = p->pts[1];
+ cpx2 = cpx; cpy2 = cpy;
+ nsvg__addPath(p, closedFlag);
+ }
+ // Start new subpath.
+ nsvg__resetPath(p);
+ nsvg__moveTo(p, cpx, cpy);
+ closedFlag = 0;
+ nargs = 0;
+ }
+ }
+ }
+ // Commit path.
+ if (p->npts)
+ nsvg__addPath(p, closedFlag);
+ }
+
+ nsvg__addShape(p);
+}
+
+static void nsvg__parseRect(NSVGparser* p, const char** attr)
+{
+ float x = 0.0f;
+ float y = 0.0f;
+ float w = 0.0f;
+ float h = 0.0f;
+ float rx = -1.0f; // marks not set
+ float ry = -1.0f;
+ int i;
+
+ for (i = 0; attr[i]; i += 2) {
+ if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "x") == 0) x = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+ if (strcmp(attr[i], "y") == 0) y = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+ if (strcmp(attr[i], "width") == 0) w = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p));
+ if (strcmp(attr[i], "height") == 0) h = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p));
+ if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p)));
+ if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p)));
+ }
+ }
+
+ if (rx < 0.0f && ry > 0.0f) rx = ry;
+ if (ry < 0.0f && rx > 0.0f) ry = rx;
+ if (rx < 0.0f) rx = 0.0f;
+ if (ry < 0.0f) ry = 0.0f;
+ if (rx > w/2.0f) rx = w/2.0f;
+ if (ry > h/2.0f) ry = h/2.0f;
+
+ if (w != 0.0f && h != 0.0f) {
+ nsvg__resetPath(p);
+
+ if (rx < 0.00001f || ry < 0.0001f) {
+ nsvg__moveTo(p, x, y);
+ nsvg__lineTo(p, x+w, y);
+ nsvg__lineTo(p, x+w, y+h);
+ nsvg__lineTo(p, x, y+h);
+ } else {
+ // Rounded rectangle
+ nsvg__moveTo(p, x+rx, y);
+ nsvg__lineTo(p, x+w-rx, y);
+ nsvg__cubicBezTo(p, x+w-rx*(1-NSVG_KAPPA90), y, x+w, y+ry*(1-NSVG_KAPPA90), x+w, y+ry);
+ nsvg__lineTo(p, x+w, y+h-ry);
+ nsvg__cubicBezTo(p, x+w, y+h-ry*(1-NSVG_KAPPA90), x+w-rx*(1-NSVG_KAPPA90), y+h, x+w-rx, y+h);
+ nsvg__lineTo(p, x+rx, y+h);
+ nsvg__cubicBezTo(p, x+rx*(1-NSVG_KAPPA90), y+h, x, y+h-ry*(1-NSVG_KAPPA90), x, y+h-ry);
+ nsvg__lineTo(p, x, y+ry);
+ nsvg__cubicBezTo(p, x, y+ry*(1-NSVG_KAPPA90), x+rx*(1-NSVG_KAPPA90), y, x+rx, y);
+ }
+
+ nsvg__addPath(p, 1);
+
+ nsvg__addShape(p);
+ }
+}
+
+static void nsvg__parseCircle(NSVGparser* p, const char** attr)
+{
+ float cx = 0.0f;
+ float cy = 0.0f;
+ float r = 0.0f;
+ int i;
+
+ for (i = 0; attr[i]; i += 2) {
+ if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+ if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+ if (strcmp(attr[i], "r") == 0) r = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualLength(p)));
+ }
+ }
+
+ if (r > 0.0f) {
+ nsvg__resetPath(p);
+
+ nsvg__moveTo(p, cx+r, cy);
+ nsvg__cubicBezTo(p, cx+r, cy+r*NSVG_KAPPA90, cx+r*NSVG_KAPPA90, cy+r, cx, cy+r);
+ nsvg__cubicBezTo(p, cx-r*NSVG_KAPPA90, cy+r, cx-r, cy+r*NSVG_KAPPA90, cx-r, cy);
+ nsvg__cubicBezTo(p, cx-r, cy-r*NSVG_KAPPA90, cx-r*NSVG_KAPPA90, cy-r, cx, cy-r);
+ nsvg__cubicBezTo(p, cx+r*NSVG_KAPPA90, cy-r, cx+r, cy-r*NSVG_KAPPA90, cx+r, cy);
+
+ nsvg__addPath(p, 1);
+
+ nsvg__addShape(p);
+ }
+}
+
+static void nsvg__parseEllipse(NSVGparser* p, const char** attr)
+{
+ float cx = 0.0f;
+ float cy = 0.0f;
+ float rx = 0.0f;
+ float ry = 0.0f;
+ int i;
+
+ for (i = 0; attr[i]; i += 2) {
+ if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+ if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+ if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p)));
+ if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p)));
+ }
+ }
+
+ if (rx > 0.0f && ry > 0.0f) {
+
+ nsvg__resetPath(p);
+
+ nsvg__moveTo(p, cx+rx, cy);
+ nsvg__cubicBezTo(p, cx+rx, cy+ry*NSVG_KAPPA90, cx+rx*NSVG_KAPPA90, cy+ry, cx, cy+ry);
+ nsvg__cubicBezTo(p, cx-rx*NSVG_KAPPA90, cy+ry, cx-rx, cy+ry*NSVG_KAPPA90, cx-rx, cy);
+ nsvg__cubicBezTo(p, cx-rx, cy-ry*NSVG_KAPPA90, cx-rx*NSVG_KAPPA90, cy-ry, cx, cy-ry);
+ nsvg__cubicBezTo(p, cx+rx*NSVG_KAPPA90, cy-ry, cx+rx, cy-ry*NSVG_KAPPA90, cx+rx, cy);
+
+ nsvg__addPath(p, 1);
+
+ nsvg__addShape(p);
+ }
+}
+
+static void nsvg__parseLine(NSVGparser* p, const char** attr)
+{
+ float x1 = 0.0;
+ float y1 = 0.0;
+ float x2 = 0.0;
+ float y2 = 0.0;
+ int i;
+
+ for (i = 0; attr[i]; i += 2) {
+ if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "x1") == 0) x1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+ if (strcmp(attr[i], "y1") == 0) y1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+ if (strcmp(attr[i], "x2") == 0) x2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+ if (strcmp(attr[i], "y2") == 0) y2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+ }
+ }
+
+ nsvg__resetPath(p);
+
+ nsvg__moveTo(p, x1, y1);
+ nsvg__lineTo(p, x2, y2);
+
+ nsvg__addPath(p, 0);
+
+ nsvg__addShape(p);
+}
+
+static void nsvg__parsePoly(NSVGparser* p, const char** attr, int closeFlag)
+{
+ int i;
+ const char* s;
+ float args[2];
+ int nargs, npts = 0;
+ char item[64];
+
+ nsvg__resetPath(p);
+
+ for (i = 0; attr[i]; i += 2) {
+ if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "points") == 0) {
+ s = attr[i + 1];
+ nargs = 0;
+ while (*s) {
+ s = nsvg__getNextPathItem(s, item);
+ args[nargs++] = (float)nsvg__atof(item);
+ if (nargs >= 2) {
+ if (npts == 0)
+ nsvg__moveTo(p, args[0], args[1]);
+ else
+ nsvg__lineTo(p, args[0], args[1]);
+ nargs = 0;
+ npts++;
+ }
+ }
+ }
+ }
+ }
+
+ nsvg__addPath(p, (char)closeFlag);
+
+ nsvg__addShape(p);
+}
+
+static void nsvg__parseSVG(NSVGparser* p, const char** attr)
+{
+ int i;
+ for (i = 0; attr[i]; i += 2) {
+ if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "width") == 0) {
+ p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f);
+ } else if (strcmp(attr[i], "height") == 0) {
+ p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f);
+ } else if (strcmp(attr[i], "viewBox") == 0) {
+ sscanf(attr[i + 1], "%f%*[%%, \t]%f%*[%%, \t]%f%*[%%, \t]%f", &p->viewMinx, &p->viewMiny, &p->viewWidth, &p->viewHeight);
+ } else if (strcmp(attr[i], "preserveAspectRatio") == 0) {
+ if (strstr(attr[i + 1], "none") != 0) {
+ // No uniform scaling
+ p->alignType = NSVG_ALIGN_NONE;
+ } else {
+ // Parse X align
+ if (strstr(attr[i + 1], "xMin") != 0)
+ p->alignX = NSVG_ALIGN_MIN;
+ else if (strstr(attr[i + 1], "xMid") != 0)
+ p->alignX = NSVG_ALIGN_MID;
+ else if (strstr(attr[i + 1], "xMax") != 0)
+ p->alignX = NSVG_ALIGN_MAX;
+ // Parse X align
+ if (strstr(attr[i + 1], "yMin") != 0)
+ p->alignY = NSVG_ALIGN_MIN;
+ else if (strstr(attr[i + 1], "yMid") != 0)
+ p->alignY = NSVG_ALIGN_MID;
+ else if (strstr(attr[i + 1], "yMax") != 0)
+ p->alignY = NSVG_ALIGN_MAX;
+ // Parse meet/slice
+ p->alignType = NSVG_ALIGN_MEET;
+ if (strstr(attr[i + 1], "slice") != 0)
+ p->alignType = NSVG_ALIGN_SLICE;
+ }
+ }
+ }
+ }
+}
+
+static void nsvg__parseGradient(NSVGparser* p, const char** attr, char type)
+{
+ int i;
+ NSVGgradientData* grad = (NSVGgradientData*)NANOSVG_malloc(sizeof(NSVGgradientData));
+ if (grad == NULL) return;
+ memset(grad, 0, sizeof(NSVGgradientData));
+ grad->units = NSVG_OBJECT_SPACE;
+ grad->type = type;
+ if (grad->type == NSVG_PAINT_LINEAR_GRADIENT) {
+ grad->linear.x1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
+ grad->linear.y1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
+ grad->linear.x2 = nsvg__coord(100.0f, NSVG_UNITS_PERCENT);
+ grad->linear.y2 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
+ } else if (grad->type == NSVG_PAINT_RADIAL_GRADIENT) {
+ grad->radial.cx = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
+ grad->radial.cy = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
+ grad->radial.r = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
+ }
+
+ nsvg__xformIdentity(grad->xform);
+
+ for (i = 0; attr[i]; i += 2) {
+ if (strcmp(attr[i], "id") == 0) {
+ strncpy(grad->id, attr[i+1], 63);
+ grad->id[63] = '\0';
+ } else if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "gradientUnits") == 0) {
+ if (strcmp(attr[i+1], "objectBoundingBox") == 0)
+ grad->units = NSVG_OBJECT_SPACE;
+ else
+ grad->units = NSVG_USER_SPACE;
+ } else if (strcmp(attr[i], "gradientTransform") == 0) {
+ nsvg__parseTransform(grad->xform, attr[i + 1]);
+ } else if (strcmp(attr[i], "cx") == 0) {
+ grad->radial.cx = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "cy") == 0) {
+ grad->radial.cy = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "r") == 0) {
+ grad->radial.r = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "fx") == 0) {
+ grad->radial.fx = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "fy") == 0) {
+ grad->radial.fy = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "x1") == 0) {
+ grad->linear.x1 = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "y1") == 0) {
+ grad->linear.y1 = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "x2") == 0) {
+ grad->linear.x2 = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "y2") == 0) {
+ grad->linear.y2 = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "spreadMethod") == 0) {
+ if (strcmp(attr[i+1], "pad") == 0)
+ grad->spread = NSVG_SPREAD_PAD;
+ else if (strcmp(attr[i+1], "reflect") == 0)
+ grad->spread = NSVG_SPREAD_REFLECT;
+ else if (strcmp(attr[i+1], "repeat") == 0)
+ grad->spread = NSVG_SPREAD_REPEAT;
+ } else if (strcmp(attr[i], "xlink:href") == 0) {
+ const char *href = attr[i+1];
+ strncpy(grad->ref, href+1, 62);
+ grad->ref[62] = '\0';
+ }
+ }
+ }
+
+ grad->next = p->gradients;
+ p->gradients = grad;
+}
+
+static void nsvg__parseGradientStop(NSVGparser* p, const char** attr)
+{
+ NSVGattrib* curAttr = nsvg__getAttr(p);
+ NSVGgradientData* grad;
+ NSVGgradientStop* stop;
+ int i, idx;
+
+ curAttr->stopOffset = 0;
+ curAttr->stopColor = 0;
+ curAttr->stopOpacity = 1.0f;
+
+ for (i = 0; attr[i]; i += 2) {
+ nsvg__parseAttr(p, attr[i], attr[i + 1]);
+ }
+
+ // Add stop to the last gradient.
+ grad = p->gradients;
+ if (grad == NULL) return;
+
+ grad->nstops++;
+ grad->stops = (NSVGgradientStop*)NANOSVG_realloc(grad->stops, sizeof(NSVGgradientStop)*grad->nstops);
+ if (grad->stops == NULL) return;
+
+ // Insert
+ idx = grad->nstops-1;
+ for (i = 0; i < grad->nstops-1; i++) {
+ if (curAttr->stopOffset < grad->stops[i].offset) {
+ idx = i;
+ break;
+ }
+ }
+ if (idx != grad->nstops-1) {
+ for (i = grad->nstops-1; i > idx; i--)
+ grad->stops[i] = grad->stops[i-1];
+ }
+
+ stop = &grad->stops[idx];
+ stop->color = curAttr->stopColor;
+ stop->color |= (unsigned int)(curAttr->stopOpacity*255) << 24;
+ stop->offset = curAttr->stopOffset;
+}
+
+static void nsvg__startElement(void* ud, const char* el, const char** attr)
+{
+ NSVGparser* p = (NSVGparser*)ud;
+
+ if (p->defsFlag) {
+ // Skip everything but gradients in defs
+ if (strcmp(el, "linearGradient") == 0) {
+ nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
+ } else if (strcmp(el, "radialGradient") == 0) {
+ nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
+ } else if (strcmp(el, "stop") == 0) {
+ nsvg__parseGradientStop(p, attr);
+ }
+ return;
+ }
+
+ if (strcmp(el, "g") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseAttribs(p, attr);
+ } else if (strcmp(el, "path") == 0) {
+ if (p->pathFlag) // Do not allow nested paths.
+ return;
+ nsvg__pushAttr(p);
+ nsvg__parsePath(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "rect") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseRect(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "circle") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseCircle(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "ellipse") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseEllipse(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "line") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseLine(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "polyline") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parsePoly(p, attr, 0);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "polygon") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parsePoly(p, attr, 1);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "linearGradient") == 0) {
+ nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
+ } else if (strcmp(el, "radialGradient") == 0) {
+ nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
+ } else if (strcmp(el, "stop") == 0) {
+ nsvg__parseGradientStop(p, attr);
+ } else if (strcmp(el, "defs") == 0) {
+ p->defsFlag = 1;
+ } else if (strcmp(el, "svg") == 0) {
+ nsvg__parseSVG(p, attr);
+ } else if (strcmp(el, "style") == 0) {
+ p->styleFlag = 1;
+ }
+}
+
+static void nsvg__endElement(void* ud, const char* el)
+{
+ NSVGparser* p = (NSVGparser*)ud;
+
+ if (strcmp(el, "g") == 0) {
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "path") == 0) {
+ p->pathFlag = 0;
+ } else if (strcmp(el, "defs") == 0) {
+ p->defsFlag = 0;
+ } else if (strcmp(el, "style") == 0) {
+ p->styleFlag = 0;
+ }
+}
+
+static char *nsvg__strndup(const char *s, size_t n)
+{
+ char *result;
+ size_t len = strlen(s);
+
+ if (n < len)
+ len = n;
+
+ result = (char*)NANOSVG_malloc(len+1);
+ if (!result)
+ return 0;
+
+ result[len] = '\0';
+ return (char *)memcpy(result, s, len);
+}
+
+static void nsvg__content(void* ud, const char* s)
+{
+ NSVGparser* p = (NSVGparser*)ud;
+ if (p->styleFlag) {
+
+ int state = 0;
+ const char* start = NULL;
+ while (*s) {
+ char c = *s;
+ if (nsvg__isspace(c) || c == '{') {
+ if (state == 1) {
+ NSVGstyles* next = p->styles;
+
+ p->styles = (NSVGstyles*)NANOSVG_malloc(sizeof(NSVGstyles));
+ p->styles->next = next;
+ p->styles->name = nsvg__strndup(start, (size_t)(s - start));
+ start = s + 1;
+ state = 2;
+ }
+ } else if (state == 2 && c == '}') {
+ p->styles->description = nsvg__strndup(start, (size_t)(s - start));
+ state = 0;
+ }
+ else if (state == 0) {
+ start = s;
+ state = 1;
+ }
+ s++;
+ /*
+ if (*s == '{' && state == NSVG_XML_CONTENT) {
+ // Start of a tag
+ *s++ = '\0';
+ nsvg__parseContent(mark, contentCb, ud);
+ mark = s;
+ state = NSVG_XML_TAG;
+ }
+ else if (*s == '>' && state == NSVG_XML_TAG) {
+ // Start of a content or new tag.
+ *s++ = '\0';
+ nsvg__parseElement(mark, startelCb, endelCb, ud);
+ mark = s;
+ state = NSVG_XML_CONTENT;
+ }
+ else {
+ s++;
+ }
+ */
+ }
+
+ }
+}
+
+static void nsvg__imageBounds(NSVGparser* p, float* bounds)
+{
+ NSVGshape* shape;
+ shape = p->image->shapes;
+ if (shape == NULL) {
+ bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0;
+ return;
+ }
+ bounds[0] = shape->bounds[0];
+ bounds[1] = shape->bounds[1];
+ bounds[2] = shape->bounds[2];
+ bounds[3] = shape->bounds[3];
+ for (shape = shape->next; shape != NULL; shape = shape->next) {
+ bounds[0] = nsvg__minf(bounds[0], shape->bounds[0]);
+ bounds[1] = nsvg__minf(bounds[1], shape->bounds[1]);
+ bounds[2] = nsvg__maxf(bounds[2], shape->bounds[2]);
+ bounds[3] = nsvg__maxf(bounds[3], shape->bounds[3]);
+ }
+}
+
+static float nsvg__viewAlign(float content, float container, int type)
+{
+ if (type == NSVG_ALIGN_MIN)
+ return 0;
+ else if (type == NSVG_ALIGN_MAX)
+ return container - content;
+ // mid
+ return (container - content) * 0.5f;
+}
+
+static void nsvg__scaleGradient(NSVGgradient* grad, float tx, float ty, float sx, float sy)
+{
+ float t[6];
+ nsvg__xformSetTranslation(t, tx, ty);
+ nsvg__xformMultiply (grad->xform, t);
+
+ nsvg__xformSetScale(t, sx, sy);
+ nsvg__xformMultiply (grad->xform, t);
+}
+
+static void nsvg__scaleToViewbox(NSVGparser* p, const char* units)
+{
+ NSVGshape* shape;
+ NSVGpath* path;
+ float tx, ty, sx, sy, us, bounds[4], t[6], avgs;
+ int i;
+ float* pt;
+
+ // Guess image size if not set completely.
+ nsvg__imageBounds(p, bounds);
+
+ if (p->viewWidth == 0) {
+ if (p->image->width > 0) {
+ p->viewWidth = p->image->width;
+ } else {
+ p->viewMinx = bounds[0];
+ p->viewWidth = bounds[2] - bounds[0];
+ }
+ }
+ if (p->viewHeight == 0) {
+ if (p->image->height > 0) {
+ p->viewHeight = p->image->height;
+ } else {
+ p->viewMiny = bounds[1];
+ p->viewHeight = bounds[3] - bounds[1];
+ }
+ }
+ if (p->image->width == 0)
+ p->image->width = p->viewWidth;
+ if (p->image->height == 0)
+ p->image->height = p->viewHeight;
+
+ tx = -p->viewMinx;
+ ty = -p->viewMiny;
+ sx = p->viewWidth > 0 ? p->image->width / p->viewWidth : 0;
+ sy = p->viewHeight > 0 ? p->image->height / p->viewHeight : 0;
+ // Unit scaling
+ us = 1.0f / nsvg__convertToPixels(p, nsvg__coord(1.0f, nsvg__parseUnits(units)), 0.0f, 1.0f);
+
+ // Fix aspect ratio
+ if (p->alignType == NSVG_ALIGN_MEET) {
+ // fit whole image into viewbox
+ sx = sy = nsvg__minf(sx, sy);
+ tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
+ ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
+ } else if (p->alignType == NSVG_ALIGN_SLICE) {
+ // fill whole viewbox with image
+ sx = sy = nsvg__maxf(sx, sy);
+ tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
+ ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
+ }
+
+ // Transform
+ sx *= us;
+ sy *= us;
+ avgs = (sx+sy) / 2.0f;
+ for (shape = p->image->shapes; shape != NULL; shape = shape->next) {
+ shape->bounds[0] = (shape->bounds[0] + tx) * sx;
+ shape->bounds[1] = (shape->bounds[1] + ty) * sy;
+ shape->bounds[2] = (shape->bounds[2] + tx) * sx;
+ shape->bounds[3] = (shape->bounds[3] + ty) * sy;
+ for (path = shape->paths; path != NULL; path = path->next) {
+ path->bounds[0] = (path->bounds[0] + tx) * sx;
+ path->bounds[1] = (path->bounds[1] + ty) * sy;
+ path->bounds[2] = (path->bounds[2] + tx) * sx;
+ path->bounds[3] = (path->bounds[3] + ty) * sy;
+ for (i =0; i < path->npts; i++) {
+ pt = &path->pts[i*2];
+ pt[0] = (pt[0] + tx) * sx;
+ pt[1] = (pt[1] + ty) * sy;
+ }
+ }
+
+ if (shape->fill.type == NSVG_PAINT_LINEAR_GRADIENT || shape->fill.type == NSVG_PAINT_RADIAL_GRADIENT) {
+ nsvg__scaleGradient(shape->fill.gradient, tx,ty, sx,sy);
+ memcpy(t, shape->fill.gradient->xform, sizeof(float)*6);
+ nsvg__xformInverse(shape->fill.gradient->xform, t);
+ }
+ if (shape->stroke.type == NSVG_PAINT_LINEAR_GRADIENT || shape->stroke.type == NSVG_PAINT_RADIAL_GRADIENT) {
+ nsvg__scaleGradient(shape->stroke.gradient, tx,ty, sx,sy);
+ memcpy(t, shape->stroke.gradient->xform, sizeof(float)*6);
+ nsvg__xformInverse(shape->stroke.gradient->xform, t);
+ }
+
+ shape->strokeWidth *= avgs;
+ shape->strokeDashOffset *= avgs;
+ for (i = 0; i < shape->strokeDashCount; i++)
+ shape->strokeDashArray[i] *= avgs;
+ }
+}
+
+NANOSVG_SCOPE
+NSVGimage* nsvgParse(char* input, const char* units, float dpi)
+{
+ NSVGparser* p;
+ NSVGimage* ret = 0;
+
+ p = nsvg__createParser();
+ if (p == NULL) {
+ return NULL;
+ }
+ p->dpi = dpi;
+
+ nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p);
+
+ // Scale to viewBox
+ nsvg__scaleToViewbox(p, units);
+
+ ret = p->image;
+ p->image = NULL;
+
+ nsvg__deleteParser(p);
+
+ return ret;
+}
+
+NANOSVG_SCOPE
+NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi)
+{
+ FILE* fp = NULL;
+ size_t size;
+ char* data = NULL;
+ NSVGimage* image = NULL;
+
+ fp = fopen(filename, "rb");
+ if (!fp) goto error;
+ fseek(fp, 0, SEEK_END);
+ size = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+ data = (char*)NANOSVG_malloc(size+1);
+ if (data == NULL) goto error;
+ if (fread(data, 1, size, fp) != size) goto error;
+ data[size] = '\0'; // Must be null terminated.
+ fclose(fp);
+ image = nsvgParse(data, units, dpi);
+ NANOSVG_free(data);
+
+ return image;
+
+error:
+ if (fp) fclose(fp);
+ if (data) NANOSVG_free(data);
+ if (image) nsvgDelete(image);
+ return NULL;
+}
+
+NANOSVG_SCOPE
+void nsvgDelete(NSVGimage* image)
+{
+ NSVGshape *snext, *shape;
+ if (image == NULL) return;
+ shape = image->shapes;
+ while (shape != NULL) {
+ snext = shape->next;
+ nsvg__deletePaths(shape->paths);
+ nsvg__deletePaint(&shape->fill);
+ nsvg__deletePaint(&shape->stroke);
+ NANOSVG_free(shape);
+ shape = snext;
+ }
+ NANOSVG_free(image);
+}
+
+#endif
diff --git a/generic/nanosvgrast.h b/generic/nanosvgrast.h
new file mode 100644
index 0000000..2720ce5
--- /dev/null
+++ b/generic/nanosvgrast.h
@@ -0,0 +1,1467 @@
+/*
+ * Copyright (c) 2013-14 Mikko Mononen memon@inside.org
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ *
+ * The polygon rasterization is heavily based on stb_truetype rasterizer
+ * by Sean Barrett - http://nothings.org/
+ *
+ */
+
+#ifndef NANOSVGRAST_H
+#define NANOSVGRAST_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef NANOSVG_SCOPE
+#define NANOSVG_SCOPE
+#endif
+
+#ifndef NANOSVG_malloc
+#define NANOSVG_malloc malloc
+#endif
+
+#ifndef NANOSVG_realloc
+#define NANOSVG_realloc realloc
+#endif
+
+#ifndef NANOSVG_free
+#define NANOSVG_free free
+#endif
+
+typedef struct NSVGrasterizer NSVGrasterizer;
+
+/* Example Usage:
+ // Load SVG
+ struct SNVGImage* image = nsvgParseFromFile("test.svg.");
+
+ // Create rasterizer (can be used to render multiple images).
+ struct NSVGrasterizer* rast = nsvgCreateRasterizer();
+ // Allocate memory for image
+ unsigned char* img = malloc(w*h*4);
+ // Rasterize
+ nsvgRasterize(rast, image, 0,0,1, img, w, h, w*4);
+*/
+
+// Allocated rasterizer context.
+NANOSVG_SCOPE NSVGrasterizer* nsvgCreateRasterizer(void);
+
+// Rasterizes SVG image, returns RGBA image (non-premultiplied alpha)
+// r - pointer to rasterizer context
+// image - pointer to image to rasterize
+// tx,ty - image offset (applied after scaling)
+// scale - image scale
+// dst - pointer to destination image data, 4 bytes per pixel (RGBA)
+// w - width of the image to render
+// h - height of the image to render
+// stride - number of bytes per scaleline in the destination buffer
+NANOSVG_SCOPE void nsvgRasterize(NSVGrasterizer* r,
+ NSVGimage* image, float tx, float ty, float scale,
+ unsigned char* dst, int w, int h, int stride);
+
+// Deletes rasterizer context.
+NANOSVG_SCOPE void nsvgDeleteRasterizer(NSVGrasterizer*);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // NANOSVGRAST_H
+
+#ifdef NANOSVGRAST_IMPLEMENTATION
+
+#include <math.h>
+
+#define NSVG__SUBSAMPLES 5
+#define NSVG__FIXSHIFT 10
+#define NSVG__FIX (1 << NSVG__FIXSHIFT)
+#define NSVG__FIXMASK (NSVG__FIX-1)
+#define NSVG__MEMPAGE_SIZE 1024
+
+typedef struct NSVGedge {
+ float x0,y0, x1,y1;
+ int dir;
+ struct NSVGedge* next;
+} NSVGedge;
+
+typedef struct NSVGpoint {
+ float x, y;
+ float dx, dy;
+ float len;
+ float dmx, dmy;
+ unsigned char flags;
+} NSVGpoint;
+
+typedef struct NSVGactiveEdge {
+ int x,dx;
+ float ey;
+ int dir;
+ struct NSVGactiveEdge *next;
+} NSVGactiveEdge;
+
+typedef struct NSVGmemPage {
+ unsigned char mem[NSVG__MEMPAGE_SIZE];
+ int size;
+ struct NSVGmemPage* next;
+} NSVGmemPage;
+
+typedef struct NSVGcachedPaint {
+ char type;
+ char spread;
+ float xform[6];
+ unsigned int colors[256];
+} NSVGcachedPaint;
+
+struct NSVGrasterizer
+{
+ float px, py;
+
+ float tessTol;
+ float distTol;
+
+ NSVGedge* edges;
+ int nedges;
+ int cedges;
+
+ NSVGpoint* points;
+ int npoints;
+ int cpoints;
+
+ NSVGpoint* points2;
+ int npoints2;
+ int cpoints2;
+
+ NSVGactiveEdge* freelist;
+ NSVGmemPage* pages;
+ NSVGmemPage* curpage;
+
+ unsigned char* scanline;
+ int cscanline;
+
+ unsigned char* bitmap;
+ int width, height, stride;
+};
+
+NANOSVG_SCOPE
+NSVGrasterizer* nsvgCreateRasterizer(void)
+{
+ NSVGrasterizer* r = (NSVGrasterizer*)NANOSVG_malloc(sizeof(NSVGrasterizer));
+ if (r == NULL) goto error;
+ memset(r, 0, sizeof(NSVGrasterizer));
+
+ r->tessTol = 0.25f;
+ r->distTol = 0.01f;
+
+ return r;
+
+error:
+ nsvgDeleteRasterizer(r);
+ return NULL;
+}
+
+NANOSVG_SCOPE
+void nsvgDeleteRasterizer(NSVGrasterizer* r)
+{
+ NSVGmemPage* p;
+
+ if (r == NULL) return;
+
+ p = r->pages;
+ while (p != NULL) {
+ NSVGmemPage* next = p->next;
+ NANOSVG_free(p);
+ p = next;
+ }
+
+ if (r->edges) NANOSVG_free(r->edges);
+ if (r->points) NANOSVG_free(r->points);
+ if (r->points2) NANOSVG_free(r->points2);
+ if (r->scanline) NANOSVG_free(r->scanline);
+
+ NANOSVG_free(r);
+}
+
+static NSVGmemPage* nsvg__nextPage(NSVGrasterizer* r, NSVGmemPage* cur)
+{
+ NSVGmemPage *newp;
+
+ // If using existing chain, return the next page in chain
+ if (cur != NULL && cur->next != NULL) {
+ return cur->next;
+ }
+
+ // Alloc new page
+ newp = (NSVGmemPage*)NANOSVG_malloc(sizeof(NSVGmemPage));
+ if (newp == NULL) return NULL;
+ memset(newp, 0, sizeof(NSVGmemPage));
+
+ // Add to linked list
+ if (cur != NULL)
+ cur->next = newp;
+ else
+ r->pages = newp;
+
+ return newp;
+}
+
+static void nsvg__resetPool(NSVGrasterizer* r)
+{
+ NSVGmemPage* p = r->pages;
+ while (p != NULL) {
+ p->size = 0;
+ p = p->next;
+ }
+ r->curpage = r->pages;
+}
+
+static unsigned char* nsvg__alloc(NSVGrasterizer* r, int size)
+{
+ unsigned char* buf;
+ if (size > NSVG__MEMPAGE_SIZE) return NULL;
+ if (r->curpage == NULL || r->curpage->size+size > NSVG__MEMPAGE_SIZE) {
+ r->curpage = nsvg__nextPage(r, r->curpage);
+ }
+ buf = &r->curpage->mem[r->curpage->size];
+ r->curpage->size += size;
+ return buf;
+}
+
+static int nsvg__ptEquals(float x1, float y1, float x2, float y2, float tol)
+{
+ float dx = x2 - x1;
+ float dy = y2 - y1;
+ return dx*dx + dy*dy < tol*tol;
+}
+
+static void nsvg__addPathPoint(NSVGrasterizer* r, float x, float y, int flags)
+{
+ NSVGpoint* pt;
+
+ if (r->npoints > 0) {
+ pt = &r->points[r->npoints-1];
+ if (nsvg__ptEquals(pt->x,pt->y, x,y, r->distTol)) {
+ pt->flags = (unsigned char)(pt->flags | flags);
+ return;
+ }
+ }
+
+ if (r->npoints+1 > r->cpoints) {
+ r->cpoints = r->cpoints > 0 ? r->cpoints * 2 : 64;
+ r->points = (NSVGpoint*)NANOSVG_realloc(r->points, sizeof(NSVGpoint) * r->cpoints);
+ if (r->points == NULL) return;
+ }
+
+ pt = &r->points[r->npoints];
+ pt->x = x;
+ pt->y = y;
+ pt->flags = (unsigned char)flags;
+ r->npoints++;
+}
+
+static void nsvg__appendPathPoint(NSVGrasterizer* r, NSVGpoint pt)
+{
+ if (r->npoints+1 > r->cpoints) {
+ r->cpoints = r->cpoints > 0 ? r->cpoints * 2 : 64;
+ r->points = (NSVGpoint*)NANOSVG_realloc(r->points, sizeof(NSVGpoint) * r->cpoints);
+ if (r->points == NULL) return;
+ }
+ r->points[r->npoints] = pt;
+ r->npoints++;
+}
+
+static void nsvg__duplicatePoints(NSVGrasterizer* r)
+{
+ if (r->npoints > r->cpoints2) {
+ r->cpoints2 = r->npoints;
+ r->points2 = (NSVGpoint*)NANOSVG_realloc(r->points2, sizeof(NSVGpoint) * r->cpoints2);
+ if (r->points2 == NULL) return;
+ }
+
+ memcpy(r->points2, r->points, sizeof(NSVGpoint) * r->npoints);
+ r->npoints2 = r->npoints;
+}
+
+static void nsvg__addEdge(NSVGrasterizer* r, float x0, float y0, float x1, float y1)
+{
+ NSVGedge* e;
+
+ // Skip horizontal edges
+ if (y0 == y1)
+ return;
+
+ if (r->nedges+1 > r->cedges) {
+ r->cedges = r->cedges > 0 ? r->cedges * 2 : 64;
+ r->edges = (NSVGedge*)NANOSVG_realloc(r->edges, sizeof(NSVGedge) * r->cedges);
+ if (r->edges == NULL) return;
+ }
+
+ e = &r->edges[r->nedges];
+ r->nedges++;
+
+ if (y0 < y1) {
+ e->x0 = x0;
+ e->y0 = y0;
+ e->x1 = x1;
+ e->y1 = y1;
+ e->dir = 1;
+ } else {
+ e->x0 = x1;
+ e->y0 = y1;
+ e->x1 = x0;
+ e->y1 = y0;
+ e->dir = -1;
+ }
+}
+
+static float nsvg__normalize(float *x, float* y)
+{
+ float d = sqrtf((*x)*(*x) + (*y)*(*y));
+ if (d > 1e-6f) {
+ float id = 1.0f / d;
+ *x *= id;
+ *y *= id;
+ }
+ return d;
+}
+
+static float nsvg__absf(float x) { return x < 0 ? -x : x; }
+
+static void nsvg__flattenCubicBez(NSVGrasterizer* r,
+ float x1, float y1, float x2, float y2,
+ float x3, float y3, float x4, float y4,
+ int level, int type)
+{
+ float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234;
+ float dx,dy,d2,d3;
+
+ if (level > 10) return;
+
+ x12 = (x1+x2)*0.5f;
+ y12 = (y1+y2)*0.5f;
+ x23 = (x2+x3)*0.5f;
+ y23 = (y2+y3)*0.5f;
+ x34 = (x3+x4)*0.5f;
+ y34 = (y3+y4)*0.5f;
+ x123 = (x12+x23)*0.5f;
+ y123 = (y12+y23)*0.5f;
+
+ dx = x4 - x1;
+ dy = y4 - y1;
+ d2 = nsvg__absf(((x2 - x4) * dy - (y2 - y4) * dx));
+ d3 = nsvg__absf(((x3 - x4) * dy - (y3 - y4) * dx));
+
+ if ((d2 + d3)*(d2 + d3) < r->tessTol * (dx*dx + dy*dy)) {
+ nsvg__addPathPoint(r, x4, y4, type);
+ return;
+ }
+
+ x234 = (x23+x34)*0.5f;
+ y234 = (y23+y34)*0.5f;
+ x1234 = (x123+x234)*0.5f;
+ y1234 = (y123+y234)*0.5f;
+
+ nsvg__flattenCubicBez(r, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0);
+ nsvg__flattenCubicBez(r, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type);
+}
+
+static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float scale)
+{
+ int i, j;
+ NSVGpath* path;
+
+ for (path = shape->paths; path != NULL; path = path->next) {
+ r->npoints = 0;
+ // Flatten path
+ nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
+ for (i = 0; i < path->npts-1; i += 3) {
+ float* p = &path->pts[i*2];
+ nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, 0);
+ }
+ // Close path
+ nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
+ // Build edges
+ for (i = 0, j = r->npoints-1; i < r->npoints; j = i++)
+ nsvg__addEdge(r, r->points[j].x, r->points[j].y, r->points[i].x, r->points[i].y);
+ }
+}
+
+enum NSVGpointFlags
+{
+ NSVG_PT_CORNER = 0x01,
+ NSVG_PT_BEVEL = 0x02,
+ NSVG_PT_LEFT = 0x04
+};
+
+static void nsvg__initClosed(NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
+{
+ float w = lineWidth * 0.5f;
+ float dx = p1->x - p0->x;
+ float dy = p1->y - p0->y;
+ float len = nsvg__normalize(&dx, &dy);
+ float px = p0->x + dx*len*0.5f, py = p0->y + dy*len*0.5f;
+ float dlx = dy, dly = -dx;
+ float lx = px - dlx*w, ly = py - dly*w;
+ float rx = px + dlx*w, ry = py + dly*w;
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static void nsvg__buttCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int connect)
+{
+ float w = lineWidth * 0.5f;
+ float px = p->x, py = p->y;
+ float dlx = dy, dly = -dx;
+ float lx = px - dlx*w, ly = py - dly*w;
+ float rx = px + dlx*w, ry = py + dly*w;
+
+ nsvg__addEdge(r, lx, ly, rx, ry);
+
+ if (connect) {
+ nsvg__addEdge(r, left->x, left->y, lx, ly);
+ nsvg__addEdge(r, rx, ry, right->x, right->y);
+ }
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static void nsvg__squareCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int connect)
+{
+ float w = lineWidth * 0.5f;
+ float px = p->x - dx*w, py = p->y - dy*w;
+ float dlx = dy, dly = -dx;
+ float lx = px - dlx*w, ly = py - dly*w;
+ float rx = px + dlx*w, ry = py + dly*w;
+
+ nsvg__addEdge(r, lx, ly, rx, ry);
+
+ if (connect) {
+ nsvg__addEdge(r, left->x, left->y, lx, ly);
+ nsvg__addEdge(r, rx, ry, right->x, right->y);
+ }
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+#ifndef NSVG_PI
+#define NSVG_PI (3.14159265358979323846264338327f)
+#endif
+
+static void nsvg__roundCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int ncap, int connect)
+{
+ int i;
+ float w = lineWidth * 0.5f;
+ float px = p->x, py = p->y;
+ float dlx = dy, dly = -dx;
+ float lx = 0, ly = 0, rx = 0, ry = 0, prevx = 0, prevy = 0;
+
+ for (i = 0; i < ncap; i++) {
+ float a = (float)i/(float)(ncap-1)*NSVG_PI;
+ float ax = cosf(a) * w, ay = sinf(a) * w;
+ float x = px - dlx*ax - dx*ay;
+ float y = py - dly*ax - dy*ay;
+
+ if (i > 0)
+ nsvg__addEdge(r, prevx, prevy, x, y);
+
+ prevx = x;
+ prevy = y;
+
+ if (i == 0) {
+ lx = x; ly = y;
+ } else if (i == ncap-1) {
+ rx = x; ry = y;
+ }
+ }
+
+ if (connect) {
+ nsvg__addEdge(r, left->x, left->y, lx, ly);
+ nsvg__addEdge(r, rx, ry, right->x, right->y);
+ }
+
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static void nsvg__bevelJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
+{
+ float w = lineWidth * 0.5f;
+ float dlx0 = p0->dy, dly0 = -p0->dx;
+ float dlx1 = p1->dy, dly1 = -p1->dx;
+ float lx0 = p1->x - (dlx0 * w), ly0 = p1->y - (dly0 * w);
+ float rx0 = p1->x + (dlx0 * w), ry0 = p1->y + (dly0 * w);
+ float lx1 = p1->x - (dlx1 * w), ly1 = p1->y - (dly1 * w);
+ float rx1 = p1->x + (dlx1 * w), ry1 = p1->y + (dly1 * w);
+
+ nsvg__addEdge(r, lx0, ly0, left->x, left->y);
+ nsvg__addEdge(r, lx1, ly1, lx0, ly0);
+
+ nsvg__addEdge(r, right->x, right->y, rx0, ry0);
+ nsvg__addEdge(r, rx0, ry0, rx1, ry1);
+
+ left->x = lx1; left->y = ly1;
+ right->x = rx1; right->y = ry1;
+}
+
+static void nsvg__miterJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
+{
+ float w = lineWidth * 0.5f;
+ float dlx0 = p0->dy, dly0 = -p0->dx;
+ float dlx1 = p1->dy, dly1 = -p1->dx;
+ float lx0, rx0, lx1, rx1;
+ float ly0, ry0, ly1, ry1;
+
+ if (p1->flags & NSVG_PT_LEFT) {
+ lx0 = lx1 = p1->x - p1->dmx * w;
+ ly0 = ly1 = p1->y - p1->dmy * w;
+ nsvg__addEdge(r, lx1, ly1, left->x, left->y);
+
+ rx0 = p1->x + (dlx0 * w);
+ ry0 = p1->y + (dly0 * w);
+ rx1 = p1->x + (dlx1 * w);
+ ry1 = p1->y + (dly1 * w);
+ nsvg__addEdge(r, right->x, right->y, rx0, ry0);
+ nsvg__addEdge(r, rx0, ry0, rx1, ry1);
+ } else {
+ lx0 = p1->x - (dlx0 * w);
+ ly0 = p1->y - (dly0 * w);
+ lx1 = p1->x - (dlx1 * w);
+ ly1 = p1->y - (dly1 * w);
+ nsvg__addEdge(r, lx0, ly0, left->x, left->y);
+ nsvg__addEdge(r, lx1, ly1, lx0, ly0);
+
+ rx0 = rx1 = p1->x + p1->dmx * w;
+ ry0 = ry1 = p1->y + p1->dmy * w;
+ nsvg__addEdge(r, right->x, right->y, rx1, ry1);
+ }
+
+ left->x = lx1; left->y = ly1;
+ right->x = rx1; right->y = ry1;
+}
+
+static void nsvg__roundJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth, int ncap)
+{
+ int i, n;
+ float w = lineWidth * 0.5f;
+ float dlx0 = p0->dy, dly0 = -p0->dx;
+ float dlx1 = p1->dy, dly1 = -p1->dx;
+ float a0 = atan2f(dly0, dlx0);
+ float a1 = atan2f(dly1, dlx1);
+ float da = a1 - a0;
+ float lx, ly, rx, ry;
+
+ if (da < NSVG_PI) da += NSVG_PI*2;
+ if (da > NSVG_PI) da -= NSVG_PI*2;
+
+ n = (int)ceilf((nsvg__absf(da) / NSVG_PI) * (float)ncap);
+ if (n < 2) n = 2;
+ if (n > ncap) n = ncap;
+
+ lx = left->x;
+ ly = left->y;
+ rx = right->x;
+ ry = right->y;
+
+ for (i = 0; i < n; i++) {
+ float u = (float)i/(float)(n-1);
+ float a = a0 + u*da;
+ float ax = cosf(a) * w, ay = sinf(a) * w;
+ float lx1 = p1->x - ax, ly1 = p1->y - ay;
+ float rx1 = p1->x + ax, ry1 = p1->y + ay;
+
+ nsvg__addEdge(r, lx1, ly1, lx, ly);
+ nsvg__addEdge(r, rx, ry, rx1, ry1);
+
+ lx = lx1; ly = ly1;
+ rx = rx1; ry = ry1;
+ }
+
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static void nsvg__straightJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p1, float lineWidth)
+{
+ float w = lineWidth * 0.5f;
+ float lx = p1->x - (p1->dmx * w), ly = p1->y - (p1->dmy * w);
+ float rx = p1->x + (p1->dmx * w), ry = p1->y + (p1->dmy * w);
+
+ nsvg__addEdge(r, lx, ly, left->x, left->y);
+ nsvg__addEdge(r, right->x, right->y, rx, ry);
+
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static int nsvg__curveDivs(float r, float arc, float tol)
+{
+ float da = acosf(r / (r + tol)) * 2.0f;
+ int divs = (int)ceilf(arc / da);
+ if (divs < 2) divs = 2;
+ return divs;
+}
+
+static void nsvg__expandStroke(NSVGrasterizer* r, NSVGpoint* points, int npoints, int closed, int lineJoin, int lineCap, float lineWidth)
+{
+ int ncap = nsvg__curveDivs(lineWidth*0.5f, NSVG_PI, r->tessTol); // Calculate divisions per half circle.
+ NSVGpoint left = {0,0,0,0,0,0,0,0}, right = {0,0,0,0,0,0,0,0}, firstLeft = {0,0,0,0,0,0,0,0}, firstRight = {0,0,0,0,0,0,0,0};
+ NSVGpoint* p0, *p1;
+ int j, s, e;
+
+ // Build stroke edges
+ if (closed) {
+ // Looping
+ p0 = &points[npoints-1];
+ p1 = &points[0];
+ s = 0;
+ e = npoints;
+ } else {
+ // Add cap
+ p0 = &points[0];
+ p1 = &points[1];
+ s = 1;
+ e = npoints-1;
+ }
+
+ if (closed) {
+ nsvg__initClosed(&left, &right, p0, p1, lineWidth);
+ firstLeft = left;
+ firstRight = right;
+ } else {
+ // Add cap
+ float dx = p1->x - p0->x;
+ float dy = p1->y - p0->y;
+ nsvg__normalize(&dx, &dy);
+ if (lineCap == NSVG_CAP_BUTT)
+ nsvg__buttCap(r, &left, &right, p0, dx, dy, lineWidth, 0);
+ else if (lineCap == NSVG_CAP_SQUARE)
+ nsvg__squareCap(r, &left, &right, p0, dx, dy, lineWidth, 0);
+ else if (lineCap == NSVG_CAP_ROUND)
+ nsvg__roundCap(r, &left, &right, p0, dx, dy, lineWidth, ncap, 0);
+ }
+
+ for (j = s; j < e; ++j) {
+ if (p1->flags & NSVG_PT_CORNER) {
+ if (lineJoin == NSVG_JOIN_ROUND)
+ nsvg__roundJoin(r, &left, &right, p0, p1, lineWidth, ncap);
+ else if (lineJoin == NSVG_JOIN_BEVEL || (p1->flags & NSVG_PT_BEVEL))
+ nsvg__bevelJoin(r, &left, &right, p0, p1, lineWidth);
+ else
+ nsvg__miterJoin(r, &left, &right, p0, p1, lineWidth);
+ } else {
+ nsvg__straightJoin(r, &left, &right, p1, lineWidth);
+ }
+ p0 = p1++;
+ }
+
+ if (closed) {
+ // Loop it
+ nsvg__addEdge(r, firstLeft.x, firstLeft.y, left.x, left.y);
+ nsvg__addEdge(r, right.x, right.y, firstRight.x, firstRight.y);
+ } else {
+ // Add cap
+ float dx = p1->x - p0->x;
+ float dy = p1->y - p0->y;
+ nsvg__normalize(&dx, &dy);
+ if (lineCap == NSVG_CAP_BUTT)
+ nsvg__buttCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1);
+ else if (lineCap == NSVG_CAP_SQUARE)
+ nsvg__squareCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1);
+ else if (lineCap == NSVG_CAP_ROUND)
+ nsvg__roundCap(r, &right, &left, p1, -dx, -dy, lineWidth, ncap, 1);
+ }
+}
+
+static void nsvg__prepareStroke(NSVGrasterizer* r, float miterLimit, int lineJoin)
+{
+ int i, j;
+ NSVGpoint* p0, *p1;
+
+ p0 = &r->points[r->npoints-1];
+ p1 = &r->points[0];
+ for (i = 0; i < r->npoints; i++) {
+ // Calculate segment direction and length
+ p0->dx = p1->x - p0->x;
+ p0->dy = p1->y - p0->y;
+ p0->len = nsvg__normalize(&p0->dx, &p0->dy);
+ // Advance
+ p0 = p1++;
+ }
+
+ // calculate joins
+ p0 = &r->points[r->npoints-1];
+ p1 = &r->points[0];
+ for (j = 0; j < r->npoints; j++) {
+ float dlx0, dly0, dlx1, dly1, dmr2, cross;
+ dlx0 = p0->dy;
+ dly0 = -p0->dx;
+ dlx1 = p1->dy;
+ dly1 = -p1->dx;
+ // Calculate extrusions
+ p1->dmx = (dlx0 + dlx1) * 0.5f;
+ p1->dmy = (dly0 + dly1) * 0.5f;
+ dmr2 = p1->dmx*p1->dmx + p1->dmy*p1->dmy;
+ if (dmr2 > 0.000001f) {
+ float s2 = 1.0f / dmr2;
+ if (s2 > 600.0f) {
+ s2 = 600.0f;
+ }
+ p1->dmx *= s2;
+ p1->dmy *= s2;
+ }
+
+ // Clear flags, but keep the corner.
+ p1->flags = (p1->flags & NSVG_PT_CORNER) ? NSVG_PT_CORNER : 0;
+
+ // Keep track of left turns.
+ cross = p1->dx * p0->dy - p0->dx * p1->dy;
+ if (cross > 0.0f)
+ p1->flags |= NSVG_PT_LEFT;
+
+ // Check to see if the corner needs to be beveled.
+ if (p1->flags & NSVG_PT_CORNER) {
+ if ((dmr2 * miterLimit*miterLimit) < 1.0f || lineJoin == NSVG_JOIN_BEVEL || lineJoin == NSVG_JOIN_ROUND) {
+ p1->flags |= NSVG_PT_BEVEL;
+ }
+ }
+
+ p0 = p1++;
+ }
+}
+
+static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float scale)
+{
+ int i, j, closed;
+ NSVGpath* path;
+ NSVGpoint* p0, *p1;
+ float miterLimit = shape->miterLimit;
+ int lineJoin = shape->strokeLineJoin;
+ int lineCap = shape->strokeLineCap;
+ float lineWidth = shape->strokeWidth * scale;
+
+ for (path = shape->paths; path != NULL; path = path->next) {
+ // Flatten path
+ r->npoints = 0;
+ nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, NSVG_PT_CORNER);
+ for (i = 0; i < path->npts-1; i += 3) {
+ float* p = &path->pts[i*2];
+ nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, NSVG_PT_CORNER);
+ }
+ if (r->npoints < 2)
+ continue;
+
+ closed = path->closed;
+
+ // If the first and last points are the same, remove the last, mark as closed path.
+ p0 = &r->points[r->npoints-1];
+ p1 = &r->points[0];
+ if (nsvg__ptEquals(p0->x,p0->y, p1->x,p1->y, r->distTol)) {
+ r->npoints--;
+ p0 = &r->points[r->npoints-1];
+ closed = 1;
+ }
+
+ if (shape->strokeDashCount > 0) {
+ int idash = 0, dashState = 1;
+ float totalDist = 0, dashLen, allDashLen, dashOffset;
+ NSVGpoint cur;
+
+ if (closed)
+ nsvg__appendPathPoint(r, r->points[0]);
+
+ // Duplicate points -> points2.
+ nsvg__duplicatePoints(r);
+
+ r->npoints = 0;
+ cur = r->points2[0];
+ nsvg__appendPathPoint(r, cur);
+
+ // Figure out dash offset.
+ allDashLen = 0;
+ for (j = 0; j < shape->strokeDashCount; j++)
+ allDashLen += shape->strokeDashArray[j];
+ if (shape->strokeDashCount & 1)
+ allDashLen *= 2.0f;
+ // Find location inside pattern
+ dashOffset = fmodf(shape->strokeDashOffset, allDashLen);
+ if (dashOffset < 0.0f)
+ dashOffset += allDashLen;
+
+ while (dashOffset > shape->strokeDashArray[idash]) {
+ dashOffset -= shape->strokeDashArray[idash];
+ idash = (idash + 1) % shape->strokeDashCount;
+ }
+ dashLen = (shape->strokeDashArray[idash] - dashOffset) * scale;
+
+ for (j = 1; j < r->npoints2; ) {
+ float dx = r->points2[j].x - cur.x;
+ float dy = r->points2[j].y - cur.y;
+ float dist = sqrtf(dx*dx + dy*dy);
+
+ if ((totalDist + dist) > dashLen) {
+ // Calculate intermediate point
+ float d = (dashLen - totalDist) / dist;
+ float x = cur.x + dx * d;
+ float y = cur.y + dy * d;
+ nsvg__addPathPoint(r, x, y, NSVG_PT_CORNER);
+
+ // Stroke
+ if (r->npoints > 1 && dashState) {
+ nsvg__prepareStroke(r, miterLimit, lineJoin);
+ nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth);
+ }
+ // Advance dash pattern
+ dashState = !dashState;
+ idash = (idash+1) % shape->strokeDashCount;
+ dashLen = shape->strokeDashArray[idash] * scale;
+ // Restart
+ cur.x = x;
+ cur.y = y;
+ cur.flags = NSVG_PT_CORNER;
+ totalDist = 0.0f;
+ r->npoints = 0;
+ nsvg__appendPathPoint(r, cur);
+ } else {
+ totalDist += dist;
+ cur = r->points2[j];
+ nsvg__appendPathPoint(r, cur);
+ j++;
+ }
+ }
+ // Stroke any leftover path
+ if (r->npoints > 1 && dashState)
+ nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth);
+ } else {
+ nsvg__prepareStroke(r, miterLimit, lineJoin);
+ nsvg__expandStroke(r, r->points, r->npoints, closed, lineJoin, lineCap, lineWidth);
+ }
+ }
+}
+
+static int nsvg__cmpEdge(const void *p, const void *q)
+{
+ const NSVGedge* a = (const NSVGedge*)p;
+ const NSVGedge* b = (const NSVGedge*)q;
+
+ if (a->y0 < b->y0) return -1;
+ if (a->y0 > b->y0) return 1;
+ return 0;
+}
+
+
+static NSVGactiveEdge* nsvg__addActive(NSVGrasterizer* r, NSVGedge* e, float startPoint)
+{
+ NSVGactiveEdge* z;
+ float dxdy;
+
+ if (r->freelist != NULL) {
+ // Restore from freelist.
+ z = r->freelist;
+ r->freelist = z->next;
+ } else {
+ // Alloc new edge.
+ z = (NSVGactiveEdge*)nsvg__alloc(r, sizeof(NSVGactiveEdge));
+ if (z == NULL) return NULL;
+ }
+
+ dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
+// STBTT_assert(e->y0 <= start_point);
+ // round dx down to avoid going too far
+ if (dxdy < 0)
+ z->dx = (int)(-floorf(NSVG__FIX * -dxdy));
+ else
+ z->dx = (int)floorf(NSVG__FIX * dxdy);
+ z->x = (int)floorf(NSVG__FIX * (e->x0 + dxdy * (startPoint - e->y0)));
+// z->x -= off_x * FIX;
+ z->ey = e->y1;
+ z->next = 0;
+ z->dir = e->dir;
+
+ return z;
+}
+
+static void nsvg__freeActive(NSVGrasterizer* r, NSVGactiveEdge* z)
+{
+ z->next = r->freelist;
+ r->freelist = z;
+}
+
+static void nsvg__fillScanline(unsigned char* scanline, int len, int x0, int x1, int maxWeight, int* xmin, int* xmax)
+{
+ int i = x0 >> NSVG__FIXSHIFT;
+ int j = x1 >> NSVG__FIXSHIFT;
+ if (i < *xmin) *xmin = i;
+ if (j > *xmax) *xmax = j;
+ if (i < len && j >= 0) {
+ if (i == j) {
+ // x0,x1 are the same pixel, so compute combined coverage
+ scanline[i] = (unsigned char)(scanline[i] + ((x1 - x0) * maxWeight >> NSVG__FIXSHIFT));
+ } else {
+ if (i >= 0) // add antialiasing for x0
+ scanline[i] = (unsigned char)(scanline[i] + (((NSVG__FIX - (x0 & NSVG__FIXMASK)) * maxWeight) >> NSVG__FIXSHIFT));
+ else
+ i = -1; // clip
+
+ if (j < len) // add antialiasing for x1
+ scanline[j] = (unsigned char)(scanline[j] + (((x1 & NSVG__FIXMASK) * maxWeight) >> NSVG__FIXSHIFT));
+ else
+ j = len; // clip
+
+ for (++i; i < j; ++i) // fill pixels between x0 and x1
+ scanline[i] = (unsigned char)(scanline[i] + maxWeight);
+ }
+ }
+}
+
+// note: this routine clips fills that extend off the edges... ideally this
+// wouldn't happen, but it could happen if the truetype glyph bounding boxes
+// are wrong, or if the user supplies a too-small bitmap
+static void nsvg__fillActiveEdges(unsigned char* scanline, int len, NSVGactiveEdge* e, int maxWeight, int* xmin, int* xmax, char fillRule)
+{
+ // non-zero winding fill
+ int x0 = 0, w = 0;
+
+ if (fillRule == NSVG_FILLRULE_NONZERO) {
+ // Non-zero
+ while (e != NULL) {
+ if (w == 0) {
+ // if we're currently at zero, we need to record the edge start point
+ x0 = e->x; w += e->dir;
+ } else {
+ int x1 = e->x; w += e->dir;
+ // if we went to zero, we need to draw
+ if (w == 0)
+ nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax);
+ }
+ e = e->next;
+ }
+ } else if (fillRule == NSVG_FILLRULE_EVENODD) {
+ // Even-odd
+ while (e != NULL) {
+ if (w == 0) {
+ // if we're currently at zero, we need to record the edge start point
+ x0 = e->x; w = 1;
+ } else {
+ int x1 = e->x; w = 0;
+ nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax);
+ }
+ e = e->next;
+ }
+ }
+}
+
+static float nsvg__clampf(float a, float mn, float mx) { return a < mn ? mn : (a > mx ? mx : a); }
+
+static unsigned int nsvg__RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
+{
+ return (r) | (g << 8) | (b << 16) | (a << 24);
+}
+
+static unsigned int nsvg__lerpRGBA(unsigned int c0, unsigned int c1, float u)
+{
+ int iu = (int)(nsvg__clampf(u, 0.0f, 1.0f) * 256.0f);
+ int r = (((c0) & 0xff)*(256-iu) + (((c1) & 0xff)*iu)) >> 8;
+ int g = (((c0>>8) & 0xff)*(256-iu) + (((c1>>8) & 0xff)*iu)) >> 8;
+ int b = (((c0>>16) & 0xff)*(256-iu) + (((c1>>16) & 0xff)*iu)) >> 8;
+ int a = (((c0>>24) & 0xff)*(256-iu) + (((c1>>24) & 0xff)*iu)) >> 8;
+ return nsvg__RGBA((unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a);
+}
+
+static unsigned int nsvg__applyOpacity(unsigned int c, float u)
+{
+ int iu = (int)(nsvg__clampf(u, 0.0f, 1.0f) * 256.0f);
+ int r = (c) & 0xff;
+ int g = (c>>8) & 0xff;
+ int b = (c>>16) & 0xff;
+ int a = (((c>>24) & 0xff)*iu) >> 8;
+ return nsvg__RGBA((unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a);
+}
+
+static inline int nsvg__div255(int x)
+{
+ return ((x+1) * 257) >> 16;
+}
+
+static void nsvg__scanlineSolid(unsigned char* dst, int count, unsigned char* cover, int x, int y,
+ float tx, float ty, float scale, NSVGcachedPaint* cache)
+{
+
+ if (cache->type == NSVG_PAINT_COLOR) {
+ int i, cr, cg, cb, ca;
+ cr = cache->colors[0] & 0xff;
+ cg = (cache->colors[0] >> 8) & 0xff;
+ cb = (cache->colors[0] >> 16) & 0xff;
+ ca = (cache->colors[0] >> 24) & 0xff;
+
+ for (i = 0; i < count; i++) {
+ int r,g,b;
+ int a = nsvg__div255((int)cover[0] * ca);
+ int ia = 255 - a;
+ // Premultiply
+ r = nsvg__div255(cr * a);
+ g = nsvg__div255(cg * a);
+ b = nsvg__div255(cb * a);
+
+ // Blend over
+ r += nsvg__div255(ia * (int)dst[0]);
+ g += nsvg__div255(ia * (int)dst[1]);
+ b += nsvg__div255(ia * (int)dst[2]);
+ a += nsvg__div255(ia * (int)dst[3]);
+
+ dst[0] = (unsigned char)r;
+ dst[1] = (unsigned char)g;
+ dst[2] = (unsigned char)b;
+ dst[3] = (unsigned char)a;
+
+ cover++;
+ dst += 4;
+ }
+ } else if (cache->type == NSVG_PAINT_LINEAR_GRADIENT) {
+ // TODO: spread modes.
+ // TODO: plenty of opportunities to optimize.
+ float fx, fy, dx, gy;
+ float* t = cache->xform;
+ int i, cr, cg, cb, ca;
+ unsigned int c;
+
+ fx = ((float)x - tx) / scale;
+ fy = ((float)y - ty) / scale;
+ dx = 1.0f / scale;
+
+ for (i = 0; i < count; i++) {
+ int r,g,b,a,ia;
+ gy = fx*t[1] + fy*t[3] + t[5];
+ c = cache->colors[(int)nsvg__clampf(gy*255.0f, 0, 255.0f)];
+ cr = (c) & 0xff;
+ cg = (c >> 8) & 0xff;
+ cb = (c >> 16) & 0xff;
+ ca = (c >> 24) & 0xff;
+
+ a = nsvg__div255((int)cover[0] * ca);
+ ia = 255 - a;
+
+ // Premultiply
+ r = nsvg__div255(cr * a);
+ g = nsvg__div255(cg * a);
+ b = nsvg__div255(cb * a);
+
+ // Blend over
+ r += nsvg__div255(ia * (int)dst[0]);
+ g += nsvg__div255(ia * (int)dst[1]);
+ b += nsvg__div255(ia * (int)dst[2]);
+ a += nsvg__div255(ia * (int)dst[3]);
+
+ dst[0] = (unsigned char)r;
+ dst[1] = (unsigned char)g;
+ dst[2] = (unsigned char)b;
+ dst[3] = (unsigned char)a;
+
+ cover++;
+ dst += 4;
+ fx += dx;
+ }
+ } else if (cache->type == NSVG_PAINT_RADIAL_GRADIENT) {
+ // TODO: spread modes.
+ // TODO: plenty of opportunities to optimize.
+ // TODO: focus (fx,fy)
+ float fx, fy, dx, gx, gy, gd;
+ float* t = cache->xform;
+ int i, cr, cg, cb, ca;
+ unsigned int c;
+
+ fx = ((float)x - tx) / scale;
+ fy = ((float)y - ty) / scale;
+ dx = 1.0f / scale;
+
+ for (i = 0; i < count; i++) {
+ int r,g,b,a,ia;
+ gx = fx*t[0] + fy*t[2] + t[4];
+ gy = fx*t[1] + fy*t[3] + t[5];
+ gd = sqrtf(gx*gx + gy*gy);
+ c = cache->colors[(int)nsvg__clampf(gd*255.0f, 0, 255.0f)];
+ cr = (c) & 0xff;
+ cg = (c >> 8) & 0xff;
+ cb = (c >> 16) & 0xff;
+ ca = (c >> 24) & 0xff;
+
+ a = nsvg__div255((int)cover[0] * ca);
+ ia = 255 - a;
+
+ // Premultiply
+ r = nsvg__div255(cr * a);
+ g = nsvg__div255(cg * a);
+ b = nsvg__div255(cb * a);
+
+ // Blend over
+ r += nsvg__div255(ia * (int)dst[0]);
+ g += nsvg__div255(ia * (int)dst[1]);
+ b += nsvg__div255(ia * (int)dst[2]);
+ a += nsvg__div255(ia * (int)dst[3]);
+
+ dst[0] = (unsigned char)r;
+ dst[1] = (unsigned char)g;
+ dst[2] = (unsigned char)b;
+ dst[3] = (unsigned char)a;
+
+ cover++;
+ dst += 4;
+ fx += dx;
+ }
+ }
+}
+
+static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float scale, NSVGcachedPaint* cache, char fillRule)
+{
+ NSVGactiveEdge *active = NULL;
+ int y, s;
+ int e = 0;
+ int maxWeight = (255 / NSVG__SUBSAMPLES); // weight per vertical scanline
+ int xmin, xmax;
+
+ for (y = 0; y < r->height; y++) {
+ memset(r->scanline, 0, r->width);
+ xmin = r->width;
+ xmax = 0;
+ for (s = 0; s < NSVG__SUBSAMPLES; ++s) {
+ // find center of pixel for this scanline
+ float scany = (float)(y*NSVG__SUBSAMPLES + s) + 0.5f;
+ NSVGactiveEdge **step = &active;
+
+ // update all active edges;
+ // remove all active edges that terminate before the center of this scanline
+ while (*step) {
+ NSVGactiveEdge *z = *step;
+ if (z->ey <= scany) {
+ *step = z->next; // delete from list
+// NSVG__assert(z->valid);
+ nsvg__freeActive(r, z);
+ } else {
+ z->x += z->dx; // advance to position for current scanline
+ step = &((*step)->next); // advance through list
+ }
+ }
+
+ // resort the list if needed
+ for (;;) {
+ int changed = 0;
+ step = &active;
+ while (*step && (*step)->next) {
+ if ((*step)->x > (*step)->next->x) {
+ NSVGactiveEdge* t = *step;
+ NSVGactiveEdge* q = t->next;
+ t->next = q->next;
+ q->next = t;
+ *step = q;
+ changed = 1;
+ }
+ step = &(*step)->next;
+ }
+ if (!changed) break;
+ }
+
+ // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline
+ while (e < r->nedges && r->edges[e].y0 <= scany) {
+ if (r->edges[e].y1 > scany) {
+ NSVGactiveEdge* z = nsvg__addActive(r, &r->edges[e], scany);
+ if (z == NULL) break;
+ // find insertion point
+ if (active == NULL) {
+ active = z;
+ } else if (z->x < active->x) {
+ // insert at front
+ z->next = active;
+ active = z;
+ } else {
+ // find thing to insert AFTER
+ NSVGactiveEdge* p = active;
+ while (p->next && p->next->x < z->x)
+ p = p->next;
+ // at this point, p->next->x is NOT < z->x
+ z->next = p->next;
+ p->next = z;
+ }
+ }
+ e++;
+ }
+
+ // now process all active edges in non-zero fashion
+ if (active != NULL)
+ nsvg__fillActiveEdges(r->scanline, r->width, active, maxWeight, &xmin, &xmax, fillRule);
+ }
+ // Blit
+ if (xmin < 0) xmin = 0;
+ if (xmax > r->width-1) xmax = r->width-1;
+ if (xmin <= xmax) {
+ nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, scale, cache);
+ }
+ }
+
+}
+
+static void nsvg__unpremultiplyAlpha(unsigned char* image, int w, int h, int stride)
+{
+ int x,y;
+
+ // Unpremultiply
+ for (y = 0; y < h; y++) {
+ unsigned char *row = &image[y*stride];
+ for (x = 0; x < w; x++) {
+ int r = row[0], g = row[1], b = row[2], a = row[3];
+ if (a != 0) {
+ row[0] = (unsigned char)(r*255/a);
+ row[1] = (unsigned char)(g*255/a);
+ row[2] = (unsigned char)(b*255/a);
+ }
+ row += 4;
+ }
+ }
+
+ // Defringe
+ for (y = 0; y < h; y++) {
+ unsigned char *row = &image[y*stride];
+ for (x = 0; x < w; x++) {
+ int r = 0, g = 0, b = 0, a = row[3], n = 0;
+ if (a == 0) {
+ if (x-1 > 0 && row[-1] != 0) {
+ r += row[-4];
+ g += row[-3];
+ b += row[-2];
+ n++;
+ }
+ if (x+1 < w && row[7] != 0) {
+ r += row[4];
+ g += row[5];
+ b += row[6];
+ n++;
+ }
+ if (y-1 > 0 && row[-stride+3] != 0) {
+ r += row[-stride];
+ g += row[-stride+1];
+ b += row[-stride+2];
+ n++;
+ }
+ if (y+1 < h && row[stride+3] != 0) {
+ r += row[stride];
+ g += row[stride+1];
+ b += row[stride+2];
+ n++;
+ }
+ if (n > 0) {
+ row[0] = (unsigned char)(r/n);
+ row[1] = (unsigned char)(g/n);
+ row[2] = (unsigned char)(b/n);
+ }
+ }
+ row += 4;
+ }
+ }
+}
+
+
+static void nsvg__initPaint(NSVGcachedPaint* cache, NSVGpaint* paint, float opacity)
+{
+ int i, j;
+ NSVGgradient* grad;
+
+ cache->type = paint->type;
+
+ if (paint->type == NSVG_PAINT_COLOR) {
+ cache->colors[0] = nsvg__applyOpacity(paint->color, opacity);
+ return;
+ }
+
+ grad = paint->gradient;
+
+ cache->spread = grad->spread;
+ memcpy(cache->xform, grad->xform, sizeof(float)*6);
+
+ if (grad->nstops == 0) {
+ for (i = 0; i < 256; i++)
+ cache->colors[i] = 0;
+ } if (grad->nstops == 1) {
+ for (i = 0; i < 256; i++)
+ cache->colors[i] = nsvg__applyOpacity(grad->stops[i].color, opacity);
+ } else {
+ unsigned int ca, cb = 0;
+ float ua, ub, du, u;
+ int ia, ib, count;
+
+ ca = nsvg__applyOpacity(grad->stops[0].color, opacity);
+ ua = nsvg__clampf(grad->stops[0].offset, 0, 1);
+ ub = nsvg__clampf(grad->stops[grad->nstops-1].offset, ua, 1);
+ ia = (int)(ua * 255.0f);
+ ib = (int)(ub * 255.0f);
+ for (i = 0; i < ia; i++) {
+ cache->colors[i] = ca;
+ }
+
+ for (i = 0; i < grad->nstops-1; i++) {
+ ca = nsvg__applyOpacity(grad->stops[i].color, opacity);
+ cb = nsvg__applyOpacity(grad->stops[i+1].color, opacity);
+ ua = nsvg__clampf(grad->stops[i].offset, 0, 1);
+ ub = nsvg__clampf(grad->stops[i+1].offset, 0, 1);
+ ia = (int)(ua * 255.0f);
+ ib = (int)(ub * 255.0f);
+ count = ib - ia;
+ if (count <= 0) continue;
+ u = 0;
+ du = 1.0f / (float)count;
+ for (j = 0; j < count; j++) {
+ cache->colors[ia+j] = nsvg__lerpRGBA(ca,cb,u);
+ u += du;
+ }
+ }
+
+ for (i = ib; i < 256; i++)
+ cache->colors[i] = cb;
+ }
+
+}
+
+/*
+static void dumpEdges(NSVGrasterizer* r, const char* name)
+{
+ float xmin = 0, xmax = 0, ymin = 0, ymax = 0;
+ NSVGedge *e = NULL;
+ int i;
+ if (r->nedges == 0) return;
+ FILE* fp = fopen(name, "w");
+ if (fp == NULL) return;
+
+ xmin = xmax = r->edges[0].x0;
+ ymin = ymax = r->edges[0].y0;
+ for (i = 0; i < r->nedges; i++) {
+ e = &r->edges[i];
+ xmin = nsvg__minf(xmin, e->x0);
+ xmin = nsvg__minf(xmin, e->x1);
+ xmax = nsvg__maxf(xmax, e->x0);
+ xmax = nsvg__maxf(xmax, e->x1);
+ ymin = nsvg__minf(ymin, e->y0);
+ ymin = nsvg__minf(ymin, e->y1);
+ ymax = nsvg__maxf(ymax, e->y0);
+ ymax = nsvg__maxf(ymax, e->y1);
+ }
+
+ fprintf(fp, "<svg viewBox=\"%f %f %f %f\" xmlns=\"http://www.w3.org/2000/svg\">", xmin, ymin, (xmax - xmin), (ymax - ymin));
+
+ for (i = 0; i < r->nedges; i++) {
+ e = &r->edges[i];
+ fprintf(fp ,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" style=\"stroke:#000;\" />", e->x0,e->y0, e->x1,e->y1);
+ }
+
+ for (i = 0; i < r->npoints; i++) {
+ if (i+1 < r->npoints)
+ fprintf(fp ,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" style=\"stroke:#f00;\" />", r->points[i].x, r->points[i].y, r->points[i+1].x, r->points[i+1].y);
+ fprintf(fp ,"<circle cx=\"%f\" cy=\"%f\" r=\"1\" style=\"fill:%s;\" />", r->points[i].x, r->points[i].y, r->points[i].flags == 0 ? "#f00" : "#0f0");
+ }
+
+ fprintf(fp, "</svg>");
+ fclose(fp);
+}
+*/
+
+NANOSVG_SCOPE
+void nsvgRasterize(NSVGrasterizer* r,
+ NSVGimage* image, float tx, float ty, float scale,
+ unsigned char* dst, int w, int h, int stride)
+{
+ NSVGshape *shape = NULL;
+ NSVGedge *e = NULL;
+ NSVGcachedPaint cache;
+ int i;
+
+ r->bitmap = dst;
+ r->width = w;
+ r->height = h;
+ r->stride = stride;
+
+ if (w > r->cscanline) {
+ r->cscanline = w;
+ r->scanline = (unsigned char*)NANOSVG_realloc(r->scanline, w);
+ if (r->scanline == NULL) return;
+ }
+
+ for (i = 0; i < h; i++)
+ memset(&dst[i*stride], 0, w*4);
+
+ for (shape = image->shapes; shape != NULL; shape = shape->next) {
+ if (!(shape->flags & NSVG_FLAGS_VISIBLE))
+ continue;
+
+ if (shape->fill.type != NSVG_PAINT_NONE) {
+ nsvg__resetPool(r);
+ r->freelist = NULL;
+ r->nedges = 0;
+
+ nsvg__flattenShape(r, shape, scale);
+
+ // Scale and translate edges
+ for (i = 0; i < r->nedges; i++) {
+ e = &r->edges[i];
+ e->x0 = tx + e->x0;
+ e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES;
+ e->x1 = tx + e->x1;
+ e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES;
+ }
+
+ // Rasterize edges
+ qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
+
+ // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
+ nsvg__initPaint(&cache, &shape->fill, shape->opacity);
+
+ nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, shape->fillRule);
+ }
+ if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * scale) > 0.01f) {
+ nsvg__resetPool(r);
+ r->freelist = NULL;
+ r->nedges = 0;
+
+ nsvg__flattenShapeStroke(r, shape, scale);
+
+// dumpEdges(r, "edge.svg");
+
+ // Scale and translate edges
+ for (i = 0; i < r->nedges; i++) {
+ e = &r->edges[i];
+ e->x0 = tx + e->x0;
+ e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES;
+ e->x1 = tx + e->x1;
+ e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES;
+ }
+
+ // Rasterize edges
+ qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
+
+ // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
+ nsvg__initPaint(&cache, &shape->stroke, shape->opacity);
+
+ nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, NSVG_FILLRULE_NONZERO);
+ }
+ }
+
+ nsvg__unpremultiplyAlpha(dst, w, h, stride);
+
+ r->bitmap = NULL;
+ r->width = 0;
+ r->height = 0;
+ r->stride = 0;
+}
+
+#endif
diff --git a/generic/tk.decls b/generic/tk.decls
index 9ab13b2..2952bc3 100644
--- a/generic/tk.decls
+++ b/generic/tk.decls
@@ -1147,6 +1147,30 @@ declare 9 aqua {
declare 10 aqua {
int Tk_MacOSXIsAppInFront(void)
}
+declare 11 aqua {
+ void Tk_MacOSXSetEmbedHandler_(
+ Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr,
+ Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr,
+ Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr,
+ Tk_MacOSXEmbedGetClipProc *getClipProc,
+ Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc)
+}
+declare 12 aqua {
+ void Tk_MacOSXTurnOffMenus_(void)
+}
+declare 13 aqua {
+ void Tk_MacOSXTkOwnsCursor_(int tkOwnsIt)
+}
+declare 14 aqua {
+ void TkMacOSXInitMenus_(Tcl_Interp *interp)
+}
+declare 15 aqua {
+ void TkMacOSXInitAppleEvents_(Tcl_Interp *interp)
+}
+declare 16 aqua {
+ void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y, int width,
+ int height, int flags)
+}
##############################################################################
diff --git a/generic/tk.h b/generic/tk.h
index f106f1c..3c75b98 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -68,10 +68,10 @@ extern "C" {
#define TK_MAJOR_VERSION 8
#define TK_MINOR_VERSION 7
#define TK_RELEASE_LEVEL TCL_ALPHA_RELEASE
-#define TK_RELEASE_SERIAL 2
+#define TK_RELEASE_SERIAL 4
#define TK_VERSION "8.7"
-#define TK_PATCH_LEVEL "8.7a2"
+#define TK_PATCH_LEVEL "8.7a4"
/*
* A special definition used to allow this header file to be included from
@@ -85,13 +85,17 @@ extern "C" {
#ifndef RC_INVOKED
-#ifndef _XLIB_H
+#if !defined(_XLIB_H) && !defined(_X11_XLIB_H_)
+#if defined(__GNUC__) && !defined(__cplusplus)
+# pragma GCC diagnostic ignored "-Wc++-compat"
+#endif
# include <X11/Xlib.h>
# ifdef MAC_OSX_TK
# include <X11/X.h>
# endif
#endif
-#ifdef __STDC__
+#if defined(STDC_HEADERS) || defined(__STDC__) || defined(__C99__FUNC__) \
+ || defined(__cplusplus) || defined(_MSC_VER) || defined(__ICC)
# include <stddef.h>
#endif
@@ -110,7 +114,7 @@ extern "C" {
* Decide whether or not to use input methods.
*/
-#ifdef XNQueryInputStyle
+#if defined(XNQueryInputStyle) && !defined(_WIN32) && !defined(MAC_OSX_TK)
#define TK_USE_INPUT_METHODS
#endif
@@ -191,17 +195,17 @@ typedef struct Tk_OptionSpec {
size_t objOffset; /* Where in record to store a Tcl_Obj * that
* holds the value of this option, specified
* as an offset in bytes from the start of the
- * record. Use the Tk_Offset macro to generate
- * values for this. -1 means don't store the
- * Tcl_Obj in the record. */
+ * record. Use the offsetof macro to generate
+ * values for this. TCL_INDEX_NONE means don't
+ * store the Tcl_Obj in the record. */
size_t internalOffset; /* Where in record to store the internal
* representation of the value of this option,
* such as an int or XColor *. This field is
* specified as an offset in bytes from the
- * start of the record. Use the Tk_Offset
- * macro to generate values for it. -1 means
- * don't store the internal representation in
- * the record. */
+ * start of the record. Use the offsetof
+ * macro to generate values for it.
+ * TCL_INDEX_NONE means don't store the
+ * internal representation in the record. */
#else
int objOffset;
int internalOffset;
@@ -268,10 +272,12 @@ typedef struct Tk_ObjCustomOption {
* Computes number of bytes from beginning of structure to a given field.
*/
-#ifdef offsetof
-#define Tk_Offset(type, field) ((int) offsetof(type, field))
-#else
-#define Tk_Offset(type, field) ((int) ((char *) &((type *) 0)->field))
+#ifndef TK_NO_DEPRECATED
+# define Tk_Offset(type, field) ((int) offsetof(type, field))
+#endif
+/* Workaround for platforms missing offsetof(), e.g. VC++ 6.0 */
+#ifndef offsetof
+# define offsetof(type, field) ((size_t) ((char *) &((type *) 0)->field))
#endif
/*
@@ -376,7 +382,7 @@ typedef struct Tk_ConfigSpec {
* in command line or database. */
#if TCL_MAJOR_VERSION > 8
size_t offset; /* Where in widget record to store value; use
- * Tk_Offset macro to generate values for
+ * offsetof macro to generate values for
* this. */
#else
int offset;
@@ -438,9 +444,9 @@ typedef struct {
const char *key; /* The key string that flags the option in the
* argv array. */
int type; /* Indicates option type; see below. */
- char *src; /* Value to be used in setting dst; usage
+ void *src; /* Value to be used in setting dst; usage
* depends on type. */
- char *dst; /* Address of value to be modified; usage
+ void *dst; /* Address of value to be modified; usage
* depends on type. */
const char *help; /* Documentation message describing this
* option. */
@@ -616,12 +622,12 @@ typedef struct Tk_ClassProcs {
*
* #define Tk_GetField(name, who, which) \
* (((who) == NULL) ? NULL :
- * (((who)->size <= Tk_Offset(name, which)) ? NULL :(name)->which))
+ * (((who)->size <= offsetof(name, which)) ? NULL :(name)->which))
*/
#define Tk_GetClassProc(procs, which) \
(((procs) == NULL) ? NULL : \
- (((procs)->size <= (size_t)Tk_Offset(Tk_ClassProcs, which)) ? NULL:(procs)->which))
+ (((procs)->size <= offsetof(Tk_ClassProcs, which)) ? NULL:(procs)->which))
/*
* Each geometry manager (the packer, the placer, etc.) is represented by a
@@ -810,7 +816,7 @@ typedef struct Tk_FakeWin {
unsigned long dummy7; /* dirtyAtts */
unsigned int flags;
char *dummy8; /* handlerList */
-#ifdef TK_USE_INPUT_METHODS
+#if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8)
XIC dummy9; /* inputContext */
#endif /* TK_USE_INPUT_METHODS */
ClientData *dummy10; /* tagPtr */
@@ -830,9 +836,14 @@ typedef struct Tk_FakeWin {
int internalBorderBottom;
int minReqWidth;
int minReqHeight;
- char *dummy20; /* geometryMaster */
-#ifdef TK_USE_INPUT_METHODS
- int dummy21;
+#if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8)
+ int dummy20;
+#endif /* TK_USE_INPUT_METHODS */
+ char *dummy21; /* geomMgrName */
+ Tk_Window dummy22; /* maintainerPtr */
+#if !defined(TK_USE_INPUT_METHODS) && (TCL_MAJOR_VERSION < 9)
+ XIC dummy9; /* inputContext */
+ int dummy20;
#endif /* TK_USE_INPUT_METHODS */
} Tk_FakeWin;
@@ -899,6 +910,10 @@ typedef struct Tk_FakeWin {
* window.
* TK_WM_MANAGEABLE 1 marks a window as capable of being converted
* into a toplevel using [wm manage].
+ * TK_CAN_INPUT_TEXT 1 means that this window accepts text input.
+ * Used on macOS to indicate that key events can be
+ * processed with the NSTextInputClient protocol.
+ * Not currently accessible through the public API.
*/
#define TK_MAPPED 1
@@ -912,6 +927,7 @@ typedef struct Tk_FakeWin {
#define TK_EMBEDDED 0x100
#define TK_CONTAINER 0x200
#define TK_BOTH_HALVES 0x400
+
#define TK_WRAPPER 0x1000
#define TK_REPARENTED 0x2000
#define TK_ANONYMOUS_WINDOW 0x4000
@@ -920,6 +936,7 @@ typedef struct Tk_FakeWin {
#define TK_TOP_HIERARCHY 0x20000
#define TK_PROP_PROPCHANGE 0x40000
#define TK_WM_MANAGEABLE 0x80000
+#define TK_CAN_INPUT_TEXT 0x100000
/*
*----------------------------------------------------------------------
@@ -1034,6 +1051,8 @@ typedef int (Tk_ItemAreaProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
double *rectPtr);
typedef int (Tk_ItemPostscriptProc)(Tcl_Interp *interp, Tk_Canvas canvas,
Tk_Item *itemPtr, int prepass);
+typedef void (Tk_ItemRotateProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRadians);
typedef void (Tk_ItemScaleProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
double originX, double originY, double scaleX,
double scaleY);
@@ -1117,7 +1136,9 @@ typedef struct Tk_ItemType {
/* Procedure to delete characters from an
* item. */
struct Tk_ItemType *nextPtr;/* Used to link types together into a list. */
- char *reserved1; /* Reserved for future extension. */
+ Tk_ItemRotateProc *rotateProc;
+ /* Procedure to rotate an item's coordinates
+ * about a point. */
int reserved2; /* Carefully compatible with */
char *reserved3; /* Jan Nijtmans dash patch */
char *reserved4;
diff --git a/generic/tk3d.c b/generic/tk3d.c
index 92a7803..155f6ae 100644
--- a/generic/tk3d.c
+++ b/generic/tk3d.c
@@ -90,7 +90,7 @@ Tk_Alloc3DBorderFromObj(
if (objPtr->typePtr != &tkBorderObjType) {
InitBorderObj(objPtr);
}
- borderPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ borderPtr = (TkBorder *)objPtr->internalRep.twoPtrValue.ptr1;
/*
* If the object currently points to a TkBorder, see if it's the one we
@@ -127,7 +127,7 @@ Tk_Alloc3DBorderFromObj(
*/
if (borderPtr != NULL) {
- TkBorder *firstBorderPtr = Tcl_GetHashValue(borderPtr->hashPtr);
+ TkBorder *firstBorderPtr = (TkBorder *)Tcl_GetHashValue(borderPtr->hashPtr);
FreeBorderObj(objPtr);
for (borderPtr = firstBorderPtr ; borderPtr != NULL;
@@ -200,7 +200,7 @@ Tk_Get3DBorder(
hashPtr = Tcl_CreateHashEntry(&dispPtr->borderTable, colorName, &isNew);
if (!isNew) {
- existingBorderPtr = Tcl_GetHashValue(hashPtr);
+ existingBorderPtr = (TkBorder *)Tcl_GetHashValue(hashPtr);
for (borderPtr = existingBorderPtr; borderPtr != NULL;
borderPtr = borderPtr->nextPtr) {
if ((Tk_Screen(tkwin) == borderPtr->screen)
@@ -420,12 +420,11 @@ Tk_Free3DBorder(
Display *display = DisplayOfScreen(borderPtr->screen);
TkBorder *prevPtr;
- borderPtr->resourceRefCount--;
- if (borderPtr->resourceRefCount > 0) {
+ if (borderPtr->resourceRefCount-- > 1) {
return;
}
- prevPtr = Tcl_GetHashValue(borderPtr->hashPtr);
+ prevPtr = (TkBorder *)Tcl_GetHashValue(borderPtr->hashPtr);
TkpFreeBorder(borderPtr);
if (borderPtr->bgColorPtr != NULL) {
Tk_FreeColor(borderPtr->bgColorPtr);
@@ -527,7 +526,7 @@ static void
FreeBorderObj(
Tcl_Obj *objPtr) /* The object we are releasing. */
{
- TkBorder *borderPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ TkBorder *borderPtr = (TkBorder *)objPtr->internalRep.twoPtrValue.ptr1;
if (borderPtr != NULL) {
borderPtr->objRefCount--;
@@ -562,7 +561,7 @@ DupBorderObjProc(
Tcl_Obj *srcObjPtr, /* The object we are copying from. */
Tcl_Obj *dupObjPtr) /* The object we are copying to. */
{
- TkBorder *borderPtr = srcObjPtr->internalRep.twoPtrValue.ptr1;
+ TkBorder *borderPtr = (TkBorder *)srcObjPtr->internalRep.twoPtrValue.ptr1;
dupObjPtr->typePtr = srcObjPtr->typePtr;
dupObjPtr->internalRep.twoPtrValue.ptr1 = borderPtr;
@@ -594,7 +593,7 @@ Tk_SetBackgroundFromBorder(
Tk_Window tkwin, /* Window whose background is to be set. */
Tk_3DBorder border) /* Token for border. */
{
- register TkBorder *borderPtr = (TkBorder *) border;
+ TkBorder *borderPtr = (TkBorder *) border;
Tk_SetWindowBackground(tkwin, borderPtr->bgColorPtr->pixel);
}
@@ -759,7 +758,7 @@ Tk_Draw3DPolygon(
{
XPoint poly[4], b1, b2, newB1, newB2;
XPoint perp, c, shift1, shift2; /* Used for handling parallel lines. */
- register XPoint *p1Ptr, *p2Ptr;
+ XPoint *p1Ptr, *p2Ptr;
TkBorder *borderPtr = (TkBorder *) border;
GC gc;
int i, lightOnLeft, dx, dy, parallel, pointsSeen;
@@ -956,7 +955,7 @@ Tk_Fill3DRectangle(
int relief) /* Indicates 3D effect: TK_RELIEF_FLAT,
* TK_RELIEF_RAISED, or TK_RELIEF_SUNKEN. */
{
- register TkBorder *borderPtr = (TkBorder *) border;
+ TkBorder *borderPtr = (TkBorder *) border;
int doubleBorder;
/*
@@ -1027,7 +1026,7 @@ Tk_Fill3DPolygon(
* TK_RELIEF_FLAT, TK_RELIEF_RAISED, or
* TK_RELIEF_SUNKEN. */
{
- register TkBorder *borderPtr = (TkBorder *) border;
+ TkBorder *borderPtr = (TkBorder *) border;
XFillPolygon(Tk_Display(tkwin), drawable, borderPtr->bgGC,
pointPtr, numPoints, Complex, CoordModeOrigin);
@@ -1253,7 +1252,7 @@ Tk_Get3DBorderFromObj(
* cached in the internal representation of the Tcl_Obj. Check it out...
*/
- borderPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ borderPtr = (TkBorder *)objPtr->internalRep.twoPtrValue.ptr1;
if ((borderPtr != NULL)
&& (borderPtr->resourceRefCount > 0)
&& (Tk_Screen(tkwin) == borderPtr->screen)
@@ -1281,7 +1280,7 @@ Tk_Get3DBorderFromObj(
if (hashPtr == NULL) {
goto error;
}
- for (borderPtr = Tcl_GetHashValue(hashPtr); borderPtr != NULL;
+ for (borderPtr = (TkBorder *)Tcl_GetHashValue(hashPtr); borderPtr != NULL;
borderPtr = borderPtr->nextPtr) {
if ((Tk_Screen(tkwin) == borderPtr->screen)
&& (Tk_Colormap(tkwin) == borderPtr->colormap)) {
@@ -1315,7 +1314,7 @@ Tk_Get3DBorderFromObj(
*
* Side effects:
* If no error occurs, a blank internal format for a border value is
- * intialized. The final form cannot be done without a Tk_Window.
+ * initialized. The final form cannot be done without a Tk_Window.
*
*----------------------------------------------------------------------
*/
@@ -1371,7 +1370,7 @@ TkDebugBorder(
resultPtr = Tcl_NewObj();
hashPtr = Tcl_FindHashEntry(&dispPtr->borderTable, name);
if (hashPtr != NULL) {
- TkBorder *borderPtr = Tcl_GetHashValue(hashPtr);
+ TkBorder *borderPtr = (TkBorder *)Tcl_GetHashValue(hashPtr);
if (borderPtr == NULL) {
Tcl_Panic("TkDebugBorder found empty hash table entry");
diff --git a/generic/tkArgv.c b/generic/tkArgv.c
index 6c2c5c5..81e7a44 100644
--- a/generic/tkArgv.c
+++ b/generic/tkArgv.c
@@ -67,12 +67,12 @@ Tk_ParseArgv(
int flags) /* Or'ed combination of various flag bits,
* such as TK_ARGV_NO_DEFAULTS. */
{
- register const Tk_ArgvInfo *infoPtr;
+ const Tk_ArgvInfo *infoPtr;
/* Pointer to the current entry in the table
* of argument descriptions. */
const Tk_ArgvInfo *matchPtr;/* Descriptor that matches current argument. */
const char *curArg; /* Current argument */
- register char c; /* Second character of current arg (used for
+ char c; /* Second character of current arg (used for
* quick check for matching; use 2nd char.
* because first char. will almost always be
* '-'). */
@@ -228,9 +228,9 @@ Tk_ParseArgv(
break;
case TK_ARGV_FUNC: {
typedef int (ArgvFunc)(char *, const char *, const char *);
- ArgvFunc *handlerProc = (ArgvFunc *) infoPtr->src;
+ ArgvFunc *handlerProc = (ArgvFunc *)infoPtr->src;
- if (handlerProc(infoPtr->dst, infoPtr->key, argv[srcIndex])) {
+ if (handlerProc((char *)infoPtr->dst, infoPtr->key, argv[srcIndex])) {
srcIndex++;
argc--;
}
@@ -239,9 +239,9 @@ Tk_ParseArgv(
case TK_ARGV_GENFUNC: {
typedef int (ArgvGenFunc)(char *, Tcl_Interp *, const char *, int,
const char **);
- ArgvGenFunc *handlerProc = (ArgvGenFunc *) infoPtr->src;
+ ArgvGenFunc *handlerProc = (ArgvGenFunc *)infoPtr->src;
- argc = handlerProc(infoPtr->dst, interp, infoPtr->key, argc,
+ argc = handlerProc((char *)infoPtr->dst, interp, infoPtr->key, argc,
argv+srcIndex);
if (argc < 0) {
return TCL_ERROR;
@@ -253,14 +253,14 @@ Tk_ParseArgv(
Tcl_SetErrorCode(interp, "TK", "ARG", "HELP", NULL);
return TCL_ERROR;
case TK_ARGV_CONST_OPTION:
- Tk_AddOption(tkwin, infoPtr->dst, infoPtr->src,
+ Tk_AddOption(tkwin, (char *)infoPtr->dst, (char *)infoPtr->src,
TK_INTERACTIVE_PRIO);
break;
case TK_ARGV_OPTION_VALUE:
if (argc < 1) {
goto missingArg;
}
- Tk_AddOption(tkwin, infoPtr->dst, argv[srcIndex],
+ Tk_AddOption(tkwin, (char *)infoPtr->dst, argv[srcIndex],
TK_INTERACTIVE_PRIO);
srcIndex++;
argc--;
@@ -338,7 +338,7 @@ PrintUsage(
* this word, then don't generate information
* for default options. */
{
- register const Tk_ArgvInfo *infoPtr;
+ const Tk_ArgvInfo *infoPtr;
size_t width, i, numSpaces;
Tcl_Obj *message;
diff --git a/generic/tkArray.h b/generic/tkArray.h
new file mode 100644
index 0000000..81f3198
--- /dev/null
+++ b/generic/tkArray.h
@@ -0,0 +1,610 @@
+/*
+ * tkArray.h --
+ *
+ * An array is a sequence of items, stored in a contiguous memory region.
+ * Random access to any item is very fast. New items can be either appended
+ * or prepended. An array may be traversed in the forward or backward direction.
+ *
+ * Copyright (c) 2018-2019 by Gregor Cramer.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+/*
+ * Note that this file will not be included in header files, it is the purpose
+ * of this file to be included in source files only. Thus we are not using the
+ * prefix "Tk_" here for functions, because all the functions have private scope.
+ */
+
+/*
+ * -------------------------------------------------------------------------------
+ * Use the array in the following way:
+ * -------------------------------------------------------------------------------
+ * typedef struct { int key, value; } Pair;
+ * TK_PTR_ARRAY_DEFINE(MyArray, Pair);
+ * MyArray *arr = NULL;
+ * if (MyArray_IsEmpty(arr)) {
+ * MyArray_Append(&arr, MakePair(1, 2));
+ * MyArray_Append(&arr, MakePair(2, 3));
+ * for (i = 0; i < MyArray_Size(arr); ++i) {
+ * Pair *p = MyArray_Get(arr, i);
+ * printf("%d -> %d\n", p->key, p->value);
+ * ckfree(p);
+ * }
+ * MyArray_Free(&arr);
+ * assert(arr == NULL);
+ * }
+ * -------------------------------------------------------------------------------
+ * Or with aggregated elements:
+ * -------------------------------------------------------------------------------
+ * typedef struct { int key, value; } Pair;
+ * TK_ARRAY_DEFINE(MyArray, Pair);
+ * Pair p1 = { 1, 2 };
+ * Pair p2 = { 2, 3 };
+ * MyArray *arr = NULL;
+ * if (MyArray_IsEmpty(arr)) {
+ * MyArray_Append(&arr, p1);
+ * MyArray_Append(&arr, p2);
+ * for (i = 0; i < MyArray_Size(arr); ++i) {
+ * const Pair *p = MyArray_Get(arr, i);
+ * printf("%d -> %d\n", p->key, p->value);
+ * }
+ * MyArray_Free(&arr);
+ * assert(arr == NULL);
+ * }
+ * -------------------------------------------------------------------------------
+ */
+
+/*************************************************************************/
+/*
+ * Two array types will be provided:
+ * Use TK_ARRAY_DEFINE if your array is aggregating the elements. Use
+ * TK_PTR_ARRAY_DEFINE if your array contains pointers to elements. But
+ * in latter case the array is not responsible for the lifetime of the
+ * elements.
+ */
+/*************************************************************************/
+/*
+ * Array_ElemSize: Returns the memory size for one array element.
+ */
+/*************************************************************************/
+/*
+ * Array_BufferSize: Returns the memory size for given number of elements.
+ */
+/*************************************************************************/
+/*
+ * Array_IsEmpty: Array is empty?
+ */
+/*************************************************************************/
+/*
+ * Array_Size: Number of elements in array.
+ */
+/*************************************************************************/
+/*
+ * Array_Capacity: Capacity of given array. This is the maximal number of
+ * elements fitting into current array memory without resizing the buffer.
+ */
+/*************************************************************************/
+/*
+ * Array_SetSize: Set array size, new size must not exceed the capacity of
+ * the array. This function has to be used with care when increasing the
+ * array size.
+ */
+/*************************************************************************/
+/*
+ * Array_First: Returns position of first element in array. Given array
+ * may be NULL.
+ */
+/*************************************************************************/
+/*
+ * Array_Last: Returns position after last element in array. Given array
+ * may be empty.
+ */
+/*************************************************************************/
+/*
+ * Array_Front: Returns first element in array. Given array must not be
+ * empty.
+ */
+/*************************************************************************/
+/*
+ * Array_Back: Returns last element in array. Given array must not be
+ * empty.
+ */
+/*************************************************************************/
+/*
+ * Array_Resize: Resize buffer of array for given number of elements. The
+ * array may grow or shrink. Note that this function is not initializing
+ * the increased buffer.
+ */
+/*************************************************************************/
+/*
+ * Array_ResizeAndClear: Resize buffer of array for given number of
+ * elements. The array may grow or shrink. The increased memory will be
+ * filled with zeroes.
+ */
+/*************************************************************************/
+/*
+ * Array_Clear: Fill specified range with zeroes.
+ */
+/*************************************************************************/
+/*
+ * Array_Free: Resize array to size zero. This function will release the
+ * array buffer.
+ */
+/*************************************************************************/
+/*
+ * Array_Append: Insert given element after end of array.
+ */
+/*************************************************************************/
+/*
+ * Array_PopBack: Shrink array by one element. Given array must not be
+ * empty.
+ */
+/*************************************************************************/
+/*
+ * Array_Get: Random access to array element at given position. The given
+ * index must not exceed current array size.
+ */
+/*************************************************************************/
+/*
+ * Array_Set: Replace array element at given position with new value. The
+ * given index must not exceed current array size.
+ */
+/*************************************************************************/
+/*
+ * Array_Find: Return index position of element which matches given
+ * argument. If not found then -1 will be returned.
+ */
+/*************************************************************************/
+
+#ifndef TK_ARRAY_DEFINED
+#define TK_ARRAY_DEFINED
+
+#include "tkInt.h"
+
+#if defined(__GNUC__) || defined(__clang__)
+# define __TK_ARRAY_UNUSED __attribute__((unused))
+#else
+# define __TK_ARRAY_UNUSED
+#endif
+
+#define TK_ARRAY_DEFINE(AT, ElemType) /* AT = type of array */ \
+/* ------------------------------------------------------------------------- */ \
+typedef struct AT { \
+ size_t size; \
+ size_t capacity; \
+ ElemType buf[1]; \
+} AT; \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_Init(AT *arr) \
+{ \
+ assert(arr); \
+ arr->size = 0; \
+ arr->capacity = 0; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static size_t \
+AT##_ElemSize(void) \
+{ \
+ return sizeof(ElemType); \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static size_t \
+AT##_BufferSize(size_t numElems) \
+{ \
+ return numElems*sizeof(ElemType); \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static int \
+AT##_IsEmpty(const AT *arr) \
+{ \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ return !arr || arr->size == 0u; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static size_t \
+AT##_Size(const AT *arr) \
+{ \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ return arr ? arr->size : 0u; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static size_t \
+AT##_Capacity(const AT *arr) \
+{ \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ return arr ? arr->capacity : 0u; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static ElemType * \
+AT##_First(AT *arr) \
+{ \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ return arr ? arr->buf : NULL; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static ElemType * \
+AT##_Last(AT *arr) \
+{ \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ return arr ? arr->buf + arr->size : NULL; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static ElemType * \
+AT##_Front(AT *arr) \
+{ \
+ assert(arr); \
+ assert(arr->size != 0xdeadbeef); \
+ assert(!AT##_IsEmpty(arr)); \
+ return &arr->buf[0]; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static ElemType * \
+AT##_Back(AT *arr) \
+{ \
+ assert(arr); \
+ assert(arr->size != 0xdeadbeef); \
+ assert(!AT##_IsEmpty(arr)); \
+ return &arr->buf[arr->size - 1]; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_Resize(AT **arrp, size_t newSize) \
+{ \
+ assert(arrp); \
+ assert(!*arrp || (*arrp)->size != 0xdeadbeef); \
+ if (newSize == 0) { \
+ assert(!*arrp || ((*arrp)->size = 0xdeadbeef)); \
+ ckfree(*arrp); \
+ *arrp = NULL; \
+ } else { \
+ int init = *arrp == NULL; \
+ size_t memSize = AT##_BufferSize(newSize - 1) + sizeof(AT); \
+ *arrp = (AT *)ckrealloc(*arrp, memSize); \
+ if (init) { \
+ (*arrp)->size = 0; \
+ } else if (newSize < (*arrp)->size) { \
+ (*arrp)->size = newSize; \
+ } \
+ (*arrp)->capacity = newSize; \
+ } \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_Clear(AT *arr, size_t from, size_t to) \
+{ \
+ assert(arr); \
+ assert(arr->size != 0xdeadbeef); \
+ assert(to <= AT##_Capacity(arr)); \
+ assert(from <= to); \
+ memset(arr->buf + from, 0, AT##_BufferSize(to - from)); \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_ResizeAndClear(AT **arrp, size_t newSize) \
+{ \
+ size_t oldCapacity; \
+ assert(arrp); \
+ oldCapacity = *arrp ? (*arrp)->capacity : 0; \
+ AT##_Resize(arrp, newSize); \
+ if (newSize > oldCapacity) { \
+ AT##_Clear(*arrp, oldCapacity, newSize); \
+ } \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_SetSize(AT *arr, size_t newSize) \
+{ \
+ assert(newSize <= AT##_Capacity(arr)); \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ if (arr) { \
+ arr->size = newSize; \
+ } \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_Append(AT **arrp, ElemType *elem) \
+{ \
+ assert(arrp); \
+ if (!*arrp) { \
+ AT##_Resize(arrp, 1); \
+ } else if ((*arrp)->size == (*arrp)->capacity) { \
+ AT##_Resize(arrp, (*arrp)->capacity + ((*arrp)->capacity + 1)/2); \
+ } \
+ (*arrp)->buf[(*arrp)->size++] = *elem; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static size_t \
+AT##_PopBack(AT *arr) \
+{ \
+ assert(!AT##_IsEmpty(arr)); \
+ return arr->size -= 1; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static ElemType * \
+AT##_Get(const AT *arr, size_t at) \
+{ \
+ assert(arr); \
+ assert(at < AT##_Size(arr)); \
+ return (ElemType *) &arr->buf[at]; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_Set(AT *arr, size_t at, ElemType *elem) \
+{ \
+ assert(arr); \
+ assert(at < AT##_Size(arr)); \
+ arr->buf[at] = *elem; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_Free(AT **arrp) \
+{ \
+ AT##_Resize(arrp, 0); \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static int \
+AT##_Find(const AT *arr, const ElemType *elem) \
+{ \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ if (arr) { \
+ const ElemType *buf = arr->buf; \
+ size_t i; \
+ for (i = 0; i < arr->size; ++i) { \
+ if (memcmp(&buf[i], elem, sizeof(ElemType)) == 0) { \
+ return (int) i; \
+ } \
+ } \
+ } \
+ return -1; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static int \
+AT##_Contains(const AT *arr, const ElemType *elem) \
+{ \
+ return AT##_Find(arr, elem) != -1; \
+} \
+/* ------------------------------------------------------------------------- */
+
+#define TK_PTR_ARRAY_DEFINE(AT, ElemType) /* AT = type of array */ \
+/* ------------------------------------------------------------------------- */ \
+typedef struct AT { \
+ size_t size; \
+ size_t capacity; \
+ ElemType *buf[1]; \
+} AT; \
+ \
+__TK_ARRAY_UNUSED \
+static size_t \
+AT##_ElemSize(void) \
+{ \
+ return sizeof(ElemType); \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static size_t \
+AT##_BufferSize(size_t numElems) \
+{ \
+ return numElems*sizeof(ElemType *); \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static int \
+AT##_IsEmpty(const AT *arr) \
+{ \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ return !arr || arr->size == 0; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static ElemType ** \
+AT##_First(AT *arr) \
+{ \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ return arr ? arr->buf : NULL; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static ElemType ** \
+AT##_Last(AT *arr) \
+{ \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ return arr ? arr->buf + arr->size : NULL; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static ElemType * \
+AT##_Front(AT *arr) \
+{ \
+ assert(arr); \
+ assert(arr->size != 0xdeadbeef); \
+ assert(!AT##_IsEmpty(arr)); \
+ return arr->buf[0]; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static ElemType * \
+AT##_Back(AT *arr) \
+{ \
+ assert(arr); \
+ assert(arr->size != 0xdeadbeef); \
+ assert(!AT##_IsEmpty(arr)); \
+ return arr->buf[arr->size - 1]; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static size_t \
+AT##_Size(const AT *arr) \
+{ \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ return arr ? arr->size : 0; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static size_t \
+AT##_Capacity(const AT *arr) \
+{ \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ return arr ? arr->capacity : 0; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_Resize(AT **arrp, size_t newCapacity) \
+{ \
+ assert(arrp); \
+ assert(!*arrp || (*arrp)->size != 0xdeadbeef); \
+ if (newCapacity == 0) { \
+ assert(!*arrp || ((*arrp)->size = 0xdeadbeef)); \
+ ckfree(*arrp); \
+ *arrp = NULL; \
+ } else { \
+ int init = *arrp == NULL; \
+ size_t memSize = AT##_BufferSize(newCapacity - 1) + sizeof(AT); \
+ *arrp = (AT *)ckrealloc(*arrp, memSize); \
+ if (init) { \
+ (*arrp)->size = 0; \
+ } else if (newCapacity < (*arrp)->size) { \
+ (*arrp)->size = newCapacity; \
+ } \
+ (*arrp)->capacity = newCapacity; \
+ } \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_Clear(AT *arr, size_t from, size_t to) \
+{ \
+ assert(arr); \
+ assert(arr->size != 0xdeadbeef); \
+ assert(to <= AT##_Capacity(arr)); \
+ assert(from <= to); \
+ memset(arr->buf + from, 0, AT##_BufferSize(to - from)); \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_ResizeAndClear(AT **arrp, size_t newCapacity) \
+{ \
+ size_t oldCapacity; \
+ assert(arrp); \
+ oldCapacity = *arrp ? (*arrp)->capacity : 0; \
+ AT##_Resize(arrp, newCapacity); \
+ if (newCapacity > oldCapacity) { \
+ AT##_Clear(*arrp, oldCapacity, newCapacity); \
+ } \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_SetSize(AT *arr, size_t newSize) \
+{ \
+ assert(arr); \
+ assert(newSize <= AT##_Capacity(arr)); \
+ arr->size = newSize; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_Append(AT **arrp, ElemType *elem) \
+{ \
+ assert(arrp); \
+ if (!*arrp) { \
+ AT##_Resize(arrp, 1); \
+ } else if ((*arrp)->size == (*arrp)->capacity) { \
+ AT##_Resize(arrp, (*arrp)->capacity + ((*arrp)->capacity + 1)/2); \
+ } \
+ (*arrp)->buf[(*arrp)->size++] = elem; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static size_t \
+AT##_PopBack(AT *arr) \
+{ \
+ assert(!AT##_IsEmpty(arr)); \
+ return arr->size -= 1; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static ElemType * \
+AT##_Get(const AT *arr, size_t at) \
+{ \
+ assert(arr); \
+ assert(at < AT##_Size(arr)); \
+ return arr->buf[at]; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_Set(AT *arr, size_t at, ElemType *elem) \
+{ \
+ assert(arr); \
+ assert(at < AT##_Size(arr)); \
+ arr->buf[at] = elem; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static void \
+AT##_Free(AT **arrp) \
+{ \
+ AT##_Resize(arrp, 0); \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static int \
+AT##_Find(const AT *arr, const ElemType *elem) \
+{ \
+ assert(!arr || arr->size != 0xdeadbeef); \
+ if (arr) { \
+ ElemType *const *buf = arr->buf; \
+ size_t i; \
+ for (i = 0; i < arr->size; ++i) { \
+ if (buf[i] == elem) { \
+ return (int) i; \
+ } \
+ } \
+ } \
+ return -1; \
+} \
+ \
+__TK_ARRAY_UNUSED \
+static int \
+AT##_Contains(const AT *arr, const ElemType *elem) \
+{ \
+ return AT##_Find(arr, elem) != -1; \
+} \
+/* ------------------------------------------------------------------------- */
+
+#endif /* TK_ARRAY_DEFINED */
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 105
+ * End:
+ * vi:set ts=8 sw=4:
+ */
diff --git a/generic/tkAtom.c b/generic/tkAtom.c
index ddfa97f..a4e1e11 100644
--- a/generic/tkAtom.c
+++ b/generic/tkAtom.c
@@ -154,11 +154,11 @@ Tk_GetAtomName(
if (mustFree) {
XFree(mustFree);
}
- name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
+ name = (const char *)Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew);
Tcl_SetHashValue(hPtr, (char *)name);
}
- return Tcl_GetHashValue(hPtr);
+ return (const char *)Tcl_GetHashValue(hPtr);
}
/*
@@ -200,7 +200,7 @@ AtomInit(
name = atomNameArray[atom - 1];
hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, name, &isNew);
Tcl_SetHashValue(hPtr, INT2PTR(atom));
- name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
+ name = (const char *)Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew);
Tcl_SetHashValue(hPtr, (char *)name);
}
diff --git a/generic/tkBind.c b/generic/tkBind.c
index 953d936..e8827b3 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -7,21 +7,40 @@
* Copyright (c) 1989-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
* Copyright (c) 1998 by Scriptics Corporation.
+ * Copyright (c) 2018-2019 by Gregor Cramer.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkInt.h"
+#include "tkDList.h"
+#include "tkArray.h"
-#ifdef _WIN32
+#if defined(_WIN32)
#include "tkWinInt.h"
#elif defined(MAC_OSX_TK)
#include "tkMacOSXInt.h"
-#else
+#else /* if defined(__unix__) */
#include "tkUnixInt.h"
#endif
+#ifdef NDEBUG
+# define DEBUG(expr)
+#else
+# define DEBUG(expr) expr
+#endif
+
+#ifdef _MSC_VER
+/*
+ * Earlier versions of MSVC don't know snprintf, but _snprintf is compatible.
+ * Note that sprintf is deprecated.
+ */
+# define snprintf _snprintf
+#endif
+
+#define SIZE_OF_ARRAY(arr) (sizeof(arr)/sizeof(arr[0]))
+
/*
* File structure:
*
@@ -29,8 +48,7 @@
*
* Init/Free this package.
*
- * Tcl "bind" command (actually located in tkCmds.c) core implementation, plus
- * helpers.
+ * Tcl "bind" command (actually located in tkCmds.c) core implementation, plus helpers.
*
* Tcl "event" command implementation, plus helpers.
*
@@ -40,21 +58,129 @@
*/
/*
+ * In old implementation (the one that used an event ring), <Double-1> and <1><1> were
+ * equivalent sequences. However it is logical to give <Double-1> higher precedence.
+ * This is achieved by setting PREFER_MOST_SPECIALIZED_EVENT to 1.
+ */
+
+#ifndef PREFER_MOST_SPECIALIZED_EVENT
+# define PREFER_MOST_SPECIALIZED_EVENT 1
+#endif
+
+/*
+ * Traditionally motion events can be combined with buttons in this way: <B1-B2-Motion>.
+ * However it should be allowed to express this as <Motion-1-2> in addition. This is achieved
+ * by setting SUPPORT_ADDITIONAL_MOTION_SYNTAX to 1.
+ */
+
+#ifndef SUPPORT_ADDITIONAL_MOTION_SYNTAX
+# define SUPPORT_ADDITIONAL_MOTION_SYNTAX 1
+#endif
+
+/*
+ * The output for motion events is of the type <B1-Motion>. This can be changed to become
+ * <Motion-1> instead by setting PRINT_SHORT_MOTION_SYNTAX to 1, however this would be a
+ * backwards incompatibility.
+ */
+
+#ifndef PRINT_SHORT_MOTION_SYNTAX
+# define PRINT_SHORT_MOTION_SYNTAX 0 /* set to 1 if wanted */
+#endif
+
+#if !SUPPORT_ADDITIONAL_MOTION_SYNTAX
+# undef PRINT_SHORT_MOTION_SYNTAX
+# define PRINT_SHORT_MOTION_SYNTAX 0
+#endif
+
+/*
+ * For debugging only, normally set to zero.
+ */
+
+#ifdef SUPPORT_DEBUGGING
+# undef SUPPORT_DEBUGGING
+#endif
+#define SUPPORT_DEBUGGING 0
+
+/*
+ * Test validity of PSEntry items.
+ */
+
+# define TEST_PSENTRY(psPtr) psPtr->number != 0xdeadbeef
+# define MARK_PSENTRY(psPtr) psPtr->number = 0xdeadbeef
+
+/*
* The following union is used to hold the detail information from an XEvent
* (including Tk's XVirtualEvent extension).
*/
+typedef KeySym Info;
+
typedef union {
- KeySym keySym; /* KeySym that corresponds to xkey.keycode. */
- int button; /* Button that was pressed (xbutton.button). */
- Tk_Uid name; /* Tk_Uid of virtual event. */
- ClientData clientData; /* Used when type of Detail is unknown, and to
- * ensure that all bytes of Detail are
- * initialized when this structure is used in
- * a hash key. */
+ Info info; /* This either corresponds to xkey.keycode, or to xbutton.button,
+ * or is meaningless, depending on event type. */
+ Tk_Uid name; /* Tk_Uid of virtual event. */
} Detail;
/*
+ * We need an extended event definition.
+ */
+
+typedef struct {
+ XEvent xev; /* The original event from server. */
+ Detail detail; /* Additional information (for hashing). */
+ unsigned countAny; /* Count of multi-events, like multi-clicks, or repeated key pressing,
+ * this count does not depend on detail (keySym or button). */
+ unsigned countDetailed;
+ /* Count of multi-events, like multi-clicks, or repeated key pressing,
+ * this count considers the detail (keySym or button). */
+} Event;
+
+/*
+ * We need a structure providing a list of pattern sequences.
+ */
+
+typedef unsigned EventMask;
+typedef unsigned long ModMask;
+
+struct PatSeq; /* forward declaration */
+
+/* We need this array for bookkeeping the last matching modifier mask per pattern. */
+TK_ARRAY_DEFINE(PSModMaskArr, ModMask);
+
+typedef struct PSEntry {
+ TK_DLIST_LINKS(PSEntry); /* Makes this struct a double linked list; must be first entry. */
+ Window window; /* Window of last match. */
+ struct PatSeq* psPtr; /* Pointer to pattern sequence. */
+ PSModMaskArr *lastModMaskArr;
+ /* Last matching modifier mask per pattern (except last pattern).
+ * Only needed if pattern sequence is not single (more than one
+ * pattern), and if one of these patterns contains a non-zero
+ * modifier mask. */
+ unsigned count; /* Only promote to next level if this count has reached count of
+ * pattern. */
+ unsigned expired:1; /* Whether this entry is expired, this means it has to be removed
+ * from promotion list. */
+ unsigned keepIt:1; /* Whether to keep this entry, even if expired. */
+} PSEntry;
+
+/* Defining the whole PSList_* stuff (list of PSEntry items). */
+TK_DLIST_DEFINE(PSList, PSEntry);
+
+/* Don't keep larger arrays of modifier masks inside PSEntry. */
+#define MAX_MOD_MASK_ARR_SIZE 8
+
+/*
+ * Maps and lookup tables from an event to a list of patterns that match that event.
+ */
+
+typedef struct {
+ Tcl_HashTable patternTable; /* Keys are PatternTableKey structs, values are (PatSeq *). */
+ Tcl_HashTable listTable; /* Keys are PatternTableKey structs, values are (PSList *). */
+ PSList entryPool; /* Contains free (unused) list items. */
+ unsigned number; /* Needed for enumeration of pattern sequences. */
+} LookupTables;
+
+/*
* The structure below represents a binding table. A binding table represents
* a domain in which event bindings may occur. It includes a space of objects
* relative to which events occur (usually windows, but not always), a history
@@ -65,49 +191,21 @@ typedef union {
* application with separate event bindings for each (for example, each canvas
* widget has a separate binding table for associating events with the items
* in the canvas).
- *
- * Note: it is probably a bad idea to reduce EVENT_BUFFER_SIZE much below 30.
- * To see this, consider a triple mouse button click while the Shift key is
- * down (and auto-repeating). There may be as many as 3 auto-repeat events
- * after each mouse button press or release (see the first large comment block
- * within Tk_BindEvent for more on this), for a total of 20 events to cover
- * the three button presses and two intervening releases. If you reduce
- * EVENT_BUFFER_SIZE too much, shift multi-clicks will be lost.
- */
-
-/*
- * NOTE: The changes which were needed to make Tk work on OSX 10.14 (Mojave)
- * also demand that the event ring be a bit bigger. It might be wise to
- * augment the current double-click pattern matching by adding a new
- * DoubleClick modifier bit which could be set based on the clickCount of the
- * Apple NSEvent object.
*/
-#ifndef TK_MAC_OSX
- #define EVENT_BUFFER_SIZE 90
-#else
- #define EVENT_BUFFER_SIZE 30
-#endif
+/* defining the whole Promotion_* stuff (array of PSList entries) */
+TK_ARRAY_DEFINE(PromArr, PSList);
typedef struct Tk_BindingTable_ {
- XEvent eventRing[EVENT_BUFFER_SIZE];
- /* Circular queue of recent events (higher
- * indices are for more recent events). */
- Detail detailRing[EVENT_BUFFER_SIZE];
- /* "Detail" information (keySym, button,
- * Tk_Uid, or 0) for each entry in
- * eventRing. */
- int curEvent; /* Index in eventRing of most recent event.
- * Newer events have higher indices. */
- Tcl_HashTable patternTable; /* Used to map from an event to a list of
- * patterns that may match that event. Keys
- * are PatternTableKey structs, values are
- * (PatSeq *). */
- Tcl_HashTable objectTable; /* Used to map from an object to a list of
- * patterns associated with that object. Keys
- * are ClientData, values are (PatSeq *). */
- Tcl_Interp *interp; /* Interpreter in which commands are
- * executed. */
+ Event eventInfo[TK_LASTEVENT];
+ /* Containing the most recent event for every event type. */
+ PromArr *promArr; /* Contains the promoted pattern sequences. */
+ Event *curEvent; /* Pointing to most recent event. */
+ ModMask curModMask; /* Containing the current modifier mask. */
+ LookupTables lookupTables; /* Containing hash tables for fast lookup. */
+ Tcl_HashTable objectTable; /* Used to map from an object to a list of patterns associated with
+ * that object. Keys are ClientData, values are (PatSeq *). */
+ Tcl_Interp *interp; /* Interpreter in which commands are executed. */
} BindingTable;
/*
@@ -124,15 +222,10 @@ typedef struct Tk_BindingTable_ {
*/
typedef struct {
- Tcl_HashTable patternTable; /* Used to map from a physical event to a list
- * of patterns that may match that event. Keys
- * are PatternTableKey structs, values are
- * (PatSeq *). */
- Tcl_HashTable nameTable; /* Used to map a virtual event name to the
- * array of physical events that can trigger
- * it. Keys are the Tk_Uid names of the
- * virtual events, values are PhysicalsOwned
- * structs. */
+ LookupTables lookupTables; /* Providing fast lookup tables to lists of pattern sequences. */
+ Tcl_HashTable nameTable; /* Used to map a virtual event name to the array of physical events
+ * that can trigger it. Keys are the Tk_Uid names of the virtual
+ * events, values are PhysOwned structs. */
} VirtualEventTable;
/*
@@ -151,38 +244,45 @@ typedef struct {
*/
typedef struct {
- ClientData object; /* For binding table, identifies the binding
- * tag of the object (or class of objects)
- * relative to which the event occurred. For
- * virtual event table, always NULL. */
- int type; /* Type of event (from X). */
- Detail detail; /* Additional information, such as keysym,
- * button, Tk_Uid, or 0 if nothing
- * additional. */
+ ClientData object; /* For binding table, identifies the binding tag of the object
+ * (or class of objects) relative to which the event occurred.
+ * For virtual event table, always NULL. */
+ unsigned type; /* Type of event (from X). */
+ Detail detail; /* Additional information, such as keysym, button, Tk_Uid, or zero
+ * if nothing additional. */
} PatternTableKey;
/*
* The following structure defines a pattern, which is matched against X
* events as part of the process of converting X events into Tcl commands.
+ *
+ * For technical reasons we do not use 'union Detail', although this would
+ * be possible, instead 'info' and 'name' are both included.
*/
typedef struct {
- int eventType; /* Type of X event, e.g. ButtonPress. */
- int needMods; /* Mask of modifiers that must be present (0
- * means no modifiers are required). */
- Detail detail; /* Additional information that must match
- * event. Normally this is 0, meaning no
- * additional information must match. For
- * KeyPress and KeyRelease events, a keySym
- * may be specified to select a particular
- * keystroke (0 means any keystrokes). For
- * button events, specifies a particular
- * button (0 means any buttons are OK). For
- * virtual events, specifies the Tk_Uid of the
- * virtual event name (never 0). */
+ unsigned eventType; /* Type of X event, e.g. ButtonPress. */
+ unsigned count; /* Multi-event count, e.g. double-clicks, triple-clicks, etc. */
+ ModMask modMask; /* Mask of modifiers that must be present (zero means no modifiers
+ * are required). */
+ Info info; /* Additional information that must match event. Normally this is zero,
+ * meaning no additional information must match. For KeyPress and
+ * KeyRelease events, it may be specified to select a particular
+ * keystroke (zero means any keystrokes). For button events, specifies
+ * a particular button (zero means any buttons are OK). */
+ Tk_Uid name; /* Specifies the Tk_Uid of the virtual event name. NULL if not a
+ * virtual event. */
} TkPattern;
/*
+ * The following structure keeps track of all the virtual events that are
+ * associated with a particular physical event. It is pointed to by the 'owners'
+ * field in a PatSeq in the patternTable of a virtual event table.
+ */
+
+TK_PTR_ARRAY_DEFINE(VirtOwners, Tcl_HashEntry); /* define array of hash entries */
+
+/*
* The following structure defines a pattern sequence, which consists of one
* or more patterns. In order to trigger, a pattern sequence must match the
* most recent X events (first pattern to most recent event, next pattern to
@@ -201,78 +301,55 @@ typedef struct {
*/
typedef struct PatSeq {
- int numPats; /* Number of patterns in sequence (usually
- * 1). */
- char *script; /* Binding script to evaluate when sequence
- * matches (ckalloc()ed) */
- int flags; /* Miscellaneous flag values; see below for
- * definitions. */
- struct PatSeq *nextSeqPtr; /* Next in list of all pattern sequences that
- * have the same initial pattern. NULL means
- * end of list. */
- Tcl_HashEntry *hPtr; /* Pointer to hash table entry for the initial
- * pattern. This is the head of the list of
- * which nextSeqPtr forms a part. */
- struct VirtualOwners *voPtr;/* In a binding table, always NULL. In a
- * virtual event table, identifies the array
- * of virtual events that can be triggered by
- * this event. */
- struct PatSeq *nextObjPtr; /* In a binding table, next in list of all
- * pattern sequences for the same object (NULL
- * for end of list). Needed to implement
- * Tk_DeleteAllBindings. In a virtual event
- * table, always NULL. */
- TkPattern pats[1]; /* Array of "numPats" patterns. Only one
- * element is declared here but in actuality
- * enough space will be allocated for
- * "numPats" patterns. To match, pats[0] must
- * match event n, pats[1] must match event
- * n-1, etc. */
+ unsigned numPats; /* Number of patterns in sequence (usually 1). */
+ unsigned count; /* Total number of repetition counts, summed over count in TkPattern. */
+ unsigned number; /* Needed for the decision whether a binding is less recently defined
+ * than another, it is guaranteed that the most recently bound event
+ * has the highest number. */
+ unsigned added:1; /* Is this pattern sequence already added to lookup table? */
+ unsigned modMaskUsed:1; /* Does at least one pattern contain a non-zero modifier mask? */
+ DEBUG(unsigned owned:1;) /* For debugging purposes. */
+ char *script; /* Binding script to evaluate when sequence matches (ckalloc()ed) */
+ Tcl_Obj* object; /* Token for object with which binding is associated. For virtual
+ * event table this is NULL. */
+ struct PatSeq *nextSeqPtr; /* Next in list of all pattern sequences that have the same initial
+ * pattern. NULL means end of list. */
+ Tcl_HashEntry *hPtr; /* Pointer to hash table entry for the initial pattern. This is the
+ * head of the list of which nextSeqPtr forms a part. */
+ union {
+ VirtOwners *owners; /* In a binding table it has no meaning. In a virtual event table,
+ * identifies the array of virtual events that can be triggered
+ * by this event. */
+ struct PatSeq *nextObj; /* In a binding table, next in list of all pattern sequences for
+ * the same object (NULL for end of list). Needed to implement
+ * Tk_DeleteAllBindings. In a virtual event table it has no meaning. */
+ } ptr;
+ TkPattern pats[1]; /* Array of "numPats" patterns. Only one element is declared here
+ * but in actuality enough space will be allocated for "numPats"
+ * patterns (but usually 1). */
} PatSeq;
/*
- * Flag values for PatSeq structures:
- *
- * PAT_NEARBY 1 means that all of the events matching this sequence
- * must occur with nearby X and Y mouse coordinates and
- * close in time. This is typically used to restrict
- * multiple button presses.
+ * Compute memory size of struct PatSeq with given pattern size.
+ * The caller must be sure that pattern size is greater than zero.
*/
-
-#define PAT_NEARBY 0x1
+#define PATSEQ_MEMSIZE(numPats) (sizeof(PatSeq) + (numPats - 1)*sizeof(TkPattern))
/*
* Constants that define how close together two events must be in milliseconds
* or pixels to meet the PAT_NEARBY constraint:
*/
-#define NEARBY_PIXELS 5
-#define NEARBY_MS 500
-
-/*
- * The following structure keeps track of all the virtual events that are
- * associated with a particular physical event. It is pointed to by the voPtr
- * field in a PatSeq in the patternTable of a virtual event table.
- */
-
-typedef struct VirtualOwners {
- int numOwners; /* Number of virtual events to trigger. */
- Tcl_HashEntry *owners[1]; /* Array of pointers to entries in nameTable.
- * Enough space will actually be allocated for
- * numOwners hash entries. */
-} VirtualOwners;
+#define NEARBY_PIXELS 5
+#define NEARBY_MS 500
/*
* The following structure is used in the nameTable of a virtual event table
* to associate a virtual event with all the physical events that can trigger
* it.
*/
-typedef struct {
- int numOwned; /* Number of physical events owned. */
- PatSeq *patSeqs[1]; /* Array of pointers to physical event
- * patterns. Enough space will actually be
- * allocated to hold numOwned. */
-} PhysicalsOwned;
+
+TK_PTR_ARRAY_DEFINE(PhysOwned, PatSeq); /* define array of pattern seqs */
/*
* One of the following structures exists for each interpreter. This structure
@@ -282,11 +359,9 @@ typedef struct {
*/
typedef struct {
- TkDisplay *curDispPtr; /* Display for last binding command invoked in
- * this application. */
+ TkDisplay *curDispPtr; /* Display for last binding command invoked in this application. */
int curScreenIndex; /* Index of screen for last binding command */
- int bindingDepth; /* Number of active instances of Tk_BindEvent
- * in this application. */
+ unsigned bindingDepth; /* Number of active instances of Tk_BindEvent in this application. */
} ScreenInfo;
/*
@@ -296,13 +371,13 @@ typedef struct {
typedef struct TkBindInfo_ {
VirtualEventTable virtualEventTable;
- /* The virtual events that exist in this
- * interpreter. */
- ScreenInfo screenInfo; /* Keeps track of the current display and
- * screen, so it can be restored after a
- * binding has executed. */
- int deleted; /* 1 the application has been deleted but the
- * structure has been preserved. */
+ /* The virtual events that exist in this interpreter. */
+ ScreenInfo screenInfo; /* Keeps track of the current display and screen, so it can be
+ * restored after a binding has executed. */
+ int deleted; /* 1 if the application has been deleted but the structure has been
+ * preserved. */
+ Time lastEventTime; /* Needed for time measurement. */
+ Time lastCurrentTime; /* Needed for time measurement. */
} BindInfo;
/*
@@ -317,7 +392,7 @@ typedef struct TkBindInfo_ {
#ifdef REDO_KEYSYM_LOOKUP
typedef struct {
- const char *name; /* Name of keysym. */
+ const char *name; /* Name of keysym. */
KeySym value; /* Numeric identifier for keysym. */
} KeySymInfo;
static const KeySymInfo keyArray[] = {
@@ -326,19 +401,11 @@ static const KeySymInfo keyArray[] = {
#endif
{NULL, 0}
};
-static Tcl_HashTable keySymTable; /* keyArray hashed by keysym value. */
-static Tcl_HashTable nameTable; /* keyArray hashed by keysym name. */
+static Tcl_HashTable keySymTable; /* keyArray hashed by keysym value. */
+static Tcl_HashTable nameTable; /* keyArray hashed by keysym name. */
#endif /* REDO_KEYSYM_LOOKUP */
/*
- * Set to non-zero when the package-wide static variables have been
- * initialized.
- */
-
-static int initialized = 0;
-TCL_DECLARE_MUTEX(bindMutex)
-
-/*
* A hash table is kept to map from the string names of event modifiers to
* information about those modifiers. The structure for storing this
* information, and the hash table built at initialization time, are defined
@@ -346,29 +413,24 @@ TCL_DECLARE_MUTEX(bindMutex)
*/
typedef struct {
- const char *name; /* Name of modifier. */
- int mask; /* Button/modifier mask value, such as
- * Button1Mask. */
- int flags; /* Various flags; see below for
- * definitions. */
+ const char *name; /* Name of modifier. */
+ ModMask mask; /* Button/modifier mask value, such as Button1Mask. */
+ unsigned flags; /* Various flags; see below for definitions. */
} ModInfo;
/*
* Flags for ModInfo structures:
*
- * DOUBLE - Non-zero means duplicate this event,
- * e.g. for double-clicks.
- * TRIPLE - Non-zero means triplicate this event,
- * e.g. for triple-clicks.
- * QUADRUPLE - Non-zero means quadruple this event,
- * e.g. for 4-fold-clicks.
+ * DOUBLE - Non-zero means duplicate this event, e.g. for double-clicks.
+ * TRIPLE - Non-zero means triplicate this event, e.g. for triple-clicks.
+ * QUADRUPLE - Non-zero means quadruple this event, e.g. for 4-fold-clicks.
* MULT_CLICKS - Combination of all of above.
*/
-#define DOUBLE 1
-#define TRIPLE 2
-#define QUADRUPLE 4
-#define MULT_CLICKS 7
+#define DOUBLE (1<<0)
+#define TRIPLE (1<<1)
+#define QUADRUPLE (1<<2)
+#define MULT_CLICKS (DOUBLE|TRIPLE|QUADRUPLE)
static const ModInfo modArray[] = {
{"Control", ControlMask, 0},
@@ -388,6 +450,14 @@ static const ModInfo modArray[] = {
{"Button4", Button4Mask, 0},
{"B5", Button5Mask, 0},
{"Button5", Button5Mask, 0},
+ {"B6", Button6Mask, 0},
+ {"Button6", Button6Mask, 0},
+ {"B7", Button7Mask, 0},
+ {"Button7", Button7Mask, 0},
+ {"B8", Button8Mask, 0},
+ {"Button8", Button8Mask, 0},
+ {"B9", Button9Mask, 0},
+ {"Button9", Button9Mask, 0},
{"Mod1", Mod1Mask, 0},
{"M1", Mod1Mask, 0},
{"Command", Mod1Mask, 0},
@@ -416,9 +486,8 @@ static Tcl_HashTable modTable;
typedef struct {
const char *name; /* Name of event. */
- int type; /* Event type for X, such as ButtonPress. */
- int eventMask; /* Mask bits (for XSelectInput) for this event
- * type. */
+ unsigned type; /* Event type for X, such as ButtonPress. */
+ unsigned eventMask; /* Mask bits (for XSelectInput) for this event type. */
} EventInfo;
/*
@@ -434,10 +503,8 @@ static const EventInfo eventArray[] = {
{"KeyRelease", KeyRelease, KeyPressMask|KeyReleaseMask},
{"Button", ButtonPress, ButtonPressMask},
{"ButtonPress", ButtonPress, ButtonPressMask},
- {"ButtonRelease", ButtonRelease,
- ButtonPressMask|ButtonReleaseMask},
- {"Motion", MotionNotify,
- ButtonPressMask|PointerMotionMask},
+ {"ButtonRelease", ButtonRelease, ButtonPressMask|ButtonReleaseMask},
+ {"Motion", MotionNotify, ButtonPressMask|PointerMotionMask},
{"Enter", EnterNotify, EnterWindowMask},
{"Leave", LeaveNotify, LeaveWindowMask},
{"FocusIn", FocusIn, FocusChangeMask},
@@ -465,6 +532,8 @@ static const EventInfo eventArray[] = {
};
static Tcl_HashTable eventTable;
+static int eventArrayIndex[TK_LASTEVENT];
+
/*
* The defines and table below are used to classify events into various
* groups. The reason for this is that logically identical fields (e.g.
@@ -473,32 +542,51 @@ static Tcl_HashTable eventTable;
* information from events.
*/
-#define KEY 0x1
-#define BUTTON 0x2
-#define MOTION 0x4
-#define CROSSING 0x8
-#define FOCUS 0x10
-#define EXPOSE 0x20
-#define VISIBILITY 0x40
-#define CREATE 0x80
-#define DESTROY 0x100
-#define UNMAP 0x200
-#define MAP 0x400
-#define REPARENT 0x800
-#define CONFIG 0x1000
-#define GRAVITY 0x2000
-#define CIRC 0x4000
-#define PROP 0x8000
-#define COLORMAP 0x10000
-#define VIRTUAL 0x20000
-#define ACTIVATE 0x40000
-#define MAPREQ 0x80000
-#define CONFIGREQ 0x100000
-#define RESIZEREQ 0x200000
-#define CIRCREQ 0x400000
-
-#define KEY_BUTTON_MOTION_VIRTUAL (KEY|BUTTON|MOTION|VIRTUAL)
-#define KEY_BUTTON_MOTION_CROSSING (KEY|BUTTON|MOTION|VIRTUAL|CROSSING)
+#define KEY (1<<0)
+#define BUTTON (1<<1)
+#define MOTION (1<<2)
+#define CROSSING (1<<3)
+#define FOCUS (1<<4)
+#define EXPOSE (1<<5)
+#define VISIBILITY (1<<6)
+#define CREATE (1<<7)
+#define DESTROY (1<<8)
+#define UNMAP (1<<9)
+#define MAP (1<<10)
+#define REPARENT (1<<11)
+#define CONFIG (1<<12)
+#define GRAVITY (1<<13)
+#define CIRC (1<<14)
+#define PROP (1<<15)
+#define COLORMAP (1<<16)
+#define VIRTUAL (1<<17)
+#define ACTIVATE (1<<18)
+#define WHEEL (1<<19)
+#define MAPREQ (1<<20)
+#define CONFIGREQ (1<<21)
+#define RESIZEREQ (1<<22)
+#define CIRCREQ (1<<23)
+
+/*
+ * These structs agree with xkey for the fields type, serial, send_event, display,
+ * window, root, subwindow, time, x, y, x_root, and y_root. So when accessing
+ * these fields we may pretend that we are using a struct xkey.
+ */
+
+#define HAS_XKEY_HEAD (KEY|BUTTON|MOTION|VIRTUAL|CROSSING|WHEEL)
+
+/*
+ * The xcrossing struct puts the state field in a different location, but the other
+ * events above agree on where state is located.
+ */
+
+#define HAS_XKEY_HEAD_AND_STATE (KEY|BUTTON|MOTION|VIRTUAL|WHEEL)
+
+/*
+ * Event types which support -warp.
+ */
+
+#define CAN_WARP (KEY|BUTTON|MOTION|WHEEL)
static const int flagArray[TK_LASTEVENT] = {
/* Not used */ 0,
@@ -539,7 +627,7 @@ static const int flagArray[TK_LASTEVENT] = {
/* VirtualEvent */ VIRTUAL,
/* Activate */ ACTIVATE,
/* Deactivate */ ACTIVATE,
- /* MouseWheel */ KEY
+ /* MouseWheel */ WHEEL
};
/*
@@ -548,11 +636,11 @@ static const int flagArray[TK_LASTEVENT] = {
*/
static const TkStateMap queuePosition[] = {
- {-1, "now"},
- {TCL_QUEUE_HEAD, "head"},
- {TCL_QUEUE_MARK, "mark"},
- {TCL_QUEUE_TAIL, "tail"},
- {-2, NULL}
+ {-1, "now"},
+ {TCL_QUEUE_HEAD, "head"},
+ {TCL_QUEUE_MARK, "mark"},
+ {TCL_QUEUE_TAIL, "tail"},
+ {-2, NULL}
};
/*
@@ -583,8 +671,8 @@ static const TkStateMap notifyDetail[] = {
};
static const TkStateMap circPlace[] = {
- {PlaceOnTop, "PlaceOnTop"},
- {PlaceOnBottom, "PlaceOnBottom"},
+ {PlaceOnTop, "PlaceOnTop"},
+ {PlaceOnBottom, "PlaceOnBottom"},
{-1, NULL}
};
@@ -596,12 +684,12 @@ static const TkStateMap visNotify[] = {
};
static const TkStateMap configureRequestDetail[] = {
- {None, "None"},
- {Above, "Above"},
- {Below, "Below"},
- {BottomIf, "BottomIf"},
- {TopIf, "TopIf"},
- {Opposite, "Opposite"},
+ {None, "None"},
+ {Above, "Above"},
+ {Below, "Below"},
+ {BottomIf, "BottomIf"},
+ {TopIf, "TopIf"},
+ {Opposite, "Opposite"},
{-1, NULL}
};
@@ -611,47 +699,522 @@ static const TkStateMap propNotify[] = {
{-1, NULL}
};
+DEBUG(static int countTableItems = 0;)
+DEBUG(static int countEntryItems = 0;)
+DEBUG(static int countListItems = 0;)
+DEBUG(static int countBindItems = 0;)
+DEBUG(static int countSeqItems = 0;)
+
/*
* Prototypes for local functions defined in this file:
*/
-static void ChangeScreen(Tcl_Interp *interp, char *dispName,
- int screenIndex);
-static int CreateVirtualEvent(Tcl_Interp *interp,
- VirtualEventTable *vetPtr, char *virtString,
- const char *eventString);
-static int DeleteVirtualEvent(Tcl_Interp *interp,
- VirtualEventTable *vetPtr, char *virtString,
- const char *eventString);
+static void ChangeScreen(Tcl_Interp *interp, char *dispName, int screenIndex);
+static int CreateVirtualEvent(Tcl_Interp *interp, VirtualEventTable *vetPtr,
+ char *virtString, const char *eventString);
+static int DeleteVirtualEvent(Tcl_Interp *interp, VirtualEventTable *vetPtr,
+ char *virtString, const char *eventString);
static void DeleteVirtualEventTable(VirtualEventTable *vetPtr);
-static void ExpandPercents(TkWindow *winPtr, const char *before,
- XEvent *eventPtr,KeySym keySym,
- unsigned int scriptCount, Tcl_DString *dsPtr);
-static PatSeq * FindSequence(Tcl_Interp *interp,
- Tcl_HashTable *patternTablePtr, ClientData object,
- const char *eventString, int create,
- int allowVirtual, unsigned long *maskPtr);
-static void GetAllVirtualEvents(Tcl_Interp *interp,
- VirtualEventTable *vetPtr);
-static char * GetField(char *p, char *copy, int size);
-static Tcl_Obj * GetPatternObj(PatSeq *psPtr);
-static int GetVirtualEvent(Tcl_Interp *interp,
- VirtualEventTable *vetPtr, Tcl_Obj *virtName);
-static Tk_Uid GetVirtualEventUid(Tcl_Interp *interp,
- char *virtString);
+static void ExpandPercents(TkWindow *winPtr, const char *before, Event *eventPtr,
+ unsigned scriptCount, Tcl_DString *dsPtr);
+static PatSeq * FindSequence(Tcl_Interp *interp, LookupTables *lookupTables,
+ ClientData object, const char *eventString, int create,
+ int allowVirtual, EventMask *maskPtr);
+static void GetAllVirtualEvents(Tcl_Interp *interp, VirtualEventTable *vetPtr);
+static const char * GetField(const char *p, char *copy, unsigned size);
+static Tcl_Obj * GetPatternObj(const PatSeq *psPtr);
+static int GetVirtualEvent(Tcl_Interp *interp, VirtualEventTable *vetPtr,
+ Tcl_Obj *virtName);
+static Tk_Uid GetVirtualEventUid(Tcl_Interp *interp, char *virtString);
static int HandleEventGenerate(Tcl_Interp *interp, Tk_Window main,
int objc, Tcl_Obj *const objv[]);
static void InitVirtualEventTable(VirtualEventTable *vetPtr);
-static PatSeq * MatchPatterns(TkDisplay *dispPtr,
- BindingTable *bindPtr, PatSeq *psPtr,
- PatSeq *bestPtr, ClientData *objectPtr,
- PatSeq **sourcePtrPtr);
+static PatSeq * MatchPatterns(TkDisplay *dispPtr, Tk_BindingTable bindPtr, PSList *psList,
+ PSList *psSuccList, unsigned patIndex, const Event *eventPtr,
+ ClientData object, PatSeq **physPtrPtr);
static int NameToWindow(Tcl_Interp *interp, Tk_Window main,
Tcl_Obj *objPtr, Tk_Window *tkwinPtr);
-static int ParseEventDescription(Tcl_Interp *interp,
- const char **eventStringPtr, TkPattern *patPtr,
- unsigned long *eventMaskPtr);
+static unsigned ParseEventDescription(Tcl_Interp *interp, const char **eventStringPtr,
+ TkPattern *patPtr, EventMask *eventMaskPtr);
static void DoWarp(ClientData clientData);
+static PSList * GetLookupForEvent(LookupTables* lookupPtr, const Event *eventPtr,
+ Tcl_Obj *object, int onlyConsiderDetailedEvents);
+static void ClearLookupTable(LookupTables *lookupTables, ClientData object);
+static void ClearPromotionLists(Tk_BindingTable bindPtr, ClientData object);
+static PSEntry * MakeListEntry(PSList *pool, PatSeq *psPtr, int needModMasks);
+static void RemovePatSeqFromLookup(LookupTables *lookupTables, PatSeq *psPtr);
+static void RemovePatSeqFromPromotionLists(Tk_BindingTable bindPtr, PatSeq *psPtr);
+static PatSeq * DeletePatSeq(PatSeq *psPtr);
+static void InsertPatSeq(LookupTables *lookupTables, PatSeq *psPtr);
+#if SUPPORT_DEBUGGING
+void TkpDumpPS(const PatSeq *psPtr);
+void TkpDumpPSList(const PSList *psList);
+#endif
+
+/*
+ * Some useful helper functions.
+ */
+#ifdef SUPPORT_DEBUGGING
+static int BindCount = 0;
+#endif
+
+static unsigned Max(unsigned a, unsigned b) { return a < b ? b : a; }
+static int Abs(int n) { return n < 0 ? -n : n; }
+static int IsOdd(int n) { return n & 1; }
+
+static int TestNearbyTime(int lhs, int rhs) { return Abs(lhs - rhs) <= NEARBY_MS; }
+static int TestNearbyCoords(int lhs, int rhs) { return Abs(lhs - rhs) <= NEARBY_PIXELS; }
+
+static int
+IsSubsetOf(
+ ModMask lhsMask, /* this is a subset */
+ ModMask rhsMask) /* of this bit field? */
+{
+ return (lhsMask & rhsMask) == lhsMask;
+}
+
+static const char*
+SkipSpaces(
+ const char* s)
+{
+ assert(s);
+ while (isspace(UCHAR(*s)))
+ ++s;
+ return s;
+}
+
+static const char*
+SkipFieldDelims(
+ const char* s)
+{
+ assert(s);
+ while (*s == '-' || isspace(UCHAR(*s))) {
+ ++s;
+ }
+ return s;
+}
+
+static unsigned
+GetButtonNumber(
+ const char *field)
+{
+ assert(field);
+ return (field[0] >= '1' && field[0] <= '9' && field[1] == '\0') ? field[0] - '0' : 0;
+}
+
+static Time
+CurrentTimeInMilliSecs(void)
+{
+ Tcl_Time now;
+ Tcl_GetTime(&now);
+ return ((Time) now.sec)*1000 + ((Time) now.usec)/1000;
+}
+
+static Info
+GetInfo(
+ const PatSeq *psPtr,
+ unsigned index)
+{
+ assert(psPtr);
+ assert(index < psPtr->numPats);
+
+ return psPtr->pats[index].info;
+}
+
+static unsigned
+GetCount(
+ const PatSeq *psPtr,
+ unsigned index)
+{
+ assert(psPtr);
+ assert(index < psPtr->numPats);
+
+ return psPtr->pats[index].count;
+}
+
+static int
+CountSpecialized(
+ const PatSeq *fstMatchPtr,
+ const PatSeq *sndMatchPtr)
+{
+ int fstCount = 0;
+ int sndCount = 0;
+ unsigned i;
+
+ assert(fstMatchPtr);
+ assert(sndMatchPtr);
+
+ for (i = 0; i < fstMatchPtr->numPats; ++i) {
+ if (GetInfo(fstMatchPtr, i)) { fstCount += GetCount(fstMatchPtr, i); }
+ }
+ for (i = 0; i < sndMatchPtr->numPats; ++i) {
+ if (GetInfo(sndMatchPtr, i)) { sndCount += GetCount(sndMatchPtr, i); }
+ }
+
+ return sndCount - fstCount;
+}
+
+static int
+MatchEventNearby(
+ const XEvent *lhs, /* previous button event */
+ const XEvent *rhs) /* current button event */
+{
+ assert(lhs);
+ assert(rhs);
+ assert(lhs->type == ButtonPress || lhs->type == ButtonRelease);
+ assert(lhs->type == rhs->type);
+
+ /* assert: lhs->xbutton.time <= rhs->xbutton.time */
+
+ return TestNearbyTime(rhs->xbutton.time, lhs->xbutton.time)
+ && TestNearbyCoords(rhs->xbutton.x_root, lhs->xbutton.x_root)
+ && TestNearbyCoords(rhs->xbutton.y_root, lhs->xbutton.y_root);
+}
+
+static int
+MatchEventRepeat(
+ const XEvent *lhs, /* previous key event */
+ const XEvent *rhs) /* current key event */
+{
+ assert(lhs);
+ assert(rhs);
+ assert(lhs->type == KeyPress || lhs->type == KeyRelease);
+ assert(lhs->type == rhs->type);
+
+ /* assert: lhs->xkey.time <= rhs->xkey.time */
+ return TestNearbyTime(rhs->xkey.time, lhs->xkey.time);
+}
+
+static void
+FreePatSeq(
+ PatSeq *psPtr)
+{
+ assert(psPtr);
+ assert(!psPtr->owned);
+ DEBUG(MARK_PSENTRY(psPtr);)
+ ckfree(psPtr->script);
+ if (!psPtr->object) {
+ VirtOwners_Free(&psPtr->ptr.owners);
+ }
+ ckfree(psPtr);
+ DEBUG(countSeqItems -= 1;)
+}
+
+static void
+RemoveListEntry(
+ PSList *pool,
+ PSEntry *psEntry)
+{
+ assert(pool);
+ assert(psEntry);
+
+ if (PSModMaskArr_Capacity(psEntry->lastModMaskArr) > MAX_MOD_MASK_ARR_SIZE) {
+ PSModMaskArr_Free(&psEntry->lastModMaskArr);
+ }
+ PSList_Remove(psEntry);
+ PSList_Append(pool, psEntry);
+}
+
+static void
+ClearList(
+ PSList *psList,
+ PSList *pool,
+ ClientData object)
+{
+ assert(psList);
+ assert(pool);
+
+ if (object) {
+ PSEntry *psEntry;
+ PSEntry *psNext;
+
+ for (psEntry = PSList_First(psList); psEntry; psEntry = psNext) {
+ psNext = PSList_Next(psEntry);
+ if (psEntry->psPtr->object == object) {
+ RemoveListEntry(pool, psEntry);
+ }
+ }
+ } else {
+ PSList_Move(pool, psList);
+ }
+}
+
+static PSEntry *
+FreePatSeqEntry(
+ PSList *pool,
+ PSEntry *entry)
+{
+ PSEntry *next = PSList_Next(entry);
+ (void)pool;
+
+ PSModMaskArr_Free(&entry->lastModMaskArr);
+ ckfree(entry);
+ return next;
+}
+
+static unsigned
+ResolveModifiers(
+ TkDisplay *dispPtr,
+ unsigned modMask)
+{
+ assert(dispPtr);
+
+ if (dispPtr->metaModMask) {
+ if (modMask & META_MASK) {
+ modMask &= ~(ModMask)META_MASK;
+ modMask |= dispPtr->metaModMask;
+ }
+ }
+ if (dispPtr->altModMask) {
+ if (modMask & ALT_MASK) {
+ modMask &= ~(ModMask)ALT_MASK;
+ modMask |= dispPtr->altModMask;
+ }
+ }
+
+ return modMask;
+}
+
+static int
+ButtonNumberFromState(
+ ModMask state)
+{
+ if (!(state & ALL_BUTTONS)) { return 0; }
+ if (state & Button1Mask) { return 1; }
+ if (state & Button2Mask) { return 2; }
+ if (state & Button3Mask) { return 3; }
+ if (state & Button4Mask) { return 4; }
+ if (state & Button5Mask) { return 5; }
+ if (state & Button6Mask) { return 6; }
+ if (state & Button7Mask) { return 7; }
+ if (state & Button8Mask) { return 8; }
+ return 9;
+}
+
+static void
+SetupPatternKey(
+ PatternTableKey *key,
+ const PatSeq *psPtr)
+{
+ const TkPattern *patPtr;
+
+ assert(key);
+ assert(psPtr);
+
+ /* otherwise on some systems the key contains uninitialized bytes */
+ memset(key, 0, sizeof(PatternTableKey));
+
+ patPtr = psPtr->pats;
+ assert(!patPtr->info || !patPtr->name);
+
+ key->object = psPtr->object;
+ key->type = patPtr->eventType;
+ if (patPtr->info) {
+ key->detail.info = patPtr->info;
+ } else {
+ key->detail.name = patPtr->name;
+ }
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * MakeListEntry --
+ *
+ * Makes new entry item for lookup table. We are using a
+ * pool of items, this avoids superfluous memory allocation/
+ * deallocation.
+ *
+ * Results:
+ * New entry item.
+ *
+ * Side effects:
+ * Memory allocated.
+ *
+ *--------------------------------------------------------------
+ */
+
+static PSEntry *
+MakeListEntry(
+ PSList *pool,
+ PatSeq *psPtr,
+ int needModMasks)
+{
+ PSEntry *newEntry = NULL;
+
+ assert(pool);
+ assert(psPtr);
+ assert(psPtr->numPats > 0);
+ assert(TEST_PSENTRY(psPtr));
+
+ if (PSList_IsEmpty(pool)) {
+ newEntry = (PSEntry *)ckalloc(sizeof(PSEntry));
+ newEntry->lastModMaskArr = NULL;
+ DEBUG(countEntryItems += 1;)
+ } else {
+ newEntry = PSList_First(pool);
+ PSList_RemoveHead(pool);
+ }
+
+ if (!needModMasks) {
+ PSModMaskArr_SetSize(newEntry->lastModMaskArr, 0);
+ } else {
+ if (PSModMaskArr_Capacity(newEntry->lastModMaskArr) < psPtr->numPats - 1) {
+ PSModMaskArr_Resize(&newEntry->lastModMaskArr, psPtr->numPats - 1);
+ }
+ PSModMaskArr_SetSize(newEntry->lastModMaskArr, psPtr->numPats - 1);
+ }
+
+ newEntry->psPtr = psPtr;
+ newEntry->window = None;
+ newEntry->expired = 0;
+ newEntry->keepIt = 1;
+ newEntry->count = 1;
+ DEBUG(psPtr->owned = 0;)
+
+ return newEntry;
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * GetLookupForEvent --
+ *
+ * Get specific pattern sequence table for given event.
+ *
+ * Results:
+ * Specific pattern sequence table for given event.
+ *
+ * Side effects:
+ * None.
+ *
+ *--------------------------------------------------------------
+ */
+
+static PSList *
+GetLookupForEvent(
+ LookupTables* lookupTables,
+ const Event *eventPtr,
+ Tcl_Obj *object,
+ int onlyConsiderDetailedEvents)
+{
+ PatternTableKey key;
+ Tcl_HashEntry *hPtr;
+
+ assert(lookupTables);
+ assert(eventPtr);
+
+ /* otherwise on some systems the key contains uninitialized bytes */
+ memset(&key, 0, sizeof(PatternTableKey));
+
+ if (onlyConsiderDetailedEvents) {
+ switch (eventPtr->xev.type) {
+ case ButtonPress: /* fallthru */
+ case ButtonRelease: key.detail.info = eventPtr->xev.xbutton.button; break;
+ case MotionNotify: key.detail.info = ButtonNumberFromState(eventPtr->xev.xmotion.state); break;
+ case KeyPress: /* fallthru */
+ case KeyRelease: key.detail.info = eventPtr->detail.info; break;
+ case VirtualEvent: key.detail.name = eventPtr->detail.name; break;
+ }
+ if (!key.detail.name) {
+ assert(!key.detail.info);
+ return NULL;
+ }
+ }
+
+ key.object = object;
+ key.type = eventPtr->xev.type;
+ hPtr = Tcl_FindHashEntry(&lookupTables->listTable, (char *) &key);
+ return hPtr ? (PSList *)Tcl_GetHashValue(hPtr) : NULL;
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * ClearLookupTable --
+ *
+ * Clear lookup table in given binding table, but only those
+ * bindings associated to given object. If object is NULL
+ * then remove all entries.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *--------------------------------------------------------------
+ */
+static void
+ClearLookupTable(
+ LookupTables *lookupTables,
+ ClientData object)
+{
+ Tcl_HashSearch search;
+ Tcl_HashEntry *hPtr;
+ Tcl_HashEntry *nextPtr;
+ PSList *pool = &lookupTables->entryPool;
+
+ assert(lookupTables);
+
+ for (hPtr = Tcl_FirstHashEntry(&lookupTables->listTable, &search); hPtr; hPtr = nextPtr) {
+ PSList *psList;
+
+ nextPtr = Tcl_NextHashEntry(&search);
+
+ if (object) {
+ const PatternTableKey *key = (const PatternTableKey *)Tcl_GetHashKey(&lookupTables->listTable, hPtr);
+ if (key->object != object) {
+ continue;
+ }
+ }
+
+ psList = (PSList *)Tcl_GetHashValue(hPtr);
+ PSList_Move(pool, psList);
+ ckfree(psList);
+ DEBUG(countListItems -= 1;)
+ Tcl_DeleteHashEntry(hPtr);
+ }
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * ClearPromotionLists --
+ *
+ * Clear all the lists holding the promoted pattern
+ * sequences, which belongs to given object. If object
+ * is NULL then remove all patterns.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+ClearPromotionLists(
+ Tk_BindingTable bindPtr,
+ ClientData object)
+{
+ unsigned newArraySize = 0;
+ unsigned i;
+
+ assert(bindPtr);
+
+ for (i = 0; i < PromArr_Size(bindPtr->promArr); ++i) {
+ PSList *psList = PromArr_Get(bindPtr->promArr, i);
+ ClearList(psList, &bindPtr->lookupTables.entryPool, object);
+ if (!PSList_IsEmpty(psList)) {
+ newArraySize = i + 1;
+ }
+ }
+
+ PromArr_SetSize(bindPtr->promArr, newArraySize);
+}
/*
*---------------------------------------------------------------------------
@@ -671,15 +1234,92 @@ static void DoWarp(ClientData clientData);
*---------------------------------------------------------------------------
*/
+/*
+ * Windoze compiler does not allow the definition of these static variables inside a function,
+ * otherwise this should belong to function TkBindInit().
+ */
+TCL_DECLARE_MUTEX(bindMutex);
+static int initialized = 0;
+
void
TkBindInit(
TkMainInfo *mainPtr) /* The newly created application. */
{
BindInfo *bindInfoPtr;
- if (sizeof(XEvent) < sizeof(XVirtualEvent)) {
- Tcl_Panic("TkBindInit: virtual events can't be supported");
- }
+ assert(mainPtr);
+
+ /* otherwise virtual events can't be supported */
+ assert(sizeof(XEvent) >= sizeof(XVirtualEvent));
+
+ /* type of TkPattern.info is well defined? */
+ assert(sizeof(Info) >= sizeof(KeySym));
+ assert(sizeof(Info) >= sizeof(unsigned));
+
+ /* ensure that our matching algorithm is working (when testing detail) */
+ assert(sizeof(Detail) == sizeof(Tk_Uid));
+
+ /* test expected indices of Button1..Button5, otherwise our button handling is not working */
+ assert(Button1 == 1 && Button2 == 2 && Button3 == 3 && Button4 == 4 && Button5 == 5);
+ assert(Button2Mask == (Button1Mask << 1));
+ assert(Button3Mask == (Button1Mask << 2));
+ assert(Button4Mask == (Button1Mask << 3));
+ assert(Button5Mask == (Button1Mask << 4));
+
+ /* test expected values of button motion masks, otherwise our button handling is not working */
+ assert(Button1MotionMask == Button1Mask);
+ assert(Button2MotionMask == Button2Mask);
+ assert(Button3MotionMask == Button3Mask);
+ assert(Button4MotionMask == Button4Mask);
+ assert(Button5MotionMask == Button5Mask);
+
+ /* because we expect zero if keySym is empty */
+ assert(NoSymbol == 0L);
+
+ /* this must be a union, not a struct, otherwise comparison with NULL will not work */
+ assert(offsetof(Detail, name) == offsetof(Detail, info));
+
+ /* we use some constraints about X*Event */
+ assert(offsetof(XButtonEvent, time) == offsetof(XMotionEvent, time));
+ assert(offsetof(XButtonEvent, x_root) == offsetof(XMotionEvent, x_root));
+ assert(offsetof(XButtonEvent, y_root) == offsetof(XMotionEvent, y_root));
+ assert(offsetof(XCreateWindowEvent, border_width) == offsetof(XConfigureEvent, border_width));
+ assert(offsetof(XCreateWindowEvent, width) == offsetof(XConfigureEvent, width));
+ assert(offsetof(XCreateWindowEvent, window) == offsetof(XCirculateRequestEvent, window));
+ assert(offsetof(XCreateWindowEvent, window) == offsetof(XConfigureEvent, window));
+ assert(offsetof(XCreateWindowEvent, window) == offsetof(XGravityEvent, window));
+ assert(offsetof(XCreateWindowEvent, window) == offsetof(XMapEvent, window));
+ assert(offsetof(XCreateWindowEvent, window) == offsetof(XReparentEvent, window));
+ assert(offsetof(XCreateWindowEvent, window) == offsetof(XUnmapEvent, window));
+ assert(offsetof(XCreateWindowEvent, x) == offsetof(XConfigureEvent, x));
+ assert(offsetof(XCreateWindowEvent, x) == offsetof(XGravityEvent, x));
+ assert(offsetof(XCreateWindowEvent, y) == offsetof(XConfigureEvent, y));
+ assert(offsetof(XCreateWindowEvent, y) == offsetof(XGravityEvent, y));
+ assert(offsetof(XCrossingEvent, time) == offsetof(XEnterWindowEvent, time));
+ assert(offsetof(XCrossingEvent, time) == offsetof(XLeaveWindowEvent, time));
+ assert(offsetof(XCrossingEvent, time) == offsetof(XKeyEvent, time));
+ assert(offsetof(XKeyEvent, root) == offsetof(XButtonEvent, root));
+ assert(offsetof(XKeyEvent, root) == offsetof(XCrossingEvent, root));
+ assert(offsetof(XKeyEvent, root) == offsetof(XMotionEvent, root));
+ assert(offsetof(XKeyEvent, state) == offsetof(XButtonEvent, state));
+ assert(offsetof(XKeyEvent, state) == offsetof(XMotionEvent, state));
+ assert(offsetof(XKeyEvent, subwindow) == offsetof(XButtonEvent, subwindow));
+ assert(offsetof(XKeyEvent, subwindow) == offsetof(XCrossingEvent, subwindow));
+ assert(offsetof(XKeyEvent, subwindow) == offsetof(XMotionEvent, subwindow));
+ assert(offsetof(XKeyEvent, time) == offsetof(XButtonEvent, time));
+ assert(offsetof(XKeyEvent, time) == offsetof(XMotionEvent, time));
+ assert(offsetof(XKeyEvent, x) == offsetof(XButtonEvent, x));
+ assert(offsetof(XKeyEvent, x) == offsetof(XCrossingEvent, x));
+ assert(offsetof(XKeyEvent, x) == offsetof(XMotionEvent, x));
+ assert(offsetof(XKeyEvent, x_root) == offsetof(XButtonEvent, x_root));
+ assert(offsetof(XKeyEvent, x_root) == offsetof(XCrossingEvent, x_root));
+ assert(offsetof(XKeyEvent, x_root) == offsetof(XMotionEvent, x_root));
+ assert(offsetof(XKeyEvent, y) == offsetof(XButtonEvent, y));
+ assert(offsetof(XKeyEvent, y) == offsetof(XCrossingEvent, y));
+ assert(offsetof(XKeyEvent, y) == offsetof(XMotionEvent, y));
+ assert(offsetof(XKeyEvent, y_root) == offsetof(XButtonEvent, y_root));
+ assert(offsetof(XKeyEvent, y_root) == offsetof(XCrossingEvent, y_root));
+ assert(offsetof(XKeyEvent, y_root) == offsetof(XMotionEvent, y_root));
/*
* Initialize the static data structures used by the binding package. They
@@ -693,33 +1333,46 @@ TkBindInit(
const ModInfo *modPtr;
const EventInfo *eiPtr;
int newEntry;
+ unsigned i;
#ifdef REDO_KEYSYM_LOOKUP
const KeySymInfo *kPtr;
Tcl_InitHashTable(&keySymTable, TCL_STRING_KEYS);
Tcl_InitHashTable(&nameTable, TCL_ONE_WORD_KEYS);
- for (kPtr = keyArray; kPtr->name != NULL; kPtr++) {
+ for (kPtr = keyArray; kPtr->name; ++kPtr) {
hPtr = Tcl_CreateHashEntry(&keySymTable, kPtr->name, &newEntry);
- Tcl_SetHashValue(hPtr, INT2PTR(kPtr->value));
- hPtr = Tcl_CreateHashEntry(&nameTable, INT2PTR(kPtr->value),
- &newEntry);
+ Tcl_SetHashValue(hPtr, kPtr->value);
+ hPtr = Tcl_CreateHashEntry(&nameTable, (char *) kPtr->value, &newEntry);
if (newEntry) {
- Tcl_SetHashValue(hPtr, (char *) kPtr->name);
+ Tcl_SetHashValue(hPtr, kPtr->name);
}
}
#endif /* REDO_KEYSYM_LOOKUP */
+ for (i = 0; i < SIZE_OF_ARRAY(eventArrayIndex); ++i) {
+ eventArrayIndex[i] = -1;
+ }
+ for (i = 0; i < SIZE_OF_ARRAY(eventArray); ++i) {
+ unsigned type = eventArray[i].type;
+ assert(type < TK_LASTEVENT);
+ assert(type > 0 || i == SIZE_OF_ARRAY(eventArray) - 1);
+ if (type > 0 && eventArrayIndex[type] == -1) {
+ eventArrayIndex[type] = i;
+ }
+ }
+
Tcl_InitHashTable(&modTable, TCL_STRING_KEYS);
- for (modPtr = modArray; modPtr->name != NULL; modPtr++) {
+ for (modPtr = modArray; modPtr->name; ++modPtr) {
hPtr = Tcl_CreateHashEntry(&modTable, modPtr->name, &newEntry);
- Tcl_SetHashValue(hPtr, (ModInfo *) modPtr);
+ Tcl_SetHashValue(hPtr, modPtr);
}
Tcl_InitHashTable(&eventTable, TCL_STRING_KEYS);
- for (eiPtr = eventArray; eiPtr->name != NULL; eiPtr++) {
+ for (eiPtr = eventArray; eiPtr->name; ++eiPtr) {
hPtr = Tcl_CreateHashEntry(&eventTable, eiPtr->name, &newEntry);
- Tcl_SetHashValue(hPtr, (EventInfo *) eiPtr);
+ Tcl_SetHashValue(hPtr, eiPtr);
}
+
initialized = 1;
}
Tcl_MutexUnlock(&bindMutex);
@@ -727,13 +1380,16 @@ TkBindInit(
mainPtr->bindingTable = Tk_CreateBindingTable(mainPtr->interp);
- bindInfoPtr = ckalloc(sizeof(BindInfo));
+ bindInfoPtr = (BindInfo *)ckalloc(sizeof(BindInfo));
InitVirtualEventTable(&bindInfoPtr->virtualEventTable);
bindInfoPtr->screenInfo.curDispPtr = NULL;
bindInfoPtr->screenInfo.curScreenIndex = -1;
bindInfoPtr->screenInfo.bindingDepth = 0;
bindInfoPtr->deleted = 0;
+ bindInfoPtr->lastCurrentTime = CurrentTimeInMilliSecs();
+ bindInfoPtr->lastEventTime = 0;
mainPtr->bindInfo = bindInfoPtr;
+ DEBUG(countBindItems += 1;)
TkpInitializeMenuBindings(mainPtr->interp, mainPtr->bindingTable);
}
@@ -761,14 +1417,21 @@ TkBindFree(
{
BindInfo *bindInfoPtr;
+ assert(mainPtr);
+
Tk_DeleteBindingTable(mainPtr->bindingTable);
mainPtr->bindingTable = NULL;
-
bindInfoPtr = mainPtr->bindInfo;
DeleteVirtualEventTable(&bindInfoPtr->virtualEventTable);
bindInfoPtr->deleted = 1;
Tcl_EventuallyFree(bindInfoPtr, TCL_DYNAMIC);
mainPtr->bindInfo = NULL;
+
+ DEBUG(countBindItems -= 1;)
+ assert(countBindItems > 0 || countTableItems == 0);
+ assert(countBindItems > 0 || countEntryItems == 0);
+ assert(countBindItems > 0 || countListItems == 0);
+ assert(countBindItems > 0 || countSeqItems == 0);
}
/*
@@ -790,23 +1453,28 @@ TkBindFree(
Tk_BindingTable
Tk_CreateBindingTable(
- Tcl_Interp *interp) /* Interpreter to associate with the binding
- * table: commands are executed in this
- * interpreter. */
+ Tcl_Interp *interp) /* Interpreter to associate with the binding table: commands are
+ * executed in this interpreter. */
{
- BindingTable *bindPtr = ckalloc(sizeof(BindingTable));
- int i;
+ BindingTable *bindPtr = (BindingTable *)ckalloc(sizeof(BindingTable));
+ unsigned i;
+
+ assert(interp);
+ DEBUG(countTableItems += 1;)
/*
* Create and initialize a new binding table.
*/
- for (i = 0; i < EVENT_BUFFER_SIZE; i++) {
- bindPtr->eventRing[i].type = -1;
+ memset(bindPtr, 0, sizeof(BindingTable));
+ for (i = 0; i < SIZE_OF_ARRAY(bindPtr->eventInfo); ++i) {
+ bindPtr->eventInfo[i].xev.type = -1;
}
- bindPtr->curEvent = 0;
- Tcl_InitHashTable(&bindPtr->patternTable,
- sizeof(PatternTableKey)/sizeof(int));
+ bindPtr->curEvent = bindPtr->eventInfo; /* do not assign NULL */
+ bindPtr->lookupTables.number = 0;
+ PromArr_ResizeAndClear(&bindPtr->promArr, 2);
+ Tcl_InitHashTable(&bindPtr->lookupTables.listTable, sizeof(PatternTableKey)/sizeof(int));
+ Tcl_InitHashTable(&bindPtr->lookupTables.patternTable, sizeof(PatternTableKey)/sizeof(int));
Tcl_InitHashTable(&bindPtr->objectTable, TCL_ONE_WORD_KEYS);
bindPtr->interp = interp;
return bindPtr;
@@ -833,35 +1501,103 @@ void
Tk_DeleteBindingTable(
Tk_BindingTable bindPtr) /* Token for the binding table to destroy. */
{
- PatSeq *psPtr, *nextPtr;
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
+ assert(bindPtr);
+
/*
* Find and delete all of the patterns associated with the binding table.
*/
- for (hPtr = Tcl_FirstHashEntry(&bindPtr->patternTable, &search);
- hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- for (psPtr = Tcl_GetHashValue(hPtr); psPtr != NULL; psPtr = nextPtr) {
+ hPtr = Tcl_FirstHashEntry(&bindPtr->lookupTables.patternTable, &search);
+ for ( ; hPtr; hPtr = Tcl_NextHashEntry(&search)) {
+ PatSeq *nextPtr;
+ PatSeq *psPtr;
+
+ for (psPtr = (PatSeq *)Tcl_GetHashValue(hPtr); psPtr; psPtr = nextPtr) {
+ assert(TEST_PSENTRY(psPtr));
nextPtr = psPtr->nextSeqPtr;
- ckfree(psPtr->script);
- ckfree(psPtr);
+ FreePatSeq(psPtr);
}
}
/*
+ * Don't forget to release lookup elements.
+ */
+
+ ClearLookupTable(&bindPtr->lookupTables, NULL);
+ ClearPromotionLists(bindPtr, NULL);
+ PromArr_Free(&bindPtr->promArr);
+ DEBUG(countEntryItems -= PSList_Size(&bindPtr->lookupTables.entryPool);)
+ PSList_Traverse(&bindPtr->lookupTables.entryPool, FreePatSeqEntry);
+
+ /*
* Clean up the rest of the information associated with the binding table.
*/
- Tcl_DeleteHashTable(&bindPtr->patternTable);
+ Tcl_DeleteHashTable(&bindPtr->lookupTables.patternTable);
+ Tcl_DeleteHashTable(&bindPtr->lookupTables.listTable);
Tcl_DeleteHashTable(&bindPtr->objectTable);
+
ckfree(bindPtr);
+ DEBUG(countTableItems -= 1;)
}
/*
*--------------------------------------------------------------
*
+ * InsertPatSeq --
+ *
+ * Insert given pattern sequence into lookup table for fast
+ * access.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Memory allocated.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+InsertPatSeq(
+ LookupTables *lookupTables,
+ PatSeq *psPtr)
+{
+ assert(lookupTables);
+ assert(psPtr);
+ assert(TEST_PSENTRY(psPtr));
+ assert(psPtr->numPats >= 1u);
+
+ if (!(psPtr->added)) {
+ PatternTableKey key;
+ Tcl_HashEntry *hPtr;
+ int isNew;
+ PSList *psList;
+ PSEntry *psEntry;
+
+ SetupPatternKey(&key, psPtr);
+ hPtr = Tcl_CreateHashEntry(&lookupTables->listTable, (char *) &key, &isNew);
+
+ if (isNew) {
+ psList = (PSList *)ckalloc(sizeof(PSList));
+ PSList_Init(psList);
+ Tcl_SetHashValue(hPtr, psList);
+ DEBUG(countListItems += 1;)
+ } else {
+ psList = (PSList *)Tcl_GetHashValue(hPtr);
+ }
+
+ psEntry = MakeListEntry(&lookupTables->entryPool, psPtr, 0);
+ PSList_Append(psList, psEntry);
+ psPtr->added = 1;
+ }
+}
+/*
+ *--------------------------------------------------------------
+ *
* Tk_CreateBinding --
*
* Add a binding to a binding table, so that future calls to Tk_BindEvent
@@ -887,35 +1623,50 @@ unsigned long
Tk_CreateBinding(
Tcl_Interp *interp, /* Used for error reporting. */
Tk_BindingTable bindPtr, /* Table in which to create binding. */
- ClientData object, /* Token for object with which binding is
- * associated. */
- const char *eventString, /* String describing event sequence that
- * triggers binding. */
- const char *script, /* Contains Tcl script to execute when
- * binding triggers. */
- int append) /* 0 means replace any existing binding for
- * eventString; 1 means append to that
- * binding. If the existing binding is for a
- * callback function and not a Tcl command
- * string, the existing binding will always be
- * replaced. */
+ ClientData object, /* Token for object with which binding is associated. */
+ const char *eventString, /* String describing event sequence that triggers binding. */
+ const char *script, /* Contains Tcl script to execute when binding triggers. */
+ int append) /* 0 means replace any existing binding for eventString;
+ * 1 means append to that binding. If the existing binding is
+ * for a callback function and not a Tcl command string, the
+ * existing binding will always be replaced. */
{
PatSeq *psPtr;
- unsigned long eventMask;
- char *newStr, *oldStr;
+ EventMask eventMask;
+ char *oldStr;
+ char *newStr;
+
+ assert(bindPtr);
+ assert(object);
+ assert(eventString);
+ assert(script);
+
+ psPtr = FindSequence(interp, &bindPtr->lookupTables, object, eventString,
+ !!*script, 1, &eventMask);
if (!*script) {
+ assert(!psPtr || psPtr->added);
/* Silently ignore empty scripts -- see SF#3006842 */
- return 1;
+ return eventMask;
}
- psPtr = FindSequence(interp, &bindPtr->patternTable, object, eventString,
- 1, 1, &eventMask);
- if (psPtr == NULL) {
+ if (!psPtr) {
return 0;
}
- if (psPtr->script == NULL) {
- int isNew;
+ assert(TEST_PSENTRY(psPtr));
+
+ if (psPtr->numPats > PromArr_Capacity(bindPtr->promArr)) {
+ /*
+ * We have to increase the size of array containing the lists of promoted sequences.
+ * Normally the maximal size is 1, only in very seldom cases a bigger size is needed.
+ * Note that for technical reasons the capacity should be one higher than the expected
+ * maximal size.
+ */
+ PromArr_ResizeAndClear(&bindPtr->promArr, psPtr->numPats);
+ }
+
+ if (!psPtr->script) {
Tcl_HashEntry *hPtr;
+ int isNew;
/*
* This pattern sequence was just created. Link the pattern into the
@@ -923,33 +1674,28 @@ Tk_CreateBinding(
* these bindings will all automatically be deleted.
*/
- hPtr = Tcl_CreateHashEntry(&bindPtr->objectTable, (char *) object,
- &isNew);
- if (isNew) {
- psPtr->nextObjPtr = NULL;
- } else {
- psPtr->nextObjPtr = Tcl_GetHashValue(hPtr);
- }
+ hPtr = Tcl_CreateHashEntry(&bindPtr->objectTable, (char *) object, &isNew);
+ psPtr->ptr.nextObj = isNew ? NULL : (PatSeq *)Tcl_GetHashValue(hPtr);
Tcl_SetHashValue(hPtr, psPtr);
+ InsertPatSeq(&bindPtr->lookupTables, psPtr);
}
oldStr = psPtr->script;
- if ((append != 0) && (oldStr != NULL)) {
- size_t length1 = strlen(oldStr), length2 = strlen(script);
+ if (append && oldStr) {
+ size_t length1 = strlen(oldStr);
+ size_t length2 = strlen(script);
- newStr = ckalloc(length1 + length2 + 2);
+ newStr = (char *)ckalloc(length1 + length2 + 2);
memcpy(newStr, oldStr, length1);
newStr[length1] = '\n';
- memcpy(newStr+length1+1, script, length2+1);
+ memcpy(newStr + length1 + 1, script, length2 + 1);
} else {
size_t length = strlen(script);
- newStr = ckalloc(length + 1);
- memcpy(newStr, script, length+1);
- }
- if (oldStr != NULL) {
- ckfree(oldStr);
+ newStr = (char *)ckalloc(length + 1);
+ memcpy(newStr, script, length + 1);
}
+ ckfree(oldStr);
psPtr->script = newStr;
return eventMask;
}
@@ -976,66 +1722,51 @@ int
Tk_DeleteBinding(
Tcl_Interp *interp, /* Used for error reporting. */
Tk_BindingTable bindPtr, /* Table in which to delete binding. */
- ClientData object, /* Token for object with which binding is
- * associated. */
- const char *eventString) /* String describing event sequence that
- * triggers binding. */
+ ClientData object, /* Token for object with which binding is associated. */
+ const char *eventString) /* String describing event sequence that triggers binding. */
{
- PatSeq *psPtr, *prevPtr;
- unsigned long eventMask;
- Tcl_HashEntry *hPtr;
+ PatSeq *psPtr;
- psPtr = FindSequence(interp, &bindPtr->patternTable, object, eventString,
- 0, 1, &eventMask);
- if (psPtr == NULL) {
+ assert(bindPtr);
+ assert(object);
+ assert(eventString);
+
+ psPtr = FindSequence(interp, &bindPtr->lookupTables, object, eventString, 0, 1, NULL);
+ if (!psPtr) {
Tcl_ResetResult(interp);
- return TCL_OK;
- }
+ } else {
+ Tcl_HashEntry *hPtr;
+ PatSeq *prevPtr;
- /*
- * Unlink the binding from the list for its object, then from the list for
- * its pattern.
- */
+ assert(TEST_PSENTRY(psPtr));
- hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, object);
- if (hPtr == NULL) {
- Tcl_Panic("Tk_DeleteBinding couldn't find object table entry");
- }
- prevPtr = Tcl_GetHashValue(hPtr);
- if (prevPtr == psPtr) {
- Tcl_SetHashValue(hPtr, psPtr->nextObjPtr);
- } else {
- for ( ; ; prevPtr = prevPtr->nextObjPtr) {
- if (prevPtr == NULL) {
- Tcl_Panic("Tk_DeleteBinding couldn't find on object list");
- }
- if (prevPtr->nextObjPtr == psPtr) {
- prevPtr->nextObjPtr = psPtr->nextObjPtr;
- break;
- }
+ /*
+ * Unlink the binding from the list for its object.
+ */
+
+ if (!(hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, (char *) object))) {
+ Tcl_Panic("Tk_DeleteBinding couldn't find object table entry");
}
- }
- prevPtr = Tcl_GetHashValue(psPtr->hPtr);
- if (prevPtr == psPtr) {
- if (psPtr->nextSeqPtr == NULL) {
- Tcl_DeleteHashEntry(psPtr->hPtr);
+ prevPtr = (PatSeq *)Tcl_GetHashValue(hPtr);
+ if (prevPtr == psPtr) {
+ Tcl_SetHashValue(hPtr, psPtr->ptr.nextObj);
} else {
- Tcl_SetHashValue(psPtr->hPtr, psPtr->nextSeqPtr);
- }
- } else {
- for ( ; ; prevPtr = prevPtr->nextSeqPtr) {
- if (prevPtr == NULL) {
- Tcl_Panic("Tk_DeleteBinding couldn't find on hash chain");
- }
- if (prevPtr->nextSeqPtr == psPtr) {
- prevPtr->nextSeqPtr = psPtr->nextSeqPtr;
- break;
+ for ( ; ; prevPtr = prevPtr->ptr.nextObj) {
+ if (!prevPtr) {
+ Tcl_Panic("Tk_DeleteBinding couldn't find on object list");
+ }
+ if (prevPtr->ptr.nextObj == psPtr) {
+ prevPtr->ptr.nextObj = psPtr->ptr.nextObj;
+ break;
+ }
}
}
+
+ RemovePatSeqFromLookup(&bindPtr->lookupTables, psPtr);
+ RemovePatSeqFromPromotionLists(bindPtr, psPtr);
+ DeletePatSeq(psPtr);
}
- ckfree(psPtr->script);
- ckfree(psPtr);
return TCL_OK;
}
@@ -1064,20 +1795,18 @@ const char *
Tk_GetBinding(
Tcl_Interp *interp, /* Interpreter for error reporting. */
Tk_BindingTable bindPtr, /* Table in which to look for binding. */
- ClientData object, /* Token for object with which binding is
- * associated. */
- const char *eventString) /* String describing event sequence that
- * triggers binding. */
+ ClientData object, /* Token for object with which binding is associated. */
+ const char *eventString) /* String describing event sequence that triggers binding. */
{
- PatSeq *psPtr;
- unsigned long eventMask;
+ const PatSeq *psPtr;
- psPtr = FindSequence(interp, &bindPtr->patternTable, object, eventString,
- 0, 1, &eventMask);
- if (psPtr == NULL) {
- return NULL;
- }
- return psPtr->script;
+ assert(bindPtr);
+ assert(object);
+ assert(eventString);
+
+ psPtr = FindSequence(interp, &bindPtr->lookupTables, object, eventString, 0, 1, NULL);
+ assert(!psPtr || TEST_PSENTRY(psPtr));
+ return psPtr ? psPtr->script : NULL;
}
/*
@@ -1106,26 +1835,171 @@ Tk_GetAllBindings(
Tk_BindingTable bindPtr, /* Table in which to look for bindings. */
ClientData object) /* Token for object. */
{
- PatSeq *psPtr;
Tcl_HashEntry *hPtr;
- Tcl_Obj *resultObj;
- hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, object);
- if (hPtr == NULL) {
- return;
- }
+ assert(bindPtr);
+ assert(object);
+
+ if ((hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, (char *) object))) {
+ const PatSeq *psPtr;
+ Tcl_Obj *resultObj = Tcl_NewObj();
- resultObj = Tcl_NewObj();
- for (psPtr = Tcl_GetHashValue(hPtr); psPtr != NULL;
- psPtr = psPtr->nextObjPtr) {
/*
- * For each binding, output information about each of the patterns in
- * its sequence.
+ * For each binding, output information about each of the patterns in its sequence.
*/
- Tcl_ListObjAppendElement(NULL, resultObj, GetPatternObj(psPtr));
+ for (psPtr = (const PatSeq *)Tcl_GetHashValue(hPtr); psPtr; psPtr = psPtr->ptr.nextObj) {
+ assert(TEST_PSENTRY(psPtr));
+ Tcl_ListObjAppendElement(NULL, resultObj, GetPatternObj(psPtr));
+ }
+ Tcl_SetObjResult(interp, resultObj);
}
- Tcl_SetObjResult(interp, resultObj);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * RemovePatSeqFromLookup --
+ *
+ * Remove given pattern sequence from lookup tables. This
+ * can be required before deleting the pattern sequence.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RemovePatSeqFromLookup(
+ LookupTables *lookupTables, /* Remove from this lookup tables. */
+ PatSeq *psPtr) /* Remove this pattern sequence. */
+{
+ PatternTableKey key;
+ Tcl_HashEntry *hPtr;
+
+ assert(lookupTables);
+ assert(psPtr);
+
+ SetupPatternKey(&key, psPtr);
+
+ if ((hPtr = Tcl_FindHashEntry(&lookupTables->listTable, (char *) &key))) {
+ PSList *psList = (PSList *)Tcl_GetHashValue(hPtr);
+ PSEntry *psEntry;
+
+ TK_DLIST_FOREACH(psEntry, psList) {
+ if (psEntry->psPtr == psPtr) {
+ psPtr->added = 0;
+ RemoveListEntry(&lookupTables->entryPool, psEntry);
+ return;
+ }
+ }
+ }
+
+ assert(!"couldn't find pattern sequence in lookup");
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * RemovePatSeqFromPromotionLists --
+ *
+ * Remove given pattern sequence from promotion lists. This
+ * can be required before deleting the pattern sequence.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RemovePatSeqFromPromotionLists(
+ Tk_BindingTable bindPtr, /* Table in which to look for bindings. */
+ PatSeq *psPtr) /* Remove this pattern sequence. */
+{
+ unsigned i;
+
+ assert(bindPtr);
+ assert(psPtr);
+
+ for (i = 0; i < PromArr_Size(bindPtr->promArr); ++i) {
+ PSList *psList = PromArr_Get(bindPtr->promArr, i);
+ PSEntry *psEntry;
+
+ TK_DLIST_FOREACH(psEntry, psList) {
+ if (psEntry->psPtr == psPtr) {
+ RemoveListEntry(&bindPtr->lookupTables.entryPool, psEntry);
+ break;
+ }
+ }
+ }
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * DeletePatSeq --
+ *
+ * Delete given pattern sequence. Possibly it is required
+ * to invoke RemovePatSeqFromLookup(), and RemovePatSeqFromPromotionLists()
+ * before.
+ *
+ * Results:
+ * Pointer to succeeding pattern sequence.
+ *
+ * Side effects:
+ * Deallocation of memory.
+ *
+ *--------------------------------------------------------------
+ */
+
+static PatSeq *
+DeletePatSeq(
+ PatSeq *psPtr) /* Delete this pattern sequence. */
+{
+ PatSeq *prevPtr;
+ PatSeq *nextPtr;
+
+ assert(psPtr);
+ assert(!psPtr->added);
+ assert(!psPtr->owned);
+
+ prevPtr = (PatSeq *)Tcl_GetHashValue(psPtr->hPtr);
+ nextPtr = psPtr->ptr.nextObj;
+
+ /*
+ * Be sure to remove each binding from its hash chain in the pattern
+ * table. If this is the last pattern in the chain, then delete the
+ * hash entry too.
+ */
+
+ if (prevPtr == psPtr) {
+ if (!psPtr->nextSeqPtr) {
+ Tcl_DeleteHashEntry(psPtr->hPtr);
+ } else {
+ Tcl_SetHashValue(psPtr->hPtr, psPtr->nextSeqPtr);
+ }
+ } else {
+ for ( ; ; prevPtr = prevPtr->nextSeqPtr) {
+ if (!prevPtr) {
+ Tcl_Panic("DeletePatSeq couldn't find on hash chain");
+ }
+ if (prevPtr->nextSeqPtr == psPtr) {
+ prevPtr->nextSeqPtr = psPtr->nextSeqPtr;
+ break;
+ }
+ }
+ }
+
+ FreePatSeq(psPtr);
+ return nextPtr;
}
/*
@@ -1150,45 +2024,30 @@ Tk_DeleteAllBindings(
Tk_BindingTable bindPtr, /* Table in which to delete bindings. */
ClientData object) /* Token for object. */
{
- PatSeq *psPtr, *prevPtr;
+ PatSeq *psPtr;
PatSeq *nextPtr;
Tcl_HashEntry *hPtr;
- hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, object);
- if (hPtr == NULL) {
+ assert(bindPtr);
+ assert(object);
+
+ if (!(hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, (char *) object))) {
return;
}
- for (psPtr = Tcl_GetHashValue(hPtr); psPtr != NULL;
- psPtr = nextPtr) {
- nextPtr = psPtr->nextObjPtr;
- /*
- * Be sure to remove each binding from its hash chain in the pattern
- * table. If this is the last pattern in the chain, then delete the
- * hash entry too.
- */
+ /*
+ * Don't forget to clear lookup tables.
+ */
- prevPtr = Tcl_GetHashValue(psPtr->hPtr);
- if (prevPtr == psPtr) {
- if (psPtr->nextSeqPtr == NULL) {
- Tcl_DeleteHashEntry(psPtr->hPtr);
- } else {
- Tcl_SetHashValue(psPtr->hPtr, psPtr->nextSeqPtr);
- }
- } else {
- for ( ; ; prevPtr = prevPtr->nextSeqPtr) {
- if (prevPtr == NULL) {
- Tcl_Panic("Tk_DeleteAllBindings couldn't find on hash chain");
- }
- if (prevPtr->nextSeqPtr == psPtr) {
- prevPtr->nextSeqPtr = psPtr->nextSeqPtr;
- break;
- }
- }
- }
- ckfree(psPtr->script);
- ckfree(psPtr);
+ ClearLookupTable(&bindPtr->lookupTables, object);
+ ClearPromotionLists(bindPtr, object);
+
+ for (psPtr = (PatSeq *)Tcl_GetHashValue(hPtr); psPtr; psPtr = nextPtr) {
+ assert(TEST_PSENTRY(psPtr));
+ DEBUG(psPtr->added = 0;)
+ nextPtr = DeletePatSeq(psPtr);
}
+
Tcl_DeleteHashEntry(hPtr);
}
@@ -1217,42 +2076,139 @@ Tk_DeleteAllBindings(
*---------------------------------------------------------------------------
*/
+/* helper function */
+static void
+ResetCounters(
+ Event *eventInfo,
+ unsigned eventType,
+ Window window)
+{
+ Event *curEvent;
+
+ assert(eventInfo);
+ curEvent = eventInfo + eventType;
+
+ if (curEvent->xev.xany.window == window) {
+ curEvent->xev.xany.window = None;
+ eventInfo[eventType].countAny = 0;
+ eventInfo[eventType].countDetailed = 0;
+ }
+}
+
+/* helper function */
+static int
+IsBetterMatch(
+ const PatSeq *fstMatchPtr,
+ const PatSeq *sndMatchPtr) /* this is a better match? */
+{
+ int diff;
+
+ if (!sndMatchPtr) { return 0; }
+ if (!fstMatchPtr) { return 1; }
+
+ diff = CountSpecialized(fstMatchPtr, sndMatchPtr);
+ if (diff > 0) { return 1; }
+ if (diff < 0) { return 0; }
+
+#if PREFER_MOST_SPECIALIZED_EVENT
+ { /* local scope */
+#define M (Tcl_WideUInt)1000000
+ static const Tcl_WideUInt weight[5] = { 0, 1, M, M*M, M*M*M };
+#undef M
+ Tcl_WideUInt fstCount = 0;
+ Tcl_WideUInt sndCount = 0;
+ unsigned i;
+
+ /*
+ * Count the most high-ordered patterns.
+ *
+ * (This computation assumes that a sequence does not contain more than
+ * 1,000,000 single patterns. It can be precluded that in practice this
+ * assumption will not be violated.)
+ */
+
+ for (i = 0; i < fstMatchPtr->numPats; ++i) {
+ assert(GetCount(fstMatchPtr, i) < SIZE_OF_ARRAY(weight));
+ fstCount += weight[GetCount(fstMatchPtr, i)];
+ }
+ for (i = 0; i < sndMatchPtr->numPats; ++i) {
+ assert(GetCount(sndMatchPtr, i) < SIZE_OF_ARRAY(weight));
+ sndCount += weight[GetCount(sndMatchPtr, i)];
+ }
+ if (sndCount > fstCount) { return 1; }
+ if (sndCount < fstCount) { return 0; }
+ }
+#endif
+
+ return sndMatchPtr->number > fstMatchPtr->number;
+}
+
void
Tk_BindEvent(
Tk_BindingTable bindPtr, /* Table in which to look for bindings. */
XEvent *eventPtr, /* What actually happened. */
- Tk_Window tkwin, /* Window on display where event occurred
- * (needed in order to locate display
- * information). */
- int numObjects, /* Number of objects at *objectPtr. */
- ClientData *objectPtr) /* Array of one or more objects to check for a
- * matching binding. */
+ Tk_Window tkwin, /* Window on display where event occurred (needed in order to
+ * locate display information). */
+ int numObjects, /* Number of objects at *objArr. */
+ ClientData *objArr) /* Array of one or more objects to check for a matching binding. */
{
- TkDisplay *dispPtr;
+ Tcl_Interp *interp;
ScreenInfo *screenPtr;
- BindInfo *bindInfoPtr;
+ TkDisplay *dispPtr;
TkDisplay *oldDispPtr;
- XEvent *ringPtr;
- PatSeq *vMatchDetailList, *vMatchNoDetailList;
- int flags, oldScreen;
- unsigned int scriptCount;
- Tcl_Interp *interp;
- Tcl_DString scripts;
- Tcl_InterpState interpState;
- Detail detail;
- char *p, *end;
+ Event *curEvent;
TkWindow *winPtr = (TkWindow *) tkwin;
- PatternTableKey key;
+ BindInfo *bindInfoPtr;
+ Tcl_InterpState interpState;
+ LookupTables *physTables;
+ PatSeq *psPtr[2];
+ PatSeq *matchPtrBuf[32];
+ PatSeq **matchPtrArr = matchPtrBuf;
+ PSList *psl[2];
+ Tcl_DString scripts;
+ const char *p;
+ const char *end;
+ unsigned scriptCount;
+ int oldScreen;
+ unsigned flags;
+ unsigned arraySize;
+ unsigned newArraySize;
+ unsigned i, k;
+
+ assert(bindPtr);
+ assert(eventPtr);
+ assert(tkwin);
+ assert(numObjects >= 0);
/*
* Ignore events on windows that don't have names: these are windows like
* wrapper windows that shouldn't be visible to the application.
*/
- if (winPtr->pathName == NULL) {
+ if (!winPtr->pathName) {
return;
}
+ flags = flagArray[eventPtr->type];
+
+ /*
+ * Ignore event types which are not in flagArray and all zeroes there.
+ */
+
+ if (eventPtr->type >= TK_LASTEVENT || !flags) {
+ return;
+ }
+
+ if (flags & HAS_XKEY_HEAD_AND_STATE) {
+ bindPtr->curModMask = eventPtr->xkey.state;
+ } else if (flags & CROSSING) {
+ bindPtr->curModMask = eventPtr->xcrossing.state;
+ }
+
+ dispPtr = ((TkWindow *) tkwin)->dispPtr;
+ bindInfoPtr = winPtr->mainPtr->bindInfo;
+ curEvent = bindPtr->eventInfo + eventPtr->type;
+
/*
* Ignore the event completely if it is an Enter, Leave, FocusIn, or
* FocusOut event with detail NotifyInferior. The reason for ignoring
@@ -1260,205 +2216,339 @@ Tk_BindEvent(
* children to visible to bindings on the parent: this would cause
* problems for mega-widgets, since the internal structure of a
* mega-widget isn't supposed to be visible to people watching the parent.
+ *
+ * Furthermore we have to compute current time, needed for "event generate".
*/
- if ((eventPtr->type == EnterNotify) || (eventPtr->type == LeaveNotify)) {
+ switch (eventPtr->type) {
+ case EnterNotify:
+ case LeaveNotify:
+ if (eventPtr->xcrossing.time) {
+ bindInfoPtr->lastCurrentTime = CurrentTimeInMilliSecs();
+ bindInfoPtr->lastEventTime = eventPtr->xcrossing.time;
+ }
if (eventPtr->xcrossing.detail == NotifyInferior) {
return;
}
- }
- if ((eventPtr->type == FocusIn) || (eventPtr->type == FocusOut)) {
+ break;
+ case FocusIn:
+ case FocusOut:
if (eventPtr->xfocus.detail == NotifyInferior) {
return;
}
- }
-
- /*
- * Ignore event types which are not in flagArray and all zeroes there.
- * Most notably, NoExpose events can fill the ring buffer and disturb
- * (thus masking out) event sequences of interest.
- */
+ break;
+ case KeyPress:
+ case KeyRelease: {
+ int reset = 1;
- if ((eventPtr->type >= TK_LASTEVENT) || !flagArray[eventPtr->type]) {
- return;
+ if (eventPtr->xkey.time) {
+ bindInfoPtr->lastCurrentTime = CurrentTimeInMilliSecs();
+ bindInfoPtr->lastEventTime = eventPtr->xkey.time;
+ }
+ /* modifier keys should not influence button events */
+ for (i = 0; i < (unsigned) dispPtr->numModKeyCodes; ++i) {
+ if (dispPtr->modKeyCodes[i] == eventPtr->xkey.keycode) {
+ reset = 0;
+ }
+ }
+ if (reset) {
+ /* reset repetition count for button events */
+ bindPtr->eventInfo[ButtonPress].countAny = 0;
+ bindPtr->eventInfo[ButtonPress].countDetailed = 0;
+ bindPtr->eventInfo[ButtonRelease].countAny = 0;
+ bindPtr->eventInfo[ButtonRelease].countDetailed = 0;
+ }
+ break;
+ }
+ case ButtonPress:
+ case ButtonRelease:
+ /* reset repetition count for key events */
+ bindPtr->eventInfo[KeyPress].countAny = 0;
+ bindPtr->eventInfo[KeyPress].countDetailed = 0;
+ bindPtr->eventInfo[KeyRelease].countAny = 0;
+ bindPtr->eventInfo[KeyRelease].countDetailed = 0;
+ /* fallthru */
+ case MotionNotify:
+ if (eventPtr->xmotion.time) {
+ bindInfoPtr->lastCurrentTime = CurrentTimeInMilliSecs();
+ bindInfoPtr->lastEventTime = eventPtr->xmotion.time;
+ }
+ break;
+ case PropertyNotify:
+ if (eventPtr->xproperty.time) {
+ bindInfoPtr->lastCurrentTime = CurrentTimeInMilliSecs();
+ bindInfoPtr->lastEventTime = eventPtr->xproperty.time;
+ }
+ break;
+ case DestroyNotify:
+ ResetCounters(bindPtr->eventInfo, KeyPress, eventPtr->xany.window);
+ ResetCounters(bindPtr->eventInfo, KeyRelease, eventPtr->xany.window);
+ ResetCounters(bindPtr->eventInfo, ButtonPress, eventPtr->xany.window);
+ ResetCounters(bindPtr->eventInfo, ButtonRelease, eventPtr->xany.window);
+ break;
}
-
- dispPtr = ((TkWindow *) tkwin)->dispPtr;
- bindInfoPtr = winPtr->mainPtr->bindInfo;
/*
- * Add the new event to the ring of saved events for the binding table.
- * Two tricky points:
- *
- * 1. Combine consecutive MotionNotify events. Do this by putting the new
- * event *on top* of the previous event.
- * 2. If a modifier key is held down, it auto-repeats to generate
- * continuous KeyPress and KeyRelease events. These can flush the event
- * ring so that valuable information is lost (such as repeated button
- * clicks). To handle this, check for the special case of a modifier
- * KeyPress arriving when the previous two events are a KeyRelease and
- * KeyPress of the same key. If this happens, mark the most recent
- * event (the KeyRelease) invalid and put the new event on top of the
- * event before that (the KeyPress).
+ * Now check whether this is a repeating event (multi-click, repeated key press, and so on).
*/
- if ((eventPtr->type == MotionNotify)
- && (bindPtr->eventRing[bindPtr->curEvent].type == MotionNotify)) {
- /*
- * Don't advance the ring pointer.
- */
- } else if (eventPtr->type == KeyPress) {
- int i;
-
- for (i = 0; ; i++) {
- if (i >= dispPtr->numModKeyCodes) {
- goto advanceRingPointer;
+ /* NOTE: if curEvent is not yet set, then the following cannot match: */
+ if (curEvent->xev.xany.window == eventPtr->xany.window) {
+ switch (eventPtr->type) {
+ case KeyPress:
+ case KeyRelease:
+ if (MatchEventRepeat(&curEvent->xev, eventPtr)) {
+ if (curEvent->xev.xkey.keycode == eventPtr->xkey.keycode) {
+ ++curEvent->countDetailed;
+ } else {
+ curEvent->countDetailed = 1;
+ }
+ ++curEvent->countAny;
+ } else {
+ curEvent->countAny = curEvent->countDetailed = 1;
}
- if (dispPtr->modKeyCodes[i] == eventPtr->xkey.keycode) {
- break;
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ if (MatchEventNearby(&curEvent->xev, eventPtr)) {
+ if (curEvent->xev.xbutton.button == eventPtr->xbutton.button) {
+ ++curEvent->countDetailed;
+ } else {
+ curEvent->countDetailed = 1;
+ }
+ ++curEvent->countAny;
+ } else {
+ curEvent->countAny = curEvent->countDetailed = 1;
}
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ if (TestNearbyTime(eventPtr->xcrossing.time, curEvent->xev.xcrossing.time)) {
+ ++curEvent->countAny;
+ } else {
+ curEvent->countAny = 1;
+ }
+ break;
+ case PropertyNotify:
+ if (TestNearbyTime(eventPtr->xproperty.time, curEvent->xev.xproperty.time)) {
+ ++curEvent->countAny;
+ } else {
+ curEvent->countAny = 1;
+ }
+ break;
+ default:
+ ++curEvent->countAny;
+ break;
}
- ringPtr = &bindPtr->eventRing[bindPtr->curEvent];
- if ((ringPtr->type != KeyRelease)
- || (ringPtr->xkey.keycode != eventPtr->xkey.keycode)) {
- goto advanceRingPointer;
- }
- if (bindPtr->curEvent <= 0) {
- i = EVENT_BUFFER_SIZE - 1;
- } else {
- i = bindPtr->curEvent - 1;
- }
- ringPtr = &bindPtr->eventRing[i];
- if ((ringPtr->type != KeyPress)
- || (ringPtr->xkey.keycode != eventPtr->xkey.keycode)) {
- goto advanceRingPointer;
- }
- bindPtr->eventRing[bindPtr->curEvent].type = -1;
- bindPtr->curEvent = i;
} else {
-
- advanceRingPointer:
- bindPtr->curEvent++;
- if (bindPtr->curEvent >= EVENT_BUFFER_SIZE) {
- bindPtr->curEvent = 0;
- }
+ curEvent->countAny = curEvent->countDetailed = 1;
}
- ringPtr = &bindPtr->eventRing[bindPtr->curEvent];
- memcpy(ringPtr, eventPtr, sizeof(XEvent));
- detail.clientData = 0;
- flags = flagArray[ringPtr->type];
+
+ /*
+ * Now update the details.
+ */
+
+ curEvent->xev = *eventPtr;
if (flags & KEY) {
- detail.keySym = TkpGetKeySym(dispPtr, ringPtr);
- if (detail.keySym == NoSymbol) {
- detail.keySym = 0;
- }
+ curEvent->detail.info = TkpGetKeySym(dispPtr, eventPtr);
} else if (flags & BUTTON) {
- detail.button = ringPtr->xbutton.button;
+ curEvent->detail.info = eventPtr->xbutton.button;
+ } else if (flags & MOTION) {
+ curEvent->detail.info = ButtonNumberFromState(eventPtr->xmotion.state);
} else if (flags & VIRTUAL) {
- detail.name = ((XVirtualEvent *) ringPtr)->name;
+ curEvent->detail.name = ((XVirtualEvent *) eventPtr)->name;
}
- bindPtr->detailRing[bindPtr->curEvent] = detail;
- /*
- * Find out if there are any virtual events that correspond to this
- * physical event (or sequence of physical events).
- */
+ bindPtr->curEvent = curEvent;
+ physTables = &bindPtr->lookupTables;
+ scriptCount = 0;
+ arraySize = 0;
+ Tcl_DStringInit(&scripts);
- vMatchDetailList = NULL;
- vMatchNoDetailList = NULL;
- memset(&key, 0, sizeof(key));
+ if ((size_t) numObjects > SIZE_OF_ARRAY(matchPtrBuf)) {
+ /* it's unrealistic that the buffer size is too small, but who knows? */
+ matchPtrArr = (PatSeq **)ckalloc(numObjects*sizeof(matchPtrArr[0]));
+ }
+ memset(matchPtrArr, 0, numObjects*sizeof(matchPtrArr[0]));
- if (ringPtr->type != VirtualEvent) {
- Tcl_HashTable *veptPtr = &bindInfoPtr->virtualEventTable.patternTable;
- Tcl_HashEntry *hPtr;
+ if (!PromArr_IsEmpty(bindPtr->promArr)) {
+ for (k = 0; k < (unsigned) numObjects; ++k) {
+ psl[1] = PromArr_Last(bindPtr->promArr);
+ psl[0] = psl[1] - 1;
- key.object = NULL;
- key.type = ringPtr->type;
- key.detail = detail;
+ /*
+ * Loop over all promoted bindings, finding the longest matching one.
+ *
+ * Note that we must process all lists, because all matching patterns
+ * have to be promoted. Normally at most one list will be processed, and
+ * usually this list only contains one or two patterns.
+ */
- hPtr = Tcl_FindHashEntry(veptPtr, &key);
- if (hPtr != NULL) {
- vMatchDetailList = Tcl_GetHashValue(hPtr);
- }
+ for (i = PromArr_Size(bindPtr->promArr); i > 0; --i, --psl[0], --psl[1]) {
+ psPtr[0] = MatchPatterns(dispPtr, bindPtr, psl[0], psl[1], i, curEvent, objArr[k], NULL);
- if (key.detail.clientData != 0) {
- key.detail.clientData = 0;
- hPtr = Tcl_FindHashEntry(veptPtr, &key);
- if (hPtr != NULL) {
- vMatchNoDetailList = Tcl_GetHashValue(hPtr);
+ if (IsBetterMatch(matchPtrArr[k], psPtr[0])) {
+ /* we will process it later, because we still may find a pattern with better match */
+ matchPtrArr[k] = psPtr[0];
+ }
+ if (!PSList_IsEmpty(psl[1])) {
+ /* we have promoted sequences, adjust array size */
+ arraySize = Max(i + 1, arraySize);
+ }
}
}
}
/*
- * Loop over all the binding tags, finding the binding script or callback
- * for each one. Append all of the binding scripts, with %-sequences
- * expanded, to "scripts", with null characters separating the scripts for
- * each object.
+ * 1. Look for bindings for the specific detail (button and key events).
+ * 2. Look for bindings without detail.
*/
- scriptCount = 0;
- Tcl_DStringInit(&scripts);
+ for (k = 0; k < (unsigned) numObjects; ++k) {
+ PSList *psSuccList = PromArr_First(bindPtr->promArr);
+ PatSeq *bestPtr;
- for ( ; numObjects > 0; numObjects--, objectPtr++) {
- PatSeq *matchPtr = NULL, *sourcePtr = NULL;
- Tcl_HashEntry *hPtr;
+ psl[0] = GetLookupForEvent(physTables, curEvent, (Tcl_Obj *)objArr[k], 1);
+ psl[1] = GetLookupForEvent(physTables, curEvent, (Tcl_Obj *)objArr[k], 0);
- /*
- * Match the new event against those recorded in the pattern table,
- * saving the longest matching pattern. For events with details
- * (button and key events), look for a binding for the specific key or
- * button. First see if the event matches a physical event that the
- * object is interested in, then look for a virtual event.
- */
+ assert(psl[0] == NULL || psl[0] != psl[1]);
- key.object = *objectPtr;
- key.type = ringPtr->type;
- key.detail = detail;
- hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, &key);
- if (hPtr != NULL) {
- matchPtr = MatchPatterns(dispPtr, bindPtr, Tcl_GetHashValue(hPtr),
- matchPtr, NULL, &sourcePtr);
- }
+ psPtr[0] = MatchPatterns(dispPtr, bindPtr, psl[0], psSuccList, 0, curEvent, objArr[k], NULL);
+ psPtr[1] = MatchPatterns(dispPtr, bindPtr, psl[1], psSuccList, 0, curEvent, objArr[k], NULL);
- if (vMatchDetailList != NULL) {
- matchPtr = MatchPatterns(dispPtr, bindPtr, vMatchDetailList,
- matchPtr, objectPtr, &sourcePtr);
+ if (!PSList_IsEmpty(psSuccList)) {
+ /* we have promoted sequences, adjust array size */
+ arraySize = Max(1u, arraySize);
}
- /*
- * If no match was found, look for a binding for all keys or buttons
- * (detail of 0). Again, first match on a virtual event.
- */
+ bestPtr = psPtr[0] ? psPtr[0] : psPtr[1];
- if ((detail.clientData != 0) && (matchPtr == NULL)) {
- key.detail.clientData = 0;
- hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, &key);
- if (hPtr != NULL) {
- matchPtr = MatchPatterns(dispPtr, bindPtr,
- Tcl_GetHashValue(hPtr), matchPtr, NULL, &sourcePtr);
+ if (matchPtrArr[k]) {
+ if (IsBetterMatch(matchPtrArr[k], bestPtr)) {
+ matchPtrArr[k] = bestPtr;
+ } else {
+ /*
+ * We've already found a higher level match, nevertheless it was required to
+ * process the level zero patterns because of possible promotions.
+ */
}
+ /*
+ * Now we have to catch up the processing of the script.
+ */
+ } else {
+ /*
+ * We have to look whether we can find a better match in virtual table, provided that we
+ * don't have a higher level match.
+ */
- if (vMatchNoDetailList != NULL) {
- matchPtr = MatchPatterns(dispPtr, bindPtr, vMatchNoDetailList,
- matchPtr, objectPtr, &sourcePtr);
+ matchPtrArr[k] = bestPtr;
+
+ if (eventPtr->type != VirtualEvent) {
+ LookupTables *virtTables = &bindInfoPtr->virtualEventTable.lookupTables;
+ PatSeq *matchPtr = matchPtrArr[k];
+ PatSeq *mPtr;
+ PSList *psl[2];
+
+ /*
+ * Note that virtual events cannot promote.
+ */
+
+ psl[0] = GetLookupForEvent(virtTables, curEvent, NULL, 1);
+ psl[1] = GetLookupForEvent(virtTables, curEvent, NULL, 0);
+
+ assert(psl[0] == NULL || psl[0] != psl[1]);
+
+ mPtr = MatchPatterns(dispPtr, bindPtr, psl[0], NULL, 0, curEvent, objArr[k], &matchPtr);
+ if (mPtr) {
+ matchPtrArr[k] = matchPtr;
+ matchPtr = mPtr;
+ }
+ if (MatchPatterns(dispPtr, bindPtr, psl[1], NULL, 0, curEvent, objArr[k], &matchPtr)) {
+ matchPtrArr[k] = matchPtr;
+ }
}
}
- if (matchPtr != NULL) {
- ExpandPercents(winPtr, sourcePtr->script, eventPtr,
- detail.keySym, scriptCount++, &scripts);
+ if (matchPtrArr[k]) {
+ ExpandPercents(winPtr, matchPtrArr[k]->script, curEvent, scriptCount++, &scripts);
+ /* nul is added to the scripts string to separate the various scripts */
+ Tcl_DStringAppend(&scripts, "", 1);
+ }
+ }
+
+ PromArr_SetSize(bindPtr->promArr, arraySize);
+
+ /*
+ * Remove expired pattern sequences.
+ */
+
+ for (i = 0, newArraySize = 0; i < arraySize; ++i) {
+ PSList *psList = PromArr_Get(bindPtr->promArr, i);
+ PSEntry *psEntry;
+ PSEntry *psNext;
+
+ for (psEntry = PSList_First(psList); psEntry; psEntry = psNext) {
+ const TkPattern *patPtr;
+
+ assert(i + 1 < psEntry->psPtr->numPats);
+
+ psNext = PSList_Next(psEntry);
+ patPtr = &psEntry->psPtr->pats[i + 1];
/*
- * A "" is added to the scripts string to separate the various
- * scripts that should be invoked.
+ * We have to remove the following entries from promotion list (but
+ * only if we don't want to keep it):
+ * ------------------------------------------------------------------
+ * 1) It is marked as expired (see MatchPatterns()).
+ * 2) If we have a Key event, and current entry is matching a Button.
+ * 3) If we have a Button event, and current entry is matching a Key.
+ * 4) If we have a detailed event, current entry it is also detailed,
+ * we have matching event types, but the details are different.
+ * 5) Current entry has been matched with a different window.
*/
- Tcl_DStringAppend(&scripts, "", 1);
+ if (psEntry->keepIt) {
+ assert(!psEntry->expired);
+ psEntry->keepIt = 0;
+ } else if (psEntry->expired
+ || psEntry->window != curEvent->xev.xany.window
+ || (patPtr->info
+ && curEvent->detail.info
+ && patPtr->eventType == (unsigned) curEvent->xev.type
+ && patPtr->info != curEvent->detail.info)) {
+ RemoveListEntry(&bindPtr->lookupTables.entryPool, psEntry);
+ } else {
+ switch (patPtr->eventType) {
+ case ButtonPress:
+ case ButtonRelease:
+ if (curEvent->xev.type == KeyPress || curEvent->xev.type == KeyRelease) {
+ RemoveListEntry(&bindPtr->lookupTables.entryPool, psEntry);
+ }
+ break;
+ case KeyPress:
+ case KeyRelease:
+ if (curEvent->xev.type == ButtonPress || curEvent->xev.type == ButtonRelease) {
+ RemoveListEntry(&bindPtr->lookupTables.entryPool, psEntry);
+ }
+ break;
+ }
+ }
+ }
+
+ if (!PSList_IsEmpty(psList)) {
+ /* we still have promoted sequences, adjust array size */
+ newArraySize = Max(i + 1, newArraySize);
}
}
+
+ PromArr_SetSize(bindPtr->promArr, newArraySize);
+
+ if (matchPtrArr != matchPtrBuf) {
+ ckfree(matchPtrArr);
+ }
+
if (Tcl_DStringLength(&scripts) == 0) {
- return;
+ return; /* nothing to do */
}
/*
@@ -1489,16 +2579,13 @@ Tk_BindEvent(
screenPtr = &bindInfoPtr->screenInfo;
oldDispPtr = screenPtr->curDispPtr;
oldScreen = screenPtr->curScreenIndex;
- if ((dispPtr != screenPtr->curDispPtr)
- || (Tk_ScreenNumber(tkwin) != screenPtr->curScreenIndex)) {
+
+ if (dispPtr != screenPtr->curDispPtr || Tk_ScreenNumber(tkwin) != screenPtr->curScreenIndex) {
screenPtr->curDispPtr = dispPtr;
screenPtr->curScreenIndex = Tk_ScreenNumber(tkwin);
ChangeScreen(interp, dispPtr->name, screenPtr->curScreenIndex);
}
- p = Tcl_DStringValue(&scripts);
- end = p + Tcl_DStringLength(&scripts);
-
/*
* Be careful when dereferencing screenPtr or bindInfoPtr. If we evaluate
* something that destroys ".", bindInfoPtr would have been freed, but we
@@ -1506,12 +2593,13 @@ Tk_BindEvent(
*/
Tcl_Preserve(bindInfoPtr);
- while (p < end) {
- int len = (int) strlen(p);
+
+ for (p = Tcl_DStringValue(&scripts), end = p + Tcl_DStringLength(&scripts); p < end; ) {
+ unsigned len = strlen(p);
int code;
if (!bindInfoPtr->deleted) {
- screenPtr->bindingDepth++;
+ ++screenPtr->bindingDepth;
}
Tcl_AllowExceptions(interp);
@@ -1519,38 +2607,30 @@ Tk_BindEvent(
p += len + 1;
if (!bindInfoPtr->deleted) {
- screenPtr->bindingDepth--;
+ --screenPtr->bindingDepth;
}
- if (code != TCL_OK) {
- if (code == TCL_CONTINUE) {
- /*
- * Do nothing: just go on to the next command.
- */
- } else if (code == TCL_BREAK) {
- break;
- } else {
+ if (code != TCL_OK && code != TCL_CONTINUE) {
+ if (code != TCL_BREAK) {
Tcl_AddErrorInfo(interp, "\n (command bound to event)");
Tcl_BackgroundException(interp, code);
- break;
}
+ break;
}
}
- if (!bindInfoPtr->deleted && (screenPtr->bindingDepth != 0)
- && ((oldDispPtr != screenPtr->curDispPtr)
- || (oldScreen != screenPtr->curScreenIndex))) {
+ if (!bindInfoPtr->deleted
+ && screenPtr->bindingDepth > 0
+ && (oldDispPtr != screenPtr->curDispPtr || oldScreen != screenPtr->curScreenIndex)) {
/*
* Some other binding script is currently executing, but its screen is
* no longer current. Change the current display back again.
*/
-
screenPtr->curDispPtr = oldDispPtr;
screenPtr->curScreenIndex = oldScreen;
ChangeScreen(interp, oldDispPtr->name, oldScreen);
}
- (void) Tcl_RestoreInterpState(interp, interpState);
+ Tcl_RestoreInterpState(interp, interpState);
Tcl_DStringFree(&scripts);
-
Tcl_Release(bindInfoPtr);
}
@@ -1559,31 +2639,15 @@ Tk_BindEvent(
*
* MatchPatterns --
*
- * Given a list of pattern sequences and a list of recent events, return
- * the pattern sequence that best matches the event list, if there is
+ * Given a list of pattern sequences and the recent event, return
+ * the pattern sequence that best matches this event, if there is
* one.
*
- * This function is used in two different ways. In the simplest use,
- * "object" is NULL and psPtr is a list of pattern sequences, each of
- * which corresponds to a binding. In this case, the function finds the
- * pattern sequences that match the event list and returns the most
- * specific of those, if there is more than one.
- *
- * In the second case, psPtr is a list of pattern sequences, each of
- * which corresponds to a definition for a virtual binding. In order for
- * one of these sequences to "match", it must match the events (as above)
- * but in addition there must be a binding for its associated virtual
- * event on the current object. The "object" argument indicates which
- * object the binding must be for.
- *
* Results:
-
- * The return value is NULL if bestPtr is NULL and no pattern matches the
- * recent events from bindPtr. Otherwise the return value is the most
- * specific pattern sequence among bestPtr and all those at psPtr that
- * match the event list and object. If a pattern sequence other than
- * bestPtr is returned, then *bestCommandPtr is filled in with a pointer
- * to the command from the best sequence.
+ *
+ * The return value is NULL if no match is found. Otherwise the
+ * return value is the most specific pattern sequence among all
+ * those that match the event table.
*
* Side effects:
* None.
@@ -1591,313 +2655,253 @@ Tk_BindEvent(
*----------------------------------------------------------------------
*/
-static PatSeq *
-MatchPatterns(
- TkDisplay *dispPtr, /* Display from which the event came. */
- BindingTable *bindPtr, /* Information about binding table, such as
- * ring of recent events. */
- PatSeq *psPtr, /* List of pattern sequences. */
- PatSeq *bestPtr, /* The best match seen so far, from a previous
- * call to this function. NULL means no prior
- * best match. */
- ClientData *objectPtr, /* If NULL, the sequences at psPtr correspond
- * to "normal" bindings. If non-NULL, the
- * sequences at psPtr correspond to virtual
- * bindings; in order to match each sequence
- * must correspond to a virtual binding for
- * which a binding exists for object in
- * bindPtr. */
- PatSeq **sourcePtrPtr) /* Filled with the pattern sequence that
- * contains the eventProc and clientData
- * associated with the best match. If this
- * differs from the return value, it is the
- * virtual event that most closely matched the
- * return value (a physical event). Not
- * modified unless a result other than bestPtr
- * is returned. */
+/* helper function */
+static int
+VirtPatIsBound(
+ Tk_BindingTable bindPtr, /* Table in which to look for bindings. */
+ PatSeq *psPtr, /* Test this pattern. */
+ ClientData object, /* Check for this binding tag. */
+ PatSeq **physPtrPtr) /* Input: the best physical event.
+ * Output: the physical event associated with matching virtual event. */
{
- PatSeq *matchPtr, *bestSourcePtr, *sourcePtr;
+ PatternTableKey key;
+ const struct VirtOwners *owners;
+ unsigned i;
- bestSourcePtr = *sourcePtrPtr;
+ assert(bindPtr);
+ assert(psPtr);
+ assert(!psPtr->object);
+ assert(physPtrPtr);
- /*
- * Iterate over all the pattern sequences.
- */
+ if (*physPtrPtr) {
+ const TkPattern *physPatPtr = (*physPtrPtr)->pats;
+ const TkPattern *virtPatPtr = psPtr->pats;
- for ( ; psPtr != NULL; psPtr = psPtr->nextSeqPtr) {
- XEvent *eventPtr = &bindPtr->eventRing[bindPtr->curEvent];
- Detail *detailPtr = &bindPtr->detailRing[bindPtr->curEvent];
- TkPattern *patPtr = psPtr->pats;
- Window window = eventPtr->xany.window;
- int patCount, ringCount, flags, state, modMask, i;
+ if (physPatPtr->info || !virtPatPtr->info) {
+ if (IsSubsetOf(virtPatPtr->modMask, physPatPtr->modMask)) {
+ return 0; /* we cannot surpass this match */
+ }
+ }
+ }
- /*
- * Iterate over all the patterns in a sequence to be sure that they
- * all match.
- */
+ /* otherwise on some systems the key contains uninitialized bytes */
+ memset(&key, 0, sizeof(key));
- patCount = psPtr->numPats;
- ringCount = EVENT_BUFFER_SIZE;
- while (patCount > 0) {
- if (ringCount <= 0) {
- goto nextSequence;
- }
- if (eventPtr->xany.type != patPtr->eventType) {
- /*
- * Most of the event types are considered superfluous in that
- * they are ignored if they occur in the middle of a pattern
- * sequence and have mismatching types. The only ones that
- * cannot be ignored are ButtonPress and ButtonRelease events
- * (if the next event in the pattern is a KeyPress or
- * KeyRelease) and KeyPress and KeyRelease events (if the next
- * pattern event is a ButtonPress or ButtonRelease). Here are
- * some tricky cases to consider:
- * 1. Double-Button or Double-Key events.
- * 2. Double-ButtonRelease or Double-KeyRelease events.
- * 3. The arrival of various events like Enter and Leave and
- * FocusIn and GraphicsExpose between two button presses or
- * key presses.
- * 4. Modifier keys like Shift and Control shouldn't generate
- * conflicts with button events.
- */
+ key.object = object;
+ key.type = VirtualEvent;
+ owners = psPtr->ptr.owners;
- if ((patPtr->eventType == KeyPress)
- || (patPtr->eventType == KeyRelease)) {
- if ((eventPtr->xany.type == ButtonPress)
- || (eventPtr->xany.type == ButtonRelease)) {
- goto nextSequence;
- }
- } else if ((patPtr->eventType == ButtonPress)
- || (patPtr->eventType == ButtonRelease)) {
- if ((eventPtr->xany.type == KeyPress)
- || (eventPtr->xany.type == KeyRelease)) {
- /*
- * Ignore key events if they are modifier keys.
- */
+ for (i = 0; i < VirtOwners_Size(owners); ++i) {
+ Tcl_HashEntry *hPtr = VirtOwners_Get(owners, i);
- for (i = 0; i < dispPtr->numModKeyCodes; i++) {
- if (dispPtr->modKeyCodes[i]
- == eventPtr->xkey.keycode) {
- /*
- * This key is a modifier key, so ignore it.
- */
+ key.detail.name = (Tk_Uid) Tcl_GetHashKey(hPtr->tablePtr, hPtr);
- goto nextEvent;
- }
- }
- goto nextSequence;
- }
- }
- goto nextEvent;
- }
- if (eventPtr->xany.type == CreateNotify
- && eventPtr->xcreatewindow.parent != window) {
- goto nextSequence;
- } else if (eventPtr->xany.window != window) {
- goto nextSequence;
- }
+ if ((hPtr = Tcl_FindHashEntry(&bindPtr->lookupTables.patternTable, (char *) &key))) {
+ /* The physical event matches this virtual event's definition. */
+ *physPtrPtr = (PatSeq *) Tcl_GetHashValue(hPtr);
+ return 1;
+ }
+ }
- /*
- * Note: it's important for the keysym check to go before the
- * modifier check, so we can ignore unwanted modifier keys before
- * choking on the modifier check.
- */
+ return 0;
+}
- if ((patPtr->detail.clientData != 0)
- && (patPtr->detail.clientData != detailPtr->clientData)) {
- /*
- * The detail appears not to match. However, if the event is a
- * KeyPress for a modifier key then just ignore the event.
- * Otherwise event sequences like "aD" never match because the
- * shift key goes down between the "a" and the "D".
- */
+/* helper function */
+static int
+Compare(
+ const PatSeq *fstMatchPtr,
+ const PatSeq *sndMatchPtr) /* most recent match */
+{
+ int diff;
- if (eventPtr->xany.type == KeyPress) {
- for (i = 0; i < dispPtr->numModKeyCodes; i++) {
- if (dispPtr->modKeyCodes[i] == eventPtr->xkey.keycode) {
- goto nextEvent;
- }
- }
- }
- goto nextSequence;
- }
- flags = flagArray[eventPtr->type];
- if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
- state = eventPtr->xkey.state;
- } else if (flags & CROSSING) {
- state = eventPtr->xcrossing.state;
- } else {
- state = 0;
- }
- if (patPtr->needMods != 0) {
- modMask = patPtr->needMods;
- if ((modMask & META_MASK) && (dispPtr->metaModMask != 0)) {
- modMask = (modMask & ~META_MASK) | dispPtr->metaModMask;
- }
- if ((modMask & ALT_MASK) && (dispPtr->altModMask != 0)) {
- modMask = (modMask & ~ALT_MASK) | dispPtr->altModMask;
- }
+ if (!fstMatchPtr) { return +1; }
+ assert(sndMatchPtr);
+ diff = CountSpecialized(fstMatchPtr, sndMatchPtr);
+ return diff ? diff : (int) sndMatchPtr->count - (int) fstMatchPtr->count;
+}
- if ((state & META_MASK) && (dispPtr->metaModMask != 0)) {
- state = (state & ~META_MASK) | dispPtr->metaModMask;
- }
- if ((state & ALT_MASK) && (dispPtr->altModMask != 0)) {
- state = (state & ~ALT_MASK) | dispPtr->altModMask;
- }
+/* helper function */
+static int
+CompareModMasks(
+ const PSModMaskArr *fstModMaskArr,
+ const PSModMaskArr *sndModMaskArr,
+ ModMask fstModMask,
+ ModMask sndModMask)
+{
+ int fstCount = 0;
+ int sndCount = 0;
+ int i;
- if ((state & modMask) != modMask) {
- goto nextSequence;
+ if (PSModMaskArr_IsEmpty(fstModMaskArr)) {
+ if (!PSModMaskArr_IsEmpty(sndModMaskArr)) {
+ for (i = PSModMaskArr_Size(sndModMaskArr) - 1; i >= 0; --i) {
+ if (*PSModMaskArr_Get(sndModMaskArr, i)) {
+ ++sndCount;
}
}
- if (psPtr->flags & PAT_NEARBY) {
- XEvent *firstPtr = &bindPtr->eventRing[bindPtr->curEvent];
- long timeDiff;
-
- timeDiff = ((long)firstPtr->xkey.time -
- (long)eventPtr->xkey.time);
- if ((firstPtr->xkey.x_root
- < (eventPtr->xkey.x_root - NEARBY_PIXELS))
- || (firstPtr->xkey.x_root
- > (eventPtr->xkey.x_root + NEARBY_PIXELS))
- || (firstPtr->xkey.y_root
- < (eventPtr->xkey.y_root - NEARBY_PIXELS))
- || (firstPtr->xkey.y_root
- > (eventPtr->xkey.y_root + NEARBY_PIXELS))
- || (timeDiff > NEARBY_MS)) {
- goto nextSequence;
- }
- }
- patPtr++;
- patCount--;
- nextEvent:
- if (eventPtr == bindPtr->eventRing) {
- eventPtr = &bindPtr->eventRing[EVENT_BUFFER_SIZE-1];
- detailPtr = &bindPtr->detailRing[EVENT_BUFFER_SIZE-1];
- } else {
- eventPtr--;
- detailPtr--;
+ }
+ } else if (PSModMaskArr_IsEmpty(sndModMaskArr)) {
+ for (i = PSModMaskArr_Size(fstModMaskArr) - 1; i >= 0; --i) {
+ if (*PSModMaskArr_Get(fstModMaskArr, i)) {
+ ++fstCount;
}
- ringCount--;
}
+ } else {
+ assert(PSModMaskArr_Size(fstModMaskArr) == PSModMaskArr_Size(sndModMaskArr));
- matchPtr = psPtr;
- sourcePtr = psPtr;
+ for (i = PSModMaskArr_Size(fstModMaskArr) - 1; i >= 0; --i) {
+ ModMask fstModMask = *PSModMaskArr_Get(fstModMaskArr, i);
+ ModMask sndModMask = *PSModMaskArr_Get(sndModMaskArr, i);
- if (objectPtr != NULL) {
- int iVirt;
- VirtualOwners *voPtr;
- PatternTableKey key;
+ if (IsSubsetOf(fstModMask, sndModMask)) { ++sndCount; }
+ if (IsSubsetOf(sndModMask, fstModMask)) { ++fstCount; }
+ }
+ }
- /*
- * The sequence matches the physical constraints. Is this object
- * interested in any of the virtual events that correspond to this
- * sequence?
- */
+ /* Finally compare modifier masks of last pattern. */
- voPtr = psPtr->voPtr;
+ if (IsSubsetOf(fstModMask, sndModMask)) { ++sndCount; }
+ if (IsSubsetOf(sndModMask, fstModMask)) { ++fstCount; }
- memset(&key, 0, sizeof(key));
- key.object = *objectPtr;
- key.type = VirtualEvent;
- key.detail.clientData = 0;
+ return fstCount - sndCount;
+}
- for (iVirt = 0; iVirt < voPtr->numOwners; iVirt++) {
- Tcl_HashEntry *hPtr = voPtr->owners[iVirt];
+static PatSeq *
+MatchPatterns(
+ TkDisplay *dispPtr, /* Display from which the event came. */
+ Tk_BindingTable bindPtr, /* Table in which to look for bindings. */
+ PSList *psList, /* List of potentially matching patterns, can be NULL. */
+ PSList *psSuccList, /* Add all matching higher-level pattern sequences to this list.
+ * Can be NULL. */
+ unsigned patIndex, /* Match only this tag in sequence. */
+ const Event *curEvent, /* Match this event. */
+ ClientData object, /* Check for this binding tag. */
+ PatSeq **physPtrPtr) /* Input: the best physical event; NULL if we test physical events.
+ * Output: the associated physical event for the best matching virtual
+ * event; NULL when we match physical events. */
+{
+ Window window;
+ PSEntry *psEntry;
+ PatSeq *bestPtr;
+ PatSeq *bestPhysPtr;
+ ModMask bestModMask;
+ const PSModMaskArr *bestModMaskArr = NULL;
+
+ assert(dispPtr);
+ assert(bindPtr);
+ assert(curEvent);
+
+ if (!psList) {
+ return NULL;
+ }
- key.detail.name = (Tk_Uid) Tcl_GetHashKey(hPtr->tablePtr,
- hPtr);
- hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, &key);
- if (hPtr != NULL) {
+ bestModMask = 0;
+ bestPtr = NULL;
+ bestPhysPtr = NULL;
+ window = curEvent->xev.xany.window;
+
+ for (psEntry = PSList_First(psList); psEntry; psEntry = PSList_Next(psEntry)) {
+ if (patIndex == 0 || psEntry->window == window) {
+ PatSeq* psPtr = psEntry->psPtr;
+
+ assert(TEST_PSENTRY(psPtr));
+ assert((psPtr->object == NULL) == (physPtrPtr != NULL));
+ assert(psPtr->object || patIndex == 0);
+ assert(psPtr->numPats > patIndex);
+
+ if (psPtr->object
+ ? psPtr->object == object
+ : VirtPatIsBound(bindPtr, psPtr, object, physPtrPtr)) {
+ TkPattern *patPtr = psPtr->pats + patIndex;
+
+ if (patPtr->eventType == (unsigned) curEvent->xev.type
+ && (curEvent->xev.type != CreateNotify
+ || curEvent->xev.xcreatewindow.parent == window)
+ && (!patPtr->name || patPtr->name == curEvent->detail.name)
+ && (!patPtr->info || patPtr->info == curEvent->detail.info)) {
/*
- * This tag is interested in this virtual event and its
- * corresponding physical event is a good match with the
- * virtual event's definition.
+ * Resolve the modifier mask for Alt and Mod keys. Unfortunately this
+ * cannot be done in ParseEventDescription, otherwise this function would
+ * be the better place.
*/
+ ModMask modMask = ResolveModifiers(dispPtr, patPtr->modMask);
+ ModMask curModMask = ResolveModifiers(dispPtr, bindPtr->curModMask);
- PatSeq *virtMatchPtr = Tcl_GetHashValue(hPtr);
+ psEntry->expired = 1; /* remove it from promotion list */
- if ((virtMatchPtr->numPats != 1)
- || (virtMatchPtr->nextSeqPtr != NULL)) {
- Tcl_Panic("MatchPattern: badly constructed virtual event");
- }
- sourcePtr = virtMatchPtr;
- goto match;
- }
- }
+ if ((modMask & ~curModMask) == 0) {
+ unsigned count = patPtr->info ? curEvent->countDetailed : curEvent->countAny;
- /*
- * The physical event matches a virtual event's definition, but
- * the tag isn't interested in it.
- */
-
- goto nextSequence;
- }
- match:
+ if (patIndex < PSModMaskArr_Size(psEntry->lastModMaskArr)) {
+ PSModMaskArr_Set(psEntry->lastModMaskArr, patIndex, &modMask);
+ }
- /*
- * This sequence matches. If we've already got another match, pick
- * whichever is most specific. Detail is most important, then
- * needMods.
- */
+ /*
+ * This pattern is finally matching.
+ */
- if (bestPtr != NULL) {
- TkPattern *patPtr2;
+ if (psPtr->numPats == patIndex + 1) {
+ if (patPtr->count <= count) {
+ /*
+ * This is also a final pattern.
+ * We always prefer the pattern with better match.
+ * If completely equal than prefer most recently defined pattern.
+ */
- if (matchPtr->numPats != bestPtr->numPats) {
- if (bestPtr->numPats > matchPtr->numPats) {
- goto nextSequence;
- } else {
- goto newBest;
- }
- }
- for (i = 0, patPtr = matchPtr->pats, patPtr2 = bestPtr->pats;
- i < matchPtr->numPats; i++, patPtr++, patPtr2++) {
- if (patPtr->detail.clientData != patPtr2->detail.clientData) {
- if (patPtr->detail.clientData == 0) {
- goto nextSequence;
- } else {
- goto newBest;
- }
- }
- if (patPtr->needMods != patPtr2->needMods) {
- if ((patPtr->needMods & patPtr2->needMods)
- == patPtr->needMods) {
- goto nextSequence;
- } else if ((patPtr->needMods & patPtr2->needMods)
- == patPtr2->needMods) {
- goto newBest;
+ int cmp = Compare(bestPtr, psPtr);
+
+ if (cmp == 0) {
+ cmp = CompareModMasks(psEntry->lastModMaskArr, bestModMaskArr,
+ modMask, bestModMask);
+ }
+
+ if (cmp > 0 || (cmp == 0 && bestPtr->number < psPtr->number)) {
+ bestPtr = psPtr;
+ bestModMask = modMask;
+ bestModMaskArr = psEntry->lastModMaskArr;
+ if (physPtrPtr) {
+ bestPhysPtr = *physPtrPtr;
+ }
+ }
+ } else {
+ DEBUG(psEntry->expired = 0;)
+ psEntry->keepIt = 1; /* don't remove it from promotion list */
+ }
+ } else if (psSuccList) {
+ /*
+ * Not a final pattern, but matching, so promote it to next level.
+ * But do not promote if count of current pattern is not yet reached.
+ */
+ if (patPtr->count == psEntry->count) {
+ PSEntry *psNewEntry;
+
+ assert(!patPtr->name);
+ psNewEntry = MakeListEntry(
+ &bindPtr->lookupTables.entryPool, psPtr, psPtr->modMaskUsed);
+ if (!PSModMaskArr_IsEmpty(psNewEntry->lastModMaskArr)) {
+ PSModMaskArr_Set(psNewEntry->lastModMaskArr, patIndex, &modMask);
+ }
+ assert(psNewEntry->keepIt);
+ assert(psNewEntry->count == 1u);
+ PSList_Append(psSuccList, psNewEntry);
+ psNewEntry->window = window; /* bind to current window */
+ } else {
+ assert(psEntry->count < patPtr->count);
+ DEBUG(psEntry->expired = 0;)
+ psEntry->count += 1;
+ psEntry->keepIt = 1; /* don't remove it from promotion list */
+ }
+ }
}
}
}
-
- /*
- * Tie goes to current best pattern.
- *
- * (1) For virtual vs. virtual, the least recently defined virtual
- * wins, because virtuals are examined in order of definition.
- * This order is _not_ guaranteed in the documentation.
- *
- * (2) For virtual vs. physical, the physical wins because all the
- * physicals are examined before the virtuals. This order is
- * guaranteed in the documentation.
- *
- * (3) For physical vs. physical pattern, the most recently
- * defined physical wins, because physicals are examined in
- * reverse order of definition. This order is guaranteed in the
- * documentation.
- */
-
- goto nextSequence;
}
- newBest:
- bestPtr = matchPtr;
- bestSourcePtr = sourcePtr;
-
- nextSequence:
- continue;
}
- *sourcePtrPtr = bestSourcePtr;
+ if (bestPhysPtr) {
+ assert(physPtrPtr);
+ *physPtrPtr = bestPhysPtr;
+ }
return bestPtr;
}
@@ -1921,50 +2925,54 @@ MatchPatterns(
static void
ExpandPercents(
- TkWindow *winPtr, /* Window where event occurred: needed to get
- * input context. */
- const char *before, /* Command containing percent expressions to
- * be replaced. */
- XEvent *eventPtr, /* X event containing information to be used
- * in % replacements. */
- KeySym keySym, /* KeySym: only relevant for KeyPress and
- * KeyRelease events). */
- unsigned int scriptCount, /* The number of script-based binding patterns
- * matched so far for this event. */
- Tcl_DString *dsPtr) /* Dynamic string in which to append new
- * command. */
+ TkWindow *winPtr, /* Window where event occurred: needed to get input context. */
+ const char *before, /* Command containing percent expressions to be replaced. */
+ Event *eventPtr, /* Event containing information to be used in % replacements. */
+ unsigned scriptCount, /* The number of script-based binding patterns matched so far for
+ * this event. */
+ Tcl_DString *dsPtr) /* Dynamic string in which to append new command. */
{
- size_t spaceNeeded;
- int cvtFlags; /* Used to substitute string as proper Tcl
- * list element. */
- int number, flags, length;
-#define NUM_SIZE 40
- const char *string;
+ unsigned flags;
Tcl_DString buf;
- char numStorage[NUM_SIZE+1];
+ XEvent *evPtr;
+
+ assert(winPtr);
+ assert(before);
+ assert(eventPtr);
+ assert(dsPtr);
Tcl_DStringInit(&buf);
+ evPtr = &eventPtr->xev;
+ flags = (evPtr->type < TK_LASTEVENT) ? flagArray[evPtr->type] : 0;
- if (eventPtr->type < TK_LASTEVENT) {
- flags = flagArray[eventPtr->type];
- } else {
- flags = 0;
+#define SET_NUMBER(value) { number = (value); \
+ snprintf(numStorage, sizeof(numStorage), "%" TCL_LL_MODIFIER "d", number); \
+ string = numStorage; \
+ }
+
+#define SET_UNUMBER(value) { unumber = (value); \
+ snprintf(numStorage, sizeof(numStorage), "%" TCL_LL_MODIFIER "u", unumber); \
+ string = numStorage; \
}
while (1) {
+ char numStorage[TCL_INTEGER_SPACE];
+ const char *string;
+ Tcl_WideInt number; /* signed */
+ Tcl_WideUInt unumber; /* unsigned */
+
/*
* Find everything up to the next % character and append it to the
* result string.
*/
- for (string = before; (*string != 0) && (*string != '%'); string++) {
- /* Empty loop body. */
- }
+ for (string = before; *string && *string != '%'; ++string)
+ ;
if (string != before) {
- Tcl_DStringAppend(dsPtr, before, (int) (string-before));
+ Tcl_DStringAppend(dsPtr, before, string - before);
before = string;
}
- if (*before == 0) {
+ if (!*before) {
break;
}
@@ -1972,328 +2980,260 @@ ExpandPercents(
* There's a percent sequence here. Process it.
*/
- number = 0;
string = "??";
switch (before[1]) {
case '#':
- number = eventPtr->xany.serial;
- goto doNumber;
+ SET_UNUMBER(evPtr->xany.serial);
+ break;
case 'a':
if (flags & CONFIG) {
- TkpPrintWindowId(numStorage, eventPtr->xconfigure.above);
+ TkpPrintWindowId(numStorage, evPtr->xconfigure.above);
string = numStorage;
}
- goto doString;
+ break;
case 'b':
if (flags & BUTTON) {
- number = eventPtr->xbutton.button;
- goto doNumber;
+ SET_UNUMBER(evPtr->xbutton.button);
}
- goto doString;
+ break;
case 'c':
if (flags & EXPOSE) {
- number = eventPtr->xexpose.count;
- goto doNumber;
+ SET_NUMBER(evPtr->xexpose.count);
}
- goto doString;
+ break;
case 'd':
if (flags & (CROSSING|FOCUS)) {
- if (flags & FOCUS) {
- number = eventPtr->xfocus.detail;
- } else {
- number = eventPtr->xcrossing.detail;
- }
- string = TkFindStateString(notifyDetail, number);
+ int detail = (flags & FOCUS) ? evPtr->xfocus.detail : evPtr->xcrossing.detail;
+ string = TkFindStateString(notifyDetail, detail);
} else if (flags & CONFIGREQ) {
- if (eventPtr->xconfigurerequest.value_mask & CWStackMode) {
- string = TkFindStateString(configureRequestDetail,
- eventPtr->xconfigurerequest.detail);
+ if (evPtr->xconfigurerequest.value_mask & CWStackMode) {
+ string = TkFindStateString(configureRequestDetail, evPtr->xconfigurerequest.detail);
} else {
string = "";
}
} else if (flags & VIRTUAL) {
- XVirtualEvent *vePtr = (XVirtualEvent *) eventPtr;
-
- if (vePtr->user_data != NULL) {
- string = Tcl_GetString(vePtr->user_data);
- } else {
- string = "";
- }
+ XVirtualEvent *vePtr = (XVirtualEvent *) evPtr;
+ string = vePtr->user_data ? Tcl_GetString(vePtr->user_data) : "";
}
- goto doString;
+ break;
case 'f':
if (flags & CROSSING) {
- number = eventPtr->xcrossing.focus;
- goto doNumber;
+ SET_NUMBER(evPtr->xcrossing.focus != 0);
}
- goto doString;
+ break;
case 'h':
if (flags & EXPOSE) {
- number = eventPtr->xexpose.height;
+ SET_NUMBER(evPtr->xexpose.height);
} else if (flags & CONFIG) {
- number = eventPtr->xconfigure.height;
+ SET_NUMBER(evPtr->xconfigure.height);
} else if (flags & CREATE) {
- number = eventPtr->xcreatewindow.height;
+ SET_NUMBER(evPtr->xcreatewindow.height);
} else if (flags & CONFIGREQ) {
- number = eventPtr->xconfigurerequest.height;
+ SET_NUMBER(evPtr->xconfigurerequest.height);
} else if (flags & RESIZEREQ) {
- number = eventPtr->xresizerequest.height;
- } else {
- goto doString;
+ SET_NUMBER(evPtr->xresizerequest.height);
}
- goto doNumber;
+ break;
case 'i':
if (flags & CREATE) {
- TkpPrintWindowId(numStorage, eventPtr->xcreatewindow.window);
+ TkpPrintWindowId(numStorage, evPtr->xcreatewindow.window);
} else if (flags & CONFIGREQ) {
- TkpPrintWindowId(numStorage,
- eventPtr->xconfigurerequest.window);
+ TkpPrintWindowId(numStorage, evPtr->xconfigurerequest.window);
} else if (flags & MAPREQ) {
- TkpPrintWindowId(numStorage, eventPtr->xmaprequest.window);
+ TkpPrintWindowId(numStorage, evPtr->xmaprequest.window);
} else {
- TkpPrintWindowId(numStorage, eventPtr->xany.window);
+ TkpPrintWindowId(numStorage, evPtr->xany.window);
}
string = numStorage;
- goto doString;
+ break;
case 'k':
- if ((flags & KEY) && (eventPtr->type != MouseWheelEvent)) {
- number = eventPtr->xkey.keycode;
- goto doNumber;
+ if (flags & KEY) {
+ SET_UNUMBER(evPtr->xkey.keycode);
}
- goto doString;
+ break;
case 'm':
if (flags & CROSSING) {
- number = eventPtr->xcrossing.mode;
- string = TkFindStateString(notifyMode, number);
+ string = TkFindStateString(notifyMode, evPtr->xcrossing.mode);
} else if (flags & FOCUS) {
- number = eventPtr->xfocus.mode;
- string = TkFindStateString(notifyMode, number);
+ string = TkFindStateString(notifyMode, evPtr->xfocus.mode);
}
- goto doString;
+ break;
case 'o':
if (flags & CREATE) {
- number = eventPtr->xcreatewindow.override_redirect;
+ SET_NUMBER(evPtr->xcreatewindow.override_redirect != 0);
} else if (flags & MAP) {
- number = eventPtr->xmap.override_redirect;
+ SET_NUMBER(evPtr->xmap.override_redirect != 0);
} else if (flags & REPARENT) {
- number = eventPtr->xreparent.override_redirect;
+ SET_NUMBER(evPtr->xreparent.override_redirect != 0);
} else if (flags & CONFIG) {
- number = eventPtr->xconfigure.override_redirect;
- } else {
- goto doString;
+ SET_NUMBER(evPtr->xconfigure.override_redirect != 0);
}
- goto doNumber;
+ break;
case 'p':
if (flags & CIRC) {
- string = TkFindStateString(circPlace,
- eventPtr->xcirculate.place);
+ string = TkFindStateString(circPlace, evPtr->xcirculate.place);
} else if (flags & CIRCREQ) {
- string = TkFindStateString(circPlace,
- eventPtr->xcirculaterequest.place);
+ string = TkFindStateString(circPlace, evPtr->xcirculaterequest.place);
}
- goto doString;
+ break;
case 's':
- if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
- number = eventPtr->xkey.state;
- goto doNumber;
+ if (flags & HAS_XKEY_HEAD_AND_STATE) {
+ SET_UNUMBER(evPtr->xkey.state);
} else if (flags & CROSSING) {
- number = eventPtr->xcrossing.state;
- goto doNumber;
+ SET_UNUMBER(evPtr->xcrossing.state);
} else if (flags & PROP) {
- string = TkFindStateString(propNotify,
- eventPtr->xproperty.state);
+ string = TkFindStateString(propNotify, evPtr->xproperty.state);
} else if (flags & VISIBILITY) {
- string = TkFindStateString(visNotify,
- eventPtr->xvisibility.state);
+ string = TkFindStateString(visNotify, evPtr->xvisibility.state);
}
- goto doString;
+ break;
case 't':
- if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
- number = (int) eventPtr->xkey.time;
- } else if (flags & CROSSING) {
- number = (int) eventPtr->xcrossing.time;
+ if (flags & HAS_XKEY_HEAD) {
+ SET_UNUMBER(evPtr->xkey.time);
} else if (flags & PROP) {
- number = (int) eventPtr->xproperty.time;
- } else {
- goto doString;
+ SET_UNUMBER(evPtr->xproperty.time);
}
- goto doNumber;
+ break;
case 'v':
- number = eventPtr->xconfigurerequest.value_mask;
- goto doNumber;
+ SET_UNUMBER(evPtr->xconfigurerequest.value_mask);
+ break;
case 'w':
if (flags & EXPOSE) {
- number = eventPtr->xexpose.width;
+ SET_NUMBER(evPtr->xexpose.width);
} else if (flags & CONFIG) {
- number = eventPtr->xconfigure.width;
+ SET_NUMBER(evPtr->xconfigure.width);
} else if (flags & CREATE) {
- number = eventPtr->xcreatewindow.width;
+ SET_NUMBER(evPtr->xcreatewindow.width);
} else if (flags & CONFIGREQ) {
- number = eventPtr->xconfigurerequest.width;
+ SET_NUMBER(evPtr->xconfigurerequest.width);
} else if (flags & RESIZEREQ) {
- number = eventPtr->xresizerequest.width;
- } else {
- goto doString;
+ SET_NUMBER(evPtr->xresizerequest.width);
}
- goto doNumber;
+ break;
case 'x':
- if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
- number = eventPtr->xkey.x;
- } else if (flags & CROSSING) {
- number = eventPtr->xcrossing.x;
+ if (flags & HAS_XKEY_HEAD) {
+ SET_NUMBER(evPtr->xkey.x);
} else if (flags & EXPOSE) {
- number = eventPtr->xexpose.x;
+ SET_NUMBER(evPtr->xexpose.x);
} else if (flags & (CREATE|CONFIG|GRAVITY)) {
- number = eventPtr->xcreatewindow.x;
+ SET_NUMBER(evPtr->xcreatewindow.x);
} else if (flags & REPARENT) {
- number = eventPtr->xreparent.x;
- } else if (flags & CREATE) {
- number = eventPtr->xcreatewindow.x;
+ SET_NUMBER(evPtr->xreparent.x);
} else if (flags & CONFIGREQ) {
- number = eventPtr->xconfigurerequest.x;
- } else {
- goto doString;
+ SET_NUMBER(evPtr->xconfigurerequest.x);
}
- goto doNumber;
+ break;
case 'y':
- if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
- number = eventPtr->xkey.y;
+ if (flags & HAS_XKEY_HEAD) {
+ SET_NUMBER(evPtr->xkey.y);
} else if (flags & EXPOSE) {
- number = eventPtr->xexpose.y;
+ SET_NUMBER(evPtr->xexpose.y);
} else if (flags & (CREATE|CONFIG|GRAVITY)) {
- number = eventPtr->xcreatewindow.y;
+ SET_NUMBER(evPtr->xcreatewindow.y);
} else if (flags & REPARENT) {
- number = eventPtr->xreparent.y;
- } else if (flags & CROSSING) {
- number = eventPtr->xcrossing.y;
- } else if (flags & CREATE) {
- number = eventPtr->xcreatewindow.y;
+ SET_NUMBER(evPtr->xreparent.y);
} else if (flags & CONFIGREQ) {
- number = eventPtr->xconfigurerequest.y;
- } else {
- goto doString;
+ SET_NUMBER(evPtr->xconfigurerequest.y);
}
- goto doNumber;
+ break;
case 'A':
- if ((flags & KEY) && (eventPtr->type != MouseWheelEvent)) {
+ if (flags & KEY) {
Tcl_DStringFree(&buf);
- string = TkpGetString(winPtr, eventPtr, &buf);
+ string = TkpGetString(winPtr, evPtr, &buf);
}
- goto doString;
+ break;
case 'B':
if (flags & CREATE) {
- number = eventPtr->xcreatewindow.border_width;
+ SET_NUMBER(evPtr->xcreatewindow.border_width);
} else if (flags & CONFIGREQ) {
- number = eventPtr->xconfigurerequest.border_width;
+ SET_NUMBER(evPtr->xconfigurerequest.border_width);
} else if (flags & CONFIG) {
- number = eventPtr->xconfigure.border_width;
- } else {
- goto doString;
+ SET_NUMBER(evPtr->xconfigure.border_width);
}
- goto doNumber;
+ break;
case 'D':
- /*
- * This is used only by the MouseWheel event.
- */
-
- if ((flags & KEY) && (eventPtr->type == MouseWheelEvent)) {
- number = eventPtr->xkey.keycode;
- goto doNumber;
+ if (flags & WHEEL) {
+ SET_NUMBER((int)evPtr->xbutton.button); /* mis-use button field for this */
}
- goto doString;
+ break;
case 'E':
- number = (int) eventPtr->xany.send_event;
- goto doNumber;
+ SET_NUMBER(evPtr->xany.send_event != 0);
+ break;
case 'K':
- if ((flags & KEY) && (eventPtr->type != MouseWheelEvent)) {
- const char *name = TkKeysymToString(keySym);
-
- if (name != NULL) {
+ if (flags & KEY) {
+ const char *name = TkKeysymToString(eventPtr->detail.info);
+ if (name) {
string = name;
}
}
- goto doString;
+ break;
case 'M':
- number = scriptCount;
- goto doNumber;
+ SET_UNUMBER(scriptCount);
+ break;
case 'N':
- if ((flags & KEY) && (eventPtr->type != MouseWheelEvent)) {
- number = (int) keySym;
- goto doNumber;
+ if (flags & KEY) {
+ SET_UNUMBER(eventPtr->detail.info);
}
- goto doString;
+ break;
case 'P':
if (flags & PROP) {
- string = Tk_GetAtomName((Tk_Window) winPtr,
- eventPtr->xproperty.atom);
+ string = Tk_GetAtomName((Tk_Window) winPtr, evPtr->xproperty.atom);
}
- goto doString;
+ break;
case 'R':
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
- TkpPrintWindowId(numStorage, eventPtr->xkey.root);
+ if (flags & HAS_XKEY_HEAD) {
+ TkpPrintWindowId(numStorage, evPtr->xkey.root);
string = numStorage;
}
- goto doString;
+ break;
case 'S':
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
- TkpPrintWindowId(numStorage, eventPtr->xkey.subwindow);
+ if (flags & HAS_XKEY_HEAD) {
+ TkpPrintWindowId(numStorage, evPtr->xkey.subwindow);
string = numStorage;
}
- goto doString;
+ break;
case 'T':
- number = eventPtr->type;
- goto doNumber;
+ SET_NUMBER(evPtr->type);
+ break;
case 'W': {
- Tk_Window tkwin;
-
- tkwin = Tk_IdToWindow(eventPtr->xany.display,
- eventPtr->xany.window);
- if (tkwin != NULL) {
+ Tk_Window tkwin = Tk_IdToWindow(evPtr->xany.display, evPtr->xany.window);
+ if (tkwin) {
string = Tk_PathName(tkwin);
- } else {
- string = "??";
}
- goto doString;
+ break;
}
case 'X':
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
-
- number = eventPtr->xkey.x_root;
- Tk_IdToWindow(eventPtr->xany.display,
- eventPtr->xany.window);
- goto doNumber;
+ if (flags & HAS_XKEY_HEAD) {
+ SET_NUMBER(evPtr->xkey.x_root);
}
- goto doString;
+ break;
case 'Y':
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
-
- number = eventPtr->xkey.y_root;
- Tk_IdToWindow(eventPtr->xany.display,
- eventPtr->xany.window);
- goto doNumber;
+ if (flags & HAS_XKEY_HEAD) {
+ SET_NUMBER(evPtr->xkey.y_root);
}
- goto doString;
+ break;
default:
numStorage[0] = before[1];
numStorage[1] = '\0';
string = numStorage;
- goto doString;
+ break;
+ }
+ { /* local scope */
+ int cvtFlags;
+ unsigned spaceNeeded = Tcl_ScanElement(string, &cvtFlags);
+ unsigned length = Tcl_DStringLength(dsPtr);
+
+ Tcl_DStringSetLength(dsPtr, length + spaceNeeded);
+ spaceNeeded = Tcl_ConvertElement(
+ string, Tcl_DStringValue(dsPtr) + length, cvtFlags | TCL_DONT_USE_BRACES);
+ Tcl_DStringSetLength(dsPtr, length + spaceNeeded);
+ before += 2;
}
-
- doNumber:
- sprintf(numStorage, "%d", number);
- string = numStorage;
-
- doString:
- spaceNeeded = Tcl_ScanElement(string, &cvtFlags);
- length = Tcl_DStringLength(dsPtr);
- Tcl_DStringSetLength(dsPtr, length + spaceNeeded);
- spaceNeeded = Tcl_ConvertElement(string,
- Tcl_DStringValue(dsPtr) + length,
- cvtFlags | TCL_DONT_USE_BRACES);
- Tcl_DStringSetLength(dsPtr, length + spaceNeeded);
- before += 2;
}
+
+#undef SET_NUMBER
+#undef SET_UNUMBER
+
Tcl_DStringFree(&buf);
}
@@ -2324,15 +3264,13 @@ ChangeScreen(
char *dispName, /* Name of new display. */
int screenIndex) /* Index of new screen. */
{
- Tcl_Obj *cmdObj = Tcl_ObjPrintf("::tk::ScreenChanged %s.%d",
- dispName, screenIndex);
+ Tcl_Obj *cmdObj = Tcl_ObjPrintf("::tk::ScreenChanged %s.%d", dispName, screenIndex);
int code;
Tcl_IncrRefCount(cmdObj);
code = Tcl_EvalObjEx(interp, cmdObj, TCL_EVAL_GLOBAL);
if (code != TCL_OK) {
- Tcl_AddErrorInfo(interp,
- "\n (changing screen in event binding)");
+ Tcl_AddErrorInfo(interp, "\n (changing screen in event binding)");
Tcl_BackgroundException(interp, code);
}
Tcl_DecrRefCount(cmdObj);
@@ -2365,38 +3303,48 @@ Tk_EventObjCmd(
int index, i;
char *name;
const char *event;
- Tk_Window tkwin = clientData;
- TkBindInfo bindInfo = ((TkWindow *) tkwin)->mainPtr->bindInfo;
- VirtualEventTable *vetPtr = &bindInfo->virtualEventTable;
- static const char *const optionStrings[] = {
- "add", "delete", "generate", "info",
- NULL
- };
- enum options {
- EVENT_ADD, EVENT_DELETE, EVENT_GENERATE, EVENT_INFO
- };
+ Tk_Window tkwin;
+ TkBindInfo bindInfo;
+ VirtualEventTable *vetPtr;
+ static const char *const optionStrings[] = { "add", "delete", "generate", "info", NULL };
+ enum options { EVENT_ADD, EVENT_DELETE, EVENT_GENERATE, EVENT_INFO };
+
+ assert(clientData);
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "option ?arg?");
return TCL_ERROR;
}
- if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings,
- sizeof(char *), "option", 0, &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObjStruct(
+ interp, objv[1], optionStrings, sizeof(char *), "option", 0, &index) != TCL_OK) {
+#ifdef SUPPORT_DEBUGGING
+ if (strcmp(Tcl_GetString(objv[1]), "debug") == 0) {
+ if (objc < 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "debug number");
+ return TCL_ERROR;
+ }
+ Tcl_GetIntFromObj(interp, objv[2], &BindCount);
+ return TCL_OK;
+ }
+#endif
return TCL_ERROR;
}
+ tkwin = (Tk_Window) clientData;
+ bindInfo = ((TkWindow *) tkwin)->mainPtr->bindInfo;
+ vetPtr = &bindInfo->virtualEventTable;
+
switch ((enum options) index) {
case EVENT_ADD:
if (objc < 4) {
- Tcl_WrongNumArgs(interp, 2, objv,
- "virtual sequence ?sequence ...?");
+ Tcl_WrongNumArgs(interp, 2, objv, "virtual sequence ?sequence ...?");
return TCL_ERROR;
}
name = Tcl_GetString(objv[2]);
- for (i = 3; i < objc; i++) {
+ for (i = 3; i < objc; ++i) {
event = Tcl_GetString(objv[i]);
- if (CreateVirtualEvent(interp, vetPtr, name, event) != TCL_OK) {
+ if (!CreateVirtualEvent(interp, vetPtr, name, event)) {
return TCL_ERROR;
}
}
@@ -2410,7 +3358,7 @@ Tk_EventObjCmd(
if (objc == 3) {
return DeleteVirtualEvent(interp, vetPtr, name, NULL);
}
- for (i = 3; i < objc; i++) {
+ for (i = 3; i < objc; ++i) {
event = Tcl_GetString(objv[i]);
if (DeleteVirtualEvent(interp, vetPtr, name, event) != TCL_OK) {
return TCL_ERROR;
@@ -2419,8 +3367,7 @@ Tk_EventObjCmd(
break;
case EVENT_GENERATE:
if (objc < 4) {
- Tcl_WrongNumArgs(interp, 2, objv,
- "window event ?-option value ...?");
+ Tcl_WrongNumArgs(interp, 2, objv, "window event ?-option value ...?");
return TCL_ERROR;
}
return HandleEventGenerate(interp, tkwin, objc - 2, objv + 2);
@@ -2428,12 +3375,12 @@ Tk_EventObjCmd(
if (objc == 2) {
GetAllVirtualEvents(interp, vetPtr);
return TCL_OK;
- } else if (objc == 3) {
+ }
+ if (objc == 3) {
return GetVirtualEvent(interp, vetPtr, objv[2]);
- } else {
- Tcl_WrongNumArgs(interp, 2, objv, "?virtual?");
- return TCL_ERROR;
}
+ Tcl_WrongNumArgs(interp, 2, objv, "?virtual?");
+ return TCL_ERROR;
}
return TCL_OK;
}
@@ -2457,12 +3404,14 @@ Tk_EventObjCmd(
static void
InitVirtualEventTable(
- VirtualEventTable *vetPtr) /* Pointer to virtual event table. Memory is
- * supplied by the caller. */
+ VirtualEventTable *vetPtr) /* Pointer to virtual event table. Memory is supplied by the caller. */
{
- Tcl_InitHashTable(&vetPtr->patternTable,
- sizeof(PatternTableKey) / sizeof(int));
+ assert(vetPtr);
+ memset(vetPtr, 0, sizeof(*vetPtr));
+ Tcl_InitHashTable(&vetPtr->lookupTables.patternTable, sizeof(PatternTableKey)/sizeof(int));
+ Tcl_InitHashTable(&vetPtr->lookupTables.listTable, sizeof(PatternTableKey)/sizeof(int));
Tcl_InitHashTable(&vetPtr->nameTable, TCL_ONE_WORD_KEYS);
+ PSList_Init(&vetPtr->lookupTables.entryPool);
}
/*
@@ -2488,24 +3437,34 @@ DeleteVirtualEventTable(
{
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
- PatSeq *psPtr, *nextPtr;
- hPtr = Tcl_FirstHashEntry(&vetPtr->patternTable, &search);
- for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- psPtr = Tcl_GetHashValue(hPtr);
- for ( ; psPtr != NULL; psPtr = nextPtr) {
+ assert(vetPtr);
+
+ hPtr = Tcl_FirstHashEntry(&vetPtr->lookupTables.patternTable, &search);
+ for ( ; hPtr; hPtr = Tcl_NextHashEntry(&search)) {
+ PatSeq *nextPtr;
+ PatSeq *psPtr;
+
+ for (psPtr = (PatSeq *)Tcl_GetHashValue(hPtr); psPtr; psPtr = nextPtr) {
+ assert(TEST_PSENTRY(psPtr));
nextPtr = psPtr->nextSeqPtr;
- ckfree(psPtr->voPtr);
- ckfree(psPtr);
+ DEBUG(psPtr->owned = 0;)
+ FreePatSeq(psPtr);
}
}
- Tcl_DeleteHashTable(&vetPtr->patternTable);
+ Tcl_DeleteHashTable(&vetPtr->lookupTables.patternTable);
hPtr = Tcl_FirstHashEntry(&vetPtr->nameTable, &search);
- for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
+ for ( ; hPtr; hPtr = Tcl_NextHashEntry(&search)) {
ckfree(Tcl_GetHashValue(hPtr));
}
Tcl_DeleteHashTable(&vetPtr->nameTable);
+
+ ClearLookupTable(&vetPtr->lookupTables, NULL);
+ Tcl_DeleteHashTable(&vetPtr->lookupTables.listTable);
+
+ DEBUG(countEntryItems -= PSList_Size(&vetPtr->lookupTables.entryPool);)
+ PSList_Traverse(&vetPtr->lookupTables.entryPool, FreePatSeqEntry);
}
/*
@@ -2517,7 +3476,7 @@ DeleteVirtualEventTable(
* already defined, the new definition augments those that already exist.
*
* Results:
- * The return value is TCL_ERROR if an error occurred while creating the
+ * The return value is TCL_ERROR if an error occured while creating the
* virtual binding. In this case, an error message will be left in the
* interp's result. If all went well then the return value is TCL_OK.
*
@@ -2533,31 +3492,30 @@ CreateVirtualEvent(
Tcl_Interp *interp, /* Used for error reporting. */
VirtualEventTable *vetPtr, /* Table in which to augment virtual event. */
char *virtString, /* Name of new virtual event. */
- const char *eventString) /* String describing physical event that
- * triggers virtual event. */
+ const char *eventString) /* String describing physical event that triggers virtual event. */
{
PatSeq *psPtr;
int dummy;
Tcl_HashEntry *vhPtr;
- unsigned long eventMask;
- PhysicalsOwned *poPtr;
- VirtualOwners *voPtr;
+ PhysOwned *owned;
Tk_Uid virtUid;
- virtUid = GetVirtualEventUid(interp, virtString);
- if (virtUid == NULL) {
- return TCL_ERROR;
+ assert(vetPtr);
+ assert(virtString);
+ assert(eventString);
+
+ if (!(virtUid = GetVirtualEventUid(interp, virtString))) {
+ return 0;
}
/*
* Find/create physical event
*/
- psPtr = FindSequence(interp, &vetPtr->patternTable, NULL, eventString,
- 1, 0, &eventMask);
- if (psPtr == NULL) {
- return TCL_ERROR;
+ if (!(psPtr = FindSequence(interp, &vetPtr->lookupTables, NULL, eventString, 1, 0, NULL))) {
+ return 0;
}
+ assert(TEST_PSENTRY(psPtr));
/*
* Find/create virtual event.
@@ -2569,47 +3527,18 @@ CreateVirtualEvent(
* Make virtual event own the physical event.
*/
- poPtr = Tcl_GetHashValue(vhPtr);
- if (poPtr == NULL) {
- poPtr = ckalloc(sizeof(PhysicalsOwned));
- poPtr->numOwned = 0;
- } else {
- /*
- * See if this virtual event is already defined for this physical
- * event and just return if it is.
- */
+ owned = (PhysOwned *)Tcl_GetHashValue(vhPtr);
- int i;
-
- for (i = 0; i < poPtr->numOwned; i++) {
- if (poPtr->patSeqs[i] == psPtr) {
- return TCL_OK;
- }
- }
- poPtr = ckrealloc(poPtr, sizeof(PhysicalsOwned)
- + poPtr->numOwned * sizeof(PatSeq *));
+ if (!PhysOwned_Contains(owned, psPtr)) {
+ PhysOwned_Append(&owned, psPtr);
+ Tcl_SetHashValue(vhPtr, owned);
+ DEBUG(psPtr->owned = 1;)
+ InsertPatSeq(&vetPtr->lookupTables, psPtr);
+ /* Make physical event so it can trigger the virtual event. */
+ VirtOwners_Append(&psPtr->ptr.owners, vhPtr);
}
- Tcl_SetHashValue(vhPtr, poPtr);
- poPtr->patSeqs[poPtr->numOwned] = psPtr;
- poPtr->numOwned++;
-
- /*
- * Make physical event so it can trigger the virtual event.
- */
- voPtr = psPtr->voPtr;
- if (voPtr == NULL) {
- voPtr = ckalloc(sizeof(VirtualOwners));
- voPtr->numOwners = 0;
- } else {
- voPtr = ckrealloc(voPtr, sizeof(VirtualOwners)
- + voPtr->numOwners * sizeof(Tcl_HashEntry *));
- }
- psPtr->voPtr = voPtr;
- voPtr->owners[voPtr->numOwners] = vhPtr;
- voPtr->numOwners++;
-
- return TCL_OK;
+ return 1;
}
/*
@@ -2639,32 +3568,32 @@ static int
DeleteVirtualEvent(
Tcl_Interp *interp, /* Used for error reporting. */
VirtualEventTable *vetPtr, /* Table in which to delete event. */
- char *virtString, /* String describing event sequence that
- * triggers binding. */
- const char *eventString) /* The event sequence that should be deleted,
- * or NULL to delete all event sequences for
- * the entire virtual event. */
+ char *virtString, /* String describing event sequence that triggers binding. */
+ const char *eventString) /* The event sequence that should be deleted, or NULL to delete
+ * all event sequences for the entire virtual event. */
{
int iPhys;
Tk_Uid virtUid;
Tcl_HashEntry *vhPtr;
- PhysicalsOwned *poPtr;
- PatSeq *eventPSPtr;
+ PhysOwned *owned;
+ const PatSeq *eventPSPtr;
+ PatSeq *lastElemPtr;
+
+ assert(vetPtr);
+ assert(virtString);
- virtUid = GetVirtualEventUid(interp, virtString);
- if (virtUid == NULL) {
+ if (!(virtUid = GetVirtualEventUid(interp, virtString))) {
return TCL_ERROR;
}
- vhPtr = Tcl_FindHashEntry(&vetPtr->nameTable, virtUid);
- if (vhPtr == NULL) {
+ if (!(vhPtr = Tcl_FindHashEntry(&vetPtr->nameTable, virtUid))) {
return TCL_OK;
}
- poPtr = Tcl_GetHashValue(vhPtr);
+ owned = (PhysOwned *)Tcl_GetHashValue(vhPtr);
eventPSPtr = NULL;
- if (eventString != NULL) {
- unsigned long eventMask;
+ if (eventString) {
+ LookupTables *lookupTables = &vetPtr->lookupTables;
/*
* Delete only the specific physical event associated with the virtual
@@ -2672,102 +3601,75 @@ DeleteVirtualEvent(
* event doesn't own that physical event, return w/o doing anything.
*/
- eventPSPtr = FindSequence(interp, &vetPtr->patternTable, NULL,
- eventString, 0, 0, &eventMask);
- if (eventPSPtr == NULL) {
+ eventPSPtr = FindSequence(interp, lookupTables, NULL, eventString, 0, 0, NULL);
+ if (!eventPSPtr) {
const char *string = Tcl_GetString(Tcl_GetObjResult(interp));
-
- return (string[0] != '\0') ? TCL_ERROR : TCL_OK;
+ return string[0] ? TCL_ERROR : TCL_OK;
}
}
- for (iPhys = poPtr->numOwned; --iPhys >= 0; ) {
- PatSeq *psPtr = poPtr->patSeqs[iPhys];
+ for (iPhys = PhysOwned_Size(owned); --iPhys >= 0; ) {
+ PatSeq *psPtr = PhysOwned_Get(owned, iPhys);
+
+ assert(TEST_PSENTRY(psPtr));
- if ((eventPSPtr == NULL) || (psPtr == eventPSPtr)) {
- int iVirt;
- VirtualOwners *voPtr;
+ if (!eventPSPtr || psPtr == eventPSPtr) {
+ VirtOwners *owners = psPtr->ptr.owners;
+ int iVirt = VirtOwners_Find(owners, vhPtr);
+
+ assert(iVirt != -1); /* otherwise we couldn't find owner, and this should not happen */
/*
* Remove association between this physical event and the given
* virtual event that it triggers.
*/
- voPtr = psPtr->voPtr;
- for (iVirt = 0; iVirt < voPtr->numOwners; iVirt++) {
- if (voPtr->owners[iVirt] == vhPtr) {
- break;
- }
- }
- if (iVirt == voPtr->numOwners) {
- Tcl_Panic("DeleteVirtualEvent: couldn't find owner");
- }
- voPtr->numOwners--;
- if (voPtr->numOwners == 0) {
- /*
- * Removed last reference to this physical event, so remove it
- * from physical->virtual map.
- */
-
- PatSeq *prevPtr = Tcl_GetHashValue(psPtr->hPtr);
-
- if (prevPtr == psPtr) {
- if (psPtr->nextSeqPtr == NULL) {
- Tcl_DeleteHashEntry(psPtr->hPtr);
- } else {
- Tcl_SetHashValue(psPtr->hPtr,
- psPtr->nextSeqPtr);
- }
- } else {
- for ( ; ; prevPtr = prevPtr->nextSeqPtr) {
- if (prevPtr == NULL) {
- Tcl_Panic("DeleteVirtualEvent couldn't find on hash chain");
- }
- if (prevPtr->nextSeqPtr == psPtr) {
- prevPtr->nextSeqPtr = psPtr->nextSeqPtr;
- break;
- }
- }
- }
- ckfree(psPtr->voPtr);
- ckfree(psPtr);
- } else {
+ if (VirtOwners_Size(owners) > 1) {
/*
* This physical event still triggers some other virtual
* event(s). Consolidate the list of virtual owners for this
* physical event so it no longer triggers the given virtual
* event.
*/
-
- voPtr->owners[iVirt] = voPtr->owners[voPtr->numOwners];
+ VirtOwners_Set(owners, iVirt, VirtOwners_Back(owners));
+ VirtOwners_PopBack(owners);
+ } else {
+ /*
+ * Removed last reference to this physical event, so remove it
+ * from lookup table.
+ */
+ DEBUG(psPtr->owned = 0;)
+ RemovePatSeqFromLookup(&vetPtr->lookupTables, psPtr);
+ DeletePatSeq(psPtr);
}
/*
* Now delete the virtual event's reference to the physical event.
*/
- poPtr->numOwned--;
- if (eventPSPtr != NULL && poPtr->numOwned != 0) {
+ lastElemPtr = PhysOwned_Back(owned);
+
+ if (PhysOwned_PopBack(owned) > 0 && eventPSPtr) {
/*
* Just deleting this one physical event. Consolidate list of
* owned physical events and return.
*/
-
- poPtr->patSeqs[iPhys] = poPtr->patSeqs[poPtr->numOwned];
+ if ((size_t) iPhys < PhysOwned_Size(owned)) {
+ PhysOwned_Set(owned, iPhys, lastElemPtr);
+ }
return TCL_OK;
}
}
}
- if (poPtr->numOwned == 0) {
+ if (PhysOwned_IsEmpty(owned)) {
/*
* All the physical events for this virtual event were deleted, either
* because there was only one associated physical event or because the
* caller was deleting the entire virtual event. Now the virtual event
* itself should be deleted.
*/
-
- ckfree(poPtr);
+ PhysOwned_Free(&owned);
Tcl_DeleteHashEntry(vhPtr);
}
return TCL_OK;
@@ -2802,26 +3704,26 @@ GetVirtualEvent(
Tcl_Obj *virtName) /* String describing virtual event. */
{
Tcl_HashEntry *vhPtr;
- int iPhys;
- PhysicalsOwned *poPtr;
+ unsigned iPhys;
+ const PhysOwned *owned;
Tk_Uid virtUid;
Tcl_Obj *resultObj;
- virtUid = GetVirtualEventUid(interp, Tcl_GetString(virtName));
- if (virtUid == NULL) {
+ assert(vetPtr);
+ assert(virtName);
+
+ if (!(virtUid = GetVirtualEventUid(interp, Tcl_GetString(virtName)))) {
return TCL_ERROR;
}
- vhPtr = Tcl_FindHashEntry(&vetPtr->nameTable, virtUid);
- if (vhPtr == NULL) {
+ if (!(vhPtr = Tcl_FindHashEntry(&vetPtr->nameTable, virtUid))) {
return TCL_OK;
}
resultObj = Tcl_NewObj();
- poPtr = Tcl_GetHashValue(vhPtr);
- for (iPhys = 0; iPhys < poPtr->numOwned; iPhys++) {
- Tcl_ListObjAppendElement(NULL, resultObj,
- GetPatternObj(poPtr->patSeqs[iPhys]));
+ owned = (const PhysOwned *)Tcl_GetHashValue(vhPtr);
+ for (iPhys = 0; iPhys < PhysOwned_Size(owned); ++iPhys) {
+ Tcl_ListObjAppendElement(NULL, resultObj, GetPatternObj(PhysOwned_Get(owned, iPhys)));
}
Tcl_SetObjResult(interp, resultObj);
@@ -2855,11 +3757,13 @@ GetAllVirtualEvents(
Tcl_HashSearch search;
Tcl_Obj *resultObj;
+ assert(vetPtr);
+
resultObj = Tcl_NewObj();
hPtr = Tcl_FirstHashEntry(&vetPtr->nameTable, &search);
- for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- Tcl_ListObjAppendElement(NULL, resultObj, Tcl_ObjPrintf(
- "<<%s>>", (char *) Tcl_GetHashKey(hPtr->tablePtr, hPtr)));
+ for ( ; hPtr; hPtr = Tcl_NextHashEntry(&search)) {
+ Tcl_Obj* msg = Tcl_ObjPrintf("<<%s>>", (char *) Tcl_GetHashKey(hPtr->tablePtr, hPtr));
+ Tcl_ListObjAppendElement(NULL, resultObj, msg);
}
Tcl_SetObjResult(interp, resultObj);
}
@@ -2906,16 +3810,24 @@ HandleEventGenerate(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- union {XEvent general; XVirtualEvent virtual;} event;
+ union { XEvent general; XVirtualEvent virt; } event;
+
const char *p;
- const char *name, *windowName;
- int count, flags, synch, i, number, warp;
+ const char *name;
+ const char *windowName;
Tcl_QueuePosition pos;
TkPattern pat;
- Tk_Window tkwin, tkwin2;
+ Tk_Window tkwin;
+ Tk_Window tkwin2;
TkWindow *mainPtr;
- unsigned long eventMask;
+ EventMask eventMask;
Tcl_Obj *userDataObj;
+ int synch;
+ int warp;
+ unsigned count;
+ unsigned flags;
+ int number;
+ unsigned i;
static const char *const fieldStrings[] = {
"-when", "-above", "-borderwidth", "-button",
@@ -2925,7 +3837,7 @@ HandleEventGenerate(
"-place", "-root", "-rootx", "-rooty",
"-sendevent", "-serial", "-state", "-subwindow",
"-time", "-warp", "-width", "-window",
- "-x", "-y", NULL
+ "-x", "-y", NULL
};
enum field {
EVENT_WHEN, EVENT_ABOVE, EVENT_BORDER, EVENT_BUTTON,
@@ -2938,42 +3850,39 @@ HandleEventGenerate(
EVENT_X, EVENT_Y
};
+ assert(mainWin);
+
windowName = Tcl_GetString(objv[0]);
if (!windowName[0]) {
tkwin = mainWin;
- } else if (NameToWindow(interp, mainWin, objv[0], &tkwin) != TCL_OK) {
+ } else if (!NameToWindow(interp, mainWin, objv[0], &tkwin)) {
return TCL_ERROR;
}
mainPtr = (TkWindow *) mainWin;
- if ((tkwin == NULL)
- || (mainPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr)) {
+ if (!tkwin || mainPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window id \"%s\" doesn't exist in this application",
Tcl_GetString(objv[0])));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW",
- Tcl_GetString(objv[0]), NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW", Tcl_GetString(objv[0]), NULL);
return TCL_ERROR;
}
name = Tcl_GetString(objv[1]);
-
p = name;
eventMask = 0;
userDataObj = NULL;
- count = ParseEventDescription(interp, &p, &pat, &eventMask);
- if (count == 0) {
+ if ((count = ParseEventDescription(interp, &p, &pat, &eventMask)) == 0) {
return TCL_ERROR;
}
- if (count != 1) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "Double or Triple modifier not allowed", -1));
+ if (count != 1u) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("Double, Triple, or Quadruple modifier not allowed", -1));
Tcl_SetErrorCode(interp, "TK", "EVENT", "BAD_MODIFIER", NULL);
return TCL_ERROR;
}
- if (*p != '\0') {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "only one event specification allowed", -1));
+ if (*p) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("only one event specification allowed", -1));
Tcl_SetErrorCode(interp, "TK", "EVENT", "MULTIPLE", NULL);
return TCL_ERROR;
}
@@ -2981,12 +3890,11 @@ HandleEventGenerate(
memset(&event, 0, sizeof(event));
event.general.xany.type = pat.eventType;
event.general.xany.serial = NextRequest(Tk_Display(tkwin));
- event.general.xany.send_event = False;
+ event.general.xany.send_event = 0;
if (windowName[0]) {
event.general.xany.window = Tk_WindowId(tkwin);
} else {
- event.general.xany.window =
- RootWindow(Tk_Display(tkwin), Tk_ScreenNumber(tkwin));
+ event.general.xany.window = RootWindow(Tk_Display(tkwin), Tk_ScreenNumber(tkwin));
}
event.general.xany.display = Tk_Display(tkwin);
@@ -2995,44 +3903,43 @@ HandleEventGenerate(
/*
* Event DestroyNotify should be generated by destroying the window.
*/
-
Tk_DestroyWindow(tkwin);
return TCL_OK;
}
- if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
- event.general.xkey.state = pat.needMods;
- if ((flags & KEY) && (event.general.xany.type != MouseWheelEvent)) {
- TkpSetKeycodeAndState(tkwin, pat.detail.keySym, &event.general);
+ if (flags & HAS_XKEY_HEAD_AND_STATE) {
+ event.general.xkey.state = pat.modMask;
+ if (flags & KEY) {
+ TkpSetKeycodeAndState(tkwin, pat.info, &event.general);
} else if (flags & BUTTON) {
- event.general.xbutton.button = pat.detail.button;
+ event.general.xbutton.button = pat.info;
} else if (flags & VIRTUAL) {
- event.virtual.name = pat.detail.name;
+ event.virt.name = pat.name;
}
}
if (flags & (CREATE|UNMAP|MAP|REPARENT|CONFIG|GRAVITY|CIRC)) {
event.general.xcreatewindow.window = event.general.xany.window;
}
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ if (flags & HAS_XKEY_HEAD) {
event.general.xkey.x_root = -1;
event.general.xkey.y_root = -1;
}
- if (event.general.xany.type == FocusIn
- || event.general.xany.type == FocusOut) {
+ if (event.general.xany.type == FocusIn || event.general.xany.type == FocusOut) {
event.general.xany.send_event = GENERATED_FOCUS_EVENT_MAGIC;
}
/*
- * Process the remaining arguments to fill in additional fields of the
- * event.
+ * Process the remaining arguments to fill in additional fields of the event.
*/
synch = 1;
warp = 0;
pos = TCL_QUEUE_TAIL;
- for (i = 2; i < objc; i += 2) {
+
+ for (i = 2; i < (unsigned) objc; i += 2) {
Tcl_Obj *optionPtr, *valuePtr;
+ int badOpt = 0;
int index;
optionPtr = objv[i];
@@ -3042,7 +3949,7 @@ HandleEventGenerate(
sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
return TCL_ERROR;
}
- if (objc & 1) {
+ if (IsOdd(objc)) {
/*
* This test occurs after Tcl_GetIndexFromObj() so that "event
* generate <Button> -xyz" will return the error message that
@@ -3061,39 +3968,35 @@ HandleEventGenerate(
if (Tcl_GetBooleanFromObj(interp, valuePtr, &warp) != TCL_OK) {
return TCL_ERROR;
}
- if (!(flags & KEY_BUTTON_MOTION_VIRTUAL)) {
- goto badopt;
+ if (!(flags & CAN_WARP)) {
+ badOpt = 1;
}
break;
case EVENT_WHEN:
- pos = (Tcl_QueuePosition) TkFindStateNumObj(interp, optionPtr,
- queuePosition, valuePtr);
+ pos = (Tcl_QueuePosition) TkFindStateNumObj(interp, optionPtr, queuePosition, valuePtr);
if ((int) pos < -1) {
return TCL_ERROR;
}
- synch = 0;
- if ((int) pos == -1) {
- synch = 1;
- }
+ synch = ((int) pos == -1);
break;
case EVENT_ABOVE:
- if (NameToWindow(interp, tkwin, valuePtr, &tkwin2) != TCL_OK) {
+ if (!NameToWindow(interp, tkwin, valuePtr, &tkwin2)) {
return TCL_ERROR;
}
if (flags & CONFIG) {
event.general.xconfigure.above = Tk_WindowId(tkwin2);
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_BORDER:
- if (Tk_GetPixelsFromObj(interp,tkwin,valuePtr,&number) != TCL_OK) {
+ if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
if (flags & (CREATE|CONFIG)) {
event.general.xcreatewindow.border_width = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_BUTTON:
@@ -3103,7 +4006,7 @@ HandleEventGenerate(
if (flags & BUTTON) {
event.general.xbutton.button = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_COUNT:
@@ -3113,7 +4016,7 @@ HandleEventGenerate(
if (flags & EXPOSE) {
event.general.xexpose.count = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_DATA:
@@ -3123,25 +4026,23 @@ HandleEventGenerate(
* completes and we know that the event generation is really
* going to happen.
*/
-
userDataObj = valuePtr;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_DELTA:
if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- if ((flags & KEY) && (event.general.xkey.type == MouseWheelEvent)) {
- event.general.xkey.keycode = number;
+ if (flags & WHEEL) {
+ event.general.xbutton.button = (unsigned)number; /* mis-use button field for this */
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_DETAIL:
- number = TkFindStateNumObj(interp, optionPtr, notifyDetail,
- valuePtr);
+ number = TkFindStateNumObj(interp, optionPtr, notifyDetail, valuePtr);
if (number < 0) {
return TCL_ERROR;
}
@@ -3150,7 +4051,7 @@ HandleEventGenerate(
} else if (flags & CROSSING) {
event.general.xcrossing.detail = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_FOCUS:
@@ -3160,12 +4061,11 @@ HandleEventGenerate(
if (flags & CROSSING) {
event.general.xcrossing.focus = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_HEIGHT:
- if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr,
- &number) != TCL_OK) {
+ if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
if (flags & EXPOSE) {
@@ -3173,17 +4073,17 @@ HandleEventGenerate(
} else if (flags & CONFIG) {
event.general.xconfigure.height = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_KEYCODE:
if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- if ((flags & KEY) && (event.general.xkey.type != MouseWheelEvent)) {
+ if (flags & KEY) {
event.general.xkey.keycode = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_KEYSYM: {
@@ -3193,30 +4093,24 @@ HandleEventGenerate(
value = Tcl_GetString(valuePtr);
keysym = TkStringToKeysym(value);
if (keysym == NoSymbol) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "unknown keysym \"%s\"", value));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYSYM", value,
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("unknown keysym \"%s\"", value));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYSYM", value, NULL);
return TCL_ERROR;
}
TkpSetKeycodeAndState(tkwin, keysym, &event.general);
if (event.general.xkey.keycode == 0) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "no keycode for keysym \"%s\"", value));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYCODE", value,
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("no keycode for keysym \"%s\"", value));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYCODE", value, NULL);
return TCL_ERROR;
}
- if (!(flags & KEY)
- || (event.general.xkey.type == MouseWheelEvent)) {
- goto badopt;
+ if (!(flags & KEY)) {
+ badOpt = 1;
}
break;
}
case EVENT_MODE:
- number = TkFindStateNumObj(interp,optionPtr,notifyMode,valuePtr);
- if (number < 0) {
+ if ((number = TkFindStateNumObj(interp, optionPtr, notifyMode, valuePtr)) < 0) {
return TCL_ERROR;
}
if (flags & CROSSING) {
@@ -3224,7 +4118,7 @@ HandleEventGenerate(
} else if (flags & FOCUS) {
event.general.xfocus.mode = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_OVERRIDE:
@@ -3240,48 +4134,47 @@ HandleEventGenerate(
} else if (flags & CONFIG) {
event.general.xconfigure.override_redirect = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_PLACE:
- number = TkFindStateNumObj(interp, optionPtr, circPlace, valuePtr);
- if (number < 0) {
+ if ((number = TkFindStateNumObj(interp, optionPtr, circPlace, valuePtr)) < 0) {
return TCL_ERROR;
}
if (flags & CIRC) {
event.general.xcirculate.place = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_ROOT:
- if (NameToWindow(interp, tkwin, valuePtr, &tkwin2) != TCL_OK) {
+ if (!NameToWindow(interp, tkwin, valuePtr, &tkwin2)) {
return TCL_ERROR;
}
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ if (flags & HAS_XKEY_HEAD) {
event.general.xkey.root = Tk_WindowId(tkwin2);
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_ROOTX:
- if (Tk_GetPixelsFromObj(interp,tkwin,valuePtr,&number) != TCL_OK) {
+ if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ if (flags & HAS_XKEY_HEAD) {
event.general.xkey.x_root = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_ROOTY:
- if (Tk_GetPixelsFromObj(interp,tkwin,valuePtr,&number) != TCL_OK) {
+ if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ if (flags & HAS_XKEY_HEAD) {
event.general.xkey.y_root = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_SEND: {
@@ -3293,16 +4186,21 @@ HandleEventGenerate(
* Allow arbitrary integer values for the field; they are
* needed by a few of the tests in the Tk test suite.
*/
-
if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- } else {
- if (Tcl_GetBooleanFromObj(interp,valuePtr,&number) != TCL_OK) {
- return TCL_ERROR;
+ if (number) {
+ /*
+ * send_event only expects 1 or 0. We cannot allow arbitrary non-zero
+ * values, otherwise the thing with GENERATED_FOCUS_EVENT_MAGIC will not
+ * work.
+ */
+ number = 1;
}
+ } else if (Tcl_GetBooleanFromObj(interp, valuePtr, &number) != TCL_OK) {
+ return TCL_ERROR;
}
- event.general.xany.send_event = number;
+ event.general.xany.send_event |= number;
break;
}
case EVENT_SERIAL:
@@ -3312,50 +4210,53 @@ HandleEventGenerate(
event.general.xany.serial = number;
break;
case EVENT_STATE:
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ if (flags & HAS_XKEY_HEAD) {
if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
+ if (flags & HAS_XKEY_HEAD_AND_STATE) {
event.general.xkey.state = number;
} else {
event.general.xcrossing.state = number;
}
} else if (flags & VISIBILITY) {
- number = TkFindStateNumObj(interp, optionPtr, visNotify,
- valuePtr);
- if (number < 0) {
+ if ((number = TkFindStateNumObj(interp, optionPtr, visNotify, valuePtr)) < 0) {
return TCL_ERROR;
}
event.general.xvisibility.state = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_SUBWINDOW:
- if (NameToWindow(interp, tkwin, valuePtr, &tkwin2) != TCL_OK) {
+ if (!NameToWindow(interp, tkwin, valuePtr, &tkwin2)) {
return TCL_ERROR;
}
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ if (flags & HAS_XKEY_HEAD) {
event.general.xkey.subwindow = Tk_WindowId(tkwin2);
} else {
- goto badopt;
+ badOpt = 1;
}
break;
- case EVENT_TIME:
- if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
+ case EVENT_TIME: {
+ if (strcmp(Tcl_GetString(valuePtr), "current") == 0) {
+ TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
+ BindInfo *biPtr = mainPtr->mainPtr->bindInfo;
+ number = dispPtr->lastEventTime + (CurrentTimeInMilliSecs() - biPtr->lastCurrentTime);
+ } else if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ if (flags & HAS_XKEY_HEAD) {
event.general.xkey.time = number;
} else if (flags & PROP) {
event.general.xproperty.time = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
+ }
case EVENT_WIDTH:
- if (Tk_GetPixelsFromObj(interp,tkwin,valuePtr,&number) != TCL_OK) {
+ if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
if (flags & EXPOSE) {
@@ -3363,24 +4264,24 @@ HandleEventGenerate(
} else if (flags & (CREATE|CONFIG)) {
event.general.xcreatewindow.width = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_WINDOW:
- if (NameToWindow(interp, tkwin, valuePtr, &tkwin2) != TCL_OK) {
+ if (!NameToWindow(interp, tkwin, valuePtr, &tkwin2)) {
return TCL_ERROR;
}
if (flags & (CREATE|UNMAP|MAP|REPARENT|CONFIG|GRAVITY|CIRC)) {
event.general.xcreatewindow.window = Tk_WindowId(tkwin2);
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_X:
- if (Tk_GetPixelsFromObj(interp,tkwin,valuePtr,&number) != TCL_OK) {
+ if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ if (flags & HAS_XKEY_HEAD) {
event.general.xkey.x = number;
/*
@@ -3400,14 +4301,14 @@ HandleEventGenerate(
} else if (flags & REPARENT) {
event.general.xreparent.x = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
case EVENT_Y:
- if (Tk_GetPixelsFromObj(interp,tkwin,valuePtr,&number) != TCL_OK) {
+ if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ if (flags & HAS_XKEY_HEAD) {
event.general.xkey.y = number;
/*
@@ -3427,85 +4328,94 @@ HandleEventGenerate(
} else if (flags & REPARENT) {
event.general.xreparent.y = number;
} else {
- goto badopt;
+ badOpt = 1;
}
break;
}
- continue;
- badopt:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "%s event doesn't accept \"%s\" option",
- name, Tcl_GetString(optionPtr)));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "BAD_OPTION", NULL);
- return TCL_ERROR;
+ if (badOpt) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "%s event doesn't accept \"%s\" option", name, Tcl_GetString(optionPtr)));
+ Tcl_SetErrorCode(interp, "TK", "EVENT", "BAD_OPTION", NULL);
+ return TCL_ERROR;
+ }
}
/*
* Don't generate events for windows that don't exist yet.
*/
- if (!event.general.xany.window) {
- goto done;
- }
-
- if (userDataObj != NULL) {
+ if (event.general.xany.window) {
+ if (userDataObj) {
+ /*
+ * Must be virtual event to set that variable to non-NULL. Now we want
+ * to install the object into the event. Note that we must incr the
+ * refcount before firing it into the low-level event subsystem; the
+ * refcount will be decremented once the event has been processed.
+ */
+ event.virt.user_data = userDataObj;
+ Tcl_IncrRefCount(userDataObj);
+ }
/*
- * Must be virtual event to set that variable to non-NULL. Now we want
- * to install the object into the event. Note that we must incr the
- * refcount before firing it into the low-level event subsystem; the
- * refcount will be decremented once the event has been processed.
+ * Now we have constructed the event, inject it into the event handling
+ * code.
*/
- event.virtual.user_data = userDataObj;
- Tcl_IncrRefCount(userDataObj);
- }
-
- /*
- * Now we have constructed the event, inject it into the event handling
- * code.
- */
-
- if (synch != 0) {
- Tk_HandleEvent(&event.general);
- } else {
- Tk_QueueWindowEvent(&event.general, pos);
- }
-
- /*
- * We only allow warping if the window is mapped.
- */
+ if (synch) {
+ Tk_HandleEvent(&event.general);
+ } else {
+ Tk_QueueWindowEvent(&event.general, pos);
+ }
- if ((warp != 0) && Tk_IsMapped(tkwin)) {
- TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display);
+ /*
+ * We only allow warping if the window is mapped.
+ */
- Tk_Window warpWindow = Tk_IdToWindow(dispPtr->display,
- event.general.xmotion.window);
+ if (warp && Tk_IsMapped(tkwin)) {
+ TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display);
- if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
- Tcl_DoWhenIdle(DoWarp, dispPtr);
- dispPtr->flags |= TK_DISPLAY_IN_WARP;
- }
+ Tk_Window warpWindow = Tk_IdToWindow(dispPtr->display, event.general.xmotion.window);
- if (warpWindow != dispPtr->warpWindow) {
- if (warpWindow) {
- Tcl_Preserve(warpWindow);
+ if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
+ Tcl_DoWhenIdle(DoWarp, dispPtr);
+ dispPtr->flags |= TK_DISPLAY_IN_WARP;
}
- if (dispPtr->warpWindow) {
- Tcl_Release(dispPtr->warpWindow);
+
+ if (warpWindow != dispPtr->warpWindow) {
+ if (warpWindow) {
+ Tcl_Preserve(warpWindow);
+ }
+ if (dispPtr->warpWindow) {
+ Tcl_Release(dispPtr->warpWindow);
+ }
+ dispPtr->warpWindow = warpWindow;
}
- dispPtr->warpWindow = warpWindow;
+ dispPtr->warpMainwin = mainWin;
+ dispPtr->warpX = event.general.xmotion.x;
+ dispPtr->warpY = event.general.xmotion.y;
}
- dispPtr->warpMainwin = mainWin;
- dispPtr->warpX = event.general.xmotion.x;
- dispPtr->warpY = event.general.xmotion.y;
}
- done:
Tcl_ResetResult(interp);
return TCL_OK;
}
+/*
+ *---------------------------------------------------------------------------
+ *
+ * NameToWindow --
+ *
+ * Helper function for lookup of a window given its path name. Our
+ * version is able to handle window id's.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *---------------------------------------------------------------------------
+ */
static int
NameToWindow(
@@ -3514,38 +4424,43 @@ NameToWindow(
Tcl_Obj *objPtr, /* Contains name or id string of window. */
Tk_Window *tkwinPtr) /* Filled with token for window. */
{
- const char *name = Tcl_GetString(objPtr);
+ const char *name;
Tk_Window tkwin;
+ assert(mainWin);
+ assert(objPtr);
+ assert(tkwinPtr);
+
+ name = Tcl_GetString(objPtr);
+
if (name[0] == '.') {
- tkwin = Tk_NameToWindow(interp, name, mainWin);
- if (tkwin == NULL) {
- return TCL_ERROR;
+ if (!(tkwin = Tk_NameToWindow(interp, name, mainWin))) {
+ return 0;
}
} else {
Window id;
+ tkwin = NULL;
+
/*
- * Check for the winPtr being valid, even if it looks ok to
+ * Check for the winPtr being valid, even if it looks okay to
* TkpScanWindowId. [Bug #411307]
*/
- if (TkpScanWindowId(NULL, name, &id) != TCL_OK) {
- goto badWindow;
+ if (TkpScanWindowId(NULL, name, &id) == TCL_OK) {
+ tkwin = Tk_IdToWindow(Tk_Display(mainWin), id);
}
- tkwin = Tk_IdToWindow(Tk_Display(mainWin), id);
- if (tkwin == NULL) {
- goto badWindow;
+
+ if (!tkwin) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad window name/identifier \"%s\"", name));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW_ID", name, NULL);
+ return 0;
}
}
- *tkwinPtr = tkwin;
- return TCL_OK;
- badWindow:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad window name/identifier \"%s\"", name));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW_ID", name, NULL);
- return TCL_ERROR;
+ assert(tkwin);
+ *tkwinPtr = tkwin;
+ return 1;
}
/*
@@ -3568,7 +4483,9 @@ static void
DoWarp(
ClientData clientData)
{
- TkDisplay *dispPtr = clientData;
+ TkDisplay *dispPtr = (TkDisplay *)clientData;
+
+ assert(clientData);
/*
* DoWarp was scheduled only if the window was mapped. It needs to be
@@ -3578,9 +4495,8 @@ DoWarp(
* the whole screen.
*/
- if ((dispPtr->warpWindow == NULL) ||
- (Tk_IsMapped(dispPtr->warpWindow)
- && (Tk_WindowId(dispPtr->warpWindow) != None))) {
+ if (!dispPtr->warpWindow ||
+ (Tk_IsMapped(dispPtr->warpWindow) && Tk_WindowId(dispPtr->warpWindow) != None)) {
TkpWarpPointer(dispPtr);
XForceScreenSaver(dispPtr->display, ScreenSaverReset);
}
@@ -3620,12 +4536,16 @@ GetVirtualEventUid(
Tk_Uid uid;
size_t length;
+ assert(virtString);
+
length = strlen(virtString);
- if (length < 5 || virtString[0] != '<' || virtString[1] != '<' ||
- virtString[length - 2] != '>' || virtString[length - 1] != '>') {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "virtual event \"%s\" is badly formed", virtString));
+ if (length < 5
+ || virtString[0] != '<'
+ || virtString[1] != '<'
+ || virtString[length - 2] != '>'
+ || virtString[length - 1] != '>') {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("virtual event \"%s\" is badly formed", virtString));
Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "MALFORMED", NULL);
return NULL;
}
@@ -3663,118 +4583,116 @@ GetVirtualEventUid(
static PatSeq *
FindSequence(
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
- Tcl_HashTable *patternTablePtr,
- /* Table to use for lookup. */
- ClientData object, /* For binding table, token for object with
- * which binding is associated. For virtual
- * event table, NULL. */
- const char *eventString, /* String description of pattern to match on.
- * See user documentation for details. */
- int create, /* 0 means don't create the entry if it
- * doesn't already exist. Non-zero means
- * create. */
- int allowVirtual, /* 0 means that virtual events are not allowed
- * in the sequence. Non-zero otherwise. */
- unsigned long *maskPtr) /* *maskPtr is filled in with the event types
- * on which this pattern sequence depends. */
+ LookupTables *lookupTables, /* Tables used for lookup. */
+ ClientData object, /* For binding table, token for object with which binding is
+ * associated. For virtual event table, NULL. */
+ const char *eventString, /* String description of pattern to match on. See user
+ * documentation for details. */
+ int create, /* 0 means don't create the entry if it doesn't already exist.
+ * 1 means create. */
+ int allowVirtual, /* 0 means that virtual events are not allowed in the sequence.
+ * 1 otherwise. */
+ EventMask *maskPtr) /* *maskPtr is filled in with the event types on which this
+ * pattern sequence depends. */
{
- TkPattern pats[EVENT_BUFFER_SIZE];
- int numPats, virtualFound;
- const char *p;
+ unsigned patsBufSize = 1;
+ unsigned numPats;
+ unsigned totalCount = 0;
+ int virtualFound = 0;
+ const char *p = eventString;
TkPattern *patPtr;
PatSeq *psPtr;
Tcl_HashEntry *hPtr;
- int flags, count, isNew;
- size_t sequenceSize;
- unsigned long eventMask;
+ int isNew;
+ unsigned count;
+ unsigned maxCount = 0;
+ EventMask eventMask = 0;
+ ModMask modMask = 0;
PatternTableKey key;
+ assert(lookupTables);
+ assert(eventString);
+
+ psPtr = (PatSeq *)ckalloc(PATSEQ_MEMSIZE(patsBufSize));
+
/*
- *-------------------------------------------------------------
- * Step 1: parse the pattern string to produce an array of Patterns. The
- * array is generated backwards, so that the lowest-indexed pattern
- * corresponds to the last event that must occur.
- *-------------------------------------------------------------
+ *------------------------------------------------------------------
+ * Step 1: parse the pattern string to produce an array of Patterns.
+ *------------------------------------------------------------------
*/
- p = eventString;
- flags = 0;
- eventMask = 0;
- virtualFound = 0;
-
- patPtr = &pats[EVENT_BUFFER_SIZE-1];
- for (numPats = 0; numPats < EVENT_BUFFER_SIZE; numPats++, patPtr--) {
- while (isspace(UCHAR(*p))) {
- p++;
- }
- if (*p == '\0') {
- break;
+ for (patPtr = psPtr->pats, numPats = 0; *(p = SkipSpaces(p)); ++patPtr, ++numPats) {
+ if (numPats >= patsBufSize) {
+ unsigned pos = patPtr - psPtr->pats;
+ patsBufSize += patsBufSize;
+ psPtr = (PatSeq *)ckrealloc(psPtr, PATSEQ_MEMSIZE(patsBufSize));
+ patPtr = psPtr->pats + pos;
}
- count = ParseEventDescription(interp, &p, patPtr, &eventMask);
- if (count == 0) {
+ if ((count = ParseEventDescription(interp, &p, patPtr, &eventMask)) == 0) {
+ /* error encountered */
+ ckfree(psPtr);
return NULL;
}
if (eventMask & VirtualEventMask) {
- if (allowVirtual == 0) {
+ if (!allowVirtual) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "virtual event not allowed in definition of another virtual event",
- -1));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "INNER",
- NULL);
+ "virtual event not allowed in definition of another virtual event", -1));
+ Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "INNER", NULL);
+ ckfree(psPtr);
return NULL;
}
virtualFound = 1;
}
- /*
- * Replicate events for DOUBLE, TRIPLE, QUADRUPLE.
- */
-
- while ((count-- > 1) && (numPats < EVENT_BUFFER_SIZE-1)) {
- flags |= PAT_NEARBY;
- patPtr[-1] = patPtr[0];
- patPtr--;
- numPats++;
+ if (count > 1u) {
+ maxCount = Max(count, maxCount);
}
+
+ totalCount += count;
+ modMask |= patPtr->modMask;
}
/*
- *-------------------------------------------------------------
- * Step 2: find the sequence in the binding table if it exists, and add a
- * new sequence to the table if it doesn't.
- *-------------------------------------------------------------
+ *------------------------------------------------------------------
+ * Step 2: find the sequence in the binding table if it exists, and
+ * add a new sequence to the table if it doesn't.
+ *------------------------------------------------------------------
*/
if (numPats == 0) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "no events specified in binding", -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("no events specified in binding", -1));
Tcl_SetErrorCode(interp, "TK", "EVENT", "NO_EVENTS", NULL);
+ ckfree(psPtr);
return NULL;
}
- if ((numPats > 1) && (virtualFound != 0)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "virtual events may not be composed", -1));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "COMPOSITION",
- NULL);
+ if (numPats > 1u && virtualFound) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("virtual events may not be composed", -1));
+ Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "COMPOSITION", NULL);
+ ckfree(psPtr);
return NULL;
}
+ if (patsBufSize > numPats) {
+ psPtr = (PatSeq *)ckrealloc(psPtr, PATSEQ_MEMSIZE(numPats));
+ }
- patPtr = &pats[EVENT_BUFFER_SIZE-numPats];
- memset(&key, 0, sizeof(key));
- key.object = object;
- key.type = patPtr->eventType;
- key.detail = patPtr->detail;
- hPtr = Tcl_CreateHashEntry(patternTablePtr, (char *) &key, &isNew);
- sequenceSize = numPats*sizeof(TkPattern);
+ patPtr = psPtr->pats;
+ psPtr->object = (Tcl_Obj *)object;
+ SetupPatternKey(&key, psPtr);
+ hPtr = Tcl_CreateHashEntry(&lookupTables->patternTable, (char *) &key, &isNew);
if (!isNew) {
- for (psPtr = Tcl_GetHashValue(hPtr); psPtr != NULL;
- psPtr = psPtr->nextSeqPtr) {
- if ((numPats == psPtr->numPats)
- && ((flags & PAT_NEARBY) == (psPtr->flags & PAT_NEARBY))
- && (memcmp(patPtr, psPtr->pats, sequenceSize) == 0)) {
- goto done;
+ unsigned sequenceSize = numPats*sizeof(TkPattern);
+ PatSeq *psPtr2;
+
+ for (psPtr2 = (PatSeq *)Tcl_GetHashValue(hPtr); psPtr2; psPtr2 = psPtr2->nextSeqPtr) {
+ assert(TEST_PSENTRY(psPtr2));
+ if (numPats == psPtr2->numPats && memcmp(patPtr, psPtr2->pats, sequenceSize) == 0) {
+ ckfree(psPtr);
+ if (maskPtr) {
+ *maskPtr = eventMask;
+ }
+ return psPtr2;
}
}
}
@@ -3791,22 +4709,28 @@ FindSequence(
* silently ignore missing bindings.
*/
+ ckfree(psPtr);
return NULL;
}
- psPtr = ckalloc(sizeof(PatSeq) + (numPats-1)*sizeof(TkPattern));
+
+ DEBUG(countSeqItems += 1;)
+
psPtr->numPats = numPats;
+ psPtr->count = totalCount;
+ psPtr->number = lookupTables->number++;
+ psPtr->added = 0;
+ psPtr->modMaskUsed = (modMask != 0);
psPtr->script = NULL;
- psPtr->flags = flags;
- psPtr->nextSeqPtr = Tcl_GetHashValue(hPtr);
+ psPtr->nextSeqPtr = (PatSeq *)Tcl_GetHashValue(hPtr);
psPtr->hPtr = hPtr;
- psPtr->voPtr = NULL;
- psPtr->nextObjPtr = NULL;
+ psPtr->ptr.nextObj = NULL;
+ assert(psPtr->ptr.owners == NULL);
+ DEBUG(psPtr->owned = 0;)
Tcl_SetHashValue(hPtr, psPtr);
- memcpy(psPtr->pats, patPtr, sequenceSize);
-
- done:
- *maskPtr = eventMask;
+ if (maskPtr) {
+ *maskPtr = eventMask;
+ }
return psPtr;
}
@@ -3831,33 +4755,44 @@ FindSequence(
*---------------------------------------------------------------------------
*/
-static int
+/* helper function */
+static unsigned
+FinalizeParseEventDescription(
+ Tcl_Interp *interp,
+ TkPattern *patPtr,
+ unsigned count,
+ Tcl_Obj* errorObj,
+ const char* errCode)
+{
+ assert(patPtr);
+ assert(!errorObj == (count > 0));
+
+ if (errorObj) {
+ Tcl_SetObjResult(interp, errorObj);
+ Tcl_SetErrorCode(interp, "TK", "EVENT", errCode, NULL);
+ }
+ patPtr->count = count;
+ return count;
+}
+
+static unsigned
ParseEventDescription(
Tcl_Interp *interp, /* For error messages. */
- const char **eventStringPtr,/* On input, holds a pointer to start of event
- * string. On exit, gets pointer to rest of
- * string after parsed event. */
- TkPattern *patPtr, /* Filled with the pattern parsed from the
- * event string. */
- unsigned long *eventMaskPtr)/* Filled with event mask of matched event. */
+ const char **eventStringPtr,/* On input, holds a pointer to start of event string. On exit,
+ * gets pointer to rest of string after parsed event. */
+ TkPattern *patPtr, /* Filled with the pattern parsed from the event string. */
+ EventMask *eventMaskPtr) /* Filled with event mask of matched event. */
{
- char *p;
- unsigned long eventMask;
- int count, eventFlags;
-#define FIELD_SIZE 48
- char field[FIELD_SIZE];
- Tcl_HashEntry *hPtr;
- Tcl_DString copy;
-
- Tcl_DStringInit(&copy);
- p = Tcl_DStringAppend(&copy, *eventStringPtr, -1);
+ const char *p;
+ EventMask eventMask = 0;
+ unsigned count = 1;
- patPtr->eventType = -1;
- patPtr->needMods = 0;
- patPtr->detail.clientData = 0;
+ assert(eventStringPtr);
+ assert(patPtr);
+ assert(eventMaskPtr);
- eventMask = 0;
- count = 1;
+ p = *eventStringPtr;
+ memset(patPtr, 0, sizeof(TkPattern)); /* otherwise memcmp doesn't work */
/*
* Handle simple ASCII characters.
@@ -3869,200 +4804,214 @@ ParseEventDescription(
patPtr->eventType = KeyPress;
eventMask = KeyPressMask;
string[0] = *p;
- string[1] = 0;
- patPtr->detail.keySym = TkStringToKeysym(string);
- if (patPtr->detail.keySym == NoSymbol) {
- if (isprint(UCHAR(*p))) {
- patPtr->detail.keySym = *p;
- } else {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad ASCII character 0x%x", UCHAR(*p)));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "BAD_CHAR", NULL);
- count = 0;
- goto done;
+ string[1] = '\0';
+ patPtr->info = TkStringToKeysym(string);
+ if (patPtr->info == NoSymbol) {
+ if (!isprint(UCHAR(*p))) {
+ return FinalizeParseEventDescription(
+ interp,
+ patPtr, 0,
+ Tcl_ObjPrintf("bad ASCII character 0x%x", UCHAR(*p)), "BAD_CHAR");
}
+ patPtr->info = *p;
}
- p++;
- goto end;
- }
-
- /*
- * A fancier event description. This can be either a virtual event or a
- * physical event.
- *
- * A virtual event description consists of:
- *
- * 1. double open angle brackets.
- * 2. virtual event name.
- * 3. double close angle brackets.
- *
- * A physical event description consists of:
- *
- * 1. open angle bracket.
- * 2. any number of modifiers, each followed by spaces or dashes.
- * 3. an optional event name.
- * 4. an option button or keysym name. Either this or item 3 *must* be
- * present; if both are present then they are separated by spaces or
- * dashes.
- * 5. a close angle bracket.
- */
-
- p++;
- if (*p == '<') {
+ ++p;
+ } else {
/*
- * This is a virtual event: soak up all the characters up to the next
- * '>'.
+ * A fancier event description. This can be either a virtual event or a physical event.
+ *
+ * A virtual event description consists of:
+ *
+ * 1. double open angle brackets.
+ * 2. virtual event name.
+ * 3. double close angle brackets.
+ *
+ * A physical event description consists of:
+ *
+ * 1. open angle bracket.
+ * 2. any number of modifiers, each followed by spaces or dashes.
+ * 3. an optional event name.
+ * 4. an option button or keysym name. Either this or item 3 *must* be present; if both
+ * are present then they are separated by spaces or dashes.
+ * 5. a close angle bracket.
*/
- char *field = p + 1;
-
- p = strchr(field, '>');
- if (p == field) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "virtual event \"<<>>\" is badly formed", -1));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "MALFORMED",
- NULL);
- count = 0;
- goto done;
- }
- if ((p == NULL) || (p[1] != '>')) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "missing \">\" in virtual binding", -1));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "MALFORMED",
- NULL);
- count = 0;
- goto done;
- }
- *p = '\0';
- patPtr->eventType = VirtualEvent;
- eventMask = VirtualEventMask;
- patPtr->detail.name = Tk_GetUid(field);
- *p = '>';
-
- p += 2;
- goto end;
- }
-
- while (1) {
- ModInfo *modPtr;
-
- p = GetField(p, field, FIELD_SIZE);
- if (*p == '>') {
+ ++p;
+ if (*p == '<') {
/*
- * This solves the problem of, e.g., <Control-M> being
- * misinterpreted as Control + Meta + missing keysym instead of
- * Control + KeyPress + M.
+ * This is a virtual event: soak up all the characters up to the next '>'.
*/
- break;
- }
- hPtr = Tcl_FindHashEntry(&modTable, field);
- if (hPtr == NULL) {
- break;
- }
- modPtr = Tcl_GetHashValue(hPtr);
- patPtr->needMods |= modPtr->mask;
- if (modPtr->flags & MULT_CLICKS) {
- int i = modPtr->flags & MULT_CLICKS;
-
- count = 2;
- while (i >>= 1) {
- count++;
+ const char *field = p + 1;
+ char buf[256];
+ char* bufPtr = buf;
+ unsigned size;
+
+ p = strchr(field, '>');
+ if (p == field) {
+ return FinalizeParseEventDescription(
+ interp,
+ patPtr, 0,
+ Tcl_NewStringObj("virtual event \"<<>>\" is badly formed", -1), "MALFORMED");
+ }
+ if (!p || p[1] != '>') {
+ return FinalizeParseEventDescription(
+ interp,
+ patPtr, 0,
+ Tcl_NewStringObj("missing \">\" in virtual binding", -1), "MALFORMED");
}
- }
- while ((*p == '-') || isspace(UCHAR(*p))) {
- p++;
- }
- }
-
- eventFlags = 0;
- hPtr = Tcl_FindHashEntry(&eventTable, field);
- if (hPtr != NULL) {
- const EventInfo *eiPtr = Tcl_GetHashValue(hPtr);
- patPtr->eventType = eiPtr->type;
- eventFlags = flagArray[eiPtr->type];
- eventMask = eiPtr->eventMask;
- while ((*p == '-') || isspace(UCHAR(*p))) {
- p++;
- }
- p = GetField(p, field, FIELD_SIZE);
- }
- if (*field != '\0') {
- if ((*field >= '1') && (*field <= '9') && (field[1] == '\0')) {
- if (eventFlags == 0) {
- patPtr->eventType = ButtonPress;
- eventMask = ButtonPressMask;
- } else if (eventFlags & KEY) {
- goto getKeysym;
- } else if (!(eventFlags & BUTTON)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "specified button \"%s\" for non-button event",
- field));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "NON_BUTTON", NULL);
- count = 0;
- goto done;
+ size = p - field;
+ if (size >= sizeof(buf)) {
+ bufPtr = (char *)ckalloc(size + 1);
+ }
+ strncpy(bufPtr, field, size);
+ bufPtr[size] = '\0';
+ eventMask = VirtualEventMask;
+ patPtr->eventType = VirtualEvent;
+ patPtr->name = Tk_GetUid(bufPtr);
+ if (bufPtr != buf) {
+ ckfree(bufPtr);
}
- patPtr->detail.button = (*field - '0');
+ p += 2;
} else {
+ unsigned eventFlags;
+ char field[512];
+ Tcl_HashEntry *hPtr;
+
+ while (1) {
+ ModInfo *modPtr;
+
+ p = GetField(p, field, sizeof(field));
+ if (*p == '>') {
+ /*
+ * This solves the problem of, e.g., <Control-M> being
+ * misinterpreted as Control + Meta + missing keysym instead of
+ * Control + KeyPress + M.
+ */
- getKeysym:
- patPtr->detail.keySym = TkStringToKeysym(field);
- if (patPtr->detail.keySym == NoSymbol) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad event type or keysym \"%s\"", field));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYSYM", field,
- NULL);
- count = 0;
- goto done;
+ break;
+ }
+ if (!(hPtr = Tcl_FindHashEntry(&modTable, field))) {
+ break;
+ }
+ modPtr = (ModInfo *)Tcl_GetHashValue(hPtr);
+ patPtr->modMask |= modPtr->mask;
+ if (modPtr->flags & MULT_CLICKS) {
+ unsigned i = modPtr->flags & MULT_CLICKS;
+
+ count = 2;
+ while (i >>= 1) {
+ ++count;
+ }
+ }
+ p = SkipFieldDelims(p);
}
- if (eventFlags == 0) {
- patPtr->eventType = KeyPress;
- eventMask = KeyPressMask;
- } else if (!(eventFlags & KEY)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "specified keysym \"%s\" for non-key event", field));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "NON_KEY", NULL);
- count = 0;
- goto done;
+
+ eventFlags = 0;
+ if ((hPtr = Tcl_FindHashEntry(&eventTable, field))) {
+ const EventInfo *eiPtr = (const EventInfo *)Tcl_GetHashValue(hPtr);
+
+ patPtr->eventType = eiPtr->type;
+ eventFlags = flagArray[eiPtr->type];
+ eventMask = eiPtr->eventMask;
+ p = GetField(SkipFieldDelims(p), field, sizeof(field));
+ }
+ if (*field) {
+ unsigned button = GetButtonNumber(field);
+
+ if ((eventFlags & BUTTON)
+ || (button && eventFlags == 0)
+ || (SUPPORT_ADDITIONAL_MOTION_SYNTAX && (eventFlags & MOTION) && button == 0)) {
+ /* This must be a button (or bad motion) event */
+ if (button == 0) {
+ return FinalizeParseEventDescription(
+ interp,
+ patPtr, 0,
+ Tcl_ObjPrintf("bad button number \"%s\"", field), "BUTTON");
+ }
+ patPtr->info = button;
+ if (!(eventFlags & BUTTON)) {
+ patPtr->eventType = ButtonPress;
+ eventMask = ButtonPressMask;
+ }
+ } else if ((eventFlags & KEY) || eventFlags == 0) {
+ /* This must be a key event */
+ patPtr->info = TkStringToKeysym(field);
+ if (patPtr->info == NoSymbol) {
+ return FinalizeParseEventDescription(
+ interp,
+ patPtr, 0,
+ Tcl_ObjPrintf("bad event type or keysym \"%s\"", field), "KEYSYM");
+ }
+ if (!(eventFlags & KEY)) {
+ patPtr->eventType = KeyPress;
+ eventMask = KeyPressMask;
+ }
+ } else if (button) {
+ if (!SUPPORT_ADDITIONAL_MOTION_SYNTAX || patPtr->eventType != MotionNotify) {
+ return FinalizeParseEventDescription(
+ interp,
+ patPtr, 0,
+ Tcl_ObjPrintf("specified button \"%s\" for non-button event", field),
+ "NON_BUTTON");
+ }
+#if SUPPORT_ADDITIONAL_MOTION_SYNTAX
+ patPtr->modMask |= TkGetButtonMask(button);
+ p = SkipFieldDelims(p);
+ while (*p && *p != '>') {
+ p = SkipFieldDelims(GetField(p, field, sizeof(field)));
+ if ((button = GetButtonNumber(field)) == 0) {
+ return FinalizeParseEventDescription(
+ interp,
+ patPtr, 0,
+ Tcl_ObjPrintf("bad button number \"%s\"", field), "BUTTON");
+ }
+ patPtr->modMask |= TkGetButtonMask(button);
+ }
+ patPtr->info = ButtonNumberFromState(patPtr->modMask);
+#endif
+ } else {
+ return FinalizeParseEventDescription(
+ interp,
+ patPtr, 0,
+ Tcl_ObjPrintf("specified keysym \"%s\" for non-key event", field),
+ "NON_KEY");
+ }
+ } else if (eventFlags == 0) {
+ return FinalizeParseEventDescription(
+ interp,
+ patPtr, 0,
+ Tcl_NewStringObj("no event type or button # or keysym", -1), "UNMODIFIABLE");
+ } else if (patPtr->eventType == MotionNotify) {
+ patPtr->info = ButtonNumberFromState(patPtr->modMask);
}
- }
- } else if (eventFlags == 0) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "no event type or button # or keysym", -1));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "UNMODIFIABLE", NULL);
- count = 0;
- goto done;
- }
- while ((*p == '-') || isspace(UCHAR(*p))) {
- p++;
- }
- if (*p != '>') {
- while (*p != '\0') {
- p++;
- if (*p == '>') {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "extra characters after detail in binding", -1));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "PAST_DETAIL", NULL);
- count = 0;
- goto done;
+ p = SkipFieldDelims(p);
+
+ if (*p != '>') {
+ while (*p) {
+ ++p;
+ if (*p == '>') {
+ return FinalizeParseEventDescription(
+ interp,
+ patPtr, 0,
+ Tcl_NewStringObj("extra characters after detail in binding", -1),
+ "PAST_DETAIL");
+ }
+ }
+ return FinalizeParseEventDescription(
+ interp,
+ patPtr, 0,
+ Tcl_NewStringObj("missing \">\" in binding", -1), "MALFORMED");
}
+ ++p;
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "missing \">\" in binding", -1));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "MALFORMED", NULL);
- count = 0;
- goto done;
}
- p++;
- end:
- *eventStringPtr += (p - Tcl_DStringValue(&copy));
+ *eventStringPtr = p;
*eventMaskPtr |= eventMask;
- done:
- Tcl_DStringFree(&copy);
- return count;
+ return FinalizeParseEventDescription(interp, patPtr, count, NULL, NULL);
}
/*
@@ -4086,18 +5035,17 @@ ParseEventDescription(
*----------------------------------------------------------------------
*/
-static char *
+static const char *
GetField(
- char *p, /* Pointer to part of pattern. */
- char *copy, /* Place to copy field. */
- int size) /* Maximum number of characters to copy. */
+ const char *p, /* Pointer to part of pattern. */
+ char *copy, /* Place to copy field. */
+ unsigned size) /* Maximum number of characters to copy. */
{
- while ((*p != '\0') && !isspace(UCHAR(*p)) && (*p != '>')
- && (*p != '-') && (size > 1)) {
- *copy = *p;
- p++;
- copy++;
- size--;
+ assert(p);
+ assert(copy);
+
+ for ( ; *p && !isspace(UCHAR(*p)) && *p != '>' && *p != '-' && size > 1u; --size) {
+ *copy++ = *p++;
}
*copy = '\0';
return p;
@@ -4123,108 +5071,99 @@ GetField(
static Tcl_Obj *
GetPatternObj(
- PatSeq *psPtr)
+ const PatSeq *psPtr)
{
- TkPattern *patPtr;
- int patsLeft, needMods;
- const ModInfo *modPtr;
- const EventInfo *eiPtr;
Tcl_Obj *patternObj = Tcl_NewObj();
+ unsigned i;
- /*
- * The order of the patterns in the sequence is backwards from the order
- * in which they must be output.
- */
+ assert(psPtr);
+
+ for (i = 0; i < psPtr->numPats; ++i) {
+ const TkPattern *patPtr = psPtr->pats + i;
- for (patsLeft = psPtr->numPats, patPtr = &psPtr->pats[psPtr->numPats - 1];
- patsLeft > 0; patsLeft--, patPtr--) {
/*
* Check for simple case of an ASCII character.
*/
-
- if ((patPtr->eventType == KeyPress)
- && !(psPtr->flags & PAT_NEARBY)
- && (patPtr->needMods == 0)
- && (patPtr->detail.keySym < 128)
- && isprint(UCHAR(patPtr->detail.keySym))
- && (patPtr->detail.keySym != '<')
- && (patPtr->detail.keySym != ' ')) {
- char c = (char) patPtr->detail.keySym;
-
+ if (patPtr->eventType == KeyPress
+ && patPtr->count == 1
+ && patPtr->modMask == 0
+ && patPtr->info < 128
+ && isprint(UCHAR(patPtr->info))
+ && patPtr->info != '<'
+ && patPtr->info != ' ') {
+ char c = (char) patPtr->info;
Tcl_AppendToObj(patternObj, &c, 1);
- continue;
- }
-
- /*
- * Check for virtual event.
- */
+ } else if (patPtr->eventType == VirtualEvent) {
+ assert(patPtr->name);
+ Tcl_AppendPrintfToObj(patternObj, "<<%s>>", patPtr->name);
+ } else {
+ ModMask modMask;
+ const ModInfo *modPtr;
- if (patPtr->eventType == VirtualEvent) {
- Tcl_AppendPrintfToObj(patternObj, "<<%s>>", patPtr->detail.name);
- continue;
- }
+ /*
+ * It's a more general event specification. First check for "Double",
+ * "Triple", "Quadruple", then modifiers, then event type, then keysym
+ * or button detail.
+ */
- /*
- * It's a more general event specification. First check for "Double",
- * "Triple", "Quadruple", then modifiers, then event type, then keysym
- * or button detail.
- */
+ Tcl_AppendToObj(patternObj, "<", 1);
- Tcl_AppendToObj(patternObj, "<", 1);
-
- if ((psPtr->flags & PAT_NEARBY) && (patsLeft > 1)
- && (memcmp(patPtr, patPtr-1, sizeof(TkPattern)) == 0)) {
- patsLeft--;
- patPtr--;
- if ((patsLeft > 1) &&
- (memcmp(patPtr, patPtr-1, sizeof(TkPattern)) == 0)) {
- patsLeft--;
- patPtr--;
- if ((patsLeft > 1) &&
- (memcmp(patPtr, patPtr-1, sizeof(TkPattern)) == 0)) {
- patsLeft--;
- patPtr--;
- Tcl_AppendToObj(patternObj, "Quadruple-", 10);
- } else {
- Tcl_AppendToObj(patternObj, "Triple-", 7);
- }
- } else {
- Tcl_AppendToObj(patternObj, "Double-", 7);
+ switch (patPtr->count) {
+ case 2: Tcl_AppendToObj(patternObj, "Double-", 7); break;
+ case 3: Tcl_AppendToObj(patternObj, "Triple-", 7); break;
+ case 4: Tcl_AppendToObj(patternObj, "Quadruple-", 10); break;
}
- }
- for (needMods = patPtr->needMods, modPtr = modArray;
- needMods != 0; modPtr++) {
- if (modPtr->mask & needMods) {
- needMods &= ~modPtr->mask;
- Tcl_AppendPrintfToObj(patternObj, "%s-", modPtr->name);
+ modMask = patPtr->modMask;
+#if PRINT_SHORT_MOTION_SYNTAX
+ if (patPtr->eventType == MotionNotify) {
+ modMask &= ~(ModMask)ALL_BUTTONS;
}
- }
+#endif
- for (eiPtr = eventArray; eiPtr->name != NULL; eiPtr++) {
- if (eiPtr->type == patPtr->eventType) {
- Tcl_AppendToObj(patternObj, eiPtr->name, -1);
- if (patPtr->detail.clientData != 0) {
- Tcl_AppendToObj(patternObj, "-", 1);
+ for (modPtr = modArray; modMask; ++modPtr) {
+ if (modPtr->mask & modMask) {
+ modMask &= ~modPtr->mask;
+ Tcl_AppendPrintfToObj(patternObj, "%s-", modPtr->name);
}
- break;
}
- }
- if (patPtr->detail.clientData != 0) {
- if ((patPtr->eventType == KeyPress)
- || (patPtr->eventType == KeyRelease)) {
- const char *string = TkKeysymToString(patPtr->detail.keySym);
-
- if (string != NULL) {
- Tcl_AppendToObj(patternObj, string, -1);
+ assert(patPtr->eventType < TK_LASTEVENT);
+ assert(((size_t) eventArrayIndex[patPtr->eventType]) < SIZE_OF_ARRAY(eventArray));
+ Tcl_AppendToObj(patternObj, eventArray[eventArrayIndex[patPtr->eventType]].name, -1);
+
+ if (patPtr->info) {
+ switch (patPtr->eventType) {
+ case KeyPress:
+ case KeyRelease: {
+ const char *string = TkKeysymToString(patPtr->info);
+ if (string) {
+ Tcl_AppendToObj(patternObj, "-", 1);
+ Tcl_AppendToObj(patternObj, string, -1);
+ }
+ break;
+ }
+ case ButtonPress:
+ case ButtonRelease:
+ assert(patPtr->info <= Button9);
+ Tcl_AppendPrintfToObj(patternObj, "-%d", (int) patPtr->info);
+ break;
+#if PRINT_SHORT_MOTION_SYNTAX
+ case MotionNotify: {
+ ModMask mask = patPtr->modMask;
+ while (mask & ALL_BUTTONS) {
+ int button = ButtonNumberFromState(mask);
+ Tcl_AppendPrintfToObj(patternObj, "-%d", button);
+ mask &= ~TkGetButtonMask(button);
+ }
+ break;
+ }
+#endif
}
- } else {
- Tcl_AppendPrintfToObj(patternObj, "%d", patPtr->detail.button);
}
- }
- Tcl_AppendToObj(patternObj, ">", 1);
+ Tcl_AppendToObj(patternObj, ">", 1);
+ }
}
return patternObj;
@@ -4254,17 +5193,19 @@ TkStringToKeysym(
#ifdef REDO_KEYSYM_LOOKUP
Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&keySymTable, name);
- if (hPtr != NULL) {
+ if (hPtr) {
return (KeySym) Tcl_GetHashValue(hPtr);
}
- if (strlen(name) == 1) {
+ assert(name);
+ if (strlen(name) == 1u) {
KeySym keysym = (KeySym) (unsigned char) name[0];
- if (TkKeysymToString(keysym) != NULL) {
+ if (TkKeysymToString(keysym)) {
return keysym;
}
}
#endif /* REDO_KEYSYM_LOOKUP */
+ assert(name);
return XStringToKeysym(name);
}
@@ -4290,13 +5231,16 @@ TkKeysymToString(
KeySym keysym)
{
#ifdef REDO_KEYSYM_LOOKUP
- Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&nameTable, keysym);
+ Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&nameTable, (char *)keysym);
- if (hPtr != NULL) {
- return Tcl_GetHashValue(hPtr);
+ if (hPtr) {
+ return (const char *)Tcl_GetHashValue(hPtr);
}
#endif /* REDO_KEYSYM_LOOKUP */
+ if (keysym > (KeySym)0x1008FFFF) {
+ return NULL;
+ }
return XKeysymToString(keysym);
}
@@ -4323,10 +5267,10 @@ XEvent *
TkpGetBindingXEvent(
Tcl_Interp *interp) /* Interpreter. */
{
- TkWindow *winPtr = (TkWindow *) Tk_MainWindow(interp);
- BindingTable *bindPtr = winPtr->mainPtr->bindingTable;
+ TkWindow *winPtr = (TkWindow *) Tk_MainWindow(interp);
+ BindingTable *bindPtr = winPtr->mainPtr->bindingTable;
- return &(bindPtr->eventRing[bindPtr->curEvent]);
+ return &bindPtr->curEvent->xev;
}
/*
@@ -4350,6 +5294,8 @@ void
TkpCancelWarp(
TkDisplay *dispPtr)
{
+ assert(dispPtr);
+
if (dispPtr->flags & TK_DISPLAY_IN_WARP) {
Tcl_CancelIdleCall(DoWarp, dispPtr);
dispPtr->flags &= ~TK_DISPLAY_IN_WARP;
@@ -4357,9 +5303,81 @@ TkpCancelWarp(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * TkpDumpPS --
+ *
+ * Dump given pattern sequence to stdout.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+#if SUPPORT_DEBUGGING
+void
+TkpDumpPS(
+ const PatSeq *psPtr)
+{
+ if (!psPtr) {
+ fprintf(stdout, "<null>\n");
+ } else {
+ Tcl_Obj* result = GetPatternObj(psPtr);
+ Tcl_IncrRefCount(result);
+ fprintf(stdout, "%s", Tcl_GetString(result));
+ if (psPtr->object) {
+ fprintf(stdout, " (%s)", (char *) psPtr->object);
+ }
+ fprintf(stdout, "\n");
+ Tcl_DecrRefCount(result);
+ }
+}
+#endif
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpDumpPSList --
+ *
+ * Dump given pattern sequence list to stdout.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+#if SUPPORT_DEBUGGING
+void
+TkpDumpPSList(
+ const PSList *psList)
+{
+ if (!psList) {
+ fprintf(stdout, "<null>\n");
+ } else {
+ const PSEntry *psEntry;
+
+ fprintf(stdout, "Dump PSList ========================================\n");
+ TK_DLIST_FOREACH(psEntry, psList) {
+ TkpDumpPS(psEntry->psPtr);
+ }
+ fprintf(stdout, "====================================================\n");
+ }
+}
+#endif
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
- * fill-column: 78
+ * fill-column: 105
* End:
+ * vi:set ts=8 sw=4:
*/
diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c
index 0ab922b..36fb382 100644
--- a/generic/tkBitmap.c
+++ b/generic/tkBitmap.c
@@ -88,7 +88,7 @@ typedef struct {
int width, height; /* Dimensions of bitmap. */
} DataKey;
-typedef struct ThreadSpecificData {
+typedef struct {
int initialized; /* 0 means table below needs initializing. */
Tcl_HashTable predefBitmapTable;
/* Hash table created by Tk_DefineBitmap to
@@ -167,7 +167,7 @@ Tk_AllocBitmapFromObj(
if (objPtr->typePtr != &tkBitmapObjType) {
InitBitmapObj(objPtr);
}
- bitmapPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ bitmapPtr = (TkBitmap *)objPtr->internalRep.twoPtrValue.ptr1;
/*
* If the object currently points to a TkBitmap, see if it's the one we
@@ -197,7 +197,7 @@ Tk_AllocBitmapFromObj(
*/
if (bitmapPtr != NULL) {
- TkBitmap *firstBitmapPtr = Tcl_GetHashValue(bitmapPtr->nameHashPtr);
+ TkBitmap *firstBitmapPtr = (TkBitmap *)Tcl_GetHashValue(bitmapPtr->nameHashPtr);
FreeBitmapObj(objPtr);
for (bitmapPtr = firstBitmapPtr; bitmapPtr != NULL;
@@ -307,7 +307,7 @@ GetBitmap(
Pixmap bitmap;
int isNew, width = 0, height = 0, dummy2;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!dispPtr->bitmapInit) {
@@ -317,7 +317,7 @@ GetBitmap(
nameHashPtr = Tcl_CreateHashEntry(&dispPtr->bitmapNameTable, string,
&isNew);
if (!isNew) {
- existingBitmapPtr = Tcl_GetHashValue(nameHashPtr);
+ existingBitmapPtr = (TkBitmap *)Tcl_GetHashValue(nameHashPtr);
for (bitmapPtr = existingBitmapPtr; bitmapPtr != NULL;
bitmapPtr = bitmapPtr->nextPtr) {
if ((Tk_Display(tkwin) == bitmapPtr->display) &&
@@ -395,7 +395,7 @@ GetBitmap(
goto error;
}
} else {
- predefPtr = Tcl_GetHashValue(predefHashPtr);
+ predefPtr = (TkPredefBitmap *)Tcl_GetHashValue(predefHashPtr);
width = predefPtr->width;
height = predefPtr->height;
if (predefPtr->native) {
@@ -407,7 +407,7 @@ GetBitmap(
} else {
bitmap = XCreateBitmapFromData(Tk_Display(tkwin),
RootWindowOfScreen(Tk_Screen(tkwin)),
- predefPtr->source, (unsigned)width, (unsigned)height);
+ (const char *)predefPtr->source, (unsigned)width, (unsigned)height);
}
}
}
@@ -416,7 +416,7 @@ GetBitmap(
* Add information about this bitmap to our database.
*/
- bitmapPtr = ckalloc(sizeof(TkBitmap));
+ bitmapPtr = (TkBitmap *)ckalloc(sizeof(TkBitmap));
bitmapPtr->bitmap = bitmap;
bitmapPtr->width = width;
bitmapPtr->height = height;
@@ -474,7 +474,7 @@ Tk_DefineBitmap(
int isNew;
Tcl_HashEntry *predefHashPtr;
TkPredefBitmap *predefPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -497,7 +497,7 @@ Tk_DefineBitmap(
Tcl_SetErrorCode(interp, "TK", "BITMAP", "EXISTS", NULL);
return TCL_ERROR;
}
- predefPtr = ckalloc(sizeof(TkPredefBitmap));
+ predefPtr = (TkPredefBitmap *)ckalloc(sizeof(TkPredefBitmap));
predefPtr->source = source;
predefPtr->width = width;
predefPtr->height = height;
@@ -540,7 +540,7 @@ Tk_NameOfBitmap(
if (idHashPtr == NULL) {
goto unknown;
}
- bitmapPtr = Tcl_GetHashValue(idHashPtr);
+ bitmapPtr = (TkBitmap *)Tcl_GetHashValue(idHashPtr);
return bitmapPtr->nameHashPtr->key.string;
}
@@ -582,7 +582,7 @@ Tk_SizeOfBitmap(
if (idHashPtr == NULL) {
goto unknownBitmap;
}
- bitmapPtr = Tcl_GetHashValue(idHashPtr);
+ bitmapPtr = (TkBitmap *)Tcl_GetHashValue(idHashPtr);
*widthPtr = bitmapPtr->width;
*heightPtr = bitmapPtr->height;
}
@@ -612,14 +612,13 @@ FreeBitmap(
{
TkBitmap *prevPtr;
- bitmapPtr->resourceRefCount--;
- if (bitmapPtr->resourceRefCount > 0) {
+ if (bitmapPtr->resourceRefCount-- > 1) {
return;
}
Tk_FreePixmap(bitmapPtr->display, bitmapPtr->bitmap);
Tcl_DeleteHashEntry(bitmapPtr->idHashPtr);
- prevPtr = Tcl_GetHashValue(bitmapPtr->nameHashPtr);
+ prevPtr = (TkBitmap *)Tcl_GetHashValue(bitmapPtr->nameHashPtr);
if (prevPtr == bitmapPtr) {
if (bitmapPtr->nextPtr == NULL) {
Tcl_DeleteHashEntry(bitmapPtr->nameHashPtr);
@@ -671,7 +670,7 @@ Tk_FreeBitmap(
if (idHashPtr == NULL) {
Tcl_Panic("Tk_FreeBitmap received unknown bitmap argument");
}
- FreeBitmap(Tcl_GetHashValue(idHashPtr));
+ FreeBitmap((TkBitmap *)Tcl_GetHashValue(idHashPtr));
}
/*
@@ -735,7 +734,7 @@ static void
FreeBitmapObj(
Tcl_Obj *objPtr) /* The object we are releasing. */
{
- TkBitmap *bitmapPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ TkBitmap *bitmapPtr = (TkBitmap *)objPtr->internalRep.twoPtrValue.ptr1;
if (bitmapPtr != NULL) {
bitmapPtr->objRefCount--;
@@ -770,7 +769,7 @@ DupBitmapObjProc(
Tcl_Obj *srcObjPtr, /* The object we are copying from. */
Tcl_Obj *dupObjPtr) /* The object we are copying to. */
{
- TkBitmap *bitmapPtr = srcObjPtr->internalRep.twoPtrValue.ptr1;
+ TkBitmap *bitmapPtr = (TkBitmap *)srcObjPtr->internalRep.twoPtrValue.ptr1;
dupObjPtr->typePtr = srcObjPtr->typePtr;
dupObjPtr->internalRep.twoPtrValue.ptr1 = bitmapPtr;
@@ -806,7 +805,6 @@ DupBitmapObjProc(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
Pixmap
Tk_GetBitmapFromData(
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
@@ -820,20 +818,20 @@ Tk_GetBitmapFromData(
char string[16 + TCL_INTEGER_SPACE];
char *name;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
BitmapInit(dispPtr);
}
- nameKey.source = source;
+ nameKey.source = (const char *)source;
nameKey.width = width;
nameKey.height = height;
dataHashPtr = Tcl_CreateHashEntry(&dispPtr->bitmapDataTable,
(char *) &nameKey, &isNew);
if (!isNew) {
- name = Tcl_GetHashValue(dataHashPtr);
+ name = (char *)Tcl_GetHashValue(dataHashPtr);
} else {
dispPtr->bitmapAutoNumber++;
sprintf(string, "_tk%d", dispPtr->bitmapAutoNumber);
@@ -911,7 +909,7 @@ GetBitmapFromObj(
InitBitmapObj(objPtr);
}
- bitmapPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ bitmapPtr = (TkBitmap *)objPtr->internalRep.twoPtrValue.ptr1;
if (bitmapPtr != NULL) {
if ((bitmapPtr->resourceRefCount > 0)
&& (Tk_Display(tkwin) == bitmapPtr->display)) {
@@ -932,7 +930,7 @@ GetBitmapFromObj(
* more TkBitmap structures. See if any of them will work.
*/
- for (bitmapPtr = Tcl_GetHashValue(hashPtr); bitmapPtr != NULL;
+ for (bitmapPtr = (TkBitmap *)Tcl_GetHashValue(hashPtr); bitmapPtr != NULL;
bitmapPtr = bitmapPtr->nextPtr) {
if (Tk_Display(tkwin) == bitmapPtr->display) {
objPtr->internalRep.twoPtrValue.ptr1 = bitmapPtr;
@@ -1012,7 +1010,7 @@ BitmapInit(
* or NULL if unavailable. */
{
Tcl_Interp *dummy;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -1150,7 +1148,7 @@ TkDebugBitmap(
resultPtr = Tcl_NewObj();
hashPtr = Tcl_FindHashEntry(&dispPtr->bitmapNameTable, name);
if (hashPtr != NULL) {
- bitmapPtr = Tcl_GetHashValue(hashPtr);
+ bitmapPtr = (TkBitmap *)Tcl_GetHashValue(hashPtr);
if (bitmapPtr == NULL) {
Tcl_Panic("TkDebugBitmap found empty hash table entry");
}
@@ -1190,7 +1188,7 @@ TkDebugBitmap(
Tcl_HashTable *
TkGetBitmapPredefTable(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
return &tsdPtr->predefBitmapTable;
diff --git a/generic/tkBusy.c b/generic/tkBusy.c
index 4dee047..5014eeb 100644
--- a/generic/tkBusy.c
+++ b/generic/tkBusy.c
@@ -23,7 +23,7 @@
static const Tk_OptionSpec busyOptionSpecs[] = {
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUSY_CURSOR, -1, Tk_Offset(Busy, cursor),
+ DEF_BUSY_CURSOR, TCL_INDEX_NONE, offsetof(Busy, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -54,7 +54,7 @@ static void MakeTransparentWindowExist(Tk_Window tkwin,
Window parent);
static inline Tk_Window NextChild(Tk_Window tkwin);
static void RefWinEventProc(ClientData clientData,
- register XEvent *eventPtr);
+ XEvent *eventPtr);
static inline void SetWindowInstanceData(Tk_Window tkwin,
ClientData instanceData);
@@ -122,13 +122,13 @@ SetWindowInstanceData(
*----------------------------------------------------------------------
*/
-/* ARGSUSED */
static void
BusyCustodyProc(
ClientData clientData, /* Information about the busy window. */
Tk_Window tkwin) /* Not used. */
{
- Busy *busyPtr = clientData;
+ Busy *busyPtr = (Busy *)clientData;
+ (void)tkwin;
Tk_DeleteEventHandler(busyPtr->tkBusy, StructureNotifyMask, BusyEventProc,
busyPtr);
@@ -156,14 +156,16 @@ BusyCustodyProc(
*----------------------------------------------------------------------
*/
-/* ARGSUSED */
static void
BusyGeometryProc(
- ClientData clientData, /* Information about window that got new
+ ClientData dummy, /* Information about window that got new
* preferred geometry. */
Tk_Window tkwin) /* Other Tk-related information about the
* window. */
{
+ (void)dummy;
+ (void)tkwin;
+
/* Should never get here */
}
@@ -249,9 +251,9 @@ DoConfigureNotify(
static void
RefWinEventProc(
ClientData clientData, /* Busy window record */
- register XEvent *eventPtr) /* Event which triggered call to routine */
+ XEvent *eventPtr) /* Event which triggered call to routine */
{
- register Busy *busyPtr = clientData;
+ Busy *busyPtr = (Busy *)clientData;
switch (eventPtr->type) {
case ReparentNotify:
@@ -333,7 +335,7 @@ static void
DestroyBusy(
void *data) /* Busy window structure record */
{
- register Busy *busyPtr = data;
+ Busy *busyPtr = (Busy *)data;
if (busyPtr->hashPtr != NULL) {
Tcl_DeleteHashEntry(busyPtr->hashPtr);
@@ -377,7 +379,7 @@ BusyEventProc(
ClientData clientData, /* Busy window record */
XEvent *eventPtr) /* Event which triggered call to routine */
{
- Busy *busyPtr = clientData;
+ Busy *busyPtr = (Busy *)clientData;
if (eventPtr->type == DestroyNotify) {
busyPtr->tkBusy = NULL;
@@ -527,10 +529,10 @@ CreateBusy(
Window parent;
Tk_FakeWin *winPtr;
- busyPtr = ckalloc(sizeof(Busy));
+ busyPtr = (Busy *)ckalloc(sizeof(Busy));
x = y = 0;
length = strlen(Tk_Name(tkRef));
- name = ckalloc(length + 6);
+ name = (char *)ckalloc(length + 6);
if (Tk_IsTopLevel(tkRef)) {
fmt = "_Busy"; /* Child */
tkParent = tkRef;
@@ -696,7 +698,7 @@ GetBusy(
Tcl_GetString(windowObj), NULL);
return NULL;
}
- return Tcl_GetHashValue(hPtr);
+ return (Busy *)Tcl_GetHashValue(hPtr);
}
/*
@@ -746,7 +748,7 @@ HoldBusy(
Tcl_SetHashValue(hPtr, busyPtr);
busyPtr->hashPtr = hPtr;
} else {
- busyPtr = Tcl_GetHashValue(hPtr);
+ busyPtr = (Busy *)Tcl_GetHashValue(hPtr);
}
busyPtr->tablePtr = busyTablePtr;
@@ -792,7 +794,7 @@ Tk_BusyObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
Tcl_HashTable *busyTablePtr = &((TkWindow *) tkwin)->mainPtr->busyTable;
Busy *busyPtr;
Tcl_Obj *objPtr;
@@ -894,9 +896,9 @@ Tk_BusyObjCmd(
objPtr = Tcl_NewObj();
for (hPtr = Tcl_FirstHashEntry(busyTablePtr, &cursor); hPtr != NULL;
hPtr = Tcl_NextHashEntry(&cursor)) {
- busyPtr = Tcl_GetHashValue(hPtr);
+ busyPtr = (Busy *)Tcl_GetHashValue(hPtr);
if (pattern == NULL ||
- Tcl_StringMatch(Tk_PathName(busyPtr->tkRef), pattern)) {
+ Tcl_StringCaseMatch(Tk_PathName(busyPtr->tkRef), pattern, 0)) {
Tcl_ListObjAppendElement(interp, objPtr,
TkNewWindowObj(busyPtr->tkRef));
}
diff --git a/generic/tkButton.c b/generic/tkButton.c
index e05fbe2..8056f31 100644
--- a/generic/tkButton.c
+++ b/generic/tkButton.c
@@ -16,7 +16,7 @@
#include "tkButton.h"
#include "default.h"
-typedef struct ThreadSpecificData {
+typedef struct {
int defaultsInitialized;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -70,413 +70,413 @@ char tkDefLabelPady[TCL_INTEGER_SPACE] = DEF_LABCHKRAD_PADY;
static const Tk_OptionSpec labelOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_BUTTON_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg),
+ DEF_BUTTON_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeFg),
TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0},
+ DEF_BUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkButton, anchor), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, normalBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
+ DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
- Tk_Offset(TkButton, borderWidth), 0, 0, 0},
+ tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
+ offsetof(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0,
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0,
compoundStrings, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
(ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0},
+ DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_BUTTON_FG, -1, Tk_Offset(TkButton, normalFg), 0, 0, 0},
+ DEF_BUTTON_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightPtr), -1, 0, 0, 0},
+ DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkButton, highlightBorder), 0,
+ TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
(ClientData) DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
+ DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", tkDefLabelHighlightWidth,
- Tk_Offset(TkButton, highlightWidthPtr),
- Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
+ offsetof(TkButton, highlightWidthPtr),
+ offsetof(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
+ DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), 0, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- tkDefLabelPadx, Tk_Offset(TkButton, padXPtr),
- Tk_Offset(TkButton, padX), 0, 0, 0},
+ tkDefLabelPadx, offsetof(TkButton, padXPtr),
+ offsetof(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- tkDefLabelPady, Tk_Offset(TkButton, padYPtr),
- Tk_Offset(TkButton, padY), 0, 0, 0},
+ tkDefLabelPady, offsetof(TkButton, padYPtr),
+ offsetof(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
+ DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_LABEL_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
+ DEF_LABEL_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, textPtr), -1, 0, 0, 0},
+ DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarNamePtr), -1,
+ DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, -1, Tk_Offset(TkButton, underline), 0, 0, 0},
+ DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthPtr), -1, 0, 0, 0},
+ DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr),
- Tk_Offset(TkButton, wrapLength), 0, 0, 0},
+ DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
+ offsetof(TkButton, wrapLength), 0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
static const Tk_OptionSpec buttonOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_BUTTON_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg),
+ DEF_BUTTON_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeFg),
TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0},
+ DEF_BUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkButton, anchor), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, normalBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
+ DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
- Tk_Offset(TkButton, borderWidth), 0, 0, 0},
+ tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
+ offsetof(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1,
+ DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0,
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0,
compoundStrings, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-default", "default", "Default",
- DEF_BUTTON_DEFAULT, -1, Tk_Offset(TkButton, defaultState),
+ DEF_BUTTON_DEFAULT, TCL_INDEX_NONE, offsetof(TkButton, defaultState),
0, defaultStrings, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
(ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0},
+ DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_BUTTON_FG, -1, Tk_Offset(TkButton, normalFg), 0, 0, 0},
+ DEF_BUTTON_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightPtr), -1, 0, 0, 0},
+ DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkButton, highlightBorder), 0,
+ TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
(ClientData) DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
+ DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", tkDefButtonHighlightWidth,
- Tk_Offset(TkButton, highlightWidthPtr),
- Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
+ offsetof(TkButton, highlightWidthPtr),
+ offsetof(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
+ DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), 0, 0, 0},
{TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief",
- DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief),
+ DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- tkDefButtonPadx, Tk_Offset(TkButton, padXPtr),
- Tk_Offset(TkButton, padX), 0, 0, 0},
+ tkDefButtonPadx, offsetof(TkButton, padXPtr),
+ offsetof(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- tkDefButtonPady, Tk_Offset(TkButton, padYPtr),
- Tk_Offset(TkButton, padY), 0, 0, 0},
+ tkDefButtonPady, offsetof(TkButton, padYPtr),
+ offsetof(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, relief),
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief),
0, 0, 0},
{TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_BUTTON_REPEAT_DELAY, -1, Tk_Offset(TkButton, repeatDelay),
+ DEF_BUTTON_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(TkButton, repeatDelay),
0, 0, 0},
{TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_BUTTON_REPEAT_INTERVAL, -1, Tk_Offset(TkButton, repeatInterval),
+ DEF_BUTTON_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(TkButton, repeatInterval),
0, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
+ DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, textPtr), -1, 0, 0, 0},
+ DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarNamePtr), -1,
+ DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, -1, Tk_Offset(TkButton, underline), 0, 0, 0},
+ DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthPtr), -1, 0, 0, 0},
+ DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr),
- Tk_Offset(TkButton, wrapLength), 0, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
+ offsetof(TkButton, wrapLength), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
static const Tk_OptionSpec checkbuttonOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_CHKRAD_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg),
+ DEF_CHKRAD_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeFg),
TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0},
+ DEF_BUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkButton, anchor), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, normalBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
+ DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
- Tk_Offset(TkButton, borderWidth), 0, 0, 0},
+ tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
+ offsetof(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1,
+ DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0,
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0,
compoundStrings, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
(ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0},
+ DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_CHKRAD_FG, -1, Tk_Offset(TkButton, normalFg), 0, 0, 0},
+ DEF_CHKRAD_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightPtr), -1, 0, 0, 0},
+ DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkButton, highlightBorder), 0,
+ TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
(ClientData) DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
+ DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", tkDefButtonHighlightWidth,
- Tk_Offset(TkButton, highlightWidthPtr),
- Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
+ offsetof(TkButton, highlightWidthPtr),
+ offsetof(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
- DEF_BUTTON_INDICATOR, -1, Tk_Offset(TkButton, indicatorOn), 0, 0, 0},
+ DEF_BUTTON_INDICATOR, TCL_INDEX_NONE, offsetof(TkButton, indicatorOn), 0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
+ DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), 0, 0, 0},
{TK_OPTION_RELIEF, "-offrelief", "offRelief", "OffRelief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, offRelief), 0, 0, 0},
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, offRelief), 0, 0, 0},
{TK_OPTION_STRING, "-offvalue", "offValue", "Value",
- DEF_BUTTON_OFF_VALUE, Tk_Offset(TkButton, offValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_OFF_VALUE, offsetof(TkButton, offValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-onvalue", "onValue", "Value",
- DEF_BUTTON_ON_VALUE, Tk_Offset(TkButton, onValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_ON_VALUE, offsetof(TkButton, onValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief",
- DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief),
+ DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- tkDefLabelPadx, Tk_Offset(TkButton, padXPtr),
- Tk_Offset(TkButton, padX), 0, 0, 0},
+ tkDefLabelPadx, offsetof(TkButton, padXPtr),
+ offsetof(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- tkDefLabelPady, Tk_Offset(TkButton, padYPtr),
- Tk_Offset(TkButton, padY), 0, 0, 0},
+ tkDefLabelPady, offsetof(TkButton, padYPtr),
+ offsetof(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
+ DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background",
- DEF_BUTTON_SELECT_COLOR, -1, Tk_Offset(TkButton, selectBorder),
+ DEF_BUTTON_SELECT_COLOR, TCL_INDEX_NONE, offsetof(TkButton, selectBorder),
TK_OPTION_NULL_OK, DEF_BUTTON_SELECT_MONO, 0},
{TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage",
- DEF_BUTTON_SELECT_IMAGE, Tk_Offset(TkButton, selectImagePtr), -1,
+ DEF_BUTTON_SELECT_IMAGE, offsetof(TkButton, selectImagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
+ DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, textPtr), -1, 0, 0, 0},
+ DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarNamePtr), -1,
+ DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-tristateimage", "tristateImage", "TristateImage",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, tristateImagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, tristateImagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-tristatevalue", "tristateValue", "TristateValue",
- DEF_BUTTON_TRISTATE_VALUE, Tk_Offset(TkButton, tristateValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_TRISTATE_VALUE, offsetof(TkButton, tristateValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, -1, Tk_Offset(TkButton, underline), 0, 0, 0},
+ DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0},
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- DEF_CHECKBUTTON_VARIABLE, Tk_Offset(TkButton, selVarNamePtr), -1,
+ DEF_CHECKBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthPtr), -1, 0, 0, 0},
+ DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr),
- Tk_Offset(TkButton, wrapLength), 0, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
+ offsetof(TkButton, wrapLength), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
static const Tk_OptionSpec radiobuttonOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_CHKRAD_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg),
+ DEF_CHKRAD_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeFg),
TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0},
+ DEF_BUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkButton, anchor), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, normalBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
+ DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
- Tk_Offset(TkButton, borderWidth), 0, 0, 0},
+ tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
+ offsetof(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1,
+ DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0,
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0,
compoundStrings, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
(ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0},
+ DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_CHKRAD_FG, -1, Tk_Offset(TkButton, normalFg), 0, 0, 0},
+ DEF_CHKRAD_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightPtr), -1, 0, 0, 0},
+ DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkButton, highlightBorder), 0,
+ TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
(ClientData) DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
+ DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", tkDefButtonHighlightWidth,
- Tk_Offset(TkButton, highlightWidthPtr),
- Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
+ offsetof(TkButton, highlightWidthPtr),
+ offsetof(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
- DEF_BUTTON_INDICATOR, -1, Tk_Offset(TkButton, indicatorOn),
+ DEF_BUTTON_INDICATOR, TCL_INDEX_NONE, offsetof(TkButton, indicatorOn),
0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
+ DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), 0, 0, 0},
{TK_OPTION_RELIEF, "-offrelief", "offRelief", "OffRelief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, offRelief), 0, 0, 0},
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, offRelief), 0, 0, 0},
{TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief",
- DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief),
+ DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- tkDefLabelPadx, Tk_Offset(TkButton, padXPtr),
- Tk_Offset(TkButton, padX), 0, 0, 0},
+ tkDefLabelPadx, offsetof(TkButton, padXPtr),
+ offsetof(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- tkDefLabelPady, Tk_Offset(TkButton, padYPtr),
- Tk_Offset(TkButton, padY), 0, 0, 0},
+ tkDefLabelPady, offsetof(TkButton, padYPtr),
+ offsetof(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
+ DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background",
- DEF_BUTTON_SELECT_COLOR, -1, Tk_Offset(TkButton, selectBorder),
+ DEF_BUTTON_SELECT_COLOR, TCL_INDEX_NONE, offsetof(TkButton, selectBorder),
TK_OPTION_NULL_OK, DEF_BUTTON_SELECT_MONO, 0},
{TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage",
- DEF_BUTTON_SELECT_IMAGE, Tk_Offset(TkButton, selectImagePtr), -1,
+ DEF_BUTTON_SELECT_IMAGE, offsetof(TkButton, selectImagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
+ DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, textPtr), -1, 0, 0, 0},
+ DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarNamePtr), -1,
+ DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-tristateimage", "tristateImage", "TristateImage",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, tristateImagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, tristateImagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-tristatevalue", "tristateValue", "TristateValue",
- DEF_BUTTON_TRISTATE_VALUE, Tk_Offset(TkButton, tristateValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_TRISTATE_VALUE, offsetof(TkButton, tristateValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, -1, Tk_Offset(TkButton, underline), 0, 0, 0},
+ DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0},
{TK_OPTION_STRING, "-value", "value", "Value",
- DEF_BUTTON_VALUE, Tk_Offset(TkButton, onValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_VALUE, offsetof(TkButton, onValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- DEF_RADIOBUTTON_VARIABLE, Tk_Offset(TkButton, selVarNamePtr), -1,
+ DEF_RADIOBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE,
0, 0, 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthPtr), -1, 0, 0, 0},
+ DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr),
- Tk_Offset(TkButton, wrapLength), 0, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
+ offsetof(TkButton, wrapLength), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -628,7 +628,7 @@ Tk_RadiobuttonObjCmd(
static int
ButtonCreate(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument values. */
@@ -639,8 +639,9 @@ ButtonCreate(
TkButton *butPtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
if (!tsdPtr->defaultsInitialized) {
TkpButtonSetDefaults();
@@ -788,7 +789,7 @@ ButtonWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
- TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
int index;
int result;
Tcl_Obj *objPtr;
@@ -878,7 +879,7 @@ ButtonWidgetObjCmd(
*/
Tcl_CancelIdleCall(TkpDisplayButton, butPtr);
- XFlush(butPtr->display);
+ (void)XFlush(butPtr->display);
#ifndef MAC_OSX_TK
/*
* On the mac you can not sleep in a display proc, and the
@@ -1036,7 +1037,7 @@ DestroyButton(
static int
ConfigureButton(
Tcl_Interp *interp, /* Used for error reporting. */
- register TkButton *butPtr, /* Information about widget; may or may
+ TkButton *butPtr, /* Information about widget; may or may
* not already have values for some fields. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
@@ -1126,7 +1127,7 @@ ConfigureButton(
if (butPtr->selVarNamePtr == NULL) {
butPtr->selVarNamePtr = Tcl_NewStringObj(
- Tk_Name(butPtr->tkwin), -1);
+ Tk_Name(butPtr->tkwin), TCL_INDEX_NONE);
Tcl_IncrRefCount(butPtr->selVarNamePtr);
}
namePtr = butPtr->selVarNamePtr;
@@ -1175,7 +1176,7 @@ ConfigureButton(
*/
if ((butPtr->type == TYPE_RADIO_BUTTON) &&
- (*Tcl_GetString(butPtr->onValuePtr) == 0)) {
+ (*Tcl_GetString(butPtr->onValuePtr) == '\0')) {
butPtr->flags |= SELECTED;
}
}
@@ -1348,7 +1349,7 @@ TkButtonWorldChanged(
XGCValues gcValues;
GC newGC;
unsigned long mask;
- TkButton *butPtr = instanceData;
+ TkButton *butPtr = (TkButton *)instanceData;
/*
* Recompute GCs.
@@ -1459,7 +1460,7 @@ ButtonEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
goto redraw;
} else if (eventPtr->type == ConfigureNotify) {
@@ -1517,7 +1518,7 @@ static void
ButtonCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
/*
* This function could be invoked either because the window was destroyed
@@ -1603,7 +1604,6 @@ TkInvokeButton(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
ButtonVarProc(
ClientData clientData, /* Information about button. */
@@ -1612,22 +1612,11 @@ ButtonVarProc(
const char *name2, /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- register TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
const char *value;
Tcl_Obj *valuePtr;
-
- /*
- * See ticket [5d991b82].
- */
-
- if (butPtr->selVarNamePtr == NULL) {
- if (!(flags & TCL_INTERP_DESTROYED)) {
- Tcl_UntraceVar2(interp, name1, name2,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ButtonVarProc, clientData);
- }
- return NULL;
- }
+ (void)name1;
+ (void)name2;
/*
* If the variable is being unset, then just re-establish the trace unless
@@ -1636,7 +1625,27 @@ ButtonVarProc(
if (flags & TCL_TRACE_UNSETS) {
butPtr->flags &= ~(SELECTED | TRISTATED);
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
+ if (!Tcl_InterpDeleted(interp)) {
+ ClientData probe = NULL;
+
+ do {
+ probe = Tcl_VarTraceInfo(interp,
+ Tcl_GetString(butPtr->selVarNamePtr),
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ ButtonVarProc, probe);
+ if (probe == (ClientData)butPtr) {
+ break;
+ }
+ } while (probe);
+ if (probe) {
+ /*
+ * We were able to fetch the unset trace for our
+ * selVarNamePtr, which means it is not unset and not
+ * the cause of this unset trace. Instead some outdated
+ * former variable must be, and we should ignore it.
+ */
+ goto redisplay;
+ }
Tcl_TraceVar2(interp, Tcl_GetString(butPtr->selVarNamePtr),
NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
ButtonVarProc, clientData);
@@ -1706,42 +1715,57 @@ ButtonVarProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
ButtonTextVarProc(
ClientData clientData, /* Information about button. */
Tcl_Interp *interp, /* Interpreter containing variable. */
- const char *name1, /* Name of variable. */
- const char *name2, /* Second part of variable name. */
+ const char *name1, /* Not used. */
+ const char *name2, /* Not used. */
int flags) /* Information about what happened. */
{
- TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
Tcl_Obj *valuePtr;
+ (void)name1;
+ (void)name2;
if (butPtr->flags & BUTTON_DELETED) {
return NULL;
}
/*
- * See ticket [5d991b82].
- */
-
- if (butPtr->textVarNamePtr == NULL) {
- if (!(flags & TCL_INTERP_DESTROYED)) {
- Tcl_UntraceVar2(interp, name1, name2,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ButtonTextVarProc, clientData);
- }
- return NULL;
- }
-
- /*
* If the variable is unset, then immediately recreate it unless the whole
* interpreter is going away.
*/
if (flags & TCL_TRACE_UNSETS) {
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
+ if (!Tcl_InterpDeleted(interp) && butPtr->textVarNamePtr != NULL) {
+
+ /*
+ * An unset trace on some variable brought us here, but is it
+ * the variable we have stored in butPtr->textVarNamePtr ?
+ */
+
+ ClientData probe = NULL;
+
+ do {
+ probe = Tcl_VarTraceInfo(interp,
+ Tcl_GetString(butPtr->textVarNamePtr),
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ ButtonTextVarProc, probe);
+ if (probe == (ClientData)butPtr) {
+ break;
+ }
+ } while (probe);
+ if (probe) {
+ /*
+ * We were able to fetch the unset trace for our
+ * textVarNamePtr, which means it is not unset and not
+ * the cause of this unset trace. Instead some outdated
+ * former textvariable must be, and we should ignore it.
+ */
+ return NULL;
+ }
+
Tcl_ObjSetVar2(interp, butPtr->textVarNamePtr, NULL,
butPtr->textPtr, TCL_GLOBAL_ONLY);
Tcl_TraceVar2(interp, Tcl_GetString(butPtr->textVarNamePtr),
@@ -1796,7 +1820,13 @@ ButtonImageProc(
* <= 0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- register TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
if (butPtr->tkwin != NULL) {
TkpComputeButtonGeometry(butPtr);
@@ -1834,7 +1864,13 @@ ButtonSelectImageProc(
* <= 0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- register TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
#ifdef MAC_OSX_TK
if (butPtr->tkwin != NULL) {
@@ -1881,7 +1917,13 @@ ButtonTristateImageProc(
* <= 0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- register TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
#ifdef MAC_OSX_TK
if (butPtr->tkwin != NULL) {
diff --git a/generic/tkButton.h b/generic/tkButton.h
index 7e04fb9..edf7efe 100644
--- a/generic/tkButton.h
+++ b/generic/tkButton.h
@@ -306,7 +306,7 @@ MODULE_SCOPE char tkDefLabelPady[TCL_INTEGER_SPACE];
*/
#ifndef TkpButtonSetDefaults
-MODULE_SCOPE void TkpButtonSetDefaults();
+MODULE_SCOPE void TkpButtonSetDefaults(void);
#endif
MODULE_SCOPE void TkButtonWorldChanged(ClientData instanceData);
MODULE_SCOPE void TkpComputeButtonGeometry(TkButton *butPtr);
diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c
index d2daa17..6952f4d 100644
--- a/generic/tkCanvArc.c
+++ b/generic/tkCanvArc.c
@@ -12,6 +12,9 @@
#include "tkInt.h"
#include "tkCanvas.h"
+#include "default.h"
+
+#include "float.h"
/*
* The structure below defines the record for each arc item.
@@ -110,67 +113,67 @@ static const Tk_CustomOption pixelOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_CUSTOM, "-activedash", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.activeDash),
+ NULL, offsetof(ArcItem, outline.activeDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(ArcItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-activeoutline", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activeoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-activewidth", NULL, NULL,
- "0.0", Tk_Offset(ArcItem, outline.activeWidth),
+ "0.0", offsetof(ArcItem, outline.activeWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_CUSTOM, "-dash", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.dash),
+ NULL, offsetof(ArcItem, outline.dash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_PIXELS, "-dashoffset", NULL, NULL,
- "0", Tk_Offset(ArcItem, outline.offset), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(ArcItem, outline.offset), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-disableddash", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.disabledDash),
+ NULL, offsetof(ArcItem, outline.disabledDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-disabledfill", NULL, NULL,
- NULL, Tk_Offset(ArcItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-disabledoutline", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.disabledColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.disabledColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.disabledStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.disabledStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-disabledwidth", NULL, NULL,
- "0.0", Tk_Offset(ArcItem, outline.disabledWidth),
+ "0.0", offsetof(ArcItem, outline.disabledWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_DOUBLE, "-extent", NULL, NULL,
- "90", Tk_Offset(ArcItem, extent), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "90", offsetof(ArcItem, extent), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- NULL, Tk_Offset(ArcItem, fillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, fillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_DOUBLE, "-height", NULL, NULL,
- 0, Tk_Offset(ArcItem, height), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ 0, offsetof(ArcItem, height), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-offset", NULL, NULL,
- "0,0", Tk_Offset(ArcItem, tsoffset),
+ "0,0", offsetof(ArcItem, tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_COLOR, "-outline", NULL, NULL,
- "black", Tk_Offset(ArcItem, outline.color), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVITEM_OUTLINE, offsetof(ArcItem, outline.color), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-outlineoffset", NULL, NULL,
- "0,0", Tk_Offset(ArcItem, outline.tsoffset),
+ "0,0", offsetof(ArcItem, outline.tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_BITMAP, "-outlinestipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_DOUBLE, "-start", NULL, NULL,
- "0", Tk_Offset(ArcItem, start), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(ArcItem, start), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_BITMAP, "-stipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, fillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, fillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-style", NULL, NULL,
- NULL, Tk_Offset(ArcItem, style), TK_CONFIG_DONT_SET_DEFAULT,
+ NULL, offsetof(ArcItem, style), TK_CONFIG_DONT_SET_DEFAULT,
&styleOption},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_CUSTOM, "-width", NULL, NULL,
- "1.0", Tk_Offset(ArcItem, outline.width), TK_CONFIG_DONT_SET_DEFAULT,
+ "1.0", offsetof(ArcItem, outline.width), TK_CONFIG_DONT_SET_DEFAULT,
&pixelOption},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -183,7 +186,7 @@ static void ComputeArcBbox(Tk_Canvas canvas, ArcItem *arcPtr);
static int ConfigureArc(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
Tcl_Obj *const objv[], int flags);
-static void ComputeArcFromHeight(ArcItem *arcPtr);
+static void ComputeArcParametersFromHeight(ArcItem *arcPtr);
static int CreateArc(Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
int objc, Tcl_Obj *const objv[]);
@@ -214,6 +217,8 @@ static int HorizLineToArc(double x1, double x2,
static int VertLineToArc(double x, double y1,
double y2, double rx, double ry,
double start, double extent);
+static void RotateArc(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
/*
* The structures below defines the arc item types by means of functions that
@@ -241,7 +246,8 @@ Tk_ItemType tkArcType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateArc, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -469,13 +475,12 @@ ConfigureArc(
}
/*
- * If either the height is provided then the start and extent will be
- * overridden.
+ * Override the start and extent if the height is given.
*/
- if (arcPtr->height != 0) {
- ComputeArcFromHeight(arcPtr);
- ComputeArcBbox(canvas, arcPtr);
- }
+
+ ComputeArcParametersFromHeight(arcPtr);
+
+ ComputeArcBbox(canvas, arcPtr);
i = (int) (arcPtr->start/360.0);
arcPtr->start -= i*360.0;
@@ -589,7 +594,7 @@ ConfigureArc(
/*
*--------------------------------------------------------------
*
- * ComputeArcFromHeight --
+ * ComputeArcParametersFromHeight --
*
* This function calculates the arc parameters given start-point,
* end-point and height (!= 0).
@@ -604,17 +609,30 @@ ConfigureArc(
*/
static void
-ComputeArcFromHeight(
+ComputeArcParametersFromHeight(
ArcItem* arcPtr)
{
double chordLen, chordDir[2], chordCen[2], arcCen[2], d, radToDeg, radius;
/*
- * The chord.
+ * Do nothing if no height has been specified.
+ */
+
+ if (arcPtr->height == 0)
+ return;
+
+ /*
+ * Calculate the chord length, return early if it is too small.
*/
chordLen = hypot(arcPtr->endPoint[1] - arcPtr->startPoint[1],
arcPtr->startPoint[0] - arcPtr->endPoint[0]);
+
+ if (chordLen < DBL_EPSILON) {
+ arcPtr->start = arcPtr->extent = arcPtr->height = 0;
+ return;
+ }
+
chordDir[0] = (arcPtr->endPoint[0] - arcPtr->startPoint[0]) / chordLen;
chordDir[1] = (arcPtr->endPoint[1] - arcPtr->startPoint[1]) / chordLen;
chordCen[0] = (arcPtr->startPoint[0] + arcPtr->endPoint[0]) / 2;
@@ -694,6 +712,7 @@ DeleteArc(
Display *display) /* Display containing window for canvas. */
{
ArcItem *arcPtr = (ArcItem *) itemPtr;
+ (void)canvas;
Tk_DeleteOutline(display, &(arcPtr->outline));
if (arcPtr->numOutlinePoints != 0) {
@@ -739,7 +758,6 @@ DeleteArc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
ComputeArcBbox(
Tk_Canvas canvas, /* Canvas that contains item. */
@@ -791,7 +809,7 @@ ComputeArcBbox(
ComputeArcOutline(canvas,arcPtr);
/*
- * To compute the bounding box, start with the the bbox formed by the two
+ * To compute the bounding box, start with the bbox formed by the two
* endpoints of the arc. Then add in the center of the arc's oval (if
* relevant) and the 3-o'clock, 6-o'clock, 9-o'clock, and 12-o'clock
* positions, if they are relevant.
@@ -891,6 +909,10 @@ DisplayArc(
double lineWidth;
Tk_State state = itemPtr->state;
Pixmap stipple;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
@@ -1055,7 +1077,6 @@ DisplayArc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static double
ArcToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1220,7 +1241,6 @@ ArcToPoint(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ArcToArea(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1493,6 +1513,60 @@ ScaleArc(
/*
*--------------------------------------------------------------
*
+ * RotateArc --
+ *
+ * This function is called to rotate an arc by a given amount.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the arc is rotated by angleRad radians about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateArc(
+ Tk_Canvas canvas,
+ Tk_Item *itemPtr,
+ double originX,
+ double originY,
+ double angleRad)
+{
+ ArcItem *arcPtr = (ArcItem *) itemPtr;
+ double newX, newY, oldX, oldY;
+
+ /*
+ * Compute the centre of the box, then rotate that about the origin.
+ */
+
+ newX = oldX = (arcPtr->bbox[0] + arcPtr->bbox[2]) / 2.0;
+ newY = oldY = (arcPtr->bbox[1] + arcPtr->bbox[3]) / 2.0;
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &newX, &newY);
+
+ /*
+ * Apply the translation to the box.
+ */
+
+ arcPtr->bbox[0] += newX - oldX;
+ arcPtr->bbox[1] += newY - oldY;
+ arcPtr->bbox[2] += newX - oldX;
+ arcPtr->bbox[3] += newY - oldY;
+
+ /*
+ * TODO: update the arc endpoints?
+ */
+
+ ComputeArcBbox(canvas, arcPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* TranslateArc --
*
* This function is called to move an arc by a given amount.
@@ -1560,7 +1634,7 @@ ComputeArcOutline(
*/
if (arcPtr->numOutlinePoints == 0) {
- arcPtr->outlinePtr = ckalloc(26 * sizeof(double));
+ arcPtr->outlinePtr = (double *)ckalloc(26 * sizeof(double));
arcPtr->numOutlinePoints = 22;
}
outlinePtr = arcPtr->outlinePtr;
@@ -1940,6 +2014,7 @@ ArcToPostscript(
Tk_State state = itemPtr->state;
Tcl_Obj *psObj;
Tcl_InterpState interpState;
+ (void)prepass;
y1 = Tk_CanvasPsY(canvas, arcPtr->bbox[1]);
y2 = Tk_CanvasPsY(canvas, arcPtr->bbox[3]);
@@ -2012,18 +2087,14 @@ ArcToPostscript(
ang1, ang2);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fillColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (fillStipple != None) {
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, fillStipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (arcPtr->outline.gc != NULL) {
@@ -2049,9 +2120,7 @@ ArcToPostscript(
ang1, ang2);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsOutline(canvas, itemPtr, &arcPtr->outline) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsOutline(canvas, itemPtr, &arcPtr->outline);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (arcPtr->style != ARC_STYLE) {
@@ -2064,18 +2133,14 @@ ArcToPostscript(
} else {
Tk_CanvasPsPath(interp, canvas, arcPtr->outlinePtr,
PIE_OUTLINE1_PTS);
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) !=TCL_OK){
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
Tcl_AppendToObj(psObj, "fill\n", -1);
@@ -2087,18 +2152,14 @@ ArcToPostscript(
arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS,
PIE_OUTLINE2_PTS);
}
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
Tcl_AppendToObj(psObj, "fill\n", -1);
@@ -2114,11 +2175,6 @@ ArcToPostscript(
Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
-
- error:
- Tcl_DiscardInterpState(interpState);
- Tcl_DecrRefCount(psObj);
- return TCL_ERROR;
}
/*
@@ -2141,7 +2197,7 @@ ArcToPostscript(
static int
StyleParseProc(
- ClientData clientData, /* some flags.*/
+ ClientData dummy, /* some flags.*/
Tcl_Interp *interp, /* Used for reporting errors. */
Tk_Window tkwin, /* Window containing canvas widget. */
const char *value, /* Value of option. */
@@ -2150,8 +2206,9 @@ StyleParseProc(
{
int c;
size_t length;
-
- register Style *stylePtr = (Style *) (widgRec + offset);
+ Style *stylePtr = (Style *) (widgRec + offset);
+ (void)dummy;
+ (void)tkwin;
if (value == NULL || *value == 0) {
*stylePtr = PIESLICE_STYLE;
@@ -2205,7 +2262,7 @@ StyleParseProc(
static const char *
StylePrintProc(
- ClientData clientData, /* Ignored. */
+ ClientData dummy, /* Ignored. */
Tk_Window tkwin, /* Ignored. */
char *widgRec, /* Pointer to record for item. */
int offset, /* Offset into item. */
@@ -2213,7 +2270,10 @@ StylePrintProc(
* information about how to reclaim storage
* for return string. */
{
- register Style *stylePtr = (Style *) (widgRec + offset);
+ Style *stylePtr = (Style *) (widgRec + offset);
+ (void)dummy;
+ (void)tkwin;
+ (void)freeProcPtr;
if (*stylePtr == ARC_STYLE) {
return "arc";
diff --git a/generic/tkCanvBmap.c b/generic/tkCanvBmap.c
index b9de07b..3053469 100644
--- a/generic/tkCanvBmap.c
+++ b/generic/tkCanvBmap.c
@@ -12,6 +12,7 @@
#include "tkInt.h"
#include "tkCanvas.h"
+#include "default.h"
/*
* The structure below defines the record for each bitmap item.
@@ -49,30 +50,30 @@ static const Tk_CustomOption tagsOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_COLOR, "-activebackground", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, activeBgColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapItem, activeBgColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activebitmap", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, activeBitmap), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapItem, activeBitmap), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-activeforeground", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, activeFgColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapItem, activeFgColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
- "center", Tk_Offset(BitmapItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "center", offsetof(BitmapItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_COLOR, "-background", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, bgColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapItem, bgColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-bitmap", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, bitmap), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapItem, bitmap), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-disabledbackground", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, disabledBgColor),
+ NULL, offsetof(BitmapItem, disabledBgColor),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledbitmap", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, disabledBitmap),
+ NULL, offsetof(BitmapItem, disabledBitmap),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-disabledforeground", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, disabledFgColor),
+ NULL, offsetof(BitmapItem, disabledFgColor),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-foreground", NULL, NULL,
- "black", Tk_Offset(BitmapItem, fgColor), 0, NULL},
+ DEF_CANVBMAP_FG, offsetof(BitmapItem, fgColor), 0, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK,
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK,
&stateOption},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
@@ -105,6 +106,8 @@ static void DeleteBitmap(Tk_Canvas canvas,
static void DisplayBitmap(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
+static void RotateBitmap(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleBitmap(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -137,7 +140,8 @@ Tk_ItemType tkBitmapType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateBitmap, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -418,6 +422,7 @@ DeleteBitmap(
Display *display) /* Display containing window for canvas. */
{
BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
+ (void)canvas;
if (bmapPtr->bitmap != None) {
Tk_FreeBitmap(display, bmapPtr->bitmap);
@@ -469,7 +474,6 @@ DeleteBitmap(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
ComputeBitmapBbox(
Tk_Canvas canvas, /* Canvas that contains item. */
@@ -667,7 +671,6 @@ DisplayBitmap(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static double
BitmapToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -676,6 +679,7 @@ BitmapToPoint(
{
BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
double x1, x2, y1, y2, xDiff, yDiff;
+ (void)canvas;
x1 = bmapPtr->header.x1;
y1 = bmapPtr->header.y1;
@@ -724,7 +728,6 @@ BitmapToPoint(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
BitmapToArea(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -734,6 +737,7 @@ BitmapToArea(
* area. */
{
BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
+ (void)canvas;
if ((rectPtr[2] <= bmapPtr->header.x1)
|| (rectPtr[0] >= bmapPtr->header.x2)
@@ -790,6 +794,39 @@ ScaleBitmap(
/*
*--------------------------------------------------------------
*
+ * RotateBitmap --
+ *
+ * This function is called to rotate a bitmap's origin by a given amount.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the bitmap is rotated by angleRad radians about
+ * (originX, originY), and the bounding box is updated in the generic
+ * part of the item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateBitmap(
+ Tk_Canvas canvas,
+ Tk_Item *itemPtr,
+ double originX,
+ double originY,
+ double angleRad)
+{
+ BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
+
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &bmapPtr->x, &bmapPtr->y);
+ ComputeBitmapBbox(canvas, bmapPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* TranslateBitmap --
*
* This function is called to move an item by a given amount.
@@ -856,6 +893,7 @@ BitmapToPostscript(
Tk_State state = itemPtr->state;
Tcl_Obj *psObj;
Tcl_InterpState interpState;
+ (void)prepass;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
@@ -928,9 +966,7 @@ BitmapToPostscript(
x, y, width, height, -width);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, bgColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, bgColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
Tcl_AppendToObj(psObj, "fill\n", -1);
@@ -945,9 +981,7 @@ BitmapToPostscript(
if (fgColor != NULL) {
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, fgColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fgColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (width > 60000) {
@@ -976,10 +1010,8 @@ BitmapToPostscript(
(double) rowsThisTime, width, rowsThisTime);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsBitmap(interp, canvas, bitmap,
- 0, curRow, width, rowsThisTime) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsBitmap(interp, canvas, bitmap, 0, curRow, width,
+ rowsThisTime);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
Tcl_AppendToObj(psObj, "\n} imagemask\n", -1);
diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c
index 70b9c79..34b52ea 100644
--- a/generic/tkCanvImg.c
+++ b/generic/tkCanvImg.c
@@ -52,15 +52,15 @@ static const Tk_CustomOption tagsOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_STRING, "-activeimage", NULL, NULL,
- NULL, Tk_Offset(ImageItem, activeImageString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ImageItem, activeImageString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
- "center", Tk_Offset(ImageItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "center", offsetof(ImageItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_STRING, "-disabledimage", NULL, NULL,
- NULL, Tk_Offset(ImageItem, disabledImageString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ImageItem, disabledImageString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_STRING, "-image", NULL, NULL,
- NULL, Tk_Offset(ImageItem, imageString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ImageItem, imageString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
@@ -94,6 +94,8 @@ static void DeleteImage(Tk_Canvas canvas,
static void DisplayImage(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
+static void RotateImage(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleImage(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -126,7 +128,8 @@ Tk_ItemType tkImageType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateImage, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -382,6 +385,8 @@ DeleteImage(
Display *display) /* Display containing window for canvas. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
+ (void)canvas;
+ (void)display;
if (imgPtr->imageString != NULL) {
ckfree(imgPtr->imageString);
@@ -421,7 +426,6 @@ DeleteImage(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
ComputeImageBbox(
Tk_Canvas canvas, /* Canvas that contains item. */
@@ -534,6 +538,7 @@ DisplayImage(
short drawableX, drawableY;
Tk_Image image;
Tk_State state = itemPtr->state;
+ (void)display;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
@@ -592,6 +597,7 @@ ImageToPoint(
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
double x1, x2, y1, y2, xDiff, yDiff;
+ (void)canvas;
x1 = imgPtr->header.x1;
y1 = imgPtr->header.y1;
@@ -649,6 +655,7 @@ ImageToArea(
* area. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
+ (void)canvas;
if ((rectPtr[2] <= imgPtr->header.x1)
|| (rectPtr[0] >= imgPtr->header.x2)
@@ -761,6 +768,40 @@ ImageToPostscript(
/*
*--------------------------------------------------------------
*
+ * RotateImage --
+ *
+ * This function is called to rotate an image's origin by a given amount.
+ * This does *not* rotate the contents of the image.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the image anchor is rotated by angleRad radians about
+ * (originX, originY), and the bounding box is updated in the generic
+ * part of the item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateImage(
+ Tk_Canvas canvas,
+ Tk_Item *itemPtr,
+ double originX,
+ double originY,
+ double angleRad)
+{
+ ImageItem *imgPtr = (ImageItem *) itemPtr;
+
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &imgPtr->x, &imgPtr->y);
+ ComputeImageBbox(canvas, imgPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ScaleImage --
*
* This function is invoked to rescale an item.
@@ -851,7 +892,7 @@ ImageChangedProc(
* 0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- ImageItem *imgPtr = clientData;
+ ImageItem *imgPtr = (ImageItem *)clientData;
/*
* If the image's size changed and it's not anchored at its northwest
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c
index b6c845d..0737d76 100644
--- a/generic/tkCanvLine.c
+++ b/generic/tkCanvLine.c
@@ -13,6 +13,7 @@
#include "tkInt.h"
#include "tkCanvas.h"
+#include "default.h"
/*
* The structure below defines the record for each line item.
@@ -117,6 +118,8 @@ static int ParseArrowShape(ClientData clientData,
static const char * PrintArrowShape(ClientData clientData,
Tk_Window tkwin, char *recordPtr, int offset,
Tcl_FreeProc **freeProcPtr);
+static void RotateLine(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleLine(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -157,58 +160,58 @@ static const Tk_CustomOption pixelOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_CUSTOM, "-activedash", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.activeDash),
+ NULL, offsetof(LineItem, outline.activeDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(LineItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(LineItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-activewidth", NULL, NULL,
- "0.0", Tk_Offset(LineItem, outline.activeWidth),
+ "0.0", offsetof(LineItem, outline.activeWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_CUSTOM, "-arrow", NULL, NULL,
- "none", Tk_Offset(LineItem, arrow),
+ "none", offsetof(LineItem, arrow),
TK_CONFIG_DONT_SET_DEFAULT, &arrowOption},
{TK_CONFIG_CUSTOM, "-arrowshape", NULL, NULL,
- "8 10 3", Tk_Offset(LineItem, arrowShapeA),
+ "8 10 3", offsetof(LineItem, arrowShapeA),
TK_CONFIG_DONT_SET_DEFAULT, &arrowShapeOption},
{TK_CONFIG_CAP_STYLE, "-capstyle", NULL, NULL,
- "butt", Tk_Offset(LineItem, capStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "butt", offsetof(LineItem, capStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- "black", Tk_Offset(LineItem, outline.color), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVITEM_OUTLINE, offsetof(LineItem, outline.color), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-dash", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.dash),
+ NULL, offsetof(LineItem, outline.dash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_PIXELS, "-dashoffset", NULL, NULL,
- "0", Tk_Offset(LineItem, outline.offset), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(LineItem, outline.offset), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-disableddash", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.disabledDash),
+ NULL, offsetof(LineItem, outline.disabledDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-disabledfill", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.disabledColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(LineItem, outline.disabledColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.disabledStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(LineItem, outline.disabledStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-disabledwidth", NULL, NULL,
- "0.0", Tk_Offset(LineItem, outline.disabledWidth),
+ "0.0", offsetof(LineItem, outline.disabledWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_JOIN_STYLE, "-joinstyle", NULL, NULL,
- "round", Tk_Offset(LineItem, joinStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "round", offsetof(LineItem, joinStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-offset", NULL, NULL,
- "0,0", Tk_Offset(LineItem, outline.tsoffset),
+ "0,0", offsetof(LineItem, outline.tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_CUSTOM, "-smooth", NULL, NULL,
- "0", Tk_Offset(LineItem, smooth),
+ "0", offsetof(LineItem, smooth),
TK_CONFIG_DONT_SET_DEFAULT, &smoothOption},
{TK_CONFIG_INT, "-splinesteps", NULL, NULL,
- "12", Tk_Offset(LineItem, splineSteps), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "12", offsetof(LineItem, splineSteps), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_BITMAP, "-stipple", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(LineItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_CUSTOM, "-width", NULL, NULL,
- "1.0", Tk_Offset(LineItem, outline.width),
+ "1.0", offsetof(LineItem, outline.width),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -239,7 +242,8 @@ Tk_ItemType tkLineType = {
LineInsert, /* insertProc */
LineDeleteCoords, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateLine, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -405,7 +409,7 @@ LineCoords(
numPoints = objc/2;
if (linePtr->numPoints != numPoints) {
- coordPtr = ckalloc(sizeof(double) * objc);
+ coordPtr = (double *)ckalloc(sizeof(double) * objc);
if (linePtr->coordPtr != NULL) {
ckfree(linePtr->coordPtr);
}
@@ -606,6 +610,7 @@ DeleteLine(
Display *display) /* Display containing window for canvas. */
{
LineItem *linePtr = (LineItem *) itemPtr;
+ (void)canvas;
Tk_DeleteOutline(display, &linePtr->outline);
if (linePtr->coordPtr != NULL) {
@@ -839,6 +844,10 @@ DisplayLine(
double linewidth;
int numPoints;
Tk_State state = itemPtr->state;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
if (!linePtr->numPoints || (linePtr->outline.gc == NULL)) {
return;
@@ -874,7 +883,7 @@ DisplayLine(
if (numPoints <= MAX_STATIC_POINTS) {
pointPtr = staticPoints;
} else {
- pointPtr = ckalloc(numPoints * 3 * sizeof(XPoint));
+ pointPtr = (XPoint *)ckalloc(numPoints * 3 * sizeof(XPoint));
}
if ((linePtr->smooth) && (linePtr->numPoints > 2)) {
@@ -983,7 +992,7 @@ LineInsert(
linePtr->coordPtr[length-2] = linePtr->lastArrowPtr[0];
linePtr->coordPtr[length-1] = linePtr->lastArrowPtr[1];
}
- newCoordPtr = ckalloc(sizeof(double) * (length + objc));
+ newCoordPtr = (double *)ckalloc(sizeof(double) * (length + objc));
for (i=0; i<beforeThis; i++) {
newCoordPtr[i] = linePtr->coordPtr[i];
}
@@ -1318,7 +1327,6 @@ LineDeleteCoords(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static double
LineToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1364,7 +1372,7 @@ LineToPoint(
if (numPoints <= MAX_STATIC_POINTS) {
linePoints = staticSpace;
} else {
- linePoints = ckalloc(2 * numPoints * sizeof(double));
+ linePoints = (double *)ckalloc(2 * numPoints * sizeof(double));
}
numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
linePtr->numPoints, linePtr->splineSteps, NULL, linePoints);
@@ -1546,7 +1554,6 @@ LineToPoint(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
LineToArea(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1599,7 +1606,7 @@ LineToArea(
if (numPoints <= MAX_STATIC_POINTS) {
linePoints = staticSpace;
} else {
- linePoints = ckalloc(2 * numPoints * sizeof(double));
+ linePoints = (double *)ckalloc(2 * numPoints * sizeof(double));
}
numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
linePtr->numPoints, linePtr->splineSteps, NULL, linePoints);
@@ -1742,16 +1749,26 @@ GetLineIndex(
* itemPtr's line. */
int *indexPtr) /* Where to store converted index. */
{
+ TkSizeT idx, length;
LineItem *linePtr = (LineItem *) itemPtr;
- const char *string = Tcl_GetString(obj);
-
- if (string[0] == 'e') {
- if (strncmp(string, "end", obj->length) == 0) {
- *indexPtr = 2*linePtr->numPoints;
+ const char *string;
+ (void)canvas;
+
+ if (TCL_OK == TkGetIntForIndex(obj, 2*linePtr->numPoints - 1, 0, &idx)) {
+ if (idx == TCL_INDEX_NONE) {
+ idx = 0;
+ } else if (idx > (2*(TkSizeT)linePtr->numPoints)) {
+ idx = 2*linePtr->numPoints;
} else {
- goto badIndex;
+ idx &= (TkSizeT)-2; /* If index is odd, make it even. */
}
- } else if (string[0] == '@') {
+ *indexPtr = (int)idx;
+ return TCL_OK;
+ }
+
+ string = TkGetStringFromObj(obj, &length);
+
+ if (string[0] == '@') {
int i;
double x, y, bestDist, dist, *coordPtr;
char *end;
@@ -1779,28 +1796,18 @@ GetLineIndex(
coordPtr += 2;
}
} else {
- if (Tcl_GetIntFromObj(interp, obj, indexPtr) != TCL_OK) {
- goto badIndex;
- }
- *indexPtr &= -2; /* If index is odd, make it even. */
- if (*indexPtr < 0){
- *indexPtr = 0;
- } else if (*indexPtr > (2*linePtr->numPoints)) {
- *indexPtr = (2*linePtr->numPoints);
- }
- }
- return TCL_OK;
- /*
- * Some of the paths here leave messages in interp->result, so we have to
- * clear it out before storing our own message.
- */
+ /*
+ * Some of the paths here leave messages in interp->result, so we have to
+ * clear it out before storing our own message.
+ */
- badIndex:
- Tcl_ResetResult(interp);
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "LINE", NULL);
- return TCL_ERROR;
+ badIndex:
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "LINE", NULL);
+ return TCL_ERROR;
+ }
+ return TCL_OK;
}
/*
@@ -1856,6 +1863,56 @@ TranslateLine(
/*
*--------------------------------------------------------------
*
+ * RotateLine --
+ *
+ * This function is called to rotate a line by a given amount about a
+ * point.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the line is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateLine(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being moved. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ LineItem *linePtr = (LineItem *) itemPtr;
+ double *coordPtr;
+ int i;
+ double s = sin(angleRad), c = cos(angleRad);
+
+ for (i = 0, coordPtr = linePtr->coordPtr; i < linePtr->numPoints;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ if (linePtr->firstArrowPtr != NULL) {
+ for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ }
+ if (linePtr->lastArrowPtr != NULL) {
+ for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ }
+ ComputeLineBbox(canvas, linePtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ParseArrowShape --
*
* This function is called back during option parsing to parse arrow
@@ -1872,10 +1929,9 @@ TranslateLine(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ParseArrowShape(
- ClientData clientData, /* Not used. */
+ ClientData dummy, /* Not used. */
Tcl_Interp *interp, /* Used for error reporting. */
Tk_Window tkwin, /* Not used. */
const char *value, /* Textual specification of arrow shape. */
@@ -1888,8 +1944,10 @@ ParseArrowShape(
double a, b, c;
int argc;
const char **argv = NULL;
+ (void)dummy;
+ (void)tkwin;
- if (offset != Tk_Offset(LineItem, arrowShapeA)) {
+ if ((size_t)offset != offsetof(LineItem, arrowShapeA)) {
Tcl_Panic("ParseArrowShape received bogus offset");
}
@@ -1941,10 +1999,9 @@ ParseArrowShape(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static const char *
PrintArrowShape(
- ClientData clientData, /* Not used. */
+ ClientData dummy, /* Not used. */
Tk_Window tkwin, /* Window associated with linePtr's widget. */
char *recordPtr, /* Pointer to item record containing current
* shape information. */
@@ -1953,7 +2010,10 @@ PrintArrowShape(
* string here. */
{
LineItem *linePtr = (LineItem *) recordPtr;
- char *buffer = ckalloc(120);
+ char *buffer = (char *)ckalloc(120);
+ (void)dummy;
+ (void)tkwin;
+ (void)offset;
sprintf(buffer, "%.5g %.5g %.5g", linePtr->arrowShapeA,
linePtr->arrowShapeB, linePtr->arrowShapeC);
@@ -1981,7 +2041,7 @@ PrintArrowShape(
static int
ArrowParseProc(
- ClientData clientData, /* some flags.*/
+ ClientData dummy, /* some flags.*/
Tcl_Interp *interp, /* Used for reporting errors. */
Tk_Window tkwin, /* Window containing canvas widget. */
const char *value, /* Value of option. */
@@ -1990,8 +2050,9 @@ ArrowParseProc(
{
int c;
size_t length;
-
- register Arrows *arrowPtr = (Arrows *) (widgRec + offset);
+ Arrows *arrowPtr = (Arrows *) (widgRec + offset);
+ (void)dummy;
+ (void)tkwin;
if (value == NULL || *value == 0) {
*arrowPtr = ARROWS_NONE;
@@ -2049,7 +2110,7 @@ ArrowParseProc(
static const char *
ArrowPrintProc(
- ClientData clientData, /* Ignored. */
+ ClientData dummy, /* Ignored. */
Tk_Window tkwin, /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
int offset, /* Offset into item. */
@@ -2057,7 +2118,10 @@ ArrowPrintProc(
* information about how to reclaim storage
* for return string. */
{
- register Arrows *arrowPtr = (Arrows *) (widgRec + offset);
+ Arrows *arrowPtr = (Arrows *) (widgRec + offset);
+ (void)dummy;
+ (void)tkwin;
+ (void)freeProcPtr;
switch (*arrowPtr) {
case ARROWS_FIRST:
@@ -2091,7 +2155,6 @@ ArrowPrintProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ConfigureArrows(
Tk_Canvas canvas, /* Canvas in which arrows will be displayed
@@ -2152,7 +2215,7 @@ ConfigureArrows(
if (linePtr->arrow != ARROWS_LAST) {
poly = linePtr->firstArrowPtr;
if (poly == NULL) {
- poly = ckalloc(2 * PTS_IN_ARROW * sizeof(double));
+ poly = (double *)ckalloc(2 * PTS_IN_ARROW * sizeof(double));
poly[0] = poly[10] = linePtr->coordPtr[0];
poly[1] = poly[11] = linePtr->coordPtr[1];
linePtr->firstArrowPtr = poly;
@@ -2196,7 +2259,7 @@ ConfigureArrows(
coordPtr = linePtr->coordPtr + 2*(linePtr->numPoints-2);
poly = linePtr->lastArrowPtr;
if (poly == NULL) {
- poly = ckalloc(2 * PTS_IN_ARROW * sizeof(double));
+ poly = (double *)ckalloc(2 * PTS_IN_ARROW * sizeof(double));
poly[0] = poly[10] = coordPtr[2];
poly[1] = poly[11] = coordPtr[3];
linePtr->lastArrowPtr = poly;
@@ -2265,6 +2328,7 @@ LineToPostscript(
Tk_State state = itemPtr->state;
Tcl_Obj *psObj;
Tcl_InterpState interpState;
+ (void)prepass;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
@@ -2319,17 +2383,13 @@ LineToPostscript(
" scale 1 0 moveto 0 0 1 0 360 arc\nsetmatrix\n", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
Tcl_AppendToObj(psObj, "fill\n", -1);
@@ -2365,7 +2425,7 @@ LineToPostscript(
linePtr->numPoints, linePtr->splineSteps, NULL, NULL);
pointPtr = staticPoints;
if (numPoints > MAX_STATIC_POINTS) {
- pointPtr = ckalloc(numPoints * 2 * sizeof(double));
+ pointPtr = (double *)ckalloc(numPoints * 2 * sizeof(double));
}
numPoints = linePtr->smooth->coordProc(canvas, linePtr->coordPtr,
linePtr->numPoints, linePtr->splineSteps, NULL, pointPtr);
@@ -2398,9 +2458,7 @@ LineToPostscript(
Tcl_AppendPrintfToObj(psObj, "%d setlinejoin\n", style);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsOutline(canvas, itemPtr, &linePtr->outline) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsOutline(canvas, itemPtr, &linePtr->outline);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
/*
@@ -2411,19 +2469,15 @@ LineToPostscript(
if (stipple != None) {
Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
}
- if (ArrowheadPostscript(interp, canvas, linePtr,
- linePtr->firstArrowPtr, psObj) != TCL_OK) {
- goto error;
- }
+ ArrowheadPostscript(interp, canvas, linePtr,
+ linePtr->firstArrowPtr, psObj);
}
if (linePtr->lastArrowPtr != NULL) {
if (stipple != None) {
Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
}
- if (ArrowheadPostscript(interp, canvas, linePtr,
- linePtr->lastArrowPtr, psObj) != TCL_OK) {
- goto error;
- }
+ ArrowheadPostscript(interp, canvas, linePtr,
+ linePtr->lastArrowPtr, psObj);
}
/*
@@ -2435,11 +2489,6 @@ LineToPostscript(
Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
-
- error:
- Tcl_DiscardInterpState(interpState);
- Tcl_DecrRefCount(psObj);
- return TCL_ERROR;
}
/*
@@ -2499,9 +2548,7 @@ ArrowheadPostscript(
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- return TCL_ERROR;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
Tcl_AppendToObj(psObj, "fill\n", -1);
diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c
index 6a8f865..c0329d6 100644
--- a/generic/tkCanvPoly.c
+++ b/generic/tkCanvPoly.c
@@ -13,6 +13,7 @@
#include "tkInt.h"
#include "tkCanvas.h"
+#include "default.h"
/*
* The structure below defines the record for each polygon item.
@@ -76,69 +77,69 @@ static const Tk_CustomOption pixelOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_CUSTOM, "-activedash", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.activeDash),
+ NULL, offsetof(PolygonItem, outline.activeDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-activeoutline", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activeoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.activeStipple),
+ NULL, offsetof(PolygonItem, outline.activeStipple),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-activewidth", NULL, NULL,
- "0.0", Tk_Offset(PolygonItem, outline.activeWidth),
+ "0.0", offsetof(PolygonItem, outline.activeWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_CUSTOM, "-dash", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.dash),
+ NULL, offsetof(PolygonItem, outline.dash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_PIXELS, "-dashoffset", NULL, NULL,
- "0", Tk_Offset(PolygonItem, outline.offset),
+ "0", offsetof(PolygonItem, outline.offset),
TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-disableddash", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.disabledDash),
+ NULL, offsetof(PolygonItem, outline.disabledDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-disabledfill", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-disabledoutline", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.disabledColor),
+ NULL, offsetof(PolygonItem, outline.disabledColor),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.disabledStipple),
+ NULL, offsetof(PolygonItem, outline.disabledStipple),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-disabledwidth", NULL, NULL,
- "0.0", Tk_Offset(PolygonItem, outline.disabledWidth),
+ "0.0", offsetof(PolygonItem, outline.disabledWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- "black", Tk_Offset(PolygonItem, fillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, fillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_JOIN_STYLE, "-joinstyle", NULL, NULL,
- "round", Tk_Offset(PolygonItem, joinStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "round", offsetof(PolygonItem, joinStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-offset", NULL, NULL,
- "0,0", Tk_Offset(PolygonItem, tsoffset),
+ "0,0", offsetof(PolygonItem, tsoffset),
TK_CONFIG_NULL_OK, &offsetOption},
{TK_CONFIG_COLOR, "-outline", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.color), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVITEM_OUTLINE, offsetof(PolygonItem, outline.color), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-outlineoffset", NULL, NULL,
- "0,0", Tk_Offset(PolygonItem, outline.tsoffset),
+ "0,0", offsetof(PolygonItem, outline.tsoffset),
TK_CONFIG_NULL_OK, &offsetOption},
{TK_CONFIG_BITMAP, "-outlinestipple", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-smooth", NULL, NULL,
- "0", Tk_Offset(PolygonItem, smooth),
+ "0", offsetof(PolygonItem, smooth),
TK_CONFIG_DONT_SET_DEFAULT, &smoothOption},
{TK_CONFIG_INT, "-splinesteps", NULL, NULL,
- "12", Tk_Offset(PolygonItem, splineSteps), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "12", offsetof(PolygonItem, splineSteps), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_BITMAP, "-stipple", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, fillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, fillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_CUSTOM, "-width", NULL, NULL,
- "1.0", Tk_Offset(PolygonItem, outline.width),
+ "1.0", offsetof(PolygonItem, outline.width),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -176,6 +177,8 @@ static double PolygonToPoint(Tk_Canvas canvas,
Tk_Item *itemPtr, double *pointPtr);
static int PolygonToPostscript(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
+static void RotatePolygon(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScalePolygon(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -208,7 +211,8 @@ Tk_ItemType tkPolygonType = {
PolygonInsert, /* insertProc */
PolygonDeleteCoords, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotatePolygon, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -374,7 +378,7 @@ PolygonCoords(
* another point to close the polygon.
*/
- polyPtr->coordPtr = ckalloc(sizeof(double) * (objc+2));
+ polyPtr->coordPtr = (double *)ckalloc(sizeof(double) * (objc+2));
polyPtr->pointsAllocated = numPoints+1;
}
for (i = objc-1; i >= 0; i--) {
@@ -562,7 +566,7 @@ ConfigurePolygon(
static void
DeletePolygon(
- Tk_Canvas canvas, /* Info about overall canvas widget. */
+ TCL_UNUSED(Tk_Canvas), /* Info about overall canvas widget. */
Tk_Item *itemPtr, /* Item that is being deleted. */
Display *display) /* Display containing window for canvas. */
{
@@ -823,7 +827,7 @@ TkFillPolygon(
if (numPoints <= MAX_STATIC_POINTS) {
pointPtr = staticPoints;
} else {
- pointPtr = ckalloc(numPoints * sizeof(XPoint));
+ pointPtr = (XPoint *)ckalloc(numPoints * sizeof(XPoint));
}
for (i=0, pPtr=pointPtr ; i<numPoints; i+=1, coordPtr+=2, pPtr++) {
@@ -872,7 +876,10 @@ DisplayPolygon(
Tk_Item *itemPtr, /* Item to be displayed. */
Display *display, /* Display on which to draw item. */
Drawable drawable, /* Pixmap or window in which to draw item. */
- int x, int y, int width, int height)
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int))
/* Describes region of canvas that must be
* redisplayed (not used). */
{
@@ -969,7 +976,7 @@ DisplayPolygon(
if (numPoints <= MAX_STATIC_POINTS) {
pointPtr = staticPoints;
} else {
- pointPtr = ckalloc(numPoints * sizeof(XPoint));
+ pointPtr = (XPoint *)ckalloc(numPoints * sizeof(XPoint));
}
numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr,
polyPtr->numPoints, polyPtr->splineSteps, pointPtr, NULL);
@@ -1036,7 +1043,7 @@ PolygonInsert(
while (beforeThis < 0) {
beforeThis += length;
}
- newCoordPtr = ckalloc(sizeof(double) * (length + 2 + objc));
+ newCoordPtr = (double *)ckalloc(sizeof(double) * (length + 2 + objc));
for (i=0; i<beforeThis; i++) {
newCoordPtr[i] = polyPtr->coordPtr[i];
}
@@ -1238,7 +1245,6 @@ PolygonDeleteCoords(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static double
PolygonToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1286,7 +1292,7 @@ PolygonToPoint(
if (numPoints <= MAX_STATIC_POINTS) {
polyPoints = staticSpace;
} else {
- polyPoints = ckalloc(2 * numPoints * sizeof(double));
+ polyPoints = (double *)ckalloc(2 * numPoints * sizeof(double));
}
numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr,
polyPtr->numPoints, polyPtr->splineSteps, NULL, polyPoints);
@@ -1428,7 +1434,6 @@ PolygonToPoint(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
PolygonToArea(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1495,7 +1500,7 @@ PolygonToArea(
if (numPoints <= MAX_STATIC_POINTS) {
polyPoints = staticSpace;
} else {
- polyPoints = ckalloc(2 * numPoints * sizeof(double));
+ polyPoints = (double *)ckalloc(2 * numPoints * sizeof(double));
}
numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr,
polyPtr->numPoints, polyPtr->splineSteps, NULL, polyPoints);
@@ -1665,22 +1670,31 @@ ScalePolygon(
static int
GetPolygonIndex(
Tcl_Interp *interp, /* Used for error reporting. */
- Tk_Canvas canvas, /* Canvas containing item. */
+ TCL_UNUSED(Tk_Canvas), /* Canvas containing item. */
Tk_Item *itemPtr, /* Item for which the index is being
* specified. */
Tcl_Obj *obj, /* Specification of a particular coord in
* itemPtr's line. */
int *indexPtr) /* Where to store converted index. */
{
+ TkSizeT length, idx;
PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- const char *string = Tcl_GetString(obj);
+ const char *string;
+ TkSizeT count = 2*(polyPtr->numPoints - polyPtr->autoClosed);
- if (string[0] == 'e') {
- if (strncmp(string, "end", obj->length) != 0) {
- goto badIndex;
+ if (TCL_OK == TkGetIntForIndex(obj, (INT_MAX - 1) - ((INT_MAX) % count), 1, &idx)) {
+ if (idx == TCL_INDEX_NONE) {
+ idx = 0;
+ } else {
+ idx = (idx & (TkSizeT)-2) % count;
}
- *indexPtr = 2*(polyPtr->numPoints - polyPtr->autoClosed);
- } else if (string[0] == '@') {
+ *indexPtr = (int)idx;
+ return TCL_OK;
+ }
+
+ string = TkGetStringFromObj(obj, &length);
+
+ if (string[0] == '@') {
int i;
double x, y, bestDist, dist, *coordPtr;
char *end;
@@ -1708,31 +1722,55 @@ GetPolygonIndex(
coordPtr += 2;
}
} else {
- int count = 2*(polyPtr->numPoints - polyPtr->autoClosed);
+ /*
+ * Some of the paths here leave messages in interp->result, so we have to
+ * clear it out before storing our own message.
+ */
- if (Tcl_GetIntFromObj(interp, obj, indexPtr) != TCL_OK) {
- goto badIndex;
- }
- *indexPtr &= -2; /* if odd, make it even */
- if (!count) {
- *indexPtr = 0;
- } else if (*indexPtr > 0) {
- *indexPtr = ((*indexPtr - 2) % count) + 2;
- } else {
- *indexPtr = -((-(*indexPtr)) % count);
- }
+ badIndex:
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "POLY", NULL);
+ return TCL_ERROR;
}
return TCL_OK;
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * RotatePolygon --
+ *
+ * This function is called to rotate a polygon by a given amount about a
+ * point.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the polygon is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
- /*
- * Some of the paths here leave messages in interp->result, so we have to
- * clear it out before storing our own message.
- */
+static void
+RotatePolygon(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being moved. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ PolygonItem *polyPtr = (PolygonItem *) itemPtr;
+ double *coordPtr;
+ int i;
+ double s = sin(angleRad), c = cos(angleRad);
- badIndex:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "POLY", NULL);
- return TCL_ERROR;
+ for (i = 0, coordPtr = polyPtr->coordPtr; i < polyPtr->numPoints;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ ComputePolygonBbox(canvas, polyPtr);
}
/*
@@ -1795,7 +1833,7 @@ PolygonToPostscript(
Tcl_Interp *interp, /* Leave Postscript or error message here. */
Tk_Canvas canvas, /* Information about overall canvas. */
Tk_Item *itemPtr, /* Item for which Postscript is wanted. */
- int prepass) /* 1 means this is a prepass to collect font
+ TCL_UNUSED(int)) /* 1 means this is a prepass to collect font
* information; 0 means final Postscript is
* being created. */
{
@@ -1889,18 +1927,14 @@ PolygonToPostscript(
*/
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
Tcl_AppendToObj(psObj, "fill\n", -1);
@@ -1921,18 +1955,14 @@ PolygonToPostscript(
polyPtr->smooth->postscriptProc(interp, canvas, polyPtr->coordPtr,
polyPtr->numPoints, polyPtr->splineSteps);
}
- if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fillColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (fillStipple != None) {
Tcl_AppendToObj(psObj, "eoclip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, fillStipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (color != NULL) {
@@ -1968,9 +1998,7 @@ PolygonToPostscript(
Tcl_AppendPrintfToObj(psObj, "%d setlinejoin 1 setlinecap\n", style);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsOutline(canvas, itemPtr, &polyPtr->outline) != TCL_OK){
- goto error;
- }
+ Tk_CanvasPsOutline(canvas, itemPtr, &polyPtr->outline);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
}
@@ -1983,11 +2011,6 @@ PolygonToPostscript(
Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
-
- error:
- Tcl_DiscardInterpState(interpState);
- Tcl_DecrRefCount(psObj);
- return TCL_ERROR;
}
/*
diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c
index 609901b..77cff1f 100644
--- a/generic/tkCanvPs.c
+++ b/generic/tkCanvPs.c
@@ -94,37 +94,37 @@ typedef struct TkPostscriptInfo {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_STRING, "-colormap", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, colorVar), 0, NULL},
+ "", offsetof(TkPostscriptInfo, colorVar), 0, NULL},
{TK_CONFIG_STRING, "-colormode", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, colorMode), 0, NULL},
+ "", offsetof(TkPostscriptInfo, colorMode), 0, NULL},
{TK_CONFIG_STRING, "-file", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, fileName), 0, NULL},
+ "", offsetof(TkPostscriptInfo, fileName), 0, NULL},
{TK_CONFIG_STRING, "-channel", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, channelName), 0, NULL},
+ "", offsetof(TkPostscriptInfo, channelName), 0, NULL},
{TK_CONFIG_STRING, "-fontmap", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, fontVar), 0, NULL},
+ "", offsetof(TkPostscriptInfo, fontVar), 0, NULL},
{TK_CONFIG_PIXELS, "-height", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, height), 0, NULL},
+ "", offsetof(TkPostscriptInfo, height), 0, NULL},
{TK_CONFIG_ANCHOR, "-pageanchor", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageAnchor), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageAnchor), 0, NULL},
{TK_CONFIG_STRING, "-pageheight", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageHeightString), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageHeightString), 0, NULL},
{TK_CONFIG_STRING, "-pagewidth", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageWidthString), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageWidthString), 0, NULL},
{TK_CONFIG_STRING, "-pagex", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageXString), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageXString), 0, NULL},
{TK_CONFIG_STRING, "-pagey", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageYString), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageYString), 0, NULL},
{TK_CONFIG_BOOLEAN, "-prolog", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, prolog), 0, NULL},
+ "", offsetof(TkPostscriptInfo, prolog), 0, NULL},
{TK_CONFIG_BOOLEAN, "-rotate", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, rotate), 0, NULL},
+ "", offsetof(TkPostscriptInfo, rotate), 0, NULL},
{TK_CONFIG_PIXELS, "-width", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, width), 0, NULL},
+ "", offsetof(TkPostscriptInfo, width), 0, NULL},
{TK_CONFIG_PIXELS, "-x", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, x), 0, NULL},
+ "", offsetof(TkPostscriptInfo, x), 0, NULL},
{TK_CONFIG_PIXELS, "-y", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, y), 0, NULL},
+ "", offsetof(TkPostscriptInfo, y), 0, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -157,7 +157,6 @@ static inline Tcl_Obj * GetPostscriptBuffer(Tcl_Interp *interp);
*--------------------------------------------------------------
*/
- /* ARGSUSED */
int
TkCanvPostscriptCmd(
TkCanvas *canvasPtr, /* Information about canvas widget. */
@@ -381,7 +380,7 @@ TkCanvPostscriptCmd(
*/
psInfo.chan = Tcl_GetChannel(interp, psInfo.channelName, &mode);
- if (psInfo.chan == (Tcl_Channel) NULL) {
+ if (psInfo.chan == NULL) {
result = TCL_ERROR;
goto cleanup;
}
@@ -572,7 +571,6 @@ TkCanvPostscriptCmd(
continue;
}
- Tcl_ResetResult(interp);
result = itemPtr->typePtr->postscriptProc(interp,
(Tk_Canvas) canvasPtr, itemPtr, 0);
if (result != TCL_OK) {
@@ -585,6 +583,7 @@ TkCanvPostscriptCmd(
Tcl_AppendToObj(psObj, "gsave\n", -1);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
Tcl_AppendToObj(psObj, "grestore\n", -1);
+ Tcl_ResetResult(interp);
if (psInfo.chan != NULL) {
if (Tcl_WriteObj(psInfo.chan, psObj) == TCL_IO_FAILURE) {
@@ -1194,6 +1193,8 @@ TkImageGetColor(
double *red, double *green, double *blue)
/* Color data to return */
{
+ (void)cdata;
+
*red = (double) GetRValue(pixel) / 255.0;
*green = (double) GetGValue(pixel) / 255.0;
*blue = (double) GetBValue(pixel) / 255.0;
@@ -1262,6 +1263,7 @@ TkPostscriptImage(
Visual *visual;
TkColormapData cdata;
Tcl_Obj *psObj;
+ (void)y;
if (psInfoPtr->prepass) {
return TCL_OK;
@@ -1276,10 +1278,10 @@ TkPostscriptImage(
*/
ncolors = visual->map_entries;
- cdata.colors = ckalloc(sizeof(XColor) * ncolors);
+ cdata.colors = (XColor *)ckalloc(sizeof(XColor) * ncolors);
cdata.ncolors = ncolors;
- if (visual->class == DirectColor || visual->class == TrueColor) {
+ if (visual->c_class == DirectColor || visual->c_class == TrueColor) {
cdata.separated = 1;
cdata.red_mask = visual->red_mask;
cdata.green_mask = visual->green_mask;
@@ -1311,7 +1313,7 @@ TkPostscriptImage(
}
}
- if (visual->class == StaticGray || visual->class == GrayScale) {
+ if (visual->c_class == StaticGray || visual->c_class == GrayScale) {
cdata.color = 0;
} else {
cdata.color = 1;
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c
index c918399..ab7b882 100644
--- a/generic/tkCanvText.c
+++ b/generic/tkCanvText.c
@@ -95,38 +95,38 @@ static const Tk_CustomOption offsetOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(TextItem, activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(TextItem, activeStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, activeStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
- "center", Tk_Offset(TextItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "center", offsetof(TextItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_DOUBLE, "-angle", NULL, NULL,
- "0.0", Tk_Offset(TextItem, angle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0.0", offsetof(TextItem, angle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_COLOR, "-disabledfill", NULL, NULL,
- NULL, Tk_Offset(TextItem, disabledColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, disabledColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL,
- NULL, Tk_Offset(TextItem, disabledStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, disabledStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- "black", Tk_Offset(TextItem, color), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVITEM_OUTLINE, offsetof(TextItem, color), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_FONT, "-font", NULL, NULL,
- DEF_CANVTEXT_FONT, Tk_Offset(TextItem, tkfont), 0, NULL},
+ DEF_CANVTEXT_FONT, offsetof(TextItem, tkfont), 0, NULL},
{TK_CONFIG_JUSTIFY, "-justify", NULL, NULL,
- "left", Tk_Offset(TextItem, justify), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "left", offsetof(TextItem, justify), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-offset", NULL, NULL,
- "0,0", Tk_Offset(TextItem, tsoffset),
+ "0,0", offsetof(TextItem, tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_BITMAP, "-stipple", NULL, NULL,
- NULL, Tk_Offset(TextItem, stipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, stipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_STRING, "-text", NULL, NULL,
- "", Tk_Offset(TextItem, text), 0, NULL},
+ "", offsetof(TextItem, text), 0, NULL},
{TK_CONFIG_INT, "-underline", NULL, NULL,
- "-1", Tk_Offset(TextItem, underline), 0, NULL},
+ "-1", offsetof(TextItem, underline), 0, NULL},
{TK_CONFIG_PIXELS, "-width", NULL, NULL,
- "0", Tk_Offset(TextItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(TextItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -170,6 +170,8 @@ static double TextToPoint(Tk_Canvas canvas,
Tk_Item *itemPtr, double *pointPtr);
static int TextToPostscript(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
+static void RotateText(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void TranslateText(Tk_Canvas canvas,
Tk_Item *itemPtr, double deltaX, double deltaY);
@@ -199,7 +201,8 @@ Tk_ItemType tkTextType = {
TextInsert, /* insertProc */
TextDeleteChars, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateText, /* rotateProc */
+ 0, NULL, NULL
};
#define ROUND(d) ((int) floor((d) + 0.5))
@@ -567,6 +570,7 @@ DeleteText(
Display *display) /* Display containing window for canvas. */
{
TextItem *textPtr = (TextItem *) itemPtr;
+ (void)canvas;
if (textPtr->color != NULL) {
Tk_FreeColor(textPtr->color);
@@ -835,7 +839,7 @@ DisplayCanvText(
}
selFirstChar = -1;
- selLastChar = 0; /* lint. */
+ selLastChar = 0;
Tk_CanvasDrawableCoords(canvas, textPtr->drawOrigin[0],
textPtr->drawOrigin[1], &drawableX, &drawableY);
@@ -957,19 +961,23 @@ DisplayCanvText(
*/
if ((selFirstChar >= 0) && (textPtr->selTextGC != textPtr->gc)) {
- TkDrawAngledTextLayout(display, drawable, textPtr->gc,
- textPtr->textLayout, drawableX, drawableY, textPtr->angle,
- 0, selFirstChar);
+ if (0 < selFirstChar) {
+ TkDrawAngledTextLayout(display, drawable, textPtr->gc,
+ textPtr->textLayout, drawableX, drawableY, textPtr->angle,
+ 0, selFirstChar);
+ }
TkDrawAngledTextLayout(display, drawable, textPtr->selTextGC,
textPtr->textLayout, drawableX, drawableY, textPtr->angle,
selFirstChar, selLastChar + 1);
- TkDrawAngledTextLayout(display, drawable, textPtr->gc,
- textPtr->textLayout, drawableX, drawableY, textPtr->angle,
- selLastChar + 1, -1);
+ if (selLastChar + 1 < textPtr->numChars) {
+ TkDrawAngledTextLayout(display, drawable, textPtr->gc,
+ textPtr->textLayout, drawableX, drawableY, textPtr->angle,
+ selLastChar + 1, textPtr->numChars);
+ }
} else {
TkDrawAngledTextLayout(display, drawable, textPtr->gc,
textPtr->textLayout, drawableX, drawableY, textPtr->angle,
- 0, -1);
+ 0, textPtr->numChars);
}
TkUnderlineAngledTextLayout(display, drawable, textPtr->gc,
textPtr->textLayout, drawableX, drawableY, textPtr->angle,
@@ -1007,7 +1015,7 @@ TextInsert(
{
TextItem *textPtr = (TextItem *) itemPtr;
int byteIndex, charsAdded;
- size_t byteCount;
+ TkSizeT byteCount;
char *newStr, *text;
const char *string;
Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
@@ -1028,8 +1036,8 @@ TextInsert(
return;
}
- newStr = ckalloc(textPtr->numBytes + byteCount + 1);
- memcpy(newStr, text, (size_t) byteIndex);
+ newStr = (char *)ckalloc(textPtr->numBytes + byteCount + 1);
+ memcpy(newStr, text, byteIndex);
strcpy(newStr + byteIndex, string);
strcpy(newStr + byteIndex + byteCount, text + byteIndex);
@@ -1109,8 +1117,8 @@ TextDeleteChars(
byteCount = Tcl_UtfAtIndex(text + byteIndex, charsRemoved)
- (text + byteIndex);
- newStr = ckalloc(textPtr->numBytes + 1 - byteCount);
- memcpy(newStr, text, (size_t) byteIndex);
+ newStr = (char *)ckalloc(textPtr->numBytes + 1 - byteCount);
+ memcpy(newStr, text, byteIndex);
strcpy(newStr + byteIndex, text + byteIndex + byteCount);
ckfree(text);
@@ -1250,6 +1258,39 @@ TextToArea(
/*
*--------------------------------------------------------------
*
+ * RotateText --
+ *
+ * This function is called to rotate a text item by a given amount about a
+ * point. Note that this does *not* rotate the text of the item.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the text anchor is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateText(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being rotated. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ TextItem *textPtr = (TextItem *) itemPtr;
+
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &textPtr->x, &textPtr->y);
+ ComputeTextBbox(canvas, textPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ScaleText --
*
* This function is invoked to rescale a text item.
@@ -1264,7 +1305,6 @@ TextToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
ScaleText(
Tk_Canvas canvas, /* Canvas containing rectangle. */
@@ -1344,21 +1384,30 @@ GetTextIndex(
* index. */
{
TextItem *textPtr = (TextItem *) itemPtr;
- size_t length;
+ TkSizeT length, idx;
int c;
- TkCanvas *canvasPtr = (TkCanvas *) canvas;
Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
- const char *string = TkGetStringFromObj(obj, &length);
+ const char *string;
+ (void)canvas;
+ if (TCL_OK == TkGetIntForIndex(obj, textPtr->numChars - 1, 1, &idx)) {
+ if (idx == TCL_INDEX_NONE) {
+ idx = 0;
+ } else if (idx > (TkSizeT)textPtr->numChars) {
+ idx = textPtr->numChars;
+ }
+ *indexPtr = (int)idx;
+ return TCL_OK;
+ }
+
+ string = TkGetStringFromObj(obj, &length);
c = string[0];
- if ((c == 'e') && (strncmp(string, "end", (unsigned) length) == 0)) {
- *indexPtr = textPtr->numChars;
- } else if ((c == 'i')
- && (strncmp(string, "insert", (unsigned) length) == 0)) {
+ if ((c == 'i')
+ && (strncmp(string, "insert", length) == 0)) {
*indexPtr = textPtr->insertPos;
} else if ((c == 's') && (length >= 5)
- && (strncmp(string, "sel.first", (unsigned) length) == 0)) {
+ && (strncmp(string, "sel.first", length) == 0)) {
if (textInfoPtr->selItemPtr != itemPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"selection isn't in item", -1));
@@ -1367,7 +1416,7 @@ GetTextIndex(
}
*indexPtr = textInfoPtr->selectFirst;
} else if ((c == 's') && (length >= 5)
- && (strncmp(string, "sel.last", (unsigned) length) == 0)) {
+ && (strncmp(string, "sel.last", length) == 0)) {
if (textInfoPtr->selItemPtr != itemPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"selection isn't in item", -1));
@@ -1393,16 +1442,10 @@ GetTextIndex(
goto badIndex;
}
y = (int) ((tmp < 0) ? tmp - 0.5 : tmp + 0.5);
- x += canvasPtr->scrollX1 - (int) textPtr->drawOrigin[0];
- y += canvasPtr->scrollY1 - (int) textPtr->drawOrigin[1];
+ x -= (int) textPtr->drawOrigin[0];
+ y -= (int) textPtr->drawOrigin[1];
*indexPtr = Tk_PointToChar(textPtr->textLayout,
(int) (x*c - y*s), (int) (y*c + x*s));
- } else if (Tcl_GetIntFromObj(NULL, obj, indexPtr) == TCL_OK) {
- if (*indexPtr < 0) {
- *indexPtr = 0;
- } else if (*indexPtr > textPtr->numChars) {
- *indexPtr = textPtr->numChars;
- }
} else {
/*
* Some of the paths here leave messages in the interp's result, so we
@@ -1433,7 +1476,6 @@ GetTextIndex(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
SetTextCursor(
Tk_Canvas canvas, /* Record describing canvas widget. */
@@ -1443,6 +1485,7 @@ SetTextCursor(
* which cursor is to be positioned. */
{
TextItem *textPtr = (TextItem *) itemPtr;
+ (void)canvas;
if (index < 0) {
textPtr->insertPos = 0;
@@ -1489,6 +1532,7 @@ GetSelText(
char *text;
const char *selStart, *selEnd;
Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
+ (void)canvas;
if ((textInfoPtr->selectFirst < 0) ||
(textInfoPtr->selectFirst > textInfoPtr->selectLast)) {
@@ -1505,7 +1549,7 @@ GetSelText(
if (byteCount <= 0) {
return 0;
}
- memcpy(buffer, selStart + offset, (size_t) byteCount);
+ memcpy(buffer, selStart + offset, byteCount);
buffer[byteCount] = '\0';
return byteCount;
}
@@ -1594,9 +1638,7 @@ TextToPostscript(
}
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
@@ -1606,7 +1648,7 @@ TextToPostscript(
Tcl_GetString(Tcl_GetObjResult(interp)));
}
- x = 0; y = 0; justify = NULL; /* lint. */
+ x = 0; y = 0; justify = NULL;
switch (textPtr->anchor) {
case TK_ANCHOR_NW: x = 0; y = 0; break;
case TK_ANCHOR_N: x = 1; y = 0; break;
diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c
index 6ce671d..1d6a394 100644
--- a/generic/tkCanvUtil.c
+++ b/generic/tkCanvUtil.c
@@ -12,7 +12,6 @@
#include "tkInt.h"
#include "tkCanvas.h"
-#include <assert.h>
/*
* Structures defined only in this file.
@@ -29,15 +28,16 @@ const Tk_SmoothMethod tkBezierSmoothMethod = {
"true",
TkMakeBezierCurve,
(void (*) (Tcl_Interp *interp, Tk_Canvas canvas, double *coordPtr,
- int numPoints, int numSteps)) TkMakeBezierPostscript,
+ int numPoints, int numSteps))(void *)TkMakeBezierPostscript,
};
static const Tk_SmoothMethod tkRawSmoothMethod = {
"raw",
TkMakeRawCurve,
(void (*) (Tcl_Interp *interp, Tk_Canvas canvas, double *coordPtr,
- int numPoints, int numSteps)) TkMakeRawCurvePostscript,
+ int numPoints, int numSteps))(void *)TkMakeRawCurvePostscript,
};
+
/*
* Function forward-declarations.
*/
@@ -231,12 +231,14 @@ Tk_CanvasWindowCoords(
int
Tk_CanvasGetCoord(
- Tcl_Interp *interp, /* Interpreter for error reporting. */
+ Tcl_Interp *dummy, /* Interpreter for error reporting. */
Tk_Canvas canvas, /* Canvas to which coordinate applies. */
const char *string, /* Describes coordinate (any screen coordinate
* form may be used here). */
double *doublePtr) /* Place to store converted coordinate. */
{
+ (void)dummy;
+
if (Tk_GetScreenMM(Canvas(canvas)->interp, Canvas(canvas)->tkwin, string,
doublePtr) != TCL_OK) {
return TCL_ERROR;
@@ -267,12 +269,14 @@ Tk_CanvasGetCoord(
int
Tk_CanvasGetCoordFromObj(
- Tcl_Interp *interp, /* Interpreter for error reporting. */
+ Tcl_Interp *dummy, /* Interpreter for error reporting. */
Tk_Canvas canvas, /* Canvas to which coordinate applies. */
Tcl_Obj *obj, /* Describes coordinate (any screen coordinate
* form may be used here). */
double *doublePtr) /* Place to store converted coordinate. */
{
+ (void)dummy;
+
return Tk_GetDoublePixelsFromObj(Canvas(canvas)->interp, Canvas(canvas)->tkwin, obj, doublePtr);
}
@@ -332,7 +336,7 @@ Tk_CanvasSetOffset(
* redisplaying the canvas. */
Tk_TSOffset *offset) /* Offset (may be NULL pointer)*/
{
- register TkCanvas *canvasPtr = Canvas(canvas);
+ TkCanvas *canvasPtr = Canvas(canvas);
int flags = 0;
int x = - canvasPtr->drawableXOrigin;
int y = - canvasPtr->drawableYOrigin;
@@ -399,17 +403,20 @@ Tk_CanvasGetTextInfo(
int
Tk_CanvasTagsParseProc(
- ClientData clientData, /* Not used.*/
+ ClientData dummy, /* Not used.*/
Tcl_Interp *interp, /* Used for reporting errors. */
Tk_Window tkwin, /* Window containing canvas widget. */
const char *value, /* Value of option (list of tag names). */
char *widgRec, /* Pointer to record for item. */
int offset) /* Offset into item (ignored). */
{
- register Tk_Item *itemPtr = (Tk_Item *) widgRec;
+ Tk_Item *itemPtr = (Tk_Item *) widgRec;
int argc, i;
const char **argv;
Tk_Uid *newPtr;
+ (void)dummy;
+ (void)tkwin;
+ (void)offset;
/*
* Break the value up into the individual tag names.
@@ -424,7 +431,7 @@ Tk_CanvasTagsParseProc(
*/
if (itemPtr->tagSpace < argc) {
- newPtr = ckalloc(argc * sizeof(Tk_Uid));
+ newPtr = (Tk_Uid *)ckalloc(argc * sizeof(Tk_Uid));
for (i = itemPtr->numTags-1; i >= 0; i--) {
newPtr[i] = itemPtr->tagPtr[i];
}
@@ -466,7 +473,7 @@ Tk_CanvasTagsParseProc(
const char *
Tk_CanvasTagsPrintProc(
- ClientData clientData, /* Ignored. */
+ ClientData dummy, /* Ignored. */
Tk_Window tkwin, /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
int offset, /* Ignored. */
@@ -474,7 +481,10 @@ Tk_CanvasTagsPrintProc(
* information about how to reclaim storage
* for return string. */
{
- register Tk_Item *itemPtr = (Tk_Item *) widgRec;
+ Tk_Item *itemPtr = (Tk_Item *) widgRec;
+ (void)dummy;
+ (void)tkwin;
+ (void)offset;
if (itemPtr->numTags == 0) {
*freeProcPtr = NULL;
@@ -508,13 +518,16 @@ Tk_CanvasTagsPrintProc(
int
TkCanvasDashParseProc(
- ClientData clientData, /* Not used.*/
+ ClientData dummy, /* Not used.*/
Tcl_Interp *interp, /* Used for reporting errors. */
Tk_Window tkwin, /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
int offset) /* Offset into item. */
{
+ (void)dummy;
+ (void)tkwin;
+
return Tk_GetDash(interp, value, (Tk_Dash *) (widgRec+offset));
}
@@ -542,7 +555,7 @@ TkCanvasDashParseProc(
const char *
TkCanvasDashPrintProc(
- ClientData clientData, /* Ignored. */
+ ClientData dummy, /* Ignored. */
Tk_Window tkwin, /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
int offset, /* Offset in record for item. */
@@ -553,11 +566,13 @@ TkCanvasDashPrintProc(
Tk_Dash *dash = (Tk_Dash *) (widgRec+offset);
char *buffer, *p;
int i = dash->number;
+ (void)dummy;
+ (void)tkwin;
if (i < 0) {
i = -i;
*freeProcPtr = TCL_DYNAMIC;
- buffer = ckalloc(i + 1);
+ buffer = (char *)ckalloc(i + 1);
p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array;
memcpy(buffer, p, (unsigned int) i);
buffer[i] = 0;
@@ -566,7 +581,7 @@ TkCanvasDashPrintProc(
*freeProcPtr = NULL;
return "";
}
- buffer = ckalloc(4 * i);
+ buffer = (char *)ckalloc(4 * i);
*freeProcPtr = TCL_DYNAMIC;
p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array;
@@ -602,12 +617,12 @@ InitSmoothMethods(
{
SmoothAssocData *methods, *ptr;
- methods = ckalloc(sizeof(SmoothAssocData));
+ methods = (SmoothAssocData *)ckalloc(sizeof(SmoothAssocData));
methods->smooth.name = tkRawSmoothMethod.name;
methods->smooth.coordProc = tkRawSmoothMethod.coordProc;
methods->smooth.postscriptProc = tkRawSmoothMethod.postscriptProc;
- ptr = methods->nextPtr = ckalloc(sizeof(SmoothAssocData));
+ ptr = methods->nextPtr = (SmoothAssocData *)ckalloc(sizeof(SmoothAssocData));
ptr->smooth.name = tkBezierSmoothMethod.name;
ptr->smooth.coordProc = tkBezierSmoothMethod.coordProc;
ptr->smooth.postscriptProc = tkBezierSmoothMethod.postscriptProc;
@@ -641,7 +656,7 @@ Tk_CreateSmoothMethod(
const Tk_SmoothMethod *smooth)
{
SmoothAssocData *methods, *typePtr2, *prevPtr, *ptr;
- methods = Tcl_GetAssocData(interp, "smoothMethod", NULL);
+ methods = (SmoothAssocData *)Tcl_GetAssocData(interp, "smoothMethod", NULL);
/*
* Initialize if we were not previously initialized.
@@ -667,7 +682,7 @@ Tk_CreateSmoothMethod(
break;
}
}
- ptr = ckalloc(sizeof(SmoothAssocData));
+ ptr = (SmoothAssocData *)ckalloc(sizeof(SmoothAssocData));
ptr->smooth.name = smooth->name;
ptr->smooth.coordProc = smooth->coordProc;
ptr->smooth.postscriptProc = smooth->postscriptProc;
@@ -696,9 +711,10 @@ static void
SmoothMethodCleanupProc(
ClientData clientData, /* Points to "smoothMethod" AssocData for the
* interpreter. */
- Tcl_Interp *interp) /* Interpreter that is being deleted. */
+ Tcl_Interp *dummy) /* Interpreter that is being deleted. */
{
- SmoothAssocData *ptr, *methods = clientData;
+ SmoothAssocData *ptr, *methods = (SmoothAssocData *)clientData;
+ (void)dummy;
while (methods != NULL) {
ptr = methods;
@@ -726,26 +742,28 @@ SmoothMethodCleanupProc(
int
TkSmoothParseProc(
- ClientData clientData, /* Ignored. */
+ ClientData dummy, /* Ignored. */
Tcl_Interp *interp, /* Used for reporting errors. */
Tk_Window tkwin, /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
int offset) /* Offset into item. */
{
- register const Tk_SmoothMethod **smoothPtr =
+ const Tk_SmoothMethod **smoothPtr =
(const Tk_SmoothMethod **) (widgRec + offset);
const Tk_SmoothMethod *smooth = NULL;
int b;
size_t length;
SmoothAssocData *methods;
+ (void)dummy;
+ (void)tkwin;
if (value == NULL || *value == 0) {
*smoothPtr = NULL;
return TCL_OK;
}
length = strlen(value);
- methods = Tcl_GetAssocData(interp, "smoothMethod", NULL);
+ methods = (SmoothAssocData *)Tcl_GetAssocData(interp, "smoothMethod", NULL);
/*
* Not initialized yet; fix that now.
@@ -818,7 +836,7 @@ TkSmoothParseProc(
const char *
TkSmoothPrintProc(
- ClientData clientData, /* Ignored. */
+ ClientData dummy, /* Ignored. */
Tk_Window tkwin, /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
int offset, /* Offset into item. */
@@ -826,8 +844,11 @@ TkSmoothPrintProc(
* information about how to reclaim storage
* for return string. */
{
- register const Tk_SmoothMethod *smoothPtr =
+ const Tk_SmoothMethod *smoothPtr =
* (Tk_SmoothMethod **) (widgRec + offset);
+ (void)dummy;
+ (void)tkwin;
+ (void)freeProcPtr;
return smoothPtr ? smoothPtr->name : "0";
}
@@ -877,7 +898,7 @@ Tk_GetDash(
}
i = strlen(value);
if (i > (int) sizeof(char *)) {
- dash->pattern.pt = pt = ckalloc(strlen(value));
+ dash->pattern.pt = pt = (char *)ckalloc(strlen(value));
} else {
pt = dash->pattern.array;
}
@@ -895,7 +916,7 @@ Tk_GetDash(
ckfree(dash->pattern.pt);
}
if (argc > (int) sizeof(char *)) {
- dash->pattern.pt = pt = ckalloc(argc);
+ dash->pattern.pt = pt = (char *)ckalloc(argc);
} else {
pt = dash->pattern.array;
}
@@ -1226,7 +1247,7 @@ Tk_ChangeOutlineGC(
int i = -dash->number;
p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array;
- q = ckalloc(2 * i);
+ q = (char *)ckalloc(2 * i);
i = DashConvert(q, p, i, width);
XSetDashes(Canvas(canvas)->display, outline->gc, outline->offset, q,i);
ckfree(q);
@@ -1265,7 +1286,6 @@ Tk_ChangeOutlineGC(
}
return 0;
}
-
/*
*--------------------------------------------------------------
@@ -1448,7 +1468,7 @@ Tk_CanvasPsOutline(
Tcl_AppendPrintfToObj(psObj, "] %d setdash\n", outline->offset);
} else if (dash->number < 0) {
if (dash->number < -5) {
- lptr = ckalloc(1 - 2*dash->number);
+ lptr = (char *)ckalloc(1 - 2*dash->number);
}
i = DashConvert(lptr, ptr, -dash->number, width);
if (i > 0) {
@@ -1469,19 +1489,11 @@ Tk_CanvasPsOutline(
Tcl_AppendToObj(psObj, "] 0 setdash\n", -1);
}
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * Note that psObj might hold an invalid reference now.
- */
+ Tk_CanvasPsColor(interp, canvas, color);
if (stipple != None) {
Tcl_AppendToObj(GetPostscriptBuffer(interp), "StrokeClip ", -1);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- return TCL_ERROR;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
} else {
Tcl_AppendToObj(GetPostscriptBuffer(interp), "stroke\n", -1);
}
@@ -1661,6 +1673,7 @@ TkCanvTranslatePath(
int i, j; /* Loop counters */
double limit[4]; /* Boundries at which clipping occurs */
double staticSpace[480]; /* Temp space from the stack */
+ (void)closedPath;
/*
* Constrain all vertices of the path to be within a box that is no larger
@@ -1720,7 +1733,7 @@ TkCanvTranslatePath(
if (numVertex*12 <= (int) (sizeof(staticSpace) / sizeof(double))) {
tempArr = staticSpace;
} else {
- tempArr = ckalloc(numVertex * 12 * sizeof(double));
+ tempArr = (double *)ckalloc(numVertex * 12 * sizeof(double));
}
for (i=0; i<numVertex*2; i++){
tempArr[i] = coordArr[i];
@@ -1865,6 +1878,43 @@ TkCanvTranslatePath(
}
/*
+ *--------------------------------------------------------------
+ *
+ * TkRotatePoint --
+ *
+ * Rotate a point about another point. The angle should be converted into
+ * its sine and cosine before calling this function.
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * The point in (*xPtr,*yPtr) is updated to be rotated about
+ * (originX,originY) by the amount given by the sine and cosine of the
+ * angle to rotate.
+ *
+ *--------------------------------------------------------------
+ */
+
+void
+TkRotatePoint(
+ double originX, double originY, /* The point about which to rotate. */
+ double sine, double cosine, /* How much to rotate? */
+ double *xPtr, double *yPtr) /* The point to be rotated. (INOUT) */
+{
+ double x = *xPtr - originX;
+ double y = *yPtr - originY;
+
+ /*
+ * Beware! The canvas coordinate space is flipped vertically, so rotations
+ * go the "wrong" way with respect to mathematics.
+ */
+
+ *xPtr = originX + x * cosine + y * sine;
+ *yPtr = originY - x * sine + y * cosine;
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/generic/tkCanvWind.c b/generic/tkCanvWind.c
index f73546f..22729d6 100644
--- a/generic/tkCanvWind.c
+++ b/generic/tkCanvWind.c
@@ -46,17 +46,17 @@ static const Tk_CustomOption tagsOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
- "center", Tk_Offset(WindowItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "center", offsetof(WindowItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_PIXELS, "-height", NULL, NULL,
- "0", Tk_Offset(WindowItem, height), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(WindowItem, height), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_PIXELS, "-width", NULL, NULL,
- "0", Tk_Offset(WindowItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(WindowItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_WINDOW, "-window", NULL, NULL,
- NULL, Tk_Offset(WindowItem, tkwin), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(WindowItem, tkwin), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -77,6 +77,8 @@ static void DeleteWinItem(Tk_Canvas canvas,
static void DisplayWinItem(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
+static void RotateWinItem(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleWinItem(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -130,7 +132,8 @@ Tk_ItemType tkWindowType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateWinItem, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -405,6 +408,7 @@ DeleteWinItem(
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
Tk_Window canvasTkwin = Tk_CanvasTkwin(canvas);
+ (void)display;
if (winItemPtr->tkwin != NULL) {
Tk_DeleteEventHandler(winItemPtr->tkwin, StructureNotifyMask,
@@ -567,6 +571,11 @@ DisplayWinItem(
short x, y;
Tk_Window canvasTkwin = Tk_CanvasTkwin(canvas);
Tk_State state = itemPtr->state;
+ (void)display;
+ (void)regionX;
+ (void)regionY;
+ (void)regionWidth;
+ (void)regionHeight;
if (winItemPtr->tkwin == NULL) {
return;
@@ -655,6 +664,7 @@ WinItemToPoint(
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
double x1, x2, y1, y2, xDiff, yDiff;
+ (void)canvas;
x1 = winItemPtr->header.x1;
y1 = winItemPtr->header.y1;
@@ -712,6 +722,7 @@ WinItemToArea(
* area. */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
+ (void)canvas;
if ((rectPtr[2] <= winItemPtr->header.x1)
|| (rectPtr[0] >= winItemPtr->header.x2)
@@ -748,9 +759,12 @@ WinItemToArea(
#ifdef X_GetImage
static int
xerrorhandler(
- ClientData clientData,
+ ClientData dummy,
XErrorEvent *e)
{
+ (void)dummy;
+ (void)e;
+
return 0;
}
#endif /* X_GetImage */
@@ -915,6 +929,40 @@ CanvasPsWindow(
/*
*--------------------------------------------------------------
*
+ * RotateWinItem --
+ *
+ * This function is called to rotate a window item by a given amount
+ * about a point. Note that this does *not* rotate the window of the
+ * item.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the window anchor is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateWinItem(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being rotated. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ WindowItem *winItemPtr = (WindowItem *) itemPtr;
+
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &winItemPtr->x, &winItemPtr->y);
+ ComputeWindowBbox(canvas, winItemPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ScaleWinItem --
*
* This function is invoked to rescale a window item.
@@ -1007,7 +1055,7 @@ WinItemStructureProc(
ClientData clientData, /* Pointer to record describing window item. */
XEvent *eventPtr) /* Describes what just happened. */
{
- WindowItem *winItemPtr = clientData;
+ WindowItem *winItemPtr = (WindowItem *)clientData;
if (eventPtr->type == DestroyNotify) {
winItemPtr->tkwin = NULL;
@@ -1037,7 +1085,8 @@ WinItemRequestProc(
ClientData clientData, /* Pointer to record for window item. */
Tk_Window tkwin) /* Window that changed its desired size. */
{
- WindowItem *winItemPtr = clientData;
+ WindowItem *winItemPtr = (WindowItem *)clientData;
+ (void)tkwin;
ComputeWindowBbox(winItemPtr->canvas, winItemPtr);
@@ -1067,15 +1116,15 @@ WinItemRequestProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
WinItemLostSlaveProc(
ClientData clientData, /* WindowItem structure for slave window that
* was stolen away. */
Tk_Window tkwin) /* Tk's handle for the slave window. */
{
- WindowItem *winItemPtr = clientData;
+ WindowItem *winItemPtr = (WindowItem *)clientData;
Tk_Window canvasTkwin = Tk_CanvasTkwin(winItemPtr->canvas);
+ (void)tkwin;
Tk_DeleteEventHandler(winItemPtr->tkwin, StructureNotifyMask,
WinItemStructureProc, winItemPtr);
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index f3778a6..d3868d5 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -91,92 +91,92 @@ static const Tk_CustomOption offsetOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_CANVAS_BG_COLOR, Tk_Offset(TkCanvas, bgBorder),
+ DEF_CANVAS_BG_COLOR, offsetof(TkCanvas, bgBorder),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_CANVAS_BG_MONO, Tk_Offset(TkCanvas, bgBorder),
+ DEF_CANVAS_BG_MONO, offsetof(TkCanvas, bgBorder),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_SYNONYM, "-bd", "borderWidth", NULL, NULL, 0, 0, NULL},
{TK_CONFIG_SYNONYM, "-bg", "background", NULL, NULL, 0, 0, NULL},
{TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_CANVAS_BORDER_WIDTH, Tk_Offset(TkCanvas, borderWidth), 0, NULL},
+ DEF_CANVAS_BORDER_WIDTH, offsetof(TkCanvas, borderWidth), 0, NULL},
{TK_CONFIG_DOUBLE, "-closeenough", "closeEnough", "CloseEnough",
- DEF_CANVAS_CLOSE_ENOUGH, Tk_Offset(TkCanvas, closeEnough), 0, NULL},
+ DEF_CANVAS_CLOSE_ENOUGH, offsetof(TkCanvas, closeEnough), 0, NULL},
{TK_CONFIG_BOOLEAN, "-confine", "confine", "Confine",
- DEF_CANVAS_CONFINE, Tk_Offset(TkCanvas, confine), 0, NULL},
+ DEF_CANVAS_CONFINE, offsetof(TkCanvas, confine), 0, NULL},
{TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_CANVAS_CURSOR, Tk_Offset(TkCanvas, cursor), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVAS_CURSOR, offsetof(TkCanvas, cursor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-height", "height", "Height",
- DEF_CANVAS_HEIGHT, Tk_Offset(TkCanvas, height), 0, NULL},
+ DEF_CANVAS_HEIGHT, offsetof(TkCanvas, height), 0, NULL},
{TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_CANVAS_HIGHLIGHT_BG,
- Tk_Offset(TkCanvas, highlightBgColorPtr), 0, NULL},
+ offsetof(TkCanvas, highlightBgColorPtr), 0, NULL},
{TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_CANVAS_HIGHLIGHT, Tk_Offset(TkCanvas, highlightColorPtr), 0, NULL},
+ DEF_CANVAS_HIGHLIGHT, offsetof(TkCanvas, highlightColorPtr), 0, NULL},
{TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness",
- DEF_CANVAS_HIGHLIGHT_WIDTH, Tk_Offset(TkCanvas, highlightWidth), 0, NULL},
+ DEF_CANVAS_HIGHLIGHT_WIDTH, offsetof(TkCanvas, highlightWidth), 0, NULL},
{TK_CONFIG_BORDER, "-insertbackground", "insertBackground", "Foreground",
- DEF_CANVAS_INSERT_BG, Tk_Offset(TkCanvas, textInfo.insertBorder), 0, NULL},
+ DEF_CANVAS_INSERT_BG, offsetof(TkCanvas, textInfo.insertBorder), 0, NULL},
{TK_CONFIG_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth",
DEF_CANVAS_INSERT_BD_COLOR,
- Tk_Offset(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_COLOR_ONLY, NULL},
+ offsetof(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth",
DEF_CANVAS_INSERT_BD_MONO,
- Tk_Offset(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_MONO_ONLY, NULL},
+ offsetof(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_CANVAS_INSERT_OFF_TIME, Tk_Offset(TkCanvas, insertOffTime), 0, NULL},
+ DEF_CANVAS_INSERT_OFF_TIME, offsetof(TkCanvas, insertOffTime), 0, NULL},
{TK_CONFIG_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_CANVAS_INSERT_ON_TIME, Tk_Offset(TkCanvas, insertOnTime), 0, NULL},
+ DEF_CANVAS_INSERT_ON_TIME, offsetof(TkCanvas, insertOnTime), 0, NULL},
{TK_CONFIG_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_CANVAS_INSERT_WIDTH, Tk_Offset(TkCanvas, textInfo.insertWidth), 0, NULL},
+ DEF_CANVAS_INSERT_WIDTH, offsetof(TkCanvas, textInfo.insertWidth), 0, NULL},
{TK_CONFIG_CUSTOM, "-offset", "offset", "Offset", "0,0",
- Tk_Offset(TkCanvas, tsoffset),TK_CONFIG_DONT_SET_DEFAULT,
+ offsetof(TkCanvas, tsoffset),TK_CONFIG_DONT_SET_DEFAULT,
&offsetOption},
{TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_CANVAS_RELIEF, Tk_Offset(TkCanvas, relief), 0, NULL},
+ DEF_CANVAS_RELIEF, offsetof(TkCanvas, relief), 0, NULL},
{TK_CONFIG_STRING, "-scrollregion", "scrollRegion", "ScrollRegion",
- DEF_CANVAS_SCROLL_REGION, Tk_Offset(TkCanvas, regionString),
+ DEF_CANVAS_SCROLL_REGION, offsetof(TkCanvas, regionString),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_CANVAS_SELECT_COLOR, Tk_Offset(TkCanvas, textInfo.selBorder),
+ DEF_CANVAS_SELECT_COLOR, offsetof(TkCanvas, textInfo.selBorder),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_CANVAS_SELECT_MONO, Tk_Offset(TkCanvas, textInfo.selBorder),
+ DEF_CANVAS_SELECT_MONO, offsetof(TkCanvas, textInfo.selBorder),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth",
DEF_CANVAS_SELECT_BD_COLOR,
- Tk_Offset(TkCanvas, textInfo.selBorderWidth), TK_CONFIG_COLOR_ONLY, NULL},
+ offsetof(TkCanvas, textInfo.selBorderWidth), TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth",
- DEF_CANVAS_SELECT_BD_MONO, Tk_Offset(TkCanvas, textInfo.selBorderWidth),
+ DEF_CANVAS_SELECT_BD_MONO, offsetof(TkCanvas, textInfo.selBorderWidth),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_CANVAS_SELECT_FG_COLOR, Tk_Offset(TkCanvas, textInfo.selFgColorPtr),
+ DEF_CANVAS_SELECT_FG_COLOR, offsetof(TkCanvas, textInfo.selFgColorPtr),
TK_CONFIG_COLOR_ONLY|TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_CANVAS_SELECT_FG_MONO, Tk_Offset(TkCanvas, textInfo.selFgColorPtr),
+ DEF_CANVAS_SELECT_FG_MONO, offsetof(TkCanvas, textInfo.selFgColorPtr),
TK_CONFIG_MONO_ONLY|TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-state", "state", "State",
- "normal", Tk_Offset(TkCanvas, canvas_state), TK_CONFIG_DONT_SET_DEFAULT,
+ "normal", offsetof(TkCanvas, canvas_state), TK_CONFIG_DONT_SET_DEFAULT,
&stateOption},
{TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_CANVAS_TAKE_FOCUS, Tk_Offset(TkCanvas, takeFocus),
+ DEF_CANVAS_TAKE_FOCUS, offsetof(TkCanvas, takeFocus),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-width", "width", "Width",
- DEF_CANVAS_WIDTH, Tk_Offset(TkCanvas, width), 0, NULL},
+ DEF_CANVAS_WIDTH, offsetof(TkCanvas, width), 0, NULL},
{TK_CONFIG_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_CANVAS_X_SCROLL_CMD, Tk_Offset(TkCanvas, xScrollCmd),
+ DEF_CANVAS_X_SCROLL_CMD, offsetof(TkCanvas, xScrollCmd),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-xscrollincrement", "xScrollIncrement",
"ScrollIncrement",
- DEF_CANVAS_X_SCROLL_INCREMENT, Tk_Offset(TkCanvas, xScrollIncrement),
+ DEF_CANVAS_X_SCROLL_INCREMENT, offsetof(TkCanvas, xScrollIncrement),
0, NULL},
{TK_CONFIG_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- DEF_CANVAS_Y_SCROLL_CMD, Tk_Offset(TkCanvas, yScrollCmd),
+ DEF_CANVAS_Y_SCROLL_CMD, offsetof(TkCanvas, yScrollCmd),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-yscrollincrement", "yScrollIncrement",
"ScrollIncrement",
- DEF_CANVAS_Y_SCROLL_INCREMENT, Tk_Offset(TkCanvas, yScrollIncrement),
+ DEF_CANVAS_Y_SCROLL_INCREMENT, offsetof(TkCanvas, yScrollIncrement),
0, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -241,6 +241,9 @@ static void CanvasWorldChanged(ClientData instanceData);
static int ConfigureCanvas(Tcl_Interp *interp,
TkCanvas *canvasPtr, int argc,
Tcl_Obj *const *argv, int flags);
+static void DefaultRotateImplementation(TkCanvas *canvasPtr,
+ Tk_Item *itemPtr, double x, double y,
+ double angleRadians);
static void DestroyCanvas(void *memPtr);
static int DrawCanvas(Tcl_Interp *interp, ClientData clientData, Tk_PhotoHandle photohandle, int subsample, int zoom);
static void DisplayCanvas(ClientData clientData);
@@ -560,6 +563,102 @@ ItemTranslate(
itemPtr->typePtr->translateProc((Tk_Canvas) canvasPtr, itemPtr,
xDelta, yDelta);
}
+
+static inline void
+ItemRotate(
+ TkCanvas *canvasPtr,
+ Tk_Item *itemPtr,
+ double x,
+ double y,
+ double angleRadians)
+{
+ if (itemPtr->typePtr->rotateProc != NULL) {
+ itemPtr->typePtr->rotateProc((Tk_Canvas) canvasPtr,
+ itemPtr, x, y, angleRadians);
+ } else {
+ DefaultRotateImplementation(canvasPtr, itemPtr, x, y, angleRadians);
+ }
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * DefaultRotateImplementation --
+ *
+ * The default implementation of the rotation operation, used when items
+ * do not provide their own version.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+DefaultRotateImplementation(
+ TkCanvas *canvasPtr,
+ Tk_Item *itemPtr,
+ double x,
+ double y,
+ double angleRadians)
+{
+ int objc, i, ok = 1;
+ Tcl_Obj **objv, **newObjv;
+ double *coordv;
+ double s = sin(angleRadians);
+ double c = cos(angleRadians);
+ Tcl_Interp *interp = canvasPtr->interp;
+
+ /*
+ * Get the coordinates out of the item.
+ */
+
+ if (ItemCoords(canvasPtr, itemPtr, 0, NULL) == TCL_OK &&
+ Tcl_ListObjGetElements(NULL, Tcl_GetObjResult(interp),
+ &objc, &objv) == TCL_OK) {
+ coordv = (double *) ckalloc(sizeof(double) * objc);
+ for (i=0 ; i<objc ; i++) {
+ if (Tcl_GetDoubleFromObj(NULL, objv[i], &coordv[i]) != TCL_OK) {
+ ok = 0;
+ break;
+ }
+ }
+ if (ok) {
+ /*
+ * Apply the rotation.
+ */
+
+ for (i=0 ; i<objc ; i+=2) {
+ double px = coordv[i+0] - x;
+ double py = coordv[i+1] - y;
+ double nx = px * c - py * s;
+ double ny = px * s + py * c;
+
+ coordv[i+0] = nx + x;
+ coordv[i+1] = ny + y;
+ }
+
+ /*
+ * Write the coordinates back into the item.
+ */
+
+ newObjv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * objc);
+ for (i=0 ; i<objc ; i++) {
+ newObjv[i] = Tcl_NewDoubleObj(coordv[i]);
+ Tcl_IncrRefCount(newObjv[i]);
+ }
+ ItemCoords(canvasPtr, itemPtr, objc, newObjv);
+ for (i=0 ; i<objc ; i++) {
+ Tcl_DecrRefCount(newObjv[i]);
+ }
+ ckfree((char *) newObjv);
+ }
+ ckfree((char *) coordv);
+ }
+
+ /*
+ * The interpreter result was (probably) modified above; reset it.
+ */
+
+ Tcl_ResetResult(interp);
+}
/*
*--------------------------------------------------------------
@@ -585,7 +684,7 @@ Tk_CanvasObjCmd(
int argc, /* Number of arguments. */
Tcl_Obj *const argv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
TkCanvas *canvasPtr;
Tk_Window newWin;
@@ -609,7 +708,7 @@ Tk_CanvasObjCmd(
* pointers).
*/
- canvasPtr = ckalloc(sizeof(TkCanvas));
+ canvasPtr = (TkCanvas *)ckalloc(sizeof(TkCanvas));
canvasPtr->tkwin = newWin;
canvasPtr->display = Tk_Display(newWin);
canvasPtr->interp = interp;
@@ -645,7 +744,7 @@ Tk_CanvasObjCmd(
canvasPtr->textInfo.cursorOn = 0;
canvasPtr->insertOnTime = 0;
canvasPtr->insertOffTime = 0;
- canvasPtr->insertBlinkHandler = (Tcl_TimerToken) NULL;
+ canvasPtr->insertBlinkHandler = NULL;
canvasPtr->xOrigin = canvasPtr->yOrigin = 0;
canvasPtr->drawableXOrigin = canvasPtr->drawableYOrigin = 0;
canvasPtr->bindingTable = NULL;
@@ -733,7 +832,7 @@ CanvasWidgetCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- TkCanvas *canvasPtr = clientData;
+ TkCanvas *canvasPtr = (TkCanvas *)clientData;
int c, result;
Tk_Item *itemPtr = NULL; /* Initialization needed only to prevent
* compiler warning. */
@@ -746,25 +845,24 @@ CanvasWidgetCmd(
"canvasy", "cget", "configure", "coords",
"create", "dchars", "delete", "dtag",
"find", "focus", "gettags", "icursor",
- "image",
- "imove", "index", "insert", "itemcget",
- "itemconfigure",
+ "image", "imove", "index", "insert",
+ "itemcget", "itemconfigure",
"lower", "move", "moveto", "postscript",
- "raise", "rchars", "scale", "scan",
- "select", "type", "xview", "yview",
- NULL
+ "raise", "rchars", "rotate", "scale",
+ "scan", "select", "type", "xview",
+ "yview", NULL
};
enum options {
CANV_ADDTAG, CANV_BBOX, CANV_BIND, CANV_CANVASX,
CANV_CANVASY, CANV_CGET, CANV_CONFIGURE, CANV_COORDS,
CANV_CREATE, CANV_DCHARS, CANV_DELETE, CANV_DTAG,
CANV_FIND, CANV_FOCUS, CANV_GETTAGS, CANV_ICURSOR,
- CANV_IMAGE,
- CANV_IMOVE, CANV_INDEX, CANV_INSERT, CANV_ITEMCGET,
- CANV_ITEMCONFIGURE,
+ CANV_IMAGE, CANV_IMOVE, CANV_INDEX, CANV_INSERT,
+ CANV_ITEMCGET, CANV_ITEMCONFIGURE,
CANV_LOWER, CANV_MOVE, CANV_MOVETO, CANV_POSTSCRIPT,
- CANV_RAISE, CANV_RCHARS, CANV_SCALE, CANV_SCAN,
- CANV_SELECT, CANV_TYPE, CANV_XVIEW, CANV_YVIEW
+ CANV_RAISE, CANV_RCHARS, CANV_ROTATE, CANV_SCALE,
+ CANV_SCAN, CANV_SELECT, CANV_TYPE, CANV_XVIEW,
+ CANV_YVIEW
};
if (objc < 2) {
@@ -831,10 +929,10 @@ CanvasWidgetCmd(
if (gotAny) {
Tcl_Obj *resultObjs[4];
- resultObjs[0] = Tcl_NewIntObj(x1);
- resultObjs[1] = Tcl_NewIntObj(y1);
- resultObjs[2] = Tcl_NewIntObj(x2);
- resultObjs[3] = Tcl_NewIntObj(y2);
+ resultObjs[0] = Tcl_NewWideIntObj(x1);
+ resultObjs[1] = Tcl_NewWideIntObj(y1);
+ resultObjs[2] = Tcl_NewWideIntObj(x2);
+ resultObjs[3] = Tcl_NewWideIntObj(y2);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, resultObjs));
}
break;
@@ -864,7 +962,7 @@ CanvasWidgetCmd(
entryPtr = Tcl_FindHashEntry(&canvasPtr->idTable,
INT2PTR(searchPtr->id));
if (entryPtr != NULL) {
- itemPtr = Tcl_GetHashValue(entryPtr);
+ itemPtr = (Tk_Item *)Tcl_GetHashValue(entryPtr);
object = itemPtr;
}
@@ -938,7 +1036,7 @@ CanvasWidgetCmd(
result = TCL_ERROR;
goto done;
}
- if (mask & (unsigned) ~(ButtonMotionMask|Button1MotionMask
+ if (mask & ~(unsigned long)(ButtonMotionMask|Button1MotionMask
|Button2MotionMask|Button3MotionMask|Button4MotionMask
|Button5MotionMask|ButtonPressMask|ButtonReleaseMask
|EnterWindowMask|LeaveWindowMask|KeyPressMask
@@ -1153,7 +1251,7 @@ CanvasWidgetCmd(
int isNew = 0;
Tcl_HashEntry *entryPtr;
const char *arg;
- size_t length;
+ TkSizeT length;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "type coords ?arg ...?");
@@ -1207,7 +1305,7 @@ CanvasWidgetCmd(
}
typePtr = matchPtr;
- itemPtr = ckalloc(typePtr->itemSize);
+ itemPtr = (Tk_Item *)ckalloc(typePtr->itemSize);
itemPtr->id = canvasPtr->nextId;
canvasPtr->nextId++;
itemPtr->tagPtr = itemPtr->staticTagSpace;
@@ -1239,7 +1337,7 @@ CanvasWidgetCmd(
itemPtr->redraw_flags |= FORCE_REDRAW;
EventuallyRedrawItem(canvasPtr, itemPtr);
canvasPtr->flags |= REPICK_NEEDED;
- Tcl_SetObjResult(interp, Tcl_NewIntObj(itemPtr->id));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(itemPtr->id));
break;
}
case CANV_DCHARS: {
@@ -1361,9 +1459,22 @@ CanvasWidgetCmd(
FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done) {
for (i = itemPtr->numTags-1; i >= 0; i--) {
if (itemPtr->tagPtr[i] == tag) {
- itemPtr->tagPtr[i] = itemPtr->tagPtr[itemPtr->numTags-1];
+
+ /*
+ * Don't shuffle the tags sequence: memmove the tags.
+ */
+
+ memmove((void *)(itemPtr->tagPtr + i),
+ itemPtr->tagPtr + i + 1,
+ (itemPtr->numTags - (i+1)) * sizeof(Tk_Uid));
itemPtr->numTags--;
- }
+
+ /*
+ * There must be no break here: all tags with the same name must
+ * be deleted.
+ */
+
+ }
}
}
break;
@@ -1385,7 +1496,7 @@ CanvasWidgetCmd(
itemPtr = canvasPtr->textInfo.focusItemPtr;
if (objc == 2) {
if (itemPtr != NULL) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(itemPtr->id));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(itemPtr->id));
}
goto done;
}
@@ -1477,7 +1588,7 @@ CanvasWidgetCmd(
if (result != TCL_OK) {
goto done;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
break;
}
case CANV_INSERT: {
@@ -1570,11 +1681,6 @@ CanvasWidgetCmd(
} else {
FIRST_CANVAS_ITEM_MATCHING(objv[3], &searchPtr, goto done);
if (itemPtr == NULL) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "tagOrId \"%s\" doesn't match any items",
- Tcl_GetString(objv[3])));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM", NULL);
- result = TCL_ERROR;
goto done;
}
itemPtr = itemPtr->prevPtr;
@@ -1697,11 +1803,6 @@ CanvasWidgetCmd(
prevPtr = itemPtr;
}
if (prevPtr == NULL) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "tagOrId \"%s\" doesn't match any items",
- Tcl_GetString(objv[3])));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM", NULL);
- result = TCL_ERROR;
goto done;
}
}
@@ -1760,6 +1861,30 @@ CanvasWidgetCmd(
}
break;
}
+ case CANV_ROTATE: {
+ double x, y, angle;
+ Tk_Canvas canvas = (Tk_Canvas) canvasPtr;
+
+ if (objc != 6) {
+ Tcl_WrongNumArgs(interp, 2, objv, "tagOrId x y angle");
+ result = TCL_ERROR;
+ goto done;
+ }
+ if (Tk_CanvasGetCoordFromObj(interp, canvas, objv[3], &x) != TCL_OK ||
+ Tk_CanvasGetCoordFromObj(interp, canvas, objv[4], &y) != TCL_OK ||
+ Tcl_GetDoubleFromObj(interp, objv[5], &angle) != TCL_OK) {
+ result = TCL_ERROR;
+ goto done;
+ }
+ angle = angle * 3.1415927 / 180.0;
+ FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done) {
+ EventuallyRedrawItem(canvasPtr, itemPtr);
+ ItemRotate(canvasPtr, itemPtr, x, y, angle);
+ EventuallyRedrawItem(canvasPtr, itemPtr);
+ canvasPtr->flags |= REPICK_NEEDED;
+ }
+ break;
+ }
case CANV_SCALE: {
double xOrigin, yOrigin, xScale, yScale;
@@ -1924,7 +2049,7 @@ CanvasWidgetCmd(
}
if (canvasPtr->textInfo.selItemPtr != NULL) {
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(canvasPtr->textInfo.selItemPtr->id));
+ Tcl_NewWideIntObj(canvasPtr->textInfo.selItemPtr->id));
}
break;
case CANV_TO:
@@ -2111,7 +2236,7 @@ static void
DestroyCanvas(
void *memPtr) /* Info about canvas widget. */
{
- TkCanvas *canvasPtr = memPtr;
+ TkCanvas *canvasPtr = (TkCanvas *)memPtr;
Tk_Item *itemPtr;
TagSearchExpr *expr, *next;
@@ -2344,7 +2469,7 @@ static void
CanvasWorldChanged(
ClientData instanceData) /* Information about widget. */
{
- TkCanvas *canvasPtr = instanceData;
+ TkCanvas *canvasPtr = (TkCanvas *)instanceData;
Tk_Item *itemPtr;
itemPtr = canvasPtr->firstItemPtr;
@@ -2457,12 +2582,12 @@ DrawCanvas(
int subsample, /* If either subsample or zoom are not 1 then we call Tk_PhotoPutZoomedBlock() */
int zoom)
{
- TkCanvas * canvasPtr = clientData;
+ TkCanvas *canvasPtr = (TkCanvas *)clientData;
Tk_Window tkwin;
Display *displayPtr;
- Tk_PhotoImageBlock blockPtr = {0};
+ Tk_PhotoImageBlock blockPtr = {0,0,0,0,0,{0,0,0,0}};
Window wid;
- Tk_Item * itemPtr;
+ Tk_Item *itemPtr;
Pixmap pixmap = 0;
XImage *ximagePtr = NULL;
Visual *visualPtr;
@@ -2689,7 +2814,7 @@ DrawCanvas(
blockPtr.offset[1] = 1;
blockPtr.offset[2] = 2;
blockPtr.offset[3] = 3;
- blockPtr.pixelPtr = ckalloc(blockPtr.pixelSize * blockPtr.height * blockPtr.width);
+ blockPtr.pixelPtr = (unsigned char *)ckalloc(blockPtr.pixelSize * blockPtr.height * blockPtr.width);
/*
* Now convert the image data pixel by pixel from XImage to 32bit RGBA
@@ -2769,10 +2894,21 @@ DrawCanvas(
* colours and place them in the photo block. Perhaps we could
* just not bother with the alpha byte because we are using
* TK_PHOTO_COMPOSITE_SET later?
+ * ***Windows: We have to swap the red and blue values. The
+ * XImage storage is B - G - R - A which becomes a 32bit ARGB
+ * quad. However the visual mask is a 32bit ABGR quad. And
+ * Tk_PhotoPutBlock() wants R-G-B-A which is a 32bit ABGR quad.
+ * If the visual mask was correct there would be no need to
+ * swap anything here.
*/
+#ifdef _WIN32
+#define R_OFFSET 2
+#define B_OFFSET 0
+#else
#define R_OFFSET 0
#define B_OFFSET 2
+#endif
blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x + R_OFFSET] =
(unsigned char)((pixel & visualPtr->red_mask) >> rshift);
blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x +1] =
@@ -2865,7 +3001,7 @@ static void
DisplayCanvas(
ClientData clientData) /* Information about widget. */
{
- TkCanvas *canvasPtr = clientData;
+ TkCanvas *canvasPtr = (TkCanvas *)clientData;
Tk_Window tkwin = canvasPtr->tkwin;
Tk_Item *itemPtr;
Pixmap pixmap;
@@ -3119,7 +3255,7 @@ CanvasEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkCanvas *canvasPtr = clientData;
+ TkCanvas *canvasPtr = (TkCanvas *)clientData;
if (eventPtr->type == Expose) {
int x, y;
@@ -3209,7 +3345,7 @@ static void
CanvasCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TkCanvas *canvasPtr = clientData;
+ TkCanvas *canvasPtr = (TkCanvas *)clientData;
Tk_Window tkwin = canvasPtr->tkwin;
/*
@@ -3316,7 +3452,7 @@ EventuallyRedrawItem(
Tk_Item *itemPtr) /* Item to be redrawn. May be NULL, in which
* case nothing happens. */
{
- if (itemPtr == NULL) {
+ if (itemPtr == NULL || canvasPtr->tkwin == NULL) {
return;
}
if ((itemPtr->x1 >= itemPtr->x2) || (itemPtr->y1 >= itemPtr->y2) ||
@@ -3499,7 +3635,7 @@ InitCanvas(void)
static SearchUids *
GetStaticUids(void)
{
- SearchUids *searchUids =
+ SearchUids *searchUids = (SearchUids *)
Tcl_GetThreadData(&dataKey, sizeof(SearchUids));
if (searchUids->allUid == NULL) {
@@ -3538,7 +3674,7 @@ TagSearchExprInit(
TagSearchExpr *expr = *exprPtrPtr;
if (expr == NULL) {
- expr = ckalloc(sizeof(TagSearchExpr));
+ expr = (TagSearchExpr *)ckalloc(sizeof(TagSearchExpr));
expr->allocated = 0;
expr->uids = NULL;
expr->next = NULL;
@@ -3619,7 +3755,7 @@ TagSearchScan(
* Allocate primary search struct on first call.
*/
- *searchPtrPtr = searchPtr = ckalloc(sizeof(TagSearch));
+ *searchPtrPtr = searchPtr = (TagSearch *)ckalloc(sizeof(TagSearch));
searchPtr->expr = NULL;
/*
@@ -3627,7 +3763,7 @@ TagSearchScan(
*/
searchPtr->rewritebufferAllocated = 100;
- searchPtr->rewritebuffer = ckalloc(searchPtr->rewritebufferAllocated);
+ searchPtr->rewritebuffer =(char *) ckalloc(searchPtr->rewritebufferAllocated);
}
TagSearchExprInit(&searchPtr->expr);
@@ -3644,7 +3780,7 @@ TagSearchScan(
if ((unsigned) searchPtr->stringLength >=
searchPtr->rewritebufferAllocated) {
searchPtr->rewritebufferAllocated = searchPtr->stringLength + 100;
- searchPtr->rewritebuffer =
+ searchPtr->rewritebuffer = (char *)
ckrealloc(searchPtr->rewritebuffer,
searchPtr->rewritebufferAllocated);
}
@@ -3827,10 +3963,10 @@ TagSearchScanExpr(
if (expr->index >= expr->allocated-1) {
expr->allocated += 15;
if (expr->uids) {
- expr->uids = ckrealloc(expr->uids,
+ expr->uids = (Tk_Uid *)ckrealloc(expr->uids,
expr->allocated * sizeof(Tk_Uid));
} else {
- expr->uids = ckalloc(expr->allocated * sizeof(Tk_Uid));
+ expr->uids = (Tk_Uid *)ckalloc(expr->allocated * sizeof(Tk_Uid));
}
}
@@ -4242,7 +4378,7 @@ TagSearchFirst(
entryPtr = Tcl_FindHashEntry(&searchPtr->canvasPtr->idTable,
INT2PTR(searchPtr->id));
if (entryPtr != NULL) {
- itemPtr = Tcl_GetHashValue(entryPtr);
+ itemPtr = (Tk_Item *)Tcl_GetHashValue(entryPtr);
lastPtr = itemPtr->prevPtr;
} else {
lastPtr = itemPtr = NULL;
@@ -4441,7 +4577,7 @@ DoItem(
*/
if (tag == NULL) {
- Tcl_ListObjAppendElement(NULL, accumObj, Tcl_NewIntObj(itemPtr->id));
+ Tcl_ListObjAppendElement(NULL, accumObj, Tcl_NewWideIntObj(itemPtr->id));
return;
}
@@ -4460,7 +4596,7 @@ DoItem(
Tk_Uid *newTagPtr;
itemPtr->tagSpace += 5;
- newTagPtr = ckalloc(itemPtr->tagSpace * sizeof(Tk_Uid));
+ newTagPtr = (Tk_Uid*)ckalloc(itemPtr->tagSpace * sizeof(Tk_Uid));
memcpy((void *) newTagPtr, itemPtr->tagPtr,
itemPtr->numTags * sizeof(Tk_Uid));
if (itemPtr->tagPtr != itemPtr->staticTagSpace) {
@@ -4945,8 +5081,8 @@ CanvasBindProc(
ClientData clientData, /* Pointer to canvas structure. */
XEvent *eventPtr) /* Pointer to X event that just happened. */
{
- TkCanvas *canvasPtr = clientData;
- int mask;
+ TkCanvas *canvasPtr = (TkCanvas *)clientData;
+ unsigned long mask;
Tcl_Preserve(canvasPtr);
@@ -4959,26 +5095,7 @@ CanvasBindProc(
switch (eventPtr->type) {
case ButtonPress:
case ButtonRelease:
- switch (eventPtr->xbutton.button) {
- case Button1:
- mask = Button1Mask;
- break;
- case Button2:
- mask = Button2Mask;
- break;
- case Button3:
- mask = Button3Mask;
- break;
- case Button4:
- mask = Button4Mask;
- break;
- case Button5:
- mask = Button5Mask;
- break;
- default:
- mask = 0;
- break;
- }
+ mask = TkGetButtonMask(eventPtr->xbutton.button);
/*
* For button press events, repick the current item using the button
@@ -5061,7 +5178,7 @@ PickCurrentItem(
* ButtonRelease, or MotionNotify. */
{
double coords[2];
- int buttonDown;
+ unsigned long buttonDown;
Tk_Item *prevItemPtr;
SearchUids *searchUids = GetStaticUids();
@@ -5072,8 +5189,7 @@ PickCurrentItem(
* for windows.
*/
- buttonDown = canvasPtr->state
- & (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask);
+ buttonDown = canvasPtr->state & ALL_BUTTONS;
/*
* Save information about this event in the canvas. The event in the
@@ -5188,7 +5304,9 @@ PickCurrentItem(
for (i = itemPtr->numTags-1; i >= 0; i--) {
if (itemPtr->tagPtr[i] == searchUids->currentUid)
/* then */ {
- itemPtr->tagPtr[i] = itemPtr->tagPtr[itemPtr->numTags-1];
+ memmove((void *)(itemPtr->tagPtr + i),
+ itemPtr->tagPtr + i + 1,
+ (itemPtr->numTags - (i+1)) * sizeof(Tk_Uid));
itemPtr->numTags--;
break;
}
@@ -5368,7 +5486,7 @@ CanvasDoEvent(
if (numObjects <= NUM_STATIC) {
objectPtr = staticObjects;
} else {
- objectPtr = ckalloc(numObjects * sizeof(void *));
+ objectPtr = (void **)ckalloc(numObjects * sizeof(void *));
}
objectPtr[0] = (char *)searchUids->allUid;
for (i = itemPtr->numTags-1; i >= 0; i--) {
@@ -5425,7 +5543,7 @@ static void
CanvasBlinkProc(
ClientData clientData) /* Pointer to record describing entry. */
{
- TkCanvas *canvasPtr = clientData;
+ TkCanvas *canvasPtr = (TkCanvas *)clientData;
if (!canvasPtr->textInfo.gotFocus || (canvasPtr->insertOffTime == 0)) {
return;
@@ -5477,7 +5595,7 @@ CanvasFocusProc(
} else {
canvasPtr->textInfo.gotFocus = 0;
canvasPtr->textInfo.cursorOn = 0;
- canvasPtr->insertBlinkHandler = (Tcl_TimerToken) NULL;
+ canvasPtr->insertBlinkHandler = NULL;
}
EventuallyRedrawItem(canvasPtr, canvasPtr->textInfo.focusItemPtr);
if (canvasPtr->highlightWidth > 0) {
@@ -5581,7 +5699,7 @@ CanvasFetchSelection(
* not including terminating NULL
* character. */
{
- TkCanvas *canvasPtr = clientData;
+ TkCanvas *canvasPtr = (TkCanvas *)clientData;
return ItemSelection(canvasPtr, canvasPtr->textInfo.selItemPtr, offset,
buffer, maxBytes);
@@ -5609,7 +5727,7 @@ static void
CanvasLostSelection(
ClientData clientData) /* Information about entry widget. */
{
- TkCanvas *canvasPtr = clientData;
+ TkCanvas *canvasPtr = (TkCanvas *)clientData;
EventuallyRedrawItem(canvasPtr, canvasPtr->textInfo.selItemPtr);
canvasPtr->textInfo.selItemPtr = NULL;
@@ -5938,19 +6056,18 @@ CanvasSetOrigin(
*----------------------------------------------------------------------
*/
-/* ARGSUSED */
static const char **
TkGetStringsFromObjs(
int objc,
Tcl_Obj *const objv[])
{
- register int i;
+ int i;
const char **argv;
if (objc <= 0) {
return NULL;
}
- argv = ckalloc((objc+1) * sizeof(char *));
+ argv = (const char **)ckalloc((objc+1) * sizeof(char *));
for (i = 0; i < objc; i++) {
argv[i] = Tcl_GetString(objv[i]);
}
diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h
index e2221a8..fc0ac7a 100644
--- a/generic/tkCanvas.h
+++ b/generic/tkCanvas.h
@@ -147,7 +147,7 @@ typedef struct TkCanvas {
* currentItem is based. Must be saved so that
* if the currentItem is deleted, can pick
* another. */
- int state; /* Last known modifier state. Used to defer
+ unsigned int state; /* Last known modifier state. Used to defer
* picking a new current object while buttons
* are down. */
diff --git a/generic/tkClipboard.c b/generic/tkClipboard.c
index 9f6822f..f09958e 100644
--- a/generic/tkClipboard.c
+++ b/generic/tkClipboard.c
@@ -56,11 +56,11 @@ ClipboardHandler(
char *buffer, /* Place to store converted selection. */
int maxBytes) /* Maximum # of bytes to store at buffer. */
{
- TkClipboardTarget *targetPtr = clientData;
+ TkClipboardTarget *targetPtr = (TkClipboardTarget *)clientData;
TkClipboardBuffer *cbPtr;
char *srcPtr, *destPtr;
size_t count = 0;
- int scanned = 0;
+ size_t scanned = 0;
size_t length, freeCount;
/*
@@ -71,7 +71,7 @@ ClipboardHandler(
if (cbPtr == NULL) {
return 0;
}
- if (scanned + cbPtr->length > offset) {
+ if (scanned + cbPtr->length > (size_t)offset) {
break;
}
scanned += cbPtr->length;
@@ -134,7 +134,7 @@ ClipboardAppHandler(
char *buffer, /* Place to store converted selection. */
int maxBytes) /* Maximum # of bytes to store at buffer. */
{
- TkDisplay *dispPtr = clientData;
+ TkDisplay *dispPtr = (TkDisplay *)clientData;
size_t length;
const char *p;
@@ -147,7 +147,8 @@ ClipboardAppHandler(
if (length > (size_t) maxBytes) {
length = maxBytes;
}
- strncpy(buffer, p, length);
+ memcpy(buffer, p, length);
+ buffer[length] = 0;
return (int)length;
}
@@ -172,12 +173,16 @@ ClipboardAppHandler(
static int
ClipboardWindowHandler(
- ClientData clientData, /* Not used. */
+ ClientData dummy, /* Not used. */
int offset, /* Return selection bytes starting at this
* offset. */
char *buffer, /* Place to store converted selection. */
int maxBytes) /* Maximum # of bytes to store at buffer. */
{
+ (void)dummy;
+ (void)offset;
+ (void)maxBytes;
+
buffer[0] = '.';
buffer[1] = 0;
return 1;
@@ -205,7 +210,7 @@ static void
ClipboardLostSel(
ClientData clientData) /* Pointer to TkDisplay structure. */
{
- TkDisplay *dispPtr = clientData;
+ TkDisplay *dispPtr = (TkDisplay *)clientData;
dispPtr->clipboardActive = 0;
}
@@ -358,7 +363,7 @@ Tk_ClipboardAppend(
}
}
if (targetPtr == NULL) {
- targetPtr = ckalloc(sizeof(TkClipboardTarget));
+ targetPtr = (TkClipboardTarget *)ckalloc(sizeof(TkClipboardTarget));
targetPtr->type = type;
targetPtr->format = format;
targetPtr->firstBufferPtr = targetPtr->lastBufferPtr = NULL;
@@ -380,7 +385,7 @@ Tk_ClipboardAppend(
* Append a new buffer to the buffer chain.
*/
- cbPtr = ckalloc(sizeof(TkClipboardBuffer));
+ cbPtr = (TkClipboardBuffer *)ckalloc(sizeof(TkClipboardBuffer));
cbPtr->nextPtr = NULL;
if (targetPtr->lastBufferPtr != NULL) {
targetPtr->lastBufferPtr->nextPtr = cbPtr;
@@ -390,7 +395,7 @@ Tk_ClipboardAppend(
targetPtr->lastBufferPtr = cbPtr;
cbPtr->length = strlen(buffer);
- cbPtr->buffer = ckalloc(cbPtr->length + 1);
+ cbPtr->buffer = (char *)ckalloc(cbPtr->length + 1);
strcpy(cbPtr->buffer, buffer);
TkSelUpdateClipboard((TkWindow *) dispPtr->clipWindow, targetPtr);
@@ -422,7 +427,7 @@ Tk_ClipboardObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
const char *path = NULL;
Atom selection;
static const char *const optionStrings[] = { "append", "clear", "get", NULL };
@@ -450,7 +455,7 @@ Tk_ClipboardObjCmd(
};
enum appendOptions { APPEND_DISPLAYOF, APPEND_FORMAT, APPEND_TYPE };
int subIndex;
- size_t length;
+ TkSizeT length;
for (i = 2; i < objc - 1; i++) {
string = TkGetStringFromObj(objv[i], &length);
@@ -636,10 +641,11 @@ Tk_ClipboardObjCmd(
int
TkClipInit(
- Tcl_Interp *interp, /* Interpreter to use for error reporting. */
- register TkDisplay *dispPtr)/* Display to initialize. */
+ Tcl_Interp *dummy, /* Interpreter to use for error reporting. */
+ TkDisplay *dispPtr)/* Display to initialize. */
{
XSetWindowAttributes atts;
+ (void)dummy;
dispPtr->clipTargetPtr = NULL;
dispPtr->clipboardActive = 0;
@@ -700,16 +706,17 @@ TkClipInit(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ClipboardGetProc(
ClientData clientData, /* Dynamic string holding partially assembled
* selection. */
- Tcl_Interp *interp, /* Interpreter used for error reporting (not
+ Tcl_Interp *dummy, /* Interpreter used for error reporting (not
* used). */
const char *portion) /* New information to be appended. */
{
- Tcl_DStringAppend(clientData, portion, -1);
+ (void)dummy;
+
+ Tcl_DStringAppend((Tcl_DString *)clientData, portion, -1);
return TCL_OK;
}
diff --git a/generic/tkCmds.c b/generic/tkCmds.c
index cefd5fc..c9026ef 100644
--- a/generic/tkCmds.c
+++ b/generic/tkCmds.c
@@ -99,7 +99,7 @@ Tk_BellObjCmd(
"-displayof", "-nice", NULL
};
enum options { TK_BELL_DISPLAYOF, TK_BELL_NICE };
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
int i, index, nice = 0;
Tk_ErrorHandler handler;
@@ -134,7 +134,7 @@ Tk_BellObjCmd(
if (!nice) {
XForceScreenSaver(Tk_Display(tkwin), ScreenSaverReset);
}
- XFlush(Tk_Display(tkwin));
+ (void)XFlush(Tk_Display(tkwin));
Tk_DeleteErrorHandler(handler);
return TCL_OK;
}
@@ -163,7 +163,7 @@ Tk_BindObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
TkWindow *winPtr;
ClientData object;
const char *string;
@@ -187,7 +187,7 @@ Tk_BindObjCmd(
}
object = (ClientData) winPtr->pathName;
} else {
- winPtr = clientData;
+ winPtr = (TkWindow *)clientData;
object = (ClientData) Tk_GetUid(string);
}
@@ -285,10 +285,10 @@ TkBindEventProc(
*/
if (winPtr->numTags > MAX_OBJS) {
- objPtr = ckalloc(winPtr->numTags * sizeof(ClientData));
+ objPtr = (void **)ckalloc(winPtr->numTags * sizeof(void *));
}
for (i = 0; i < winPtr->numTags; i++) {
- p = winPtr->tagPtr[i];
+ p = (const char *)winPtr->tagPtr[i];
if (*p == '.') {
hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->nameTable, p);
if (hPtr != NULL) {
@@ -347,7 +347,7 @@ Tk_BindtagsObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
TkWindow *winPtr, *winPtr2;
int i, length;
const char *p;
@@ -399,7 +399,7 @@ Tk_BindtagsObjCmd(
}
winPtr->numTags = length;
- winPtr->tagPtr = ckalloc(length * sizeof(ClientData));
+ winPtr->tagPtr = (void **)ckalloc(length * sizeof(void *));
for (i = 0; i < length; i++) {
p = Tcl_GetString(tags[i]);
if (p[0] == '.') {
@@ -412,7 +412,7 @@ Tk_BindtagsObjCmd(
* is one.
*/
- copy = ckalloc(strlen(p) + 1);
+ copy = (char *)ckalloc(strlen(p) + 1);
strcpy(copy, p);
winPtr->tagPtr[i] = (ClientData) copy;
} else {
@@ -448,7 +448,7 @@ TkFreeBindingTags(
const char *p;
for (i = 0; i < winPtr->numTags; i++) {
- p = winPtr->tagPtr[i];
+ p = (const char *)winPtr->tagPtr[i];
if (*p == '.') {
/*
* Names starting with "." are malloced rather than Uids, so they
@@ -488,7 +488,7 @@ Tk_DestroyObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window window;
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
int i;
for (i = 1; i < objc; i++) {
@@ -527,7 +527,6 @@ Tk_DestroyObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
Tk_LowerObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
@@ -535,7 +534,7 @@ Tk_LowerObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window mainwin = clientData;
+ Tk_Window mainwin = (Tk_Window)clientData;
Tk_Window tkwin, other;
if ((objc != 2) && (objc != 3)) {
@@ -587,7 +586,6 @@ Tk_LowerObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
Tk_RaiseObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
@@ -595,7 +593,7 @@ Tk_RaiseObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window mainwin = clientData;
+ Tk_Window mainwin = (Tk_Window)clientData;
Tk_Window tkwin, other;
if ((objc != 2) && (objc != 3)) {
@@ -683,7 +681,7 @@ AppnameCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
TkWindow *winPtr;
const char *string;
@@ -715,7 +713,7 @@ CaretCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
int index;
Tcl_Obj *objPtr;
TkCaret *caretPtr;
@@ -746,15 +744,15 @@ CaretCmd(
Tcl_ListObjAppendElement(interp, objPtr,
Tcl_NewStringObj("-height", 7));
Tcl_ListObjAppendElement(interp, objPtr,
- Tcl_NewIntObj(caretPtr->height));
+ Tcl_NewWideIntObj(caretPtr->height));
Tcl_ListObjAppendElement(interp, objPtr,
Tcl_NewStringObj("-x", 2));
Tcl_ListObjAppendElement(interp, objPtr,
- Tcl_NewIntObj(caretPtr->x));
+ Tcl_NewWideIntObj(caretPtr->x));
Tcl_ListObjAppendElement(interp, objPtr,
Tcl_NewStringObj("-y", 2));
Tcl_ListObjAppendElement(interp, objPtr,
- Tcl_NewIntObj(caretPtr->y));
+ Tcl_NewWideIntObj(caretPtr->y));
Tcl_SetObjResult(interp, objPtr);
} else if (objc == 3) {
int value;
@@ -774,7 +772,7 @@ CaretCmd(
} else /* if (index == TK_CARET_HEIGHT) -- last case */ {
value = caretPtr->height;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(value));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(value));
} else {
int i, value, x = 0, y = 0, height = -1;
@@ -807,7 +805,7 @@ ScalingCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
Screen *screenPtr;
int skip, width, height;
double d;
@@ -858,7 +856,7 @@ UseinputmethodsCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
TkDisplay *dispPtr;
int skip;
@@ -875,11 +873,6 @@ UseinputmethodsCmd(
}
dispPtr = ((TkWindow *) tkwin)->dispPtr;
if ((objc - skip) == 2) {
- /*
- * In the case where TK_USE_INPUT_METHODS is not defined, this
- * will be ignored and we will always return 0. That will indicate
- * to the user that input methods are just not available.
- */
int boolVal;
@@ -887,13 +880,11 @@ UseinputmethodsCmd(
&boolVal) != TCL_OK) {
return TCL_ERROR;
}
-#ifdef TK_USE_INPUT_METHODS
- if (boolVal) {
+ if (boolVal && (dispPtr->inputMethod != NULL)) {
dispPtr->flags |= TK_DISPLAY_USE_IM;
} else {
dispPtr->flags &= ~TK_DISPLAY_USE_IM;
}
-#endif /* TK_USE_INPUT_METHODS */
} else if ((objc - skip) != 1) {
Tcl_WrongNumArgs(interp, 1, objv,
"?-displayof window? ?boolean?");
@@ -906,12 +897,13 @@ UseinputmethodsCmd(
int
WindowingsystemCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ ClientData dummy, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *windowingsystem;
+ (void)dummy;
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
@@ -935,7 +927,7 @@ InactiveCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
int skip = TkGetDisplayOf(interp, objc - 1, objv + 1, &tkwin);
if (skip < 0) {
@@ -991,7 +983,6 @@ InactiveCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
Tk_TkwaitObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
@@ -999,7 +990,7 @@ Tk_TkwaitObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
int done, index;
int code = TCL_OK;
static const char *const optionStrings[] = {
@@ -1120,28 +1111,30 @@ Tk_TkwaitObjCmd(
return code;
}
- /* ARGSUSED */
static char *
WaitVariableProc(
ClientData clientData, /* Pointer to integer to set to 1. */
- Tcl_Interp *interp, /* Interpreter containing variable. */
+ Tcl_Interp *dummy, /* Interpreter containing variable. */
const char *name1, /* Name of variable. */
const char *name2, /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- int *donePtr = clientData;
+ int *donePtr = (int *)clientData;
+ (void)dummy;
+ (void)name1;
+ (void)name2;
+ (void)flags;
*donePtr = 1;
return NULL;
}
- /*ARGSUSED*/
static void
WaitVisibilityProc(
ClientData clientData, /* Pointer to integer to set to 1. */
XEvent *eventPtr) /* Information about event (not used). */
{
- int *donePtr = clientData;
+ int *donePtr = (int *)clientData;
if (eventPtr->type == VisibilityNotify) {
*donePtr = 1;
@@ -1155,7 +1148,7 @@ WaitWindowProc(
ClientData clientData, /* Pointer to integer to set to 1. */
XEvent *eventPtr) /* Information about event. */
{
- int *donePtr = clientData;
+ int *donePtr = (int *)clientData;
if (eventPtr->type == DestroyNotify) {
*donePtr = 1;
@@ -1179,10 +1172,9 @@ WaitWindowProc(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
Tk_UpdateObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ ClientData dummy, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -1191,6 +1183,7 @@ Tk_UpdateObjCmd(
int flags, index;
TkDisplay *dispPtr;
int code = TCL_OK;
+ (void)dummy;
if (objc == 1) {
flags = TCL_DONT_WAIT;
@@ -1285,10 +1278,10 @@ Tk_WinfoObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- int index, x, y, width, height, useX, useY, class, skip;
+ int index, x, y, width, height, useX, useY, c_class, skip;
const char *string;
TkWindow *winPtr;
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
static const TkStateMap visualMap[] = {
{PseudoColor, "pseudocolor"},
@@ -1363,7 +1356,7 @@ Tk_WinfoObjCmd(
switch ((enum options) index) {
case WIN_CELLS:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(Tk_Visual(tkwin)->map_entries));
+ Tcl_NewWideIntObj(Tk_Visual(tkwin)->map_entries));
break;
case WIN_CHILDREN: {
Tcl_Obj *strPtr, *resultPtr = Tcl_NewObj();
@@ -1386,14 +1379,14 @@ Tk_WinfoObjCmd(
Tcl_NewBooleanObj(TkpCmapStressed(tkwin,Tk_Colormap(tkwin))));
break;
case WIN_DEPTH:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_Depth(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_Depth(tkwin)));
break;
case WIN_GEOMETRY:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("%dx%d+%d+%d",
Tk_Width(tkwin), Tk_Height(tkwin), Tk_X(tkwin), Tk_Y(tkwin)));
break;
case WIN_HEIGHT:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_Height(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_Height(tkwin)));
break;
case WIN_ID: {
char buf[TCL_INTEGER_SPACE];
@@ -1444,28 +1437,28 @@ Tk_WinfoObjCmd(
if (useX & useY) {
Tcl_Obj *xyObj[2];
- xyObj[0] = Tcl_NewIntObj(x);
- xyObj[1] = Tcl_NewIntObj(y);
+ xyObj[0] = Tcl_NewWideIntObj(x);
+ xyObj[1] = Tcl_NewWideIntObj(y);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, xyObj));
} else if (useX) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(x));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(x));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(y));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(y));
}
break;
case WIN_REQHEIGHT:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_ReqHeight(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_ReqHeight(tkwin)));
break;
case WIN_REQWIDTH:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_ReqWidth(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_ReqWidth(tkwin)));
break;
case WIN_ROOTX:
Tk_GetRootCoords(tkwin, &x, &y);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(x));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(x));
break;
case WIN_ROOTY:
Tk_GetRootCoords(tkwin, &x, &y);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(y));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(y));
break;
case WIN_SCREEN:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s.%d",
@@ -1473,30 +1466,30 @@ Tk_WinfoObjCmd(
break;
case WIN_SCREENCELLS:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(CellsOfScreen(Tk_Screen(tkwin))));
+ Tcl_NewWideIntObj(CellsOfScreen(Tk_Screen(tkwin))));
break;
case WIN_SCREENDEPTH:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(DefaultDepthOfScreen(Tk_Screen(tkwin))));
+ Tcl_NewWideIntObj(DefaultDepthOfScreen(Tk_Screen(tkwin))));
break;
case WIN_SCREENHEIGHT:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(HeightOfScreen(Tk_Screen(tkwin))));
+ Tcl_NewWideIntObj(HeightOfScreen(Tk_Screen(tkwin))));
break;
case WIN_SCREENWIDTH:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(WidthOfScreen(Tk_Screen(tkwin))));
+ Tcl_NewWideIntObj(WidthOfScreen(Tk_Screen(tkwin))));
break;
case WIN_SCREENMMHEIGHT:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(HeightMMOfScreen(Tk_Screen(tkwin))));
+ Tcl_NewWideIntObj(HeightMMOfScreen(Tk_Screen(tkwin))));
break;
case WIN_SCREENMMWIDTH:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(WidthMMOfScreen(Tk_Screen(tkwin))));
+ Tcl_NewWideIntObj(WidthMMOfScreen(Tk_Screen(tkwin))));
break;
case WIN_SCREENVISUAL:
- class = DefaultVisualOfScreen(Tk_Screen(tkwin))->class;
+ c_class = DefaultVisualOfScreen(Tk_Screen(tkwin))->c_class;
goto visual;
case WIN_SERVER:
TkGetServerInfo(interp, tkwin);
@@ -1524,10 +1517,10 @@ Tk_WinfoObjCmd(
break;
}
case WIN_VISUAL:
- class = Tk_Visual(tkwin)->class;
+ c_class = Tk_Visual(tkwin)->c_class;
visual:
- string = TkFindStateString(visualMap, class);
+ string = TkFindStateString(visualMap, c_class);
if (string == NULL) {
string = "unknown";
}
@@ -1539,28 +1532,28 @@ Tk_WinfoObjCmd(
break;
case WIN_VROOTHEIGHT:
Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(height));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(height));
break;
case WIN_VROOTWIDTH:
Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(width));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(width));
break;
case WIN_VROOTX:
Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(x));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(x));
break;
case WIN_VROOTY:
Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(y));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(y));
break;
case WIN_WIDTH:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_Width(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_Width(tkwin)));
break;
case WIN_X:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_X(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_X(tkwin)));
break;
case WIN_Y:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_Y(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_Y(tkwin)));
break;
/*
@@ -1735,7 +1728,7 @@ Tk_WinfoObjCmd(
if (Tk_GetPixels(interp, tkwin, string, &pixels) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(pixels));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pixels));
break;
}
case WIN_RGB: {
@@ -1758,7 +1751,7 @@ Tk_WinfoObjCmd(
break;
}
case WIN_VISUALSAVAILABLE: {
- XVisualInfo template, *visInfoPtr;
+ XVisualInfo templ, *visInfoPtr;
int count, i;
int includeVisualId;
Tcl_Obj *strPtr, *resultPtr;
@@ -1779,9 +1772,9 @@ Tk_WinfoObjCmd(
return TCL_ERROR;
}
- template.screen = Tk_ScreenNumber(tkwin);
+ templ.screen = Tk_ScreenNumber(tkwin);
visInfoPtr = XGetVisualInfo(Tk_Display(tkwin), VisualScreenMask,
- &template, &count);
+ &templ, &count);
if (visInfoPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't find any visuals for screen", -1));
@@ -1790,15 +1783,15 @@ Tk_WinfoObjCmd(
}
resultPtr = Tcl_NewObj();
for (i = 0; i < count; i++) {
- string = TkFindStateString(visualMap, visInfoPtr[i].class);
+ string = TkFindStateString(visualMap, visInfoPtr[i].c_class);
if (string == NULL) {
strcpy(buf, "unknown");
} else {
sprintf(buf, "%s %d", string, visInfoPtr[i].depth);
}
if (includeVisualId) {
- sprintf(visualIdString, " 0x%x",
- (unsigned) visInfoPtr[i].visualid);
+ sprintf(visualIdString, " 0x%lx",
+ (unsigned long) visInfoPtr[i].visualid);
strcat(buf, visualIdString);
}
strPtr = Tcl_NewStringObj(buf, -1);
@@ -1812,224 +1805,7 @@ Tk_WinfoObjCmd(
return TCL_OK;
}
-#if 0
-/*
- *----------------------------------------------------------------------
- *
- * Tk_WmObjCmd --
- *
- * This function is invoked to process the "wm" Tcl command. See the user
- * documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-int
-Tk_WmObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
- Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument objects. */
-{
- Tk_Window tkwin;
- TkWindow *winPtr;
- static const char *const optionStrings[] = {
- "aspect", "client", "command", "deiconify",
- "focusmodel", "frame", "geometry", "grid",
- "group", "iconbitmap", "iconify", "iconmask",
- "iconname", "iconposition", "iconwindow", "maxsize",
- "minsize", "overrideredirect", "positionfrom", "protocol",
- "resizable", "sizefrom", "state", "title",
- "tracing", "transient", "withdraw", NULL
- };
- enum options {
- TKWM_ASPECT, TKWM_CLIENT, TKWM_COMMAND, TKWM_DEICONIFY,
- TKWM_FOCUSMOD, TKWM_FRAME, TKWM_GEOMETRY, TKWM_GRID,
- TKWM_GROUP, TKWM_ICONBMP, TKWM_ICONIFY, TKWM_ICONMASK,
- TKWM_ICONNAME, TKWM_ICONPOS, TKWM_ICONWIN, TKWM_MAXSIZE,
- TKWM_MINSIZE, TKWM_OVERRIDE, TKWM_POSFROM, TKWM_PROTOCOL,
- TKWM_RESIZABLE, TKWM_SIZEFROM, TKWM_STATE, TKWM_TITLE,
- TKWM_TRACING, TKWM_TRANSIENT, TKWM_WITHDRAW
- };
-
- tkwin = clientData;
-
- if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg?");
- return TCL_ERROR;
- }
- if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
-
- if (index == TKWM_TRACING) {
- int wmTracing;
- TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
-
- if ((objc != 2) && (objc != 3)) {
- Tcl_WrongNumArgs(interp, 1, objv, "tracing ?boolean?");
- return TCL_ERROR;
- }
- if (objc == 2) {
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
- dispPtr->flags & TK_DISPLAY_WM_TRACING));
- return TCL_OK;
- }
- if (Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing) != TCL_OK) {
- return TCL_ERROR;
- }
- if (wmTracing) {
- dispPtr->flags |= TK_DISPLAY_WM_TRACING;
- } else {
- dispPtr->flags &= ~TK_DISPLAY_WM_TRACING;
- }
- return TCL_OK;
- }
-
- if (objc < 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?arg?");
- return TCL_ERROR;
- }
-
- winPtr = (TkWindow *) Tk_NameToWindow(interp,
- Tcl_GetString(objv[2]), tkwin);
- if (winPtr == NULL) {
- return TCL_ERROR;
- }
- if (!(winPtr->flags & TK_TOP_LEVEL)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "window \"%s\" isn't a top-level window", winPtr->pathName));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TOPLEVEL", winPtr->pathName,
- NULL);
- return TCL_ERROR;
- }
-
- switch ((enum options) index) {
- case TKWM_ASPECT:
- TkpWmAspectCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_CLIENT:
- TkpWmClientCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_COMMAND:
- TkpWmCommandCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_DEICONIFY:
- TkpWmDeiconifyCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_FOCUSMOD:
- TkpWmFocusmodCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_FRAME:
- TkpWmFrameCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_GEOMETRY:
- TkpWmGeometryCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_GRID:
- TkpWmGridCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_GROUP:
- TkpWmGroupCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_ICONBMP:
- TkpWmIconbitmapCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_ICONIFY:
- TkpWmIconifyCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_ICONMASK:
- TkpWmIconmaskCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_ICONNAME:
- /*
- * Slight Unix variation.
- */
- TkpWmIconnameCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_ICONPOS:
- /*
- * nearly same - 1 line more on Unix.
- */
- TkpWmIconpositionCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_ICONWIN:
- TkpWmIconwindowCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_MAXSIZE:
- /*
- * Nearly same, win diffs.
- */
- TkpWmMaxsizeCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_MINSIZE:
- /*
- * Nearly same, win diffs
- */
- TkpWmMinsizeCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_OVERRIDE:
- /*
- * Almost same.
- */
- TkpWmOverrideCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_POSFROM:
- /*
- * Equal across platforms
- */
- TkpWmPositionfromCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_PROTOCOL:
- /*
- * Equal across platforms
- */
- TkpWmProtocolCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_RESIZABLE:
- /*
- * Almost same
- */
- TkpWmResizableCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_SIZEFROM:
- /*
- * Equal across platforms
- */
- TkpWmSizefromCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_STATE:
- TkpWmStateCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_TITLE:
- TkpWmTitleCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_TRANSIENT:
- TkpWmTransientCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_WITHDRAW:
- TkpWmWithdrawCmd(interp, tkwin, winPtr, objc, objv);
- break;
- }
-
- updateGeom:
- if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
- wmPtr->flags |= WM_UPDATE_PENDING;
- }
- return TCL_OK;
-}
-#endif
-
/*
*----------------------------------------------------------------------
*
@@ -2071,7 +1847,7 @@ TkGetDisplayOf(
* present. */
{
const char *string;
- size_t length;
+ TkSizeT length;
if (objc < 1) {
return 0;
@@ -2112,14 +1888,16 @@ TkGetDisplayOf(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
TkDeadAppObjCmd(
- ClientData clientData, /* Dummy. */
+ ClientData dummy, /* Dummy. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
+ (void)dummy;
+ (void)objc;
+
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't invoke \"%s\" command: application has been destroyed",
Tcl_GetString(objv[0])));
diff --git a/generic/tkColor.c b/generic/tkColor.c
index 3a82545..cf5c5f6 100644
--- a/generic/tkColor.c
+++ b/generic/tkColor.c
@@ -31,7 +31,7 @@ typedef struct {
* The structure below is used to allocate thread-local data.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
char rgbString[20]; /* */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -128,7 +128,7 @@ Tk_AllocColorFromObj(
*/
if (tkColPtr != NULL) {
- TkColor *firstColorPtr = Tcl_GetHashValue(tkColPtr->hashPtr);
+ TkColor *firstColorPtr = (TkColor *)Tcl_GetHashValue(tkColPtr->hashPtr);
FreeColorObj(objPtr);
for (tkColPtr = firstColorPtr; tkColPtr != NULL;
@@ -203,7 +203,7 @@ Tk_GetColor(
nameHashPtr = Tcl_CreateHashEntry(&dispPtr->colorNameTable, name, &isNew);
if (!isNew) {
- existingColPtr = Tcl_GetHashValue(nameHashPtr);
+ existingColPtr = (TkColor *)Tcl_GetHashValue(nameHashPtr);
for (tkColPtr = existingColPtr; tkColPtr != NULL;
tkColPtr = tkColPtr->nextPtr) {
if ((tkColPtr->screen == Tk_Screen(tkwin))
@@ -314,7 +314,7 @@ Tk_GetColorByValue(
valueHashPtr = Tcl_CreateHashEntry(&dispPtr->colorValueTable,
(char *) &valueKey, &isNew);
if (!isNew) {
- tkColPtr = Tcl_GetHashValue(valueHashPtr);
+ tkColPtr = (TkColor *)Tcl_GetHashValue(valueHashPtr);
tkColPtr->resourceRefCount++;
return &tkColPtr->color;
}
@@ -363,12 +363,12 @@ const char *
Tk_NameOfColor(
XColor *colorPtr) /* Color whose name is desired. */
{
- register TkColor *tkColPtr = (TkColor *) colorPtr;
+ TkColor *tkColPtr = (TkColor *) colorPtr;
if (tkColPtr->magic==COLOR_MAGIC && tkColPtr->type==TK_COLOR_BY_NAME) {
return tkColPtr->hashPtr->key.string;
} else {
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
sprintf(tsdPtr->rgbString, "#%04x%04x%04x", colorPtr->red,
@@ -496,7 +496,7 @@ Tk_FreeColor(
}
TkpFreeColor(tkColPtr);
- prevPtr = Tcl_GetHashValue(tkColPtr->hashPtr);
+ prevPtr = (TkColor *)Tcl_GetHashValue(tkColPtr->hashPtr);
if (prevPtr == tkColPtr) {
if (tkColPtr->nextPtr == NULL) {
Tcl_DeleteHashEntry(tkColPtr->hashPtr);
@@ -583,7 +583,7 @@ static void
FreeColorObj(
Tcl_Obj *objPtr) /* The object we are releasing. */
{
- TkColor *tkColPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ TkColor *tkColPtr = (TkColor *)objPtr->internalRep.twoPtrValue.ptr1;
if (tkColPtr != NULL) {
if ((tkColPtr->objRefCount-- <= 1)
@@ -617,7 +617,7 @@ DupColorObjProc(
Tcl_Obj *srcObjPtr, /* The object we are copying from. */
Tcl_Obj *dupObjPtr) /* The object we are copying to. */
{
- TkColor *tkColPtr = srcObjPtr->internalRep.twoPtrValue.ptr1;
+ TkColor *tkColPtr = (TkColor *)srcObjPtr->internalRep.twoPtrValue.ptr1;
dupObjPtr->typePtr = srcObjPtr->typePtr;
dupObjPtr->internalRep.twoPtrValue.ptr1 = tkColPtr;
@@ -667,7 +667,7 @@ Tk_GetColorFromObj(
* map. If it is, we are done.
*/
- tkColPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ tkColPtr = (TkColor *)objPtr->internalRep.twoPtrValue.ptr1;
if ((tkColPtr != NULL)
&& (tkColPtr->resourceRefCount > 0)
&& (Tk_Screen(tkwin) == tkColPtr->screen)
@@ -693,7 +693,7 @@ Tk_GetColorFromObj(
if (hashPtr == NULL) {
goto error;
}
- for (tkColPtr = Tcl_GetHashValue(hashPtr);
+ for (tkColPtr = (TkColor *)Tcl_GetHashValue(hashPtr);
(tkColPtr != NULL); tkColPtr = tkColPtr->nextPtr) {
if ((Tk_Screen(tkwin) == tkColPtr->screen)
&& (Tk_Colormap(tkwin) == tkColPtr->colormap)) {
@@ -809,7 +809,7 @@ TkDebugColor(
resultPtr = Tcl_NewObj();
hashPtr = Tcl_FindHashEntry(&dispPtr->colorNameTable, name);
if (hashPtr != NULL) {
- TkColor *tkColPtr = Tcl_GetHashValue(hashPtr);
+ TkColor *tkColPtr = (TkColor *)Tcl_GetHashValue(hashPtr);
if (tkColPtr == NULL) {
Tcl_Panic("TkDebugColor found empty hash table entry");
diff --git a/generic/tkConfig.c b/generic/tkConfig.c
index b9499e5..d4ffa7c 100644
--- a/generic/tkConfig.c
+++ b/generic/tkConfig.c
@@ -31,7 +31,7 @@
* the option tables that have been created for a thread.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
int initialized; /* 0 means table below needs initializing. */
Tcl_HashTable hashTable;
} ThreadSpecificData;
@@ -178,7 +178,7 @@ Tk_CreateOptionTable(
const Tk_OptionSpec *specPtr, *specPtr2;
Option *optionPtr;
size_t numOptions, i;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -202,7 +202,7 @@ Tk_CreateOptionTable(
hashEntryPtr = Tcl_CreateHashEntry(&tsdPtr->hashTable, (char *) templatePtr,
&newEntry);
if (!newEntry) {
- tablePtr = Tcl_GetHashValue(hashEntryPtr);
+ tablePtr = (OptionTable *)Tcl_GetHashValue(hashEntryPtr);
tablePtr->refCount++;
return (Tk_OptionTable) tablePtr;
}
@@ -216,7 +216,7 @@ Tk_CreateOptionTable(
for (specPtr = templatePtr; specPtr->type != TK_OPTION_END; specPtr++) {
numOptions++;
}
- tablePtr = ckalloc(sizeof(OptionTable) + (numOptions * sizeof(Option)));
+ tablePtr = (OptionTable *)ckalloc(sizeof(OptionTable) + (numOptions * sizeof(Option)));
tablePtr->refCount = 1;
tablePtr->hashEntryPtr = hashEntryPtr;
tablePtr->nextPtr = NULL;
@@ -266,7 +266,7 @@ Tk_CreateOptionTable(
|| (specPtr->type == TK_OPTION_BORDER))
&& (specPtr->clientData != NULL)) {
optionPtr->extra.monoColorPtr =
- Tcl_NewStringObj(specPtr->clientData, -1);
+ Tcl_NewStringObj((const char *)specPtr->clientData, -1);
Tcl_IncrRefCount(optionPtr->extra.monoColorPtr);
}
@@ -275,11 +275,11 @@ Tk_CreateOptionTable(
* Get the custom parsing, etc., functions.
*/
- optionPtr->extra.custom = specPtr->clientData;
+ optionPtr->extra.custom = (const Tk_ObjCustomOption *)specPtr->clientData;
}
}
if (((specPtr->type == TK_OPTION_STRING)
- && (specPtr->internalOffset != TCL_AUTO_LENGTH))
+ && (specPtr->internalOffset != TCL_INDEX_NONE))
|| (specPtr->type == TK_OPTION_COLOR)
|| (specPtr->type == TK_OPTION_FONT)
|| (specPtr->type == TK_OPTION_BITMAP)
@@ -300,7 +300,7 @@ Tk_CreateOptionTable(
if (specPtr->clientData != NULL) {
tablePtr->nextPtr = (OptionTable *)
- Tk_CreateOptionTable(interp, specPtr->clientData);
+ Tk_CreateOptionTable(interp, (Tk_OptionSpec *)specPtr->clientData);
}
return (Tk_OptionTable) tablePtr;
@@ -584,7 +584,7 @@ DoObjConfig(
*/
specPtr = optionPtr->specPtr;
- if (specPtr->objOffset != TCL_AUTO_LENGTH) {
+ if (specPtr->objOffset != TCL_INDEX_NONE) {
slotPtrPtr = (Tcl_Obj **) ((char *)recordPtr + specPtr->objOffset);
oldPtr = *slotPtrPtr;
} else {
@@ -597,7 +597,7 @@ DoObjConfig(
* object and internal forms, if they exist.
*/
- if (specPtr->internalOffset != TCL_AUTO_LENGTH) {
+ if (specPtr->internalOffset != TCL_INDEX_NONE) {
internalPtr = (char *)recordPtr + specPtr->internalOffset;
} else {
internalPtr = NULL;
@@ -656,7 +656,7 @@ DoObjConfig(
case TK_OPTION_STRING: {
char *newStr;
const char *value;
- size_t length;
+ TkSizeT length;
if (nullOK && ObjectIsEmpty(valuePtr)) {
valuePtr = NULL;
@@ -664,7 +664,7 @@ DoObjConfig(
if (internalPtr != NULL) {
if (valuePtr != NULL) {
value = TkGetStringFromObj(valuePtr, &length);
- newStr = ckalloc(length + 1);
+ newStr = (char *)ckalloc(length + 1);
strcpy(newStr, value);
} else {
newStr = NULL;
@@ -677,11 +677,16 @@ DoObjConfig(
case TK_OPTION_STRING_TABLE: {
int newValue;
- if (Tcl_GetIndexFromObjStruct(interp, valuePtr,
- optionPtr->specPtr->clientData, sizeof(char *),
- optionPtr->specPtr->optionName+1, 0, &newValue) != TCL_OK) {
- return TCL_ERROR;
- }
+ if (nullOK && ObjectIsEmpty(valuePtr)) {
+ valuePtr = NULL;
+ newValue = -1;
+ } else {
+ if (Tcl_GetIndexFromObjStruct(interp, valuePtr,
+ optionPtr->specPtr->clientData, sizeof(char *),
+ optionPtr->specPtr->optionName+1, 0, &newValue) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ }
if (internalPtr != NULL) {
*((int *) oldInternalPtr) = *((int *) internalPtr);
*((int *) internalPtr) = newValue;
@@ -878,7 +883,7 @@ DoObjConfig(
const Tk_ObjCustomOption *custom = optionPtr->extra.custom;
if (custom->setProc(custom->clientData, interp, tkwin,
- &valuePtr, recordPtr, optionPtr->specPtr->internalOffset,
+ &valuePtr, (char *)recordPtr, optionPtr->specPtr->internalOffset,
(char *)oldInternalPtr, optionPtr->specPtr->flags) != TCL_OK) {
return TCL_ERROR;
}
@@ -1160,9 +1165,9 @@ TkGetOptionSpec(
static void
FreeOptionInternalRep(
- register Tcl_Obj *objPtr) /* Object whose internal rep to free. */
+ Tcl_Obj *objPtr) /* Object whose internal rep to free. */
{
- register Tk_OptionTable tablePtr = (Tk_OptionTable) objPtr->internalRep.twoPtrValue.ptr1;
+ Tk_OptionTable tablePtr = (Tk_OptionTable) objPtr->internalRep.twoPtrValue.ptr1;
Tk_DeleteOptionTable(tablePtr);
objPtr->typePtr = NULL;
@@ -1186,7 +1191,7 @@ DupOptionInternalRep(
Tcl_Obj *srcObjPtr, /* The object we are copying from. */
Tcl_Obj *dupObjPtr) /* The object we are copying to. */
{
- register OptionTable *tablePtr = (OptionTable *) srcObjPtr->internalRep.twoPtrValue.ptr1;
+ OptionTable *tablePtr = (OptionTable *) srcObjPtr->internalRep.twoPtrValue.ptr1;
tablePtr->refCount++;
dupObjPtr->typePtr = srcObjPtr->typePtr;
dupObjPtr->internalRep = srcObjPtr->internalRep;
@@ -1283,7 +1288,7 @@ Tk_SetOptions(
* more space.
*/
- newSavePtr = ckalloc(sizeof(Tk_SavedOptions));
+ newSavePtr = (Tk_SavedOptions *)ckalloc(sizeof(Tk_SavedOptions));
newSavePtr->recordPtr = recordPtr;
newSavePtr->tkwin = tkwin;
newSavePtr->numItems = 0;
@@ -1369,12 +1374,12 @@ Tk_RestoreSavedOptions(
* record.
*/
- if (specPtr->objOffset != TCL_AUTO_LENGTH) {
+ if (specPtr->objOffset != TCL_INDEX_NONE) {
newPtr = *((Tcl_Obj **) ((char *)savePtr->recordPtr + specPtr->objOffset));
} else {
newPtr = NULL;
}
- if (specPtr->internalOffset != TCL_AUTO_LENGTH) {
+ if (specPtr->internalOffset != TCL_INDEX_NONE) {
internalPtr = (char *)savePtr->recordPtr + specPtr->internalOffset;
} else {
internalPtr = NULL;
@@ -1390,12 +1395,12 @@ Tk_RestoreSavedOptions(
* Now restore the old value of the option.
*/
- if (specPtr->objOffset != TCL_AUTO_LENGTH) {
+ if (specPtr->objOffset != TCL_INDEX_NONE) {
*((Tcl_Obj **) ((char *)savePtr->recordPtr + specPtr->objOffset))
= savePtr->items[i].valuePtr;
}
- if (specPtr->internalOffset != TCL_AUTO_LENGTH) {
- register char *ptr = (char *) &savePtr->items[i].internalForm;
+ if (specPtr->internalOffset != TCL_INDEX_NONE) {
+ char *ptr = (char *) &savePtr->items[i].internalForm;
CLANG_ASSERT(internalPtr);
switch (specPtr->type) {
@@ -1453,7 +1458,7 @@ Tk_RestoreSavedOptions(
if (custom->restoreProc != NULL) {
custom->restoreProc(custom->clientData, savePtr->tkwin,
- internalPtr, ptr);
+ (char *)internalPtr, ptr);
}
break;
}
@@ -1524,7 +1529,6 @@ Tk_FreeSavedOptions(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
void
Tk_FreeConfigOptions(
void *recordPtr, /* Record whose fields contain current values
@@ -1548,14 +1552,14 @@ Tk_FreeConfigOptions(
if (specPtr->type == TK_OPTION_SYNONYM) {
continue;
}
- if (specPtr->objOffset != TCL_AUTO_LENGTH) {
+ if (specPtr->objOffset != TCL_INDEX_NONE) {
oldPtrPtr = (Tcl_Obj **) ((char *)recordPtr + specPtr->objOffset);
oldPtr = *oldPtrPtr;
*oldPtrPtr = NULL;
} else {
oldPtr = NULL;
}
- if (specPtr->internalOffset != TCL_AUTO_LENGTH) {
+ if (specPtr->internalOffset != TCL_INDEX_NONE) {
oldInternalPtr = (char *)recordPtr + specPtr->internalOffset;
} else {
oldInternalPtr = NULL;
@@ -1607,7 +1611,7 @@ FreeResources(
* form, then use the object form.
*/
- internalFormExists = optionPtr->specPtr->internalOffset != TCL_AUTO_LENGTH;
+ internalFormExists = optionPtr->specPtr->internalOffset != TCL_INDEX_NONE;
switch (optionPtr->specPtr->type) {
case TK_OPTION_STRING:
if (internalFormExists) {
@@ -1674,7 +1678,7 @@ FreeResources(
case TK_OPTION_CUSTOM: {
const Tk_ObjCustomOption *custom = optionPtr->extra.custom;
if (internalFormExists && custom->freeProc != NULL) {
- custom->freeProc(custom->clientData, tkwin, internalPtr);
+ custom->freeProc(custom->clientData, tkwin, (char *)internalPtr);
}
break;
}
@@ -1824,7 +1828,7 @@ GetConfigList(
}
Tcl_ListObjAppendElement(NULL, listPtr, elementPtr);
- if (optionPtr->specPtr->objOffset != TCL_AUTO_LENGTH) {
+ if (optionPtr->specPtr->objOffset != TCL_INDEX_NONE) {
elementPtr = *((Tcl_Obj **) ((char *)recordPtr
+ optionPtr->specPtr->objOffset));
if (elementPtr == NULL) {
@@ -1874,10 +1878,10 @@ GetObjectForOption(
objPtr = NULL;
switch (optionPtr->specPtr->type) {
case TK_OPTION_BOOLEAN:
- objPtr = Tcl_NewIntObj(*((int *) internalPtr));
+ objPtr = Tcl_NewWideIntObj(*((int *) internalPtr));
break;
case TK_OPTION_INT:
- objPtr = Tcl_NewIntObj(*((int *) internalPtr));
+ objPtr = Tcl_NewWideIntObj(*((int *) internalPtr));
break;
case TK_OPTION_DOUBLE:
objPtr = Tcl_NewDoubleObj(*((double *) internalPtr));
@@ -1951,7 +1955,7 @@ GetObjectForOption(
*((Tk_Anchor *) internalPtr)), -1);
break;
case TK_OPTION_PIXELS:
- objPtr = Tcl_NewIntObj(*((int *) internalPtr));
+ objPtr = Tcl_NewWideIntObj(*((int *) internalPtr));
break;
case TK_OPTION_WINDOW: {
Tk_Window tkwin = *((Tk_Window *) internalPtr);
@@ -1964,7 +1968,7 @@ GetObjectForOption(
case TK_OPTION_CUSTOM: {
const Tk_ObjCustomOption *custom = optionPtr->extra.custom;
- objPtr = custom->getProc(custom->clientData, tkwin, recordPtr,
+ objPtr = custom->getProc(custom->clientData, tkwin, (char *)recordPtr,
optionPtr->specPtr->internalOffset);
break;
}
@@ -2019,7 +2023,7 @@ Tk_GetOptionValue(
if (optionPtr->specPtr->type == TK_OPTION_SYNONYM) {
optionPtr = optionPtr->extra.synonymPtr;
}
- if (optionPtr->specPtr->objOffset != TCL_AUTO_LENGTH) {
+ if (optionPtr->specPtr->objOffset != TCL_INDEX_NONE) {
resultPtr = *((Tcl_Obj **) ((char *)recordPtr+optionPtr->specPtr->objOffset));
if (resultPtr == NULL) {
/*
@@ -2061,7 +2065,7 @@ Tk_GetOptionValue(
Tcl_Obj *
TkDebugConfig(
- Tcl_Interp *interp, /* Interpreter in which the table is
+ Tcl_Interp *dummy, /* Interpreter in which the table is
* defined. */
Tk_OptionTable table) /* Table about which information is to be
* returned. May not necessarily exist in the
@@ -2071,8 +2075,9 @@ TkDebugConfig(
Tcl_HashEntry *hashEntryPtr;
Tcl_HashSearch search;
Tcl_Obj *objPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
objPtr = Tcl_NewObj();
if (!tablePtr || !tsdPtr->initialized) {
diff --git a/generic/tkConsole.c b/generic/tkConsole.c
index 7a74344..0ab2954 100644
--- a/generic/tkConsole.c
+++ b/generic/tkConsole.c
@@ -44,6 +44,7 @@ typedef struct ChannelData {
*/
static int ConsoleClose(ClientData instanceData, Tcl_Interp *interp);
+static int Console2Close(ClientData instanceData, Tcl_Interp *interp, int flags);
static void ConsoleDeleteProc(ClientData clientData);
static void ConsoleEventProc(ClientData clientData, XEvent *eventPtr);
static int ConsoleHandle(ClientData instanceData, int direction,
@@ -66,8 +67,8 @@ static int InterpreterObjCmd(ClientData clientData, Tcl_Interp *interp,
static const Tcl_ChannelType consoleChannelType = {
"console", /* Type name. */
- TCL_CHANNEL_VERSION_4, /* v4 channel */
- ConsoleClose, /* Close proc. */
+ TCL_CHANNEL_VERSION_5, /* v4 channel */
+ (Tcl_DriverCloseProc *)ConsoleClose, /* Close proc. */
ConsoleInput, /* Input proc. */
ConsoleOutput, /* Output proc. */
NULL, /* Seek proc. */
@@ -75,7 +76,7 @@ static const Tcl_ChannelType consoleChannelType = {
NULL, /* Get option proc. */
ConsoleWatch, /* Watch for events on console. */
ConsoleHandle, /* Get a handle from the device. */
- NULL, /* close2proc. */
+ Console2Close, /* close2proc. */
NULL, /* Always non-blocking.*/
NULL, /* flush proc. */
NULL, /* handler proc. */
@@ -227,7 +228,7 @@ Tk_InitConsoleChannels(
return;
}
- consoleInitPtr = Tcl_GetThreadData(&consoleInitKey, (int) sizeof(int));
+ consoleInitPtr = (int *)Tcl_GetThreadData(&consoleInitKey, (int) sizeof(int));
if (*consoleInitPtr) {
/*
* We've already initialized console channels in this thread.
@@ -255,13 +256,13 @@ Tk_InitConsoleChannels(
* interp for it to live in.
*/
- info = ckalloc(sizeof(ConsoleInfo));
+ info = (ConsoleInfo *) ckalloc(sizeof(ConsoleInfo));
info->consoleInterp = NULL;
info->interp = NULL;
info->refCount = 0;
if (doIn) {
- ChannelData *data = ckalloc(sizeof(ChannelData));
+ ChannelData *data = (ChannelData *)ckalloc(sizeof(ChannelData));
data->info = info;
data->info->refCount++;
@@ -278,7 +279,7 @@ Tk_InitConsoleChannels(
}
if (doOut) {
- ChannelData *data = ckalloc(sizeof(ChannelData));
+ ChannelData *data = (ChannelData *)ckalloc(sizeof(ChannelData));
data->info = info;
data->info->refCount++;
@@ -295,7 +296,7 @@ Tk_InitConsoleChannels(
}
if (doErr) {
- ChannelData *data = ckalloc(sizeof(ChannelData));
+ ChannelData *data = (ChannelData *)ckalloc(sizeof(ChannelData));
data->info = info;
data->info->refCount++;
@@ -377,7 +378,7 @@ Tk_CreateConsoleWindow(
* New ConsoleInfo for a new console window.
*/
- info = ckalloc(sizeof(ConsoleInfo));
+ info = (ConsoleInfo *)ckalloc(sizeof(ConsoleInfo));
info->refCount = 0;
/*
@@ -407,7 +408,7 @@ Tk_CreateConsoleWindow(
}
}
} else {
- info = ckalloc(sizeof(ConsoleInfo));
+ info = (ConsoleInfo *)ckalloc(sizeof(ConsoleInfo));
info->refCount = 0;
}
@@ -497,7 +498,7 @@ ConsoleOutput(
int toWrite, /* How many bytes to write? */
int *errorCode) /* Where to store error code. */
{
- ChannelData *data = instanceData;
+ ChannelData *data = (ChannelData *)instanceData;
ConsoleInfo *info = data->info;
*errorCode = 0;
@@ -558,22 +559,26 @@ ConsoleOutput(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ConsoleInput(
- ClientData instanceData, /* Unused. */
+ void *dummy, /* Unused. */
char *buf, /* Where to store data read. */
int bufSize, /* How much space is available in the
* buffer? */
int *errorCode) /* Where to store error code. */
{
+ (void)dummy;
+ (void)buf;
+ (void)bufSize;
+ (void)errorCode;
+
return 0; /* Always return EOF. */
}
/*
*----------------------------------------------------------------------
*
- * ConsoleClose --
+ * ConsoleClose/Console2Close --
*
* Closes the IO channel.
*
@@ -586,14 +591,14 @@ ConsoleInput(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ConsoleClose(
- ClientData instanceData, /* Unused. */
- Tcl_Interp *interp) /* Unused. */
+ ClientData instanceData,
+ Tcl_Interp *dummy) /* Unused. */
{
- ChannelData *data = instanceData;
+ ChannelData *data = (ChannelData *)instanceData;
ConsoleInfo *info = data->info;
+ (void)dummy;
if (info) {
if (info->refCount-- <= 1) {
@@ -607,6 +612,18 @@ ConsoleClose(
ckfree(data);
return 0;
}
+
+static int
+Console2Close(
+ ClientData instanceData, /* Unused. */
+ Tcl_Interp *interp, /* Unused. */
+ int flags)
+{
+ if ((flags&(TCL_CLOSE_READ|TCL_CLOSE_WRITE))==0) {
+ return ConsoleClose(instanceData, interp);
+ }
+ return EINVAL;
+}
/*
*----------------------------------------------------------------------
@@ -626,14 +643,15 @@ ConsoleClose(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static void
ConsoleWatch(
- ClientData instanceData, /* Device ID for the channel. */
+ ClientData dummy, /* Device ID for the channel. */
int mask) /* OR-ed combination of TCL_READABLE,
* TCL_WRITABLE and TCL_EXCEPTION, for the
* events we are interested in. */
{
+ (void)dummy;
+ (void)mask;
}
/*
@@ -653,15 +671,18 @@ ConsoleWatch(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ConsoleHandle(
- ClientData instanceData, /* Device ID for the channel. */
+ ClientData dummy, /* Device ID for the channel. */
int direction, /* TCL_READABLE or TCL_WRITABLE to indicate
* which direction of the channel is being
* requested. */
ClientData *handlePtr) /* Where to store handle */
{
+ (void)dummy;
+ (void)direction;
+ (void)handlePtr;
+
return TCL_ERROR;
}
@@ -694,7 +715,7 @@ ConsoleObjCmd(
"eval", "hide", "show", "title", NULL};
enum option {CON_EVAL, CON_HIDE, CON_SHOW, CON_TITLE};
Tcl_Obj *cmd = NULL;
- ConsoleInfo *info = clientData;
+ ConsoleInfo *info = (ConsoleInfo *)clientData;
Tcl_Interp *consoleInterp = info->consoleInterp;
if (objc < 2) {
@@ -784,7 +805,7 @@ InterpreterObjCmd(
int index, result = TCL_OK;
static const char *const options[] = {"eval", "record", NULL};
enum option {OTHER_EVAL, OTHER_RECORD};
- ConsoleInfo *info = clientData;
+ ConsoleInfo *info = (ConsoleInfo *)clientData;
Tcl_Interp *otherInterp = info->interp;
if (objc < 2) {
@@ -852,7 +873,7 @@ static void
DeleteConsoleInterp(
ClientData clientData)
{
- Tcl_Interp *interp = clientData;
+ Tcl_Interp *interp = (Tcl_Interp *)clientData;
Tcl_DeleteInterp(interp);
}
@@ -879,7 +900,7 @@ InterpDeleteProc(
ClientData clientData,
Tcl_Interp *interp)
{
- ConsoleInfo *info = clientData;
+ ConsoleInfo *info = (ConsoleInfo *)clientData;
if (info->consoleInterp == interp) {
Tcl_DeleteThreadExitHandler(DeleteConsoleInterp, info->consoleInterp);
@@ -911,7 +932,7 @@ static void
ConsoleDeleteProc(
ClientData clientData)
{
- ConsoleInfo *info = clientData;
+ ConsoleInfo *info = (ConsoleInfo *)clientData;
if (info->consoleInterp) {
Tcl_DeleteInterp(info->consoleInterp);
@@ -946,7 +967,7 @@ ConsoleEventProc(
XEvent *eventPtr)
{
if (eventPtr->type == DestroyNotify) {
- ConsoleInfo *info = clientData;
+ ConsoleInfo *info = (ConsoleInfo *)clientData;
Tcl_Interp *consoleInterp = info->consoleInterp;
if (consoleInterp && !Tcl_InterpDeleted(consoleInterp)) {
diff --git a/generic/tkCursor.c b/generic/tkCursor.c
index 76bbc89..98f018a 100644
--- a/generic/tkCursor.c
+++ b/generic/tkCursor.c
@@ -100,7 +100,7 @@ Tk_AllocCursorFromObj(
if (objPtr->typePtr != &tkCursorObjType) {
InitCursorObj(objPtr);
}
- cursorPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ cursorPtr = (TkCursor *)objPtr->internalRep.twoPtrValue.ptr1;
/*
* If the object currently points to a TkCursor, see if it's the one we
@@ -129,7 +129,7 @@ Tk_AllocCursorFromObj(
*/
if (cursorPtr != NULL) {
- TkCursor *firstCursorPtr = Tcl_GetHashValue(cursorPtr->hashPtr);
+ TkCursor *firstCursorPtr = (TkCursor *)Tcl_GetHashValue(cursorPtr->hashPtr);
FreeCursorObj(objPtr);
for (cursorPtr = firstCursorPtr; cursorPtr != NULL;
@@ -229,7 +229,7 @@ TkcGetCursor(
* details on legal syntax. */
{
Tcl_HashEntry *nameHashPtr;
- register TkCursor *cursorPtr;
+ TkCursor *cursorPtr;
TkCursor *existingCursorPtr = NULL;
int isNew;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -241,7 +241,7 @@ TkcGetCursor(
nameHashPtr = Tcl_CreateHashEntry(&dispPtr->cursorNameTable,
string, &isNew);
if (!isNew) {
- existingCursorPtr = Tcl_GetHashValue(nameHashPtr);
+ existingCursorPtr = (TkCursor *)Tcl_GetHashValue(nameHashPtr);
for (cursorPtr = existingCursorPtr; cursorPtr != NULL;
cursorPtr = cursorPtr->nextPtr) {
if (Tk_Display(tkwin) == cursorPtr->display) {
@@ -320,7 +320,7 @@ Tk_GetCursorFromData(
{
DataKey dataKey;
Tcl_HashEntry *dataHashPtr;
- register TkCursor *cursorPtr;
+ TkCursor *cursorPtr;
int isNew;
XColor fgColor, bgColor;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -341,7 +341,7 @@ Tk_GetCursorFromData(
dataHashPtr = Tcl_CreateHashEntry(&dispPtr->cursorDataTable,
(char *) &dataKey, &isNew);
if (!isNew) {
- cursorPtr = Tcl_GetHashValue(dataHashPtr);
+ cursorPtr = (TkCursor *)Tcl_GetHashValue(dataHashPtr);
cursorPtr->resourceRefCount++;
return cursorPtr->cursor;
}
@@ -425,14 +425,14 @@ Tk_NameOfCursor(
if (!dispPtr->cursorInit) {
printid:
- sprintf(dispPtr->cursorString, "cursor id %p", cursor);
+ sprintf(dispPtr->cursorString, "cursor id 0x%" TCL_Z_MODIFIER "x", (size_t)cursor);
return dispPtr->cursorString;
}
idHashPtr = Tcl_FindHashEntry(&dispPtr->cursorIdTable, cursor);
if (idHashPtr == NULL) {
goto printid;
}
- cursorPtr = Tcl_GetHashValue(idHashPtr);
+ cursorPtr = (TkCursor *)Tcl_GetHashValue(idHashPtr);
if (cursorPtr->otherTable != &dispPtr->cursorNameTable) {
goto printid;
}
@@ -468,7 +468,7 @@ FreeCursor(
}
Tcl_DeleteHashEntry(cursorPtr->idHashPtr);
- prevPtr = Tcl_GetHashValue(cursorPtr->hashPtr);
+ prevPtr = (TkCursor *)Tcl_GetHashValue(cursorPtr->hashPtr);
if (prevPtr == cursorPtr) {
if (cursorPtr->nextPtr == NULL) {
Tcl_DeleteHashEntry(cursorPtr->hashPtr);
@@ -521,7 +521,7 @@ Tk_FreeCursor(
if (idHashPtr == NULL) {
Tcl_Panic("Tk_FreeCursor received unknown cursor argument");
}
- FreeCursor(Tcl_GetHashValue(idHashPtr));
+ FreeCursor((TkCursor *)Tcl_GetHashValue(idHashPtr));
}
/*
@@ -586,7 +586,7 @@ static void
FreeCursorObj(
Tcl_Obj *objPtr) /* The object we are releasing. */
{
- TkCursor *cursorPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ TkCursor *cursorPtr = (TkCursor *)objPtr->internalRep.twoPtrValue.ptr1;
if (cursorPtr != NULL) {
if ((cursorPtr->objRefCount-- <= 1)
@@ -620,7 +620,7 @@ DupCursorObjProc(
Tcl_Obj *srcObjPtr, /* The object we are copying from. */
Tcl_Obj *dupObjPtr) /* The object we are copying to. */
{
- TkCursor *cursorPtr = srcObjPtr->internalRep.twoPtrValue.ptr1;
+ TkCursor *cursorPtr = (TkCursor *)srcObjPtr->internalRep.twoPtrValue.ptr1;
dupObjPtr->typePtr = srcObjPtr->typePtr;
dupObjPtr->internalRep.twoPtrValue.ptr1 = cursorPtr;
@@ -705,7 +705,7 @@ GetCursorFromObj(
* cached is the one that is needed.
*/
- cursorPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ cursorPtr = (TkCursor *)objPtr->internalRep.twoPtrValue.ptr1;
if ((cursorPtr != NULL) && (Tk_Display(tkwin) == cursorPtr->display)) {
return cursorPtr;
}
@@ -720,7 +720,7 @@ GetCursorFromObj(
if (hashPtr == NULL) {
goto error;
}
- for (cursorPtr = Tcl_GetHashValue(hashPtr);
+ for (cursorPtr = (TkCursor *)Tcl_GetHashValue(hashPtr);
cursorPtr != NULL; cursorPtr = cursorPtr->nextPtr) {
if (Tk_Display(tkwin) == cursorPtr->display) {
FreeCursorObj(objPtr);
@@ -855,7 +855,7 @@ TkDebugCursor(
resultPtr = Tcl_NewObj();
hashPtr = Tcl_FindHashEntry(&dispPtr->cursorNameTable, name);
if (hashPtr != NULL) {
- cursorPtr = Tcl_GetHashValue(hashPtr);
+ cursorPtr = (TkCursor *)Tcl_GetHashValue(hashPtr);
if (cursorPtr == NULL) {
Tcl_Panic("TkDebugCursor found empty hash table entry");
}
diff --git a/generic/tkDList.h b/generic/tkDList.h
new file mode 100644
index 0000000..57af7d8
--- /dev/null
+++ b/generic/tkDList.h
@@ -0,0 +1,546 @@
+/*
+ * tkDList.h --
+ *
+ * A list is headed by pointers to first and last element. The elements
+ * are doubly linked so that an arbitrary element can be removed without
+ * a need to traverse the list. New elements can be added to the list
+ * before or after an existing element or at the head/tail of the list.
+ * A list may be traversed in the forward or backward direction.
+ *
+ * Copyright (c) 2018 by Gregor Cramer.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+/*
+ * Note that this file will not be included in header files, it is the purpose
+ * of this file to be included in source files only. Thus we are not using the
+ * prefix "Tk_" here for functions, because all the functions have private scope.
+ */
+
+/*
+ * -------------------------------------------------------------------------------
+ * Use the double linked list in the following way:
+ * -------------------------------------------------------------------------------
+ * typedef struct MyListEntry { TK_DLIST_LINKS(MyListEntry); int value; } MyListEntry;
+ * TK_DLIST_DEFINE(MyList, MyListEntry);
+ * MyList listHdr = TK_DLIST_LIST_INITIALIZER; // or MyList_Init(&listHdr)
+ * MyListEntry *p;
+ * int i = 0;
+ * MyList_Append(&listHdr, (MyListEntry *)ckalloc(sizeof(MyListEntry)));
+ * MyList_Append(&listHdr, (MyListEntry *)ckalloc(sizeof(MyListEntry)));
+ * TK_DLIST_FOREACH(p, &listHdr) { p->value = i++; }
+ * // ...
+ * MyList_RemoveHead(&listHdr);
+ * MyList_RemoveHead(&listHdr);
+ * MyList_Clear(MyListEntry, &listHdr); // invokes ckfree() for each element
+ * -------------------------------------------------------------------------------
+ * IMPORTANT NOTE: TK_DLIST_LINKS must be used at start of struct!
+ */
+
+#ifndef TK_DLIST_DEFINED
+#define TK_DLIST_DEFINED
+
+#include "tkInt.h"
+
+/*
+ * List definitions.
+ */
+
+#define TK_DLIST_LINKS(ElemType) \
+struct { \
+ struct ElemType *prev; /* previous element */ \
+ struct ElemType *next; /* next element */ \
+} _dl_
+
+#define TK_DLIST_LIST_INITIALIZER { NULL, NULL }
+#define TK_DLIST_ELEM_INITIALIZER { NULL, NULL }
+
+/*************************************************************************/
+/*
+ * DList_Init: Initialize list header. This can also be used to clear the
+ * list.
+ *
+ * See also: DList_Clear()
+ */
+/*************************************************************************/
+/*
+ * DList_ElemInit: Initialize a list element.
+ */
+/*************************************************************************/
+/*
+ * DList_InsertAfter: Insert 'elem' after 'listElem'. 'elem' must not
+ * be linked, but 'listElem' must be linked.
+ */
+/*************************************************************************/
+/*
+ * DList_InsertBefore: Insert 'elem' before 'listElem'. 'elem' must not
+ * be linked, but 'listElem' must be linked.
+ */
+/*************************************************************************/
+/*
+ * DList_Prepend: Insert 'elem' at start of list. This element must not
+ * be linked.
+ *
+ * See also: DList_Append()
+ */
+/*************************************************************************/
+/*
+ * DList_Append: Append 'elem' to end of list. This element must not
+ * be linked.
+ *
+ * See also: DList_Prepend()
+ */
+/*************************************************************************/
+/*
+ * DList_Move: Append all list items of 'src' to end of 'dst'.
+ */
+/*************************************************************************/
+/*
+ * DList_Remove: Remove 'elem' from list. This element must be linked.
+ *
+ * See also: DList_Free()
+ */
+/*************************************************************************/
+/*
+ * DList_Free: Remove 'elem' from list and free it. This element must
+ * be linked.
+ *
+ * See also: DList_Remove()
+ */
+/*************************************************************************/
+/*
+ * DList_RemoveHead: Remove first element from list. The list must
+ * not be empty.
+ *
+ * See also: DList_FreeHead()
+ */
+/*************************************************************************/
+/*
+ * DList_RemoveTail: Remove last element from list. The list must
+ * not be empty.
+ *
+ * See also: DList_FreeTail()
+ */
+/*************************************************************************/
+/*
+ * DList_FreeHead: Remove first element from list and free it.
+ * The list must not be empty.
+ *
+ * See also: DList_RemoveHead()
+ */
+/*************************************************************************/
+/*
+ * DList_FreeTail: Remove last element from list and free it.
+ * The list must not be empty.
+ *
+ * See also: DList_RemoveTail()
+ */
+/*************************************************************************/
+/*
+ * DList_SwapElems: Swap positions of given elements 'lhs' and 'rhs'.
+ * Both elements must be linked, and must belong to same list.
+ */
+/*************************************************************************/
+/*
+ * DList_Clear: Clear whole list and free all elements.
+ *
+ * See also: DList_Init
+ */
+/*************************************************************************/
+/*
+ * DList_Traverse: Iterate over all elements in list from first to last.
+ * Call given function func(head, elem) for each element. The function has
+ * to return the next element in list to traverse, normally this is
+ * DList_Next(elem).
+ *
+ * See also: TK_DLIST_FOREACH, TK_DLIST_FOREACH_REVERSE
+ */
+/*************************************************************************/
+/*
+ * DList_First: Return pointer of first element in list, maybe it's NULL.
+ */
+/*************************************************************************/
+/*
+ * DList_Last: Return pointer of last element in list, maybe it's NULL.
+ */
+/*************************************************************************/
+/*
+ * DList_Next: Return pointer of next element after 'elem', maybe it's NULL.
+ *
+ * See also: DList_Prev()
+ */
+/*************************************************************************/
+/*
+ * DList_Prev: Return pointer of previous element before 'elem', maybe it's
+ * NULL.
+ *
+ * See also: DList_Next()
+ */
+/*************************************************************************/
+/*
+ * DList_IsEmpty: Test whether given list is empty.
+ */
+/*************************************************************************/
+/*
+ * DList_IsLinked: Test whether given element is linked.
+ */
+/*************************************************************************/
+/*
+ * DList_IsFirst: Test whether given element is first element in list.
+ * Note that 'elem' must be linked.
+ *
+ * See also: DList_IsLast(), DList_IsLinked()
+ */
+/*************************************************************************/
+/*
+ * DList_IsLast: Test whether given element is last element in list.
+ * Note that 'elem' must be linked.
+ *
+ * See also: DList_IsFirst(), DList_IsLinked()
+ */
+/*************************************************************************/
+/*
+ * DList_Size: Count number of elements in given list.
+ */
+/*************************************************************************/
+/*
+ * TK_DLIST_FOREACH: Iterate over all elements in list from first to last.
+ * 'var' is the name of the variable which points to current element.
+ *
+ * See also: TK_DLIST_FOREACH_REVERSE, DList_Traverse()
+ */
+/*************************************************************************/
+/*
+ * TK_DLIST_FOREACH_REVERSE: Iterate over all elements in list from last
+ * to first (backwards). 'var' is the name of the variable which points to
+ * current element.
+ */
+/*************************************************************************/
+
+#if defined(__GNUC__) || defined(__clang__)
+# define __TK_DLIST_UNUSED __attribute__((unused))
+#else
+# define __TK_DLIST_UNUSED
+#endif
+
+#define TK_DLIST_DEFINE(LT, ElemType) /* LT = type of head/list */ \
+/* ------------------------------------------------------------------------- */ \
+typedef struct LT { \
+ struct ElemType *first; /* first element */ \
+ struct ElemType *last; /* last element */ \
+} LT; \
+ \
+typedef struct ElemType *(LT##_Func)(LT *head, struct ElemType *elem); \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_Init(LT *head) \
+{ \
+ assert(head); \
+ head->first = NULL; \
+ head->last = NULL; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_ElemInit(struct ElemType *elem) \
+{ \
+ assert(elem); \
+ elem->_dl_.next = NULL; \
+ elem->_dl_.prev = NULL; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static int \
+LT##_IsEmpty(LT *head) \
+{ \
+ assert(head); \
+ return head->first == NULL; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static int \
+LT##_IsLinked(struct ElemType *elem) \
+{ \
+ assert(elem); \
+ return elem->_dl_.next && elem->_dl_.prev; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static int \
+LT##_IsFirst(struct ElemType *elem) \
+{ \
+ assert(LT##_IsLinked(elem)); \
+ return elem->_dl_.prev->_dl_.prev == elem; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static int \
+LT##_IsLast(struct ElemType *elem) \
+{ \
+ assert(LT##_IsLinked(elem)); \
+ return elem->_dl_.next->_dl_.next == elem; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static struct ElemType * \
+LT##_First(LT *head) \
+{ \
+ assert(head); \
+ return head->first; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static struct ElemType * \
+LT##_Last(LT *head) \
+{ \
+ assert(head); \
+ return head->last; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static struct ElemType * \
+LT##_Next(struct ElemType *elem) \
+{ \
+ assert(elem); \
+ return LT##_IsLast(elem) ? NULL : elem->_dl_.next; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static struct ElemType * \
+LT##_Prev(struct ElemType *elem) \
+{ \
+ assert(elem); \
+ return LT##_IsFirst(elem) ? NULL : elem->_dl_.prev; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static unsigned \
+LT##_Size(const LT *head) \
+{ \
+ const struct ElemType *elem; \
+ unsigned size = 0; \
+ assert(head); \
+ if ((elem = head->first)) { \
+ for ( ; elem != (void *) head; elem = elem->_dl_.next) { \
+ ++size; \
+ } \
+ } \
+ return size; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_InsertAfter(struct ElemType *listElem, struct ElemType *elem) \
+{ \
+ assert(listElem); \
+ assert(elem); \
+ elem->_dl_.next = listElem->_dl_.next; \
+ elem->_dl_.prev = listElem; \
+ listElem->_dl_.next->_dl_.prev = elem; \
+ listElem->_dl_.next = elem; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_InsertBefore(struct ElemType *listElem, struct ElemType *elem) \
+{ \
+ assert(listElem); \
+ assert(elem); \
+ elem->_dl_.next = listElem; \
+ elem->_dl_.prev = listElem->_dl_.prev;; \
+ listElem->_dl_.prev->_dl_.next = elem; \
+ listElem->_dl_.prev = elem; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_Prepend(LT *head, struct ElemType *elem) \
+{ \
+ assert(head); \
+ assert(elem); \
+ elem->_dl_.prev = (PSEntry *) head; \
+ if (!head->first) { \
+ elem->_dl_.next = (PSEntry *) head; \
+ head->last = elem; \
+ } else { \
+ elem->_dl_.next = head->first; \
+ head->first->_dl_.prev = elem; \
+ } \
+ head->first = elem; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_Append(LT *head, struct ElemType *elem) \
+{ \
+ assert(head); \
+ assert(elem); \
+ elem->_dl_.next = (PSEntry *) head; \
+ if (!head->first) { \
+ elem->_dl_.prev = (PSEntry *) head; \
+ head->first = elem; \
+ } else { \
+ elem->_dl_.prev = head->last; \
+ head->last->_dl_.next = elem; \
+ } \
+ head->last = elem; \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_Move(LT *dst, LT *src) \
+{ \
+ assert(dst); \
+ assert(src); \
+ if (src->first) { \
+ if (dst->first) { \
+ dst->last->_dl_.next = src->first; \
+ src->first->_dl_.prev = dst->last; \
+ dst->last = src->last; \
+ } else { \
+ *dst = *src; \
+ dst->first->_dl_.prev = (PSEntry *) dst; \
+ } \
+ dst->last->_dl_.next = (PSEntry *) dst; \
+ LT##_Init(src); \
+ } \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_Remove(struct ElemType *elem) \
+{ \
+ int isFirst, isLast; \
+ assert(LT##_IsLinked(elem)); \
+ isFirst = LT##_IsFirst(elem); \
+ isLast = LT##_IsLast(elem); \
+ if (isFirst && isLast) { \
+ ((LT *) elem->_dl_.prev)->first = NULL; \
+ ((LT *) elem->_dl_.next)->last = NULL; \
+ } else { \
+ if (isFirst) { \
+ ((LT *) elem->_dl_.prev)->first = elem->_dl_.next; \
+ } else { \
+ elem->_dl_.prev->_dl_.next = elem->_dl_.next; \
+ } \
+ if (isLast) { \
+ ((LT *) elem->_dl_.next)->last = elem->_dl_.prev; \
+ } else { \
+ elem->_dl_.next->_dl_.prev = elem->_dl_.prev; \
+ } \
+ } \
+ LT##_ElemInit(elem); \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_Free(struct ElemType *elem) \
+{ \
+ LT##_Remove(elem); \
+ ckfree((void *) elem); \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_RemoveHead(LT *head) \
+{ \
+ assert(!LT##_IsEmpty(head)); \
+ LT##_Remove(head->first); \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_RemoveTail(LT *head) \
+{ \
+ assert(!LT##_IsEmpty(head)); \
+ LT##_Remove(head->last); \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_FreeHead(LT *head) \
+{ \
+ assert(!LT##_IsEmpty(head)); \
+ LT##_Free(head->first); \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_FreeTail(LT *head) \
+{ \
+ assert(!LT##_IsEmpty(head)); \
+ LT##_Free(head->last); \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_SwapElems(struct ElemType *lhs, struct ElemType *rhs) \
+{ \
+ assert(lhs); \
+ assert(rhs); \
+ if (lhs != rhs) { \
+ struct ElemType tmp; \
+ if (LT##_IsFirst(lhs)) { \
+ ((LT *) lhs->_dl_.prev)->first = rhs; \
+ } else if (LT##_IsFirst(rhs)) { \
+ ((LT *) rhs->_dl_.prev)->first = lhs; \
+ } \
+ if (LT##_IsLast(lhs)) { \
+ ((LT *) lhs->_dl_.next)->last = rhs; \
+ } else if (LT##_IsLast(rhs)) { \
+ ((LT *) rhs->_dl_.next)->last = lhs; \
+ } \
+ tmp._dl_ = lhs->_dl_; \
+ lhs->_dl_ = rhs->_dl_; \
+ rhs->_dl_ = tmp._dl_; \
+ } \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_Clear(LT *head) \
+{ \
+ struct ElemType *p; \
+ struct ElemType *next; \
+ assert(head); \
+ for (p = head->first; p; p = next) { \
+ next = LT##_Next(p); \
+ ckfree((void *) p); \
+ } \
+ LT##_Init(head); \
+} \
+ \
+__TK_DLIST_UNUSED \
+static void \
+LT##_Traverse(LT *head, LT##_Func func) \
+{ \
+ struct ElemType *next; \
+ struct ElemType *p; \
+ assert(head); \
+ for (p = head->first; p; p = next) { \
+ next = func(head, p); \
+ } \
+} \
+/* ------------------------------------------------------------------------- */
+
+#define TK_DLIST_FOREACH(var, head) \
+ assert(head); \
+ for (var = head->first ? head->first : (PSEntry *) head; var != (PSEntry *) head; var = var->_dl_.next)
+
+#define TK_DLIST_FOREACH_REVERSE(var, head) \
+ assert(head); \
+ for (var = head->last ? head->last : (PSEntry *) head; var != (PSEntry *) head; var = var->_dl_.prev)
+
+#endif /* TK_DLIST_DEFINED */
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 105
+ * End:
+ * vi:set ts=8 sw=4:
+ */
diff --git a/generic/tkEntry.c b/generic/tkEntry.c
index 7e94d9b..bffe8b8 100644
--- a/generic/tkEntry.c
+++ b/generic/tkEntry.c
@@ -63,108 +63,108 @@ enum validateType {
static const Tk_OptionSpec entryOptSpec[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_ENTRY_BG_COLOR, -1, Tk_Offset(Entry, normalBorder),
+ DEF_ENTRY_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, normalBorder),
0, DEF_ENTRY_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_ENTRY_BORDER_WIDTH, -1, Tk_Offset(Entry, borderWidth), 0, 0, 0},
+ DEF_ENTRY_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Entry, borderWidth), 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_ENTRY_CURSOR, -1, Tk_Offset(Entry, cursor),
+ DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BORDER, "-disabledbackground", "disabledBackground",
- "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, -1,
- Tk_Offset(Entry, disabledBorder), TK_OPTION_NULL_OK,
+ "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, disabledBorder), TK_OPTION_NULL_OK,
(ClientData) DEF_ENTRY_DISABLED_BG_MONO, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_ENTRY_DISABLED_FG, -1,
- Tk_Offset(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
+ "DisabledForeground", DEF_ENTRY_DISABLED_FG, TCL_INDEX_NONE,
+ offsetof(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, -1,
- Tk_Offset(Entry, exportSelection), 0, 0, 0},
+ "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, TCL_INDEX_NONE,
+ offsetof(Entry, exportSelection), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_ENTRY_FONT, -1, Tk_Offset(Entry, tkfont), 0, 0, 0},
+ DEF_ENTRY_FONT, TCL_INDEX_NONE, offsetof(Entry, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_ENTRY_FG, -1, Tk_Offset(Entry, fgColorPtr), 0, 0, 0},
+ DEF_ENTRY_FG, TCL_INDEX_NONE, offsetof(Entry, fgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_ENTRY_HIGHLIGHT_BG,
- -1, Tk_Offset(Entry, highlightBgColorPtr), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Entry, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_ENTRY_HIGHLIGHT, -1, Tk_Offset(Entry, highlightColorPtr), 0, 0, 0},
+ DEF_ENTRY_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Entry, highlightColorPtr), 0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Entry, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Entry, highlightWidth), 0, 0, 0},
{TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
- DEF_ENTRY_INSERT_BG, -1, Tk_Offset(Entry, insertBorder), 0, 0, 0},
+ DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0},
{TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth",
- "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, -1,
- Tk_Offset(Entry, insertBorderWidth), 0,
+ "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, insertBorderWidth), 0,
(ClientData) DEF_ENTRY_INSERT_BD_MONO, 0},
{TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_ENTRY_INSERT_OFF_TIME, -1, Tk_Offset(Entry, insertOffTime),
+ DEF_ENTRY_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOffTime),
0, 0, 0},
{TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_ENTRY_INSERT_ON_TIME, -1, Tk_Offset(Entry, insertOnTime), 0, 0, 0},
+ DEF_ENTRY_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOnTime), 0, 0, 0},
{TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_ENTRY_INSERT_WIDTH, -1, Tk_Offset(Entry, insertWidth), 0, 0, 0},
+ DEF_ENTRY_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(Entry, insertWidth), 0, 0, 0},
{TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand",
- DEF_ENTRY_INVALIDCMD, -1, Tk_Offset(Entry, invalidCmd),
+ DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-invcmd", NULL, NULL,
- NULL, 0, -1, 0, "-invalidcommand", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-invalidcommand", 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_ENTRY_JUSTIFY, -1, Tk_Offset(Entry, justify), 0, 0, 0},
+ DEF_ENTRY_JUSTIFY, TCL_INDEX_NONE, offsetof(Entry, justify), 0, 0, 0},
{TK_OPTION_STRING, "-placeholder", "placeHolder", "PlaceHolder",
- DEF_ENTRY_PLACEHOLDER, -1, Tk_Offset(Entry, placeholderString),
+ DEF_ENTRY_PLACEHOLDER, TCL_INDEX_NONE, offsetof(Entry, placeholderString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-placeholderforeground", "placeholderForeground",
- "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, -1,
- Tk_Offset(Entry, placeholderColorPtr), 0, 0, 0},
+ "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, TCL_INDEX_NONE,
+ offsetof(Entry, placeholderColorPtr), 0, 0, 0},
{TK_OPTION_BORDER, "-readonlybackground", "readonlyBackground",
- "ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, -1,
- Tk_Offset(Entry, readonlyBorder), TK_OPTION_NULL_OK,
+ "ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, readonlyBorder), TK_OPTION_NULL_OK,
(ClientData) DEF_ENTRY_READONLY_BG_MONO, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_ENTRY_RELIEF, -1, Tk_Offset(Entry, relief), 0, 0, 0},
+ DEF_ENTRY_RELIEF, TCL_INDEX_NONE, offsetof(Entry, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_ENTRY_SELECT_COLOR, -1, Tk_Offset(Entry, selBorder),
+ DEF_ENTRY_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Entry, selBorder),
0, DEF_ENTRY_SELECT_MONO, 0},
{TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
- "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, -1,
- Tk_Offset(Entry, selBorderWidth),
+ "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, selBorderWidth),
0, DEF_ENTRY_SELECT_BD_MONO, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_ENTRY_SELECT_FG_COLOR, -1, Tk_Offset(Entry, selFgColorPtr),
+ DEF_ENTRY_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Entry, selFgColorPtr),
TK_OPTION_NULL_OK, DEF_ENTRY_SELECT_FG_MONO, 0},
{TK_OPTION_STRING, "-show", "show", "Show",
- DEF_ENTRY_SHOW, -1, Tk_Offset(Entry, showChar),
+ DEF_ENTRY_SHOW, TCL_INDEX_NONE, offsetof(Entry, showChar),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_ENTRY_STATE, -1, Tk_Offset(Entry, state),
+ DEF_ENTRY_STATE, TCL_INDEX_NONE, offsetof(Entry, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_ENTRY_TAKE_FOCUS, -1, Tk_Offset(Entry, takeFocus),
+ DEF_ENTRY_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Entry, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_ENTRY_TEXT_VARIABLE, -1, Tk_Offset(Entry, textVarName),
+ DEF_ENTRY_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Entry, textVarName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate",
- DEF_ENTRY_VALIDATE, -1, Tk_Offset(Entry, validate),
+ DEF_ENTRY_VALIDATE, TCL_INDEX_NONE, offsetof(Entry, validate),
0, validateStrings, 0},
{TK_OPTION_STRING, "-validatecommand", "validateCommand","ValidateCommand",
- NULL, -1, Tk_Offset(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-vcmd", NULL, NULL,
- NULL, 0, -1, 0, "-validatecommand", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-validatecommand", 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_ENTRY_WIDTH, -1, Tk_Offset(Entry, prefWidth), 0, 0, 0},
+ DEF_ENTRY_WIDTH, TCL_INDEX_NONE, offsetof(Entry, prefWidth), 0, 0, 0},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_ENTRY_SCROLL_COMMAND, -1, Tk_Offset(Entry, scrollCmd),
+ DEF_ENTRY_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Entry, scrollCmd),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -186,141 +186,141 @@ static const Tk_OptionSpec entryOptSpec[] = {
static const Tk_OptionSpec sbOptSpec[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Background",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(Spinbox, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(Spinbox, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_ENTRY_BG_COLOR, -1, Tk_Offset(Entry, normalBorder),
+ DEF_ENTRY_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, normalBorder),
0, DEF_ENTRY_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_ENTRY_BORDER_WIDTH, -1, Tk_Offset(Entry, borderWidth), 0, 0, 0},
- {TK_OPTION_BORDER, "-buttonbackground", "Button.background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(Spinbox, buttonBorder),
+ DEF_ENTRY_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Entry, borderWidth), 0, 0, 0},
+ {TK_OPTION_BORDER, "-buttonbackground", "buttonBackground", "Background",
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(Spinbox, buttonBorder),
0, DEF_BUTTON_BG_MONO, 0},
- {TK_OPTION_CURSOR, "-buttoncursor", "Button.cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(Spinbox, bCursor),
+ {TK_OPTION_CURSOR, "-buttoncursor", "buttonCursor", "Cursor",
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(Spinbox, bCursor),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_RELIEF, "-buttondownrelief", "Button.relief", "Relief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(Spinbox, bdRelief), 0, 0, 0},
- {TK_OPTION_RELIEF, "-buttonuprelief", "Button.relief", "Relief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(Spinbox, buRelief), 0, 0, 0},
+ {TK_OPTION_RELIEF, "-buttondownrelief", "buttonDownRelief", "Relief",
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(Spinbox, bdRelief), 0, 0, 0},
+ {TK_OPTION_RELIEF, "-buttonuprelief", "buttonUpRelief", "Relief",
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(Spinbox, buRelief), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_SPINBOX_CMD, -1, Tk_Offset(Spinbox, command),
+ DEF_SPINBOX_CMD, TCL_INDEX_NONE, offsetof(Spinbox, command),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_ENTRY_CURSOR, -1, Tk_Offset(Entry, cursor),
+ DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BORDER, "-disabledbackground", "disabledBackground",
- "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, -1,
- Tk_Offset(Entry, disabledBorder), TK_OPTION_NULL_OK,
+ "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, disabledBorder), TK_OPTION_NULL_OK,
(ClientData) DEF_ENTRY_DISABLED_BG_MONO, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_ENTRY_DISABLED_FG, -1,
- Tk_Offset(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
+ "DisabledForeground", DEF_ENTRY_DISABLED_FG, TCL_INDEX_NONE,
+ offsetof(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, -1,
- Tk_Offset(Entry, exportSelection), 0, 0, 0},
+ "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, TCL_INDEX_NONE,
+ offsetof(Entry, exportSelection), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_ENTRY_FONT, -1, Tk_Offset(Entry, tkfont), 0, 0, 0},
+ DEF_ENTRY_FONT, TCL_INDEX_NONE, offsetof(Entry, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_ENTRY_FG, -1, Tk_Offset(Entry, fgColorPtr), 0, 0, 0},
+ DEF_ENTRY_FG, TCL_INDEX_NONE, offsetof(Entry, fgColorPtr), 0, 0, 0},
{TK_OPTION_STRING, "-format", "format", "Format",
- DEF_SPINBOX_FORMAT, -1, Tk_Offset(Spinbox, reqFormat),
+ DEF_SPINBOX_FORMAT, TCL_INDEX_NONE, offsetof(Spinbox, reqFormat),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_DOUBLE, "-from", "from", "From",
- DEF_SPINBOX_FROM, -1, Tk_Offset(Spinbox, fromValue), 0, 0, 0},
+ DEF_SPINBOX_FROM, TCL_INDEX_NONE, offsetof(Spinbox, fromValue), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_ENTRY_HIGHLIGHT_BG,
- -1, Tk_Offset(Entry, highlightBgColorPtr), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Entry, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_ENTRY_HIGHLIGHT, -1, Tk_Offset(Entry, highlightColorPtr), 0, 0, 0},
+ DEF_ENTRY_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Entry, highlightColorPtr), 0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Entry, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Entry, highlightWidth), 0, 0, 0},
{TK_OPTION_DOUBLE, "-increment", "increment", "Increment",
- DEF_SPINBOX_INCREMENT, -1, Tk_Offset(Spinbox, increment), 0, 0, 0},
+ DEF_SPINBOX_INCREMENT, TCL_INDEX_NONE, offsetof(Spinbox, increment), 0, 0, 0},
{TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
- DEF_ENTRY_INSERT_BG, -1, Tk_Offset(Entry, insertBorder), 0, 0, 0},
+ DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0},
{TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth",
- "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, -1,
- Tk_Offset(Entry, insertBorderWidth), 0,
+ "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, insertBorderWidth), 0,
(ClientData) DEF_ENTRY_INSERT_BD_MONO, 0},
{TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_ENTRY_INSERT_OFF_TIME, -1, Tk_Offset(Entry, insertOffTime),
+ DEF_ENTRY_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOffTime),
0, 0, 0},
{TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_ENTRY_INSERT_ON_TIME, -1, Tk_Offset(Entry, insertOnTime), 0, 0, 0},
+ DEF_ENTRY_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOnTime), 0, 0, 0},
{TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_ENTRY_INSERT_WIDTH, -1, Tk_Offset(Entry, insertWidth), 0, 0, 0},
+ DEF_ENTRY_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(Entry, insertWidth), 0, 0, 0},
{TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand",
- DEF_ENTRY_INVALIDCMD, -1, Tk_Offset(Entry, invalidCmd),
+ DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-invcmd", NULL, NULL,
- NULL, 0, -1, 0, "-invalidcommand", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-invalidcommand", 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_ENTRY_JUSTIFY, -1, Tk_Offset(Entry, justify), 0, 0, 0},
+ DEF_ENTRY_JUSTIFY, TCL_INDEX_NONE, offsetof(Entry, justify), 0, 0, 0},
{TK_OPTION_STRING, "-placeholder", "placeHolder", "PlaceHolder",
- DEF_ENTRY_PLACEHOLDER, -1, Tk_Offset(Entry, placeholderString),
+ DEF_ENTRY_PLACEHOLDER, TCL_INDEX_NONE, offsetof(Entry, placeholderString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-placeholderforeground", "placeholderForeground",
- "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, -1,
- Tk_Offset(Entry, placeholderColorPtr), 0, 0, 0},
+ "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, TCL_INDEX_NONE,
+ offsetof(Entry, placeholderColorPtr), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_ENTRY_RELIEF, -1, Tk_Offset(Entry, relief), 0, 0, 0},
+ DEF_ENTRY_RELIEF, TCL_INDEX_NONE, offsetof(Entry, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-readonlybackground", "readonlyBackground",
- "ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, -1,
- Tk_Offset(Entry, readonlyBorder), TK_OPTION_NULL_OK,
+ "ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, readonlyBorder), TK_OPTION_NULL_OK,
(ClientData) DEF_ENTRY_READONLY_BG_MONO, 0},
{TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_SPINBOX_REPEAT_DELAY, -1, Tk_Offset(Spinbox, repeatDelay),
+ DEF_SPINBOX_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(Spinbox, repeatDelay),
0, 0, 0},
{TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_SPINBOX_REPEAT_INTERVAL, -1, Tk_Offset(Spinbox, repeatInterval),
+ DEF_SPINBOX_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(Spinbox, repeatInterval),
0, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_ENTRY_SELECT_COLOR, -1, Tk_Offset(Entry, selBorder),
+ DEF_ENTRY_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Entry, selBorder),
0, DEF_ENTRY_SELECT_MONO, 0},
{TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
- "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, -1,
- Tk_Offset(Entry, selBorderWidth),
+ "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, selBorderWidth),
0, DEF_ENTRY_SELECT_BD_MONO, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_ENTRY_SELECT_FG_COLOR, -1, Tk_Offset(Entry, selFgColorPtr),
+ DEF_ENTRY_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Entry, selFgColorPtr),
TK_OPTION_NULL_OK, DEF_ENTRY_SELECT_FG_MONO, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_ENTRY_STATE, -1, Tk_Offset(Entry, state),
+ DEF_ENTRY_STATE, TCL_INDEX_NONE, offsetof(Entry, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_ENTRY_TAKE_FOCUS, -1, Tk_Offset(Entry, takeFocus),
+ DEF_ENTRY_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Entry, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_ENTRY_TEXT_VARIABLE, -1, Tk_Offset(Entry, textVarName),
+ DEF_ENTRY_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Entry, textVarName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_DOUBLE, "-to", "to", "To",
- DEF_SPINBOX_TO, -1, Tk_Offset(Spinbox, toValue), 0, 0, 0},
+ DEF_SPINBOX_TO, TCL_INDEX_NONE, offsetof(Spinbox, toValue), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate",
- DEF_ENTRY_VALIDATE, -1, Tk_Offset(Entry, validate),
+ DEF_ENTRY_VALIDATE, TCL_INDEX_NONE, offsetof(Entry, validate),
0, validateStrings, 0},
{TK_OPTION_STRING, "-validatecommand", "validateCommand","ValidateCommand",
- NULL, -1, Tk_Offset(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-values", "values", "Values",
- DEF_SPINBOX_VALUES, -1, Tk_Offset(Spinbox, valueStr),
+ DEF_SPINBOX_VALUES, TCL_INDEX_NONE, offsetof(Spinbox, valueStr),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-vcmd", NULL, NULL,
- NULL, 0, -1, 0, "-validatecommand", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-validatecommand", 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_ENTRY_WIDTH, -1, Tk_Offset(Entry, prefWidth), 0, 0, 0},
+ DEF_ENTRY_WIDTH, TCL_INDEX_NONE, offsetof(Entry, prefWidth), 0, 0, 0},
{TK_OPTION_BOOLEAN, "-wrap", "wrap", "Wrap",
- DEF_SPINBOX_WRAP, -1, Tk_Offset(Spinbox, wrap), 0, 0, 0},
+ DEF_SPINBOX_WRAP, TCL_INDEX_NONE, offsetof(Spinbox, wrap), 0, 0, 0},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_ENTRY_SCROLL_COMMAND, -1, Tk_Offset(Entry, scrollCmd),
+ DEF_ENTRY_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Entry, scrollCmd),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -438,7 +438,7 @@ static int EntryWidgetObjCmd(ClientData clientData,
Tcl_Obj *const objv[]);
static void EntryWorldChanged(ClientData instanceData);
static int GetEntryIndex(Tcl_Interp *interp, Entry *entryPtr,
- const char *string, int *indexPtr);
+ Tcl_Obj *indexObj, int *indexPtr);
static int InsertChars(Entry *entryPtr, int index, const char *string);
/*
@@ -484,15 +484,16 @@ static const Tk_ClassProcs entryClass = {
int
Tk_EntryObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Entry *entryPtr;
+ Entry *entryPtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
char *tmp;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -519,7 +520,7 @@ Tk_EntryObjCmd(
* initialized as memset covers the rest.
*/
- entryPtr = ckalloc(sizeof(Entry));
+ entryPtr = (Entry *)ckalloc(sizeof(Entry));
memset(entryPtr, 0, sizeof(Entry));
entryPtr->tkwin = tkwin;
@@ -530,7 +531,7 @@ Tk_EntryObjCmd(
EntryCmdDeletedProc);
entryPtr->optionTable = optionTable;
entryPtr->type = TK_ENTRY;
- tmp = ckalloc(1);
+ tmp = (char *)ckalloc(1);
tmp[0] = '\0';
entryPtr->string = tmp;
entryPtr->selectFirst = -1;
@@ -602,7 +603,7 @@ EntryWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
int cmdIndex, selIndex, result;
Tcl_Obj *objPtr;
@@ -632,7 +633,7 @@ EntryWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
+ if (GetEntryIndex(interp, entryPtr, objv[2],
&index) != TCL_OK) {
goto error;
}
@@ -640,10 +641,10 @@ EntryWidgetObjCmd(
index--;
}
Tk_CharBbox(entryPtr->textLayout, index, &x, &y, &width, &height);
- bbox[0] = Tcl_NewIntObj(x + entryPtr->layoutX);
- bbox[1] = Tcl_NewIntObj(y + entryPtr->layoutY);
- bbox[2] = Tcl_NewIntObj(width);
- bbox[3] = Tcl_NewIntObj(height);
+ bbox[0] = Tcl_NewWideIntObj(x + entryPtr->layoutX);
+ bbox[1] = Tcl_NewWideIntObj(y + entryPtr->layoutY);
+ bbox[2] = Tcl_NewWideIntObj(width);
+ bbox[3] = Tcl_NewWideIntObj(height);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, bbox));
break;
}
@@ -684,13 +685,13 @@ EntryWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "firstIndex ?lastIndex?");
goto error;
}
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
+ if (GetEntryIndex(interp, entryPtr, objv[2],
&first) != TCL_OK) {
goto error;
}
if (objc == 3) {
last = first + 1;
- } else if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[3]),
+ } else if (GetEntryIndex(interp, entryPtr, objv[3],
&last) != TCL_OK) {
goto error;
}
@@ -708,7 +709,7 @@ EntryWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, NULL);
goto error;
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->string, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->string, TCL_INDEX_NONE));
break;
case COMMAND_ICURSOR:
@@ -716,7 +717,7 @@ EntryWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "pos");
goto error;
}
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
+ if (GetEntryIndex(interp, entryPtr, objv[2],
&entryPtr->insertPos) != TCL_OK) {
goto error;
}
@@ -730,11 +731,11 @@ EntryWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "string");
goto error;
}
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
+ if (GetEntryIndex(interp, entryPtr, objv[2],
&index) != TCL_OK) {
goto error;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
break;
}
@@ -745,7 +746,7 @@ EntryWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "index text");
goto error;
}
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
+ if (GetEntryIndex(interp, entryPtr, objv[2],
&index) != TCL_OK) {
goto error;
}
@@ -825,7 +826,7 @@ EntryWidgetObjCmd(
goto error;
}
if (GetEntryIndex(interp, entryPtr,
- Tcl_GetString(objv[3]), &index) != TCL_OK) {
+ objv[3], &index) != TCL_OK) {
goto error;
}
if (entryPtr->selectFirst >= 0) {
@@ -865,7 +866,7 @@ EntryWidgetObjCmd(
goto error;
}
if (GetEntryIndex(interp, entryPtr,
- Tcl_GetString(objv[3]), &index) != TCL_OK) {
+ objv[3], &index) != TCL_OK) {
goto error;
}
entryPtr->selectAnchor = index;
@@ -885,11 +886,11 @@ EntryWidgetObjCmd(
Tcl_WrongNumArgs(interp, 3, objv, "start end");
goto error;
}
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[3]),
+ if (GetEntryIndex(interp, entryPtr, objv[3],
&index) != TCL_OK) {
goto error;
}
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[4]),
+ if (GetEntryIndex(interp, entryPtr, objv[4],
&index2) != TCL_OK) {
goto error;
}
@@ -916,7 +917,7 @@ EntryWidgetObjCmd(
goto error;
}
if (GetEntryIndex(interp, entryPtr,
- Tcl_GetString(objv[3]), &index) != TCL_OK) {
+ objv[3], &index) != TCL_OK) {
goto error;
}
EntrySelectTo(entryPtr, index);
@@ -956,7 +957,7 @@ EntryWidgetObjCmd(
Tcl_SetObjResult(interp, Tcl_NewListObj(2, span));
goto done;
} else if (objc == 3) {
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
+ if (GetEntryIndex(interp, entryPtr, objv[2],
&index) != TCL_OK) {
goto error;
}
@@ -1033,7 +1034,7 @@ static void
DestroyEntry(
void *memPtr) /* Info about entry widget. */
{
- Entry *entryPtr = memPtr;
+ Entry *entryPtr = (Entry *)memPtr;
/*
* Free up all the stuff that requires special handling, then let
@@ -1111,13 +1112,13 @@ ConfigureEntry(
Spinbox *sbPtr = (Spinbox *) entryPtr;
/* Only used when this widget is of type
* TK_SPINBOX */
- char *oldValues = NULL; /* lint initialization */
- char *oldFormat = NULL; /* lint initialization */
+ char *oldValues = NULL;
+ char *oldFormat = NULL;
int error;
- int oldExport = 0; /* lint initialization */
- int valuesChanged = 0; /* lint initialization */
- double oldFrom = 0.0; /* lint initialization */
- double oldTo = 0.0; /* lint initialization */
+ int oldExport = 0;
+ int valuesChanged = 0;
+ double oldFrom = 0.0;
+ double oldTo = 0.0;
int code;
/*
@@ -1236,7 +1237,7 @@ ConfigureEntry(
if (formatSpace < TCL_DOUBLE_SPACE) {
formatSpace = TCL_DOUBLE_SPACE;
}
- sbPtr->formatBuf = ckrealloc(sbPtr->formatBuf, formatSpace);
+ sbPtr->formatBuf = (char *)ckrealloc(sbPtr->formatBuf, formatSpace);
/*
* We perturb the value of oldFrom to allow us to go into the
@@ -1259,7 +1260,7 @@ ConfigureEntry(
Tcl_Obj *newObjPtr;
int nelems;
- newObjPtr = Tcl_NewStringObj(sbPtr->valueStr, -1);
+ newObjPtr = Tcl_NewStringObj(sbPtr->valueStr, TCL_INDEX_NONE);
if (Tcl_ListObjLength(interp, newObjPtr, &nelems)
!= TCL_OK) {
valuesChanged = -1;
@@ -1450,7 +1451,7 @@ EntryWorldChanged(
unsigned long mask;
Tk_3DBorder border;
XColor *colorPtr;
- Entry *entryPtr = instanceData;
+ Entry *entryPtr = (Entry *)instanceData;
entryPtr->avgWidth = Tk_TextWidth(entryPtr->tkfont, "0", 1);
if (entryPtr->avgWidth == 0) {
@@ -1541,17 +1542,15 @@ EntryWorldChanged(
*
* TkpDrawEntryBorderAndFocus --
*
- * This function redraws the border of an entry widget. It overrides the
- * generic border drawing code if the entry widget parameters are such
- * that the native widget drawing is a good fit. This version just
- * returns 0, so platforms that don't do special native drawing don't
- * have to implement it.
+ * Stub function for Tk on platforms other than Aqua
+ * (Windows and X11), which do not draw native entry borders.
+ * See macosx/tkMacOSXEntry.c for function definition in Tk Aqua.
*
* Results:
- * 1 if it has drawn the border, 0 if not.
+ * Returns 0.
*
* Side effects:
- * May draw the entry border into pixmap.
+ * None.
*
*--------------------------------------------------------------
*/
@@ -1562,6 +1561,10 @@ TkpDrawEntryBorderAndFocus(
Drawable pixmap,
int isSpinbox)
{
+ (void)entryPtr;
+ (void)pixmap;
+ (void)isSpinbox;
+
return 0;
}
@@ -1570,17 +1573,15 @@ TkpDrawEntryBorderAndFocus(
*
* TkpDrawSpinboxButtons --
*
- * This function redraws the buttons of an spinbox widget. It overrides
- * the generic button drawing code if the spinbox widget parameters are
- * such that the native widget drawing is a good fit. This version just
- * returns 0, so platforms that don't do special native drawing don't
- * have to implement it.
+ * Stub function for Tk on platforms other than Aqua
+ * (Windows and X11), which do not draw native spinbox buttons.
+ * See macosx/tkMacOSXEntry.c for function definition in Tk Aqua.
*
* Results:
- * 1 if it has drawn the border, 0 if not.
+ * Returns 0.
*
* Side effects:
- * May draw the entry border into pixmap.
+ * None.
*
*--------------------------------------------------------------
*/
@@ -1590,6 +1591,9 @@ TkpDrawSpinboxButtons(
Spinbox *sbPtr,
Pixmap pixmap)
{
+ (void)sbPtr;
+ (void)pixmap;
+
return 0;
}
#endif /* Not MAC_OSX_TK */
@@ -1614,7 +1618,7 @@ static void
DisplayEntry(
ClientData clientData) /* Information about window. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
Tk_Window tkwin = entryPtr->tkwin;
int baseY, selStartX, selEndX, cursorX;
int showSelection, xBound;
@@ -1975,7 +1979,7 @@ EntryComputeGeometry(
size = TkUniCharToUtf(ch, buf);
entryPtr->numDisplayBytes = entryPtr->numChars * size;
- p = ckalloc(entryPtr->numDisplayBytes + 1);
+ p = (char *)ckalloc(entryPtr->numDisplayBytes + 1);
entryPtr->displayString = p;
for (i = entryPtr->numChars; --i >= 0; ) {
@@ -2144,7 +2148,7 @@ InsertChars(
}
newByteCount = entryPtr->numBytes + byteCount + 1;
- newStr = ckalloc(newByteCount);
+ newStr = (char *)ckalloc(newByteCount);
memcpy(newStr, string, byteIndex);
strcpy(newStr + byteIndex, value);
strcpy(newStr + byteIndex + byteCount, string + byteIndex);
@@ -2170,7 +2174,7 @@ InsertChars(
*/
oldChars = entryPtr->numChars;
- entryPtr->numChars = Tcl_NumUtfChars(newStr, -1);
+ entryPtr->numChars = Tcl_NumUtfChars(newStr, TCL_INDEX_NONE);
charsAdded = entryPtr->numChars - oldChars;
entryPtr->numBytes += byteCount;
@@ -2245,11 +2249,11 @@ DeleteChars(
byteCount = Tcl_UtfAtIndex(string + byteIndex, count) - (string+byteIndex);
newByteCount = entryPtr->numBytes + 1 - byteCount;
- newStr = ckalloc(newByteCount);
+ newStr = (char *)ckalloc(newByteCount);
memcpy(newStr, string, (size_t) byteIndex);
strcpy(newStr + byteIndex, string + byteIndex + byteCount);
- toDelete = ckalloc(byteCount + 1);
+ toDelete = (char *)ckalloc(byteCount + 1);
memcpy(toDelete, string + byteIndex, (size_t) byteCount);
toDelete[byteCount] = '\0';
@@ -2435,7 +2439,7 @@ EntrySetValue(
* during validation
*/
- char *tmp = ckalloc(valueLen + 1);
+ char *tmp = (char *)ckalloc(valueLen + 1);
strcpy(tmp, value);
value = tmp;
@@ -2464,7 +2468,7 @@ EntrySetValue(
if (malloced) {
entryPtr->string = value;
} else {
- char *tmp = ckalloc(valueLen + 1);
+ char *tmp = (char *)ckalloc(valueLen + 1);
strcpy(tmp, value);
entryPtr->string = tmp;
@@ -2524,10 +2528,10 @@ EntryEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
if ((entryPtr->type == TK_SPINBOX) && (eventPtr->type == MotionNotify)) {
- Spinbox *sbPtr = clientData;
+ Spinbox *sbPtr = (Spinbox *)clientData;
int elem;
elem = GetSpinboxElement(sbPtr, eventPtr->xmotion.x,
@@ -2605,7 +2609,7 @@ static void
EntryCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
/*
* This function could be invoked either because the window was destroyed
@@ -2644,12 +2648,23 @@ GetEntryIndex(
Tcl_Interp *interp, /* For error messages. */
Entry *entryPtr, /* Entry for which the index is being
* specified. */
- const char *string, /* Specifies character in entryPtr. */
+ Tcl_Obj *indexObj, /* Specifies character in entryPtr. */
int *indexPtr) /* Where to store converted character index */
{
- size_t length;
+ TkSizeT length, idx;
+ const char *string;
+
+ if (TCL_OK == TkGetIntForIndex(indexObj, entryPtr->numChars - 1, 1, &idx)) {
+ if (idx == TCL_INDEX_NONE) {
+ idx = 0;
+ } else if (idx > (TkSizeT)entryPtr->numChars) {
+ idx = (TkSizeT)entryPtr->numChars;
+ }
+ *indexPtr = (int)idx;
+ return TCL_OK;
+ }
- length = strlen(string);
+ string = TkGetStringFromObj(indexObj, &length);
switch (string[0]) {
case 'a':
@@ -2658,12 +2673,6 @@ GetEntryIndex(
}
*indexPtr = entryPtr->selectAnchor;
break;
- case 'e':
- if (strncmp(string, "end", length) != 0) {
- goto badIndex;
- }
- *indexPtr = entryPtr->numChars;
- break;
case 'i':
if (strncmp(string, "insert", length) != 0) {
goto badIndex;
@@ -2724,24 +2733,15 @@ GetEntryIndex(
break;
}
default:
- if (Tcl_GetInt(NULL, string, indexPtr) != TCL_OK) {
- goto badIndex;
- }
- if (*indexPtr < 0){
- *indexPtr = 0;
- } else if (*indexPtr > entryPtr->numChars) {
- *indexPtr = entryPtr->numChars;
- }
+ badIndex:
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad %s index \"%s\"",
+ (entryPtr->type == TK_ENTRY) ? "entry" : "spinbox", string));
+ Tcl_SetErrorCode(interp, "TK",
+ (entryPtr->type == TK_ENTRY) ? "ENTRY" : "SPINBOX",
+ "BAD_INDEX", NULL);
+ return TCL_ERROR;
}
return TCL_OK;
-
- badIndex:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad %s index \"%s\"",
- (entryPtr->type == TK_ENTRY) ? "entry" : "spinbox", string));
- Tcl_SetErrorCode(interp, "TK",
- (entryPtr->type == TK_ENTRY) ? "ENTRY" : "SPINBOX",
- "BAD_INDEX", NULL);
- return TCL_ERROR;
}
/*
@@ -2894,7 +2894,7 @@ EntryFetchSelection(
int maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NUL character. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
int byteCount;
const char *string;
const char *selStart, *selEnd;
@@ -2941,7 +2941,7 @@ static void
EntryLostSelection(
ClientData clientData) /* Information about entry widget. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
entryPtr->flags &= ~GOT_SELECTION;
@@ -3089,12 +3089,12 @@ EntryUpdateScrollbar(
Tcl_PrintDouble(NULL, first, firstStr);
Tcl_PrintDouble(NULL, last, lastStr);
Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, entryPtr->scrollCmd, -1);
- Tcl_DStringAppend(&buf, " ", -1);
- Tcl_DStringAppend(&buf, firstStr, -1);
- Tcl_DStringAppend(&buf, " ", -1);
- Tcl_DStringAppend(&buf, lastStr, -1);
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
+ Tcl_DStringAppend(&buf, entryPtr->scrollCmd, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, firstStr, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, lastStr, TCL_INDEX_NONE);
+ code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, 0);
Tcl_DStringFree(&buf);
if (code != TCL_OK) {
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
@@ -3128,7 +3128,7 @@ static void
EntryBlinkProc(
ClientData clientData) /* Pointer to record describing entry. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
if ((entryPtr->state == STATE_DISABLED) ||
(entryPtr->state == STATE_READONLY) ||
@@ -3214,17 +3214,18 @@ EntryFocusProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
EntryTextVarProc(
ClientData clientData, /* Information about button. */
Tcl_Interp *interp, /* Interpreter containing variable. */
- const char *name1, /* Name of variable. */
- const char *name2, /* Second part of variable name. */
+ const char *name1, /* Not used. */
+ const char *name2, /* Not used. */
int flags) /* Information about what happened. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
const char *value;
+ (void)name1;
+ (void)name2;
if (entryPtr->flags & ENTRY_DELETED) {
/*
@@ -3234,32 +3235,39 @@ EntryTextVarProc(
}
/*
- * See ticket [5d991b82].
- */
-
- if (entryPtr->textVarName == NULL) {
- if (!(flags & TCL_INTERP_DESTROYED)) {
- Tcl_UntraceVar2(interp, name1, name2,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- EntryTextVarProc, clientData);
- }
- return NULL;
- }
-
- /*
* If the variable is unset, then immediately recreate it unless the whole
* interpreter is going away.
*/
if (flags & TCL_TRACE_UNSETS) {
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
+ if (!Tcl_InterpDeleted(interp) && entryPtr->textVarName) {
+ ClientData probe = NULL;
+
+ do {
+ probe = Tcl_VarTraceInfo(interp,
+ entryPtr->textVarName,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ EntryTextVarProc, probe);
+ if (probe == (ClientData)entryPtr) {
+ break;
+ }
+ } while (probe);
+ if (probe) {
+ /*
+ * We were able to fetch the unset trace for our
+ * textVarName, which means it is not unset and not
+ * the cause of this unset trace. Instead some outdated
+ * former variable must be, and we should ignore it.
+ */
+ return NULL;
+ }
Tcl_SetVar2(interp, entryPtr->textVarName, NULL,
entryPtr->string, TCL_GLOBAL_ONLY);
Tcl_TraceVar2(interp, entryPtr->textVarName, NULL,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
EntryTextVarProc, clientData);
entryPtr->flags |= ENTRY_VAR_TRACED;
- }
+ }
return NULL;
}
@@ -3299,14 +3307,14 @@ EntryTextVarProc(
static int
EntryValidate(
- register Entry *entryPtr, /* Entry that needs validation. */
- register char *cmd) /* Validation command (NULL-terminated
+ Entry *entryPtr, /* Entry that needs validation. */
+ char *cmd) /* Validation command (NULL-terminated
* string). */
{
- register Tcl_Interp *interp = entryPtr->interp;
- int code, bool;
+ Tcl_Interp *interp = entryPtr->interp;
+ int code, isOK;
- code = Tcl_EvalEx(interp, cmd, -1, TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
+ code = Tcl_EvalEx(interp, cmd, TCL_INDEX_NONE, TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
/*
* We accept TCL_OK and TCL_RETURN as valid return codes from the command
@@ -3326,7 +3334,7 @@ EntryValidate(
*/
if (Tcl_GetBooleanFromObj(interp, Tcl_GetObjResult(interp),
- &bool) != TCL_OK) {
+ &isOK) != TCL_OK) {
Tcl_AddErrorInfo(interp,
"\n (invalid boolean result from validation command)");
Tcl_BackgroundException(interp, TCL_ERROR);
@@ -3335,7 +3343,7 @@ EntryValidate(
}
Tcl_ResetResult(interp);
- return (bool ? TCL_OK : TCL_BREAK);
+ return (isOK ? TCL_OK : TCL_BREAK);
}
/*
@@ -3359,7 +3367,7 @@ EntryValidate(
static int
EntryValidateChange(
- register Entry *entryPtr, /* Entry that needs validation. */
+ Entry *entryPtr, /* Entry that needs validation. */
const char *change, /* Characters to be added/deleted
* (NUL-terminated string). */
const char *newValue, /* Potential new value of entry string */
@@ -3498,8 +3506,8 @@ EntryValidateChange(
static void
ExpandPercents(
- register Entry *entryPtr, /* Entry that needs validation. */
- register const char *before,
+ Entry *entryPtr, /* Entry that needs validation. */
+ const char *before,
/* Command containing percent expressions to
* be replaced. */
const char *change, /* Characters to added/deleted (NUL-terminated
@@ -3513,7 +3521,7 @@ ExpandPercents(
int spaceNeeded, cvtFlags; /* Used to substitute string as proper Tcl
* list element. */
int number, length;
- register const char *string;
+ const char *string;
int ch;
char numStorage[2*TCL_INTEGER_SPACE];
@@ -3663,16 +3671,17 @@ ExpandPercents(
int
Tk_SpinboxObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Entry *entryPtr;
- register Spinbox *sbPtr;
+ Entry *entryPtr;
+ Spinbox *sbPtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
char *tmp;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -3699,7 +3708,7 @@ Tk_SpinboxObjCmd(
* initialized as memset covers the rest.
*/
- sbPtr = ckalloc(sizeof(Spinbox));
+ sbPtr = (Spinbox *)ckalloc(sizeof(Spinbox));
entryPtr = (Entry *) sbPtr;
memset(sbPtr, 0, sizeof(Spinbox));
@@ -3711,7 +3720,7 @@ Tk_SpinboxObjCmd(
EntryCmdDeletedProc);
entryPtr->optionTable = optionTable;
entryPtr->type = TK_SPINBOX;
- tmp = ckalloc(1);
+ tmp = (char *)ckalloc(1);
tmp[0] = '\0';
entryPtr->string = tmp;
entryPtr->selectFirst = -1;
@@ -3738,7 +3747,7 @@ Tk_SpinboxObjCmd(
sbPtr->fromValue = 0.0;
sbPtr->toValue = 100.0;
sbPtr->increment = 1.0;
- sbPtr->formatBuf = ckalloc(TCL_DOUBLE_SPACE);
+ sbPtr->formatBuf = (char *)ckalloc(TCL_DOUBLE_SPACE);
sbPtr->bdRelief = TK_RELIEF_FLAT;
sbPtr->buRelief = TK_RELIEF_FLAT;
@@ -3801,8 +3810,8 @@ SpinboxWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Entry *entryPtr = clientData;
- Spinbox *sbPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
+ Spinbox *sbPtr = (Spinbox *)clientData;
int cmdIndex, selIndex, result;
Tcl_Obj *objPtr;
@@ -3832,7 +3841,7 @@ SpinboxWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
+ if (GetEntryIndex(interp, entryPtr, objv[2],
&index) != TCL_OK) {
goto error;
}
@@ -3840,10 +3849,10 @@ SpinboxWidgetObjCmd(
index--;
}
Tk_CharBbox(entryPtr->textLayout, index, &x, &y, &width, &height);
- bbox[0] = Tcl_NewIntObj(x + entryPtr->layoutX);
- bbox[1] = Tcl_NewIntObj(y + entryPtr->layoutY);
- bbox[2] = Tcl_NewIntObj(width);
- bbox[3] = Tcl_NewIntObj(height);
+ bbox[0] = Tcl_NewWideIntObj(x + entryPtr->layoutX);
+ bbox[1] = Tcl_NewWideIntObj(y + entryPtr->layoutY);
+ bbox[2] = Tcl_NewWideIntObj(width);
+ bbox[3] = Tcl_NewWideIntObj(height);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, bbox));
break;
}
@@ -3883,14 +3892,14 @@ SpinboxWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "firstIndex ?lastIndex?");
goto error;
}
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
+ if (GetEntryIndex(interp, entryPtr, objv[2],
&first) != TCL_OK) {
goto error;
}
if (objc == 3) {
last = first + 1;
} else {
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[3]),
+ if (GetEntryIndex(interp, entryPtr, objv[3],
&last) != TCL_OK) {
goto error;
}
@@ -3917,7 +3926,7 @@ SpinboxWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "pos");
goto error;
}
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
+ if (GetEntryIndex(interp, entryPtr, objv[2],
&entryPtr->insertPos) != TCL_OK) {
goto error;
}
@@ -3950,11 +3959,11 @@ SpinboxWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "string");
goto error;
}
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
+ if (GetEntryIndex(interp, entryPtr, objv[2],
&index) != TCL_OK) {
goto error;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
break;
}
@@ -3965,7 +3974,7 @@ SpinboxWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "index text");
goto error;
}
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
+ if (GetEntryIndex(interp, entryPtr, objv[2],
&index) != TCL_OK) {
goto error;
}
@@ -4062,7 +4071,7 @@ SpinboxWidgetObjCmd(
goto error;
}
if (GetEntryIndex(interp, entryPtr,
- Tcl_GetString(objv[3]), &index) != TCL_OK) {
+ objv[3], &index) != TCL_OK) {
goto error;
}
if (entryPtr->selectFirst >= 0) {
@@ -4102,7 +4111,7 @@ SpinboxWidgetObjCmd(
goto error;
}
if (GetEntryIndex(interp, entryPtr,
- Tcl_GetString(objv[3]), &index) != TCL_OK) {
+ objv[3], &index) != TCL_OK) {
goto error;
}
entryPtr->selectAnchor = index;
@@ -4123,11 +4132,11 @@ SpinboxWidgetObjCmd(
goto error;
}
if (GetEntryIndex(interp, entryPtr,
- Tcl_GetString(objv[3]), &index) != TCL_OK) {
+ objv[3], &index) != TCL_OK) {
goto error;
}
if (GetEntryIndex(interp, entryPtr,
- Tcl_GetString(objv[4]),& index2) != TCL_OK) {
+ objv[4],& index2) != TCL_OK) {
goto error;
}
if (index >= index2) {
@@ -4153,7 +4162,7 @@ SpinboxWidgetObjCmd(
goto error;
}
if (GetEntryIndex(interp, entryPtr,
- Tcl_GetString(objv[3]), &index) != TCL_OK) {
+ objv[3], &index) != TCL_OK) {
goto error;
}
EntrySelectTo(entryPtr, index);
@@ -4233,7 +4242,7 @@ SpinboxWidgetObjCmd(
Tcl_SetObjResult(interp, Tcl_NewListObj(2, span));
goto done;
} else if (objc == 3) {
- if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]),
+ if (GetEntryIndex(interp, entryPtr, objv[2],
&index) != TCL_OK) {
goto error;
}
@@ -4348,8 +4357,8 @@ GetSpinboxElement(
static int
SpinboxInvoke(
- register Tcl_Interp *interp,/* Current interpreter. */
- register Spinbox *sbPtr, /* Spinbox to invoke. */
+ Tcl_Interp *interp,/* Current interpreter. */
+ Spinbox *sbPtr, /* Spinbox to invoke. */
int element) /* Element to invoke, either the "up" or
* "down" button. */
{
@@ -4385,7 +4394,7 @@ SpinboxInvoke(
*/
int i, listc;
- size_t elemLen, length = entryPtr->numChars;
+ TkSizeT elemLen, length = entryPtr->numChars;
const char *bytes;
Tcl_Obj **listv;
diff --git a/generic/tkError.c b/generic/tkError.c
index 5aa6d88..938afc3 100644
--- a/generic/tkError.c
+++ b/generic/tkError.c
@@ -107,7 +107,7 @@ Tk_CreateErrorHandler(
* Create the handler record.
*/
- errorPtr = ckalloc(sizeof(TkErrorHandler));
+ errorPtr = (TkErrorHandler *)ckalloc(sizeof(TkErrorHandler));
errorPtr->dispPtr = dispPtr;
errorPtr->firstRequest = NextRequest(display);
errorPtr->lastRequest = (unsigned) -1;
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
index 891f667..bd312ad 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -15,6 +15,14 @@
#include "tkInt.h"
+#ifdef _WIN32
+#include "tkWinInt.h"
+#elif defined(MAC_OSX_TK)
+#include "tkMacOSXInt.h"
+#else
+#include "tkUnixInt.h"
+#endif
+
/*
* There's a potential problem if a handler is deleted while it's current
* (i.e. its function is executing), since Tk_HandleEvent will need to read
@@ -73,7 +81,7 @@ typedef struct TkWindowEvent {
* Array of event masks corresponding to each X event:
*/
-static const unsigned long realEventMasks[MappingNotify+1] = {
+static const unsigned long eventMasks[TK_LASTEVENT] = {
0,
0,
KeyPressMask, /* KeyPress */
@@ -111,10 +119,7 @@ static const unsigned long realEventMasks[MappingNotify+1] = {
0, /* SelectionNotify */
ColormapChangeMask, /* ColormapNotify */
0, /* ClientMessage */
- 0 /* Mapping Notify */
-};
-
-static const unsigned long virtualEventMasks[TK_LASTEVENT-VirtualEvent] = {
+ 0, /* Mapping Notify */
VirtualEventMask, /* VirtualEvents */
ActivateMask, /* ActivateNotify */
ActivateMask, /* DeactivateNotify */
@@ -139,7 +144,7 @@ typedef struct ExitHandler {
* storage for the current thread.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
int handlersActive; /* The following variable has a non-zero value
* when a handler is active. */
InProgress *pendingPtr; /* Topmost search in progress, or NULL if
@@ -193,7 +198,6 @@ TCL_DECLARE_MUTEX(exitMutex)
static void CleanUpTkEvent(XEvent *eventPtr);
static void DelayedMotionProc(ClientData clientData);
-static int GetButtonMask(unsigned int Button);
static unsigned long GetEventMaskFromXEvent(XEvent *eventPtr);
static TkWindow * GetTkWindowFromXEvent(XEvent *eventPtr);
static void InvokeClientMessageHandlers(ThreadSpecificData *tsdPtr,
@@ -208,11 +212,8 @@ static Window ParentXId(Display *display, Window w);
static int RefreshKeyboardMappingIfNeeded(XEvent *eventPtr);
static int TkXErrorHandler(ClientData clientData,
XErrorEvent *errEventPtr);
-static void UpdateButtonEventState(XEvent *eventPtr);
static int WindowEventProc(Tcl_Event *evPtr, int flags);
-#ifdef TK_USE_INPUT_METHODS
static void CreateXIC(TkWindow *winPtr);
-#endif /* TK_USE_INPUT_METHODS */
/*
*----------------------------------------------------------------------
@@ -320,7 +321,6 @@ InvokeMouseHandlers(
*----------------------------------------------------------------------
*/
-#ifdef TK_USE_INPUT_METHODS
static void
CreateXIC(
TkWindow *winPtr)
@@ -367,7 +367,6 @@ CreateXIC(
XSelectInput(winPtr->display, winPtr->window, winPtr->atts.event_mask);
}
}
-#endif
/*
*----------------------------------------------------------------------
@@ -454,18 +453,8 @@ GetEventMaskFromXEvent(
{
unsigned long mask;
- /*
- * Get the event mask from the correct table. Note that there are two
- * tables here because that means we no longer need this code to rely on
- * the exact value of VirtualEvent, which has caused us problems in the
- * past when X11 changed the value of LASTEvent. [Bug ???]
- */
-
- if (eventPtr->xany.type <= MappingNotify) {
- mask = realEventMasks[eventPtr->xany.type];
- } else if (eventPtr->xany.type >= VirtualEvent
- && eventPtr->xany.type<TK_LASTEVENT) {
- mask = virtualEventMasks[eventPtr->xany.type - VirtualEvent];
+ if (eventPtr->xany.type <TK_LASTEVENT) {
+ mask = eventMasks[eventPtr->xany.type];
} else {
mask = 0;
}
@@ -524,7 +513,7 @@ RefreshKeyboardMappingIfNeeded(
/*
*----------------------------------------------------------------------
*
- * GetButtonMask --
+ * TkGetButtonMask --
*
* Return the proper Button${n}Mask for the button.
*
@@ -537,88 +526,16 @@ RefreshKeyboardMappingIfNeeded(
*----------------------------------------------------------------------
*/
-static int
-GetButtonMask(
- unsigned int button)
-{
- switch (button) {
- case 1:
- return Button1Mask;
- case 2:
- return Button2Mask;
- case 3:
- return Button3Mask;
- case 4:
- return Button4Mask;
- case 5:
- return Button5Mask;
- }
- return 0;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * UpdateButtonEventState --
- *
- * Update the button event state in our TkDisplay using the XEvent
- * passed. We also may modify the the XEvent passed to fit some aspects
- * of our TkDisplay.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The TkDisplay's private button state may be modified. The eventPtr's
- * state may be updated to reflect masks stored in our TkDisplay that the
- * event doesn't contain. The eventPtr may also be modified to not
- * contain a button state for the window in which it was not pressed in.
- *
- *----------------------------------------------------------------------
- */
+static const unsigned long buttonMasks[] = {
+ 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask,
+ Button6Mask, Button7Mask, Button8Mask, Button9Mask
+};
-static void
-UpdateButtonEventState(
- XEvent *eventPtr)
+unsigned long
+TkGetButtonMask(
+ unsigned int button)
{
- TkDisplay *dispPtr;
- int allButtonsMask = Button1Mask | Button2Mask | Button3Mask
- | Button4Mask | Button5Mask;
-
- switch (eventPtr->type) {
- case ButtonPress:
- dispPtr = TkGetDisplay(eventPtr->xbutton.display);
- dispPtr->mouseButtonWindow = eventPtr->xbutton.window;
- eventPtr->xbutton.state |= dispPtr->mouseButtonState;
-
- dispPtr->mouseButtonState |= GetButtonMask(eventPtr->xbutton.button);
- break;
-
- case ButtonRelease:
- dispPtr = TkGetDisplay(eventPtr->xbutton.display);
- dispPtr->mouseButtonWindow = None;
- dispPtr->mouseButtonState &= ~GetButtonMask(eventPtr->xbutton.button);
- eventPtr->xbutton.state |= dispPtr->mouseButtonState;
- break;
-
- case MotionNotify:
- dispPtr = TkGetDisplay(eventPtr->xmotion.display);
- if (dispPtr->mouseButtonState & allButtonsMask) {
- if (eventPtr->xbutton.window != dispPtr->mouseButtonWindow) {
- /*
- * This motion event should not be interpreted as a button
- * press + motion event since this is not the same window the
- * button was pressed down in.
- */
-
- dispPtr->mouseButtonState &= ~allButtonsMask;
- dispPtr->mouseButtonWindow = None;
- } else {
- eventPtr->xmotion.state |= dispPtr->mouseButtonState;
- }
- }
- break;
- }
+ return (button > Button9) ? 0 : buttonMasks[button];
}
/*
@@ -773,8 +690,8 @@ Tk_CreateEventHandler(
Tk_EventProc *proc, /* Function to call for each selected event */
ClientData clientData) /* Arbitrary data to pass to proc. */
{
- register TkEventHandler *handlerPtr;
- register TkWindow *winPtr = (TkWindow *) token;
+ TkEventHandler *handlerPtr;
+ TkWindow *winPtr = (TkWindow *) token;
/*
* Skim through the list of existing handlers to (a) compute the overall
@@ -789,7 +706,7 @@ Tk_CreateEventHandler(
* No event handlers defined at all, so must create.
*/
- handlerPtr = ckalloc(sizeof(TkEventHandler));
+ handlerPtr = (TkEventHandler *)ckalloc(sizeof(TkEventHandler));
winPtr->handlerList = handlerPtr;
} else {
int found = 0;
@@ -820,7 +737,7 @@ Tk_CreateEventHandler(
* No event handler matched, so create a new one.
*/
- handlerPtr->nextPtr = ckalloc(sizeof(TkEventHandler));
+ handlerPtr->nextPtr = (TkEventHandler *)ckalloc(sizeof(TkEventHandler));
handlerPtr = handlerPtr->nextPtr;
}
@@ -863,11 +780,11 @@ Tk_DeleteEventHandler(
Tk_EventProc *proc,
ClientData clientData)
{
- register TkEventHandler *handlerPtr;
- register InProgress *ipPtr;
+ TkEventHandler *handlerPtr;
+ InProgress *ipPtr;
TkEventHandler *prevPtr;
- register TkWindow *winPtr = (TkWindow *) token;
- ThreadSpecificData *tsdPtr =
+ TkWindow *winPtr = (TkWindow *) token;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -939,10 +856,10 @@ Tk_CreateGenericHandler(
ClientData clientData) /* One-word value to pass to proc. */
{
GenericHandler *handlerPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- handlerPtr = ckalloc(sizeof(GenericHandler));
+ handlerPtr = (GenericHandler *)ckalloc(sizeof(GenericHandler));
handlerPtr->proc = proc;
handlerPtr->clientData = clientData;
@@ -980,7 +897,7 @@ Tk_DeleteGenericHandler(
ClientData clientData)
{
GenericHandler * handler;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (handler=tsdPtr->genericList ; handler ; handler=handler->nextPtr) {
@@ -1013,7 +930,7 @@ Tk_CreateClientMessageHandler(
Tk_ClientMessageProc *proc) /* Function to call on event. */
{
GenericHandler *handlerPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -1021,7 +938,7 @@ Tk_CreateClientMessageHandler(
* with an extra clientData field we'll never use.
*/
- handlerPtr = ckalloc(sizeof(GenericHandler));
+ handlerPtr = (GenericHandler *)ckalloc(sizeof(GenericHandler));
handlerPtr->proc = (Tk_GenericProc *) proc;
handlerPtr->clientData = NULL; /* never used */
@@ -1059,7 +976,7 @@ Tk_DeleteClientMessageHandler(
Tk_ClientMessageProc *proc)
{
GenericHandler * handler;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (handler=tsdPtr->cmList ; handler!=NULL ; handler=handler->nextPtr) {
@@ -1090,7 +1007,7 @@ Tk_DeleteClientMessageHandler(
void
TkEventInit(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
tsdPtr->handlersActive = 0;
@@ -1125,7 +1042,8 @@ TkXErrorHandler(
ClientData clientData, /* Pointer to flag we set. */
XErrorEvent *errEventPtr) /* X error info. */
{
- int *error = clientData;
+ int *error = (int *)clientData;
+ (void)errEventPtr;
*error = 1;
return 0;
@@ -1212,16 +1130,14 @@ void
Tk_HandleEvent(
XEvent *eventPtr) /* Event to dispatch. */
{
- register TkEventHandler *handlerPtr;
+ TkEventHandler *handlerPtr;
TkWindow *winPtr;
unsigned long mask;
InProgress ip;
Tcl_Interp *interp = NULL;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- UpdateButtonEventState(eventPtr);
-
/*
* If the generic handler processed this event we are done and can return.
*/
@@ -1288,7 +1204,6 @@ Tk_HandleEvent(
* ever active for X11.
*/
-#ifdef TK_USE_INPUT_METHODS
/*
* If the XIC has been invalidated, it must be recreated.
*/
@@ -1310,7 +1225,6 @@ Tk_HandleEvent(
XSetICFocus(winPtr->inputContext);
}
}
-#endif /*TK_USE_INPUT_METHODS*/
/*
* For events where it hasn't already been done, update the current time
@@ -1419,9 +1333,9 @@ TkEventDeadWindow(
TkWindow *winPtr) /* Information about the window that is being
* deleted. */
{
- register TkEventHandler *handlerPtr;
- register InProgress *ipPtr;
- ThreadSpecificData *tsdPtr =
+ TkEventHandler *handlerPtr;
+ InProgress *ipPtr;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -1469,8 +1383,8 @@ Time
TkCurrentTime(
TkDisplay *dispPtr) /* Display for which the time is desired. */
{
- register XEvent *eventPtr;
- ThreadSpecificData *tsdPtr =
+ XEvent *eventPtr;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->pendingPtr == NULL) {
@@ -1524,7 +1438,7 @@ Tk_RestrictEvents(
* argument. */
{
Tk_RestrictProc *prev;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
prev = tsdPtr->restrictProc;
@@ -1617,7 +1531,7 @@ Tk_QueueWindowEvent(
*/
if (!(dispPtr->flags & TK_DISPLAY_COLLAPSE_MOTION_EVENTS)) {
- wevPtr = ckalloc(sizeof(TkWindowEvent));
+ wevPtr = (TkWindowEvent *)ckalloc(sizeof(TkWindowEvent));
wevPtr->header.proc = WindowEventProc;
wevPtr->event = *eventPtr;
Tcl_QueueEvent(&wevPtr->header, position);
@@ -1649,7 +1563,7 @@ Tk_QueueWindowEvent(
}
}
- wevPtr = ckalloc(sizeof(TkWindowEvent));
+ wevPtr = (TkWindowEvent *)ckalloc(sizeof(TkWindowEvent));
wevPtr->header.proc = WindowEventProc;
wevPtr->event = *eventPtr;
if ((eventPtr->type == MotionNotify) && (position == TCL_QUEUE_TAIL)) {
@@ -1712,6 +1626,47 @@ TkQueueEventForAllChildren(
/*
*----------------------------------------------------------------------
*
+ * TkGenerateActivateEvents --
+ *
+ * This function is called by the Mac and Windows window manager routines
+ * when a toplevel window is activated or deactivated.
+ * Activate/Deactivate events will be sent to every subwindow of the
+ * toplevel followed by a FocusIn/FocusOut message.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Generates X events.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkGenerateActivateEvents(
+ TkWindow *winPtr, /* Toplevel to activate. */
+ int active) /* Non-zero if the window is being activated,
+ * else 0.*/
+{
+ XEvent event;
+
+ /*
+ * Generate Activate and Deactivate events. This event is sent to every
+ * subwindow in a toplevel window.
+ */
+
+ event.xany.serial = NextRequest(winPtr->display);
+ event.xany.send_event = False;
+ event.xany.display = winPtr->display;
+ event.xany.window = winPtr->window;
+
+ event.xany.type = active ? ActivateNotify : DeactivateNotify;
+ TkQueueEventForAllChildren(winPtr, &event);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* WindowEventProc --
*
* This function is called by Tcl_DoOneEvent when a window event reaches
@@ -1739,7 +1694,7 @@ WindowEventProc(
{
TkWindowEvent *wevPtr = (TkWindowEvent *) evPtr;
Tk_RestrictAction result;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!(flags & TCL_WINDOW_EVENTS)) {
@@ -1792,13 +1747,15 @@ CleanUpTkEvent(
switch (eventPtr->type) {
case KeyPress:
case KeyRelease: {
- TkKeyEvent *kePtr = (TkKeyEvent *) eventPtr;
+#if !defined(_WIN32) && !defined(MAC_OSX_TK)
+ TkKeyEvent *kePtr = (TkKeyEvent *) eventPtr;
if (kePtr->charValuePtr != NULL) {
ckfree(kePtr->charValuePtr);
kePtr->charValuePtr = NULL;
kePtr->charValueLen = 0;
}
+#endif
break;
}
@@ -1838,7 +1795,7 @@ DelayedMotionProc(
ClientData clientData) /* Pointer to display containing a delayed
* motion event to be serviced. */
{
- TkDisplay *dispPtr = clientData;
+ TkDisplay *dispPtr = (TkDisplay *)clientData;
if (dispPtr->delayedMotionPtr == NULL) {
Tcl_Panic("DelayedMotionProc found no delayed mouse motion event");
@@ -1870,7 +1827,7 @@ TkCreateExitHandler(
{
ExitHandler *exitPtr;
- exitPtr = ckalloc(sizeof(ExitHandler));
+ exitPtr = (ExitHandler *)ckalloc(sizeof(ExitHandler));
exitPtr->proc = proc;
exitPtr->clientData = clientData;
Tcl_MutexLock(&exitMutex);
@@ -1966,10 +1923,10 @@ TkCreateThreadExitHandler(
ClientData clientData) /* Arbitrary value to pass to proc. */
{
ExitHandler *exitPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- exitPtr = ckalloc(sizeof(ExitHandler));
+ exitPtr = (ExitHandler *)ckalloc(sizeof(ExitHandler));
exitPtr->proc = proc;
exitPtr->clientData = clientData;
@@ -2007,7 +1964,7 @@ TkDeleteThreadExitHandler(
ClientData clientData) /* Arbitrary value to pass to proc. */
{
ExitHandler *exitPtr, *prevPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (prevPtr = NULL, exitPtr = tsdPtr->firstExitPtr; exitPtr != NULL;
@@ -2046,9 +2003,10 @@ TkDeleteThreadExitHandler(
void
TkFinalize(
- ClientData clientData) /* Arbitrary value to pass to proc. */
+ ClientData dummy) /* Arbitrary value to pass to proc. */
{
ExitHandler *exitPtr;
+ (void)dummy;
#if defined(_WIN32) && !defined(STATIC_BUILD)
if (!tclStubsPtr) {
@@ -2098,11 +2056,12 @@ TkFinalize(
void
TkFinalizeThread(
- ClientData clientData) /* Arbitrary value to pass to proc. */
+ ClientData dummy) /* Arbitrary value to pass to proc. */
{
ExitHandler *exitPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
Tcl_DeleteThreadExitHandler(TkFinalizeThread, NULL);
diff --git a/generic/tkFileFilter.c b/generic/tkFileFilter.c
index 8588d70..038129f 100644
--- a/generic/tkFileFilter.c
+++ b/generic/tkFileFilter.c
@@ -164,7 +164,7 @@ TkFreeFileFilters(
FileFilterClause *clausePtr;
GlobPattern *globPtr;
MacFileType *mfPtr;
- register void *toFree; /* A pointer that we are about to free. */
+ void *toFree; /* A pointer that we are about to free. */
for (filterPtr = flistPtr->filters; filterPtr != NULL; ) {
for (clausePtr = filterPtr->clauses; clausePtr != NULL; ) {
@@ -262,8 +262,8 @@ AddClause(
*/
for (i=0; i<ostypeCount; i++) {
- int len;
- const char *strType = Tcl_GetStringFromObj(ostypeList[i], &len);
+ TkSizeT len;
+ const char *strType = TkGetStringFromObj(ostypeList[i], &len);
/*
* If len is < 4, it is definitely an error. If equal or longer,
@@ -305,7 +305,7 @@ AddClause(
* Add the clause into the list of clauses
*/
- clausePtr = ckalloc(sizeof(FileFilterClause));
+ clausePtr = (FileFilterClause *)ckalloc(sizeof(FileFilterClause));
clausePtr->patterns = NULL;
clausePtr->patternsTail = NULL;
clausePtr->macTypes = NULL;
@@ -321,9 +321,9 @@ AddClause(
if (globCount > 0 && globList != NULL) {
for (i=0; i<globCount; i++) {
- GlobPattern *globPtr = ckalloc(sizeof(GlobPattern));
- int len;
- const char *str = Tcl_GetStringFromObj(globList[i], &len);
+ GlobPattern *globPtr = (GlobPattern *)ckalloc(sizeof(GlobPattern));
+ TkSizeT len;
+ const char *str = TkGetStringFromObj(globList[i], &len);
len = (len + 1) * sizeof(char);
if (str[0] && str[0] != '*') {
@@ -331,12 +331,12 @@ AddClause(
* Prepend a "*" to patterns that do not have a leading "*"
*/
- globPtr->pattern = ckalloc(len + 1);
+ globPtr->pattern = (char *)ckalloc(len + 1);
globPtr->pattern[0] = '*';
strcpy(globPtr->pattern+1, str);
} else if (isWindows) {
if (strcmp(str, "*") == 0) {
- globPtr->pattern = ckalloc(4);
+ globPtr->pattern = (char *)ckalloc(4);
strcpy(globPtr->pattern, "*.*");
} else if (strcmp(str, "") == 0) {
/*
@@ -345,14 +345,14 @@ AddClause(
* TODO: "*." actually matches with all files on Win95
*/
- globPtr->pattern = ckalloc(3);
+ globPtr->pattern = (char *)ckalloc(3);
strcpy(globPtr->pattern, "*.");
} else {
- globPtr->pattern = ckalloc(len);
+ globPtr->pattern = (char *)ckalloc(len);
strcpy(globPtr->pattern, str);
}
} else {
- globPtr->pattern = ckalloc(len);
+ globPtr->pattern = (char *)ckalloc(len);
strcpy(globPtr->pattern, str);
}
@@ -375,9 +375,9 @@ AddClause(
}
for (i=0; i<ostypeCount; i++) {
Tcl_DString osTypeDS;
- int len;
- MacFileType *mfPtr = ckalloc(sizeof(MacFileType));
- const char *strType = Tcl_GetStringFromObj(ostypeList[i], &len);
+ TkSizeT len;
+ MacFileType *mfPtr = (MacFileType *)ckalloc(sizeof(MacFileType));
+ const char *strType = TkGetStringFromObj(ostypeList[i], &len);
char *string;
/*
@@ -445,11 +445,11 @@ GetFilter(
}
}
- filterPtr = ckalloc(sizeof(FileFilter));
+ filterPtr = (FileFilter *)ckalloc(sizeof(FileFilter));
filterPtr->clauses = NULL;
filterPtr->clausesTail = NULL;
len = strlen(name) + 1;
- filterPtr->name = ckalloc(len);
+ filterPtr->name = (char *)ckalloc(len);
memcpy(filterPtr->name, name, len);
if (flistPtr->filters == NULL) {
diff --git a/generic/tkFocus.c b/generic/tkFocus.c
index c621bf9..8066afd 100644
--- a/generic/tkFocus.c
+++ b/generic/tkFocus.c
@@ -113,8 +113,8 @@ Tk_FocusObjCmd(
static const char *const focusOptions[] = {
"-displayof", "-force", "-lastfor", NULL
};
- Tk_Window tkwin = clientData;
- TkWindow *winPtr = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
TkWindow *newPtr, *topLevelPtr;
ToplevelFocusInfo *tlFocusPtr;
const char *windowName;
@@ -279,8 +279,8 @@ TkFocusFilterEvent(
* pass the event through to Tk bindings.
*/
- if (eventPtr->xfocus.send_event == GENERATED_FOCUS_EVENT_MAGIC) {
- eventPtr->xfocus.send_event = 0;
+ if ((eventPtr->xfocus.send_event & GENERATED_FOCUS_EVENT_MAGIC) == GENERATED_FOCUS_EVENT_MAGIC) {
+ eventPtr->xfocus.send_event &= ~GENERATED_FOCUS_EVENT_MAGIC;
return 1;
}
@@ -415,7 +415,7 @@ TkFocusFilterEvent(
}
}
if (tlFocusPtr == NULL) {
- tlFocusPtr = ckalloc(sizeof(ToplevelFocusInfo));
+ tlFocusPtr = (ToplevelFocusInfo *)ckalloc(sizeof(ToplevelFocusInfo));
tlFocusPtr->topLevelPtr = tlFocusPtr->focusWinPtr = winPtr;
tlFocusPtr->nextPtr = winPtr->mainPtr->tlFocusPtr;
winPtr->mainPtr->tlFocusPtr = tlFocusPtr;
@@ -603,7 +603,7 @@ TkSetFocusWin(
if (displayFocusPtr->focusOnMapPtr != NULL) {
Tk_DeleteEventHandler((Tk_Window) displayFocusPtr->focusOnMapPtr,
- StructureNotifyMask, FocusMapProc,
+ VisibilityChangeMask, FocusMapProc,
displayFocusPtr->focusOnMapPtr);
displayFocusPtr->focusOnMapPtr = NULL;
}
@@ -622,15 +622,16 @@ TkSetFocusWin(
}
}
if (tlFocusPtr == NULL) {
- tlFocusPtr = ckalloc(sizeof(ToplevelFocusInfo));
+ tlFocusPtr = (ToplevelFocusInfo *)ckalloc(sizeof(ToplevelFocusInfo));
tlFocusPtr->topLevelPtr = topLevelPtr;
tlFocusPtr->nextPtr = winPtr->mainPtr->tlFocusPtr;
winPtr->mainPtr->tlFocusPtr = tlFocusPtr;
}
tlFocusPtr->focusWinPtr = winPtr;
- if (topLevelPtr->flags & TK_EMBEDDED) {
-
+ if (topLevelPtr->flags & TK_EMBEDDED &&
+ (displayFocusPtr->focusWinPtr == NULL)) {
+
/*
* We are assigning focus to an embedded toplevel. The platform
* specific function TkpClaimFocus needs to handle the job of
@@ -646,7 +647,7 @@ TkSetFocusWin(
* toplevel from a different application, clear the focus in that
* application.
*/
-
+
if (force) {
TkWindow *focusPtr = winPtr->dispPtr->focusPtr;
if (focusPtr && focusPtr->mainPtr != winPtr->mainPtr) {
@@ -660,7 +661,7 @@ TkSetFocusWin(
* Call the platform specific function TkpChangeFocus to move the
* window manager's focus to a new toplevel.
*/
-
+
serial = TkpChangeFocus(TkpGetWrapperWindow(topLevelPtr), force);
if (serial != 0) {
displayFocusPtr->focusSerial = serial;
@@ -806,7 +807,7 @@ TkFocusKeyEvent(
void
TkFocusDeadWindow(
- register TkWindow *winPtr) /* Information about the window that is being
+ TkWindow *winPtr) /* Information about the window that is being
* deleted. */
{
ToplevelFocusInfo *tlFocusPtr, *prevPtr;
@@ -960,7 +961,7 @@ FocusMapProc(
ClientData clientData, /* Toplevel window. */
XEvent *eventPtr) /* Information about event. */
{
- TkWindow *winPtr = clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
DisplayFocusInfo *displayFocusPtr;
if (eventPtr->type == VisibilityNotify) {
@@ -1014,7 +1015,7 @@ FindDisplayFocusInfo(
* The record doesn't exist yet. Make a new one.
*/
- displayFocusPtr = ckalloc(sizeof(DisplayFocusInfo));
+ displayFocusPtr = (DisplayFocusInfo *)ckalloc(sizeof(DisplayFocusInfo));
displayFocusPtr->dispPtr = dispPtr;
displayFocusPtr->focusWinPtr = NULL;
displayFocusPtr->focusOnMapPtr = NULL;
@@ -1142,7 +1143,7 @@ TkFocusSplit(
* Move focus to new toplevel.
*/
- ToplevelFocusInfo *newTlFocusPtr = ckalloc(sizeof(ToplevelFocusInfo));
+ ToplevelFocusInfo *newTlFocusPtr = (ToplevelFocusInfo *)ckalloc(sizeof(ToplevelFocusInfo));
newTlFocusPtr->topLevelPtr = winPtr;
newTlFocusPtr->focusWinPtr = tlFocusPtr->focusWinPtr;
diff --git a/generic/tkFont.c b/generic/tkFont.c
index c0ff7d0..34f8921 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -13,7 +13,9 @@
#include "tkInt.h"
#include "tkFont.h"
-
+#if defined(MAC_OSX_TK)
+#include "tkMacOSXInt.h"
+#endif
/*
* The following structure is used to keep track of all the fonts that exist
* in the current application. It must be stored in the TkMainInfo for the
@@ -377,7 +379,7 @@ void
TkFontPkgInit(
TkMainInfo *mainPtr) /* The application being created. */
{
- TkFontInfo *fiPtr = ckalloc(sizeof(TkFontInfo));
+ TkFontInfo *fiPtr = (TkFontInfo *)ckalloc(sizeof(TkFontInfo));
Tcl_InitHashTable(&fiPtr->fontCache, TCL_STRING_KEYS);
Tcl_InitHashTable(&fiPtr->namedTable, TCL_STRING_KEYS);
@@ -470,7 +472,7 @@ Tk_FontObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
int index;
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
TkFontInfo *fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr;
static const char *const optionStrings[] = {
"actual", "configure", "create", "delete",
@@ -614,9 +616,9 @@ Tk_FontObjCmd(
}
string = Tcl_GetString(objv[2]);
namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, string);
- nfPtr = NULL; /* lint. */
+ nfPtr = NULL;
if (namedHashPtr != NULL) {
- nfPtr = Tcl_GetHashValue(namedHashPtr);
+ nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr);
}
if ((namedHashPtr == NULL) || nfPtr->deletePending) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -712,7 +714,7 @@ Tk_FontObjCmd(
case FONT_MEASURE: {
const char *string;
Tk_Font tkfont;
- size_t length = 0;
+ TkSizeT length = 0;
int skip = 0;
if (objc > 4) {
@@ -731,7 +733,7 @@ Tk_FontObjCmd(
return TCL_ERROR;
}
string = TkGetStringFromObj(objv[3 + skip], &length);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
Tk_TextWidth(tkfont, string, length)));
Tk_FreeFont(tkfont);
break;
@@ -778,7 +780,7 @@ Tk_FontObjCmd(
case 2: i = fmPtr->ascent + fmPtr->descent; break;
case 3: i = fmPtr->fixed; break;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(i));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(i));
}
Tk_FreeFont(tkfont);
break;
@@ -795,10 +797,10 @@ Tk_FontObjCmd(
resultPtr = Tcl_NewObj();
namedHashPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search);
while (namedHashPtr != NULL) {
- NamedFont *nfPtr = Tcl_GetHashValue(namedHashPtr);
+ NamedFont *nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr);
if (!nfPtr->deletePending) {
- char *string = Tcl_GetHashKey(&fiPtr->namedTable,
+ char *string = (char *)Tcl_GetHashKey(&fiPtr->namedTable,
namedHashPtr);
Tcl_ListObjAppendElement(NULL, resultPtr,
@@ -841,7 +843,7 @@ UpdateDependentFonts(
Tcl_HashEntry *cacheHashPtr;
Tcl_HashSearch search;
TkFont *fontPtr;
- NamedFont *nfPtr = Tcl_GetHashValue(namedHashPtr);
+ NamedFont *nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr);
if (nfPtr->refCount == 0) {
/*
@@ -854,7 +856,7 @@ UpdateDependentFonts(
cacheHashPtr = Tcl_FirstHashEntry(&fiPtr->fontCache, &search);
while (cacheHashPtr != NULL) {
- for (fontPtr = Tcl_GetHashValue(cacheHashPtr);
+ for (fontPtr = (TkFont *)Tcl_GetHashValue(cacheHashPtr);
fontPtr != NULL; fontPtr = fontPtr->nextPtr) {
if (fontPtr->namedHashPtr == namedHashPtr) {
TkpGetFontFromAttributes(fontPtr, tkwin, &nfPtr->fa);
@@ -872,8 +874,19 @@ static void
TheWorldHasChanged(
ClientData clientData) /* Info about application's fonts. */
{
- TkFontInfo *fiPtr = clientData;
+ TkFontInfo *fiPtr = (TkFontInfo *)clientData;
+#if defined(MAC_OSX_TK)
+
+ /*
+ * On macOS it is catastrophic to recompute all widgets while the
+ * [NSView drawRect] method is drawing. The best that we can do in
+ * that situation is to abort the recomputation and hope for the best.
+ */
+ if (TkpAppIsDrawing()) {
+ return;
+ }
+#endif
fiPtr->updatePending = 0;
RecomputeWidgets(fiPtr->mainPtr->winPtr);
}
@@ -951,7 +964,7 @@ TkCreateNamedFont(
namedHashPtr = Tcl_CreateHashEntry(&fiPtr->namedTable, name, &isNew);
if (!isNew) {
- nfPtr = Tcl_GetHashValue(namedHashPtr);
+ nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr);
if (!nfPtr->deletePending) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -973,7 +986,7 @@ TkCreateNamedFont(
return TCL_OK;
}
- nfPtr = ckalloc(sizeof(NamedFont));
+ nfPtr = (NamedFont *)ckalloc(sizeof(NamedFont));
nfPtr->deletePending = 0;
Tcl_SetHashValue(namedHashPtr, nfPtr);
nfPtr->fa = *faPtr;
@@ -1012,7 +1025,7 @@ TkDeleteNamedFont(
}
return TCL_ERROR;
}
- nfPtr = Tcl_GetHashValue(namedHashPtr);
+ nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr);
if (nfPtr->refCount != 0) {
nfPtr->deletePending = 1;
} else {
@@ -1101,7 +1114,7 @@ Tk_AllocFontFromObj(
SetFontFromAny(interp, objPtr);
}
- oldFontPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ oldFontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1;
if (oldFontPtr != NULL) {
if (oldFontPtr->resourceRefCount == 0) {
/*
@@ -1130,7 +1143,7 @@ Tk_AllocFontFromObj(
cacheHashPtr = Tcl_CreateHashEntry(&fiPtr->fontCache,
Tcl_GetString(objPtr), &isNew);
}
- firstFontPtr = Tcl_GetHashValue(cacheHashPtr);
+ firstFontPtr = (TkFont *)Tcl_GetHashValue(cacheHashPtr);
for (fontPtr = firstFontPtr; (fontPtr != NULL);
fontPtr = fontPtr->nextPtr) {
if (Tk_Screen(tkwin) == fontPtr->screen) {
@@ -1153,7 +1166,7 @@ Tk_AllocFontFromObj(
* Construct a font based on a named font.
*/
- nfPtr = Tcl_GetHashValue(namedHashPtr);
+ nfPtr = (NamedFont *)Tcl_GetHashValue(namedHashPtr);
nfPtr->refCount++;
fontPtr = TkpGetFontFromAttributes(NULL, tkwin, &nfPtr->fa);
@@ -1286,7 +1299,7 @@ Tk_GetFontFromObj(
SetFontFromAny(NULL, objPtr);
}
- fontPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ fontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1;
if (fontPtr != NULL) {
if (fontPtr->resourceRefCount == 0) {
/*
@@ -1313,7 +1326,7 @@ Tk_GetFontFromObj(
hashPtr = Tcl_FindHashEntry(&fiPtr->fontCache, Tcl_GetString(objPtr));
}
if (hashPtr != NULL) {
- for (fontPtr = Tcl_GetHashValue(hashPtr); fontPtr != NULL;
+ for (fontPtr = (TkFont *)Tcl_GetHashValue(hashPtr); fontPtr != NULL;
fontPtr = fontPtr->nextPtr) {
if (Tk_Screen(tkwin) == fontPtr->screen) {
fontPtr->objRefCount++;
@@ -1348,10 +1361,11 @@ Tk_GetFontFromObj(
static int
SetFontFromAny(
- Tcl_Interp *interp, /* Used for error reporting if not NULL. */
+ Tcl_Interp *dummy, /* Used for error reporting if not NULL. */
Tcl_Obj *objPtr) /* The object to convert. */
{
const Tcl_ObjType *typePtr;
+ (void)dummy;
/*
* Free the old internalRep before setting the new one.
@@ -1433,14 +1447,14 @@ Tk_FreeFont(
* the named font and free it if no-one else is using it.
*/
- nfPtr = Tcl_GetHashValue(fontPtr->namedHashPtr);
+ nfPtr = (NamedFont *)Tcl_GetHashValue(fontPtr->namedHashPtr);
if ((nfPtr->refCount-- <= 1) && nfPtr->deletePending) {
Tcl_DeleteHashEntry(fontPtr->namedHashPtr);
ckfree(nfPtr);
}
}
- prevPtr = Tcl_GetHashValue(fontPtr->cacheHashPtr);
+ prevPtr = (TkFont *)Tcl_GetHashValue(fontPtr->cacheHashPtr);
if (prevPtr == fontPtr) {
if (fontPtr->nextPtr == NULL) {
Tcl_DeleteHashEntry(fontPtr->cacheHashPtr);
@@ -1518,7 +1532,7 @@ static void
FreeFontObj(
Tcl_Obj *objPtr) /* The object we are releasing. */
{
- TkFont *fontPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ TkFont *fontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1;
if (fontPtr != NULL) {
if ((fontPtr->objRefCount-- <= 1) && (fontPtr->resourceRefCount == 0)) {
@@ -1552,7 +1566,7 @@ DupFontObjProc(
Tcl_Obj *srcObjPtr, /* The object we are copying from. */
Tcl_Obj *dupObjPtr) /* The object we are copying to. */
{
- TkFont *fontPtr = srcObjPtr->internalRep.twoPtrValue.ptr1;
+ TkFont *fontPtr = (TkFont *)srcObjPtr->internalRep.twoPtrValue.ptr1;
dupObjPtr->typePtr = srcObjPtr->typePtr;
dupObjPtr->internalRep.twoPtrValue.ptr1 = fontPtr;
@@ -1987,7 +2001,7 @@ Tk_ComputeTextLayout(
maxChunks = 1;
- layoutPtr = ckalloc(sizeof(TextLayout)
+ layoutPtr = (TextLayout *)ckalloc(sizeof(TextLayout)
+ (maxChunks-1) * sizeof(LayoutChunk));
layoutPtr->tkfont = tkfont;
layoutPtr->string = string;
@@ -2724,8 +2738,8 @@ Tk_CharBbox(
x += chunkPtr->x;
}
if (widthPtr != NULL) {
- Tk_MeasureChars(tkfont, end, Tcl_UtfNext(end) - end,
- -1, 0, &w);
+ int ch;
+ Tk_MeasureChars(tkfont, end, TkUtfToUniChar(end, &ch), -1, 0, &w);
}
goto check;
}
@@ -3245,7 +3259,7 @@ Tk_TextLayoutToPostscript(
int baseline = chunkPtr->y;
Tcl_Obj *psObj = Tcl_NewObj();
int i, j;
- size_t len;
+ TkSizeT len;
const char *p, *glyphname;
char uindex[5], c, *ps;
int ch;
@@ -3368,6 +3382,7 @@ ConfigAttributesObj(
int i, n, index;
Tcl_Obj *optionPtr, *valuePtr;
const char *value;
+ (void)tkwin;
for (i = 0; i < objc; i += 2) {
optionPtr = objv[i];
@@ -3494,9 +3509,9 @@ GetAttributeInfoObj(
case FONT_SIZE:
if (faPtr->size >= 0.0) {
- valuePtr = Tcl_NewIntObj((int)(faPtr->size + 0.5));
+ valuePtr = Tcl_NewWideIntObj((Tcl_WideInt)(faPtr->size + 0.5));
} else {
- valuePtr = Tcl_NewIntObj(-(int)(-faPtr->size + 0.5));
+ valuePtr = Tcl_NewWideIntObj(-(Tcl_WideInt)(-faPtr->size + 0.5));
}
break;
@@ -3565,7 +3580,7 @@ ParseFontNameObj(
* specified in font name are filled with
* default values. */
{
- char *dash;
+ const char *dash;
int objc, result, i, n;
Tcl_Obj **objv;
const char *string;
@@ -3734,7 +3749,7 @@ NewChunk(
if (layoutPtr->numChunks == maxChunks) {
maxChunks *= 2;
s = sizeof(TextLayout) + ((maxChunks - 1) * sizeof(LayoutChunk));
- layoutPtr = ckrealloc(layoutPtr, s);
+ layoutPtr = (TextLayout *)ckrealloc(layoutPtr, s);
*layoutPtrPtr = layoutPtr;
*maxPtr = maxChunks;
@@ -4197,7 +4212,7 @@ TkDebugFont(
hashPtr = Tcl_FindHashEntry(
&((TkWindow *) tkwin)->mainPtr->fontInfoPtr->fontCache, name);
if (hashPtr != NULL) {
- fontPtr = Tcl_GetHashValue(hashPtr);
+ fontPtr = (TkFont *)Tcl_GetHashValue(hashPtr);
if (fontPtr == NULL) {
Tcl_Panic("TkDebugFont found empty hash table entry");
}
@@ -4250,7 +4265,7 @@ TkFontGetFirstTextLayout(
}
chunkPtr = layoutPtr->chunks;
numBytesInChunk = chunkPtr->numBytes;
- strncpy(dst, chunkPtr->start, (size_t) numBytesInChunk);
+ strncpy(dst, chunkPtr->start, numBytesInChunk);
*font = layoutPtr->tkfont;
return numBytesInChunk;
}
diff --git a/generic/tkFrame.c b/generic/tkFrame.c
index 392799e..df370af 100644
--- a/generic/tkFrame.c
+++ b/generic/tkFrame.c
@@ -94,6 +94,16 @@ typedef struct {
* pixels of extra space to leave above and
* below child area. */
int padY; /* Integer value corresponding to padYPtr. */
+ Tcl_Obj *bgimgPtr; /* Value of -backgroundimage option: specifies
+ * image to display on window's background, or
+ * NULL if none. */
+ Tk_Image bgimg; /* Derived from bgimgPtr by calling
+ * Tk_GetImage, or NULL if bgimgPtr is
+ * NULL. */
+ int tile; /* Whether to tile the bgimg. */
+#ifndef TK_NO_DOUBLE_BUFFERING
+ GC copyGC; /* GC for copying when double-buffering. */
+#endif /* TK_NO_DOUBLE_BUFFERING */
} Frame;
/*
@@ -174,80 +184,94 @@ static const char *const labelAnchorStrings[] = {
static const Tk_OptionSpec commonOptSpec[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_FRAME_BG_COLOR, -1, Tk_Offset(Frame, border),
+ DEF_FRAME_BG_COLOR, TCL_INDEX_NONE, offsetof(Frame, border),
TK_OPTION_NULL_OK, DEF_FRAME_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_STRING, "-colormap", "colormap", "Colormap",
- DEF_FRAME_COLORMAP, -1, Tk_Offset(Frame, colormapName),
+ DEF_FRAME_COLORMAP, TCL_INDEX_NONE, offsetof(Frame, colormapName),
TK_OPTION_NULL_OK, 0, 0},
/*
* Having -container is useless in a labelframe since a container has
* no border. It should be deprecated.
*/
{TK_OPTION_BOOLEAN, "-container", "container", "Container",
- DEF_FRAME_CONTAINER, -1, Tk_Offset(Frame, isContainer), 0, 0, 0},
+ DEF_FRAME_CONTAINER, TCL_INDEX_NONE, offsetof(Frame, isContainer), 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_FRAME_CURSOR, -1, Tk_Offset(Frame, cursor),
+ DEF_FRAME_CURSOR, TCL_INDEX_NONE, offsetof(Frame, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- DEF_FRAME_HEIGHT, -1, Tk_Offset(Frame, height), 0, 0, 0},
+ DEF_FRAME_HEIGHT, TCL_INDEX_NONE, offsetof(Frame, height), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_FRAME_HIGHLIGHT_BG, -1,
- Tk_Offset(Frame, highlightBgColorPtr), 0, 0, 0},
+ "HighlightBackground", DEF_FRAME_HIGHLIGHT_BG, TCL_INDEX_NONE,
+ offsetof(Frame, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_FRAME_HIGHLIGHT, -1, Tk_Offset(Frame, highlightColorPtr),
+ DEF_FRAME_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Frame, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Frame, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Frame, highlightWidth), 0, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_FRAME_PADX, Tk_Offset(Frame, padXPtr),
- Tk_Offset(Frame, padX), 0, 0, 0},
+ DEF_FRAME_PADX, offsetof(Frame, padXPtr),
+ offsetof(Frame, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_FRAME_PADY, Tk_Offset(Frame, padYPtr),
- Tk_Offset(Frame, padY), 0, 0, 0},
+ DEF_FRAME_PADY, offsetof(Frame, padYPtr),
+ offsetof(Frame, padY), 0, 0, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_FRAME_TAKE_FOCUS, -1, Tk_Offset(Frame, takeFocus),
+ DEF_FRAME_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Frame, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-visual", "visual", "Visual",
- DEF_FRAME_VISUAL, -1, Tk_Offset(Frame, visualName),
+ DEF_FRAME_VISUAL, TCL_INDEX_NONE, offsetof(Frame, visualName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_FRAME_WIDTH, -1, Tk_Offset(Frame, width), 0, 0, 0},
+ DEF_FRAME_WIDTH, TCL_INDEX_NONE, offsetof(Frame, width), 0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
static const Tk_OptionSpec frameOptSpec[] = {
+ {TK_OPTION_STRING, "-backgroundimage", "backgroundImage", "BackgroundImage",
+ DEF_FRAME_BG_IMAGE, offsetof(Frame, bgimgPtr), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
+ {TK_OPTION_SYNONYM, "-bgimg", NULL, NULL,
+ NULL, 0, TCL_INDEX_NONE, 0, "-backgroundimage", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_FRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth), 0, 0, 0},
+ DEF_FRAME_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Frame, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-class", "class", "Class",
- DEF_FRAME_CLASS, -1, Tk_Offset(Frame, className), 0, 0, 0},
+ DEF_FRAME_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_FRAME_RELIEF, -1, Tk_Offset(Frame, relief), 0, 0, 0},
+ DEF_FRAME_RELIEF, TCL_INDEX_NONE, offsetof(Frame, relief), 0, 0, 0},
+ {TK_OPTION_BOOLEAN, "-tile", "tile", "Tile",
+ DEF_FRAME_BG_TILE, TCL_INDEX_NONE, offsetof(Frame, tile), 0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL,
NULL, 0, 0, 0, commonOptSpec, 0}
};
static const Tk_OptionSpec toplevelOptSpec[] = {
+ {TK_OPTION_STRING, "-backgroundimage", "backgroundImage", "BackgroundImage",
+ DEF_FRAME_BG_IMAGE, offsetof(Frame, bgimgPtr), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
+ {TK_OPTION_SYNONYM, "-bgimg", NULL, NULL,
+ NULL, 0, TCL_INDEX_NONE, 0, "-backgroundimage", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_FRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth), 0, 0, 0},
+ DEF_FRAME_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Frame, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-class", "class", "Class",
- DEF_TOPLEVEL_CLASS, -1, Tk_Offset(Frame, className), 0, 0, 0},
+ DEF_TOPLEVEL_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0},
{TK_OPTION_STRING, "-menu", "menu", "Menu",
- DEF_TOPLEVEL_MENU, -1, Tk_Offset(Frame, menuName),
+ DEF_TOPLEVEL_MENU, TCL_INDEX_NONE, offsetof(Frame, menuName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_FRAME_RELIEF, -1, Tk_Offset(Frame, relief), 0, 0, 0},
+ DEF_FRAME_RELIEF, TCL_INDEX_NONE, offsetof(Frame, relief), 0, 0, 0},
{TK_OPTION_STRING, "-screen", "screen", "Screen",
- DEF_TOPLEVEL_SCREEN, -1, Tk_Offset(Frame, screenName),
+ DEF_TOPLEVEL_SCREEN, TCL_INDEX_NONE, offsetof(Frame, screenName),
TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_BOOLEAN, "-tile", "tile", "Tile",
+ DEF_FRAME_BG_TILE, TCL_INDEX_NONE, offsetof(Frame, tile), 0, 0, 0},
{TK_OPTION_STRING, "-use", "use", "Use",
- DEF_TOPLEVEL_USE, -1, Tk_Offset(Frame, useThis),
+ DEF_TOPLEVEL_USE, TCL_INDEX_NONE, offsetof(Frame, useThis),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL,
NULL, 0, 0, 0, commonOptSpec, 0}
@@ -255,27 +279,27 @@ static const Tk_OptionSpec toplevelOptSpec[] = {
static const Tk_OptionSpec labelframeOptSpec[] = {
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_LABELFRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth),
+ DEF_LABELFRAME_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Frame, borderWidth),
0, 0, 0},
{TK_OPTION_STRING, "-class", "class", "Class",
- DEF_LABELFRAME_CLASS, -1, Tk_Offset(Frame, className), 0, 0, 0},
+ DEF_LABELFRAME_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_LABELFRAME_FONT, -1, Tk_Offset(Labelframe, tkfont), 0, 0, 0},
+ DEF_LABELFRAME_FONT, TCL_INDEX_NONE, offsetof(Labelframe, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_LABELFRAME_FG, -1, Tk_Offset(Labelframe, textColorPtr), 0, 0, 0},
+ DEF_LABELFRAME_FG, TCL_INDEX_NONE, offsetof(Labelframe, textColorPtr), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-labelanchor", "labelAnchor", "LabelAnchor",
- DEF_LABELFRAME_LABELANCHOR, -1, Tk_Offset(Labelframe, labelAnchor),
+ DEF_LABELFRAME_LABELANCHOR, TCL_INDEX_NONE, offsetof(Labelframe, labelAnchor),
0, labelAnchorStrings, 0},
{TK_OPTION_WINDOW, "-labelwidget", "labelWidget", "LabelWidget",
- NULL, -1, Tk_Offset(Labelframe, labelWin), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(Labelframe, labelWin), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LABELFRAME_RELIEF, -1, Tk_Offset(Frame, relief), 0, 0, 0},
+ DEF_LABELFRAME_RELIEF, TCL_INDEX_NONE, offsetof(Frame, relief), 0, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_LABELFRAME_TEXT, Tk_Offset(Labelframe, textPtr), -1,
+ DEF_LABELFRAME_TEXT, offsetof(Labelframe, textPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL,
NULL, 0, 0, 0, commonOptSpec, 0}
@@ -311,6 +335,12 @@ static int CreateFrame(ClientData clientData, Tcl_Interp *interp,
static void DestroyFrame(void *memPtr);
static void DestroyFramePartly(Frame *framePtr);
static void DisplayFrame(ClientData clientData);
+static void DrawFrameBackground(Tk_Window tkwin, Pixmap pixmap,
+ int highlightWidth, int borderWidth,
+ Tk_Image bgimg, int bgtile);
+static void FrameBgImageProc(ClientData clientData,
+ int x, int y, int width, int height,
+ int imgWidth, int imgHeight);
static void FrameCmdDeletedProc(ClientData clientData);
static void FrameEventProc(ClientData clientData,
XEvent *eventPtr);
@@ -431,7 +461,7 @@ TkCreateFrame(
* application. */
{
int result, i;
- Tcl_Obj **objv = ckalloc((argc+1) * sizeof(Tcl_Obj **));
+ Tcl_Obj **objv = (Tcl_Obj **)ckalloc((argc+1) * sizeof(Tcl_Obj **));
for (i=0; i<argc; i++) {
objv[i] = Tcl_NewStringObj(argv[i], -1);
@@ -472,7 +502,7 @@ TkListCreateFrame(
static int
CreateFrame(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects. */
@@ -489,10 +519,11 @@ CreateFrame(
const char *className, *screenName, *visualName, *colormapName;
const char *arg, *useOption;
int i, depth;
- size_t length;
+ TkSizeT length;
unsigned int mask;
Colormap colormap;
Visual *visual;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -648,10 +679,10 @@ CreateFrame(
*/
if (type == TYPE_LABELFRAME) {
- framePtr = ckalloc(sizeof(Labelframe));
+ framePtr = (Frame *)ckalloc(sizeof(Labelframe));
memset(framePtr, 0, sizeof(Labelframe));
} else {
- framePtr = ckalloc(sizeof(Frame));
+ framePtr = (Frame *)ckalloc(sizeof(Frame));
memset(framePtr, 0, sizeof(Frame));
}
framePtr->tkwin = newWin;
@@ -742,10 +773,10 @@ FrameWidgetObjCmd(
enum options {
FRAME_CGET, FRAME_CONFIGURE
};
- register Frame *framePtr = clientData;
+ Frame *framePtr = (Frame *)clientData;
int result = TCL_OK, index;
int c, i;
- size_t length;
+ TkSizeT length;
Tcl_Obj *objPtr;
if (objc < 2) {
@@ -796,17 +827,17 @@ FrameWidgetObjCmd(
}
c = arg[1];
if (((c == 'c') && (length >= 2)
- && (strncmp(arg, "-class", (unsigned)length) == 0))
+ && (strncmp(arg, "-class", length) == 0))
|| ((c == 'c') && (length >= 3)
- && (strncmp(arg, "-colormap", (unsigned)length) == 0))
+ && (strncmp(arg, "-colormap", length) == 0))
|| ((c == 'c') && (length >= 3)
- && (strncmp(arg, "-container", (unsigned)length) == 0))
+ && (strncmp(arg, "-container", length) == 0))
|| ((c == 's') && (framePtr->type == TYPE_TOPLEVEL)
- && (strncmp(arg, "-screen", (unsigned)length) == 0))
+ && (strncmp(arg, "-screen", length) == 0))
|| ((c == 'u') && (framePtr->type == TYPE_TOPLEVEL)
- && (strncmp(arg, "-use", (unsigned)length) == 0))
+ && (strncmp(arg, "-use", length) == 0))
|| ((c == 'v')
- && (strncmp(arg, "-visual", (unsigned)length) == 0))) {
+ && (strncmp(arg, "-visual", length) == 0))) {
#ifdef SUPPORT_CONFIG_EMBEDDED
if (c == 'u') {
@@ -861,8 +892,8 @@ static void
DestroyFrame(
void *memPtr) /* Info about frame widget. */
{
- register Frame *framePtr = memPtr;
- register Labelframe *labelframePtr = memPtr;
+ Frame *framePtr = (Frame *)memPtr;
+ Labelframe *labelframePtr = (Labelframe *)memPtr;
if (framePtr->type == TYPE_LABELFRAME) {
Tk_FreeTextLayout(labelframePtr->textLayout);
@@ -870,9 +901,17 @@ DestroyFrame(
Tk_FreeGC(framePtr->display, labelframePtr->textGC);
}
}
+#ifndef TK_NO_DOUBLE_BUFFERING
+ if (framePtr->copyGC != NULL) {
+ Tk_FreeGC(framePtr->display, framePtr->copyGC);
+ }
+#endif /* TK_NO_DOUBLE_BUFFERING */
if (framePtr->colormap != None) {
Tk_FreeColormap(framePtr->display, framePtr->colormap);
}
+ if (framePtr->bgimg) {
+ Tk_FreeImage(framePtr->bgimg);
+ }
ckfree(framePtr);
}
@@ -898,7 +937,7 @@ static void
DestroyFramePartly(
Frame *framePtr) /* Info about frame widget. */
{
- register Labelframe *labelframePtr = (Labelframe *) framePtr;
+ Labelframe *labelframePtr = (Labelframe *) framePtr;
if (framePtr->type == TYPE_LABELFRAME && labelframePtr->labelWin != NULL) {
Tk_DeleteEventHandler(labelframePtr->labelWin, StructureNotifyMask,
@@ -938,7 +977,7 @@ DestroyFramePartly(
static int
ConfigureFrame(
Tcl_Interp *interp, /* Used for error reporting. */
- register Frame *framePtr, /* Information about widget; may or may not
+ Frame *framePtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in objv. */
Tcl_Obj *const objv[]) /* Arguments. */
@@ -947,6 +986,7 @@ ConfigureFrame(
char *oldMenuName;
Tk_Window oldWindow = NULL;
Labelframe *labelframePtr = (Labelframe *) framePtr;
+ Tk_Image image = NULL;
/*
* Need the old menubar name for the menu code to delete it.
@@ -955,7 +995,7 @@ ConfigureFrame(
if (framePtr->menuName == NULL) {
oldMenuName = NULL;
} else {
- oldMenuName = ckalloc(strlen(framePtr->menuName) + 1);
+ oldMenuName = (char *)ckalloc(strlen(framePtr->menuName) + 1);
strcpy(oldMenuName, framePtr->menuName);
}
@@ -970,6 +1010,20 @@ ConfigureFrame(
}
return TCL_ERROR;
}
+
+ if (framePtr->bgimgPtr) {
+ image = Tk_GetImage(interp, framePtr->tkwin,
+ Tcl_GetString(framePtr->bgimgPtr), FrameBgImageProc, framePtr);
+ if (image == NULL) {
+ Tk_RestoreSavedOptions(&savedOptions);
+ return TCL_ERROR;
+ }
+ }
+ if (framePtr->bgimg) {
+ Tk_FreeImage(framePtr->bgimg);
+ }
+ framePtr->bgimg = image;
+
Tk_FreeSavedOptions(&savedOptions);
/*
@@ -1096,8 +1150,8 @@ static void
FrameWorldChanged(
ClientData instanceData) /* Information about widget. */
{
- Frame *framePtr = instanceData;
- Labelframe *labelframePtr = instanceData;
+ Frame *framePtr = (Frame *)instanceData;
+ Labelframe *labelframePtr = (Labelframe *)instanceData;
Tk_Window tkwin = framePtr->tkwin;
XGCValues gcValues;
GC gc;
@@ -1111,6 +1165,15 @@ FrameWorldChanged(
anyWindowLabel = (framePtr->type == TYPE_LABELFRAME) &&
(labelframePtr->labelWin != NULL);
+#ifndef TK_NO_DOUBLE_BUFFERING
+ gcValues.graphics_exposures = False;
+ gc = Tk_GetGC(tkwin, GCGraphicsExposures, &gcValues);
+ if (framePtr->copyGC != NULL) {
+ Tk_FreeGC(framePtr->display, framePtr->copyGC);
+ }
+ framePtr->copyGC = gc;
+#endif /* TK_NO_DOUBLE_BUFFERING */
+
if (framePtr->type == TYPE_LABELFRAME) {
/*
* The textGC is needed even in the labelWin case, so it's always
@@ -1265,7 +1328,7 @@ FrameWorldChanged(
static void
ComputeFrameGeometry(
- register Frame *framePtr) /* Information about widget. */
+ Frame *framePtr) /* Information about widget. */
{
int otherWidth, otherHeight, otherWidthT, otherHeightT, padding;
int maxWidth, maxHeight;
@@ -1414,8 +1477,8 @@ static void
DisplayFrame(
ClientData clientData) /* Information about widget. */
{
- register Frame *framePtr = clientData;
- register Tk_Window tkwin = framePtr->tkwin;
+ Frame *framePtr = (Frame *)clientData;
+ Tk_Window tkwin = framePtr->tkwin;
int bdX1, bdY1, bdX2, bdY2, hlWidth;
Pixmap pixmap;
TkRegion clipRegion = NULL;
@@ -1455,6 +1518,20 @@ DisplayFrame(
return;
}
+#ifndef TK_NO_DOUBLE_BUFFERING
+ /*
+ * In order to avoid screen flashes, this function redraws the frame into
+ * off-screen memory, then copies it back on-screen in a single operation.
+ * This means there's no point in time where the on-screen image has been
+ * cleared.
+ */
+
+ pixmap = Tk_GetPixmap(framePtr->display, Tk_WindowId(tkwin),
+ Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin));
+#else
+ pixmap = Tk_WindowId(tkwin);
+#endif /* TK_NO_DOUBLE_BUFFERING */
+
if (framePtr->type != TYPE_LABELFRAME) {
/*
* Pass to platform specific draw function. In general, it just draws
@@ -1462,8 +1539,12 @@ DisplayFrame(
*/
noLabel:
- TkpDrawFrame(tkwin, framePtr->border, hlWidth,
+ TkpDrawFrameEx(tkwin, pixmap, framePtr->border, hlWidth,
framePtr->borderWidth, framePtr->relief);
+ if (framePtr->bgimg) {
+ DrawFrameBackground(tkwin, pixmap, hlWidth, framePtr->borderWidth,
+ framePtr->bgimg, framePtr->tile);
+ }
} else {
Labelframe *labelframePtr = (Labelframe *) framePtr;
@@ -1472,20 +1553,6 @@ DisplayFrame(
goto noLabel;
}
-#ifndef TK_NO_DOUBLE_BUFFERING
- /*
- * In order to avoid screen flashes, this function redraws the frame
- * into off-screen memory, then copies it back on-screen in a single
- * operation. This means there's no point in time where the on-screen
- * image has been cleared.
- */
-
- pixmap = Tk_GetPixmap(framePtr->display, Tk_WindowId(tkwin),
- Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin));
-#else
- pixmap = Tk_WindowId(tkwin);
-#endif /* TK_NO_DOUBLE_BUFFERING */
-
/*
* Clear the pixmap.
*/
@@ -1597,22 +1664,54 @@ DisplayFrame(
labelframePtr->labelBox.height);
}
}
+ }
#ifndef TK_NO_DOUBLE_BUFFERING
- /*
- * Everything's been redisplayed; now copy the pixmap onto the screen
- * and free up the pixmap.
- */
+ /*
+ * Everything's been redisplayed; now copy the pixmap onto the screen and
+ * free up the pixmap.
+ */
- XCopyArea(framePtr->display, pixmap, Tk_WindowId(tkwin),
- labelframePtr->textGC, hlWidth, hlWidth,
- (unsigned) (Tk_Width(tkwin) - 2 * hlWidth),
- (unsigned) (Tk_Height(tkwin) - 2 * hlWidth),
- hlWidth, hlWidth);
- Tk_FreePixmap(framePtr->display, pixmap);
+ XCopyArea(framePtr->display, pixmap, Tk_WindowId(tkwin),
+ framePtr->copyGC, hlWidth, hlWidth,
+ (unsigned) (Tk_Width(tkwin) - 2 * hlWidth),
+ (unsigned) (Tk_Height(tkwin) - 2 * hlWidth),
+ hlWidth, hlWidth);
+ Tk_FreePixmap(framePtr->display, pixmap);
#endif /* TK_NO_DOUBLE_BUFFERING */
- }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpDrawFrame --
+ *
+ * This procedure draws the rectangular frame area.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Draws inside the tkwin area.
+ *
+ *----------------------------------------------------------------------
+ */
+void
+TkpDrawFrame(
+ Tk_Window tkwin,
+ Tk_3DBorder border,
+ int highlightWidth,
+ int borderWidth,
+ int relief)
+{
+ /*
+ * Legacy shim to allow for external callers. Internal ones use
+ * non-exposed TkpDrawFrameEx directly so they can use double-buffering.
+ */
+
+ TkpDrawFrameEx(tkwin, Tk_WindowId(tkwin), border,
+ highlightWidth, borderWidth, relief);
}
/*
@@ -1637,9 +1736,9 @@ DisplayFrame(
static void
FrameEventProc(
ClientData clientData, /* Information about window. */
- register XEvent *eventPtr) /* Information about event. */
+ XEvent *eventPtr) /* Information about event. */
{
- register Frame *framePtr = clientData;
+ Frame *framePtr = (Frame *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
goto redraw;
@@ -1731,7 +1830,7 @@ static void
FrameCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- Frame *framePtr = clientData;
+ Frame *framePtr = (Frame *)clientData;
Tk_Window tkwin = framePtr->tkwin;
if (framePtr->menuName != NULL) {
@@ -1782,7 +1881,7 @@ static void
MapFrame(
ClientData clientData) /* Pointer to frame structure. */
{
- Frame *framePtr = clientData;
+ Frame *framePtr = (Frame *)clientData;
/*
* Wait for all other background events to be processed before mapping
@@ -1837,7 +1936,7 @@ TkInstallFrameMenu(
TkWindow *winPtr = (TkWindow *) tkwin;
if (winPtr->mainPtr != NULL) {
- Frame *framePtr = winPtr->instanceData;
+ Frame *framePtr = (Frame *)winPtr->instanceData;
if (framePtr == NULL) {
Tcl_Panic("TkInstallFrameMenu couldn't get frame pointer");
@@ -1870,7 +1969,7 @@ FrameStructureProc(
ClientData clientData, /* Pointer to record describing frame. */
XEvent *eventPtr) /* Describes what just happened. */
{
- Labelframe *labelframePtr = clientData;
+ Labelframe *labelframePtr = (Labelframe *)clientData;
if (eventPtr->type == DestroyNotify) {
/*
@@ -1908,7 +2007,8 @@ FrameRequestProc(
ClientData clientData, /* Pointer to record for frame. */
Tk_Window tkwin) /* Window that changed its desired size. */
{
- Frame *framePtr = clientData;
+ Frame *framePtr = (Frame *)clientData;
+ (void)tkwin;
FrameWorldChanged(framePtr);
}
@@ -1936,8 +2036,9 @@ FrameLostSlaveProc(
* stolen away. */
Tk_Window tkwin) /* Tk's handle for the slave window. */
{
- Frame *framePtr = clientData;
- Labelframe *labelframePtr = clientData;
+ Frame *framePtr = (Frame *)clientData;
+ Labelframe *labelframePtr = (Labelframe *)clientData;
+ (void)tkwin;
/*
* This should only happen in a labelframe but it doesn't hurt to be
@@ -1960,7 +2061,7 @@ void
TkMapTopFrame(
Tk_Window tkwin)
{
- Frame *framePtr = ((TkWindow *) tkwin)->instanceData;
+ Frame *framePtr = (Frame *)((TkWindow *) tkwin)->instanceData;
Tk_OptionTable optionTable;
if (Tk_IsTopLevel(tkwin) && framePtr->type == TYPE_FRAME) {
@@ -2024,7 +2125,7 @@ TkToplevelWindowForCommand(
if (cmdInfo.objProc != FrameWidgetObjCmd) {
return NULL;
}
- framePtr = cmdInfo.objClientData;
+ framePtr = (Frame *)cmdInfo.objClientData;
if (framePtr->type != TYPE_TOPLEVEL) {
return NULL;
}
@@ -2032,6 +2133,135 @@ TkToplevelWindowForCommand(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * FrameBgImageProc --
+ *
+ * This function is invoked by the image code whenever the manager for an
+ * image does something that affects the size or contents of an image
+ * displayed on a frame's background.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Arranges for the button to get redisplayed.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+FrameBgImageProc(
+ ClientData clientData, /* Pointer to widget record. */
+ int x, int y, /* Upper left pixel (within image) that must
+ * be redisplayed. */
+ int width, int height, /* Dimensions of area to redisplay (might be
+ * <= 0). */
+ int imgWidth, int imgHeight)/* New dimensions of image. */
+{
+ Frame *framePtr = (Frame *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
+
+
+ /*
+ * Changing the background image never alters the dimensions of the frame.
+ */
+
+ if (framePtr->tkwin && Tk_IsMapped(framePtr->tkwin) &&
+ !(framePtr->flags & REDRAW_PENDING)) {
+ Tcl_DoWhenIdle(DisplayFrame, framePtr);
+ framePtr->flags |= REDRAW_PENDING;
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * DrawFrameBackground --
+ *
+ * This function draws the background image of a rectangular frame area.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Draws inside the tkwin area.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+DrawFrameBackground(
+ Tk_Window tkwin,
+ Pixmap pixmap,
+ int highlightWidth,
+ int borderWidth,
+ Tk_Image bgimg,
+ int bgtile)
+{
+ int width, height; /* Area to paint on. */
+ int imageWidth, imageHeight; /* Dimensions of image. */
+ const int bw = highlightWidth + borderWidth;
+
+ Tk_SizeOfImage(bgimg, &imageWidth, &imageHeight);
+ width = Tk_Width(tkwin) - 2*bw;
+ height = Tk_Height(tkwin) - 2*bw;
+
+ if (bgtile) {
+ /*
+ * Draw the image tiled in the widget (inside the border).
+ */
+
+ int x, y;
+
+ for (x = bw; x - bw < width; x += imageWidth) {
+ int w = imageWidth;
+ if (x - bw + imageWidth > width) {
+ w = (width + bw) - x;
+ }
+ for (y = bw; y < height + bw; y += imageHeight) {
+ int h = imageHeight;
+ if (y - bw + imageHeight > height) {
+ h = (height + bw) - y;
+ }
+ Tk_RedrawImage(bgimg, 0, 0, w, h, pixmap, x, y);
+ }
+ }
+ } else {
+ /*
+ * Draw the image centred in the widget (inside the border).
+ */
+
+ int x, y, xOff, yOff, w, h;
+
+ if (width > imageWidth) {
+ x = 0;
+ xOff = (Tk_Width(tkwin) - imageWidth) / 2;
+ w = imageWidth;
+ } else {
+ x = (imageWidth - width) / 2;
+ xOff = bw;
+ w = width;
+ }
+ if (height > imageHeight) {
+ y = 0;
+ yOff = (Tk_Height(tkwin) - imageHeight) / 2;
+ h = imageHeight;
+ } else {
+ y = (imageHeight - height) / 2;
+ yOff = bw;
+ h = height;
+ }
+ Tk_RedrawImage(bgimg, x, y, w, h, pixmap, xOff, yOff);
+ }
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/generic/tkGC.c b/generic/tkGC.c
index 4caa046..47931a6 100644
--- a/generic/tkGC.c
+++ b/generic/tkGC.c
@@ -66,17 +66,17 @@ static void GCInit(TkDisplay *dispPtr);
GC
Tk_GetGC(
Tk_Window tkwin, /* Window in which GC will be used. */
- register unsigned long valueMask,
+ unsigned long valueMask,
/* 1 bits correspond to values specified in
* *valuesPtr; other values are set from
* defaults. */
- register XGCValues *valuePtr)
+ XGCValues *valuePtr)
/* Values are specified here for bits set in
* valueMask. */
{
ValueKey valueKey;
Tcl_HashEntry *valueHashPtr, *idHashPtr;
- register TkGC *gcPtr;
+ TkGC *gcPtr;
int isNew;
Drawable d, freeDrawable;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -218,7 +218,7 @@ Tk_GetGC(
valueHashPtr = Tcl_CreateHashEntry(&dispPtr->gcValueTable,
(char *) &valueKey, &isNew);
if (!isNew) {
- gcPtr = Tcl_GetHashValue(valueHashPtr);
+ gcPtr = (TkGC *)Tcl_GetHashValue(valueHashPtr);
gcPtr->refCount++;
return gcPtr->gc;
}
@@ -228,7 +228,7 @@ Tk_GetGC(
* and add a new structure to the database.
*/
- gcPtr = ckalloc(sizeof(TkGC));
+ gcPtr = (TkGC *)ckalloc(sizeof(TkGC));
/*
* Find or make a drawable to use to specify the screen and depth of the
@@ -291,7 +291,7 @@ Tk_FreeGC(
GC gc) /* Graphics context to be released. */
{
Tcl_HashEntry *idHashPtr;
- register TkGC *gcPtr;
+ TkGC *gcPtr;
TkDisplay *dispPtr = TkGetDisplay(display);
if (!dispPtr->gcInit) {
@@ -311,7 +311,7 @@ Tk_FreeGC(
if (idHashPtr == NULL) {
Tcl_Panic("Tk_FreeGC received unknown gc argument");
}
- gcPtr = Tcl_GetHashValue(idHashPtr);
+ gcPtr = (TkGC *)Tcl_GetHashValue(idHashPtr);
if (gcPtr->refCount-- <= 1) {
XFreeGC(gcPtr->display, gcPtr->gc);
Tcl_DeleteHashEntry(gcPtr->valueHashPtr);
@@ -347,7 +347,7 @@ TkGCCleanup(
for (entryPtr = Tcl_FirstHashEntry(&dispPtr->gcIdTable, &search);
entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) {
- gcPtr = Tcl_GetHashValue(entryPtr);
+ gcPtr = (TkGC *)Tcl_GetHashValue(entryPtr);
XFreeGC(gcPtr->display, gcPtr->gc);
Tcl_DeleteHashEntry(gcPtr->valueHashPtr);
diff --git a/generic/tkGeometry.c b/generic/tkGeometry.c
index eab3850..30a57a9 100644
--- a/generic/tkGeometry.c
+++ b/generic/tkGeometry.c
@@ -90,7 +90,7 @@ Tk_ManageGeometry(
ClientData clientData) /* Arbitrary one-word argument to pass to
* geometry manager procedures. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
if ((winPtr->geomMgrPtr != NULL) && (mgrPtr != NULL)
&& ((winPtr->geomMgrPtr != mgrPtr)
@@ -132,7 +132,7 @@ Tk_GeometryRequest(
int reqWidth, int reqHeight)/* Minimum desired dimensions for window, in
* pixels. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
/*
* X gets very upset if a window requests a width or height of zero, so
@@ -182,8 +182,8 @@ Tk_SetInternalBorderEx(
int left, int right, /* Width of internal border, in pixels. */
int top, int bottom)
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
- register int changed = 0;
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ int changed = 0;
if (left < 0) {
left = 0;
@@ -220,13 +220,12 @@ Tk_SetInternalBorderEx(
/*
* All the slaves for which this is the master window must now be
* repositioned to take account of the new internal border width. To
- * signal all the geometry managers to do this, just resize the window to
- * its current size. The ConfigureNotify event will cause geometry
- * managers to recompute everything.
+ * signal all the geometry managers to do this, trigger a ConfigureNotify
+ * event. This will cause geometry managers to recompute everything.
*/
if (changed) {
- Tk_ResizeWindow(tkwin, Tk_Width(tkwin), Tk_Height(tkwin));
+ TkDoConfigureNotify(winPtr);
}
}
@@ -280,7 +279,7 @@ Tk_SetMinimumRequestSize(
Tk_Window tkwin, /* Window that will have internal border. */
int minWidth, int minHeight)/* Minimum requested size, in pixels. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
if ((winPtr->minReqWidth == minWidth) &&
(winPtr->minReqHeight == minHeight)) {
@@ -325,25 +324,25 @@ TkSetGeometryMaster(
* set. */
const char *master) /* The master identity. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
- if (winPtr->geometryMaster != NULL &&
- strcmp(winPtr->geometryMaster, master) == 0) {
+ if (winPtr->geomMgrName != NULL &&
+ strcmp(winPtr->geomMgrName, master) == 0) {
return TCL_OK;
}
- if (winPtr->geometryMaster != NULL) {
+ if (winPtr->geomMgrName != NULL) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"cannot use geometry manager %s inside %s which already"
" has slaves managed by %s",
- master, Tk_PathName(tkwin), winPtr->geometryMaster));
+ master, Tk_PathName(tkwin), winPtr->geomMgrName));
Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "FIGHT", NULL);
}
return TCL_ERROR;
}
- winPtr->geometryMaster = ckalloc(strlen(master) + 1);
- strcpy(winPtr->geometryMaster, master);
+ winPtr->geomMgrName = (char *)ckalloc(strlen(master) + 1);
+ strcpy(winPtr->geomMgrName, master);
return TCL_OK;
}
@@ -370,16 +369,16 @@ TkFreeGeometryMaster(
* cleared. */
const char *master) /* The master identity. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
- if (winPtr->geometryMaster != NULL &&
- strcmp(winPtr->geometryMaster, master) != 0) {
+ if (winPtr->geomMgrName != NULL &&
+ strcmp(winPtr->geomMgrName, master) != 0) {
Tcl_Panic("Trying to free %s from geometry manager %s",
- winPtr->geometryMaster, master);
+ winPtr->geomMgrName, master);
}
- if (winPtr->geometryMaster != NULL) {
- ckfree(winPtr->geometryMaster);
- winPtr->geometryMaster = NULL;
+ if (winPtr->geomMgrName != NULL) {
+ ckfree(winPtr->geomMgrName);
+ winPtr->geomMgrName = NULL;
}
}
@@ -420,11 +419,14 @@ Tk_MaintainGeometry(
{
Tcl_HashEntry *hPtr;
MaintainMaster *masterPtr;
- register MaintainSlave *slavePtr;
+ MaintainSlave *slavePtr;
int isNew, map;
Tk_Window ancestor, parent;
TkDisplay *dispPtr = ((TkWindow *) master)->dispPtr;
+ ((TkWindow *)slave)->maintainerPtr = (TkWindow *)master;
+
+ ((TkWindow *)slave)->maintainerPtr = (TkWindow *)master;
if (master == Tk_Parent(slave)) {
/*
* If the slave is a direct descendant of the master, don't bother
@@ -461,9 +463,9 @@ Tk_MaintainGeometry(
hPtr = Tcl_CreateHashEntry(&dispPtr->maintainHashTable,
(char *) master, &isNew);
if (!isNew) {
- masterPtr = Tcl_GetHashValue(hPtr);
+ masterPtr = (MaintainMaster *)Tcl_GetHashValue(hPtr);
} else {
- masterPtr = ckalloc(sizeof(MaintainMaster));
+ masterPtr = (MaintainMaster *)ckalloc(sizeof(MaintainMaster));
masterPtr->ancestor = master;
masterPtr->checkScheduled = 0;
masterPtr->slavePtr = NULL;
@@ -481,7 +483,7 @@ Tk_MaintainGeometry(
goto gotSlave;
}
}
- slavePtr = ckalloc(sizeof(MaintainSlave));
+ slavePtr = (MaintainSlave *)ckalloc(sizeof(MaintainSlave));
slavePtr->slave = slave;
slavePtr->master = master;
slavePtr->nextPtr = masterPtr->slavePtr;
@@ -566,10 +568,13 @@ Tk_UnmaintainGeometry(
{
Tcl_HashEntry *hPtr;
MaintainMaster *masterPtr;
- register MaintainSlave *slavePtr, *prevPtr;
+ MaintainSlave *slavePtr, *prevPtr;
Tk_Window ancestor;
TkDisplay *dispPtr = ((TkWindow *) slave)->dispPtr;
+ ((TkWindow *)slave)->maintainerPtr = NULL;
+
+ ((TkWindow *)slave)->maintainerPtr = NULL;
if (master == Tk_Parent(slave)) {
/*
* If the slave is a direct descendant of the master,
@@ -591,7 +596,7 @@ Tk_UnmaintainGeometry(
if (hPtr == NULL) {
return;
}
- masterPtr = Tcl_GetHashValue(hPtr);
+ masterPtr = (MaintainMaster *)Tcl_GetHashValue(hPtr);
slavePtr = masterPtr->slavePtr;
if (slavePtr->slave == slave) {
masterPtr->slavePtr = slavePtr->nextPtr;
@@ -655,7 +660,7 @@ MaintainMasterProc(
* master window. */
XEvent *eventPtr) /* Describes what just happened. */
{
- MaintainMaster *masterPtr = clientData;
+ MaintainMaster *masterPtr = (MaintainMaster *)clientData;
MaintainSlave *slavePtr;
int done;
@@ -709,7 +714,7 @@ MaintainSlaveProc(
* master-slave pair. */
XEvent *eventPtr) /* Describes what just happened. */
{
- MaintainSlave *slavePtr = clientData;
+ MaintainSlave *slavePtr = (MaintainSlave *)clientData;
if (eventPtr->type == DestroyNotify) {
Tk_UnmaintainGeometry(slavePtr->slave, slavePtr->master);
@@ -741,7 +746,7 @@ MaintainCheckProc(
ClientData clientData) /* Pointer to MaintainMaster structure for the
* master window. */
{
- MaintainMaster *masterPtr = clientData;
+ MaintainMaster *masterPtr = (MaintainMaster *)clientData;
MaintainSlave *slavePtr;
Tk_Window ancestor, parent;
int x, y, map;
diff --git a/generic/tkGet.c b/generic/tkGet.c
index d58b4a5..7ca4d17 100644
--- a/generic/tkGet.c
+++ b/generic/tkGet.c
@@ -22,7 +22,7 @@
* the current thread.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
int initialized;
Tcl_HashTable uidTable;
} ThreadSpecificData;
@@ -493,10 +493,11 @@ Tk_NameOfJustify(
static void
FreeUidThreadExitProc(
- ClientData clientData) /* Not used. */
+ ClientData dummy) /* Not used. */
{
- ThreadSpecificData *tsdPtr =
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
Tcl_DeleteHashTable(&tsdPtr->uidTable);
tsdPtr->initialized = 0;
@@ -529,7 +530,7 @@ Tk_GetUid(
const char *string) /* String to convert. */
{
int dummy;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashTable *tablePtr = &tsdPtr->uidTable;
diff --git a/generic/tkGrab.c b/generic/tkGrab.c
index ff5d083..012d434 100644
--- a/generic/tkGrab.c
+++ b/generic/tkGrab.c
@@ -135,17 +135,6 @@ typedef struct NewGrabWinEvent {
#define GENERATED_GRAB_EVENT_MAGIC ((Bool) 0x147321ac)
/*
- * Mask that selects any of the state bits corresponding to buttons, plus
- * masks that select individual buttons' bits:
- */
-
-#define ALL_BUTTONS \
- (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
-static const unsigned int buttonStates[] = {
- Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
-};
-
-/*
* Forward declarations for functions declared later in this file:
*/
@@ -177,7 +166,6 @@ static void ReleaseButtonGrab(TkDisplay *dispPtr);
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
Tk_GrabObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
@@ -190,7 +178,7 @@ Tk_GrabObjCmd(
TkDisplay *dispPtr;
const char *arg;
int index;
- size_t len;
+ TkSizeT len;
static const char *const optionStrings[] = {
"current", "release", "set", "status", NULL
};
@@ -234,7 +222,7 @@ Tk_GrabObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "?-global? window");
return TCL_ERROR;
}
- tkwin = Tk_NameToWindow(interp, arg, clientData);
+ tkwin = Tk_NameToWindow(interp, arg, (Tk_Window)clientData);
if (tkwin == NULL) {
return TCL_ERROR;
}
@@ -250,7 +238,7 @@ Tk_GrabObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "?-global? window");
return TCL_ERROR;
}
- tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), clientData);
+ tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), (Tk_Window)clientData);
if (tkwin == NULL) {
return TCL_ERROR;
}
@@ -276,7 +264,7 @@ Tk_GrabObjCmd(
}
if (objc == 3) {
tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]),
- clientData);
+ (Tk_Window)clientData);
if (tkwin == NULL) {
return TCL_ERROR;
}
@@ -305,7 +293,7 @@ Tk_GrabObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "release window");
return TCL_ERROR;
}
- tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), clientData);
+ tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), (Tk_Window)clientData);
if (tkwin == NULL) {
Tcl_ResetResult(interp);
} else {
@@ -322,7 +310,7 @@ Tk_GrabObjCmd(
if (objc == 3) {
globalGrab = 0;
tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]),
- clientData);
+ (Tk_Window)clientData);
} else {
globalGrab = 1;
@@ -338,7 +326,7 @@ Tk_GrabObjCmd(
return TCL_ERROR;
}
tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[3]),
- clientData);
+ (Tk_Window)clientData);
}
if (tkwin == NULL) {
return TCL_ERROR;
@@ -355,7 +343,7 @@ Tk_GrabObjCmd(
return TCL_ERROR;
}
winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]),
- clientData);
+ (Tk_Window)clientData);
if (winPtr == NULL) {
return TCL_ERROR;
}
@@ -649,7 +637,7 @@ Tk_Ungrab(
static void
ReleaseButtonGrab(
- register TkDisplay *dispPtr)/* Display whose button grab is to be
+ TkDisplay *dispPtr)/* Display whose button grab is to be
* released. */
{
unsigned int serial;
@@ -695,11 +683,11 @@ ReleaseButtonGrab(
int
TkPointerEvent(
- register XEvent *eventPtr, /* Pointer to the event. */
+ XEvent *eventPtr, /* Pointer to the event. */
TkWindow *winPtr) /* Tk's information for window where event was
* reported. */
{
- register TkWindow *winPtr2;
+ TkWindow *winPtr2;
TkDisplay *dispPtr = winPtr->dispPtr;
unsigned int serial;
int outsideGrabTree = 0;
@@ -881,8 +869,9 @@ TkPointerEvent(
return 1;
}
} else {
- if ((eventPtr->xbutton.state & ALL_BUTTONS)
- == buttonStates[eventPtr->xbutton.button - Button1]) {
+ if (eventPtr->xbutton.button != AnyButton &&
+ ((eventPtr->xbutton.state & ALL_BUTTONS)
+ == TkGetButtonMask(eventPtr->xbutton.button))) {
ReleaseButtonGrab(dispPtr); /* Note 4. */
}
}
@@ -917,14 +906,14 @@ TkPointerEvent(
void
TkChangeEventWindow(
- register XEvent *eventPtr, /* Event to retarget. Must have type
+ XEvent *eventPtr, /* Event to retarget. Must have type
* ButtonPress, ButtonRelease, KeyPress,
* KeyRelease, MotionNotify, EnterNotify, or
* LeaveNotify. */
TkWindow *winPtr) /* New target window for event. */
{
int x, y, sameScreen, bd;
- register TkWindow *childPtr;
+ TkWindow *childPtr;
eventPtr->xmotion.window = Tk_WindowId(winPtr);
if (eventPtr->xmotion.root ==
@@ -1005,7 +994,7 @@ TkInOutEvents(
Tcl_QueuePosition position) /* Position at which events are added to the
* system event queue. */
{
- register TkWindow *winPtr;
+ TkWindow *winPtr;
int upLevels, downLevels, i, j, focus;
/*
@@ -1198,7 +1187,7 @@ MovePointer2(
void
TkGrabDeadWindow(
- register TkWindow *winPtr) /* Window that is in the process of being
+ TkWindow *winPtr) /* Window that is in the process of being
* deleted. */
{
TkDisplay *dispPtr = winPtr->dispPtr;
@@ -1288,7 +1277,7 @@ GrabRestrictProc(
ClientData arg,
XEvent *eventPtr)
{
- GrabInfo *info = arg;
+ GrabInfo *info = (GrabInfo *)arg;
int mode, diff;
/*
@@ -1346,7 +1335,7 @@ QueueGrabWindowChange(
{
NewGrabWinEvent *grabEvPtr;
- grabEvPtr = ckalloc(sizeof(NewGrabWinEvent));
+ grabEvPtr = (NewGrabWinEvent *)ckalloc(sizeof(NewGrabWinEvent));
grabEvPtr->header.proc = GrabWinEventProc;
grabEvPtr->dispPtr = dispPtr;
if (grabWinPtr == NULL) {
@@ -1381,11 +1370,12 @@ QueueGrabWindowChange(
static int
GrabWinEventProc(
Tcl_Event *evPtr, /* Event of type NewGrabWinEvent. */
- int flags) /* Flags argument to Tk_DoOneEvent: indicates
+ int flags) /* Flags argument to Tcl_DoOneEvent: indicates
* what kinds of events are being processed
* right now. */
{
NewGrabWinEvent *grabEvPtr = (NewGrabWinEvent *) evPtr;
+ (void)flags;
grabEvPtr->dispPtr->grabWinPtr = (TkWindow *) Tk_IdToWindow(
grabEvPtr->dispPtr->display, grabEvPtr->grabWindow);
@@ -1426,7 +1416,7 @@ FindCommonAncestor(
int *countPtr2) /* Store nesting level of winPtr2 within
* common ancestor here. */
{
- register TkWindow *winPtr;
+ TkWindow *winPtr;
TkWindow *ancestorPtr;
int count1, count2, i;
diff --git a/generic/tkGrid.c b/generic/tkGrid.c
index c632793..32246ae 100644
--- a/generic/tkGrid.c
+++ b/generic/tkGrid.c
@@ -292,8 +292,8 @@ static void GridLostSlaveProc(ClientData clientData,
Tk_Window tkwin);
static void GridReqProc(ClientData clientData, Tk_Window tkwin);
static void InitMasterData(Gridder *masterPtr);
-static Tcl_Obj * NewPairObj(int, int);
-static Tcl_Obj * NewQuadObj(int, int, int, int);
+static Tcl_Obj * NewPairObj(Tcl_WideInt, Tcl_WideInt);
+static Tcl_Obj * NewQuadObj(Tcl_WideInt, Tcl_WideInt, Tcl_WideInt, Tcl_WideInt);
static int ResolveConstraints(Gridder *gridPtr, int rowOrColumn,
int maxOffset);
static void SetGridSize(Gridder *gridPtr);
@@ -335,7 +335,7 @@ Tk_GridObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
static const char *const optionStrings[] = {
"anchor", "bbox", "columnconfigure", "configure",
"forget", "info", "location", "propagate", "remove",
@@ -720,7 +720,7 @@ GridInfoCommand(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Gridder *slavePtr;
+ Gridder *slavePtr;
Tk_Window slave;
Tcl_Obj *infoObj;
@@ -741,13 +741,13 @@ GridInfoCommand(
Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", -1),
TkNewWindowObj(slavePtr->masterPtr->tkwin));
Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-column", -1),
- Tcl_NewIntObj(slavePtr->column));
+ Tcl_NewWideIntObj(slavePtr->column));
Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-row", -1),
- Tcl_NewIntObj(slavePtr->row));
+ Tcl_NewWideIntObj(slavePtr->row));
Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-columnspan", -1),
- Tcl_NewIntObj(slavePtr->numCols));
+ Tcl_NewWideIntObj(slavePtr->numCols));
Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-rowspan", -1),
- Tcl_NewIntObj(slavePtr->numRows));
+ Tcl_NewWideIntObj(slavePtr->numRows));
TkAppendPadAmount(infoObj, "-ipadx", slavePtr->iPadX/2, slavePtr->iPadX);
TkAppendPadAmount(infoObj, "-ipady", slavePtr->iPadY/2, slavePtr->iPadY);
TkAppendPadAmount(infoObj, "-padx", slavePtr->padLeft, slavePtr->padX);
@@ -785,7 +785,7 @@ GridLocationCommand(
Tk_Window master;
Gridder *masterPtr; /* Master grid record. */
GridMaster *gridPtr; /* Pointer to grid data. */
- register SlotInfo *slotPtr;
+ SlotInfo *slotPtr;
int x, y; /* Offset in pixels, from edge of master. */
int i, j; /* Corresponding column and row indeces. */
int endX, endY; /* End of grid. */
@@ -1010,8 +1010,8 @@ GridRowColumnConfigureCommand(
}
masterPtr = GetGrid(master);
- first = 0; /* lint */
- last = 0; /* lint */
+ first = 0;
+ last = 0;
if ((objc == 4) || (objc == 5)) {
if (lObjc != 1) {
@@ -1055,17 +1055,17 @@ GridRowColumnConfigureCommand(
Tcl_ListObjAppendElement(interp, res,
Tcl_NewStringObj("-minsize", -1));
- Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(minsize));
+ Tcl_ListObjAppendElement(interp, res, Tcl_NewWideIntObj(minsize));
Tcl_ListObjAppendElement(interp, res,
Tcl_NewStringObj("-pad", -1));
- Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(pad));
+ Tcl_ListObjAppendElement(interp, res, Tcl_NewWideIntObj(pad));
Tcl_ListObjAppendElement(interp, res,
Tcl_NewStringObj("-uniform", -1));
Tcl_ListObjAppendElement(interp, res,
Tcl_NewStringObj(uniform == NULL ? "" : uniform, -1));
Tcl_ListObjAppendElement(interp, res,
Tcl_NewStringObj("-weight", -1));
- Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(weight));
+ Tcl_ListObjAppendElement(interp, res, Tcl_NewWideIntObj(weight));
Tcl_SetObjResult(interp, res);
Tcl_DecrRefCount(listCopy);
return TCL_OK;
@@ -1082,10 +1082,10 @@ GridRowColumnConfigureCommand(
return TCL_ERROR;
}
if (index == ROWCOL_MINSIZE) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
(ok == TCL_OK) ? slotPtr[slot].minSize : 0));
} else if (index == ROWCOL_WEIGHT) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
(ok == TCL_OK) ? slotPtr[slot].weight : 0));
} else if (index == ROWCOL_UNIFORM) {
Tk_Uid value = (ok == TCL_OK) ? slotPtr[slot].uniform : "";
@@ -1093,7 +1093,7 @@ GridRowColumnConfigureCommand(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
(value == NULL) ? "" : value, -1));
} else if (index == ROWCOL_PAD) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
(ok == TCL_OK) ? slotPtr[slot].pad : 0));
}
Tcl_DecrRefCount(listCopy);
@@ -1431,7 +1431,8 @@ GridReqProc(
Tk_Window tkwin) /* Other Tk-related information about the
* window. */
{
- register Gridder *gridPtr = clientData;
+ Gridder *gridPtr = (Gridder *)clientData;
+ (void)tkwin;
gridPtr = gridPtr->masterPtr;
if (gridPtr && !(gridPtr->flags & REQUESTED_RELAYOUT)) {
@@ -1463,7 +1464,8 @@ GridLostSlaveProc(
* stolen away. */
Tk_Window tkwin) /* Tk's handle for the slave window. */
{
- register Gridder *slavePtr = clientData;
+ Gridder *slavePtr = (Gridder *)clientData;
+ (void)tkwin;
if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin);
@@ -1496,9 +1498,9 @@ static int
AdjustOffsets(
int size, /* The total layout size (in pixels). */
int slots, /* Number of slots. */
- register SlotInfo *slotPtr) /* Pointer to slot array. */
+ SlotInfo *slotPtr) /* Pointer to slot array. */
{
- register int slot; /* Current slot. */
+ int slot; /* Current slot. */
int diff; /* Extra pixels needed to add to the layout. */
int totalWeight; /* Sum of the weights for all the slots. */
int weight; /* Sum of the weights so far. */
@@ -1721,8 +1723,8 @@ ArrangeGrid(
ClientData clientData) /* Structure describing master whose slaves
* are to be re-layed out. */
{
- register Gridder *masterPtr = clientData;
- register Gridder *slavePtr;
+ Gridder *masterPtr = (Gridder *)clientData;
+ Gridder *slavePtr;
GridMaster *slotPtr = masterPtr->masterDataPtr;
int abort;
int width, height; /* Requested size of layout, in pixels. */
@@ -1902,8 +1904,8 @@ ResolveConstraints(
int maxOffset) /* The actual maximum size of this layout in
* pixels, or 0 (not currently used). */
{
- register SlotInfo *slotPtr; /* Pointer to row/col constraints. */
- register Gridder *slavePtr; /* List of slave windows in this grid. */
+ SlotInfo *slotPtr; /* Pointer to row/col constraints. */
+ Gridder *slavePtr; /* List of slave windows in this grid. */
int constraintCount; /* Count of rows or columns that have
* constraints. */
int slotCount; /* Last occupied row or column. */
@@ -1912,7 +1914,7 @@ ResolveConstraints(
GridLayout *layoutPtr; /* Temporary layout structure. */
int requiredSize; /* The natural size of the grid (pixels).
* This is the minimum size needed to
- * accomodate all of the slaves at their
+ * accommodate all of the slaves at their
* requested sizes. */
int offset; /* The pixel offset of the right edge of the
* current slot from the beginning of the
@@ -1955,7 +1957,7 @@ ResolveConstraints(
gridCount = MAX(constraintCount, slotCount);
if (gridCount >= TYPICAL_SIZE) {
- layoutPtr = ckalloc(sizeof(GridLayout) * (1+gridCount));
+ layoutPtr = (GridLayout *)ckalloc(sizeof(GridLayout) * (1+gridCount));
} else {
layoutPtr = layoutData;
}
@@ -2077,7 +2079,7 @@ ResolveConstraints(
* sizeof(UniformGroup);
size_t newSize = (uniformGroupsAlloced + UNIFORM_PREALLOC)
* sizeof(UniformGroup);
- UniformGroup *newUG = ckalloc(newSize);
+ UniformGroup *newUG = (UniformGroup *)ckalloc(newSize);
UniformGroup *oldUG = uniformGroupPtr;
memcpy(newUG, oldUG, oldSize);
@@ -2421,7 +2423,7 @@ GetGrid(
Tk_Window tkwin) /* Token for window for which grid structure
* is desired. */
{
- register Gridder *gridPtr;
+ Gridder *gridPtr;
Tcl_HashEntry *hPtr;
int isNew;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -2438,9 +2440,9 @@ GetGrid(
hPtr = Tcl_CreateHashEntry(&dispPtr->gridHashTable, (char*) tkwin, &isNew);
if (!isNew) {
- return Tcl_GetHashValue(hPtr);
+ return (Gridder *)Tcl_GetHashValue(hPtr);
}
- gridPtr = ckalloc(sizeof(Gridder));
+ gridPtr = (Gridder *)ckalloc(sizeof(Gridder));
gridPtr->tkwin = tkwin;
gridPtr->masterPtr = NULL;
gridPtr->masterDataPtr = NULL;
@@ -2485,7 +2487,7 @@ GetGrid(
* Side effects:
* The width and height arguments are filled in the master data
* structure. Additional space is allocated for the constraints to
- * accomodate the offsets.
+ * accommodate the offsets.
*
*----------------------------------------------------------------------
*/
@@ -2494,7 +2496,7 @@ static void
SetGridSize(
Gridder *masterPtr) /* The geometry master for this grid. */
{
- register Gridder *slavePtr; /* Current slave window. */
+ Gridder *slavePtr; /* Current slave window. */
int maxX = 0, maxY = 0;
for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
@@ -2650,7 +2652,7 @@ CheckSlotData(
int newNumSlot = slot + PREALLOC;
size_t oldSize = numSlot * sizeof(SlotInfo);
size_t newSize = newNumSlot * sizeof(SlotInfo);
- SlotInfo *newSI = ckalloc(newSize);
+ SlotInfo *newSI = (SlotInfo *)ckalloc(newSize);
SlotInfo *oldSI = (slotType == ROW)
? masterPtr->masterDataPtr->rowPtr
: masterPtr->masterDataPtr->columnPtr;
@@ -2700,17 +2702,17 @@ InitMasterData(
Gridder *masterPtr)
{
if (masterPtr->masterDataPtr == NULL) {
- GridMaster *gridPtr = masterPtr->masterDataPtr =
+ GridMaster *gridPtr = masterPtr->masterDataPtr = (GridMaster *)
ckalloc(sizeof(GridMaster));
size_t size = sizeof(SlotInfo) * TYPICAL_SIZE;
gridPtr->columnEnd = 0;
gridPtr->columnMax = 0;
- gridPtr->columnPtr = ckalloc(size);
+ gridPtr->columnPtr = (SlotInfo *)ckalloc(size);
gridPtr->columnSpace = TYPICAL_SIZE;
gridPtr->rowEnd = 0;
gridPtr->rowMax = 0;
- gridPtr->rowPtr = ckalloc(size);
+ gridPtr->rowPtr = (SlotInfo *)ckalloc(size);
gridPtr->rowSpace = TYPICAL_SIZE;
gridPtr->startX = 0;
gridPtr->startY = 0;
@@ -2740,9 +2742,9 @@ InitMasterData(
static void
Unlink(
- register Gridder *slavePtr) /* Window to unlink. */
+ Gridder *slavePtr) /* Window to unlink. */
{
- register Gridder *masterPtr, *slavePtr2;
+ Gridder *masterPtr, *slavePtr2;
masterPtr = slavePtr->masterPtr;
if (masterPtr == NULL) {
@@ -2812,7 +2814,7 @@ static void
DestroyGrid(
void *memPtr) /* Info about window that is now dead. */
{
- register Gridder *gridPtr = memPtr;
+ Gridder *gridPtr = (Gridder *)memPtr;
if (gridPtr->masterDataPtr != NULL) {
if (gridPtr->masterDataPtr->rowPtr != NULL) {
@@ -2853,7 +2855,7 @@ GridStructureProc(
* eventPtr. */
XEvent *eventPtr) /* Describes what just happened. */
{
- register Gridder *gridPtr = clientData;
+ Gridder *gridPtr = (Gridder *)clientData;
TkDisplay *dispPtr = ((TkWindow *) gridPtr->tkwin)->dispPtr;
if (eventPtr->type == ConfigureNotify) {
@@ -2871,7 +2873,7 @@ GridStructureProc(
}
}
} else if (eventPtr->type == DestroyNotify) {
- register Gridder *slavePtr, *nextPtr;
+ Gridder *slavePtr, *nextPtr;
if (gridPtr->masterPtr != NULL) {
Unlink(gridPtr);
@@ -2898,7 +2900,7 @@ GridStructureProc(
Tcl_DoWhenIdle(ArrangeGrid, gridPtr);
}
} else if (eventPtr->type == UnmapNotify) {
- register Gridder *slavePtr;
+ Gridder *slavePtr;
for (slavePtr = gridPtr->slavePtr; slavePtr != NULL;
slavePtr = slavePtr->nextPtr) {
@@ -2941,6 +2943,7 @@ ConfigureSlaves(
Gridder *masterPtr = NULL;
Gridder *slavePtr;
Tk_Window other, slave, parent, ancestor;
+ TkWindow *master;
int i, j, tmp;
int numWindows;
int width;
@@ -2968,7 +2971,7 @@ ConfigureSlaves(
firstChar = 0;
for (numWindows=0, i=0; i < objc; i++) {
- size_t length;
+ TkSizeT length;
char prevChar = firstChar;
string = TkGetStringFromObj(objv[i], &length);
@@ -3355,17 +3358,23 @@ ConfigureSlaves(
}
/*
- * Try to make sure our master isn't managed by us.
+ * Check for management loops.
*/
- if (masterPtr->masterPtr == slavePtr) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ for (master = (TkWindow *)masterPtr->tkwin; master != NULL;
+ master = (TkWindow *)TkGetGeomMaster(master)) {
+ if (master == (TkWindow *)slave) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't put %s inside %s, would cause management loop",
- Tcl_GetString(objv[j]), Tk_PathName(masterPtr->tkwin)));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
- Unlink(slavePtr);
- return TCL_ERROR;
- }
+ Tcl_GetString(objv[j]), Tk_PathName(masterPtr->tkwin)));
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
+ Unlink(slavePtr);
+ return TCL_ERROR;
+ }
+ }
+ if (masterPtr->tkwin != Tk_Parent(slave)) {
+ ((TkWindow *)slave)->maintainerPtr = (TkWindow *)masterPtr->tkwin;
+ }
Tk_ManageGeometry(slave, &gridMgrType, slavePtr);
@@ -3631,12 +3640,12 @@ StringToSticky(
static Tcl_Obj *
NewPairObj(
- int val1, int val2)
+ Tcl_WideInt val1, Tcl_WideInt val2)
{
Tcl_Obj *ary[2];
- ary[0] = Tcl_NewIntObj(val1);
- ary[1] = Tcl_NewIntObj(val2);
+ ary[0] = Tcl_NewWideIntObj(val1);
+ ary[1] = Tcl_NewWideIntObj(val2);
return Tcl_NewListObj(2, ary);
}
@@ -3658,14 +3667,14 @@ NewPairObj(
static Tcl_Obj *
NewQuadObj(
- int val1, int val2, int val3, int val4)
+ Tcl_WideInt val1, Tcl_WideInt val2, Tcl_WideInt val3, Tcl_WideInt val4)
{
Tcl_Obj *ary[4];
- ary[0] = Tcl_NewIntObj(val1);
- ary[1] = Tcl_NewIntObj(val2);
- ary[2] = Tcl_NewIntObj(val3);
- ary[3] = Tcl_NewIntObj(val4);
+ ary[0] = Tcl_NewWideIntObj(val1);
+ ary[1] = Tcl_NewWideIntObj(val2);
+ ary[2] = Tcl_NewWideIntObj(val3);
+ ary[3] = Tcl_NewWideIntObj(val4);
return Tcl_NewListObj(4, ary);
}
diff --git a/generic/tkImage.c b/generic/tkImage.c
index 32e09c0..1874d38 100644
--- a/generic/tkImage.c
+++ b/generic/tkImage.c
@@ -66,7 +66,7 @@ typedef struct ImageMaster {
* when the world is falling apart.) */
} ImageMaster;
-typedef struct ThreadSpecificData {
+typedef struct {
Tk_ImageType *imageTypeList;/* First in a list of all known image
* types. */
Tk_ImageType *oldImageTypeList;
@@ -104,11 +104,12 @@ static void EventuallyDeleteImage(ImageMaster *masterPtr,
static void
ImageTypeThreadExitProc(
- ClientData clientData) /* not used */
+ ClientData dummy) /* not used */
{
Tk_ImageType *freePtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
while (tsdPtr->oldImageTypeList != NULL) {
freePtr = tsdPtr->oldImageTypeList;
@@ -149,14 +150,14 @@ Tk_CreateOldImageType(
* by caller. */
{
Tk_ImageType *copyPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
tsdPtr->initialized = 1;
Tcl_CreateThreadExitHandler(ImageTypeThreadExitProc, NULL);
}
- copyPtr = ckalloc(sizeof(Tk_ImageType));
+ copyPtr = (Tk_ImageType *)ckalloc(sizeof(Tk_ImageType));
*copyPtr = *typePtr;
copyPtr->nextPtr = tsdPtr->oldImageTypeList;
tsdPtr->oldImageTypeList = copyPtr;
@@ -170,14 +171,14 @@ Tk_CreateImageType(
* by caller. */
{
Tk_ImageType *copyPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
tsdPtr->initialized = 1;
Tcl_CreateThreadExitHandler(ImageTypeThreadExitProc, NULL);
}
- copyPtr = ckalloc(sizeof(Tk_ImageType));
+ copyPtr = (Tk_ImageType *)ckalloc(sizeof(Tk_ImageType));
*copyPtr = *typePtr;
copyPtr->nextPtr = tsdPtr->imageTypeList;
tsdPtr->imageTypeList = copyPtr;
@@ -215,7 +216,7 @@ Tk_ImageObjCmd(
IMAGE_CREATE, IMAGE_DELETE, IMAGE_HEIGHT, IMAGE_INUSE, IMAGE_NAMES,
IMAGE_TYPE, IMAGE_TYPES, IMAGE_WIDTH
};
- TkWindow *winPtr = clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
int i, isNew, firstOption, index;
Tk_ImageType *typePtr;
ImageMaster *masterPtr;
@@ -226,7 +227,7 @@ Tk_ImageObjCmd(
TkDisplay *dispPtr = winPtr->dispPtr;
const char *arg, *name;
Tcl_Obj *resultObj;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (objc < 2) {
@@ -318,7 +319,7 @@ Tk_ImageObjCmd(
hPtr = Tcl_CreateHashEntry(&winPtr->mainPtr->imageTable, name, &isNew);
if (isNew) {
- masterPtr = ckalloc(sizeof(ImageMaster));
+ masterPtr = (ImageMaster *)ckalloc(sizeof(ImageMaster));
masterPtr->typePtr = NULL;
masterPtr->masterData = NULL;
masterPtr->width = masterPtr->height = 1;
@@ -335,7 +336,7 @@ Tk_ImageObjCmd(
* from the master.
*/
- masterPtr = Tcl_GetHashValue(hPtr);
+ masterPtr = (ImageMaster *)Tcl_GetHashValue(hPtr);
if (masterPtr->typePtr != NULL) {
for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
imagePtr = imagePtr->nextPtr) {
@@ -363,7 +364,7 @@ Tk_ImageObjCmd(
if (oldimage) {
int i;
- args = ckalloc((objc+1) * sizeof(char *));
+ args = (Tcl_Obj **)ckalloc((objc+1) * sizeof(Tcl_Obj *));
for (i = 0; i < objc; i++) {
args[i] = (Tcl_Obj *) Tcl_GetString(objv[i]);
}
@@ -390,7 +391,7 @@ Tk_ImageObjCmd(
masterPtr->masterData);
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1));
+ (const char *)Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1));
break;
}
case IMAGE_DELETE:
@@ -400,7 +401,7 @@ Tk_ImageObjCmd(
if (hPtr == NULL) {
goto alreadyDeleted;
}
- masterPtr = Tcl_GetHashValue(hPtr);
+ masterPtr = (ImageMaster *)Tcl_GetHashValue(hPtr);
if (masterPtr->deleted) {
goto alreadyDeleted;
}
@@ -415,12 +416,12 @@ Tk_ImageObjCmd(
hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search);
resultObj = Tcl_NewObj();
for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- masterPtr = Tcl_GetHashValue(hPtr);
+ masterPtr = (ImageMaster *)Tcl_GetHashValue(hPtr);
if (masterPtr->deleted) {
continue;
}
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
- Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1));
+ (const char *)Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1));
}
Tcl_SetObjResult(interp, resultObj);
break;
@@ -463,7 +464,7 @@ Tk_ImageObjCmd(
if (hPtr == NULL) {
goto alreadyDeleted;
}
- masterPtr = Tcl_GetHashValue(hPtr);
+ masterPtr = (ImageMaster *)Tcl_GetHashValue(hPtr);
if (masterPtr->deleted) {
goto alreadyDeleted;
}
@@ -474,7 +475,7 @@ Tk_ImageObjCmd(
switch ((enum options) index) {
case IMAGE_HEIGHT:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(masterPtr->height));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(masterPtr->height));
break;
case IMAGE_INUSE:
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
@@ -487,7 +488,7 @@ Tk_ImageObjCmd(
}
break;
case IMAGE_WIDTH:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(masterPtr->width));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(masterPtr->width));
break;
default:
Tcl_Panic("can't happen");
@@ -572,7 +573,7 @@ Tk_NameOfImage(
if (masterPtr->hPtr == NULL) {
return NULL;
}
- return Tcl_GetHashKey(masterPtr->tablePtr, masterPtr->hPtr);
+ return (const char *)Tcl_GetHashKey(masterPtr->tablePtr, masterPtr->hPtr);
}
/*
@@ -617,14 +618,14 @@ Tk_GetImage(
if (hPtr == NULL) {
goto noSuchImage;
}
- masterPtr = Tcl_GetHashValue(hPtr);
+ masterPtr = (ImageMaster *)Tcl_GetHashValue(hPtr);
if (masterPtr->typePtr == NULL) {
goto noSuchImage;
}
if (masterPtr->deleted) {
goto noSuchImage;
}
- imagePtr = ckalloc(sizeof(Image));
+ imagePtr = (Image *)ckalloc(sizeof(Image));
imagePtr->tkwin = tkwin;
imagePtr->display = Tk_Display(tkwin);
imagePtr->masterPtr = masterPtr;
@@ -933,7 +934,7 @@ Tk_DeleteImage(
if (hPtr == NULL) {
return;
}
- DeleteImage(Tcl_GetHashValue(hPtr));
+ DeleteImage((ImageMaster *)Tcl_GetHashValue(hPtr));
}
/*
@@ -1045,7 +1046,7 @@ TkDeleteAllImages(
for (hPtr = Tcl_FirstHashEntry(&mainPtr->imageTable, &search);
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- EventuallyDeleteImage(Tcl_GetHashValue(hPtr), 1);
+ EventuallyDeleteImage((ImageMaster *)Tcl_GetHashValue(hPtr), 1);
}
Tcl_DeleteHashTable(&mainPtr->imageTable);
}
@@ -1088,7 +1089,7 @@ Tk_GetImageMasterData(
*typePtrPtr = NULL;
return NULL;
}
- masterPtr = Tcl_GetHashValue(hPtr);
+ masterPtr = (ImageMaster *)Tcl_GetHashValue(hPtr);
if (masterPtr->deleted) {
*typePtrPtr = NULL;
return NULL;
@@ -1118,7 +1119,6 @@ Tk_GetImageMasterData(
*----------------------------------------------------------------------
*/
-/*ARGSUSED*/
void
Tk_SetTSOrigin(
Tk_Window tkwin,
diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c
index a3a94f9..a43d2b7 100644
--- a/generic/tkImgBmap.c
+++ b/generic/tkImgBmap.c
@@ -108,17 +108,17 @@ Tk_ImageType tkBitmapImageType = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_UID, "-background", NULL, NULL,
- "", Tk_Offset(BitmapMaster, bgUid), 0, NULL},
+ "", offsetof(BitmapMaster, bgUid), 0, NULL},
{TK_CONFIG_STRING, "-data", NULL, NULL,
- NULL, Tk_Offset(BitmapMaster, dataString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapMaster, dataString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_STRING, "-file", NULL, NULL,
- NULL, Tk_Offset(BitmapMaster, fileString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapMaster, fileString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_UID, "-foreground", NULL, NULL,
- "#000000", Tk_Offset(BitmapMaster, fgUid), 0, NULL},
+ "#000000", offsetof(BitmapMaster, fgUid), 0, NULL},
{TK_CONFIG_STRING, "-maskdata", NULL, NULL,
- NULL, Tk_Offset(BitmapMaster, maskDataString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapMaster, maskDataString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_STRING, "-maskfile", NULL, NULL,
- NULL, Tk_Offset(BitmapMaster, maskFileString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapMaster, maskFileString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -169,7 +169,6 @@ static int NextBitmapWord(ParseInfo *parseInfoPtr);
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ImgBmapCreate(
Tcl_Interp *interp, /* Interpreter for application containing
@@ -184,7 +183,8 @@ ImgBmapCreate(
ClientData *clientDataPtr) /* Store manager's token for image here; it
* will be returned in later callbacks. */
{
- BitmapMaster *masterPtr = ckalloc(sizeof(BitmapMaster));
+ BitmapMaster *masterPtr = (BitmapMaster *)ckalloc(sizeof(BitmapMaster));
+ (void)typePtr;
masterPtr->tkMaster = master;
masterPtr->interp = interp;
@@ -239,7 +239,7 @@ ImgBmapConfigureMaster(
{
BitmapInstance *instancePtr;
int maskWidth, maskHeight, dummy1, dummy2;
- const char **argv = ckalloc((objc+1) * sizeof(char *));
+ const char **argv = (const char **)ckalloc((objc+1) * sizeof(char *));
for (dummy1 = 0; dummy1 < objc; dummy1++) {
argv[dummy1] = Tcl_GetString(objv[dummy1]);
@@ -620,7 +620,7 @@ TkGetBitmapData(
goto error;
}
numBytes = ((width+7)/8) * height;
- data = ckalloc(numBytes);
+ data = (char *)ckalloc(numBytes);
for (p = data; numBytes > 0; p++, numBytes--) {
if (NextBitmapWord(&pi) != TCL_OK) {
goto error;
@@ -757,7 +757,7 @@ ImgBmapCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *const bmapOptions[] = {"cget", "configure", NULL};
- BitmapMaster *masterPtr = clientData;
+ BitmapMaster *masterPtr = (BitmapMaster *)clientData;
int index;
if (objc < 2) {
@@ -819,7 +819,7 @@ ImgBmapGet(
ClientData masterData) /* Pointer to our master structure for the
* image. */
{
- BitmapMaster *masterPtr = masterData;
+ BitmapMaster *masterPtr = (BitmapMaster *)masterData;
BitmapInstance *instancePtr;
/*
@@ -840,7 +840,7 @@ ImgBmapGet(
* the image.
*/
- instancePtr = ckalloc(sizeof(BitmapInstance));
+ instancePtr = (BitmapInstance *)ckalloc(sizeof(BitmapInstance));
instancePtr->refCount = 1;
instancePtr->masterPtr = masterPtr;
instancePtr->tkwin = tkwin;
@@ -894,7 +894,7 @@ ImgBmapDisplay(
/* Coordinates within drawable that correspond
* to imageX and imageY. */
{
- BitmapInstance *instancePtr = clientData;
+ BitmapInstance *instancePtr = (BitmapInstance *)clientData;
int masking;
/*
@@ -948,7 +948,7 @@ ImgBmapFree(
* instance to be displayed. */
Display *display) /* Display containing window that used image. */
{
- BitmapInstance *instancePtr = clientData;
+ BitmapInstance *instancePtr = (BitmapInstance *)clientData;
BitmapInstance *prevPtr;
if (instancePtr->refCount-- > 1) {
@@ -1009,7 +1009,7 @@ ImgBmapDelete(
ClientData masterData) /* Pointer to BitmapMaster structure for
* image. Must not have any more instances. */
{
- BitmapMaster *masterPtr = masterData;
+ BitmapMaster *masterPtr = (BitmapMaster *)masterData;
if (masterPtr->instancePtr != NULL) {
Tcl_Panic("tried to delete bitmap image when instances still exist");
@@ -1050,7 +1050,7 @@ ImgBmapCmdDeletedProc(
ClientData clientData) /* Pointer to BitmapMaster structure for
* image. */
{
- BitmapMaster *masterPtr = clientData;
+ BitmapMaster *masterPtr = (BitmapMaster *)clientData;
masterPtr->imageCmd = NULL;
if (masterPtr->tkMaster != NULL) {
@@ -1197,7 +1197,7 @@ ImgBmapPostscript(
int x, int y, int width, int height,
int prepass)
{
- BitmapMaster *masterPtr = clientData;
+ BitmapMaster *masterPtr = (BitmapMaster *)clientData;
Tcl_InterpState interpState;
Tcl_Obj *psObj;
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c
index e3fe8f6..3a66f28 100644
--- a/generic/tkImgGIF.c
+++ b/generic/tkImgGIF.c
@@ -63,9 +63,9 @@ typedef struct mFile {
* Most data in a GIF image is binary and is treated as such. However, a few
* key bits are stashed in ASCII. If we try to compare those pieces to the
* char they represent, it will fail on any non-ASCII (eg, EBCDIC) system. To
- * accomodate these systems, we test against the numeric value of the ASCII
+ * accommodate these systems, we test against the numeric value of the ASCII
* characters instead of the characters themselves. This is encoding
- * independant.
+ * independent.
*/
static const char GIF87a[] = { /* ASCII GIF87a */
@@ -353,9 +353,12 @@ FileMatchGIF(
int *widthPtr, int *heightPtr,
/* The dimensions of the image are returned
* here if the file is a valid raw GIF file. */
- Tcl_Interp *interp) /* not used */
+ Tcl_Interp *dummy) /* not used */
{
GIFImageConfig gifConf;
+ (void)fileName;
+ (void)format;
+ (void)dummy;
memset(&gifConf, 0, sizeof(GIFImageConfig));
return ReadGIFHeader(&gifConf, chan, widthPtr, heightPtr);
@@ -602,7 +605,7 @@ FileReadGIF(
goto error;
}
nBytes = fileWidth * fileHeight * 3;
- trashBuffer = ckalloc(nBytes);
+ trashBuffer = (unsigned char *)ckalloc(nBytes);
if (trashBuffer) {
memset(trashBuffer, 0, nBytes);
}
@@ -697,7 +700,7 @@ FileReadGIF(
goto error;
}
nBytes = block.pitch * imageHeight;
- block.pixelPtr = ckalloc(nBytes);
+ block.pixelPtr = (unsigned char *)ckalloc(nBytes);
if (block.pixelPtr) {
memset(block.pixelPtr, 0, nBytes);
}
@@ -851,11 +854,13 @@ StringMatchGIF(
Tcl_Obj *format, /* the image format object, or NULL */
int *widthPtr, /* where to put the string width */
int *heightPtr, /* where to put the string height */
- Tcl_Interp *interp) /* not used */
+ Tcl_Interp *dummy) /* not used */
{
unsigned char *data, header[10];
- size_t got, length;
+ TkSizeT got, length;
MFile handle;
+ (void)format;
+ (void)dummy;
data = TkGetByteArrayFromObj(dataObj, &length);
@@ -923,7 +928,7 @@ StringReadGIF(
int srcX, int srcY)
{
MFile handle, *hdlPtr = &handle;
- size_t length;
+ TkSizeT length;
const char *xferFormat;
unsigned char *data = TkGetByteArrayFromObj(dataObj, &length);
@@ -1147,15 +1152,17 @@ ReadImage(
{
unsigned char initialCodeSize;
int xpos = 0, ypos = 0, pass = 0, i, count;
- register unsigned char *pixelPtr;
+ unsigned char *pixelPtr;
static const int interlaceStep[] = { 8, 8, 4, 2 };
static const int interlaceStart[] = { 0, 4, 2, 1 };
unsigned short prefix[(1 << MAX_LWZ_BITS)];
unsigned char append[(1 << MAX_LWZ_BITS)];
unsigned char stack[(1 << MAX_LWZ_BITS)*2];
- register unsigned char *top;
+ unsigned char *top;
int codeSize, clearCode, inCode, endCode, oldCode, maxCode;
int code, firstCode, v;
+ (void)srcX;
+ (void)srcY;
/*
* Initialize the decoder
@@ -1372,7 +1379,7 @@ ReadImage(
*
* The field "stack" is abused for temporary buffer. it has 4096 bytes
* and we need 256.
- *
+ *
* Loop until we hit a 0 length block which is the end sign.
*/
while ( 0 < (count = GetDataBlock(gifConfPtr, chan, stack)))
@@ -1791,7 +1798,7 @@ WriteToChannel(
const char *bytes,
size_t byteCount)
{
- Tcl_Channel handle = clientData;
+ Tcl_Channel handle = (Tcl_Channel)clientData;
return Tcl_Write(handle, bytes, byteCount);
}
@@ -1802,7 +1809,7 @@ WriteToByteArray(
const char *bytes,
size_t byteCount)
{
- Tcl_Obj *objPtr = clientData;
+ Tcl_Obj *objPtr = (Tcl_Obj *)clientData;
Tcl_Obj *tmpObj = Tcl_NewByteArrayObj((unsigned char *) bytes, byteCount);
Tcl_IncrRefCount(tmpObj);
@@ -1824,6 +1831,7 @@ CommonWriteGIF(
long width, height, x;
unsigned char c;
unsigned int top, left;
+ (void)format;
top = 0;
left = 0;
@@ -2269,9 +2277,9 @@ ClearHashTable( /* Reset code table. */
GIFState_t *statePtr,
int hSize)
{
- register int *hashTablePtr = statePtr->hashTable + hSize;
- register long i;
- register long m1 = -1;
+ int *hashTablePtr = statePtr->hashTable + hSize;
+ long i;
+ long m1 = -1;
i = hSize - 16;
do { /* might use Sys V memset(3) here */
diff --git a/generic/tkImgListFormat.c b/generic/tkImgListFormat.c
index 4636c41..70efc96 100644
--- a/generic/tkImgListFormat.c
+++ b/generic/tkImgListFormat.c
@@ -158,7 +158,8 @@ Tk_PhotoImageFormat tkImgFmtDefault = {
NULL, /* fileReadProc: format doesn't support file read */
StringReadDef, /* stringReadProc */
NULL, /* fileWriteProc: format doesn't support file write */
- StringWriteDef /* stringWriteProc */
+ StringWriteDef, /* stringWriteProc */
+ NULL /* nextPtr */
};
/*
@@ -195,7 +196,8 @@ ParseFormatOptions(
* this struct */
{
- int index, optIndex, typeIndex, first;
+ int index, optIndex, first;
+ enum ColorFormatType typeIndex;
const char *option;
first = 1;
@@ -256,7 +258,7 @@ ParseFormatOptions(
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(NULL, objv[index], colorFormatNames, "",
- TCL_EXACT, &typeIndex) != TCL_OK
+ TCL_EXACT, (int *)&typeIndex) != TCL_OK
|| (typeIndex != COLORFORMAT_LIST
&& typeIndex != COLORFORMAT_RGB2
&& typeIndex != COLORFORMAT_RGBA2) ) {
@@ -365,6 +367,7 @@ StringMatchDef(
int y, rowCount, colCount, curColCount;
unsigned char dummy;
Tcl_Obj **rowListPtr, *pixelData;
+ (void)formatString;
/*
* See if data can be parsed as a list, if every element is itself a valid
@@ -549,7 +552,7 @@ StringReadDef(
srcBlock.offset[1] = 1;
srcBlock.offset[2] = 2;
srcBlock.offset[3] = 3;
- srcBlock.pixelPtr = attemptckalloc(srcBlock.pitch * srcBlock.height);
+ srcBlock.pixelPtr = (unsigned char *)attemptckalloc(srcBlock.pitch * srcBlock.height);
if (srcBlock.pixelPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(TK_PHOTO_ALLOC_FAILURE_MESSAGE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
@@ -772,7 +775,7 @@ ParseColor(
unsigned char *alphaPtr)
{
const char *specString;
- size_t charCount;
+ TkSizeT charCount;
/*
* Find out which color format we have
@@ -836,7 +839,7 @@ ParseColor(
*/
static int
ParseColorAsList(
- Tcl_Interp *interp, /* not used */
+ Tcl_Interp *dummy, /* not used */
const char *colorString, /* the color data to parse */
int colorStrLen, /* length of the color string */
unsigned char *redPtr, /* the result is written to these pointers */
@@ -844,7 +847,6 @@ ParseColorAsList(
unsigned char *bluePtr,
unsigned char *alphaPtr)
{
-
/*
* This is kinda ugly. The code would be certainly nicer if it
* used Tcl_ListObjGetElements() and Tcl_GetIntFromObj(). But with
@@ -854,6 +856,8 @@ ParseColorAsList(
const char *curPos;
int values[4];
int i;
+ (void)dummy;
+ (void)colorStrLen;
curPos = colorString;
i = 0;
@@ -863,7 +867,7 @@ ParseColorAsList(
* To avoid that, avance the pointer to the next non-blank char.
*/
- while(isspace(*curPos)) {
+ while(isspace(UCHAR(*curPos))) {
++curPos;
}
while (i < 4 && *curPos != '\0') {
@@ -871,7 +875,7 @@ ParseColorAsList(
if (values[i] < 0 || values[i] > 255) {
return TCL_ERROR;
}
- while(isspace(*curPos)) {
+ while(isspace(UCHAR(*curPos))) {
++curPos;
}
++i;
diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c
index a620515..0c62b58 100644
--- a/generic/tkImgPNG.c
+++ b/generic/tkImgPNG.c
@@ -10,7 +10,6 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "assert.h"
#include "tkInt.h"
#define PNG_INT32(a,b,c,d) \
@@ -127,7 +126,7 @@ typedef struct {
Tcl_Channel channel; /* Channel for from-file reads. */
Tcl_Obj *objDataPtr;
unsigned char *strDataBuf; /* Raw source data for from-string reads. */
- size_t strDataLen; /* Length of source data. */
+ TkSizeT strDataLen; /* Length of source data. */
unsigned char *base64Data; /* base64 encoded string data. */
unsigned char base64Bits; /* Remaining bits from last base64 read. */
unsigned char base64State; /* Current state of base64 decoder. */
@@ -2098,7 +2097,7 @@ ReadIDAT(
*/
while (chunkSz && !Tcl_ZlibStreamEof(pngPtr->stream)) {
- size_t len1, len2;
+ TkSizeT len1, len2;
/*
* Read another block of input into the zlib stream if data remains.
@@ -2154,7 +2153,7 @@ ReadIDAT(
}
TkGetByteArrayFromObj(pngPtr->thisLineObj, &len2);
- if (len2 == (size_t)pngPtr->phaseSize) {
+ if (len2 == (TkSizeT)pngPtr->phaseSize) {
if (pngPtr->phase > 7) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"extra data after final scan line of final phase",
@@ -2238,14 +2237,14 @@ ApplyAlpha(
PNGImage *pngPtr)
{
if (pngPtr->alpha != 1.0) {
- register unsigned char *p = pngPtr->block.pixelPtr;
+ unsigned char *p = pngPtr->block.pixelPtr;
unsigned char *endPtr = p + pngPtr->blockLen;
int offset = pngPtr->block.offset[3];
p += offset;
if (16 == pngPtr->bitDepth) {
- register unsigned int channel;
+ unsigned int channel;
while (p < endPtr) {
channel = (unsigned int)
@@ -2521,7 +2520,7 @@ DecodePNG(
pngPtr->thisLineObj = Tcl_NewObj();
Tcl_IncrRefCount(pngPtr->thisLineObj);
- pngPtr->block.pixelPtr = attemptckalloc(pngPtr->blockLen);
+ pngPtr->block.pixelPtr = (unsigned char *)attemptckalloc(pngPtr->blockLen);
if (!pngPtr->block.pixelPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"memory allocation failed", -1));
@@ -2677,6 +2676,8 @@ FileMatchPNG(
{
PNGImage png;
int match = 0;
+ (void)fileName;
+ (void)fmtObj;
InitPNGImage(NULL, &png, chan, NULL, TCL_ZLIB_STREAM_INFLATE);
@@ -2726,6 +2727,11 @@ FileReadPNG(
{
PNGImage png;
int result = TCL_ERROR;
+ (void)fileName;
+ (void)width;
+ (void)height;
+ (void)srcX;
+ (void)srcY;
result = InitPNGImage(interp, &png, chan, NULL, TCL_ZLIB_STREAM_INFLATE);
@@ -2765,6 +2771,7 @@ StringMatchPNG(
{
PNGImage png;
int match = 0;
+ (void)fmtObj;
InitPNGImage(NULL, &png, NULL, pObjData, TCL_ZLIB_STREAM_INFLATE);
@@ -2813,6 +2820,10 @@ StringReadPNG(
{
PNGImage png;
int result = TCL_ERROR;
+ (void)width;
+ (void)height;
+ (void)srcX;
+ (void)srcY;
result = InitPNGImage(interp, &png, NULL, pObjData,
TCL_ZLIB_STREAM_INFLATE);
@@ -2863,7 +2874,7 @@ WriteData(
*/
if (pngPtr->objDataPtr) {
- size_t objSz;
+ TkSizeT objSz;
unsigned char *destPtr;
TkGetByteArrayFromObj(pngPtr->objDataPtr, &objSz);
@@ -3135,7 +3146,7 @@ WriteIDAT(
int rowNum, flush = TCL_ZLIB_NO_FLUSH, result;
Tcl_Obj *outputObj;
unsigned char *outputBytes;
- size_t outputSize;
+ TkSizeT outputSize;
/*
* Filter and compress each row one at a time.
@@ -3460,6 +3471,7 @@ FileWritePNG(
Tcl_Channel chan;
PNGImage png;
int result = TCL_ERROR;
+ (void)fmtObj;
/*
* Open a Tcl file channel where the image data will be stored. Tk ought
@@ -3530,6 +3542,7 @@ StringWritePNG(
Tcl_Obj *resultObj = Tcl_NewObj();
PNGImage png;
int result = TCL_ERROR;
+ (void)fmtObj;
/*
* Initalize PNGImage instance for encoding.
diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c
index d6ec63c..91d809b 100644
--- a/generic/tkImgPPM.c
+++ b/generic/tkImgPPM.c
@@ -103,6 +103,9 @@ FileMatchPPM(
Tcl_Interp *interp) /* unused */
{
int dummy;
+ (void)fileName;
+ (void)format;
+ (void)interp;
return ReadPPMFileHeader(chan, widthPtr, heightPtr, &dummy);
}
@@ -145,6 +148,7 @@ FileReadPPM(
size_t nBytes, count;
unsigned char *pixelPtr;
Tk_PhotoImageBlock block;
+ (void)format;
type = ReadPPMFileHeader(chan, &fileWidth, &fileHeight, &maxIntensity);
if (type == 0) {
@@ -212,7 +216,7 @@ FileReadPPM(
nLines = 1;
}
nBytes = nLines * block.pitch;
- pixelPtr = ckalloc(nBytes);
+ pixelPtr = (unsigned char *)ckalloc(nBytes);
block.pixelPtr = pixelPtr + srcX * block.pixelSize;
for (h = height; h > 0; h -= nLines) {
@@ -290,6 +294,7 @@ FileWritePPM(
size_t nBytes;
unsigned char *pixelPtr, *pixLinePtr;
char header[16 + TCL_INTEGER_SPACE * 2];
+ (void)format;
chan = Tcl_OpenFileChannel(interp, fileName, "w", 0666);
if (chan == NULL) {
@@ -377,6 +382,7 @@ StringWritePPM(
unsigned char *pixLinePtr, *byteArray;
char header[16 + TCL_INTEGER_SPACE * 2];
Tcl_Obj *byteArrayObj;
+ (void)format;
sprintf(header, "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height);
@@ -454,6 +460,8 @@ StringMatchPPM(
Tcl_Interp *interp) /* unused */
{
int dummy;
+ (void)format;
+ (void)interp;
return ReadPPMStringHeader(dataObj, widthPtr, heightPtr,
&dummy, NULL, NULL);
@@ -494,6 +502,7 @@ StringReadPPM(
int nLines, nBytes, h, type, count, dataSize, bytesPerChannel = 1;
unsigned char *pixelPtr, *dataBuffer;
Tk_PhotoImageBlock block;
+ (void)format;
type = ReadPPMStringHeader(dataObj, &fileWidth, &fileHeight,
&maxIntensity, &dataBuffer, &dataSize);
@@ -580,7 +589,7 @@ StringReadPPM(
nLines = 1;
}
nBytes = nLines * block.pitch;
- pixelPtr = ckalloc(nBytes);
+ pixelPtr = (unsigned char *)ckalloc(nBytes);
block.pixelPtr = pixelPtr + srcX * block.pixelSize;
for (h = height; h > 0; h -= nLines) {
@@ -765,7 +774,7 @@ ReadPPMStringHeader(
#define BUFFER_SIZE 1000
char buffer[BUFFER_SIZE], c;
int i, numFields, type = 0;
- size_t dataSize;
+ TkSizeT dataSize;
unsigned char *dataBuffer;
dataBuffer = TkGetByteArrayFromObj(dataPtr, &dataSize);
diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c
index f67ab36..81b196c 100644
--- a/generic/tkImgPhInstance.c
+++ b/generic/tkImgPhInstance.c
@@ -26,8 +26,15 @@
/*
* Declaration for internal Xlib function used here:
*/
-
+#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC_OSX_TK)
+#ifdef __cplusplus
+extern "C" {
+#endif
extern int _XInitImageFuncPtrs(XImage *image);
+#ifdef __cplusplus
+}
+#endif
+#endif
/*
* Forward declarations
@@ -212,7 +219,7 @@ TkImgPhotoGet(
ClientData masterData) /* Pointer to our master structure for the
* image. */
{
- PhotoMaster *masterPtr = masterData;
+ PhotoMaster *masterPtr = (PhotoMaster *)masterData;
PhotoInstance *instancePtr;
Colormap colormap;
int mono, nRed, nGreen, nBlue, numVisuals;
@@ -278,7 +285,7 @@ TkImgPhotoGet(
* a new instance of the image.
*/
- instancePtr = ckalloc(sizeof(PhotoInstance));
+ instancePtr = (PhotoInstance *)ckalloc(sizeof(PhotoInstance));
instancePtr->masterPtr = masterPtr;
instancePtr->display = Tk_Display(tkwin);
instancePtr->colormap = Tk_Colormap(tkwin);
@@ -309,7 +316,7 @@ TkImgPhotoGet(
nGreen = nBlue = 0;
mono = 1;
instancePtr->visualInfo = *visInfoPtr;
- switch (visInfoPtr->class) {
+ switch (visInfoPtr->c_class) {
case DirectColor:
case TrueColor:
nRed = 1 << CountBits(visInfoPtr->red_mask);
@@ -611,7 +618,7 @@ TkImgPhotoDisplay(
int drawableX,int drawableY)/* Coordinates within drawable that correspond
* to imageX and imageY. */
{
- PhotoInstance *instancePtr = clientData;
+ PhotoInstance *instancePtr = (PhotoInstance *)clientData;
#ifndef TKPUTIMAGE_CAN_BLEND
XVisualInfo visInfo = instancePtr->visualInfo;
#endif
@@ -645,7 +652,7 @@ TkImgPhotoDisplay(
if ((instancePtr->masterPtr->flags & COMPLEX_ALPHA)
&& visInfo.depth >= 15
- && (visInfo.class == DirectColor || visInfo.class == TrueColor)) {
+ && (visInfo.c_class == DirectColor || visInfo.c_class == TrueColor)) {
Tk_ErrorHandler handler;
XImage *bgImg = NULL;
@@ -700,7 +707,7 @@ TkImgPhotoDisplay(
XSetClipMask(display, instancePtr->gc, None);
XSetClipOrigin(display, instancePtr->gc, 0, 0);
}
- XFlush(display);
+ (void)XFlush(display);
#endif
}
@@ -729,8 +736,9 @@ TkImgPhotoFree(
Display *display) /* Display containing window that used
* image. */
{
- PhotoInstance *instancePtr = clientData;
+ PhotoInstance *instancePtr = (PhotoInstance *)clientData;
ColorTable *colorPtr;
+ (void)display;
if (instancePtr->refCount-- > 1) {
return;
@@ -829,7 +837,7 @@ TkImgPhotoInstanceSetSize(
* such possibility.
*/
- newError = ckalloc(masterPtr->height * masterPtr->width
+ newError = (schar *)ckalloc(masterPtr->height * masterPtr->width
* 3 * sizeof(schar));
/*
@@ -867,8 +875,8 @@ TkImgPhotoInstanceSetSize(
if (masterPtr->width == instancePtr->width) {
offset = validBox.y * masterPtr->width * 3;
memcpy(newError + offset, instancePtr->error + offset,
- (size_t) (validBox.height
- * masterPtr->width * 3 * sizeof(schar)));
+ (size_t) validBox.height
+ * masterPtr->width * 3 * sizeof(schar));
} else if (validBox.width > 0 && validBox.height > 0) {
errDestPtr = newError +
@@ -948,7 +956,7 @@ IsValidPalette(
mono = 0;
}
- switch (instancePtr->visualInfo.class) {
+ switch (instancePtr->visualInfo.c_class) {
case DirectColor:
case TrueColor:
if ((nRed > (1 << CountBits(instancePtr->visualInfo.red_mask)))
@@ -1058,13 +1066,13 @@ GetColorTable(
* Re-use the existing entry.
*/
- colorPtr = Tcl_GetHashValue(entry);
+ colorPtr = (ColorTable *)Tcl_GetHashValue(entry);
} else {
/*
* No color table currently available; need to make one.
*/
- colorPtr = ckalloc(sizeof(ColorTable));
+ colorPtr = (ColorTable *)ckalloc(sizeof(ColorTable));
/*
* The following line of code should not normally be needed due to the
@@ -1212,8 +1220,8 @@ AllocateColors(
* store them in *colors.
*/
- if ((colorPtr->visualInfo.class == DirectColor)
- || (colorPtr->visualInfo.class == TrueColor)) {
+ if ((colorPtr->visualInfo.c_class == DirectColor)
+ || (colorPtr->visualInfo.c_class == TrueColor)) {
/*
* Direct/True Color: allocate shades of red, green, blue
@@ -1225,7 +1233,7 @@ AllocateColors(
} else {
numColors = MAX(MAX(nRed, nGreen), nBlue);
}
- colors = ckalloc(numColors * sizeof(XColor));
+ colors = (XColor *)ckalloc(numColors * sizeof(XColor));
for (i = 0; i < numColors; ++i) {
if (igam == 1.0) {
@@ -1245,7 +1253,7 @@ AllocateColors(
*/
numColors = (mono) ? nRed: (nRed * nGreen * nBlue);
- colors = ckalloc(numColors * sizeof(XColor));
+ colors = (XColor *)ckalloc(numColors * sizeof(XColor));
if (!mono) {
/*
@@ -1289,7 +1297,7 @@ AllocateColors(
* Now try to allocate the colors we've calculated.
*/
- pixels = ckalloc(numColors * sizeof(unsigned long));
+ pixels = (unsigned long *)ckalloc(numColors * sizeof(unsigned long));
for (i = 0; i < numColors; ++i) {
if (!XAllocColor(colorPtr->id.display, colorPtr->id.colormap,
&colors[i])) {
@@ -1367,8 +1375,8 @@ AllocateColors(
*/
#ifndef _WIN32
- if ((colorPtr->visualInfo.class != DirectColor)
- && (colorPtr->visualInfo.class != TrueColor)) {
+ if ((colorPtr->visualInfo.c_class != DirectColor)
+ && (colorPtr->visualInfo.c_class != TrueColor)) {
colorPtr->flags |= MAP_COLORS;
}
#endif /* _WIN32 */
@@ -1394,8 +1402,8 @@ AllocateColors(
} else {
g = (i * (nGreen - 1) + 127) / 255;
b = (i * (nBlue - 1) + 127) / 255;
- if ((colorPtr->visualInfo.class == DirectColor)
- || (colorPtr->visualInfo.class == TrueColor)) {
+ if ((colorPtr->visualInfo.c_class == DirectColor)
+ || (colorPtr->visualInfo.c_class == TrueColor)) {
colorPtr->redValues[i] =
colors[r].pixel & colorPtr->visualInfo.red_mask;
colorPtr->greenValues[i] =
@@ -1449,7 +1457,7 @@ DisposeColorTable(
ClientData clientData) /* Pointer to the ColorTable whose
* colors are to be released. */
{
- ColorTable *colorPtr = clientData;
+ ColorTable *colorPtr = (ColorTable *)clientData;
Tcl_HashEntry *entry;
if (colorPtr->pixelMap != NULL) {
@@ -1509,7 +1517,7 @@ ReclaimColors(
entry = Tcl_FirstHashEntry(&imgPhotoColorHash, &srch);
while (entry != NULL) {
- colorPtr = Tcl_GetHashValue(entry);
+ colorPtr = (ColorTable *)Tcl_GetHashValue(entry);
if ((colorPtr->id.display == id->display)
&& (colorPtr->id.colormap == id->colormap)
&& (colorPtr->liveRefCount == 0 )&& (colorPtr->numColors != 0)
@@ -1538,7 +1546,7 @@ ReclaimColors(
entry = Tcl_FirstHashEntry(&imgPhotoColorHash, &srch);
while ((entry != NULL) && (numColors > 0)) {
- colorPtr = Tcl_GetHashValue(entry);
+ colorPtr = (ColorTable *)Tcl_GetHashValue(entry);
if ((colorPtr->id.display == id->display)
&& (colorPtr->id.colormap == id->colormap)
&& (colorPtr->liveRefCount == 0) && (colorPtr->numColors != 0)
@@ -1583,7 +1591,7 @@ TkImgDisposeInstance(
ClientData clientData) /* Pointer to the instance whose resources are
* to be released. */
{
- PhotoInstance *instancePtr = clientData;
+ PhotoInstance *instancePtr = (PhotoInstance *)clientData;
PhotoInstance *prevPtr;
if (instancePtr->pixels != None) {
@@ -1653,8 +1661,8 @@ TkImgDitherInstance(
* DirectColor with many colors).
*/
- if ((colorPtr->visualInfo.class == DirectColor)
- || (colorPtr->visualInfo.class == TrueColor)) {
+ if ((colorPtr->visualInfo.c_class == DirectColor)
+ || (colorPtr->visualInfo.c_class == TrueColor)) {
int nRed, nGreen, nBlue, result;
result = sscanf(colorPtr->id.palette, "%d/%d/%d", &nRed,
@@ -1693,7 +1701,7 @@ TkImgDitherInstance(
* recovering from the failure.
*/
- imagePtr->data = ckalloc(imagePtr->bytes_per_line * nLines);
+ imagePtr->data = (char *)ckalloc(imagePtr->bytes_per_line * nLines);
bigEndian = imagePtr->bitmap_bit_order == MSBFirst;
firstBit = bigEndian? (1 << (imagePtr->bitmap_unit - 1)): 1;
@@ -1982,8 +1990,8 @@ TkImgResetDither(
{
if (instancePtr->error) {
memset(instancePtr->error, 0,
- /*(size_t)*/ (instancePtr->masterPtr->width
- * instancePtr->masterPtr->height * 3 * sizeof(schar)));
+ (size_t) instancePtr->masterPtr->width
+ * instancePtr->masterPtr->height * 3 * sizeof(schar));
}
}
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index ea6e76f..a71ad74 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -135,7 +135,7 @@ Tk_ImageType tkPhotoImageType = {
NULL
};
-typedef struct ThreadSpecificData {
+typedef struct {
Tk_PhotoImageFormat *formatList;
/* Pointer to the first in the list of known
* photo image formats.*/
@@ -162,15 +162,15 @@ static Tcl_ThreadDataKey dataKey;
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_STRING, "-file", NULL, NULL,
- NULL, Tk_Offset(PhotoMaster, fileString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PhotoMaster, fileString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_DOUBLE, "-gamma", NULL, NULL,
- DEF_PHOTO_GAMMA, Tk_Offset(PhotoMaster, gamma), 0, NULL},
+ DEF_PHOTO_GAMMA, offsetof(PhotoMaster, gamma), 0, NULL},
{TK_CONFIG_INT, "-height", NULL, NULL,
- DEF_PHOTO_HEIGHT, Tk_Offset(PhotoMaster, userHeight), 0, NULL},
+ DEF_PHOTO_HEIGHT, offsetof(PhotoMaster, userHeight), 0, NULL},
{TK_CONFIG_UID, "-palette", NULL, NULL,
- DEF_PHOTO_PALETTE, Tk_Offset(PhotoMaster, palette), 0, NULL},
+ DEF_PHOTO_PALETTE, offsetof(PhotoMaster, palette), 0, NULL},
{TK_CONFIG_INT, "-width", NULL, NULL,
- DEF_PHOTO_WIDTH, Tk_Offset(PhotoMaster, userWidth), 0, NULL},
+ DEF_PHOTO_WIDTH, offsetof(PhotoMaster, userWidth), 0, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -223,11 +223,12 @@ static const char * GetExtension(const char *path);
static void
PhotoFormatThreadExitProc(
- ClientData clientData) /* not used */
+ ClientData dummy) /* not used */
{
Tk_PhotoImageFormat *freePtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
while (tsdPtr->oldFormatList != NULL) {
freePtr = tsdPtr->oldFormatList;
@@ -269,14 +270,14 @@ Tk_CreateOldPhotoImageFormat(
* by caller. */
{
Tk_PhotoImageFormat *copyPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
tsdPtr->initialized = 1;
Tcl_CreateThreadExitHandler(PhotoFormatThreadExitProc, NULL);
}
- copyPtr = ckalloc(sizeof(Tk_PhotoImageFormat));
+ copyPtr = (Tk_PhotoImageFormat *)ckalloc(sizeof(Tk_PhotoImageFormat));
*copyPtr = *formatPtr;
copyPtr->nextPtr = tsdPtr->oldFormatList;
tsdPtr->oldFormatList = copyPtr;
@@ -290,21 +291,21 @@ Tk_CreatePhotoImageFormat(
* by caller. */
{
Tk_PhotoImageFormat *copyPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
tsdPtr->initialized = 1;
Tcl_CreateThreadExitHandler(PhotoFormatThreadExitProc, NULL);
}
- copyPtr = ckalloc(sizeof(Tk_PhotoImageFormat));
+ copyPtr = (Tk_PhotoImageFormat *)ckalloc(sizeof(Tk_PhotoImageFormat));
*copyPtr = *formatPtr;
if (isupper((unsigned char) *formatPtr->name)) {
copyPtr->nextPtr = tsdPtr->oldFormatList;
tsdPtr->oldFormatList = copyPtr;
} else {
/* for compatibility with aMSN: make a copy of formatPtr->name */
- char *name = ckalloc(strlen(formatPtr->name) + 1);
+ char *name = (char *)ckalloc(strlen(formatPtr->name) + 1);
strcpy(name, formatPtr->name);
copyPtr->name = name;
copyPtr->nextPtr = tsdPtr->formatList;
@@ -344,12 +345,13 @@ ImgPhotoCreate(
* will be returned in later callbacks. */
{
PhotoMaster *masterPtr;
+ (void)typePtr;
/*
* Allocate and initialize the photo image master record.
*/
- masterPtr = ckalloc(sizeof(PhotoMaster));
+ masterPtr = (PhotoMaster *)ckalloc(sizeof(PhotoMaster));
memset(masterPtr, 0, sizeof(PhotoMaster));
masterPtr->tkMaster = master;
masterPtr->interp = interp;
@@ -408,17 +410,17 @@ ImgPhotoCmd(
PHOTO_WRITE
};
- PhotoMaster *masterPtr = clientData;
+ PhotoMaster *masterPtr = (PhotoMaster *)clientData;
int result, index, x, y, width, height;
struct SubcommandOptions options;
unsigned char *pixelPtr;
Tk_PhotoImageBlock block;
Tk_PhotoImageFormat *imageFormat;
- size_t length;
+ TkSizeT length;
int imageWidth, imageHeight, matched, oldformat = 0;
Tcl_Channel chan;
Tk_PhotoHandle srcHandle;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (objc < 2) {
@@ -798,7 +800,7 @@ ImgPhotoCmd(
Tk_PhotoImageBlock *blockPtr);
Tcl_DStringInit(&buffer);
- result = ((OldStringWriteProc) stringWriteProc)(interp, &buffer,
+ result = ((OldStringWriteProc)(void *)stringWriteProc)(interp, &buffer,
Tcl_GetString(options.format), &block);
if (result == TCL_OK) {
Tcl_DStringResult(interp, &buffer);
@@ -810,7 +812,7 @@ ImgPhotoCmd(
Tcl_Obj *formatString, Tk_PhotoImageBlock *blockPtr,
void *dummy);
- result = ((NewStringWriteProc) stringWriteProc)(interp,
+ result = ((NewStringWriteProc)(void *)stringWriteProc)(interp,
options.format, &block, NULL);
}
if (options.background) {
@@ -879,10 +881,10 @@ ImgPhotoCmd(
*/
pixelPtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4;
- channels[0] = Tcl_NewIntObj(pixelPtr[0]);
- channels[1] = Tcl_NewIntObj(pixelPtr[1]);
- channels[2] = Tcl_NewIntObj(pixelPtr[2]);
- channels[3] = Tcl_NewIntObj(pixelPtr[3]);
+ channels[0] = Tcl_NewWideIntObj(pixelPtr[0]);
+ channels[1] = Tcl_NewWideIntObj(pixelPtr[1]);
+ channels[2] = Tcl_NewWideIntObj(pixelPtr[2]);
+ channels[3] = Tcl_NewWideIntObj(pixelPtr[3]);
Tcl_SetObjResult(interp, Tcl_NewListObj(channelCount, channels));
return TCL_OK;
}
@@ -1172,7 +1174,7 @@ ImgPhotoCmd(
if (boolMode) {
Tcl_SetObjResult(interp, Tcl_NewBooleanObj( ! pixelPtr[3]));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(pixelPtr[3]));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pixelPtr[3]));
}
return TCL_OK;
}
@@ -1508,7 +1510,7 @@ ParseSubcommandOptions(
* TK_PHOTO_COMPOSITE_* constants. */
NULL
};
- size_t length;
+ TkSizeT length;
int index, c, bit, currentBit;
int values[4], numValues, maxValues, argIndex;
const char *option, *expandedOption, *needed;
@@ -1801,14 +1803,14 @@ ImgPhotoConfigureMaster(
const char *oldFileString, *oldPaletteString;
Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL, *metadata = NULL;
Tcl_Obj *tempdata, *tempformat;
- size_t length;
+ TkSizeT length;
int i, j, result, imageWidth, imageHeight, oldformat;
double oldGamma;
Tcl_Channel chan;
Tk_PhotoImageFormat *imageFormat;
const char **args;
- args = ckalloc((objc + 1) * sizeof(char *));
+ args = (const char **)ckalloc((objc + 1) * sizeof(char *));
for (i = 0, j = 0; i < objc; i++,j++) {
args[j] = TkGetStringFromObj(objv[i], &length);
if ((length > 1) && (args[j][0] == '-')) {
@@ -1902,7 +1904,7 @@ ImgPhotoConfigureMaster(
* Force into ByteArray format, which most (all) image handlers will
* use anyway. Empty length means ignore the -data option.
*/
- size_t bytesize;
+ TkSizeT bytesize;
(void) TkGetByteArrayFromObj(data, &bytesize);
if (bytesize) {
@@ -2185,7 +2187,7 @@ ImgPhotoDelete(
ClientData masterData) /* Pointer to PhotoMaster structure for image.
* Must not have any more instances. */
{
- PhotoMaster *masterPtr = masterData;
+ PhotoMaster *masterPtr = (PhotoMaster *)masterData;
PhotoInstance *instancePtr;
while ((instancePtr = masterPtr->instancePtr) != NULL) {
@@ -2240,7 +2242,7 @@ ImgPhotoCmdDeletedProc(
ClientData clientData) /* Pointer to PhotoMaster structure for
* image. */
{
- PhotoMaster *masterPtr = clientData;
+ PhotoMaster *masterPtr = (PhotoMaster *)clientData;
masterPtr->imageCmd = NULL;
if (masterPtr->tkMaster != NULL) {
@@ -2313,7 +2315,7 @@ ImgPhotoSetSize(
if (newPixSize == 0) {
newPix32 = NULL;
} else {
- newPix32 = attemptckalloc(newPixSize);
+ newPix32 = (unsigned char *)attemptckalloc(newPixSize);
if (newPix32 == NULL) {
return TCL_ERROR;
}
@@ -2476,7 +2478,7 @@ MatchFileFormat(
{
int matched = 0, useoldformat = 0;
Tk_PhotoImageFormat *formatPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
const char *formatString = NULL;
@@ -2616,7 +2618,7 @@ MatchStringFormat(
{
int matched = 0, useoldformat = 0;
Tk_PhotoImageFormat *formatPtr, *defaultFormatPtr = NULL;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
const char *formatString = NULL;
@@ -2727,10 +2729,19 @@ MatchStringFormat(
formatString, NULL);
return TCL_ERROR;
} else {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "couldn't recognize image data", -1));
- Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
- "UNRECOGNIZED_DATA", NULL);
+
+ /*
+ * Some lower level routine (stringMatchProc) may have already set
+ * a specific error message, so just return this. Otherwise return
+ * a generic image data error.
+ */
+
+ if (Tcl_GetString(Tcl_GetObjResult(interp))[0] == '\0') {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "couldn't recognize image data", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "UNRECOGNIZED_DATA", NULL);
+ }
return TCL_ERROR;
}
}
@@ -2817,7 +2828,7 @@ Tk_PhotoPutBlock(
int compRule) /* Compositing rule to use when processing
* transparent pixels. */
{
- register PhotoMaster *masterPtr = (PhotoMaster *) handle;
+ PhotoMaster *masterPtr = (PhotoMaster *) handle;
Tk_PhotoImageBlock sourceBlock;
unsigned char *memToFree;
int xEnd, yEnd, greenOffset, blueOffset, alphaOffset;
@@ -2865,7 +2876,7 @@ Tk_PhotoPutBlock(
if (sourceBlock.pixelPtr >= masterPtr->pix32
&& sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width
* masterPtr->height * 4) {
- sourceBlock.pixelPtr = attemptckalloc(sourceBlock.height
+ sourceBlock.pixelPtr = (unsigned char *)attemptckalloc(sourceBlock.height
* sourceBlock.pitch);
if (sourceBlock.pixelPtr == NULL) {
if (interp != NULL) {
@@ -3158,10 +3169,10 @@ Tk_PhotoPutBlock(
*/
if (!(masterPtr->flags & COMPLEX_ALPHA)) {
- register int x1;
+ int x1;
for (x1=x ; x1<x+width ; x1++) {
- register unsigned char newAlpha;
+ unsigned char newAlpha;
destLinePtr = masterPtr->pix32 + (y*masterPtr->width + x1)*4;
newAlpha = destLinePtr[3];
@@ -3243,8 +3254,8 @@ Tk_PhotoPutZoomedBlock(
int compRule) /* Compositing rule to use when processing
* transparent pixels. */
{
- register PhotoMaster *masterPtr = (PhotoMaster *) handle;
- register Tk_PhotoImageBlock sourceBlock;
+ PhotoMaster *masterPtr = (PhotoMaster *) handle;
+ Tk_PhotoImageBlock sourceBlock;
unsigned char *memToFree;
int xEnd, yEnd, greenOffset, blueOffset, alphaOffset;
int wLeft, hLeft, wCopy, hCopy, blockWid, blockHt;
@@ -3299,7 +3310,7 @@ Tk_PhotoPutZoomedBlock(
if (sourceBlock.pixelPtr >= masterPtr->pix32
&& sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width
* masterPtr->height * 4) {
- sourceBlock.pixelPtr = attemptckalloc(sourceBlock.height
+ sourceBlock.pixelPtr = (unsigned char *)attemptckalloc(sourceBlock.height
* sourceBlock.pitch);
if (sourceBlock.pixelPtr == NULL) {
if (interp != NULL) {
@@ -3985,7 +3996,7 @@ ImgGetPhoto(
if (blockPtr->height > (int)((UINT_MAX/newPixelSize)/blockPtr->width)) {
return NULL;
}
- data = attemptckalloc(newPixelSize*blockPtr->width*blockPtr->height);
+ data = (char *)attemptckalloc(newPixelSize*blockPtr->width*blockPtr->height);
if (data == NULL) {
return NULL;
}
@@ -4167,6 +4178,8 @@ ImgPhotoPostscript(
int prepass) /* (unused) */
{
Tk_PhotoImageBlock block;
+ (void)tkwin;
+ (void)prepass;
Tk_PhotoGetImage(clientData, &block);
block.pixelPtr += y * block.pitch + x * block.pixelSize;
diff --git a/generic/tkImgSVGnano.c b/generic/tkImgSVGnano.c
new file mode 100644
index 0000000..7575f86
--- /dev/null
+++ b/generic/tkImgSVGnano.c
@@ -0,0 +1,810 @@
+/*
+ * tkImgSVGnano.c
+ *
+ * A photo file handler for SVG files.
+ *
+ * Copyright (c) 2013-14 Mikko Mononen memon@inside.org
+ * Copyright (c) 2018 Christian Gollwitzer auriocus@gmx.de
+ * Copyright (c) 2018 Rene Zaumseil r.zaumseil@freenet.de
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * This handler is build using the original nanosvg library files from
+ * https://github.com/memononen/nanosvg and the tcl extension files from
+ * https://github.com/auriocus/tksvg
+ *
+ */
+
+#include "tkInt.h"
+#define NANOSVG_malloc ckalloc
+#define NANOSVG_realloc ckrealloc
+#define NANOSVG_free ckfree
+#define NANOSVG_SCOPE MODULE_SCOPE
+#define NANOSVG_ALL_COLOR_KEYWORDS
+#define NANOSVG_IMPLEMENTATION
+#include "nanosvg.h"
+#define NANOSVGRAST_IMPLEMENTATION
+#include "nanosvgrast.h"
+
+/* Additional parameters to nsvgRasterize() */
+
+typedef struct {
+ double scale;
+ int scaleToHeight;
+ int scaleToWidth;
+} RastOpts;
+
+/*
+ * Per interp cache of last NSVGimage which was matched to
+ * be immediately rasterized after the match. This helps to
+ * eliminate double parsing of the SVG file/string.
+ */
+
+typedef struct {
+ /* A poiner to remember if it is the same svn image (data)
+ * It is a Tcl_Channel if image created by -file option
+ * or a Tcl_Obj, if image is created with the -data option
+ */
+ ClientData dataOrChan;
+ Tcl_DString formatString;
+ NSVGimage *nsvgImage;
+ RastOpts ropts;
+} NSVGcache;
+
+static int FileMatchSVG(Tcl_Channel chan, const char *fileName,
+ Tcl_Obj *format, int *widthPtr, int *heightPtr,
+ Tcl_Interp *interp);
+static int FileReadSVG(Tcl_Interp *interp, Tcl_Channel chan,
+ const char *fileName, Tcl_Obj *format,
+ Tk_PhotoHandle imageHandle, int destX, int destY,
+ int width, int height, int srcX, int srcY);
+static int StringMatchSVG(Tcl_Obj *dataObj, Tcl_Obj *format,
+ int *widthPtr, int *heightPtr, Tcl_Interp *interp);
+static int StringReadSVG(Tcl_Interp *interp, Tcl_Obj *dataObj,
+ Tcl_Obj *format, Tk_PhotoHandle imageHandle,
+ int destX, int destY, int width, int height,
+ int srcX, int srcY);
+static NSVGimage * ParseSVGWithOptions(Tcl_Interp *interp,
+ const char *input, TkSizeT length, Tcl_Obj *format,
+ RastOpts *ropts);
+static int RasterizeSVG(Tcl_Interp *interp,
+ Tk_PhotoHandle imageHandle, NSVGimage *nsvgImage,
+ int destX, int destY, int width, int height,
+ int srcX, int srcY, RastOpts *ropts);
+static double GetScaleFromParameters(NSVGimage *nsvgImage,
+ RastOpts *ropts, int *widthPtr, int *heightPtr);
+static NSVGcache * GetCachePtr(Tcl_Interp *interp);
+static int CacheSVG(Tcl_Interp *interp, ClientData dataOrChan,
+ Tcl_Obj *formatObj, NSVGimage *nsvgImage,
+ RastOpts *ropts);
+static NSVGimage * GetCachedSVG(Tcl_Interp *interp, ClientData dataOrChan,
+ Tcl_Obj *formatObj, RastOpts *ropts);
+static void CleanCache(Tcl_Interp *interp);
+static void FreeCache(ClientData clientData, Tcl_Interp *interp);
+
+/*
+ * The format record for the SVG nano file format:
+ */
+
+Tk_PhotoImageFormat tkImgFmtSVGnano = {
+ "svg", /* name */
+ FileMatchSVG, /* fileMatchProc */
+ StringMatchSVG, /* stringMatchProc */
+ FileReadSVG, /* fileReadProc */
+ StringReadSVG, /* stringReadProc */
+ NULL, /* fileWriteProc */
+ NULL, /* stringWriteProc */
+ NULL
+};
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FileMatchSVG --
+ *
+ * This function is invoked by the photo image type to see if a file
+ * contains image data in SVG format.
+ *
+ * Results:
+ * The return value is >0 if the file can be successfully parsed,
+ * and 0 otherwise.
+ *
+ * Side effects:
+ * The file is saved in the internal cache for further use.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+FileMatchSVG(
+ Tcl_Channel chan,
+ const char *fileName,
+ Tcl_Obj *formatObj,
+ int *widthPtr, int *heightPtr,
+ Tcl_Interp *interp)
+{
+ TkSizeT length;
+ Tcl_Obj *dataObj = Tcl_NewObj();
+ const char *data;
+ RastOpts ropts;
+ NSVGimage *nsvgImage;
+ (void)fileName;
+
+ CleanCache(interp);
+ if (Tcl_ReadChars(chan, dataObj, -1, 0) == TCL_IO_FAILURE) {
+ /* in case of an error reading the file */
+ Tcl_DecrRefCount(dataObj);
+ return 0;
+ }
+ data = TkGetStringFromObj(dataObj, &length);
+ nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts);
+ Tcl_DecrRefCount(dataObj);
+ if (nsvgImage != NULL) {
+ GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr);
+ if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) {
+ nsvgDelete(nsvgImage);
+ return 0;
+ }
+ if (!CacheSVG(interp, chan, formatObj, nsvgImage, &ropts)) {
+ nsvgDelete(nsvgImage);
+ }
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FileReadSVG --
+ *
+ * This function is called by the photo image type to read SVG format
+ * data from a file and write it into a given photo image.
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ * Side effects:
+ * The access position in file f is changed, and new data is added to the
+ * image given by imageHandle.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+FileReadSVG(
+ Tcl_Interp *interp,
+ Tcl_Channel chan,
+ const char *fileName,
+ Tcl_Obj *formatObj,
+ Tk_PhotoHandle imageHandle,
+ int destX, int destY,
+ int width, int height,
+ int srcX, int srcY)
+{
+ TkSizeT length;
+ const char *data;
+ RastOpts ropts;
+ NSVGimage *nsvgImage = GetCachedSVG(interp, chan, formatObj, &ropts);
+ (void)fileName;
+
+ if (nsvgImage == NULL) {
+ Tcl_Obj *dataObj = Tcl_NewObj();
+
+ if (Tcl_ReadChars(chan, dataObj, -1, 0) == TCL_IO_FAILURE) {
+ /* in case of an error reading the file */
+ Tcl_DecrRefCount(dataObj);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("read error", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "READ_ERROR", NULL);
+ return TCL_ERROR;
+ }
+ data = TkGetStringFromObj(dataObj, &length);
+ nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj,
+ &ropts);
+ Tcl_DecrRefCount(dataObj);
+ if (nsvgImage == NULL) {
+ return TCL_ERROR;
+ }
+ }
+ return RasterizeSVG(interp, imageHandle, nsvgImage, destX, destY,
+ width, height, srcX, srcY, &ropts);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringMatchSVG --
+ *
+ * This function is invoked by the photo image type to see if a string
+ * contains image data in SVG format.
+ *
+ * Results:
+ * The return value is >0 if the file can be successfully parsed,
+ * and 0 otherwise.
+ *
+ * Side effects:
+ * The file is saved in the internal cache for further use.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+StringMatchSVG(
+ Tcl_Obj *dataObj,
+ Tcl_Obj *formatObj,
+ int *widthPtr, int *heightPtr,
+ Tcl_Interp *interp)
+{
+ TkSizeT length;
+ const char *data;
+ RastOpts ropts;
+ NSVGimage *nsvgImage;
+
+ CleanCache(interp);
+ data = TkGetStringFromObj(dataObj, &length);
+ nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts);
+ if (nsvgImage != NULL) {
+ GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr);
+ if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) {
+ nsvgDelete(nsvgImage);
+ return 0;
+ }
+ if (!CacheSVG(interp, dataObj, formatObj, nsvgImage, &ropts)) {
+ nsvgDelete(nsvgImage);
+ }
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringReadSVG --
+ *
+ * This function is called by the photo image type to read SVG format
+ * data from a string and write it into a given photo image.
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ * Side effects:
+ * New data is added to the image given by imageHandle.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+StringReadSVG(
+ Tcl_Interp *interp,
+ Tcl_Obj *dataObj,
+ Tcl_Obj *formatObj,
+ Tk_PhotoHandle imageHandle,
+ int destX, int destY,
+ int width, int height,
+ int srcX, int srcY)
+{
+ TkSizeT length;
+ const char *data;
+ RastOpts ropts;
+ NSVGimage *nsvgImage = GetCachedSVG(interp, dataObj, formatObj, &ropts);
+
+ if (nsvgImage == NULL) {
+ data = TkGetStringFromObj(dataObj, &length);
+ nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj,
+ &ropts);
+ }
+ if (nsvgImage == NULL) {
+ return TCL_ERROR;
+ }
+ return RasterizeSVG(interp, imageHandle, nsvgImage, destX, destY,
+ width, height, srcX, srcY, &ropts);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ParseSVGWithOptions --
+ *
+ * This function is called to parse the given input string as SVG.
+ *
+ * Results:
+ * Return a newly create NSVGimage on success, and NULL otherwise.
+ *
+ * Side effects:
+ *
+ *----------------------------------------------------------------------
+ */
+
+static NSVGimage *
+ParseSVGWithOptions(
+ Tcl_Interp *interp,
+ const char *input,
+ TkSizeT length,
+ Tcl_Obj *formatObj,
+ RastOpts *ropts)
+{
+ Tcl_Obj **objv = NULL;
+ int objc = 0;
+ double dpi = 96.0;
+ char *inputCopy = NULL;
+ NSVGimage *nsvgImage;
+ int parameterScaleSeen = 0;
+ static const char *const fmtOptions[] = {
+ "-dpi", "-scale", "-scaletoheight", "-scaletowidth", NULL
+ };
+ enum fmtOptions {
+ OPT_DPI, OPT_SCALE, OPT_SCALE_TO_HEIGHT, OPT_SCALE_TO_WIDTH
+ };
+
+ /*
+ * The parser destroys the original input string,
+ * therefore first duplicate.
+ */
+
+ inputCopy = (char *)attemptckalloc(length+1);
+ if (inputCopy == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot alloc data buffer", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "OUT_OF_MEMORY", NULL);
+ goto error;
+ }
+ memcpy(inputCopy, input, length);
+ inputCopy[length] = '\0';
+
+ /*
+ * Process elements of format specification as a list.
+ */
+
+ ropts->scale = 1.0;
+ ropts->scaleToHeight = 0;
+ ropts->scaleToWidth = 0;
+ if ((formatObj != NULL) &&
+ Tcl_ListObjGetElements(interp, formatObj, &objc, &objv) != TCL_OK) {
+ goto error;
+ }
+ for (; objc > 0 ; objc--, objv++) {
+ int optIndex;
+
+ /*
+ * Ignore the "svg" part of the format specification.
+ */
+
+ if (!strcasecmp(Tcl_GetString(objv[0]), "svg")) {
+ continue;
+ }
+
+ if (Tcl_GetIndexFromObjStruct(interp, objv[0], fmtOptions,
+ sizeof(char *), "option", 0, &optIndex) == TCL_ERROR) {
+ goto error;
+ }
+
+ if (objc < 2) {
+ ckfree(inputCopy);
+ inputCopy = NULL;
+ Tcl_WrongNumArgs(interp, 1, objv, "value");
+ goto error;
+ }
+
+ objc--;
+ objv++;
+
+ /*
+ * check that only one scale option is given
+ */
+ switch ((enum fmtOptions) optIndex) {
+ case OPT_SCALE:
+ case OPT_SCALE_TO_HEIGHT:
+ case OPT_SCALE_TO_WIDTH:
+ if ( parameterScaleSeen ) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "only one of -scale, -scaletoheight, -scaletowidth may be given", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE",
+ NULL);
+ goto error;
+ }
+ parameterScaleSeen = 1;
+ break;
+ default:
+ break;
+ }
+
+ /*
+ * Decode parameters
+ */
+ switch ((enum fmtOptions) optIndex) {
+ case OPT_DPI:
+ if (Tcl_GetDoubleFromObj(interp, objv[0], &dpi) == TCL_ERROR) {
+ goto error;
+ }
+ if (dpi < 0.0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-dpi value must be positive", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_DPI",
+ NULL);
+ goto error;
+ }
+ break;
+ case OPT_SCALE:
+ if (Tcl_GetDoubleFromObj(interp, objv[0], &ropts->scale) ==
+ TCL_ERROR) {
+ goto error;
+ }
+ if (ropts->scale <= 0.0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-scale value must be positive", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE",
+ NULL);
+ goto error;
+ }
+ break;
+ case OPT_SCALE_TO_HEIGHT:
+ if (Tcl_GetIntFromObj(interp, objv[0], &ropts->scaleToHeight) ==
+ TCL_ERROR) {
+ goto error;
+ }
+ if (ropts->scaleToHeight <= 0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-scaletoheight value must be positive", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE",
+ NULL);
+ goto error;
+ }
+ break;
+ case OPT_SCALE_TO_WIDTH:
+ if (Tcl_GetIntFromObj(interp, objv[0], &ropts->scaleToWidth) ==
+ TCL_ERROR) {
+ goto error;
+ }
+ if (ropts->scaleToWidth <= 0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-scaletowidth value must be positive", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE",
+ NULL);
+ goto error;
+ }
+ break;
+ }
+ }
+
+ nsvgImage = nsvgParse(inputCopy, "px", (float) dpi);
+ if (nsvgImage == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot parse SVG image", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "PARSE_ERROR", NULL);
+ goto error;
+ }
+ ckfree(inputCopy);
+ return nsvgImage;
+
+error:
+ if (inputCopy != NULL) {
+ ckfree(inputCopy);
+ }
+ return NULL;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * RasterizeSVG --
+ *
+ * This function is called to rasterize the given nsvgImage and
+ * fill the imageHandle with data.
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ *
+ * Side effects:
+ * On error the given nsvgImage will be deleted.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+RasterizeSVG(
+ Tcl_Interp *interp,
+ Tk_PhotoHandle imageHandle,
+ NSVGimage *nsvgImage,
+ int destX, int destY,
+ int width, int height,
+ int srcX, int srcY,
+ RastOpts *ropts)
+{
+ int w, h, c;
+ NSVGrasterizer *rast;
+ unsigned char *imgData;
+ Tk_PhotoImageBlock svgblock;
+ double scale;
+ (void)srcX;
+ (void)srcY;
+
+ scale = GetScaleFromParameters(nsvgImage, ropts, &w, &h);
+
+ rast = nsvgCreateRasterizer();
+ if (rast == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot initialize rasterizer", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "RASTERIZER_ERROR",
+ NULL);
+ goto cleanAST;
+ }
+ imgData = (unsigned char *)attemptckalloc(w * h *4);
+ if (imgData == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot alloc image buffer", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "OUT_OF_MEMORY", NULL);
+ goto cleanRAST;
+ }
+ nsvgRasterize(rast, nsvgImage, 0, 0,
+ (float) scale, imgData, w, h, w * 4);
+ /* transfer the data to a photo block */
+ svgblock.pixelPtr = imgData;
+ svgblock.width = w;
+ svgblock.height = h;
+ svgblock.pitch = w * 4;
+ svgblock.pixelSize = 4;
+ for (c = 0; c <= 3; c++) {
+ svgblock.offset[c] = c;
+ }
+ if (Tk_PhotoExpand(interp, imageHandle,
+ destX + width, destY + height) != TCL_OK) {
+ goto cleanRAST;
+ }
+ if (Tk_PhotoPutBlock(interp, imageHandle, &svgblock, destX, destY,
+ width, height, TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
+ goto cleanimg;
+ }
+ ckfree(imgData);
+ nsvgDeleteRasterizer(rast);
+ nsvgDelete(nsvgImage);
+ return TCL_OK;
+
+cleanimg:
+ ckfree(imgData);
+
+cleanRAST:
+ nsvgDeleteRasterizer(rast);
+
+cleanAST:
+ nsvgDelete(nsvgImage);
+ return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetScaleFromParameters --
+ *
+ * Get the scale value from the already parsed parameters -scale,
+ * -scaletoheight and -scaletowidth.
+ *
+ * The image width and height is also returned.
+ *
+ * Results:
+ * The evaluated or configured scale value, or 0.0 on failure
+ *
+ * Side effects:
+ * heightPtr and widthPtr are set to height and width of the image.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static double
+GetScaleFromParameters(
+ NSVGimage *nsvgImage,
+ RastOpts *ropts,
+ int *widthPtr,
+ int *heightPtr)
+{
+ double scale;
+ int width, height;
+
+ if ((nsvgImage->width == 0.0) || (nsvgImage->height == 0.0)) {
+ width = height = 0;
+ scale = 1.0;
+ } else if (ropts->scaleToHeight > 0) {
+ /*
+ * Fixed height
+ */
+ height = ropts->scaleToHeight;
+ scale = height / nsvgImage->height;
+ width = (int) ceil(nsvgImage->width * scale);
+ } else if (ropts->scaleToWidth > 0) {
+ /*
+ * Fixed width
+ */
+ width = ropts->scaleToWidth;
+ scale = width / nsvgImage->width;
+ height = (int) ceil(nsvgImage->height * scale);
+ } else {
+ /*
+ * Scale factor
+ */
+ scale = ropts->scale;
+ width = (int) ceil(nsvgImage->width * scale);
+ height = (int) ceil(nsvgImage->height * scale);
+ }
+
+ *heightPtr = height;
+ *widthPtr = width;
+ return scale;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetCachePtr --
+ *
+ * This function is called to get the per interpreter used
+ * svg image cache.
+ *
+ * Results:
+ * Return a pointer to the used cache.
+ *
+ * Side effects:
+ * Initialize the cache on the first call.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static NSVGcache *
+GetCachePtr(
+ Tcl_Interp *interp
+) {
+ NSVGcache *cachePtr = (NSVGcache *)Tcl_GetAssocData(interp, "tksvgnano", NULL);
+ if (cachePtr == NULL) {
+ cachePtr = (NSVGcache *)ckalloc(sizeof(NSVGcache));
+ cachePtr->dataOrChan = NULL;
+ Tcl_DStringInit(&cachePtr->formatString);
+ cachePtr->nsvgImage = NULL;
+ Tcl_SetAssocData(interp, "tksvgnano", FreeCache, cachePtr);
+ }
+ return cachePtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CacheSVG --
+ *
+ * Add the given svg image informations to the cache for further usage.
+ *
+ * Results:
+ * Return 1 on success, and 0 otherwise.
+ *
+ * Side effects:
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+CacheSVG(
+ Tcl_Interp *interp,
+ ClientData dataOrChan,
+ Tcl_Obj *formatObj,
+ NSVGimage *nsvgImage,
+ RastOpts *ropts)
+{
+ TkSizeT length;
+ const char *data;
+ NSVGcache *cachePtr = GetCachePtr(interp);
+
+ if (cachePtr != NULL) {
+ cachePtr->dataOrChan = dataOrChan;
+ if (formatObj != NULL) {
+ data = TkGetStringFromObj(formatObj, &length);
+ Tcl_DStringAppend(&cachePtr->formatString, data, length);
+ }
+ cachePtr->nsvgImage = nsvgImage;
+ cachePtr->ropts = *ropts;
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetCachedSVG --
+ *
+ * Try to get the NSVGimage from the internal cache.
+ *
+ * Results:
+ * Return the found NSVGimage on success, and NULL otherwise.
+ *
+ * Side effects:
+ * Calls the CleanCache() function.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static NSVGimage *
+GetCachedSVG(
+ Tcl_Interp *interp,
+ ClientData dataOrChan,
+ Tcl_Obj *formatObj,
+ RastOpts *ropts)
+{
+ TkSizeT length;
+ const char *data;
+ NSVGcache *cachePtr = GetCachePtr(interp);
+ NSVGimage *nsvgImage = NULL;
+
+ if ((cachePtr != NULL) && (cachePtr->nsvgImage != NULL) &&
+ (cachePtr->dataOrChan == dataOrChan)) {
+ if (formatObj != NULL) {
+ data = TkGetStringFromObj(formatObj, &length);
+ if (strcmp(data, Tcl_DStringValue(&cachePtr->formatString)) == 0) {
+ nsvgImage = cachePtr->nsvgImage;
+ *ropts = cachePtr->ropts;
+ cachePtr->nsvgImage = NULL;
+ }
+ } else if (Tcl_DStringLength(&cachePtr->formatString) == 0) {
+ nsvgImage = cachePtr->nsvgImage;
+ *ropts = cachePtr->ropts;
+ cachePtr->nsvgImage = NULL;
+ }
+ }
+ CleanCache(interp);
+ return nsvgImage;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CleanCache --
+ *
+ * Reset the cache and delete the saved image in it.
+ *
+ * Results:
+ *
+ * Side effects:
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+CleanCache(Tcl_Interp *interp)
+{
+ NSVGcache *cachePtr = GetCachePtr(interp);
+
+ if (cachePtr != NULL) {
+ cachePtr->dataOrChan = NULL;
+ Tcl_DStringSetLength(&cachePtr->formatString, 0);
+ if (cachePtr->nsvgImage != NULL) {
+ nsvgDelete(cachePtr->nsvgImage);
+ cachePtr->nsvgImage = NULL;
+ }
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FreeCache --
+ *
+ * This function is called to clean up the internal cache data.
+ *
+ * Results:
+ *
+ * Side effects:
+ * Existing image data in the cache and the cache will be deleted.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+FreeCache(ClientData clientData, Tcl_Interp *interp)
+{
+ NSVGcache *cachePtr = (NSVGcache *)clientData;
+ (void)interp;
+
+ Tcl_DStringFree(&cachePtr->formatString);
+ if (cachePtr->nsvgImage != NULL) {
+ nsvgDelete(cachePtr->nsvgImage);
+ }
+ ckfree(cachePtr);
+}
+
diff --git a/generic/tkImgUtil.c b/generic/tkImgUtil.c
index 5487165..6a43fbe 100644
--- a/generic/tkImgUtil.c
+++ b/generic/tkImgUtil.c
@@ -55,7 +55,7 @@ TkAlignImageData(
dataWidth += (alignment - (dataWidth % alignment));
}
- data = ckalloc(dataWidth * image->height);
+ data = (char *)ckalloc(dataWidth * image->height);
destPtr = data;
for (i = 0; i < image->height; i++) {
diff --git a/generic/tkInt.decls b/generic/tkInt.decls
index 3a3cbc7..dd493e9 100644
--- a/generic/tkInt.decls
+++ b/generic/tkInt.decls
@@ -288,7 +288,7 @@ declare 78 {
}
declare 79 {
int TkScrollWindow(Tk_Window tkwin, GC gc, int x, int y,
- int width, int height, int dx, int dy, TkRegion damageRgn)
+ int width, int height, int dx, int dy, Region damageRgn)
}
declare 80 {
void TkSelDeadWindow(TkWindow *winPtr)
@@ -402,27 +402,27 @@ declare 112 {
void TkpMenuThreadInit(void)
}
declare 113 {
- void TkClipBox(TkRegion rgn, XRectangle *rect_return)
+ int XClipBox(Region rgn, XRectangle *rect_return)
}
declare 114 {
- TkRegion TkCreateRegion(void)
+ Region XCreateRegion(void)
}
declare 115 {
- void TkDestroyRegion(TkRegion rgn)
+ int XDestroyRegion(Region rgn)
}
declare 116 {
- void TkIntersectRegion(TkRegion sra, TkRegion srcb, TkRegion dr_return)
+ int XIntersectRegion(Region sra, Region srcb, Region dr_return)
}
declare 117 {
- int TkRectInRegion(TkRegion rgn, int x, int y, unsigned int width,
+ int XRectInRegion(Region rgn, int x, int y, unsigned int width,
unsigned int height)
}
declare 118 {
- void TkSetRegion(Display *display, GC gc, TkRegion rgn)
+ int XSetRegion(Display *display, GC gc, Region rgn)
}
declare 119 {
- void TkUnionRectWithRegion(XRectangle *rect,
- TkRegion src, TkRegion dr_return)
+ int XUnionRectWithRegion(XRectangle *rect,
+ Region src, Region dr_return)
}
declare 121 aqua {
Pixmap TkpCreateNativeBitmap(Display *display, const void *source)
@@ -452,7 +452,7 @@ declare 139 {
void TkpInitKeymapInfo(TkDisplay *dispPtr)
}
declare 140 {
- TkRegion TkPhotoGetValidRegion(Tk_PhotoHandle handle)
+ Region TkPhotoGetValidRegion(Tk_PhotoHandle handle)
}
declare 141 {
TkWindow **TkWmStackorderToplevel(TkWindow *parentPtr)
@@ -467,7 +467,7 @@ declare 144 {
void TkGCCleanup(TkDisplay *dispPtr)
}
declare 145 {
- void TkSubtractRegion(TkRegion sra, TkRegion srcb, TkRegion dr_return)
+ int XSubtractRegion(Region sra, Region srcb, Region dr_return)
}
declare 146 {
void TkStylePkgInit(TkMainInfo *mainPtr)
@@ -655,10 +655,9 @@ interface tkIntPlat
declare 0 x11 {
void TkCreateXEventSource(void)
}
-#
-# Slot 1 unused (WAS: TkFreeWindowId)
-# Slot 2 unused (WAS: TkInitXId)
-#
+declare 2 x11 {
+ void TkGenerateActivateEvents(TkWindow *winPtr, int active)
+}
declare 3 x11 {
int TkpCmapStressed(Tk_Window tkwin, Colormap colormap)
}
@@ -683,9 +682,6 @@ declare 9 x11 {
declare 10 x11 {
void TkSendCleanup(TkDisplay *dispPtr)
}
-#
-# Slot 11 unused (WAS: TkFreeXId)
-#
declare 12 x11 {
int TkpWmSetState(TkWindow *winPtr, int state)
}
@@ -694,6 +690,32 @@ declare 13 x11 {
int TkpTestsendCmd(ClientData clientData, Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[])
}
+declare 38 x11 {
+ int TkpCmapStressed_(Tk_Window tkwin, Colormap colormap)
+}
+declare 39 x11 {
+ void TkpSync_(Display *display)
+}
+declare 40 x11 {
+ Window TkUnixContainerId_(TkWindow *winPtr)
+}
+declare 41 x11 {
+ int TkUnixDoOneXEvent_(Tcl_Time *timePtr)
+}
+declare 42 x11 {
+ void TkUnixSetMenubar_(Tk_Window tkwin, Tk_Window menubar)
+}
+declare 43 x11 {
+ void TkWmCleanup_(TkDisplay *dispPtr)
+}
+declare 44 x11 {
+ void TkSendCleanup_(TkDisplay *dispPtr)
+}
+# only needed by tktest:
+declare 45 x11 {
+ int TkpTestsendCmd_(ClientData clientData, Tcl_Interp *interp, int objc,
+ Tcl_Obj *const objv[])
+}
################################
# Windows specific functions
@@ -851,6 +873,9 @@ declare 45 win {
int TkpTestsendCmd(ClientData clientData, Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[])
}
+declare 47 win {
+ Tk_Window TkpGetCapture(void)
+}
################################
# Aqua specific functions
@@ -858,16 +883,9 @@ declare 45 win {
declare 0 aqua {
void TkGenerateActivateEvents(TkWindow *winPtr, int active)
}
-
-# removed duplicates from tkInt table
-#declare 1 aqua {
-# Pixmap TkpCreateNativeBitmap(Display *display, const void *source)
-#}
-#
-#declare 2 aqua {
-# void TkpDefineNativeBitmaps(void)
-#}
-
+declare 2 aqua {
+ void TkGenerateActivateEvents_(TkWindow *winPtr, int active)
+}
declare 3 aqua {
void TkPointerDeadWindow(TkWindow *winPtr)
}
@@ -898,21 +916,9 @@ declare 11 aqua {
declare 12 aqua {
void TkMacOSXHandleTearoffMenu(void)
}
-
-# removed duplicate from tkPlat table(tk.decls)
-#declare 13 aqua {
-# void TkMacOSXInvalClipRgns(TkWindow *winPtr)
-#}
-
declare 14 aqua {
int TkMacOSXDoHLEvent(void *theEvent)
}
-
-# removed duplicate from tkPlat table(tk.decls)
-#declare 15 aqua {
-# void *TkMacOSXGetDrawablePort(Drawable drawable)
-#}
-
declare 16 aqua {
Window TkMacOSXGetXWindow(void *macWinPtr)
}
@@ -976,7 +982,7 @@ declare 34 aqua {
int TkMacOSXUseMenuID(short macID)
}
declare 35 aqua {
- TkRegion TkMacOSXVisableClipRgn(TkWindow *winPtr)
+ Region TkMacOSXVisableClipRgn(TkWindow *winPtr)
}
declare 36 aqua {
void TkMacOSXWinBounds(TkWindow *winPtr, void *geometry)
@@ -990,9 +996,6 @@ declare 38 aqua {
declare 39 aqua {
void TkSetWMName(TkWindow *winPtr, Tk_Uid titleUid)
}
-#
-# Slot 40 unused (WAS: TkSuspendClipboard)
-#
declare 41 aqua {
int TkMacOSXZoomToplevel(void *whichWindow, short zoomPart)
}
@@ -1013,7 +1016,7 @@ declare 46 aqua {
int TkpIsWindowFloating(void *window)
}
declare 47 aqua {
- Tk_Window TkMacOSXGetCapture(void)
+ Tk_Window TkpGetCapture(void)
}
declare 49 aqua {
Tk_Window TkGetTransientMaster(TkWindow *winPtr)
@@ -1027,17 +1030,9 @@ declare 51 aqua {
declare 52 aqua {
void TkMacOSXSetDrawingEnabled(TkWindow *winPtr, int flag)
}
-
-# removed duplicate from tkPlat table (tk.decls)
-#declare 52 aqua {
-# void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y,
-# int width, int height, int flags)
-#}
-
declare 53 aqua {
unsigned long TkpGetMS(void)
}
-
# For Canvas3d, requested by Sean Woods
declare 54 aqua {
void *TkMacOSXDrawable(Drawable drawable)
@@ -1506,328 +1501,556 @@ declare 138 win {
declare 139 win {
int XPointInRegion(Region rgn, int x, int y)
}
+# For XIM
+declare 140 win {
+ XVaNestedList XVaCreateNestedList(int dummy, ...)
+}
+declare 141 win {
+ char *XSetICValues(XIC xic, ...)
+}
+declare 142 win {
+ char *XGetICValues(XIC xic, ...)
+}
+declare 143 win {
+ void XSetICFocus(XIC xic)
+}
+declare 147 win {
+ void XFreeFontSet(Display *display, XFontSet fontset)
+}
+declare 148 win {
+ int XCloseIM(XIM im)
+}
+declare 149 win {
+ Bool XRegisterIMInstantiateCallback(Display *dpy, struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class, XIDProc callback, XPointer client_data)
+}
+declare 150 win {
+ Bool XUnregisterIMInstantiateCallback(Display *dpy, struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class, XIDProc callback, XPointer client_data)
+}
+declare 151 win {
+ char *XSetLocaleModifiers(const char *modifier_list)
+}
+declare 152 win {
+ XIM XOpenIM(Display *dpy, struct _XrmHashBucketRec *rdb, char *res_name,
+ char *res_class)
+}
+declare 153 win {
+ char *XGetIMValues(XIM im, ...)
+}
+declare 154 win {
+ char *XSetIMValues(XIM im, ...)
+}
+declare 155 win {
+ XFontSet XCreateFontSet(Display *display, _Xconst char *base_font_name_list,
+ char ***missing_charset_list, int *missing_charset_count, char **def_string)
+}
+declare 156 win {
+ void XFreeStringList(char **list)
+}
+declare 157 win {
+ KeySym XkbKeycodeToKeysym(Display *d, unsigned int k, int g, int i)
+}
+declare 158 win {
+ Display *XkbOpenDisplay(const char *name, int *ev_rtrn, int *err_rtrn,
+ int *major_rtrn, int *minor_rtrn, int *reason)
+}
################################
-# X functions for Aqua
+# X functions for MacOSX
-declare 0 aqua {
+declare 0 macosx {
int XSetDashes(Display *display, GC gc, int dash_offset,
_Xconst char *dash_list, int n)
}
-declare 1 aqua {
+declare 1 macosx {
XModifierKeymap *XGetModifierMapping(Display *d)
}
-declare 2 aqua {
+declare 2 macosx {
XImage *XCreateImage(Display *d, Visual *v, unsigned int ui1, int i1,
int i2, char *cp, unsigned int ui2, unsigned int ui3, int i3,
int i4)
}
-declare 3 aqua {
+declare 3 macosx {
XImage *XGetImage(Display *d, Drawable dr, int i1, int i2,
unsigned int ui1, unsigned int ui2, unsigned long ul, int i3)
}
-declare 4 aqua {
+declare 4 macosx {
char *XGetAtomName(Display *d, Atom a)
}
-declare 5 aqua {
+declare 5 macosx {
char *XKeysymToString(KeySym k)
}
-declare 6 aqua {
+declare 6 macosx {
Colormap XCreateColormap(Display *d, Window w, Visual *v, int i)
}
-declare 7 aqua {
+declare 7 macosx {
GContext XGContextFromGC(GC g)
}
-declare 8 aqua {
- KeySym XKeycodeToKeysym(Display *d, KeyCode k, int i)
+# second parameter was of type KeyCode
+declare 8 macosx {
+ KeySym XKeycodeToKeysym(Display *d, unsigned int k, int i)
}
-declare 9 aqua {
+declare 9 macosx {
KeySym XStringToKeysym(_Xconst char *c)
}
-declare 10 aqua {
+declare 10 macosx {
Window XRootWindow(Display *d, int i)
}
-declare 11 aqua {
+declare 11 macosx {
XErrorHandler XSetErrorHandler(XErrorHandler x)
}
-declare 12 aqua {
+declare 12 macosx {
Status XAllocColor(Display *d, Colormap c, XColor *xp)
}
-declare 13 aqua {
+declare 13 macosx {
int XBell(Display *d, int i)
}
-declare 14 aqua {
- void XChangeProperty(Display *d, Window w, Atom a1, Atom a2, int i1,
+declare 14 macosx {
+ int XChangeProperty(Display *d, Window w, Atom a1, Atom a2, int i1,
int i2, _Xconst unsigned char *c, int i3)
}
-declare 15 aqua {
- void XChangeWindowAttributes(Display *d, Window w, unsigned long ul,
+declare 15 macosx {
+ int XChangeWindowAttributes(Display *d, Window w, unsigned long ul,
XSetWindowAttributes *x)
}
-declare 16 aqua {
- void XConfigureWindow(Display *d, Window w, unsigned int i,
+declare 16 macosx {
+ int XConfigureWindow(Display *d, Window w, unsigned int i,
XWindowChanges *x)
}
-declare 17 aqua {
- void XCopyArea(Display *d, Drawable dr1, Drawable dr2, GC g, int i1,
+declare 17 macosx {
+ int XCopyArea(Display *d, Drawable dr1, Drawable dr2, GC g, int i1,
int i2, unsigned int ui1, unsigned int ui2, int i3, int i4)
}
-declare 18 aqua {
- void XCopyPlane(Display *d, Drawable dr1, Drawable dr2, GC g, int i1,
+declare 18 macosx {
+ int XCopyPlane(Display *d, Drawable dr1, Drawable dr2, GC g, int i1,
int i2, unsigned int ui1,
unsigned int ui2, int i3, int i4, unsigned long ul)
}
-declare 19 aqua {
+declare 19 macosx {
Pixmap XCreateBitmapFromData(Display *display, Drawable d,
_Xconst char *data, unsigned int width, unsigned int height)
}
-declare 20 aqua {
+declare 20 macosx {
int XDefineCursor(Display *d, Window w, Cursor c)
}
-declare 21 aqua {
- void XDestroyWindow(Display *d, Window w)
+declare 21 macosx {
+ int XDestroyWindow(Display *d, Window w)
}
-declare 22 aqua {
- void XDrawArc(Display *d, Drawable dr, GC g, int i1, int i2,
+declare 22 macosx {
+ int XDrawArc(Display *d, Drawable dr, GC g, int i1, int i2,
unsigned int ui1, unsigned int ui2, int i3, int i4)
}
-declare 23 aqua {
+declare 23 macosx {
int XDrawLines(Display *d, Drawable dr, GC g, XPoint *x, int i1, int i2)
}
-declare 24 aqua {
- void XDrawRectangle(Display *d, Drawable dr, GC g, int i1, int i2,
+declare 24 macosx {
+ int XDrawRectangle(Display *d, Drawable dr, GC g, int i1, int i2,
unsigned int ui1, unsigned int ui2)
}
-declare 25 aqua {
- void XFillArc(Display *d, Drawable dr, GC g, int i1, int i2,
+declare 25 macosx {
+ int XFillArc(Display *d, Drawable dr, GC g, int i1, int i2,
unsigned int ui1, unsigned int ui2, int i3, int i4)
}
-declare 26 aqua {
- void XFillPolygon(Display *d, Drawable dr, GC g, XPoint *x,
+declare 26 macosx {
+ int XFillPolygon(Display *d, Drawable dr, GC g, XPoint *x,
int i1, int i2, int i3)
}
-declare 27 aqua {
+declare 27 macosx {
int XFillRectangles(Display *d, Drawable dr, GC g, XRectangle *x, int i)
}
-declare 28 aqua {
+declare 28 macosx {
int XFreeColormap(Display *d, Colormap c)
}
-declare 29 aqua {
+declare 29 macosx {
int XFreeColors(Display *d, Colormap c,
unsigned long *ulp, int i, unsigned long ul)
}
-declare 30 aqua {
+declare 30 macosx {
int XFreeModifiermap(XModifierKeymap *x)
}
-declare 31 aqua {
+declare 31 macosx {
Status XGetGeometry(Display *d, Drawable dr, Window *w, int *i1,
int *i2, unsigned int *ui1, unsigned int *ui2, unsigned int *ui3,
unsigned int *ui4)
}
-declare 32 aqua {
+declare 32 macosx {
int XGetWindowProperty(Display *d, Window w, Atom a1, long l1, long l2,
Bool b, Atom a2, Atom *ap, int *ip, unsigned long *ulp1,
unsigned long *ulp2, unsigned char **cpp)
}
-declare 33 aqua {
+declare 33 macosx {
int XGrabKeyboard(Display *d, Window w, Bool b, int i1, int i2, Time t)
}
-declare 34 aqua {
+declare 34 macosx {
int XGrabPointer(Display *d, Window w1, Bool b, unsigned int ui,
int i1, int i2, Window w2, Cursor c, Time t)
}
-declare 35 aqua {
+declare 35 macosx {
KeyCode XKeysymToKeycode(Display *d, KeySym k)
}
-declare 36 aqua {
- void XMapWindow(Display *d, Window w)
+declare 36 macosx {
+ int XMapWindow(Display *d, Window w)
}
-declare 37 aqua {
- void XMoveResizeWindow(Display *d, Window w, int i1, int i2,
+declare 37 macosx {
+ int XMoveResizeWindow(Display *d, Window w, int i1, int i2,
unsigned int ui1, unsigned int ui2)
}
-declare 38 aqua {
- void XMoveWindow(Display *d, Window w, int i1, int i2)
+declare 38 macosx {
+ int XMoveWindow(Display *d, Window w, int i1, int i2)
}
-declare 39 aqua {
+declare 39 macosx {
Bool XQueryPointer(Display *d, Window w1, Window *w2, Window *w3,
int *i1, int *i2, int *i3, int *i4, unsigned int *ui)
}
-declare 40 aqua {
- void XRaiseWindow(Display *d, Window w)
+declare 40 macosx {
+ int XRaiseWindow(Display *d, Window w)
}
-declare 41 aqua {
- void XRefreshKeyboardMapping(XMappingEvent *x)
+declare 41 macosx {
+ int XRefreshKeyboardMapping(XMappingEvent *x)
}
-declare 42 aqua {
- void XResizeWindow(Display *d, Window w, unsigned int ui1,
+declare 42 macosx {
+ int XResizeWindow(Display *d, Window w, unsigned int ui1,
unsigned int ui2)
}
-declare 43 aqua {
- void XSelectInput(Display *d, Window w, long l)
+declare 43 macosx {
+ int XSelectInput(Display *d, Window w, long l)
}
-declare 44 aqua {
+declare 44 macosx {
Status XSendEvent(Display *d, Window w, Bool b, long l, XEvent *x)
}
-declare 45 aqua {
- void XSetIconName(Display *d, Window w, _Xconst char *c)
+declare 45 macosx {
+ int XSetIconName(Display *d, Window w, _Xconst char *c)
}
-declare 46 aqua {
- void XSetInputFocus(Display *d, Window w, int i, Time t)
+declare 46 macosx {
+ int XSetInputFocus(Display *d, Window w, int i, Time t)
}
-declare 47 aqua {
+declare 47 macosx {
int XSetSelectionOwner(Display *d, Atom a, Window w, Time t)
}
-declare 48 aqua {
- void XSetWindowBackground(Display *d, Window w, unsigned long ul)
+declare 48 macosx {
+ int XSetWindowBackground(Display *d, Window w, unsigned long ul)
}
-declare 49 aqua {
- void XSetWindowBackgroundPixmap(Display *d, Window w, Pixmap p)
+declare 49 macosx {
+ int XSetWindowBackgroundPixmap(Display *d, Window w, Pixmap p)
}
-declare 50 aqua {
- void XSetWindowBorder(Display *d, Window w, unsigned long ul)
+declare 50 macosx {
+ int XSetWindowBorder(Display *d, Window w, unsigned long ul)
}
-declare 51 aqua {
- void XSetWindowBorderPixmap(Display *d, Window w, Pixmap p)
+declare 51 macosx {
+ int XSetWindowBorderPixmap(Display *d, Window w, Pixmap p)
}
-declare 52 aqua {
- void XSetWindowBorderWidth(Display *d, Window w, unsigned int ui)
+declare 52 macosx {
+ int XSetWindowBorderWidth(Display *d, Window w, unsigned int ui)
}
-declare 53 aqua {
- void XSetWindowColormap(Display *d, Window w, Colormap c)
+declare 53 macosx {
+ int XSetWindowColormap(Display *d, Window w, Colormap c)
}
-declare 54 aqua {
- void XUngrabKeyboard(Display *d, Time t)
+declare 54 macosx {
+ int XUngrabKeyboard(Display *d, Time t)
}
-declare 55 aqua {
+declare 55 macosx {
int XUngrabPointer(Display *d, Time t)
}
-declare 56 aqua {
- void XUnmapWindow(Display *d, Window w)
+declare 56 macosx {
+ int XUnmapWindow(Display *d, Window w)
}
-declare 57 aqua {
+declare 57 macosx {
int TkPutImage(unsigned long *colors, int ncolors, Display *display,
Drawable d, GC gc, XImage *image, int src_x, int src_y,
int dest_x, int dest_y, unsigned int width, unsigned int height)
}
-declare 58 aqua {
+declare 58 macosx {
Status XParseColor(Display *display, Colormap map,
_Xconst char *spec, XColor *colorPtr)
}
-declare 59 aqua {
+declare 59 macosx {
GC XCreateGC(Display *display, Drawable d,
unsigned long valuemask, XGCValues *values)
}
-declare 60 aqua {
+declare 60 macosx {
int XFreeGC(Display *display, GC gc)
}
-declare 61 aqua {
+declare 61 macosx {
Atom XInternAtom(Display *display, _Xconst char *atom_name,
Bool only_if_exists)
}
-declare 62 aqua {
+declare 62 macosx {
int XSetBackground(Display *display, GC gc, unsigned long foreground)
}
-declare 63 aqua {
+declare 63 macosx {
int XSetForeground(Display *display, GC gc, unsigned long foreground)
}
-declare 64 aqua {
+declare 64 macosx {
int XSetClipMask(Display *display, GC gc, Pixmap pixmap)
}
-declare 65 aqua {
+declare 65 macosx {
int XSetClipOrigin(Display *display, GC gc,
int clip_x_origin, int clip_y_origin)
}
-declare 66 aqua {
+declare 66 macosx {
int XSetTSOrigin(Display *display, GC gc,
int ts_x_origin, int ts_y_origin)
}
-declare 67 aqua {
+declare 67 macosx {
int XChangeGC(Display *d, GC gc, unsigned long mask, XGCValues *values)
}
-declare 68 aqua {
+declare 68 macosx {
int XSetFont(Display *display, GC gc, Font font)
}
-declare 69 aqua {
+declare 69 macosx {
int XSetArcMode(Display *display, GC gc, int arc_mode)
}
-declare 70 aqua {
+declare 70 macosx {
int XSetStipple(Display *display, GC gc, Pixmap stipple)
}
-declare 71 aqua {
+declare 71 macosx {
int XSetFillRule(Display *display, GC gc, int fill_rule)
}
-declare 72 aqua {
+declare 72 macosx {
int XSetFillStyle(Display *display, GC gc, int fill_style)
}
-declare 73 aqua {
+declare 73 macosx {
int XSetFunction(Display *display, GC gc, int function)
}
-declare 74 aqua {
+declare 74 macosx {
int XSetLineAttributes(Display *display, GC gc, unsigned int line_width,
int line_style, int cap_style, int join_style)
}
-declare 75 aqua {
+declare 75 macosx {
int _XInitImageFuncPtrs(XImage *image)
}
-declare 76 aqua {
- XIC XCreateIC(void)
+declare 76 macosx {
+ XIC XCreateIC(XIM xim, ...)
}
-declare 77 aqua {
+declare 77 macosx {
XVisualInfo *XGetVisualInfo(Display *display, long vinfo_mask,
XVisualInfo *vinfo_template, int *nitems_return)
}
-declare 78 aqua {
+declare 78 macosx {
void XSetWMClientMachine(Display *display, Window w,
XTextProperty *text_prop)
}
-declare 79 aqua {
+declare 79 macosx {
Status XStringListToTextProperty(char **list, int count,
XTextProperty *text_prop_return)
}
-declare 80 aqua {
+declare 80 macosx {
int XDrawSegments(Display *display, Drawable d, GC gc,
XSegment *segments, int nsegments)
}
-declare 81 aqua {
- void XForceScreenSaver(Display *display, int mode)
+declare 81 macosx {
+ int XForceScreenSaver(Display *display, int mode)
}
-declare 82 aqua {
+declare 82 macosx {
int XDrawLine(Display *d, Drawable dr, GC g, int x1, int y1,
int x2, int y2)
}
-declare 83 aqua {
+declare 83 macosx {
int XFillRectangle(Display *display, Drawable d, GC gc,
int x, int y, unsigned int width, unsigned int height)
}
-declare 84 aqua {
- void XClearWindow(Display *d, Window w)
+declare 84 macosx {
+ int XClearWindow(Display *d, Window w)
}
-declare 85 aqua {
+declare 85 macosx {
int XDrawPoint(Display *display, Drawable d, GC gc, int x, int y)
}
-declare 86 aqua {
+declare 86 macosx {
int XDrawPoints(Display *display, Drawable d, GC gc, XPoint *points,
int npoints, int mode)
}
-declare 87 aqua {
+declare 87 macosx {
int XWarpPointer(Display *display, Window src_w, Window dest_w,
int src_x, int src_y, unsigned int src_width,
unsigned int src_height, int dest_x, int dest_y)
}
-declare 88 aqua {
- void XQueryColor(Display *display, Colormap colormap, XColor *def_in_out)
+declare 88 macosx {
+ int XQueryColor(Display *display, Colormap colormap, XColor *def_in_out)
}
-declare 89 aqua {
- void XQueryColors(Display *display, Colormap colormap,
+declare 89 macosx {
+ int XQueryColors(Display *display, Colormap colormap,
XColor *defs_in_out, int ncolors)
}
-declare 90 aqua {
+declare 90 macosx {
Status XQueryTree(Display *d, Window w1, Window *w2, Window *w3,
Window **w4, unsigned int *ui)
}
-declare 91 aqua {
- int XSync(Display *display, Bool flag)
+declare 91 macosx {
+ int XSync(Display *display, Bool discard)
+}
+declare 92 macosx {
+ Bool XTranslateCoordinates(Display *d, Window w1, Window w2, int i1,
+ int i2, int *i3, int *i4, Window *w3)
+}
+declare 93 macosx {
+ int XDeleteProperty(Display *d, Window w, Atom a)
+}
+declare 94 macosx {
+ int XFreeCursor(Display *d, Cursor c)
+}
+declare 95 macosx {
+ int XGetInputFocus(Display *d, Window *w, int *i)
+}
+declare 96 macosx {
+ int XmbLookupString(XIC xi, XKeyPressedEvent *xk, char *c, int i,
+ KeySym *k, Status *s)
+}
+declare 97 macosx {
+ int XNextEvent(Display *d, XEvent *x)
+}
+declare 98 macosx {
+ int XPutBackEvent(Display *d, XEvent *x)
+}
+declare 99 macosx {
+ int XSetCommand(Display *d, Window w, char **c, int i)
+}
+declare 100 macosx {
+ int XWindowEvent(Display *d, Window w, long l, XEvent *x)
+}
+declare 101 macosx {
+ Status XGetWindowAttributes(Display *d, Window w, XWindowAttributes *x)
+}
+declare 102 macosx {
+ Status XGetWMColormapWindows(Display *d, Window w, Window **wpp, int *ip)
+}
+declare 103 macosx {
+ Status XIconifyWindow(Display *d, Window w, int i)
+}
+declare 104 macosx {
+ Status XWithdrawWindow(Display *d, Window w, int i)
+}
+declare 105 macosx {
+ XHostAddress *XListHosts(Display *d, int *i, Bool *b)
+}
+declare 107 macosx {
+ int XFlush(Display *display)
+}
+declare 108 macosx {
+ int XGrabServer(Display *display)
+}
+declare 109 macosx {
+ int XUngrabServer(Display *display)
+}
+declare 110 macosx {
+ int XFree(void *data)
+}
+declare 111 macosx {
+ int XNoOp(Display *display)
+}
+declare 112 macosx {
+ XAfterFunction XSynchronize(Display *display, Bool onoff)
+}
+declare 113 macosx {
+ Status XLookupColor(Display *d, Colormap c1, _Xconst char *c2,
+ XColor *x1, XColor *x2)
+}
+declare 114 macosx {
+ VisualID XVisualIDFromVisual(Visual *visual)
+}
+declare 120 macosx {
+ int XOffsetRegion(Region rgn, int dx, int dy)
+}
+declare 121 macosx {
+ int XUnionRegion(Region srca, Region srcb, Region dr_return)
+}
+declare 122 macosx {
+ Window XCreateWindow(Display *display, Window parent, int x, int y,
+ unsigned int width, unsigned int height,
+ unsigned int border_width, int depth, unsigned int clazz,
+ Visual *visual, unsigned long value_mask,
+ XSetWindowAttributes *attributes)
+}
+declare 129 macosx {
+ int XLowerWindow(Display *d, Window w)
+}
+declare 130 macosx {
+ int XFillArcs(Display *d, Drawable dr, GC gc, XArc *a, int n)
+}
+declare 131 macosx {
+ int XDrawArcs(Display *d, Drawable dr, GC gc, XArc *a, int n)
+}
+declare 132 macosx {
+ int XDrawRectangles(Display *d, Drawable dr, GC gc, XRectangle *r, int n)
+}
+declare 136 macosx {
+ int XReparentWindow(Display *d, Window w, Window p, int x, int y)
+}
+declare 137 macosx {
+ int XPutImage(Display *d, Drawable dr, GC gc, XImage *im,
+ int sx, int sy, int dx, int dy,
+ unsigned int w, unsigned int h)
+}
+declare 138 macosx {
+ Region XPolygonRegion(XPoint *pts, int n, int rule)
+}
+declare 139 macosx {
+ int XPointInRegion(Region rgn, int x, int y)
+}
+declare 140 macosx {
+ XVaNestedList XVaCreateNestedList(int dummy, ...)
+}
+declare 141 macosx {
+ char *XSetICValues(XIC xic, ...)
+}
+declare 142 macosx {
+ char *XGetICValues(XIC xic, ...)
+}
+declare 143 macosx {
+ void XSetICFocus(XIC xic)
+}
+declare 144 macosx {
+ void XDestroyIC(XIC xic)
+}
+declare 145 macosx {
+ Cursor XCreatePixmapCursor(Display *d, Pixmap p1, Pixmap p2,
+ XColor *x1, XColor *x2, unsigned int ui1, unsigned int ui2)
+}
+declare 146 macosx {
+ Cursor XCreateGlyphCursor(Display *d, Font f1, Font f2,
+ unsigned int ui1, unsigned int ui2, XColor _Xconst *x1,
+ XColor _Xconst *x2)
+}
+declare 147 macosx {
+ void XFreeFontSet(Display *display, XFontSet fontset)
+}
+declare 148 macosx {
+ int XCloseIM(XIM im)
+}
+declare 149 macosx {
+ Bool XRegisterIMInstantiateCallback(Display *dpy, struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class, XIDProc callback, XPointer client_data)
+}
+declare 150 macosx {
+ Bool XUnregisterIMInstantiateCallback(Display *dpy, struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class, XIDProc callback, XPointer client_data)
+}
+declare 151 macosx {
+ char *XSetLocaleModifiers(const char *modifier_list)
+}
+declare 152 macosx {
+ XIM XOpenIM(Display *dpy, struct _XrmHashBucketRec *rdb, char *res_name,
+ char *res_class)
+}
+declare 153 macosx {
+ char *XGetIMValues(XIM im, ...)
+}
+declare 154 macosx {
+ char *XSetIMValues(XIM im, ...)
+}
+declare 155 macosx {
+ XFontSet XCreateFontSet(Display *display, _Xconst char *base_font_name_list,
+ char ***missing_charset_list, int *missing_charset_count, char **def_string)
+}
+declare 156 macosx {
+ void XFreeStringList(char **list)
+}
+declare 157 macosx {
+ KeySym XkbKeycodeToKeysym(Display *d, unsigned int k, int g, int i)
+}
+declare 158 macosx {
+ Display *XkbOpenDisplay(const char *name, int *ev_rtrn, int *err_rtrn,
+ int *major_rtrn, int *minor_rtrn, int *reason)
}
# Local Variables:
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 767bbbb..6ebf8eb 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -58,6 +58,21 @@
# endif
#endif
+#ifndef JOIN
+# define JOIN(a,b) JOIN1(a,b)
+# define JOIN1(a,b) a##b
+#endif
+
+#ifndef TCL_UNUSED
+# if defined(__cplusplus)
+# define TCL_UNUSED(T) T
+# elif defined(__GNUC__) && (__GNUC__ > 2)
+# define TCL_UNUSED(T) T JOIN(dummy, __LINE__) __attribute__((unused))
+# else
+# define TCL_UNUSED(T) T JOIN(dummy, __LINE__)
+# endif
+#endif
+
#ifndef TkSizeT
# if TCL_MAJOR_VERSION > 8
# define TkSizeT size_t
@@ -66,6 +81,13 @@
# endif
#endif
+#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 7)
+# define Tcl_WCharToUtfDString ((char * (*)(const WCHAR *, int len, Tcl_DString *))Tcl_UniCharToUtfDString)
+# define Tcl_UtfToWCharDString ((WCHAR * (*)(const char *, int len, Tcl_DString *))Tcl_UtfToUniCharDString)
+# define Tcl_Char16ToUtfDString Tcl_UniCharToUtfDString
+# define Tcl_UtfToChar16DString Tcl_UtfToUniCharDString
+#endif
+
/*
* Macros used to cast between pointers and integers (e.g. when storing an int
* in ClientData), on 64-bit architectures they avoid gcc warning about "cast
@@ -91,10 +113,6 @@
# endif
#endif
-#ifndef TCL_AUTO_LENGTH
-# define TCL_AUTO_LENGTH (-1)
-#endif
-
#ifndef TCL_Z_MODIFIER
# if defined(_WIN64)
# define TCL_Z_MODIFIER "I"
@@ -113,7 +131,7 @@ typedef struct TkColormap TkColormap;
typedef struct TkFontAttributes TkFontAttributes;
typedef struct TkGrabEvent TkGrabEvent;
typedef struct TkpCursor_ *TkpCursor;
-typedef struct TkRegion_ *TkRegion;
+#define TkRegion Region
typedef struct TkStressedCmap TkStressedCmap;
typedef struct TkBindInfo_ *TkBindInfo;
typedef struct Busy *TkBusy;
@@ -172,6 +190,8 @@ typedef struct TkCaret {
* specific data, since each thread will have its own TkDisplay structure.
*/
+typedef enum TkLockUsage {LU_IGNORE, LU_CAPS, LU_SHIFT} TkLockUsage;
+
typedef struct TkDisplay {
Display *display; /* Xlib's info about display. */
struct TkDisplay *nextPtr; /* Next in list of all displays. */
@@ -213,7 +233,7 @@ typedef struct TkDisplay {
unsigned int altModMask; /* Has one bit set to indicate the modifier
* corresponding to the "Meta" key. If no such
* modifier, then this is zero. */
- enum {LU_IGNORE, LU_CAPS, LU_SHIFT} lockUsage;
+ TkLockUsage lockUsage;
/* Indicates how to interpret lock
* modifier. */
int numModKeyCodes; /* Number of entries in modKeyCodes array
@@ -344,6 +364,9 @@ typedef struct TkDisplay {
* by that master. */
int geomInit;
+#define TkGetGeomMaster(tkwin) (((TkWindow *)tkwin)->maintainerPtr != NULL ? \
+ ((TkWindow *)tkwin)->maintainerPtr : ((TkWindow *)tkwin)->parentPtr)
+
/*
* Information used by tkGet.c only:
*/
@@ -493,7 +516,7 @@ typedef struct TkDisplay {
* Miscellaneous information:
*/
-#ifdef TK_USE_INPUT_METHODS
+#if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8)
XIM inputMethod; /* Input method for this display. */
XIMStyle inputStyle; /* Input style selected for this display. */
XFontSet inputXfs; /* XFontSet cached for over-the-spot XIM. */
@@ -509,10 +532,17 @@ typedef struct TkDisplay {
* The following field were all added for Tk8.3
*/
+#if TCL_MAJOR_VERSION < 9
+#if !defined(TK_NO_DEPRECATED)
int mouseButtonState; /* Current mouse button state for this
- * display. */
+ * display. NOT USED as of 8.6.10 */
Window mouseButtonWindow; /* Window the button state was set in, added
* in Tk 8.4. */
+#else
+ int notused1;
+ XID notused2;
+#endif /* !TK_NO_DEPRECATED */
+#endif
Tk_Window warpWindow;
Tk_Window warpMainwin; /* For finding the root window for warping
* purposes. */
@@ -530,8 +560,11 @@ typedef struct TkDisplay {
int iconDataSize; /* Size of default iconphoto image data. */
unsigned char *iconDataPtr; /* Default iconphoto image data, if set. */
-#ifdef TK_USE_INPUT_METHODS
int ximGeneration; /* Used to invalidate XIC */
+#if !defined(TK_USE_INPUT_METHODS) && (TCL_MAJOR_VERSION < 9)
+ XIM inputMethod; /* Input method for this display. */
+ XIMStyle inputStyle; /* Input style selected for this display. */
+ XFontSet inputXfs; /* XFontSet cached for over-the-spot XIM. */
#endif /* TK_USE_INPUT_METHODS */
} TkDisplay;
@@ -551,7 +584,6 @@ typedef struct TkDisplay {
#define TK_DISPLAY_USE_IM (1 << 1)
#define TK_DISPLAY_WM_TRACING (1 << 3)
#define TK_DISPLAY_IN_WARP (1 << 4)
-#define TK_DISPLAY_USE_XKB (1 << 5)
/*
* One of the following structures exists for each error handler created by a
@@ -756,7 +788,7 @@ typedef struct TkWindow {
TkEventHandler *handlerList;/* First in list of event handlers declared
* for this window, or NULL if none. */
-#ifdef TK_USE_INPUT_METHODS
+#if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8)
XIC inputContext; /* XIM input context. */
#endif /* TK_USE_INPUT_METHODS */
@@ -837,8 +869,16 @@ typedef struct TkWindow {
int minReqWidth; /* Minimum requested width. */
int minReqHeight; /* Minimum requested height. */
- char *geometryMaster;
-#ifdef TK_USE_INPUT_METHODS
+#if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8)
+ int ximGeneration; /* Used to invalidate XIC */
+#endif /* TK_USE_INPUT_METHODS */
+ char *geomMgrName; /* Records the name of the geometry manager. */
+ struct TkWindow *maintainerPtr;
+ /* The geometry master for this window. The
+ * value is NULL if the window has no master or
+ * if its master is its parent. */
+#if !defined(TK_USE_INPUT_METHODS) && (TCL_MAJOR_VERSION < 9)
+ XIC inputContext; /* XIM input context. */
int ximGeneration; /* Used to invalidate XIC */
#endif /* TK_USE_INPUT_METHODS */
} TkWindow;
@@ -849,8 +889,13 @@ typedef struct TkWindow {
*/
typedef struct {
- XKeyEvent keyEvent; /* The real event from X11. */
- char *charValuePtr; /* A pointer to a string that holds the key's
+ XKeyEvent keyEvent; /* The real event from X11. */
+#ifdef _WIN32
+ char trans_chars[XMaxTransChars];
+ /* translated characters */
+ unsigned char nbytes;
+#elif !defined(MAC_OSC_TK)
+ char *charValuePtr; /* A pointer to a string that holds the key's
* %A substitution text (before backslash
* adding), or NULL if that has not been
* computed yet. If non-NULL, this string was
@@ -859,6 +904,7 @@ typedef struct {
* is non-NULL. */
KeySym keysym; /* Key symbol computed after input methods
* have been invoked */
+#endif
} TkKeyEvent;
/*
@@ -873,6 +919,10 @@ typedef struct {
#ifndef TCL_IO_FAILURE
# define TCL_IO_FAILURE (-1)
#endif
+/* See TIP #537 */
+#ifndef TCL_INDEX_NONE
+# define TCL_INDEX_NONE (-1)
+#endif
/*
* The following structure is used with TkMakeEnsemble to create ensemble
@@ -905,7 +955,7 @@ typedef struct TkpClipMask {
int type; /* TKP_CLIP_PIXMAP or TKP_CLIP_REGION. */
union {
Pixmap pixmap;
- TkRegion region;
+ Region region;
} value;
} TkpClipMask;
@@ -954,6 +1004,38 @@ typedef struct TkpClipMask {
#define ALT_MASK (AnyModifier<<2)
#define EXTENDED_MASK (AnyModifier<<3)
+#ifndef Button8
+# define Button8 8
+#endif
+#ifndef Button9
+# define Button9 9
+#endif
+
+#ifndef Button6Mask
+# define Button6Mask (1<<13)
+#endif
+#ifndef Button7Mask
+# define Button7Mask (1<<14)
+#endif
+#ifndef Button8Mask
+# define Button8Mask (AnyModifier<<4)
+#endif
+#ifndef Button9Mask
+# define Button9Mask (AnyModifier<<5)
+#endif
+
+/*
+ * Mask that selects any of the state bits corresponding to buttons, plus
+ * masks that select individual buttons' bits:
+ */
+
+#define ALL_BUTTONS \
+ (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask \
+ |Button6Mask|Button7Mask|Button8Mask|Button9Mask)
+
+
+MODULE_SCOPE unsigned long TkGetButtonMask(unsigned int);
+
/*
* Object types not declared in tkObj.c need to be mentioned here so they can
* be properly registered with Tcl:
@@ -979,6 +1061,7 @@ MODULE_SCOPE void (*tkHandleEventProc) (XEvent* eventPtr);
MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtDefault;
MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtPNG;
MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtPPM;
+MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtSVGnano;
MODULE_SCOPE TkMainInfo *tkMainWindowList;
MODULE_SCOPE Tk_ImageType tkPhotoImageType;
MODULE_SCOPE Tcl_HashTable tkPredefBitmapTable;
@@ -1008,7 +1091,6 @@ MODULE_SCOPE const char *const tkWebColors[20];
void Tcl_Panic(const char *, ...) __attribute__((analyzer_noreturn));
#endif
#if !defined(CLANG_ASSERT)
-#include <assert.h>
#define CLANG_ASSERT(x) assert(x)
#endif
#elif !defined(CLANG_ASSERT)
@@ -1209,7 +1291,7 @@ MODULE_SCOPE void TkDeleteExitHandler(Tcl_ExitProc *proc,
ClientData clientData);
MODULE_SCOPE Tcl_ExitProc TkFinalize;
MODULE_SCOPE Tcl_ExitProc TkFinalizeThread;
-MODULE_SCOPE void TkpBuildRegionFromAlphaData(TkRegion region,
+MODULE_SCOPE void TkpBuildRegionFromAlphaData(Region region,
unsigned x, unsigned y, unsigned width,
unsigned height, unsigned char *dataPtr,
unsigned pixelStride, unsigned lineStride);
@@ -1235,6 +1317,9 @@ MODULE_SCOPE void TkUnderlineCharsInContext(Display *display,
int firstByte, int lastByte);
MODULE_SCOPE void TkpGetFontAttrsForChar(Tk_Window tkwin, Tk_Font tkfont,
int c, struct TkFontAttributes *faPtr);
+MODULE_SCOPE void TkpDrawFrameEx(Tk_Window tkwin, Drawable drawable,
+ Tk_3DBorder border, int highlightWidth,
+ int borderWidth, int relief);
MODULE_SCOPE Tcl_Obj * TkNewWindowObj(Tk_Window tkwin);
MODULE_SCOPE void TkpShowBusyWindow(TkBusy busy);
MODULE_SCOPE void TkpHideBusyWindow(TkBusy busy);
@@ -1254,11 +1339,18 @@ MODULE_SCOPE int TkInitTkCmd(Tcl_Interp *interp,
ClientData clientData);
MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp,
ClientData clientData);
+MODULE_SCOPE void TkInitEmbeddedConfigurationInformation(
+ Tcl_Interp *interp);
MODULE_SCOPE void TkpWarpPointer(TkDisplay *dispPtr);
MODULE_SCOPE void TkpCancelWarp(TkDisplay *dispPtr);
MODULE_SCOPE int TkListCreateFrame(ClientData clientData,
Tcl_Interp *interp, Tcl_Obj *listObj,
int toplevel, Tcl_Obj *nameObj);
+MODULE_SCOPE void TkRotatePoint(double originX, double originY,
+ double sine, double cosine, double *xPtr,
+ double *yPtr);
+MODULE_SCOPE int TkGetIntForIndex(Tcl_Obj *, TkSizeT, int lastOK, TkSizeT*);
+
#ifdef _WIN32
#define TkParseColor XParseColor
@@ -1267,24 +1359,56 @@ MODULE_SCOPE Status TkParseColor (Display * display,
Colormap map, const char* spec,
XColor * colorPtr);
#endif
+#if !defined(_WIN32) && !defined(__CYGWIN__) /* UNIX and MacOSX */
+#undef TkPutImage
+#define TkPutImage(colors, ncolors, display, pixels, gc, image, srcx, srcy, destx, desty, width, height) \
+ XPutImage(display, pixels, gc, image, srcx, srcy, destx, desty, width, height);
+#else
+#undef XPutImage
+#define XPutImage(display, pixels, gc, image, srcx, srcy, destx, desty, width, height) \
+ TkPutImage(NULL, 0, display, pixels, gc, image, srcx, srcy, destx, desty, width, height);
+#endif
+
+/*
+ * These macros are just wrappers for the equivalent X Region calls.
+ */
+#define TkClipBox XClipBox
+#define TkCreateRegion XCreateRegion
+#define TkDestroyRegion XDestroyRegion
+#define TkIntersectRegion XIntersectRegion
+#define TkRectInRegion XRectInRegion
+#define TkSetRegion XSetRegion
+#define TkSubtractRegion XSubtractRegion
+#define TkUnionRectWithRegion XUnionRectWithRegion
+
#ifdef HAVE_XFT
-MODULE_SCOPE void TkUnixSetXftClipRegion(TkRegion clipRegion);
+MODULE_SCOPE void TkUnixSetXftClipRegion(Region clipRegion);
+#endif
+
+#if !defined(__cplusplus) && !defined(c_plusplus)
+# define c_class class
#endif
#if TCL_UTF_MAX > 4
# define TkUtfToUniChar (size_t)Tcl_UtfToUniChar
# define TkUniCharToUtf (size_t)Tcl_UniCharToUtf
+# define TkUtfPrev Tcl_UtfPrev
#else
MODULE_SCOPE size_t TkUtfToUniChar(const char *, int *);
MODULE_SCOPE size_t TkUniCharToUtf(int, char *);
+ MODULE_SCOPE const char *TkUtfPrev(const char *, const char *);
#endif
+#if TCL_MAJOR_VERSION > 8
#define TkGetStringFromObj(objPtr, lenPtr) \
(((objPtr)->bytes ? 0 : Tcl_GetString(objPtr)), \
*(lenPtr) = (objPtr)->length, (objPtr)->bytes)
-
MODULE_SCOPE unsigned char *TkGetByteArrayFromObj(Tcl_Obj *objPtr,
size_t *lengthPtr);
+#else
+#define TkGetStringFromObj Tcl_GetStringFromObj
+#define TkGetByteArrayFromObj Tcl_GetByteArrayFromObj
+#endif
/*
* Unsupported commands.
diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h
index a646779..0b3a3cc 100644
--- a/generic/tkIntDecls.h
+++ b/generic/tkIntDecls.h
@@ -15,6 +15,8 @@
#ifndef _TKINTDECLS
#define _TKINTDECLS
+#include "X11/Xutil.h"
+
#ifdef BUILD_tk
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
@@ -254,7 +256,7 @@ EXTERN int TkReadBitmapFile(Display *display, Drawable d,
/* 79 */
EXTERN int TkScrollWindow(Tk_Window tkwin, GC gc, int x, int y,
int width, int height, int dx, int dy,
- TkRegion damageRgn);
+ Region damageRgn);
/* 80 */
EXTERN void TkSelDeadWindow(TkWindow *winPtr);
/* 81 */
@@ -334,22 +336,22 @@ EXTERN Tcl_Obj * TkpGetSystemDefault(Tk_Window tkwin,
/* 112 */
EXTERN void TkpMenuThreadInit(void);
/* 113 */
-EXTERN void TkClipBox(TkRegion rgn, XRectangle *rect_return);
+EXTERN int XClipBox(Region rgn, XRectangle *rect_return);
/* 114 */
-EXTERN TkRegion TkCreateRegion(void);
+EXTERN Region XCreateRegion(void);
/* 115 */
-EXTERN void TkDestroyRegion(TkRegion rgn);
+EXTERN int XDestroyRegion(Region rgn);
/* 116 */
-EXTERN void TkIntersectRegion(TkRegion sra, TkRegion srcb,
- TkRegion dr_return);
+EXTERN int XIntersectRegion(Region sra, Region srcb,
+ Region dr_return);
/* 117 */
-EXTERN int TkRectInRegion(TkRegion rgn, int x, int y,
+EXTERN int XRectInRegion(Region rgn, int x, int y,
unsigned int width, unsigned int height);
/* 118 */
-EXTERN void TkSetRegion(Display *display, GC gc, TkRegion rgn);
+EXTERN int XSetRegion(Display *display, GC gc, Region rgn);
/* 119 */
-EXTERN void TkUnionRectWithRegion(XRectangle *rect, TkRegion src,
- TkRegion dr_return);
+EXTERN int XUnionRectWithRegion(XRectangle *rect, Region src,
+ Region dr_return);
/* Slot 120 is reserved */
#ifdef MAC_OSX_TK /* AQUA */
/* 121 */
@@ -390,7 +392,7 @@ EXTERN KeySym TkpGetKeySym(TkDisplay *dispPtr, XEvent *eventPtr);
/* 139 */
EXTERN void TkpInitKeymapInfo(TkDisplay *dispPtr);
/* 140 */
-EXTERN TkRegion TkPhotoGetValidRegion(Tk_PhotoHandle handle);
+EXTERN Region TkPhotoGetValidRegion(Tk_PhotoHandle handle);
/* 141 */
EXTERN TkWindow ** TkWmStackorderToplevel(TkWindow *parentPtr);
/* 142 */
@@ -400,8 +402,8 @@ EXTERN void TkClipCleanup(TkDisplay *dispPtr);
/* 144 */
EXTERN void TkGCCleanup(TkDisplay *dispPtr);
/* 145 */
-EXTERN void TkSubtractRegion(TkRegion sra, TkRegion srcb,
- TkRegion dr_return);
+EXTERN int XSubtractRegion(Region sra, Region srcb,
+ Region dr_return);
/* 146 */
EXTERN void TkStylePkgInit(TkMainInfo *mainPtr);
/* 147 */
@@ -638,7 +640,7 @@ typedef struct TkIntStubs {
void (*reserved76)(void);
void (*tkQueueEventForAllChildren) (TkWindow *winPtr, XEvent *eventPtr); /* 77 */
int (*tkReadBitmapFile) (Display *display, Drawable d, const char *filename, unsigned int *width_return, unsigned int *height_return, Pixmap *bitmap_return, int *x_hot_return, int *y_hot_return); /* 78 */
- int (*tkScrollWindow) (Tk_Window tkwin, GC gc, int x, int y, int width, int height, int dx, int dy, TkRegion damageRgn); /* 79 */
+ int (*tkScrollWindow) (Tk_Window tkwin, GC gc, int x, int y, int width, int height, int dx, int dy, Region damageRgn); /* 79 */
void (*tkSelDeadWindow) (TkWindow *winPtr); /* 80 */
void (*tkSelEventProc) (Tk_Window tkwin, XEvent *eventPtr); /* 81 */
void (*tkSelInit) (Tk_Window tkwin); /* 82 */
@@ -672,13 +674,13 @@ typedef struct TkIntStubs {
void (*tkpGetSubFonts) (Tcl_Interp *interp, Tk_Font tkfont); /* 110 */
Tcl_Obj * (*tkpGetSystemDefault) (Tk_Window tkwin, const char *dbName, const char *className); /* 111 */
void (*tkpMenuThreadInit) (void); /* 112 */
- void (*tkClipBox) (TkRegion rgn, XRectangle *rect_return); /* 113 */
- TkRegion (*tkCreateRegion) (void); /* 114 */
- void (*tkDestroyRegion) (TkRegion rgn); /* 115 */
- void (*tkIntersectRegion) (TkRegion sra, TkRegion srcb, TkRegion dr_return); /* 116 */
- int (*tkRectInRegion) (TkRegion rgn, int x, int y, unsigned int width, unsigned int height); /* 117 */
- void (*tkSetRegion) (Display *display, GC gc, TkRegion rgn); /* 118 */
- void (*tkUnionRectWithRegion) (XRectangle *rect, TkRegion src, TkRegion dr_return); /* 119 */
+ int (*xClipBox) (Region rgn, XRectangle *rect_return); /* 113 */
+ Region (*xCreateRegion) (void); /* 114 */
+ int (*xDestroyRegion) (Region rgn); /* 115 */
+ int (*xIntersectRegion) (Region sra, Region srcb, Region dr_return); /* 116 */
+ int (*xRectInRegion) (Region rgn, int x, int y, unsigned int width, unsigned int height); /* 117 */
+ int (*xSetRegion) (Display *display, GC gc, Region rgn); /* 118 */
+ int (*xUnionRectWithRegion) (XRectangle *rect, Region src, Region dr_return); /* 119 */
void (*reserved120)(void);
#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */
void (*reserved121)(void);
@@ -726,12 +728,12 @@ typedef struct TkIntStubs {
void (*tkpSetKeycodeAndState) (Tk_Window tkwin, KeySym keySym, XEvent *eventPtr); /* 137 */
KeySym (*tkpGetKeySym) (TkDisplay *dispPtr, XEvent *eventPtr); /* 138 */
void (*tkpInitKeymapInfo) (TkDisplay *dispPtr); /* 139 */
- TkRegion (*tkPhotoGetValidRegion) (Tk_PhotoHandle handle); /* 140 */
+ Region (*tkPhotoGetValidRegion) (Tk_PhotoHandle handle); /* 140 */
TkWindow ** (*tkWmStackorderToplevel) (TkWindow *parentPtr); /* 141 */
void (*tkFocusFree) (TkMainInfo *mainPtr); /* 142 */
void (*tkClipCleanup) (TkDisplay *dispPtr); /* 143 */
void (*tkGCCleanup) (TkDisplay *dispPtr); /* 144 */
- void (*tkSubtractRegion) (TkRegion sra, TkRegion srcb, TkRegion dr_return); /* 145 */
+ int (*xSubtractRegion) (Region sra, Region srcb, Region dr_return); /* 145 */
void (*tkStylePkgInit) (TkMainInfo *mainPtr); /* 146 */
void (*tkStylePkgFree) (TkMainInfo *mainPtr); /* 147 */
Tk_Window (*tkToplevelWindowForCommand) (Tcl_Interp *interp, const char *cmdName); /* 148 */
@@ -1007,20 +1009,20 @@ extern const TkIntStubs *tkIntStubsPtr;
(tkIntStubsPtr->tkpGetSystemDefault) /* 111 */
#define TkpMenuThreadInit \
(tkIntStubsPtr->tkpMenuThreadInit) /* 112 */
-#define TkClipBox \
- (tkIntStubsPtr->tkClipBox) /* 113 */
-#define TkCreateRegion \
- (tkIntStubsPtr->tkCreateRegion) /* 114 */
-#define TkDestroyRegion \
- (tkIntStubsPtr->tkDestroyRegion) /* 115 */
-#define TkIntersectRegion \
- (tkIntStubsPtr->tkIntersectRegion) /* 116 */
-#define TkRectInRegion \
- (tkIntStubsPtr->tkRectInRegion) /* 117 */
-#define TkSetRegion \
- (tkIntStubsPtr->tkSetRegion) /* 118 */
-#define TkUnionRectWithRegion \
- (tkIntStubsPtr->tkUnionRectWithRegion) /* 119 */
+#define XClipBox \
+ (tkIntStubsPtr->xClipBox) /* 113 */
+#define XCreateRegion \
+ (tkIntStubsPtr->xCreateRegion) /* 114 */
+#define XDestroyRegion \
+ (tkIntStubsPtr->xDestroyRegion) /* 115 */
+#define XIntersectRegion \
+ (tkIntStubsPtr->xIntersectRegion) /* 116 */
+#define XRectInRegion \
+ (tkIntStubsPtr->xRectInRegion) /* 117 */
+#define XSetRegion \
+ (tkIntStubsPtr->xSetRegion) /* 118 */
+#define XUnionRectWithRegion \
+ (tkIntStubsPtr->xUnionRectWithRegion) /* 119 */
/* Slot 120 is reserved */
#ifdef MAC_OSX_TK /* AQUA */
#define TkpCreateNativeBitmap \
@@ -1065,8 +1067,8 @@ extern const TkIntStubs *tkIntStubsPtr;
(tkIntStubsPtr->tkClipCleanup) /* 143 */
#define TkGCCleanup \
(tkIntStubsPtr->tkGCCleanup) /* 144 */
-#define TkSubtractRegion \
- (tkIntStubsPtr->tkSubtractRegion) /* 145 */
+#define XSubtractRegion \
+ (tkIntStubsPtr->xSubtractRegion) /* 145 */
#define TkStylePkgInit \
(tkIntStubsPtr->tkStylePkgInit) /* 146 */
#define TkStylePkgFree \
@@ -1154,33 +1156,13 @@ extern const TkIntStubs *tkIntStubsPtr;
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
-/*
- * On X11, these macros are just wrappers for the equivalent X Region calls.
- */
-#if !(defined(_WIN32) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */
-
-#undef TkClipBox
-#undef TkCreateRegion
-#undef TkDestroyRegion
-#undef TkIntersectRegion
-#undef TkRectInRegion
-#undef TkSetRegion
-#undef TkSubtractRegion
-#undef TkUnionRectWithRegion
-
-#define TkClipBox(rgn, rect) XClipBox((Region) rgn, rect)
-#define TkCreateRegion() (TkRegion) XCreateRegion()
-#define TkDestroyRegion(rgn) XDestroyRegion((Region) rgn)
-#define TkIntersectRegion(a, b, r) XIntersectRegion((Region) a, \
- (Region) b, (Region) r)
-#define TkRectInRegion(r, x, y, w, h) XRectInRegion((Region) r, x, y, w, h)
-#define TkSetRegion(d, gc, rgn) XSetRegion(d, gc, (Region) rgn)
-#define TkSubtractRegion(a, b, r) XSubtractRegion((Region) a, \
- (Region) b, (Region) r)
-#define TkUnionRectWithRegion(rect, src, ret) XUnionRectWithRegion(rect, \
- (Region) src, (Region) ret)
-
-#endif /* UNIX */
+#undef TkpCmapStressed_
+#undef TkpSync_
+#undef TkUnixContainerId_
+#undef TkUnixDoOneXEvent_
+#undef TkUnixSetMenubar_
+#undef TkWmCleanup_
+#undef TkSendCleanup_
+#undef TkpTestsendCmd_
#endif /* _TKINTDECLS */
-
diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h
index 4162396..aecc222 100644
--- a/generic/tkIntPlatDecls.h
+++ b/generic/tkIntPlatDecls.h
@@ -142,13 +142,18 @@ EXTERN void TkSendCleanup(TkDisplay *dispPtr);
EXTERN int TkpTestsendCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
+/* Slot 46 is reserved */
+/* 47 */
+EXTERN Tk_Window TkpGetCapture(void);
#endif /* WIN */
#ifdef MAC_OSX_TK /* AQUA */
/* 0 */
EXTERN void TkGenerateActivateEvents(TkWindow *winPtr,
int active);
/* Slot 1 is reserved */
-/* Slot 2 is reserved */
+/* 2 */
+EXTERN void TkGenerateActivateEvents_(TkWindow *winPtr,
+ int active);
/* 3 */
EXTERN void TkPointerDeadWindow(TkWindow *winPtr);
/* 4 */
@@ -214,7 +219,7 @@ EXTERN void TkMacOSXUnregisterMacWindow(void *portPtr);
/* 34 */
EXTERN int TkMacOSXUseMenuID(short macID);
/* 35 */
-EXTERN TkRegion TkMacOSXVisableClipRgn(TkWindow *winPtr);
+EXTERN Region TkMacOSXVisableClipRgn(TkWindow *winPtr);
/* 36 */
EXTERN void TkMacOSXWinBounds(TkWindow *winPtr, void *geometry);
/* 37 */
@@ -240,7 +245,7 @@ EXTERN void TkMacOSXPreprocessMenu(void);
/* 46 */
EXTERN int TkpIsWindowFloating(void *window);
/* 47 */
-EXTERN Tk_Window TkMacOSXGetCapture(void);
+EXTERN Tk_Window TkpGetCapture(void);
/* Slot 48 is reserved */
/* 49 */
EXTERN Tk_Window TkGetTransientMaster(TkWindow *winPtr);
@@ -263,7 +268,9 @@ EXTERN int TkpScanWindowId(Tcl_Interp *interp,
/* 0 */
EXTERN void TkCreateXEventSource(void);
/* Slot 1 is reserved */
-/* Slot 2 is reserved */
+/* 2 */
+EXTERN void TkGenerateActivateEvents(TkWindow *winPtr,
+ int active);
/* 3 */
EXTERN int TkpCmapStressed(Tk_Window tkwin, Colormap colormap);
/* 4 */
@@ -288,6 +295,48 @@ EXTERN int TkpWmSetState(TkWindow *winPtr, int state);
EXTERN int TkpTestsendCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
+/* Slot 14 is reserved */
+/* Slot 15 is reserved */
+/* Slot 16 is reserved */
+/* Slot 17 is reserved */
+/* Slot 18 is reserved */
+/* Slot 19 is reserved */
+/* Slot 20 is reserved */
+/* Slot 21 is reserved */
+/* Slot 22 is reserved */
+/* Slot 23 is reserved */
+/* Slot 24 is reserved */
+/* Slot 25 is reserved */
+/* Slot 26 is reserved */
+/* Slot 27 is reserved */
+/* Slot 28 is reserved */
+/* Slot 29 is reserved */
+/* Slot 30 is reserved */
+/* Slot 31 is reserved */
+/* Slot 32 is reserved */
+/* Slot 33 is reserved */
+/* Slot 34 is reserved */
+/* Slot 35 is reserved */
+/* Slot 36 is reserved */
+/* Slot 37 is reserved */
+/* 38 */
+EXTERN int TkpCmapStressed_(Tk_Window tkwin, Colormap colormap);
+/* 39 */
+EXTERN void TkpSync_(Display *display);
+/* 40 */
+EXTERN Window TkUnixContainerId_(TkWindow *winPtr);
+/* 41 */
+EXTERN int TkUnixDoOneXEvent_(Tcl_Time *timePtr);
+/* 42 */
+EXTERN void TkUnixSetMenubar_(Tk_Window tkwin, Tk_Window menubar);
+/* 43 */
+EXTERN void TkWmCleanup_(TkDisplay *dispPtr);
+/* 44 */
+EXTERN void TkSendCleanup_(TkDisplay *dispPtr);
+/* 45 */
+EXTERN int TkpTestsendCmd_(ClientData clientData,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *const objv[]);
#endif /* X11 */
typedef struct TkIntPlatStubs {
@@ -341,11 +390,13 @@ typedef struct TkIntPlatStubs {
void (*tkWmCleanup) (TkDisplay *dispPtr); /* 43 */
void (*tkSendCleanup) (TkDisplay *dispPtr); /* 44 */
int (*tkpTestsendCmd) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 45 */
+ void (*reserved46)(void);
+ Tk_Window (*tkpGetCapture) (void); /* 47 */
#endif /* WIN */
#ifdef MAC_OSX_TK /* AQUA */
void (*tkGenerateActivateEvents) (TkWindow *winPtr, int active); /* 0 */
void (*reserved1)(void);
- void (*reserved2)(void);
+ void (*tkGenerateActivateEvents_) (TkWindow *winPtr, int active); /* 2 */
void (*tkPointerDeadWindow) (TkWindow *winPtr); /* 3 */
void (*tkpSetCapture) (TkWindow *winPtr); /* 4 */
void (*tkpSetCursor) (TkpCursor cursor); /* 5 */
@@ -378,7 +429,7 @@ typedef struct TkIntPlatStubs {
void (*tkMacOSXUpdateClipRgn) (TkWindow *winPtr); /* 32 */
void (*tkMacOSXUnregisterMacWindow) (void *portPtr); /* 33 */
int (*tkMacOSXUseMenuID) (short macID); /* 34 */
- TkRegion (*tkMacOSXVisableClipRgn) (TkWindow *winPtr); /* 35 */
+ Region (*tkMacOSXVisableClipRgn) (TkWindow *winPtr); /* 35 */
void (*tkMacOSXWinBounds) (TkWindow *winPtr, void *geometry); /* 36 */
void (*tkMacOSXWindowOffset) (void *wRef, int *xOffset, int *yOffset); /* 37 */
int (*tkSetMacColor) (unsigned long pixel, void *macColor); /* 38 */
@@ -390,7 +441,7 @@ typedef struct TkIntPlatStubs {
MacDrawable * (*tkMacOSXGetHostToplevel) (TkWindow *winPtr); /* 44 */
void (*tkMacOSXPreprocessMenu) (void); /* 45 */
int (*tkpIsWindowFloating) (void *window); /* 46 */
- Tk_Window (*tkMacOSXGetCapture) (void); /* 47 */
+ Tk_Window (*tkpGetCapture) (void); /* 47 */
void (*reserved48)(void);
Tk_Window (*tkGetTransientMaster) (TkWindow *winPtr); /* 49 */
int (*tkGenerateButtonEvent) (int x, int y, Window window, unsigned int state); /* 50 */
@@ -403,7 +454,7 @@ typedef struct TkIntPlatStubs {
#if !(defined(_WIN32) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */
void (*tkCreateXEventSource) (void); /* 0 */
void (*reserved1)(void);
- void (*reserved2)(void);
+ void (*tkGenerateActivateEvents) (TkWindow *winPtr, int active); /* 2 */
int (*tkpCmapStressed) (Tk_Window tkwin, Colormap colormap); /* 3 */
void (*tkpSync) (Display *display); /* 4 */
Window (*tkUnixContainerId) (TkWindow *winPtr); /* 5 */
@@ -415,6 +466,38 @@ typedef struct TkIntPlatStubs {
void (*reserved11)(void);
int (*tkpWmSetState) (TkWindow *winPtr, int state); /* 12 */
int (*tkpTestsendCmd) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 13 */
+ void (*reserved14)(void);
+ void (*reserved15)(void);
+ void (*reserved16)(void);
+ void (*reserved17)(void);
+ void (*reserved18)(void);
+ void (*reserved19)(void);
+ void (*reserved20)(void);
+ void (*reserved21)(void);
+ void (*reserved22)(void);
+ void (*reserved23)(void);
+ void (*reserved24)(void);
+ void (*reserved25)(void);
+ void (*reserved26)(void);
+ void (*reserved27)(void);
+ void (*reserved28)(void);
+ void (*reserved29)(void);
+ void (*reserved30)(void);
+ void (*reserved31)(void);
+ void (*reserved32)(void);
+ void (*reserved33)(void);
+ void (*reserved34)(void);
+ void (*reserved35)(void);
+ void (*reserved36)(void);
+ void (*reserved37)(void);
+ int (*tkpCmapStressed_) (Tk_Window tkwin, Colormap colormap); /* 38 */
+ void (*tkpSync_) (Display *display); /* 39 */
+ Window (*tkUnixContainerId_) (TkWindow *winPtr); /* 40 */
+ int (*tkUnixDoOneXEvent_) (Tcl_Time *timePtr); /* 41 */
+ void (*tkUnixSetMenubar_) (Tk_Window tkwin, Tk_Window menubar); /* 42 */
+ void (*tkWmCleanup_) (TkDisplay *dispPtr); /* 43 */
+ void (*tkSendCleanup_) (TkDisplay *dispPtr); /* 44 */
+ int (*tkpTestsendCmd_) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 45 */
#endif /* X11 */
} TkIntPlatStubs;
@@ -522,12 +605,16 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr;
(tkIntPlatStubsPtr->tkSendCleanup) /* 44 */
#define TkpTestsendCmd \
(tkIntPlatStubsPtr->tkpTestsendCmd) /* 45 */
+/* Slot 46 is reserved */
+#define TkpGetCapture \
+ (tkIntPlatStubsPtr->tkpGetCapture) /* 47 */
#endif /* WIN */
#ifdef MAC_OSX_TK /* AQUA */
#define TkGenerateActivateEvents \
(tkIntPlatStubsPtr->tkGenerateActivateEvents) /* 0 */
/* Slot 1 is reserved */
-/* Slot 2 is reserved */
+#define TkGenerateActivateEvents_ \
+ (tkIntPlatStubsPtr->tkGenerateActivateEvents_) /* 2 */
#define TkPointerDeadWindow \
(tkIntPlatStubsPtr->tkPointerDeadWindow) /* 3 */
#define TkpSetCapture \
@@ -611,8 +698,8 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr;
(tkIntPlatStubsPtr->tkMacOSXPreprocessMenu) /* 45 */
#define TkpIsWindowFloating \
(tkIntPlatStubsPtr->tkpIsWindowFloating) /* 46 */
-#define TkMacOSXGetCapture \
- (tkIntPlatStubsPtr->tkMacOSXGetCapture) /* 47 */
+#define TkpGetCapture \
+ (tkIntPlatStubsPtr->tkpGetCapture) /* 47 */
/* Slot 48 is reserved */
#define TkGetTransientMaster \
(tkIntPlatStubsPtr->tkGetTransientMaster) /* 49 */
@@ -633,7 +720,8 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr;
#define TkCreateXEventSource \
(tkIntPlatStubsPtr->tkCreateXEventSource) /* 0 */
/* Slot 1 is reserved */
-/* Slot 2 is reserved */
+#define TkGenerateActivateEvents \
+ (tkIntPlatStubsPtr->tkGenerateActivateEvents) /* 2 */
#define TkpCmapStressed \
(tkIntPlatStubsPtr->tkpCmapStressed) /* 3 */
#define TkpSync \
@@ -655,12 +743,62 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr;
(tkIntPlatStubsPtr->tkpWmSetState) /* 12 */
#define TkpTestsendCmd \
(tkIntPlatStubsPtr->tkpTestsendCmd) /* 13 */
+/* Slot 14 is reserved */
+/* Slot 15 is reserved */
+/* Slot 16 is reserved */
+/* Slot 17 is reserved */
+/* Slot 18 is reserved */
+/* Slot 19 is reserved */
+/* Slot 20 is reserved */
+/* Slot 21 is reserved */
+/* Slot 22 is reserved */
+/* Slot 23 is reserved */
+/* Slot 24 is reserved */
+/* Slot 25 is reserved */
+/* Slot 26 is reserved */
+/* Slot 27 is reserved */
+/* Slot 28 is reserved */
+/* Slot 29 is reserved */
+/* Slot 30 is reserved */
+/* Slot 31 is reserved */
+/* Slot 32 is reserved */
+/* Slot 33 is reserved */
+/* Slot 34 is reserved */
+/* Slot 35 is reserved */
+/* Slot 36 is reserved */
+/* Slot 37 is reserved */
+#define TkpCmapStressed_ \
+ (tkIntPlatStubsPtr->tkpCmapStressed_) /* 38 */
+#define TkpSync_ \
+ (tkIntPlatStubsPtr->tkpSync_) /* 39 */
+#define TkUnixContainerId_ \
+ (tkIntPlatStubsPtr->tkUnixContainerId_) /* 40 */
+#define TkUnixDoOneXEvent_ \
+ (tkIntPlatStubsPtr->tkUnixDoOneXEvent_) /* 41 */
+#define TkUnixSetMenubar_ \
+ (tkIntPlatStubsPtr->tkUnixSetMenubar_) /* 42 */
+#define TkWmCleanup_ \
+ (tkIntPlatStubsPtr->tkWmCleanup_) /* 43 */
+#define TkSendCleanup_ \
+ (tkIntPlatStubsPtr->tkSendCleanup_) /* 44 */
+#define TkpTestsendCmd_ \
+ (tkIntPlatStubsPtr->tkpTestsendCmd_) /* 45 */
#endif /* X11 */
#endif /* defined(USE_TK_STUBS) */
/* !END!: Do not edit above this line. */
+#undef TkpCmapStressed_
+#undef TkpSync_
+#undef TkUnixContainerId_
+#undef TkUnixDoOneXEvent_
+#undef TkUnixSetMenubar_
+#undef TkWmCleanup_
+#undef TkSendCleanup_
+#undef TkpTestsendCmd_
+#undef TkGenerateActivateEvents_
+
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h
index 4efa241..774075d 100644
--- a/generic/tkIntXlibDecls.h
+++ b/generic/tkIntXlibDecls.h
@@ -27,13 +27,7 @@
# define EXTERN extern TCL_STORAGE_CLASS
#endif
-/* Some (older) versions of X11/Xutil.h have a wrong signature of those
- two functions, so move them out of the way temporarly. */
-#define XOffsetRegion _XOffsetRegion
-#define XUnionRegion _XUnionRegion
#include "X11/Xutil.h"
-#undef XOffsetRegion
-#undef XUnionRegion
#ifdef BUILD_tk
# undef TCL_STORAGE_CLASS
@@ -425,8 +419,57 @@ EXTERN int XPutImage(Display *d, Drawable dr, GC gc, XImage *im,
EXTERN Region XPolygonRegion(XPoint *pts, int n, int rule);
/* 139 */
EXTERN int XPointInRegion(Region rgn, int x, int y);
+/* 140 */
+EXTERN XVaNestedList XVaCreateNestedList(int dummy, ...);
+/* 141 */
+EXTERN char * XSetICValues(XIC xic, ...);
+/* 142 */
+EXTERN char * XGetICValues(XIC xic, ...);
+/* 143 */
+EXTERN void XSetICFocus(XIC xic);
+/* Slot 144 is reserved */
+/* Slot 145 is reserved */
+/* Slot 146 is reserved */
+/* 147 */
+EXTERN void XFreeFontSet(Display *display, XFontSet fontset);
+/* 148 */
+EXTERN int XCloseIM(XIM im);
+/* 149 */
+EXTERN Bool XRegisterIMInstantiateCallback(Display *dpy,
+ struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class,
+ XIDProc callback, XPointer client_data);
+/* 150 */
+EXTERN Bool XUnregisterIMInstantiateCallback(Display *dpy,
+ struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class,
+ XIDProc callback, XPointer client_data);
+/* 151 */
+EXTERN char * XSetLocaleModifiers(const char *modifier_list);
+/* 152 */
+EXTERN XIM XOpenIM(Display *dpy, struct _XrmHashBucketRec *rdb,
+ char *res_name, char *res_class);
+/* 153 */
+EXTERN char * XGetIMValues(XIM im, ...);
+/* 154 */
+EXTERN char * XSetIMValues(XIM im, ...);
+/* 155 */
+EXTERN XFontSet XCreateFontSet(Display *display,
+ _Xconst char *base_font_name_list,
+ char ***missing_charset_list,
+ int *missing_charset_count,
+ char **def_string);
+/* 156 */
+EXTERN void XFreeStringList(char **list);
+/* 157 */
+EXTERN KeySym XkbKeycodeToKeysym(Display *d, unsigned int k, int g,
+ int i);
+/* 158 */
+EXTERN Display * XkbOpenDisplay(const char *name, int *ev_rtrn,
+ int *err_rtrn, int *major_rtrn,
+ int *minor_rtrn, int *reason);
#endif /* WIN */
-#ifdef MAC_OSX_TK /* AQUA */
+#ifdef MAC_OSX_TCL /* MACOSX */
/* 0 */
EXTERN int XSetDashes(Display *display, GC gc, int dash_offset,
_Xconst char *dash_list, int n);
@@ -450,7 +493,7 @@ EXTERN Colormap XCreateColormap(Display *d, Window w, Visual *v,
/* 7 */
EXTERN GContext XGContextFromGC(GC g);
/* 8 */
-EXTERN KeySym XKeycodeToKeysym(Display *d, KeyCode k, int i);
+EXTERN KeySym XKeycodeToKeysym(Display *d, unsigned int k, int i);
/* 9 */
EXTERN KeySym XStringToKeysym(_Xconst char *c);
/* 10 */
@@ -462,21 +505,21 @@ EXTERN Status XAllocColor(Display *d, Colormap c, XColor *xp);
/* 13 */
EXTERN int XBell(Display *d, int i);
/* 14 */
-EXTERN void XChangeProperty(Display *d, Window w, Atom a1,
+EXTERN int XChangeProperty(Display *d, Window w, Atom a1,
Atom a2, int i1, int i2,
_Xconst unsigned char *c, int i3);
/* 15 */
-EXTERN void XChangeWindowAttributes(Display *d, Window w,
+EXTERN int XChangeWindowAttributes(Display *d, Window w,
unsigned long ul, XSetWindowAttributes *x);
/* 16 */
-EXTERN void XConfigureWindow(Display *d, Window w,
+EXTERN int XConfigureWindow(Display *d, Window w,
unsigned int i, XWindowChanges *x);
/* 17 */
-EXTERN void XCopyArea(Display *d, Drawable dr1, Drawable dr2,
+EXTERN int XCopyArea(Display *d, Drawable dr1, Drawable dr2,
GC g, int i1, int i2, unsigned int ui1,
unsigned int ui2, int i3, int i4);
/* 18 */
-EXTERN void XCopyPlane(Display *d, Drawable dr1, Drawable dr2,
+EXTERN int XCopyPlane(Display *d, Drawable dr1, Drawable dr2,
GC g, int i1, int i2, unsigned int ui1,
unsigned int ui2, int i3, int i4,
unsigned long ul);
@@ -487,23 +530,23 @@ EXTERN Pixmap XCreateBitmapFromData(Display *display, Drawable d,
/* 20 */
EXTERN int XDefineCursor(Display *d, Window w, Cursor c);
/* 21 */
-EXTERN void XDestroyWindow(Display *d, Window w);
+EXTERN int XDestroyWindow(Display *d, Window w);
/* 22 */
-EXTERN void XDrawArc(Display *d, Drawable dr, GC g, int i1,
+EXTERN int XDrawArc(Display *d, Drawable dr, GC g, int i1,
int i2, unsigned int ui1, unsigned int ui2,
int i3, int i4);
/* 23 */
EXTERN int XDrawLines(Display *d, Drawable dr, GC g, XPoint *x,
int i1, int i2);
/* 24 */
-EXTERN void XDrawRectangle(Display *d, Drawable dr, GC g, int i1,
+EXTERN int XDrawRectangle(Display *d, Drawable dr, GC g, int i1,
int i2, unsigned int ui1, unsigned int ui2);
/* 25 */
-EXTERN void XFillArc(Display *d, Drawable dr, GC g, int i1,
+EXTERN int XFillArc(Display *d, Drawable dr, GC g, int i1,
int i2, unsigned int ui1, unsigned int ui2,
int i3, int i4);
/* 26 */
-EXTERN void XFillPolygon(Display *d, Drawable dr, GC g,
+EXTERN int XFillPolygon(Display *d, Drawable dr, GC g,
XPoint *x, int i1, int i2, int i3);
/* 27 */
EXTERN int XFillRectangles(Display *d, Drawable dr, GC g,
@@ -535,58 +578,58 @@ EXTERN int XGrabPointer(Display *d, Window w1, Bool b,
/* 35 */
EXTERN KeyCode XKeysymToKeycode(Display *d, KeySym k);
/* 36 */
-EXTERN void XMapWindow(Display *d, Window w);
+EXTERN int XMapWindow(Display *d, Window w);
/* 37 */
-EXTERN void XMoveResizeWindow(Display *d, Window w, int i1,
+EXTERN int XMoveResizeWindow(Display *d, Window w, int i1,
int i2, unsigned int ui1, unsigned int ui2);
/* 38 */
-EXTERN void XMoveWindow(Display *d, Window w, int i1, int i2);
+EXTERN int XMoveWindow(Display *d, Window w, int i1, int i2);
/* 39 */
EXTERN Bool XQueryPointer(Display *d, Window w1, Window *w2,
Window *w3, int *i1, int *i2, int *i3,
int *i4, unsigned int *ui);
/* 40 */
-EXTERN void XRaiseWindow(Display *d, Window w);
+EXTERN int XRaiseWindow(Display *d, Window w);
/* 41 */
-EXTERN void XRefreshKeyboardMapping(XMappingEvent *x);
+EXTERN int XRefreshKeyboardMapping(XMappingEvent *x);
/* 42 */
-EXTERN void XResizeWindow(Display *d, Window w, unsigned int ui1,
+EXTERN int XResizeWindow(Display *d, Window w, unsigned int ui1,
unsigned int ui2);
/* 43 */
-EXTERN void XSelectInput(Display *d, Window w, long l);
+EXTERN int XSelectInput(Display *d, Window w, long l);
/* 44 */
EXTERN Status XSendEvent(Display *d, Window w, Bool b, long l,
XEvent *x);
/* 45 */
-EXTERN void XSetIconName(Display *d, Window w, _Xconst char *c);
+EXTERN int XSetIconName(Display *d, Window w, _Xconst char *c);
/* 46 */
-EXTERN void XSetInputFocus(Display *d, Window w, int i, Time t);
+EXTERN int XSetInputFocus(Display *d, Window w, int i, Time t);
/* 47 */
EXTERN int XSetSelectionOwner(Display *d, Atom a, Window w,
Time t);
/* 48 */
-EXTERN void XSetWindowBackground(Display *d, Window w,
+EXTERN int XSetWindowBackground(Display *d, Window w,
unsigned long ul);
/* 49 */
-EXTERN void XSetWindowBackgroundPixmap(Display *d, Window w,
+EXTERN int XSetWindowBackgroundPixmap(Display *d, Window w,
Pixmap p);
/* 50 */
-EXTERN void XSetWindowBorder(Display *d, Window w,
+EXTERN int XSetWindowBorder(Display *d, Window w,
unsigned long ul);
/* 51 */
-EXTERN void XSetWindowBorderPixmap(Display *d, Window w,
+EXTERN int XSetWindowBorderPixmap(Display *d, Window w,
Pixmap p);
/* 52 */
-EXTERN void XSetWindowBorderWidth(Display *d, Window w,
+EXTERN int XSetWindowBorderWidth(Display *d, Window w,
unsigned int ui);
/* 53 */
-EXTERN void XSetWindowColormap(Display *d, Window w, Colormap c);
+EXTERN int XSetWindowColormap(Display *d, Window w, Colormap c);
/* 54 */
-EXTERN void XUngrabKeyboard(Display *d, Time t);
+EXTERN int XUngrabKeyboard(Display *d, Time t);
/* 55 */
EXTERN int XUngrabPointer(Display *d, Time t);
/* 56 */
-EXTERN void XUnmapWindow(Display *d, Window w);
+EXTERN int XUnmapWindow(Display *d, Window w);
/* 57 */
EXTERN int TkPutImage(unsigned long *colors, int ncolors,
Display *display, Drawable d, GC gc,
@@ -641,7 +684,7 @@ EXTERN int XSetLineAttributes(Display *display, GC gc,
/* 75 */
EXTERN int _XInitImageFuncPtrs(XImage *image);
/* 76 */
-EXTERN XIC XCreateIC(void);
+EXTERN XIC XCreateIC(XIM xim, ...);
/* 77 */
EXTERN XVisualInfo * XGetVisualInfo(Display *display, long vinfo_mask,
XVisualInfo *vinfo_template,
@@ -656,7 +699,7 @@ EXTERN Status XStringListToTextProperty(char **list, int count,
EXTERN int XDrawSegments(Display *display, Drawable d, GC gc,
XSegment *segments, int nsegments);
/* 81 */
-EXTERN void XForceScreenSaver(Display *display, int mode);
+EXTERN int XForceScreenSaver(Display *display, int mode);
/* 82 */
EXTERN int XDrawLine(Display *d, Drawable dr, GC g, int x1,
int y1, int x2, int y2);
@@ -665,7 +708,7 @@ EXTERN int XFillRectangle(Display *display, Drawable d, GC gc,
int x, int y, unsigned int width,
unsigned int height);
/* 84 */
-EXTERN void XClearWindow(Display *d, Window w);
+EXTERN int XClearWindow(Display *d, Window w);
/* 85 */
EXTERN int XDrawPoint(Display *display, Drawable d, GC gc,
int x, int y);
@@ -679,17 +722,173 @@ EXTERN int XWarpPointer(Display *display, Window src_w,
unsigned int src_height, int dest_x,
int dest_y);
/* 88 */
-EXTERN void XQueryColor(Display *display, Colormap colormap,
+EXTERN int XQueryColor(Display *display, Colormap colormap,
XColor *def_in_out);
/* 89 */
-EXTERN void XQueryColors(Display *display, Colormap colormap,
+EXTERN int XQueryColors(Display *display, Colormap colormap,
XColor *defs_in_out, int ncolors);
/* 90 */
EXTERN Status XQueryTree(Display *d, Window w1, Window *w2,
Window *w3, Window **w4, unsigned int *ui);
/* 91 */
-EXTERN int XSync(Display *display, Bool flag);
-#endif /* AQUA */
+EXTERN int XSync(Display *display, Bool discard);
+/* 92 */
+EXTERN Bool XTranslateCoordinates(Display *d, Window w1,
+ Window w2, int i1, int i2, int *i3, int *i4,
+ Window *w3);
+/* 93 */
+EXTERN int XDeleteProperty(Display *d, Window w, Atom a);
+/* 94 */
+EXTERN int XFreeCursor(Display *d, Cursor c);
+/* 95 */
+EXTERN int XGetInputFocus(Display *d, Window *w, int *i);
+/* 96 */
+EXTERN int XmbLookupString(XIC xi, XKeyPressedEvent *xk,
+ char *c, int i, KeySym *k, Status *s);
+/* 97 */
+EXTERN int XNextEvent(Display *d, XEvent *x);
+/* 98 */
+EXTERN int XPutBackEvent(Display *d, XEvent *x);
+/* 99 */
+EXTERN int XSetCommand(Display *d, Window w, char **c, int i);
+/* 100 */
+EXTERN int XWindowEvent(Display *d, Window w, long l, XEvent *x);
+/* 101 */
+EXTERN Status XGetWindowAttributes(Display *d, Window w,
+ XWindowAttributes *x);
+/* 102 */
+EXTERN Status XGetWMColormapWindows(Display *d, Window w,
+ Window **wpp, int *ip);
+/* 103 */
+EXTERN Status XIconifyWindow(Display *d, Window w, int i);
+/* 104 */
+EXTERN Status XWithdrawWindow(Display *d, Window w, int i);
+/* 105 */
+EXTERN XHostAddress * XListHosts(Display *d, int *i, Bool *b);
+/* Slot 106 is reserved */
+/* 107 */
+EXTERN int XFlush(Display *display);
+/* 108 */
+EXTERN int XGrabServer(Display *display);
+/* 109 */
+EXTERN int XUngrabServer(Display *display);
+/* 110 */
+EXTERN int XFree(void *data);
+/* 111 */
+EXTERN int XNoOp(Display *display);
+/* 112 */
+EXTERN XAfterFunction XSynchronize(Display *display, Bool onoff);
+/* 113 */
+EXTERN Status XLookupColor(Display *d, Colormap c1,
+ _Xconst char *c2, XColor *x1, XColor *x2);
+/* 114 */
+EXTERN VisualID XVisualIDFromVisual(Visual *visual);
+/* Slot 115 is reserved */
+/* Slot 116 is reserved */
+/* Slot 117 is reserved */
+/* Slot 118 is reserved */
+/* Slot 119 is reserved */
+/* 120 */
+EXTERN int XOffsetRegion(Region rgn, int dx, int dy);
+/* 121 */
+EXTERN int XUnionRegion(Region srca, Region srcb,
+ Region dr_return);
+/* 122 */
+EXTERN Window XCreateWindow(Display *display, Window parent, int x,
+ int y, unsigned int width,
+ unsigned int height,
+ unsigned int border_width, int depth,
+ unsigned int clazz, Visual *visual,
+ unsigned long value_mask,
+ XSetWindowAttributes *attributes);
+/* Slot 123 is reserved */
+/* Slot 124 is reserved */
+/* Slot 125 is reserved */
+/* Slot 126 is reserved */
+/* Slot 127 is reserved */
+/* Slot 128 is reserved */
+/* 129 */
+EXTERN int XLowerWindow(Display *d, Window w);
+/* 130 */
+EXTERN int XFillArcs(Display *d, Drawable dr, GC gc, XArc *a,
+ int n);
+/* 131 */
+EXTERN int XDrawArcs(Display *d, Drawable dr, GC gc, XArc *a,
+ int n);
+/* 132 */
+EXTERN int XDrawRectangles(Display *d, Drawable dr, GC gc,
+ XRectangle *r, int n);
+/* Slot 133 is reserved */
+/* Slot 134 is reserved */
+/* Slot 135 is reserved */
+/* 136 */
+EXTERN int XReparentWindow(Display *d, Window w, Window p,
+ int x, int y);
+/* 137 */
+EXTERN int XPutImage(Display *d, Drawable dr, GC gc, XImage *im,
+ int sx, int sy, int dx, int dy,
+ unsigned int w, unsigned int h);
+/* 138 */
+EXTERN Region XPolygonRegion(XPoint *pts, int n, int rule);
+/* 139 */
+EXTERN int XPointInRegion(Region rgn, int x, int y);
+/* 140 */
+EXTERN XVaNestedList XVaCreateNestedList(int dummy, ...);
+/* 141 */
+EXTERN char * XSetICValues(XIC xic, ...);
+/* 142 */
+EXTERN char * XGetICValues(XIC xic, ...);
+/* 143 */
+EXTERN void XSetICFocus(XIC xic);
+/* 144 */
+EXTERN void XDestroyIC(XIC xic);
+/* 145 */
+EXTERN Cursor XCreatePixmapCursor(Display *d, Pixmap p1, Pixmap p2,
+ XColor *x1, XColor *x2, unsigned int ui1,
+ unsigned int ui2);
+/* 146 */
+EXTERN Cursor XCreateGlyphCursor(Display *d, Font f1, Font f2,
+ unsigned int ui1, unsigned int ui2,
+ XColor _Xconst *x1, XColor _Xconst *x2);
+/* 147 */
+EXTERN void XFreeFontSet(Display *display, XFontSet fontset);
+/* 148 */
+EXTERN int XCloseIM(XIM im);
+/* 149 */
+EXTERN Bool XRegisterIMInstantiateCallback(Display *dpy,
+ struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class,
+ XIDProc callback, XPointer client_data);
+/* 150 */
+EXTERN Bool XUnregisterIMInstantiateCallback(Display *dpy,
+ struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class,
+ XIDProc callback, XPointer client_data);
+/* 151 */
+EXTERN char * XSetLocaleModifiers(const char *modifier_list);
+/* 152 */
+EXTERN XIM XOpenIM(Display *dpy, struct _XrmHashBucketRec *rdb,
+ char *res_name, char *res_class);
+/* 153 */
+EXTERN char * XGetIMValues(XIM im, ...);
+/* 154 */
+EXTERN char * XSetIMValues(XIM im, ...);
+/* 155 */
+EXTERN XFontSet XCreateFontSet(Display *display,
+ _Xconst char *base_font_name_list,
+ char ***missing_charset_list,
+ int *missing_charset_count,
+ char **def_string);
+/* 156 */
+EXTERN void XFreeStringList(char **list);
+/* 157 */
+EXTERN KeySym XkbKeycodeToKeysym(Display *d, unsigned int k, int g,
+ int i);
+/* 158 */
+EXTERN Display * XkbOpenDisplay(const char *name, int *ev_rtrn,
+ int *err_rtrn, int *major_rtrn,
+ int *minor_rtrn, int *reason);
+#endif /* MACOSX */
typedef struct TkIntXlibStubs {
int magic;
@@ -836,8 +1035,27 @@ typedef struct TkIntXlibStubs {
int (*xPutImage) (Display *d, Drawable dr, GC gc, XImage *im, int sx, int sy, int dx, int dy, unsigned int w, unsigned int h); /* 137 */
Region (*xPolygonRegion) (XPoint *pts, int n, int rule); /* 138 */
int (*xPointInRegion) (Region rgn, int x, int y); /* 139 */
+ XVaNestedList (*xVaCreateNestedList) (int dummy, ...); /* 140 */
+ char * (*xSetICValues) (XIC xic, ...); /* 141 */
+ char * (*xGetICValues) (XIC xic, ...); /* 142 */
+ void (*xSetICFocus) (XIC xic); /* 143 */
+ void (*reserved144)(void);
+ void (*reserved145)(void);
+ void (*reserved146)(void);
+ void (*xFreeFontSet) (Display *display, XFontSet fontset); /* 147 */
+ int (*xCloseIM) (XIM im); /* 148 */
+ Bool (*xRegisterIMInstantiateCallback) (Display *dpy, struct _XrmHashBucketRec *rbd, char *res_name, char *res_class, XIDProc callback, XPointer client_data); /* 149 */
+ Bool (*xUnregisterIMInstantiateCallback) (Display *dpy, struct _XrmHashBucketRec *rbd, char *res_name, char *res_class, XIDProc callback, XPointer client_data); /* 150 */
+ char * (*xSetLocaleModifiers) (const char *modifier_list); /* 151 */
+ XIM (*xOpenIM) (Display *dpy, struct _XrmHashBucketRec *rdb, char *res_name, char *res_class); /* 152 */
+ char * (*xGetIMValues) (XIM im, ...); /* 153 */
+ char * (*xSetIMValues) (XIM im, ...); /* 154 */
+ XFontSet (*xCreateFontSet) (Display *display, _Xconst char *base_font_name_list, char ***missing_charset_list, int *missing_charset_count, char **def_string); /* 155 */
+ void (*xFreeStringList) (char **list); /* 156 */
+ KeySym (*xkbKeycodeToKeysym) (Display *d, unsigned int k, int g, int i); /* 157 */
+ Display * (*xkbOpenDisplay) (const char *name, int *ev_rtrn, int *err_rtrn, int *major_rtrn, int *minor_rtrn, int *reason); /* 158 */
#endif /* WIN */
-#ifdef MAC_OSX_TK /* AQUA */
+#ifdef MAC_OSX_TCL /* MACOSX */
int (*xSetDashes) (Display *display, GC gc, int dash_offset, _Xconst char *dash_list, int n); /* 0 */
XModifierKeymap * (*xGetModifierMapping) (Display *d); /* 1 */
XImage * (*xCreateImage) (Display *d, Visual *v, unsigned int ui1, int i1, int i2, char *cp, unsigned int ui2, unsigned int ui3, int i3, int i4); /* 2 */
@@ -846,25 +1064,25 @@ typedef struct TkIntXlibStubs {
char * (*xKeysymToString) (KeySym k); /* 5 */
Colormap (*xCreateColormap) (Display *d, Window w, Visual *v, int i); /* 6 */
GContext (*xGContextFromGC) (GC g); /* 7 */
- KeySym (*xKeycodeToKeysym) (Display *d, KeyCode k, int i); /* 8 */
+ KeySym (*xKeycodeToKeysym) (Display *d, unsigned int k, int i); /* 8 */
KeySym (*xStringToKeysym) (_Xconst char *c); /* 9 */
Window (*xRootWindow) (Display *d, int i); /* 10 */
XErrorHandler (*xSetErrorHandler) (XErrorHandler x); /* 11 */
Status (*xAllocColor) (Display *d, Colormap c, XColor *xp); /* 12 */
int (*xBell) (Display *d, int i); /* 13 */
- void (*xChangeProperty) (Display *d, Window w, Atom a1, Atom a2, int i1, int i2, _Xconst unsigned char *c, int i3); /* 14 */
- void (*xChangeWindowAttributes) (Display *d, Window w, unsigned long ul, XSetWindowAttributes *x); /* 15 */
- void (*xConfigureWindow) (Display *d, Window w, unsigned int i, XWindowChanges *x); /* 16 */
- void (*xCopyArea) (Display *d, Drawable dr1, Drawable dr2, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2, int i3, int i4); /* 17 */
- void (*xCopyPlane) (Display *d, Drawable dr1, Drawable dr2, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2, int i3, int i4, unsigned long ul); /* 18 */
+ int (*xChangeProperty) (Display *d, Window w, Atom a1, Atom a2, int i1, int i2, _Xconst unsigned char *c, int i3); /* 14 */
+ int (*xChangeWindowAttributes) (Display *d, Window w, unsigned long ul, XSetWindowAttributes *x); /* 15 */
+ int (*xConfigureWindow) (Display *d, Window w, unsigned int i, XWindowChanges *x); /* 16 */
+ int (*xCopyArea) (Display *d, Drawable dr1, Drawable dr2, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2, int i3, int i4); /* 17 */
+ int (*xCopyPlane) (Display *d, Drawable dr1, Drawable dr2, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2, int i3, int i4, unsigned long ul); /* 18 */
Pixmap (*xCreateBitmapFromData) (Display *display, Drawable d, _Xconst char *data, unsigned int width, unsigned int height); /* 19 */
int (*xDefineCursor) (Display *d, Window w, Cursor c); /* 20 */
- void (*xDestroyWindow) (Display *d, Window w); /* 21 */
- void (*xDrawArc) (Display *d, Drawable dr, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2, int i3, int i4); /* 22 */
+ int (*xDestroyWindow) (Display *d, Window w); /* 21 */
+ int (*xDrawArc) (Display *d, Drawable dr, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2, int i3, int i4); /* 22 */
int (*xDrawLines) (Display *d, Drawable dr, GC g, XPoint *x, int i1, int i2); /* 23 */
- void (*xDrawRectangle) (Display *d, Drawable dr, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2); /* 24 */
- void (*xFillArc) (Display *d, Drawable dr, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2, int i3, int i4); /* 25 */
- void (*xFillPolygon) (Display *d, Drawable dr, GC g, XPoint *x, int i1, int i2, int i3); /* 26 */
+ int (*xDrawRectangle) (Display *d, Drawable dr, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2); /* 24 */
+ int (*xFillArc) (Display *d, Drawable dr, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2, int i3, int i4); /* 25 */
+ int (*xFillPolygon) (Display *d, Drawable dr, GC g, XPoint *x, int i1, int i2, int i3); /* 26 */
int (*xFillRectangles) (Display *d, Drawable dr, GC g, XRectangle *x, int i); /* 27 */
int (*xFreeColormap) (Display *d, Colormap c); /* 28 */
int (*xFreeColors) (Display *d, Colormap c, unsigned long *ulp, int i, unsigned long ul); /* 29 */
@@ -874,27 +1092,27 @@ typedef struct TkIntXlibStubs {
int (*xGrabKeyboard) (Display *d, Window w, Bool b, int i1, int i2, Time t); /* 33 */
int (*xGrabPointer) (Display *d, Window w1, Bool b, unsigned int ui, int i1, int i2, Window w2, Cursor c, Time t); /* 34 */
KeyCode (*xKeysymToKeycode) (Display *d, KeySym k); /* 35 */
- void (*xMapWindow) (Display *d, Window w); /* 36 */
- void (*xMoveResizeWindow) (Display *d, Window w, int i1, int i2, unsigned int ui1, unsigned int ui2); /* 37 */
- void (*xMoveWindow) (Display *d, Window w, int i1, int i2); /* 38 */
+ int (*xMapWindow) (Display *d, Window w); /* 36 */
+ int (*xMoveResizeWindow) (Display *d, Window w, int i1, int i2, unsigned int ui1, unsigned int ui2); /* 37 */
+ int (*xMoveWindow) (Display *d, Window w, int i1, int i2); /* 38 */
Bool (*xQueryPointer) (Display *d, Window w1, Window *w2, Window *w3, int *i1, int *i2, int *i3, int *i4, unsigned int *ui); /* 39 */
- void (*xRaiseWindow) (Display *d, Window w); /* 40 */
- void (*xRefreshKeyboardMapping) (XMappingEvent *x); /* 41 */
- void (*xResizeWindow) (Display *d, Window w, unsigned int ui1, unsigned int ui2); /* 42 */
- void (*xSelectInput) (Display *d, Window w, long l); /* 43 */
+ int (*xRaiseWindow) (Display *d, Window w); /* 40 */
+ int (*xRefreshKeyboardMapping) (XMappingEvent *x); /* 41 */
+ int (*xResizeWindow) (Display *d, Window w, unsigned int ui1, unsigned int ui2); /* 42 */
+ int (*xSelectInput) (Display *d, Window w, long l); /* 43 */
Status (*xSendEvent) (Display *d, Window w, Bool b, long l, XEvent *x); /* 44 */
- void (*xSetIconName) (Display *d, Window w, _Xconst char *c); /* 45 */
- void (*xSetInputFocus) (Display *d, Window w, int i, Time t); /* 46 */
+ int (*xSetIconName) (Display *d, Window w, _Xconst char *c); /* 45 */
+ int (*xSetInputFocus) (Display *d, Window w, int i, Time t); /* 46 */
int (*xSetSelectionOwner) (Display *d, Atom a, Window w, Time t); /* 47 */
- void (*xSetWindowBackground) (Display *d, Window w, unsigned long ul); /* 48 */
- void (*xSetWindowBackgroundPixmap) (Display *d, Window w, Pixmap p); /* 49 */
- void (*xSetWindowBorder) (Display *d, Window w, unsigned long ul); /* 50 */
- void (*xSetWindowBorderPixmap) (Display *d, Window w, Pixmap p); /* 51 */
- void (*xSetWindowBorderWidth) (Display *d, Window w, unsigned int ui); /* 52 */
- void (*xSetWindowColormap) (Display *d, Window w, Colormap c); /* 53 */
- void (*xUngrabKeyboard) (Display *d, Time t); /* 54 */
+ int (*xSetWindowBackground) (Display *d, Window w, unsigned long ul); /* 48 */
+ int (*xSetWindowBackgroundPixmap) (Display *d, Window w, Pixmap p); /* 49 */
+ int (*xSetWindowBorder) (Display *d, Window w, unsigned long ul); /* 50 */
+ int (*xSetWindowBorderPixmap) (Display *d, Window w, Pixmap p); /* 51 */
+ int (*xSetWindowBorderWidth) (Display *d, Window w, unsigned int ui); /* 52 */
+ int (*xSetWindowColormap) (Display *d, Window w, Colormap c); /* 53 */
+ int (*xUngrabKeyboard) (Display *d, Time t); /* 54 */
int (*xUngrabPointer) (Display *d, Time t); /* 55 */
- void (*xUnmapWindow) (Display *d, Window w); /* 56 */
+ int (*xUnmapWindow) (Display *d, Window w); /* 56 */
int (*tkPutImage) (unsigned long *colors, int ncolors, Display *display, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height); /* 57 */
Status (*xParseColor) (Display *display, Colormap map, _Xconst char *spec, XColor *colorPtr); /* 58 */
GC (*xCreateGC) (Display *display, Drawable d, unsigned long valuemask, XGCValues *values); /* 59 */
@@ -914,23 +1132,90 @@ typedef struct TkIntXlibStubs {
int (*xSetFunction) (Display *display, GC gc, int function); /* 73 */
int (*xSetLineAttributes) (Display *display, GC gc, unsigned int line_width, int line_style, int cap_style, int join_style); /* 74 */
int (*_XInitImageFuncPtrs) (XImage *image); /* 75 */
- XIC (*xCreateIC) (void); /* 76 */
+ XIC (*xCreateIC) (XIM xim, ...); /* 76 */
XVisualInfo * (*xGetVisualInfo) (Display *display, long vinfo_mask, XVisualInfo *vinfo_template, int *nitems_return); /* 77 */
void (*xSetWMClientMachine) (Display *display, Window w, XTextProperty *text_prop); /* 78 */
Status (*xStringListToTextProperty) (char **list, int count, XTextProperty *text_prop_return); /* 79 */
int (*xDrawSegments) (Display *display, Drawable d, GC gc, XSegment *segments, int nsegments); /* 80 */
- void (*xForceScreenSaver) (Display *display, int mode); /* 81 */
+ int (*xForceScreenSaver) (Display *display, int mode); /* 81 */
int (*xDrawLine) (Display *d, Drawable dr, GC g, int x1, int y1, int x2, int y2); /* 82 */
int (*xFillRectangle) (Display *display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height); /* 83 */
- void (*xClearWindow) (Display *d, Window w); /* 84 */
+ int (*xClearWindow) (Display *d, Window w); /* 84 */
int (*xDrawPoint) (Display *display, Drawable d, GC gc, int x, int y); /* 85 */
int (*xDrawPoints) (Display *display, Drawable d, GC gc, XPoint *points, int npoints, int mode); /* 86 */
int (*xWarpPointer) (Display *display, Window src_w, Window dest_w, int src_x, int src_y, unsigned int src_width, unsigned int src_height, int dest_x, int dest_y); /* 87 */
- void (*xQueryColor) (Display *display, Colormap colormap, XColor *def_in_out); /* 88 */
- void (*xQueryColors) (Display *display, Colormap colormap, XColor *defs_in_out, int ncolors); /* 89 */
+ int (*xQueryColor) (Display *display, Colormap colormap, XColor *def_in_out); /* 88 */
+ int (*xQueryColors) (Display *display, Colormap colormap, XColor *defs_in_out, int ncolors); /* 89 */
Status (*xQueryTree) (Display *d, Window w1, Window *w2, Window *w3, Window **w4, unsigned int *ui); /* 90 */
- int (*xSync) (Display *display, Bool flag); /* 91 */
-#endif /* AQUA */
+ int (*xSync) (Display *display, Bool discard); /* 91 */
+ Bool (*xTranslateCoordinates) (Display *d, Window w1, Window w2, int i1, int i2, int *i3, int *i4, Window *w3); /* 92 */
+ int (*xDeleteProperty) (Display *d, Window w, Atom a); /* 93 */
+ int (*xFreeCursor) (Display *d, Cursor c); /* 94 */
+ int (*xGetInputFocus) (Display *d, Window *w, int *i); /* 95 */
+ int (*xmbLookupString) (XIC xi, XKeyPressedEvent *xk, char *c, int i, KeySym *k, Status *s); /* 96 */
+ int (*xNextEvent) (Display *d, XEvent *x); /* 97 */
+ int (*xPutBackEvent) (Display *d, XEvent *x); /* 98 */
+ int (*xSetCommand) (Display *d, Window w, char **c, int i); /* 99 */
+ int (*xWindowEvent) (Display *d, Window w, long l, XEvent *x); /* 100 */
+ Status (*xGetWindowAttributes) (Display *d, Window w, XWindowAttributes *x); /* 101 */
+ Status (*xGetWMColormapWindows) (Display *d, Window w, Window **wpp, int *ip); /* 102 */
+ Status (*xIconifyWindow) (Display *d, Window w, int i); /* 103 */
+ Status (*xWithdrawWindow) (Display *d, Window w, int i); /* 104 */
+ XHostAddress * (*xListHosts) (Display *d, int *i, Bool *b); /* 105 */
+ void (*reserved106)(void);
+ int (*xFlush) (Display *display); /* 107 */
+ int (*xGrabServer) (Display *display); /* 108 */
+ int (*xUngrabServer) (Display *display); /* 109 */
+ int (*xFree) (void *data); /* 110 */
+ int (*xNoOp) (Display *display); /* 111 */
+ XAfterFunction (*xSynchronize) (Display *display, Bool onoff); /* 112 */
+ Status (*xLookupColor) (Display *d, Colormap c1, _Xconst char *c2, XColor *x1, XColor *x2); /* 113 */
+ VisualID (*xVisualIDFromVisual) (Visual *visual); /* 114 */
+ void (*reserved115)(void);
+ void (*reserved116)(void);
+ void (*reserved117)(void);
+ void (*reserved118)(void);
+ void (*reserved119)(void);
+ int (*xOffsetRegion) (Region rgn, int dx, int dy); /* 120 */
+ int (*xUnionRegion) (Region srca, Region srcb, Region dr_return); /* 121 */
+ Window (*xCreateWindow) (Display *display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, int depth, unsigned int clazz, Visual *visual, unsigned long value_mask, XSetWindowAttributes *attributes); /* 122 */
+ void (*reserved123)(void);
+ void (*reserved124)(void);
+ void (*reserved125)(void);
+ void (*reserved126)(void);
+ void (*reserved127)(void);
+ void (*reserved128)(void);
+ int (*xLowerWindow) (Display *d, Window w); /* 129 */
+ int (*xFillArcs) (Display *d, Drawable dr, GC gc, XArc *a, int n); /* 130 */
+ int (*xDrawArcs) (Display *d, Drawable dr, GC gc, XArc *a, int n); /* 131 */
+ int (*xDrawRectangles) (Display *d, Drawable dr, GC gc, XRectangle *r, int n); /* 132 */
+ void (*reserved133)(void);
+ void (*reserved134)(void);
+ void (*reserved135)(void);
+ int (*xReparentWindow) (Display *d, Window w, Window p, int x, int y); /* 136 */
+ int (*xPutImage) (Display *d, Drawable dr, GC gc, XImage *im, int sx, int sy, int dx, int dy, unsigned int w, unsigned int h); /* 137 */
+ Region (*xPolygonRegion) (XPoint *pts, int n, int rule); /* 138 */
+ int (*xPointInRegion) (Region rgn, int x, int y); /* 139 */
+ XVaNestedList (*xVaCreateNestedList) (int dummy, ...); /* 140 */
+ char * (*xSetICValues) (XIC xic, ...); /* 141 */
+ char * (*xGetICValues) (XIC xic, ...); /* 142 */
+ void (*xSetICFocus) (XIC xic); /* 143 */
+ void (*xDestroyIC) (XIC xic); /* 144 */
+ Cursor (*xCreatePixmapCursor) (Display *d, Pixmap p1, Pixmap p2, XColor *x1, XColor *x2, unsigned int ui1, unsigned int ui2); /* 145 */
+ Cursor (*xCreateGlyphCursor) (Display *d, Font f1, Font f2, unsigned int ui1, unsigned int ui2, XColor _Xconst *x1, XColor _Xconst *x2); /* 146 */
+ void (*xFreeFontSet) (Display *display, XFontSet fontset); /* 147 */
+ int (*xCloseIM) (XIM im); /* 148 */
+ Bool (*xRegisterIMInstantiateCallback) (Display *dpy, struct _XrmHashBucketRec *rbd, char *res_name, char *res_class, XIDProc callback, XPointer client_data); /* 149 */
+ Bool (*xUnregisterIMInstantiateCallback) (Display *dpy, struct _XrmHashBucketRec *rbd, char *res_name, char *res_class, XIDProc callback, XPointer client_data); /* 150 */
+ char * (*xSetLocaleModifiers) (const char *modifier_list); /* 151 */
+ XIM (*xOpenIM) (Display *dpy, struct _XrmHashBucketRec *rdb, char *res_name, char *res_class); /* 152 */
+ char * (*xGetIMValues) (XIM im, ...); /* 153 */
+ char * (*xSetIMValues) (XIM im, ...); /* 154 */
+ XFontSet (*xCreateFontSet) (Display *display, _Xconst char *base_font_name_list, char ***missing_charset_list, int *missing_charset_count, char **def_string); /* 155 */
+ void (*xFreeStringList) (char **list); /* 156 */
+ KeySym (*xkbKeycodeToKeysym) (Display *d, unsigned int k, int g, int i); /* 157 */
+ Display * (*xkbOpenDisplay) (const char *name, int *ev_rtrn, int *err_rtrn, int *major_rtrn, int *minor_rtrn, int *reason); /* 158 */
+#endif /* MACOSX */
} TkIntXlibStubs;
extern const TkIntXlibStubs *tkIntXlibStubsPtr;
@@ -1214,8 +1499,43 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr;
(tkIntXlibStubsPtr->xPolygonRegion) /* 138 */
#define XPointInRegion \
(tkIntXlibStubsPtr->xPointInRegion) /* 139 */
+#define XVaCreateNestedList \
+ (tkIntXlibStubsPtr->xVaCreateNestedList) /* 140 */
+#define XSetICValues \
+ (tkIntXlibStubsPtr->xSetICValues) /* 141 */
+#define XGetICValues \
+ (tkIntXlibStubsPtr->xGetICValues) /* 142 */
+#define XSetICFocus \
+ (tkIntXlibStubsPtr->xSetICFocus) /* 143 */
+/* Slot 144 is reserved */
+/* Slot 145 is reserved */
+/* Slot 146 is reserved */
+#define XFreeFontSet \
+ (tkIntXlibStubsPtr->xFreeFontSet) /* 147 */
+#define XCloseIM \
+ (tkIntXlibStubsPtr->xCloseIM) /* 148 */
+#define XRegisterIMInstantiateCallback \
+ (tkIntXlibStubsPtr->xRegisterIMInstantiateCallback) /* 149 */
+#define XUnregisterIMInstantiateCallback \
+ (tkIntXlibStubsPtr->xUnregisterIMInstantiateCallback) /* 150 */
+#define XSetLocaleModifiers \
+ (tkIntXlibStubsPtr->xSetLocaleModifiers) /* 151 */
+#define XOpenIM \
+ (tkIntXlibStubsPtr->xOpenIM) /* 152 */
+#define XGetIMValues \
+ (tkIntXlibStubsPtr->xGetIMValues) /* 153 */
+#define XSetIMValues \
+ (tkIntXlibStubsPtr->xSetIMValues) /* 154 */
+#define XCreateFontSet \
+ (tkIntXlibStubsPtr->xCreateFontSet) /* 155 */
+#define XFreeStringList \
+ (tkIntXlibStubsPtr->xFreeStringList) /* 156 */
+#define XkbKeycodeToKeysym \
+ (tkIntXlibStubsPtr->xkbKeycodeToKeysym) /* 157 */
+#define XkbOpenDisplay \
+ (tkIntXlibStubsPtr->xkbOpenDisplay) /* 158 */
#endif /* WIN */
-#ifdef MAC_OSX_TK /* AQUA */
+#ifdef MAC_OSX_TCL /* MACOSX */
#define XSetDashes \
(tkIntXlibStubsPtr->xSetDashes) /* 0 */
#define XGetModifierMapping \
@@ -1400,12 +1720,135 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr;
(tkIntXlibStubsPtr->xQueryTree) /* 90 */
#define XSync \
(tkIntXlibStubsPtr->xSync) /* 91 */
-#endif /* AQUA */
+#define XTranslateCoordinates \
+ (tkIntXlibStubsPtr->xTranslateCoordinates) /* 92 */
+#define XDeleteProperty \
+ (tkIntXlibStubsPtr->xDeleteProperty) /* 93 */
+#define XFreeCursor \
+ (tkIntXlibStubsPtr->xFreeCursor) /* 94 */
+#define XGetInputFocus \
+ (tkIntXlibStubsPtr->xGetInputFocus) /* 95 */
+#define XmbLookupString \
+ (tkIntXlibStubsPtr->xmbLookupString) /* 96 */
+#define XNextEvent \
+ (tkIntXlibStubsPtr->xNextEvent) /* 97 */
+#define XPutBackEvent \
+ (tkIntXlibStubsPtr->xPutBackEvent) /* 98 */
+#define XSetCommand \
+ (tkIntXlibStubsPtr->xSetCommand) /* 99 */
+#define XWindowEvent \
+ (tkIntXlibStubsPtr->xWindowEvent) /* 100 */
+#define XGetWindowAttributes \
+ (tkIntXlibStubsPtr->xGetWindowAttributes) /* 101 */
+#define XGetWMColormapWindows \
+ (tkIntXlibStubsPtr->xGetWMColormapWindows) /* 102 */
+#define XIconifyWindow \
+ (tkIntXlibStubsPtr->xIconifyWindow) /* 103 */
+#define XWithdrawWindow \
+ (tkIntXlibStubsPtr->xWithdrawWindow) /* 104 */
+#define XListHosts \
+ (tkIntXlibStubsPtr->xListHosts) /* 105 */
+/* Slot 106 is reserved */
+#define XFlush \
+ (tkIntXlibStubsPtr->xFlush) /* 107 */
+#define XGrabServer \
+ (tkIntXlibStubsPtr->xGrabServer) /* 108 */
+#define XUngrabServer \
+ (tkIntXlibStubsPtr->xUngrabServer) /* 109 */
+#define XFree \
+ (tkIntXlibStubsPtr->xFree) /* 110 */
+#define XNoOp \
+ (tkIntXlibStubsPtr->xNoOp) /* 111 */
+#define XSynchronize \
+ (tkIntXlibStubsPtr->xSynchronize) /* 112 */
+#define XLookupColor \
+ (tkIntXlibStubsPtr->xLookupColor) /* 113 */
+#define XVisualIDFromVisual \
+ (tkIntXlibStubsPtr->xVisualIDFromVisual) /* 114 */
+/* Slot 115 is reserved */
+/* Slot 116 is reserved */
+/* Slot 117 is reserved */
+/* Slot 118 is reserved */
+/* Slot 119 is reserved */
+#define XOffsetRegion \
+ (tkIntXlibStubsPtr->xOffsetRegion) /* 120 */
+#define XUnionRegion \
+ (tkIntXlibStubsPtr->xUnionRegion) /* 121 */
+#define XCreateWindow \
+ (tkIntXlibStubsPtr->xCreateWindow) /* 122 */
+/* Slot 123 is reserved */
+/* Slot 124 is reserved */
+/* Slot 125 is reserved */
+/* Slot 126 is reserved */
+/* Slot 127 is reserved */
+/* Slot 128 is reserved */
+#define XLowerWindow \
+ (tkIntXlibStubsPtr->xLowerWindow) /* 129 */
+#define XFillArcs \
+ (tkIntXlibStubsPtr->xFillArcs) /* 130 */
+#define XDrawArcs \
+ (tkIntXlibStubsPtr->xDrawArcs) /* 131 */
+#define XDrawRectangles \
+ (tkIntXlibStubsPtr->xDrawRectangles) /* 132 */
+/* Slot 133 is reserved */
+/* Slot 134 is reserved */
+/* Slot 135 is reserved */
+#define XReparentWindow \
+ (tkIntXlibStubsPtr->xReparentWindow) /* 136 */
+#define XPutImage \
+ (tkIntXlibStubsPtr->xPutImage) /* 137 */
+#define XPolygonRegion \
+ (tkIntXlibStubsPtr->xPolygonRegion) /* 138 */
+#define XPointInRegion \
+ (tkIntXlibStubsPtr->xPointInRegion) /* 139 */
+#define XVaCreateNestedList \
+ (tkIntXlibStubsPtr->xVaCreateNestedList) /* 140 */
+#define XSetICValues \
+ (tkIntXlibStubsPtr->xSetICValues) /* 141 */
+#define XGetICValues \
+ (tkIntXlibStubsPtr->xGetICValues) /* 142 */
+#define XSetICFocus \
+ (tkIntXlibStubsPtr->xSetICFocus) /* 143 */
+#define XDestroyIC \
+ (tkIntXlibStubsPtr->xDestroyIC) /* 144 */
+#define XCreatePixmapCursor \
+ (tkIntXlibStubsPtr->xCreatePixmapCursor) /* 145 */
+#define XCreateGlyphCursor \
+ (tkIntXlibStubsPtr->xCreateGlyphCursor) /* 146 */
+#define XFreeFontSet \
+ (tkIntXlibStubsPtr->xFreeFontSet) /* 147 */
+#define XCloseIM \
+ (tkIntXlibStubsPtr->xCloseIM) /* 148 */
+#define XRegisterIMInstantiateCallback \
+ (tkIntXlibStubsPtr->xRegisterIMInstantiateCallback) /* 149 */
+#define XUnregisterIMInstantiateCallback \
+ (tkIntXlibStubsPtr->xUnregisterIMInstantiateCallback) /* 150 */
+#define XSetLocaleModifiers \
+ (tkIntXlibStubsPtr->xSetLocaleModifiers) /* 151 */
+#define XOpenIM \
+ (tkIntXlibStubsPtr->xOpenIM) /* 152 */
+#define XGetIMValues \
+ (tkIntXlibStubsPtr->xGetIMValues) /* 153 */
+#define XSetIMValues \
+ (tkIntXlibStubsPtr->xSetIMValues) /* 154 */
+#define XCreateFontSet \
+ (tkIntXlibStubsPtr->xCreateFontSet) /* 155 */
+#define XFreeStringList \
+ (tkIntXlibStubsPtr->xFreeStringList) /* 156 */
+#define XkbKeycodeToKeysym \
+ (tkIntXlibStubsPtr->xkbKeycodeToKeysym) /* 157 */
+#define XkbOpenDisplay \
+ (tkIntXlibStubsPtr->xkbOpenDisplay) /* 158 */
+#endif /* MACOSX */
#endif /* defined(USE_TK_STUBS) */
/* !END!: Do not edit above this line. */
+#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* X11, Except MacOS/Cygwin */
+EXTERN Display *XkbOpenDisplay(const char *, int *, int *, int *, int *, int *);
+#endif
+
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index 3a0237c..ce5f350 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -239,80 +239,80 @@ static const char *const activeStyleStrings[] = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-activestyle", "activeStyle", "ActiveStyle",
- DEF_LISTBOX_ACTIVE_STYLE, -1, Tk_Offset(Listbox, activeStyle),
+ DEF_LISTBOX_ACTIVE_STYLE, TCL_INDEX_NONE, offsetof(Listbox, activeStyle),
0, activeStyleStrings, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_LISTBOX_BG_COLOR, -1, Tk_Offset(Listbox, normalBorder),
+ DEF_LISTBOX_BG_COLOR, TCL_INDEX_NONE, offsetof(Listbox, normalBorder),
0, DEF_LISTBOX_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_LISTBOX_BORDER_WIDTH, -1, Tk_Offset(Listbox, borderWidth),
+ DEF_LISTBOX_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Listbox, borderWidth),
0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_LISTBOX_CURSOR, -1, Tk_Offset(Listbox, cursor),
+ DEF_LISTBOX_CURSOR, TCL_INDEX_NONE, offsetof(Listbox, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_LISTBOX_DISABLED_FG, -1,
- Tk_Offset(Listbox, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
+ "DisabledForeground", DEF_LISTBOX_DISABLED_FG, TCL_INDEX_NONE,
+ offsetof(Listbox, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_LISTBOX_EXPORT_SELECTION, -1,
- Tk_Offset(Listbox, exportSelection), 0, 0, 0},
+ "ExportSelection", DEF_LISTBOX_EXPORT_SELECTION, TCL_INDEX_NONE,
+ offsetof(Listbox, exportSelection), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_LISTBOX_FONT, -1, Tk_Offset(Listbox, tkfont), 0, 0, 0},
+ DEF_LISTBOX_FONT, TCL_INDEX_NONE, offsetof(Listbox, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_LISTBOX_FG, -1, Tk_Offset(Listbox, fgColorPtr), 0, 0, 0},
+ DEF_LISTBOX_FG, TCL_INDEX_NONE, offsetof(Listbox, fgColorPtr), 0, 0, 0},
{TK_OPTION_INT, "-height", "height", "Height",
- DEF_LISTBOX_HEIGHT, -1, Tk_Offset(Listbox, height), 0, 0, 0},
+ DEF_LISTBOX_HEIGHT, TCL_INDEX_NONE, offsetof(Listbox, height), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_LISTBOX_HIGHLIGHT_BG, -1,
- Tk_Offset(Listbox, highlightBgColorPtr), 0, 0, 0},
+ "HighlightBackground", DEF_LISTBOX_HIGHLIGHT_BG, TCL_INDEX_NONE,
+ offsetof(Listbox, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_LISTBOX_HIGHLIGHT, -1, Tk_Offset(Listbox, highlightColorPtr),
+ DEF_LISTBOX_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Listbox, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Listbox, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Listbox, highlightWidth), 0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_LISTBOX_JUSTIFY, -1, Tk_Offset(Listbox, justify), 0, 0, 0},
+ DEF_LISTBOX_JUSTIFY, TCL_INDEX_NONE, offsetof(Listbox, justify), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LISTBOX_RELIEF, -1, Tk_Offset(Listbox, relief), 0, 0, 0},
+ DEF_LISTBOX_RELIEF, TCL_INDEX_NONE, offsetof(Listbox, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_LISTBOX_SELECT_COLOR, -1, Tk_Offset(Listbox, selBorder),
+ DEF_LISTBOX_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Listbox, selBorder),
0, DEF_LISTBOX_SELECT_MONO, 0},
{TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
- "BorderWidth", DEF_LISTBOX_SELECT_BD, -1,
- Tk_Offset(Listbox, selBorderWidth), 0, 0, 0},
+ "BorderWidth", DEF_LISTBOX_SELECT_BD, TCL_INDEX_NONE,
+ offsetof(Listbox, selBorderWidth), 0, 0, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_LISTBOX_SELECT_FG_COLOR, -1, Tk_Offset(Listbox, selFgColorPtr),
+ DEF_LISTBOX_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Listbox, selFgColorPtr),
TK_OPTION_NULL_OK, DEF_LISTBOX_SELECT_FG_MONO, 0},
{TK_OPTION_STRING, "-selectmode", "selectMode", "SelectMode",
- DEF_LISTBOX_SELECT_MODE, -1, Tk_Offset(Listbox, selectMode),
+ DEF_LISTBOX_SELECT_MODE, TCL_INDEX_NONE, offsetof(Listbox, selectMode),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid",
- DEF_LISTBOX_SET_GRID, -1, Tk_Offset(Listbox, setGrid), 0, 0, 0},
+ DEF_LISTBOX_SET_GRID, TCL_INDEX_NONE, offsetof(Listbox, setGrid), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_LISTBOX_STATE, -1, Tk_Offset(Listbox, state),
+ DEF_LISTBOX_STATE, TCL_INDEX_NONE, offsetof(Listbox, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_LISTBOX_TAKE_FOCUS, -1, Tk_Offset(Listbox, takeFocus),
+ DEF_LISTBOX_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Listbox, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_LISTBOX_WIDTH, -1, Tk_Offset(Listbox, width), 0, 0, 0},
+ DEF_LISTBOX_WIDTH, TCL_INDEX_NONE, offsetof(Listbox, width), 0, 0, 0},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_LISTBOX_SCROLL_COMMAND, -1, Tk_Offset(Listbox, xScrollCmd),
+ DEF_LISTBOX_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Listbox, xScrollCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- DEF_LISTBOX_SCROLL_COMMAND, -1, Tk_Offset(Listbox, yScrollCmd),
+ DEF_LISTBOX_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Listbox, yScrollCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-listvariable", "listVariable", "Variable",
- DEF_LISTBOX_LIST_VARIABLE, -1, Tk_Offset(Listbox, listVarName),
+ DEF_LISTBOX_LIST_VARIABLE, TCL_INDEX_NONE, offsetof(Listbox, listVarName),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -322,25 +322,25 @@ static const Tk_OptionSpec optionSpecs[] = {
static const Tk_OptionSpec itemAttrOptionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- NULL, -1, Tk_Offset(ItemAttr, border),
+ NULL, TCL_INDEX_NONE, offsetof(ItemAttr, border),
TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
DEF_LISTBOX_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- NULL, -1, Tk_Offset(ItemAttr, fgColor),
+ NULL, TCL_INDEX_NONE, offsetof(ItemAttr, fgColor),
TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- NULL, -1, Tk_Offset(ItemAttr, selBorder),
+ NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selBorder),
TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
DEF_LISTBOX_SELECT_MONO, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- NULL, -1, Tk_Offset(ItemAttr, selFgColor),
+ NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selFgColor),
TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
DEF_LISTBOX_SELECT_FG_MONO, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -377,10 +377,10 @@ enum scancommand {
};
static const char *const indexNames[] = {
- "active", "anchor", "end", NULL
+ "active", "anchor", NULL
};
enum indices {
- INDEX_ACTIVE, INDEX_ANCHOR, INDEX_END
+ INDEX_ACTIVE, INDEX_ANCHOR
};
/*
@@ -473,14 +473,15 @@ static const Tk_ClassProcs listboxClass = {
int
Tk_ListboxObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Listbox *listPtr;
+ Listbox *listPtr;
Tk_Window tkwin;
ListboxOptionTables *optionTables;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -493,7 +494,7 @@ Tk_ListboxObjCmd(
return TCL_ERROR;
}
- optionTables = Tcl_GetAssocData(interp, "ListboxOptionTables", NULL);
+ optionTables = (ListboxOptionTables *)Tcl_GetAssocData(interp, "ListboxOptionTables", NULL);
if (optionTables == NULL) {
/*
* We haven't created the option tables for this widget class yet. Do
@@ -501,7 +502,7 @@ Tk_ListboxObjCmd(
* command, so future invocations will have access to it.
*/
- optionTables = ckalloc(sizeof(ListboxOptionTables));
+ optionTables = (ListboxOptionTables *)ckalloc(sizeof(ListboxOptionTables));
/*
* Set up an exit handler to free the optionTables struct.
@@ -526,7 +527,7 @@ Tk_ListboxObjCmd(
* already (e.g. resource pointers).
*/
- listPtr = ckalloc(sizeof(Listbox));
+ listPtr = (Listbox *)ckalloc(sizeof(Listbox));
memset(listPtr, 0, sizeof(Listbox));
listPtr->tkwin = tkwin;
@@ -537,9 +538,9 @@ Tk_ListboxObjCmd(
ListboxCmdDeletedProc);
listPtr->optionTable = optionTables->listboxOptionTable;
listPtr->itemAttrOptionTable = optionTables->itemAttrOptionTable;
- listPtr->selection = ckalloc(sizeof(Tcl_HashTable));
+ listPtr->selection = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(listPtr->selection, TCL_ONE_WORD_KEYS);
- listPtr->itemAttrTable = ckalloc(sizeof(Tcl_HashTable));
+ listPtr->itemAttrTable = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(listPtr->itemAttrTable, TCL_ONE_WORD_KEYS);
listPtr->relief = TK_RELIEF_RAISED;
listPtr->textGC = NULL;
@@ -607,7 +608,7 @@ ListboxWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Arguments as Tcl_Obj's. */
{
- register Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
int cmdIndex, index;
int result = TCL_OK;
Tcl_Obj *objPtr;
@@ -728,7 +729,7 @@ ListboxWidgetObjCmd(
objPtr = Tcl_NewObj();
for (i = 0; i < listPtr->nElements; i++) {
if (Tcl_FindHashEntry(listPtr->selection, KEY(i))) {
- Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewIntObj(i));
+ Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewWideIntObj(i));
}
}
Tcl_SetObjResult(interp, objPtr);
@@ -841,7 +842,7 @@ ListboxWidgetObjCmd(
if (result != TCL_OK) {
break;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
result = TCL_OK;
break;
@@ -956,7 +957,7 @@ ListboxWidgetObjCmd(
break;
}
index = NearestListboxElement(listPtr, y);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
result = TCL_OK;
break;
}
@@ -1044,7 +1045,7 @@ ListboxWidgetObjCmd(
result = TCL_ERROR;
break;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(listPtr->nElements));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(listPtr->nElements));
result = TCL_OK;
break;
case COMMAND_XVIEW:
@@ -1082,7 +1083,7 @@ ListboxBboxSubCmd(
Listbox *listPtr, /* Information about the listbox */
int index) /* Index of the element to get bbox info on */
{
- register Tk_Window tkwin = listPtr->tkwin;
+ Tk_Window tkwin = listPtr->tkwin;
int lastVisibleIndex;
/*
@@ -1103,7 +1104,7 @@ ListboxBboxSubCmd(
Tcl_Obj *el, *results[4];
const char *stringRep;
int pixelWidth, x, y, result;
- size_t stringLen;
+ TkSizeT stringLen;
Tk_FontMetrics fm;
/*
@@ -1130,10 +1131,10 @@ ListboxBboxSubCmd(
}
y = ((index - listPtr->topIndex)*listPtr->lineHeight)
+ listPtr->inset + listPtr->selBorderWidth;
- results[0] = Tcl_NewIntObj(x);
- results[1] = Tcl_NewIntObj(y);
- results[2] = Tcl_NewIntObj(pixelWidth);
- results[3] = Tcl_NewIntObj(fm.linespace);
+ results[0] = Tcl_NewWideIntObj(x);
+ results[1] = Tcl_NewWideIntObj(y);
+ results[2] = Tcl_NewWideIntObj(pixelWidth);
+ results[3] = Tcl_NewWideIntObj(fm.linespace);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
@@ -1411,7 +1412,7 @@ ListboxGetItemAttributes(
entry = Tcl_CreateHashEntry(listPtr->itemAttrTable, KEY(index), &isNew);
if (isNew) {
- attrs = ckalloc(sizeof(ItemAttr));
+ attrs = (ItemAttr *)ckalloc(sizeof(ItemAttr));
attrs->border = NULL;
attrs->selBorder = NULL;
attrs->fgColor = NULL;
@@ -1420,7 +1421,7 @@ ListboxGetItemAttributes(
listPtr->tkwin);
Tcl_SetHashValue(entry, attrs);
} else {
- attrs = Tcl_GetHashValue(entry);
+ attrs = (ItemAttr *)Tcl_GetHashValue(entry);
}
return attrs;
}
@@ -1447,7 +1448,7 @@ static void
DestroyListbox(
void *memPtr) /* Info about listbox widget. */
{
- register Listbox *listPtr = memPtr;
+ Listbox *listPtr = (Listbox *)memPtr;
Tcl_HashEntry *entry;
Tcl_HashSearch search;
@@ -1527,8 +1528,10 @@ DestroyListbox(
static void
DestroyListboxOptionTables(
ClientData clientData, /* Pointer to the OptionTables struct */
- Tcl_Interp *interp) /* Pointer to the calling interp */
+ Tcl_Interp *dummy) /* Pointer to the calling interp */
{
+ (void)dummy;
+
ckfree(clientData);
return;
}
@@ -1556,7 +1559,7 @@ DestroyListboxOptionTables(
static int
ConfigureListbox(
Tcl_Interp *interp, /* Used for error reporting. */
- register Listbox *listPtr, /* Information about widget; may or may not
+ Listbox *listPtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
@@ -1716,7 +1719,7 @@ ConfigureListbox(
static int
ConfigureListboxItem(
Tcl_Interp *interp, /* Used for error reporting. */
- register Listbox *listPtr, /* Information about widget; may or may not
+ Listbox *listPtr, /* Information about widget; may or may not
* already have values for some fields. */
ItemAttr *attrs, /* Information about the item to configure */
int objc, /* Number of valid entries in argv. */
@@ -1767,7 +1770,7 @@ ListboxWorldChanged(
XGCValues gcValues;
GC gc;
unsigned long mask;
- Listbox *listPtr = instanceData;
+ Listbox *listPtr = (Listbox *)instanceData;
if (listPtr->state & STATE_NORMAL) {
gcValues.foreground = listPtr->fgColorPtr->pixel;
@@ -1838,11 +1841,11 @@ static void
DisplayListbox(
ClientData clientData) /* Information about window. */
{
- register Listbox *listPtr = clientData;
- register Tk_Window tkwin = listPtr->tkwin;
+ Listbox *listPtr = (Listbox *)clientData;
+ Tk_Window tkwin = listPtr->tkwin;
GC gc;
int i, limit, x, y, prevSelected, freeGC;
- size_t stringLen;
+ TkSizeT stringLen;
Tk_FontMetrics fm;
Tcl_Obj *curElement;
Tcl_HashEntry *entry;
@@ -1958,7 +1961,7 @@ DisplayListbox(
*/
if (entry != NULL) {
- attrs = Tcl_GetHashValue(entry);
+ attrs = (ItemAttr *)Tcl_GetHashValue(entry);
/*
* Default GC has the values from the widget at large.
@@ -2039,7 +2042,7 @@ DisplayListbox(
*/
if (entry != NULL) {
- attrs = Tcl_GetHashValue(entry);
+ attrs = (ItemAttr *)Tcl_GetHashValue(entry);
gcValues.foreground = listPtr->fgColorPtr->pixel;
gcValues.font = Tk_FontId(listPtr->tkfont);
gcValues.graphics_exposures = False;
@@ -2239,7 +2242,7 @@ ListboxComputeGeometry(
* window. */
{
int width, height, pixelWidth, pixelHeight, i, result;
- size_t textLength;
+ TkSizeT textLength;
Tk_FontMetrics fm;
Tcl_Obj *element;
const char *text;
@@ -2320,14 +2323,14 @@ ListboxComputeGeometry(
static int
ListboxInsertSubCmd(
- register Listbox *listPtr, /* Listbox that is to get the new elements. */
+ Listbox *listPtr, /* Listbox that is to get the new elements. */
int index, /* Add the new elements before this
* element. */
int objc, /* Number of new elements to add. */
Tcl_Obj *const objv[]) /* New elements (one per entry). */
{
int i, oldMaxWidth, pixelWidth, result;
- size_t length;
+ TkSizeT length;
Tcl_Obj *newListObj;
const char *stringRep;
@@ -2437,12 +2440,12 @@ ListboxInsertSubCmd(
static int
ListboxDeleteSubCmd(
- register Listbox *listPtr, /* Listbox widget to modify. */
+ Listbox *listPtr, /* Listbox widget to modify. */
int first, /* Index of first element to delete. */
int last) /* Index of last element to delete. */
{
int count, i, widthChanged, result, pixelWidth;
- size_t length;
+ TkSizeT length;
Tcl_Obj *newListObj, *element;
const char *stringRep;
Tcl_HashEntry *entry;
@@ -2615,7 +2618,7 @@ ListboxEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
if (eventPtr->type == Expose) {
EventuallyRedrawRange(listPtr,
@@ -2690,7 +2693,7 @@ static void
ListboxCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
/*
* This procedure could be invoked either because the window was destroyed
@@ -2728,14 +2731,24 @@ GetListboxIndex(
Listbox *listPtr, /* Listbox for which the index is being
* specified. */
Tcl_Obj *indexObj, /* Specifies an element in the listbox. */
- int endIsSize, /* If 1, "end" refers to the number of entries
+ int lastOK, /* If 1, "end" refers to the number of entries
* in the listbox. If 0, "end" refers to 1
* less than the number of entries. */
int *indexPtr) /* Where to store converted index. */
{
int result, index;
+ TkSizeT idx;
const char *stringRep;
+ result = TkGetIntForIndex(indexObj, listPtr->nElements - 1, lastOK, &idx);
+ if (result == TCL_OK) {
+ if (idx + 1 > (TkSizeT)listPtr->nElements + 1) {
+ idx = listPtr->nElements;
+ }
+ *indexPtr = (int)idx;
+ return TCL_OK;
+ }
+
/*
* First see if the index is one of the named indices.
*/
@@ -2751,14 +2764,6 @@ GetListboxIndex(
/* "anchor" index */
*indexPtr = listPtr->selectAnchor;
break;
- case INDEX_END:
- /* "end" index */
- if (endIsSize) {
- *indexPtr = listPtr->nElements;
- } else {
- *indexPtr = listPtr->nElements - 1;
- }
- break;
}
return TCL_OK;
}
@@ -2793,14 +2798,6 @@ GetListboxIndex(
}
/*
- * Maybe the index is just an integer.
- */
-
- if (Tcl_GetIntFromObj(interp, indexObj, indexPtr) == TCL_OK) {
- return TCL_OK;
- }
-
- /*
* Everything failed, nothing matched. Throw up an error message.
*/
@@ -2833,7 +2830,7 @@ GetListboxIndex(
static void
ChangeListboxView(
- register Listbox *listPtr, /* Information about widget. */
+ Listbox *listPtr, /* Information about widget. */
int index) /* Index of element in listPtr that should now
* appear at the top of the listbox. */
{
@@ -2868,7 +2865,7 @@ ChangeListboxView(
static void
ChangeListboxOffset(
- register Listbox *listPtr, /* Information about widget. */
+ Listbox *listPtr, /* Information about widget. */
int offset) /* Desired new "xOffset" for listbox. */
{
int maxOffset;
@@ -2916,7 +2913,7 @@ ChangeListboxOffset(
static void
ListboxScanTo(
- register Listbox *listPtr, /* Information about widget. */
+ Listbox *listPtr, /* Information about widget. */
int x, /* X-coordinate to use for scan operation. */
int y) /* Y-coordinate to use for scan operation. */
{
@@ -2983,7 +2980,7 @@ ListboxScanTo(
static int
NearestListboxElement(
- register Listbox *listPtr, /* Information about widget. */
+ Listbox *listPtr, /* Information about widget. */
int y) /* Y-coordinate in listPtr's window. */
{
int index;
@@ -3024,7 +3021,7 @@ NearestListboxElement(
static int
ListboxSelect(
- register Listbox *listPtr, /* Information about widget. */
+ Listbox *listPtr, /* Information about widget. */
int first, /* Index of first element to select or
* deselect. */
int last, /* Index of last element to select or
@@ -3125,10 +3122,10 @@ ListboxFetchSelection(
* not including terminating NULL
* character. */
{
- register Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
Tcl_DString selection;
int count, needNewline, i;
- size_t length, stringLen;
+ TkSizeT length, stringLen;
Tcl_Obj *curElement;
const char *stringRep;
Tcl_HashEntry *entry;
@@ -3166,7 +3163,7 @@ ListboxFetchSelection(
* Copy the requested portion of the selection to the buffer.
*/
- if (length <= (size_t)offset) {
+ if (length <= (TkSizeT)offset) {
count = 0;
} else {
count = length - offset;
@@ -3202,7 +3199,7 @@ static void
ListboxLostSelection(
ClientData clientData) /* Information about listbox widget. */
{
- register Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
if ((listPtr->exportSelection) && (!Tcl_IsSafe(listPtr->interp))
&& (listPtr->nElements > 0)) {
@@ -3254,13 +3251,16 @@ GenerateListboxSelectEvent(
static void
EventuallyRedrawRange(
- register Listbox *listPtr, /* Information about widget. */
+ Listbox *listPtr, /* Information about widget. */
int first, /* Index of first element in list that needs
* to be redrawn. */
int last) /* Index of last element in list that needs to
* be redrawn. May be less than first; these
* just bracket a range. */
{
+ (void)first;
+ (void)last;
+
/*
* We don't have to register a redraw callback if one is already pending,
* or if the window doesn't exist, or if the window isn't mapped.
@@ -3297,7 +3297,7 @@ EventuallyRedrawRange(
static void
ListboxUpdateVScrollbar(
- register Listbox *listPtr) /* Information about widget. */
+ Listbox *listPtr) /* Information about widget. */
{
char firstStr[TCL_DOUBLE_SPACE], lastStr[TCL_DOUBLE_SPACE];
double first, last;
@@ -3367,7 +3367,7 @@ ListboxUpdateVScrollbar(
static void
ListboxUpdateHScrollbar(
- register Listbox *listPtr) /* Information about widget. */
+ Listbox *listPtr) /* Information about widget. */
{
char firstStr[TCL_DOUBLE_SPACE], lastStr[TCL_DOUBLE_SPACE];
int result, windowWidth;
@@ -3437,34 +3437,44 @@ static char *
ListboxListVarProc(
ClientData clientData, /* Information about button. */
Tcl_Interp *interp, /* Interpreter containing variable. */
- const char *name1, /* Name of variable. */
- const char *name2, /* Second part of variable name. */
+ const char *name1, /* Not used. */
+ const char *name2, /* Not used. */
int flags) /* Information about what happened. */
{
- Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
Tcl_Obj *oldListObj, *varListObj;
int oldLength, i;
Tcl_HashEntry *entry;
-
- /*
- * See ticket [5d991b82].
- */
-
- if (listPtr->listVarName == NULL) {
- if (!(flags & TCL_INTERP_DESTROYED)) {
- Tcl_UntraceVar2(interp, name1, name2,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ListboxListVarProc, clientData);
- }
- return NULL;
- }
+ (void)name1;
+ (void)name2;
/*
* Bwah hahahaha! Puny mortal, you can't unset a -listvar'd variable!
*/
if (flags & TCL_TRACE_UNSETS) {
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
+
+ if (!Tcl_InterpDeleted(interp) && listPtr->listVarName) {
+ ClientData probe = NULL;
+
+ do {
+ probe = Tcl_VarTraceInfo(interp,
+ listPtr->listVarName,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ ListboxListVarProc, probe);
+ if (probe == (ClientData)listPtr) {
+ break;
+ }
+ } while (probe);
+ if (probe) {
+ /*
+ * We were able to fetch the unset trace for our
+ * listVarName, which means it is not unset and not
+ * the cause of this unset trace. Instead some outdated
+ * former variable must be, and we should ignore it.
+ */
+ return NULL;
+ }
Tcl_SetVar2Ex(interp, listPtr->listVarName, NULL,
listPtr->listObj, TCL_GLOBAL_ONLY);
Tcl_TraceVar2(interp, listPtr->listVarName,
@@ -3640,7 +3650,7 @@ MigrateHashEntries(
*----------------------------------------------------------------------
*/
static int GetMaxOffset(
- register Listbox *listPtr)
+ Listbox *listPtr)
{
int maxOffset;
diff --git a/generic/tkMacWinMenu.c b/generic/tkMacWinMenu.c
index 9449838..40a5ea8 100644
--- a/generic/tkMacWinMenu.c
+++ b/generic/tkMacWinMenu.c
@@ -13,7 +13,7 @@
#include "tkInt.h"
#include "tkMenu.h"
-typedef struct ThreadSpecificData {
+typedef struct {
int postCommandGeneration;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -43,7 +43,7 @@ PreprocessMenu(
TkMenu *menuPtr)
{
int index, result, finished;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_Preserve(menuPtr);
@@ -66,8 +66,8 @@ PreprocessMenu(
do {
finished = 1;
- for (index = 0; index < menuPtr->numEntries; index++) {
- register TkMenuEntry *entryPtr = menuPtr->entries[index];
+ for (index = 0; index < (int)menuPtr->numEntries; index++) {
+ TkMenuEntry *entryPtr = menuPtr->entries[index];
if ((entryPtr->type == CASCADE_ENTRY)
&& (entryPtr->namePtr != NULL)
@@ -129,7 +129,7 @@ int
TkPreprocessMenu(
TkMenu *menuPtr)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
tsdPtr->postCommandGeneration++;
diff --git a/generic/tkMain.c b/generic/tkMain.c
index eb311ff..879a7c0 100644
--- a/generic/tkMain.c
+++ b/generic/tkMain.c
@@ -14,21 +14,6 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-/**
- * On Windows, this file needs to be compiled twice, once with
- * TK_ASCII_MAIN defined. This way both Tk_MainEx and Tk_MainExW
- * can be implemented, sharing the same source code.
- */
-#if defined(TK_ASCII_MAIN)
-# ifdef UNICODE
-# undef UNICODE
-# undef _UNICODE
-# else
-# define UNICODE
-# define _UNICODE
-# endif
-#endif
-
#include "tkInt.h"
extern int TkCygwinMainEx(int, char **, Tcl_AppInitProc *, Tcl_Interp *);
@@ -50,13 +35,13 @@ static const char DEFAULT_PRIMARY_PROMPT[] = "% ";
/* Little hack to eliminate the need for "tclInt.h" here:
Just copy a small portion of TclIntPlatStubs, just
enough to make it work. See [600b72bfbc] */
-typedef struct {
+typedef struct TclIntPlatStubs {
int magic;
void *hooks;
void (*dummy[16]) (void); /* dummy entries 0-15, not used */
int (*tclpIsAtty) (int fd); /* 16 */
} TclIntPlatStubs;
-extern const TclIntPlatStubs *tclIntPlatStubsPtr;
+const TclIntPlatStubs *tclIntPlatStubsPtr;
# include "tkWinInt.h"
#else
# define TCHAR char
@@ -70,23 +55,23 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr;
#include "tkMacOSXInt.h"
#endif
-/*
- * Further on, in UNICODE mode, we need to use Tcl_NewUnicodeObj,
- * while otherwise NewNativeObj is needed (which provides proper
- * conversion from native encoding to UTF-8).
- */
+static inline Tcl_Obj *
+NewNativeObj(
+ TCHAR *string)
+{
+ Tcl_Obj *obj;
+ Tcl_DString ds;
+
#ifdef UNICODE
-# define NewNativeObj Tcl_NewUnicodeObj
-#else /* !UNICODE */
- static Tcl_Obj *NewNativeObj(char *string, int length) {
- Tcl_Obj *obj;
- Tcl_DString ds;
- Tcl_ExternalToUtfDString(NULL, string, length, &ds);
- obj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
- Tcl_DStringFree(&ds);
- return obj;
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(string, wcslen(string), &ds);
+#else
+ Tcl_ExternalToUtfDString(NULL, (char *) string, -1, &ds);
+#endif
+ obj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
+ Tcl_DStringFree(&ds);
+ return obj;
}
-#endif /* !UNICODE */
/*
* Declarations for various library functions and variables (don't want to
@@ -261,19 +246,19 @@ Tk_MainEx(
if ((argc > 3) && (0 == _tcscmp(TEXT("-encoding"), argv[1]))
&& (TEXT('-') != argv[3][0])) {
- Tcl_Obj *value = NewNativeObj(argv[2], -1);
- Tcl_SetStartupScript(NewNativeObj(argv[3], -1), Tcl_GetString(value));
+ Tcl_Obj *value = NewNativeObj(argv[2]);
+ Tcl_SetStartupScript(NewNativeObj(argv[3]), Tcl_GetString(value));
Tcl_DecrRefCount(value);
argc -= 3;
argv += 3;
} else if ((argc > 1) && (TEXT('-') != argv[1][0])) {
- Tcl_SetStartupScript(NewNativeObj(argv[1], -1), NULL);
+ Tcl_SetStartupScript(NewNativeObj(argv[1]), NULL);
argc--;
argv++;
} else if ((argc > 2) && (length = _tcslen(argv[1]))
&& (length > 1) && (0 == _tcsncmp(TEXT("-file"), argv[1], length))
&& (TEXT('-') != argv[2][0])) {
- Tcl_SetStartupScript(NewNativeObj(argv[2], -1), NULL);
+ Tcl_SetStartupScript(NewNativeObj(argv[2]), NULL);
argc -= 2;
argv += 2;
}
@@ -281,7 +266,7 @@ Tk_MainEx(
path = Tcl_GetStartupScript(&encodingName);
if (path == NULL) {
- appName = NewNativeObj(argv[0], -1);
+ appName = NewNativeObj(argv[0]);
} else {
appName = path;
}
@@ -289,11 +274,11 @@ Tk_MainEx(
argc--;
argv++;
- Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc), TCL_GLOBAL_ONLY);
+ Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewWideIntObj(argc), TCL_GLOBAL_ONLY);
argvPtr = Tcl_NewListObj(0, NULL);
while (argc--) {
- Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(*argv++, -1));
+ Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(*argv++));
}
Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
@@ -316,7 +301,7 @@ Tk_MainEx(
}
#endif
Tcl_SetVar2Ex(interp, "tcl_interactive", NULL,
- Tcl_NewIntObj(!path && (is.tty || nullStdin)), TCL_GLOBAL_ONLY);
+ Tcl_NewWideIntObj(!path && (is.tty || nullStdin)), TCL_GLOBAL_ONLY);
/*
* Invoke application-specific initialization.
@@ -409,7 +394,6 @@ Tk_MainEx(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static void
StdinProc(
ClientData clientData, /* The state of interactive cmd line */
@@ -418,11 +402,12 @@ StdinProc(
char *cmd;
int code;
size_t count;
- InteractiveState *isPtr = clientData;
+ InteractiveState *isPtr = (InteractiveState *)clientData;
Tcl_Channel chan = isPtr->input;
Tcl_Interp *interp = isPtr->interp;
+ (void)mask;
- count = Tcl_Gets(chan, &isPtr->line);
+ count = (size_t)Tcl_Gets(chan, &isPtr->line);
if (count == (size_t)-1 && !isPtr->gotPartial) {
if (isPtr->tty) {
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index dd29d79..3b50daa 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -77,7 +77,7 @@
#define MENU_HASH_KEY "tkMenus"
-typedef struct ThreadSpecificData {
+typedef struct {
int menusInitialized; /* Flag indicates whether thread-specific
* elements of the Windows Menu module have
* been initialized. */
@@ -90,7 +90,7 @@ static Tcl_ThreadDataKey dataKey;
/*
* The following flag indicates whether the process-wide state for the Menu
- * module has been intialized. The Mutex protects access to that flag.
+ * module has been initialized. The Mutex protects access to that flag.
*/
static int menusInitialized;
@@ -118,117 +118,117 @@ static const char *const compoundStrings[] = {
static const Tk_OptionSpec tkBasicMenuEntryConfigSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", NULL, NULL,
- DEF_MENU_ENTRY_ACTIVE_BG, Tk_Offset(TkMenuEntry, activeBorderPtr), -1,
+ DEF_MENU_ENTRY_ACTIVE_BG, offsetof(TkMenuEntry, activeBorderPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-activeforeground", NULL, NULL,
DEF_MENU_ENTRY_ACTIVE_FG,
- Tk_Offset(TkMenuEntry, activeFgPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, activeFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-accelerator", NULL, NULL,
DEF_MENU_ENTRY_ACCELERATOR,
- Tk_Offset(TkMenuEntry, accelPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, accelPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BORDER, "-background", NULL, NULL,
DEF_MENU_ENTRY_BG,
- Tk_Offset(TkMenuEntry, borderPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BITMAP, "-bitmap", NULL, NULL,
DEF_MENU_ENTRY_BITMAP,
- Tk_Offset(TkMenuEntry, bitmapPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, bitmapPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-columnbreak", NULL, NULL,
DEF_MENU_ENTRY_COLUMN_BREAK,
- -1, Tk_Offset(TkMenuEntry, columnBreak), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, columnBreak), 0, NULL, 0},
{TK_OPTION_STRING, "-command", NULL, NULL,
DEF_MENU_ENTRY_COMMAND,
- Tk_Offset(TkMenuEntry, commandPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_MENU_ENTRY_COMPOUND, -1, Tk_Offset(TkMenuEntry, compound), 0,
+ DEF_MENU_ENTRY_COMPOUND, TCL_INDEX_NONE, offsetof(TkMenuEntry, compound), 0,
(ClientData) compoundStrings, 0},
{TK_OPTION_FONT, "-font", NULL, NULL,
DEF_MENU_ENTRY_FONT,
- Tk_Offset(TkMenuEntry, fontPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, fontPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-foreground", NULL, NULL,
DEF_MENU_ENTRY_FG,
- Tk_Offset(TkMenuEntry, fgPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, fgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-hidemargin", NULL, NULL,
DEF_MENU_ENTRY_HIDE_MARGIN,
- -1, Tk_Offset(TkMenuEntry, hideMargin), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, hideMargin), 0, NULL, 0},
{TK_OPTION_STRING, "-image", NULL, NULL,
DEF_MENU_ENTRY_IMAGE,
- Tk_Offset(TkMenuEntry, imagePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-label", NULL, NULL,
DEF_MENU_ENTRY_LABEL,
- Tk_Offset(TkMenuEntry, labelPtr), -1, 0, NULL, 0},
+ offsetof(TkMenuEntry, labelPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING_TABLE, "-state", NULL, NULL,
DEF_MENU_ENTRY_STATE,
- -1, Tk_Offset(TkMenuEntry, state), 0,
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, state), 0,
(ClientData) menuStateStrings, 0},
{TK_OPTION_INT, "-underline", NULL, NULL,
- DEF_MENU_ENTRY_UNDERLINE, -1, Tk_Offset(TkMenuEntry, underline), 0, NULL, 0},
+ DEF_MENU_ENTRY_UNDERLINE, TCL_INDEX_NONE, offsetof(TkMenuEntry, underline), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
};
static const Tk_OptionSpec tkSeparatorEntryConfigSpecs[] = {
{TK_OPTION_BORDER, "-background", NULL, NULL,
DEF_MENU_ENTRY_BG,
- Tk_Offset(TkMenuEntry, borderPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
};
static const Tk_OptionSpec tkCheckButtonEntryConfigSpecs[] = {
{TK_OPTION_BOOLEAN, "-indicatoron", NULL, NULL,
DEF_MENU_ENTRY_INDICATOR,
- -1, Tk_Offset(TkMenuEntry, indicatorOn), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, indicatorOn), 0, NULL, 0},
{TK_OPTION_STRING, "-offvalue", NULL, NULL,
DEF_MENU_ENTRY_OFF_VALUE,
- Tk_Offset(TkMenuEntry, offValuePtr), -1, 0, NULL, 0},
+ offsetof(TkMenuEntry, offValuePtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-onvalue", NULL, NULL,
DEF_MENU_ENTRY_ON_VALUE,
- Tk_Offset(TkMenuEntry, onValuePtr), -1, 0, NULL, 0},
+ offsetof(TkMenuEntry, onValuePtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_COLOR, "-selectcolor", NULL, NULL,
DEF_MENU_ENTRY_SELECT,
- Tk_Offset(TkMenuEntry, indicatorFgPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, indicatorFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-selectimage", NULL, NULL,
DEF_MENU_ENTRY_SELECT_IMAGE,
- Tk_Offset(TkMenuEntry, selectImagePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, selectImagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-variable", NULL, NULL,
DEF_MENU_ENTRY_CHECK_VARIABLE,
- Tk_Offset(TkMenuEntry, namePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, namePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL,
- NULL, 0, -1, 0, tkBasicMenuEntryConfigSpecs, 0}
+ NULL, 0, TCL_INDEX_NONE, 0, tkBasicMenuEntryConfigSpecs, 0}
};
static const Tk_OptionSpec tkRadioButtonEntryConfigSpecs[] = {
{TK_OPTION_BOOLEAN, "-indicatoron", NULL, NULL,
DEF_MENU_ENTRY_INDICATOR,
- -1, Tk_Offset(TkMenuEntry, indicatorOn), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, indicatorOn), 0, NULL, 0},
{TK_OPTION_COLOR, "-selectcolor", NULL, NULL,
DEF_MENU_ENTRY_SELECT,
- Tk_Offset(TkMenuEntry, indicatorFgPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, indicatorFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-selectimage", NULL, NULL,
DEF_MENU_ENTRY_SELECT_IMAGE,
- Tk_Offset(TkMenuEntry, selectImagePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, selectImagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-value", NULL, NULL,
DEF_MENU_ENTRY_VALUE,
- Tk_Offset(TkMenuEntry, onValuePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, onValuePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-variable", NULL, NULL,
DEF_MENU_ENTRY_RADIO_VARIABLE,
- Tk_Offset(TkMenuEntry, namePtr), -1, 0, NULL, 0},
+ offsetof(TkMenuEntry, namePtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL,
- NULL, 0, -1, 0, tkBasicMenuEntryConfigSpecs, 0}
+ NULL, 0, TCL_INDEX_NONE, 0, tkBasicMenuEntryConfigSpecs, 0}
};
static const Tk_OptionSpec tkCascadeEntryConfigSpecs[] = {
{TK_OPTION_STRING, "-menu", NULL, NULL,
DEF_MENU_ENTRY_MENU,
- Tk_Offset(TkMenuEntry, namePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, namePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL,
- NULL, 0, -1, 0, tkBasicMenuEntryConfigSpecs, 0}
+ NULL, 0, TCL_INDEX_NONE, 0, tkBasicMenuEntryConfigSpecs, 0}
};
static const Tk_OptionSpec tkTearoffEntryConfigSpecs[] = {
{TK_OPTION_BORDER, "-background", NULL, NULL,
DEF_MENU_ENTRY_BG,
- Tk_Offset(TkMenuEntry, borderPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING_TABLE, "-state", NULL, NULL,
- DEF_MENU_ENTRY_STATE, -1, Tk_Offset(TkMenuEntry, state), 0,
+ DEF_MENU_ENTRY_STATE, TCL_INDEX_NONE, offsetof(TkMenuEntry, state), 0,
(ClientData) menuStateStrings, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
};
@@ -250,62 +250,62 @@ static const char *const menuTypeStrings[] = {
static const Tk_OptionSpec tkMenuConfigSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground",
"Foreground", DEF_MENU_ACTIVE_BG_COLOR,
- Tk_Offset(TkMenu, activeBorderPtr), -1, 0,
+ offsetof(TkMenu, activeBorderPtr), TCL_INDEX_NONE, 0,
(ClientData) DEF_MENU_ACTIVE_BG_MONO, 0},
{TK_OPTION_PIXELS, "-activeborderwidth", "activeBorderWidth",
"BorderWidth", DEF_MENU_ACTIVE_BORDER_WIDTH,
- Tk_Offset(TkMenu, activeBorderWidthPtr), -1, 0, NULL, 0},
+ offsetof(TkMenu, activeBorderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground",
"Background", DEF_MENU_ACTIVE_FG_COLOR,
- Tk_Offset(TkMenu, activeFgPtr), -1, 0,
+ offsetof(TkMenu, activeFgPtr), TCL_INDEX_NONE, 0,
(ClientData) DEF_MENU_ACTIVE_FG_MONO, 0},
{TK_OPTION_RELIEF, "-activerelief", "activeRelief", "Relief",
- DEF_MENU_ACTIVE_RELIEF, Tk_Offset(TkMenu, activeReliefPtr),
- -1, 0, NULL, 0},
+ DEF_MENU_ACTIVE_RELIEF, offsetof(TkMenu, activeReliefPtr),
+ TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_MENU_BG_COLOR, Tk_Offset(TkMenu, borderPtr), -1, 0,
+ DEF_MENU_BG_COLOR, offsetof(TkMenu, borderPtr), TCL_INDEX_NONE, 0,
(ClientData) DEF_MENU_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
DEF_MENU_BORDER_WIDTH,
- Tk_Offset(TkMenu, borderWidthPtr), -1, 0, NULL, 0},
+ offsetof(TkMenu, borderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
DEF_MENU_CURSOR,
- Tk_Offset(TkMenu, cursorPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenu, cursorPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_MENU_DISABLED_FG_COLOR,
- Tk_Offset(TkMenu, disabledFgPtr), -1, TK_OPTION_NULL_OK,
+ offsetof(TkMenu, disabledFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK,
(ClientData) DEF_MENU_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", NULL, NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_MENU_FONT, Tk_Offset(TkMenu, fontPtr), -1, 0, NULL, 0},
+ DEF_MENU_FONT, offsetof(TkMenu, fontPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MENU_FG, Tk_Offset(TkMenu, fgPtr), -1, 0, NULL, 0},
+ DEF_MENU_FG, offsetof(TkMenu, fgPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-postcommand", "postCommand", "Command",
DEF_MENU_POST_COMMAND,
- Tk_Offset(TkMenu, postCommandPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenu, postCommandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_MENU_RELIEF, Tk_Offset(TkMenu, reliefPtr), -1, 0, NULL, 0},
+ DEF_MENU_RELIEF, offsetof(TkMenu, reliefPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_COLOR, "-selectcolor", "selectColor", "Background",
- DEF_MENU_SELECT_COLOR, Tk_Offset(TkMenu, indicatorFgPtr), -1, 0,
+ DEF_MENU_SELECT_COLOR, offsetof(TkMenu, indicatorFgPtr), TCL_INDEX_NONE, 0,
(ClientData) DEF_MENU_SELECT_MONO, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
DEF_MENU_TAKE_FOCUS,
- Tk_Offset(TkMenu, takeFocusPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenu, takeFocusPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-tearoff", "tearOff", "TearOff",
- DEF_MENU_TEAROFF, -1, Tk_Offset(TkMenu, tearoff), 0, NULL, 0},
+ DEF_MENU_TEAROFF, TCL_INDEX_NONE, offsetof(TkMenu, tearoff), 0, NULL, 0},
{TK_OPTION_STRING, "-tearoffcommand", "tearOffCommand",
"TearOffCommand", DEF_MENU_TEAROFF_CMD,
- Tk_Offset(TkMenu, tearoffCommandPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenu, tearoffCommandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-title", "title", "Title",
- DEF_MENU_TITLE, Tk_Offset(TkMenu, titlePtr), -1,
+ DEF_MENU_TITLE, offsetof(TkMenu, titlePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING_TABLE, "-type", "type", "Type",
- DEF_MENU_TYPE, Tk_Offset(TkMenu, menuTypePtr), -1, TK_OPTION_NULL_OK,
+ DEF_MENU_TYPE, offsetof(TkMenu, menuTypePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK,
(ClientData) menuTypeStrings, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
};
@@ -346,9 +346,9 @@ static void DestroyMenuHashTable(ClientData clientData,
Tcl_Interp *interp);
static void DestroyMenuInstance(TkMenu *menuPtr);
static void DestroyMenuEntry(void *memPtr);
-static int GetIndexFromCoords(Tcl_Interp *interp,
+static TkSizeT GetIndexFromCoords(Tcl_Interp *interp,
TkMenu *menuPtr, const char *string,
- int *indexPtr);
+ TkSizeT *indexPtr);
static int MenuDoYPosition(Tcl_Interp *interp,
TkMenu *menuPtr, Tcl_Obj *objPtr);
static int MenuDoXPosition(Tcl_Interp *interp,
@@ -357,7 +357,7 @@ static int MenuAddOrInsert(Tcl_Interp *interp,
TkMenu *menuPtr, Tcl_Obj *indexPtr, int objc,
Tcl_Obj *const objv[]);
static void MenuCmdDeletedProc(ClientData clientData);
-static TkMenuEntry * MenuNewEntry(TkMenu *menuPtr, int index, int type);
+static TkMenuEntry * MenuNewEntry(TkMenu *menuPtr, TkSizeT index, int type);
static char * MenuVarProc(ClientData clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
@@ -368,7 +368,9 @@ static void MenuWorldChanged(ClientData instanceData);
static int PostProcessEntry(TkMenuEntry *mePtr);
static void RecursivelyDeleteMenu(TkMenu *menuPtr);
static void UnhookCascadeEntry(TkMenuEntry *mePtr);
-static void TkMenuCleanup(ClientData unused);
+static void MenuCleanup(ClientData unused);
+static int GetMenuIndex(Tcl_Interp *interp, TkMenu *menuPtr,
+ Tcl_Obj *objPtr, int lastOK, TkSizeT *indexPtr);
/*
* The structure below is a list of procs that respond to certain window
@@ -407,14 +409,14 @@ Tk_MenuObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
Tk_Window newWin;
- register TkMenu *menuPtr;
+ TkMenu *menuPtr;
TkMenuReferences *menuRefPtr;
int i, index, toplevel;
const char *windowName;
static const char *const typeStringList[] = {"-type", NULL};
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (objc < 2) {
@@ -449,7 +451,7 @@ Tk_MenuObjCmd(
* Tcl_EventuallyFree is called.
*/
- menuPtr = ckalloc(sizeof(TkMenu));
+ menuPtr = (TkMenu *)ckalloc(sizeof(TkMenu));
memset(menuPtr, 0, sizeof(TkMenu));
menuPtr->tkwin = newWin;
menuPtr->display = Tk_Display(newWin);
@@ -457,7 +459,7 @@ Tk_MenuObjCmd(
menuPtr->widgetCmd = Tcl_CreateObjCommand(interp,
Tk_PathName(menuPtr->tkwin), MenuWidgetObjCmd, menuPtr,
MenuCmdDeletedProc);
- menuPtr->active = -1;
+ menuPtr->active = TCL_INDEX_NONE;
menuPtr->cursorPtr = NULL;
menuPtr->masterMenuPtr = menuPtr;
menuPtr->menuType = UNKNOWN_TYPE;
@@ -620,11 +622,11 @@ MenuWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- register TkMenu *menuPtr = clientData;
- register TkMenuEntry *mePtr;
+ TkMenu *menuPtr = (TkMenu *)clientData;
+ TkMenuEntry *mePtr;
int result = TCL_OK;
int option;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (objc < 2) {
@@ -639,21 +641,21 @@ MenuWidgetObjCmd(
switch ((enum options) option) {
case MENU_ACTIVATE: {
- int index;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
if (menuPtr->active == index) {
goto done;
}
- if ((index >= 0) && ((menuPtr->entries[index]->type==SEPARATOR_ENTRY)
+ if ((index != TCL_INDEX_NONE) && ((menuPtr->entries[index]->type==SEPARATOR_ENTRY)
|| (menuPtr->entries[index]->state == ENTRY_DISABLED))) {
- index = -1;
+ index = TCL_INDEX_NONE;
}
result = TkActivateMenuEntry(menuPtr, index);
break;
@@ -723,7 +725,8 @@ MenuWidgetObjCmd(
break;
}
case MENU_DELETE: {
- int first, last;
+ TkSizeT first, last;
+ Tcl_WideInt w;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "first ?last?");
@@ -736,16 +739,17 @@ MenuWidgetObjCmd(
*/
if (isdigit(UCHAR(Tcl_GetString(objv[2])[0]))
- && Tcl_GetIntFromObj(NULL, objv[2], &first) == TCL_OK) {
+ && Tcl_GetWideIntFromObj(NULL, objv[2], &w) == TCL_OK) {
+ first = w;
if (first >= menuPtr->numEntries) {
goto done;
}
- } else if (TkGetMenuIndex(interp,menuPtr,objv[2],0,&first) != TCL_OK){
+ } else if (GetMenuIndex(interp,menuPtr,objv[2],0,&first) != TCL_OK){
goto error;
}
if (objc == 3) {
last = first;
- } else if (TkGetMenuIndex(interp,menuPtr,objv[3],0,&last) != TCL_OK) {
+ } else if (GetMenuIndex(interp,menuPtr,objv[3],0,&last) != TCL_OK) {
goto error;
}
@@ -757,24 +761,24 @@ MenuWidgetObjCmd(
first = 1;
}
- if ((first < 0) || (last < first)) {
+ if ((first == TCL_INDEX_NONE) || (last < first)) {
goto done;
}
DeleteMenuCloneEntries(menuPtr, first, last);
break;
}
case MENU_ENTRYCGET: {
- int index;
+ TkSizeT index;
Tcl_Obj *resultPtr;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "index option");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
goto done;
}
mePtr = menuPtr->entries[index];
@@ -789,17 +793,17 @@ MenuWidgetObjCmd(
break;
}
case MENU_ENTRYCONFIGURE: {
- int index;
+ TkSizeT index;
Tcl_Obj *resultPtr;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index ?-option value ...?");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
goto done;
}
mePtr = menuPtr->entries[index];
@@ -830,19 +834,19 @@ MenuWidgetObjCmd(
break;
}
case MENU_INDEX: {
- int index;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "string");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
}
break;
}
@@ -857,23 +861,24 @@ MenuWidgetObjCmd(
}
break;
case MENU_INVOKE: {
- int index;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
goto done;
}
result = TkInvokeMenu(interp, menuPtr, index);
break;
}
case MENU_POST: {
- int x, y, index = -1;
+ int x, y;
+ TkSizeT index = TCL_INDEX_NONE;
if (objc != 4 && objc != 5) {
Tcl_WrongNumArgs(interp, 2, objv, "x y ?index?");
@@ -884,7 +889,7 @@ MenuWidgetObjCmd(
goto error;
}
if (objc == 5) {
- if (TkGetMenuIndex(interp, menuPtr, objv[4], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[4], 0, &index) != TCL_OK) {
goto error;
}
}
@@ -908,17 +913,17 @@ MenuWidgetObjCmd(
break;
}
case MENU_POSTCASCADE: {
- int index;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if ((index < 0) || (menuPtr->entries[index]->type != CASCADE_ENTRY)) {
+ if ((index == TCL_INDEX_NONE) || (menuPtr->entries[index]->type != CASCADE_ENTRY)) {
result = TkPostSubmenu(interp, menuPtr, NULL);
} else {
result = TkPostSubmenu(interp, menuPtr, menuPtr->entries[index]);
@@ -926,17 +931,17 @@ MenuWidgetObjCmd(
break;
}
case MENU_TYPE: {
- int index;
+ TkSizeT index;
const char *typeStr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
goto done;
}
if (menuPtr->entries[index]->type == TEAROFF_ENTRY) {
@@ -1001,13 +1006,13 @@ int
TkInvokeMenu(
Tcl_Interp *interp, /* The interp that the menu lives in. */
TkMenu *menuPtr, /* The menu we are invoking. */
- int index) /* The zero based index of the item we are
+ TkSizeT index) /* The zero based index of the item we are
* invoking. */
{
int result = TCL_OK;
TkMenuEntry *mePtr;
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
goto done;
}
mePtr = menuPtr->entries[index];
@@ -1105,7 +1110,7 @@ DestroyMenuInstance(
Tcl_Obj *newObjv[2];
TkMenu *parentMasterMenuPtr;
TkMenuEntry *parentMasterEntryPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -1388,7 +1393,7 @@ static void
DestroyMenuEntry(
void *memPtr) /* Pointer to entry to be freed. */
{
- register TkMenuEntry *mePtr = memPtr;
+ TkMenuEntry *mePtr = (TkMenuEntry *)memPtr;
TkMenu *menuPtr = mePtr->menuPtr;
if (menuPtr->postedCascade == mePtr) {
@@ -1488,8 +1493,8 @@ static void
MenuWorldChanged(
ClientData instanceData) /* Information about widget. */
{
- TkMenu *menuPtr = instanceData;
- int i;
+ TkMenu *menuPtr = (TkMenu *)instanceData;
+ TkSizeT i;
TkMenuConfigureDrawOptions(menuPtr);
for (i = 0; i < menuPtr->numEntries; i++) {
@@ -1522,7 +1527,7 @@ MenuWorldChanged(
static int
ConfigureMenu(
Tcl_Interp *interp, /* Used for error reporting. */
- register TkMenu *menuPtr, /* Information about widget; may or may not
+ TkMenu *menuPtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
@@ -1530,12 +1535,12 @@ ConfigureMenu(
int i;
TkMenu *menuListPtr, *cleanupPtr;
int result;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL;
menuListPtr = menuListPtr->nextInstancePtr) {
- menuListPtr->errorStructPtr = ckalloc(sizeof(Tk_SavedOptions));
+ menuListPtr->errorStructPtr = (Tk_SavedOptions *)ckalloc(sizeof(Tk_SavedOptions));
result = Tk_SetOptions(interp, menuListPtr,
tsdPtr->menuOptionTable, objc, objv,
menuListPtr->tkwin, menuListPtr->errorStructPtr, NULL);
@@ -1630,12 +1635,11 @@ ConfigureMenu(
Tcl_EventuallyFree(menuListPtr->entries[0], (Tcl_FreeProc *) DestroyMenuEntry);
- for (i = 0; i < menuListPtr->numEntries - 1; i++) {
+ for (i = 0; i < (int)menuListPtr->numEntries - 1; i++) {
menuListPtr->entries[i] = menuListPtr->entries[i + 1];
menuListPtr->entries[i]->index = i;
}
- menuListPtr->numEntries--;
- if (menuListPtr->numEntries == 0) {
+ if (--menuListPtr->numEntries == 0) {
ckfree(menuListPtr->entries);
menuListPtr->entries = NULL;
}
@@ -1650,7 +1654,7 @@ ConfigureMenu(
* parent.
*/
- for (i = 0; i < menuListPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuListPtr->numEntries; i++) {
TkMenuEntry *mePtr;
mePtr = menuListPtr->entries[i];
@@ -1740,7 +1744,7 @@ PostProcessEntry(
name = Tcl_GetString(mePtr->namePtr);
if (mePtr->childMenuRefPtr != NULL) {
- oldHashKey = Tcl_GetHashKey(TkGetMenuHashTable(menuPtr->interp),
+ oldHashKey = (char *)Tcl_GetHashKey(TkGetMenuHashTable(menuPtr->interp),
mePtr->childMenuRefPtr->hashEntryPtr);
if (strcmp(oldHashKey, name) != 0) {
UnhookCascadeEntry(mePtr);
@@ -1906,7 +1910,7 @@ PostProcessEntry(
static int
ConfigureMenuEntry(
- register TkMenuEntry *mePtr,/* Information about menu entry; may or may
+ TkMenuEntry *mePtr,/* Information about menu entry; may or may
* not already have values for some fields. */
int objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
@@ -1970,7 +1974,7 @@ ConfigureMenuEntry(
static int
ConfigureMenuCloneEntries(
- Tcl_Interp *interp, /* Used for error reporting. */
+ Tcl_Interp *dummy, /* Used for error reporting. */
TkMenu *menuPtr, /* Information about whole menu. */
int index, /* Index of mePtr within menuPtr's entries. */
int objc, /* Number of valid entries in argv. */
@@ -1982,6 +1986,7 @@ ConfigureMenuCloneEntries(
TkMenuReferences *oldCascadeMenuRefPtr, *cascadeMenuRefPtr = NULL;
Tcl_Obj *oldCascadePtr = NULL;
const char *newCascadeName;
+ (void)dummy;
/*
* Cascades are kind of tricky here. This is special case #3 in the
@@ -2092,7 +2097,7 @@ ConfigureMenuCloneEntries(
/*
*--------------------------------------------------------------
*
- * TkGetMenuIndex --
+ * GetMenuIndex --
*
* Parse a textual index into a menu and return the numerical index of
* the indicated entry.
@@ -2110,7 +2115,7 @@ ConfigureMenuCloneEntries(
*/
int
-TkGetMenuIndex(
+GetMenuIndex(
Tcl_Interp *interp, /* For error messages. */
TkMenu *menuPtr, /* Menu for which the index is being
* specified. */
@@ -2118,56 +2123,49 @@ TkGetMenuIndex(
* manual entry for valid .*/
int lastOK, /* Non-zero means its OK to return index just
* *after* last entry. */
- int *indexPtr) /* Where to store converted index. */
+ TkSizeT *indexPtr) /* Where to store converted index. */
{
int i;
- const char *string = Tcl_GetString(objPtr);
+ const char *string;
+
+ if (TkGetIntForIndex(objPtr, menuPtr->numEntries - 1, lastOK, indexPtr) == TCL_OK) {
+ if (*indexPtr != TCL_INDEX_NONE) {
+ if (*indexPtr >= menuPtr->numEntries) {
+ *indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1);
+ }
+ return TCL_OK;
+ }
+ }
+
+ string = Tcl_GetString(objPtr);
if ((string[0] == 'a') && (strcmp(string, "active") == 0)) {
*indexPtr = menuPtr->active;
goto success;
}
- if (((string[0] == 'l') && (strcmp(string, "last") == 0))
- || ((string[0] == 'e') && (strcmp(string, "end") == 0))) {
+ if ((string[0] == 'l') && (strcmp(string, "last") == 0)) {
*indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1);
goto success;
}
if ((string[0] == 'n') && (strcmp(string, "none") == 0)) {
- *indexPtr = -1;
+ *indexPtr = TCL_INDEX_NONE;
goto success;
}
if (string[0] == '@') {
- if (GetIndexFromCoords(interp, menuPtr, string, indexPtr)
+ if (GetIndexFromCoords(NULL, menuPtr, string, indexPtr)
== TCL_OK) {
goto success;
}
}
- if (isdigit(UCHAR(string[0]))) {
- if (Tcl_GetInt(interp, string, &i) == TCL_OK) {
- if (i >= menuPtr->numEntries) {
- if (lastOK) {
- i = menuPtr->numEntries;
- } else {
- i = menuPtr->numEntries-1;
- }
- } else if (i < 0) {
- i = -1;
- }
- *indexPtr = i;
- goto success;
- }
- Tcl_ResetResult(interp);
- }
-
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuPtr->numEntries; i++) {
Tcl_Obj *labelPtr = menuPtr->entries[i]->labelPtr;
const char *label = (labelPtr == NULL) ? NULL : Tcl_GetString(labelPtr);
- if ((label != NULL) && (Tcl_StringMatch(label, string))) {
+ if ((label != NULL) && (Tcl_StringCaseMatch(label, string, 0))) {
*indexPtr = i;
goto success;
}
@@ -2204,7 +2202,7 @@ static void
MenuCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TkMenu *menuPtr = clientData;
+ TkMenu *menuPtr = (TkMenu *)clientData;
Tk_Window tkwin = menuPtr->tkwin;
/*
@@ -2246,21 +2244,21 @@ MenuCmdDeletedProc(
static TkMenuEntry *
MenuNewEntry(
TkMenu *menuPtr, /* Menu that will hold the new entry. */
- int index, /* Where in the menu the new entry is to
+ TkSizeT index, /* Where in the menu the new entry is to
* go. */
int type) /* The type of the new entry. */
{
TkMenuEntry *mePtr;
TkMenuEntry **newEntries;
- int i;
- ThreadSpecificData *tsdPtr =
+ TkSizeT i;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
* Create a new array of entries with an empty slot for the new entry.
*/
- newEntries = ckalloc((menuPtr->numEntries+1) * sizeof(TkMenuEntry *));
+ newEntries = (TkMenuEntry **)ckalloc((menuPtr->numEntries+1) * sizeof(TkMenuEntry *));
for (i = 0; i < index; i++) {
newEntries[i] = menuPtr->entries[i];
}
@@ -2273,7 +2271,7 @@ MenuNewEntry(
}
menuPtr->entries = newEntries;
menuPtr->numEntries++;
- mePtr = ckalloc(sizeof(TkMenuEntry));
+ mePtr = (TkMenuEntry *)ckalloc(sizeof(TkMenuEntry));
menuPtr->entries[index] = mePtr;
mePtr->type = type;
mePtr->optionTable = tsdPtr->entryOptionTables[type];
@@ -2349,18 +2347,19 @@ MenuAddOrInsert(
Tcl_Obj *const objv[]) /* Arguments to command: first arg is type of
* entry, others are config options. */
{
- int type, index;
+ int type;
+ TkSizeT index;
TkMenuEntry *mePtr;
TkMenu *menuListPtr;
if (indexPtr != NULL) {
- if (TkGetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) {
return TCL_ERROR;
}
} else {
index = menuPtr->numEntries;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad index \"%s\"", Tcl_GetString(indexPtr)));
Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", NULL);
@@ -2392,7 +2391,7 @@ MenuAddOrInsert(
}
if (ConfigureMenuEntry(mePtr, objc - 1, objv + 1) != TCL_OK) {
TkMenu *errorMenuPtr;
- int i;
+ TkSizeT i;
for (errorMenuPtr = menuPtr->masterMenuPtr;
errorMenuPtr != NULL;
@@ -2403,8 +2402,7 @@ MenuAddOrInsert(
errorMenuPtr->entries[i] = errorMenuPtr->entries[i + 1];
errorMenuPtr->entries[i]->index = i;
}
- errorMenuPtr->numEntries--;
- if (errorMenuPtr->numEntries == 0) {
+ if (--errorMenuPtr->numEntries == 0) {
ckfree(errorMenuPtr->entries);
errorMenuPtr->entries = NULL;
}
@@ -2489,14 +2487,17 @@ MenuVarProc(
const char *name2, /* Second part of variable's name. */
int flags) /* Describes what just happened. */
{
- TkMenuEntry *mePtr = clientData;
+ TkMenuEntry *mePtr = (TkMenuEntry *)clientData;
TkMenu *menuPtr;
const char *value;
const char *name, *onValue;
+ (void)name1;
+ (void)name2;
- if (flags & TCL_INTERP_DESTROYED) {
+ if (Tcl_InterpDeleted(interp) || (mePtr->namePtr == NULL)) {
/*
- * Do nothing if the interpreter is going away.
+ * Do nothing if the interpreter is going away or we have
+ * no variable name.
*/
return NULL;
@@ -2508,17 +2509,6 @@ MenuVarProc(
return NULL;
}
- /*
- * See ticket [5d991b82].
- */
-
- if (mePtr->namePtr == NULL) {
- Tcl_UntraceVar2(interp, name1, name2,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuVarProc, clientData);
- return NULL;
- }
-
name = Tcl_GetString(mePtr->namePtr);
/*
@@ -2526,12 +2516,29 @@ MenuVarProc(
*/
if (flags & TCL_TRACE_UNSETS) {
+ ClientData probe = NULL;
mePtr->entryFlags &= ~ENTRY_SELECTED;
- if (flags & TCL_TRACE_DESTROYED) {
- Tcl_TraceVar2(interp, name, NULL,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuVarProc, clientData);
- }
+
+ do {
+ probe = Tcl_VarTraceInfo(interp, name,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ MenuVarProc, probe);
+ if (probe == (ClientData)mePtr) {
+ break;
+ }
+ } while (probe);
+ if (probe) {
+ /*
+ * We were able to fetch the unset trace for our
+ * namePtr, which means it is not unset and not
+ * the cause of this unset trace. Instead some outdated
+ * former variable must be, and we should ignore it.
+ */
+ return NULL;
+ }
+ Tcl_TraceVar2(interp, name, NULL,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ MenuVarProc, clientData);
TkpConfigureMenuEntry(mePtr);
TkEventuallyRedrawMenu(menuPtr, NULL);
return NULL;
@@ -2587,14 +2594,14 @@ MenuVarProc(
int
TkActivateMenuEntry(
- register TkMenu *menuPtr, /* Menu in which to activate. */
- int index) /* Index of entry to activate, or -1 to
- * deactivate all entries. */
+ TkMenu *menuPtr, /* Menu in which to activate. */
+ TkSizeT index) /* Index of entry to activate, or
+ * TCL_INDEX_NONE to deactivate all entries. */
{
- register TkMenuEntry *mePtr;
+ TkMenuEntry *mePtr;
int result = TCL_OK;
- if (menuPtr->active >= 0) {
+ if (menuPtr->active != TCL_INDEX_NONE) {
mePtr = menuPtr->entries[menuPtr->active];
/*
@@ -2608,7 +2615,7 @@ TkActivateMenuEntry(
TkEventuallyRedrawMenu(menuPtr, menuPtr->entries[menuPtr->active]);
}
menuPtr->active = index;
- if (index >= 0) {
+ if (index != TCL_INDEX_NONE) {
mePtr = menuPtr->entries[index];
mePtr->state = ENTRY_ACTIVE;
TkEventuallyRedrawMenu(menuPtr, mePtr);
@@ -2799,7 +2806,7 @@ CloneMenu(
* Clone all of the cascade menus that this menu points to.
*/
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuPtr->numEntries; i++) {
TkMenuReferences *cascadeRefPtr;
TkMenu *oldCascadePtr;
@@ -2863,17 +2870,17 @@ MenuDoXPosition(
TkMenu *menuPtr,
Tcl_Obj *objPtr)
{
- int index;
+ TkSizeT index;
TkRecomputeMenu(menuPtr);
- if (TkGetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) {
return TCL_ERROR;
}
Tcl_ResetResult(interp);
- if (index < 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
+ if (index == TCL_INDEX_NONE) {
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(menuPtr->entries[index]->x));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(menuPtr->entries[index]->x));
}
return TCL_OK;
}
@@ -2900,17 +2907,17 @@ MenuDoYPosition(
TkMenu *menuPtr,
Tcl_Obj *objPtr)
{
- int index;
+ TkSizeT index;
TkRecomputeMenu(menuPtr);
- if (TkGetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) {
goto error;
}
Tcl_ResetResult(interp);
- if (index < 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
+ if (index == TCL_INDEX_NONE) {
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(menuPtr->entries[index]->y));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(menuPtr->entries[index]->y));
}
return TCL_OK;
@@ -2938,12 +2945,12 @@ MenuDoYPosition(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
GetIndexFromCoords(
Tcl_Interp *interp, /* Interpreter of menu. */
TkMenu *menuPtr, /* The menu we are searching. */
const char *string, /* The @string we are parsing. */
- int *indexPtr) /* The index of the item that matches. */
+ TkSizeT *indexPtr) /* The index of the item that matches. */
{
int x, y, i;
const char *p;
@@ -2978,7 +2985,7 @@ GetIndexFromCoords(
? Tk_Width(menuPtr->tkwin) : Tk_ReqWidth(menuPtr->tkwin);
max -= borderwidth;
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuPtr->numEntries; i++) {
if (menuPtr->entries[i]->entryFlags & ENTRY_LAST_COLUMN) {
x2 = max;
} else {
@@ -3021,7 +3028,7 @@ static void
RecursivelyDeleteMenu(
TkMenu *menuPtr) /* The menubar instance we are deleting. */
{
- int i;
+ TkSizeT i;
TkMenuEntry *mePtr;
/*
@@ -3108,7 +3115,7 @@ TkNewMenuName(
Tcl_AppendToObj(resultPtr, ".", -1);
}
Tcl_AppendObjToObj(resultPtr, childPtr);
- intPtr = Tcl_NewIntObj(i);
+ intPtr = Tcl_NewWideIntObj(i);
Tcl_AppendObjToObj(resultPtr, intPtr);
Tcl_DecrRefCount(intPtr);
}
@@ -3277,7 +3284,7 @@ TkSetWindowMenuBar(
* menu.
*/
- topLevelListPtr = ckalloc(sizeof(TkMenuTopLevelList));
+ topLevelListPtr = (TkMenuTopLevelList *)ckalloc(sizeof(TkMenuTopLevelList));
topLevelListPtr->tkwin = tkwin;
topLevelListPtr->nextPtr = menuRefPtr->topLevelListPtr;
menuRefPtr->topLevelListPtr = topLevelListPtr;
@@ -3307,9 +3314,11 @@ TkSetWindowMenuBar(
static void
DestroyMenuHashTable(
ClientData clientData, /* The menu hash table we are destroying. */
- Tcl_Interp *interp) /* The interpreter we are destroying. */
+ Tcl_Interp *dummy) /* The interpreter we are destroying. */
{
- Tcl_DeleteHashTable(clientData);
+ (void)dummy;
+
+ Tcl_DeleteHashTable((Tcl_HashTable *)clientData);
ckfree(clientData);
}
@@ -3335,11 +3344,11 @@ Tcl_HashTable *
TkGetMenuHashTable(
Tcl_Interp *interp) /* The interp we need the hash table in.*/
{
- Tcl_HashTable *menuTablePtr =
+ Tcl_HashTable *menuTablePtr = (Tcl_HashTable *)
Tcl_GetAssocData(interp, MENU_HASH_KEY, NULL);
if (menuTablePtr == NULL) {
- menuTablePtr = ckalloc(sizeof(Tcl_HashTable));
+ menuTablePtr = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(menuTablePtr, TCL_STRING_KEYS);
Tcl_SetAssocData(interp, MENU_HASH_KEY, DestroyMenuHashTable,
menuTablePtr);
@@ -3380,14 +3389,14 @@ TkCreateMenuReferences(
hashEntryPtr = Tcl_CreateHashEntry(menuTablePtr, pathName, &newEntry);
if (newEntry) {
- menuRefPtr = ckalloc(sizeof(TkMenuReferences));
+ menuRefPtr = (TkMenuReferences *)ckalloc(sizeof(TkMenuReferences));
menuRefPtr->menuPtr = NULL;
menuRefPtr->topLevelListPtr = NULL;
menuRefPtr->parentEntryPtr = NULL;
menuRefPtr->hashEntryPtr = hashEntryPtr;
Tcl_SetHashValue(hashEntryPtr, menuRefPtr);
} else {
- menuRefPtr = Tcl_GetHashValue(hashEntryPtr);
+ menuRefPtr = (TkMenuReferences *)Tcl_GetHashValue(hashEntryPtr);
}
return menuRefPtr;
}
@@ -3424,7 +3433,7 @@ TkFindMenuReferences(
menuTablePtr = TkGetMenuHashTable(interp);
hashEntryPtr = Tcl_FindHashEntry(menuTablePtr, pathName);
if (hashEntryPtr != NULL) {
- menuRefPtr = Tcl_GetHashValue(hashEntryPtr);
+ menuRefPtr = (TkMenuReferences *)Tcl_GetHashValue(hashEntryPtr);
}
return menuRefPtr;
}
@@ -3525,7 +3534,7 @@ DeleteMenuCloneEntries(
for (i = last; i >= first; i--) {
Tcl_EventuallyFree(menuListPtr->entries[i], (Tcl_FreeProc *) DestroyMenuEntry);
}
- for (i = last + 1; i < menuListPtr->numEntries; i++) {
+ for (i = last + 1; i < (int)menuListPtr->numEntries; i++) {
j = i - numDeleted;
menuListPtr->entries[j] = menuListPtr->entries[i];
menuListPtr->entries[j]->index = j;
@@ -3535,10 +3544,10 @@ DeleteMenuCloneEntries(
ckfree(menuListPtr->entries);
menuListPtr->entries = NULL;
}
- if ((menuListPtr->active >= first)
- && (menuListPtr->active <= last)) {
+ if (((int)menuListPtr->active >= first)
+ && ((int)menuListPtr->active <= last)) {
menuListPtr->active = -1;
- } else if (menuListPtr->active > last) {
+ } else if ((int)menuListPtr->active > last) {
menuListPtr->active -= numDeleted;
}
TkEventuallyRecomputeMenu(menuListPtr);
@@ -3548,7 +3557,7 @@ DeleteMenuCloneEntries(
/*
*----------------------------------------------------------------------
*
- * TkMenuCleanup --
+ * MenuCleanup --
*
* Resets menusInitialized to allow Tk to be finalized and reused without
* the DLL being unloaded.
@@ -3563,9 +3572,11 @@ DeleteMenuCloneEntries(
*/
static void
-TkMenuCleanup(
- ClientData unused)
+MenuCleanup(
+ ClientData dummy)
{
+ (void)dummy;
+
menusInitialized = 0;
}
@@ -3589,7 +3600,7 @@ TkMenuCleanup(
void
TkMenuInit(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!menusInitialized) {
@@ -3603,7 +3614,7 @@ TkMenuInit(void)
* Make sure we cleanup on finalize.
*/
- TkCreateExitHandler((Tcl_ExitProc *) TkMenuCleanup, NULL);
+ TkCreateExitHandler((Tcl_ExitProc *) MenuCleanup, NULL);
Tcl_MutexUnlock(&menuMutex);
}
if (!tsdPtr->menusInitialized) {
diff --git a/generic/tkMenu.h b/generic/tkMenu.h
index 8e25059..ecb6fac 100644
--- a/generic/tkMenu.h
+++ b/generic/tkMenu.h
@@ -13,10 +13,6 @@
#ifndef _TKMENU
#define _TKMENU
-#ifndef _TK
-#include "tk.h"
-#endif
-
#ifndef _TKINT
#include "tkInt.h"
#endif
@@ -120,7 +116,7 @@ typedef struct TkMenuEntry {
* always 0 for tearoff and separator
* entries. */
int hideMargin; /* If this is 0, then the item has enough
- * margin to accomodate a standard check mark
+ * margin to accommodate a standard check mark
* and a default right margin. If this is 1,
* then the item has no such margins, and
* checkbuttons and radiobuttons with this set
@@ -267,9 +263,9 @@ typedef struct TkMenu {
Tcl_Command widgetCmd; /* Token for menu's widget command. */
TkMenuEntry **entries; /* Array of pointers to all the entries in the
* menu. NULL means no entries. */
- int numEntries; /* Number of elements in entries. */
- int active; /* Index of active entry. -1 means nothing
- * active. */
+ TkSizeT numEntries; /* Number of elements in entries. */
+ TkSizeT active; /* Index of active entry. TCL_INDEX_NONE means
+ * nothing active. */
int menuType; /* MASTER_MENU, TEAROFF_MENU, or MENUBAR. See
* below for definitions. */
Tcl_Obj *menuTypePtr; /* Used to control whether created tkwin is a
@@ -482,7 +478,7 @@ typedef struct TkMenuReferences {
* the outside world:
*/
-MODULE_SCOPE int TkActivateMenuEntry(TkMenu *menuPtr, int index);
+MODULE_SCOPE int TkActivateMenuEntry(TkMenu *menuPtr, TkSizeT index);
MODULE_SCOPE void TkBindMenu(Tk_Window tkwin, TkMenu *menuPtr);
MODULE_SCOPE TkMenuReferences*TkCreateMenuReferences(Tcl_Interp *interp,
const char *name);
@@ -495,15 +491,13 @@ MODULE_SCOPE TkMenuReferences*TkFindMenuReferencesObj(Tcl_Interp *interp,
Tcl_Obj *namePtr);
MODULE_SCOPE int TkFreeMenuReferences(TkMenuReferences *menuRefPtr);
MODULE_SCOPE Tcl_HashTable *TkGetMenuHashTable(Tcl_Interp *interp);
-MODULE_SCOPE int TkGetMenuIndex(Tcl_Interp *interp, TkMenu *menuPtr,
- Tcl_Obj *objPtr, int lastOK, int *indexPtr);
MODULE_SCOPE void TkMenuInitializeDrawingFields(TkMenu *menuPtr);
MODULE_SCOPE void TkMenuInitializeEntryDrawingFields(TkMenuEntry *mePtr);
MODULE_SCOPE int TkInvokeMenu(Tcl_Interp *interp, TkMenu *menuPtr,
- int index);
+ TkSizeT index);
MODULE_SCOPE void TkMenuConfigureDrawOptions(TkMenu *menuPtr);
MODULE_SCOPE int TkMenuConfigureEntryDrawOptions(
- TkMenuEntry *mePtr, int index);
+ TkMenuEntry *mePtr, TkSizeT index);
MODULE_SCOPE void TkMenuFreeDrawOptions(TkMenu *menuPtr);
MODULE_SCOPE void TkMenuEntryFreeDrawOptions(TkMenuEntry *mePtr);
MODULE_SCOPE void TkMenuEventProc(ClientData clientData,
diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c
index bd00d38..2512f7c 100644
--- a/generic/tkMenuDraw.c
+++ b/generic/tkMenuDraw.c
@@ -298,7 +298,7 @@ TkMenuConfigureDrawOptions(
int
TkMenuConfigureEntryDrawOptions(
TkMenuEntry *mePtr,
- int index)
+ TkSizeT index)
{
XGCValues gcValues;
GC newGC, newActiveGC, newDisabledGC, newIndicatorGC;
@@ -475,7 +475,7 @@ TkRecomputeMenu(
* None.
*
* Side effects:
- * A when-idle hander is scheduled to do the redisplay, if there isn't
+ * A when-idle handler is scheduled to do the redisplay, if there isn't
* one already scheduled.
*
*----------------------------------------------------------------------
@@ -483,11 +483,11 @@ TkRecomputeMenu(
void
TkEventuallyRedrawMenu(
- register TkMenu *menuPtr, /* Information about menu to redraw. */
- register TkMenuEntry *mePtr)/* Entry to redraw. NULL means redraw all the
+ TkMenu *menuPtr, /* Information about menu to redraw. */
+ TkMenuEntry *mePtr)/* Entry to redraw. NULL means redraw all the
* entries in the menu. */
{
- int i;
+ TkSizeT i;
if (menuPtr->tkwin == NULL) {
return;
@@ -530,7 +530,7 @@ static void
ComputeMenuGeometry(
ClientData clientData) /* Structure describing menu. */
{
- TkMenu *menuPtr = clientData;
+ TkMenu *menuPtr = (TkMenu *)clientData;
if (menuPtr->tkwin == NULL) {
return;
@@ -586,7 +586,13 @@ TkMenuSelectImageProc(
* <=0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- register TkMenuEntry *mePtr = clientData;
+ TkMenuEntry *mePtr = (TkMenuEntry *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
if ((mePtr->entryFlags & ENTRY_SELECTED)
&& !(mePtr->menuPtr->menuFlags & REDRAW_PENDING)) {
@@ -615,10 +621,11 @@ static void
DisplayMenu(
ClientData clientData) /* Information about widget. */
{
- register TkMenu *menuPtr = clientData;
- register TkMenuEntry *mePtr;
- register Tk_Window tkwin = menuPtr->tkwin;
- int index, strictMotif;
+ TkMenu *menuPtr = (TkMenu *)clientData;
+ TkMenuEntry *mePtr;
+ Tk_Window tkwin = menuPtr->tkwin;
+ TkSizeT index;
+ int strictMotif;
Tk_Font tkfont;
Tk_FontMetrics menuMetrics;
int width;
@@ -668,8 +675,27 @@ DisplayMenu(
TkpDrawMenuEntry(mePtr, Tk_WindowId(menuPtr->tkwin), tkfont,
&menuMetrics, mePtr->x, mePtr->y, mePtr->width,
mePtr->height, strictMotif, 1);
+
+ if (mePtr->entryFlags & ENTRY_LAST_COLUMN) {
+
+ /*
+ * Paint the area at the right of an entry in the last column.
+ * This has zero width except after menu resizing.
+ */
+
+ Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border,
+ mePtr->x + mePtr->width, mePtr->y,
+ Tk_Width(tkwin) - mePtr->x - mePtr->width - borderWidth,
+ mePtr->height, 0, TK_RELIEF_FLAT);
+ }
+
if ((index > 0) && (menuPtr->menuType != MENUBAR)
&& mePtr->columnBreak) {
+
+ /*
+ * Paint the area under the last entry in a column.
+ */
+
mePtr = menuPtr->entries[index - 1];
Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border,
mePtr->x, mePtr->y + mePtr->height, mePtr->width,
@@ -687,6 +713,11 @@ DisplayMenu(
height = Tk_Height(tkwin) - 2 * borderWidth;
} else {
mePtr = menuPtr->entries[menuPtr->numEntries - 1];
+
+ /*
+ * Paint the area under the last entry of the menu.
+ */
+
Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin),
border, mePtr->x, mePtr->y + mePtr->height, mePtr->width,
Tk_Height(tkwin) - mePtr->y - mePtr->height - borderWidth,
@@ -696,6 +727,12 @@ DisplayMenu(
width = Tk_Width(tkwin) - x - borderWidth;
height = Tk_Height(tkwin) - y - borderWidth;
}
+
+ /*
+ * Paint the area at the bottom right of the last entry.
+ * This has zero width except after menu resizing.
+ */
+
Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, x, y,
width, height, 0, TK_RELIEF_FLAT);
}
@@ -729,7 +766,7 @@ TkMenuEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkMenu *menuPtr = clientData;
+ TkMenu *menuPtr = (TkMenu *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
TkEventuallyRedrawMenu(menuPtr, NULL);
@@ -794,7 +831,13 @@ TkMenuImageProc(
* <=0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- register TkMenu *menuPtr = ((TkMenuEntry *) clientData)->menuPtr;
+ TkMenu *menuPtr = (TkMenu *)((TkMenuEntry *) clientData)->menuPtr;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
if ((menuPtr->tkwin != NULL) && !(menuPtr->menuFlags & RESIZE_PENDING)) {
menuPtr->menuFlags |= RESIZE_PENDING;
@@ -852,8 +895,8 @@ int
TkPostSubmenu(
Tcl_Interp *interp, /* Used for invoking sub-commands and
* reporting errors. */
- register TkMenu *menuPtr, /* Information about menu as a whole. */
- register TkMenuEntry *mePtr)/* Info about submenu that is to be posted.
+ TkMenu *menuPtr, /* Information about menu as a whole. */
+ TkMenuEntry *mePtr)/* Info about submenu that is to be posted.
* NULL means make sure that no submenu is
* posted. */
{
@@ -911,8 +954,8 @@ TkPostSubmenu(
menuPtr->postedCascade = mePtr;
subary[0] = mePtr->namePtr;
subary[1] = Tcl_NewStringObj("post", -1);
- subary[2] = Tcl_NewIntObj(x);
- subary[3] = Tcl_NewIntObj(y);
+ subary[2] = Tcl_NewWideIntObj(x);
+ subary[3] = Tcl_NewWideIntObj(y);
Tcl_IncrRefCount(subary[1]);
Tcl_IncrRefCount(subary[2]);
Tcl_IncrRefCount(subary[3]);
diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c
index fa5b63f..4b7a492 100644
--- a/generic/tkMenubutton.c
+++ b/generic/tkMenubutton.c
@@ -60,99 +60,99 @@ static const char *const compoundStrings[] = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_MENUBUTTON_ACTIVE_BG_COLOR, -1,
- Tk_Offset(TkMenuButton, activeBorder), 0,
+ DEF_MENUBUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, activeBorder), 0,
(ClientData) DEF_MENUBUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_MENUBUTTON_ACTIVE_FG_COLOR, -1,
- Tk_Offset(TkMenuButton, activeFg),
+ DEF_MENUBUTTON_ACTIVE_FG_COLOR, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, activeFg),
0, DEF_MENUBUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_MENUBUTTON_ANCHOR, -1,
- Tk_Offset(TkMenuButton, anchor), 0, 0, 0},
+ DEF_MENUBUTTON_ANCHOR, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, anchor), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_MENUBUTTON_BG_COLOR, -1, Tk_Offset(TkMenuButton, normalBorder),
+ DEF_MENUBUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkMenuButton, normalBorder),
0, DEF_MENUBUTTON_BG_MONO, 0},
- {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, -1, 0,
+ {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
(ClientData) "-borderwidth", 0},
- {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, -1, 0,
+ {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
(ClientData) "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_MENUBUTTON_BITMAP, -1, Tk_Offset(TkMenuButton, bitmap),
+ DEF_MENUBUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkMenuButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_MENUBUTTON_BORDER_WIDTH, -1,
- Tk_Offset(TkMenuButton, borderWidth), 0, 0, 0},
+ DEF_MENUBUTTON_BORDER_WIDTH, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, borderWidth), 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_MENUBUTTON_CURSOR, -1, Tk_Offset(TkMenuButton, cursor),
+ DEF_MENUBUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkMenuButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction",
- DEF_MENUBUTTON_DIRECTION, -1, Tk_Offset(TkMenuButton, direction),
+ DEF_MENUBUTTON_DIRECTION, TCL_INDEX_NONE, offsetof(TkMenuButton, direction),
0, directionStrings, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_MENUBUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkMenuButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkMenuButton, disabledFg), TK_OPTION_NULL_OK,
(ClientData) DEF_MENUBUTTON_DISABLED_FG_MONO, 0},
- {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, -1, 0,
+ {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0,
(ClientData) "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_MENUBUTTON_FONT, -1, Tk_Offset(TkMenuButton, tkfont), 0, 0, 0},
+ DEF_MENUBUTTON_FONT, TCL_INDEX_NONE, offsetof(TkMenuButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MENUBUTTON_FG, -1, Tk_Offset(TkMenuButton, normalFg), 0, 0, 0},
+ DEF_MENUBUTTON_FG, TCL_INDEX_NONE, offsetof(TkMenuButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_MENUBUTTON_HEIGHT, -1, Tk_Offset(TkMenuButton, heightString),
+ DEF_MENUBUTTON_HEIGHT, TCL_INDEX_NONE, offsetof(TkMenuButton, heightString),
0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkMenuButton, highlightBgColorPtr), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuButton, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_MENUBUTTON_HIGHLIGHT, -1,
- Tk_Offset(TkMenuButton, highlightColorPtr), 0, 0, 0},
+ DEF_MENUBUTTON_HIGHLIGHT, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, highlightColorPtr), 0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", DEF_MENUBUTTON_HIGHLIGHT_WIDTH,
- -1, Tk_Offset(TkMenuButton, highlightWidth), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_MENUBUTTON_IMAGE, -1, Tk_Offset(TkMenuButton, imageString),
+ DEF_MENUBUTTON_IMAGE, TCL_INDEX_NONE, offsetof(TkMenuButton, imageString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
- DEF_MENUBUTTON_INDICATOR, -1, Tk_Offset(TkMenuButton, indicatorOn),
+ DEF_MENUBUTTON_INDICATOR, TCL_INDEX_NONE, offsetof(TkMenuButton, indicatorOn),
0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_MENUBUTTON_JUSTIFY, -1, Tk_Offset(TkMenuButton, justify), 0, 0, 0},
+ DEF_MENUBUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkMenuButton, justify), 0, 0, 0},
{TK_OPTION_STRING, "-menu", "menu", "Menu",
- DEF_MENUBUTTON_MENU, -1, Tk_Offset(TkMenuButton, menuName),
+ DEF_MENUBUTTON_MENU, TCL_INDEX_NONE, offsetof(TkMenuButton, menuName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_MENUBUTTON_PADX, -1, Tk_Offset(TkMenuButton, padX),
+ DEF_MENUBUTTON_PADX, TCL_INDEX_NONE, offsetof(TkMenuButton, padX),
0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_MENUBUTTON_PADY, -1, Tk_Offset(TkMenuButton, padY),
+ DEF_MENUBUTTON_PADY, TCL_INDEX_NONE, offsetof(TkMenuButton, padY),
0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_MENUBUTTON_RELIEF, -1, Tk_Offset(TkMenuButton, relief),
+ DEF_MENUBUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkMenuButton, relief),
0, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkMenuButton, compound), 0,
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkMenuButton, compound), 0,
compoundStrings, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_MENUBUTTON_STATE, -1, Tk_Offset(TkMenuButton, state),
+ DEF_MENUBUTTON_STATE, TCL_INDEX_NONE, offsetof(TkMenuButton, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_MENUBUTTON_TAKE_FOCUS, -1,
- Tk_Offset(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0},
+ DEF_MENUBUTTON_TAKE_FOCUS, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_MENUBUTTON_TEXT, -1, Tk_Offset(TkMenuButton, text), 0, 0, 0},
+ DEF_MENUBUTTON_TEXT, TCL_INDEX_NONE, offsetof(TkMenuButton, text), 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_MENUBUTTON_TEXT_VARIABLE, -1,
- Tk_Offset(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0},
+ DEF_MENUBUTTON_TEXT_VARIABLE, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_MENUBUTTON_UNDERLINE, -1, Tk_Offset(TkMenuButton, underline),
+ DEF_MENUBUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkMenuButton, underline),
0, 0, 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_MENUBUTTON_WIDTH, -1, Tk_Offset(TkMenuButton, widthString),
+ DEF_MENUBUTTON_WIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, widthString),
0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_MENUBUTTON_WRAP_LENGTH, -1, Tk_Offset(TkMenuButton, wrapLength),
+ DEF_MENUBUTTON_WRAP_LENGTH, TCL_INDEX_NONE, offsetof(TkMenuButton, wrapLength),
0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
@@ -212,14 +212,15 @@ static void DestroyMenuButton(char *memPtr);
int
Tk_MenubuttonObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register TkMenuButton *mbPtr;
+ TkMenuButton *mbPtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -347,7 +348,7 @@ MenuButtonWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
int result, index;
Tcl_Obj *objPtr;
@@ -422,7 +423,7 @@ static void
DestroyMenuButton(
char *memPtr) /* Info about button widget. */
{
- register TkMenuButton *mbPtr = (TkMenuButton *) memPtr;
+ TkMenuButton *mbPtr = (TkMenuButton *) memPtr;
TkpDestroyMenuButton(mbPtr);
if (mbPtr->flags & REDRAW_PENDING) {
@@ -490,7 +491,7 @@ DestroyMenuButton(
static int
ConfigureMenuButton(
Tcl_Interp *interp, /* Used for error reporting. */
- register TkMenuButton *mbPtr,
+ TkMenuButton *mbPtr,
/* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in objv. */
@@ -633,7 +634,7 @@ ConfigureMenuButton(
if (mbPtr->text != NULL) {
ckfree(mbPtr->text);
}
- mbPtr->text = ckalloc(strlen(value) + 1);
+ mbPtr->text = (char *)ckalloc(strlen(value) + 1);
strcpy(mbPtr->text, value);
}
Tcl_TraceVar2(interp, mbPtr->textVarName, NULL,
@@ -675,7 +676,7 @@ TkMenuButtonWorldChanged(
XGCValues gcValues;
GC gc;
unsigned long mask;
- TkMenuButton *mbPtr = instanceData;
+ TkMenuButton *mbPtr = (TkMenuButton *)instanceData;
gcValues.font = Tk_FontId(mbPtr->tkfont);
gcValues.foreground = mbPtr->normalFg->pixel;
@@ -776,7 +777,7 @@ MenuButtonEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
goto redraw;
@@ -835,7 +836,7 @@ static void
MenuButtonCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
Tk_Window tkwin = mbPtr->tkwin;
/*
@@ -868,7 +869,6 @@ MenuButtonCmdDeletedProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
MenuButtonTextVarProc(
ClientData clientData, /* Information about button. */
@@ -877,22 +877,11 @@ MenuButtonTextVarProc(
const char *name2, /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- register TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
const char *value;
- unsigned len;
-
- /*
- * See ticket [5d991b82].
- */
-
- if (mbPtr->textVarName == NULL) {
- if (!(flags & TCL_INTERP_DESTROYED)) {
- Tcl_UntraceVar2(interp, name1, name2,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuButtonTextVarProc, clientData);
- }
- return NULL;
- }
+ size_t len;
+ (void)name1;
+ (void)name2;
/*
* If the variable is unset, then immediately recreate it unless the whole
@@ -900,7 +889,27 @@ MenuButtonTextVarProc(
*/
if (flags & TCL_TRACE_UNSETS) {
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
+ if (!Tcl_InterpDeleted(interp) && mbPtr->textVarName) {
+ ClientData probe = NULL;
+
+ do {
+ probe = Tcl_VarTraceInfo(interp,
+ mbPtr->textVarName,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ MenuButtonTextVarProc, probe);
+ if (probe == (ClientData)mbPtr) {
+ break;
+ }
+ } while (probe);
+ if (probe) {
+ /*
+ * We were able to fetch the unset trace for our
+ * textVarName, which means it is not unset and not
+ * the cause of this unset trace. Instead some outdated
+ * former variable must be, and we should ignore it.
+ */
+ return NULL;
+ }
Tcl_SetVar2(interp, mbPtr->textVarName, NULL, mbPtr->text,
TCL_GLOBAL_ONLY);
Tcl_TraceVar2(interp, mbPtr->textVarName, NULL,
@@ -917,8 +926,8 @@ MenuButtonTextVarProc(
if (mbPtr->text != NULL) {
ckfree(mbPtr->text);
}
- len = 1 + (unsigned) strlen(value);
- mbPtr->text = ckalloc(len);
+ len = 1 + strlen(value);
+ mbPtr->text = (char *)ckalloc(len);
memcpy(mbPtr->text, value, len);
TkpComputeMenuButtonGeometry(mbPtr);
@@ -957,7 +966,13 @@ MenuButtonImageProc(
* 0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- register TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
if (mbPtr->tkwin != NULL) {
TkpComputeMenuButtonGeometry(mbPtr);
diff --git a/generic/tkMessage.c b/generic/tkMessage.c
index 306572e..f7d1a33 100644
--- a/generic/tkMessage.c
+++ b/generic/tkMessage.c
@@ -109,57 +109,57 @@ typedef struct {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_MESSAGE_ANCHOR,
- -1, Tk_Offset(Message, anchor), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Message, anchor), 0, 0, 0},
{TK_OPTION_INT, "-aspect", "aspect", "Aspect", DEF_MESSAGE_ASPECT,
- -1, Tk_Offset(Message, aspect), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Message, aspect), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_MESSAGE_BG_COLOR, -1, Tk_Offset(Message, border), 0,
+ DEF_MESSAGE_BG_COLOR, TCL_INDEX_NONE, offsetof(Message, border), 0,
DEF_MESSAGE_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL,
- 0, -1, 0, "-borderwidth", 0},
+ 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL,
- 0, -1, 0, "-background", 0},
+ 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_MESSAGE_BORDER_WIDTH, -1,
- Tk_Offset(Message, borderWidth), 0, 0, 0},
+ DEF_MESSAGE_BORDER_WIDTH, TCL_INDEX_NONE,
+ offsetof(Message, borderWidth), 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_MESSAGE_CURSOR, -1, Tk_Offset(Message, cursor),
+ DEF_MESSAGE_CURSOR, TCL_INDEX_NONE, offsetof(Message, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL,
- 0, -1, 0, "-foreground", 0},
+ 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_MESSAGE_FONT, -1, Tk_Offset(Message, tkfont), 0, 0, 0},
+ DEF_MESSAGE_FONT, TCL_INDEX_NONE, offsetof(Message, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MESSAGE_FG, -1, Tk_Offset(Message, fgColorPtr), 0, 0, 0},
+ DEF_MESSAGE_FG, TCL_INDEX_NONE, offsetof(Message, fgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_MESSAGE_HIGHLIGHT_BG, -1,
- Tk_Offset(Message, highlightBgColorPtr), 0, 0, 0},
+ "HighlightBackground", DEF_MESSAGE_HIGHLIGHT_BG, TCL_INDEX_NONE,
+ offsetof(Message, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_MESSAGE_HIGHLIGHT, -1, Tk_Offset(Message, highlightColorPtr),
+ DEF_MESSAGE_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Message, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_MESSAGE_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Message, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_MESSAGE_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Message, highlightWidth), 0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_MESSAGE_JUSTIFY, -1, Tk_Offset(Message, justify), 0, 0, 0},
+ DEF_MESSAGE_JUSTIFY, TCL_INDEX_NONE, offsetof(Message, justify), 0, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_MESSAGE_PADX, Tk_Offset(Message, padXPtr),
- Tk_Offset(Message, padX), 0, 0, 0},
+ DEF_MESSAGE_PADX, offsetof(Message, padXPtr),
+ offsetof(Message, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_MESSAGE_PADY, Tk_Offset(Message, padYPtr),
- Tk_Offset(Message, padY), 0, 0, 0},
+ DEF_MESSAGE_PADY, offsetof(Message, padYPtr),
+ offsetof(Message, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_MESSAGE_RELIEF, -1, Tk_Offset(Message, relief), 0, 0, 0},
+ DEF_MESSAGE_RELIEF, TCL_INDEX_NONE, offsetof(Message, relief), 0, 0, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_MESSAGE_TAKE_FOCUS, -1, Tk_Offset(Message, takeFocus),
+ DEF_MESSAGE_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Message, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_MESSAGE_TEXT, -1, Tk_Offset(Message, string), 0, 0, 0},
+ DEF_MESSAGE_TEXT, TCL_INDEX_NONE, offsetof(Message, string), 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_MESSAGE_TEXT_VARIABLE, -1, Tk_Offset(Message, textVarName),
+ DEF_MESSAGE_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Message, textVarName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_MESSAGE_WIDTH, -1, Tk_Offset(Message, width), 0, 0 ,0},
+ DEF_MESSAGE_WIDTH, TCL_INDEX_NONE, offsetof(Message, width), 0, 0 ,0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -180,7 +180,7 @@ static void MessageWorldChanged(ClientData instanceData);
static void ComputeMessageGeometry(Message *msgPtr);
static int ConfigureMessage(Tcl_Interp *interp, Message *msgPtr,
int objc, Tcl_Obj *const objv[], int flags);
-static void DestroyMessage(char *memPtr);
+static void DestroyMessage(void *memPtr);
static void DisplayMessage(ClientData clientData);
/*
@@ -214,14 +214,15 @@ static const Tk_ClassProcs messageClass = {
int
Tk_MessageObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- register Message *msgPtr;
+ Message *msgPtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -241,7 +242,7 @@ Tk_MessageObjCmd(
optionTable = Tk_CreateOptionTable(interp, optionSpecs);
- msgPtr = ckalloc(sizeof(Message));
+ msgPtr = (Message *)ckalloc(sizeof(Message));
memset(msgPtr, 0, sizeof(Message));
/*
@@ -306,7 +307,7 @@ MessageWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- register Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
static const char *const optionStrings[] = { "cget", "configure", NULL };
enum options { MESSAGE_CGET, MESSAGE_CONFIGURE };
int index;
@@ -382,9 +383,9 @@ MessageWidgetObjCmd(
static void
DestroyMessage(
- char *memPtr) /* Info about message widget. */
+ void *memPtr) /* Info about message widget. */
{
- register Message *msgPtr = (Message *) memPtr;
+ Message *msgPtr = (Message *) memPtr;
msgPtr->flags |= MESSAGE_DELETED;
@@ -437,13 +438,14 @@ DestroyMessage(
static int
ConfigureMessage(
Tcl_Interp *interp, /* Used for error reporting. */
- register Message *msgPtr, /* Information about widget; may or may not
+ Message *msgPtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[], /* Arguments. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
Tk_SavedOptions savedOptions;
+ (void)flags;
/*
* Eliminate any existing trace on a variable monitored by the message.
@@ -478,7 +480,7 @@ ConfigureMessage(
if (msgPtr->string != NULL) {
ckfree(msgPtr->string);
}
- msgPtr->string = strcpy(ckalloc(strlen(value) + 1), value);
+ msgPtr->string = strcpy((char *)ckalloc(strlen(value) + 1), value);
}
Tcl_TraceVar2(interp, msgPtr->textVarName, NULL,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
@@ -527,7 +529,7 @@ MessageWorldChanged(
XGCValues gcValues;
GC gc = NULL;
Tk_FontMetrics fm;
- Message *msgPtr = instanceData;
+ Message *msgPtr = (Message *)instanceData;
if (msgPtr->border != NULL) {
Tk_SetBackgroundFromBorder(msgPtr->tkwin, msgPtr->border);
@@ -582,7 +584,7 @@ MessageWorldChanged(
static void
ComputeMessageGeometry(
- register Message *msgPtr) /* Information about window. */
+ Message *msgPtr) /* Information about window. */
{
int width, inc, height;
int thisWidth, thisHeight, maxWidth;
@@ -666,8 +668,8 @@ static void
DisplayMessage(
ClientData clientData) /* Information about window. */
{
- register Message *msgPtr = clientData;
- register Tk_Window tkwin = msgPtr->tkwin;
+ Message *msgPtr = (Message *)clientData;
+ Tk_Window tkwin = msgPtr->tkwin;
int x, y;
int borderWidth = msgPtr->highlightWidth;
@@ -742,7 +744,7 @@ MessageEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
if (((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0))
|| (eventPtr->type == ConfigureNotify)) {
@@ -795,7 +797,7 @@ static void
MessageCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
/*
* This function could be invoked either because the window was destroyed
@@ -826,7 +828,6 @@ MessageCmdDeletedProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
MessageTextVarProc(
ClientData clientData, /* Information about message. */
@@ -835,21 +836,10 @@ MessageTextVarProc(
const char *name2, /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- register Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
const char *value;
-
- /*
- * See ticket [5d991b82].
- */
-
- if (msgPtr->textVarName == NULL) {
- if (!(flags & TCL_INTERP_DESTROYED)) {
- Tcl_UntraceVar2(interp, name1, name2,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MessageTextVarProc, clientData);
- }
- return NULL;
- }
+ (void)name1;
+ (void)name2;
/*
* If the variable is unset, then immediately recreate it unless the whole
@@ -857,7 +847,27 @@ MessageTextVarProc(
*/
if (flags & TCL_TRACE_UNSETS) {
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
+ if (!Tcl_InterpDeleted(interp) && msgPtr->textVarName) {
+ ClientData probe = NULL;
+
+ do {
+ probe = Tcl_VarTraceInfo(interp,
+ msgPtr->textVarName,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ MessageTextVarProc, probe);
+ if (probe == (ClientData)msgPtr) {
+ break;
+ }
+ } while (probe);
+ if (probe) {
+ /*
+ * We were able to fetch the unset trace for our
+ * textVarName, which means it is not unset and not
+ * the cause of this unset trace. Instead some outdated
+ * former variable must be, and we should ignore it.
+ */
+ return NULL;
+ }
Tcl_SetVar2(interp, msgPtr->textVarName, NULL, msgPtr->string,
TCL_GLOBAL_ONLY);
Tcl_TraceVar2(interp, msgPtr->textVarName, NULL,
@@ -875,7 +885,7 @@ MessageTextVarProc(
ckfree(msgPtr->string);
}
msgPtr->numChars = Tcl_NumUtfChars(value, -1);
- msgPtr->string = ckalloc(strlen(value) + 1);
+ msgPtr->string = (char *)ckalloc(strlen(value) + 1);
strcpy(msgPtr->string, value);
ComputeMessageGeometry(msgPtr);
diff --git a/generic/tkObj.c b/generic/tkObj.c
index b857d98..63c6db7 100644
--- a/generic/tkObj.c
+++ b/generic/tkObj.c
@@ -47,9 +47,10 @@ typedef struct PixelRep {
* thread.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
const Tcl_ObjType *doubleTypePtr;
const Tcl_ObjType *intTypePtr;
+ const Tcl_ObjType *endTypePtr;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -97,10 +98,33 @@ static int SetMMFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static int SetPixelFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static int SetWindowFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
+#if TCL_MAJOR_VERSION < 9
+#if defined(USE_TCL_STUBS)
+/* Little hack to eliminate the need for "tclInt.h" here:
+ Just copy a small portion of TclIntStubs, just
+ enough to make it work */
+typedef struct TclIntStubs {
+ int magic;
+ void *hooks;
+ void (*dummy[34]) (void); /* dummy entries 0-33, not used */
+ int (*tclGetIntForIndex) (Tcl_Interp *interp, Tcl_Obj *objPtr, int endValue, int *indexPtr); /* 34 */
+} TclIntStubs;
+extern const struct TclIntStubs *tclIntStubsPtr;
+
+# undef Tcl_GetIntForIndex
+# define Tcl_GetIntForIndex(interp, obj, max, ptr) ((tclIntStubsPtr->tclGetIntForIndex == NULL)? \
+ ((int (*)(Tcl_Interp*, Tcl_Obj *, int, int*))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[645]))((interp), (obj), (max), (ptr)): \
+ tclIntStubsPtr->tclGetIntForIndex((interp), (obj), (max), (ptr)))
+#elif TCL_MINOR_VERSION < 7
+extern int TclGetIntForIndex(Tcl_Interp*, Tcl_Obj *, int, int*);
+# define Tcl_GetIntForIndex TclGetIntForIndex
+#endif
+#endif
+
/*
* The following structure defines the implementation of the "pixel" Tcl
* object, used for measuring distances. The pixel object remembers its
- * initial display-independant settings.
+ * initial display-independent settings.
*/
static const Tcl_ObjType pixelObjType = {
@@ -114,7 +138,7 @@ static const Tcl_ObjType pixelObjType = {
/*
* The following structure defines the implementation of the "pixel" Tcl
* object, used for measuring distances. The pixel object remembers its
- * initial display-independant settings.
+ * initial display-independent settings.
*/
static const Tcl_ObjType mmObjType = {
@@ -153,19 +177,24 @@ static const Tcl_ObjType windowObjType = {
static ThreadSpecificData *
GetTypeCache(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->doubleTypePtr == NULL) {
/* Smart initialization of doubleTypePtr/intTypePtr without
* hash-table lookup or creating complete Tcl_Obj's */
Tcl_Obj obj;
+ obj.bytes = (char *)"end";
obj.length = 3;
+ obj.typePtr = NULL;
+ Tcl_GetIntForIndex(NULL, &obj, TCL_INDEX_NONE, (TkSizeT *)&obj.internalRep.doubleValue);
+ tsdPtr->endTypePtr = obj.typePtr;
obj.bytes = (char *)"0.0";
+ obj.length = 3;
obj.typePtr = NULL;
Tcl_GetDoubleFromObj(NULL, &obj, &obj.internalRep.doubleValue);
tsdPtr->doubleTypePtr = obj.typePtr;
- obj.bytes += 2;
+ obj.bytes = (char *)"0";
obj.length = 1;
obj.typePtr = NULL;
Tcl_GetLongFromObj(NULL, &obj, &obj.internalRep.longValue);
@@ -177,6 +206,56 @@ GetTypeCache(void)
/*
*----------------------------------------------------------------------
*
+ * TkGetIntForIndex --
+ *
+ * Almost the same as Tcl_GetIntForIndex, but it return an int, and it is
+ * more restricted. For example it only accepts "end", not "end-1", and
+ * only "2", not "1+1"
+ *
+ * Results:
+ * The return value is a standard Tcl object result.
+ *
+ * Side effects:
+ * None
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkGetIntForIndex(
+ Tcl_Obj *indexObj,
+ TkSizeT end,
+ int lastOK,
+ TkSizeT *indexPtr)
+{
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
+ if (Tcl_GetIntForIndex(NULL, indexObj, end + lastOK, indexPtr) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (indexObj->typePtr == tsdPtr->endTypePtr) {
+ /* check for "end", but not "end-??" or "end+??" */
+ return (*indexPtr == (end + lastOK)) ? TCL_OK : TCL_ERROR;
+ }
+ if (indexObj->typePtr != tsdPtr->intTypePtr) {
+ /* Neither do we accept "??-??" or "??+??" */
+ return TCL_ERROR;
+ }
+#if TCL_MAJOR_VERSION < 9
+ if ((*indexPtr < -1) || (end < -1)) {
+ return TCL_ERROR;
+ }
+#endif
+ if ((*indexPtr + 1) > (end + 1)) {
+ *indexPtr = end + 1;
+ }
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* GetPixelsFromObjEx --
*
* Attempt to return a pixel value from the Tcl object "objPtr". If the
@@ -412,8 +491,8 @@ FreePixelInternalRep(
static void
DupPixelInternalRep(
- register Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
- register Tcl_Obj *copyPtr) /* Object with internal rep to set. */
+ Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
+ Tcl_Obj *copyPtr) /* Object with internal rep to set. */
{
copyPtr->typePtr = srcPtr->typePtr;
@@ -423,7 +502,7 @@ DupPixelInternalRep(
PixelRep *oldPtr, *newPtr;
oldPtr = GET_COMPLEXPIXEL(srcPtr);
- newPtr = ckalloc(sizeof(PixelRep));
+ newPtr = (PixelRep *)ckalloc(sizeof(PixelRep));
newPtr->value = oldPtr->value;
newPtr->units = oldPtr->units;
newPtr->tkwin = oldPtr->tkwin;
@@ -507,7 +586,7 @@ SetPixelFromAny(
if ((units < 0) && (i == d)) {
SET_SIMPLEPIXEL(objPtr, i);
} else {
- PixelRep *pixelPtr = ckalloc(sizeof(PixelRep));
+ PixelRep *pixelPtr = (PixelRep *)ckalloc(sizeof(PixelRep));
pixelPtr->value = d;
pixelPtr->units = units;
@@ -568,7 +647,7 @@ Tk_GetMMFromObj(
}
}
- mmPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ mmPtr = (MMRep *)objPtr->internalRep.twoPtrValue.ptr1;
if (mmPtr->tkwin != tkwin) {
d = mmPtr->value;
if (mmPtr->units == -1) {
@@ -632,14 +711,14 @@ FreeMMInternalRep(
static void
DupMMInternalRep(
- register Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
- register Tcl_Obj *copyPtr) /* Object with internal rep to set. */
+ Tcl_Obj *srcPtr, /* Object with internal rep to copy. */
+ Tcl_Obj *copyPtr) /* Object with internal rep to set. */
{
MMRep *oldPtr, *newPtr;
copyPtr->typePtr = srcPtr->typePtr;
- oldPtr = srcPtr->internalRep.twoPtrValue.ptr1;
- newPtr = ckalloc(sizeof(MMRep));
+ oldPtr = (MMRep *)srcPtr->internalRep.twoPtrValue.ptr1;
+ newPtr = (MMRep *)ckalloc(sizeof(MMRep));
newPtr->value = oldPtr->value;
newPtr->units = oldPtr->units;
newPtr->tkwin = oldPtr->tkwin;
@@ -668,13 +747,13 @@ DupMMInternalRep(
static void
UpdateStringOfMM(
- register Tcl_Obj *objPtr) /* pixel obj with string rep to update. */
+ Tcl_Obj *objPtr) /* pixel obj with string rep to update. */
{
MMRep *mmPtr;
char buffer[TCL_DOUBLE_SPACE];
- size_t len;
+ TkSizeT len;
- mmPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ mmPtr = (MMRep *)objPtr->internalRep.twoPtrValue.ptr1;
/* assert( mmPtr->units == -1 && objPtr->bytes == NULL ); */
if ((mmPtr->units != -1) || (objPtr->bytes != NULL)) {
Tcl_Panic("UpdateStringOfMM: false precondition");
@@ -683,7 +762,7 @@ UpdateStringOfMM(
Tcl_PrintDouble(NULL, mmPtr->value, buffer);
len = strlen(buffer);
- objPtr->bytes = ckalloc(len + 1);
+ objPtr->bytes = (char *)ckalloc(len + 1);
strcpy(objPtr->bytes, buffer);
objPtr->length = len;
}
@@ -791,7 +870,7 @@ SetMMFromAny(
objPtr->typePtr = &mmObjType;
- mmPtr = ckalloc(sizeof(MMRep));
+ mmPtr = (MMRep *)ckalloc(sizeof(MMRep));
mmPtr->value = d;
mmPtr->units = units;
mmPtr->tkwin = NULL;
@@ -831,7 +910,7 @@ TkGetWindowFromObj(
Tk_Window *windowPtr) /* Place to store resulting window. */
{
TkMainInfo *mainPtr = ((TkWindow *) tkwin)->mainPtr;
- register WindowRep *winPtr;
+ WindowRep *winPtr;
if (objPtr->typePtr != &windowObjType) {
int result = SetWindowFromAny(interp, objPtr);
@@ -840,7 +919,7 @@ TkGetWindowFromObj(
}
}
- winPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ winPtr = (WindowRep *)objPtr->internalRep.twoPtrValue.ptr1;
if (winPtr->tkwin == NULL
|| winPtr->mainPtr == NULL
|| winPtr->mainPtr != mainPtr
@@ -886,11 +965,12 @@ TkGetWindowFromObj(
static int
SetWindowFromAny(
- Tcl_Interp *interp, /* Used for error reporting if not NULL. */
- register Tcl_Obj *objPtr) /* The object to convert. */
+ Tcl_Interp *dummy, /* Used for error reporting if not NULL. */
+ Tcl_Obj *objPtr) /* The object to convert. */
{
const Tcl_ObjType *typePtr;
WindowRep *winPtr;
+ (void)dummy;
/*
* Free the old internalRep before setting the new one.
@@ -902,7 +982,7 @@ SetWindowFromAny(
typePtr->freeIntRepProc(objPtr);
}
- winPtr = ckalloc(sizeof(WindowRep));
+ winPtr = (WindowRep *)ckalloc(sizeof(WindowRep));
winPtr->tkwin = NULL;
winPtr->mainPtr = NULL;
winPtr->epoch = 0;
@@ -933,13 +1013,13 @@ SetWindowFromAny(
static void
DupWindowInternalRep(
- register Tcl_Obj *srcPtr,
- register Tcl_Obj *copyPtr)
+ Tcl_Obj *srcPtr,
+ Tcl_Obj *copyPtr)
{
- register WindowRep *oldPtr, *newPtr;
+ WindowRep *oldPtr, *newPtr;
- oldPtr = srcPtr->internalRep.twoPtrValue.ptr1;
- newPtr = ckalloc(sizeof(WindowRep));
+ oldPtr = (WindowRep *)srcPtr->internalRep.twoPtrValue.ptr1;
+ newPtr = (WindowRep *)ckalloc(sizeof(WindowRep));
newPtr->tkwin = oldPtr->tkwin;
newPtr->mainPtr = oldPtr->mainPtr;
newPtr->epoch = oldPtr->epoch;
@@ -997,11 +1077,11 @@ TkNewWindowObj(
{
Tcl_Obj *objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1);
TkMainInfo *mainPtr = ((TkWindow *) tkwin)->mainPtr;
- register WindowRep *winPtr;
+ WindowRep *winPtr;
SetWindowFromAny(NULL, objPtr);
- winPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ winPtr = (WindowRep *)objPtr->internalRep.twoPtrValue.ptr1;
winPtr->tkwin = tkwin;
winPtr->mainPtr = mainPtr;
winPtr->epoch = mainPtr->deletionEpoch;
diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c
index d83c30b..7400b32 100644
--- a/generic/tkOldConfig.c
+++ b/generic/tkOldConfig.c
@@ -86,7 +86,7 @@ Tk_ConfigureWidget(
* considered. Also, may have
* TK_CONFIG_ARGV_ONLY set. */
{
- register Tk_ConfigSpec *specPtr, *staticSpecs;
+ Tk_ConfigSpec *specPtr, *staticSpecs;
Tk_Uid value; /* Value of option from database. */
int needFlags; /* Specs must contain this set of flags or
* else they are not considered. */
@@ -249,8 +249,8 @@ FindConfigSpec(
int hateFlags) /* Flags that must NOT be present in matching
* entry. */
{
- register Tk_ConfigSpec *specPtr;
- register char c; /* First character of current argument. */
+ Tk_ConfigSpec *specPtr;
+ char c; /* First character of current argument. */
Tk_ConfigSpec *matchPtr; /* Matching spec, or NULL. */
size_t length;
@@ -380,7 +380,7 @@ DoConfig(
if (nullValue) {
newStr = NULL;
} else {
- newStr = ckalloc(strlen(value) + 1);
+ newStr = (char *)ckalloc(strlen(value) + 1);
strcpy(newStr, value);
}
oldStr = *((char **) ptr);
@@ -550,7 +550,7 @@ DoConfig(
}
case TK_CONFIG_CUSTOM:
if (specPtr->customPtr->parseProc(specPtr->customPtr->clientData,
- interp, tkwin, value, widgRec, specPtr->offset)!=TCL_OK) {
+ interp, tkwin, value, (char *)widgRec, specPtr->offset)!=TCL_OK) {
return TCL_ERROR;
}
break;
@@ -607,7 +607,7 @@ Tk_ConfigureInfo(
* be present in config specs for them to be
* considered. */
{
- register Tk_ConfigSpec *specPtr, *staticSpecs;
+ Tk_ConfigSpec *specPtr, *staticSpecs;
int needFlags, hateFlags;
char *list;
const char *leader = "{";
@@ -690,7 +690,7 @@ FormatConfigInfo(
Tcl_Interp *interp, /* Interpreter to use for things like
* floating-point precision. */
Tk_Window tkwin, /* Window corresponding to widget. */
- register const Tk_ConfigSpec *specPtr,
+ const Tk_ConfigSpec *specPtr,
/* Pointer to information describing
* option. */
void *widgRec) /* Pointer to record holding current values of
@@ -878,7 +878,7 @@ FormatConfigValue(
}
case TK_CONFIG_CUSTOM:
result = specPtr->customPtr->printProc(specPtr->customPtr->clientData,
- tkwin, widgRec, specPtr->offset, freeProcPtr);
+ tkwin, (char *)widgRec, specPtr->offset, freeProcPtr);
break;
default:
result = "?? unknown type ??";
@@ -976,7 +976,6 @@ Tk_ConfigureValue(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
void
Tk_FreeOptions(
const Tk_ConfigSpec *specs, /* Describes legal options. */
@@ -988,7 +987,7 @@ Tk_FreeOptions(
* be present in config specs for them to be
* considered. */
{
- register const Tk_ConfigSpec *specPtr;
+ const Tk_ConfigSpec *specPtr;
char *ptr;
for (specPtr = specs; specPtr->type != TK_CONFIG_END; specPtr++) {
@@ -1076,10 +1075,10 @@ GetCachedSpecs(
* self-initializing code.
*/
- specCacheTablePtr =
+ specCacheTablePtr = (Tcl_HashTable *)
Tcl_GetAssocData(interp, "tkConfigSpec.threadTable", NULL);
if (specCacheTablePtr == NULL) {
- specCacheTablePtr = ckalloc(sizeof(Tcl_HashTable));
+ specCacheTablePtr = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(specCacheTablePtr, TCL_ONE_WORD_KEYS);
Tcl_SetAssocData(interp, "tkConfigSpec.threadTable",
DeleteSpecCacheTable, specCacheTablePtr);
@@ -1093,7 +1092,7 @@ GetCachedSpecs(
entryPtr = Tcl_CreateHashEntry(specCacheTablePtr, (char *) staticSpecs,
&isNew);
if (isNew) {
- unsigned int entrySpace = sizeof(Tk_ConfigSpec);
+ size_t entrySpace = sizeof(Tk_ConfigSpec);
const Tk_ConfigSpec *staticSpecPtr;
Tk_ConfigSpec *specPtr;
@@ -1112,7 +1111,7 @@ GetCachedSpecs(
* from the master copy.
*/
- cachedSpecs = ckalloc(entrySpace);
+ cachedSpecs = (Tk_ConfigSpec *)ckalloc(entrySpace);
memcpy(cachedSpecs, staticSpecs, entrySpace);
Tcl_SetHashValue(entryPtr, cachedSpecs);
@@ -1136,7 +1135,7 @@ GetCachedSpecs(
}
}
} else {
- cachedSpecs = Tcl_GetHashValue(entryPtr);
+ cachedSpecs = (Tk_ConfigSpec *)Tcl_GetHashValue(entryPtr);
}
return cachedSpecs;
@@ -1162,11 +1161,12 @@ GetCachedSpecs(
static void
DeleteSpecCacheTable(
ClientData clientData,
- Tcl_Interp *interp)
+ Tcl_Interp *dummy)
{
- Tcl_HashTable *tablePtr = clientData;
+ Tcl_HashTable *tablePtr = (Tcl_HashTable *)clientData;
Tcl_HashEntry *entryPtr;
Tcl_HashSearch search;
+ (void)dummy;
for (entryPtr = Tcl_FirstHashEntry(tablePtr,&search); entryPtr != NULL;
entryPtr = Tcl_NextHashEntry(&search)) {
diff --git a/generic/tkOldTest.c b/generic/tkOldTest.c
index f78ebba..d9e8053 100644
--- a/generic/tkOldTest.c
+++ b/generic/tkOldTest.c
@@ -91,7 +91,7 @@ static int ImageObjCmd(ClientData dummy,
*
* TkOldTestInit --
*
- * This function performs intialization for the Tk test suite
+ * This function performs initialization for the Tk test suite
* extensions for testing support for legacy interfaces.
*
* Results:
@@ -106,9 +106,10 @@ static int ImageObjCmd(ClientData dummy,
int
TkOldTestInit(
- Tcl_Interp *interp)
+ Tcl_Interp *dummy)
{
static int initialized = 0;
+ (void)dummy;
if (!initialized) {
initialized = 1;
@@ -133,7 +134,6 @@ TkOldTestInit(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ImageCreate(
Tcl_Interp *interp, /* Interpreter for application containing
@@ -151,6 +151,7 @@ ImageCreate(
TImageMaster *timPtr;
const char *varName;
int i;
+ (void)typePtr;
varName = "log";
for (i = 0; i < argc; i += 2) {
@@ -167,14 +168,14 @@ ImageCreate(
varName = argv[i+1];
}
- timPtr = ckalloc(sizeof(TImageMaster));
+ timPtr = (TImageMaster *)ckalloc(sizeof(TImageMaster));
timPtr->master = master;
timPtr->interp = interp;
timPtr->width = 30;
timPtr->height = 15;
- timPtr->imageName = ckalloc(strlen(name) + 1);
+ timPtr->imageName = (char *)ckalloc(strlen(name) + 1);
strcpy(timPtr->imageName, name);
- timPtr->varName = ckalloc(strlen(varName) + 1);
+ timPtr->varName = (char *)ckalloc(strlen(varName) + 1);
strcpy(timPtr->varName, varName);
Tcl_CreateObjCommand(interp, name, ImageObjCmd, timPtr, NULL);
*clientDataPtr = timPtr;
@@ -199,7 +200,6 @@ ImageCreate(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ImageObjCmd(
ClientData clientData, /* Main window for application. */
@@ -207,7 +207,7 @@ ImageObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- TImageMaster *timPtr = clientData;
+ TImageMaster *timPtr = (TImageMaster *)clientData;
int x, y, width, height;
if (objc < 2) {
@@ -262,7 +262,7 @@ ImageGet(
* used. */
ClientData clientData) /* Pointer to TImageMaster for image. */
{
- TImageMaster *timPtr = clientData;
+ TImageMaster *timPtr = (TImageMaster *)clientData;
TImageInstance *instPtr;
char buffer[100];
XGCValues gcValues;
@@ -271,7 +271,7 @@ ImageGet(
Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer,
TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
- instPtr = ckalloc(sizeof(TImageInstance));
+ instPtr = (TImageInstance *)ckalloc(sizeof(TImageInstance));
instPtr->masterPtr = timPtr;
instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000");
gcValues.foreground = instPtr->fg->pixel;
@@ -309,7 +309,7 @@ ImageDisplay(
/* Coordinates in drawable corresponding to
* imageX and imageY. */
{
- TImageInstance *instPtr = clientData;
+ TImageInstance *instPtr = (TImageInstance *)clientData;
char buffer[200 + TCL_INTEGER_SPACE * 6];
sprintf(buffer, "%s display %d %d %d %d %d %d",
@@ -354,7 +354,7 @@ ImageFree(
ClientData clientData, /* Pointer to TImageInstance for instance. */
Display *display) /* Display where image was to be drawn. */
{
- TImageInstance *instPtr = clientData;
+ TImageInstance *instPtr = (TImageInstance *)clientData;
char buffer[200];
sprintf(buffer, "%s free", instPtr->masterPtr->imageName);
@@ -388,7 +388,7 @@ ImageDelete(
* this function is called, no more instances
* exist. */
{
- TImageMaster *timPtr = clientData;
+ TImageMaster *timPtr = (TImageMaster *)clientData;
char buffer[100];
sprintf(buffer, "%s delete", timPtr->imageName);
diff --git a/generic/tkOption.c b/generic/tkOption.c
index 5ffb301..54ddb34 100644
--- a/generic/tkOption.c
+++ b/generic/tkOption.c
@@ -176,7 +176,7 @@ typedef struct StackLevel {
* of a level. */
} StackLevel;
-typedef struct ThreadSpecificData {
+typedef struct {
int initialized; /* 0 means the ThreadSpecific Data structure
* for the current thread needs to be
* initialized. */
@@ -254,16 +254,16 @@ Tk_AddOption(
* TK_MAX_PRIO. */
{
TkWindow *winPtr = ((TkWindow *) tkwin)->mainPtr->winPtr;
- register ElArray **arrayPtrPtr;
- register Element *elPtr;
+ ElArray **arrayPtrPtr;
+ Element *elPtr;
Element newEl;
- register const char *p;
+ const char *p;
const char *field;
int count, firstField;
size_t length;
#define TMP_SIZE 100
char tmp[TMP_SIZE+1];
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->mainPtr->optionRootPtr == NULL) {
@@ -406,12 +406,12 @@ Tk_GetOption(
* name. */
{
Tk_Uid nameId, classId = NULL;
- char *masqName;
- register Element *elPtr, *bestPtr;
- register int count;
+ const char *masqName;
+ Element *elPtr, *bestPtr;
+ int count;
StackLevel *levelPtr;
int stackDepth[NUM_STACKS];
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -521,8 +521,8 @@ Tk_GetOption(
if (masqName != NULL) {
char *masqClass;
Tk_Uid nodeId, winClassId, winNameId;
- unsigned int classNameLength;
- register Element *nodePtr, *leafPtr;
+ size_t classNameLength;
+ Element *nodePtr, *leafPtr;
static const int searchOrder[] = {
EXACT_NODE_NAME, WILDCARD_NODE_NAME, EXACT_NODE_CLASS,
WILDCARD_NODE_CLASS, -1
@@ -535,7 +535,7 @@ Tk_GetOption(
*/
classNameLength = (unsigned) (masqName - name);
- masqClass = ckalloc(classNameLength + 1);
+ masqClass = (char *)ckalloc(classNameLength + 1);
strncpy(masqClass, name, classNameLength);
masqClass[classNameLength] = '\0';
@@ -615,9 +615,9 @@ Tk_OptionObjCmd(
int objc, /* Number of Tcl_Obj arguments. */
Tcl_Obj *const objv[]) /* Tcl_Obj arguments. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
int index, result;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
static const char *const optionCmds[] = {
"add", "clear", "get", "readfile", NULL
@@ -738,9 +738,9 @@ Tk_OptionObjCmd(
void
TkOptionDeadWindow(
- register TkWindow *winPtr) /* Window to be cleaned up. */
+ TkWindow *winPtr) /* Window to be cleaned up. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -796,7 +796,7 @@ TkOptionClassChanged(
{
int i, j, *basePtr;
ElArray *arrayPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->optionLevel == -1) {
@@ -922,7 +922,7 @@ AddFromString(
* TK_INTERACTIVE_PRIO. Must be between 0 and
* TK_MAX_PRIO. */
{
- register char *src, *dst;
+ char *src, *dst;
char *name, *value;
int lineNum;
@@ -1150,7 +1150,7 @@ static ElArray *
NewArray(
int numEls) /* How many elements of space to allocate. */
{
- register ElArray *arrayPtr = ckalloc(EL_ARRAY_SIZE(numEls));
+ ElArray *arrayPtr = (ElArray *)ckalloc(EL_ARRAY_SIZE(numEls));
arrayPtr->arraySize = numEls;
arrayPtr->numUsed = 0;
@@ -1177,17 +1177,17 @@ NewArray(
static ElArray *
ExtendArray(
- register ElArray *arrayPtr, /* Array to be extended. */
- register Element *elPtr) /* Element to be copied into array. */
+ ElArray *arrayPtr, /* Array to be extended. */
+ Element *elPtr) /* Element to be copied into array. */
{
/*
* If the current array has filled up, make it bigger.
*/
if (arrayPtr->numUsed >= arrayPtr->arraySize) {
- register int newSize = 2*arrayPtr->arraySize;
+ int newSize = 2*arrayPtr->arraySize;
- arrayPtr = ckrealloc(arrayPtr, EL_ARRAY_SIZE(newSize));
+ arrayPtr = (ElArray *)ckrealloc(arrayPtr, EL_ARRAY_SIZE(newSize));
arrayPtr->arraySize = newSize;
arrayPtr->nextToUse = &arrayPtr->els[arrayPtr->numUsed];
}
@@ -1226,9 +1226,9 @@ SetupStacks(
{
int level, i;
const int *iPtr;
- register StackLevel *levelPtr;
- register ElArray *arrayPtr;
- ThreadSpecificData *tsdPtr =
+ StackLevel *levelPtr;
+ ElArray *arrayPtr;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -1305,7 +1305,7 @@ SetupStacks(
*/
if (tsdPtr->curLevel >= tsdPtr->numLevels) {
- StackLevel *newLevels =
+ StackLevel *newLevels = (StackLevel *)
ckalloc(tsdPtr->numLevels * 2 * sizeof(StackLevel));
memcpy(newLevels, tsdPtr->levels,
@@ -1332,7 +1332,7 @@ SetupStacks(
*/
for (iPtr = searchOrder; *iPtr != -1; iPtr++) {
- register Element *elPtr;
+ Element *elPtr;
int count;
Tk_Uid id;
@@ -1387,9 +1387,9 @@ ExtendStacks(
int leaf) /* If zero, then don't copy exact leaf
* elements. */
{
- register int count;
- register Element *elPtr;
- ThreadSpecificData *tsdPtr =
+ int count;
+ Element *elPtr;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (elPtr = arrayPtr->els, count = arrayPtr->numUsed;
@@ -1420,10 +1420,11 @@ ExtendStacks(
static void
OptionThreadExitProc(
- ClientData clientData) /* not used */
+ ClientData dummy) /* not used */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
if (tsdPtr->initialized) {
int i;
@@ -1454,13 +1455,13 @@ OptionThreadExitProc(
static void
OptionInit(
- register TkMainInfo *mainPtr)
+ TkMainInfo *mainPtr)
/* Top-level information about window that
* isn't initialized yet. */
{
int i;
Tcl_Interp *interp;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Element *defaultMatchPtr = &tsdPtr->defaultMatch;
@@ -1475,7 +1476,7 @@ OptionInit(
tsdPtr->curLevel = -1;
tsdPtr->serial = 0;
- tsdPtr->levels = ckalloc(5 * sizeof(StackLevel));
+ tsdPtr->levels = (StackLevel *)ckalloc(5 * sizeof(StackLevel));
for (i = 0; i < NUM_STACKS; i++) {
tsdPtr->stacks[i] = NewArray(10);
tsdPtr->levels[0].bases[i] = 0;
@@ -1522,7 +1523,7 @@ ClearOptionTree(
ElArray *arrayPtr) /* Array of options; delete everything
* referred to recursively by this. */
{
- register Element *elPtr;
+ Element *elPtr;
int count;
for (count = arrayPtr->numUsed, elPtr = arrayPtr->els; count > 0;
diff --git a/generic/tkPack.c b/generic/tkPack.c
index aabfe1f..796530a 100644
--- a/generic/tkPack.c
+++ b/generic/tkPack.c
@@ -163,10 +163,10 @@ TkAppendPadAmount(
if (halfSpace*2 == allSpace) {
Tcl_DictObjPut(NULL, bufferObj, Tcl_NewStringObj(switchName, -1),
- Tcl_NewIntObj(halfSpace));
+ Tcl_NewWideIntObj(halfSpace));
} else {
- padding[0] = Tcl_NewIntObj(halfSpace);
- padding[1] = Tcl_NewIntObj(allSpace - halfSpace);
+ padding[0] = Tcl_NewWideIntObj(halfSpace);
+ padding[1] = Tcl_NewWideIntObj(allSpace - halfSpace);
Tcl_DictObjPut(NULL, bufferObj, Tcl_NewStringObj(switchName, -1),
Tcl_NewListObj(2, padding));
}
@@ -196,7 +196,7 @@ Tk_PackObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
const char *argv2;
static const char *const optionStrings[] = {
#ifndef TK_NO_DEPRECATED
@@ -259,7 +259,7 @@ Tk_PackObjCmd(
}
case PACK_APPEND: {
Packer *masterPtr;
- register Packer *prevPtr;
+ Packer *prevPtr;
Tk_Window tkwin2;
if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) {
@@ -276,7 +276,7 @@ Tk_PackObjCmd(
}
case PACK_BEFORE: {
Packer *packPtr, *masterPtr;
- register Packer *prevPtr;
+ Packer *prevPtr;
Tk_Window tkwin2;
if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) {
@@ -337,7 +337,7 @@ Tk_PackObjCmd(
break;
}
case PACK_INFO: {
- register Packer *slavePtr;
+ Packer *slavePtr;
Tk_Window slave;
Tcl_Obj *infoObj;
@@ -515,7 +515,6 @@ Tk_PackObjCmd(
*------------------------------------------------------------------------
*/
- /* ARGSUSED */
static void
PackReqProc(
ClientData clientData, /* Packer's information about window that got
@@ -523,7 +522,8 @@ PackReqProc(
Tk_Window tkwin) /* Other Tk-related information about the
* window. */
{
- register Packer *packPtr = clientData;
+ Packer *packPtr = (Packer *)clientData;
+ (void)tkwin;
packPtr = packPtr->masterPtr;
if (!(packPtr->flags & REQUESTED_REPACK)) {
@@ -549,14 +549,14 @@ PackReqProc(
*------------------------------------------------------------------------
*/
- /* ARGSUSED */
static void
PackLostSlaveProc(
ClientData clientData, /* Packer structure for slave window that was
* stolen away. */
Tk_Window tkwin) /* Tk's handle for the slave window. */
{
- register Packer *slavePtr = clientData;
+ Packer *slavePtr = (Packer *)clientData;
+ (void)tkwin;
if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin);
@@ -589,8 +589,8 @@ ArrangePacking(
ClientData clientData) /* Structure describing master whose slaves
* are to be re-layed out. */
{
- register Packer *masterPtr = clientData;
- register Packer *slavePtr;
+ Packer *masterPtr = (Packer *)clientData;
+ Packer *slavePtr;
int cavityX, cavityY, cavityWidth, cavityHeight;
/* These variables keep track of the
* as-yet-unallocated space remaining in the
@@ -913,7 +913,7 @@ ArrangePacking(
static int
XExpansion(
- register Packer *slavePtr, /* First in list of remaining slaves. */
+ Packer *slavePtr, /* First in list of remaining slaves. */
int cavityWidth) /* Horizontal space left for all remaining
* slaves. */
{
@@ -979,7 +979,7 @@ XExpansion(
static int
YExpansion(
- register Packer *slavePtr, /* First in list of remaining slaves. */
+ Packer *slavePtr, /* First in list of remaining slaves. */
int cavityHeight) /* Vertical space left for all remaining
* slaves. */
{
@@ -1042,7 +1042,7 @@ GetPacker(
Tk_Window tkwin) /* Token for window for which packer structure
* is desired. */
{
- register Packer *packPtr;
+ Packer *packPtr;
Tcl_HashEntry *hPtr;
int isNew;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -1060,9 +1060,9 @@ GetPacker(
hPtr = Tcl_CreateHashEntry(&dispPtr->packerHashTable, (char *) tkwin,
&isNew);
if (!isNew) {
- return Tcl_GetHashValue(hPtr);
+ return (Packer *)Tcl_GetHashValue(hPtr);
}
- packPtr = ckalloc(sizeof(Packer));
+ packPtr = (Packer *)ckalloc(sizeof(Packer));
packPtr->tkwin = tkwin;
packPtr->masterPtr = NULL;
packPtr->nextPtr = NULL;
@@ -1112,7 +1112,7 @@ PackAfter(
* window name and side against which to
* pack. */
{
- register Packer *packPtr;
+ Packer *packPtr;
Tk_Window tkwin, ancestor, parent;
Tcl_Obj **options;
int index, optionCount, c;
@@ -1182,7 +1182,7 @@ PackAfter(
packPtr->flags |= OLD_STYLE;
for (index = 0 ; index < optionCount; index++) {
Tcl_Obj *curOptPtr = options[index];
- size_t length;
+ TkSizeT length;
const char *curOpt = TkGetStringFromObj(curOptPtr, &length);
c = curOpt[0];
@@ -1240,7 +1240,7 @@ PackAfter(
packPtr->iPadY = 0;
index++;
} else if ((c == 'f') && (length > 1)
- && (strncmp(curOpt, "frame", (size_t) length) == 0)) {
+ && (strncmp(curOpt, "frame", length) == 0)) {
if (optionCount < (index+2)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"wrong # args: \"frame\""
@@ -1340,9 +1340,9 @@ PackAfter(
static void
Unlink(
- register Packer *packPtr) /* Window to unlink. */
+ Packer *packPtr) /* Window to unlink. */
{
- register Packer *masterPtr, *packPtr2;
+ Packer *masterPtr, *packPtr2;
masterPtr = packPtr->masterPtr;
if (masterPtr == NULL) {
@@ -1410,7 +1410,7 @@ DestroyPacker(
void *memPtr) /* Info about packed window that is now
* dead. */
{
- register Packer *packPtr = memPtr;
+ Packer *packPtr = (Packer *)memPtr;
ckfree(packPtr);
}
@@ -1439,7 +1439,7 @@ PackStructureProc(
* eventPtr. */
XEvent *eventPtr) /* Describes what just happened. */
{
- register Packer *packPtr = clientData;
+ Packer *packPtr = (Packer *)clientData;
if (eventPtr->type == ConfigureNotify) {
if ((packPtr->slavePtr != NULL)
@@ -1456,7 +1456,7 @@ PackStructureProc(
}
}
} else if (eventPtr->type == DestroyNotify) {
- register Packer *slavePtr, *nextPtr;
+ Packer *slavePtr, *nextPtr;
if (packPtr->masterPtr != NULL) {
Unlink(packPtr);
@@ -1494,7 +1494,7 @@ PackStructureProc(
Tcl_DoWhenIdle(ArrangePacking, packPtr);
}
} else if (eventPtr->type == UnmapNotify) {
- register Packer *packPtr2;
+ Packer *packPtr2;
/*
* Unmap all of the slaves when the master gets unmapped, so that they
@@ -1540,6 +1540,7 @@ ConfigureSlaves(
{
Packer *masterPtr, *slavePtr, *prevPtr, *otherPtr;
Tk_Window other, slave, parent, ancestor;
+ TkWindow *master;
int i, j, numWindows, tmp, positionGiven;
const char *string;
static const char *const optionStrings[] = {
@@ -1817,6 +1818,24 @@ ConfigureSlaves(
}
/*
+ * Check for management loops.
+ */
+
+ for (master = (TkWindow *)masterPtr->tkwin; master != NULL;
+ master = (TkWindow *)TkGetGeomMaster(master)) {
+ if (master == (TkWindow *)slave) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't put %s inside %s, would cause management loop",
+ Tcl_GetString(objv[j]), Tk_PathName(masterPtr->tkwin)));
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
+ return TCL_ERROR;
+ }
+ }
+ if (masterPtr->tkwin != Tk_Parent(slave)) {
+ ((TkWindow *)slave)->maintainerPtr = (TkWindow *)masterPtr->tkwin;
+ }
+
+ /*
* Unpack the slave if it's currently packed, then position it after
* prevPtr.
*/
diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c
index faec67a..297b335 100644
--- a/generic/tkPanedWindow.c
+++ b/generic/tkPanedWindow.c
@@ -236,7 +236,7 @@ static void AdjustForSticky(int sticky, int cavityWidth,
int *slaveWidthPtr, int *slaveHeightPtr);
static void MoveSash(PanedWindow *pwPtr, int sash, int diff);
static int ObjectIsEmpty(Tcl_Obj *objPtr);
-static void * ComputeSlotAddress(void *recordPtr, int offset);
+static void * ComputeSlotAddress(void *recordPtr, size_t offset);
static int PanedWindowIdentifyCoords(PanedWindow *pwPtr,
Tcl_Interp *interp, int x, int y);
@@ -275,92 +275,92 @@ static const Tk_ObjCustomOption stickyOption = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_PANEDWINDOW_BG_COLOR, -1, Tk_Offset(PanedWindow, background), 0,
+ DEF_PANEDWINDOW_BG_COLOR, TCL_INDEX_NONE, offsetof(PanedWindow, background), 0,
DEF_PANEDWINDOW_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_PANEDWINDOW_BORDERWIDTH, -1, Tk_Offset(PanedWindow, borderWidth),
+ DEF_PANEDWINDOW_BORDERWIDTH, TCL_INDEX_NONE, offsetof(PanedWindow, borderWidth),
0, 0, GEOMETRY},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_PANEDWINDOW_CURSOR, -1, Tk_Offset(PanedWindow, cursor),
+ DEF_PANEDWINDOW_CURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-handlepad", "handlePad", "HandlePad",
- DEF_PANEDWINDOW_HANDLEPAD, -1, Tk_Offset(PanedWindow, handlePad),
+ DEF_PANEDWINDOW_HANDLEPAD, TCL_INDEX_NONE, offsetof(PanedWindow, handlePad),
0, 0, GEOMETRY},
{TK_OPTION_PIXELS, "-handlesize", "handleSize", "HandleSize",
- DEF_PANEDWINDOW_HANDLESIZE, Tk_Offset(PanedWindow, handleSizePtr),
- Tk_Offset(PanedWindow, handleSize), 0, 0, GEOMETRY},
+ DEF_PANEDWINDOW_HANDLESIZE, offsetof(PanedWindow, handleSizePtr),
+ offsetof(PanedWindow, handleSize), 0, 0, GEOMETRY},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- DEF_PANEDWINDOW_HEIGHT, Tk_Offset(PanedWindow, heightPtr),
- Tk_Offset(PanedWindow, height), TK_OPTION_NULL_OK, 0, GEOMETRY},
+ DEF_PANEDWINDOW_HEIGHT, offsetof(PanedWindow, heightPtr),
+ offsetof(PanedWindow, height), TK_OPTION_NULL_OK, 0, GEOMETRY},
{TK_OPTION_BOOLEAN, "-opaqueresize", "opaqueResize", "OpaqueResize",
- DEF_PANEDWINDOW_OPAQUERESIZE, -1,
- Tk_Offset(PanedWindow, resizeOpaque), 0, 0, 0},
+ DEF_PANEDWINDOW_OPAQUERESIZE, TCL_INDEX_NONE,
+ offsetof(PanedWindow, resizeOpaque), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
- DEF_PANEDWINDOW_ORIENT, -1, Tk_Offset(PanedWindow, orient),
+ DEF_PANEDWINDOW_ORIENT, TCL_INDEX_NONE, offsetof(PanedWindow, orient),
0, orientStrings, GEOMETRY},
{TK_OPTION_BORDER, "-proxybackground", "proxyBackground", "ProxyBackground",
- 0, -1, Tk_Offset(PanedWindow, proxyBackground), TK_OPTION_NULL_OK,
- (ClientData) DEF_PANEDWINDOW_BG_MONO},
+ 0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyBackground), TK_OPTION_NULL_OK,
+ (ClientData) DEF_PANEDWINDOW_BG_MONO, 0},
{TK_OPTION_PIXELS, "-proxyborderwidth", "proxyBorderWidth", "ProxyBorderWidth",
- DEF_PANEDWINDOW_PROXYBORDER, Tk_Offset(PanedWindow, proxyBorderWidthPtr),
- Tk_Offset(PanedWindow, proxyBorderWidth), 0, 0, GEOMETRY},
+ DEF_PANEDWINDOW_PROXYBORDER, offsetof(PanedWindow, proxyBorderWidthPtr),
+ offsetof(PanedWindow, proxyBorderWidth), 0, 0, GEOMETRY},
{TK_OPTION_RELIEF, "-proxyrelief", "proxyRelief", "Relief",
- 0, -1, Tk_Offset(PanedWindow, proxyRelief),
+ 0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_PANEDWINDOW_RELIEF, -1, Tk_Offset(PanedWindow, relief), 0, 0, 0},
+ DEF_PANEDWINDOW_RELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, relief), 0, 0, 0},
{TK_OPTION_CURSOR, "-sashcursor", "sashCursor", "Cursor",
- DEF_PANEDWINDOW_SASHCURSOR, -1, Tk_Offset(PanedWindow, sashCursor),
+ DEF_PANEDWINDOW_SASHCURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, sashCursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-sashpad", "sashPad", "SashPad",
- DEF_PANEDWINDOW_SASHPAD, -1, Tk_Offset(PanedWindow, sashPad),
+ DEF_PANEDWINDOW_SASHPAD, TCL_INDEX_NONE, offsetof(PanedWindow, sashPad),
0, 0, GEOMETRY},
{TK_OPTION_RELIEF, "-sashrelief", "sashRelief", "Relief",
- DEF_PANEDWINDOW_SASHRELIEF, -1, Tk_Offset(PanedWindow, sashRelief),
+ DEF_PANEDWINDOW_SASHRELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, sashRelief),
0, 0, 0},
{TK_OPTION_PIXELS, "-sashwidth", "sashWidth", "Width",
- DEF_PANEDWINDOW_SASHWIDTH, Tk_Offset(PanedWindow, sashWidthPtr),
- Tk_Offset(PanedWindow, sashWidth), 0, 0, GEOMETRY},
+ DEF_PANEDWINDOW_SASHWIDTH, offsetof(PanedWindow, sashWidthPtr),
+ offsetof(PanedWindow, sashWidth), 0, 0, GEOMETRY},
{TK_OPTION_BOOLEAN, "-showhandle", "showHandle", "ShowHandle",
- DEF_PANEDWINDOW_SHOWHANDLE, -1, Tk_Offset(PanedWindow, showHandle),
+ DEF_PANEDWINDOW_SHOWHANDLE, TCL_INDEX_NONE, offsetof(PanedWindow, showHandle),
0, 0, GEOMETRY},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_PANEDWINDOW_WIDTH, Tk_Offset(PanedWindow, widthPtr),
- Tk_Offset(PanedWindow, width), TK_OPTION_NULL_OK, 0, GEOMETRY},
+ DEF_PANEDWINDOW_WIDTH, offsetof(PanedWindow, widthPtr),
+ offsetof(PanedWindow, width), TK_OPTION_NULL_OK, 0, GEOMETRY},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
static const Tk_OptionSpec slaveOptionSpecs[] = {
{TK_OPTION_WINDOW, "-after", NULL, NULL,
- DEF_PANEDWINDOW_PANE_AFTER, -1, Tk_Offset(Slave, after),
+ DEF_PANEDWINDOW_PANE_AFTER, TCL_INDEX_NONE, offsetof(Slave, after),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_WINDOW, "-before", NULL, NULL,
- DEF_PANEDWINDOW_PANE_BEFORE, -1, Tk_Offset(Slave, before),
+ DEF_PANEDWINDOW_PANE_BEFORE, TCL_INDEX_NONE, offsetof(Slave, before),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-height", NULL, NULL,
- DEF_PANEDWINDOW_PANE_HEIGHT, Tk_Offset(Slave, heightPtr),
- Tk_Offset(Slave, height), TK_OPTION_NULL_OK, 0, 0},
+ DEF_PANEDWINDOW_PANE_HEIGHT, offsetof(Slave, heightPtr),
+ offsetof(Slave, height), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-hide", "hide", "Hide",
- DEF_PANEDWINDOW_PANE_HIDE, -1, Tk_Offset(Slave, hide), 0,0,GEOMETRY},
+ DEF_PANEDWINDOW_PANE_HIDE, TCL_INDEX_NONE, offsetof(Slave, hide), 0,0,GEOMETRY},
{TK_OPTION_PIXELS, "-minsize", NULL, NULL,
- DEF_PANEDWINDOW_PANE_MINSIZE, -1, Tk_Offset(Slave, minSize), 0, 0, 0},
+ DEF_PANEDWINDOW_PANE_MINSIZE, TCL_INDEX_NONE, offsetof(Slave, minSize), 0, 0, 0},
{TK_OPTION_PIXELS, "-padx", NULL, NULL,
- DEF_PANEDWINDOW_PANE_PADX, -1, Tk_Offset(Slave, padx), 0, 0, 0},
+ DEF_PANEDWINDOW_PANE_PADX, TCL_INDEX_NONE, offsetof(Slave, padx), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", NULL, NULL,
- DEF_PANEDWINDOW_PANE_PADY, -1, Tk_Offset(Slave, pady), 0, 0, 0},
+ DEF_PANEDWINDOW_PANE_PADY, TCL_INDEX_NONE, offsetof(Slave, pady), 0, 0, 0},
{TK_OPTION_CUSTOM, "-sticky", NULL, NULL,
- DEF_PANEDWINDOW_PANE_STICKY, -1, Tk_Offset(Slave, sticky), 0,
+ DEF_PANEDWINDOW_PANE_STICKY, TCL_INDEX_NONE, offsetof(Slave, sticky), 0,
&stickyOption, 0},
{TK_OPTION_STRING_TABLE, "-stretch", "stretch", "Stretch",
- DEF_PANEDWINDOW_PANE_STRETCH, -1, Tk_Offset(Slave, stretch), 0,
+ DEF_PANEDWINDOW_PANE_STRETCH, TCL_INDEX_NONE, offsetof(Slave, stretch), 0,
(ClientData) stretchStrings, 0},
{TK_OPTION_PIXELS, "-width", NULL, NULL,
- DEF_PANEDWINDOW_PANE_WIDTH, Tk_Offset(Slave, widthPtr),
- Tk_Offset(Slave, width), TK_OPTION_NULL_OK, 0, 0},
+ DEF_PANEDWINDOW_PANE_WIDTH, offsetof(Slave, widthPtr),
+ offsetof(Slave, width), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -383,7 +383,7 @@ static const Tk_OptionSpec slaveOptionSpecs[] = {
int
Tk_PanedWindowObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj * const objv[]) /* Argument objects. */
@@ -392,6 +392,7 @@ Tk_PanedWindowObjCmd(
Tk_Window tkwin, parent;
OptionTables *pwOpts;
XSetWindowAttributes atts;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -414,7 +415,7 @@ Tk_PanedWindowObjCmd(
* easy access to it in the future.
*/
- pwOpts = ckalloc(sizeof(OptionTables));
+ pwOpts = (OptionTables *)ckalloc(sizeof(OptionTables));
/*
* Set up an exit handler to free the optionTables struct.
@@ -437,7 +438,7 @@ Tk_PanedWindowObjCmd(
* Allocate and initialize the widget record.
*/
- pwPtr = ckalloc(sizeof(PanedWindow));
+ pwPtr = (PanedWindow *)ckalloc(sizeof(PanedWindow));
memset((void *)pwPtr, 0, (sizeof(PanedWindow)));
pwPtr->tkwin = tkwin;
pwPtr->display = Tk_Display(tkwin);
@@ -535,7 +536,7 @@ PanedWindowWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj * const objv[]) /* Argument objects. */
{
- PanedWindow *pwPtr = clientData;
+ PanedWindow *pwPtr = (PanedWindow *)clientData;
int result = TCL_OK;
static const char *const optionStrings[] = {
"add", "cget", "configure", "forget", "identify", "panecget",
@@ -903,7 +904,7 @@ ConfigureSlaves(
* structures may already have existed, some may be new.
*/
- inserts = ckalloc(sizeof(Slave *) * (firstOptionArg - 2));
+ inserts = (Slave **)ckalloc(sizeof(Slave *) * (firstOptionArg - 2));
insertIndex = 0;
/*
@@ -970,7 +971,7 @@ ConfigureSlaves(
* out with their "natural" dimensions.
*/
- slavePtr = ckalloc(sizeof(Slave));
+ slavePtr = (Slave *)ckalloc(sizeof(Slave));
memset(slavePtr, 0, sizeof(Slave));
Tk_InitOptions(interp, slavePtr, pwPtr->slaveOpts,
pwPtr->tkwin);
@@ -1010,8 +1011,8 @@ ConfigureSlaves(
*/
i = sizeof(Slave *) * (pwPtr->numSlaves + numNewSlaves);
- newSlaves = ckalloc(i);
- memset(newSlaves, 0, (size_t) i);
+ newSlaves = (Slave **)ckalloc(i);
+ memset(newSlaves, 0, i);
if (index == -1) {
/*
* If none of the existing slaves have to be moved, just copy the old
@@ -1132,8 +1133,8 @@ PanedWindowSashCommand(
}
slavePtr = pwPtr->slaves[sash];
- coords[0] = Tcl_NewIntObj(slavePtr->sashx);
- coords[1] = Tcl_NewIntObj(slavePtr->sashy);
+ coords[0] = Tcl_NewWideIntObj(slavePtr->sashx);
+ coords[1] = Tcl_NewWideIntObj(slavePtr->sashy);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords));
break;
@@ -1166,8 +1167,8 @@ PanedWindowSashCommand(
pwPtr->slaves[sash]->markx = x;
pwPtr->slaves[sash]->marky = y;
} else {
- coords[0] = Tcl_NewIntObj(pwPtr->slaves[sash]->markx);
- coords[1] = Tcl_NewIntObj(pwPtr->slaves[sash]->marky);
+ coords[0] = Tcl_NewWideIntObj(pwPtr->slaves[sash]->markx);
+ coords[1] = Tcl_NewWideIntObj(pwPtr->slaves[sash]->marky);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords));
}
break;
@@ -1295,7 +1296,7 @@ PanedWindowWorldChanged(
{
XGCValues gcValues;
GC newGC;
- PanedWindow *pwPtr = instanceData;
+ PanedWindow *pwPtr = (PanedWindow *)instanceData;
/*
* Allocated a graphics context for drawing the paned window widget
@@ -1352,7 +1353,7 @@ PanedWindowEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- PanedWindow *pwPtr = clientData;
+ PanedWindow *pwPtr = (PanedWindow *)clientData;
int i;
if (eventPtr->type == Expose) {
@@ -1405,7 +1406,7 @@ static void
PanedWindowCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- PanedWindow *pwPtr = clientData;
+ PanedWindow *pwPtr = (PanedWindow *)clientData;
/*
* This function could be invoked either because the window was destroyed
@@ -1442,7 +1443,7 @@ static void
DisplayPanedWindow(
ClientData clientData) /* Information about window. */
{
- PanedWindow *pwPtr = clientData;
+ PanedWindow *pwPtr = (PanedWindow *)clientData;
Slave *slavePtr;
Pixmap pixmap;
Tk_Window tkwin = pwPtr->tkwin;
@@ -1630,8 +1631,9 @@ PanedWindowReqProc(
Tk_Window tkwin) /* Other Tk-related information about the
* window. */
{
- Slave *slavePtr = clientData;
+ Slave *slavePtr = (Slave *)clientData;
PanedWindow *pwPtr = (PanedWindow *) slavePtr->masterPtr;
+ (void)tkwin;
if (Tk_IsMapped(pwPtr->tkwin)) {
if (!(pwPtr->flags & RESIZE_PENDING)) {
@@ -1675,8 +1677,9 @@ PanedWindowLostSlaveProc(
* stolen away. */
Tk_Window tkwin) /* Tk's handle for the slave window. */
{
- register Slave *slavePtr = clientData;
+ Slave *slavePtr = (Slave *)clientData;
PanedWindow *pwPtr = (PanedWindow *) slavePtr->masterPtr;
+ (void)tkwin;
if (pwPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin);
@@ -1714,8 +1717,8 @@ ArrangePanes(
ClientData clientData) /* Structure describing parent whose slaves
* are to be re-layed out. */
{
- register PanedWindow *pwPtr = clientData;
- register Slave *slavePtr;
+ PanedWindow *pwPtr = (PanedWindow *)clientData;
+ Slave *slavePtr;
int i, slaveWidth, slaveHeight, slaveX, slaveY;
int paneWidth, paneHeight, paneSize, paneMinSize;
int doubleBw;
@@ -2014,9 +2017,9 @@ ArrangePanes(
static void
Unlink(
- register Slave *slavePtr) /* Window to unlink. */
+ Slave *slavePtr) /* Window to unlink. */
{
- register PanedWindow *masterPtr;
+ PanedWindow *masterPtr;
int i, j;
masterPtr = slavePtr->masterPtr;
@@ -2160,7 +2163,7 @@ SlaveStructureProc(
ClientData clientData, /* Pointer to record describing window item. */
XEvent *eventPtr) /* Describes what just happened. */
{
- Slave *slavePtr = clientData;
+ Slave *slavePtr = (Slave *)clientData;
PanedWindow *pwPtr = slavePtr->masterPtr;
if (eventPtr->type == DestroyNotify) {
@@ -2370,8 +2373,10 @@ ComputeGeometry(
static void
DestroyOptionTables(
ClientData clientData, /* Pointer to the OptionTables struct */
- Tcl_Interp *interp) /* Pointer to the calling interp */
+ Tcl_Interp *dummy) /* Pointer to the calling interp */
{
+ (void)dummy;
+
ckfree(clientData);
}
@@ -2394,7 +2399,7 @@ DestroyOptionTables(
static Tcl_Obj *
GetSticky(
- ClientData clientData,
+ ClientData dummy,
Tk_Window tkwin,
char *recordPtr, /* Pointer to widget record. */
int internalOffset) /* Offset within *recordPtr containing the
@@ -2403,6 +2408,8 @@ GetSticky(
int sticky = *(int *)(recordPtr + internalOffset);
char buffer[5];
char *p = &buffer[0];
+ (void)dummy;
+ (void)tkwin;
if (sticky & STICK_NORTH) {
*p++ = 'n';
@@ -2442,7 +2449,7 @@ GetSticky(
static int
SetSticky(
- ClientData clientData,
+ ClientData dummy,
Tcl_Interp *interp, /* Current interp; may be used for errors. */
Tk_Window tkwin, /* Window for which option is being set. */
Tcl_Obj **value, /* Pointer to the pointer to the value object.
@@ -2458,6 +2465,8 @@ SetSticky(
char c;
void *internalPtr;
const char *string;
+ (void)dummy;
+ (void)tkwin;
internalPtr = ComputeSlotAddress(recordPtr, internalOffset);
@@ -2522,11 +2531,14 @@ SetSticky(
static void
RestoreSticky(
- ClientData clientData,
+ ClientData dummy,
Tk_Window tkwin,
char *internalPtr, /* Pointer to storage for value. */
char *oldInternalPtr) /* Pointer to old value. */
{
+ (void)dummy;
+ (void)tkwin;
+
*(int *)internalPtr = *(int *)oldInternalPtr;
}
@@ -2755,7 +2767,7 @@ ProxyWindowEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- PanedWindow *pwPtr = clientData;
+ PanedWindow *pwPtr = (PanedWindow *)clientData;
if (eventPtr->type == Expose) {
if (pwPtr->proxywin != NULL &&!(pwPtr->flags & PROXY_REDRAW_PENDING)) {
@@ -2787,7 +2799,7 @@ static void
DisplayProxyWindow(
ClientData clientData) /* Information about window. */
{
- PanedWindow *pwPtr = clientData;
+ PanedWindow *pwPtr = (PanedWindow *)clientData;
Pixmap pixmap;
Tk_Window tkwin = pwPtr->proxywin;
pwPtr->flags &= ~PROXY_REDRAW_PENDING;
@@ -2877,8 +2889,8 @@ PanedWindowProxyCommand(
return TCL_ERROR;
}
- coords[0] = Tcl_NewIntObj(pwPtr->proxyx);
- coords[1] = Tcl_NewIntObj(pwPtr->proxyy);
+ coords[0] = Tcl_NewWideIntObj(pwPtr->proxyx);
+ coords[1] = Tcl_NewWideIntObj(pwPtr->proxyy);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords));
break;
@@ -3023,9 +3035,9 @@ ObjectIsEmpty(
static void *
ComputeSlotAddress(
void *recordPtr, /* Pointer to the start of a record. */
- int offset) /* Offset of a slot within that record; may be < 0. */
+ size_t offset) /* Offset of a slot within that record; may be -1. */
{
- if (offset >= 0) {
+ if (offset != (size_t)-1) {
return (char *)recordPtr + offset;
} else {
return NULL;
@@ -3142,7 +3154,7 @@ PanedWindowIdentifyCoords(
if (found != -1) {
Tcl_Obj *list[2];
- list[0] = Tcl_NewIntObj(found);
+ list[0] = Tcl_NewWideIntObj(found);
list[1] = Tcl_NewStringObj((isHandle ? "handle" : "sash"), -1);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, list));
}
diff --git a/generic/tkPkgConfig.c b/generic/tkPkgConfig.c
new file mode 100644
index 0000000..a3666d4
--- /dev/null
+++ b/generic/tkPkgConfig.c
@@ -0,0 +1,166 @@
+/*
+ * tkPkgConfig.c --
+ *
+ * This file contains the configuration information to embed into the tcl
+ * binary library.
+ *
+ * Copyright (c) 2002 Andreas Kupries <andreas_kupries@users.sourceforge.net>
+ * Copyright (c) 2017 Stuart Cassoff <stwo@users.sourceforge.net>
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+/* Note, the definitions in this module are influenced by the following C
+ * preprocessor macros:
+ *
+ * OSCMa = shortcut for "old style configuration macro activates"
+ * NSCMdt = shortcut for "new style configuration macro declares that"
+ *
+ * - TCL_THREADS OSCMa compilation as threaded.
+ * - TCL_MEM_DEBUG OSCMa memory debugging.
+ *
+ * - TCL_CFG_DO64BIT NSCMdt tk is compiled for a 64bit system.
+ * - NDEBUG NSCMdt tk is compiled with symbol info off.
+ * - TCL_CFG_OPTIMIZED NSCMdt tk is compiled with cc optimizations on
+ * - TCL_CFG_PROFILED NSCMdt tk is compiled with profiling info.
+ *
+ * - _WIN32 || __CYGWIN__ The value for the fontsytem key will be
+ * MAC_OSX_TK chosen based on these macros/defines.
+ * HAVE_XFT NSCMdt xft font support was requested.
+ *
+ * - CFG_RUNTIME_* Paths to various stuff at runtime.
+ * - CFG_INSTALL_* Paths to various stuff at installation time.
+ *
+ * - TCL_CFGVAL_ENCODING string containing the encoding used for the
+ * configuration values.
+ */
+
+#include "tkInt.h"
+
+
+#ifndef TCL_CFGVAL_ENCODING
+#define TCL_CFGVAL_ENCODING "ascii"
+#endif
+
+/*
+ * Use C preprocessor statements to define the various values for the embedded
+ * configuration information.
+ */
+
+#ifdef TCL_THREADS
+# define CFG_THREADED "1"
+#else
+# define CFG_THREADED "0"
+#endif
+
+#ifdef TCL_MEM_DEBUG
+# define CFG_MEMDEBUG "1"
+#else
+# define CFG_MEMDEBUG "0"
+#endif
+
+#ifdef TCL_CFG_DO64BIT
+# define CFG_64 "1"
+#else
+# define CFG_64 "0"
+#endif
+
+#ifndef NDEBUG
+# define CFG_DEBUG "1"
+#else
+# define CFG_DEBUG "0"
+#endif
+
+#ifdef TCL_CFG_OPTIMIZED
+# define CFG_OPTIMIZED "1"
+#else
+# define CFG_OPTIMIZED "0"
+#endif
+
+#ifdef TCL_CFG_PROFILED
+# define CFG_PROFILED "1"
+#else
+# define CFG_PROFILED "0"
+#endif
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+# define CFG_FONTSYSTEM "gdi"
+#elif defined(MAC_OSX_TK)
+# define CFG_FONTSYSTEM "cocoa"
+#elif defined(HAVE_XFT)
+# define CFG_FONTSYSTEM "xft"
+#else
+# define CFG_FONTSYSTEM "x11"
+#endif
+
+static const Tcl_Config cfg[] = {
+ {"debug", CFG_DEBUG},
+ {"threaded", CFG_THREADED},
+ {"profiled", CFG_PROFILED},
+ {"64bit", CFG_64},
+ {"optimized", CFG_OPTIMIZED},
+ {"mem_debug", CFG_MEMDEBUG},
+ {"fontsystem", CFG_FONTSYSTEM},
+
+ /* Runtime paths to various stuff */
+
+#ifdef CFG_RUNTIME_LIBDIR
+ {"libdir,runtime", CFG_RUNTIME_LIBDIR},
+#endif
+#ifdef CFG_RUNTIME_BINDIR
+ {"bindir,runtime", CFG_RUNTIME_BINDIR},
+#endif
+#ifdef CFG_RUNTIME_SCRDIR
+ {"scriptdir,runtime", CFG_RUNTIME_SCRDIR},
+#endif
+#ifdef CFG_RUNTIME_INCDIR
+ {"includedir,runtime", CFG_RUNTIME_INCDIR},
+#endif
+#ifdef CFG_RUNTIME_DOCDIR
+ {"docdir,runtime", CFG_RUNTIME_DOCDIR},
+#endif
+#ifdef CFG_RUNTIME_DEMODIR
+ {"demodir,runtime", CFG_RUNTIME_DEMODIR},
+#endif
+
+ /* Installation paths to various stuff */
+
+#ifdef CFG_INSTALL_LIBDIR
+ {"libdir,install", CFG_INSTALL_LIBDIR},
+#endif
+#ifdef CFG_INSTALL_BINDIR
+ {"bindir,install", CFG_INSTALL_BINDIR},
+#endif
+#ifdef CFG_INSTALL_SCRDIR
+ {"scriptdir,install", CFG_INSTALL_SCRDIR},
+#endif
+#ifdef CFG_INSTALL_INCDIR
+ {"includedir,install", CFG_INSTALL_INCDIR},
+#endif
+#ifdef CFG_INSTALL_DOCDIR
+ {"docdir,install", CFG_INSTALL_DOCDIR},
+#endif
+#ifdef CFG_INSTALL_DEMODIR
+ {"demodir,install", CFG_INSTALL_DEMODIR},
+#endif
+
+ /* Last entry, closes the array */
+ {NULL, NULL}
+};
+
+void
+TkInitEmbeddedConfigurationInformation(
+ Tcl_Interp *interp) /* Interpreter the configuration command is
+ * registered in. */
+{
+ Tcl_RegisterConfig(interp, "tk", cfg, TCL_CFGVAL_ENCODING);
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/generic/tkPlace.c b/generic/tkPlace.c
index 08d5c8e..2b5ab2d 100644
--- a/generic/tkPlace.c
+++ b/generic/tkPlace.c
@@ -81,31 +81,31 @@ typedef struct Slave {
#define IN_MASK 1
static const Tk_OptionSpec optionSpecs[] = {
- {TK_OPTION_ANCHOR, "-anchor", NULL, NULL, "nw", -1,
- Tk_Offset(Slave, anchor), 0, 0, 0},
- {TK_OPTION_STRING_TABLE, "-bordermode", NULL, NULL, "inside", -1,
- Tk_Offset(Slave, borderMode), 0, borderModeStrings, 0},
- {TK_OPTION_PIXELS, "-height", NULL, NULL, "", Tk_Offset(Slave, heightPtr),
- Tk_Offset(Slave, height), TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_WINDOW, "-in", NULL, NULL, "", -1, Tk_Offset(Slave, inTkwin),
+ {TK_OPTION_ANCHOR, "-anchor", NULL, NULL, "nw", TCL_INDEX_NONE,
+ offsetof(Slave, anchor), 0, 0, 0},
+ {TK_OPTION_STRING_TABLE, "-bordermode", NULL, NULL, "inside", TCL_INDEX_NONE,
+ offsetof(Slave, borderMode), 0, borderModeStrings, 0},
+ {TK_OPTION_PIXELS, "-height", NULL, NULL, "", offsetof(Slave, heightPtr),
+ offsetof(Slave, height), TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_WINDOW, "-in", NULL, NULL, "", TCL_INDEX_NONE, offsetof(Slave, inTkwin),
0, 0, IN_MASK},
{TK_OPTION_DOUBLE, "-relheight", NULL, NULL, "",
- Tk_Offset(Slave, relHeightPtr), Tk_Offset(Slave, relHeight),
+ offsetof(Slave, relHeightPtr), offsetof(Slave, relHeight),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_DOUBLE, "-relwidth", NULL, NULL, "",
- Tk_Offset(Slave, relWidthPtr), Tk_Offset(Slave, relWidth),
+ offsetof(Slave, relWidthPtr), offsetof(Slave, relWidth),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_DOUBLE, "-relx", NULL, NULL, "0", -1,
- Tk_Offset(Slave, relX), 0, 0, 0},
- {TK_OPTION_DOUBLE, "-rely", NULL, NULL, "0", -1,
- Tk_Offset(Slave, relY), 0, 0, 0},
- {TK_OPTION_PIXELS, "-width", NULL, NULL, "", Tk_Offset(Slave, widthPtr),
- Tk_Offset(Slave, width), TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_PIXELS, "-x", NULL, NULL, "0", Tk_Offset(Slave, xPtr),
- Tk_Offset(Slave, x), TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", Tk_Offset(Slave, yPtr),
- Tk_Offset(Slave, y), TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_DOUBLE, "-relx", NULL, NULL, "0", TCL_INDEX_NONE,
+ offsetof(Slave, relX), 0, 0, 0},
+ {TK_OPTION_DOUBLE, "-rely", NULL, NULL, "0", TCL_INDEX_NONE,
+ offsetof(Slave, relY), 0, 0, 0},
+ {TK_OPTION_PIXELS, "-width", NULL, NULL, "", offsetof(Slave, widthPtr),
+ offsetof(Slave, width), TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_PIXELS, "-x", NULL, NULL, "0", offsetof(Slave, xPtr),
+ offsetof(Slave, x), TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", offsetof(Slave, yPtr),
+ offsetof(Slave, y), TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -208,7 +208,7 @@ Tk_PlaceObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window main_win = clientData;
+ Tk_Window main_win = (Tk_Window)clientData;
Tk_Window tkwin;
Slave *slavePtr;
TkDisplay *dispPtr;
@@ -378,13 +378,13 @@ CreateSlave(
Tk_OptionTable table)
{
Tcl_HashEntry *hPtr;
- register Slave *slavePtr;
+ Slave *slavePtr;
int isNew;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
hPtr = Tcl_CreateHashEntry(&dispPtr->slaveTable, (char *) tkwin, &isNew);
if (!isNew) {
- return Tcl_GetHashValue(hPtr);
+ return (Slave *)Tcl_GetHashValue(hPtr);
}
/*
@@ -392,7 +392,7 @@ CreateSlave(
* populate it with some default values.
*/
- slavePtr = ckalloc(sizeof(Slave));
+ slavePtr = (Slave *)ckalloc(sizeof(Slave));
memset(slavePtr, 0, sizeof(Slave));
slavePtr->tkwin = tkwin;
slavePtr->inTkwin = NULL;
@@ -452,14 +452,14 @@ static Slave *
FindSlave(
Tk_Window tkwin) /* Token for desired slave. */
{
- register Tcl_HashEntry *hPtr;
+ Tcl_HashEntry *hPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
hPtr = Tcl_FindHashEntry(&dispPtr->slaveTable, tkwin);
if (hPtr == NULL) {
return NULL;
}
- return Tcl_GetHashValue(hPtr);
+ return (Slave *)Tcl_GetHashValue(hPtr);
}
/*
@@ -483,8 +483,8 @@ static void
UnlinkSlave(
Slave *slavePtr) /* Slave structure to be unlinked. */
{
- register Master *masterPtr;
- register Slave *prevPtr;
+ Master *masterPtr;
+ Slave *prevPtr;
masterPtr = slavePtr->masterPtr;
if (masterPtr == NULL) {
@@ -532,13 +532,13 @@ CreateMaster(
Tk_Window tkwin) /* Token for desired master. */
{
Tcl_HashEntry *hPtr;
- register Master *masterPtr;
+ Master *masterPtr;
int isNew;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
hPtr = Tcl_CreateHashEntry(&dispPtr->masterTable, (char *) tkwin, &isNew);
if (isNew) {
- masterPtr = ckalloc(sizeof(Master));
+ masterPtr = (Master *)ckalloc(sizeof(Master));
masterPtr->tkwin = tkwin;
masterPtr->slavePtr = NULL;
masterPtr->abortPtr = NULL;
@@ -547,7 +547,7 @@ CreateMaster(
Tk_CreateEventHandler(masterPtr->tkwin, StructureNotifyMask,
MasterStructureProc, masterPtr);
} else {
- masterPtr = Tcl_GetHashValue(hPtr);
+ masterPtr = (Master *)Tcl_GetHashValue(hPtr);
}
return masterPtr;
}
@@ -575,14 +575,14 @@ static Master *
FindMaster(
Tk_Window tkwin) /* Token for desired master. */
{
- register Tcl_HashEntry *hPtr;
+ Tcl_HashEntry *hPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
hPtr = Tcl_FindHashEntry(&dispPtr->masterTable, tkwin);
if (hPtr == NULL) {
return NULL;
}
- return Tcl_GetHashValue(hPtr);
+ return (Master *)Tcl_GetHashValue(hPtr);
}
/*
@@ -612,11 +612,12 @@ ConfigureSlave(
int objc, /* Number of config arguments. */
Tcl_Obj *const objv[]) /* Object values for arguments. */
{
- register Master *masterPtr;
+ Master *masterPtr;
Tk_SavedOptions savedOptions;
int mask;
Slave *slavePtr;
- Tk_Window masterWin = (Tk_Window) NULL;
+ Tk_Window masterWin = NULL;
+ TkWindow *master;
if (Tk_TopWinHierarchy(tkwin)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -694,6 +695,25 @@ ConfigureSlave(
Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
goto error;
}
+
+ /*
+ * Check for management loops.
+ */
+
+ for (master = (TkWindow *)tkwin; master != NULL;
+ master = (TkWindow *)TkGetGeomMaster(master)) {
+ if (master == (TkWindow *)slavePtr->tkwin) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't put %s inside %s, would cause management loop",
+ Tk_PathName(slavePtr->tkwin), Tk_PathName(tkwin)));
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
+ goto error;
+ }
+ }
+ if (tkwin != Tk_Parent(slavePtr->tkwin)) {
+ ((TkWindow *)slavePtr->tkwin)->maintainerPtr = (TkWindow *)tkwin;
+ }
+
if ((slavePtr->masterPtr != NULL)
&& (slavePtr->masterPtr->tkwin == tkwin)) {
/*
@@ -843,8 +863,8 @@ static void
RecomputePlacement(
ClientData clientData) /* Pointer to Master record. */
{
- register Master *masterPtr = clientData;
- register Slave *slavePtr;
+ Master *masterPtr = (Master *)clientData;
+ Slave *slavePtr;
int x, y, width, height, tmp;
int masterWidth, masterHeight, masterX, masterY;
double x1, y1, x2, y2;
@@ -1064,8 +1084,8 @@ MasterStructureProc(
* referred to by eventPtr. */
XEvent *eventPtr) /* Describes what just happened. */
{
- register Master *masterPtr = clientData;
- register Slave *slavePtr, *nextPtr;
+ Master *masterPtr = (Master *)clientData;
+ Slave *slavePtr, *nextPtr;
TkDisplay *dispPtr = ((TkWindow *) masterPtr->tkwin)->dispPtr;
switch (eventPtr->type) {
@@ -1143,7 +1163,7 @@ SlaveStructureProc(
* referred to by eventPtr. */
XEvent *eventPtr) /* Describes what just happened. */
{
- register Slave *slavePtr = clientData;
+ Slave *slavePtr = (Slave *)clientData;
TkDisplay *dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr;
if (eventPtr->type == DestroyNotify) {
@@ -1174,14 +1194,14 @@ SlaveStructureProc(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static void
PlaceRequestProc(
ClientData clientData, /* Pointer to our record for slave. */
Tk_Window tkwin) /* Window that changed its desired size. */
{
- Slave *slavePtr = clientData;
+ Slave *slavePtr = (Slave *)clientData;
Master *masterPtr;
+ (void)tkwin;
if ((slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH))
&& (slavePtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT))) {
@@ -1220,14 +1240,13 @@ PlaceRequestProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
PlaceLostSlaveProc(
ClientData clientData, /* Slave structure for slave window that was
* stolen away. */
Tk_Window tkwin) /* Tk's handle for the slave window. */
{
- register Slave *slavePtr = clientData;
+ Slave *slavePtr = (Slave *)clientData;
TkDisplay *dispPtr = ((TkWindow *) slavePtr->tkwin)->dispPtr;
if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
diff --git a/generic/tkPlatDecls.h b/generic/tkPlatDecls.h
index 1e69c88..db9141c 100644
--- a/generic/tkPlatDecls.h
+++ b/generic/tkPlatDecls.h
@@ -82,6 +82,24 @@ EXTERN void * TkMacOSXGetRootControl(Drawable drawable);
EXTERN void Tk_MacOSXSetupTkNotifier(void);
/* 10 */
EXTERN int Tk_MacOSXIsAppInFront(void);
+/* 11 */
+EXTERN void Tk_MacOSXSetEmbedHandler_(
+ Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr,
+ Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr,
+ Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr,
+ Tk_MacOSXEmbedGetClipProc *getClipProc,
+ Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc);
+/* 12 */
+EXTERN void Tk_MacOSXTurnOffMenus_(void);
+/* 13 */
+EXTERN void Tk_MacOSXTkOwnsCursor_(int tkOwnsIt);
+/* 14 */
+EXTERN void TkMacOSXInitMenus_(Tcl_Interp *interp);
+/* 15 */
+EXTERN void TkMacOSXInitAppleEvents_(Tcl_Interp *interp);
+/* 16 */
+EXTERN void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y,
+ int width, int height, int flags);
#endif /* AQUA */
typedef struct TkPlatStubs {
@@ -108,6 +126,12 @@ typedef struct TkPlatStubs {
void * (*tkMacOSXGetRootControl) (Drawable drawable); /* 8 */
void (*tk_MacOSXSetupTkNotifier) (void); /* 9 */
int (*tk_MacOSXIsAppInFront) (void); /* 10 */
+ void (*tk_MacOSXSetEmbedHandler_) (Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr, Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr, Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr, Tk_MacOSXEmbedGetClipProc *getClipProc, Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc); /* 11 */
+ void (*tk_MacOSXTurnOffMenus_) (void); /* 12 */
+ void (*tk_MacOSXTkOwnsCursor_) (int tkOwnsIt); /* 13 */
+ void (*tkMacOSXInitMenus_) (Tcl_Interp *interp); /* 14 */
+ void (*tkMacOSXInitAppleEvents_) (Tcl_Interp *interp); /* 15 */
+ void (*tkGenWMConfigureEvent_) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 16 */
#endif /* AQUA */
} TkPlatStubs;
@@ -160,12 +184,31 @@ extern const TkPlatStubs *tkPlatStubsPtr;
(tkPlatStubsPtr->tk_MacOSXSetupTkNotifier) /* 9 */
#define Tk_MacOSXIsAppInFront \
(tkPlatStubsPtr->tk_MacOSXIsAppInFront) /* 10 */
+#define Tk_MacOSXSetEmbedHandler_ \
+ (tkPlatStubsPtr->tk_MacOSXSetEmbedHandler_) /* 11 */
+#define Tk_MacOSXTurnOffMenus_ \
+ (tkPlatStubsPtr->tk_MacOSXTurnOffMenus_) /* 12 */
+#define Tk_MacOSXTkOwnsCursor_ \
+ (tkPlatStubsPtr->tk_MacOSXTkOwnsCursor_) /* 13 */
+#define TkMacOSXInitMenus_ \
+ (tkPlatStubsPtr->tkMacOSXInitMenus_) /* 14 */
+#define TkMacOSXInitAppleEvents_ \
+ (tkPlatStubsPtr->tkMacOSXInitAppleEvents_) /* 15 */
+#define TkGenWMConfigureEvent_ \
+ (tkPlatStubsPtr->tkGenWMConfigureEvent_) /* 16 */
#endif /* AQUA */
#endif /* defined(USE_TK_STUBS) */
/* !END!: Do not edit above this line. */
+#undef Tk_MacOSXSetEmbedHandler_
+#undef Tk_MacOSXTurnOffMenus_
+#undef Tk_MacOSXTkOwnsCursor_
+#undef TkMacOSXInitMenus_
+#undef TkMacOSXInitAppleEvents_
+#undef TkGenWMConfigureEvent_
+
#ifdef __cplusplus
}
#endif
diff --git a/generic/tkPointer.c b/generic/tkPointer.c
index 0141b64..ece6281 100644
--- a/generic/tkPointer.c
+++ b/generic/tkPointer.c
@@ -20,22 +20,9 @@
#if defined(MAC_OSX_TK)
#include "tkMacOSXInt.h"
-#define Cursor XCursor
#endif
-/*
- * Mask that selects any of the state bits corresponding to buttons, plus
- * masks that select individual buttons' bits:
- */
-
-#define ALL_BUTTONS \
- (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
-static const unsigned int buttonMasks[] = {
- Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
-};
-#define ButtonMask(b) (buttonMasks[(b)-Button1])
-
-typedef struct ThreadSpecificData {
+typedef struct {
TkWindow *grabWinPtr; /* Window that defines the top of the grab
* tree in a global grab. */
int lastState; /* Last known state flags. */
@@ -138,7 +125,7 @@ GenerateEnterLeave(
int state) /* State flags. */
{
int crossed = 0; /* 1 if mouse crossed a window boundary */
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
TkWindow *restrictWinPtr = tsdPtr->restrictWinPtr;
TkWindow *lastWinPtr = tsdPtr->lastWinPtr;
@@ -231,7 +218,7 @@ Tk_UpdatePointer(
int x, int y, /* Pointer location in root coords. */
int state) /* Modifier state mask. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
TkWindow *winPtr = (TkWindow *)tkwin;
TkWindow *targetWinPtr;
@@ -266,8 +253,8 @@ Tk_UpdatePointer(
* between the current button state and the last known button state.
*/
- for (b = Button1; b <= Button5; b++) {
- mask = ButtonMask(b);
+ for (b = Button1; b <= Button9; b++) {
+ mask = TkGetButtonMask(b);
if (changes & mask) {
if (state & mask) {
type = ButtonPress;
@@ -436,8 +423,15 @@ XGrabPointer(
Cursor cursor,
Time time)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)owner_events;
+ (void)event_mask;
+ (void)pointer_mode;
+ (void)keyboard_mode;
+ (void)confine_to;
+ (void)cursor;
+ (void)time;
display->request++;
tsdPtr->grabWinPtr = (TkWindow *) Tk_IdToWindow(display, grab_window);
@@ -471,8 +465,9 @@ XUngrabPointer(
Display *display,
Time time)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)time;
display->request++;
tsdPtr->grabWinPtr = NULL;
@@ -502,7 +497,7 @@ void
TkPointerDeadWindow(
TkWindow *winPtr)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr == tsdPtr->lastWinPtr) {
@@ -515,7 +510,15 @@ TkPointerDeadWindow(
tsdPtr->restrictWinPtr = NULL;
}
if (!(tsdPtr->restrictWinPtr || tsdPtr->grabWinPtr)) {
- TkpSetCapture(NULL);
+
+ /*
+ * Release mouse capture only if the dead window is the capturing
+ * window.
+ */
+
+ if (winPtr == (TkWindow *)TkpGetCapture()) {
+ TkpSetCapture(NULL);
+ }
}
}
@@ -541,7 +544,7 @@ UpdateCursor(
TkWindow *winPtr)
{
Cursor cursor = None;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -587,8 +590,9 @@ XDefineCursor(
Cursor cursor)
{
TkWindow *winPtr = (TkWindow *) Tk_IdToWindow(display, w);
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)cursor;
if (tsdPtr->cursorWinPtr == winPtr) {
UpdateCursor(winPtr);
@@ -598,47 +602,6 @@ XDefineCursor(
}
/*
- *----------------------------------------------------------------------
- *
- * TkGenerateActivateEvents --
- *
- * This function is called by the Mac and Windows window manager routines
- * when a toplevel window is activated or deactivated.
- * Activate/Deactivate events will be sent to every subwindow of the
- * toplevel followed by a FocusIn/FocusOut message.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Generates X events.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkGenerateActivateEvents(
- TkWindow *winPtr, /* Toplevel to activate. */
- int active) /* Non-zero if the window is being activated,
- * else 0.*/
-{
- XEvent event;
-
- /*
- * Generate Activate and Deactivate events. This event is sent to every
- * subwindow in a toplevel window.
- */
-
- event.xany.serial = winPtr->display->request++;
- event.xany.send_event = False;
- event.xany.display = winPtr->display;
- event.xany.window = winPtr->window;
-
- event.xany.type = active ? ActivateNotify : DeactivateNotify;
- TkQueueEventForAllChildren(winPtr, &event);
-}
-
-/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c
index 359d3ef..a820411 100644
--- a/generic/tkRectOval.c
+++ b/generic/tkRectOval.c
@@ -12,6 +12,7 @@
#include "tkInt.h"
#include "tkCanvas.h"
+#include "default.h"
/*
* The structure below defines the record for each rectangle/oval item.
@@ -60,62 +61,62 @@ static const Tk_CustomOption pixelOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_CUSTOM, "-activedash", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.activeDash),
+ NULL, offsetof(RectOvalItem, outline.activeDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-activeoutline", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activeoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.activeStipple),
+ NULL, offsetof(RectOvalItem, outline.activeStipple),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-activewidth", NULL, NULL,
- "0.0", Tk_Offset(RectOvalItem, outline.activeWidth),
+ "0.0", offsetof(RectOvalItem, outline.activeWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_CUSTOM, "-dash", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.dash),
+ NULL, offsetof(RectOvalItem, outline.dash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_PIXELS, "-dashoffset", NULL, NULL,
- "0", Tk_Offset(RectOvalItem, outline.offset),
+ "0", offsetof(RectOvalItem, outline.offset),
TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-disableddash", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.disabledDash),
+ NULL, offsetof(RectOvalItem, outline.disabledDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-disabledfill", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-disabledoutline", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.disabledColor),
+ NULL, offsetof(RectOvalItem, outline.disabledColor),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.disabledStipple),
+ NULL, offsetof(RectOvalItem, outline.disabledStipple),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-disabledwidth", NULL, NULL,
- "0.0", Tk_Offset(RectOvalItem, outline.disabledWidth),
+ "0.0", offsetof(RectOvalItem, outline.disabledWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, fillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, fillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-offset", NULL, NULL,
- "0,0", Tk_Offset(RectOvalItem, tsoffset),
+ "0,0", offsetof(RectOvalItem, tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_COLOR, "-outline", NULL, NULL,
- "black", Tk_Offset(RectOvalItem, outline.color), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVITEM_OUTLINE, offsetof(RectOvalItem, outline.color), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-outlineoffset", NULL, NULL,
- "0,0", Tk_Offset(RectOvalItem, outline.tsoffset),
+ "0,0", offsetof(RectOvalItem, outline.tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_BITMAP, "-outlinestipple", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state),TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state),TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_BITMAP, "-stipple", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, fillStipple),TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, fillStipple),TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_CUSTOM, "-width", NULL, NULL,
- "1.0", Tk_Offset(RectOvalItem, outline.width),
+ "1.0", offsetof(RectOvalItem, outline.width),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -148,6 +149,8 @@ static int RectToArea(Tk_Canvas canvas, Tk_Item *itemPtr,
double *areaPtr);
static double RectToPoint(Tk_Canvas canvas, Tk_Item *itemPtr,
double *pointPtr);
+static void RotateRectOval(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleRectOval(Tk_Canvas canvas, Tk_Item *itemPtr,
double originX, double originY,
double scaleX, double scaleY);
@@ -180,7 +183,8 @@ Tk_ItemType tkRectangleType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateRectOval, /* rotateProc */
+ 0, NULL, NULL
};
Tk_ItemType tkOvalType = {
@@ -204,7 +208,8 @@ Tk_ItemType tkOvalType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateRectOval, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -574,6 +579,7 @@ DeleteRectOval(
Display *display) /* Display containing window for canvas. */
{
RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
+ (void)canvas;
Tk_DeleteOutline(display, &(rectOvalPtr->outline));
if (rectOvalPtr->fillColor != NULL) {
@@ -616,7 +622,6 @@ DeleteRectOval(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
ComputeRectOvalBbox(
Tk_Canvas canvas, /* Canvas that contains item. */
@@ -747,6 +752,10 @@ DisplayRectOval(
short x1, y1, x2, y2;
Pixmap fillStipple;
Tk_State state = itemPtr->state;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
/*
* Compute the screen coordinates of the bounding box for the item. Make
@@ -956,7 +965,6 @@ DisplayRectOval(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static double
RectToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1076,7 +1084,6 @@ RectToPoint(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static double
OvalToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1131,7 +1138,6 @@ OvalToPoint(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
RectToArea(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1205,7 +1211,6 @@ RectToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
OvalToArea(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1285,6 +1290,57 @@ OvalToArea(
/*
*--------------------------------------------------------------
*
+ * RotateRectOval --
+ *
+ * This function is invoked to rotate a rectangle or oval item's
+ * coordinates. It works by rotating a computed point in the centre of
+ * the bounding box, NOT by rotating the corners of the bounding box.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the rectangle or oval is rotated by angleRad about
+ * (originX, originY), and the bounding box is updated in the generic
+ * part of the item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateRectOval(
+ Tk_Canvas canvas, /* Canvas containing rectangle. */
+ Tk_Item *itemPtr, /* Rectangle to be scaled. */
+ double originX, double originY,
+ /* Origin about which to rotate rect. */
+ double angleRad) /* Amount to scale in X direction. */
+{
+ RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
+ double newX, newY, oldX, oldY;
+
+ /*
+ * Compute the centre of the box, then rotate that about the origin.
+ */
+
+ newX = oldX = (rectOvalPtr->bbox[0] + rectOvalPtr->bbox[2]) / 2.0;
+ newY = oldY = (rectOvalPtr->bbox[1] + rectOvalPtr->bbox[3]) / 2.0;
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &newX, &newY);
+
+ /*
+ * Apply the translation to the box.
+ */
+
+ rectOvalPtr->bbox[0] += newX - oldX;
+ rectOvalPtr->bbox[1] += newY - oldY;
+ rectOvalPtr->bbox[2] += newX - oldX;
+ rectOvalPtr->bbox[3] += newY - oldY;
+ ComputeRectOvalBbox(canvas, rectOvalPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ScaleRectOval --
*
* This function is invoked to rescale a rectangle or oval item.
@@ -1390,6 +1446,7 @@ RectOvalToPostscript(
Pixmap fillStipple;
Tk_State state = itemPtr->state;
Tcl_InterpState interpState;
+ (void)prepass;
y1 = Tk_CanvasPsY(canvas, rectOvalPtr->bbox[1]);
y2 = Tk_CanvasPsY(canvas, rectOvalPtr->bbox[3]);
@@ -1464,18 +1521,14 @@ RectOvalToPostscript(
Tcl_AppendObjToObj(psObj, pathObj);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fillColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (fillStipple != None) {
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, fillStipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (color != NULL) {
Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
@@ -1494,10 +1547,7 @@ RectOvalToPostscript(
Tcl_AppendToObj(psObj, "0 setlinejoin 2 setlinecap\n", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsOutline(canvas, itemPtr,
- &rectOvalPtr->outline)!= TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsOutline(canvas, itemPtr, &rectOvalPtr->outline);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
}
@@ -1510,12 +1560,6 @@ RectOvalToPostscript(
Tcl_DecrRefCount(psObj);
Tcl_DecrRefCount(pathObj);
return TCL_OK;
-
- error:
- Tcl_DiscardInterpState(interpState);
- Tcl_DecrRefCount(psObj);
- Tcl_DecrRefCount(pathObj);
- return TCL_ERROR;
}
/*
diff --git a/generic/tkScale.c b/generic/tkScale.c
index 216fd02..affea94 100644
--- a/generic/tkScale.c
+++ b/generic/tkScale.c
@@ -45,97 +45,97 @@ static const char *const stateStrings[] = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCALE_ACTIVE_BG_COLOR, -1, Tk_Offset(TkScale, activeBorder),
+ DEF_SCALE_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, activeBorder),
0, DEF_SCALE_ACTIVE_BG_MONO, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_SCALE_BG_COLOR, -1, Tk_Offset(TkScale, bgBorder),
+ DEF_SCALE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, bgBorder),
0, DEF_SCALE_BG_MONO, 0},
{TK_OPTION_DOUBLE, "-bigincrement", "bigIncrement", "BigIncrement",
- DEF_SCALE_BIG_INCREMENT, -1, Tk_Offset(TkScale, bigIncrement),
+ DEF_SCALE_BIG_INCREMENT, TCL_INDEX_NONE, offsetof(TkScale, bigIncrement),
0, 0, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_SCALE_BORDER_WIDTH, -1, Tk_Offset(TkScale, borderWidth),
+ DEF_SCALE_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(TkScale, borderWidth),
0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_SCALE_COMMAND, -1, Tk_Offset(TkScale, command),
+ DEF_SCALE_COMMAND, TCL_INDEX_NONE, offsetof(TkScale, command),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_SCALE_CURSOR, -1, Tk_Offset(TkScale, cursor),
+ DEF_SCALE_CURSOR, TCL_INDEX_NONE, offsetof(TkScale, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-digits", "digits", "Digits",
- DEF_SCALE_DIGITS, -1, Tk_Offset(TkScale, digits),
+ DEF_SCALE_DIGITS, TCL_INDEX_NONE, offsetof(TkScale, digits),
0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_SCALE_FONT, -1, Tk_Offset(TkScale, tkfont), 0, 0, 0},
+ DEF_SCALE_FONT, TCL_INDEX_NONE, offsetof(TkScale, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_SCALE_FG_COLOR, -1, Tk_Offset(TkScale, textColorPtr), 0,
+ DEF_SCALE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, textColorPtr), 0,
(ClientData) DEF_SCALE_FG_MONO, 0},
- {TK_OPTION_DOUBLE, "-from", "from", "From", DEF_SCALE_FROM, -1,
- Tk_Offset(TkScale, fromValue), 0, 0, 0},
+ {TK_OPTION_DOUBLE, "-from", "from", "From", DEF_SCALE_FROM, TCL_INDEX_NONE,
+ offsetof(TkScale, fromValue), 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_SCALE_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkScale, highlightBorder),
+ TCL_INDEX_NONE, offsetof(TkScale, highlightBorder),
0, DEF_SCALE_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_SCALE_HIGHLIGHT, -1, Tk_Offset(TkScale, highlightColorPtr),
+ DEF_SCALE_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkScale, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_SCALE_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(TkScale, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_SCALE_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(TkScale, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-label", "label", "Label",
- DEF_SCALE_LABEL, -1, Tk_Offset(TkScale, label),
+ DEF_SCALE_LABEL, TCL_INDEX_NONE, offsetof(TkScale, label),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-length", "length", "Length",
- DEF_SCALE_LENGTH, -1, Tk_Offset(TkScale, length), 0, 0, 0},
+ DEF_SCALE_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, length), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
- DEF_SCALE_ORIENT, -1, Tk_Offset(TkScale, orient),
+ DEF_SCALE_ORIENT, TCL_INDEX_NONE, offsetof(TkScale, orient),
0, orientStrings, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_SCALE_RELIEF, -1, Tk_Offset(TkScale, relief), 0, 0, 0},
+ DEF_SCALE_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, relief), 0, 0, 0},
{TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_SCALE_REPEAT_DELAY, -1, Tk_Offset(TkScale, repeatDelay),
+ DEF_SCALE_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(TkScale, repeatDelay),
0, 0, 0},
{TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_SCALE_REPEAT_INTERVAL, -1, Tk_Offset(TkScale, repeatInterval),
+ DEF_SCALE_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(TkScale, repeatInterval),
0, 0, 0},
{TK_OPTION_DOUBLE, "-resolution", "resolution", "Resolution",
- DEF_SCALE_RESOLUTION, -1, Tk_Offset(TkScale, resolution),
+ DEF_SCALE_RESOLUTION, TCL_INDEX_NONE, offsetof(TkScale, resolution),
0, 0, 0},
{TK_OPTION_BOOLEAN, "-showvalue", "showValue", "ShowValue",
- DEF_SCALE_SHOW_VALUE, -1, Tk_Offset(TkScale, showValue),
+ DEF_SCALE_SHOW_VALUE, TCL_INDEX_NONE, offsetof(TkScale, showValue),
0, 0, 0},
{TK_OPTION_PIXELS, "-sliderlength", "sliderLength", "SliderLength",
- DEF_SCALE_SLIDER_LENGTH, -1, Tk_Offset(TkScale, sliderLength),
+ DEF_SCALE_SLIDER_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, sliderLength),
0, 0, 0},
{TK_OPTION_RELIEF, "-sliderrelief", "sliderRelief", "SliderRelief",
- DEF_SCALE_SLIDER_RELIEF, -1, Tk_Offset(TkScale, sliderRelief),
+ DEF_SCALE_SLIDER_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, sliderRelief),
0, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_SCALE_STATE, -1, Tk_Offset(TkScale, state),
+ DEF_SCALE_STATE, TCL_INDEX_NONE, offsetof(TkScale, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_SCALE_TAKE_FOCUS, Tk_Offset(TkScale, takeFocusPtr), -1,
+ DEF_SCALE_TAKE_FOCUS, offsetof(TkScale, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_DOUBLE, "-tickinterval", "tickInterval", "TickInterval",
- DEF_SCALE_TICK_INTERVAL, -1, Tk_Offset(TkScale, tickInterval),
+ DEF_SCALE_TICK_INTERVAL, TCL_INDEX_NONE, offsetof(TkScale, tickInterval),
0, 0, 0},
{TK_OPTION_DOUBLE, "-to", "to", "To",
- DEF_SCALE_TO, -1, Tk_Offset(TkScale, toValue), 0, 0, 0},
+ DEF_SCALE_TO, TCL_INDEX_NONE, offsetof(TkScale, toValue), 0, 0, 0},
{TK_OPTION_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCALE_TROUGH_COLOR, -1, Tk_Offset(TkScale, troughColorPtr),
+ DEF_SCALE_TROUGH_COLOR, TCL_INDEX_NONE, offsetof(TkScale, troughColorPtr),
0, DEF_SCALE_TROUGH_MONO, 0},
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- DEF_SCALE_VARIABLE, Tk_Offset(TkScale, varNamePtr), -1,
+ DEF_SCALE_VARIABLE, offsetof(TkScale, varNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_SCALE_WIDTH, -1, Tk_Offset(TkScale, width), 0, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ DEF_SCALE_WIDTH, TCL_INDEX_NONE, offsetof(TkScale, width), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -157,11 +157,13 @@ enum command {
* Forward declarations for procedures defined later in this file:
*/
-static void ComputeFormat(TkScale *scalePtr);
+static void ComputeFormat(TkScale *scalePtr, int forTicks);
static void ComputeScaleGeometry(TkScale *scalePtr);
static int ConfigureScale(Tcl_Interp *interp, TkScale *scalePtr,
int objc, Tcl_Obj *const objv[]);
-static void DestroyScale(char *memPtr);
+static void DestroyScale(void *memPtr);
+static double MaxTickRoundingError(TkScale *scalePtr,
+ double tickResolution);
static void ScaleCmdDeletedProc(ClientData clientData);
static void ScaleEventProc(ClientData clientData,
XEvent *eventPtr);
@@ -182,13 +184,54 @@ static void ScaleSetVariable(TkScale *scalePtr);
static const Tk_ClassProcs scaleClass = {
sizeof(Tk_ClassProcs), /* size */
ScaleWorldChanged, /* worldChangedProc */
- NULL, /* createProc */
- NULL /* modalProc */
+ NULL, /* createProc */
+ NULL /* modalProc */
};
/*
*--------------------------------------------------------------
*
+ * ScaleDigit, ScaleMax, ScaleMin, ScaleRound --
+ *
+ * Simple math helper functions, designed to be automatically inlined by
+ * the compiler most of the time.
+ *
+ *--------------------------------------------------------------
+ */
+
+static inline int
+ScaleDigit(
+ double value)
+{
+ return (int) floor(log10(fabs(value)));
+}
+
+static inline double
+ScaleMax(
+ double a,
+ double b)
+{
+ return (a > b) ? a : b;
+}
+
+static inline double
+ScaleMin(
+ double a,
+ double b)
+{
+ return (a < b) ? a : b;
+}
+
+static inline int
+ScaleRound(
+ double value)
+{
+ return (int) floor(value + 0.5);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* Tk_ScaleObjCmd --
*
* This procedure is invoked to process the "scale" Tcl command. See the
@@ -205,14 +248,15 @@ static const Tk_ClassProcs scaleClass = {
int
Tk_ScaleObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
- register TkScale *scalePtr;
+ TkScale *scalePtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -342,7 +386,7 @@ ScaleWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
Tcl_Obj *objPtr;
int index, result;
@@ -408,8 +452,8 @@ ScaleWidgetObjCmd(
y = scalePtr->horizTroughY + scalePtr->width/2
+ scalePtr->borderWidth;
}
- coords[0] = Tcl_NewIntObj(x);
- coords[1] = Tcl_NewIntObj(y);
+ coords[0] = Tcl_NewWideIntObj(x);
+ coords[1] = Tcl_NewWideIntObj(y);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords));
break;
}
@@ -430,7 +474,7 @@ ScaleWidgetObjCmd(
}
value = TkScalePixelToValue(scalePtr, x, y);
}
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(scalePtr->format, value));
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(scalePtr->valueFormat, value));
break;
}
case COMMAND_IDENTIFY: {
@@ -497,9 +541,9 @@ ScaleWidgetObjCmd(
static void
DestroyScale(
- char *memPtr) /* Info about scale widget. */
+ void *memPtr) /* Info about scale widget. */
{
- register TkScale *scalePtr = (TkScale *) memPtr;
+ TkScale *scalePtr = (TkScale *) memPtr;
scalePtr->flags |= SCALE_DELETED;
@@ -556,7 +600,7 @@ DestroyScale(
static int
ConfigureScale(
Tcl_Interp *interp, /* Used for error reporting. */
- register TkScale *scalePtr, /* Information about widget; may or may not
+ TkScale *scalePtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in objv. */
Tcl_Obj *const objv[]) /* Argument values. */
@@ -636,7 +680,8 @@ ConfigureScale(
scalePtr->tickInterval = -scalePtr->tickInterval;
}
- ComputeFormat(scalePtr);
+ ComputeFormat(scalePtr, 0);
+ ComputeFormat(scalePtr, 1);
scalePtr->labelLength = scalePtr->label ? strlen(scalePtr->label) : 0;
@@ -725,7 +770,7 @@ ScaleWorldChanged(
{
XGCValues gcValues;
GC gc;
- TkScale *scalePtr = instanceData;
+ TkScale *scalePtr = (TkScale *)instanceData;
gcValues.foreground = scalePtr->troughColorPtr->pixel;
gc = Tk_GetGC(scalePtr->tkwin, GCForeground, &gcValues);
@@ -759,27 +804,77 @@ ScaleWorldChanged(
TkEventuallyRedrawScale(scalePtr, REDRAW_ALL);
}
+ /*
+ *----------------------------------------------------------------------
+ *
+ * MaxTickRoundingError --
+ *
+ * Given the separation between values that can be displayed on ticks,
+ * this calculates the maximum magnitude of error for the displayed
+ * value. Tries to be clever by working out the increment in error
+ * between ticks rather than testing all of them, so may overestimate
+ * error if it is greater than 0.25 x the value separation.
+ *
+ * Results:
+ * Maximum error magnitude of tick numbers.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static double
+MaxTickRoundingError(
+ TkScale *scalePtr, /* Information about scale widget. */
+ double tickResolution) /* Separation between displayable values. */
+{
+ double tickPosn, firstTickError, lastTickError, intervalError;
+ int tickCount;
+
+ /*
+ * Compute the error for each tick-related measure.
+ */
+
+ tickPosn = scalePtr->fromValue / tickResolution;
+ firstTickError = tickPosn - ScaleRound(tickPosn);
+
+ tickPosn = scalePtr->tickInterval / tickResolution;
+ intervalError = tickPosn - ScaleRound(tickPosn);
+
+ tickCount = (int) ((scalePtr->toValue - scalePtr->fromValue) /
+ scalePtr->tickInterval); /* not including first */
+ lastTickError = ScaleMin(0.5,
+ fabs(firstTickError + tickCount * intervalError));
+
+ /*
+ * Compute the maximum cumulative rounding error.
+ */
+
+ return ScaleMax(fabs(firstTickError), lastTickError) * tickResolution;
+}
+
/*
*----------------------------------------------------------------------
*
* ComputeFormat --
*
- * This procedure is invoked to recompute the "format" field of a scale's
- * widget record, which determines how the value of the scale is
- * converted to a string.
+ * This procedure is invoked to recompute the "valueFormat" or
+ * "tickFormat" field of a scale's widget record, which determines how
+ * the value of the scale or one of its ticks is converted to a string.
*
* Results:
* None.
*
- * Side effects:
- * The format field of scalePtr is modified.
+ * Side effects: The valueFormat or tickFormat field of scalePtr is modified.
*
*----------------------------------------------------------------------
*/
static void
ComputeFormat(
- TkScale *scalePtr) /* Information about scale widget. */
+ TkScale *scalePtr, /* Information about scale widget. */
+ int forTicks) /* Do for ticks rather than value */
{
double maxValue, x;
int mostSigDigit, numDigits, leastSigDigit, afterDecimal;
@@ -798,48 +893,73 @@ ComputeFormat(
if (maxValue == 0) {
maxValue = 1;
}
- mostSigDigit = (int) floor(log10(maxValue));
+ mostSigDigit = ScaleDigit(maxValue);
- /*
- * If the number of significant digits wasn't specified explicitly,
- * compute it. It's the difference between the most significant digit
- * needed to represent any number on the scale and the most significant
- * digit of the smallest difference between numbers on the scale. In other
- * words, display enough digits so that at least one digit will be
- * different between any two adjacent positions of the scale.
- */
+ if (forTicks) {
+ /*
+ * Display only enough digits to ensure adjacent ticks have different
+ * values.
+ */
- numDigits = scalePtr->digits;
- if (numDigits > TCL_MAX_PREC) {
- numDigits = 0;
- }
- if (numDigits <= 0) {
- if (scalePtr->resolution > 0) {
- /*
- * A resolution was specified for the scale, so just use it.
- */
+ if (scalePtr->tickInterval != 0) {
+ leastSigDigit = ScaleDigit(scalePtr->tickInterval);
- leastSigDigit = (int) floor(log10(scalePtr->resolution));
- } else {
/*
- * No resolution was specified, so compute the difference in value
- * between adjacent pixels and use it for the least significant
- * digit.
+ * Now add more digits until max error is less than
+ * TICK_VALUES_DISPLAY_ACCURACY intervals
*/
- x = fabs(scalePtr->fromValue - scalePtr->toValue);
- if (scalePtr->length > 0) {
- x /= scalePtr->length;
+ while (MaxTickRoundingError(scalePtr, pow(10, leastSigDigit))
+ > fabs(TICK_VALUES_DISPLAY_ACCURACY * scalePtr->tickInterval)) {
+ --leastSigDigit;
}
- if (x > 0){
- leastSigDigit = (int) floor(log10(x));
+ numDigits = 1 + mostSigDigit - leastSigDigit;
+ } else {
+ numDigits = 1;
+ }
+ } else {
+ /*
+ * If the number of significant digits wasn't specified explicitly,
+ * compute it. It's the difference between the most significant digit
+ * needed to represent any number on the scale and the most
+ * significant digit of the smallest difference between numbers on the
+ * scale. In other words, display enough digits so that at least one
+ * digit will be different between any two adjacent positions of the
+ * scale.
+ */
+
+ numDigits = scalePtr->digits;
+ if (numDigits > TCL_MAX_PREC) {
+ numDigits = 0;
+ }
+ if (numDigits <= 0) {
+ if (scalePtr->resolution > 0) {
+ /*
+ * A resolution was specified for the scale, so just use it.
+ */
+
+ leastSigDigit = ScaleDigit(scalePtr->resolution);
} else {
- leastSigDigit = 0;
+ /*
+ * No resolution was specified, so compute the difference in
+ * value between adjacent pixels and use it for the least
+ * significant digit.
+ */
+
+ x = fabs(scalePtr->fromValue - scalePtr->toValue);
+ if (scalePtr->length > 0) {
+ x /= scalePtr->length;
+ }
+ if (x > 0) {
+ leastSigDigit = ScaleDigit(x);
+ } else {
+ leastSigDigit = 0;
+ }
+ }
+ numDigits = mostSigDigit - leastSigDigit + 1;
+ if (numDigits < 1) {
+ numDigits = 1;
}
- }
- numDigits = mostSigDigit - leastSigDigit + 1;
- if (numDigits < 1) {
- numDigits = 1;
}
}
@@ -863,10 +983,19 @@ ComputeFormat(
if (mostSigDigit < 0) {
fDigits++; /* Zero to left of decimal point. */
}
- if (fDigits <= eDigits) {
- sprintf(scalePtr->format, "%%.%df", afterDecimal);
+
+ if (forTicks) {
+ if (fDigits <= eDigits) {
+ sprintf(scalePtr->tickFormat, "%%.%df", afterDecimal);
+ } else {
+ sprintf(scalePtr->tickFormat, "%%.%de", numDigits - 1);
+ }
} else {
- sprintf(scalePtr->format, "%%.%de", numDigits-1);
+ if (fDigits <= eDigits) {
+ sprintf(scalePtr->valueFormat, "%%.%df", afterDecimal);
+ } else {
+ sprintf(scalePtr->valueFormat, "%%.%de", numDigits - 1);
+ }
}
}
@@ -891,10 +1020,10 @@ ComputeFormat(
static void
ComputeScaleGeometry(
- register TkScale *scalePtr) /* Information about widget. */
+ TkScale *scalePtr) /* Information about widget. */
{
char valueString[TCL_DOUBLE_SPACE];
- int tmp, valuePixels, x, y, extraSpace;
+ int tmp, valuePixels, tickPixels, x, y, extraSpace;
Tk_FontMetrics fm;
Tk_GetFontMetrics(scalePtr->tkfont, &fm);
@@ -940,13 +1069,13 @@ ComputeScaleGeometry(
* whichever length is longer.
*/
- if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->format,
+ if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->valueFormat,
scalePtr->fromValue) < 0) {
valueString[TCL_DOUBLE_SPACE - 1] = '\0';
}
valuePixels = Tk_TextWidth(scalePtr->tkfont, valueString, -1);
- if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->format,
+ if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->valueFormat,
scalePtr->toValue) < 0) {
valueString[TCL_DOUBLE_SPACE - 1] = '\0';
}
@@ -956,18 +1085,37 @@ ComputeScaleGeometry(
}
/*
+ * Now do the same thing for the tick values
+ */
+
+ if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->tickFormat,
+ scalePtr->fromValue) < 0) {
+ valueString[TCL_DOUBLE_SPACE - 1] = '\0';
+ }
+ tickPixels = Tk_TextWidth(scalePtr->tkfont, valueString, -1);
+
+ if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->tickFormat,
+ scalePtr->toValue) < 0) {
+ valueString[TCL_DOUBLE_SPACE - 1] = '\0';
+ }
+ tmp = Tk_TextWidth(scalePtr->tkfont, valueString, -1);
+ if (tickPixels < tmp) {
+ tickPixels = tmp;
+ }
+
+ /*
* Assign x-locations to the elements of the scale, working from left to
* right.
*/
x = scalePtr->inset;
if ((scalePtr->tickInterval != 0) && (scalePtr->showValue)) {
- scalePtr->vertTickRightX = x + SPACING + valuePixels;
+ scalePtr->vertTickRightX = x + SPACING + tickPixels;
scalePtr->vertValueRightX = scalePtr->vertTickRightX + valuePixels
+ fm.ascent/2;
x = scalePtr->vertValueRightX + SPACING;
} else if (scalePtr->tickInterval != 0) {
- scalePtr->vertTickRightX = x + SPACING + valuePixels;
+ scalePtr->vertTickRightX = x + SPACING + tickPixels;
scalePtr->vertValueRightX = scalePtr->vertTickRightX;
x = scalePtr->vertTickRightX + SPACING;
} else if (scalePtr->showValue) {
@@ -1016,7 +1164,7 @@ ScaleEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
TkEventuallyRedrawScale(scalePtr, REDRAW_ALL);
@@ -1064,7 +1212,7 @@ static void
ScaleCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
Tk_Window tkwin = scalePtr->tkwin;
/*
@@ -1101,7 +1249,7 @@ ScaleCmdDeletedProc(
void
TkEventuallyRedrawScale(
- register TkScale *scalePtr, /* Information about widget. */
+ TkScale *scalePtr, /* Information about widget. */
int what) /* What to redraw: REDRAW_SLIDER or
* REDRAW_ALL. */
{
@@ -1190,7 +1338,6 @@ TkRoundIntervalToResolution(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
ScaleVarProc(
ClientData clientData, /* Information about button. */
@@ -1199,24 +1346,13 @@ ScaleVarProc(
const char *name2, /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- register TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
const char *resultStr;
double value;
Tcl_Obj *valuePtr;
int result;
-
- /*
- * See ticket [5d991b82].
- */
-
- if (scalePtr->varNamePtr == NULL) {
- if (!(flags & TCL_INTERP_DESTROYED)) {
- Tcl_UntraceVar2(interp, name1, name2,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ScaleVarProc, clientData);
- }
- return NULL;
- }
+ (void)name1;
+ (void)name2;
/*
* If the variable is unset, then immediately recreate it unless the whole
@@ -1224,7 +1360,27 @@ ScaleVarProc(
*/
if (flags & TCL_TRACE_UNSETS) {
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
+ if (!Tcl_InterpDeleted(interp) && scalePtr->varNamePtr) {
+ ClientData probe = NULL;
+
+ do {
+ probe = Tcl_VarTraceInfo(interp,
+ Tcl_GetString(scalePtr->varNamePtr),
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ ScaleVarProc, probe);
+ if (probe == (ClientData)scalePtr) {
+ break;
+ }
+ } while (probe);
+ if (probe) {
+ /*
+ * We were able to fetch the unset trace for our
+ * varNamePtr, which means it is not unset and not
+ * the cause of this unset trace. Instead some outdated
+ * former variable must be, and we should ignore it.
+ */
+ return NULL;
+ }
Tcl_TraceVar2(interp, Tcl_GetString(scalePtr->varNamePtr),
NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
ScaleVarProc, clientData);
@@ -1287,7 +1443,7 @@ ScaleVarProc(
void
TkScaleSetValue(
- register TkScale *scalePtr, /* Info about widget. */
+ TkScale *scalePtr, /* Info about widget. */
double value, /* New value for scale. Gets adjusted if it's
* off the scale. */
int setVar, /* Non-zero means reflect new value through to
@@ -1345,12 +1501,12 @@ TkScaleSetValue(
static void
ScaleSetVariable(
- register TkScale *scalePtr) /* Info about widget. */
+ TkScale *scalePtr) /* Info about widget. */
{
if (scalePtr->varNamePtr != NULL) {
char string[TCL_DOUBLE_SPACE];
- if (snprintf(string, TCL_DOUBLE_SPACE, scalePtr->format,
+ if (snprintf(string, TCL_DOUBLE_SPACE, scalePtr->valueFormat,
scalePtr->value) < 0) {
string[TCL_DOUBLE_SPACE - 1] = '\0';
}
@@ -1381,7 +1537,7 @@ ScaleSetVariable(
double
TkScalePixelToValue(
- register TkScale *scalePtr, /* Information about widget. */
+ TkScale *scalePtr, /* Information about widget. */
int x, int y) /* Coordinates of point within window. */
{
double value, pixelRange;
@@ -1439,7 +1595,7 @@ TkScalePixelToValue(
int
TkScaleValueToPixel(
- register TkScale *scalePtr, /* Information about widget. */
+ TkScale *scalePtr, /* Information about widget. */
double value) /* Reading of the widget. */
{
int y, pixelRange;
@@ -1452,8 +1608,8 @@ TkScaleValueToPixel(
if (valueRange == 0) {
y = 0;
} else {
- y = (int) ((value - scalePtr->fromValue) * pixelRange
- / valueRange + 0.5);
+ y = ScaleRound((value - scalePtr->fromValue) * pixelRange
+ / valueRange);
if (y < 0) {
y = 0;
} else if (y > pixelRange) {
diff --git a/generic/tkScale.h b/generic/tkScale.h
index 296620d..4e4a3e7 100644
--- a/generic/tkScale.h
+++ b/generic/tkScale.h
@@ -73,8 +73,10 @@ typedef struct TkScale {
* values. 0 means we get to choose the number
* based on resolution and/or the range of the
* scale. */
- char format[16]; /* Sprintf conversion specifier computed from
+ char valueFormat[16]; /* Sprintf conversion specifier computed from
* digits and other information. */
+ char tickFormat[16]; /* Sprintf conversion specifier computed from
+ * tick interval. */
double bigIncrement; /* Amount to use for large increments to scale
* value. (0 means we pick a value). */
char *command; /* Command prefix to use when invoking Tcl
@@ -215,6 +217,14 @@ typedef struct TkScale {
#define SPACING 2
/*
+ * The tick values are all displayed with the same number of decimal places.
+ * This number of decimal places is such that the displayed values are all
+ * accurate to within the following proportion of a tick interval.
+ */
+
+#define TICK_VALUES_DISPLAY_ACCURACY 0.2
+
+/*
* Declaration of procedures used in the implementation of the scale widget.
*/
diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c
index 030767b..600c7d7 100644
--- a/generic/tkScrollbar.c
+++ b/generic/tkScrollbar.c
@@ -33,62 +33,62 @@ char tkDefScrollbarWidth[TCL_INTEGER_SPACE] = DEF_SCROLLBAR_WIDTH;
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCROLLBAR_ACTIVE_BG_COLOR, Tk_Offset(TkScrollbar, activeBorder),
+ DEF_SCROLLBAR_ACTIVE_BG_COLOR, offsetof(TkScrollbar, activeBorder),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCROLLBAR_ACTIVE_BG_MONO, Tk_Offset(TkScrollbar, activeBorder),
+ DEF_SCROLLBAR_ACTIVE_BG_MONO, offsetof(TkScrollbar, activeBorder),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_RELIEF, "-activerelief", "activeRelief", "Relief",
- DEF_SCROLLBAR_ACTIVE_RELIEF, Tk_Offset(TkScrollbar, activeRelief), 0, NULL},
+ DEF_SCROLLBAR_ACTIVE_RELIEF, offsetof(TkScrollbar, activeRelief), 0, NULL},
{TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_SCROLLBAR_BG_COLOR, Tk_Offset(TkScrollbar, bgBorder),
+ DEF_SCROLLBAR_BG_COLOR, offsetof(TkScrollbar, bgBorder),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_SCROLLBAR_BG_MONO, Tk_Offset(TkScrollbar, bgBorder),
+ DEF_SCROLLBAR_BG_MONO, offsetof(TkScrollbar, bgBorder),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_SYNONYM, "-bd", "borderWidth", NULL, NULL, 0, 0, NULL},
{TK_CONFIG_SYNONYM, "-bg", "background", NULL, NULL, 0, 0, NULL},
{TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_SCROLLBAR_BORDER_WIDTH, Tk_Offset(TkScrollbar, borderWidth), 0, NULL},
+ DEF_SCROLLBAR_BORDER_WIDTH, offsetof(TkScrollbar, borderWidth), 0, NULL},
{TK_CONFIG_STRING, "-command", "command", "Command",
- DEF_SCROLLBAR_COMMAND, Tk_Offset(TkScrollbar, command),
+ DEF_SCROLLBAR_COMMAND, offsetof(TkScrollbar, command),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_SCROLLBAR_CURSOR, Tk_Offset(TkScrollbar, cursor), TK_CONFIG_NULL_OK, NULL},
+ DEF_SCROLLBAR_CURSOR, offsetof(TkScrollbar, cursor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-elementborderwidth", "elementBorderWidth",
"BorderWidth", DEF_SCROLLBAR_EL_BORDER_WIDTH,
- Tk_Offset(TkScrollbar, elementBorderWidth), 0, NULL},
+ offsetof(TkScrollbar, elementBorderWidth), 0, NULL},
{TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_SCROLLBAR_HIGHLIGHT_BG,
- Tk_Offset(TkScrollbar, highlightBgColorPtr), 0, NULL},
+ offsetof(TkScrollbar, highlightBgColorPtr), 0, NULL},
{TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
DEF_SCROLLBAR_HIGHLIGHT,
- Tk_Offset(TkScrollbar, highlightColorPtr), 0, NULL},
+ offsetof(TkScrollbar, highlightColorPtr), 0, NULL},
{TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness",
- DEF_SCROLLBAR_HIGHLIGHT_WIDTH, Tk_Offset(TkScrollbar, highlightWidth), 0, NULL},
+ DEF_SCROLLBAR_HIGHLIGHT_WIDTH, offsetof(TkScrollbar, highlightWidth), 0, NULL},
{TK_CONFIG_BOOLEAN, "-jump", "jump", "Jump",
- DEF_SCROLLBAR_JUMP, Tk_Offset(TkScrollbar, jump), 0, NULL},
+ DEF_SCROLLBAR_JUMP, offsetof(TkScrollbar, jump), 0, NULL},
{TK_CONFIG_CUSTOM, "-orient", "orient", "Orient",
- DEF_SCROLLBAR_ORIENT, Tk_Offset(TkScrollbar, vertical), 0,
+ DEF_SCROLLBAR_ORIENT, offsetof(TkScrollbar, vertical), 0,
&orientOption},
{TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_SCROLLBAR_RELIEF, Tk_Offset(TkScrollbar, relief), 0, NULL},
+ DEF_SCROLLBAR_RELIEF, offsetof(TkScrollbar, relief), 0, NULL},
{TK_CONFIG_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_SCROLLBAR_REPEAT_DELAY, Tk_Offset(TkScrollbar, repeatDelay), 0, NULL},
+ DEF_SCROLLBAR_REPEAT_DELAY, offsetof(TkScrollbar, repeatDelay), 0, NULL},
{TK_CONFIG_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_SCROLLBAR_REPEAT_INTERVAL, Tk_Offset(TkScrollbar, repeatInterval), 0, NULL},
+ DEF_SCROLLBAR_REPEAT_INTERVAL, offsetof(TkScrollbar, repeatInterval), 0, NULL},
{TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_SCROLLBAR_TAKE_FOCUS, Tk_Offset(TkScrollbar, takeFocus),
+ DEF_SCROLLBAR_TAKE_FOCUS, offsetof(TkScrollbar, takeFocus),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCROLLBAR_TROUGH_COLOR, Tk_Offset(TkScrollbar, troughColorPtr),
+ DEF_SCROLLBAR_TROUGH_COLOR, offsetof(TkScrollbar, troughColorPtr),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCROLLBAR_TROUGH_MONO, Tk_Offset(TkScrollbar, troughColorPtr),
+ DEF_SCROLLBAR_TROUGH_MONO, offsetof(TkScrollbar, troughColorPtr),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_PIXELS, "-width", "width", "Width",
- tkDefScrollbarWidth, Tk_Offset(TkScrollbar, width), 0, NULL},
+ tkDefScrollbarWidth, offsetof(TkScrollbar, width), 0, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -127,8 +127,8 @@ Tk_ScrollbarObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- Tk_Window tkwin = clientData;
- register TkScrollbar *scrollPtr;
+ Tk_Window tkwin = (Tk_Window)clientData;
+ TkScrollbar *scrollPtr;
Tk_Window newWin;
if (objc < 2) {
@@ -225,9 +225,9 @@ ScrollbarWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- register TkScrollbar *scrollPtr = clientData;
+ TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
int result = TCL_OK, cmdIndex;
- size_t length;
+ TkSizeT length;
static const char *const commandNames[] = {
"activate", "cget", "configure", "delta", "fraction",
"get", "identify", "set", NULL
@@ -381,10 +381,10 @@ ScrollbarWidgetObjCmd(
}
#ifndef TK_NO_DEPRECATED
if (scrollPtr->flags & OLD_STYLE_COMMANDS) {
- resObjs[0] = Tcl_NewIntObj(scrollPtr->totalUnits);
- resObjs[1] = Tcl_NewIntObj(scrollPtr->windowUnits);
- resObjs[2] = Tcl_NewIntObj(scrollPtr->firstUnit);
- resObjs[3] = Tcl_NewIntObj(scrollPtr->lastUnit);
+ resObjs[0] = Tcl_NewWideIntObj(scrollPtr->totalUnits);
+ resObjs[1] = Tcl_NewWideIntObj(scrollPtr->windowUnits);
+ resObjs[2] = Tcl_NewWideIntObj(scrollPtr->firstUnit);
+ resObjs[3] = Tcl_NewWideIntObj(scrollPtr->lastUnit);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, resObjs));
break;
}
@@ -524,7 +524,7 @@ ScrollbarWidgetObjCmd(
static int
ConfigureScrollbar(
Tcl_Interp *interp, /* Used for error reporting. */
- register TkScrollbar *scrollPtr,
+ TkScrollbar *scrollPtr,
/* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in argv. */
@@ -587,7 +587,7 @@ TkScrollbarEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkScrollbar *scrollPtr = clientData;
+ TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
TkScrollbarEventuallyRedraw(scrollPtr);
@@ -652,7 +652,7 @@ static void
ScrollbarCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TkScrollbar *scrollPtr = clientData;
+ TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
Tk_Window tkwin = scrollPtr->tkwin;
/*
diff --git a/generic/tkSelect.c b/generic/tkSelect.c
index 9e9b3c9..a6548b6 100644
--- a/generic/tkSelect.c
+++ b/generic/tkSelect.c
@@ -48,7 +48,7 @@ typedef struct LostCommand {
* The structure below is used to keep each thread's pending list separate.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
TkSelInProgress *pendingPtr;
/* Topmost search in progress, or NULL if
* none. */
@@ -125,7 +125,7 @@ Tk_CreateSelHandler(
* listed in the ICCCM will be tolerated
* (blech). */
{
- register TkSelHandler *selPtr;
+ TkSelHandler *selPtr;
TkWindow *winPtr = (TkWindow *) tkwin;
if (winPtr->dispPtr->multipleAtom == None) {
@@ -139,7 +139,7 @@ Tk_CreateSelHandler(
for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) {
if (selPtr == NULL) {
- selPtr = ckalloc(sizeof(TkSelHandler));
+ selPtr = (TkSelHandler *)ckalloc(sizeof(TkSelHandler));
selPtr->nextPtr = winPtr->selHandlerList;
winPtr->selHandlerList = selPtr;
break;
@@ -177,7 +177,7 @@ Tk_CreateSelHandler(
target = winPtr->dispPtr->utf8Atom;
for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) {
if (selPtr == NULL) {
- selPtr = ckalloc(sizeof(TkSelHandler));
+ selPtr = (TkSelHandler *)ckalloc(sizeof(TkSelHandler));
selPtr->nextPtr = winPtr->selHandlerList;
winPtr->selHandlerList = selPtr;
selPtr->selection = selection;
@@ -190,7 +190,7 @@ Tk_CreateSelHandler(
* should make a copy for this selPtr.
*/
- size_t cmdInfoLen = Tk_Offset(CommandInfo, command) + 1 +
+ size_t cmdInfoLen = offsetof(CommandInfo, command) + 1 +
((CommandInfo *)clientData)->cmdLength;
selPtr->clientData = ckalloc(cmdInfoLen);
@@ -239,9 +239,9 @@ Tk_DeleteSelHandler(
* removed. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- register TkSelHandler *selPtr, *prevPtr;
- register TkSelInProgress *ipPtr;
- ThreadSpecificData *tsdPtr =
+ TkSelHandler *selPtr, *prevPtr;
+ TkSelInProgress *ipPtr;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -353,7 +353,7 @@ Tk_OwnSelection(
ClientData clientData) /* Arbitrary one-word argument to pass to
* proc. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
TkDisplay *dispPtr = winPtr->dispPtr;
TkSelectionInfo *infoPtr;
Tk_LostSelProc *clearProc = NULL;
@@ -382,7 +382,7 @@ Tk_OwnSelection(
}
}
if (infoPtr == NULL) {
- infoPtr = ckalloc(sizeof(TkSelectionInfo));
+ infoPtr = (TkSelectionInfo *)ckalloc(sizeof(TkSelectionInfo));
infoPtr->selection = selection;
infoPtr->nextPtr = dispPtr->selectionInfoPtr;
dispPtr->selectionInfoPtr = infoPtr;
@@ -460,7 +460,7 @@ Tk_ClearSelection(
Tk_Window tkwin, /* Window that selects a display. */
Atom selection) /* Selection to be cancelled. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
TkDisplay *dispPtr = winPtr->dispPtr;
TkSelectionInfo *infoPtr;
TkSelectionInfo *prevPtr;
@@ -556,7 +556,7 @@ Tk_GetSelection(
TkWindow *winPtr = (TkWindow *) tkwin;
TkDisplay *dispPtr = winPtr->dispPtr;
TkSelectionInfo *infoPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (dispPtr->multipleAtom == None) {
@@ -577,7 +577,7 @@ Tk_GetSelection(
}
}
if (infoPtr != NULL) {
- register TkSelHandler *selPtr;
+ TkSelHandler *selPtr;
int offset, result, count;
char buffer[TK_SEL_BYTES_AT_ONCE+1];
TkSelInProgress ip;
@@ -670,7 +670,7 @@ Tk_SelectionObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
const char *path = NULL;
Atom selection;
const char *selName = NULL;
@@ -830,8 +830,8 @@ Tk_SelectionObjCmd(
Atom target, format;
const char *targetName = NULL;
const char *formatName = NULL;
- register CommandInfo *cmdInfoPtr;
- size_t cmdLength;
+ CommandInfo *cmdInfoPtr;
+ TkSizeT cmdLength;
static const char *const handleOptionStrings[] = {
"-format", "-selection", "-type", NULL
};
@@ -904,7 +904,7 @@ Tk_SelectionObjCmd(
if (cmdLength == 0) {
Tk_DeleteSelHandler(tkwin, selection, target);
} else {
- cmdInfoPtr = ckalloc(Tk_Offset(CommandInfo, command)
+ cmdInfoPtr = (CommandInfo *)ckalloc(offsetof(CommandInfo, command)
+ 1 + cmdLength);
cmdInfoPtr->interp = interp;
cmdInfoPtr->charOffset = 0;
@@ -919,7 +919,7 @@ Tk_SelectionObjCmd(
}
case SELECTION_OWN: {
- register LostCommand *lostPtr;
+ LostCommand *lostPtr;
Tcl_Obj *commandObj = NULL;
static const char *const ownOptionStrings[] = {
"-command", "-displayof", "-selection", NULL
@@ -1008,7 +1008,7 @@ Tk_SelectionObjCmd(
Tk_OwnSelection(tkwin, selection, NULL, NULL);
return TCL_OK;
}
- lostPtr = ckalloc(sizeof(LostCommand));
+ lostPtr = (LostCommand *)ckalloc(sizeof(LostCommand));
lostPtr->interp = interp;
lostPtr->cmdObj = commandObj;
Tcl_IncrRefCount(commandObj);
@@ -1040,7 +1040,7 @@ Tk_SelectionObjCmd(
TkSelInProgress *
TkSelGetInProgress(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
return tsdPtr->pendingPtr;
@@ -1067,7 +1067,7 @@ void
TkSelSetInProgress(
TkSelInProgress *pendingPtr)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
tsdPtr->pendingPtr = pendingPtr;
@@ -1092,12 +1092,12 @@ TkSelSetInProgress(
void
TkSelDeadWindow(
- register TkWindow *winPtr) /* Window that's being deleted. */
+ TkWindow *winPtr) /* Window that's being deleted. */
{
- register TkSelHandler *selPtr;
- register TkSelInProgress *ipPtr;
+ TkSelHandler *selPtr;
+ TkSelInProgress *ipPtr;
TkSelectionInfo *infoPtr, *prevPtr, *nextPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -1170,7 +1170,7 @@ TkSelInit(
Tk_Window tkwin) /* Window token (used to find display to
* initialize). */
{
- register TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
+ TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
/*
* Fetch commonly-used atoms.
@@ -1221,9 +1221,9 @@ TkSelInit(
void
TkSelClearSelection(
Tk_Window tkwin, /* Window for which event was targeted. */
- register XEvent *eventPtr) /* X SelectionClear event. */
+ XEvent *eventPtr) /* X SelectionClear event. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
TkDisplay *dispPtr = winPtr->dispPtr;
TkSelectionInfo *infoPtr;
TkSelectionInfo *prevPtr;
@@ -1285,16 +1285,17 @@ TkSelClearSelection(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
SelGetProc(
ClientData clientData, /* Dynamic string holding partially assembled
* selection. */
- Tcl_Interp *interp, /* Interpreter used for error reporting (not
+ Tcl_Interp *dummy, /* Interpreter used for error reporting (not
* used). */
const char *portion) /* New information to be appended. */
{
- Tcl_DStringAppend(clientData, portion, -1);
+ (void)dummy;
+
+ Tcl_DStringAppend((Tcl_DString *)clientData, portion, -1);
return TCL_OK;
}
@@ -1326,7 +1327,7 @@ HandleTclCommand(
char *buffer, /* Place to store converted selection. */
int maxBytes) /* Maximum # of bytes to store at buffer. */
{
- CommandInfo *cmdInfoPtr = clientData;
+ CommandInfo *cmdInfoPtr = (CommandInfo *)clientData;
int length;
Tcl_Obj *command;
const char *string;
@@ -1387,7 +1388,7 @@ HandleTclCommand(
string = Tcl_GetStringFromObj(Tcl_GetObjResult(interp), &length);
count = (length > maxBytes) ? maxBytes : length;
- memcpy(buffer, string, (size_t) count);
+ memcpy(buffer, string, count);
buffer[count] = '\0';
/*
@@ -1400,17 +1401,18 @@ HandleTclCommand(
cmdInfoPtr->charOffset += Tcl_NumUtfChars(string, -1);
cmdInfoPtr->buffer[0] = '\0';
} else {
+ int ch;
p = string;
string += count;
numChars = 0;
while (p < string) {
- p = Tcl_UtfNext(p);
+ p += TkUtfToUniChar(p, &ch);
numChars++;
}
cmdInfoPtr->charOffset += numChars;
length = p - string;
if (length > 0) {
- strncpy(cmdInfoPtr->buffer, string, (size_t) length);
+ strncpy(cmdInfoPtr->buffer, string, length);
}
cmdInfoPtr->buffer[length] = '\0';
}
@@ -1469,7 +1471,7 @@ TkSelDefaultSelection(
Atom *typePtr) /* Store here the type of the selection, for
* use in converting to proper X format. */
{
- register TkWindow *winPtr = (TkWindow *) infoPtr->owner;
+ TkWindow *winPtr = (TkWindow *) infoPtr->owner;
TkDisplay *dispPtr = winPtr->dispPtr;
if (target == dispPtr->timestampAtom) {
@@ -1482,7 +1484,7 @@ TkSelDefaultSelection(
}
if (target == dispPtr->targetsAtom) {
- register TkSelHandler *selPtr;
+ TkSelHandler *selPtr;
int length;
Tcl_DString ds;
@@ -1508,7 +1510,7 @@ TkSelDefaultSelection(
Tcl_DStringFree(&ds);
return -1;
}
- memcpy(buffer, Tcl_DStringValue(&ds), (unsigned) (1+length));
+ memcpy(buffer, Tcl_DStringValue(&ds), length + 1);
Tcl_DStringFree(&ds);
*typePtr = XA_ATOM;
return length;
@@ -1565,7 +1567,7 @@ static void
LostSelection(
ClientData clientData) /* Pointer to LostCommand structure. */
{
- LostCommand *lostPtr = clientData;
+ LostCommand *lostPtr = (LostCommand *)clientData;
Tcl_Interp *interp = lostPtr->interp;
Tcl_InterpState savedState;
int code;
diff --git a/generic/tkSelect.h b/generic/tkSelect.h
index d7df94e..405cbea 100644
--- a/generic/tkSelect.h
+++ b/generic/tkSelect.h
@@ -107,7 +107,7 @@ typedef struct TkSelRetrievalInfo {
typedef struct TkClipboardBuffer {
char *buffer; /* Null terminated data buffer. */
- long length; /* Length of string in buffer. */
+ size_t length; /* Length of string in buffer. */
struct TkClipboardBuffer *nextPtr;
/* Next in list of buffers. NULL means end of
* list . */
diff --git a/generic/tkSquare.c b/generic/tkSquare.c
index e40a684..2b2d3c5 100644
--- a/generic/tkSquare.c
+++ b/generic/tkSquare.c
@@ -66,29 +66,29 @@ typedef struct {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- "#d9d9d9", Tk_Offset(Square, bgBorderPtr), -1, 0,
+ "#d9d9d9", offsetof(Square, bgBorderPtr), TCL_INDEX_NONE, 0,
"white", 0},
- {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, -1, 0,
+ {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
"-borderwidth", 0},
- {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, -1, 0,
+ {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
"-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- "2", Tk_Offset(Square, borderWidthPtr), -1, 0, NULL, 0},
+ "2", offsetof(Square, borderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-dbl", "doubleBuffer", "DoubleBuffer",
- "1", Tk_Offset(Square, doubleBufferPtr), -1, 0 , NULL, 0},
- {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, 0, -1, 0,
+ "1", offsetof(Square, doubleBufferPtr), TCL_INDEX_NONE, 0 , NULL, 0},
+ {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
"-foreground", 0},
{TK_OPTION_BORDER, "-foreground", "foreground", "Foreground",
- "#b03060", Tk_Offset(Square, fgBorderPtr), -1, 0,
+ "#b03060", offsetof(Square, fgBorderPtr), TCL_INDEX_NONE, 0,
"black", 0},
{TK_OPTION_PIXELS, "-posx", "posx", "PosX", "0",
- Tk_Offset(Square, xPtr), -1, 0, NULL, 0},
+ offsetof(Square, xPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_PIXELS, "-posy", "posy", "PosY", "0",
- Tk_Offset(Square, yPtr), -1, 0, NULL, 0},
+ offsetof(Square, yPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- "raised", Tk_Offset(Square, reliefPtr), -1, 0, NULL, 0},
+ "raised", offsetof(Square, reliefPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_PIXELS, "-size", "size", "Size", "20",
- Tk_Offset(Square, sizeObjPtr), -1, 0, NULL, 0},
+ offsetof(Square, sizeObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
@@ -125,7 +125,7 @@ static int SquareWidgetObjCmd(ClientData clientData,
int
SquareObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -133,6 +133,7 @@ SquareObjCmd(
Square *squarePtr;
Tk_Window tkwin;
Tk_OptionTable optionTable;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -160,7 +161,7 @@ SquareObjCmd(
* just the non-NULL/0 items.
*/
- squarePtr = ckalloc(sizeof(Square));
+ squarePtr = (Square *)ckalloc(sizeof(Square));
memset(squarePtr, 0, sizeof(Square));
squarePtr->tkwin = tkwin;
@@ -223,7 +224,7 @@ SquareWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj * const objv[]) /* Argument objects. */
{
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
int result = TCL_OK;
static const char *const squareOptions[] = {"cget", "configure", NULL};
enum {
@@ -318,12 +319,13 @@ SquareWidgetObjCmd(
static int
SquareConfigure(
- Tcl_Interp *interp, /* Used for error reporting. */
+ Tcl_Interp *dummy, /* Used for error reporting. */
Square *squarePtr) /* Information about widget. */
{
int borderWidth;
Tk_3DBorder bgBorder;
int doubleBuffer;
+ (void)dummy;
/*
* Set the background for the window and create a graphics context for use
@@ -383,7 +385,7 @@ SquareObjEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
if (eventPtr->type == Expose) {
if (!squarePtr->updatePending) {
@@ -436,7 +438,7 @@ static void
SquareDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
Tk_Window tkwin = squarePtr->tkwin;
/*
@@ -473,7 +475,7 @@ static void
SquareDisplay(
ClientData clientData) /* Information about window. */
{
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
Tk_Window tkwin = squarePtr->tkwin;
Pixmap pm = None;
Drawable d;
@@ -556,7 +558,7 @@ static void
SquareDestroy(
void *memPtr) /* Info about square widget. */
{
- Square *squarePtr = memPtr;
+ Square *squarePtr = (Square *)memPtr;
ckfree(squarePtr);
}
@@ -581,7 +583,7 @@ SquareDestroy(
static void
KeepInWindow(
- register Square *squarePtr) /* Pointer to widget record. */
+ Square *squarePtr) /* Pointer to widget record. */
{
int i, bd, relief;
int borderWidth, size;
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index a6e9728..25c5604 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -30,7 +30,6 @@
#include "tkPlatDecls.h"
#include "tkIntXlibDecls.h"
-static const TkIntStubs tkIntStubs;
MODULE_SCOPE const TkStubs tkStubs;
/*
@@ -42,6 +41,22 @@ MODULE_SCOPE const TkStubs tkStubs;
#undef Tk_FreeStyleFromObj
#undef Tk_GetStyleFromObj
#undef TkWinGetPlatformId
+#undef TkPutImage
+#undef XPutImage
+
+#if defined(_WIN32) && !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
+# define Tk_TranslateWinEvent TkTranslateWinEvent
+# define Tk_PointerEvent TkWinPointerEvent
+#define TkWinGetPlatformId winGetPlatformId
+static int TkWinGetPlatformId(void) {
+ return 2;
+}
+#else
+# define Tk_TranslateWinEvent 0
+# define Tk_PointerEvent 0
+# define TkWinGetPlatformId 0
+#endif
+
#if defined(TK_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8
#define Tk_MainEx 0
@@ -61,32 +76,46 @@ doNothing(void)
{
/* dummy implementation, no need to do anything */
}
-#define Tk_FreeXId ((void (*)(Display *, XID)) doNothing)
-#define Tk_FreeStyleFromObj ((void (*)(Tcl_Obj *)) doNothing)
+#define Tk_FreeXId ((void (*)(Display *, XID))(void *)doNothing)
+#define Tk_FreeStyleFromObj ((void (*)(Tcl_Obj *))(void *)doNothing)
#define Tk_GetStyleFromObj getStyleFromObj
static Tk_Style Tk_GetStyleFromObj(Tcl_Obj *obj)
{
return Tk_AllocStyleFromObj(NULL, obj);
}
-#if defined(_WIN32) || defined(__CYGWIN__)
-#define TkWinGetPlatformId winGetPlatformId
-static int TkWinGetPlatformId(void) {
- return 2;
-}
-#endif /* defined(_WIN32) || defined(__CYGWIN__) */
#endif /* !TK_NO_DEPRECATED */
+#define TkpCmapStressed_ TkpCmapStressed
+#define TkpSync_ TkpSync
+#define TkUnixContainerId_ TkUnixContainerId
+#define TkUnixDoOneXEvent_ TkUnixDoOneXEvent
+#define TkUnixSetMenubar_ TkUnixSetMenubar
+#define TkWmCleanup_ TkWmCleanup
+#define TkSendCleanup_ TkSendCleanup
+#define TkpTestsendCmd_ TkpTestsendCmd
+#define Tk_MacOSXSetEmbedHandler_ Tk_MacOSXSetEmbedHandler
+#define Tk_MacOSXTurnOffMenus_ Tk_MacOSXTurnOffMenus
+#define Tk_MacOSXTkOwnsCursor_ Tk_MacOSXTkOwnsCursor
+#define TkMacOSXInitMenus_ TkMacOSXInitMenus
+#define TkMacOSXInitAppleEvents_ TkMacOSXInitAppleEvents
+#define TkGenWMConfigureEvent_ TkGenWMConfigureEvent
+#define TkGenerateActivateEvents_ TkGenerateActivateEvents
+
#ifdef _WIN32
int
TkpCmapStressed(Tk_Window tkwin, Colormap colormap)
{
+ (void)tkwin;
+ (void)colormap;
+
/* dummy implementation, no need to do anything */
return 0;
}
void
TkpSync(Display *display)
{
+ (void)display;
/* dummy implementation, no need to do anything */
}
@@ -99,13 +128,8 @@ TkCreateXEventSource(void)
# define TkUnixContainerId 0
# define TkUnixDoOneXEvent 0
# define TkUnixSetMenubar 0
-# define XCreateWindow 0
-# define XOffsetRegion 0
-# define XUnionRegion 0
-# define XPolygonRegion 0
-# define XPointInRegion 0
-# define TkWmCleanup (void (*)(TkDisplay *)) TkpSync
-# define TkSendCleanup (void (*)(TkDisplay *)) TkpSync
+# define TkWmCleanup (void (*)(TkDisplay *))(void *)TkpSync
+# define TkSendCleanup (void (*)(TkDisplay *))(void *)TkpSync
# define TkpTestsendCmd 0
#else /* !_WIN32 */
@@ -124,22 +148,21 @@ TkCreateXEventSource(void)
*/
#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004
+#ifdef __cplusplus
+extern "C" {
+#endif
int __stdcall GetModuleHandleExW(unsigned int, const char *, void *);
-
-void *Tk_GetHINSTANCE()
-{
- void *hInstance = NULL;
-
- GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
- (const char *) &tkIntStubs, &hInstance);
- return hInstance;
+#ifdef __cplusplus
}
+#endif
void
TkSetPixmapColormap(
Pixmap pixmap,
Colormap colormap)
{
+ (void)pixmap;
+ (void)colormap;
}
void
@@ -148,7 +171,7 @@ TkpPrintWindowId(
* the hex representation of a pointer. */
Window window) /* Window to be printed into buffer. */
{
- sprintf(buf, "%#08lx", (unsigned long) (window));
+ sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)window);
}
int
@@ -165,58 +188,19 @@ TkPutImage(
unsigned int width, unsigned int height)
/* Dimensions of subimage. */
{
- return XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height);
-}
+ (void)colors;
+ (void)ncolors;
-TkRegion TkCreateRegion()
-{
- return (TkRegion) XCreateRegion();
-}
-
-void TkDestroyRegion(TkRegion r)
-{
- XDestroyRegion((Region)r);
-}
-
-void TkSetRegion(Display *d, GC g, TkRegion r)
-{
- XSetRegion(d, g, (Region)r);
-}
-
-void TkUnionRectWithRegion(XRectangle *a, TkRegion b, TkRegion c)
-{
- XUnionRectWithRegion(a, (Region) b, (Region) c);
-}
-
-void TkClipBox(TkRegion a, XRectangle *b)
-{
- XClipBox((Region) a, b);
-}
-
-void TkIntersectRegion(TkRegion a, TkRegion b, TkRegion c)
-{
- XIntersectRegion((Region) a, (Region) b, (Region) c);
-}
-
-int TkRectInRegion (TkRegion r, int a, int b, unsigned int c, unsigned int d)
-{
- return XRectInRegion((Region) r, a, b, c, d);
-}
-
-void TkSubtractRegion (TkRegion a, TkRegion b, TkRegion c)
-{
- XSubtractRegion((Region) a, (Region) b, (Region) c);
+ return XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height);
}
/* TODO: To be implemented for Cygwin */
# define Tk_AttachHWND 0
# define Tk_GetHWND 0
# define Tk_HWNDToWindow 0
-# define Tk_PointerEvent 0
-# define Tk_TranslateWinEvent 0
# define TkAlignImageData 0
-# define TkGenerateActivateEvents 0
# define TkpGetMS 0
+# define TkpGetCapture 0
# define TkPointerDeadWindow 0
# define TkpSetCapture 0
# define TkpSetCursor 0
@@ -246,28 +230,33 @@ void TkSubtractRegion (TkRegion a, TkRegion b, TkRegion c)
# define TkWinGetPlatformTheme 0
# define TkWinChildProc 0
-# elif !defined(MAC_OSX_TK) /* UNIX */
-
-# undef TkClipBox
-# undef TkCreateRegion
-# undef TkDestroyRegion
-# undef TkIntersectRegion
-# undef TkRectInRegion
-# undef TkSetRegion
-# undef TkUnionRectWithRegion
-# undef TkSubtractRegion
-
-# define TkClipBox (void (*) (TkRegion, XRectangle *)) XClipBox
-# define TkCreateRegion (TkRegion (*) ()) XCreateRegion
-# define TkDestroyRegion (void (*) (TkRegion)) XDestroyRegion
-# define TkIntersectRegion (void (*) (TkRegion, TkRegion, TkRegion)) XIntersectRegion
-# define TkRectInRegion (int (*) (TkRegion, int, int, unsigned int, unsigned int)) XRectInRegion
-# define TkSetRegion (void (*) (Display *, GC, TkRegion)) XSetRegion
-# define TkUnionRectWithRegion (void (*) (XRectangle *, TkRegion, TkRegion)) XUnionRectWithRegion
-# define TkSubtractRegion (void (*) (TkRegion, TkRegion, TkRegion)) XSubtractRegion
# endif
#endif /* !_WIN32 */
+#if defined(MAC_OSX_TCL)
+
+int
+TkPutImage(
+ unsigned long *colors, /* Array of pixel values used by this image.
+ * May be NULL. */
+ int ncolors, /* Number of colors used, or 0. */
+ Display *display,
+ Drawable d, /* Destination drawable. */
+ GC gc,
+ XImage *image, /* Source image. */
+ int src_x, int src_y, /* Offset of subimage. */
+ int dest_x, int dest_y, /* Position of subimage origin in drawable. */
+ unsigned int width, unsigned int height)
+ /* Dimensions of subimage. */
+{
+ (void)colors;
+ (void)ncolors;
+
+ return XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height);
+}
+#endif /* MAC_OSX_TCL */
+
+
/*
* WARNING: The contents of this file is automatically generated by the
* tools/genStubs.tcl script. Any modifications to the function declarations
@@ -400,13 +389,13 @@ static const TkIntStubs tkIntStubs = {
TkpGetSubFonts, /* 110 */
TkpGetSystemDefault, /* 111 */
TkpMenuThreadInit, /* 112 */
- TkClipBox, /* 113 */
- TkCreateRegion, /* 114 */
- TkDestroyRegion, /* 115 */
- TkIntersectRegion, /* 116 */
- TkRectInRegion, /* 117 */
- TkSetRegion, /* 118 */
- TkUnionRectWithRegion, /* 119 */
+ XClipBox, /* 113 */
+ XCreateRegion, /* 114 */
+ XDestroyRegion, /* 115 */
+ XIntersectRegion, /* 116 */
+ XRectInRegion, /* 117 */
+ XSetRegion, /* 118 */
+ XUnionRectWithRegion, /* 119 */
0, /* 120 */
#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */
0, /* 121 */
@@ -459,7 +448,7 @@ static const TkIntStubs tkIntStubs = {
TkFocusFree, /* 142 */
TkClipCleanup, /* 143 */
TkGCCleanup, /* 144 */
- TkSubtractRegion, /* 145 */
+ XSubtractRegion, /* 145 */
TkStylePkgInit, /* 146 */
TkStylePkgFree, /* 147 */
TkToplevelWindowForCommand, /* 148 */
@@ -552,11 +541,13 @@ static const TkIntPlatStubs tkIntPlatStubs = {
TkWmCleanup, /* 43 */
TkSendCleanup, /* 44 */
TkpTestsendCmd, /* 45 */
+ 0, /* 46 */
+ TkpGetCapture, /* 47 */
#endif /* WIN */
#ifdef MAC_OSX_TK /* AQUA */
TkGenerateActivateEvents, /* 0 */
0, /* 1 */
- 0, /* 2 */
+ TkGenerateActivateEvents_, /* 2 */
TkPointerDeadWindow, /* 3 */
TkpSetCapture, /* 4 */
TkpSetCursor, /* 5 */
@@ -601,7 +592,7 @@ static const TkIntPlatStubs tkIntPlatStubs = {
TkMacOSXGetHostToplevel, /* 44 */
TkMacOSXPreprocessMenu, /* 45 */
TkpIsWindowFloating, /* 46 */
- TkMacOSXGetCapture, /* 47 */
+ TkpGetCapture, /* 47 */
0, /* 48 */
TkGetTransientMaster, /* 49 */
TkGenerateButtonEvent, /* 50 */
@@ -614,7 +605,7 @@ static const TkIntPlatStubs tkIntPlatStubs = {
#if !(defined(_WIN32) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */
TkCreateXEventSource, /* 0 */
0, /* 1 */
- 0, /* 2 */
+ TkGenerateActivateEvents, /* 2 */
TkpCmapStressed, /* 3 */
TkpSync, /* 4 */
TkUnixContainerId, /* 5 */
@@ -626,6 +617,38 @@ static const TkIntPlatStubs tkIntPlatStubs = {
0, /* 11 */
TkpWmSetState, /* 12 */
TkpTestsendCmd, /* 13 */
+ 0, /* 14 */
+ 0, /* 15 */
+ 0, /* 16 */
+ 0, /* 17 */
+ 0, /* 18 */
+ 0, /* 19 */
+ 0, /* 20 */
+ 0, /* 21 */
+ 0, /* 22 */
+ 0, /* 23 */
+ 0, /* 24 */
+ 0, /* 25 */
+ 0, /* 26 */
+ 0, /* 27 */
+ 0, /* 28 */
+ 0, /* 29 */
+ 0, /* 30 */
+ 0, /* 31 */
+ 0, /* 32 */
+ 0, /* 33 */
+ 0, /* 34 */
+ 0, /* 35 */
+ 0, /* 36 */
+ 0, /* 37 */
+ TkpCmapStressed_, /* 38 */
+ TkpSync_, /* 39 */
+ TkUnixContainerId_, /* 40 */
+ TkUnixDoOneXEvent_, /* 41 */
+ TkUnixSetMenubar_, /* 42 */
+ TkWmCleanup_, /* 43 */
+ TkSendCleanup_, /* 44 */
+ TkpTestsendCmd_, /* 45 */
#endif /* X11 */
};
@@ -773,8 +796,27 @@ static const TkIntXlibStubs tkIntXlibStubs = {
XPutImage, /* 137 */
XPolygonRegion, /* 138 */
XPointInRegion, /* 139 */
+ XVaCreateNestedList, /* 140 */
+ XSetICValues, /* 141 */
+ XGetICValues, /* 142 */
+ XSetICFocus, /* 143 */
+ 0, /* 144 */
+ 0, /* 145 */
+ 0, /* 146 */
+ XFreeFontSet, /* 147 */
+ XCloseIM, /* 148 */
+ XRegisterIMInstantiateCallback, /* 149 */
+ XUnregisterIMInstantiateCallback, /* 150 */
+ XSetLocaleModifiers, /* 151 */
+ XOpenIM, /* 152 */
+ XGetIMValues, /* 153 */
+ XSetIMValues, /* 154 */
+ XCreateFontSet, /* 155 */
+ XFreeStringList, /* 156 */
+ XkbKeycodeToKeysym, /* 157 */
+ XkbOpenDisplay, /* 158 */
#endif /* WIN */
-#ifdef MAC_OSX_TK /* AQUA */
+#ifdef MAC_OSX_TCL /* MACOSX */
XSetDashes, /* 0 */
XGetModifierMapping, /* 1 */
XCreateImage, /* 2 */
@@ -867,7 +909,74 @@ static const TkIntXlibStubs tkIntXlibStubs = {
XQueryColors, /* 89 */
XQueryTree, /* 90 */
XSync, /* 91 */
-#endif /* AQUA */
+ XTranslateCoordinates, /* 92 */
+ XDeleteProperty, /* 93 */
+ XFreeCursor, /* 94 */
+ XGetInputFocus, /* 95 */
+ XmbLookupString, /* 96 */
+ XNextEvent, /* 97 */
+ XPutBackEvent, /* 98 */
+ XSetCommand, /* 99 */
+ XWindowEvent, /* 100 */
+ XGetWindowAttributes, /* 101 */
+ XGetWMColormapWindows, /* 102 */
+ XIconifyWindow, /* 103 */
+ XWithdrawWindow, /* 104 */
+ XListHosts, /* 105 */
+ 0, /* 106 */
+ XFlush, /* 107 */
+ XGrabServer, /* 108 */
+ XUngrabServer, /* 109 */
+ XFree, /* 110 */
+ XNoOp, /* 111 */
+ XSynchronize, /* 112 */
+ XLookupColor, /* 113 */
+ XVisualIDFromVisual, /* 114 */
+ 0, /* 115 */
+ 0, /* 116 */
+ 0, /* 117 */
+ 0, /* 118 */
+ 0, /* 119 */
+ XOffsetRegion, /* 120 */
+ XUnionRegion, /* 121 */
+ XCreateWindow, /* 122 */
+ 0, /* 123 */
+ 0, /* 124 */
+ 0, /* 125 */
+ 0, /* 126 */
+ 0, /* 127 */
+ 0, /* 128 */
+ XLowerWindow, /* 129 */
+ XFillArcs, /* 130 */
+ XDrawArcs, /* 131 */
+ XDrawRectangles, /* 132 */
+ 0, /* 133 */
+ 0, /* 134 */
+ 0, /* 135 */
+ XReparentWindow, /* 136 */
+ XPutImage, /* 137 */
+ XPolygonRegion, /* 138 */
+ XPointInRegion, /* 139 */
+ XVaCreateNestedList, /* 140 */
+ XSetICValues, /* 141 */
+ XGetICValues, /* 142 */
+ XSetICFocus, /* 143 */
+ XDestroyIC, /* 144 */
+ XCreatePixmapCursor, /* 145 */
+ XCreateGlyphCursor, /* 146 */
+ XFreeFontSet, /* 147 */
+ XCloseIM, /* 148 */
+ XRegisterIMInstantiateCallback, /* 149 */
+ XUnregisterIMInstantiateCallback, /* 150 */
+ XSetLocaleModifiers, /* 151 */
+ XOpenIM, /* 152 */
+ XGetIMValues, /* 153 */
+ XSetIMValues, /* 154 */
+ XCreateFontSet, /* 155 */
+ XFreeStringList, /* 156 */
+ XkbKeycodeToKeysym, /* 157 */
+ XkbOpenDisplay, /* 158 */
+#endif /* MACOSX */
};
static const TkPlatStubs tkPlatStubs = {
@@ -893,6 +1002,12 @@ static const TkPlatStubs tkPlatStubs = {
TkMacOSXGetRootControl, /* 8 */
Tk_MacOSXSetupTkNotifier, /* 9 */
Tk_MacOSXIsAppInFront, /* 10 */
+ Tk_MacOSXSetEmbedHandler_, /* 11 */
+ Tk_MacOSXTurnOffMenus_, /* 12 */
+ Tk_MacOSXTkOwnsCursor_, /* 13 */
+ TkMacOSXInitMenus_, /* 14 */
+ TkMacOSXInitAppleEvents_, /* 15 */
+ TkGenWMConfigureEvent_, /* 16 */
#endif /* AQUA */
};
@@ -1185,3 +1300,16 @@ const TkStubs tkStubs = {
};
/* !END!: Do not edit above this line. */
+
+
+#ifdef __CYGWIN__
+void *Tk_GetHINSTANCE(void)
+{
+ void *hInstance = NULL;
+
+ GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+ (const char *) &tkIntStubs, &hInstance);
+ return hInstance;
+}
+#endif
+
diff --git a/generic/tkStubLib.c b/generic/tkStubLib.c
index ea48894..aed0b80 100644
--- a/generic/tkStubLib.c
+++ b/generic/tkStubLib.c
@@ -77,10 +77,10 @@ Tk_InitStubs(
{
const char *packageName = "Tk";
const char *errMsg = NULL;
- ClientData clientData = NULL;
+ void *clientData = NULL;
const char *actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp,
packageName, version, 0, &clientData);
- const TkStubs *stubsPtr = clientData;
+ const TkStubs *stubsPtr = (const TkStubs *)clientData;
if (actualVersion == NULL) {
return NULL;
diff --git a/generic/tkStyle.c b/generic/tkStyle.c
index 508a2c4..9ec08ca 100644
--- a/generic/tkStyle.c
+++ b/generic/tkStyle.c
@@ -98,7 +98,7 @@ typedef struct Element {
* Thread-local data.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
int nbInit; /* Number of calls to the init proc. */
Tcl_HashTable engineTable; /* Map a name to a style engine. Keys are
* strings, values are Tk_StyleEngine
@@ -180,8 +180,9 @@ void
TkStylePkgInit(
TkMainInfo *mainPtr) /* The application being created. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)mainPtr;
if (tsdPtr->nbInit != 0) {
return;
@@ -235,12 +236,13 @@ void
TkStylePkgFree(
TkMainInfo *mainPtr) /* The application being deleted. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashSearch search;
Tcl_HashEntry *entryPtr;
StyleEngine *enginePtr;
int i;
+ (void)mainPtr;
tsdPtr->nbInit--;
if (tsdPtr->nbInit != 0) {
@@ -264,7 +266,7 @@ TkStylePkgFree(
entryPtr = Tcl_FirstHashEntry(&tsdPtr->engineTable, &search);
while (entryPtr != NULL) {
- enginePtr = Tcl_GetHashValue(entryPtr);
+ enginePtr = (StyleEngine *)Tcl_GetHashValue(entryPtr);
FreeStyleEngine(enginePtr);
ckfree(enginePtr);
entryPtr = Tcl_NextHashEntry(&search);
@@ -307,7 +309,7 @@ Tk_RegisterStyleEngine(
Tk_StyleEngine parent) /* The engine's parent. NULL means the default
* system engine. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
int newEntry;
@@ -331,8 +333,8 @@ Tk_RegisterStyleEngine(
* Allocate and intitialize a new engine.
*/
- enginePtr = ckalloc(sizeof(StyleEngine));
- InitStyleEngine(enginePtr, Tcl_GetHashKey(&tsdPtr->engineTable, entryPtr),
+ enginePtr = (StyleEngine *)ckalloc(sizeof(StyleEngine));
+ InitStyleEngine(enginePtr, (const char *)Tcl_GetHashKey(&tsdPtr->engineTable, entryPtr),
(StyleEngine *) parent);
Tcl_SetHashValue(entryPtr, enginePtr);
@@ -364,7 +366,7 @@ InitStyleEngine(
StyleEngine *parentPtr) /* The engine's parent. NULL means the default
* system engine. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
int elementId;
@@ -389,7 +391,7 @@ InitStyleEngine(
*/
if (tsdPtr->nbElements > 0) {
- enginePtr->elements = ckalloc(
+ enginePtr->elements = (StyledElement *)ckalloc(
sizeof(StyledElement) * tsdPtr->nbElements);
for (elementId = 0; elementId < tsdPtr->nbElements; elementId++) {
InitStyledElement(enginePtr->elements+elementId);
@@ -419,7 +421,7 @@ static void
FreeStyleEngine(
StyleEngine *enginePtr) /* The style engine to free. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
int elementId;
@@ -454,7 +456,7 @@ Tk_GetStyleEngine(
const char *name) /* Name of the engine to retrieve. NULL or
* empty means the default system engine. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
@@ -467,7 +469,7 @@ Tk_GetStyleEngine(
return NULL;
}
- return Tcl_GetHashValue(entryPtr);
+ return (Tk_StyleEngine)Tcl_GetHashValue(entryPtr);
}
/*
@@ -523,6 +525,8 @@ static void
FreeElement(
Element *elementPtr) /* The element to free. */
{
+ (void)elementPtr;
+
/* Nothing to do. */
}
@@ -604,12 +608,12 @@ CreateElement(
* created explicitly (being registered) or
* implicitly (by a derived element). */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr, *engineEntryPtr;
Tcl_HashSearch search;
int newEntry, elementId, genericId = -1;
- char *dot;
+ const char *dot;
StyleEngine *enginePtr;
/*
@@ -642,10 +646,10 @@ CreateElement(
* Reallocate element table.
*/
- tsdPtr->elements = ckrealloc(tsdPtr->elements,
+ tsdPtr->elements = (Element *)ckrealloc(tsdPtr->elements,
sizeof(Element) * tsdPtr->nbElements);
InitElement(tsdPtr->elements+elementId,
- Tcl_GetHashKey(&tsdPtr->elementTable, entryPtr), elementId,
+ (const char *)Tcl_GetHashKey(&tsdPtr->elementTable, entryPtr), elementId,
genericId, create);
/*
@@ -654,9 +658,9 @@ CreateElement(
engineEntryPtr = Tcl_FirstHashEntry(&tsdPtr->engineTable, &search);
while (engineEntryPtr != NULL) {
- enginePtr = Tcl_GetHashValue(engineEntryPtr);
+ enginePtr = (StyleEngine *)Tcl_GetHashValue(engineEntryPtr);
- enginePtr->elements = ckrealloc(enginePtr->elements,
+ enginePtr->elements = (StyledElement *)ckrealloc(enginePtr->elements,
sizeof(StyledElement) * tsdPtr->nbElements);
InitStyledElement(enginePtr->elements+elementId);
@@ -686,11 +690,11 @@ int
Tk_GetElementId(
const char *name) /* Name of the element. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
int genericId = -1;
- char *dot;
+ const char *dot;
/*
* Find the element Id.
@@ -759,7 +763,7 @@ Tk_RegisterStyledElement(
StyledElement *elementPtr;
Tk_ElementSpec *specPtr;
int nbOptions;
- register Tk_ElementOptionSpec *srcOptions, *dstOptions;
+ Tk_ElementOptionSpec *srcOptions, *dstOptions;
if (templatePtr->version != TK_STYLE_VERSION_1) {
/*
@@ -786,16 +790,16 @@ Tk_RegisterStyledElement(
elementPtr = ((StyleEngine *) engine)->elements+elementId;
- specPtr = ckalloc(sizeof(Tk_ElementSpec));
+ specPtr = (Tk_ElementSpec *)ckalloc(sizeof(Tk_ElementSpec));
specPtr->version = templatePtr->version;
- specPtr->name = ckalloc(strlen(templatePtr->name)+1);
+ specPtr->name = (char *)ckalloc(strlen(templatePtr->name)+1);
strcpy(specPtr->name, templatePtr->name);
nbOptions = 0;
for (nbOptions = 0, srcOptions = templatePtr->options;
srcOptions->name != NULL; nbOptions++, srcOptions++) {
/* empty body */
}
- specPtr->options =
+ specPtr->options = (Tk_ElementOptionSpec *)
ckalloc(sizeof(Tk_ElementOptionSpec) * (nbOptions+1));
for (srcOptions = templatePtr->options, dstOptions = specPtr->options;
/* End condition within loop */; srcOptions++, dstOptions++) {
@@ -804,7 +808,7 @@ Tk_RegisterStyledElement(
break;
}
- dstOptions->name = ckalloc(strlen(srcOptions->name)+1);
+ dstOptions->name = (char *)ckalloc(strlen(srcOptions->name)+1);
strcpy(dstOptions->name, srcOptions->name);
dstOptions->type = srcOptions->type;
}
@@ -844,7 +848,7 @@ GetStyledElement(
int elementId) /* Unique element ID */
{
StyledElement *elementPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
StyleEngine *enginePtr2;
@@ -924,7 +928,7 @@ InitWidgetSpec(
*/
widgetSpecPtr->optionsPtr =
- ckalloc(sizeof(Tk_OptionSpec *) * nbOptions);
+ (const Tk_OptionSpec **)ckalloc(sizeof(Tk_OptionSpec *) * nbOptions);
for (i = 0, elementOptionPtr = elementPtr->specPtr->options;
i < nbOptions; i++, elementOptionPtr++) {
widgetOptionPtr = TkGetOptionSpec(elementOptionPtr->name, optionTable);
@@ -1008,7 +1012,7 @@ GetWidgetSpec(
*/
i = elementPtr->nbWidgetSpecs++;
- elementPtr->widgetSpecs = ckrealloc(elementPtr->widgetSpecs,
+ elementPtr->widgetSpecs = (StyledWidgetSpec *)ckrealloc(elementPtr->widgetSpecs,
sizeof(StyledWidgetSpec) * elementPtr->nbWidgetSpecs);
widgetSpecPtr = elementPtr->widgetSpecs+i;
InitWidgetSpec(widgetSpecPtr, elementPtr, optionTable);
@@ -1090,7 +1094,7 @@ Tk_GetElementSize(
StyledWidgetSpec *widgetSpecPtr = (StyledWidgetSpec *) element;
widgetSpecPtr->elementPtr->specPtr->getSize(stylePtr->clientData,
- recordPtr, widgetSpecPtr->optionsPtr, tkwin, width, height, inner,
+ (char *)recordPtr, widgetSpecPtr->optionsPtr, tkwin, width, height, inner,
widthPtr, heightPtr);
}
@@ -1133,7 +1137,7 @@ Tk_GetElementBox(
StyledWidgetSpec *widgetSpecPtr = (StyledWidgetSpec *) element;
widgetSpecPtr->elementPtr->specPtr->getBox(stylePtr->clientData,
- recordPtr, widgetSpecPtr->optionsPtr, tkwin, x, y, width, height,
+ (char *)recordPtr, widgetSpecPtr->optionsPtr, tkwin, x, y, width, height,
inner, xPtr, yPtr, widthPtr, heightPtr);
}
@@ -1166,7 +1170,7 @@ Tk_GetElementBorderWidth(
StyledWidgetSpec *widgetSpecPtr = (StyledWidgetSpec *) element;
return widgetSpecPtr->elementPtr->specPtr->getBorderWidth(
- stylePtr->clientData, recordPtr, widgetSpecPtr->optionsPtr, tkwin);
+ stylePtr->clientData, (char *)recordPtr, widgetSpecPtr->optionsPtr, tkwin);
}
/*
@@ -1201,7 +1205,7 @@ Tk_DrawElement(
StyledWidgetSpec *widgetSpecPtr = (StyledWidgetSpec *) element;
widgetSpecPtr->elementPtr->specPtr->draw(stylePtr->clientData,
- recordPtr, widgetSpecPtr->optionsPtr, tkwin, d, x, y, width,
+ (char *)recordPtr, widgetSpecPtr->optionsPtr, tkwin, d, x, y, width,
height, state);
}
@@ -1229,7 +1233,7 @@ Tk_CreateStyle(
Tk_StyleEngine engine, /* The style engine. */
ClientData clientData) /* Private data passed as is to engine code. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
int newEntry;
@@ -1253,8 +1257,8 @@ Tk_CreateStyle(
* Allocate and intitialize a new style.
*/
- stylePtr = ckalloc(sizeof(Style));
- InitStyle(stylePtr, Tcl_GetHashKey(&tsdPtr->styleTable, entryPtr),
+ stylePtr = (Style *)ckalloc(sizeof(Style));
+ InitStyle(stylePtr, (const char *)Tcl_GetHashKey(&tsdPtr->styleTable, entryPtr),
(engine!=NULL ? (StyleEngine*) engine : tsdPtr->defaultEnginePtr),
clientData);
Tcl_SetHashValue(entryPtr, stylePtr);
@@ -1344,10 +1348,9 @@ Tk_GetStyle(
const char *name) /* Name of the style to retrieve. NULL or empty
* means the default system style. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
- Style *stylePtr;
/*
* Search for a corresponding entry in the style table.
@@ -1360,11 +1363,9 @@ Tk_GetStyle(
"style \"%s\" doesn't exist", name));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "STYLE", name, NULL);
}
- return (Tk_Style) NULL;
+ return NULL;
}
- stylePtr = Tcl_GetHashValue(entryPtr);
-
- return (Tk_Style) stylePtr;
+ return (Tk_Style)Tcl_GetHashValue(entryPtr);
}
/*
@@ -1381,6 +1382,7 @@ void
Tk_FreeStyle(
Tk_Style style)
{
+ (void)style;
}
/*
@@ -1410,7 +1412,7 @@ Tk_AllocStyleFromObj(
return NULL;
}
}
- return objPtr->internalRep.twoPtrValue.ptr1;
+ return (Tk_Style)objPtr->internalRep.twoPtrValue.ptr1;
}
/*
diff --git a/generic/tkTest.c b/generic/tkTest.c
index 2061893..97b33fc 100644
--- a/generic/tkTest.c
+++ b/generic/tkTest.c
@@ -31,9 +31,9 @@
#if defined(MAC_OSX_TK)
#include "tkMacOSXInt.h"
#include "tkScrollbar.h"
-#define APP_IS_DRAWING TkTestAppIsDrawing()
+#define LOG_DISPLAY TkTestLogDisplay()
#else
-#define APP_IS_DRAWING 0
+#define LOG_DISPLAY 1
#endif
#ifdef __UNIX__
@@ -48,7 +48,14 @@
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
+#ifdef __cplusplus
+extern "C" {
+#endif
EXTERN int Tktest_Init(Tcl_Interp *interp);
+#ifdef __cplusplus
+}
+#endif
+
/*
* The following data structure represents the master for a test image:
*/
@@ -218,7 +225,7 @@ static int TestPhotoStringMatchCmd(ClientData dummy,
*
* Tktest_Init --
*
- * This function performs intialization for the Tk test suite exensions.
+ * This function performs initialization for the Tk test suite extensions.
*
* Results:
* Returns a standard Tcl completion code, and leaves an error message in
@@ -332,7 +339,6 @@ Tktest_Init(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TestbitmapObjCmd(
ClientData clientData, /* Main window for application. */
@@ -340,6 +346,7 @@ TestbitmapObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
+ (void)clientData;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "bitmap");
@@ -367,7 +374,6 @@ TestbitmapObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TestborderObjCmd(
ClientData clientData, /* Main window for application. */
@@ -375,6 +381,7 @@ TestborderObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
+ (void)clientData;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "border");
@@ -402,7 +409,6 @@ TestborderObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TestcolorObjCmd(
ClientData clientData, /* Main window for application. */
@@ -410,6 +416,8 @@ TestcolorObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
+ (void)clientData;
+
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "color");
return TCL_ERROR;
@@ -436,7 +444,6 @@ TestcolorObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TestcursorObjCmd(
ClientData clientData, /* Main window for application. */
@@ -444,6 +451,8 @@ TestcursorObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
+ (void)clientData;
+
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "cursor");
return TCL_ERROR;
@@ -471,7 +480,6 @@ TestcursorObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TestdeleteappsObjCmd(
ClientData clientData, /* Main window for application. */
@@ -480,6 +488,10 @@ TestdeleteappsObjCmd(
Tcl_Obj *const objv[]) /* Argument strings. */
{
NewApp *nextPtr;
+ (void)clientData;
+ (void)interp;
+ (void)objc;
+ (void)objv;
while (newAppPtr != NULL) {
nextPtr = newAppPtr->nextPtr;
@@ -508,7 +520,6 @@ TestdeleteappsObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TestobjconfigObjCmd(
ClientData clientData, /* Main window for application. */
@@ -537,7 +548,7 @@ TestobjconfigObjCmd(
CustomOptionFree,
INT2PTR(1)
};
- Tk_Window mainWin = clientData;
+ Tk_Window mainWin = (Tk_Window)clientData;
Tk_Window tkwin;
int index, result = TCL_OK;
@@ -556,9 +567,9 @@ TestobjconfigObjCmd(
} ExtensionWidgetRecord;
static const Tk_OptionSpec baseSpecs[] = {
{TK_OPTION_STRING, "-one", "one", "One", "one",
- Tk_Offset(ExtensionWidgetRecord, base1ObjPtr), -1, 0, NULL, 0},
+ offsetof(ExtensionWidgetRecord, base1ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-two", "two", "Two", "two",
- Tk_Offset(ExtensionWidgetRecord, base2ObjPtr), -1, 0, NULL, 0},
+ offsetof(ExtensionWidgetRecord, base2ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
@@ -600,50 +611,50 @@ TestobjconfigObjCmd(
};
static const Tk_OptionSpec typesSpecs[] = {
{TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", "1",
- Tk_Offset(TypesRecord, booleanPtr), -1, 0, 0, 0x1},
+ offsetof(TypesRecord, booleanPtr), TCL_INDEX_NONE, 0, 0, 0x1},
{TK_OPTION_INT, "-integer", "integer", "Integer", "7",
- Tk_Offset(TypesRecord, integerPtr), -1, 0, 0, 0x2},
+ offsetof(TypesRecord, integerPtr), TCL_INDEX_NONE, 0, 0, 0x2},
{TK_OPTION_DOUBLE, "-double", "double", "Double", "3.14159",
- Tk_Offset(TypesRecord, doublePtr), -1, 0, 0, 0x4},
+ offsetof(TypesRecord, doublePtr), TCL_INDEX_NONE, 0, 0, 0x4},
{TK_OPTION_STRING, "-string", "string", "String",
- "foo", Tk_Offset(TypesRecord, stringPtr), -1,
+ "foo", offsetof(TypesRecord, stringPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x8},
{TK_OPTION_STRING_TABLE,
"-stringtable", "StringTable", "stringTable",
- "one", Tk_Offset(TypesRecord, stringTablePtr), -1,
+ "one", offsetof(TypesRecord, stringTablePtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, stringTable, 0x10},
{TK_OPTION_COLOR, "-color", "color", "Color",
- "red", Tk_Offset(TypesRecord, colorPtr), -1,
+ "red", offsetof(TypesRecord, colorPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, "black", 0x20},
{TK_OPTION_FONT, "-font", "font", "Font", "Helvetica 12",
- Tk_Offset(TypesRecord, fontPtr), -1,
+ offsetof(TypesRecord, fontPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x40},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", "gray50",
- Tk_Offset(TypesRecord, bitmapPtr), -1,
+ offsetof(TypesRecord, bitmapPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x80},
{TK_OPTION_BORDER, "-border", "border", "Border",
- "blue", Tk_Offset(TypesRecord, borderPtr), -1,
+ "blue", offsetof(TypesRecord, borderPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, "white", 0x100},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", "raised",
- Tk_Offset(TypesRecord, reliefPtr), -1,
+ offsetof(TypesRecord, reliefPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x200},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", "xterm",
- Tk_Offset(TypesRecord, cursorPtr), -1,
+ offsetof(TypesRecord, cursorPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x400},
{TK_OPTION_JUSTIFY, "-justify", NULL, NULL, "left",
- Tk_Offset(TypesRecord, justifyPtr), -1,
+ offsetof(TypesRecord, justifyPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x800},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", NULL,
- Tk_Offset(TypesRecord, anchorPtr), -1,
+ offsetof(TypesRecord, anchorPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x1000},
{TK_OPTION_PIXELS, "-pixel", "pixel", "Pixel",
- "1", Tk_Offset(TypesRecord, pixelPtr), -1,
+ "1", offsetof(TypesRecord, pixelPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x2000},
{TK_OPTION_CUSTOM, "-custom", NULL, NULL,
- "", Tk_Offset(TypesRecord, customPtr), -1,
+ "", offsetof(TypesRecord, customPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, &CustomOption, 0x4000},
{TK_OPTION_SYNONYM, "-synonym", NULL, NULL,
- NULL, 0, -1, 0, "-color", 0x8000},
+ NULL, 0, TCL_INDEX_NONE, 0, "-color", 0x8000},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tk_OptionTable optionTable;
@@ -651,14 +662,14 @@ TestobjconfigObjCmd(
optionTable = Tk_CreateOptionTable(interp, typesSpecs);
tables[index] = optionTable;
- tkwin = Tk_CreateWindowFromPath(interp, clientData,
+ tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData,
Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
}
Tk_SetClass(tkwin, "Test");
- recordPtr = ckalloc(sizeof(TypesRecord));
+ recordPtr = (TypesRecord *)ckalloc(sizeof(TypesRecord));
recordPtr->header.interp = interp;
recordPtr->header.optionTable = optionTable;
recordPtr->header.tkwin = tkwin;
@@ -706,7 +717,7 @@ TestobjconfigObjCmd(
Tk_Window tkwin;
Tk_OptionTable optionTable;
- tkwin = Tk_CreateWindowFromPath(interp, clientData,
+ tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData,
Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
@@ -715,7 +726,7 @@ TestobjconfigObjCmd(
optionTable = Tk_CreateOptionTable(interp, baseSpecs);
tables[index] = optionTable;
- recordPtr = ckalloc(sizeof(ExtensionWidgetRecord));
+ recordPtr = (ExtensionWidgetRecord *)ckalloc(sizeof(ExtensionWidgetRecord));
recordPtr->header.interp = interp;
recordPtr->header.optionTable = optionTable;
recordPtr->header.tkwin = tkwin;
@@ -745,21 +756,21 @@ TestobjconfigObjCmd(
ExtensionWidgetRecord *recordPtr;
static const Tk_OptionSpec extensionSpecs[] = {
{TK_OPTION_STRING, "-three", "three", "Three", "three",
- Tk_Offset(ExtensionWidgetRecord, extension3ObjPtr), -1, 0, NULL, 0},
+ offsetof(ExtensionWidgetRecord, extension3ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-four", "four", "Four", "four",
- Tk_Offset(ExtensionWidgetRecord, extension4ObjPtr), -1, 0, NULL, 0},
+ offsetof(ExtensionWidgetRecord, extension4ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-two", "two", "Two", "two and a half",
- Tk_Offset(ExtensionWidgetRecord, base2ObjPtr), -1, 0, NULL, 0},
+ offsetof(ExtensionWidgetRecord, base2ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING,
"-oneAgain", "oneAgain", "OneAgain", "one again",
- Tk_Offset(ExtensionWidgetRecord, extension5ObjPtr), -1, 0, NULL, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0,
+ offsetof(ExtensionWidgetRecord, extension5ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
(ClientData) baseSpecs, 0}
};
Tk_Window tkwin;
Tk_OptionTable optionTable;
- tkwin = Tk_CreateWindowFromPath(interp, clientData,
+ tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData,
Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
@@ -768,7 +779,7 @@ TestobjconfigObjCmd(
optionTable = Tk_CreateOptionTable(interp, extensionSpecs);
tables[index] = optionTable;
- recordPtr = ckalloc(sizeof(ExtensionWidgetRecord));
+ recordPtr = (ExtensionWidgetRecord *)ckalloc(sizeof(ExtensionWidgetRecord));
recordPtr->header.interp = interp;
recordPtr->header.optionTable = optionTable;
recordPtr->header.tkwin = tkwin;
@@ -801,7 +812,7 @@ TestobjconfigObjCmd(
ErrorWidgetRecord widgetRecord;
static const Tk_OptionSpec errorSpecs[] = {
{TK_OPTION_INT, "-int", "integer", "Integer", "bogus",
- Tk_Offset(ErrorWidgetRecord, intPtr), 0, 0, NULL, 0},
+ offsetof(ErrorWidgetRecord, intPtr), 0, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tk_OptionTable optionTable;
@@ -875,53 +886,53 @@ TestobjconfigObjCmd(
};
static const Tk_OptionSpec internalSpecs[] = {
{TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", "1",
- -1, Tk_Offset(InternalRecord, boolean), 0, 0, 0x1},
+ TCL_INDEX_NONE, offsetof(InternalRecord, boolean), 0, 0, 0x1},
{TK_OPTION_INT, "-integer", "integer", "Integer", "148962237",
- -1, Tk_Offset(InternalRecord, integer), 0, 0, 0x2},
+ TCL_INDEX_NONE, offsetof(InternalRecord, integer), 0, 0, 0x2},
{TK_OPTION_DOUBLE, "-double", "double", "Double", "3.14159",
- -1, Tk_Offset(InternalRecord, doubleValue), 0, 0, 0x4},
+ TCL_INDEX_NONE, offsetof(InternalRecord, doubleValue), 0, 0, 0x4},
{TK_OPTION_STRING, "-string", "string", "String", "foo",
- -1, Tk_Offset(InternalRecord, string),
+ TCL_INDEX_NONE, offsetof(InternalRecord, string),
TK_CONFIG_NULL_OK, 0, 0x8},
{TK_OPTION_STRING_TABLE,
"-stringtable", "StringTable", "stringTable", "one",
- -1, Tk_Offset(InternalRecord, index),
+ TCL_INDEX_NONE, offsetof(InternalRecord, index),
TK_CONFIG_NULL_OK, internalStringTable, 0x10},
{TK_OPTION_COLOR, "-color", "color", "Color", "red",
- -1, Tk_Offset(InternalRecord, colorPtr),
+ TCL_INDEX_NONE, offsetof(InternalRecord, colorPtr),
TK_CONFIG_NULL_OK, "black", 0x20},
{TK_OPTION_FONT, "-font", "font", "Font", "Helvetica 12",
- -1, Tk_Offset(InternalRecord, tkfont),
+ TCL_INDEX_NONE, offsetof(InternalRecord, tkfont),
TK_CONFIG_NULL_OK, 0, 0x40},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", "gray50",
- -1, Tk_Offset(InternalRecord, bitmap),
+ TCL_INDEX_NONE, offsetof(InternalRecord, bitmap),
TK_CONFIG_NULL_OK, 0, 0x80},
{TK_OPTION_BORDER, "-border", "border", "Border", "blue",
- -1, Tk_Offset(InternalRecord, border),
+ TCL_INDEX_NONE, offsetof(InternalRecord, border),
TK_CONFIG_NULL_OK, "white", 0x100},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", "raised",
- -1, Tk_Offset(InternalRecord, relief),
+ TCL_INDEX_NONE, offsetof(InternalRecord, relief),
TK_CONFIG_NULL_OK, 0, 0x200},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", "xterm",
- -1, Tk_Offset(InternalRecord, cursor),
+ TCL_INDEX_NONE, offsetof(InternalRecord, cursor),
TK_CONFIG_NULL_OK, 0, 0x400},
{TK_OPTION_JUSTIFY, "-justify", NULL, NULL, "left",
- -1, Tk_Offset(InternalRecord, justify),
+ TCL_INDEX_NONE, offsetof(InternalRecord, justify),
TK_CONFIG_NULL_OK, 0, 0x800},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", NULL,
- -1, Tk_Offset(InternalRecord, anchor),
+ TCL_INDEX_NONE, offsetof(InternalRecord, anchor),
TK_CONFIG_NULL_OK, 0, 0x1000},
{TK_OPTION_PIXELS, "-pixel", "pixel", "Pixel", "1",
- -1, Tk_Offset(InternalRecord, pixels),
+ TCL_INDEX_NONE, offsetof(InternalRecord, pixels),
TK_CONFIG_NULL_OK, 0, 0x2000},
{TK_OPTION_WINDOW, "-window", "window", "Window", NULL,
- -1, Tk_Offset(InternalRecord, tkwin),
+ TCL_INDEX_NONE, offsetof(InternalRecord, tkwin),
TK_CONFIG_NULL_OK, 0, 0},
{TK_OPTION_CUSTOM, "-custom", NULL, NULL, "",
- -1, Tk_Offset(InternalRecord, custom),
+ TCL_INDEX_NONE, offsetof(InternalRecord, custom),
TK_CONFIG_NULL_OK, &CustomOption, 0x4000},
{TK_OPTION_SYNONYM, "-synonym", NULL, NULL,
- NULL, -1, -1, 0, "-color", 0x8000},
+ NULL, TCL_INDEX_NONE, TCL_INDEX_NONE, 0, "-color", 0x8000},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tk_OptionTable optionTable;
@@ -929,14 +940,14 @@ TestobjconfigObjCmd(
optionTable = Tk_CreateOptionTable(interp, internalSpecs);
tables[index] = optionTable;
- tkwin = Tk_CreateWindowFromPath(interp, clientData,
+ tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData,
Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
}
Tk_SetClass(tkwin, "Test");
- recordPtr = ckalloc(sizeof(InternalRecord));
+ recordPtr = (InternalRecord *)ckalloc(sizeof(InternalRecord));
recordPtr->header.interp = interp;
recordPtr->header.optionTable = optionTable;
recordPtr->header.tkwin = tkwin;
@@ -992,15 +1003,15 @@ TestobjconfigObjCmd(
FiveRecord *recordPtr;
static const Tk_OptionSpec smallSpecs[] = {
{TK_OPTION_INT, "-one", "one", "One", "1",
- Tk_Offset(FiveRecord, one), -1, 0, NULL, 0},
+ offsetof(FiveRecord, one), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_INT, "-two", "two", "Two", "2",
- Tk_Offset(FiveRecord, two), -1, 0, NULL, 0},
+ offsetof(FiveRecord, two), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_INT, "-three", "three", "Three", "3",
- Tk_Offset(FiveRecord, three), -1, 0, NULL, 0},
+ offsetof(FiveRecord, three), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_INT, "-four", "four", "Four", "4",
- Tk_Offset(FiveRecord, four), -1, 0, NULL, 0},
+ offsetof(FiveRecord, four), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-five", NULL, NULL, NULL,
- Tk_Offset(FiveRecord, five), -1, 0, NULL, 0},
+ offsetof(FiveRecord, five), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
@@ -1009,7 +1020,7 @@ TestobjconfigObjCmd(
return TCL_ERROR;
}
- recordPtr = ckalloc(sizeof(FiveRecord));
+ recordPtr = (FiveRecord *)ckalloc(sizeof(FiveRecord));
recordPtr->header.interp = interp;
recordPtr->header.optionTable = Tk_CreateOptionTable(interp,
smallSpecs);
@@ -1046,7 +1057,7 @@ TestobjconfigObjCmd(
NotEnoughRecord record;
static const Tk_OptionSpec errorSpecs[] = {
{TK_OPTION_INT, "-foo", "foo", "Foo", "0",
- Tk_Offset(NotEnoughRecord, fooObjPtr), 0, 0, NULL, 0},
+ offsetof(NotEnoughRecord, fooObjPtr), 0, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tcl_Obj *newObjPtr = Tcl_NewStringObj("-foo", -1);
@@ -1077,18 +1088,18 @@ TestobjconfigObjCmd(
SlaveRecord *recordPtr;
static const Tk_OptionSpec slaveSpecs[] = {
{TK_OPTION_WINDOW, "-window", "window", "Window", ".bar",
- Tk_Offset(SlaveRecord, windowPtr), -1, TK_CONFIG_NULL_OK, NULL, 0},
+ offsetof(SlaveRecord, windowPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tk_Window tkwin = Tk_CreateWindowFromPath(interp,
- clientData, Tcl_GetString(objv[2]), NULL);
+ (Tk_Window)clientData, Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
}
Tk_SetClass(tkwin, "Test");
- recordPtr = ckalloc(sizeof(SlaveRecord));
+ recordPtr = (SlaveRecord *)ckalloc(sizeof(SlaveRecord));
recordPtr->header.interp = interp;
recordPtr->header.optionTable = Tk_CreateOptionTable(interp,
slaveSpecs);
@@ -1141,7 +1152,6 @@ TestobjconfigObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TrivialConfigObjCmd(
ClientData clientData, /* Main window for application. */
@@ -1158,7 +1168,7 @@ TrivialConfigObjCmd(
};
Tcl_Obj *resultObjPtr;
int index, mask;
- TrivialCommandHeader *headerPtr = clientData;
+ TrivialCommandHeader *headerPtr = (TrivialCommandHeader *)clientData;
Tk_Window tkwin = headerPtr->tkwin;
Tk_SavedOptions saved;
@@ -1212,7 +1222,7 @@ TrivialConfigObjCmd(
headerPtr->optionTable, objc - 2, objv + 2,
tkwin, NULL, &mask);
if (result == TCL_OK) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(mask));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(mask));
}
}
break;
@@ -1222,7 +1232,7 @@ TrivialConfigObjCmd(
tkwin, &saved, &mask);
Tk_FreeSavedOptions(&saved);
if (result == TCL_OK) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(mask));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(mask));
}
break;
}
@@ -1253,7 +1263,7 @@ static void
TrivialCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TrivialCommandHeader *headerPtr = clientData;
+ TrivialCommandHeader *headerPtr = (TrivialCommandHeader *)clientData;
Tk_Window tkwin = headerPtr->tkwin;
if (tkwin != NULL) {
@@ -1292,7 +1302,7 @@ TrivialEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TrivialCommandHeader *headerPtr = clientData;
+ TrivialCommandHeader *headerPtr = (TrivialCommandHeader *)clientData;
if (eventPtr->type == DestroyNotify) {
if (headerPtr->tkwin != NULL) {
@@ -1324,7 +1334,6 @@ TrivialEventProc(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TestfontObjCmd(
ClientData clientData, /* Main window for application. */
@@ -1338,7 +1347,7 @@ TestfontObjCmd(
Tk_Window tkwin;
Tk_Font tkfont;
- tkwin = clientData;
+ tkwin = (Tk_Window)clientData;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "option fontName");
@@ -1384,7 +1393,6 @@ TestfontObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ImageCreate(
Tcl_Interp *interp, /* Interpreter for application containing
@@ -1402,6 +1410,7 @@ ImageCreate(
TImageMaster *timPtr;
const char *varName;
int i;
+ (void)typePtr;
varName = "log";
for (i = 0; i < objc; i += 2) {
@@ -1418,14 +1427,14 @@ ImageCreate(
varName = Tcl_GetString(objv[i+1]);
}
- timPtr = ckalloc(sizeof(TImageMaster));
+ timPtr = (TImageMaster *)ckalloc(sizeof(TImageMaster));
timPtr->master = master;
timPtr->interp = interp;
timPtr->width = 30;
timPtr->height = 15;
- timPtr->imageName = ckalloc(strlen(name) + 1);
+ timPtr->imageName = (char *)ckalloc(strlen(name) + 1);
strcpy(timPtr->imageName, name);
- timPtr->varName = ckalloc(strlen(varName) + 1);
+ timPtr->varName = (char *)ckalloc(strlen(varName) + 1);
strcpy(timPtr->varName, varName);
Tcl_CreateObjCommand(interp, name, ImageObjCmd, timPtr, NULL);
*clientDataPtr = timPtr;
@@ -1450,7 +1459,6 @@ ImageCreate(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ImageObjCmd(
ClientData clientData, /* Main window for application. */
@@ -1458,7 +1466,7 @@ ImageObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- TImageMaster *timPtr = clientData;
+ TImageMaster *timPtr = (TImageMaster *)clientData;
int x, y, width, height;
if (objc < 2) {
@@ -1513,7 +1521,7 @@ ImageGet(
* used. */
ClientData clientData) /* Pointer to TImageMaster for image. */
{
- TImageMaster *timPtr = clientData;
+ TImageMaster *timPtr = (TImageMaster *)clientData;
TImageInstance *instPtr;
char buffer[100];
XGCValues gcValues;
@@ -1522,7 +1530,7 @@ ImageGet(
Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer,
TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
- instPtr = ckalloc(sizeof(TImageInstance));
+ instPtr = (TImageInstance *)ckalloc(sizeof(TImageInstance));
instPtr->masterPtr = timPtr;
instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000");
gcValues.foreground = instPtr->fg->pixel;
@@ -1560,31 +1568,42 @@ ImageDisplay(
/* Coordinates in drawable corresponding to
* imageX and imageY. */
{
- TImageInstance *instPtr = clientData;
+ TImageInstance *instPtr = (TImageInstance *)clientData;
char buffer[200 + TCL_INTEGER_SPACE * 6];
/*
* The purpose of the test image type is to track the calls to an image
* display proc and record the parameters passed in each call. On macOS
- * these tests will fail because of the asynchronous drawing. The low
- * level graphics calls below which are supposed to draw a rectangle will
- * not draw anything to the screen because the idle task will not be
- * processed inside of the drawRect method and hence will not be able to
- * obtain a valid graphics context. Instead, the window will be marked as
- * needing display, and will be redrawn during a future asynchronous call
- * to drawRect. This will generate an other call to this display proc,
- * and the recorded data will show extra calls, causing the test to fail.
- * To avoid this, we can set the [NSApp simulateDrawing] flag, which will
- * cause all low level drawing routines to return immediately and not
- * schedule the window for drawing later. This flag is cleared by the
- * next call to XSync, which is called by the update command.
+ * a display proc must be run inside of the drawRect method of an NSView
+ * in order for the graphics operations to have any effect. To deal with
+ * this, whenever a display proc is called outside of any drawRect method
+ * it schedules a redraw of the NSView by calling [view setNeedsDisplay:YES].
+ * This will trigger a later call to the view's drawRect method which will
+ * run the display proc a second time.
+ *
+ * This complicates testing, since it can result in more calls to the display
+ * proc than are expected by the test. It can also result in an inconsistent
+ * number of calls unless the test waits until the call to drawRect actually
+ * occurs before validating its results.
+ *
+ * In an attempt to work around this, this display proc only logs those
+ * calls which occur within a drawRect method. This means that tests must
+ * be written so as to ensure that the drawRect method is run before
+ * results are validated. In practice it usually suffices to run update
+ * idletasks (to run the display proc the first time) followed by update
+ * (to run the display proc in drawRect).
+ *
+ * This also has the consequence that the image changed command will log
+ * different results on Aqua than on other systems, because when the image
+ * is redisplayed in the drawRect method the entire image will be drawn,
+ * not just the changed portion. Tests must account for this.
*/
- sprintf(buffer, "%s display %d %d %d %d",
- instPtr->masterPtr->imageName, imageX, imageY, width, height);
- if (!APP_IS_DRAWING) {
+ if (LOG_DISPLAY) {
+ sprintf(buffer, "%s display %d %d %d %d",
+ instPtr->masterPtr->imageName, imageX, imageY, width, height);
Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName,
- NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
+ NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
}
if (width > (instPtr->masterPtr->width - imageX)) {
width = instPtr->masterPtr->width - imageX;
@@ -1624,7 +1643,7 @@ ImageFree(
ClientData clientData, /* Pointer to TImageInstance for instance. */
Display *display) /* Display where image was to be drawn. */
{
- TImageInstance *instPtr = clientData;
+ TImageInstance *instPtr = (TImageInstance *)clientData;
char buffer[200];
sprintf(buffer, "%s free", instPtr->masterPtr->imageName);
@@ -1658,7 +1677,7 @@ ImageDelete(
* this function is called, no more instances
* exist. */
{
- TImageMaster *timPtr = clientData;
+ TImageMaster *timPtr = (TImageMaster *)clientData;
char buffer[100];
sprintf(buffer, "%s delete", timPtr->imageName);
@@ -1689,7 +1708,6 @@ ImageDelete(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TestmakeexistObjCmd(
ClientData clientData, /* Main window for application. */
@@ -1697,7 +1715,7 @@ TestmakeexistObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- Tk_Window mainWin = clientData;
+ Tk_Window mainWin = (Tk_Window)clientData;
int i;
Tk_Window tkwin;
@@ -1730,7 +1748,6 @@ TestmakeexistObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
#if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__))
static int
TestmenubarObjCmd(
@@ -1740,7 +1757,7 @@ TestmenubarObjCmd(
Tcl_Obj *const objv[]) /* Argument strings. */
{
#ifdef __UNIX__
- Tk_Window mainWin = clientData;
+ Tk_Window mainWin = (Tk_Window)clientData;
Tk_Window tkwin, menubar;
if (objc < 2) {
@@ -1800,13 +1817,14 @@ TestmenubarObjCmd(
#if defined(_WIN32)
static int
TestmetricsObjCmd(
- ClientData clientData, /* Main window for application. */
+ ClientData dummy, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
char buf[TCL_INTEGER_SPACE];
int val;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
@@ -1845,7 +1863,6 @@ TestmetricsObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TestpropObjCmd(
ClientData clientData, /* Main window for application. */
@@ -1853,7 +1870,7 @@ TestpropObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- Tk_Window mainWin = clientData;
+ Tk_Window mainWin = (Tk_Window)clientData;
int result, actualFormat;
unsigned long bytesAfter, length, value;
Atom actualType, propName;
@@ -1922,10 +1939,9 @@ TestpropObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TestprintfObjCmd(
- ClientData clientData, /* Not used */
+ ClientData dummy, /* Not used */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -1937,6 +1953,7 @@ TestprintfObjCmd(
#else
long long longLongInt;
#endif
+ (void)dummy;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "wideint");
@@ -1978,7 +1995,6 @@ TestprintfObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TestwrapperObjCmd(
ClientData clientData, /* Main window for application. */
@@ -1994,7 +2010,7 @@ TestwrapperObjCmd(
return TCL_ERROR;
}
- tkwin = clientData;
+ tkwin = (Tk_Window)clientData;
winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[1]), tkwin);
if (winPtr == NULL) {
return TCL_ERROR;
@@ -2039,7 +2055,7 @@ TestwrapperObjCmd(
static int
CustomOptionSet(
- ClientData clientData,
+ ClientData dummy,
Tcl_Interp *interp,
Tk_Window tkwin,
Tcl_Obj **value,
@@ -2050,6 +2066,8 @@ CustomOptionSet(
{
int objEmpty;
char *newStr, *string, *internalPtr;
+ (void)dummy;
+ (void)tkwin;
objEmpty = 0;
@@ -2086,7 +2104,7 @@ CustomOptionSet(
if (internalPtr != NULL) {
if (*value != NULL) {
string = Tcl_GetString(*value);
- newStr = ckalloc((*value)->length + 1);
+ newStr = (char *)ckalloc((*value)->length + 1);
strcpy(newStr, string);
} else {
newStr = NULL;
@@ -2100,31 +2118,40 @@ CustomOptionSet(
static Tcl_Obj *
CustomOptionGet(
- ClientData clientData,
+ ClientData dummy,
Tk_Window tkwin,
char *recordPtr,
int internalOffset)
{
+ (void)dummy;
+ (void)tkwin;
+
return (Tcl_NewStringObj(*(char **)(recordPtr + internalOffset), -1));
}
static void
CustomOptionRestore(
- ClientData clientData,
+ ClientData dummy,
Tk_Window tkwin,
char *internalPtr,
char *saveInternalPtr)
{
+ (void)dummy;
+ (void)tkwin;
+
*(char **)internalPtr = *(char **)saveInternalPtr;
return;
}
static void
CustomOptionFree(
- ClientData clientData,
+ ClientData dummy,
Tk_Window tkwin,
char *internalPtr)
{
+ (void)dummy;
+ (void)tkwin;
+
if (*(char **)internalPtr != NULL) {
ckfree(*(char **)internalPtr);
}
@@ -2150,7 +2177,6 @@ CustomOptionFree(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
TestPhotoStringMatchCmd(
ClientData clientData, /* Main window for application. */
@@ -2161,14 +2187,15 @@ TestPhotoStringMatchCmd(
Tcl_Obj *dummy = NULL;
Tcl_Obj *resultObj[2];
int width, height;
+ (void)clientData;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "imageData");
return TCL_ERROR;
}
if (TkDebugPhotoStringMatchDef(interp, objv[1], dummy, &width, &height)) {
- resultObj[0] = Tcl_NewIntObj(width);
- resultObj[1] = Tcl_NewIntObj(height);
+ resultObj[0] = Tcl_NewWideIntObj(width);
+ resultObj[1] = Tcl_NewWideIntObj(height);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, resultObj));
return TCL_OK;
} else {
diff --git a/generic/tkText.c b/generic/tkText.c
index fc63992..882225f 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -121,139 +121,139 @@ static const Tk_ObjCustomOption lineOption = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BOOLEAN, "-autoseparators", "autoSeparators",
- "AutoSeparators", DEF_TEXT_AUTO_SEPARATORS, -1,
- Tk_Offset(TkText, autoSeparators),
+ "AutoSeparators", DEF_TEXT_AUTO_SEPARATORS, TCL_INDEX_NONE,
+ offsetof(TkText, autoSeparators),
TK_OPTION_DONT_SET_DEFAULT, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_TEXT_BG_COLOR, -1, Tk_Offset(TkText, border),
+ DEF_TEXT_BG_COLOR, TCL_INDEX_NONE, offsetof(TkText, border),
0, DEF_TEXT_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth",
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth",
TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BOOLEAN, "-blockcursor", "blockCursor",
- "BlockCursor", DEF_TEXT_BLOCK_CURSOR, -1,
- Tk_Offset(TkText, insertCursorType), 0, 0, 0},
+ "BlockCursor", DEF_TEXT_BLOCK_CURSOR, TCL_INDEX_NONE,
+ offsetof(TkText, insertCursorType), 0, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_TEXT_BORDER_WIDTH, -1, Tk_Offset(TkText, borderWidth),
+ DEF_TEXT_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(TkText, borderWidth),
0, 0, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_TEXT_CURSOR, -1, Tk_Offset(TkText, cursor),
+ DEF_TEXT_CURSOR, TCL_INDEX_NONE, offsetof(TkText, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CUSTOM, "-endline", NULL, NULL,
- NULL, -1, Tk_Offset(TkText, end), TK_OPTION_NULL_OK,
+ NULL, TCL_INDEX_NONE, offsetof(TkText, end), TK_OPTION_NULL_OK,
&lineOption, TK_TEXT_LINE_RANGE},
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_TEXT_EXPORT_SELECTION, -1,
- Tk_Offset(TkText, exportSelection), 0, 0, 0},
+ "ExportSelection", DEF_TEXT_EXPORT_SELECTION, TCL_INDEX_NONE,
+ offsetof(TkText, exportSelection), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_TEXT_FONT, -1, Tk_Offset(TkText, tkfont), 0, 0,
+ DEF_TEXT_FONT, TCL_INDEX_NONE, offsetof(TkText, tkfont), 0, 0,
TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_TEXT_FG, -1, Tk_Offset(TkText, fgColor), 0,
+ DEF_TEXT_FG, TCL_INDEX_NONE, offsetof(TkText, fgColor), 0,
0, 0},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- DEF_TEXT_HEIGHT, -1, Tk_Offset(TkText, height), 0, 0, 0},
+ DEF_TEXT_HEIGHT, TCL_INDEX_NONE, offsetof(TkText, height), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_TEXT_HIGHLIGHT_BG,
- -1, Tk_Offset(TkText, highlightBgColorPtr),
+ TCL_INDEX_NONE, offsetof(TkText, highlightBgColorPtr),
0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_TEXT_HIGHLIGHT, -1, Tk_Offset(TkText, highlightColorPtr),
+ DEF_TEXT_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkText, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_TEXT_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(TkText, highlightWidth), 0, 0, TK_TEXT_LINE_GEOMETRY},
+ "HighlightThickness", DEF_TEXT_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(TkText, highlightWidth), 0, 0, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_BORDER, "-inactiveselectbackground","inactiveSelectBackground",
"Foreground",
DEF_TEXT_INACTIVE_SELECT_COLOR,
- -1, Tk_Offset(TkText, inactiveSelBorder),
+ TCL_INDEX_NONE, offsetof(TkText, inactiveSelBorder),
TK_OPTION_NULL_OK, DEF_TEXT_SELECT_MONO, 0},
{TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
DEF_TEXT_INSERT_BG,
- -1, Tk_Offset(TkText, insertBorder),
+ TCL_INDEX_NONE, offsetof(TkText, insertBorder),
0, 0, 0},
{TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth",
- "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, -1,
- Tk_Offset(TkText, insertBorderWidth), 0,
+ "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(TkText, insertBorderWidth), 0,
(ClientData) DEF_TEXT_INSERT_BD_MONO, 0},
{TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_TEXT_INSERT_OFF_TIME, -1, Tk_Offset(TkText, insertOffTime),
+ DEF_TEXT_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(TkText, insertOffTime),
0, 0, 0},
{TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_TEXT_INSERT_ON_TIME, -1, Tk_Offset(TkText, insertOnTime),
+ DEF_TEXT_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(TkText, insertOnTime),
0, 0, 0},
{TK_OPTION_STRING_TABLE,
"-insertunfocussed", "insertUnfocussed", "InsertUnfocussed",
- DEF_TEXT_INSERT_UNFOCUSSED, -1, Tk_Offset(TkText, insertUnfocussed),
+ DEF_TEXT_INSERT_UNFOCUSSED, TCL_INDEX_NONE, offsetof(TkText, insertUnfocussed),
0, insertUnfocussedStrings, 0},
{TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_TEXT_INSERT_WIDTH, -1, Tk_Offset(TkText, insertWidth),
+ DEF_TEXT_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(TkText, insertWidth),
0, 0, 0},
{TK_OPTION_INT, "-maxundo", "maxUndo", "MaxUndo",
- DEF_TEXT_MAX_UNDO, -1, Tk_Offset(TkText, maxUndo),
+ DEF_TEXT_MAX_UNDO, TCL_INDEX_NONE, offsetof(TkText, maxUndo),
TK_OPTION_DONT_SET_DEFAULT, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_TEXT_PADX, -1, Tk_Offset(TkText, padX), 0, 0,
+ DEF_TEXT_PADX, TCL_INDEX_NONE, offsetof(TkText, padX), 0, 0,
TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_TEXT_PADY, -1, Tk_Offset(TkText, padY), 0, 0, 0},
+ DEF_TEXT_PADY, TCL_INDEX_NONE, offsetof(TkText, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_TEXT_RELIEF, -1, Tk_Offset(TkText, relief), 0, 0, 0},
+ DEF_TEXT_RELIEF, TCL_INDEX_NONE, offsetof(TkText, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_TEXT_SELECT_COLOR, -1, Tk_Offset(TkText, selBorder),
+ DEF_TEXT_SELECT_COLOR, TCL_INDEX_NONE, offsetof(TkText, selBorder),
0, DEF_TEXT_SELECT_MONO, 0},
{TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
"BorderWidth", DEF_TEXT_SELECT_BD_COLOR,
- Tk_Offset(TkText, selBorderWidthPtr),
- Tk_Offset(TkText, selBorderWidth),
+ offsetof(TkText, selBorderWidthPtr),
+ offsetof(TkText, selBorderWidth),
TK_OPTION_NULL_OK, DEF_TEXT_SELECT_BD_MONO, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_TEXT_SELECT_FG_COLOR, -1, Tk_Offset(TkText, selFgColorPtr),
+ DEF_TEXT_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(TkText, selFgColorPtr),
TK_OPTION_NULL_OK, DEF_TEXT_SELECT_FG_MONO, 0},
{TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid",
- DEF_TEXT_SET_GRID, -1, Tk_Offset(TkText, setGrid), 0, 0, 0},
+ DEF_TEXT_SET_GRID, TCL_INDEX_NONE, offsetof(TkText, setGrid), 0, 0, 0},
{TK_OPTION_PIXELS, "-spacing1", "spacing1", "Spacing",
- DEF_TEXT_SPACING1, -1, Tk_Offset(TkText, spacing1),
+ DEF_TEXT_SPACING1, TCL_INDEX_NONE, offsetof(TkText, spacing1),
0, 0 , TK_TEXT_LINE_GEOMETRY },
{TK_OPTION_PIXELS, "-spacing2", "spacing2", "Spacing",
- DEF_TEXT_SPACING2, -1, Tk_Offset(TkText, spacing2),
+ DEF_TEXT_SPACING2, TCL_INDEX_NONE, offsetof(TkText, spacing2),
0, 0 , TK_TEXT_LINE_GEOMETRY },
{TK_OPTION_PIXELS, "-spacing3", "spacing3", "Spacing",
- DEF_TEXT_SPACING3, -1, Tk_Offset(TkText, spacing3),
+ DEF_TEXT_SPACING3, TCL_INDEX_NONE, offsetof(TkText, spacing3),
0, 0 , TK_TEXT_LINE_GEOMETRY },
{TK_OPTION_CUSTOM, "-startline", NULL, NULL,
- NULL, -1, Tk_Offset(TkText, start), TK_OPTION_NULL_OK,
+ NULL, TCL_INDEX_NONE, offsetof(TkText, start), TK_OPTION_NULL_OK,
&lineOption, TK_TEXT_LINE_RANGE},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_TEXT_STATE, -1, Tk_Offset(TkText, state),
+ DEF_TEXT_STATE, TCL_INDEX_NONE, offsetof(TkText, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-tabs", "tabs", "Tabs",
- DEF_TEXT_TABS, Tk_Offset(TkText, tabOptionPtr), -1,
+ DEF_TEXT_TABS, offsetof(TkText, tabOptionPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_STRING_TABLE, "-tabstyle", "tabStyle", "TabStyle",
- DEF_TEXT_TABSTYLE, -1, Tk_Offset(TkText, tabStyle),
+ DEF_TEXT_TABSTYLE, TCL_INDEX_NONE, offsetof(TkText, tabStyle),
0, tabStyleStrings, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_TEXT_TAKE_FOCUS, -1, Tk_Offset(TkText, takeFocus),
+ DEF_TEXT_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(TkText, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-undo", "undo", "Undo",
- DEF_TEXT_UNDO, -1, Tk_Offset(TkText, undo),
+ DEF_TEXT_UNDO, TCL_INDEX_NONE, offsetof(TkText, undo),
TK_OPTION_DONT_SET_DEFAULT, 0 , 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_TEXT_WIDTH, -1, Tk_Offset(TkText, width), 0, 0,
+ DEF_TEXT_WIDTH, TCL_INDEX_NONE, offsetof(TkText, width), 0, 0,
TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_STRING_TABLE, "-wrap", "wrap", "Wrap",
- DEF_TEXT_WRAP, -1, Tk_Offset(TkText, wrapMode),
+ DEF_TEXT_WRAP, TCL_INDEX_NONE, offsetof(TkText, wrapMode),
0, wrapStrings, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_TEXT_XSCROLL_COMMAND, -1, Tk_Offset(TkText, xScrollCmd),
+ DEF_TEXT_XSCROLL_COMMAND, TCL_INDEX_NONE, offsetof(TkText, xScrollCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- DEF_TEXT_YSCROLL_COMMAND, -1, Tk_Offset(TkText, yScrollCmd),
+ DEF_TEXT_YSCROLL_COMMAND, TCL_INDEX_NONE, offsetof(TkText, yScrollCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0}
};
@@ -461,7 +461,7 @@ Tk_TextObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -502,7 +502,7 @@ CreateWidget(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register TkText *textPtr;
+ TkText *textPtr;
Tk_OptionTable optionTable;
TkTextIndex startIndex;
Tk_Window newWin;
@@ -523,7 +523,7 @@ CreateWidget(
* and 'insert', 'current' mark pointers are all NULL to start.
*/
- textPtr = ckalloc(sizeof(TkText));
+ textPtr = (TkText *)ckalloc(sizeof(TkText));
memset(textPtr, 0, sizeof(TkText));
textPtr->tkwin = newWin;
@@ -534,7 +534,7 @@ CreateWidget(
textPtr, TextCmdDeletedProc);
if (sharedPtr == NULL) {
- sharedPtr = ckalloc(sizeof(TkSharedText));
+ sharedPtr = (TkSharedText *)ckalloc(sizeof(TkSharedText));
memset(sharedPtr, 0, sizeof(TkSharedText));
sharedPtr->refCount = 0;
@@ -632,7 +632,7 @@ CreateWidget(
*/
textPtr->selTagPtr = TkTextCreateTag(textPtr, "sel", NULL);
- textPtr->selTagPtr->reliefString =
+ textPtr->selTagPtr->reliefString = (char *)
ckalloc(sizeof(DEF_TEXT_SELECT_RELIEF));
strcpy(textPtr->selTagPtr->reliefString, DEF_TEXT_SELECT_RELIEF);
Tk_GetRelief(interp, DEF_TEXT_SELECT_RELIEF, &textPtr->selTagPtr->relief);
@@ -699,7 +699,7 @@ TextWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
int result = TCL_OK;
int index;
@@ -748,10 +748,10 @@ TextWidgetObjCmd(
NULL) == 0) {
Tcl_Obj *listObj = Tcl_NewListObj(0, NULL);
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(x));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(y));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(width));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(height));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(x));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(y));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(width));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(height));
Tcl_SetObjResult(interp, listObj);
}
@@ -864,7 +864,7 @@ TextWidgetObjCmd(
for (i = 2; i < objc-2; i++) {
int value;
- size_t length;
+ TkSizeT length;
const char *option = TkGetStringFromObj(objv[i], &length);
char c;
@@ -1019,7 +1019,7 @@ TextWidgetObjCmd(
countDone:
found++;
if (found == 1) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(value));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(value));
} else {
if (found == 2) {
/*
@@ -1031,7 +1031,7 @@ TextWidgetObjCmd(
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_GetObjResult(interp));
}
- Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewIntObj(value));
+ Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewWideIntObj(value));
}
}
@@ -1043,7 +1043,7 @@ TextWidgetObjCmd(
int value = CountIndices(textPtr, indexFromPtr, indexToPtr,
COUNT_INDICES);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(value));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(value));
} else if (found > 1) {
Tcl_SetObjResult(interp, objPtr);
}
@@ -1125,7 +1125,7 @@ TextWidgetObjCmd(
objc -= 2;
objv += 2;
- indices = ckalloc((objc + 1) * sizeof(TkTextIndex));
+ indices = (TkTextIndex *)ckalloc((objc + 1) * sizeof(TkTextIndex));
/*
* First pass verifies that all indices are valid.
@@ -1153,7 +1153,7 @@ TextWidgetObjCmd(
COUNT_INDICES);
objc++;
}
- useIdx = ckalloc(objc);
+ useIdx = (char *)ckalloc(objc);
memset(useIdx, 0, objc);
/*
@@ -1239,11 +1239,11 @@ TextWidgetObjCmd(
&base) == 0) {
Tcl_Obj *listObj = Tcl_NewListObj(0, NULL);
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(x));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(y));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(width));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(height));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(base));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(x));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(y));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(width));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(height));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(base));
Tcl_SetObjResult(interp, listObj);
}
@@ -1259,7 +1259,7 @@ TextWidgetObjCmd(
Tcl_Obj *objPtr = NULL;
int i, found = 0, visible = 0;
const char *name;
- size_t length;
+ TkSizeT length;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -1607,7 +1607,7 @@ SharedTextObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register TkSharedText *sharedPtr = clientData;
+ TkSharedText *sharedPtr = (TkSharedText *)clientData;
int result = TCL_OK;
int index;
@@ -1977,7 +1977,7 @@ DestroyText(
for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->windowTable, &search);
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
TkTextEmbWindowClient *loop;
- TkTextSegment *ewPtr = Tcl_GetHashValue(hPtr);
+ TkTextSegment *ewPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
loop = ewPtr->body.ew.clients;
if (loop->textPtr == textPtr) {
@@ -2009,7 +2009,7 @@ DestroyText(
for (hPtr = Tcl_FirstHashEntry(&sharedTextPtr->tagTable, &search);
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- tagPtr = Tcl_GetHashValue(hPtr);
+ tagPtr = (TkTextTag *)Tcl_GetHashValue(hPtr);
/*
* No need to use 'TkTextDeleteTag' since we've already removed
@@ -2075,7 +2075,7 @@ DestroyText(
static int
ConfigureText(
Tcl_Interp *interp, /* Used for error reporting. */
- register TkText *textPtr, /* Information about widget; may or may not
+ TkText *textPtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -2378,7 +2378,7 @@ static void
TextWorldChangedCallback(
ClientData instanceData) /* Information about widget. */
{
- TkText *textPtr = instanceData;
+ TkText *textPtr = (TkText *)instanceData;
TextWorldChanged(textPtr, TK_TEXT_LINE_GEOMETRY);
}
@@ -2467,9 +2467,9 @@ TextWorldChanged(
static void
TextEventProc(
ClientData clientData, /* Information about window. */
- register XEvent *eventPtr) /* Information about event. */
+ XEvent *eventPtr) /* Information about event. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
TkTextIndex index, index2;
if (eventPtr->type == Expose) {
@@ -2578,7 +2578,7 @@ static void
TextCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
Tk_Window tkwin = textPtr->tkwin;
/*
@@ -2631,7 +2631,7 @@ InsertChars(
int viewUpdate) /* Update the view if set. */
{
int lineIndex;
- size_t length;
+ TkSizeT length;
TkText *tPtr;
int *lineAndByteIndex;
int resetViewCount;
@@ -2663,7 +2663,7 @@ InsertChars(
resetViewCount = 0;
if (sharedTextPtr->refCount > PIXEL_CLIENTS) {
- lineAndByteIndex = ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount);
+ lineAndByteIndex = (int *)ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount);
} else {
lineAndByteIndex = pixels;
}
@@ -2780,7 +2780,7 @@ TextPushUndoAction(
int canUndo, canRedo;
char lMarkName[20] = "tk::undoMarkL";
char rMarkName[20] = "tk::undoMarkR";
- char stringUndoMarkId[7] = "";
+ char stringUndoMarkId[16] = "";
/*
* Create the helpers.
@@ -2961,7 +2961,7 @@ TextUndoRedoCallback(
Tcl_Obj *objPtr) /* Arguments of a command to be handled by the
* shared text data structure. */
{
- TkSharedText *sharedPtr = clientData;
+ TkSharedText *sharedPtr = (TkSharedText *)clientData;
int res, objc;
Tcl_Obj **objv;
TkText *textPtr;
@@ -3200,9 +3200,7 @@ DeleteIndexRange(
for (i=0, hPtr=Tcl_FirstHashEntry(&sharedTextPtr->tagTable, &search);
hPtr != NULL; i++, hPtr = Tcl_NextHashEntry(&search)) {
- TkTextTag *tagPtr = Tcl_GetHashValue(hPtr);
-
- TkBTreeTag(&index1, &index2, tagPtr, 0);
+ TkBTreeTag(&index1, &index2, (TkTextTag *)Tcl_GetHashValue(hPtr), 0);
}
/*
@@ -3236,7 +3234,7 @@ DeleteIndexRange(
resetViewCount = 0;
if (sharedTextPtr->refCount > PIXEL_CLIENTS) {
- lineAndByteIndex = ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount);
+ lineAndByteIndex = (int *)ckalloc(sizeof(int) * 2 * sharedTextPtr->refCount);
} else {
lineAndByteIndex = pixels;
}
@@ -3425,7 +3423,7 @@ TextFetchSelection(
* not including terminating NULL
* character. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
TkTextIndex eof;
int count, chunkSize, offsetInSeg;
TkTextSearch search;
@@ -3509,7 +3507,7 @@ TextFetchSelection(
if ((segPtr->typePtr == &tkTextCharType)
&& !TkTextIsElided(textPtr, &textPtr->selIndex, NULL)) {
memcpy(buffer, segPtr->body.chars + offsetInSeg,
- (size_t) chunkSize);
+ chunkSize);
buffer += chunkSize;
maxBytes -= chunkSize;
count += chunkSize;
@@ -3556,7 +3554,7 @@ void
TkTextLostSelection(
ClientData clientData) /* Information about text widget. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
if (TkpAlwaysShowSelection(textPtr->tkwin)) {
TkTextIndex start, end;
@@ -3641,7 +3639,7 @@ static void
TextBlinkProc(
ClientData clientData) /* Pointer to record describing text. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
TkTextIndex index;
int x, y, w, h, charWidth;
@@ -4021,7 +4019,7 @@ TextSearchGetLineIndex(
{
const TkTextIndex *indexPtr;
int line;
- TkText *textPtr = searchSpecPtr->clientData;
+ TkText *textPtr = (TkText *)searchSpecPtr->clientData;
indexPtr = TkTextGetIndexFromObj(interp, textPtr, objPtr);
if (indexPtr == NULL) {
@@ -4086,7 +4084,7 @@ TextSearchIndexInLine(
TkTextSegment *segPtr;
TkTextIndex curIndex;
int index, leftToScan;
- TkText *textPtr = searchSpecPtr->clientData;
+ TkText *textPtr = (TkText *)searchSpecPtr->clientData;
index = 0;
curIndex.tree = textPtr->sharedTextPtr->tree;
@@ -4156,7 +4154,7 @@ TextSearchAddNextLine(
TkTextLine *linePtr, *thisLinePtr;
TkTextIndex curIndex;
TkTextSegment *segPtr;
- TkText *textPtr = searchSpecPtr->clientData;
+ TkText *textPtr = (TkText *)searchSpecPtr->clientData;
int nothingYet = 1;
/*
@@ -4273,12 +4271,12 @@ TextSearchFoundMatch(
int matchLength) /* Length also in bytes/chars as per search
* type. */
{
- int numChars;
+ TkSizeT numChars;
int leftToScan;
TkTextIndex curIndex, foundIndex;
TkTextSegment *segPtr;
TkTextLine *linePtr;
- TkText *textPtr = searchSpecPtr->clientData;
+ TkText *textPtr = (TkText *)searchSpecPtr->clientData;
if (lineNum == searchSpecPtr->stopLine) {
/*
@@ -4313,7 +4311,7 @@ TextSearchFoundMatch(
if (searchSpecPtr->strictLimits && lineNum == searchSpecPtr->stopLine) {
if (searchSpecPtr->backwards ^
- ((matchOffset + numChars) > searchSpecPtr->stopOffset)) {
+ ((matchOffset + numChars + 1) > (TkSizeT) searchSpecPtr->stopOffset + 1)) {
return 0;
}
}
@@ -4329,7 +4327,7 @@ TextSearchFoundMatch(
* reached the end of the match or we have reached the end of the line.
*/
- linePtr = clientData;
+ linePtr = (TkTextLine *)clientData;
if (linePtr == NULL) {
linePtr = TkBTreeFindLine(textPtr->sharedTextPtr->tree, textPtr,
lineNum);
@@ -4466,7 +4464,7 @@ TextSearchFoundMatch(
*/
if (searchSpecPtr->varPtr != NULL) {
- Tcl_Obj *tmpPtr = Tcl_NewIntObj(numChars);
+ Tcl_Obj *tmpPtr = Tcl_NewWideIntObj(numChars);
if (searchSpecPtr->all) {
if (searchSpecPtr->countPtr == NULL) {
searchSpecPtr->countPtr = Tcl_NewObj();
@@ -4539,7 +4537,7 @@ TkTextGetTabs(
* Parse the elements of the list one at a time to fill in the array.
*/
- tabArrayPtr = ckalloc(sizeof(TkTextTabArray)
+ tabArrayPtr = (TkTextTabArray *)ckalloc(sizeof(TkTextTabArray)
+ (count - 1) * sizeof(TkTextTab));
tabArrayPtr->numTabs = 0;
prevStop = 0.0;
@@ -4666,7 +4664,7 @@ TkTextGetTabs(
static int
TextDumpCmd(
- register TkText *textPtr, /* Information about text widget. */
+ TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
@@ -4753,7 +4751,7 @@ TextDumpCmd(
if (objc == arg) {
TkTextIndexForwChars(NULL, &index1, 1, &index2, COUNT_INDICES);
} else {
- size_t length;
+ TkSizeT length;
const char *str;
if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) {
@@ -4903,7 +4901,7 @@ DumpLine(
*/
int length = last - first;
- char *range = ckalloc(length + 1);
+ char *range = (char *)ckalloc(length + 1);
memcpy(range, segPtr->body.chars + first, length);
range[length] = '\0';
@@ -4934,7 +4932,7 @@ DumpLine(
name = NULL;
lineChanged = 0;
} else {
- name = Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable,
+ name = (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable,
markPtr->hPtr);
}
if (name != NULL) {
@@ -4971,7 +4969,7 @@ DumpLine(
TkTextEmbWindow *ewPtr = &segPtr->body.ew;
const char *pathname;
- if (ewPtr->tkwin == (Tk_Window) NULL) {
+ if (ewPtr->tkwin == NULL) {
pathname = "";
} else {
pathname = Tk_PathName(ewPtr->tkwin);
@@ -5064,6 +5062,7 @@ DumpSegment(
{
char buffer[TK_POS_CHARS];
Tcl_Obj *values[3], *tuple;
+ (void)what;
TkTextPrintIndex(textPtr, index, buffer);
values[0] = Tcl_NewStringObj(key, -1);
@@ -5402,11 +5401,6 @@ TextEditCmd(
* appending several thousand lines, we could attempt to pre-allocate a
* larger space).
*
- * Also the result is built up as a utf-8 string, but, if we knew we
- * wanted it as Unicode, we could potentially save a huge conversion by
- * building it up as Unicode directly. This could be as simple as
- * replacing Tcl_NewObj by Tcl_NewUnicodeObj.
- *
* Results:
* Tcl_Obj of string type containing the specified text. If the
* visibleOnly flag is set to 1, then only those characters which are not
@@ -5604,7 +5598,7 @@ void
TkTextRunAfterSyncCmd(
ClientData clientData) /* Information about text widget. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
int code;
if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) {
@@ -5678,7 +5672,7 @@ SearchPerform(
if (toPtr != NULL) {
const TkTextIndex *indexToPtr, *indexFromPtr;
- TkText *textPtr = searchSpecPtr->clientData;
+ TkText *textPtr = (TkText *)searchSpecPtr->clientData;
indexToPtr = TkTextGetIndexFromObj(interp, textPtr, toPtr);
if (indexToPtr == NULL) {
@@ -5759,7 +5753,8 @@ SearchCore(
* they are Unicode char offsets.
*/
- int firstOffset, lastOffset, matchOffset, matchLength;
+ int firstOffset, lastOffset;
+ TkSizeT matchOffset, matchLength;
int passes;
int lineNum = searchSpecPtr->startLine;
int code = TCL_OK;
@@ -5780,9 +5775,9 @@ SearchCore(
#define LOTS_OF_MATCHES 20
int matchNum = LOTS_OF_MATCHES;
- int smArray[2 * LOTS_OF_MATCHES];
- int *storeMatch = smArray;
- int *storeLength = smArray + LOTS_OF_MATCHES;
+ TkSizeT smArray[2 * LOTS_OF_MATCHES];
+ TkSizeT *storeMatch = smArray;
+ TkSizeT *storeLength = smArray + LOTS_OF_MATCHES;
int lastBackwardsLineMatch = -1;
int lastBackwardsMatchOffset = -1;
@@ -5832,7 +5827,7 @@ SearchCore(
* it has dual purpose.
*/
- pattern = Tcl_GetStringFromObj(patObj, &matchLength);
+ pattern = TkGetStringFromObj(patObj, &matchLength);
nl = strchr(pattern, '\n');
/*
@@ -5957,7 +5952,7 @@ SearchCore(
* begin.
*/
- matchOffset = -1;
+ matchOffset = TCL_INDEX_NONE;
if (searchSpecPtr->exact) {
int maxExtraLines = 0;
@@ -5967,11 +5962,11 @@ SearchCore(
do {
int ch;
const char *p;
- int lastFullLine = lastOffset;
+ TkSizeT lastFullLine = lastOffset;
if (firstNewLine == -1) {
if (searchSpecPtr->strictLimits
- && (firstOffset + matchLength > lastOffset)) {
+ && (firstOffset + matchLength + 1 > (TkSizeT)lastOffset + 1)) {
/*
* Not enough characters to match.
*/
@@ -6001,7 +5996,7 @@ SearchCore(
}
while (p >= startOfLine + firstOffset) {
if (matchLength == 0 || (p[0] == c && !strncmp(
- p, pattern, (size_t) matchLength))) {
+ p, pattern, matchLength))) {
goto backwardsMatch;
}
p--;
@@ -6030,7 +6025,7 @@ SearchCore(
*/
p = startOfLine + lastOffset - firstNewLine - 1;
- if (strncmp(p, pattern, (unsigned) firstNewLine + 1)) {
+ if (strncmp(p, pattern, firstNewLine + 1)) {
/*
* No match.
*/
@@ -6089,14 +6084,14 @@ SearchCore(
* exact searches.
*/
- if ((lastTotal - skipFirst) >= matchLength) {
+ if ((TkSizeT)lastTotal - skipFirst + 1 >= matchLength + 1) {
/*
* We now have enough text to match, so we
* make a final test and break whatever the
* result.
*/
- if (strncmp(p,pattern,(size_t)matchLength)) {
+ if (strncmp(p, pattern, matchLength)) {
p = NULL;
}
break;
@@ -6171,7 +6166,7 @@ SearchCore(
}
} else {
firstOffset = matchLength ? p - startOfLine + matchLength
- : p - startOfLine + 1;
+ : p - startOfLine + (TkSizeT)1;
if (firstOffset >= lastOffset) {
/*
* Now, we have to be careful not to find
@@ -6211,7 +6206,7 @@ SearchCore(
do {
Tcl_RegExpInfo info;
int match;
- int lastFullLine = lastOffset;
+ TkSizeT lastFullLine = lastOffset;
match = Tcl_RegExpExecObj(interp, regexp, theLine,
firstOffset, 1, (firstOffset>0 ? TCL_REG_NOTBOL : 0));
@@ -6229,9 +6224,9 @@ SearchCore(
if (!match ||
((info.extendStart == info.matches[0].start)
- && (info.matches[0].end == lastOffset-firstOffset))) {
+ && (info.matches[0].end == (TkSizeT) (lastOffset - firstOffset)))) {
int extraLines = 0;
- int prevFullLine;
+ TkSizeT prevFullLine;
/*
* If we find a match that overlaps more than one line, we
@@ -6247,7 +6242,7 @@ SearchCore(
lastNonOverlap = lastTotal;
}
- if (info.extendStart < 0) {
+ if (info.extendStart == TCL_INDEX_NONE) {
/*
* No multi-line match is possible.
*/
@@ -6344,9 +6339,9 @@ SearchCore(
*/
if ((match &&
- firstOffset+info.matches[0].end != lastTotal &&
- firstOffset+info.matches[0].end < prevFullLine)
- || info.extendStart < 0) {
+ firstOffset + info.matches[0].end != (TkSizeT) lastTotal &&
+ firstOffset + info.matches[0].end + 1 < prevFullLine + 1)
+ || info.extendStart == TCL_INDEX_NONE) {
break;
}
@@ -6357,7 +6352,7 @@ SearchCore(
* that line.
*/
- if (match && (info.matches[0].start >= lastOffset)) {
+ if (match && (info.matches[0].start + 1 >= (TkSizeT) lastOffset + 1)) {
break;
}
if (match && ((firstOffset + info.matches[0].end)
@@ -6414,8 +6409,8 @@ SearchCore(
* Possible overlap or enclosure.
*/
- if (thisOffset-lastNonOverlap >=
- lastBackwardsMatchOffset+matchLength){
+ if ((TkSizeT)thisOffset - lastNonOverlap >=
+ lastBackwardsMatchOffset + matchLength + 1){
/*
* Totally encloses previous match, so
* forget the previous match.
@@ -6496,12 +6491,12 @@ SearchCore(
* previous match.
*/
- if (matchOffset == -1 ||
+ if (matchOffset == TCL_INDEX_NONE ||
((searchSpecPtr->all || searchSpecPtr->backwards)
- && ((firstOffset < matchOffset)
+ && (((TkSizeT)firstOffset + 1 < matchOffset + 1)
|| ((firstOffset + info.matches[0].end
- info.matches[0].start)
- > (matchOffset + matchLength))))) {
+ > matchOffset + matchLength)))) {
matchOffset = firstOffset;
matchLength = info.matches[0].end - info.matches[0].start;
@@ -6519,11 +6514,11 @@ SearchCore(
* matches on the heap.
*/
- int *newArray =
- ckalloc(4 * matchNum * sizeof(int));
- memcpy(newArray, storeMatch, matchNum*sizeof(int));
+ TkSizeT *newArray = (TkSizeT *)
+ ckalloc(4 * matchNum * sizeof(TkSizeT));
+ memcpy(newArray, storeMatch, matchNum*sizeof(TkSizeT));
memcpy(newArray + 2*matchNum, storeLength,
- matchNum * sizeof(int));
+ matchNum * sizeof(TkSizeT));
if (storeMatch != smArray) {
ckfree(storeMatch);
}
@@ -6558,7 +6553,7 @@ SearchCore(
* explicitly disallow overlapping matches.
*/
- if (matchLength > 0 && !searchSpecPtr->overlap
+ if (matchLength + 1 > 1 && !searchSpecPtr->overlap
&& !searchSpecPtr->backwards) {
firstOffset += matchLength;
if (firstOffset >= lastOffset) {
@@ -6615,8 +6610,8 @@ SearchCore(
* found which would exercise such a problem.
*/
}
- if (storeMatch[matches] + storeLength[matches]
- >= matchOffset + matchLength) {
+ if (storeMatch[matches] + storeLength[matches] + 1
+ >= matchOffset + matchLength + 1) {
/*
* The new match totally encloses the previous one, so
* we overwrite the previous one.
@@ -6664,7 +6659,7 @@ SearchCore(
* we are done.
*/
- if ((lastBackwardsLineMatch == -1) && (matchOffset >= 0)
+ if ((lastBackwardsLineMatch == -1) && (matchOffset != TCL_INDEX_NONE)
&& !searchSpecPtr->all) {
searchSpecPtr->foundMatchProc(lineNum, searchSpecPtr, lineInfo,
theLine, matchOffset, matchLength);
@@ -6780,18 +6775,20 @@ SearchCore(
static Tcl_Obj *
GetLineStartEnd(
- ClientData clientData,
+ ClientData dummy,
Tk_Window tkwin,
char *recordPtr, /* Pointer to widget record. */
int internalOffset) /* Offset within *recordPtr containing the
* line value. */
{
TkTextLine *linePtr = *(TkTextLine **)(recordPtr + internalOffset);
+ (void)dummy;
+ (void)tkwin;
if (linePtr == NULL) {
return Tcl_NewObj();
}
- return Tcl_NewIntObj(1 + TkBTreeLinesTo(NULL, linePtr));
+ return Tcl_NewWideIntObj(1 + TkBTreeLinesTo(NULL, linePtr));
}
/*
@@ -6815,7 +6812,7 @@ GetLineStartEnd(
static int
SetLineStartEnd(
- ClientData clientData,
+ ClientData dummy,
Tcl_Interp *interp, /* Current interp; may be used for errors. */
Tk_Window tkwin, /* Window for which option is being set. */
Tcl_Obj **value, /* Pointer to the pointer to the value object.
@@ -6830,6 +6827,8 @@ SetLineStartEnd(
TkTextLine *linePtr = NULL;
char *internalPtr;
TkText *textPtr = (TkText *) recordPtr;
+ (void)dummy;
+ (void)tkwin;
if (internalOffset >= 0) {
internalPtr = (char *)recordPtr + internalOffset;
@@ -6874,11 +6873,14 @@ SetLineStartEnd(
static void
RestoreLineStartEnd(
- ClientData clientData,
+ ClientData dummy,
Tk_Window tkwin,
char *internalPtr, /* Pointer to storage for value. */
char *oldInternalPtr) /* Pointer to old value. */
{
+ (void)dummy;
+ (void)tkwin;
+
*(TkTextLine **)internalPtr = *(TkTextLine **)oldInternalPtr;
}
@@ -6933,7 +6935,7 @@ ObjectIsEmpty(
int
TkpTesttextCmd(
- ClientData clientData, /* Main window for application. */
+ ClientData dummy, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -6944,6 +6946,7 @@ TkpTesttextCmd(
TkTextIndex index;
char buf[64];
Tcl_CmdInfo info;
+ (void)dummy;
if (objc < 3) {
return TCL_ERROR;
@@ -6952,7 +6955,7 @@ TkpTesttextCmd(
if (Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &info) == 0) {
return TCL_ERROR;
}
- textPtr = info.objClientData;
+ textPtr = (TkText *)info.objClientData;
len = strlen(Tcl_GetString(objv[2]));
if (strncmp(Tcl_GetString(objv[2]), "byteindex", len) == 0) {
if (objc != 5) {
diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c
index 66fa140..071ae59 100644
--- a/generic/tkTextBTree.c
+++ b/generic/tkTextBTree.c
@@ -140,9 +140,9 @@ int tkBTreeDebug = 0;
* Macros that determine how much space to allocate for new segments:
*/
-#define CSEG_SIZE(chars) (Tk_Offset(TkTextSegment, body) \
+#define CSEG_SIZE(chars) (offsetof(TkTextSegment, body) \
+ 1 + (chars))
-#define TSEG_SIZE (Tk_Offset(TkTextSegment, body) \
+#define TSEG_SIZE (offsetof(TkTextSegment, body) \
+ sizeof(TkTextToggle))
/*
@@ -261,10 +261,10 @@ TkTextBTree
TkBTreeCreate(
TkSharedText *sharedTextPtr)
{
- register BTree *treePtr;
- register Node *rootPtr;
- register TkTextLine *linePtr, *linePtr2;
- register TkTextSegment *segPtr;
+ BTree *treePtr;
+ Node *rootPtr;
+ TkTextLine *linePtr, *linePtr2;
+ TkTextSegment *segPtr;
/*
* The tree will initially have two empty lines. The second line isn't
@@ -273,9 +273,9 @@ TkBTreeCreate(
* of the tree.
*/
- rootPtr = ckalloc(sizeof(Node));
- linePtr = ckalloc(sizeof(TkTextLine));
- linePtr2 = ckalloc(sizeof(TkTextLine));
+ rootPtr = (Node *)ckalloc(sizeof(Node));
+ linePtr = (TkTextLine *)ckalloc(sizeof(TkTextLine));
+ linePtr2 = (TkTextLine *)ckalloc(sizeof(TkTextLine));
rootPtr->parentPtr = NULL;
rootPtr->nextPtr = NULL;
@@ -296,7 +296,7 @@ TkBTreeCreate(
linePtr->parentPtr = rootPtr;
linePtr->nextPtr = linePtr2;
- segPtr = ckalloc(CSEG_SIZE(1));
+ segPtr = (TkTextSegment *)ckalloc(CSEG_SIZE(1));
linePtr->segPtr = segPtr;
segPtr->typePtr = &tkTextCharType;
segPtr->nextPtr = NULL;
@@ -306,7 +306,7 @@ TkBTreeCreate(
linePtr2->parentPtr = rootPtr;
linePtr2->nextPtr = NULL;
- segPtr = ckalloc(CSEG_SIZE(1));
+ segPtr = (TkTextSegment *)ckalloc(CSEG_SIZE(1));
linePtr2->segPtr = segPtr;
segPtr->typePtr = &tkTextCharType;
segPtr->nextPtr = NULL;
@@ -314,7 +314,7 @@ TkBTreeCreate(
segPtr->body.chars[0] = '\n';
segPtr->body.chars[1] = 0;
- treePtr = ckalloc(sizeof(BTree));
+ treePtr = (BTree *)ckalloc(sizeof(BTree));
treePtr->sharedTextPtr = sharedTextPtr;
treePtr->rootPtr = rootPtr;
treePtr->clients = 0;
@@ -366,7 +366,7 @@ TkBTreeAddClient(
int defaultHeight) /* Default line height for the new client, or
* -1 if no pixel heights are to be kept. */
{
- register BTree *treePtr = (BTree *) tree;
+ BTree *treePtr = (BTree *) tree;
if (treePtr == NULL) {
Tcl_Panic("NULL treePtr in TkBTreeAddClient");
@@ -632,9 +632,9 @@ AdjustStartEndRefs(
i++;
}
treePtr->startEndCount = count;
- treePtr->startEnd = ckrealloc(treePtr->startEnd,
+ treePtr->startEnd = (TkTextLine **)ckrealloc(treePtr->startEnd,
sizeof(TkTextLine *) * count);
- treePtr->startEndRef = ckrealloc(treePtr->startEndRef,
+ treePtr->startEndRef = (TkText **)ckrealloc(treePtr->startEndRef,
sizeof(TkText *) * count);
}
if ((action & TEXT_ADD_REFS)
@@ -650,9 +650,9 @@ AdjustStartEndRefs(
count = treePtr->startEndCount;
- treePtr->startEnd = ckrealloc(treePtr->startEnd,
+ treePtr->startEnd = (TkTextLine **)ckrealloc(treePtr->startEnd,
sizeof(TkTextLine *) * count);
- treePtr->startEndRef = ckrealloc(treePtr->startEndRef,
+ treePtr->startEndRef = (TkText **)ckrealloc(treePtr->startEndRef,
sizeof(TkText *) * count);
if (textPtr->start != NULL) {
@@ -725,7 +725,7 @@ AdjustPixelClient(
loopPtr = loopPtr->nextPtr;
}
} else {
- register TkTextLine *linePtr = nodePtr->children.linePtr;
+ TkTextLine *linePtr = nodePtr->children.linePtr;
while (linePtr != NULL) {
if (!*counting && (linePtr == start)) {
@@ -735,7 +735,7 @@ AdjustPixelClient(
*counting = 0;
}
if (newPixelReferences != treePtr->pixelReferences) {
- linePtr->pixels = ckrealloc(linePtr->pixels,
+ linePtr->pixels = (int *)ckrealloc(linePtr->pixels,
sizeof(int) * 2 * newPixelReferences);
}
@@ -752,7 +752,7 @@ AdjustPixelClient(
}
}
if (newPixelReferences != treePtr->pixelReferences) {
- nodePtr->numPixels = ckrealloc(nodePtr->numPixels,
+ nodePtr->numPixels = (int *)ckrealloc(nodePtr->numPixels,
sizeof(int) * newPixelReferences);
}
nodePtr->numPixels[useReference] = pixelCount;
@@ -802,7 +802,7 @@ RemovePixelClient(
ckfree(nodePtr->numPixels);
nodePtr->numPixels = NULL;
} else {
- nodePtr->numPixels = ckrealloc(nodePtr->numPixels,
+ nodePtr->numPixels = (int *)ckrealloc(nodePtr->numPixels,
sizeof(int) * (treePtr->pixelReferences - 1));
}
if (nodePtr->level != 0) {
@@ -812,7 +812,7 @@ RemovePixelClient(
nodePtr = nodePtr->nextPtr;
}
} else {
- register TkTextLine *linePtr = nodePtr->children.linePtr;
+ TkTextLine *linePtr = nodePtr->children.linePtr;
while (linePtr != NULL) {
if (overwriteWithLast != -1) {
linePtr->pixels[2*overwriteWithLast] =
@@ -823,7 +823,7 @@ RemovePixelClient(
if (treePtr->pixelReferences == 1) {
linePtr->pixels = NULL;
} else {
- linePtr->pixels = ckrealloc(linePtr->pixels,
+ linePtr->pixels = (int *)ckrealloc(linePtr->pixels,
sizeof(int) * 2 * (treePtr->pixelReferences-1));
}
linePtr = linePtr->nextPtr;
@@ -850,7 +850,7 @@ RemovePixelClient(
static void
DestroyNode(
- register Node *nodePtr) /* Destroy from this node downwards. */
+ Node *nodePtr) /* Destroy from this node downwards. */
{
if (nodePtr->level == 0) {
TkTextLine *linePtr;
@@ -868,7 +868,7 @@ DestroyNode(
ckfree(linePtr);
}
} else {
- register Node *childPtr;
+ Node *childPtr;
while (nodePtr->children.nodePtr != NULL) {
childPtr = nodePtr->children.nodePtr;
@@ -900,10 +900,10 @@ DestroyNode(
static void
DeleteSummaries(
- register Summary *summaryPtr)
+ Summary *summaryPtr)
/* First in list of node's tag summaries. */
{
- register Summary *nextPtr;
+ Summary *nextPtr;
while (summaryPtr != NULL) {
nextPtr = summaryPtr->nextPtr;
@@ -932,7 +932,7 @@ DeleteSummaries(
int
TkBTreeAdjustPixelHeight(
const TkText *textPtr, /* Client of the B-tree. */
- register TkTextLine *linePtr,
+ TkTextLine *linePtr,
/* The logical line to update. */
int newPixelHeight, /* The line's known height in pixels. */
int mergedLogicalLines) /* The number of extra logical lines which
@@ -942,7 +942,7 @@ TkBTreeAdjustPixelHeight(
* height associated with the given
* linePtr. */
{
- register Node *nodePtr;
+ Node *nodePtr;
int changeToPixelCount; /* Counts change to total number of pixels in
* file. */
int pixelReference = textPtr->pixelReference;
@@ -1001,7 +1001,7 @@ TkBTreeAdjustPixelHeight(
void
TkBTreeInsertChars(
TkTextBTree tree, /* Tree to insert into. */
- register TkTextIndex *indexPtr,
+ TkTextIndex *indexPtr,
/* Indicates where to insert text. When the
* function returns, this index is no longer
* valid because of changes to the segment
@@ -1009,8 +1009,8 @@ TkBTreeInsertChars(
const char *string) /* Pointer to bytes to insert (may contain
* newlines, must be null-terminated). */
{
- register Node *nodePtr;
- register TkTextSegment *prevPtr;
+ Node *nodePtr;
+ TkTextSegment *prevPtr;
/* The segment just before the first new
* segment (NULL means new segment is at
* beginning of line). */
@@ -1019,10 +1019,10 @@ TkBTreeInsertChars(
* insert at beginning of line. */
TkTextLine *linePtr; /* Current line (new segments are added to
* this line). */
- register TkTextSegment *segPtr;
+ TkTextSegment *segPtr;
TkTextLine *newLinePtr;
size_t chunkSize; /* # characters in current chunk. */
- register const char *eol; /* Pointer to character just after last one in
+ const char *eol; /* Pointer to character just after last one in
* current chunk. */
int changeToLineCount; /* Counts change to total number of lines in
* file. */
@@ -1044,7 +1044,7 @@ TkBTreeInsertChars(
changeToLineCount = 0;
if (treePtr->pixelReferences > PIXEL_CLIENTS) {
- changeToPixelCount = ckalloc(sizeof(int) * treePtr->pixelReferences);
+ changeToPixelCount = (int *)ckalloc(sizeof(int) * treePtr->pixelReferences);
} else {
changeToPixelCount = pixels;
}
@@ -1060,7 +1060,7 @@ TkBTreeInsertChars(
}
}
chunkSize = eol-string;
- segPtr = ckalloc(CSEG_SIZE(chunkSize));
+ segPtr = (TkTextSegment *)ckalloc(CSEG_SIZE(chunkSize));
segPtr->typePtr = &tkTextCharType;
if (curPtr == NULL) {
segPtr->nextPtr = linePtr->segPtr;
@@ -1082,8 +1082,8 @@ TkBTreeInsertChars(
* the remainder of the old line to it.
*/
- newLinePtr = ckalloc(sizeof(TkTextLine));
- newLinePtr->pixels =
+ newLinePtr = (TkTextLine *)ckalloc(sizeof(TkTextLine));
+ newLinePtr->pixels = (int *)
ckalloc(sizeof(int) * 2 * treePtr->pixelReferences);
newLinePtr->parentPtr = linePtr->parentPtr;
@@ -1312,10 +1312,10 @@ CleanupLine(
void
TkBTreeDeleteIndexRange(
TkTextBTree tree, /* Tree to delete from. */
- register TkTextIndex *index1Ptr,
+ TkTextIndex *index1Ptr,
/* Indicates first character that is to be
* deleted. */
- register TkTextIndex *index2Ptr)
+ TkTextIndex *index2Ptr)
/* Indicates character just after the last one
* that is to be deleted. */
{
@@ -1596,8 +1596,8 @@ TkBTreeFindLine(
int line) /* Index of desired line. */
{
BTree *treePtr = (BTree *) tree;
- register Node *nodePtr;
- register TkTextLine *linePtr;
+ Node *nodePtr;
+ TkTextLine *linePtr;
if (treePtr == NULL) {
treePtr = (BTree *) textPtr->sharedTextPtr->tree;
@@ -1686,8 +1686,8 @@ TkBTreeFindPixelLine(
int *pixelOffset) /* Used to return offset. */
{
BTree *treePtr = (BTree *) tree;
- register Node *nodePtr;
- register TkTextLine *linePtr;
+ Node *nodePtr;
+ TkTextLine *linePtr;
int pixelReference = textPtr->pixelReference;
nodePtr = treePtr->rootPtr;
@@ -1755,10 +1755,10 @@ TkBTreeFindPixelLine(
TkTextLine *
TkBTreeNextLine(
const TkText *textPtr, /* Next line in the context of this client. */
- register TkTextLine *linePtr)
+ TkTextLine *linePtr)
/* Pointer to existing line in B-tree. */
{
- register Node *nodePtr;
+ Node *nodePtr;
if (linePtr->nextPtr != NULL) {
if (textPtr != NULL && (linePtr == textPtr->end)) {
@@ -1811,12 +1811,12 @@ TkBTreeNextLine(
TkTextLine *
TkBTreePreviousLine(
TkText *textPtr, /* Relative to this client of the B-tree. */
- register TkTextLine *linePtr)
+ TkTextLine *linePtr)
/* Pointer to existing line in B-tree. */
{
- register Node *nodePtr;
- register Node *node2Ptr;
- register TkTextLine *prevPtr;
+ Node *nodePtr;
+ Node *node2Ptr;
+ TkTextLine *prevPtr;
if (textPtr != NULL && textPtr->start == linePtr) {
return NULL;
@@ -1895,8 +1895,8 @@ TkBTreePixelsTo(
const TkText *textPtr, /* Relative to this client of the B-tree. */
TkTextLine *linePtr) /* Pointer to existing line in B-tree. */
{
- register TkTextLine *linePtr2;
- register Node *nodePtr, *parentPtr;
+ TkTextLine *linePtr2;
+ Node *nodePtr, *parentPtr;
int index;
int pixelReference = textPtr->pixelReference;
@@ -1921,7 +1921,7 @@ TkBTreePixelsTo(
for (parentPtr = nodePtr->parentPtr ; parentPtr != NULL;
nodePtr = parentPtr, parentPtr = parentPtr->parentPtr) {
- register Node *nodePtr2;
+ Node *nodePtr2;
for (nodePtr2 = parentPtr->children.nodePtr; nodePtr2 != nodePtr;
nodePtr2 = nodePtr2->nextPtr) {
@@ -1957,8 +1957,8 @@ TkBTreeLinesTo(
const TkText *textPtr, /* Relative to this client of the B-tree. */
TkTextLine *linePtr) /* Pointer to existing line in B-tree. */
{
- register TkTextLine *linePtr2;
- register Node *nodePtr, *parentPtr, *nodePtr2;
+ TkTextLine *linePtr2;
+ Node *nodePtr, *parentPtr, *nodePtr2;
int index;
/*
@@ -2037,7 +2037,6 @@ TkBTreeLinesTo(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
void
TkBTreeLinkSegment(
TkTextSegment *segPtr, /* Pointer to new segment to be added to
@@ -2046,7 +2045,7 @@ TkBTreeLinkSegment(
TkTextIndex *indexPtr) /* Where to add segment: it gets linked in
* just before the segment indicated here. */
{
- register TkTextSegment *prevPtr;
+ TkTextSegment *prevPtr;
prevPtr = SplitSeg(indexPtr);
if (prevPtr == NULL) {
@@ -2080,13 +2079,12 @@ TkBTreeLinkSegment(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
void
TkBTreeUnlinkSegment(
TkTextSegment *segPtr, /* Segment to be unlinked. */
TkTextLine *linePtr) /* Line that currently contains segment. */
{
- register TkTextSegment *prevPtr;
+ TkTextSegment *prevPtr;
if (linePtr->segPtr == segPtr) {
linePtr->segPtr = segPtr->nextPtr;
@@ -2135,9 +2133,9 @@ TkBTreeUnlinkSegment(
int
TkBTreeTag(
- register TkTextIndex *index1Ptr,
+ TkTextIndex *index1Ptr,
/* Indicates first character in range. */
- register TkTextIndex *index2Ptr,
+ TkTextIndex *index2Ptr,
/* Indicates character just after the last one
* in range. */
TkTextTag *tagPtr, /* Tag to add or remove. */
@@ -2157,7 +2155,7 @@ TkBTreeTag(
oldState = TkBTreeCharTagged(index1Ptr, tagPtr);
if ((add != 0) ^ oldState) {
- segPtr = ckalloc(TSEG_SIZE);
+ segPtr = (TkTextSegment *)ckalloc(TSEG_SIZE);
segPtr->typePtr = (add) ? &tkTextToggleOnType : &tkTextToggleOffType;
prevPtr = SplitSeg(index1Ptr);
if (prevPtr == NULL) {
@@ -2228,7 +2226,7 @@ TkBTreeTag(
}
}
if ((add != 0) ^ oldState) {
- segPtr = ckalloc(TSEG_SIZE);
+ segPtr = (TkTextSegment *)ckalloc(TSEG_SIZE);
segPtr->typePtr = (add) ? &tkTextToggleOffType : &tkTextToggleOnType;
prevPtr = SplitSeg(index2Ptr);
if (prevPtr == NULL) {
@@ -2285,14 +2283,14 @@ TkBTreeTag(
static void
ChangeNodeToggleCount(
- register Node *nodePtr, /* Node whose toggle count for a tag must be
+ Node *nodePtr, /* Node whose toggle count for a tag must be
* changed. */
TkTextTag *tagPtr, /* Information about tag. */
int delta) /* Amount to add to current toggle count for
* tag (may be negative). */
{
- register Summary *summaryPtr, *prevPtr;
- register Node *node2Ptr;
+ Summary *summaryPtr, *prevPtr;
+ Node *node2Ptr;
int rootLevel; /* Level of original tag root. */
tagPtr->toggleCount += delta;
@@ -2372,7 +2370,7 @@ ChangeNodeToggleCount(
Node *rootNodePtr = tagPtr->tagRootPtr;
- summaryPtr = ckalloc(sizeof(Summary));
+ summaryPtr = (Summary *)ckalloc(sizeof(Summary));
summaryPtr->tagPtr = tagPtr;
summaryPtr->toggleCount = tagPtr->toggleCount - delta;
summaryPtr->nextPtr = rootNodePtr->summaryPtr;
@@ -2381,7 +2379,7 @@ ChangeNodeToggleCount(
rootLevel = rootNodePtr->level;
tagPtr->tagRootPtr = rootNodePtr;
}
- summaryPtr = ckalloc(sizeof(Summary));
+ summaryPtr = (Summary *)ckalloc(sizeof(Summary));
summaryPtr->tagPtr = tagPtr;
summaryPtr->toggleCount = delta;
summaryPtr->nextPtr = nodePtr->summaryPtr;
@@ -2471,10 +2469,10 @@ FindTagStart(
TkTextTag *tagPtr, /* Tag to search for. */
TkTextIndex *indexPtr) /* Return - index information. */
{
- register Node *nodePtr;
- register TkTextLine *linePtr;
- register TkTextSegment *segPtr;
- register Summary *summaryPtr;
+ Node *nodePtr;
+ TkTextLine *linePtr;
+ TkTextSegment *segPtr;
+ Summary *summaryPtr;
int offset;
nodePtr = tagPtr->tagRootPtr;
@@ -2556,10 +2554,10 @@ FindTagEnd(
TkTextTag *tagPtr, /* Tag to search for. */
TkTextIndex *indexPtr) /* Return - index information. */
{
- register Node *nodePtr, *lastNodePtr;
- register TkTextLine *linePtr ,*lastLinePtr;
- register TkTextSegment *segPtr, *lastSegPtr, *last2SegPtr;
- register Summary *summaryPtr;
+ Node *nodePtr, *lastNodePtr;
+ TkTextLine *linePtr ,*lastLinePtr;
+ TkTextSegment *segPtr, *lastSegPtr, *last2SegPtr;
+ Summary *summaryPtr;
int lastoffset, lastoffset2, offset;
nodePtr = tagPtr->tagRootPtr;
@@ -2652,7 +2650,7 @@ TkBTreeStartSearch(
* position *will* be returned. */
TkTextTag *tagPtr, /* Tag to search for. NULL means search for
* any tag. */
- register TkTextSearch *searchPtr)
+ TkTextSearch *searchPtr)
/* Where to store information about search's
* progress. */
{
@@ -2748,7 +2746,7 @@ TkBTreeStartSearchBack(
* position *will* be returned. */
TkTextTag *tagPtr, /* Tag to search for. NULL means search for
* any tag. */
- register TkTextSearch *searchPtr)
+ TkTextSearch *searchPtr)
/* Where to store information about search's
* progress. */
{
@@ -2849,14 +2847,14 @@ TkBTreeStartSearchBack(
int
TkBTreeNextTag(
- register TkTextSearch *searchPtr)
+ TkTextSearch *searchPtr)
/* Information about search in progress; must
* have been set up by call to
* TkBTreeStartSearch. */
{
- register TkTextSegment *segPtr;
- register Node *nodePtr;
- register Summary *summaryPtr;
+ TkTextSegment *segPtr;
+ Node *nodePtr;
+ Summary *summaryPtr;
if (searchPtr->linesLeft <= 0) {
goto searchOver;
@@ -3014,15 +3012,15 @@ TkBTreeNextTag(
int
TkBTreePrevTag(
- register TkTextSearch *searchPtr)
+ TkTextSearch *searchPtr)
/* Information about search in progress; must
* have been set up by call to
* TkBTreeStartSearch. */
{
- register TkTextSegment *segPtr, *prevPtr;
- register TkTextLine *linePtr, *prevLinePtr;
- register Node *nodePtr, *node2Ptr, *prevNodePtr;
- register Summary *summaryPtr;
+ TkTextSegment *segPtr, *prevPtr;
+ TkTextLine *linePtr, *prevLinePtr;
+ Node *nodePtr, *node2Ptr, *prevNodePtr;
+ Summary *summaryPtr;
int byteIndex, linesSkipped;
int pastLast; /* Saw last marker during scan. */
@@ -3232,9 +3230,9 @@ TkBTreeCharTagged(
* check for a tag. */
TkTextTag *tagPtr) /* Tag of interest. */
{
- register Node *nodePtr;
- register TkTextLine *siblingLinePtr;
- register TkTextSegment *segPtr;
+ Node *nodePtr;
+ TkTextLine *siblingLinePtr;
+ TkTextSegment *segPtr;
TkTextSegment *toggleSegPtr;
int toggles, index;
@@ -3288,8 +3286,8 @@ TkBTreeCharTagged(
toggles = 0;
for (nodePtr = indexPtr->linePtr->parentPtr; nodePtr->parentPtr != NULL;
nodePtr = nodePtr->parentPtr) {
- register Node *siblingPtr;
- register Summary *summaryPtr;
+ Node *siblingPtr;
+ Summary *summaryPtr;
for (siblingPtr = nodePtr->parentPtr->children.nodePtr;
siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) {
@@ -3336,7 +3334,6 @@ TkBTreeCharTagged(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
TkTextTag **
TkBTreeGetTags(
const TkTextIndex *indexPtr,/* Indicates a particular position in the
@@ -3347,9 +3344,9 @@ TkBTreeGetTags(
int *numTagsPtr) /* Store number of tags found at this
* location. */
{
- register Node *nodePtr;
- register TkTextLine *siblingLinePtr;
- register TkTextSegment *segPtr;
+ Node *nodePtr;
+ TkTextLine *siblingLinePtr;
+ TkTextSegment *segPtr;
TkTextLine *linePtr;
int src, dst, index;
TagInfo tagInfo;
@@ -3357,8 +3354,8 @@ TkBTreeGetTags(
tagInfo.numTags = 0;
tagInfo.arraySize = NUM_TAG_INFOS;
- tagInfo.tagPtrs = ckalloc(NUM_TAG_INFOS * sizeof(TkTextTag *));
- tagInfo.counts = ckalloc(NUM_TAG_INFOS * sizeof(int));
+ tagInfo.tagPtrs = (TkTextTag **)ckalloc(NUM_TAG_INFOS * sizeof(TkTextTag *));
+ tagInfo.counts = (int *)ckalloc(NUM_TAG_INFOS * sizeof(int));
/*
* Record tag toggles within the line of indexPtr but preceding indexPtr.
@@ -3410,8 +3407,8 @@ TkBTreeGetTags(
for (nodePtr = indexPtr->linePtr->parentPtr; nodePtr->parentPtr != NULL;
nodePtr = nodePtr->parentPtr) {
- register Node *siblingPtr;
- register Summary *summaryPtr;
+ Node *siblingPtr;
+ Summary *summaryPtr;
for (siblingPtr = nodePtr->parentPtr->children.nodePtr;
siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) {
@@ -3482,7 +3479,6 @@ TkBTreeGetTags(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
TkTextIsElided(
const TkText *textPtr, /* Overall information about text widget. */
@@ -3492,17 +3488,17 @@ TkTextIsElided(
* indexPtr's elide state will be stored and
* returned. */
{
- register Node *nodePtr;
- register TkTextLine *siblingLinePtr;
- register TkTextSegment *segPtr;
- register TkTextTag *tagPtr = NULL;
- register int i, index;
- register TkTextElideInfo *infoPtr;
+ Node *nodePtr;
+ TkTextLine *siblingLinePtr;
+ TkTextSegment *segPtr;
+ TkTextTag *tagPtr = NULL;
+ int i, index;
+ TkTextElideInfo *infoPtr;
TkTextLine *linePtr;
int elide;
if (elideInfo == NULL) {
- infoPtr = ckalloc(sizeof(TkTextElideInfo));
+ infoPtr = (TkTextElideInfo *)ckalloc(sizeof(TkTextElideInfo));
} else {
infoPtr = elideInfo;
}
@@ -3517,8 +3513,8 @@ TkTextIsElided(
*/
if (LOTSA_TAGS < infoPtr->numTags) {
- infoPtr->tagCnts = ckalloc(sizeof(int) * infoPtr->numTags);
- infoPtr->tagPtrs = ckalloc(sizeof(TkTextTag *) * infoPtr->numTags);
+ infoPtr->tagCnts = (int *)ckalloc(sizeof(int) * infoPtr->numTags);
+ infoPtr->tagPtrs = (TkTextTag **)ckalloc(sizeof(TkTextTag *) * infoPtr->numTags);
}
for (i=0; i<infoPtr->numTags; i++) {
@@ -3591,8 +3587,8 @@ TkTextIsElided(
for (nodePtr = indexPtr->linePtr->parentPtr; nodePtr->parentPtr != NULL;
nodePtr = nodePtr->parentPtr) {
- register Node *siblingPtr;
- register Summary *summaryPtr;
+ Node *siblingPtr;
+ Summary *summaryPtr;
for (siblingPtr = nodePtr->parentPtr->children.nodePtr;
siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) {
@@ -3697,7 +3693,7 @@ IncCount(
TagInfo *tagInfoPtr) /* Holds cumulative information about tags;
* increment count here. */
{
- register TkTextTag **tagPtrPtr;
+ TkTextTag **tagPtrPtr;
int count;
for (tagPtrPtr = tagInfoPtr->tagPtrs, count = tagInfoPtr->numTags;
@@ -3718,12 +3714,12 @@ IncCount(
int *newCounts, newSize;
newSize = 2 * tagInfoPtr->arraySize;
- newTags = ckalloc(newSize * sizeof(TkTextTag *));
+ newTags = (TkTextTag **)ckalloc(newSize * sizeof(TkTextTag *));
memcpy(newTags, tagInfoPtr->tagPtrs,
tagInfoPtr->arraySize * sizeof(TkTextTag *));
ckfree(tagInfoPtr->tagPtrs);
tagInfoPtr->tagPtrs = newTags;
- newCounts = ckalloc(newSize * sizeof(int));
+ newCounts = (int *)ckalloc(newSize * sizeof(int));
memcpy(newCounts, tagInfoPtr->counts,
tagInfoPtr->arraySize * sizeof(int));
ckfree(tagInfoPtr->counts);
@@ -3759,11 +3755,11 @@ TkBTreeCheck(
TkTextBTree tree) /* Tree to check. */
{
BTree *treePtr = (BTree *) tree;
- register Summary *summaryPtr;
- register Node *nodePtr;
- register TkTextLine *linePtr;
- register TkTextSegment *segPtr;
- register TkTextTag *tagPtr;
+ Summary *summaryPtr;
+ Node *nodePtr;
+ TkTextLine *linePtr;
+ TkTextSegment *segPtr;
+ TkTextTag *tagPtr;
Tcl_HashEntry *entryPtr;
Tcl_HashSearch search;
int count;
@@ -3774,7 +3770,7 @@ TkBTreeCheck(
for (entryPtr=Tcl_FirstHashEntry(&treePtr->sharedTextPtr->tagTable,&search);
entryPtr != NULL ; entryPtr = Tcl_NextHashEntry(&search)) {
- tagPtr = Tcl_GetHashValue(entryPtr);
+ tagPtr = (TkTextTag *)Tcl_GetHashValue(entryPtr);
nodePtr = tagPtr->tagRootPtr;
if (nodePtr == NULL) {
if (tagPtr->toggleCount != 0) {
@@ -3898,14 +3894,14 @@ TkBTreeCheck(
static void
CheckNodeConsistency(
- register Node *nodePtr, /* Node whose subtree should be checked. */
+ Node *nodePtr, /* Node whose subtree should be checked. */
int references) /* Number of referring widgets which have
* pixel counts. */
{
- register Node *childNodePtr;
- register Summary *summaryPtr, *summaryPtr2;
- register TkTextLine *linePtr;
- register TkTextSegment *segPtr;
+ Node *childNodePtr;
+ Summary *summaryPtr, *summaryPtr2;
+ TkTextLine *linePtr;
+ TkTextSegment *segPtr;
int numChildren, numLines, toggleCount, minChildren, i;
int *numPixels;
int pixels[PIXEL_CLIENTS];
@@ -3926,7 +3922,7 @@ CheckNodeConsistency(
numChildren = 0;
numLines = 0;
if (references > PIXEL_CLIENTS) {
- numPixels = ckalloc(sizeof(int) * references);
+ numPixels = (int *)ckalloc(sizeof(int) * references);
} else {
numPixels = pixels;
}
@@ -4087,7 +4083,7 @@ CheckNodeConsistency(
static void
Rebalance(
BTree *treePtr, /* Tree that is being rebalanced. */
- register Node *nodePtr) /* Node that may be out of balance. */
+ Node *nodePtr) /* Node that may be out of balance. */
{
/*
* Loop over the entire ancestral chain of the node, working up through
@@ -4095,8 +4091,8 @@ Rebalance(
*/
for ( ; nodePtr != NULL; nodePtr = nodePtr->parentPtr) {
- register Node *newPtr, *childPtr;
- register TkTextLine *linePtr;
+ Node *newPtr, *childPtr;
+ TkTextLine *linePtr;
int i;
/*
@@ -4114,7 +4110,7 @@ Rebalance(
*/
if (nodePtr->parentPtr == NULL) {
- newPtr = ckalloc(sizeof(Node));
+ newPtr = (Node *)ckalloc(sizeof(Node));
newPtr->parentPtr = NULL;
newPtr->nextPtr = NULL;
newPtr->summaryPtr = NULL;
@@ -4122,7 +4118,7 @@ Rebalance(
newPtr->children.nodePtr = nodePtr;
newPtr->numChildren = 1;
newPtr->numLines = nodePtr->numLines;
- newPtr->numPixels =
+ newPtr->numPixels = (int *)
ckalloc(sizeof(int) * treePtr->pixelReferences);
for (i=0; i<treePtr->pixelReferences; i++) {
newPtr->numPixels[i] = nodePtr->numPixels[i];
@@ -4130,8 +4126,8 @@ Rebalance(
RecomputeNodeCounts(treePtr, newPtr);
treePtr->rootPtr = newPtr;
}
- newPtr = ckalloc(sizeof(Node));
- newPtr->numPixels =
+ newPtr = (Node *)ckalloc(sizeof(Node));
+ newPtr->numPixels = (int *)
ckalloc(sizeof(int) * treePtr->pixelReferences);
for (i=0; i<treePtr->pixelReferences; i++) {
newPtr->numPixels[i] = 0;
@@ -4170,7 +4166,7 @@ Rebalance(
}
while (nodePtr->numChildren < MIN_CHILDREN) {
- register Node *otherPtr;
+ Node *otherPtr;
Node *halfwayNodePtr = NULL; /* Initialization needed only */
TkTextLine *halfwayLinePtr = NULL; /* to prevent cc warnings. */
int totalChildren, firstChildren, i;
@@ -4234,7 +4230,7 @@ Rebalance(
otherPtr->children.linePtr = NULL;
}
if (nodePtr->level == 0) {
- register TkTextLine *linePtr;
+ TkTextLine *linePtr;
for (linePtr = nodePtr->children.linePtr, i = 1;
linePtr->nextPtr != NULL;
@@ -4250,7 +4246,7 @@ Rebalance(
i++;
}
} else {
- register Node *childPtr;
+ Node *childPtr;
for (childPtr = nodePtr->children.nodePtr, i = 1;
childPtr->nextPtr != NULL;
@@ -4326,14 +4322,14 @@ Rebalance(
static void
RecomputeNodeCounts(
- register BTree *treePtr, /* The whole B-tree. */
- register Node *nodePtr) /* Node whose tag summary information must be
+ BTree *treePtr, /* The whole B-tree. */
+ Node *nodePtr) /* Node whose tag summary information must be
* recomputed. */
{
- register Summary *summaryPtr, *summaryPtr2;
- register Node *childPtr;
- register TkTextLine *linePtr;
- register TkTextSegment *segPtr;
+ Summary *summaryPtr, *summaryPtr2;
+ Node *childPtr;
+ TkTextLine *linePtr;
+ TkTextSegment *segPtr;
TkTextTag *tagPtr;
int ref;
@@ -4377,7 +4373,7 @@ RecomputeNodeCounts(
for (summaryPtr = nodePtr->summaryPtr; ;
summaryPtr = summaryPtr->nextPtr) {
if (summaryPtr == NULL) {
- summaryPtr = ckalloc(sizeof(Summary));
+ summaryPtr = (Summary *)ckalloc(sizeof(Summary));
summaryPtr->tagPtr = tagPtr;
summaryPtr->toggleCount = 1;
summaryPtr->nextPtr = nodePtr->summaryPtr;
@@ -4405,7 +4401,7 @@ RecomputeNodeCounts(
for (summaryPtr = nodePtr->summaryPtr; ;
summaryPtr = summaryPtr->nextPtr) {
if (summaryPtr == NULL) {
- summaryPtr = ckalloc(sizeof(Summary));
+ summaryPtr = (Summary *)ckalloc(sizeof(Summary));
summaryPtr->tagPtr = summaryPtr2->tagPtr;
summaryPtr->toggleCount = summaryPtr2->toggleCount;
summaryPtr->nextPtr = nodePtr->summaryPtr;
@@ -4558,8 +4554,8 @@ CharSplitProc(
{
TkTextSegment *newPtr1, *newPtr2;
- newPtr1 = ckalloc(CSEG_SIZE(index));
- newPtr2 = ckalloc(CSEG_SIZE(segPtr->size - index));
+ newPtr1 = (TkTextSegment *)ckalloc(CSEG_SIZE(index));
+ newPtr2 = (TkTextSegment *)ckalloc(CSEG_SIZE(segPtr->size - index));
newPtr1->typePtr = &tkTextCharType;
newPtr1->nextPtr = newPtr2;
newPtr1->size = index;
@@ -4592,7 +4588,6 @@ CharSplitProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static TkTextSegment *
CharCleanupProc(
TkTextSegment *segPtr, /* Pointer to first of two adjacent segments
@@ -4600,12 +4595,13 @@ CharCleanupProc(
TkTextLine *linePtr) /* Line containing segments (not used). */
{
TkTextSegment *segPtr2, *newPtr;
+ (void)linePtr;
segPtr2 = segPtr->nextPtr;
if ((segPtr2 == NULL) || (segPtr2->typePtr != &tkTextCharType)) {
return segPtr;
}
- newPtr = ckalloc(CSEG_SIZE(segPtr->size + segPtr2->size));
+ newPtr = (TkTextSegment *)ckalloc(CSEG_SIZE(segPtr->size + segPtr2->size));
newPtr->typePtr = &tkTextCharType;
newPtr->nextPtr = segPtr2->nextPtr;
newPtr->size = segPtr->size + segPtr2->size;
@@ -4633,7 +4629,6 @@ CharCleanupProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
CharDeleteProc(
TkTextSegment *segPtr, /* Segment to delete. */
@@ -4642,6 +4637,9 @@ CharDeleteProc(
* deleted, so everything must get cleaned
* up. */
{
+ (void)linePtr;
+ (void)treeGone;
+
ckfree(segPtr);
return 0;
}
@@ -4663,12 +4661,13 @@ CharDeleteProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
CharCheckProc(
TkTextSegment *segPtr, /* Segment to check. */
TkTextLine *linePtr) /* Line containing segment. */
{
+ (void)linePtr;
+
/*
* Make sure that the segment contains the number of characters indicated
* by its header, and that the last segment in a line ends in a newline.
@@ -4858,7 +4857,7 @@ ToggleCheckProc(
TkTextSegment *segPtr, /* Segment to check. */
TkTextLine *linePtr) /* Line containing segment. */
{
- register Summary *summaryPtr;
+ Summary *summaryPtr;
int needSummary;
if (segPtr->size != 0) {
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 66ff744..2dfe964 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -654,10 +654,10 @@ void
TkTextCreateDInfo(
TkText *textPtr) /* Overall information for text widget. */
{
- register TextDInfo *dInfoPtr;
+ TextDInfo *dInfoPtr;
XGCValues gcValues;
- dInfoPtr = ckalloc(sizeof(TextDInfo));
+ dInfoPtr = (TextDInfo *)ckalloc(sizeof(TextDInfo));
Tcl_InitHashTable(&dInfoPtr->styleTable, sizeof(StyleValues)/sizeof(int));
dInfoPtr->dLinePtr = NULL;
dInfoPtr->copyGC = NULL;
@@ -713,7 +713,7 @@ void
TkTextFreeDInfo(
TkText *textPtr) /* Overall information for text widget. */
{
- register TextDInfo *dInfoPtr = textPtr->dInfoPtr;
+ TextDInfo *dInfoPtr = textPtr->dInfoPtr;
/*
* Be careful to free up styleTable *after* freeing up all the DLines, so
@@ -769,7 +769,7 @@ GetStyle(
* information is wanted. */
{
TkTextTag **tagPtrs;
- register TkTextTag *tagPtr;
+ TkTextTag *tagPtr;
StyleValues styleValues;
TextStyle *stylePtr;
Tcl_HashEntry *hPtr;
@@ -998,7 +998,7 @@ GetStyle(
hPtr = Tcl_CreateHashEntry(&textPtr->dInfoPtr->styleTable,
(char *) &styleValues, &isNew);
if (!isNew) {
- stylePtr = Tcl_GetHashValue(hPtr);
+ stylePtr = (TextStyle *)Tcl_GetHashValue(hPtr);
stylePtr->refCount++;
return stylePtr;
}
@@ -1007,7 +1007,7 @@ GetStyle(
* No existing style matched. Make a new one.
*/
- stylePtr = ckalloc(sizeof(TextStyle));
+ stylePtr = (TextStyle *)ckalloc(sizeof(TextStyle));
stylePtr->refCount = 1;
if (styleValues.border != NULL) {
gcValues.foreground = Tk_3DBorderColor(styleValues.border)->pixel;
@@ -1065,7 +1065,7 @@ GetStyle(
static void
FreeStyle(
TkText *textPtr, /* Information about overall widget. */
- register TextStyle *stylePtr)
+ TextStyle *stylePtr)
/* Information about style to free. */
{
if (stylePtr->refCount-- <= 1) {
@@ -1127,7 +1127,7 @@ LayoutDLine(
* necessarily point to a character
* segment. */
{
- register DLine *dlPtr; /* New display line. */
+ DLine *dlPtr; /* New display line. */
TkTextSegment *segPtr; /* Current segment in text. */
TkTextDispChunk *lastChunkPtr;
/* Last chunk allocated so far for line. */
@@ -1181,7 +1181,7 @@ LayoutDLine(
* Create and initialize a new DLine structure.
*/
- dlPtr = ckalloc(sizeof(DLine));
+ dlPtr = (DLine *)ckalloc(sizeof(DLine));
dlPtr->index = *indexPtr;
dlPtr->byteCount = 0;
dlPtr->y = 0;
@@ -1430,7 +1430,7 @@ LayoutDLine(
continue;
}
if (chunkPtr == NULL) {
- chunkPtr = ckalloc(sizeof(TkTextDispChunk));
+ chunkPtr = (TkTextDispChunk *)ckalloc(sizeof(TkTextDispChunk));
chunkPtr->nextPtr = NULL;
chunkPtr->clientData = NULL;
}
@@ -1828,8 +1828,8 @@ static void
UpdateDisplayInfo(
TkText *textPtr) /* Text widget to update. */
{
- register TextDInfo *dInfoPtr = textPtr->dInfoPtr;
- register DLine *dlPtr, *prevPtr;
+ TextDInfo *dInfoPtr = textPtr->dInfoPtr;
+ DLine *dlPtr, *prevPtr;
TkTextIndex index;
TkTextLine *lastLinePtr;
int y, maxY, xPixelOffset, maxOffset, lineHeight;
@@ -1866,7 +1866,7 @@ UpdateDisplayInfo(
y = dInfoPtr->y - dInfoPtr->newTopPixelOffset;
maxY = dInfoPtr->maxY;
while (1) {
- register DLine *newPtr;
+ DLine *newPtr;
if (index.linePtr == lastLinePtr) {
break;
@@ -1977,7 +1977,7 @@ UpdateDisplayInfo(
*/
if (index.linePtr != prevPtr->index.linePtr) {
- register DLine *nextPtr;
+ DLine *nextPtr;
nextPtr = dlPtr;
while ((nextPtr != NULL)
@@ -2346,7 +2346,7 @@ UpdateDisplayInfo(
static void
FreeDLines(
TkText *textPtr, /* Information about overall text widget. */
- register DLine *firstPtr, /* Pointer to first DLine to free up. */
+ DLine *firstPtr, /* Pointer to first DLine to free up. */
DLine *lastPtr, /* Pointer to DLine just after last one to
* free (NULL means everything starting with
* firstPtr). */
@@ -2359,8 +2359,8 @@ FreeDLines(
* we shouldn't invalidate anything for the
* overall widget. */
{
- register TkTextDispChunk *chunkPtr, *nextChunkPtr;
- register DLine *nextDLinePtr;
+ TkTextDispChunk *chunkPtr, *nextChunkPtr;
+ DLine *nextDLinePtr;
if (action == DLINE_FREE_TEMP) {
lineHeightsRecalculated++;
@@ -2379,7 +2379,7 @@ FreeDLines(
if (textPtr->dInfoPtr->dLinePtr == firstPtr) {
textPtr->dInfoPtr->dLinePtr = lastPtr;
} else {
- register DLine *prevPtr;
+ DLine *prevPtr;
for (prevPtr = textPtr->dInfoPtr->dLinePtr;
prevPtr->nextPtr != firstPtr; prevPtr = prevPtr->nextPtr) {
@@ -2427,14 +2427,14 @@ FreeDLines(
static void
DisplayDLine(
TkText *textPtr, /* Text widget in which to draw line. */
- register DLine *dlPtr, /* Information about line to draw. */
+ DLine *dlPtr, /* Information about line to draw. */
DLine *prevPtr, /* Line just before one to draw, or NULL if
* dlPtr is the top line. */
Pixmap pixmap) /* Pixmap to use for double-buffering. Caller
* must make sure it's large enough to hold
* line. */
{
- register TkTextDispChunk *chunkPtr;
+ TkTextDispChunk *chunkPtr;
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
Display *display;
int height, y_off;
@@ -2606,7 +2606,7 @@ DisplayDLine(
static void
DisplayLineBackground(
TkText *textPtr, /* Text widget containing line. */
- register DLine *dlPtr, /* Information about line to draw. */
+ DLine *dlPtr, /* Information about line to draw. */
DLine *prevPtr, /* Line just above dlPtr, or NULL if dlPtr is
* the top-most line in the window. */
Pixmap pixmap) /* Pixmap to use for double-buffering. Caller
@@ -3002,7 +3002,7 @@ static void
AsyncUpdateLineMetrics(
ClientData clientData) /* Information about widget. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
int lineNum;
@@ -3059,7 +3059,7 @@ AsyncUpdateLineMetrics(
* and we've reached the last line, then we're done.
*/
- if (dInfoPtr->metricEpoch == TCL_AUTO_LENGTH
+ if (dInfoPtr->metricEpoch == TCL_INDEX_NONE
&& lineNum == dInfoPtr->lastMetricUpdateLine) {
/*
* We have looped over all lines, so we're done. We must release our
@@ -3243,7 +3243,7 @@ TkTextUpdateLineMetrics(
* then we can't be done.
*/
- if (textPtr->dInfoPtr->metricEpoch == TCL_AUTO_LENGTH && lineNum == endLine) {
+ if (textPtr->dInfoPtr->metricEpoch == TCL_INDEX_NONE && lineNum == endLine) {
/*
@@ -4160,9 +4160,9 @@ static void
DisplayText(
ClientData clientData) /* Information about widget. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
- register DLine *dlPtr;
+ DLine *dlPtr;
DLine *prevPtr;
Pixmap pixmap;
int maxHeight, borders;
@@ -4246,7 +4246,7 @@ DisplayText(
*/
for (dlPtr = dInfoPtr->dLinePtr; dlPtr != NULL; dlPtr = dlPtr->nextPtr) {
- register DLine *dlPtr2;
+ DLine *dlPtr2;
int offset, height, y, oldY;
TkRegion damageRgn;
@@ -4544,7 +4544,7 @@ DisplayText(
* proc of embedded windows only.
*/
#endif
- register TkTextDispChunk *chunkPtr;
+ TkTextDispChunk *chunkPtr;
for (chunkPtr = dlPtr->chunkPtr; (chunkPtr != NULL);
chunkPtr = chunkPtr->nextPtr) {
@@ -4746,7 +4746,7 @@ TextInvalidateRegion(
TkText *textPtr, /* Widget record for text widget. */
TkRegion region) /* Region of area to redraw. */
{
- register DLine *dlPtr;
+ DLine *dlPtr;
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
int maxY, inset;
XRectangle rect;
@@ -5004,7 +5004,7 @@ TextRedrawTag(
int withTag) /* 1 means redraw characters that have the
* tag, 0 means redraw those without. */
{
- register DLine *dlPtr;
+ DLine *dlPtr;
DLine *endPtr;
int tagOn;
TkTextSearch search;
@@ -5344,7 +5344,7 @@ TkTextSetYView(
* are to be off the top of the screen. */
{
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
- register DLine *dlPtr;
+ DLine *dlPtr;
int bottomY, close, lineIndex;
TkTextIndex tmpIndex, rounded;
int lineHeight;
@@ -6153,7 +6153,7 @@ TkTextYviewCmd(
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
int pickPlace, type;
int pixels, count;
- size_t switchLength;
+ TkSizeT switchLength;
double fraction;
TkTextIndex index;
@@ -6172,7 +6172,7 @@ TkTextYviewCmd(
pickPlace = 0;
if (Tcl_GetString(objv[2])[0] == '-') {
- register const char *switchStr =
+ const char *switchStr =
TkGetStringFromObj(objv[2], &switchLength);
if ((switchLength >= 2) && (strncmp(switchStr, "-pickplace",
@@ -6350,7 +6350,7 @@ TkTextPendingsync(
int
TkTextScanCmd(
- register TkText *textPtr, /* Information about text widget. */
+ TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
@@ -6836,7 +6836,7 @@ static void
AsyncUpdateYScrollbar(
ClientData clientData) /* Information about widget. */
{
- register TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
textPtr->dInfoPtr->scrollbarTimer = NULL;
@@ -6871,7 +6871,7 @@ AsyncUpdateYScrollbar(
static DLine *
FindDLine(
TkText *textPtr, /* Widget record for text widget. */
- register DLine *dlPtr, /* Pointer to first in list of DLines to
+ DLine *dlPtr, /* Pointer to first in list of DLines to
* search. */
const TkTextIndex *indexPtr)/* Index of desired character. */
{
@@ -7041,7 +7041,7 @@ TkTextPixelIndex(
* border of the widget). */
{
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
- register DLine *dlPtr, *validDlPtr;
+ DLine *dlPtr, *validDlPtr;
int nearby = 0;
/*
@@ -7143,7 +7143,7 @@ DlineIndexOfX(
* the character nearest to x. */
{
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
- register TkTextDispChunk *chunkPtr;
+ TkTextDispChunk *chunkPtr;
/*
* Scan through the line's chunks to find the one that contains the
@@ -7271,7 +7271,7 @@ DlineXOfIndex(
int byteIndex) /* The byte index for which we want the
* coordinate. */
{
- register TkTextDispChunk *chunkPtr = dlPtr->chunkPtr;
+ TkTextDispChunk *chunkPtr = dlPtr->chunkPtr;
int x = 0;
if (byteIndex == 0 || chunkPtr == NULL) {
@@ -7341,7 +7341,7 @@ TkTextIndexBbox(
{
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
DLine *dlPtr;
- register TkTextDispChunk *chunkPtr;
+ TkTextDispChunk *chunkPtr;
int byteCount;
/*
@@ -7550,6 +7550,11 @@ ElideBboxProc(
int *heightPtr) /* Gets filled in with height of character, in
* pixels. */
{
+ (void)textPtr;
+ (void)index;
+ (void)lineHeight;
+ (void)baseline;
+
*xPtr = chunkPtr->x;
*yPtr = y;
*widthPtr = *heightPtr = 0;
@@ -7565,6 +7570,9 @@ ElideMeasureProc(
int x) /* X-coordinate, in same coordinate system as
* chunkPtr->x. */
{
+ (void)chunkPtr;
+ (void)x;
+
return 0 /*chunkPtr->numBytes - 1*/;
}
@@ -7606,7 +7614,7 @@ TkTextCharLayoutProc(
TkWrapMode wrapMode, /* How to handle line wrapping:
* TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or
* TEXT_WRAPMODE_WORD. */
- register TkTextDispChunk *chunkPtr)
+ TkTextDispChunk *chunkPtr)
/* Structure to fill in with information about
* this chunk. The x field has already been
* set by the caller. */
@@ -7623,6 +7631,8 @@ TkTextCharLayoutProc(
BaseCharInfo *bciPtr;
Tcl_DString *baseString;
#endif
+ (void)textPtr;
+ (void)indexPtr;
/*
* Figure out how many characters will fit in the space we've got. Include
@@ -7757,7 +7767,7 @@ TkTextCharLayoutProc(
chunkPtr->breakIndex = -1;
#if !TK_LAYOUT_WITH_BASE_CHUNKS
- ciPtr = ckalloc(Tk_Offset(CharInfo, chars) + 1 + bytesThatFit);
+ ciPtr = (CharInfo *)ckalloc(offsetof(CharInfo, chars) + 1 + bytesThatFit);
chunkPtr->clientData = ciPtr;
memcpy(ciPtr->chars, p, bytesThatFit);
#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
@@ -7870,7 +7880,7 @@ CharChunkMeasureChars(
* here. */
{
Tk_Font tkfont = chunkPtr->stylePtr->sValuePtr->tkfont;
- CharInfo *ciPtr = chunkPtr->clientData;
+ CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData;
#if !TK_LAYOUT_WITH_BASE_CHUNKS
if (chars == NULL) {
@@ -7959,7 +7969,7 @@ CharDisplayProc(
int screenY) /* Y-coordinate in text window that
* corresponds to y. */
{
- CharInfo *ciPtr = chunkPtr->clientData;
+ CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData;
const char *string;
TextStyle *stylePtr;
StyleValues *sValuePtr;
@@ -7967,6 +7977,9 @@ CharDisplayProc(
#if TK_DRAW_IN_CONTEXT
BaseCharInfo *bciPtr;
#endif /* TK_DRAW_IN_CONTEXT */
+ (void)textPtr;
+ (void)height;
+ (void)screenY;
if ((x + chunkPtr->width) <= 0) {
/*
@@ -8110,7 +8123,8 @@ CharUndisplayProc(
TkText *textPtr, /* Overall information about text widget. */
TkTextDispChunk *chunkPtr) /* Chunk that is about to be freed. */
{
- CharInfo *ciPtr = chunkPtr->clientData;
+ CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData;
+ (void)textPtr;
if (ciPtr) {
#if TK_LAYOUT_WITH_BASE_CHUNKS
@@ -8213,8 +8227,10 @@ CharBboxProc(
int *heightPtr) /* Gets filled in with height of character, in
* pixels. */
{
- CharInfo *ciPtr = chunkPtr->clientData;
+ CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData;
int maxX;
+ (void)textPtr;
+ (void)lineHeight;
maxX = chunkPtr->width + chunkPtr->x;
CharChunkMeasureChars(chunkPtr, NULL, 0, 0, byteIndex,
@@ -8376,7 +8392,7 @@ AdjustForTab(
if (chunkPtr2->displayProc != CharDisplayProc) {
continue;
}
- ciPtr = chunkPtr2->clientData;
+ ciPtr = (CharInfo *)chunkPtr2->clientData;
for (p = ciPtr->chars, i = 0; i < ciPtr->numBytes; p++, i++) {
if (isdigit(UCHAR(*p))) {
gotDigit = 1;
@@ -8397,7 +8413,7 @@ AdjustForTab(
if (decimalChunkPtr != NULL) {
int curX;
- ciPtr = decimalChunkPtr->clientData;
+ ciPtr = (CharInfo *)decimalChunkPtr->clientData;
CharChunkMeasureChars(decimalChunkPtr, NULL, 0, 0, decimal,
decimalChunkPtr->x, -1, 0, &curX);
desired = tabX - (curX - x);
@@ -8668,7 +8684,7 @@ MeasureChars(
int curX, width, ch;
const char *special, *end, *start;
- ch = 0; /* lint. */
+ ch = 0;
curX = startX;
start = source + rangeStart;
end = start + rangeLength;
@@ -8770,10 +8786,10 @@ TextGetScrollInfoObj(
VIEW_MOVETO, VIEW_SCROLL
};
static const char *const units[] = {
- "units", "pages", "pixels", NULL
+ "pages", "pixels", "units", NULL
};
enum viewUnits {
- VIEW_SCROLL_UNITS, VIEW_SCROLL_PAGES, VIEW_SCROLL_PIXELS
+ VIEW_SCROLL_PAGES, VIEW_SCROLL_PIXELS, VIEW_SCROLL_UNITS
};
int index;
@@ -8794,7 +8810,7 @@ TextGetScrollInfoObj(
return TKTEXT_SCROLL_MOVETO;
case VIEW_SCROLL:
if (objc != 5) {
- Tcl_WrongNumArgs(interp, 3, objv, "number units|pages|pixels");
+ Tcl_WrongNumArgs(interp, 3, objv, "number pages|pixels|units");
return TKTEXT_SCROLL_ERROR;
}
if (Tcl_GetIndexFromObjStruct(interp, objv[4], units,
diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c
index defda56..ccdfda6 100644
--- a/generic/tkTextImage.c
+++ b/generic/tkTextImage.c
@@ -18,7 +18,7 @@
*/
#define EI_SEG_SIZE \
- (Tk_Offset(TkTextSegment, body) + sizeof(TkTextEmbImage))
+ (offsetof(TkTextSegment, body) + sizeof(TkTextEmbImage))
/*
* Prototypes for functions defined in this file:
@@ -83,17 +83,17 @@ typedef enum {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-align", NULL, NULL,
- "center", -1, Tk_Offset(TkTextEmbImage, align),
+ "center", TCL_INDEX_NONE, offsetof(TkTextEmbImage, align),
0, alignStrings, 0},
{TK_OPTION_PIXELS, "-padx", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbImage, padX), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbImage, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbImage, padY), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbImage, padY), 0, 0, 0},
{TK_OPTION_STRING, "-image", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextEmbImage, imageString),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextEmbImage, imageString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-name", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextEmbImage, imageName),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextEmbImage, imageName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -117,7 +117,7 @@ static const Tk_OptionSpec optionSpecs[] = {
int
TkTextImageCmd(
- register TkText *textPtr, /* Information about text widget. */
+ TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
@@ -125,7 +125,7 @@ TkTextImageCmd(
* objv[1] is "image". */
{
int idx;
- register TkTextSegment *eiPtr;
+ TkTextSegment *eiPtr;
TkTextIndex index;
static const char *const optionStrings[] = {
"cget", "configure", "create", "names", NULL
@@ -242,7 +242,7 @@ TkTextImageCmd(
* Create the new image segment and initialize it.
*/
- eiPtr = ckalloc(EI_SEG_SIZE);
+ eiPtr = (TkTextSegment *)ckalloc(EI_SEG_SIZE);
eiPtr->typePtr = &tkTextEmbImageType;
eiPtr->size = 1;
eiPtr->body.ei.sharedTextPtr = textPtr->sharedTextPtr;
@@ -287,7 +287,7 @@ TkTextImageCmd(
for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->imageTable,
&search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
- Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr),
+ (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr),
-1));
}
Tcl_SetObjResult(interp, resultObj);
@@ -389,7 +389,7 @@ EmbImageConfigure(
len = strlen(name);
for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->imageTable,
&search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- char *haveName =
+ char *haveName = (char *)
Tcl_GetHashKey(&textPtr->sharedTextPtr->imageTable, hPtr);
if (strncmp(name, haveName, len) == 0) {
@@ -419,7 +419,7 @@ EmbImageConfigure(
&dummy);
Tcl_SetHashValue(hPtr, eiPtr);
Tcl_SetObjResult(textPtr->interp, Tcl_NewStringObj(name, -1));
- eiPtr->body.ei.name = ckalloc(Tcl_DStringLength(&newName) + 1);
+ eiPtr->body.ei.name = (char *)ckalloc(Tcl_DStringLength(&newName) + 1);
strcpy(eiPtr->body.ei.name, name);
Tcl_DStringFree(&newName);
@@ -444,7 +444,6 @@ EmbImageConfigure(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
EmbImageDeleteProc(
TkTextSegment *eiPtr, /* Segment being deleted. */
@@ -454,6 +453,8 @@ EmbImageDeleteProc(
* up. */
{
Tcl_HashEntry *hPtr;
+ (void)linePtr;
+ (void)treeGone;
if (eiPtr->body.ei.image != NULL) {
hPtr = Tcl_FindHashEntry(&eiPtr->body.ei.sharedTextPtr->imageTable,
@@ -527,7 +528,6 @@ EmbImageCleanupProc(
*--------------------------------------------------------------
*/
- /*ARGSUSED*/
static int
EmbImageLayoutProc(
TkText *textPtr, /* Text widget being layed out. */
@@ -544,12 +544,15 @@ EmbImageLayoutProc(
TkWrapMode wrapMode, /* Wrap mode to use for line:
* TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or
* TEXT_WRAPMODE_WORD. */
- register TkTextDispChunk *chunkPtr)
+ TkTextDispChunk *chunkPtr)
/* Structure to fill in with information about
* this chunk. The x field has already been
* set by the caller. */
{
int width, height;
+ (void)indexPtr;
+ (void)maxChars;
+ (void)wrapMode;
if (offset != 0) {
Tcl_Panic("Non-zero offset in EmbImageLayoutProc");
@@ -621,6 +624,8 @@ EmbImageCheckProc(
TkTextSegment *eiPtr, /* Segment to check. */
TkTextLine *linePtr) /* Line containing segment. */
{
+ (void)linePtr;
+
if (eiPtr->nextPtr == NULL) {
Tcl_Panic("EmbImageCheckProc: embedded image is last segment in line");
}
@@ -665,9 +670,11 @@ EmbImageDisplayProc(
int screenY) /* Y-coordinate in text window that
* corresponds to y. */
{
- TkTextSegment *eiPtr = chunkPtr->clientData;
+ TkTextSegment *eiPtr = (TkTextSegment *)chunkPtr->clientData;
int lineX, imageX, imageY, width, height;
Tk_Image image;
+ (void)display;
+ (void)screenY;
image = eiPtr->body.ei.image;
if (image == NULL) {
@@ -729,8 +736,10 @@ EmbImageBboxProc(
int *heightPtr) /* Gets filled in with height of image, in
* pixels. */
{
- TkTextSegment *eiPtr = chunkPtr->clientData;
+ TkTextSegment *eiPtr = (TkTextSegment *)chunkPtr->clientData;
Tk_Image image;
+ (void)textPtr;
+ (void)index;
image = eiPtr->body.ei.image;
if (image != NULL) {
@@ -794,7 +803,7 @@ TkTextImageIndex(
if (hPtr == NULL) {
return 0;
}
- eiPtr = Tcl_GetHashValue(hPtr);
+ eiPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
indexPtr->tree = textPtr->sharedTextPtr->tree;
indexPtr->linePtr = eiPtr->body.ei.linePtr;
indexPtr->byteIndex = TkTextSegToOffset(eiPtr, indexPtr->linePtr);
@@ -828,8 +837,14 @@ EmbImageProc(
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- TkTextSegment *eiPtr = clientData;
+ TkTextSegment *eiPtr = (TkTextSegment *)clientData;
TkTextIndex index;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
index.tree = eiPtr->body.ei.sharedTextPtr->tree;
index.linePtr = eiPtr->body.ei.linePtr;
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c
index 2870c07..70a53ae 100644
--- a/generic/tkTextIndex.c
+++ b/generic/tkTextIndex.c
@@ -107,7 +107,7 @@ DupTextIndexInternalRep(
TkSizeT epoch;
TkTextIndex *dupIndexPtr, *indexPtr;
- dupIndexPtr = ckalloc(sizeof(TkTextIndex));
+ dupIndexPtr = (TkTextIndex *)ckalloc(sizeof(TkTextIndex));
indexPtr = GET_TEXTINDEX(srcPtr);
epoch = GET_INDEXEPOCH(srcPtr);
@@ -139,7 +139,7 @@ UpdateStringOfTextIndex(
len = TkTextPrintIndex(indexPtr->textPtr, indexPtr, buffer);
- objPtr->bytes = ckalloc(len + 1);
+ objPtr->bytes = (char *)ckalloc(len + 1);
strcpy(objPtr->bytes, buffer);
objPtr->length = len;
}
@@ -176,7 +176,7 @@ MakeObjIndex(
* position. */
const TkTextIndex *origPtr) /* Pointer to index. */
{
- TkTextIndex *indexPtr = ckalloc(sizeof(TkTextIndex));
+ TkTextIndex *indexPtr = (TkTextIndex *)ckalloc(sizeof(TkTextIndex));
indexPtr->tree = origPtr->tree;
indexPtr->linePtr = origPtr->linePtr;
@@ -436,7 +436,7 @@ TkTextMakeByteIndex(
*/
start = segPtr->body.chars + (byteIndex - index);
- p = Tcl_UtfPrev(start, segPtr->body.chars);
+ p = TkUtfPrev(start, segPtr->body.chars);
p += TkUtfToUniChar(p, &ch);
indexPtr->byteIndex += p - start;
}
@@ -477,7 +477,7 @@ TkTextMakeCharIndex(
int charIndex, /* Index of desired character. */
TkTextIndex *indexPtr) /* Structure to fill in. */
{
- register TkTextSegment *segPtr;
+ TkTextSegment *segPtr;
char *p, *start, *end;
int index, offset;
int ch;
@@ -816,7 +816,7 @@ GetIndex(
hPtr = Tcl_FindHashEntry(&sharedPtr->tagTable, tagName);
*p = '.';
if (hPtr != NULL) {
- tagPtr = Tcl_GetHashValue(hPtr);
+ tagPtr = (TkTextTag *)Tcl_GetHashValue(hPtr);
}
}
@@ -832,7 +832,7 @@ GetIndex(
if (tagPtr == textPtr->selTagPtr) {
tagName = "sel";
} else if (hPtr != NULL) {
- tagName = Tcl_GetHashKey(&sharedPtr->tagTable, hPtr);
+ tagName = (const char *)Tcl_GetHashKey(&sharedPtr->tagTable, hPtr);
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"text doesn't contain any characters tagged with \"%s\"",
@@ -1151,7 +1151,7 @@ ForwBack(
* or "-" that starts modifier. */
TkTextIndex *indexPtr) /* Index to update as specified in string. */
{
- register const char *p, *units;
+ const char *p, *units;
char *end;
int count, lineIndex, modifier;
size_t length;
@@ -1298,6 +1298,7 @@ ForwBack(
if (forward) {
TkTextFindDisplayLineEnd(textPtr, indexPtr, 1, &xOffset);
while (count-- > 0) {
+
/*
* Go to the end of the line, then forward one char/byte
* to get to the beginning of the next line.
@@ -1310,17 +1311,31 @@ ForwBack(
} else {
TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, &xOffset);
while (count-- > 0) {
+ TkTextIndex indexPtr2;
+
/*
* Go to the beginning of the line, then backward one
* char/byte to get to the end of the previous line.
*/
TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL);
- TkTextIndexBackChars(textPtr, indexPtr, 1, indexPtr,
+ TkTextIndexBackChars(textPtr, indexPtr, 1, &indexPtr2,
COUNT_DISPLAY_INDICES);
+
+ /*
+ * If we couldn't go to the previous line, then we wanted
+ to go before the start of the text: arrange for returning
+ the first index of the first display line.
+ */
+
+ if (!TkTextIndexCmp(indexPtr, &indexPtr2)) {
+ xOffset = 0;
+ break;
+ }
+ *indexPtr = indexPtr2;
}
- TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL);
}
+ TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL);
/*
* This call assumes indexPtr is the beginning of a display line
@@ -1484,7 +1499,7 @@ TkTextIndexForwChars(
return;
}
if (checkElided) {
- infoPtr = ckalloc(sizeof(TkTextElideInfo));
+ infoPtr = (TkTextElideInfo *)ckalloc(sizeof(TkTextElideInfo));
elide = TkTextIsElided(textPtr, srcPtr, infoPtr);
}
@@ -1752,7 +1767,7 @@ TkTextIndexCount(
seg2Ptr = TkTextIndexToSeg(indexPtr2, &maxBytes);
if (checkElided) {
- infoPtr = ckalloc(sizeof(TkTextElideInfo));
+ infoPtr = (TkTextElideInfo *)ckalloc(sizeof(TkTextElideInfo));
elide = TkTextIsElided(textPtr, indexPtr1, infoPtr);
}
@@ -1829,9 +1844,9 @@ TkTextIndexCount(
if (segPtr->typePtr == &tkTextCharType) {
int byteLen = segPtr->size - byteOffset;
- register unsigned char *str = (unsigned char *)
+ unsigned char *str = (unsigned char *)
segPtr->body.chars + byteOffset;
- register int i;
+ int i;
if (segPtr == seg2Ptr) {
if (byteLen > (maxBytes - byteOffset)) {
@@ -2010,7 +2025,7 @@ TkTextIndexBackChars(
return;
}
if (checkElided) {
- infoPtr = ckalloc(sizeof(TkTextElideInfo));
+ infoPtr = (TkTextElideInfo *)ckalloc(sizeof(TkTextElideInfo));
elide = TkTextIsElided(textPtr, srcPtr, infoPtr);
}
@@ -2110,7 +2125,7 @@ TkTextIndexBackChars(
if (segPtr->typePtr == &tkTextCharType) {
start = segPtr->body.chars;
end = segPtr->body.chars + segSize;
- for (p = end; ; p = Tcl_UtfPrev(p, start)) {
+ for (p = end; ; p = TkUtfPrev(p, start)) {
if (charCount == 0) {
dstPtr->byteIndex -= (end - p);
goto backwardCharDone;
@@ -2210,7 +2225,7 @@ StartEnd(
{
const char *p;
size_t length;
- register TkTextSegment *segPtr;
+ TkTextSegment *segPtr;
int modifier;
/*
@@ -2351,7 +2366,7 @@ StartEnd(
}
if (offset > 0) {
chSize = (segPtr->body.chars + offset
- - Tcl_UtfPrev(segPtr->body.chars + offset,
+ - TkUtfPrev(segPtr->body.chars + offset,
segPtr->body.chars));
}
firstChar = 0;
diff --git a/generic/tkTextMark.c b/generic/tkTextMark.c
index da455d3..11acf37 100644
--- a/generic/tkTextMark.c
+++ b/generic/tkTextMark.c
@@ -19,7 +19,7 @@
* Macro that determines the size of a mark segment:
*/
-#define MSEG_SIZE (Tk_Offset(TkTextSegment, body) \
+#define MSEG_SIZE (offsetof(TkTextSegment, body) \
+ sizeof(TkTextMark))
/*
@@ -93,7 +93,7 @@ const Tk_SegType tkTextLeftMarkType = {
int
TkTextMarkCmd(
- register TkText *textPtr, /* Information about text widget. */
+ TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
@@ -126,7 +126,7 @@ TkTextMarkCmd(
switch ((enum markOptions) optionIndex) {
case MARK_GRAVITY: {
char c;
- size_t length;
+ TkSizeT length;
const char *str;
if (objc < 4 || objc > 5) {
@@ -147,7 +147,7 @@ TkTextMarkCmd(
NULL);
return TCL_ERROR;
}
- markPtr = Tcl_GetHashValue(hPtr);
+ markPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
}
if (objc == 4) {
const char *typeStr;
@@ -162,10 +162,10 @@ TkTextMarkCmd(
}
str = TkGetStringFromObj(objv[4],&length);
c = str[0];
- if ((c == 'l') && (strncmp(str, "left", (unsigned) length) == 0)) {
+ if ((c == 'l') && (strncmp(str, "left", length) == 0)) {
newTypePtr = &tkTextLeftMarkType;
} else if ((c == 'r') &&
- (strncmp(str, "right", (unsigned) length) == 0)) {
+ (strncmp(str, "right", length) == 0)) {
newTypePtr = &tkTextRightMarkType;
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -194,7 +194,7 @@ TkTextMarkCmd(
for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->markTable,
&search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
- Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr),
+ (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr),
-1));
}
Tcl_SetObjResult(interp, resultObj);
@@ -229,7 +229,7 @@ TkTextMarkCmd(
hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->markTable,
Tcl_GetString(objv[i]));
if (hPtr != NULL) {
- markPtr = Tcl_GetHashValue(hPtr);
+ markPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
/*
* Special case not needed with peer widgets.
@@ -290,7 +290,7 @@ TkTextSetMark(
widgetSpecific = 0;
hPtr = Tcl_CreateHashEntry(&textPtr->sharedTextPtr->markTable, name,
&isNew);
- markPtr = Tcl_GetHashValue(hPtr);
+ markPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
}
if (!isNew) {
/*
@@ -330,7 +330,7 @@ TkTextSetMark(
}
TkBTreeUnlinkSegment(markPtr, markPtr->body.mark.linePtr);
} else {
- markPtr = ckalloc(MSEG_SIZE);
+ markPtr = (TkTextSegment *)ckalloc(MSEG_SIZE);
markPtr->typePtr = &tkTextRightMarkType;
markPtr->size = 0;
markPtr->body.mark.textPtr = textPtr;
@@ -452,7 +452,7 @@ TkTextMarkNameToIndex(
if (hPtr == NULL) {
return TCL_ERROR;
}
- segPtr = Tcl_GetHashValue(hPtr);
+ segPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
}
TkTextMarkSegToIndex(textPtr, segPtr, indexPtr);
@@ -499,7 +499,6 @@ TkTextMarkNameToIndex(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
MarkDeleteProc(
TkTextSegment *segPtr, /* Segment being deleted. */
@@ -508,6 +507,10 @@ MarkDeleteProc(
* deleted, so everything must get cleaned
* up. */
{
+ (void)segPtr;
+ (void)linePtr;
+ (void)treeGone;
+
return 1;
}
@@ -570,11 +573,18 @@ MarkLayoutProc(
int noCharsYet, /* Non-zero means no characters have been
* assigned to this line yet. */
TkWrapMode wrapMode, /* Not used. */
- register TkTextDispChunk *chunkPtr)
+ TkTextDispChunk *chunkPtr)
/* Structure to fill in with information about
* this chunk. The x field has already been
* set by the caller. */
{
+ (void)indexPtr;
+ (void)offset;
+ (void)maxX;
+ (void)maxChars;
+ (void)noCharsYet;
+ (void)wrapMode;
+
if (segPtr != textPtr->insertMarkPtr) {
return -1;
}
@@ -615,7 +625,6 @@ MarkLayoutProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
void
TkTextInsertDisplayProc(
TkText *textPtr, /* The current text widget. */
@@ -641,6 +650,9 @@ TkTextInsertDisplayProc(
int halfWidth = textPtr->insertWidth/2;
int rightSideWidth;
int ix = 0, iy = 0, iw = 0, ih = 0, charWidth = 0;
+ (void)chunkPtr;
+ (void)baseline;
+ (void)display;
if (textPtr->insertCursorType) {
TkTextMarkSegToIndex(textPtr, textPtr->insertMarkPtr, &index);
@@ -721,12 +733,14 @@ TkTextInsertDisplayProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
InsertUndisplayProc(
TkText *textPtr, /* Overall information about text widget. */
TkTextDispChunk *chunkPtr) /* Chunk that is about to be freed. */
{
+ (void)textPtr;
+ (void)chunkPtr;
+
return;
}
@@ -809,7 +823,7 @@ MarkFindNext(
{
TkTextIndex index;
Tcl_HashEntry *hPtr;
- register TkTextSegment *segPtr;
+ TkTextSegment *segPtr;
int offset;
const char *string = Tcl_GetString(obj);
@@ -830,7 +844,7 @@ MarkFindNext(
* position.
*/
- segPtr = Tcl_GetHashValue(hPtr);
+ segPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
TkTextMarkSegToIndex(textPtr, segPtr, &index);
segPtr = segPtr->nextPtr;
} else {
@@ -900,7 +914,7 @@ MarkFindPrev(
{
TkTextIndex index;
Tcl_HashEntry *hPtr;
- register TkTextSegment *segPtr, *seg2Ptr, *prevPtr;
+ TkTextSegment *segPtr, *seg2Ptr, *prevPtr;
int offset;
const char *string = Tcl_GetString(obj);
@@ -919,7 +933,7 @@ MarkFindPrev(
* position.
*/
- segPtr = Tcl_GetHashValue(hPtr);
+ segPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
TkTextMarkSegToIndex(textPtr, segPtr, &index);
} else {
/*
@@ -1012,7 +1026,7 @@ GetMarkName(
return NULL;
} else {
- markName = Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable,
+ markName = (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable,
segPtr->body.mark.hPtr);
}
return Tcl_NewStringObj(markName, -1);
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c
index e20bf58..0846e1e 100644
--- a/generic/tkTextTag.c
+++ b/generic/tkTextTag.c
@@ -40,66 +40,66 @@ static const char *const tabStyleStrings[] = {
static const Tk_OptionSpec tagOptionSpecs[] = {
{TK_OPTION_BORDER, "-background", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, border), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, border), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BITMAP, "-bgstipple", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, bgStipple), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, bgStipple), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", NULL, NULL,
- NULL, Tk_Offset(TkTextTag, borderWidthPtr), Tk_Offset(TkTextTag, borderWidth),
+ NULL, offsetof(TkTextTag, borderWidthPtr), offsetof(TkTextTag, borderWidth),
TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0},
{TK_OPTION_STRING, "-elide", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, elideString),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, elideString),
TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0},
{TK_OPTION_BITMAP, "-fgstipple", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, fgStipple), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, fgStipple), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_FONT, "-font", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, tkfont), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, tkfont), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-foreground", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, fgColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, fgColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-justify", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, justifyString), TK_OPTION_NULL_OK, 0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, justifyString), TK_OPTION_NULL_OK, 0,0},
{TK_OPTION_STRING, "-lmargin1", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, lMargin1String), TK_OPTION_NULL_OK,0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMargin1String), TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-lmargin2", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, lMargin2String), TK_OPTION_NULL_OK,0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMargin2String), TK_OPTION_NULL_OK,0,0},
{TK_OPTION_BORDER, "-lmargincolor", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, lMarginColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMarginColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-offset", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, offsetString), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, offsetString), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-overstrike", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, overstrikeString),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrikeString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-overstrikefg", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, overstrikeColor),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrikeColor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-relief", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-rmargin", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0},
{TK_OPTION_BORDER, "-rmargincolor", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, rMarginColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, rMarginColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-selectforeground", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-spacing1", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, spacing1String), TK_OPTION_NULL_OK,0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing1String), TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-spacing2", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, spacing2String), TK_OPTION_NULL_OK,0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing2String), TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-spacing3", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, spacing3String), TK_OPTION_NULL_OK,0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing3String), TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-tabs", NULL, NULL,
- NULL, Tk_Offset(TkTextTag, tabStringPtr), -1, TK_OPTION_NULL_OK, 0, 0},
+ NULL, offsetof(TkTextTag, tabStringPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-tabstyle", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, tabStyle),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, tabStyle),
TK_OPTION_NULL_OK, tabStyleStrings, 0},
{TK_OPTION_STRING, "-underline", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, underlineString),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, underlineString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-underlinefg", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, underlineColor),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, underlineColor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-wrap", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, wrapMode),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, wrapMode),
TK_OPTION_NULL_OK, wrapStrings, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -137,7 +137,7 @@ static void TagBindEvent(TkText *textPtr, XEvent *eventPtr,
int
TkTextTagCmd(
- register TkText *textPtr, /* Information about text widget. */
+ TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
@@ -154,7 +154,7 @@ TkTextTagCmd(
TAG_REMOVE
};
int optionIndex, i;
- register TkTextTag *tagPtr;
+ TkTextTag *tagPtr;
TkTextIndex index1, index2;
if (objc < 3) {
@@ -292,7 +292,7 @@ TkTextTagCmd(
if (mask == 0) {
return TCL_ERROR;
}
- if (mask & (unsigned) ~(ButtonMotionMask|Button1MotionMask
+ if (mask & ~(unsigned long)(ButtonMotionMask|Button1MotionMask
|Button2MotionMask|Button3MotionMask|Button4MotionMask
|Button5MotionMask|ButtonPressMask|ButtonReleaseMask
|EnterWindowMask|LeaveWindowMask|KeyPressMask
@@ -584,7 +584,7 @@ TkTextTagCmd(
continue;
}
- tagPtr = Tcl_GetHashValue(hPtr);
+ tagPtr = (TkTextTag *)Tcl_GetHashValue(hPtr);
if (tagPtr == textPtr->selTagPtr) {
continue;
}
@@ -645,12 +645,12 @@ TkTextTagCmd(
Tcl_HashSearch search;
Tcl_HashEntry *hPtr;
- arrayPtr = ckalloc(textPtr->sharedTextPtr->numTags
+ arrayPtr = (TkTextTag **)ckalloc(textPtr->sharedTextPtr->numTags
* sizeof(TkTextTag *));
for (i=0, hPtr = Tcl_FirstHashEntry(
&textPtr->sharedTextPtr->tagTable, &search);
hPtr != NULL; i++, hPtr = Tcl_NextHashEntry(&search)) {
- arrayPtr[i] = Tcl_GetHashValue(hPtr);
+ arrayPtr[i] = (TkTextTag *)Tcl_GetHashValue(hPtr);
}
/*
@@ -986,7 +986,7 @@ TkTextCreateTag(
int *newTag) /* If non-NULL, then return 1 if new, or 0 if
* already exists. */
{
- register TkTextTag *tagPtr;
+ TkTextTag *tagPtr;
Tcl_HashEntry *hPtr = NULL;
int isNew;
const char *name;
@@ -1009,9 +1009,9 @@ TkTextCreateTag(
*newTag = isNew;
}
if (!isNew) {
- return Tcl_GetHashValue(hPtr);
+ return (TkTextTag *)Tcl_GetHashValue(hPtr);
}
- name = Tcl_GetHashKey(&textPtr->sharedTextPtr->tagTable, hPtr);
+ name = (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->tagTable, hPtr);
}
/*
@@ -1019,7 +1019,7 @@ TkTextCreateTag(
* to it to the hash table entry.
*/
- tagPtr = ckalloc(sizeof(TkTextTag));
+ tagPtr = (TkTextTag *)ckalloc(sizeof(TkTextTag));
tagPtr->name = name;
tagPtr->textPtr = NULL;
tagPtr->toggleCount = 0;
@@ -1108,7 +1108,7 @@ FindTag(
Tcl_Obj *tagName) /* Name of desired tag. */
{
Tcl_HashEntry *hPtr;
- size_t len;
+ TkSizeT len;
const char *str;
str = TkGetStringFromObj(tagName, &len);
@@ -1118,7 +1118,7 @@ FindTag(
hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->tagTable,
Tcl_GetString(tagName));
if (hPtr != NULL) {
- return Tcl_GetHashValue(hPtr);
+ return (TkTextTag *)Tcl_GetHashValue(hPtr);
}
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -1158,7 +1158,7 @@ FindTag(
void
TkTextDeleteTag(
TkText *textPtr, /* Info about overall widget. */
- register TkTextTag *tagPtr) /* Tag being deleted. */
+ TkTextTag *tagPtr) /* Tag being deleted. */
{
TkTextIndex first, last;
@@ -1216,7 +1216,7 @@ TkTextDeleteTag(
void
TkTextFreeTag(
TkText *textPtr, /* Info about overall widget. */
- register TkTextTag *tagPtr) /* Tag being deleted. */
+ TkTextTag *tagPtr) /* Tag being deleted. */
{
int i;
@@ -1295,7 +1295,7 @@ SortTags(
TkTextTag **tagArrayPtr) /* Pointer to array of pointers. */
{
int i, j, prio;
- register TkTextTag **tagPtrPtr;
+ TkTextTag **tagPtrPtr;
TkTextTag **maxPtrPtr, *tmp;
if (numTags < 2) {
@@ -1379,7 +1379,7 @@ ChangeTagPriority(
int prio) /* New priority for tag. */
{
int low, high, delta;
- register TkTextTag *tagPtr2;
+ TkTextTag *tagPtr2;
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
@@ -1412,7 +1412,7 @@ ChangeTagPriority(
}
for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->tagTable, &search);
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- tagPtr2 = Tcl_GetHashValue(hPtr);
+ tagPtr2 = (TkTextTag *)Tcl_GetHashValue(hPtr);
if ((tagPtr2->priority >= low) && (tagPtr2->priority <= high)) {
tagPtr2->priority += delta;
}
@@ -1443,12 +1443,9 @@ TkTextBindProc(
ClientData clientData, /* Pointer to canvas structure. */
XEvent *eventPtr) /* Pointer to X event that just happened. */
{
- TkText *textPtr = clientData;
+ TkText *textPtr = (TkText *)clientData;
int repick = 0;
-# define AnyButtonMask \
- (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
-
textPtr->refCount++;
/*
@@ -1460,35 +1457,16 @@ TkTextBindProc(
if (eventPtr->type == ButtonPress) {
textPtr->flags |= BUTTON_DOWN;
} else if (eventPtr->type == ButtonRelease) {
- int mask;
+ unsigned long mask;
- switch (eventPtr->xbutton.button) {
- case Button1:
- mask = Button1Mask;
- break;
- case Button2:
- mask = Button2Mask;
- break;
- case Button3:
- mask = Button3Mask;
- break;
- case Button4:
- mask = Button4Mask;
- break;
- case Button5:
- mask = Button5Mask;
- break;
- default:
- mask = 0;
- break;
- }
- if ((eventPtr->xbutton.state & AnyButtonMask) == (unsigned) mask) {
+ mask = TkGetButtonMask(eventPtr->xbutton.button);
+ if ((eventPtr->xbutton.state & ALL_BUTTONS) == mask) {
textPtr->flags &= ~BUTTON_DOWN;
repick = 1;
}
} else if ((eventPtr->type == EnterNotify)
|| (eventPtr->type == LeaveNotify)) {
- if (eventPtr->xcrossing.state & AnyButtonMask) {
+ if (eventPtr->xcrossing.state & ALL_BUTTONS) {
textPtr->flags |= BUTTON_DOWN;
} else {
textPtr->flags &= ~BUTTON_DOWN;
@@ -1496,7 +1474,7 @@ TkTextBindProc(
TkTextPickCurrent(textPtr, eventPtr);
goto done;
} else if (eventPtr->type == MotionNotify) {
- if (eventPtr->xmotion.state & AnyButtonMask) {
+ if (eventPtr->xmotion.state & ALL_BUTTONS) {
textPtr->flags |= BUTTON_DOWN;
} else {
textPtr->flags &= ~BUTTON_DOWN;
@@ -1513,8 +1491,7 @@ TkTextBindProc(
unsigned int oldState;
oldState = eventPtr->xbutton.state;
- eventPtr->xbutton.state &= ~(Button1Mask|Button2Mask
- |Button3Mask|Button4Mask|Button5Mask);
+ eventPtr->xbutton.state &= ~(unsigned long)ALL_BUTTONS;
if (!(textPtr->flags & DESTROYED)) {
TkTextPickCurrent(textPtr, eventPtr);
}
@@ -1552,7 +1529,7 @@ TkTextBindProc(
void
TkTextPickCurrent(
- register TkText *textPtr, /* Text widget in which to select current
+ TkText *textPtr, /* Text widget in which to select current
* character. */
XEvent *eventPtr) /* Event describing location of mouse cursor.
* Must be EnterWindow, LeaveWindow,
@@ -1656,7 +1633,7 @@ TkTextPickCurrent(
SortTags(textPtr->numCurTags, textPtr->curTagArrayPtr);
if (numNewTags > 0) {
size = numNewTags * sizeof(TkTextTag *);
- copyArrayPtr = ckalloc(size);
+ copyArrayPtr = (TkTextTag **)ckalloc(size);
memcpy(copyArrayPtr, newArrayPtr, size);
for (i = 0; i < textPtr->numCurTags; i++) {
for (j = 0; j < numNewTags; j++) {
@@ -1760,7 +1737,7 @@ TagBindEvent(
*/
if (numTags > NUM_BIND_TAGS) {
- nameArrPtr = ckalloc(numTags * sizeof(const char *));
+ nameArrPtr = (const char **)ckalloc(numTags * sizeof(const char *));
} else {
nameArrPtr = nameArray;
}
diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c
index 79ed1a1..d9c77d1 100644
--- a/generic/tkTextWind.c
+++ b/generic/tkTextWind.c
@@ -35,7 +35,7 @@ static const Tk_GeomMgr textGeomType = {
* Macro that determines the size of an embedded window segment:
*/
-#define EW_SEG_SIZE (Tk_Offset(TkTextSegment, body) \
+#define EW_SEG_SIZE (offsetof(TkTextSegment, body) \
+ sizeof(TkTextEmbWindow))
/*
@@ -99,18 +99,18 @@ typedef enum {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-align", NULL, NULL,
- "center", -1, Tk_Offset(TkTextEmbWindow, align),
+ "center", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, align),
0, alignStrings, 0},
{TK_OPTION_STRING, "-create", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextEmbWindow, create), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextEmbWindow, create), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbWindow, padX), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbWindow, padY), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, padY), 0, 0, 0},
{TK_OPTION_BOOLEAN, "-stretch", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbWindow, stretch), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, stretch), 0, 0, 0},
{TK_OPTION_WINDOW, "-window", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextEmbWindow, tkwin), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextEmbWindow, tkwin), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -133,7 +133,7 @@ static const Tk_OptionSpec optionSpecs[] = {
int
TkTextWindowCmd(
- register TkText *textPtr, /* Information about text widget. */
+ TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
@@ -147,7 +147,7 @@ TkTextWindowCmd(
enum windOptions {
WIND_CGET, WIND_CONFIGURE, WIND_CREATE, WIND_NAMES
};
- register TkTextSegment *ewPtr;
+ TkTextSegment *ewPtr;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "option ?arg ...?");
@@ -290,7 +290,7 @@ TkTextWindowCmd(
* Create the new window segment and initialize it.
*/
- ewPtr = ckalloc(EW_SEG_SIZE);
+ ewPtr = (TkTextSegment *)ckalloc(EW_SEG_SIZE);
ewPtr->typePtr = &tkTextEmbWindowType;
ewPtr->size = 1;
ewPtr->body.ew.sharedTextPtr = textPtr->sharedTextPtr;
@@ -302,7 +302,7 @@ TkTextWindowCmd(
ewPtr->body.ew.stretch = 0;
ewPtr->body.ew.optionTable = Tk_CreateOptionTable(interp, optionSpecs);
- client = ckalloc(sizeof(TkTextEmbWindowClient));
+ client = (TkTextEmbWindowClient *)ckalloc(sizeof(TkTextEmbWindowClient));
client->next = NULL;
client->textPtr = textPtr;
client->tkwin = NULL;
@@ -345,7 +345,7 @@ TkTextWindowCmd(
for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->windowTable,
&search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
- Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr),
+ (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr),
-1));
}
Tcl_SetObjResult(interp, resultObj);
@@ -467,7 +467,7 @@ EmbWinConfigure(
* Have to make the new client.
*/
- client = ckalloc(sizeof(TkTextEmbWindowClient));
+ client = (TkTextEmbWindowClient *)ckalloc(sizeof(TkTextEmbWindowClient));
client->next = ewPtr->body.ew.clients;
client->textPtr = textPtr;
client->tkwin = NULL;
@@ -526,7 +526,7 @@ EmbWinStructureProc(
ClientData clientData, /* Pointer to record describing window item. */
XEvent *eventPtr) /* Describes what just happened. */
{
- TkTextEmbWindowClient *client = clientData;
+ TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
TkTextSegment *ewPtr = client->parent;
TkTextIndex index;
Tcl_HashEntry *hPtr;
@@ -573,15 +573,15 @@ EmbWinStructureProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
EmbWinRequestProc(
ClientData clientData, /* Pointer to record for window item. */
Tk_Window tkwin) /* Window that changed its desired size. */
{
- TkTextEmbWindowClient *client = clientData;
+ TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
TkTextSegment *ewPtr = client->parent;
TkTextIndex index;
+ (void)tkwin;
index.tree = ewPtr->body.ew.sharedTextPtr->tree;
index.linePtr = ewPtr->body.ew.linePtr;
@@ -616,7 +616,7 @@ EmbWinLostSlaveProc(
Tk_Window tkwin) /* Window that was claimed away by another
* geometry manager. */
{
- TkTextEmbWindowClient *client = clientData;
+ TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
TkTextSegment *ewPtr = client->parent;
TkTextIndex index;
Tcl_HashEntry *hPtr;
@@ -736,7 +736,6 @@ TkTextWinFreeClient(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
EmbWinDeleteProc(
TkTextSegment *ewPtr, /* Segment being deleted. */
@@ -747,6 +746,8 @@ EmbWinDeleteProc(
{
TkTextEmbWindowClient *client;
client = ewPtr->body.ew.clients;
+ (void)linePtr;
+ (void)treeGone;
while (client != NULL) {
TkTextEmbWindowClient *next = client->next;
@@ -816,7 +817,6 @@ EmbWinCleanupProc(
*--------------------------------------------------------------
*/
- /*ARGSUSED*/
static int
EmbWinLayoutProc(
TkText *textPtr, /* Text widget being layed out. */
@@ -833,13 +833,16 @@ EmbWinLayoutProc(
TkWrapMode wrapMode, /* Wrap mode to use for line:
* TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or
* TEXT_WRAPMODE_WORD. */
- register TkTextDispChunk *chunkPtr)
+ TkTextDispChunk *chunkPtr)
/* Structure to fill in with information about
* this chunk. The x field has already been
* set by the caller. */
{
int width, height;
TkTextEmbWindowClient *client;
+ (void)indexPtr;
+ (void)maxChars;
+ (void)wrapMode;
if (offset != 0) {
Tcl_Panic("Non-zero offset in EmbWinLayoutProc");
@@ -959,7 +962,7 @@ EmbWinLayoutProc(
* now need to add to our client list.
*/
- client = ckalloc(sizeof(TkTextEmbWindowClient));
+ client = (TkTextEmbWindowClient *)ckalloc(sizeof(TkTextEmbWindowClient));
client->next = ewPtr->body.ew.clients;
client->textPtr = textPtr;
client->tkwin = NULL;
@@ -1054,6 +1057,8 @@ EmbWinCheckProc(
TkTextSegment *ewPtr, /* Segment to check. */
TkTextLine *linePtr) /* Line containing segment. */
{
+ (void)linePtr;
+
if (ewPtr->nextPtr == NULL) {
Tcl_Panic("EmbWinCheckProc: embedded window is last segment in line");
}
@@ -1100,8 +1105,11 @@ TkTextEmbWinDisplayProc(
{
int lineX, windowX, windowY, width, height;
Tk_Window tkwin;
- TkTextSegment *ewPtr = chunkPtr->clientData;
+ TkTextSegment *ewPtr = (TkTextSegment *)chunkPtr->clientData;
TkTextEmbWindowClient *client = EmbWinGetClient(textPtr, ewPtr);
+ (void)y;
+ (void)display;
+ (void)dst;
if (client == NULL) {
return;
@@ -1180,7 +1188,7 @@ EmbWinUndisplayProc(
TkText *textPtr, /* Overall information about text widget. */
TkTextDispChunk *chunkPtr) /* Chunk that is about to be freed. */
{
- TkTextSegment *ewPtr = chunkPtr->clientData;
+ TkTextSegment *ewPtr = (TkTextSegment *)chunkPtr->clientData;
TkTextEmbWindowClient *client = EmbWinGetClient(textPtr, ewPtr);
if (client == NULL) {
@@ -1243,8 +1251,9 @@ EmbWinBboxProc(
* pixels. */
{
Tk_Window tkwin;
- TkTextSegment *ewPtr = chunkPtr->clientData;
+ TkTextSegment *ewPtr = (TkTextSegment *)chunkPtr->clientData;
TkTextEmbWindowClient *client = EmbWinGetClient(textPtr, ewPtr);
+ (void)index;
if (client == NULL) {
tkwin = NULL;
@@ -1305,7 +1314,7 @@ static void
EmbWinDelayedUnmap(
ClientData clientData) /* Token for the window to be unmapped. */
{
- TkTextEmbWindowClient *client = clientData;
+ TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
if (!client->displayed && (client->tkwin != NULL)) {
if (client->textPtr->tkwin != Tk_Parent(client->tkwin)) {
@@ -1353,7 +1362,7 @@ TkTextWindowIndex(
return 0;
}
- ewPtr = Tcl_GetHashValue(hPtr);
+ ewPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
indexPtr->tree = textPtr->sharedTextPtr->tree;
indexPtr->linePtr = ewPtr->body.ew.linePtr;
indexPtr->byteIndex = TkTextSegToOffset(ewPtr, indexPtr->linePtr);
diff --git a/generic/tkTrig.c b/generic/tkTrig.c
index a2bf456..c0691a5 100644
--- a/generic/tkTrig.c
+++ b/generic/tkTrig.c
@@ -282,7 +282,6 @@ TkLineToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
int
TkThickPolyLineToArea(
double *coordPtr, /* Points to an array of coordinates for the
@@ -440,7 +439,7 @@ TkPolygonToPoint(
* intersect a ray extending vertically
* upwards from the point to infinity. */
int count;
- register double *pPtr;
+ double *pPtr;
/*
* Iterate through all of the edges in the polygon, updating bestDist and
@@ -588,7 +587,7 @@ TkPolygonToArea(
* polygon: x0, y0, x1, y1, ... The polygon
* may be self-intersecting. */
int numPoints, /* Total number of points at *polyPtr. */
- register double *rectPtr) /* Points to coords for rectangle, in the
+ double *rectPtr) /* Points to coords for rectangle, in the
* order x1, y1, x2, y2. X1 and y1 must be
* lower-left corner. */
{
@@ -596,7 +595,7 @@ TkPolygonToArea(
* outside, 1 means inside, won't ever be
* 0). */
int count;
- register double *pPtr;
+ double *pPtr;
/*
* Iterate over all of the edges of the polygon and test them against the
@@ -652,7 +651,6 @@ TkPolygonToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
double
TkOvalToPoint(
double ovalPtr[4], /* Pointer to array of four coordinates (x1,
@@ -751,11 +749,11 @@ TkOvalToPoint(
int
TkOvalToArea(
- register double *ovalPtr, /* Points to coordinates defining the
+ double *ovalPtr, /* Points to coordinates defining the
* bounding rectangle for the oval: x1, y1,
* x2, y2. X1 must be less than x2 and y1 less
* than y2. */
- register double *rectPtr) /* Points to coords for rectangle, in the
+ double *rectPtr) /* Points to coords for rectangle, in the
* order x1, y1, x2, y2. X1 and y1 must be
* lower-left corner. */
{
@@ -867,10 +865,9 @@ TkOvalToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
void
TkIncludePoint(
- register Tk_Item *itemPtr, /* Item whose bounding box is being
+ Tk_Item *itemPtr, /* Item whose bounding box is being
* calculated. */
double *pointPtr) /* Address of two doubles giving x and y
* coordinates of point. */
@@ -919,7 +916,7 @@ TkBezierScreenPoints(
double control[], /* Array of coordinates for four control
* points: x0, y0, x1, y1, ... x3 y3. */
int numSteps, /* Number of curve points to generate. */
- register XPoint *xPointPtr) /* Where to put new points. */
+ XPoint *xPointPtr) /* Where to put new points. */
{
int i;
double u, u2, u3, t, t2, t3;
@@ -965,7 +962,7 @@ TkBezierPoints(
double control[], /* Array of coordinates for four control
* points: x0, y0, x1, y1, ... x3 y3. */
int numSteps, /* Number of curve points to generate. */
- register double *coordPtr) /* Where to put new points. */
+ double *coordPtr) /* Where to put new points. */
{
int i;
double u, u2, u3, t, t2, t3;
diff --git a/generic/tkUndo.c b/generic/tkUndo.c
index c66905d..7494332 100644
--- a/generic/tkUndo.c
+++ b/generic/tkUndo.c
@@ -94,7 +94,7 @@ TkUndoInsertSeparator(
TkUndoAtom *separator;
if (*stack!=NULL && (*stack)->type!=TK_UNDO_SEPARATOR) {
- separator = ckalloc(sizeof(TkUndoAtom));
+ separator = (TkUndoAtom *)ckalloc(sizeof(TkUndoAtom));
separator->type = TK_UNDO_SEPARATOR;
TkUndoPushStack(stack,separator);
return 1;
@@ -181,7 +181,7 @@ TkUndoPushAction(
{
TkUndoAtom *atom;
- atom = ckalloc(sizeof(TkUndoAtom));
+ atom = (TkUndoAtom *)ckalloc(sizeof(TkUndoAtom));
atom->type = TK_UNDO_ACTION;
atom->apply = apply;
atom->revert = revert;
@@ -237,7 +237,7 @@ TkUndoMakeCmdSubAtom(
Tcl_Panic("NULL command and actionScript in TkUndoMakeCmdSubAtom");
}
- atom = ckalloc(sizeof(TkUndoSubAtom));
+ atom = (TkUndoSubAtom *)ckalloc(sizeof(TkUndoSubAtom));
atom->command = command;
atom->funcPtr = NULL;
atom->clientData = NULL;
@@ -299,7 +299,7 @@ TkUndoMakeSubAtom(
Tcl_Panic("NULL funcPtr in TkUndoMakeSubAtom");
}
- atom = ckalloc(sizeof(TkUndoSubAtom));
+ atom = (TkUndoSubAtom *)ckalloc(sizeof(TkUndoSubAtom));
atom->command = NULL;
atom->funcPtr = funcPtr;
atom->clientData = clientData;
@@ -341,7 +341,7 @@ TkUndoInitStack(
{
TkUndoRedoStack *stack; /* An Undo/Redo stack */
- stack = ckalloc(sizeof(TkUndoRedoStack));
+ stack = (TkUndoRedoStack *)ckalloc(sizeof(TkUndoRedoStack));
stack->undoStack = NULL;
stack->redoStack = NULL;
stack->interp = interp;
diff --git a/generic/tkUtil.c b/generic/tkUtil.c
index 6850f47..01155c9 100644
--- a/generic/tkUtil.c
+++ b/generic/tkUtil.c
@@ -48,7 +48,7 @@ int
TkStateParseProc(
ClientData clientData, /* some flags.*/
Tcl_Interp *interp, /* Used for reporting errors. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
int offset) /* Offset into item. */
@@ -57,8 +57,7 @@ TkStateParseProc(
int flags = PTR2INT(clientData);
size_t length;
Tcl_Obj *msgObj;
-
- register Tk_State *statePtr = (Tk_State *) (widgRec + offset);
+ Tk_State *statePtr = (Tk_State *) (widgRec + offset);
if (value == NULL || *value == 0) {
*statePtr = TK_STATE_NULL;
@@ -126,15 +125,15 @@ TkStateParseProc(
const char *
TkStatePrintProc(
- ClientData clientData, /* Ignored. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(void *), /* Ignored. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
int offset, /* Offset into item. */
- Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
+ TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
- register Tk_State *statePtr = (Tk_State *) (widgRec + offset);
+ Tk_State *statePtr = (Tk_State *) (widgRec + offset);
switch (*statePtr) {
case TK_STATE_NORMAL:
@@ -170,17 +169,16 @@ TkStatePrintProc(
int
TkOrientParseProc(
- ClientData clientData, /* some flags.*/
+ TCL_UNUSED(void *), /* some flags.*/
Tcl_Interp *interp, /* Used for reporting errors. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
int offset) /* Offset into item. */
{
int c;
size_t length;
-
- register int *orientPtr = (int *) (widgRec + offset);
+ int *orientPtr = (int *) (widgRec + offset);
if (value == NULL || *value == 0) {
*orientPtr = 0;
@@ -229,15 +227,15 @@ TkOrientParseProc(
const char *
TkOrientPrintProc(
- ClientData clientData, /* Ignored. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(void *), /* Ignored. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
int offset, /* Offset into item. */
- Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
+ TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
- register int *statePtr = (int *) (widgRec + offset);
+ int *statePtr = (int *) (widgRec + offset);
if (*statePtr) {
return "vertical";
@@ -299,6 +297,7 @@ TkOffsetParseProc(
tsoffset.flags = INT_MAX;
goto goodTSOffset;
}
+ break;
case 'w':
if (value[1] != '\0') {goto badTSOffset;}
tsoffset.flags = TK_OFFSET_LEFT|TK_OFFSET_MIDDLE;
@@ -410,8 +409,8 @@ TkOffsetParseProc(
const char *
TkOffsetPrintProc(
- ClientData clientData, /* not used */
- Tk_Window tkwin, /* not used */
+ TCL_UNUSED(void *), /* not used */
+ TCL_UNUSED(Tk_Window), /* not used */
char *widgRec, /* Widget structure record */
int offset, /* Offset of tile in record */
Tcl_FreeProc **freeProcPtr) /* not used */
@@ -423,7 +422,7 @@ TkOffsetPrintProc(
if (offsetPtr->flags >= INT_MAX) {
return "end";
}
- p = ckalloc(32);
+ p = (char *)ckalloc(32);
sprintf(p, "%d", offsetPtr->flags & ~TK_OFFSET_INDEX);
*freeProcPtr = TCL_DYNAMIC;
return p;
@@ -453,7 +452,7 @@ TkOffsetPrintProc(
return "se";
}
}
- q = p = ckalloc(32);
+ q = p = (char *)ckalloc(32);
if (offsetPtr->flags & TK_OFFSET_RELATIVE) {
*q++ = '#';
}
@@ -511,14 +510,14 @@ TkPixelParseProc(
const char *
TkPixelPrintProc(
- ClientData clientData, /* not used */
- Tk_Window tkwin, /* not used */
+ TCL_UNUSED(void *), /* not used */
+ TCL_UNUSED(Tk_Window), /* not used */
char *widgRec, /* Widget structure record */
int offset, /* Offset of tile in record */
Tcl_FreeProc **freeProcPtr) /* not used */
{
double *doublePtr = (double *) (widgRec + offset);
- char *p = ckalloc(24);
+ char *p = (char *)ckalloc(24);
Tcl_PrintDouble(NULL, *doublePtr, p);
*freeProcPtr = TCL_DYNAMIC;
@@ -668,7 +667,7 @@ Tk_GetScrollInfo(
if (argc != 5) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # args: should be \"%s %s %s\"",
- argv[0], argv[1], "scroll number units|pages"));
+ argv[0], argv[1], "scroll number pages|units"));
Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL);
return TK_SCROLL_ERROR;
}
@@ -684,7 +683,7 @@ Tk_GetScrollInfo(
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad argument \"%s\": must be units or pages", argv[4]));
+ "bad argument \"%s\": must be pages or units", argv[4]));
Tcl_SetErrorCode(interp, "TK", "VALUE", "SCROLL_UNITS", NULL);
return TK_SCROLL_ERROR;
}
@@ -729,7 +728,7 @@ Tk_GetScrollInfoObj(
int *intPtr) /* Filled in with number of pages or lines to
* scroll, if any. */
{
- size_t length;
+ TkSizeT length;
const char *arg = TkGetStringFromObj(objv[2], &length);
#define ArgPfxEq(str) \
@@ -746,7 +745,7 @@ Tk_GetScrollInfoObj(
return TK_SCROLL_MOVETO;
} else if (ArgPfxEq("scroll")) {
if (objc != 5) {
- Tcl_WrongNumArgs(interp, 2, objv, "scroll number units|pages");
+ Tcl_WrongNumArgs(interp, 2, objv, "scroll number pages|units");
return TK_SCROLL_ERROR;
}
if (Tcl_GetIntFromObj(interp, objv[3], intPtr) != TCL_OK) {
@@ -761,7 +760,7 @@ Tk_GetScrollInfoObj(
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad argument \"%s\": must be units or pages", arg));
+ "bad argument \"%s\": must be pages or units", arg));
Tcl_SetErrorCode(interp, "TK", "VALUE", "SCROLL_UNITS", NULL);
return TK_SCROLL_ERROR;
}
@@ -1086,7 +1085,7 @@ TkBackgroundEvalObjv(
Tcl_Command
TkMakeEnsemble(
Tcl_Interp *interp,
- const char *namespace,
+ const char *namesp,
const char *name,
ClientData clientData,
const TkEnsemble map[])
@@ -1103,11 +1102,11 @@ TkMakeEnsemble(
Tcl_DStringInit(&ds);
- namespacePtr = Tcl_FindNamespace(interp, namespace, NULL, 0);
+ namespacePtr = Tcl_FindNamespace(interp, namesp, NULL, 0);
if (namespacePtr == NULL) {
- namespacePtr = Tcl_CreateNamespace(interp, namespace, NULL, NULL);
+ namespacePtr = Tcl_CreateNamespace(interp, namesp, NULL, NULL);
if (namespacePtr == NULL) {
- Tcl_Panic("failed to create namespace \"%s\"", namespace);
+ Tcl_Panic("failed to create namespace \"%s\"", namesp);
}
}
@@ -1123,8 +1122,8 @@ TkMakeEnsemble(
}
Tcl_DStringSetLength(&ds, 0);
- Tcl_DStringAppend(&ds, namespace, -1);
- if (!(strlen(namespace) == 2 && namespace[1] == ':')) {
+ Tcl_DStringAppend(&ds, namesp, -1);
+ if (!(strlen(namesp) == 2 && namesp[1] == ':')) {
Tcl_DStringAppend(&ds, "::", -1);
}
Tcl_DStringAppend(&ds, name, -1);
@@ -1176,7 +1175,7 @@ TkSendVirtualEvent(
const char *eventName,
Tcl_Obj *detail)
{
- union {XEvent general; XVirtualEvent virtual;} event;
+ union {XEvent general; XVirtualEvent virt;} event;
memset(&event, 0, sizeof(event));
event.general.xany.type = VirtualEvent;
@@ -1184,10 +1183,8 @@ TkSendVirtualEvent(
event.general.xany.send_event = False;
event.general.xany.window = Tk_WindowId(target);
event.general.xany.display = Tk_Display(target);
- event.virtual.name = Tk_GetUid(eventName);
- if (detail != NULL) {
- event.virtual.user_data = detail;
- }
+ event.virt.name = Tk_GetUid(eventName);
+ event.virt.user_data = detail;
Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
}
@@ -1215,26 +1212,28 @@ TkSendVirtualEvent(
size_t
TkUtfToUniChar(
const char *src, /* The UTF-8 string. */
- int *chPtr) /* Filled with the Tcl_UniChar represented by
+ int *chPtr) /* Filled with the Unicode value represented by
* the UTF-8 string. */
{
Tcl_UniChar uniChar = 0;
size_t len = Tcl_UtfToUniChar(src, &uniChar);
- if ((uniChar & 0xfc00) == 0xd800) {
- Tcl_UniChar high = uniChar;
+ if ((sizeof(Tcl_UniChar) == 2)
+ && ((uniChar & 0xFC00) == 0xD800)
+#if TCL_MAJOR_VERSION > 8
+ && (len == 1)
+#endif
+ ) {
+ Tcl_UniChar low = uniChar;
/* This can only happen if Tcl is compiled with TCL_UTF_MAX=4,
* or when a high surrogate character is detected in UTF-8 form */
- size_t len2 = Tcl_UtfToUniChar(src+len, &uniChar);
- if ((uniChar & 0xfc00) == 0xdc00) {
- *chPtr = (((high & 0x3ff) << 10) | (uniChar & 0x3ff)) + 0x10000;
- len += len2;
- } else {
- *chPtr = high;
+ size_t len2 = Tcl_UtfToUniChar(src+len, &low);
+ if ((low & 0xFC00) == 0xDC00) {
+ *chPtr = (((uniChar & 0x3FF) << 10) | (low & 0x3FF)) + 0x10000;
+ return len + len2;
}
- } else {
- *chPtr = uniChar;
}
+ *chPtr = uniChar;
return len;
}
@@ -1243,8 +1242,9 @@ TkUtfToUniChar(
*
* TkUniCharToUtf --
*
- * Almost the same as Tcl_UniCharToUtf but producing surrogates if
- * TCL_UTF_MAX==3. So, up to 6 bytes might be produced.
+ * Almost the same as Tcl_UniCharToUtf but producing 2 x 3-byte UTF-8
+ * sequences for out-of-bmp characters when TCL_UTF_MAX==3.
+ * So, up to 6 bytes might be produced.
*
* Results:
* *buf is filled with the UTF-8 string, and the return value is the
@@ -1258,38 +1258,65 @@ TkUtfToUniChar(
size_t TkUniCharToUtf(int ch, char *buf)
{
- size_t size = Tcl_UniCharToUtf(ch, buf);
- if ((((unsigned)(ch - 0x10000) <= 0xFFFFF)) && (size < 4)) {
- /* Hey, this is wrong, we must be running TCL_UTF_MAX==3
- * The best thing we can do is spit out 2 surrogates */
- ch -= 0x10000;
- size = Tcl_UniCharToUtf(((ch >> 10) | 0xd800), buf);
- size += Tcl_UniCharToUtf(((ch & 0x3ff) | 0xdc00), buf+size);
+ if ((sizeof(Tcl_UniChar) == 2) && (((unsigned)(ch - 0x10000) <= 0xFFFFF))) {
+ /* Spit out a 4-byte UTF-8 character or 2 x 3-byte UTF-8 characters, depending on Tcl
+ * version and/or TCL_UTF_MAX build value */
+ int len = Tcl_UniCharToUtf(0xD800 | ((ch - 0x10000) >> 10), buf);
+ return len + Tcl_UniCharToUtf(0xDC00 | (ch & 0x7FF), buf + len);
}
- return size;
+ return Tcl_UniCharToUtf(ch, buf);
}
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TkUtfPrev --
+ *
+ * Almost the same as Tcl_UtfPrev.
+ * This function is capable of jumping over a upper/lower surrogate pair.
+ * So, might jump back up to 6 bytes.
+ *
+ * Results:
+ * pointer to the first byte of the current UTF-8 character. A surrogate
+ * pair is also handled as being a single entity.
+ *
+ * Side effects:
+ * None.
+ *
+ *---------------------------------------------------------------------------
+ */
+const char *
+TkUtfPrev(
+ const char *src, /* The UTF-8 string. */
+ const char *start) /* Start position of string */
+{
+ const char *p = Tcl_UtfPrev(src, start);
+ const char *first = Tcl_UtfPrev(p, start);
+ int ch;
+
+#if TCL_UTF_MAX == 3
+ if ((src - start > 3) && ((src[-1] & 0xC0) == 0x80) && ((src[-2] & 0xC0) == 0x80)
+ && ((src[-3] & 0xC0) == 0x80) && (UCHAR(src[-4]) >= 0xF0)) {
+ return src - 4;
+ }
+#endif
+
+ return (first + TkUtfToUniChar(first, &ch) >= src) ? first : p ;
+}
#endif
+#if TCL_MAJOR_VERSION > 8
unsigned char *
TkGetByteArrayFromObj(
Tcl_Obj *objPtr,
size_t *lengthPtr
) {
- int length;
-
- unsigned char *result = Tcl_GetByteArrayFromObj(objPtr, &length);
-#if TCL_MAJOR_VERSION > 8
- if (sizeof(TCL_HASH_TYPE) > sizeof(int)) {
- /* 64-bit and TIP #494 situation: */
- *lengthPtr = *(TCL_HASH_TYPE *) objPtr->internalRep.twoPtrValue.ptr1;
- } else
-#endif
- /* 32-bit or without TIP #494 */
- *lengthPtr = (size_t) (unsigned) length;
+ unsigned char *result = Tcl_GetByteArrayFromObj(objPtr, NULL);
+ *lengthPtr = *(size_t *) objPtr->internalRep.twoPtrValue.ptr1;
return result;
}
+#endif /* TCL_MAJOR_VERSION > 8 */
/*
* Local Variables:
diff --git a/generic/tkVisual.c b/generic/tkVisual.c
index 427e946..04afcbc 100644
--- a/generic/tkVisual.c
+++ b/generic/tkVisual.c
@@ -20,10 +20,10 @@
*/
typedef struct VisualDictionary {
- const char *name; /* Textual name of class. */
+ char name[12]; /* Textual name of class. */
unsigned short minLength; /* Minimum # characters that must be specified
* for an unambiguous match. */
- short class; /* X symbol for class. */
+ short c_class; /* X symbol for class. */
} VisualDictionary;
static const VisualDictionary visualNames[] = {
{"best", 1, 0},
@@ -35,7 +35,7 @@ static const VisualDictionary visualNames[] = {
{"staticgray", 7, StaticGray},
{"staticgrey", 7, StaticGray},
{"truecolor", 1, TrueColor},
- {NULL, 0, 0},
+ {"", 0, 0},
};
/*
@@ -96,7 +96,7 @@ Tk_GetVisual(
* Tk_FreeColormap. */
{
Tk_Window tkwin2;
- XVisualInfo template, *visInfoList, *bestPtr;
+ XVisualInfo templ, *visInfoList, *bestPtr;
long mask;
Visual *visual;
size_t length;
@@ -144,13 +144,13 @@ Tk_GetVisual(
}
return visual;
}
- template.depth = Tk_Depth(tkwin2);
- template.class = visual->class;
- template.red_mask = visual->red_mask;
- template.green_mask = visual->green_mask;
- template.blue_mask = visual->blue_mask;
- template.colormap_size = visual->map_entries;
- template.bits_per_rgb = visual->bits_per_rgb;
+ templ.depth = Tk_Depth(tkwin2);
+ templ.c_class = visual->c_class;
+ templ.red_mask = visual->red_mask;
+ templ.green_mask = visual->green_mask;
+ templ.blue_mask = visual->blue_mask;
+ templ.colormap_size = visual->map_entries;
+ templ.bits_per_rgb = visual->bits_per_rgb;
mask = VisualDepthMask|VisualClassMask|VisualRedMaskMask
|VisualGreenMaskMask|VisualBlueMaskMask|VisualColormapSizeMask
|VisualBitsPerRGBMask;
@@ -178,7 +178,7 @@ Tk_GetVisual(
Tcl_SetErrorCode(interp, "TK", "VALUE", "VISUALID", NULL);
return NULL;
}
- template.visualid = visualId;
+ templ.visualid = visualId;
mask = VisualIDMask;
} else {
/*
@@ -192,20 +192,20 @@ Tk_GetVisual(
}
}
length = p - string;
- template.class = -1;
- for (dictPtr = visualNames; dictPtr->name != NULL; dictPtr++) {
+ templ.c_class = -1;
+ for (dictPtr = visualNames; dictPtr->minLength; dictPtr++) {
if ((dictPtr->name[0] == c) && (length >= dictPtr->minLength)
&& (strncmp(string, dictPtr->name, length) == 0)) {
- template.class = dictPtr->class;
+ templ.c_class = dictPtr->c_class;
break;
}
}
- if (template.class == -1) {
+ if (templ.c_class == -1) {
Tcl_Obj *msgObj = Tcl_ObjPrintf(
"unknown or ambiguous visual name \"%s\": class must be ",
string);
- for (dictPtr = visualNames; dictPtr->name != NULL; dictPtr++) {
+ for (dictPtr = visualNames; dictPtr->minLength; dictPtr++) {
Tcl_AppendPrintfToObj(msgObj, "%s, ", dictPtr->name);
}
Tcl_AppendToObj(msgObj, "or default", -1);
@@ -217,8 +217,8 @@ Tk_GetVisual(
p++;
}
if (*p == 0) {
- template.depth = 10000;
- } else if (Tcl_GetInt(interp, p, &template.depth) != TCL_OK) {
+ templ.depth = 10000;
+ } else if (Tcl_GetInt(interp, p, &templ.depth) != TCL_OK) {
return NULL;
}
if (c == 'b') {
@@ -233,9 +233,9 @@ Tk_GetVisual(
* an error if there are none that match.
*/
- template.screen = Tk_ScreenNumber(tkwin);
+ templ.screen = Tk_ScreenNumber(tkwin);
mask |= VisualScreenMask;
- visInfoList = XGetVisualInfo(Tk_Display(tkwin), mask, &template,
+ visInfoList = XGetVisualInfo(Tk_Display(tkwin), mask, &templ,
&numVisuals);
if (visInfoList == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
@@ -261,7 +261,7 @@ Tk_GetVisual(
bestPrio = 0;
bestPtr = NULL;
for (i = 0; i < numVisuals; i++) {
- switch (visInfoList[i].class) {
+ switch (visInfoList[i].c_class) {
case DirectColor:
prio = 5; break;
case GrayScale:
@@ -285,11 +285,11 @@ Tk_GetVisual(
goto newBest;
}
if (visInfoList[i].depth < bestPtr->depth) {
- if (visInfoList[i].depth >= template.depth) {
+ if (visInfoList[i].depth >= templ.depth) {
goto newBest;
}
} else if (visInfoList[i].depth > bestPtr->depth) {
- if (bestPtr->depth < template.depth) {
+ if (bestPtr->depth < templ.depth) {
goto newBest;
}
} else {
@@ -327,7 +327,7 @@ Tk_GetVisual(
goto done;
}
}
- cmapPtr = ckalloc(sizeof(TkColormap));
+ cmapPtr = (TkColormap *)ckalloc(sizeof(TkColormap));
cmapPtr->colormap = XCreateColormap(Tk_Display(tkwin),
RootWindowOfScreen(Tk_Screen(tkwin)), visual,
AllocNone);
@@ -382,7 +382,7 @@ Tk_GetColormap(
*/
if (strcmp(string, "new") == 0) {
- cmapPtr = ckalloc(sizeof(TkColormap));
+ cmapPtr = (TkColormap *)ckalloc(sizeof(TkColormap));
cmapPtr->colormap = XCreateColormap(Tk_Display(tkwin),
RootWindowOfScreen(Tk_Screen(tkwin)), Tk_Visual(tkwin),
AllocNone);
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 3d91927..b3527e6 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -37,7 +37,7 @@ typedef struct TkHalfdeadWindow {
struct TkHalfdeadWindow *nextPtr;
} TkHalfdeadWindow;
-typedef struct ThreadSpecificData {
+typedef struct {
int numMainWindows; /* Count of numver of main windows currently
* open in this thread. */
TkMainInfo *mainWindowList;
@@ -124,7 +124,7 @@ static const TkCmd commands[] = {
{"place", Tk_PlaceObjCmd, PASSMAINWINDOW|ISSAFE},
{"raise", Tk_RaiseObjCmd, PASSMAINWINDOW|ISSAFE},
{"selection", Tk_SelectionObjCmd, PASSMAINWINDOW},
- {"tk", (Tcl_ObjCmdProc *) TkInitTkCmd, USEINITPROC|PASSMAINWINDOW|ISSAFE},
+ {"tk", (Tcl_ObjCmdProc *)(void *)TkInitTkCmd, USEINITPROC|PASSMAINWINDOW|ISSAFE},
{"tkwait", Tk_TkwaitObjCmd, PASSMAINWINDOW|ISSAFE},
{"update", Tk_UpdateObjCmd, PASSMAINWINDOW|ISSAFE},
{"winfo", Tk_WinfoObjCmd, PASSMAINWINDOW|ISSAFE},
@@ -316,10 +316,10 @@ CreateTopLevelWindow(
* parent. */
unsigned int flags) /* Additional flags to set on the window. */
{
- register TkWindow *winPtr;
- register TkDisplay *dispPtr;
+ TkWindow *winPtr;
+ TkDisplay *dispPtr;
int screenId;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
@@ -340,6 +340,7 @@ CreateTopLevelWindow(
Tk_CreatePhotoImageFormat(&tkImgFmtGIF);
Tk_CreatePhotoImageFormat(&tkImgFmtPNG);
Tk_CreatePhotoImageFormat(&tkImgFmtPPM);
+ Tk_CreatePhotoImageFormat(&tkImgFmtSVGnano);
}
if ((parent != NULL) && (screenName != NULL) && (screenName[0] == '\0')) {
@@ -358,9 +359,7 @@ CreateTopLevelWindow(
* Set the flags specified in the call.
*/
-#ifdef TK_USE_INPUT_METHODS
winPtr->ximGeneration = 0;
-#endif /*TK_USE_INPUT_METHODS*/
winPtr->flags |= flags;
/*
@@ -420,11 +419,11 @@ GetScreen(
* DISPLAY envariable. */
int *screenPtr) /* Where to store screen number. */
{
- register TkDisplay *dispPtr;
+ TkDisplay *dispPtr;
const char *p;
int screenId;
size_t length;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -488,7 +487,7 @@ GetScreen(
Tcl_InitHashTable(&dispPtr->winTable, TCL_ONE_WORD_KEYS);
- dispPtr->name = ckalloc(length + 1);
+ dispPtr->name = (char *)ckalloc(length + 1);
strncpy(dispPtr->name, screenName, length);
dispPtr->name[length] = '\0';
break;
@@ -531,7 +530,7 @@ TkGetDisplay(
Display *display) /* X's display pointer */
{
TkDisplay *dispPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (dispPtr = tsdPtr->displayList; dispPtr != NULL;
@@ -564,7 +563,7 @@ TkGetDisplay(
TkDisplay *
TkGetDisplayList(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
return tsdPtr->displayList;
@@ -591,7 +590,7 @@ TkGetDisplayList(void)
TkMainInfo *
TkGetMainInfoList(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
return tsdPtr->mainWindowList;
@@ -621,7 +620,7 @@ TkAllocWindow(
* inherit visual information. NULL means use
* screen defaults instead of inheriting. */
{
- register TkWindow *winPtr = ckalloc(sizeof(TkWindow));
+ TkWindow *winPtr = (TkWindow *)ckalloc(sizeof(TkWindow));
winPtr->display = dispPtr->display;
winPtr->dispPtr = dispPtr;
@@ -655,16 +654,16 @@ TkAllocWindow(
winPtr->dirtyAtts = CWEventMask|CWColormap|CWBitGravity;
winPtr->flags = 0;
winPtr->handlerList = NULL;
-#ifdef TK_USE_INPUT_METHODS
winPtr->ximGeneration = 0;
winPtr->inputContext = NULL;
-#endif /* TK_USE_INPUT_METHODS */
winPtr->tagPtr = NULL;
winPtr->numTags = 0;
winPtr->optionLevel = -1;
winPtr->selHandlerList = NULL;
winPtr->geomMgrPtr = NULL;
winPtr->geomData = NULL;
+ winPtr->geomMgrName = NULL;
+ winPtr->maintainerPtr = NULL;
winPtr->reqWidth = winPtr->reqHeight = 1;
winPtr->internalBorderLeft = 0;
winPtr->wmInfoPtr = NULL;
@@ -676,7 +675,6 @@ TkAllocWindow(
winPtr->internalBorderBottom = 0;
winPtr->minReqWidth = 0;
winPtr->minReqHeight = 0;
- winPtr->geometryMaster = NULL;
return winPtr;
}
@@ -701,7 +699,7 @@ TkAllocWindow(
static int
NameWindow(
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
- register TkWindow *winPtr, /* Window that is to be named and inserted. */
+ TkWindow *winPtr, /* Window that is to be named and inserted. */
TkWindow *parentPtr, /* Pointer to logical parent for winPtr (used
* for naming, options, etc.). */
const char *name) /* Name for winPtr; must be unique among
@@ -771,7 +769,7 @@ NameWindow(
if ((length1 + length2 + 2) <= FIXED_SIZE) {
pathName = staticSpace;
} else {
- pathName = ckalloc(length1 + length2 + 2);
+ pathName = (char *)ckalloc(length1 + length2 + 2);
}
if (length1 == 1) {
pathName[0] = '.';
@@ -793,7 +791,7 @@ NameWindow(
return TCL_ERROR;
}
Tcl_SetHashValue(hPtr, winPtr);
- winPtr->pathName = Tcl_GetHashKey(&parentPtr->mainPtr->nameTable, hPtr);
+ winPtr->pathName = (char *)Tcl_GetHashKey(&parentPtr->mainPtr->nameTable, hPtr);
return TCL_OK;
}
@@ -832,11 +830,11 @@ TkCreateMainWindow(
Tk_Window tkwin;
int dummy, isSafe;
Tcl_HashEntry *hPtr;
- register TkMainInfo *mainPtr;
- register TkWindow *winPtr;
- register const TkCmd *cmdPtr;
+ TkMainInfo *mainPtr;
+ TkWindow *winPtr;
+ const TkCmd *cmdPtr;
ClientData clientData;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -852,7 +850,7 @@ TkCreateMainWindow(
* Create the basic TkWindow structure.
*/
- tkwin = CreateTopLevelWindow(interp, (Tk_Window) NULL, baseName,
+ tkwin = CreateTopLevelWindow(interp, NULL, baseName,
screenName, /* flags */ 0);
if (tkwin == NULL) {
return NULL;
@@ -864,7 +862,7 @@ TkCreateMainWindow(
*/
winPtr = (TkWindow *) tkwin;
- mainPtr = ckalloc(sizeof(TkMainInfo));
+ mainPtr = (TkMainInfo *)ckalloc(sizeof(TkMainInfo));
mainPtr->winPtr = winPtr;
mainPtr->refCount = 1;
mainPtr->interp = interp;
@@ -897,7 +895,7 @@ TkCreateMainWindow(
winPtr->mainPtr = mainPtr;
hPtr = Tcl_CreateHashEntry(&mainPtr->nameTable, ".", &dummy);
Tcl_SetHashValue(hPtr, winPtr);
- winPtr->pathName = Tcl_GetHashKey(&mainPtr->nameTable, hPtr);
+ winPtr->pathName = (char *)Tcl_GetHashKey(&mainPtr->nameTable, hPtr);
Tcl_InitHashTable(&mainPtr->busyTable, TCL_ONE_WORD_KEYS);
/*
@@ -939,7 +937,7 @@ TkCreateMainWindow(
clientData = NULL;
}
if (cmdPtr->flags & USEINITPROC) {
- ((TkInitProc *) cmdPtr->objProc)(interp, clientData);
+ ((TkInitProc *)(void *)cmdPtr->objProc)(interp, clientData);
} else {
Tcl_CreateObjCommand(interp, cmdPtr->name, cmdPtr->objProc,
clientData, NULL);
@@ -1146,7 +1144,7 @@ Tk_CreateWindowFromPath(
* the situation where the parent is ".".
*/
- p = strrchr(pathName, '.');
+ p = (char *)strrchr(pathName, '.');
if (p == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad window path name \"%s\"", pathName));
@@ -1155,7 +1153,7 @@ Tk_CreateWindowFromPath(
}
numChars = p-pathName;
if (numChars > FIXED_SPACE) {
- p = ckalloc(numChars + 1);
+ p = (char *)ckalloc(numChars + 1);
} else {
p = fixedSpace;
}
@@ -1240,7 +1238,7 @@ Tk_DestroyWindow(
TkDisplay *dispPtr = winPtr->dispPtr;
XEvent event;
TkHalfdeadWindow *halfdeadPtr, *prev_halfdeadPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->flags & TK_ALREADY_DEAD) {
@@ -1263,7 +1261,7 @@ Tk_DestroyWindow(
(tsdPtr->halfdeadWindowList->winPtr == winPtr)) {
halfdeadPtr = tsdPtr->halfdeadWindowList;
} else {
- halfdeadPtr = ckalloc(sizeof(TkHalfdeadWindow));
+ halfdeadPtr = (TkHalfdeadWindow *)ckalloc(sizeof(TkHalfdeadWindow));
halfdeadPtr->flags = 0;
halfdeadPtr->winPtr = winPtr;
halfdeadPtr->nextPtr = tsdPtr->halfdeadWindowList;
@@ -1448,22 +1446,20 @@ Tk_DestroyWindow(
}
UnlinkWindow(winPtr);
TkEventDeadWindow(winPtr);
-#ifdef TK_USE_INPUT_METHODS
if (winPtr->inputContext != NULL &&
- winPtr->ximGeneration == winPtr->dispPtr->ximGeneration) {
+ winPtr->ximGeneration == winPtr->dispPtr->ximGeneration) {
XDestroyIC(winPtr->inputContext);
}
winPtr->inputContext = NULL;
-#endif /* TK_USE_INPUT_METHODS */
if (winPtr->tagPtr != NULL) {
TkFreeBindingTags(winPtr);
}
TkOptionDeadWindow(winPtr);
TkSelDeadWindow(winPtr);
TkGrabDeadWindow(winPtr);
- if (winPtr->geometryMaster != NULL) {
- ckfree(winPtr->geometryMaster);
- winPtr->geometryMaster = NULL;
+ if (winPtr->geomMgrName != NULL) {
+ ckfree(winPtr->geomMgrName);
+ winPtr->geomMgrName = NULL;
}
if (winPtr->mainPtr != NULL) {
if (winPtr->pathName != NULL) {
@@ -1488,7 +1484,7 @@ Tk_DestroyWindow(
winPtr->mainPtr->deletionEpoch++;
}
if (winPtr->mainPtr->refCount-- <= 1) {
- register const TkCmd *cmdPtr;
+ const TkCmd *cmdPtr;
/*
* We just deleted the last window in the application. Delete the
@@ -1675,7 +1671,7 @@ void
Tk_MakeWindowExist(
Tk_Window tkwin) /* Token for window. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
TkWindow *winPtr2;
Window parent;
Tcl_HashEntry *hPtr;
@@ -1784,7 +1780,7 @@ void
Tk_UnmapWindow(
Tk_Window tkwin) /* Token for window to unmap. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
if (!(winPtr->flags & TK_MAPPED) || (winPtr->flags & TK_ALREADY_DEAD)) {
return;
@@ -1821,7 +1817,7 @@ Tk_ConfigureWindow(
* are to be used. */
XWindowChanges *valuePtr) /* New values. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
if (valueMask & CWX) {
winPtr->changes.x = valuePtr->x;
@@ -1857,7 +1853,7 @@ Tk_MoveWindow(
Tk_Window tkwin, /* Window to move. */
int x, int y) /* New location for window (within parent). */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->changes.x = x;
winPtr->changes.y = y;
@@ -1875,7 +1871,7 @@ Tk_ResizeWindow(
Tk_Window tkwin, /* Window to resize. */
int width, int height) /* New dimensions for window. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->changes.width = (unsigned) width;
winPtr->changes.height = (unsigned) height;
@@ -1895,7 +1891,7 @@ Tk_MoveResizeWindow(
int x, int y, /* New location for window (within parent). */
int width, int height) /* New dimensions for window. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->changes.x = x;
winPtr->changes.y = y;
@@ -1916,7 +1912,7 @@ Tk_SetWindowBorderWidth(
Tk_Window tkwin, /* Window to modify. */
int width) /* New border width for window. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->changes.border_width = width;
if (winPtr->window != None) {
@@ -1934,10 +1930,10 @@ Tk_ChangeWindowAttributes(
Tk_Window tkwin, /* Window to manipulate. */
unsigned long valueMask, /* OR'ed combination of bits, indicating which
* fields of *attsPtr are to be used. */
- register XSetWindowAttributes *attsPtr)
+ XSetWindowAttributes *attsPtr)
/* New values for some attributes. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
if (valueMask & CWBackPixmap) {
winPtr->atts.background_pixmap = attsPtr->background_pixmap;
@@ -2000,7 +1996,7 @@ Tk_SetWindowBackground(
unsigned long pixel) /* Pixel value to use for window's
* background. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->atts.background_pixel = pixel;
@@ -2017,7 +2013,7 @@ Tk_SetWindowBackgroundPixmap(
Tk_Window tkwin, /* Window to manipulate. */
Pixmap pixmap) /* Pixmap to use for window's background. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->atts.background_pixmap = pixmap;
@@ -2035,7 +2031,7 @@ Tk_SetWindowBorder(
Tk_Window tkwin, /* Window to manipulate. */
unsigned long pixel) /* Pixel value to use for window's border. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->atts.border_pixel = pixel;
@@ -2052,7 +2048,7 @@ Tk_SetWindowBorderPixmap(
Tk_Window tkwin, /* Window to manipulate. */
Pixmap pixmap) /* Pixmap to use for window's border. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->atts.border_pixmap = pixmap;
@@ -2070,13 +2066,9 @@ Tk_DefineCursor(
Tk_Window tkwin, /* Window to manipulate. */
Tk_Cursor cursor) /* Cursor to use for window (may be None). */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
-#if defined(MAC_OSX_TK)
- winPtr->atts.cursor = (XCursor) cursor;
-#else
winPtr->atts.cursor = (Cursor) cursor;
-#endif
if (winPtr->window != None) {
XDefineCursor(winPtr->display, winPtr->window, winPtr->atts.cursor);
@@ -2097,7 +2089,7 @@ Tk_SetWindowColormap(
Tk_Window tkwin, /* Window to manipulate. */
Colormap colormap) /* Colormap to use for window. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->atts.colormap = colormap;
@@ -2139,7 +2131,7 @@ Tk_SetWindowVisual(
int depth, /* New depth for window. */
Colormap colormap) /* An appropriate colormap for the visual. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
if (winPtr->window != None) {
/* Too late! */
@@ -2182,7 +2174,7 @@ Tk_SetWindowVisual(
void
TkDoConfigureNotify(
- register TkWindow *winPtr) /* Window whose configuration was just
+ TkWindow *winPtr) /* Window whose configuration was just
* changed. */
{
XEvent event;
@@ -2228,7 +2220,7 @@ Tk_SetClass(
Tk_Window tkwin, /* Token for window to assign class. */
const char *className) /* New class for tkwin. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->classUid = Tk_GetUid(className);
if (winPtr->flags & TK_WIN_MANAGED) {
@@ -2261,7 +2253,7 @@ Tk_SetClassProcs(
const Tk_ClassProcs *procs, /* Class procs structure. */
ClientData instanceData) /* Data to be passed to class functions. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->classProcsPtr = procs;
winPtr->instanceData = instanceData;
@@ -2320,7 +2312,7 @@ Tk_NameToWindow(
}
return NULL;
}
- return Tcl_GetHashValue(hPtr);
+ return (Tk_Window)Tcl_GetHashValue(hPtr);
}
/*
@@ -2366,7 +2358,7 @@ Tk_IdToWindow(
if (hPtr == NULL) {
return NULL;
}
- return Tcl_GetHashValue(hPtr);
+ return (Tk_Window)Tcl_GetHashValue(hPtr);
}
/*
@@ -2624,7 +2616,7 @@ Tk_MainWindow(
return NULL;
}
#endif
- tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ tsdPtr = (ThreadSpecificData *)Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (mainPtr = tsdPtr->mainWindowList; mainPtr != NULL;
mainPtr = mainPtr->nextPtr) {
@@ -2694,7 +2686,7 @@ Tk_GetNumMainWindows(void)
}
#endif
- tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ tsdPtr = (ThreadSpecificData *)Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
return tsdPtr->numMainWindows;
}
@@ -2752,7 +2744,7 @@ DeleteWindowsExitProc(
{
TkDisplay *dispPtr, *nextPtr;
Tcl_Interp *interp;
- ThreadSpecificData *tsdPtr = clientData;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)clientData;
if (tsdPtr == NULL) {
return;
@@ -2849,24 +2841,24 @@ TkCygwinMainEx(
* but before starting to execute commands. */
Tcl_Interp *interp)
{
- TCHAR name[MAX_PATH];
+ WCHAR name[MAX_PATH];
size_t len;
void (*tkmainex)(int, char **, Tcl_AppInitProc *, Tcl_Interp *);
/* construct "<path>/libtk8.?.dll", from "<path>/tk8?.dll" */
len = GetModuleFileNameW(Tk_GetHINSTANCE(), name, MAX_PATH);
- name[len-2] = TEXT('.');
+ name[len-2] = '.';
name[len-1] = name[len-5];
- _tcscpy(name+len, TEXT(".dll"));
- memcpy(name+len-8, TEXT("libtk8"), 6 * sizeof(TCHAR));
+ wcscpy(name+len, L".dll");
+ memcpy(name+len-8, L"libtk8", 6 * sizeof(WCHAR));
- tkcygwindll = LoadLibrary(name);
+ tkcygwindll = LoadLibraryW(name);
if (!tkcygwindll) {
/* dll is not present */
return 0;
}
tkmainex = (void (*)(int, char **, Tcl_AppInitProc *, Tcl_Interp *))
- GetProcAddress(tkcygwindll, "Tk_MainEx");
+ (void *)GetProcAddress(tkcygwindll, "Tk_MainEx");
if (!tkmainex) {
return 0;
}
@@ -2906,7 +2898,7 @@ Tk_Init(
if (tkcygwindll) {
int (*tkinit)(Tcl_Interp *);
- tkinit = (int(*)(Tcl_Interp *)) GetProcAddress(tkcygwindll,"Tk_Init");
+ tkinit = (int(*)(Tcl_Interp *))(void *)GetProcAddress(tkcygwindll,"Tk_Init");
if (tkinit) {
return tkinit(interp);
}
@@ -2980,7 +2972,7 @@ Tk_SafeInit(
int (*tksafeinit)(Tcl_Interp *);
tksafeinit = (int (*)(Tcl_Interp *))
- GetProcAddress(tkcygwindll, "Tk_SafeInit");
+ (void *)GetProcAddress(tkcygwindll, "Tk_SafeInit");
if (tksafeinit) {
return tksafeinit(interp);
}
@@ -3015,6 +3007,8 @@ CopyValue(
Tcl_Obj *objPtr,
void *dstPtr)
{
+ (void)dummy;
+
*(Tcl_Obj **)dstPtr = objPtr;
return 1;
}
@@ -3041,17 +3035,17 @@ Initialize(
const Tcl_ArgvInfo table[] = {
{TCL_ARGV_CONSTANT, "-sync", INT2PTR(1), &sync,
"Use synchronous mode for display server", NULL},
- {TCL_ARGV_FUNC, "-colormap", CopyValue, &colorMapObj,
+ {TCL_ARGV_FUNC, "-colormap", (void *)CopyValue, &colorMapObj,
"Colormap for main window", NULL},
- {TCL_ARGV_FUNC, "-display", CopyValue, &displayObj,
+ {TCL_ARGV_FUNC, "-display", (void *)CopyValue, &displayObj,
"Display to use", NULL},
- {TCL_ARGV_FUNC, "-geometry", CopyValue, &geometryObj,
+ {TCL_ARGV_FUNC, "-geometry", (void *)CopyValue, &geometryObj,
"Initial geometry for window", NULL},
- {TCL_ARGV_FUNC, "-name", CopyValue, &nameObj,
+ {TCL_ARGV_FUNC, "-name", (void *)CopyValue, &nameObj,
"Name to use for application", NULL},
- {TCL_ARGV_FUNC, "-visual", CopyValue, &visualObj,
+ {TCL_ARGV_FUNC, "-visual", (void *)CopyValue, &visualObj,
"Visual for main window", NULL},
- {TCL_ARGV_FUNC, "-use", CopyValue, &useObj,
+ {TCL_ARGV_FUNC, "-use", (void *)CopyValue, &useObj,
"Id of window in which to embed application", NULL},
TCL_ARGV_AUTO_REST, TCL_ARGV_AUTO_HELP, TCL_ARGV_TABLE_END
};
@@ -3065,12 +3059,18 @@ Initialize(
}
/*
+ * TIP #59: Make embedded configuration information available.
+ */
+
+ TkInitEmbeddedConfigurationInformation(interp);
+
+ /*
* Ensure that our obj-types are registered with the Tcl runtime.
*/
TkRegisterObjTypes();
- tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ tsdPtr = (ThreadSpecificData *)Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
* We start by resetting the result because it might not be clean.
@@ -3170,7 +3170,7 @@ Initialize(
Tcl_SetVar2Ex(interp, "argv", NULL,
Tcl_NewListObj(objc-1, rest+1), TCL_GLOBAL_ONLY);
Tcl_SetVar2Ex(interp, "argc", NULL,
- Tcl_NewIntObj(objc-1), TCL_GLOBAL_ONLY);
+ Tcl_NewWideIntObj(objc-1), TCL_GLOBAL_ONLY);
ckfree(rest);
}
Tcl_DecrRefCount(parseList);
@@ -3202,7 +3202,7 @@ Initialize(
*/
{
- size_t numBytes;
+ TkSizeT numBytes;
const char *bytes = TkGetStringFromObj(nameObj, &numBytes);
classObj = Tcl_NewStringObj(bytes, numBytes);
@@ -3261,7 +3261,7 @@ Initialize(
}
Tcl_ResetResult(interp);
if (sync) {
- XSynchronize(Tk_Display(Tk_MainWindow(interp)), True);
+ (void)XSynchronize(Tk_Display(Tk_MainWindow(interp)), True);
}
/*
diff --git a/generic/ttk/ttk.decls b/generic/ttk/ttk.decls
index e668a2a..1c98b23 100644
--- a/generic/ttk/ttk.decls
+++ b/generic/ttk/ttk.decls
@@ -25,7 +25,7 @@ declare 5 {
int Ttk_RegisterElementSpec(
Ttk_Theme theme,
const char *elementName,
- Ttk_ElementSpec *elementSpec,
+ const Ttk_ElementSpec *elementSpec,
void *clientData)
}
@@ -34,7 +34,7 @@ declare 6 {
Tcl_Interp *interp,
Ttk_Theme theme,
const char *elementName,
- Ttk_ElementSpec *elementSpec,
+ const Ttk_ElementSpec *elementSpec,
void *clientData)
}
@@ -72,7 +72,7 @@ declare 13 {
}
declare 14 {
int Ttk_StateTableLookup(
- Ttk_StateTable map[], Ttk_State state)
+ const Ttk_StateTable *map, Ttk_State state)
}
@@ -143,7 +143,7 @@ declare 35 {
#
# Utilities.
#
-declare 40 {
+declare 40 {deprecated {}} {
int Ttk_GetOrientFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *orient)
}
diff --git a/generic/ttk/ttkBlink.c b/generic/ttk/ttkBlink.c
index 484e66b..dcd342c 100644
--- a/generic/ttk/ttkBlink.c
+++ b/generic/ttk/ttkBlink.c
@@ -34,9 +34,11 @@ typedef struct
/* CursorManagerDeleteProc --
* InterpDeleteProc for cursor manager.
*/
-static void CursorManagerDeleteProc(ClientData clientData, Tcl_Interp *interp)
+static void CursorManagerDeleteProc(ClientData clientData, Tcl_Interp *dummy)
{
CursorManager *cm = (CursorManager*)clientData;
+ (void)dummy;
+
if (cm->timer) {
Tcl_DeleteTimerHandler(cm->timer);
}
@@ -49,10 +51,10 @@ static void CursorManagerDeleteProc(ClientData clientData, Tcl_Interp *interp)
static CursorManager *GetCursorManager(Tcl_Interp *interp)
{
static const char *cm_key = "ttk::CursorManager";
- CursorManager *cm = Tcl_GetAssocData(interp, cm_key,0);
+ CursorManager *cm = (CursorManager *)Tcl_GetAssocData(interp, cm_key,0);
if (!cm) {
- cm = ckalloc(sizeof(*cm));
+ cm = (CursorManager *)ckalloc(sizeof(*cm));
cm->timer = 0;
cm->owner = 0;
cm->onTime = DEF_CURSOR_ON_TIME;
@@ -68,7 +70,7 @@ static CursorManager *GetCursorManager(Tcl_Interp *interp)
static void
CursorBlinkProc(ClientData clientData)
{
- CursorManager *cm = clientData;
+ CursorManager *cm = (CursorManager *)clientData;
int blinkTime;
if (cm->owner->flags & CURSOR_ON) {
diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c
index 722e034..9712c66 100644
--- a/generic/ttk/ttkButton.c
+++ b/generic/ttk/ttkButton.c
@@ -54,47 +54,48 @@ typedef struct
BasePart base;
} Base;
-static Tk_OptionSpec BaseOptionSpecs[] =
+static const Tk_OptionSpec BaseOptionSpecs[] =
{
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- "left", Tk_Offset(Base,base.justifyObj), -1,
+ "left", offsetof(Base,base.justifyObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-text", "text", "Text", "",
- Tk_Offset(Base,base.textObj), -1,
+ offsetof(Base,base.textObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", "",
- Tk_Offset(Base,base.textVariableObj), -1,
+ offsetof(Base,base.textVariableObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_INT, "-underline", "underline", "Underline",
- "-1", Tk_Offset(Base,base.underlineObj), -1,
+ "-1", offsetof(Base,base.underlineObj), TCL_INDEX_NONE,
0,0,0 },
/* SB: OPTION_INT, see <<NOTE-NULLOPTIONS>> */
{TK_OPTION_STRING, "-width", "width", "Width",
- NULL, Tk_Offset(Base,base.widthObj), -1,
+ NULL, offsetof(Base,base.widthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
/*
* Image options
*/
{TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/,
- Tk_Offset(Base,base.imageObj), -1,
+ offsetof(Base,base.imageObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
/*
* Compound base/image options
*/
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- "none", Tk_Offset(Base,base.compoundObj), -1,
- 0,(ClientData)ttkCompoundStrings,GEOMETRY_CHANGED },
+ NULL, offsetof(Base,base.compoundObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,(void *)ttkCompoundStrings,
+ GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-padding", "padding", "Pad",
- NULL, Tk_Offset(Base,base.paddingObj), -1,
+ NULL, offsetof(Base,base.paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED},
/*
* Compatibility/legacy options
*/
{TK_OPTION_STRING, "-state", "state", "State",
- "normal", Tk_Offset(Base,base.stateObj), -1,
+ "normal", offsetof(Base,base.stateObj), TCL_INDEX_NONE,
0,0,STATE_CHANGED },
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
@@ -105,7 +106,7 @@ static Tk_OptionSpec BaseOptionSpecs[] =
*/
static void TextVariableChanged(void *clientData, const char *value)
{
- Base *basePtr = clientData;
+ Base *basePtr = (Base *)clientData;
Tcl_Obj *newText;
if (WidgetDestroyed(&basePtr->core)) {
@@ -122,9 +123,11 @@ static void TextVariableChanged(void *clientData, const char *value)
}
static void
-BaseInitialize(Tcl_Interp *interp, void *recordPtr)
+BaseInitialize(Tcl_Interp *dummy, void *recordPtr)
{
- Base *basePtr = recordPtr;
+ Base *basePtr = (Base *)recordPtr;
+ (void)dummy;
+
basePtr->base.textVariableTrace = 0;
basePtr->base.imageSpec = NULL;
}
@@ -132,7 +135,7 @@ BaseInitialize(Tcl_Interp *interp, void *recordPtr)
static void
BaseCleanup(void *recordPtr)
{
- Base *basePtr = recordPtr;
+ Base *basePtr = (Base *)recordPtr;
if (basePtr->base.textVariableTrace)
Ttk_UntraceVariable(basePtr->base.textVariableTrace);
if (basePtr->base.imageSpec)
@@ -145,12 +148,19 @@ BaseImageChanged(
int imageWidth, int imageHeight)
{
Base *basePtr = (Base *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imageWidth;
+ (void)imageHeight;
+
TtkResizeWidget(&basePtr->core);
}
static int BaseConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Base *basePtr = recordPtr;
+ Base *basePtr = (Base *)recordPtr;
Tcl_Obj *textVarName = basePtr->base.textVariableObj;
Ttk_TraceHandle *vt = 0;
Ttk_ImageSpec *imageSpec = NULL;
@@ -193,10 +203,12 @@ error:
}
static int
-BasePostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
+BasePostConfigure(Tcl_Interp *dummy, void *recordPtr, int mask)
{
- Base *basePtr = recordPtr;
+ Base *basePtr = (Base *)recordPtr;
int status = TCL_OK;
+ (void)dummy;
+ (void)mask;
if (basePtr->base.textVariableTrace) {
status = Ttk_FireTrace(basePtr->base.textVariableTrace);
@@ -229,31 +241,31 @@ typedef struct
LabelPart label;
} Label;
-static Tk_OptionSpec LabelOptionSpecs[] =
+static const Tk_OptionSpec LabelOptionSpecs[] =
{
{TK_OPTION_BORDER, "-background", "frameColor", "FrameColor",
- NULL, Tk_Offset(Label,label.backgroundObj), -1,
+ NULL, offsetof(Label,label.backgroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
- NULL, Tk_Offset(Label,label.foregroundObj), -1,
+ NULL, offsetof(Label,label.foregroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_FONT, "-font", "font", "Font",
- NULL, Tk_Offset(Label,label.fontObj), -1,
+ NULL, offsetof(Label,label.fontObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- NULL, Tk_Offset(Label,label.borderWidthObj), -1,
+ NULL, offsetof(Label,label.borderWidthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- NULL, Tk_Offset(Label,label.reliefObj), -1,
+ NULL, offsetof(Label,label.reliefObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- NULL, Tk_Offset(Label,label.anchorObj), -1,
+ NULL, offsetof(Label,label.anchorObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- NULL, Tk_Offset(Label, label.justifyObj), -1,
+ NULL, offsetof(Label, label.justifyObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- NULL, Tk_Offset(Label, label.wrapLengthObj), -1,
+ NULL, offsetof(Label, label.wrapLengthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED /*SB: SIZE_CHANGED*/ },
WIDGET_TAKEFOCUS_FALSE,
@@ -269,7 +281,7 @@ static const Ttk_Ensemble LabelCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec LabelWidgetSpec =
+static const WidgetSpec LabelWidgetSpec =
{
"TLabel", /* className */
sizeof(Label), /* recordSize */
@@ -312,13 +324,13 @@ typedef struct
/*
* Option specifications:
*/
-static Tk_OptionSpec ButtonOptionSpecs[] =
+static const Tk_OptionSpec ButtonOptionSpecs[] =
{
{TK_OPTION_STRING, "-command", "command", "Command",
- "", Tk_Offset(Button, button.commandObj), -1, 0,0,0},
+ "", offsetof(Button, button.commandObj), TCL_INDEX_NONE, 0,0,0},
{TK_OPTION_STRING_TABLE, "-default", "default", "Default",
- "normal", Tk_Offset(Button, button.defaultStateObj), -1,
- 0, (ClientData) ttkDefaultStrings, DEFAULTSTATE_CHANGED},
+ "normal", offsetof(Button, button.defaultStateObj), TCL_INDEX_NONE,
+ 0, (void *)ttkDefaultStrings, DEFAULTSTATE_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(BaseOptionSpecs)
@@ -326,7 +338,7 @@ static Tk_OptionSpec ButtonOptionSpecs[] =
static int ButtonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Button *buttonPtr = recordPtr;
+ Button *buttonPtr = (Button *)recordPtr;
if (BaseConfigure(interp, recordPtr, mask) != TCL_OK) {
return TCL_ERROR;
@@ -335,7 +347,7 @@ static int ButtonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
/* Handle "-default" option:
*/
if (mask & DEFAULTSTATE_CHANGED) {
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
Ttk_GetButtonDefaultStateFromObj(
NULL, buttonPtr->button.defaultStateObj, &defaultState);
if (defaultState == TTK_BUTTON_DEFAULT_ACTIVE) {
@@ -354,7 +366,7 @@ static int
ButtonInvokeCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Button *buttonPtr = recordPtr;
+ Button *buttonPtr = (Button *)recordPtr;
if (objc > 2) {
Tcl_WrongNumArgs(interp, 1, objv, "invoke");
return TCL_ERROR;
@@ -375,7 +387,7 @@ static const Ttk_Ensemble ButtonCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec ButtonWidgetSpec =
+static const WidgetSpec ButtonWidgetSpec =
{
"TButton", /* className */
sizeof(Button), /* recordSize */
@@ -422,19 +434,19 @@ typedef struct
/*
* Option specifications:
*/
-static Tk_OptionSpec CheckbuttonOptionSpecs[] =
+static const Tk_OptionSpec CheckbuttonOptionSpecs[] =
{
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- NULL, Tk_Offset(Checkbutton, checkbutton.variableObj), -1,
+ NULL, offsetof(Checkbutton, checkbutton.variableObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-onvalue", "onValue", "OnValue",
- "1", Tk_Offset(Checkbutton, checkbutton.onValueObj), -1,
+ "1", offsetof(Checkbutton, checkbutton.onValueObj), TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING, "-offvalue", "offValue", "OffValue",
- "0", Tk_Offset(Checkbutton, checkbutton.offValueObj), -1,
+ "0", offsetof(Checkbutton, checkbutton.offValueObj), TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING, "-command", "command", "Command",
- "", Tk_Offset(Checkbutton, checkbutton.commandObj), -1,
+ "", offsetof(Checkbutton, checkbutton.commandObj), TCL_INDEX_NONE,
0,0,0},
WIDGET_TAKEFOCUS_TRUE,
@@ -446,7 +458,7 @@ static Tk_OptionSpec CheckbuttonOptionSpecs[] =
*/
static void CheckbuttonVariableChanged(void *clientData, const char *value)
{
- Checkbutton *checkPtr = clientData;
+ Checkbutton *checkPtr = (Checkbutton *)clientData;
if (WidgetDestroyed(&checkPtr->core)) {
return;
@@ -468,7 +480,7 @@ static void CheckbuttonVariableChanged(void *clientData, const char *value)
static void
CheckbuttonInitialize(Tcl_Interp *interp, void *recordPtr)
{
- Checkbutton *checkPtr = recordPtr;
+ Checkbutton *checkPtr = (Checkbutton *)recordPtr;
Tcl_Obj *variableObj;
/* default -variable is the widget name:
@@ -482,7 +494,7 @@ CheckbuttonInitialize(Tcl_Interp *interp, void *recordPtr)
static void
CheckbuttonCleanup(void *recordPtr)
{
- Checkbutton *checkPtr = recordPtr;
+ Checkbutton *checkPtr = (Checkbutton *)recordPtr;
Ttk_UntraceVariable(checkPtr->checkbutton.variableTrace);
checkPtr->checkbutton.variableTrace = 0;
BaseCleanup(recordPtr);
@@ -491,7 +503,7 @@ CheckbuttonCleanup(void *recordPtr)
static int
CheckbuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Checkbutton *checkPtr = recordPtr;
+ Checkbutton *checkPtr = (Checkbutton *)recordPtr;
Tcl_Obj *varName = checkPtr->checkbutton.variableObj;
Ttk_TraceHandle *vt = NULL;
@@ -519,7 +531,7 @@ CheckbuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
static int
CheckbuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Checkbutton *checkPtr = recordPtr;
+ Checkbutton *checkPtr = (Checkbutton *)recordPtr;
int status = TCL_OK;
if (checkPtr->checkbutton.variableTrace)
@@ -537,7 +549,7 @@ static int
CheckbuttonInvokeCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Checkbutton *checkPtr = recordPtr;
+ Checkbutton *checkPtr = (Checkbutton *)recordPtr;
WidgetCore *corePtr = &checkPtr->core;
Tcl_Obj *newValue;
@@ -583,7 +595,7 @@ static const Ttk_Ensemble CheckbuttonCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec CheckbuttonWidgetSpec =
+static const WidgetSpec CheckbuttonWidgetSpec =
{
"TCheckbutton", /* className */
sizeof(Checkbutton), /* recordSize */
@@ -630,16 +642,16 @@ typedef struct
/*
* Option specifications:
*/
-static Tk_OptionSpec RadiobuttonOptionSpecs[] =
+static const Tk_OptionSpec RadiobuttonOptionSpecs[] =
{
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- "::selectedButton", Tk_Offset(Radiobutton, radiobutton.variableObj),-1,
+ "::selectedButton", offsetof(Radiobutton, radiobutton.variableObj),TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING, "-value", "Value", "Value",
- "1", Tk_Offset(Radiobutton, radiobutton.valueObj), -1,
+ "1", offsetof(Radiobutton, radiobutton.valueObj), TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING, "-command", "command", "Command",
- "", Tk_Offset(Radiobutton, radiobutton.commandObj), -1,
+ "", offsetof(Radiobutton, radiobutton.commandObj), TCL_INDEX_NONE,
0,0,0},
WIDGET_TAKEFOCUS_TRUE,
@@ -652,7 +664,7 @@ static Tk_OptionSpec RadiobuttonOptionSpecs[] =
static void
RadiobuttonVariableChanged(void *clientData, const char *value)
{
- Radiobutton *radioPtr = clientData;
+ Radiobutton *radioPtr = (Radiobutton *)clientData;
if (WidgetDestroyed(&radioPtr->core)) {
return;
@@ -674,7 +686,7 @@ RadiobuttonVariableChanged(void *clientData, const char *value)
static void
RadiobuttonCleanup(void *recordPtr)
{
- Radiobutton *radioPtr = recordPtr;
+ Radiobutton *radioPtr = (Radiobutton *)recordPtr;
Ttk_UntraceVariable(radioPtr->radiobutton.variableTrace);
radioPtr->radiobutton.variableTrace = 0;
BaseCleanup(recordPtr);
@@ -683,7 +695,7 @@ RadiobuttonCleanup(void *recordPtr)
static int
RadiobuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Radiobutton *radioPtr = recordPtr;
+ Radiobutton *radioPtr = (Radiobutton *)recordPtr;
Ttk_TraceHandle *vt = Ttk_TraceVariable(
interp, radioPtr->radiobutton.variableObj,
RadiobuttonVariableChanged, radioPtr);
@@ -706,7 +718,7 @@ RadiobuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
static int
RadiobuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Radiobutton *radioPtr = recordPtr;
+ Radiobutton *radioPtr = (Radiobutton *)recordPtr;
int status = TCL_OK;
if (radioPtr->radiobutton.variableTrace)
@@ -724,7 +736,7 @@ static int
RadiobuttonInvokeCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Radiobutton *radioPtr = recordPtr;
+ Radiobutton *radioPtr = (Radiobutton *)recordPtr;
WidgetCore *corePtr = &radioPtr->core;
if (objc > 2) {
@@ -759,7 +771,7 @@ static const Ttk_Ensemble RadiobuttonCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec RadiobuttonWidgetSpec =
+static const WidgetSpec RadiobuttonWidgetSpec =
{
"TRadiobutton", /* className */
sizeof(Radiobutton), /* recordSize */
@@ -805,12 +817,12 @@ typedef struct
static const char *const directionStrings[] = {
"above", "below", "left", "right", "flush", NULL
};
-static Tk_OptionSpec MenubuttonOptionSpecs[] =
+static const Tk_OptionSpec MenubuttonOptionSpecs[] =
{
{TK_OPTION_STRING, "-menu", "menu", "Menu",
- "", Tk_Offset(Menubutton, menubutton.menuObj), -1, 0,0,0},
+ "", offsetof(Menubutton, menubutton.menuObj), TCL_INDEX_NONE, 0,0,0},
{TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction",
- "below", Tk_Offset(Menubutton, menubutton.directionObj), -1,
+ "below", offsetof(Menubutton, menubutton.directionObj), TCL_INDEX_NONE,
0,(ClientData)directionStrings,GEOMETRY_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
@@ -826,7 +838,7 @@ static const Ttk_Ensemble MenubuttonCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec MenubuttonWidgetSpec =
+static const WidgetSpec MenubuttonWidgetSpec =
{
"TMenubutton", /* className */
sizeof(Menubutton), /* recordSize */
diff --git a/generic/ttk/ttkCache.c b/generic/ttk/ttkCache.c
index c29007c..9059c55 100644
--- a/generic/ttk/ttkCache.c
+++ b/generic/ttk/ttkCache.c
@@ -48,7 +48,7 @@ struct Ttk_ResourceCache_ {
*/
Ttk_ResourceCache Ttk_CreateResourceCache(Tcl_Interp *interp)
{
- Ttk_ResourceCache cache = ckalloc(sizeof(*cache));
+ Ttk_ResourceCache cache = (Ttk_ResourceCache)ckalloc(sizeof(*cache));
cache->tkwin = NULL; /* initialized later */
cache->interp = interp;
@@ -75,7 +75,7 @@ static void Ttk_ClearCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->fontTable, &search);
while (entryPtr != NULL) {
- Tcl_Obj *fontObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *fontObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
if (fontObj) {
Tk_FreeFontFromObj(cache->tkwin, fontObj);
Tcl_DecrRefCount(fontObj);
@@ -90,7 +90,7 @@ static void Ttk_ClearCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->colorTable, &search);
while (entryPtr != NULL) {
- Tcl_Obj *colorObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *colorObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
if (colorObj) {
Tk_FreeColorFromObj(cache->tkwin, colorObj);
Tcl_DecrRefCount(colorObj);
@@ -105,7 +105,7 @@ static void Ttk_ClearCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->borderTable, &search);
while (entryPtr != NULL) {
- Tcl_Obj *borderObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *borderObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
if (borderObj) {
Tk_Free3DBorderFromObj(cache->tkwin, borderObj);
Tcl_DecrRefCount(borderObj);
@@ -120,7 +120,7 @@ static void Ttk_ClearCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->imageTable, &search);
while (entryPtr != NULL) {
- Tk_Image image = Tcl_GetHashValue(entryPtr);
+ Tk_Image image = (Tk_Image)Tcl_GetHashValue(entryPtr);
if (image) {
Tk_FreeImage(image);
}
@@ -153,7 +153,7 @@ void Ttk_FreeResourceCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->namedColors, &search);
while (entryPtr != NULL) {
- Tcl_Obj *colorNameObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *colorNameObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
Tcl_DecrRefCount(colorNameObj);
entryPtr = Tcl_NextHashEntry(&search);
}
@@ -168,7 +168,7 @@ void Ttk_FreeResourceCache(Ttk_ResourceCache cache)
*/
static void CacheWinEventHandler(ClientData clientData, XEvent *eventPtr)
{
- Ttk_ResourceCache cache = clientData;
+ Ttk_ResourceCache cache = (Ttk_ResourceCache)clientData;
if (eventPtr->type != DestroyNotify) {
return;
@@ -216,7 +216,7 @@ void Ttk_RegisterNamedColor(
entryPtr = Tcl_CreateHashEntry(&cache->namedColors, colorName, &newEntry);
if (!newEntry) {
- Tcl_Obj *oldColor = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *oldColor = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
Tcl_DecrRefCount(oldColor);
}
@@ -234,7 +234,7 @@ static Tcl_Obj *CheckNamedColor(Ttk_ResourceCache cache, Tcl_Obj *objPtr)
Tcl_HashEntry *entryPtr =
Tcl_FindHashEntry(&cache->namedColors, Tcl_GetString(objPtr));
if (entryPtr) { /* Use named color instead */
- objPtr = Tcl_GetHashValue(entryPtr);
+ objPtr = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
}
return objPtr;
}
@@ -257,7 +257,7 @@ static Tcl_Obj *Ttk_Use(
Tcl_Obj *cacheObj;
if (!newEntry) {
- return Tcl_GetHashValue(entryPtr);
+ return (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
}
cacheObj = Tcl_DuplicateObj(objPtr);
@@ -314,9 +314,17 @@ Tcl_Obj *Ttk_UseBorder(
* Tk_ImageChangedProc for Ttk_UseImage
*/
-static void NullImageChanged(ClientData clientData,
+static void NullImageChanged(ClientData dummy,
int x, int y, int width, int height, int imageWidth, int imageHeight)
-{ /* No-op */ }
+{ /* No-op */
+ (void)dummy;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imageWidth;
+ (void)imageHeight;
+}
/*
* Ttk_UseImage --
@@ -333,7 +341,7 @@ Tk_Image Ttk_UseImage(Ttk_ResourceCache cache, Tk_Window tkwin, Tcl_Obj *objPtr)
InitCacheWindow(cache, tkwin);
if (!newEntry) {
- return Tcl_GetHashValue(entryPtr);
+ return (Tk_Image)Tcl_GetHashValue(entryPtr);
}
image = Tk_GetImage(cache->interp, tkwin, imageName, NullImageChanged,0);
diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c
index e9bc74a..dae54e4 100644
--- a/generic/ttk/ttkClamTheme.c
+++ b/generic/ttk/ttkClamTheme.c
@@ -106,18 +106,18 @@ typedef struct {
Tcl_Obj *borderWidthObj; /* See <<NOTE-BORDERWIDTH>> */
} BorderElement;
-static Ttk_ElementOptionSpec BorderElementOptions[] = {
+static const Ttk_ElementOptionSpec BorderElementOptions[] = {
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(BorderElement,borderColorObj), DARKEST_COLOR },
+ offsetof(BorderElement,borderColorObj), DARKEST_COLOR },
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(BorderElement,lightColorObj), LIGHT_COLOR },
+ offsetof(BorderElement,lightColorObj), LIGHT_COLOR },
{ "-darkcolor", TK_OPTION_COLOR,
- Tk_Offset(BorderElement,darkColorObj), DARK_COLOR },
+ offsetof(BorderElement,darkColorObj), DARK_COLOR },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(BorderElement,reliefObj), "flat" },
+ offsetof(BorderElement,reliefObj), "flat" },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(BorderElement,borderWidthObj), "2" },
- { NULL, 0, 0, NULL }
+ offsetof(BorderElement,borderWidthObj), "2" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
/*
@@ -129,24 +129,30 @@ static Ttk_ElementOptionSpec BorderElementOptions[] = {
*/
static void BorderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
BorderElement *border = (BorderElement*)elementRecord;
int borderWidth = 2;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
+
Tk_GetPixelsFromObj(NULL, tkwin, border->borderWidthObj, &borderWidth);
if (borderWidth == 1) ++borderWidth;
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
static void BorderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned state)
{
- BorderElement *border = elementRecord;
+ BorderElement *border = (BorderElement *)elementRecord;
int relief = TK_RELIEF_FLAT;
int borderWidth = 2;
Tcl_Obj *outer = 0, *upper = 0, *lower = 0;
+ (void)dummy;
+ (void)state;
Tk_GetReliefFromObj(NULL, border->reliefObj, &relief);
Tk_GetPixelsFromObj(NULL, tkwin, border->borderWidthObj, &borderWidth);
@@ -177,7 +183,7 @@ static void BorderElementDraw(
DrawSmoothBorder(tkwin, d, b, outer, upper, lower);
}
-static Ttk_ElementSpec BorderElementSpec = {
+static const Ttk_ElementSpec BorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BorderElement),
BorderElementOptions,
@@ -196,41 +202,49 @@ typedef struct {
Tcl_Obj *backgroundObj;
} FieldElement;
-static Ttk_ElementOptionSpec FieldElementOptions[] = {
+static const Ttk_ElementOptionSpec FieldElementOptions[] = {
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(FieldElement,borderColorObj), DARKEST_COLOR },
+ offsetof(FieldElement,borderColorObj), DARKEST_COLOR },
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(FieldElement,lightColorObj), LIGHT_COLOR },
+ offsetof(FieldElement,lightColorObj), LIGHT_COLOR },
{ "-darkcolor", TK_OPTION_COLOR,
- Tk_Offset(FieldElement,darkColorObj), DARK_COLOR },
+ offsetof(FieldElement,darkColorObj), DARK_COLOR },
{ "-fieldbackground", TK_OPTION_BORDER,
- Tk_Offset(FieldElement,backgroundObj), "white" },
- { NULL, 0, 0, NULL }
+ offsetof(FieldElement,backgroundObj), "white" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void FieldElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+
*paddingPtr = Ttk_UniformPadding(2);
}
static void FieldElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned state)
{
- FieldElement *field = elementRecord;
+ FieldElement *field = (FieldElement *)elementRecord;
Tk_3DBorder bg = Tk_Get3DBorderFromObj(tkwin, field->backgroundObj);
Ttk_Box f = Ttk_PadBox(b, Ttk_UniformPadding(2));
Tcl_Obj *outer = field->borderColorObj,
*inner = field->lightColorObj;
+ (void)dummy;
+ (void)state;
DrawSmoothBorder(tkwin, d, b, outer, inner, inner);
Tk_Fill3DRectangle(
tkwin, d, bg, f.x, f.y, f.width, f.height, 0, TK_RELIEF_SUNKEN);
}
-static Ttk_ElementSpec FieldElementSpec = {
+static const Ttk_ElementSpec FieldElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FieldElement),
FieldElementOptions,
@@ -246,7 +260,7 @@ static void ComboboxFieldElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned state)
{
- FieldElement *field = elementRecord;
+ FieldElement *field = (FieldElement *)elementRecord;
GC gc = Ttk_GCForColor(tkwin,field->borderColorObj,d);
++b.width;
@@ -257,7 +271,7 @@ static void ComboboxFieldElementDraw(
b.x + b.width - 1, b.y + b.height - 1 + WIN32_XDRAWLINE_HACK);
}
-static Ttk_ElementSpec ComboboxFieldElementSpec = {
+static const Ttk_ElementSpec ComboboxFieldElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FieldElement),
FieldElementOptions,
@@ -278,29 +292,32 @@ typedef struct {
Tcl_Obj *lowerColorObj;
} IndicatorElement;
-static Ttk_ElementOptionSpec IndicatorElementOptions[] = {
+static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
{ "-indicatorsize", TK_OPTION_PIXELS,
- Tk_Offset(IndicatorElement,sizeObj), "10" },
+ offsetof(IndicatorElement,sizeObj), "10" },
{ "-indicatormargin", TK_OPTION_STRING,
- Tk_Offset(IndicatorElement,marginObj), "1" },
+ offsetof(IndicatorElement,marginObj), "1" },
{ "-indicatorbackground", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,backgroundObj), "white" },
+ offsetof(IndicatorElement,backgroundObj), "white" },
{ "-indicatorforeground", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,foregroundObj), "black" },
+ offsetof(IndicatorElement,foregroundObj), "black" },
{ "-upperbordercolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,upperColorObj), DARKEST_COLOR },
+ offsetof(IndicatorElement,upperColorObj), DARKEST_COLOR },
{ "-lowerbordercolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,lowerColorObj), DARK_COLOR },
- { NULL, 0, 0, NULL }
+ offsetof(IndicatorElement,lowerColorObj), DARK_COLOR },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void IndicatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- IndicatorElement *indicator = elementRecord;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
int size = 10;
+ (void)dummy;
+ (void)paddingPtr;
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
*widthPtr = size + Ttk_PaddingWidth(margins);
@@ -308,15 +325,16 @@ static void IndicatorElementSize(
}
static void RadioIndicatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned state)
{
- IndicatorElement *indicator = elementRecord;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
GC gcb=Ttk_GCForColor(tkwin,indicator->backgroundObj,d);
GC gcf=Ttk_GCForColor(tkwin,indicator->foregroundObj,d);
GC gcu=Ttk_GCForColor(tkwin,indicator->upperColorObj,d);
GC gcl=Ttk_GCForColor(tkwin,indicator->lowerColorObj,d);
Ttk_Padding padding;
+ (void)dummy;
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
b = Ttk_PadBox(b, padding);
@@ -336,17 +354,19 @@ static void RadioIndicatorElementDraw(
}
static void CheckIndicatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned state)
{
Display *display = Tk_Display(tkwin);
- IndicatorElement *indicator = elementRecord;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
+
GC gcb=Ttk_GCForColor(tkwin,indicator->backgroundObj,d);
GC gcf=Ttk_GCForColor(tkwin,indicator->foregroundObj,d);
GC gcu=Ttk_GCForColor(tkwin,indicator->upperColorObj,d);
GC gcl=Ttk_GCForColor(tkwin,indicator->lowerColorObj,d);
Ttk_Padding padding;
const int w = WIN32_XDRAWLINE_HACK;
+ (void)dummy;
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
b = Ttk_PadBox(b, padding);
@@ -375,7 +395,7 @@ static void CheckIndicatorElementDraw(
}
}
-static Ttk_ElementSpec RadioIndicatorElementSpec = {
+static const Ttk_ElementSpec RadioIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(IndicatorElement),
IndicatorElementOptions,
@@ -383,7 +403,7 @@ static Ttk_ElementSpec RadioIndicatorElementSpec = {
RadioIndicatorElementDraw
};
-static Ttk_ElementSpec CheckIndicatorElementSpec = {
+static const Ttk_ElementSpec CheckIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(IndicatorElement),
IndicatorElementOptions,
@@ -399,27 +419,30 @@ typedef struct {
Tcl_Obj *paddingObj;
} MenuIndicatorElement;
-static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] =
+static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] =
{
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(MenuIndicatorElement,sizeObj),
+ offsetof(MenuIndicatorElement,sizeObj),
STR(MENUBUTTON_ARROW_SIZE)},
{ "-arrowcolor",TK_OPTION_COLOR,
- Tk_Offset(MenuIndicatorElement,colorObj),
+ offsetof(MenuIndicatorElement,colorObj),
"black" },
{ "-arrowpadding",TK_OPTION_STRING,
- Tk_Offset(MenuIndicatorElement,paddingObj),
+ offsetof(MenuIndicatorElement,paddingObj),
"3" },
- { NULL, 0, 0, NULL }
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void MenuIndicatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- MenuIndicatorElement *indicator = elementRecord;
+ MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
Ttk_Padding margins;
int size = MENUBUTTON_ARROW_SIZE;
+ (void)dummy;
+ (void)paddingPtr;
+
Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->paddingObj, &margins);
TtkArrowSize(size, ARROW_DOWN, widthPtr, heightPtr);
@@ -428,14 +451,16 @@ static void MenuIndicatorElementSize(
}
static void MenuIndicatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- MenuIndicatorElement *indicator = elementRecord;
+ MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
XColor *arrowColor = Tk_GetColorFromObj(tkwin, indicator->colorObj);
GC gc = Tk_GCForColor(arrowColor, d);
int size = MENUBUTTON_ARROW_SIZE;
int width, height;
+ (void)dummy;
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
@@ -444,7 +469,7 @@ static void MenuIndicatorElementDraw(
TtkFillArrow(Tk_Display(tkwin), d, gc, b, ARROW_DOWN);
}
-static Ttk_ElementSpec MenuIndicatorElementSpec =
+static const Ttk_ElementSpec MenuIndicatorElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(MenuIndicatorElement),
@@ -459,36 +484,34 @@ static Ttk_ElementSpec MenuIndicatorElementSpec =
* TODO: factor this with ThumbElementDraw
*/
-static Ttk_Orient GripClientData[] = {
- TTK_ORIENT_HORIZONTAL, TTK_ORIENT_VERTICAL
-};
-
typedef struct {
Tcl_Obj *lightColorObj;
Tcl_Obj *borderColorObj;
Tcl_Obj *gripCountObj;
} GripElement;
-static Ttk_ElementOptionSpec GripElementOptions[] = {
+static const Ttk_ElementOptionSpec GripElementOptions[] = {
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(GripElement,lightColorObj), LIGHT_COLOR },
+ offsetof(GripElement,lightColorObj), LIGHT_COLOR },
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(GripElement,borderColorObj), DARKEST_COLOR },
+ offsetof(GripElement,borderColorObj), DARKEST_COLOR },
{ "-gripcount", TK_OPTION_INT,
- Tk_Offset(GripElement,gripCountObj), "5" },
- { NULL, 0, 0, NULL }
+ offsetof(GripElement,gripCountObj), "5" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void GripElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
- GripElement *grip = elementRecord;
+ Ttk_Orient orient = (Ttk_Orient)PTR2INT(clientData);
+ GripElement *grip = (GripElement *)elementRecord;
int gripCount = 0;
+ (void)tkwin;
+ (void)paddingPtr;
Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount);
- if (horizontal) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
*widthPtr = 2*gripCount;
} else {
*heightPtr = 2*gripCount;
@@ -500,16 +523,17 @@ static void GripElementDraw(
Drawable d, Ttk_Box b, unsigned state)
{
const int w = WIN32_XDRAWLINE_HACK;
- int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
- GripElement *grip = elementRecord;
+ Ttk_Orient orient = (Ttk_Orient)PTR2INT(clientData);
+ GripElement *grip = (GripElement *)elementRecord;
GC lightGC = Ttk_GCForColor(tkwin,grip->lightColorObj,d);
GC darkGC = Ttk_GCForColor(tkwin,grip->borderColorObj,d);
int gripPad = 1, gripCount = 0;
int i;
+ (void)state;
Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount);
- if (horizontal) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
int x = b.x + b.width / 2 - gripCount;
int y1 = b.y + gripPad, y2 = b.y + b.height - gripPad - 1 + w;
for (i=0; i<gripCount; ++i) {
@@ -526,7 +550,7 @@ static void GripElementDraw(
}
}
-static Ttk_ElementSpec GripElementSpec = {
+static const Ttk_ElementSpec GripElementSpec = {
TK_STYLE_VERSION_2,
sizeof(GripElement),
GripElementOptions,
@@ -554,42 +578,45 @@ typedef struct { /* Common element record for scrollbar elements */
Tcl_Obj *sliderlengthObj;
} ScrollbarElement;
-static Ttk_ElementOptionSpec ScrollbarElementOptions[] = {
+static const Ttk_ElementOptionSpec ScrollbarElementOptions[] = {
{ "-orient", TK_OPTION_ANY,
- Tk_Offset(ScrollbarElement, orientObj), "horizontal" },
+ offsetof(ScrollbarElement, orientObj), "horizontal" },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ScrollbarElement,backgroundObj), FRAME_COLOR },
+ offsetof(ScrollbarElement,backgroundObj), FRAME_COLOR },
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(ScrollbarElement,borderColorObj), DARKEST_COLOR },
+ offsetof(ScrollbarElement,borderColorObj), DARKEST_COLOR },
{ "-troughcolor", TK_OPTION_COLOR,
- Tk_Offset(ScrollbarElement,troughColorObj), DARKER_COLOR },
+ offsetof(ScrollbarElement,troughColorObj), DARKER_COLOR },
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(ScrollbarElement,lightColorObj), LIGHT_COLOR },
+ offsetof(ScrollbarElement,lightColorObj), LIGHT_COLOR },
{ "-darkcolor", TK_OPTION_COLOR,
- Tk_Offset(ScrollbarElement,darkColorObj), DARK_COLOR },
+ offsetof(ScrollbarElement,darkColorObj), DARK_COLOR },
{ "-arrowcolor", TK_OPTION_COLOR,
- Tk_Offset(ScrollbarElement,arrowColorObj), "#000000" },
+ offsetof(ScrollbarElement,arrowColorObj), "#000000" },
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(ScrollbarElement,arrowSizeObj), STR(SCROLLBAR_THICKNESS) },
+ offsetof(ScrollbarElement,arrowSizeObj), STR(SCROLLBAR_THICKNESS) },
{ "-gripcount", TK_OPTION_INT,
- Tk_Offset(ScrollbarElement,gripCountObj), "5" },
+ offsetof(ScrollbarElement,gripCountObj), "5" },
{ "-sliderlength", TK_OPTION_INT,
- Tk_Offset(ScrollbarElement,sliderlengthObj), "30" },
- { NULL, 0, 0, NULL }
+ offsetof(ScrollbarElement,sliderlengthObj), "30" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void TroughElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned state)
{
- ScrollbarElement *sb = elementRecord;
+ ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
GC gcb = Ttk_GCForColor(tkwin,sb->borderColorObj,d);
GC gct = Ttk_GCForColor(tkwin,sb->troughColorObj,d);
+ (void)dummy;
+ (void)state;
+
XFillRectangle(Tk_Display(tkwin), d, gct, b.x, b.y, b.width-1, b.height-1);
XDrawRectangle(Tk_Display(tkwin), d, gcb, b.x, b.y, b.width-1, b.height-1);
}
-static Ttk_ElementSpec TroughElementSpec = {
+static const Ttk_ElementSpec TroughElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -598,24 +625,31 @@ static Ttk_ElementSpec TroughElementSpec = {
};
static void ThumbElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ScrollbarElement *sb = elementRecord;
+ ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
int size = SCROLLBAR_THICKNESS;
+ (void)dummy;
+ (void)tkwin;
+ (void)paddingPtr;
+
Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size);
*widthPtr = *heightPtr = size;
}
static void ThumbElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned state)
{
- ScrollbarElement *sb = elementRecord;
- int gripCount = 0, orient = TTK_ORIENT_HORIZONTAL;
+ ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
+ int gripCount = 0;
+ Ttk_Orient orient = TTK_ORIENT_HORIZONTAL;
GC lightGC, darkGC;
int x1, y1, x2, y2, dx, dy, i;
const int w = WIN32_XDRAWLINE_HACK;
+ (void)dummy;
+ (void)state;
DrawSmoothBorder(tkwin, d, b,
sb->borderColorObj, sb->lightColorObj, sb->darkColorObj);
@@ -626,7 +660,7 @@ static void ThumbElementDraw(
/*
* Draw grip:
*/
- Ttk_GetOrientFromObj(NULL, sb->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, sb->orientObj, &orient);
Tcl_GetIntFromObj(NULL, sb->gripCountObj, &gripCount);
lightGC = Ttk_GCForColor(tkwin,sb->lightColorObj,d);
darkGC = Ttk_GCForColor(tkwin,sb->borderColorObj,d);
@@ -651,7 +685,7 @@ static void ThumbElementDraw(
}
}
-static Ttk_ElementSpec ThumbElementSpec = {
+static const Ttk_ElementSpec ThumbElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -663,14 +697,17 @@ static Ttk_ElementSpec ThumbElementSpec = {
* +++ Slider element.
*/
static void SliderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ScrollbarElement *sb = elementRecord;
- int length, thickness, orient;
+ ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
+ int length, thickness;
+ Ttk_Orient orient;
+ (void)dummy;
+ (void)paddingPtr;
length = thickness = SCROLLBAR_THICKNESS;
- Ttk_GetOrientFromObj(NULL, sb->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, sb->orientObj, &orient);
Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &thickness);
Tk_GetPixelsFromObj(NULL, tkwin, sb->sliderlengthObj, &length);
if (orient == TTK_ORIENT_VERTICAL) {
@@ -683,7 +720,7 @@ static void SliderElementSize(
}
-static Ttk_ElementSpec SliderElementSpec = {
+static const Ttk_ElementSpec SliderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -706,10 +743,12 @@ static void PbarElementSize(
}
static void PbarElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned state)
{
- ScrollbarElement *sb = elementRecord;
+ ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
+ (void)dummy;
+ (void)state;
b = Ttk_PadBox(b, Ttk_UniformPadding(2));
if (b.width > 4 && b.height > 4) {
@@ -721,7 +760,7 @@ static void PbarElementDraw(
}
}
-static Ttk_ElementSpec PbarElementSpec = {
+static const Ttk_ElementSpec PbarElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -733,14 +772,16 @@ static Ttk_ElementSpec PbarElementSpec = {
/*------------------------------------------------------------------------
* +++ Scrollbar arrows.
*/
-static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
-
static void ArrowElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ScrollbarElement *sb = elementRecord;
+ ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
int size = SCROLLBAR_THICKNESS;
+ (void)dummy;
+ (void)tkwin;
+ (void)paddingPtr;
+
Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size);
*widthPtr = *heightPtr = size;
}
@@ -749,10 +790,11 @@ static void ArrowElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned state)
{
- ArrowDirection dir = *(ArrowDirection*)clientData;
- ScrollbarElement *sb = elementRecord;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
GC gc = Ttk_GCForColor(tkwin,sb->arrowColorObj, d);
int h, cx, cy;
+ (void)state;
DrawSmoothBorder(tkwin, d, b,
sb->borderColorObj, sb->lightColorObj, sb->darkColorObj);
@@ -763,13 +805,13 @@ static void ArrowElementDraw(
b = Ttk_PadBox(b, Ttk_UniformPadding(3));
h = b.width < b.height ? b.width : b.height;
- TtkArrowSize(h/2, dir, &cx, &cy);
+ TtkArrowSize(h/2, direction, &cx, &cy);
b = Ttk_AnchorBox(b, cx, cy, TK_ANCHOR_CENTER);
- TtkFillArrow(Tk_Display(tkwin), d, gc, b, dir);
+ TtkFillArrow(Tk_Display(tkwin), d, gc, b, direction);
}
-static Ttk_ElementSpec ArrowElementSpec = {
+static const Ttk_ElementSpec ArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -792,38 +834,45 @@ typedef struct {
Tcl_Obj *darkColorObj;
} NotebookElement;
-static Ttk_ElementOptionSpec NotebookElementOptions[] = {
+static const Ttk_ElementOptionSpec NotebookElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(NotebookElement,backgroundObj), FRAME_COLOR },
+ offsetof(NotebookElement,backgroundObj), FRAME_COLOR },
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(NotebookElement,borderColorObj), DARKEST_COLOR },
+ offsetof(NotebookElement,borderColorObj), DARKEST_COLOR },
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(NotebookElement,lightColorObj), LIGHT_COLOR },
+ offsetof(NotebookElement,lightColorObj), LIGHT_COLOR },
{ "-darkcolor", TK_OPTION_COLOR,
- Tk_Offset(NotebookElement,darkColorObj), DARK_COLOR },
- { NULL, 0, 0, NULL }
+ offsetof(NotebookElement,darkColorObj), DARK_COLOR },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void TabElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
int borderWidth = 2;
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+
paddingPtr->top = paddingPtr->left = paddingPtr->right = borderWidth;
paddingPtr->bottom = 0;
}
static void TabElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- NotebookElement *tab = elementRecord;
+ NotebookElement *tab = (NotebookElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj);
Display *display = Tk_Display(tkwin);
int borderWidth = 2, dh = 0;
int x1,y1,x2,y2;
GC gc;
const int w = WIN32_XDRAWLINE_HACK;
+ (void)dummy;
if (state & TTK_STATE_SELECTED) {
dh = borderWidth;
@@ -850,7 +899,7 @@ static void TabElementDraw(
XDrawLine(display,d,gc, x1+1,y1+1, x2-1+w,y1+1);
}
-static Ttk_ElementSpec TabElementSpec =
+static const Ttk_ElementSpec TabElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NotebookElement),
@@ -860,20 +909,28 @@ static Ttk_ElementSpec TabElementSpec =
};
static void ClientElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
int borderWidth = 2;
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
static void ClientElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- NotebookElement *ce = elementRecord;
+ NotebookElement *ce = (NotebookElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, ce->backgroundObj);
int borderWidth = 2;
+ (void)dummy;
+ (void)state;
Tk_Fill3DRectangle(tkwin, d, border,
b.x, b.y, b.width, b.height, borderWidth,TK_RELIEF_FLAT);
@@ -881,7 +938,7 @@ static void ClientElementDraw(
ce->borderColorObj, ce->lightColorObj, ce->darkColorObj);
}
-static Ttk_ElementSpec ClientElementSpec =
+static const Ttk_ElementSpec ClientElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NotebookElement),
@@ -936,13 +993,13 @@ TtkClamTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp,
theme, "thumb", &ThumbElementSpec, NULL);
Ttk_RegisterElement(interp,
- theme, "uparrow", &ArrowElementSpec, &ArrowElements[0]);
+ theme, "uparrow", &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp,
- theme, "downarrow", &ArrowElementSpec, &ArrowElements[1]);
+ theme, "downarrow", &ArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp,
- theme, "leftarrow", &ArrowElementSpec, &ArrowElements[2]);
+ theme, "leftarrow", &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp,
- theme, "rightarrow", &ArrowElementSpec, &ArrowElements[3]);
+ theme, "rightarrow", &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
Ttk_RegisterElement(interp,
theme, "Radiobutton.indicator", &RadioIndicatorElementSpec, NULL);
@@ -959,9 +1016,9 @@ TtkClamTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "pbar", &PbarElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "hgrip",
- &GripElementSpec, &GripClientData[0]);
+ &GripElementSpec, INT2PTR(TTK_ORIENT_HORIZONTAL));
Ttk_RegisterElement(interp, theme, "vgrip",
- &GripElementSpec, &GripClientData[1]);
+ &GripElementSpec, INT2PTR(TTK_ORIENT_VERTICAL));
Ttk_RegisterLayouts(theme, LayoutTable);
diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c
index 48e856e..ec35480 100644
--- a/generic/ttk/ttkClassicTheme.c
+++ b/generic/ttk/ttkClassicTheme.c
@@ -21,32 +21,39 @@ typedef struct {
Tcl_Obj *highlightThicknessObj;
} HighlightElement;
-static Ttk_ElementOptionSpec HighlightElementOptions[] = {
+static const Ttk_ElementOptionSpec HighlightElementOptions[] = {
{ "-highlightcolor",TK_OPTION_COLOR,
- Tk_Offset(HighlightElement,highlightColorObj), DEFAULT_BACKGROUND },
+ offsetof(HighlightElement,highlightColorObj), DEFAULT_BACKGROUND },
{ "-highlightthickness",TK_OPTION_PIXELS,
- Tk_Offset(HighlightElement,highlightThicknessObj), "0" },
- { NULL, 0, 0, NULL }
+ offsetof(HighlightElement,highlightThicknessObj), "0" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void HighlightElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- HighlightElement *hl = elementRecord;
+ HighlightElement *hl = (HighlightElement *)elementRecord;
int highlightThickness = 0;
+ (void)dummy;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
Tcl_GetIntFromObj(NULL,hl->highlightThicknessObj,&highlightThickness);
*paddingPtr = Ttk_UniformPadding((short)highlightThickness);
}
static void HighlightElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- HighlightElement *hl = elementRecord;
+ HighlightElement *hl = (HighlightElement *)elementRecord;
int highlightThickness = 0;
XColor *highlightColor = Tk_GetColorFromObj(tkwin, hl->highlightColorObj);
+ (void)dummy;
+ (void)b;
+ (void)state;
Tcl_GetIntFromObj(NULL,hl->highlightThicknessObj,&highlightThickness);
if (highlightColor && highlightThickness > 0) {
@@ -55,7 +62,7 @@ static void HighlightElementDraw(
}
}
-static Ttk_ElementSpec HighlightElementSpec =
+static const Ttk_ElementSpec HighlightElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(HighlightElement),
@@ -81,26 +88,30 @@ typedef struct {
Tcl_Obj *defaultStateObj;
} ButtonBorderElement;
-static Ttk_ElementOptionSpec ButtonBorderElementOptions[] =
+static const Ttk_ElementOptionSpec ButtonBorderElementOptions[] =
{
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ButtonBorderElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(ButtonBorderElement,borderObj), DEFAULT_BACKGROUND },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(ButtonBorderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ offsetof(ButtonBorderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(ButtonBorderElement,reliefObj), "flat" },
+ offsetof(ButtonBorderElement,reliefObj), "flat" },
{ "-default", TK_OPTION_ANY,
- Tk_Offset(ButtonBorderElement,defaultStateObj), "disabled" },
- { NULL, 0, 0, NULL }
+ offsetof(ButtonBorderElement,defaultStateObj), "disabled" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void ButtonBorderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ButtonBorderElement *bd = elementRecord;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
int borderWidth = 0;
+ (void)dummy;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth);
Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState);
@@ -117,14 +128,16 @@ static void ButtonBorderElementSize(
* when the button is active.)
*/
static void ButtonBorderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ButtonBorderElement *bd = elementRecord;
+ ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord;
Tk_3DBorder border = NULL;
int borderWidth = 1, relief = TK_RELIEF_FLAT;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
int inset = 0;
+ (void)dummy;
+ (void)state;
/*
* Get option values.
@@ -170,7 +183,7 @@ static void ButtonBorderElementDraw(
}
}
-static Ttk_ElementSpec ButtonBorderElementSpec =
+static const Ttk_ElementSpec ButtonBorderElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(ButtonBorderElement),
@@ -186,7 +199,6 @@ static Ttk_ElementSpec ButtonBorderElementSpec =
* clientData is an enum ArrowDirection pointer.
*/
-static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
typedef struct
{
Tcl_Obj *sizeObj;
@@ -195,24 +207,26 @@ typedef struct
Tcl_Obj *reliefObj;
} ArrowElement;
-static Ttk_ElementOptionSpec ArrowElementOptions[] =
+static const Ttk_ElementOptionSpec ArrowElementOptions[] =
{
- { "-arrowsize", TK_OPTION_PIXELS, Tk_Offset(ArrowElement,sizeObj),
+ { "-arrowsize", TK_OPTION_PIXELS, offsetof(ArrowElement,sizeObj),
DEFAULT_ARROW_SIZE },
- { "-background", TK_OPTION_BORDER, Tk_Offset(ArrowElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(ArrowElement,borderObj),
DEFAULT_BACKGROUND },
- { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(ArrowElement,borderWidthObj),
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(ArrowElement,borderWidthObj),
DEFAULT_BORDERWIDTH },
- { "-relief", TK_OPTION_RELIEF, Tk_Offset(ArrowElement,reliefObj),"raised" },
- { NULL, 0, 0, NULL }
+ { "-relief", TK_OPTION_RELIEF, offsetof(ArrowElement,reliefObj),"raised" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void ArrowElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ArrowElement *arrow = elementRecord;
+ ArrowElement *arrow = (ArrowElement *)elementRecord;
int size = 12;
+ (void)dummy;
+ (void)paddingPtr;
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
*widthPtr = *heightPtr = size;
@@ -222,13 +236,14 @@ static void ArrowElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- int direction = *(int *)clientData;
- ArrowElement *arrow = elementRecord;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ ArrowElement *arrow = (ArrowElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
int borderWidth = 2;
int relief = TK_RELIEF_RAISED;
int size = b.width < b.height ? b.width : b.height;
XPoint points[3];
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, arrow->borderWidthObj, &borderWidth);
Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief);
@@ -266,7 +281,7 @@ static void ArrowElementDraw(
Tk_Fill3DPolygon(tkwin, d, border, points, 3, borderWidth, relief);
}
-static Ttk_ElementSpec ArrowElementSpec =
+static const Ttk_ElementSpec ArrowElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(ArrowElement),
@@ -290,10 +305,6 @@ static Ttk_ElementSpec ArrowElementSpec =
* -sashrelief raised, but that looks wrong to me.
*/
-static Ttk_Orient SashClientData[] = {
- TTK_ORIENT_HORIZONTAL, TTK_ORIENT_VERTICAL
-};
-
typedef struct {
Tcl_Obj *borderObj; /* background color */
Tcl_Obj *sashReliefObj; /* sash relief */
@@ -303,29 +314,31 @@ typedef struct {
Tcl_Obj *handlePadObj; /* handle's distance from edge */
} SashElement;
-static Ttk_ElementOptionSpec SashOptions[] = {
+static const Ttk_ElementOptionSpec SashOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(SashElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(SashElement,borderObj), DEFAULT_BACKGROUND },
{ "-sashrelief", TK_OPTION_RELIEF,
- Tk_Offset(SashElement,sashReliefObj), "sunken" },
+ offsetof(SashElement,sashReliefObj), "sunken" },
{ "-sashthickness", TK_OPTION_PIXELS,
- Tk_Offset(SashElement,sashThicknessObj), "6" },
+ offsetof(SashElement,sashThicknessObj), "6" },
{ "-sashpad", TK_OPTION_PIXELS,
- Tk_Offset(SashElement,sashPadObj), "2" },
+ offsetof(SashElement,sashPadObj), "2" },
{ "-handlesize", TK_OPTION_PIXELS,
- Tk_Offset(SashElement,handleSizeObj), "8" },
+ offsetof(SashElement,handleSizeObj), "8" },
{ "-handlepad", TK_OPTION_PIXELS,
- Tk_Offset(SashElement,handlePadObj), "8" },
- { NULL, 0, 0, NULL }
+ offsetof(SashElement,handlePadObj), "8" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void SashElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- SashElement *sash = elementRecord;
+ SashElement *sash = (SashElement *)elementRecord;
int sashPad = 2, sashThickness = 6, handleSize = 8;
- int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = (Ttk_Orient)PTR2INT(clientData);
+ (void)paddingPtr;
+ (void)paddingPtr;
Tk_GetPixelsFromObj(NULL, tkwin, sash->sashThicknessObj, &sashThickness);
Tk_GetPixelsFromObj(NULL, tkwin, sash->handleSizeObj, &handleSize);
@@ -334,7 +347,7 @@ static void SashElementSize(
if (sashThickness < handleSize + 2*sashPad)
sashThickness = handleSize + 2*sashPad;
- if (horizontal)
+ if (orient == TTK_ORIENT_HORIZONTAL)
*heightPtr = sashThickness;
else
*widthPtr = sashThickness;
@@ -344,13 +357,14 @@ static void SashElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- SashElement *sash = elementRecord;
+ SashElement *sash = (SashElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, sash->borderObj);
GC gc1,gc2;
int relief = TK_RELIEF_RAISED;
int handleSize = 8, handlePad = 8;
- int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = (Ttk_Orient)PTR2INT(clientData);
Ttk_Box hb;
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, sash->handleSizeObj, &handleSize);
Tk_GetPixelsFromObj(NULL, tkwin, sash->handlePadObj, &handlePad);
@@ -376,7 +390,7 @@ static void SashElementDraw(
/* Draw sash line:
*/
- if (horizontal) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
int y = b.y + b.height/2 - 1;
XDrawLine(Tk_Display(tkwin), d, gc1, b.x, y, b.x+b.width, y); ++y;
XDrawLine(Tk_Display(tkwin), d, gc2, b.x, y, b.x+b.width, y);
@@ -389,7 +403,7 @@ static void SashElementDraw(
/* Draw handle:
*/
if (handleSize >= 0) {
- if (horizontal) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
hb = Ttk_StickBox(b, handleSize, handleSize, TTK_STICK_W);
hb.x += handlePad;
} else {
@@ -401,7 +415,7 @@ static void SashElementDraw(
}
}
-static Ttk_ElementSpec SashElementSpec = {
+static const Ttk_ElementSpec SashElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SashElement),
SashOptions,
@@ -483,20 +497,20 @@ MODULE_SCOPE int TtkClassicTheme_Init(Tcl_Interp *interp)
&ButtonBorderElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "uparrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "downarrow",
- &ArrowElementSpec, &ArrowElements[1]);
+ &ArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "leftarrow",
- &ArrowElementSpec, &ArrowElements[2]);
+ &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp, theme, "rightarrow",
- &ArrowElementSpec, &ArrowElements[3]);
+ &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
Ttk_RegisterElement(interp, theme, "arrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "hsash",
- &SashElementSpec, &SashClientData[0]);
+ &SashElementSpec, INT2PTR(TTK_ORIENT_HORIZONTAL));
Ttk_RegisterElement(interp, theme, "vsash",
- &SashElementSpec, &SashClientData[1]);
+ &SashElementSpec, INT2PTR(TTK_ORIENT_VERTICAL));
/*
* Register layouts:
diff --git a/generic/ttk/ttkDecls.h b/generic/ttk/ttkDecls.h
index 6701724..5f76634 100644
--- a/generic/ttk/ttkDecls.h
+++ b/generic/ttk/ttkDecls.h
@@ -17,6 +17,15 @@ extern const char *TtkInitializeStubs(
#endif
+#if !defined(BUILD_tk)
+# define TTK_DEPRECATED(msg) TTKAPI TCL_DEPRECATED_API(msg)
+#elif defined(TK_NO_DEPRECATED)
+# define TTK_DEPRECATED(msg) MODULE_SCOPE
+#else
+# define TTK_DEPRECATED(msg) TTKAPI
+#endif
+
+
/* !BEGIN!: Do not edit below this line. */
@@ -47,12 +56,12 @@ TTKAPI void Ttk_RegisterCleanup(Tcl_Interp *interp,
/* 5 */
TTKAPI int Ttk_RegisterElementSpec(Ttk_Theme theme,
const char *elementName,
- Ttk_ElementSpec *elementSpec,
+ const Ttk_ElementSpec *elementSpec,
void *clientData);
/* 6 */
TTKAPI Ttk_ElementClass * Ttk_RegisterElement(Tcl_Interp *interp,
Ttk_Theme theme, const char *elementName,
- Ttk_ElementSpec *elementSpec,
+ const Ttk_ElementSpec *elementSpec,
void *clientData);
/* 7 */
TTKAPI int Ttk_RegisterElementFactory(Tcl_Interp *interp,
@@ -77,7 +86,7 @@ TTKAPI Ttk_StateMap Ttk_GetStateMapFromObj(Tcl_Interp *interp,
TTKAPI Tcl_Obj * Ttk_StateMapLookup(Tcl_Interp *interp,
Ttk_StateMap map, Ttk_State state);
/* 14 */
-TTKAPI int Ttk_StateTableLookup(Ttk_StateTable map[],
+TTKAPI int Ttk_StateTableLookup(const Ttk_StateTable *map,
Ttk_State state);
/* Slot 15 is reserved */
/* Slot 16 is reserved */
@@ -130,7 +139,8 @@ TTKAPI Tcl_Obj * Ttk_NewBoxObj(Ttk_Box box);
/* Slot 38 is reserved */
/* Slot 39 is reserved */
/* 40 */
-TTKAPI int Ttk_GetOrientFromObj(Tcl_Interp *interp,
+TTK_DEPRECATED("")
+int Ttk_GetOrientFromObj(Tcl_Interp *interp,
Tcl_Obj *objPtr, int *orient);
typedef struct TtkStubs {
@@ -144,8 +154,8 @@ typedef struct TtkStubs {
Ttk_Theme (*ttk_GetCurrentTheme) (Tcl_Interp *interp); /* 2 */
Ttk_Theme (*ttk_CreateTheme) (Tcl_Interp *interp, const char *name, Ttk_Theme parent); /* 3 */
void (*ttk_RegisterCleanup) (Tcl_Interp *interp, void *deleteData, Ttk_CleanupProc *cleanupProc); /* 4 */
- int (*ttk_RegisterElementSpec) (Ttk_Theme theme, const char *elementName, Ttk_ElementSpec *elementSpec, void *clientData); /* 5 */
- Ttk_ElementClass * (*ttk_RegisterElement) (Tcl_Interp *interp, Ttk_Theme theme, const char *elementName, Ttk_ElementSpec *elementSpec, void *clientData); /* 6 */
+ int (*ttk_RegisterElementSpec) (Ttk_Theme theme, const char *elementName, const Ttk_ElementSpec *elementSpec, void *clientData); /* 5 */
+ Ttk_ElementClass * (*ttk_RegisterElement) (Tcl_Interp *interp, Ttk_Theme theme, const char *elementName, const Ttk_ElementSpec *elementSpec, void *clientData); /* 6 */
int (*ttk_RegisterElementFactory) (Tcl_Interp *interp, const char *name, Ttk_ElementFactory factoryProc, void *clientData); /* 7 */
void (*ttk_RegisterLayout) (Ttk_Theme theme, const char *className, Ttk_LayoutSpec layoutSpec); /* 8 */
void (*reserved9)(void);
@@ -153,7 +163,7 @@ typedef struct TtkStubs {
Tcl_Obj * (*ttk_NewStateSpecObj) (unsigned int onbits, unsigned int offbits); /* 11 */
Ttk_StateMap (*ttk_GetStateMapFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr); /* 12 */
Tcl_Obj * (*ttk_StateMapLookup) (Tcl_Interp *interp, Ttk_StateMap map, Ttk_State state); /* 13 */
- int (*ttk_StateTableLookup) (Ttk_StateTable map[], Ttk_State state); /* 14 */
+ int (*ttk_StateTableLookup) (const Ttk_StateTable *map, Ttk_State state); /* 14 */
void (*reserved15)(void);
void (*reserved16)(void);
void (*reserved17)(void);
@@ -179,7 +189,7 @@ typedef struct TtkStubs {
void (*reserved37)(void);
void (*reserved38)(void);
void (*reserved39)(void);
- int (*ttk_GetOrientFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *orient); /* 40 */
+ TCL_DEPRECATED_API("") int (*ttk_GetOrientFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *orient); /* 40 */
} TtkStubs;
extern const TtkStubs *ttkStubsPtr;
diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c
index e4bfeca..a614894 100644
--- a/generic/ttk/ttkDefaultTheme.c
+++ b/generic/ttk/ttkDefaultTheme.c
@@ -37,7 +37,7 @@ static const int WIN32_XDRAWLINE_HACK = 0;
enum BorderColor { FLAT = 1, LITE = 2, DARK = 3, BRDR = 4 };
/* top-left outer, top-left inner, bottom-right inner, bottom-right outer */
-static int const shadowColors[6][4] = {
+static const enum BorderColor shadowColors[6][4] = {
{ FLAT, FLAT, FLAT, FLAT }, /* TK_RELIEF_FLAT = 0*/
{ DARK, LITE, DARK, LITE }, /* TK_RELIEF_GROOVE = 1*/
{ LITE, FLAT, DARK, BRDR }, /* TK_RELIEF_RAISED = 2*/
@@ -47,7 +47,7 @@ static int const shadowColors[6][4] = {
};
/* top-left, bottom-right */
-static int const thinShadowColors[6][4] = {
+static const enum BorderColor thinShadowColors[6][4] = {
{ FLAT, FLAT }, /* TK_RELIEF_FLAT = 0*/
{ DARK, LITE }, /* TK_RELIEF_GROOVE = 1*/
{ LITE, DARK }, /* TK_RELIEF_RAISED = 2*/
@@ -116,21 +116,19 @@ static void DrawBorder(
/* Alternate shadow colors for entry fields:
* NOTE: FLAT color is normally white, and the LITE color is a darker shade.
*/
-static int fieldShadowColors[4] = { DARK, BRDR, LITE, FLAT };
-
static void DrawFieldBorder(
Tk_Window tkwin, Drawable d, Tk_3DBorder border, XColor *borderColor,
Ttk_Box b)
{
GC borderGC = Tk_GCForColor(borderColor, d);
DrawCorner(tkwin, d, border, borderGC,
- b.x, b.y, b.width, b.height, 0,fieldShadowColors[0]);
+ b.x, b.y, b.width, b.height, 0, DARK);
DrawCorner(tkwin, d, border, borderGC,
- b.x+1, b.y+1, b.width-2, b.height-2, 0,fieldShadowColors[1]);
+ b.x+1, b.y+1, b.width-2, b.height-2, 0, BRDR);
DrawCorner(tkwin, d, border, borderGC,
- b.x+1, b.y+1, b.width-2, b.height-2, 1,fieldShadowColors[2]);
+ b.x+1, b.y+1, b.width-2, b.height-2, 1, LITE);
DrawCorner(tkwin, d, border, borderGC,
- b.x, b.y, b.width, b.height, 1,fieldShadowColors[3]);
+ b.x, b.y, b.width, b.height, 1, FLAT);
return;
}
@@ -138,11 +136,11 @@ static void DrawFieldBorder(
* ArrowPoints --
* Compute points of arrow polygon.
*/
-static void ArrowPoints(Ttk_Box b, ArrowDirection dir, XPoint points[4])
+static void ArrowPoints(Ttk_Box b, ArrowDirection direction, XPoint points[4])
{
int cx, cy, h;
- switch (dir) {
+ switch (direction) {
case ARROW_UP:
h = (b.width - 1)/2;
cx = b.x + h;
@@ -186,9 +184,9 @@ static void ArrowPoints(Ttk_Box b, ArrowDirection dir, XPoint points[4])
}
/*public*/
-void TtkArrowSize(int h, ArrowDirection dir, int *widthPtr, int *heightPtr)
+void TtkArrowSize(int h, ArrowDirection direction, int *widthPtr, int *heightPtr)
{
- switch (dir) {
+ switch (direction) {
case ARROW_UP:
case ARROW_DOWN: *widthPtr = 2*h+1; *heightPtr = h+1; break;
case ARROW_LEFT:
@@ -202,10 +200,10 @@ void TtkArrowSize(int h, ArrowDirection dir, int *widthPtr, int *heightPtr)
*/
/*public*/
void TtkFillArrow(
- Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection dir)
+ Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection direction)
{
XPoint points[4];
- ArrowPoints(b, dir, points);
+ ArrowPoints(b, direction, points);
XFillPolygon(display, d, gc, points, 3, Convex, CoordModeOrigin);
XDrawLines(display, d, gc, points, 4, CoordModeOrigin);
@@ -215,10 +213,10 @@ void TtkFillArrow(
/*public*/
void TtkDrawArrow(
- Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection dir)
+ Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection direction)
{
XPoint points[4];
- ArrowPoints(b, dir, points);
+ ArrowPoints(b, direction, points);
XDrawLines(display, d, gc, points, 4, CoordModeOrigin);
/* Work around bug [77527326e5] - ttk artifacts on Ubuntu */
@@ -244,27 +242,31 @@ typedef struct {
Tcl_Obj *defaultStateObj; /* for buttons */
} BorderElement;
-static Ttk_ElementOptionSpec BorderElementOptions[] = {
- { "-background", TK_OPTION_BORDER, Tk_Offset(BorderElement,borderObj),
+static const Ttk_ElementOptionSpec BorderElementOptions[] = {
+ { "-background", TK_OPTION_BORDER, offsetof(BorderElement,borderObj),
DEFAULT_BACKGROUND },
{ "-bordercolor",TK_OPTION_COLOR,
- Tk_Offset(BorderElement,borderColorObj), "black" },
- { "-default", TK_OPTION_ANY, Tk_Offset(BorderElement,defaultStateObj),
+ offsetof(BorderElement,borderColorObj), "black" },
+ { "-default", TK_OPTION_ANY, offsetof(BorderElement,defaultStateObj),
"disabled" },
- { "-borderwidth",TK_OPTION_PIXELS,Tk_Offset(BorderElement,borderWidthObj),
+ { "-borderwidth",TK_OPTION_PIXELS, offsetof(BorderElement,borderWidthObj),
STRINGIFY(BORDERWIDTH) },
- { "-relief", TK_OPTION_RELIEF, Tk_Offset(BorderElement,reliefObj),
+ { "-relief", TK_OPTION_RELIEF, offsetof(BorderElement,reliefObj),
"flat" },
- { NULL, 0, 0, NULL }
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void BorderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- BorderElement *bd = elementRecord;
+ BorderElement *bd = (BorderElement *)elementRecord;
int borderWidth = 0;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ (void)dummy;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth);
Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState);
@@ -277,15 +279,17 @@ static void BorderElementSize(
}
static void BorderElementDraw(
- void *clientData, void *elementRecord,
+ void *dummy, void *elementRecord,
Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state)
{
- BorderElement *bd = elementRecord;
+ BorderElement *bd = (BorderElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, bd->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, bd->borderColorObj);
int borderWidth = 2;
int relief = TK_RELIEF_FLAT;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ (void)dummy;
+ (void)state;
/*
* Get option values.
@@ -307,7 +311,7 @@ static void BorderElementDraw(
DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
}
-static Ttk_ElementSpec BorderElementSpec = {
+static const Ttk_ElementSpec BorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BorderElement),
BorderElementOptions,
@@ -324,35 +328,43 @@ typedef struct {
Tcl_Obj *borderColorObj; /* Extra border color */
} FieldElement;
-static Ttk_ElementOptionSpec FieldElementOptions[] = {
- { "-fieldbackground", TK_OPTION_BORDER, Tk_Offset(FieldElement,borderObj),
+static const Ttk_ElementOptionSpec FieldElementOptions[] = {
+ { "-fieldbackground", TK_OPTION_BORDER, offsetof(FieldElement,borderObj),
"white" },
- { "-bordercolor",TK_OPTION_COLOR, Tk_Offset(FieldElement,borderColorObj),
+ { "-bordercolor",TK_OPTION_COLOR, offsetof(FieldElement,borderColorObj),
"black" },
- { NULL, 0, 0, NULL }
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void FieldElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+
*paddingPtr = Ttk_UniformPadding(2);
}
static void FieldElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- FieldElement *field = elementRecord;
+ FieldElement *field = (FieldElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, field->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, field->borderColorObj);
+ (void)dummy;
+ (void)state;
Tk_Fill3DRectangle(
tkwin, d, border, b.x, b.y, b.width, b.height, 0, TK_RELIEF_SUNKEN);
DrawFieldBorder(tkwin, d, border, borderColor, b);
}
-static Ttk_ElementSpec FieldElementSpec = {
+static const Ttk_ElementSpec FieldElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FieldElement),
FieldElementOptions,
@@ -375,7 +387,7 @@ typedef struct {
int height; /* Height of each image */
int nimages; /* #images / row */
const char *const *pixels; /* array[height] of char[width*nimage] */
- Ttk_StateTable *map;/* used to look up image index by state */
+ const Ttk_StateTable *map;/* used to look up image index by state */
} IndicatorSpec;
#if 0
@@ -395,7 +407,7 @@ static const char *const button_images[] = {
};
#endif
-static Ttk_StateTable checkbutton_states[] = {
+static const Ttk_StateTable checkbutton_states[] = {
{ 0, 0, TTK_STATE_SELECTED|TTK_STATE_DISABLED },
{ 1, TTK_STATE_SELECTED, TTK_STATE_DISABLED },
{ 2, TTK_STATE_DISABLED, TTK_STATE_SELECTED },
@@ -425,7 +437,7 @@ static IndicatorSpec checkbutton_spec = {
checkbutton_states
};
-static Ttk_StateTable radiobutton_states[] = {
+static const Ttk_StateTable radiobutton_states[] = {
{ 0, 0, TTK_STATE_SELECTED|TTK_STATE_DISABLED },
{ 1, TTK_STATE_SELECTED, TTK_STATE_DISABLED },
{ 2, TTK_STATE_DISABLED, TTK_STATE_SELECTED },
@@ -465,31 +477,33 @@ typedef struct {
Tcl_Obj *marginObj;
} IndicatorElement;
-static Ttk_ElementOptionSpec IndicatorElementOptions[] = {
+static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
{ "-background", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,foregroundObj), DEFAULT_FOREGROUND },
+ offsetof(IndicatorElement,foregroundObj), DEFAULT_FOREGROUND },
{ "-indicatorcolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,colorObj), "#FFFFFF" },
+ offsetof(IndicatorElement,colorObj), "#FFFFFF" },
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,lightColorObj), "#DDDDDD" },
+ offsetof(IndicatorElement,lightColorObj), "#DDDDDD" },
{ "-shadecolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,shadeColorObj), "#888888" },
+ offsetof(IndicatorElement,shadeColorObj), "#888888" },
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,borderColorObj), "black" },
+ offsetof(IndicatorElement,borderColorObj), "black" },
{ "-indicatormargin", TK_OPTION_STRING,
- Tk_Offset(IndicatorElement,marginObj), "0 2 4 2" },
- { NULL, 0, 0, NULL }
+ offsetof(IndicatorElement,marginObj), "0 2 4 2" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void IndicatorElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- IndicatorSpec *spec = clientData;
- IndicatorElement *indicator = elementRecord;
+ IndicatorSpec *spec = (IndicatorSpec *)clientData;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
+ (void)paddingPtr;
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
*widthPtr = spec->width + Ttk_PaddingWidth(margins);
*heightPtr = spec->height + Ttk_PaddingHeight(margins);
@@ -499,8 +513,8 @@ static void IndicatorElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- IndicatorSpec *spec = clientData;
- IndicatorElement *indicator = elementRecord;
+ IndicatorSpec *spec = (IndicatorSpec *)clientData;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Display *display = Tk_Display(tkwin);
Ttk_Padding padding;
XColor *fgColor, *frameColor, *shadeColor, *indicatorColor, *borderColor;
@@ -579,7 +593,7 @@ static void IndicatorElementDraw(
#if defined(IGNORES_VISUAL)
- img->data = ckalloc(img->bytes_per_line * img->height);
+ img->data = (char *)ckalloc(img->bytes_per_line * img->height);
if (img->data == NULL) {
XDestroyImage(img);
return;
@@ -628,7 +642,7 @@ static void IndicatorElementDraw(
XDestroyImage(img);
}
-static Ttk_ElementSpec IndicatorElementSpec = {
+static const Ttk_ElementSpec IndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(IndicatorElement),
IndicatorElementOptions,
@@ -643,7 +657,6 @@ static Ttk_ElementSpec IndicatorElementSpec = {
* clientData is an enum ArrowDirection pointer.
*/
-static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
typedef struct {
Tcl_Obj *sizeObj;
Tcl_Obj *borderObj;
@@ -652,18 +665,18 @@ typedef struct {
Tcl_Obj *colorObj; /* Arrow color */
} ArrowElement;
-static Ttk_ElementOptionSpec ArrowElementOptions[] = {
+static const Ttk_ElementOptionSpec ArrowElementOptions[] = {
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(ArrowElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) },
+ offsetof(ArrowElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ArrowElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(ArrowElement,borderObj), DEFAULT_BACKGROUND },
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(ArrowElement,borderColorObj), "black" },
+ offsetof(ArrowElement,borderColorObj), "black" },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(ArrowElement,reliefObj),"raised"},
+ offsetof(ArrowElement,reliefObj),"raised"},
{ "-arrowcolor", TK_OPTION_COLOR,
- Tk_Offset(ArrowElement,colorObj),"black"},
- { NULL, 0, 0, NULL }
+ offsetof(ArrowElement,colorObj),"black"},
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
/*
@@ -671,15 +684,16 @@ static Ttk_ElementOptionSpec ArrowElementOptions[] = {
* top/left padding is 1 less than bottom/right,
* since in this theme 2-pixel borders are asymmetric.
*/
-static Ttk_Padding ArrowPadding = { 3,3,4,4 };
+static const Ttk_Padding ArrowPadding = { 3,3,4,4 };
static void ArrowElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ArrowElement *arrow = elementRecord;
- int direction = *(int *)clientData;
+ ArrowElement *arrow = (ArrowElement *)elementRecord;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
int width = SCROLLBAR_WIDTH;
+ (void)paddingPtr;
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &width);
width -= Ttk_PaddingWidth(ArrowPadding);
@@ -692,13 +706,14 @@ static void ArrowElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- int direction = *(int *)clientData;
- ArrowElement *arrow = elementRecord;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ ArrowElement *arrow = (ArrowElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, arrow->borderColorObj);
XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
int relief = TK_RELIEF_RAISED;
int borderWidth = 2;
+ (void)state;
Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief);
@@ -710,7 +725,7 @@ static void ArrowElementDraw(
Ttk_PadBox(b, ArrowPadding), direction);
}
-static Ttk_ElementSpec ArrowElementSpec = {
+static const Ttk_ElementSpec ArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ArrowElement),
ArrowElementOptions,
@@ -736,24 +751,27 @@ static const char *const directionStrings[] = { /* See also: button.c */
};
enum { POST_ABOVE, POST_BELOW, POST_LEFT, POST_RIGHT, POST_FLUSH };
-static Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] = {
+static const Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] = {
{ "-direction", TK_OPTION_STRING,
- Tk_Offset(MenubuttonArrowElement,directionObj), "below" },
+ offsetof(MenubuttonArrowElement,directionObj), "below" },
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(MenubuttonArrowElement,sizeObj), STRINGIFY(MENUBUTTON_ARROW_SIZE)},
+ offsetof(MenubuttonArrowElement,sizeObj), STRINGIFY(MENUBUTTON_ARROW_SIZE)},
{ "-arrowcolor",TK_OPTION_COLOR,
- Tk_Offset(MenubuttonArrowElement,colorObj), "black"},
- { NULL, 0, 0, NULL }
+ offsetof(MenubuttonArrowElement,colorObj), "black"},
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
-static Ttk_Padding MenubuttonArrowPadding = { 3, 0, 3, 0 };
+static const Ttk_Padding MenubuttonArrowPadding = { 3, 0, 3, 0 };
static void MenubuttonArrowElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- MenubuttonArrowElement *arrow = elementRecord;
+ MenubuttonArrowElement *arrow = (MenubuttonArrowElement *)elementRecord;
int size = MENUBUTTON_ARROW_SIZE;
+ (void)dummy;
+ (void)paddingPtr;
+
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
*widthPtr = *heightPtr = 2 * size + 1;
*widthPtr += Ttk_PaddingWidth(MenubuttonArrowPadding);
@@ -761,16 +779,18 @@ static void MenubuttonArrowElementSize(
}
static void MenubuttonArrowElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- MenubuttonArrowElement *arrow = elementRecord;
+ MenubuttonArrowElement *arrow = (MenubuttonArrowElement *)elementRecord;
XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
GC gc = Tk_GCForColor(arrowColor, d);
int size = MENUBUTTON_ARROW_SIZE;
int postDirection = POST_BELOW;
ArrowDirection arrowDirection = ARROW_DOWN;
int width = 0, height = 0;
+ (void)dummy;
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
Tcl_GetIndexFromObjStruct(NULL, arrow->directionObj, directionStrings,
@@ -791,7 +811,7 @@ static void MenubuttonArrowElementDraw(
TtkFillArrow(Tk_Display(tkwin), d, gc, b, arrowDirection);
}
-static Ttk_ElementSpec MenubuttonArrowElementSpec = {
+static const Ttk_ElementSpec MenubuttonArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(MenubuttonArrowElement),
MenubuttonArrowElementOptions,
@@ -820,26 +840,29 @@ typedef struct {
Tcl_Obj *orientObj;
} TroughElement;
-static Ttk_ElementOptionSpec TroughElementOptions[] = {
+static const Ttk_ElementOptionSpec TroughElementOptions[] = {
{ "-orient", TK_OPTION_ANY,
- Tk_Offset(TroughElement, orientObj), "horizontal" },
+ offsetof(TroughElement, orientObj), "horizontal" },
{ "-troughborderwidth", TK_OPTION_PIXELS,
- Tk_Offset(TroughElement,borderWidthObj), "1" },
+ offsetof(TroughElement,borderWidthObj), "1" },
{ "-troughcolor", TK_OPTION_BORDER,
- Tk_Offset(TroughElement,colorObj), DEFAULT_BACKGROUND },
+ offsetof(TroughElement,colorObj), DEFAULT_BACKGROUND },
{ "-troughrelief",TK_OPTION_RELIEF,
- Tk_Offset(TroughElement,reliefObj), "sunken" },
+ offsetof(TroughElement,reliefObj), "sunken" },
{ "-groovewidth", TK_OPTION_PIXELS,
- Tk_Offset(TroughElement,grooveWidthObj), "-1" },
- { NULL, 0, 0, NULL }
+ offsetof(TroughElement,grooveWidthObj), "-1" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void TroughElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TroughElement *troughPtr = elementRecord;
+ TroughElement *troughPtr = (TroughElement *)elementRecord;
int borderWidth = 2, grooveWidth = 0;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &grooveWidth);
@@ -850,15 +873,18 @@ static void TroughElementSize(
}
static void TroughElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- TroughElement *troughPtr = elementRecord;
+ TroughElement *troughPtr = (TroughElement *)elementRecord;
Tk_3DBorder border = NULL;
- int borderWidth = 2, relief = TK_RELIEF_SUNKEN, groove = -1, orient;
+ int borderWidth = 2, relief = TK_RELIEF_SUNKEN, groove = -1;
+ Ttk_Orient orient;
+ (void)dummy;
+ (void)state;
border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
- Ttk_GetOrientFromObj(NULL, troughPtr->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, troughPtr->orientObj, &orient);
Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief);
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &groove);
@@ -877,7 +903,7 @@ static void TroughElementDraw(
borderWidth, relief);
}
-static Ttk_ElementSpec TroughElementSpec = {
+static const Ttk_ElementSpec TroughElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TroughElement),
TroughElementOptions,
@@ -900,26 +926,30 @@ typedef struct {
Tcl_Obj *orientObj;
} ThumbElement;
-static Ttk_ElementOptionSpec ThumbElementOptions[] = {
- { "-width", TK_OPTION_PIXELS, Tk_Offset(ThumbElement,sizeObj),
+static const Ttk_ElementOptionSpec ThumbElementOptions[] = {
+ { "-width", TK_OPTION_PIXELS, offsetof(ThumbElement,sizeObj),
STRINGIFY(SCROLLBAR_WIDTH) },
- { "-background", TK_OPTION_BORDER, Tk_Offset(ThumbElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(ThumbElement,borderObj),
DEFAULT_BACKGROUND },
- { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(ThumbElement,borderColorObj),
+ { "-bordercolor", TK_OPTION_COLOR, offsetof(ThumbElement,borderColorObj),
"black" },
- { "-relief", TK_OPTION_RELIEF,Tk_Offset(ThumbElement,reliefObj),"raised" },
- { "-orient", TK_OPTION_ANY,Tk_Offset(ThumbElement,orientObj),"horizontal"},
- { NULL, 0, 0, NULL }
+ { "-relief", TK_OPTION_RELIEF, offsetof(ThumbElement,reliefObj),"raised" },
+ { "-orient", TK_OPTION_ANY, offsetof(ThumbElement,orientObj),"horizontal"},
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void ThumbElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ThumbElement *thumb = elementRecord;
- int orient, size;
+ ThumbElement *thumb = (ThumbElement *)elementRecord;
+ Ttk_Orient orient;
+ int size;
+ (void)dummy;
+ (void)paddingPtr;
+
Tk_GetPixelsFromObj(NULL, tkwin, thumb->sizeObj, &size);
- Ttk_GetOrientFromObj(NULL, thumb->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, thumb->orientObj, &orient);
if (orient == TTK_ORIENT_VERTICAL) {
*widthPtr = size;
@@ -931,14 +961,16 @@ static void ThumbElementSize(
}
static void ThumbElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ThumbElement *thumb = elementRecord;
+ ThumbElement *thumb = (ThumbElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, thumb->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, thumb->borderColorObj);
int relief = TK_RELIEF_RAISED;
int borderWidth = 2;
+ (void)dummy;
+ (void)state;
/*
* Don't draw the thumb if we are disabled.
@@ -954,7 +986,7 @@ static void ThumbElementDraw(
DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
}
-static Ttk_ElementSpec ThumbElementSpec = {
+static const Ttk_ElementSpec ThumbElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ThumbElement),
ThumbElementOptions,
@@ -983,32 +1015,35 @@ typedef struct {
Tcl_Obj *orientObj; /* Orientation of overall slider */
} SliderElement;
-static Ttk_ElementOptionSpec SliderElementOptions[] = {
- { "-sliderlength", TK_OPTION_PIXELS, Tk_Offset(SliderElement,lengthObj),
+static const Ttk_ElementOptionSpec SliderElementOptions[] = {
+ { "-sliderlength", TK_OPTION_PIXELS, offsetof(SliderElement,lengthObj),
"15" },
- { "-sliderthickness",TK_OPTION_PIXELS,Tk_Offset(SliderElement,thicknessObj),
+ { "-sliderthickness",TK_OPTION_PIXELS, offsetof(SliderElement,thicknessObj),
"15" },
- { "-sliderrelief", TK_OPTION_RELIEF, Tk_Offset(SliderElement,reliefObj),
+ { "-sliderrelief", TK_OPTION_RELIEF, offsetof(SliderElement,reliefObj),
"raised" },
- { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(SliderElement,borderWidthObj),
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(SliderElement,borderWidthObj),
STRINGIFY(BORDERWIDTH) },
- { "-background", TK_OPTION_BORDER, Tk_Offset(SliderElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(SliderElement,borderObj),
DEFAULT_BACKGROUND },
- { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(ThumbElement,borderColorObj),
+ { "-bordercolor", TK_OPTION_COLOR, offsetof(ThumbElement,borderColorObj),
"black" },
- { "-orient", TK_OPTION_ANY, Tk_Offset(SliderElement,orientObj),
+ { "-orient", TK_OPTION_ANY, offsetof(SliderElement,orientObj),
"horizontal" },
- { NULL, 0, 0, NULL }
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void SliderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- SliderElement *slider = elementRecord;
- int orient, length, thickness, borderWidth;
+ SliderElement *slider = (SliderElement *)elementRecord;
+ Ttk_Orient orient;
+ int length, thickness, borderWidth;
+ (void)dummy;
+ (void)paddingPtr;
- Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
Tk_GetPixelsFromObj(NULL, tkwin, slider->lengthObj, &length);
Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness);
@@ -1027,13 +1062,15 @@ static void SliderElementSize(
}
static void SliderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- SliderElement *slider = elementRecord;
+ SliderElement *slider = (SliderElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, slider->borderColorObj);
int relief = TK_RELIEF_RAISED, borderWidth = 2;
+ (void)dummy;
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief);
@@ -1044,7 +1081,7 @@ static void SliderElementDraw(
DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
}
-static Ttk_ElementSpec SliderElementSpec = {
+static const Ttk_ElementSpec SliderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SliderElement),
SliderElementOptions,
@@ -1065,23 +1102,25 @@ typedef struct {
Tcl_Obj *diameterObj;
} TreeitemIndicator;
-static Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = {
+static const Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = {
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
+ offsetof(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
{ "-diameter", TK_OPTION_PIXELS,
- Tk_Offset(TreeitemIndicator,diameterObj), "9" },
+ offsetof(TreeitemIndicator,diameterObj), "9" },
{ "-indicatormargins", TK_OPTION_STRING,
- Tk_Offset(TreeitemIndicator,marginObj), "2 2 4 2" },
- { NULL, 0, 0, NULL }
+ offsetof(TreeitemIndicator,marginObj), "2 2 4 2" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void TreeitemIndicatorSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TreeitemIndicator *indicator = elementRecord;
+ TreeitemIndicator *indicator = (TreeitemIndicator *)elementRecord;
int diameter = 0;
Ttk_Padding margins;
+ (void)dummy;
+ (void)paddingPtr;
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
@@ -1090,15 +1129,16 @@ static void TreeitemIndicatorSize(
}
static void TreeitemIndicatorDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- TreeitemIndicator *indicator = elementRecord;
+ TreeitemIndicator *indicator = (TreeitemIndicator *)elementRecord;
XColor *color = Tk_GetColorFromObj(tkwin, indicator->colorObj);
GC gc = Tk_GCForColor(color, d);
Ttk_Padding padding = Ttk_UniformPadding(0);
int w = WIN32_XDRAWLINE_HACK;
int cx, cy;
+ (void)dummy;
if (state & TTK_STATE_LEAF) {
/* don't draw anything ... */
@@ -1121,7 +1161,7 @@ static void TreeitemIndicatorDraw(
}
}
-static Ttk_ElementSpec TreeitemIndicatorElementSpec = {
+static const Ttk_ElementSpec TreeitemIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TreeitemIndicator),
TreeitemIndicatorOptions,
@@ -1157,18 +1197,15 @@ MODULE_SCOPE int TtkAltTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "slider", &SliderElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "uparrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "downarrow",
- &ArrowElementSpec, &ArrowElements[1]);
+ &ArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "leftarrow",
- &ArrowElementSpec, &ArrowElements[2]);
+ &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp, theme, "rightarrow",
- &ArrowElementSpec, &ArrowElements[3]);
- Ttk_RegisterElement(interp, theme, "arrow",
- &ArrowElementSpec, &ArrowElements[0]);
-
+ &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
Ttk_RegisterElement(interp, theme, "arrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "Treeitem.indicator",
&TreeitemIndicatorElementSpec, 0);
diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c
index 4dd2adb..a1cac4d 100644
--- a/generic/ttk/ttkElements.c
+++ b/generic/ttk/ttkElements.c
@@ -19,20 +19,32 @@
* and may be used in other engines.
*/
-/* public */ Ttk_ElementOptionSpec TtkNullElementOptions[] = { { NULL, 0, 0, NULL } };
+/* public */ const Ttk_ElementOptionSpec TtkNullElementOptions[] = { { NULL, TK_OPTION_BOOLEAN, 0, NULL } };
/* public */ void
TtkNullElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+ (void)paddingPtr;
}
/* public */ void
TtkNullElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)d;
+ (void)b;
+ (void)state;
}
/* public */ Ttk_ElementSpec ttkNullElementSpec = {
@@ -56,18 +68,20 @@ typedef struct {
Tcl_Obj *backgroundObj;
} BackgroundElement;
-static Ttk_ElementOptionSpec BackgroundElementOptions[] = {
+static const Ttk_ElementOptionSpec BackgroundElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(BackgroundElement,backgroundObj), DEFAULT_BACKGROUND },
- { NULL, 0, 0, NULL }
+ offsetof(BackgroundElement,backgroundObj), DEFAULT_BACKGROUND },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void FillElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- BackgroundElement *bg = elementRecord;
+ BackgroundElement *bg = (BackgroundElement *)elementRecord;
Tk_3DBorder backgroundPtr = Tk_Get3DBorderFromObj(tkwin,bg->backgroundObj);
+ (void)dummy;
+ (void)state;
XFillRectangle(Tk_Display(tkwin), d,
Tk_3DBorderGC(tkwin, backgroundPtr, TK_3D_FLAT_GC),
@@ -78,12 +92,14 @@ static void BackgroundElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
+ (void)b;
+
FillElementDraw(
clientData, elementRecord, tkwin,
d, Ttk_WinBox(tkwin), state);
}
-static Ttk_ElementSpec FillElementSpec = {
+static const Ttk_ElementSpec FillElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BackgroundElement),
BackgroundElementOptions,
@@ -91,7 +107,7 @@ static Ttk_ElementSpec FillElementSpec = {
FillElementDraw
};
-static Ttk_ElementSpec BackgroundElementSpec = {
+static const Ttk_ElementSpec BackgroundElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BackgroundElement),
BackgroundElementOptions,
@@ -109,33 +125,40 @@ typedef struct {
Tcl_Obj *reliefObj;
} BorderElement;
-static Ttk_ElementOptionSpec BorderElementOptions[] = {
+static const Ttk_ElementOptionSpec BorderElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(BorderElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(BorderElement,borderObj), DEFAULT_BACKGROUND },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(BorderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ offsetof(BorderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(BorderElement,reliefObj), "flat" },
- { NULL, 0, 0, NULL }
+ offsetof(BorderElement,reliefObj), "flat" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void BorderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- BorderElement *bd = elementRecord;
+ BorderElement *bd = (BorderElement *)elementRecord;
int borderWidth = 0;
+ (void)dummy;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+
Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth);
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
static void BorderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- BorderElement *bd = elementRecord;
+ BorderElement *bd = (BorderElement *)elementRecord;
Tk_3DBorder border = NULL;
int borderWidth = 1, relief = TK_RELIEF_FLAT;
+ (void)dummy;
+ (void)state;
border = Tk_Get3DBorderFromObj(tkwin, bd->borderObj);
Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth);
@@ -147,7 +170,7 @@ static void BorderElementDraw(
}
}
-static Ttk_ElementSpec BorderElementSpec = {
+static const Ttk_ElementSpec BorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BorderElement),
BorderElementOptions,
@@ -164,38 +187,44 @@ typedef struct {
Tcl_Obj *borderWidthObj;
} FieldElement;
-static Ttk_ElementOptionSpec FieldElementOptions[] = {
+static const Ttk_ElementOptionSpec FieldElementOptions[] = {
{ "-fieldbackground", TK_OPTION_BORDER,
- Tk_Offset(FieldElement,borderObj), "white" },
+ offsetof(FieldElement,borderObj), "white" },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(FieldElement,borderWidthObj), "2" },
- { NULL, 0, 0, NULL }
+ offsetof(FieldElement,borderWidthObj), "2" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void FieldElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- FieldElement *field = elementRecord;
+ FieldElement *field = (FieldElement *)elementRecord;
int borderWidth = 2;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
+
Tk_GetPixelsFromObj(NULL, tkwin, field->borderWidthObj, &borderWidth);
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
static void FieldElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- FieldElement *field = elementRecord;
+ FieldElement *field = (FieldElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, field->borderObj);
int borderWidth = 2;
+ (void)dummy;
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, field->borderWidthObj, &borderWidth);
Tk_Fill3DRectangle(tkwin, d, border,
b.x, b.y, b.width, b.height, borderWidth, TK_RELIEF_SUNKEN);
}
-static Ttk_ElementSpec FieldElementSpec = {
+static const Ttk_ElementSpec FieldElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FieldElement),
FieldElementOptions,
@@ -220,24 +249,27 @@ typedef struct {
Tcl_Obj *shiftreliefObj;
} PaddingElement;
-static Ttk_ElementOptionSpec PaddingElementOptions[] = {
+static const Ttk_ElementOptionSpec PaddingElementOptions[] = {
{ "-padding", TK_OPTION_STRING,
- Tk_Offset(PaddingElement,paddingObj), "0" },
+ offsetof(PaddingElement,paddingObj), "0" },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(PaddingElement,reliefObj), "flat" },
+ offsetof(PaddingElement,reliefObj), "flat" },
{ "-shiftrelief", TK_OPTION_INT,
- Tk_Offset(PaddingElement,shiftreliefObj), "0" },
- { NULL, 0, 0, NULL }
+ offsetof(PaddingElement,shiftreliefObj), "0" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void PaddingElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- PaddingElement *padding = elementRecord;
+ PaddingElement *padding = (PaddingElement *)elementRecord;
int shiftRelief = 0;
int relief = TK_RELIEF_FLAT;
Ttk_Padding pad;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
Tk_GetReliefFromObj(NULL, padding->reliefObj, &relief);
Tcl_GetIntFromObj(NULL, padding->shiftreliefObj, &shiftRelief);
@@ -245,7 +277,7 @@ static void PaddingElementSize(
*paddingPtr = Ttk_RelievePadding(pad, relief, shiftRelief);
}
-static Ttk_ElementSpec PaddingElementSpec = {
+static const Ttk_ElementSpec PaddingElementSpec = {
TK_STYLE_VERSION_2,
sizeof(PaddingElement),
PaddingElementOptions,
@@ -286,31 +318,36 @@ static void DrawFocusRing(
Tk_FreeGC(Tk_Display(tkwin), gc);
}
-static Ttk_ElementOptionSpec FocusElementOptions[] = {
+static const Ttk_ElementOptionSpec FocusElementOptions[] = {
{ "-focuscolor",TK_OPTION_COLOR,
- Tk_Offset(FocusElement,focusColorObj), "black" },
+ offsetof(FocusElement,focusColorObj), "black" },
{ "-focusthickness",TK_OPTION_PIXELS,
- Tk_Offset(FocusElement,focusThicknessObj), "1" },
- { NULL, 0, 0, NULL }
+ offsetof(FocusElement,focusThicknessObj), "1" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void FocusElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- FocusElement *focus = elementRecord;
+ FocusElement *focus = (FocusElement *)elementRecord;
int focusThickness = 0;
+ (void)dummy;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
Tcl_GetIntFromObj(NULL, focus->focusThicknessObj, &focusThickness);
*paddingPtr = Ttk_UniformPadding((short)focusThickness);
}
static void FocusElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- FocusElement *focus = elementRecord;
+ FocusElement *focus = (FocusElement *)elementRecord;
int focusThickness = 0;
+ (void)dummy;
if (state & TTK_STATE_FOCUS) {
Tcl_GetIntFromObj(NULL,focus->focusThicknessObj,&focusThickness);
@@ -318,7 +355,7 @@ static void FocusElementDraw(
}
}
-static Ttk_ElementSpec FocusElementSpec = {
+static const Ttk_ElementSpec FocusElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FocusElement),
FocusElementOptions,
@@ -338,42 +375,51 @@ typedef struct {
Tcl_Obj *borderObj;
} SeparatorElement;
-static Ttk_ElementOptionSpec SeparatorElementOptions[] = {
+static const Ttk_ElementOptionSpec SeparatorElementOptions[] = {
{ "-orient", TK_OPTION_ANY,
- Tk_Offset(SeparatorElement, orientObj), "horizontal" },
+ offsetof(SeparatorElement, orientObj), "horizontal" },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(SeparatorElement,borderObj), DEFAULT_BACKGROUND },
- { NULL, 0, 0, NULL }
+ offsetof(SeparatorElement,borderObj), DEFAULT_BACKGROUND },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void SeparatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)paddingPtr;
+
*widthPtr = *heightPtr = 2;
}
static void HorizontalSeparatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- SeparatorElement *separator = elementRecord;
+ SeparatorElement *separator = (SeparatorElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, separator->borderObj);
GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC);
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
+ (void)dummy;
+ (void)state;
XDrawLine(Tk_Display(tkwin), d, darkGC, b.x, b.y, b.x + b.width, b.y);
XDrawLine(Tk_Display(tkwin), d, lightGC, b.x, b.y+1, b.x + b.width, b.y+1);
}
static void VerticalSeparatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- SeparatorElement *separator = elementRecord;
+ SeparatorElement *separator = (SeparatorElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, separator->borderObj);
GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC);
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
+ (void)dummy;
+ (void)state;
XDrawLine(Tk_Display(tkwin), d, darkGC, b.x, b.y, b.x, b.y + b.height);
XDrawLine(Tk_Display(tkwin), d, lightGC, b.x+1, b.y, b.x+1, b.y+b.height);
@@ -383,9 +429,10 @@ static void GeneralSeparatorElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- SeparatorElement *separator = elementRecord;
- int orient;
- Ttk_GetOrientFromObj(NULL, separator->orientObj, &orient);
+ SeparatorElement *separator = (SeparatorElement *)elementRecord;
+ Ttk_Orient orient;
+
+ TtkGetOrientFromObj(NULL, separator->orientObj, &orient);
switch (orient) {
case TTK_ORIENT_HORIZONTAL:
HorizontalSeparatorElementDraw(
@@ -398,7 +445,7 @@ static void GeneralSeparatorElementDraw(
}
}
-static Ttk_ElementSpec HorizontalSeparatorElementSpec = {
+static const Ttk_ElementSpec HorizontalSeparatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SeparatorElement),
SeparatorElementOptions,
@@ -406,7 +453,7 @@ static Ttk_ElementSpec HorizontalSeparatorElementSpec = {
HorizontalSeparatorElementDraw
};
-static Ttk_ElementSpec VerticalSeparatorElementSpec = {
+static const Ttk_ElementSpec VerticalSeparatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SeparatorElement),
SeparatorElementOptions,
@@ -414,7 +461,7 @@ static Ttk_ElementSpec VerticalSeparatorElementSpec = {
HorizontalSeparatorElementDraw
};
-static Ttk_ElementSpec SeparatorElementSpec = {
+static const Ttk_ElementSpec SeparatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SeparatorElement),
SeparatorElementOptions,
@@ -430,30 +477,37 @@ typedef struct {
Tcl_Obj *backgroundObj;
} SizegripElement;
-static Ttk_ElementOptionSpec SizegripOptions[] = {
+static const Ttk_ElementOptionSpec SizegripOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(SizegripElement,backgroundObj), DEFAULT_BACKGROUND },
- {0,0,0,0}
+ offsetof(SizegripElement,backgroundObj), DEFAULT_BACKGROUND },
+ {0,TK_OPTION_BOOLEAN,0,0}
};
static void SizegripSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
int gripCount = 3, gripSpace = 2, gripThickness = 3;
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)paddingPtr;
+
*widthPtr = *heightPtr = gripCount * (gripSpace + gripThickness);
}
static void SizegripDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- SizegripElement *grip = elementRecord;
+ SizegripElement *grip = (SizegripElement *)elementRecord;
int gripCount = 3, gripSpace = 2;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, grip->backgroundObj);
GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC);
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
int x1 = b.x + b.width-1, y1 = b.y + b.height-1, x2 = x1, y2 = y1;
+ (void)dummy;
+ (void)state;
while (gripCount--) {
x1 -= gripSpace; y2 -= gripSpace;
@@ -463,7 +517,7 @@ static void SizegripDraw(
}
}
-static Ttk_ElementSpec SizegripElementSpec = {
+static const Ttk_ElementSpec SizegripElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SizegripElement),
SizegripOptions,
@@ -491,32 +545,35 @@ typedef struct {
Tcl_Obj *borderWidthObj;
} IndicatorElement;
-static Ttk_ElementOptionSpec IndicatorElementOptions[] = {
+static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
{ "-indicatorcolor", TK_OPTION_BORDER,
- Tk_Offset(IndicatorElement,colorObj), DEFAULT_BACKGROUND },
+ offsetof(IndicatorElement,colorObj), DEFAULT_BACKGROUND },
{ "-indicatorrelief", TK_OPTION_RELIEF,
- Tk_Offset(IndicatorElement,reliefObj), "raised" },
+ offsetof(IndicatorElement,reliefObj), "raised" },
{ "-indicatordiameter", TK_OPTION_PIXELS,
- Tk_Offset(IndicatorElement,diameterObj), "12" },
+ offsetof(IndicatorElement,diameterObj), "12" },
{ "-indicatormargin", TK_OPTION_STRING,
- Tk_Offset(IndicatorElement,marginObj), "0 2 4 2" },
+ offsetof(IndicatorElement,marginObj), "0 2 4 2" },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(IndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
- { NULL, 0, 0, NULL }
+ offsetof(IndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
/*
* Checkbutton indicators (default): 3-D square.
*/
static void SquareIndicatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- IndicatorElement *indicator = elementRecord;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
int diameter = 0;
+ (void)dummy;
+ (void)paddingPtr;
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
*widthPtr = diameter + Ttk_PaddingWidth(margins);
@@ -524,15 +581,17 @@ static void SquareIndicatorElementSize(
}
static void SquareIndicatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- IndicatorElement *indicator = elementRecord;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Tk_3DBorder border = 0, interior = 0;
int relief = TK_RELIEF_RAISED;
Ttk_Padding padding;
int borderWidth = 2;
int diameter;
+ (void)dummy;
+ (void)state;
interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj);
border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj);
@@ -553,12 +612,15 @@ static void SquareIndicatorElementDraw(
* Radiobutton indicators: 3-D diamond.
*/
static void DiamondIndicatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- IndicatorElement *indicator = elementRecord;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
int diameter = 0;
+ (void)dummy;
+ (void)paddingPtr;
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
*widthPtr = diameter + 3 + Ttk_PaddingWidth(margins);
@@ -566,16 +628,18 @@ static void DiamondIndicatorElementSize(
}
static void DiamondIndicatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- IndicatorElement *indicator = elementRecord;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Tk_3DBorder border = 0, interior = 0;
int borderWidth = 2;
int relief = TK_RELIEF_RAISED;
int diameter, radius;
XPoint points[4];
Ttk_Padding padding;
+ (void)dummy;
+ (void)state;
interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj);
border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj);
@@ -601,7 +665,7 @@ static void DiamondIndicatorElementDraw(
Tk_Draw3DPolygon(tkwin,d,border,points,4,borderWidth,relief);
}
-static Ttk_ElementSpec CheckbuttonIndicatorElementSpec = {
+static const Ttk_ElementSpec CheckbuttonIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(IndicatorElement),
IndicatorElementOptions,
@@ -609,7 +673,7 @@ static Ttk_ElementSpec CheckbuttonIndicatorElementSpec = {
SquareIndicatorElementDraw
};
-static Ttk_ElementSpec RadiobuttonIndicatorElementSpec = {
+static const Ttk_ElementSpec RadiobuttonIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(IndicatorElement),
IndicatorElementOptions,
@@ -637,28 +701,31 @@ typedef struct {
Tcl_Obj *marginObj;
} MenuIndicatorElement;
-static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
+static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(MenuIndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(MenuIndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
{ "-indicatorwidth", TK_OPTION_PIXELS,
- Tk_Offset(MenuIndicatorElement,widthObj), "4.0m" },
+ offsetof(MenuIndicatorElement,widthObj), "4.0m" },
{ "-indicatorheight", TK_OPTION_PIXELS,
- Tk_Offset(MenuIndicatorElement,heightObj), "1.7m" },
+ offsetof(MenuIndicatorElement,heightObj), "1.7m" },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(MenuIndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ offsetof(MenuIndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
{ "-indicatorrelief", TK_OPTION_RELIEF,
- Tk_Offset(MenuIndicatorElement,reliefObj),"raised" },
+ offsetof(MenuIndicatorElement,reliefObj),"raised" },
{ "-indicatormargin", TK_OPTION_STRING,
- Tk_Offset(MenuIndicatorElement,marginObj), "5 0" },
- { NULL, 0, 0, NULL }
+ offsetof(MenuIndicatorElement,marginObj), "5 0" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void MenuIndicatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- MenuIndicatorElement *mi = elementRecord;
+ MenuIndicatorElement *mi = (MenuIndicatorElement *)elementRecord;
Ttk_Padding margins;
+ (void)dummy;
+ (void)paddingPtr;
+
Tk_GetPixelsFromObj(NULL, tkwin, mi->widthObj, widthPtr);
Tk_GetPixelsFromObj(NULL, tkwin, mi->heightObj, heightPtr);
Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj, &margins);
@@ -667,13 +734,15 @@ static void MenuIndicatorElementSize(
}
static void MenuIndicatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- MenuIndicatorElement *mi = elementRecord;
+ MenuIndicatorElement *mi = (MenuIndicatorElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, mi->backgroundObj);
Ttk_Padding margins;
int borderWidth = 2;
+ (void)dummy;
+ (void)state;
Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj,&margins);
b = Ttk_PadBox(b, margins);
@@ -682,7 +751,7 @@ static void MenuIndicatorElementDraw(
borderWidth, TK_RELIEF_RAISED);
}
-static Ttk_ElementSpec MenuIndicatorElementSpec = {
+static const Ttk_ElementSpec MenuIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(MenuIndicatorElement),
MenuIndicatorElementOptions,
@@ -697,7 +766,6 @@ static Ttk_ElementSpec MenuIndicatorElementSpec = {
* clientData is an enum ArrowDirection pointer.
*/
-static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
typedef struct {
Tcl_Obj *borderObj;
Tcl_Obj *borderWidthObj;
@@ -706,29 +774,30 @@ typedef struct {
Tcl_Obj *colorObj;
} ArrowElement;
-static Ttk_ElementOptionSpec ArrowElementOptions[] = {
+static const Ttk_ElementOptionSpec ArrowElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ArrowElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(ArrowElement,borderObj), DEFAULT_BACKGROUND },
{ "-relief",TK_OPTION_RELIEF,
- Tk_Offset(ArrowElement,reliefObj),"raised"},
+ offsetof(ArrowElement,reliefObj),"raised"},
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(ArrowElement,borderWidthObj), "1" },
+ offsetof(ArrowElement,borderWidthObj), "1" },
{ "-arrowcolor",TK_OPTION_COLOR,
- Tk_Offset(ArrowElement,colorObj),"black"},
+ offsetof(ArrowElement,colorObj),"black"},
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(ArrowElement,sizeObj), "14" },
- { NULL, 0, 0, NULL }
+ offsetof(ArrowElement,sizeObj), "14" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
-static Ttk_Padding ArrowMargins = { 3,3,3,3 };
+static const Ttk_Padding ArrowMargins = { 3,3,3,3 };
static void ArrowElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ArrowElement *arrow = elementRecord;
- int direction = *(int *)clientData;
+ ArrowElement *arrow = (ArrowElement *)elementRecord;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
int width = 14;
+ (void)paddingPtr;
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &width);
width -= Ttk_PaddingWidth(ArrowMargins);
@@ -741,23 +810,24 @@ static void ArrowElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- int direction = *(int *)clientData;
- ArrowElement *arrow = elementRecord;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ ArrowElement *arrow = (ArrowElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
int relief = TK_RELIEF_RAISED;
int borderWidth = 1;
+ (void)state;
Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief);
- Tk_Fill3DRectangle(
- tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, relief);
+ Tk_Fill3DRectangle( tkwin, d, border, b.x, b.y, b.width, b.height,
+ borderWidth, relief);
TtkFillArrow(Tk_Display(tkwin), d, Tk_GCForColor(arrowColor, d),
- Ttk_PadBox(b, ArrowMargins), direction);
+ Ttk_PadBox(b, ArrowMargins), direction);
}
-static Ttk_ElementSpec ArrowElementSpec = {
+static const Ttk_ElementSpec ArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ArrowElement),
ArrowElementOptions,
@@ -777,34 +847,39 @@ typedef struct {
Tcl_Obj *reliefObj;
} TroughElement;
-static Ttk_ElementOptionSpec TroughElementOptions[] = {
+static const Ttk_ElementOptionSpec TroughElementOptions[] = {
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(TroughElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ offsetof(TroughElement,borderWidthObj), DEFAULT_BORDERWIDTH },
{ "-troughcolor", TK_OPTION_BORDER,
- Tk_Offset(TroughElement,colorObj), DEFAULT_BACKGROUND },
+ offsetof(TroughElement,colorObj), DEFAULT_BACKGROUND },
{ "-troughrelief",TK_OPTION_RELIEF,
- Tk_Offset(TroughElement,reliefObj), "sunken" },
- { NULL, 0, 0, NULL }
+ offsetof(TroughElement,reliefObj), "sunken" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void TroughElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TroughElement *troughPtr = elementRecord;
+ TroughElement *troughPtr = (TroughElement *)elementRecord;
int borderWidth = 2;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
static void TroughElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- TroughElement *troughPtr = elementRecord;
+ TroughElement *troughPtr = (TroughElement *)elementRecord;
Tk_3DBorder border = NULL;
int borderWidth = 2, relief = TK_RELIEF_SUNKEN;
+ (void)dummy;
+ (void)state;
border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief);
@@ -814,7 +889,7 @@ static void TroughElementDraw(
borderWidth, relief);
}
-static Ttk_ElementSpec TroughElementSpec = {
+static const Ttk_ElementSpec TroughElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TroughElement),
TroughElementOptions,
@@ -837,29 +912,32 @@ typedef struct {
Tcl_Obj *borderWidthObj;
} ThumbElement;
-static Ttk_ElementOptionSpec ThumbElementOptions[] = {
+static const Ttk_ElementOptionSpec ThumbElementOptions[] = {
{ "-orient", TK_OPTION_ANY,
- Tk_Offset(ThumbElement, orientObj), "horizontal" },
+ offsetof(ThumbElement, orientObj), "horizontal" },
{ "-width", TK_OPTION_PIXELS,
- Tk_Offset(ThumbElement,thicknessObj), DEFAULT_ARROW_SIZE },
+ offsetof(ThumbElement,thicknessObj), DEFAULT_ARROW_SIZE },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(ThumbElement,reliefObj), "raised" },
+ offsetof(ThumbElement,reliefObj), "raised" },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ThumbElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(ThumbElement,borderObj), DEFAULT_BACKGROUND },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(ThumbElement,borderWidthObj), DEFAULT_BORDERWIDTH },
- { NULL, 0, 0, NULL }
+ offsetof(ThumbElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void ThumbElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ThumbElement *thumb = elementRecord;
- int orient, thickness;
+ ThumbElement *thumb = (ThumbElement *)elementRecord;
+ Ttk_Orient orient;
+ int thickness;
+ (void)dummy;
+ (void)paddingPtr;
Tk_GetPixelsFromObj(NULL, tkwin, thumb->thicknessObj, &thickness);
- Ttk_GetOrientFromObj(NULL, thumb->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, thumb->orientObj, &orient);
if (orient == TTK_ORIENT_VERTICAL) {
*widthPtr = thickness;
@@ -871,12 +949,14 @@ static void ThumbElementSize(
}
static void ThumbElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ThumbElement *thumb = elementRecord;
+ ThumbElement *thumb = (ThumbElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, thumb->borderObj);
int borderWidth = 2, relief = TK_RELIEF_RAISED;
+ (void)dummy;
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, thumb->borderWidthObj, &borderWidth);
Tk_GetReliefFromObj(NULL, thumb->reliefObj, &relief);
@@ -884,7 +964,7 @@ static void ThumbElementDraw(
borderWidth, relief);
}
-static Ttk_ElementSpec ThumbElementSpec = {
+static const Ttk_ElementSpec ThumbElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ThumbElement),
ThumbElementOptions,
@@ -908,30 +988,33 @@ typedef struct {
Tcl_Obj *borderWidthObj; /* the size of the border */
} SliderElement;
-static Ttk_ElementOptionSpec SliderElementOptions[] = {
- { "-sliderlength", TK_OPTION_PIXELS, Tk_Offset(SliderElement,lengthObj),
+static const Ttk_ElementOptionSpec SliderElementOptions[] = {
+ { "-sliderlength", TK_OPTION_PIXELS, offsetof(SliderElement,lengthObj),
"30" },
- { "-sliderthickness",TK_OPTION_PIXELS,Tk_Offset(SliderElement,thicknessObj),
+ { "-sliderthickness",TK_OPTION_PIXELS, offsetof(SliderElement,thicknessObj),
"15" },
- { "-sliderrelief", TK_OPTION_RELIEF, Tk_Offset(SliderElement,reliefObj),
+ { "-sliderrelief", TK_OPTION_RELIEF, offsetof(SliderElement,reliefObj),
"raised" },
- { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(SliderElement,borderWidthObj),
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(SliderElement,borderWidthObj),
DEFAULT_BORDERWIDTH },
- { "-background", TK_OPTION_BORDER, Tk_Offset(SliderElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(SliderElement,borderObj),
DEFAULT_BACKGROUND },
- { "-orient", TK_OPTION_ANY, Tk_Offset(SliderElement,orientObj),
+ { "-orient", TK_OPTION_ANY, offsetof(SliderElement,orientObj),
"horizontal" },
- { NULL, 0, 0, NULL }
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void SliderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- SliderElement *slider = elementRecord;
- int orient, length, thickness;
+ SliderElement *slider = (SliderElement *)elementRecord;
+ Ttk_Orient orient;
+ int length, thickness;
+ (void)dummy;
+ (void)paddingPtr;
- Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, slider->lengthObj, &length);
Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness);
@@ -949,15 +1032,18 @@ static void SliderElementSize(
}
static void SliderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- SliderElement *slider = elementRecord;
+ SliderElement *slider = (SliderElement *)elementRecord;
Tk_3DBorder border = NULL;
- int relief = TK_RELIEF_RAISED, borderWidth = 2, orient;
+ int relief = TK_RELIEF_RAISED, borderWidth = 2;
+ Ttk_Orient orient;
+ (void)dummy;
+ (void)state;
border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj);
- Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief);
@@ -990,7 +1076,7 @@ static void SliderElementDraw(
}
}
-static Ttk_ElementSpec SliderElementSpec = {
+static const Ttk_ElementSpec SliderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SliderElement),
SliderElementOptions,
@@ -1019,30 +1105,33 @@ typedef struct {
Tcl_Obj *borderWidthObj; /* thickness of the border */
} PbarElement;
-static Ttk_ElementOptionSpec PbarElementOptions[] = {
- { "-orient", TK_OPTION_ANY, Tk_Offset(PbarElement,orientObj),
+static const Ttk_ElementOptionSpec PbarElementOptions[] = {
+ { "-orient", TK_OPTION_ANY, offsetof(PbarElement,orientObj),
"horizontal" },
- { "-thickness", TK_OPTION_PIXELS, Tk_Offset(PbarElement,thicknessObj),
+ { "-thickness", TK_OPTION_PIXELS, offsetof(PbarElement,thicknessObj),
DEFAULT_PBAR_THICKNESS },
- { "-barsize", TK_OPTION_PIXELS, Tk_Offset(PbarElement,lengthObj),
+ { "-barsize", TK_OPTION_PIXELS, offsetof(PbarElement,lengthObj),
DEFAULT_PBAR_LENGTH },
- { "-pbarrelief", TK_OPTION_RELIEF, Tk_Offset(PbarElement,reliefObj),
+ { "-pbarrelief", TK_OPTION_RELIEF, offsetof(PbarElement,reliefObj),
"raised" },
- { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(PbarElement,borderWidthObj),
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(PbarElement,borderWidthObj),
DEFAULT_BORDERWIDTH },
- { "-background", TK_OPTION_BORDER, Tk_Offset(PbarElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(PbarElement,borderObj),
DEFAULT_BACKGROUND },
- { NULL, 0, 0, NULL }
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void PbarElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- PbarElement *pbar = elementRecord;
- int orient, thickness = 15, length = 30, borderWidth = 2;
+ PbarElement *pbar = (PbarElement *)elementRecord;
+ Ttk_Orient orient;
+ int thickness = 15, length = 30, borderWidth = 2;
+ (void)dummy;
+ (void)paddingPtr;
- Ttk_GetOrientFromObj(NULL, pbar->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, pbar->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, pbar->thicknessObj, &thickness);
Tk_GetPixelsFromObj(NULL, tkwin, pbar->lengthObj, &length);
Tk_GetPixelsFromObj(NULL, tkwin, pbar->borderWidthObj, &borderWidth);
@@ -1060,12 +1149,14 @@ static void PbarElementSize(
}
static void PbarElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- PbarElement *pbar = elementRecord;
+ PbarElement *pbar = (PbarElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, pbar->borderObj);
int relief = TK_RELIEF_RAISED, borderWidth = 2;
+ (void)dummy;
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, pbar->borderWidthObj, &borderWidth);
Tk_GetReliefFromObj(NULL, pbar->reliefObj, &relief);
@@ -1075,7 +1166,7 @@ static void PbarElementDraw(
borderWidth, relief);
}
-static Ttk_ElementSpec PbarElementSpec = {
+static const Ttk_ElementSpec PbarElementSpec = {
TK_STYLE_VERSION_2,
sizeof(PbarElement),
PbarElementOptions,
@@ -1092,35 +1183,40 @@ typedef struct {
Tcl_Obj *backgroundObj;
} TabElement;
-static Ttk_ElementOptionSpec TabElementOptions[] = {
+static const Ttk_ElementOptionSpec TabElementOptions[] = {
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(TabElement,borderWidthObj),"1" },
+ offsetof(TabElement,borderWidthObj),"1" },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(TabElement,backgroundObj), DEFAULT_BACKGROUND },
- {0,0,0,0}
+ offsetof(TabElement,backgroundObj), DEFAULT_BACKGROUND },
+ {0,TK_OPTION_BOOLEAN,0,0}
};
static void TabElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TabElement *tab = elementRecord;
+ TabElement *tab = (TabElement *)elementRecord;
int borderWidth = 1;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
+
Tk_GetPixelsFromObj(0, tkwin, tab->borderWidthObj, &borderWidth);
paddingPtr->top = paddingPtr->left = paddingPtr->right = borderWidth;
paddingPtr->bottom = 0;
}
static void TabElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- TabElement *tab = elementRecord;
+ TabElement *tab = (TabElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj);
int borderWidth = 1;
int cut = 2;
XPoint pts[6];
int n = 0;
+ (void)dummy;
Tcl_GetIntFromObj(NULL, tab->borderWidthObj, &borderWidth);
@@ -1163,7 +1259,7 @@ static void TabElementDraw(
}
-static Ttk_ElementSpec TabElementSpec = {
+static const Ttk_ElementSpec TabElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TabElement),
TabElementOptions,
@@ -1179,12 +1275,14 @@ typedef TabElement ClientElement;
#define ClientElementOptions TabElementOptions
static void ClientElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ClientElement *ce = elementRecord;
+ ClientElement *ce = (ClientElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, ce->backgroundObj);
int borderWidth = 1;
+ (void)dummy;
+ (void)state;
Tcl_GetIntFromObj(NULL, ce->borderWidthObj, &borderWidth);
@@ -1193,16 +1291,20 @@ static void ClientElementDraw(
}
static void ClientElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ClientElement *ce = elementRecord;
+ ClientElement *ce = (ClientElement *)elementRecord;
int borderWidth = 1;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
+
Tk_GetPixelsFromObj(0, tkwin, ce->borderWidthObj, &borderWidth);
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
-static Ttk_ElementSpec ClientElementSpec = {
+static const Ttk_ElementSpec ClientElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ClientElement),
ClientElementOptions,
@@ -1243,15 +1345,15 @@ void TtkElements_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "indicator", &ttkNullElementSpec,NULL);
Ttk_RegisterElement(interp, theme, "uparrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "downarrow",
- &ArrowElementSpec, &ArrowElements[1]);
+ &ArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "leftarrow",
- &ArrowElementSpec, &ArrowElements[2]);
+ &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp, theme, "rightarrow",
- &ArrowElementSpec, &ArrowElements[3]);
+ &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
Ttk_RegisterElement(interp, theme, "arrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "trough", &TroughElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "thumb", &ThumbElementSpec, NULL);
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index 49b6553..fe7f6ff 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -154,55 +154,55 @@ typedef struct {
#define DEF_ENTRY_FONT "TkTextFont"
#define DEF_LIST_HEIGHT "10"
-static Tk_OptionSpec EntryOptionSpecs[] = {
+static const Tk_OptionSpec EntryOptionSpecs[] = {
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", "1", -1, Tk_Offset(Entry, entry.exportSelection),
+ "ExportSelection", "1", TCL_INDEX_NONE, offsetof(Entry, entry.exportSelection),
0,0,0 },
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_ENTRY_FONT, Tk_Offset(Entry, entry.fontObj),-1,
+ DEF_ENTRY_FONT, offsetof(Entry, entry.fontObj),TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand",
- NULL, -1, Tk_Offset(Entry, entry.invalidCmd),
+ NULL, TCL_INDEX_NONE, offsetof(Entry, entry.invalidCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- "left", -1, Tk_Offset(Entry, entry.justify),
+ "left", TCL_INDEX_NONE, offsetof(Entry, entry.justify),
0, 0, GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-placeholder", "placeHolder", "PlaceHolder",
- NULL, Tk_Offset(Entry, entry.placeholderObj), -1,
+ NULL, offsetof(Entry, entry.placeholderObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-show", "show", "Show",
- NULL, -1, Tk_Offset(Entry, entry.showChar),
+ NULL, TCL_INDEX_NONE, offsetof(Entry, entry.showChar),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-state", "state", "State",
- "normal", Tk_Offset(Entry, entry.stateObj), -1,
+ "normal", offsetof(Entry, entry.stateObj), TCL_INDEX_NONE,
0,0,STATE_CHANGED},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- NULL, Tk_Offset(Entry, entry.textVariableObj), -1,
+ NULL, offsetof(Entry, entry.textVariableObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,TEXTVAR_CHANGED},
{TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate",
- "none", -1, Tk_Offset(Entry, entry.validate),
+ "none", TCL_INDEX_NONE, offsetof(Entry, entry.validate),
0, (ClientData) validateStrings, 0},
{TK_OPTION_STRING, "-validatecommand", "validateCommand", "ValidateCommand",
- NULL, -1, Tk_Offset(Entry, entry.validateCmd),
+ NULL, TCL_INDEX_NONE, offsetof(Entry, entry.validateCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_ENTRY_WIDTH, Tk_Offset(Entry, entry.widthObj), -1,
+ DEF_ENTRY_WIDTH, offsetof(Entry, entry.widthObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- NULL, -1, Tk_Offset(Entry, entry.xscroll.scrollCmd),
+ NULL, TCL_INDEX_NONE, offsetof(Entry, entry.xscroll.scrollCmd),
TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},
/* EntryStyleData options:
*/
{TK_OPTION_COLOR, "-background", "windowColor", "WindowColor",
- NULL, Tk_Offset(Entry, entry.styleData.backgroundObj), -1,
+ NULL, offsetof(Entry, entry.styleData.backgroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0},
{TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
- NULL, Tk_Offset(Entry, entry.styleData.foregroundObj), -1,
+ NULL, offsetof(Entry, entry.styleData.foregroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0},
{TK_OPTION_COLOR, "-placeholderforeground", "placeholderForeground",
"PlaceholderForeground", NULL,
- Tk_Offset(Entry, entry.styleData.placeholderForegroundObj), -1,
+ offsetof(Entry, entry.styleData.placeholderForegroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0},
WIDGET_TAKEFOCUS_TRUE,
@@ -298,7 +298,7 @@ static char *EntryDisplayString(const char *showChar, int numChars)
TkUtfToUniChar(showChar, &ch);
size = TkUniCharToUtf(ch, buf);
- p = displayString = ckalloc(numChars * size + 1);
+ p = displayString = (char *)ckalloc(numChars * size + 1);
while (numChars--) {
memcpy(p, buf, size);
@@ -315,7 +315,7 @@ static char *EntryDisplayString(const char *showChar, int numChars)
*/
static void EntryUpdateTextLayout(Entry *entryPtr)
{
- size_t length;
+ TkSizeT length;
char *text;
Tk_FreeTextLayout(entryPtr->entry.textLayout);
if ((entryPtr->entry.numChars != 0) || (entryPtr->entry.placeholderObj == NULL)) {
@@ -354,7 +354,7 @@ static int
EntryFetchSelection(
ClientData clientData, int offset, char *buffer, int maxBytes)
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
int byteCount;
const char *string;
const char *selStart, *selEnd;
@@ -387,7 +387,7 @@ EntryFetchSelection(
*/
static void EntryLostSelection(ClientData clientData)
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
entryPtr->core.flags &= ~GOT_SELECTION;
entryPtr->entry.selectFirst = entryPtr->entry.selectLast = -1;
TtkRedisplayWidget(&entryPtr->core);
@@ -419,8 +419,8 @@ static void EntryOwnSelection(Entry *entryPtr)
static void
ExpandPercents(
Entry *entryPtr, /* Entry that needs validation. */
- const char *template, /* Script template */
- const char *new, /* Potential new value of entry string */
+ const char *templ, /* Script template */
+ const char *newValue, /* Potential new value of entry string */
int index, /* index of insert/delete */
int count, /* #changed characters */
VREASON reason, /* Reason for change */
@@ -433,28 +433,28 @@ ExpandPercents(
int ch;
char numStorage[2*TCL_INTEGER_SPACE];
- while (*template) {
+ while (*templ) {
/* Find everything up to the next % character and append it
* to the result string.
*/
- string = Tcl_UtfFindFirst(template, '%');
+ string = Tcl_UtfFindFirst(templ, '%');
if (string == NULL) {
/* No more %-sequences to expand.
* Copy the rest of the template.
*/
- Tcl_DStringAppend(dsPtr, template, -1);
+ Tcl_DStringAppend(dsPtr, templ, -1);
return;
}
- if (string != template) {
- Tcl_DStringAppend(dsPtr, template, string - template);
- template = string;
+ if (string != templ) {
+ Tcl_DStringAppend(dsPtr, templ, string - templ);
+ templ = string;
}
/* There's a percent sequence here. Process it.
*/
- ++template; /* skip over % */
- if (*template != '\0') {
- template += TkUtfToUniChar(template, &ch);
+ ++templ; /* skip over % */
+ if (*templ != '\0') {
+ templ += TkUtfToUniChar(templ, &ch);
} else {
ch = '%';
}
@@ -477,14 +477,14 @@ ExpandPercents(
string = numStorage;
break;
case 'P': /* 'Peeked' new value of the string */
- string = new;
+ string = newValue;
break;
case 's': /* Current string value */
string = entryPtr->entry.string;
break;
case 'S': /* string to be inserted/deleted, if any */
if (reason == VALIDATE_INSERT) {
- string = Tcl_UtfAtIndex(new, index);
+ string = Tcl_UtfAtIndex(newValue, index);
stringLength = Tcl_UtfAtIndex(string, count) - string;
} else if (reason == VALIDATE_DELETE) {
string = Tcl_UtfAtIndex(entryPtr->entry.string, index);
@@ -528,9 +528,9 @@ ExpandPercents(
static int RunValidationScript(
Tcl_Interp *interp, /* Interpreter to use */
Entry *entryPtr, /* Entry being validated */
- const char *template, /* Script template */
+ const char *templ, /* Script template */
const char *optionName, /* "-validatecommand", "-invalidcommand" */
- const char *new, /* Potential new value of entry string */
+ const char *newValue, /* Potential new value of entry string */
int index, /* index of insert/delete */
int count, /* #changed characters */
VREASON reason) /* Reason for change */
@@ -539,7 +539,7 @@ static int RunValidationScript(
int code;
Tcl_DStringInit(&script);
- ExpandPercents(entryPtr, template, new, index, count, reason, &script);
+ ExpandPercents(entryPtr, templ, newValue, index, count, reason, &script);
code = Tcl_EvalEx(interp,
Tcl_DStringValue(&script), Tcl_DStringLength(&script),
TCL_EVAL_GLOBAL);
@@ -656,10 +656,11 @@ done:
* Returns:
* TCL_OK if valid, TCL_BREAK if invalid, TCL_ERROR on error.
*/
-static int EntryRevalidate(Tcl_Interp *interp, Entry *entryPtr, VREASON reason)
+static int EntryRevalidate(Tcl_Interp *dummy, Entry *entryPtr, VREASON reason)
{
int code = EntryValidateChange(
entryPtr, entryPtr->entry.string, -1,0, reason);
+ (void)dummy;
if (code == TCL_BREAK) {
TtkWidgetChangeState(&entryPtr->core, TTK_STATE_INVALID, 0);
@@ -676,8 +677,12 @@ static int EntryRevalidate(Tcl_Interp *interp, Entry *entryPtr, VREASON reason)
static void EntryRevalidateBG(Entry *entryPtr, VREASON reason)
{
Tcl_Interp *interp = entryPtr->core.interp;
- if (EntryRevalidate(interp, entryPtr, reason) == TCL_ERROR) {
- Tcl_BackgroundException(interp, TCL_ERROR);
+ VMODE vmode = entryPtr->entry.validate;
+
+ if (EntryNeedsValidation(vmode, reason)) {
+ if (EntryRevalidate(interp, entryPtr, reason) == TCL_ERROR) {
+ Tcl_BackgroundException(interp, TCL_ERROR);
+ }
}
}
@@ -747,7 +752,7 @@ EntryStoreValue(Entry *entryPtr, const char *value)
/* Store new value:
*/
- entryPtr->entry.string = ckalloc(numBytes + 1);
+ entryPtr->entry.string = (char *)ckalloc(numBytes + 1);
strcpy(entryPtr->entry.string, value);
entryPtr->entry.numBytes = numBytes;
entryPtr->entry.numChars = numChars;
@@ -804,7 +809,7 @@ static int EntrySetValue(Entry *entryPtr, const char *value)
*/
static void EntryTextVariableTrace(void *recordPtr, const char *value)
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (WidgetDestroyed(&entryPtr->core)) {
return;
@@ -838,29 +843,29 @@ InsertChars(
size_t byteCount = strlen(value);
int charsAdded = Tcl_NumUtfChars(value, byteCount);
size_t newByteCount = entryPtr->entry.numBytes + byteCount + 1;
- char *new;
+ char *newBytes;
int code;
if (byteCount == 0) {
return TCL_OK;
}
- new = ckalloc(newByteCount);
- memcpy(new, string, byteIndex);
- strcpy(new + byteIndex, value);
- strcpy(new + byteIndex + byteCount, string + byteIndex);
+ newBytes = (char *)ckalloc(newByteCount);
+ memcpy(newBytes, string, byteIndex);
+ strcpy(newBytes + byteIndex, value);
+ strcpy(newBytes + byteIndex + byteCount, string + byteIndex);
code = EntryValidateChange(
- entryPtr, new, index, charsAdded, VALIDATE_INSERT);
+ entryPtr, newBytes, index, charsAdded, VALIDATE_INSERT);
if (code == TCL_OK) {
AdjustIndices(entryPtr, index, charsAdded);
- code = EntrySetValue(entryPtr, new);
+ code = EntrySetValue(entryPtr, newBytes);
} else if (code == TCL_BREAK) {
code = TCL_OK;
}
- ckfree(new);
+ ckfree(newBytes);
return code;
}
@@ -875,7 +880,7 @@ DeleteChars(
{
char *string = entryPtr->entry.string;
size_t byteIndex, byteCount, newByteCount;
- char *new;
+ char *newBytes;
int code;
if (index < 0) {
@@ -892,20 +897,20 @@ DeleteChars(
byteCount = Tcl_UtfAtIndex(string+byteIndex, count) - (string+byteIndex);
newByteCount = entryPtr->entry.numBytes + 1 - byteCount;
- new = ckalloc(newByteCount);
- memcpy(new, string, byteIndex);
- strcpy(new + byteIndex, string + byteIndex + byteCount);
+ newBytes = (char *)ckalloc(newByteCount);
+ memcpy(newBytes, string, byteIndex);
+ strcpy(newBytes + byteIndex, string + byteIndex + byteCount);
code = EntryValidateChange(
- entryPtr, new, index, count, VALIDATE_DELETE);
+ entryPtr, newBytes, index, count, VALIDATE_DELETE);
if (code == TCL_OK) {
AdjustIndices(entryPtr, index, -count);
- code = EntrySetValue(entryPtr, new);
+ code = EntrySetValue(entryPtr, newBytes);
} else if (code == TCL_BREAK) {
code = TCL_OK;
}
- ckfree(new);
+ ckfree(newBytes);
return code;
}
@@ -922,7 +927,7 @@ DeleteChars(
static void
EntryEventProc(ClientData clientData, XEvent *eventPtr)
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
Tcl_Preserve(clientData);
switch (eventPtr->type) {
@@ -945,9 +950,10 @@ EntryEventProc(ClientData clientData, XEvent *eventPtr)
*/
static void
-EntryInitialize(Tcl_Interp *interp, void *recordPtr)
+EntryInitialize(Tcl_Interp *dummy, void *recordPtr)
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
+ (void)dummy;
Tk_CreateEventHandler(
entryPtr->core.tkwin, EntryEventMask, EntryEventProc, entryPtr);
@@ -955,7 +961,7 @@ EntryInitialize(Tcl_Interp *interp, void *recordPtr)
EntryFetchSelection, (ClientData) entryPtr, XA_STRING);
TtkBlinkCursor(&entryPtr->core);
- entryPtr->entry.string = ckalloc(1);
+ entryPtr->entry.string = (char *)ckalloc(1);
*entryPtr->entry.string = '\0';
entryPtr->entry.displayString = entryPtr->entry.string;
entryPtr->entry.textVariableTrace = 0;
@@ -974,7 +980,7 @@ EntryInitialize(Tcl_Interp *interp, void *recordPtr)
static void
EntryCleanup(void *recordPtr)
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (entryPtr->entry.textVariableTrace)
Ttk_UntraceVariable(entryPtr->entry.textVariableTrace);
@@ -996,12 +1002,12 @@ EntryCleanup(void *recordPtr)
*/
static int EntryConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
Tcl_Obj *textVarName = entryPtr->entry.textVariableObj;
Ttk_TraceHandle *vt = 0;
if (mask & TEXTVAR_CHANGED) {
- if (textVarName && *Tcl_GetString(textVarName)) {
+ if (textVarName && *Tcl_GetString(textVarName) != '\0') {
vt = Ttk_TraceVariable(interp,
textVarName,EntryTextVariableTrace,entryPtr);
if (!vt) return TCL_ERROR;
@@ -1060,10 +1066,11 @@ static int EntryConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
/* EntryPostConfigure --
* Post-configuration hook for entry widgets.
*/
-static int EntryPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
+static int EntryPostConfigure(Tcl_Interp *dummy, void *recordPtr, int mask)
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
int status = TCL_OK;
+ (void)dummy;
if ((mask & TEXTVAR_CHANGED) && entryPtr->entry.textVariableTrace != NULL) {
status = Ttk_FireTrace(entryPtr->entry.textVariableTrace);
@@ -1101,7 +1108,7 @@ EntryCharPosition(Entry *entryPtr, int index)
static void
EntryDoLayout(void *recordPtr)
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
WidgetCore *corePtr = &entryPtr->core;
Tk_TextLayout textLayout = entryPtr->entry.textLayout;
int leftIndex = entryPtr->entry.xscroll.first;
@@ -1188,7 +1195,7 @@ static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj, TkRegion clip)
*/
static void EntryDisplay(void *clientData, Drawable d)
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
Tk_Window tkwin = entryPtr->core.tkwin;
int leftIndex = entryPtr->entry.xscroll.first,
rightIndex = entryPtr->entry.xscroll.last + 1,
@@ -1362,12 +1369,20 @@ EntryIndex(
int *indexPtr) /* Return value */
{
# define EntryWidth(e) (Tk_Width(entryPtr->core.tkwin)) /* Not Right */
- size_t length;
- const char *string = TkGetStringFromObj(indexObj, &length);
+ TkSizeT length, idx;
+ const char *string;
+
+ if (TCL_OK == TkGetIntForIndex(indexObj, entryPtr->entry.numChars - 1, 1, &idx)) {
+ if (idx + 1 > (TkSizeT)entryPtr->entry.numChars + 1) {
+ idx = (TkSizeT)entryPtr->entry.numChars;
+ }
+ *indexPtr = (int)idx;
+ return TCL_OK;
+ }
+
+ string = TkGetStringFromObj(indexObj, &length);
- if (strncmp(string, "end", length) == 0) {
- *indexPtr = entryPtr->entry.numChars;
- } else if (strncmp(string, "insert", length) == 0) {
+ if (strncmp(string, "insert", length) == 0) {
*indexPtr = entryPtr->entry.insertPos;
} else if (strncmp(string, "left", length) == 0) { /* for debugging */
*indexPtr = entryPtr->entry.xscroll.first;
@@ -1403,6 +1418,7 @@ EntryIndex(
*indexPtr = Tk_PointToChar(entryPtr->entry.textLayout,
x - entryPtr->entry.layoutX, 0);
+ TtkUpdateScrollInfo(entryPtr->entry.xscrollHandle);
if (*indexPtr < entryPtr->entry.xscroll.first) {
*indexPtr = entryPtr->entry.xscroll.first;
}
@@ -1418,14 +1434,7 @@ EntryIndex(
*indexPtr += 1;
}
} else {
- if (Tcl_GetInt(interp, string, indexPtr) != TCL_OK) {
- goto badIndex;
- }
- if (*indexPtr < 0) {
- *indexPtr = 0;
- } else if (*indexPtr > entryPtr->entry.numChars) {
- *indexPtr = entryPtr->entry.numChars;
- }
+ goto badIndex;
}
return TCL_OK;
@@ -1443,7 +1452,7 @@ static int
EntryBBoxCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
Ttk_Box b;
int index;
@@ -1473,7 +1482,7 @@ static int
EntryDeleteCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
int first, last;
if ((objc < 3) || (objc > 4)) {
@@ -1502,7 +1511,7 @@ static int
EntryGetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
return TCL_ERROR;
@@ -1518,7 +1527,7 @@ static int
EntryICursorCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "pos");
return TCL_ERROR;
@@ -1538,7 +1547,7 @@ static int
EntryIndexCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
int index;
if (objc != 3) {
@@ -1548,7 +1557,7 @@ EntryIndexCommand(
if (EntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
return TCL_OK;
}
@@ -1560,7 +1569,7 @@ static int
EntryInsertCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
int index;
if (objc != 4) {
@@ -1582,7 +1591,7 @@ EntryInsertCommand(
static int EntrySelectionClearCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 3, objv, NULL);
@@ -1599,13 +1608,13 @@ static int EntrySelectionClearCommand(
static int EntrySelectionPresentCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 3, objv, NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(entryPtr->entry.selectFirst >= 0));
+ Tcl_NewWideIntObj(entryPtr->entry.selectFirst >= 0));
return TCL_OK;
}
@@ -1615,7 +1624,7 @@ static int EntrySelectionPresentCommand(
static int EntrySelectionRangeCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
int start, end;
if (objc != 5) {
Tcl_WrongNumArgs(interp, 3, objv, "start end");
@@ -1653,7 +1662,7 @@ static const Ttk_Ensemble EntrySelectionCommands[] = {
static int EntrySetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "value");
return TCL_ERROR;
@@ -1669,7 +1678,7 @@ static int EntrySetCommand(
static int EntryValidateCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
int code;
if (objc != 2) {
@@ -1682,7 +1691,7 @@ static int EntryValidateCommand(
if (code == TCL_ERROR)
return code;
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(code == TCL_OK));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(code == TCL_OK));
return TCL_OK;
}
@@ -1691,13 +1700,13 @@ static int EntryValidateCommand(
static int EntryXViewCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (objc == 3) {
int newFirst;
if (EntryIndex(interp, entryPtr, objv[2], &newFirst) != TCL_OK) {
return TCL_ERROR;
}
- TtkScrollTo(entryPtr->entry.xscrollHandle, newFirst);
+ TtkScrollTo(entryPtr->entry.xscrollHandle, newFirst, 1);
return TCL_OK;
}
return TtkScrollviewCommand(interp, objc, objv, entryPtr->entry.xscrollHandle);
@@ -1725,7 +1734,7 @@ static const Ttk_Ensemble EntryCommands[] = {
* +++ Entry widget definition.
*/
-static WidgetSpec EntryWidgetSpec = {
+static const WidgetSpec EntryWidgetSpec = {
"TEntry", /* className */
sizeof(Entry), /* recordSize */
EntryOptionSpecs, /* optionSpecs */
@@ -1757,15 +1766,15 @@ typedef struct {
ComboboxPart combobox;
} Combobox;
-static Tk_OptionSpec ComboboxOptionSpecs[] = {
+static const Tk_OptionSpec ComboboxOptionSpecs[] = {
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_LIST_HEIGHT, Tk_Offset(Combobox, combobox.heightObj), -1,
+ DEF_LIST_HEIGHT, offsetof(Combobox, combobox.heightObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-postcommand", "postCommand", "PostCommand",
- "", Tk_Offset(Combobox, combobox.postCommandObj), -1,
+ "", offsetof(Combobox, combobox.postCommandObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-values", "values", "Values",
- "", Tk_Offset(Combobox, combobox.valuesObj), -1,
+ "", offsetof(Combobox, combobox.valuesObj), TCL_INDEX_NONE,
0,0,0 },
WIDGET_INHERIT_OPTIONS(EntryOptionSpecs)
};
@@ -1776,7 +1785,7 @@ static Tk_OptionSpec ComboboxOptionSpecs[] = {
static void
ComboboxInitialize(Tcl_Interp *interp, void *recordPtr)
{
- Combobox *cb = recordPtr;
+ Combobox *cb = (Combobox *)recordPtr;
cb->combobox.currentIndex = -1;
TtkTrackElementState(&cb->core);
@@ -1789,7 +1798,7 @@ ComboboxInitialize(Tcl_Interp *interp, void *recordPtr)
static int
ComboboxConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Combobox *cbPtr = recordPtr;
+ Combobox *cbPtr = (Combobox *)recordPtr;
int unused;
/* Make sure -values is a valid list:
@@ -1809,7 +1818,7 @@ ComboboxConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
static int ComboboxCurrentCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Combobox *cbPtr = recordPtr;
+ Combobox *cbPtr = (Combobox *)recordPtr;
int currentIndex = cbPtr->combobox.currentIndex;
const char *currentValue = cbPtr->entry.string;
int nValues;
@@ -1838,22 +1847,29 @@ static int ComboboxCurrentCommand(
}
}
cbPtr->combobox.currentIndex = currentIndex;
- Tcl_SetObjResult(interp, Tcl_NewIntObj(currentIndex));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(currentIndex));
return TCL_OK;
} else if (objc == 3) {
- if (Tcl_GetIntFromObj(interp, objv[2], &currentIndex) != TCL_OK) {
- return TCL_ERROR;
- }
- if (currentIndex < 0 || currentIndex >= nValues) {
+ TkSizeT idx;
+
+ if (TCL_OK == TkGetIntForIndex(objv[2], nValues - 1, 0, &idx)) {
+ if (idx == TCL_INDEX_NONE || idx > (TkSizeT)nValues) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "index \"%s\" out of range", Tcl_GetString(objv[2])));
+ Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL);
+ return TCL_ERROR;
+ }
+ currentIndex = (int)idx;
+ } else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "Index %s out of range", Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL);
+ "Incorrect index %s", Tcl_GetString(objv[2])));
+ Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_VALUE", NULL);
return TCL_ERROR;
}
cbPtr->combobox.currentIndex = currentIndex;
- return EntrySetValue(recordPtr, Tcl_GetString(values[currentIndex]));
+ return EntrySetValue((Entry *)recordPtr, Tcl_GetString(values[currentIndex]));
} else {
Tcl_WrongNumArgs(interp, 2, objv, "?newIndex?");
return TCL_ERROR;
@@ -1884,7 +1900,7 @@ static const Ttk_Ensemble ComboboxCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec ComboboxWidgetSpec = {
+static const WidgetSpec ComboboxWidgetSpec = {
"TCombobox", /* className */
sizeof(Combobox), /* recordSize */
ComboboxOptionSpecs, /* optionSpecs */
@@ -1921,29 +1937,29 @@ typedef struct {
SpinboxPart spinbox;
} Spinbox;
-static Tk_OptionSpec SpinboxOptionSpecs[] = {
+static const Tk_OptionSpec SpinboxOptionSpecs[] = {
{TK_OPTION_STRING, "-values", "values", "Values",
- "", Tk_Offset(Spinbox, spinbox.valuesObj), -1,
+ "", offsetof(Spinbox, spinbox.valuesObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_DOUBLE, "-from", "from", "From",
- "0", Tk_Offset(Spinbox,spinbox.fromObj), -1,
+ "0", offsetof(Spinbox,spinbox.fromObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_DOUBLE, "-to", "to", "To",
- "0", Tk_Offset(Spinbox,spinbox.toObj), -1,
+ "0", offsetof(Spinbox,spinbox.toObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_DOUBLE, "-increment", "increment", "Increment",
- "1", Tk_Offset(Spinbox,spinbox.incrementObj), -1,
+ "1", offsetof(Spinbox,spinbox.incrementObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-format", "format", "Format",
- "", Tk_Offset(Spinbox, spinbox.formatObj), -1,
+ "", offsetof(Spinbox, spinbox.formatObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-command", "command", "Command",
- "", Tk_Offset(Spinbox, spinbox.commandObj), -1,
+ "", offsetof(Spinbox, spinbox.commandObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_BOOLEAN, "-wrap", "wrap", "Wrap",
- "0", Tk_Offset(Spinbox,spinbox.wrapObj), -1,
+ "0", offsetof(Spinbox,spinbox.wrapObj), TCL_INDEX_NONE,
0,0,0 },
WIDGET_INHERIT_OPTIONS(EntryOptionSpecs)
@@ -1955,7 +1971,7 @@ static Tk_OptionSpec SpinboxOptionSpecs[] = {
static void
SpinboxInitialize(Tcl_Interp *interp, void *recordPtr)
{
- Spinbox *sb = recordPtr;
+ Spinbox *sb = (Spinbox *)recordPtr;
TtkTrackElementState(&sb->core);
EntryInitialize(interp, recordPtr);
}
@@ -1966,7 +1982,7 @@ SpinboxInitialize(Tcl_Interp *interp, void *recordPtr)
static int
SpinboxConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Spinbox *sb = recordPtr;
+ Spinbox *sb = (Spinbox *)recordPtr;
int unused;
/* Make sure -values is a valid list:
@@ -1996,7 +2012,7 @@ static const Ttk_Ensemble SpinboxCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec SpinboxWidgetSpec = {
+static const WidgetSpec SpinboxWidgetSpec = {
"TSpinbox", /* className */
sizeof(Spinbox), /* recordSize */
SpinboxOptionSpecs, /* optionSpecs */
@@ -2023,23 +2039,25 @@ typedef struct {
Tcl_Obj *widthObj;
} TextareaElement;
-static Ttk_ElementOptionSpec TextareaElementOptions[] = {
+static const Ttk_ElementOptionSpec TextareaElementOptions[] = {
{ "-font", TK_OPTION_FONT,
- Tk_Offset(TextareaElement,fontObj), DEF_ENTRY_FONT },
+ offsetof(TextareaElement,fontObj), DEF_ENTRY_FONT },
{ "-width", TK_OPTION_INT,
- Tk_Offset(TextareaElement,widthObj), "20" },
- { NULL, 0, 0, NULL }
+ offsetof(TextareaElement,widthObj), "20" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void TextareaElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TextareaElement *textarea = elementRecord;
+ TextareaElement *textarea = (TextareaElement *)elementRecord;
Tk_Font font = Tk_GetFontFromObj(tkwin, textarea->fontObj);
int avgWidth = Tk_TextWidth(font, "0", 1);
Tk_FontMetrics fm;
int prefWidth = 1;
+ (void)dummy;
+ (void)paddingPtr;
Tk_GetFontMetrics(font, &fm);
Tcl_GetIntFromObj(NULL, textarea->widthObj, &prefWidth);
@@ -2050,7 +2068,7 @@ static void TextareaElementSize(
*widthPtr = prefWidth * avgWidth;
}
-static Ttk_ElementSpec TextareaElementSpec = {
+static const Ttk_ElementSpec TextareaElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TextareaElement),
TextareaElementOptions,
diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c
index 10106eb..7c43bce 100644
--- a/generic/ttk/ttkFrame.c
+++ b/generic/ttk/ttkFrame.c
@@ -26,21 +26,21 @@ typedef struct {
FramePart frame;
} Frame;
-static Tk_OptionSpec FrameOptionSpecs[] = {
+static const Tk_OptionSpec FrameOptionSpecs[] = {
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", NULL,
- Tk_Offset(Frame,frame.borderWidthObj), -1,
+ offsetof(Frame,frame.borderWidthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-padding", "padding", "Pad", NULL,
- Tk_Offset(Frame,frame.paddingObj), -1,
+ offsetof(Frame,frame.paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL,
- Tk_Offset(Frame,frame.reliefObj), -1,
+ offsetof(Frame,frame.reliefObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_PIXELS, "-width", "width", "Width", "0",
- Tk_Offset(Frame,frame.widthObj), -1,
+ offsetof(Frame,frame.widthObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_PIXELS, "-height", "height", "Height", "0",
- Tk_Offset(Frame,frame.heightObj), -1,
+ offsetof(Frame,frame.heightObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
WIDGET_TAKEFOCUS_FALSE,
@@ -90,7 +90,10 @@ static Ttk_Padding FrameMargins(Frame *framePtr)
*/
static int FrameSize(void *recordPtr, int *widthPtr, int *heightPtr)
{
- Frame *framePtr = recordPtr;
+ Frame *framePtr = (Frame *)recordPtr;
+ (void)widthPtr;
+ (void)heightPtr;
+
Ttk_SetMargins(framePtr->core.tkwin, FrameMargins(framePtr));
return 0;
}
@@ -111,7 +114,7 @@ static int FrameSize(void *recordPtr, int *widthPtr, int *heightPtr)
static int FrameConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Frame *framePtr = recordPtr;
+ Frame *framePtr = (Frame *)recordPtr;
int width, height;
/*
@@ -145,7 +148,7 @@ static int FrameConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
return TtkCoreConfigure(interp, recordPtr, mask);
}
-static WidgetSpec FrameWidgetSpec = {
+static const WidgetSpec FrameWidgetSpec = {
"TFrame", /* className */
sizeof(Frame), /* recordSize */
FrameOptionSpecs, /* optionSpecs */
@@ -247,18 +250,18 @@ typedef struct {
#define LABELWIDGET_CHANGED 0x100
-static Tk_OptionSpec LabelframeOptionSpecs[] = {
+static const Tk_OptionSpec LabelframeOptionSpecs[] = {
{TK_OPTION_STRING, "-labelanchor", "labelAnchor", "LabelAnchor",
- "nw", Tk_Offset(Labelframe, label.labelAnchorObj),-1,
+ "nw", offsetof(Labelframe, label.labelAnchorObj),TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-text", "text", "Text", "",
- Tk_Offset(Labelframe,label.textObj), -1,
+ offsetof(Labelframe,label.textObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_INT, "-underline", "underline", "Underline",
- "-1", Tk_Offset(Labelframe,label.underlineObj), -1,
+ "-1", offsetof(Labelframe,label.underlineObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_WINDOW, "-labelwidget", "labelWidget", "LabelWidget", NULL,
- -1, Tk_Offset(Labelframe,label.labelWidget),
+ TCL_INDEX_NONE, offsetof(Labelframe,label.labelWidget),
TK_OPTION_NULL_OK,0,LABELWIDGET_CHANGED|GEOMETRY_CHANGED },
WIDGET_INHERIT_OPTIONS(FrameOptionSpecs)
@@ -339,11 +342,13 @@ LabelframeLabelSize(Labelframe *lframePtr, int *widthPtr, int *heightPtr)
*/
static int LabelframeSize(void *recordPtr, int *widthPtr, int *heightPtr)
{
- Labelframe *lframePtr = recordPtr;
+ Labelframe *lframePtr = (Labelframe *)recordPtr;
WidgetCore *corePtr = &lframePtr->core;
Ttk_Padding margins;
LabelframeStyle style;
int labelWidth, labelHeight;
+ (void)widthPtr;
+ (void)heightPtr;
LabelframeStyleOptions(lframePtr, &style);
@@ -384,7 +389,7 @@ static int LabelframeSize(void *recordPtr, int *widthPtr, int *heightPtr)
static Ttk_Layout LabelframeGetLayout(
Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
{
- Labelframe *lf = recordPtr;
+ Labelframe *lf = (Labelframe *)recordPtr;
Ttk_Layout frameLayout = TtkWidgetGetLayout(interp, theme, recordPtr);
Ttk_Layout labelLayout;
@@ -415,7 +420,7 @@ static Ttk_Layout LabelframeGetLayout(
static void LabelframeDoLayout(void *recordPtr)
{
- Labelframe *lframePtr = recordPtr;
+ Labelframe *lframePtr = (Labelframe *)recordPtr;
WidgetCore *corePtr = &lframePtr->core;
int lw, lh; /* Label width and height */
LabelframeStyle style;
@@ -439,8 +444,10 @@ static void LabelframeDoLayout(void *recordPtr)
*/
switch (LabelAnchorSide(style.labelAnchor)) {
case TTK_SIDE_LEFT: borderParcel.x -= lw / 2;
+ /* FALLTHRU */
case TTK_SIDE_RIGHT: borderParcel.width += lw/2; break;
case TTK_SIDE_TOP: borderParcel.y -= lh / 2;
+ /* FALLTHRU */
case TTK_SIDE_BOTTOM: borderParcel.height += lh / 2; break;
}
}
@@ -459,7 +466,7 @@ static void LabelframeDoLayout(void *recordPtr)
static void LabelframeDisplay(void *recordPtr, Drawable d)
{
- Labelframe *lframePtr = recordPtr;
+ Labelframe *lframePtr = (Labelframe *)recordPtr;
Ttk_DrawLayout(lframePtr->core.layout, lframePtr->core.state, d);
if (lframePtr->label.labelLayout) {
Ttk_DrawLayout(lframePtr->label.labelLayout, lframePtr->core.state, d);
@@ -474,7 +481,7 @@ static void LabelframeDisplay(void *recordPtr, Drawable d)
*/
static void LabelframePlaceSlaves(void *recordPtr)
{
- Labelframe *lframe = recordPtr;
+ Labelframe *lframe = (Labelframe *)recordPtr;
if (Ttk_NumberSlaves(lframe->label.mgr) == 1) {
Ttk_Box b;
@@ -485,8 +492,13 @@ static void LabelframePlaceSlaves(void *recordPtr)
}
}
-static int LabelRequest(void *managerData, int index, int width, int height)
+static int LabelRequest(void *managerData, TkSizeT index, int width, int height)
{
+ (void)managerData;
+ (void)index;
+ (void)width;
+ (void)height;
+
return 1;
}
@@ -497,9 +509,11 @@ static int LabelRequest(void *managerData, int index, int width, int height)
* This routine is also called when the widget voluntarily forgets
* the slave in LabelframeConfigure.
*/
-static void LabelRemoved(void *managerData, int slaveIndex)
+static void LabelRemoved(void *managerData, TkSizeT slaveIndex)
{
- Labelframe *lframe = managerData;
+ Labelframe *lframe = (Labelframe *)managerData;
+ (void)slaveIndex;
+
lframe->label.labelWidget = 0;
}
@@ -514,9 +528,10 @@ static Ttk_ManagerSpec LabelframeManagerSpec = {
/* LabelframeInitialize --
* Initialization hook.
*/
-static void LabelframeInitialize(Tcl_Interp *interp, void *recordPtr)
+static void LabelframeInitialize(Tcl_Interp *dummy, void *recordPtr)
{
- Labelframe *lframe = recordPtr;
+ Labelframe *lframe = (Labelframe *)recordPtr;
+ (void)dummy;
lframe->label.mgr = Ttk_CreateManager(
&LabelframeManagerSpec, lframe, lframe->core.tkwin);
@@ -530,7 +545,7 @@ static void LabelframeInitialize(Tcl_Interp *interp, void *recordPtr)
*/
static void LabelframeCleanup(void *recordPtr)
{
- Labelframe *lframe = recordPtr;
+ Labelframe *lframe = (Labelframe *)recordPtr;
Ttk_DeleteManager(lframe->label.mgr);
if (lframe->label.labelLayout) {
Ttk_FreeLayout(lframe->label.labelLayout);
@@ -561,7 +576,7 @@ static void RaiseLabelWidget(Labelframe *lframe)
*/
static int LabelframeConfigure(Tcl_Interp *interp,void *recordPtr,int mask)
{
- Labelframe *lframePtr = recordPtr;
+ Labelframe *lframePtr = (Labelframe *)recordPtr;
Tk_Window labelWidget = lframePtr->label.labelWidget;
Ttk_PositionSpec unused;
@@ -609,7 +624,7 @@ static int LabelframeConfigure(Tcl_Interp *interp,void *recordPtr,int mask)
return TCL_OK;
}
-static WidgetSpec LabelframeWidgetSpec = {
+static const WidgetSpec LabelframeWidgetSpec = {
"TLabelframe", /* className */
sizeof(Labelframe), /* recordSize */
LabelframeOptionSpecs, /* optionSpecs */
diff --git a/generic/ttk/ttkImage.c b/generic/ttk/ttkImage.c
index 002a753..e6ad27d 100644
--- a/generic/ttk/ttkImage.c
+++ b/generic/ttk/ttkImage.c
@@ -31,9 +31,17 @@ struct TtkImageSpec {
/* NullImageChanged --
* Do-nothing Tk_ImageChangedProc.
*/
-static void NullImageChanged(ClientData clientData,
+static void NullImageChanged(ClientData dummy,
int x, int y, int width, int height, int imageWidth, int imageHeight)
-{ /* No-op */ }
+{ /* No-op */
+ (void)dummy;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imageWidth;
+ (void)imageHeight;
+}
/* ImageSpecImageChanged --
* Image changes should trigger a repaint.
@@ -74,7 +82,7 @@ TtkGetImageSpecEx(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr,
int i = 0, n = 0, objc;
Tcl_Obj **objv;
- imageSpec = ckalloc(sizeof(*imageSpec));
+ imageSpec = (Ttk_ImageSpec *)ckalloc(sizeof(*imageSpec));
imageSpec->baseImage = 0;
imageSpec->mapCount = 0;
imageSpec->states = 0;
@@ -97,8 +105,8 @@ TtkGetImageSpecEx(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr,
}
n = (objc - 1) / 2;
- imageSpec->states = ckalloc(n * sizeof(Ttk_StateSpec));
- imageSpec->images = ckalloc(n * sizeof(Tk_Image *));
+ imageSpec->states = (Ttk_StateSpec *)ckalloc(n * sizeof(Ttk_StateSpec));
+ imageSpec->images = (Tk_Image *)ckalloc(n * sizeof(Tk_Image));
/* Get base image:
*/
@@ -205,6 +213,7 @@ static void Ttk_Fill(
int dr = dst.x + dst.width;
int db = dst.y + dst.height;
int x,y;
+ (void)tkwin;
if (!(src.width && src.height && dst.width && dst.height))
return;
@@ -262,7 +271,7 @@ typedef struct { /* ClientData for image elements */
static void FreeImageData(void *clientData)
{
- ImageData *imageData = clientData;
+ ImageData *imageData = (ImageData *)clientData;
if (imageData->imageSpec) { TtkFreeImageSpec(imageData->imageSpec); }
#if TILE_07_COMPAT
if (imageData->imageMap) { Tcl_DecrRefCount(imageData->imageMap); }
@@ -274,8 +283,10 @@ static void ImageElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ImageData *imageData = clientData;
+ ImageData *imageData = (ImageData *)clientData;
Tk_Image image = imageData->imageSpec->baseImage;
+ (void)elementRecord;
+ (void)tkwin;
if (image) {
Tk_SizeOfImage(image, widthPtr, heightPtr);
@@ -294,10 +305,11 @@ static void ImageElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ImageData *imageData = clientData;
+ ImageData *imageData = (ImageData *)clientData;
Tk_Image image = 0;
int imgWidth, imgHeight;
Ttk_Box src, dst;
+ (void)elementRecord;
#if TILE_07_COMPAT
if (imageData->imageMap) {
@@ -324,7 +336,7 @@ static void ImageElementDraw(
Ttk_Tile(tkwin, d, image, src, dst, imageData->border);
}
-static Ttk_ElementSpec ImageElementSpec =
+static const Ttk_ElementSpec ImageElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -339,7 +351,7 @@ static Ttk_ElementSpec ImageElementSpec =
static int
Ttk_CreateImageElement(
Tcl_Interp *interp,
- void *clientData,
+ void *dummy,
Ttk_Theme theme,
const char *elementName,
int objc, Tcl_Obj *const objv[])
@@ -352,6 +364,7 @@ Ttk_CreateImageElement(
ImageData *imageData = 0;
int padding_specified = 0;
int i;
+ (void)dummy;
if (objc <= 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
@@ -365,7 +378,7 @@ Ttk_CreateImageElement(
return TCL_ERROR;
}
- imageData = ckalloc(sizeof(*imageData));
+ imageData = (ImageData *)ckalloc(sizeof(*imageData));
imageData->imageSpec = imageSpec;
imageData->minWidth = imageData->minHeight = -1;
imageData->sticky = TTK_FILL_BOTH;
diff --git a/generic/ttk/ttkInit.c b/generic/ttk/ttkInit.c
index 60e3b6f..f14a2db 100644
--- a/generic/ttk/ttkInit.c
+++ b/generic/ttk/ttkInit.c
@@ -12,43 +12,50 @@
* Legal values for the button -default option.
* See also: enum Ttk_ButtonDefaultState.
*/
-const char *ttkDefaultStrings[] = {
+const char *const ttkDefaultStrings[] = {
"normal", "active", "disabled", NULL
};
int Ttk_GetButtonDefaultStateFromObj(
- Tcl_Interp *interp, Tcl_Obj *objPtr, int *statePtr)
+ Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_ButtonDefaultState *statePtr)
{
- *statePtr = TTK_BUTTON_DEFAULT_DISABLED;
- return Tcl_GetIndexFromObjStruct(interp, objPtr, ttkDefaultStrings,
- sizeof(char *), "default state", 0, statePtr);
+ int state = (int)TTK_BUTTON_DEFAULT_DISABLED;
+ int result = Tcl_GetIndexFromObjStruct(interp, objPtr, ttkDefaultStrings,
+ sizeof(char *), "default state", 0, &state);
+
+ *statePtr = (Ttk_ButtonDefaultState)state;
+ return result;
}
/*
* Legal values for the -compound option.
* See also: enum Ttk_Compound.
*/
-const char *ttkCompoundStrings[] = {
+const char *const ttkCompoundStrings[] = {
"none", "text", "image", "center",
"top", "bottom", "left", "right", NULL
};
int Ttk_GetCompoundFromObj(
- Tcl_Interp *interp, Tcl_Obj *objPtr, int *statePtr)
+ Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Compound *compoundPtr)
{
- *statePtr = TTK_COMPOUND_NONE;
- return Tcl_GetIndexFromObjStruct(interp, objPtr, ttkCompoundStrings,
- sizeof(char *), "compound layout", 0, statePtr);
+ int compound = (int)TTK_COMPOUND_NONE;
+ int result = Tcl_GetIndexFromObjStruct(interp, objPtr, ttkCompoundStrings,
+ sizeof(char *), "compound layout", 0, &compound);
+
+ *compoundPtr = (Ttk_Compound)compound;
+ return result;
}
/*
* Legal values for the -orient option.
* See also: enum Ttk_Orient.
*/
-const char *ttkOrientStrings[] = {
+const char *const ttkOrientStrings[] = {
"horizontal", "vertical", NULL
};
+#if !defined(TK_NO_DEPRECATED) && TK_MAJOR_VERSION < 9
int Ttk_GetOrientFromObj(
Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr)
{
@@ -56,6 +63,18 @@ int Ttk_GetOrientFromObj(
return Tcl_GetIndexFromObjStruct(interp, objPtr, ttkOrientStrings,
sizeof(char *), "orientation", 0, resultPtr);
}
+#endif
+
+int TtkGetOrientFromObj(
+ Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Orient *resultPtr)
+{
+ int orient = (int)TTK_ORIENT_HORIZONTAL;
+ int result = Tcl_GetIndexFromObjStruct(interp, objPtr, ttkOrientStrings,
+ sizeof(char *), "orientation", 0, &orient);
+
+ *resultPtr = (Ttk_Orient)orient;
+ return result;
+}
/*
* Recognized values for the -state compatibility option.
@@ -114,7 +133,7 @@ void TtkCheckStateOption(WidgetCore *corePtr, Tcl_Obj *objPtr)
*/
void TtkSendVirtualEvent(Tk_Window tgtWin, const char *eventName)
{
- union {XEvent general; XVirtualEvent virtual;} event;
+ union {XEvent general; XVirtualEvent virt;} event;
memset(&event, 0, sizeof(event));
event.general.xany.type = VirtualEvent;
@@ -122,7 +141,7 @@ void TtkSendVirtualEvent(Tk_Window tgtWin, const char *eventName)
event.general.xany.send_event = False;
event.general.xany.window = Tk_WindowId(tgtWin);
event.general.xany.display = Tk_Display(tgtWin);
- event.virtual.name = Tk_GetUid(eventName);
+ event.virt.name = Tk_GetUid(eventName);
Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
}
@@ -148,7 +167,7 @@ int TtkEnumerateOptions(
if (specPtr->type == TK_OPTION_END && specPtr->clientData != NULL) {
/* Chain to next option spec array: */
- specPtr = specPtr->clientData;
+ specPtr = (const Tk_OptionSpec *)specPtr->clientData;
}
}
Tcl_SetObjResult(interp, result);
@@ -175,14 +194,14 @@ int TtkGetOptionValue(
*/
/* public */
-Tk_OptionSpec ttkCoreOptionSpecs[] =
+const Tk_OptionSpec ttkCoreOptionSpecs[] =
{
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", NULL,
- Tk_Offset(WidgetCore, cursorObj), -1, TK_OPTION_NULL_OK,0,0 },
+ offsetof(WidgetCore, cursorObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_STRING, "-style", "style", "Style", "",
- Tk_Offset(WidgetCore,styleObj), -1, 0,0,STYLE_CHANGED},
+ offsetof(WidgetCore,styleObj), TCL_INDEX_NONE, 0,0,STYLE_CHANGED},
{TK_OPTION_STRING, "-class", "", "", NULL,
- Tk_Offset(WidgetCore,classObj), -1, 0,0,READONLY_OPTION},
+ offsetof(WidgetCore,classObj), TCL_INDEX_NONE, 0,0,READONLY_OPTION},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -274,7 +293,7 @@ Ttk_Init(Tcl_Interp *interp)
Ttk_PlatformInit(interp);
- Tcl_PkgProvideEx(interp, "Ttk", TTK_PATCH_LEVEL, (ClientData)&ttkStubs);
+ Tcl_PkgProvideEx(interp, "Ttk", TTK_PATCH_LEVEL, (void *)&ttkStubs);
return TCL_OK;
}
diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c
index d7a1f93..a4dbf96 100644
--- a/generic/ttk/ttkLabel.c
+++ b/generic/ttk/ttkLabel.c
@@ -46,26 +46,26 @@ typedef struct {
/* Text element options table.
* NB: Keep in sync with label element option table.
*/
-static Ttk_ElementOptionSpec TextElementOptions[] = {
+static const Ttk_ElementOptionSpec TextElementOptions[] = {
{ "-text", TK_OPTION_STRING,
- Tk_Offset(TextElement,textObj), "" },
+ offsetof(TextElement,textObj), "" },
{ "-font", TK_OPTION_FONT,
- Tk_Offset(TextElement,fontObj), DEFAULT_FONT },
+ offsetof(TextElement,fontObj), DEFAULT_FONT },
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(TextElement,foregroundObj), "black" },
+ offsetof(TextElement,foregroundObj), "black" },
{ "-underline", TK_OPTION_INT,
- Tk_Offset(TextElement,underlineObj), "-1"},
+ offsetof(TextElement,underlineObj), "-1"},
{ "-width", TK_OPTION_INT,
- Tk_Offset(TextElement,widthObj), "-1"},
+ offsetof(TextElement,widthObj), "-1"},
{ "-anchor", TK_OPTION_ANCHOR,
- Tk_Offset(TextElement,anchorObj), "w"},
+ offsetof(TextElement,anchorObj), "w"},
{ "-justify", TK_OPTION_JUSTIFY,
- Tk_Offset(TextElement,justifyObj), "left" },
+ offsetof(TextElement,justifyObj), "left" },
{ "-wraplength", TK_OPTION_PIXELS,
- Tk_Offset(TextElement,wrapLengthObj), "0" },
+ offsetof(TextElement,wrapLengthObj), "0" },
{ "-embossed", TK_OPTION_INT,
- Tk_Offset(TextElement,embossedObj), "0"},
- { NULL, 0, 0, NULL }
+ offsetof(TextElement,embossedObj), "0"},
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static int TextSetup(TextElement *text, Tk_Window tkwin)
@@ -193,10 +193,12 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
}
static void TextElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TextElement *text = elementRecord;
+ TextElement *text = (TextElement *)elementRecord;
+ (void)dummy;
+ (void)paddingPtr;
if (!TextSetup(text, tkwin))
return;
@@ -210,17 +212,20 @@ static void TextElementSize(
}
static void TextElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- TextElement *text = elementRecord;
+ TextElement *text = (TextElement *)elementRecord;
+ (void)dummy;
+ (void)state;
+
if (TextSetup(text, tkwin)) {
TextDraw(text, tkwin, d, b);
TextCleanup(text);
}
}
-static Ttk_ElementSpec TextElementSpec = {
+static const Ttk_ElementSpec TextElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TextElement),
TextElementOptions,
@@ -246,14 +251,14 @@ typedef struct {
/* ===> NB: Keep in sync with label element option table. <===
*/
-static Ttk_ElementOptionSpec ImageElementOptions[] = {
+static const Ttk_ElementOptionSpec ImageElementOptions[] = {
{ "-image", TK_OPTION_STRING,
- Tk_Offset(ImageElement,imageObj), "" },
+ offsetof(ImageElement,imageObj), "" },
{ "-stipple", TK_OPTION_STRING, /* Really: TK_OPTION_BITMAP */
- Tk_Offset(ImageElement,stippleObj), "gray50" },
+ offsetof(ImageElement,stippleObj), "gray50" },
{ "-background", TK_OPTION_COLOR,
- Tk_Offset(ImageElement,backgroundObj), DEFAULT_BACKGROUND },
- { NULL, 0, 0, NULL }
+ offsetof(ImageElement,backgroundObj), DEFAULT_BACKGROUND },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
/*
@@ -360,10 +365,12 @@ static void ImageDraw(
}
static void ImageElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ImageElement *image = elementRecord;
+ ImageElement *image = (ImageElement *)elementRecord;
+ (void)dummy;
+ (void)paddingPtr;
if (ImageSetup(image, tkwin, 0)) {
*widthPtr = image->width;
@@ -373,10 +380,11 @@ static void ImageElementSize(
}
static void ImageElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- ImageElement *image = elementRecord;
+ ImageElement *image = (ImageElement *)elementRecord;
+ (void)dummy;
if (ImageSetup(image, tkwin, state)) {
ImageDraw(image, tkwin, d, b, state);
@@ -384,7 +392,7 @@ static void ImageElementDraw(
}
}
-static Ttk_ElementSpec ImageElementSpec = {
+static const Ttk_ElementSpec ImageElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ImageElement),
ImageElementOptions,
@@ -440,44 +448,44 @@ typedef struct {
int totalWidth, totalHeight;
} LabelElement;
-static Ttk_ElementOptionSpec LabelElementOptions[] = {
+static const Ttk_ElementOptionSpec LabelElementOptions[] = {
{ "-compound", TK_OPTION_ANY,
- Tk_Offset(LabelElement,compoundObj), "none" },
+ offsetof(LabelElement,compoundObj), "none" },
{ "-space", TK_OPTION_PIXELS,
- Tk_Offset(LabelElement,spaceObj), "4" },
+ offsetof(LabelElement,spaceObj), "4" },
/* Text element part:
* NB: Keep in sync with TextElementOptions.
*/
{ "-text", TK_OPTION_STRING,
- Tk_Offset(LabelElement,text.textObj), "" },
+ offsetof(LabelElement,text.textObj), "" },
{ "-font", TK_OPTION_FONT,
- Tk_Offset(LabelElement,text.fontObj), DEFAULT_FONT },
+ offsetof(LabelElement,text.fontObj), DEFAULT_FONT },
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(LabelElement,text.foregroundObj), "black" },
+ offsetof(LabelElement,text.foregroundObj), "black" },
{ "-underline", TK_OPTION_INT,
- Tk_Offset(LabelElement,text.underlineObj), "-1"},
+ offsetof(LabelElement,text.underlineObj), "-1"},
{ "-width", TK_OPTION_INT,
- Tk_Offset(LabelElement,text.widthObj), ""},
+ offsetof(LabelElement,text.widthObj), ""},
{ "-anchor", TK_OPTION_ANCHOR,
- Tk_Offset(LabelElement,text.anchorObj), "w"},
+ offsetof(LabelElement,text.anchorObj), "w"},
{ "-justify", TK_OPTION_JUSTIFY,
- Tk_Offset(LabelElement,text.justifyObj), "left" },
+ offsetof(LabelElement,text.justifyObj), "left" },
{ "-wraplength", TK_OPTION_PIXELS,
- Tk_Offset(LabelElement,text.wrapLengthObj), "0" },
+ offsetof(LabelElement,text.wrapLengthObj), "0" },
{ "-embossed", TK_OPTION_INT,
- Tk_Offset(LabelElement,text.embossedObj), "0"},
+ offsetof(LabelElement,text.embossedObj), "0"},
/* Image element part:
* NB: Keep in sync with ImageElementOptions.
*/
{ "-image", TK_OPTION_STRING,
- Tk_Offset(LabelElement,image.imageObj), "" },
+ offsetof(LabelElement,image.imageObj), "" },
{ "-stipple", TK_OPTION_STRING, /* Really: TK_OPTION_BITMAP */
- Tk_Offset(LabelElement,image.stippleObj), "gray50" },
+ offsetof(LabelElement,image.stippleObj), "gray50" },
{ "-background", TK_OPTION_COLOR,
- Tk_Offset(LabelElement,image.backgroundObj), DEFAULT_BACKGROUND },
- { NULL, 0, 0, NULL }
+ offsetof(LabelElement,image.backgroundObj), DEFAULT_BACKGROUND },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
/*
@@ -494,8 +502,8 @@ static void LabelSetup(
{
Ttk_Compound *compoundPtr = &c->compound;
- Tk_GetPixelsFromObj(NULL,tkwin,c->spaceObj,&c->space);
- Ttk_GetCompoundFromObj(NULL,c->compoundObj,(int*)compoundPtr);
+ Tk_GetPixelsFromObj(NULL, tkwin, c->spaceObj, &c->space);
+ Ttk_GetCompoundFromObj(NULL, c->compoundObj, compoundPtr);
/*
* Deal with TTK_COMPOUND_NONE.
@@ -561,11 +569,13 @@ static void LabelCleanup(LabelElement *c)
}
static void LabelElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- LabelElement *label = elementRecord;
+ LabelElement *label = (LabelElement *)elementRecord;
int textReqWidth = 0;
+ (void)dummy;
+ (void)paddingPtr;
LabelSetup(label, tkwin, 0);
@@ -607,7 +617,7 @@ static void LabelElementSize(
*/
static void DrawCompound(
LabelElement *l, Ttk_Box b, Tk_Window tkwin, Drawable d, Ttk_State state,
- int imageSide, int textSide)
+ Ttk_Side imageSide, Ttk_Side textSide)
{
Ttk_Box imageBox =
Ttk_PlaceBox(&b, l->image.width, l->image.height, imageSide, 0);
@@ -618,11 +628,12 @@ static void DrawCompound(
}
static void LabelElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- LabelElement *l = elementRecord;
+ LabelElement *l = (LabelElement *)elementRecord;
Tk_Anchor anchor = TK_ANCHOR_CENTER;
+ (void)dummy;
LabelSetup(l, tkwin, state);
@@ -673,7 +684,7 @@ static void LabelElementDraw(
LabelCleanup(l);
}
-static Ttk_ElementSpec LabelElementSpec = {
+static const Ttk_ElementSpec LabelElementSpec = {
TK_STYLE_VERSION_2,
sizeof(LabelElement),
LabelElementOptions,
diff --git a/generic/ttk/ttkLayout.c b/generic/ttk/ttkLayout.c
index 795ffb5..5e8c69c 100644
--- a/generic/ttk/ttkLayout.c
+++ b/generic/ttk/ttkLayout.c
@@ -524,7 +524,7 @@ struct Ttk_LayoutNode_
static Ttk_LayoutNode *Ttk_NewLayoutNode(
unsigned flags, Ttk_ElementClass *elementClass)
{
- Ttk_LayoutNode *node = ckalloc(sizeof(*node));
+ Ttk_LayoutNode *node = (Ttk_LayoutNode *)ckalloc(sizeof(*node));
node->flags = flags;
node->eclass = elementClass;
@@ -557,8 +557,8 @@ struct Ttk_TemplateNode_ {
static Ttk_TemplateNode *Ttk_NewTemplateNode(const char *name, unsigned flags)
{
- Ttk_TemplateNode *op = ckalloc(sizeof(*op));
- op->name = ckalloc(strlen(name) + 1); strcpy(op->name, name);
+ Ttk_TemplateNode *op = (Ttk_TemplateNode *)ckalloc(sizeof(*op));
+ op->name = (char *)ckalloc(strlen(name) + 1); strcpy(op->name, name);
op->flags = flags;
op->next = op->child = 0;
return op;
@@ -843,7 +843,7 @@ static Ttk_Layout TTKNewLayout(
void *recordPtr,Tk_OptionTable optionTable, Tk_Window tkwin,
Ttk_LayoutNode *root)
{
- Ttk_Layout layout = ckalloc(sizeof(*layout));
+ Ttk_Layout layout = (Ttk_Layout)ckalloc(sizeof(*layout));
layout->style = style;
layout->recordPtr = recordPtr;
layout->optionTable = optionTable;
diff --git a/generic/ttk/ttkManager.c b/generic/ttk/ttkManager.c
index bf93699..b1e6cfd 100644
--- a/generic/ttk/ttkManager.c
+++ b/generic/ttk/ttkManager.c
@@ -115,7 +115,7 @@ static void RecomputeLayout(Ttk_Manager *mgr)
*/
static void ManagerIdleProc(ClientData clientData)
{
- Ttk_Manager *mgr = clientData;
+ Ttk_Manager *mgr = (Ttk_Manager *)clientData;
mgr->flags &= ~MGR_UPDATE_PENDING;
if (mgr->flags & MGR_RESIZE_REQUIRED) {
@@ -141,7 +141,7 @@ static void ManagerIdleProc(ClientData clientData)
static const int ManagerEventMask = StructureNotifyMask;
static void ManagerEventHandler(ClientData clientData, XEvent *eventPtr)
{
- Ttk_Manager *mgr = clientData;
+ Ttk_Manager *mgr = (Ttk_Manager *)clientData;
int i;
switch (eventPtr->type)
@@ -173,7 +173,7 @@ static void ManagerEventHandler(ClientData clientData, XEvent *eventPtr)
static const unsigned SlaveEventMask = StructureNotifyMask;
static void SlaveEventHandler(ClientData clientData, XEvent *eventPtr)
{
- Ttk_Slave *slave = clientData;
+ Ttk_Slave *slave = (Ttk_Slave *)clientData;
if (eventPtr->type == DestroyNotify) {
slave->manager->managerSpec->tkGeomMgr.lostSlaveProc(
slave->manager, slave->slaveWindow);
@@ -187,7 +187,7 @@ static void SlaveEventHandler(ClientData clientData, XEvent *eventPtr)
static Ttk_Slave *NewSlave(
Ttk_Manager *mgr, Tk_Window slaveWindow, void *slaveData)
{
- Ttk_Slave *slave = ckalloc(sizeof(*slave));
+ Ttk_Slave *slave = (Ttk_Slave *)ckalloc(sizeof(*slave));
slave->slaveWindow = slaveWindow;
slave->manager = mgr;
@@ -209,7 +209,7 @@ static void DeleteSlave(Ttk_Slave *slave)
Ttk_Manager *Ttk_CreateManager(
Ttk_ManagerSpec *managerSpec, void *managerData, Tk_Window masterWindow)
{
- Ttk_Manager *mgr = ckalloc(sizeof(*mgr));
+ Ttk_Manager *mgr = (Ttk_Manager *)ckalloc(sizeof(*mgr));
mgr->managerSpec = managerSpec;
mgr->managerData = managerData;
@@ -251,7 +251,7 @@ void Ttk_DeleteManager(Ttk_Manager *mgr)
static void InsertSlave(Ttk_Manager *mgr, Ttk_Slave *slave, int index)
{
int endIndex = mgr->nSlaves++;
- mgr->slaves = ckrealloc(mgr->slaves, mgr->nSlaves * sizeof(Ttk_Slave *));
+ mgr->slaves = (Ttk_Slave **)ckrealloc(mgr->slaves, mgr->nSlaves * sizeof(Ttk_Slave *));
while (endIndex > index) {
mgr->slaves[endIndex] = mgr->slaves[endIndex - 1];
@@ -313,7 +313,7 @@ static void RemoveSlave(Ttk_Manager *mgr, int index)
void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window slaveWindow)
{
- Ttk_Manager *mgr = clientData;
+ Ttk_Manager *mgr = (Ttk_Manager *)clientData;
int slaveIndex = Ttk_SlaveIndex(mgr, slaveWindow);
int reqWidth = Tk_ReqWidth(slaveWindow);
int reqHeight= Tk_ReqHeight(slaveWindow);
@@ -327,7 +327,7 @@ void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window slaveWindow)
void Ttk_LostSlaveProc(ClientData clientData, Tk_Window slaveWindow)
{
- Ttk_Manager *mgr = clientData;
+ Ttk_Manager *mgr = (Ttk_Manager *)clientData;
int index = Ttk_SlaveIndex(mgr, slaveWindow);
/* ASSERT: index >= 0 */
@@ -342,7 +342,7 @@ void Ttk_LostSlaveProc(ClientData clientData, Tk_Window slaveWindow)
* Add a new slave window at the specified index.
*/
void Ttk_InsertSlave(
- Ttk_Manager *mgr, int index, Tk_Window tkwin, void *slaveData)
+ Ttk_Manager *mgr, TkSizeT index, Tk_Window tkwin, void *slaveData)
{
Ttk_Slave *slave = NewSlave(mgr, tkwin, slaveData);
InsertSlave(mgr, slave, index);
@@ -351,7 +351,7 @@ void Ttk_InsertSlave(
/* ++ Ttk_ForgetSlave --
* Unmanage the specified slave.
*/
-void Ttk_ForgetSlave(Ttk_Manager *mgr, int slaveIndex)
+void Ttk_ForgetSlave(Ttk_Manager *mgr, TkSizeT slaveIndex)
{
Tk_Window slaveWindow = mgr->slaves[slaveIndex]->slaveWindow;
RemoveSlave(mgr, slaveIndex);
@@ -366,7 +366,7 @@ void Ttk_ForgetSlave(Ttk_Manager *mgr, int slaveIndex)
* map the slave.
*/
void Ttk_PlaceSlave(
- Ttk_Manager *mgr, int slaveIndex, int x, int y, int width, int height)
+ Ttk_Manager *mgr, TkSizeT slaveIndex, int x, int y, int width, int height)
{
Ttk_Slave *slave = mgr->slaves[slaveIndex];
Tk_MaintainGeometry(slave->slaveWindow,mgr->masterWindow,x,y,width,height);
@@ -379,7 +379,7 @@ void Ttk_PlaceSlave(
/* ++ Ttk_UnmapSlave --
* Unmap the specified slave, but leave it managed.
*/
-void Ttk_UnmapSlave(Ttk_Manager *mgr, int slaveIndex)
+void Ttk_UnmapSlave(Ttk_Manager *mgr, TkSizeT slaveIndex)
{
Ttk_Slave *slave = mgr->slaves[slaveIndex];
Tk_UnmaintainGeometry(slave->slaveWindow, mgr->masterWindow);
@@ -405,15 +405,15 @@ void Ttk_ManagerSizeChanged(Ttk_Manager *mgr)
/* +++ Accessors.
*/
-int Ttk_NumberSlaves(Ttk_Manager *mgr)
+TkSizeT Ttk_NumberSlaves(Ttk_Manager *mgr)
{
return mgr->nSlaves;
}
-void *Ttk_SlaveData(Ttk_Manager *mgr, int slaveIndex)
+void *Ttk_SlaveData(Ttk_Manager *mgr, TkSizeT slaveIndex)
{
return mgr->slaves[slaveIndex]->slaveData;
}
-Tk_Window Ttk_SlaveWindow(Ttk_Manager *mgr, int slaveIndex)
+Tk_Window Ttk_SlaveWindow(Ttk_Manager *mgr, TkSizeT slaveIndex)
{
return mgr->slaves[slaveIndex]->slaveWindow;
}
@@ -425,13 +425,13 @@ Tk_Window Ttk_SlaveWindow(Ttk_Manager *mgr, int slaveIndex)
/* ++ Ttk_SlaveIndex --
* Returns the index of specified slave window, -1 if not found.
*/
-int Ttk_SlaveIndex(Ttk_Manager *mgr, Tk_Window slaveWindow)
+TkSizeT Ttk_SlaveIndex(Ttk_Manager *mgr, Tk_Window slaveWindow)
{
int index;
for (index = 0; index < mgr->nSlaves; ++index)
if (mgr->slaves[index]->slaveWindow == slaveWindow)
return index;
- return -1;
+ return TCL_INDEX_NONE;
}
/* ++ Ttk_GetSlaveIndexFromObj(interp, mgr, objPtr, indexPtr) --
@@ -448,12 +448,14 @@ int Ttk_GetSlaveIndexFromObj(
{
const char *string = Tcl_GetString(objPtr);
int slaveIndex = 0;
+ TkSizeT idx;
Tk_Window tkwin;
/* Try interpreting as an integer first:
*/
- if (Tcl_GetIntFromObj(NULL, objPtr, &slaveIndex) == TCL_OK) {
- if (slaveIndex < 0 || slaveIndex >= mgr->nSlaves) {
+ if (TkGetIntForIndex(objPtr, mgr->nSlaves - 1, 1, &idx) == TCL_OK) {
+ slaveIndex = idx;
+ if (slaveIndex < 0 || slaveIndex > mgr->nSlaves) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"Slave index %d out of bounds", slaveIndex));
Tcl_SetErrorCode(interp, "TTK", "SLAVE", "INDEX", NULL);
@@ -488,7 +490,7 @@ int Ttk_GetSlaveIndexFromObj(
/* ++ Ttk_ReorderSlave(mgr, fromIndex, toIndex) --
* Change slave order.
*/
-void Ttk_ReorderSlave(Ttk_Manager *mgr, int fromIndex, int toIndex)
+void Ttk_ReorderSlave(Ttk_Manager *mgr, TkSizeT fromIndex, TkSizeT toIndex)
{
Ttk_Slave *moved = mgr->slaves[fromIndex];
diff --git a/generic/ttk/ttkManager.h b/generic/ttk/ttkManager.h
index 07fcea1..365a080 100644
--- a/generic/ttk/ttkManager.h
+++ b/generic/ttk/ttkManager.h
@@ -31,8 +31,8 @@ typedef struct { /* Manager hooks */
int (*RequestedSize)(void *managerData, int *widthPtr, int *heightPtr);
void (*PlaceSlaves)(void *managerData);
- int (*SlaveRequest)(void *managerData, int slaveIndex, int w, int h);
- void (*SlaveRemoved)(void *managerData, int slaveIndex);
+ int (*SlaveRequest)(void *managerData, TkSizeT slaveIndex, int w, int h);
+ void (*SlaveRemoved)(void *managerData, TkSizeT slaveIndex);
} Ttk_ManagerSpec;
/*
@@ -49,18 +49,18 @@ MODULE_SCOPE Ttk_Manager *Ttk_CreateManager(
MODULE_SCOPE void Ttk_DeleteManager(Ttk_Manager *);
MODULE_SCOPE void Ttk_InsertSlave(
- Ttk_Manager *, int position, Tk_Window, void *slaveData);
+ Ttk_Manager *, TkSizeT position, Tk_Window, void *slaveData);
-MODULE_SCOPE void Ttk_ForgetSlave(Ttk_Manager *, int slaveIndex);
+MODULE_SCOPE void Ttk_ForgetSlave(Ttk_Manager *, TkSizeT slaveIndex);
-MODULE_SCOPE void Ttk_ReorderSlave(Ttk_Manager *, int fromIndex, int toIndex);
+MODULE_SCOPE void Ttk_ReorderSlave(Ttk_Manager *, TkSizeT fromIndex, TkSizeT toIndex);
/* Rearrange slave positions */
MODULE_SCOPE void Ttk_PlaceSlave(
- Ttk_Manager *, int slaveIndex, int x, int y, int width, int height);
+ Ttk_Manager *, TkSizeT slaveIndex, int x, int y, int width, int height);
/* Position and map the slave */
-MODULE_SCOPE void Ttk_UnmapSlave(Ttk_Manager *, int slaveIndex);
+MODULE_SCOPE void Ttk_UnmapSlave(Ttk_Manager *, TkSizeT slaveIndex);
/* Unmap the slave */
MODULE_SCOPE void Ttk_ManagerSizeChanged(Ttk_Manager *);
@@ -69,7 +69,7 @@ MODULE_SCOPE void Ttk_ManagerLayoutChanged(Ttk_Manager *);
/* Utilities:
*/
-MODULE_SCOPE int Ttk_SlaveIndex(Ttk_Manager *, Tk_Window);
+MODULE_SCOPE TkSizeT Ttk_SlaveIndex(Ttk_Manager *, Tk_Window);
/* Returns: index in slave array of specified window, -1 if not found */
MODULE_SCOPE int Ttk_GetSlaveIndexFromObj(
@@ -77,13 +77,13 @@ MODULE_SCOPE int Ttk_GetSlaveIndexFromObj(
/* Accessor functions:
*/
-MODULE_SCOPE int Ttk_NumberSlaves(Ttk_Manager *);
+MODULE_SCOPE TkSizeT Ttk_NumberSlaves(Ttk_Manager *);
/* Returns: number of managed slaves */
-MODULE_SCOPE void *Ttk_SlaveData(Ttk_Manager *, int slaveIndex);
+MODULE_SCOPE void *Ttk_SlaveData(Ttk_Manager *, TkSizeT slaveIndex);
/* Returns: client data associated with slave */
-MODULE_SCOPE Tk_Window Ttk_SlaveWindow(Ttk_Manager *, int slaveIndex);
+MODULE_SCOPE Tk_Window Ttk_SlaveWindow(Ttk_Manager *, TkSizeT slaveIndex);
/* Returns: slave window */
MODULE_SCOPE int Ttk_Maintainable(Tcl_Interp *, Tk_Window slave, Tk_Window master);
diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c
index 0625af8..ee10a71 100644
--- a/generic/ttk/ttkNotebook.c
+++ b/generic/ttk/ttkNotebook.c
@@ -55,29 +55,29 @@ typedef struct
* PaneOptionSpecs includes additional options for child window placement
* and is used to configure the slave.
*/
-static Tk_OptionSpec TabOptionSpecs[] =
+static const Tk_OptionSpec TabOptionSpecs[] =
{
{TK_OPTION_STRING_TABLE, "-state", "", "",
- "normal", -1,Tk_Offset(Tab,state),
+ "normal", TCL_INDEX_NONE, offsetof(Tab,state),
0,(ClientData)TabStateStrings,0 },
{TK_OPTION_STRING, "-text", "text", "Text", "",
- Tk_Offset(Tab,textObj), -1, 0,0,GEOMETRY_CHANGED },
+ offsetof(Tab,textObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/,
- Tk_Offset(Tab,imageObj), -1, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
+ offsetof(Tab,imageObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- "none", Tk_Offset(Tab,compoundObj), -1,
- 0,(ClientData)ttkCompoundStrings,GEOMETRY_CHANGED },
+ NULL, offsetof(Tab,compoundObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,(void *)ttkCompoundStrings,GEOMETRY_CHANGED },
{TK_OPTION_INT, "-underline", "underline", "Underline", "-1",
- Tk_Offset(Tab,underlineObj), -1, 0,0,GEOMETRY_CHANGED },
+ offsetof(Tab,underlineObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED },
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 }
};
-static Tk_OptionSpec PaneOptionSpecs[] =
+static const Tk_OptionSpec PaneOptionSpecs[] =
{
{TK_OPTION_STRING, "-padding", "padding", "Padding", "0",
- Tk_Offset(Tab,paddingObj), -1, 0,0,GEOMETRY_CHANGED },
+ offsetof(Tab,paddingObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-sticky", "sticky", "Sticky", "nsew",
- Tk_Offset(Tab,stickyObj), -1, 0,0,GEOMETRY_CHANGED },
+ offsetof(Tab,stickyObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED },
WIDGET_INHERIT_OPTIONS(TabOptionSpecs)
};
@@ -107,16 +107,16 @@ typedef struct
NotebookPart notebook;
} Notebook;
-static Tk_OptionSpec NotebookOptionSpecs[] =
+static const Tk_OptionSpec NotebookOptionSpecs[] =
{
{TK_OPTION_INT, "-width", "width", "Width", "0",
- Tk_Offset(Notebook,notebook.widthObj),-1,
+ offsetof(Notebook,notebook.widthObj),TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_INT, "-height", "height", "Height", "0",
- Tk_Offset(Notebook,notebook.heightObj),-1,
+ offsetof(Notebook,notebook.heightObj),TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-padding", "padding", "Padding", NULL,
- Tk_Offset(Notebook,notebook.paddingObj),-1,
+ offsetof(Notebook,notebook.paddingObj),TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
WIDGET_TAKEFOCUS_TRUE,
@@ -190,7 +190,7 @@ static void NotebookStyleOptions(Notebook *nb, NotebookStyle *nbstyle)
static Tab *CreateTab(Tcl_Interp *interp, Notebook *nb, Tk_Window slaveWindow)
{
Tk_OptionTable optionTable = nb->notebook.paneOptionTable;
- void *record = ckalloc(sizeof(Tab));
+ Tab *record = (Tab *)ckalloc(sizeof(Tab));
memset(record, 0, sizeof(Tab));
if (Tk_InitOptions(interp, record, optionTable, slaveWindow) != TCL_OK) {
@@ -254,18 +254,18 @@ error:
* Return the index of the tab at point x,y,
* or -1 if no tab at that point.
*/
-static int IdentifyTab(Notebook *nb, int x, int y)
+static TkSizeT IdentifyTab(Notebook *nb, int x, int y)
{
- int index;
+ TkSizeT index;
for (index = 0; index < Ttk_NumberSlaves(nb->notebook.mgr); ++index) {
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr,index);
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr,index);
if ( tab->state != TAB_STATE_HIDDEN
&& Ttk_BoxContains(tab->parcel, x,y))
{
return index;
}
}
- return -1;
+ return TCL_INDEX_NONE;
}
/*
@@ -287,23 +287,23 @@ static void ActivateTab(Notebook *nb, int index)
* The USER1 bit is set for the leftmost visible tab, and USER2
* is set for the rightmost visible tab.
*/
-static Ttk_State TabState(Notebook *nb, int index)
+static Ttk_State TabState(Notebook *nb, TkSizeT index)
{
Ttk_State state = nb->core.state;
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index);
- int i = 0;
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index);
+ TkSizeT i = 0;
- if (index == nb->notebook.currentIndex) {
+ if ((int)index == nb->notebook.currentIndex) {
state |= TTK_STATE_SELECTED;
} else {
state &= ~TTK_STATE_FOCUS;
}
- if (index == nb->notebook.activeIndex) {
+ if ((int)index == nb->notebook.activeIndex) {
state |= TTK_STATE_ACTIVE;
}
for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i);
if (tab->state == TAB_STATE_HIDDEN) {
continue;
}
@@ -312,8 +312,8 @@ static Ttk_State TabState(Notebook *nb, int index)
}
break;
}
- for (i = Ttk_NumberSlaves(nb->notebook.mgr) - 1; i >= 0; --i) {
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
+ for (i = Ttk_NumberSlaves(nb->notebook.mgr) - 1; i != TCL_INDEX_NONE; --i) {
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i);
if (tab->state == TAB_STATE_HIDDEN) {
continue;
}
@@ -351,10 +351,10 @@ static void TabrowSize(
{
Ttk_Layout tabLayout = nb->notebook.tabLayout;
int tabrowWidth = 0, tabrowHeight = 0;
- int i;
+ TkSizeT i;
for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i);
Ttk_State tabState = TabState(nb,i);
Ttk_RebindSublayout(tabLayout, tab);
@@ -384,14 +384,14 @@ static void TabrowSize(
static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr)
{
- Notebook *nb = clientData;
+ Notebook *nb = (Notebook *)clientData;
NotebookStyle nbstyle;
Ttk_Padding padding;
Ttk_Element clientNode = Ttk_FindElement(nb->core.layout, "client");
int clientWidth = 0, clientHeight = 0,
reqWidth = 0, reqHeight = 0,
tabrowWidth = 0, tabrowHeight = 0;
- int i;
+ TkSizeT i;
NotebookStyleOptions(nb, &nbstyle);
@@ -399,7 +399,7 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr)
*/
for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
Tk_Window slaveWindow = Ttk_SlaveWindow(nb->notebook.mgr, i);
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i);
int slaveWidth
= Tk_ReqWidth(slaveWindow) + Ttk_PaddingWidth(tab->padding);
int slaveHeight
@@ -470,7 +470,7 @@ static void SqueezeTabs(
int i;
for (i = 0; i < nTabs; ++i) {
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i);
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr,i);
double ad = slack + tab->width * delta;
tab->width += (int)ad;
slack = ad - (int)ad;
@@ -489,7 +489,7 @@ static void PlaceTabs(
int i;
for (i = 0; i < nTabs; ++i) {
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, i);
Ttk_State tabState = TabState(nb, i);
if (tab->state != TAB_STATE_HIDDEN) {
@@ -517,7 +517,7 @@ static void PlaceTabs(
*/
static void NotebookDoLayout(void *recordPtr)
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
Tk_Window nbwin = nb->core.tkwin;
Ttk_Box cavity = Ttk_WinBox(nbwin);
int tabrowWidth = 0, tabrowHeight = 0;
@@ -571,9 +571,9 @@ static void NotebookDoLayout(void *recordPtr)
* Set the position and size of a child widget
* based on the current client area and slave options:
*/
-static void NotebookPlaceSlave(Notebook *nb, int slaveIndex)
+static void NotebookPlaceSlave(Notebook *nb, TkSizeT slaveIndex)
{
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr, slaveIndex);
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, slaveIndex);
Tk_Window slaveWindow = Ttk_SlaveWindow(nb->notebook.mgr, slaveIndex);
Ttk_Box slaveBox =
Ttk_StickBox(Ttk_PadBox(nb->notebook.clientArea, tab->padding),
@@ -588,7 +588,7 @@ static void NotebookPlaceSlave(Notebook *nb, int slaveIndex)
*/
static void NotebookPlaceSlaves(void *recordPtr)
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
int currentIndex = nb->notebook.currentIndex;
if (currentIndex >= 0) {
NotebookDoLayout(nb);
@@ -602,7 +602,7 @@ static void NotebookPlaceSlaves(void *recordPtr)
*/
static void SelectTab(Notebook *nb, int index)
{
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr,index);
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr,index);
int currentIndex = nb->notebook.currentIndex;
if (index == currentIndex) {
@@ -647,7 +647,7 @@ static int NextTab(Notebook *nb, int index)
/* Scan forward for following usable tab:
*/
for (nextIndex = index + 1; nextIndex < nTabs; ++nextIndex) {
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr, nextIndex);
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, nextIndex);
if (tab->state == TAB_STATE_NORMAL) {
return nextIndex;
}
@@ -656,7 +656,7 @@ static int NextTab(Notebook *nb, int index)
/* Not found -- scan backwards.
*/
for (nextIndex = index - 1; nextIndex >= 0; --nextIndex) {
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr, nextIndex);
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, nextIndex);
if (tab->state == TAB_STATE_NORMAL) {
return nextIndex;
}
@@ -695,16 +695,16 @@ static void SelectNearestTab(Notebook *nb)
* Select the next tab if the current one is being removed.
* Adjust currentIndex to account for removed slave.
*/
-static void TabRemoved(void *managerData, int index)
+static void TabRemoved(void *managerData, TkSizeT index)
{
- Notebook *nb = managerData;
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index);
+ Notebook *nb = (Notebook *)managerData;
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index);
- if (index == nb->notebook.currentIndex) {
+ if ((int)index == nb->notebook.currentIndex) {
SelectNearestTab(nb);
}
- if (index < nb->notebook.currentIndex) {
+ if ((int)index < nb->notebook.currentIndex) {
--nb->notebook.currentIndex;
}
@@ -713,8 +713,13 @@ static void TabRemoved(void *managerData, int index)
TtkRedisplayWidget(&nb->core);
}
-static int TabRequest(void *managerData, int index, int width, int height)
+static int TabRequest(void *managerData, TkSizeT index, int width, int height)
{
+ (void)managerData;
+ (void)index;
+ (void)width;
+ (void)height;
+
return 1;
}
@@ -731,7 +736,7 @@ static int AddTab(
return TCL_ERROR;
}
#if 0 /* can't happen */
- if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) >= 0) {
+ if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) != TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s already added",
Tk_PathName(slaveWindow)));
Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "PRESENT", NULL);
@@ -785,13 +790,13 @@ static const int NotebookEventMask
;
static void NotebookEventHandler(ClientData clientData, XEvent *eventPtr)
{
- Notebook *nb = clientData;
+ Notebook *nb = (Notebook *)clientData;
if (eventPtr->type == DestroyNotify) { /* Remove self */
Tk_DeleteEventHandler(nb->core.tkwin,
NotebookEventMask, NotebookEventHandler, clientData);
} else if (eventPtr->type == MotionNotify) {
- int index = IdentifyTab(nb, eventPtr->xmotion.x, eventPtr->xmotion.y);
+ TkSizeT index = IdentifyTab(nb, eventPtr->xmotion.x, eventPtr->xmotion.y);
ActivateTab(nb, index);
} else if (eventPtr->type == LeaveNotify) {
ActivateTab(nb, -1);
@@ -847,6 +852,12 @@ static int FindTabIndex(
{
return TCL_OK;
}
+ if (*index_rtn == (int)Ttk_NumberSlaves(nb->notebook.mgr)) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Invalid slave specification %s", string));
+ Tcl_SetErrorCode(interp, "TTK", "SLAVE", "SPEC", NULL);
+ return TCL_ERROR;
+ }
/* Nothing matched; Ttk_GetSlaveIndexFromObj will have left error message.
*/
@@ -862,6 +873,12 @@ static int GetTabIndex(
Tcl_Interp *interp, Notebook *nb, Tcl_Obj *objPtr, int *index_rtn)
{
int status = FindTabIndex(interp, nb, objPtr, index_rtn);
+ if (status == TCL_OK && *index_rtn >= (int)Ttk_NumberSlaves(nb->notebook.mgr)) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Slave index %s out of bounds", Tcl_GetString(objPtr)));
+ Tcl_SetErrorCode(interp, "TTK", "SLAVE", "INDEX", NULL);
+ return TCL_ERROR;
+ }
if (status == TCL_OK && *index_rtn < 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -881,7 +898,7 @@ static int GetTabIndex(
static int NotebookAddCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
int index = Ttk_NumberSlaves(nb->notebook.mgr);
Tk_Window slaveWindow;
int slaveIndex;
@@ -902,7 +919,7 @@ static int NotebookAddCommand(
return AddTab(interp, nb, index, slaveWindow, objc-3,objv+3);
}
- tab = Ttk_SlaveData(nb->notebook.mgr, slaveIndex);
+ tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, slaveIndex);
if (tab->state == TAB_STATE_HIDDEN) {
tab->state = TAB_STATE_NORMAL;
}
@@ -921,7 +938,7 @@ static int NotebookAddCommand(
static int NotebookInsertCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
int current = nb->notebook.currentIndex;
int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
int srcIndex, destIndex;
@@ -931,9 +948,7 @@ static int NotebookInsertCommand(
return TCL_ERROR;
}
- if (!strcmp(Tcl_GetString(objv[2]), "end")) {
- destIndex = Ttk_NumberSlaves(nb->notebook.mgr);
- } else if (TCL_OK != Ttk_GetSlaveIndexFromObj(
+ if (TCL_OK != Ttk_GetSlaveIndexFromObj(
interp, nb->notebook.mgr, objv[2], &destIndex)) {
return TCL_ERROR;
}
@@ -956,12 +971,14 @@ static int NotebookInsertCommand(
interp, nb->notebook.mgr, objv[3], &srcIndex) != TCL_OK)
{
return TCL_ERROR;
+ } else if (srcIndex >= (int)Ttk_NumberSlaves(nb->notebook.mgr)) {
+ srcIndex = Ttk_NumberSlaves(nb->notebook.mgr) - 1;
}
/* Move existing slave:
*/
if (ConfigureTab(interp, nb,
- Ttk_SlaveData(nb->notebook.mgr,srcIndex),
+ (Tab *)Ttk_SlaveData(nb->notebook.mgr,srcIndex),
Ttk_SlaveWindow(nb->notebook.mgr,srcIndex),
objc-4,objv+4) != TCL_OK)
{
@@ -995,7 +1012,7 @@ static int NotebookInsertCommand(
static int NotebookForgetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
int index;
if (objc != 3) {
@@ -1019,7 +1036,7 @@ static int NotebookForgetCommand(
static int NotebookHideCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
int index;
Tab *tab;
@@ -1032,7 +1049,7 @@ static int NotebookHideCommand(
return TCL_ERROR;
}
- tab = Ttk_SlaveData(nb->notebook.mgr, index);
+ tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index);
tab->state = TAB_STATE_HIDDEN;
if (index == nb->notebook.currentIndex) {
SelectNearestTab(nb);
@@ -1052,9 +1069,10 @@ static int NotebookIdentifyCommand(
static const char *const whatTable[] = { "element", "tab", NULL };
enum { IDENTIFY_ELEMENT, IDENTIFY_TAB };
int what = IDENTIFY_ELEMENT;
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
Ttk_Element element = NULL;
- int x, y, tabIndex;
+ int x, y;
+ TkSizeT tabIndex;
if (objc < 4 || objc > 5) {
Tcl_WrongNumArgs(interp, 2,objv, "?what? x y");
@@ -1070,8 +1088,8 @@ static int NotebookIdentifyCommand(
}
tabIndex = IdentifyTab(nb, x, y);
- if (tabIndex >= 0) {
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr, tabIndex);
+ if (tabIndex != TCL_INDEX_NONE) {
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, tabIndex);
Ttk_State state = TabState(nb, tabIndex);
Ttk_Layout tabLayout = nb->notebook.tabLayout;
@@ -1090,8 +1108,8 @@ static int NotebookIdentifyCommand(
}
break;
case IDENTIFY_TAB:
- if (tabIndex >= 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(tabIndex));
+ if (tabIndex != TCL_INDEX_NONE) {
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(tabIndex));
}
break;
}
@@ -1106,7 +1124,7 @@ static int NotebookIdentifyCommand(
static int NotebookIndexCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
int index, status;
if (objc != 3) {
@@ -1114,18 +1132,9 @@ static int NotebookIndexCommand(
return TCL_ERROR;
}
- /*
- * Special-case for "end":
- */
- if (!strcmp("end", Tcl_GetString(objv[2]))) {
- int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(nSlaves));
- return TCL_OK;
- }
-
status = FindTabIndex(interp, nb, objv[2], &index);
- if (status == TCL_OK && index >= 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ if (status == TCL_OK && index != -1) {
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
}
return status;
@@ -1138,7 +1147,7 @@ static int NotebookIndexCommand(
static int NotebookSelectCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
if (objc == 2) {
if (nb->notebook.currentIndex >= 0) {
@@ -1164,10 +1173,10 @@ static int NotebookSelectCommand(
static int NotebookTabsCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
Ttk_Manager *mgr = nb->notebook.mgr;
Tcl_Obj *result;
- int i;
+ TkSizeT i;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, "");
@@ -1189,7 +1198,7 @@ static int NotebookTabsCommand(
static int NotebookTabCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
Ttk_Manager *mgr = nb->notebook.mgr;
int index;
Tk_Window slaveWindow;
@@ -1204,7 +1213,7 @@ static int NotebookTabCommand(
return TCL_ERROR;
}
- tab = Ttk_SlaveData(mgr, index);
+ tab = (Tab *)Ttk_SlaveData(mgr, index);
slaveWindow = Ttk_SlaveWindow(mgr, index);
if (objc == 3) {
@@ -1254,7 +1263,7 @@ static const Ttk_Ensemble NotebookCommands[] = {
static void NotebookInitialize(Tcl_Interp *interp, void *recordPtr)
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
nb->notebook.mgr = Ttk_CreateManager(
&NotebookManagerSpec, recordPtr, nb->core.tkwin);
@@ -1274,7 +1283,7 @@ static void NotebookInitialize(Tcl_Interp *interp, void *recordPtr)
static void NotebookCleanup(void *recordPtr)
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
Ttk_DeleteManager(nb->notebook.mgr);
if (nb->notebook.tabLayout)
@@ -1283,7 +1292,7 @@ static void NotebookCleanup(void *recordPtr)
static int NotebookConfigure(Tcl_Interp *interp, void *clientData, int mask)
{
- Notebook *nb = clientData;
+ Notebook *nb = (Notebook *)clientData;
/*
* Error-checks:
@@ -1307,7 +1316,7 @@ static int NotebookConfigure(Tcl_Interp *interp, void *clientData, int mask)
static Ttk_Layout NotebookGetLayout(
Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
{
- Notebook *nb = recordPtr;
+ Notebook *nb = (Notebook *)recordPtr;
Ttk_Layout notebookLayout = TtkWidgetGetLayout(interp, theme, recordPtr);
Ttk_Layout tabLayout;
@@ -1335,7 +1344,7 @@ static Ttk_Layout NotebookGetLayout(
static void DisplayTab(Notebook *nb, int index, Drawable d)
{
Ttk_Layout tabLayout = nb->notebook.tabLayout;
- Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index);
+ Tab *tab = (Tab *)Ttk_SlaveData(nb->notebook.mgr, index);
Ttk_State state = TabState(nb, index);
if (tab->state != TAB_STATE_HIDDEN) {
@@ -1347,7 +1356,7 @@ static void DisplayTab(Notebook *nb, int index, Drawable d)
static void NotebookDisplay(void *clientData, Drawable d)
{
- Notebook *nb = clientData;
+ Notebook *nb = (Notebook *)clientData;
int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr);
int index;
@@ -1372,7 +1381,7 @@ static void NotebookDisplay(void *clientData, Drawable d)
* +++ Widget specification and layout definitions.
*/
-static WidgetSpec NotebookWidgetSpec =
+static const WidgetSpec NotebookWidgetSpec =
{
"TNotebook", /* className */
sizeof(Notebook), /* recordSize */
diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c
index 8f8094e..d06c863 100644
--- a/generic/ttk/ttkPanedwindow.c
+++ b/generic/ttk/ttkPanedwindow.c
@@ -74,15 +74,15 @@ typedef struct {
/* @@@ NOTE: -orient is readonly 'cause dynamic oriention changes NYI
*/
-static Tk_OptionSpec PanedOptionSpecs[] = {
+static const Tk_OptionSpec PanedOptionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical",
- Tk_Offset(Paned,paned.orientObj), Tk_Offset(Paned,paned.orient),
+ offsetof(Paned,paned.orientObj), offsetof(Paned,paned.orient),
0,(ClientData)ttkOrientStrings,READONLY_OPTION|STYLE_CHANGED },
{TK_OPTION_INT, "-width", "width", "Width", "0",
- -1,Tk_Offset(Paned,paned.width),
+ TCL_INDEX_NONE, offsetof(Paned,paned.width),
0,0,GEOMETRY_CHANGED },
{TK_OPTION_INT, "-height", "height", "Height", "0",
- -1,Tk_Offset(Paned,paned.height),
+ TCL_INDEX_NONE, offsetof(Paned,paned.height),
0,0,GEOMETRY_CHANGED },
WIDGET_TAKEFOCUS_FALSE,
@@ -98,10 +98,10 @@ typedef struct {
int weight; /* Pane -weight, for resizing */
} Pane;
-static Tk_OptionSpec PaneOptionSpecs[] = {
+static const Tk_OptionSpec PaneOptionSpecs[] = {
{TK_OPTION_INT, "-weight", "weight", "Weight", "0",
- -1,Tk_Offset(Pane,weight), 0,0,GEOMETRY_CHANGED },
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
+ TCL_INDEX_NONE, offsetof(Pane,weight), 0,0,GEOMETRY_CHANGED },
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
};
/* CreatePane --
@@ -111,7 +111,7 @@ static Pane *CreatePane(Tcl_Interp *interp, Paned *pw, Tk_Window slaveWindow)
{
Tk_OptionTable optionTable = pw->paned.paneOptionTable;
void *record = ckalloc(sizeof(Pane));
- Pane *pane = record;
+ Pane *pane = (Pane *)record;
memset(record, 0, sizeof(Pane));
if (Tk_InitOptions(interp, record, optionTable, slaveWindow) != TCL_OK) {
@@ -188,14 +188,14 @@ error:
static int ShoveUp(Paned *pw, int i, int pos)
{
- Pane *pane = Ttk_SlaveData(pw->paned.mgr, i);
+ Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, i);
int sashThickness = pw->paned.sashThickness;
if (i == 0) {
if (pos < 0)
pos = 0;
} else {
- Pane *prevPane = Ttk_SlaveData(pw->paned.mgr, i-1);
+ Pane *prevPane = (Pane *)Ttk_SlaveData(pw->paned.mgr, i-1);
if (pos < prevPane->sashPos + sashThickness)
pos = ShoveUp(pw, i-1, pos - sashThickness) + sashThickness;
}
@@ -206,15 +206,15 @@ static int ShoveUp(Paned *pw, int i, int pos)
* Same as ShoveUp, but going in the opposite direction
* and stopping at the sentinel sash.
*/
-static int ShoveDown(Paned *pw, int i, int pos)
+static int ShoveDown(Paned *pw, TkSizeT i, int pos)
{
- Pane *pane = Ttk_SlaveData(pw->paned.mgr,i);
+ Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr,i);
int sashThickness = pw->paned.sashThickness;
if (i == Ttk_NumberSlaves(pw->paned.mgr) - 1) {
pos = pane->sashPos; /* Sentinel value == master window size */
} else {
- Pane *nextPane = Ttk_SlaveData(pw->paned.mgr,i+1);
+ Pane *nextPane = (Pane *)Ttk_SlaveData(pw->paned.mgr,i+1);
if (pos + sashThickness > nextPane->sashPos)
pos = ShoveDown(pw, i+1, pos + sashThickness) - sashThickness;
}
@@ -229,7 +229,7 @@ static int ShoveDown(Paned *pw, int i, int pos)
*/
static int PanedSize(void *recordPtr, int *widthPtr, int *heightPtr)
{
- Paned *pw = recordPtr;
+ Paned *pw = (Paned *)recordPtr;
int nPanes = Ttk_NumberSlaves(pw->paned.mgr);
int nSashes = nPanes - 1;
int sashThickness = pw->paned.sashThickness;
@@ -238,7 +238,7 @@ static int PanedSize(void *recordPtr, int *widthPtr, int *heightPtr)
if (pw->paned.orient == TTK_ORIENT_HORIZONTAL) {
for (index = 0; index < nPanes; ++index) {
- Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
+ Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index);
Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index);
if (height < Tk_ReqHeight(slaveWindow))
@@ -248,7 +248,7 @@ static int PanedSize(void *recordPtr, int *widthPtr, int *heightPtr)
width += nSashes * sashThickness;
} else {
for (index = 0; index < nPanes; ++index) {
- Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
+ Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index);
Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index);
if (width < Tk_ReqWidth(slaveWindow))
@@ -275,10 +275,10 @@ static void AdjustPanes(Paned *pw)
{
int sashThickness = pw->paned.sashThickness;
int pos = 0;
- int index;
+ TkSizeT index;
for (index = 0; index < Ttk_NumberSlaves(pw->paned.mgr); ++index) {
- Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
+ Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index);
int size = pane->sashPos - pos;
pane->reqSize = size >= 0 ? size : 0;
pos = pane->sashPos + sashThickness;
@@ -316,7 +316,7 @@ static void PlaceSashes(Paned *pw, int width, int height)
/* Compute total required size and total available weight:
*/
for (i = 0; i < nPanes; ++i) {
- Pane *pane = Ttk_SlaveData(mgr, i);
+ Pane *pane = (Pane *)Ttk_SlaveData(mgr, i);
reqSize += pane->reqSize;
totalWeight += pane->weight * (pane->reqSize != 0);
}
@@ -340,7 +340,7 @@ static void PlaceSashes(Paned *pw, int width, int height)
*/
pos = 0;
for (i = 0; i < nPanes; ++i) {
- Pane *pane = Ttk_SlaveData(mgr, i);
+ Pane *pane = (Pane *)Ttk_SlaveData(mgr, i);
int weight = pane->weight * (pane->reqSize != 0);
int size = pane->reqSize + delta * weight;
@@ -372,10 +372,10 @@ static void PlacePanes(Paned *pw)
int width = Tk_Width(pw->core.tkwin), height = Tk_Height(pw->core.tkwin);
int sashThickness = pw->paned.sashThickness;
int pos = 0;
- int index;
+ TkSizeT index;
for (index = 0; index < Ttk_NumberSlaves(pw->paned.mgr); ++index) {
- Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
+ Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index);
int size = pane->sashPos - pos;
if (size > 0) {
@@ -398,15 +398,15 @@ static void PlacePanes(Paned *pw)
static void PanedPlaceSlaves(void *managerData)
{
- Paned *pw = managerData;
+ Paned *pw = (Paned *)managerData;
PlaceSashes(pw, Tk_Width(pw->core.tkwin), Tk_Height(pw->core.tkwin));
PlacePanes(pw);
}
-static void PaneRemoved(void *managerData, int index)
+static void PaneRemoved(void *managerData, TkSizeT index)
{
- Paned *pw = managerData;
- Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
+ Paned *pw = (Paned *)managerData;
+ Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index);
DestroyPane(pw, pane);
}
@@ -419,7 +419,7 @@ static int AddPane(
if (!Ttk_Maintainable(interp, slaveWindow, pw->core.tkwin)) {
return TCL_ERROR;
}
- if (Ttk_SlaveIndex(pw->paned.mgr, slaveWindow) >= 0) {
+ if (Ttk_SlaveIndex(pw->paned.mgr, slaveWindow) != TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s already added", Tk_PathName(slaveWindow)));
Tcl_SetErrorCode(interp, "TTK", "PANE", "PRESENT", NULL);
@@ -445,10 +445,10 @@ static int AddPane(
* in order to avoid unexpected pane resizes (esp. while the
* user is dragging a sash [#1325286]).
*/
-static int PaneRequest(void *managerData, int index, int width, int height)
+static int PaneRequest(void *managerData, TkSizeT index, int width, int height)
{
- Paned *pw = managerData;
- Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
+ Paned *pw = (Paned *)managerData;
+ Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index);
Tk_Window slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, index);
int horizontal = pw->paned.orient == TTK_ORIENT_HORIZONTAL;
@@ -482,7 +482,7 @@ static Ttk_ManagerSpec PanedManagerSpec = {
static const unsigned PanedEventMask = LeaveWindowMask;
static void PanedEventProc(ClientData clientData, XEvent *eventPtr)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
if ( eventPtr->type == LeaveNotify
&& eventPtr->xcrossing.detail == NotifyInferior)
{
@@ -496,7 +496,7 @@ static void PanedEventProc(ClientData clientData, XEvent *eventPtr)
static void PanedInitialize(Tcl_Interp *interp, void *recordPtr)
{
- Paned *pw = recordPtr;
+ Paned *pw = (Paned *)recordPtr;
Tk_CreateEventHandler(pw->core.tkwin,
PanedEventMask, PanedEventProc, recordPtr);
@@ -508,7 +508,7 @@ static void PanedInitialize(Tcl_Interp *interp, void *recordPtr)
static void PanedCleanup(void *recordPtr)
{
- Paned *pw = recordPtr;
+ Paned *pw = (Paned *)recordPtr;
if (pw->paned.sashLayout)
Ttk_FreeLayout(pw->paned.sashLayout);
@@ -519,9 +519,10 @@ static void PanedCleanup(void *recordPtr)
/* Post-configuration hook.
*/
-static int PanedPostConfigure(Tcl_Interp *interp, void *clientData, int mask)
+static int PanedPostConfigure(Tcl_Interp *dummy, void *clientData, int mask)
{
- Paned *pw = clientData;
+ Paned *pw = (Paned *)clientData;
+ (void)dummy;
if (mask & GEOMETRY_CHANGED) {
/* User has changed -width or -height.
@@ -542,7 +543,7 @@ static int PanedPostConfigure(Tcl_Interp *interp, void *clientData, int mask)
static Ttk_Layout PanedGetLayout(
Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr)
{
- Paned *pw = recordPtr;
+ Paned *pw = (Paned *)recordPtr;
Ttk_Layout panedLayout = TtkWidgetGetLayout(interp, themePtr, recordPtr);
if (panedLayout) {
@@ -580,7 +581,7 @@ static Ttk_Layout PanedGetLayout(
*/
static Ttk_Layout SashLayout(Paned *pw, int index)
{
- Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
+ Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index);
int thickness = pw->paned.sashThickness,
height = Tk_Height(pw->core.tkwin),
width = Tk_Width(pw->core.tkwin),
@@ -602,12 +603,12 @@ static void DrawSash(Paned *pw, int index, Drawable d)
static void PanedDisplay(void *recordPtr, Drawable d)
{
- Paned *pw = recordPtr;
- int i, nSashes = Ttk_NumberSlaves(pw->paned.mgr) - 1;
+ Paned *pw = (Paned *)recordPtr;
+ TkSizeT i, nSlaves = Ttk_NumberSlaves(pw->paned.mgr);
TtkWidgetDisplay(recordPtr, d);
- for (i = 0; i < nSashes; ++i) {
- DrawSash(pw, i, d);
+ for (i = 1; i < nSlaves; ++i) {
+ DrawSash(pw, i - 1, d);
}
}
@@ -620,7 +621,7 @@ static void PanedDisplay(void *recordPtr, Drawable d)
static int PanedAddCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Paned *pw = recordPtr;
+ Paned *pw = (Paned *)recordPtr;
Tk_Window slaveWindow;
if (objc < 3) {
@@ -645,7 +646,7 @@ static int PanedAddCommand(
static int PanedInsertCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Paned *pw = recordPtr;
+ Paned *pw = (Paned *)recordPtr;
int nSlaves = Ttk_NumberSlaves(pw->paned.mgr);
int srcIndex, destIndex;
Tk_Window slaveWindow;
@@ -661,9 +662,7 @@ static int PanedInsertCommand(
return TCL_ERROR;
}
- if (!strcmp(Tcl_GetString(objv[2]), "end")) {
- destIndex = Ttk_NumberSlaves(pw->paned.mgr);
- } else if (TCL_OK != Ttk_GetSlaveIndexFromObj(
+ if (TCL_OK != Ttk_GetSlaveIndexFromObj(
interp,pw->paned.mgr,objv[2],&destIndex))
{
return TCL_ERROR;
@@ -680,7 +679,7 @@ static int PanedInsertCommand(
return objc == 4 ? TCL_OK :
ConfigurePane(interp, pw,
- Ttk_SlaveData(pw->paned.mgr, destIndex),
+ (Pane *)Ttk_SlaveData(pw->paned.mgr, destIndex),
Ttk_SlaveWindow(pw->paned.mgr, destIndex),
objc-4,objv+4);
}
@@ -690,7 +689,7 @@ static int PanedInsertCommand(
static int PanedForgetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Paned *pw = recordPtr;
+ Paned *pw = (Paned *)recordPtr;
int paneIndex;
if (objc != 3) {
@@ -702,6 +701,8 @@ static int PanedForgetCommand(
interp, pw->paned.mgr, objv[2], &paneIndex))
{
return TCL_ERROR;
+ } else if (paneIndex >= (int)Ttk_NumberSlaves(pw->paned.mgr)) {
+ paneIndex = Ttk_NumberSlaves(pw->paned.mgr) - 1;
}
Ttk_ForgetSlave(pw->paned.mgr, paneIndex);
@@ -717,7 +718,7 @@ static int PanedIdentifyCommand(
static const char *const whatTable[] = { "element", "sash", NULL };
enum { IDENTIFY_ELEMENT, IDENTIFY_SASH };
int what = IDENTIFY_SASH;
- Paned *pw = recordPtr;
+ Paned *pw = (Paned *)recordPtr;
int sashThickness = pw->paned.sashThickness;
int nSashes = Ttk_NumberSlaves(pw->paned.mgr) - 1;
int x, y, pos;
@@ -738,12 +739,12 @@ static int PanedIdentifyCommand(
pos = pw->paned.orient == TTK_ORIENT_HORIZONTAL ? x : y;
for (index = 0; index < nSashes; ++index) {
- Pane *pane = Ttk_SlaveData(pw->paned.mgr, index);
+ Pane *pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, index);
if (pane->sashPos <= pos && pos <= pane->sashPos + sashThickness) {
/* Found it. */
switch (what) {
case IDENTIFY_SASH:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
return TCL_OK;
case IDENTIFY_ELEMENT:
{
@@ -768,7 +769,7 @@ static int PanedIdentifyCommand(
static int PanedPaneCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Paned *pw = recordPtr;
+ Paned *pw = (Paned *)recordPtr;
int paneIndex;
Tk_Window slaveWindow;
Pane *pane;
@@ -782,9 +783,11 @@ static int PanedPaneCommand(
interp,pw->paned.mgr,objv[2],&paneIndex))
{
return TCL_ERROR;
+ } else if (paneIndex >= (int)Ttk_NumberSlaves(pw->paned.mgr)) {
+ paneIndex = Ttk_NumberSlaves(pw->paned.mgr) - 1;
}
- pane = Ttk_SlaveData(pw->paned.mgr, paneIndex);
+ pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, paneIndex);
slaveWindow = Ttk_SlaveWindow(pw->paned.mgr, paneIndex);
switch (objc) {
@@ -805,10 +808,10 @@ static int PanedPaneCommand(
static int PanedPanesCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Paned *pw = recordPtr;
+ Paned *pw = (Paned *)recordPtr;
Ttk_Manager *mgr = pw->paned.mgr;
Tcl_Obj *panes;
- int i;
+ TkSizeT i;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, "");
@@ -832,7 +835,7 @@ static int PanedPanesCommand(
static int PanedSashposCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Paned *pw = recordPtr;
+ Paned *pw = (Paned *)recordPtr;
int sashIndex, position = -1;
Pane *pane;
@@ -843,17 +846,17 @@ static int PanedSashposCommand(
if (Tcl_GetIntFromObj(interp, objv[2], &sashIndex) != TCL_OK) {
return TCL_ERROR;
}
- if (sashIndex < 0 || sashIndex >= Ttk_NumberSlaves(pw->paned.mgr) - 1) {
+ if (sashIndex < 0 || (TkSizeT)(sashIndex + 1) >= Ttk_NumberSlaves(pw->paned.mgr)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"sash index %d out of range", sashIndex));
Tcl_SetErrorCode(interp, "TTK", "PANE", "SASH_INDEX", NULL);
return TCL_ERROR;
}
- pane = Ttk_SlaveData(pw->paned.mgr, sashIndex);
+ pane = (Pane *)Ttk_SlaveData(pw->paned.mgr, sashIndex);
if (objc == 3) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(pane->sashPos));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pane->sashPos));
return TCL_OK;
}
/* else -- set new sash position */
@@ -871,7 +874,7 @@ static int PanedSashposCommand(
AdjustPanes(pw);
Ttk_ManagerLayoutChanged(pw->paned.mgr);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(pane->sashPos));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pane->sashPos));
return TCL_OK;
}
@@ -894,7 +897,7 @@ static const Ttk_Ensemble PanedCommands[] = {
* +++ Widget specification.
*/
-static WidgetSpec PanedWidgetSpec =
+static const WidgetSpec PanedWidgetSpec =
{
"TPanedwindow", /* className */
sizeof(Paned), /* recordSize */
@@ -920,23 +923,27 @@ typedef struct {
Tcl_Obj *thicknessObj;
} SashElement;
-static Ttk_ElementOptionSpec SashElementOptions[] = {
+static const Ttk_ElementOptionSpec SashElementOptions[] = {
{ "-sashthickness", TK_OPTION_INT,
- Tk_Offset(SashElement,thicknessObj), "5" },
- { NULL, 0, 0, NULL }
+ offsetof(SashElement,thicknessObj), "5" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void SashElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- SashElement *sash = elementRecord;
+ SashElement *sash = (SashElement *)elementRecord;
int thickness = DEFAULT_SASH_THICKNESS;
+ (void)dummy;
+ (void)tkwin;
+ (void)paddingPtr;
+
Tcl_GetIntFromObj(NULL, sash->thicknessObj, &thickness);
*widthPtr = *heightPtr = thickness;
}
-static Ttk_ElementSpec SashElementSpec = {
+static const Ttk_ElementSpec SashElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SashElement),
SashElementOptions,
diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c
index cb4b464..6e5875e 100644
--- a/generic/ttk/ttkProgress.c
+++ b/generic/ttk/ttkProgress.c
@@ -48,47 +48,47 @@ typedef struct {
ProgressbarPart progress;
} Progressbar;
-static Tk_OptionSpec ProgressbarOptionSpecs[] =
+static const Tk_OptionSpec ProgressbarOptionSpecs[] =
{
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- "w", Tk_Offset(Progressbar,progress.anchorObj), -1,
+ "w", offsetof(Progressbar,progress.anchorObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEFAULT_FONT, Tk_Offset(Progressbar,progress.fontObj), -1,
+ DEFAULT_FONT, offsetof(Progressbar,progress.fontObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
- "black", Tk_Offset(Progressbar,progress.foregroundObj), -1,
+ "black", offsetof(Progressbar,progress.foregroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- "left", Tk_Offset(Progressbar,progress.justifyObj), -1,
+ "left", offsetof(Progressbar,progress.justifyObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_PIXELS, "-length", "length", "Length",
- DEF_PROGRESSBAR_LENGTH, Tk_Offset(Progressbar,progress.lengthObj), -1,
+ DEF_PROGRESSBAR_LENGTH, offsetof(Progressbar,progress.lengthObj), TCL_INDEX_NONE,
0, 0, GEOMETRY_CHANGED },
{TK_OPTION_DOUBLE, "-maximum", "maximum", "Maximum",
- "100", Tk_Offset(Progressbar,progress.maximumObj), -1,
+ "100", offsetof(Progressbar,progress.maximumObj), TCL_INDEX_NONE,
0, 0, 0 },
{TK_OPTION_STRING_TABLE, "-mode", "mode", "ProgressMode", "determinate",
- Tk_Offset(Progressbar,progress.modeObj),
- Tk_Offset(Progressbar,progress.mode),
+ offsetof(Progressbar,progress.modeObj),
+ offsetof(Progressbar,progress.mode),
0, (ClientData)ProgressbarModeStrings, 0 },
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
- "horizontal", Tk_Offset(Progressbar,progress.orientObj), -1,
+ "horizontal", offsetof(Progressbar,progress.orientObj), TCL_INDEX_NONE,
0, (ClientData)ttkOrientStrings, STYLE_CHANGED },
{TK_OPTION_INT, "-phase", "phase", "Phase",
- "0", Tk_Offset(Progressbar,progress.phaseObj), -1,
+ "0", offsetof(Progressbar,progress.phaseObj), TCL_INDEX_NONE,
0, 0, 0 },
{TK_OPTION_STRING, "-text", "text", "Text", "",
- Tk_Offset(Progressbar,progress.textObj), -1,
+ offsetof(Progressbar,progress.textObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_DOUBLE, "-value", "value", "Value",
- "0.0", Tk_Offset(Progressbar,progress.valueObj), -1,
+ "0.0", offsetof(Progressbar,progress.valueObj), TCL_INDEX_NONE,
0, 0, 0 },
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- NULL, Tk_Offset(Progressbar,progress.variableObj), -1,
+ NULL, offsetof(Progressbar,progress.variableObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0 },
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- "0", Tk_Offset(Progressbar, progress.wrapLengthObj), -1,
+ "0", offsetof(Progressbar, progress.wrapLengthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED},
WIDGET_TAKEFOCUS_FALSE,
@@ -122,7 +122,7 @@ static int AnimationEnabled(Progressbar *pb)
*/
static void AnimateProgressProc(ClientData clientData)
{
- Progressbar *pb = clientData;
+ Progressbar *pb = (Progressbar *)clientData;
pb->progress.timer = 0;
@@ -175,7 +175,7 @@ static void CheckAnimation(Progressbar *pb)
static void VariableChanged(void *recordPtr, const char *value)
{
- Progressbar *pb = recordPtr;
+ Progressbar *pb = (Progressbar *)recordPtr;
Tcl_Obj *newValue;
double scratch;
@@ -208,16 +208,18 @@ static void VariableChanged(void *recordPtr, const char *value)
* +++ Widget class methods:
*/
-static void ProgressbarInitialize(Tcl_Interp *interp, void *recordPtr)
+static void ProgressbarInitialize(Tcl_Interp *dummy, void *recordPtr)
{
- Progressbar *pb = recordPtr;
+ Progressbar *pb = (Progressbar *)recordPtr;
+ (void)dummy;
+
pb->progress.variableTrace = 0;
pb->progress.timer = 0;
}
static void ProgressbarCleanup(void *recordPtr)
{
- Progressbar *pb = recordPtr;
+ Progressbar *pb = (Progressbar *)recordPtr;
if (pb->progress.variableTrace)
Ttk_UntraceVariable(pb->progress.variableTrace);
if (pb->progress.timer)
@@ -231,7 +233,7 @@ static void ProgressbarCleanup(void *recordPtr)
*/
static int ProgressbarConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Progressbar *pb = recordPtr;
+ Progressbar *pb = (Progressbar *)recordPtr;
Tcl_Obj *varName = pb->progress.variableObj;
Ttk_TraceHandle *vt = 0;
@@ -257,10 +259,12 @@ static int ProgressbarConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
* Post-configuration hook:
*/
static int ProgressbarPostConfigure(
- Tcl_Interp *interp, void *recordPtr, int mask)
+ Tcl_Interp *dummy, void *recordPtr, int mask)
{
- Progressbar *pb = recordPtr;
+ Progressbar *pb = (Progressbar *)recordPtr;
int status = TCL_OK;
+ (void)dummy;
+ (void)mask;
if (pb->progress.variableTrace) {
status = Ttk_FireTrace(pb->progress.variableTrace);
@@ -288,15 +292,16 @@ static int ProgressbarPostConfigure(
*/
static int ProgressbarSize(void *recordPtr, int *widthPtr, int *heightPtr)
{
- Progressbar *pb = recordPtr;
- int length = 100, orient = TTK_ORIENT_HORIZONTAL;
+ Progressbar *pb = (Progressbar *)recordPtr;
+ int length = 100;
+ Ttk_Orient orient = TTK_ORIENT_HORIZONTAL;
TtkWidgetSize(recordPtr, widthPtr, heightPtr);
/* Override requested width (height) based on -length and -orient
*/
Tk_GetPixelsFromObj(NULL, pb->core.tkwin, pb->progress.lengthObj, &length);
- Ttk_GetOrientFromObj(NULL, pb->progress.orientObj, &orient);
+ TtkGetOrientFromObj(NULL, pb->progress.orientObj, &orient);
if (orient == TTK_ORIENT_HORIZONTAL) {
*widthPtr = length;
@@ -356,11 +361,11 @@ static void ProgressbarIndeterminateLayout(
static void ProgressbarDoLayout(void *recordPtr)
{
- Progressbar *pb = recordPtr;
+ Progressbar *pb = (Progressbar *)recordPtr;
WidgetCore *corePtr = &pb->core;
Ttk_Element pbar = Ttk_FindElement(corePtr->layout, "pbar");
double value = 0.0, maximum = 100.0;
- int orient = TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = TTK_ORIENT_HORIZONTAL;
Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin));
@@ -369,7 +374,7 @@ static void ProgressbarDoLayout(void *recordPtr)
Tcl_GetDoubleFromObj(NULL, pb->progress.valueObj, &value);
Tcl_GetDoubleFromObj(NULL, pb->progress.maximumObj, &maximum);
- Ttk_GetOrientFromObj(NULL, pb->progress.orientObj, &orient);
+ TtkGetOrientFromObj(NULL, pb->progress.orientObj, &orient);
if (pbar) {
double fraction = value / maximum;
@@ -388,7 +393,7 @@ static void ProgressbarDoLayout(void *recordPtr)
static Ttk_Layout ProgressbarGetLayout(
Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
{
- Progressbar *pb = recordPtr;
+ Progressbar *pb = (Progressbar *)recordPtr;
Ttk_Layout layout = TtkWidgetGetOrientedLayout(
interp, theme, recordPtr, pb->progress.orientObj);
@@ -418,7 +423,7 @@ static Ttk_Layout ProgressbarGetLayout(
static int ProgressbarStepCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Progressbar *pb = recordPtr;
+ Progressbar *pb = (Progressbar *)recordPtr;
double value = 0.0, stepAmount = 1.0;
Tcl_Obj *newValueObj;
@@ -494,6 +499,8 @@ static int ProgressbarStartStopCommand(
static int ProgressbarStartCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+ (void)recordPtr;
+
return ProgressbarStartStopCommand(
interp, "::ttk::progressbar::start", objc, objv);
}
@@ -501,6 +508,8 @@ static int ProgressbarStartCommand(
static int ProgressbarStopCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
+ (void)recordPtr;
+
return ProgressbarStartStopCommand(
interp, "::ttk::progressbar::stop", objc, objv);
}
@@ -520,7 +529,7 @@ static const Ttk_Ensemble ProgressbarCommands[] = {
/*
* Widget specification:
*/
-static WidgetSpec ProgressbarWidgetSpec =
+static const WidgetSpec ProgressbarWidgetSpec =
{
"TProgressbar", /* className */
sizeof(Progressbar), /* recordSize */
diff --git a/generic/ttk/ttkScale.c b/generic/ttk/ttkScale.c
index 458bccd..a6bde9a 100644
--- a/generic/ttk/ttkScale.c
+++ b/generic/ttk/ttkScale.c
@@ -50,31 +50,31 @@ typedef struct
ScalePart scale;
} Scale;
-static Tk_OptionSpec ScaleOptionSpecs[] =
+static const Tk_OptionSpec ScaleOptionSpecs[] =
{
{TK_OPTION_STRING, "-command", "command", "Command", "",
- Tk_Offset(Scale,scale.commandObj), -1,
+ offsetof(Scale,scale.commandObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-variable", "variable", "Variable", "",
- Tk_Offset(Scale,scale.variableObj), -1,
+ offsetof(Scale,scale.variableObj), TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
- Tk_Offset(Scale,scale.orientObj),
- Tk_Offset(Scale,scale.orient), 0,
+ offsetof(Scale,scale.orientObj),
+ offsetof(Scale,scale.orient), 0,
(ClientData)ttkOrientStrings, STYLE_CHANGED },
{TK_OPTION_DOUBLE, "-from", "from", "From", "0",
- Tk_Offset(Scale,scale.fromObj), -1, 0, 0, 0},
+ offsetof(Scale,scale.fromObj), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_DOUBLE, "-to", "to", "To", "1.0",
- Tk_Offset(Scale,scale.toObj), -1, 0, 0, 0},
+ offsetof(Scale,scale.toObj), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_DOUBLE, "-value", "value", "Value", "0",
- Tk_Offset(Scale,scale.valueObj), -1, 0, 0, 0},
+ offsetof(Scale,scale.valueObj), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-length", "length", "Length",
- DEF_SCALE_LENGTH, Tk_Offset(Scale,scale.lengthObj), -1, 0, 0,
+ DEF_SCALE_LENGTH, offsetof(Scale,scale.lengthObj), TCL_INDEX_NONE, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-state", "state", "State",
- "normal", Tk_Offset(Scale,scale.stateObj), -1,
+ "normal", offsetof(Scale,scale.stateObj), TCL_INDEX_NONE,
0,0,STATE_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
@@ -92,7 +92,7 @@ static double PointToValue(Scale *scalePtr, int x, int y);
*/
static void ScaleVariableChanged(void *recordPtr, const char *value)
{
- Scale *scale = recordPtr;
+ Scale *scale = (Scale *)recordPtr;
double v;
if (value == NULL || Tcl_GetDouble(0, value, &v) != TCL_OK) {
@@ -110,15 +110,17 @@ static void ScaleVariableChanged(void *recordPtr, const char *value)
/* ScaleInitialize --
* Scale widget initialization hook.
*/
-static void ScaleInitialize(Tcl_Interp *interp, void *recordPtr)
+static void ScaleInitialize(Tcl_Interp *dummy, void *recordPtr)
{
- Scale *scalePtr = recordPtr;
+ Scale *scalePtr = (Scale *)recordPtr;
+ (void)dummy;
+
TtkTrackElementState(&scalePtr->core);
}
static void ScaleCleanup(void *recordPtr)
{
- Scale *scale = recordPtr;
+ Scale *scale = (Scale *)recordPtr;
if (scale->scale.variableTrace) {
Ttk_UntraceVariable(scale->scale.variableTrace);
@@ -131,7 +133,7 @@ static void ScaleCleanup(void *recordPtr)
*/
static int ScaleConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Scale *scale = recordPtr;
+ Scale *scale = (Scale *)recordPtr;
Tcl_Obj *varName = scale->scale.variableObj;
Ttk_TraceHandle *vt = 0;
@@ -161,10 +163,12 @@ static int ScaleConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
* Post-configuration hook.
*/
static int ScalePostConfigure(
- Tcl_Interp *interp, void *recordPtr, int mask)
+ Tcl_Interp *dummy, void *recordPtr, int mask)
{
- Scale *scale = recordPtr;
+ Scale *scale = (Scale *)recordPtr;
int status = TCL_OK;
+ (void)dummy;
+ (void)mask;
if (scale->scale.variableTrace) {
status = Ttk_FireTrace(scale->scale.variableTrace);
@@ -190,7 +194,7 @@ static int ScalePostConfigure(
static Ttk_Layout
ScaleGetLayout(Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
{
- Scale *scalePtr = recordPtr;
+ Scale *scalePtr = (Scale *)recordPtr;
return TtkWidgetGetOrientedLayout(
interp, theme, recordPtr, scalePtr->scale.orientObj);
}
@@ -258,7 +262,7 @@ static int
ScaleGetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Scale *scalePtr = recordPtr;
+ Scale *scalePtr = (Scale *)recordPtr;
int x, y, r = TCL_OK;
double value = 0;
@@ -286,7 +290,7 @@ static int
ScaleSetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Scale *scalePtr = recordPtr;
+ Scale *scalePtr = (Scale *)recordPtr;
double from = 0.0, to = 1.0, value;
int result = TCL_OK;
@@ -354,7 +358,7 @@ static int
ScaleCoordsCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Scale *scalePtr = recordPtr;
+ Scale *scalePtr = (Scale *)recordPtr;
double value;
int r = TCL_OK;
@@ -381,7 +385,7 @@ ScaleCoordsCommand(
static void ScaleDoLayout(void *clientData)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
Ttk_Element slider = Ttk_FindElement(corePtr->layout, "slider");
Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin));
@@ -389,7 +393,7 @@ static void ScaleDoLayout(void *clientData)
/* Adjust the slider position:
*/
if (slider) {
- Scale *scalePtr = clientData;
+ Scale *scalePtr = (Scale *)clientData;
Ttk_Box troughBox = TroughBox(scalePtr);
Ttk_Box sliderBox = Ttk_ElementParcel(slider);
double value = 0.0;
@@ -416,8 +420,8 @@ static void ScaleDoLayout(void *clientData)
*/
static int ScaleSize(void *clientData, int *widthPtr, int *heightPtr)
{
- WidgetCore *corePtr = clientData;
- Scale *scalePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
+ Scale *scalePtr = (Scale *)clientData;
int length;
Ttk_LayoutSize(corePtr->layout, corePtr->state, widthPtr, heightPtr);
@@ -488,7 +492,7 @@ static const Ttk_Ensemble ScaleCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec ScaleWidgetSpec =
+static const WidgetSpec ScaleWidgetSpec =
{
"TScale", /* Class name */
sizeof(Scale), /* record size */
diff --git a/generic/ttk/ttkScroll.c b/generic/ttk/ttkScroll.c
index 184f5f2..b031dc6 100644
--- a/generic/ttk/ttkScroll.c
+++ b/generic/ttk/ttkScroll.c
@@ -55,7 +55,7 @@ struct ScrollHandleRec
*/
ScrollHandle TtkCreateScrollHandle(WidgetCore *corePtr, Scrollable *scrollPtr)
{
- ScrollHandle h = ckalloc(sizeof(*h));
+ ScrollHandle h = (ScrollHandle)ckalloc(sizeof(*h));
h->flags = 0;
h->corePtr = corePtr;
@@ -104,15 +104,18 @@ static int UpdateScrollbar(Tcl_Interp *interp, ScrollHandle h)
Tcl_Release(corePtr);
if (code != TCL_OK && !Tcl_InterpDeleted(interp)) {
- /* Disable the -scrollcommand, add to stack trace:
+ /* Add error to stack trace.
+ * Also set the SCROLL_UPDATE_REQUIRED flag so that a later call to
+ * TtkScrolled has an effect. Indeed, the error in the -scrollcommand
+ * callback may later be gone, for instance the callback proc got
+ * defined in the meantime.
*/
- ckfree(s->scrollCmd);
- s->scrollCmd = 0;
Tcl_AddErrorInfo(interp, /* @@@ "horizontal" / "vertical" */
"\n (scrolling command executed by ");
Tcl_AddErrorInfo(interp, Tk_PathName(h->corePtr->tkwin));
Tcl_AddErrorInfo(interp, ")");
+ TtkScrollbarUpdateRequired(h);
}
return code;
}
@@ -181,6 +184,19 @@ void TtkScrollbarUpdateRequired(ScrollHandle h)
h->flags |= SCROLL_UPDATE_REQUIRED;
}
+/* TtkUpdateScrollInfo --
+ * Call the layoutProc to update the scroll info first, last, and total.
+ * Do it only if needed, that is when a redisplay is pending (which
+ * indicates scroll info are possibly out of date).
+ */
+
+void TtkUpdateScrollInfo(ScrollHandle h)
+{
+ if (h->corePtr->flags & REDISPLAY_PENDING) {
+ h->corePtr->widgetSpec->layoutProc(h->corePtr);
+ }
+}
+
/* TtkScrollviewCommand --
* Widget [xy]view command implementation.
*
@@ -193,7 +209,10 @@ int TtkScrollviewCommand(
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], ScrollHandle h)
{
Scrollable *s = h->scrollPtr;
- int newFirst = s->first;
+ int newFirst;
+
+ TtkUpdateScrollInfo(h);
+ newFirst = s->first;
if (objc == 2) {
Tcl_Obj *result[2];
@@ -226,15 +245,19 @@ int TtkScrollviewCommand(
}
}
- TtkScrollTo(h, newFirst);
+ TtkScrollTo(h, newFirst, 0);
return TCL_OK;
}
-void TtkScrollTo(ScrollHandle h, int newFirst)
+void TtkScrollTo(ScrollHandle h, int newFirst, int updateScrollInfo)
{
Scrollable *s = h->scrollPtr;
+ if (updateScrollInfo) {
+ TtkUpdateScrollInfo(h);
+ }
+
if (newFirst >= s->total)
newFirst = s->total - 1;
if (newFirst > s->first && s->last >= s->total) /* don't scroll past end */
diff --git a/generic/ttk/ttkScrollbar.c b/generic/ttk/ttkScrollbar.c
index f304ea9..1b915cc 100644
--- a/generic/ttk/ttkScrollbar.c
+++ b/generic/ttk/ttkScrollbar.c
@@ -31,14 +31,14 @@ typedef struct
ScrollbarPart scrollbar;
} Scrollbar;
-static Tk_OptionSpec ScrollbarOptionSpecs[] =
+static const Tk_OptionSpec ScrollbarOptionSpecs[] =
{
{TK_OPTION_STRING, "-command", "command", "Command", "",
- Tk_Offset(Scrollbar,scrollbar.commandObj), -1, 0,0,0},
+ offsetof(Scrollbar,scrollbar.commandObj), TCL_INDEX_NONE, 0,0,0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical",
- Tk_Offset(Scrollbar,scrollbar.orientObj),
- Tk_Offset(Scrollbar,scrollbar.orient),
+ offsetof(Scrollbar,scrollbar.orientObj),
+ offsetof(Scrollbar,scrollbar.orient),
0,(ClientData)ttkOrientStrings,STYLE_CHANGED },
WIDGET_TAKEFOCUS_FALSE,
@@ -50,9 +50,11 @@ static Tk_OptionSpec ScrollbarOptionSpecs[] =
*/
static void
-ScrollbarInitialize(Tcl_Interp *interp, void *recordPtr)
+ScrollbarInitialize(Tcl_Interp *dummy, void *recordPtr)
{
- Scrollbar *sb = recordPtr;
+ Scrollbar *sb = (Scrollbar *)recordPtr;
+ (void)dummy;
+
sb->scrollbar.first = 0.0;
sb->scrollbar.last = 1.0;
@@ -62,7 +64,7 @@ ScrollbarInitialize(Tcl_Interp *interp, void *recordPtr)
static Ttk_Layout ScrollbarGetLayout(
Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
{
- Scrollbar *sb = recordPtr;
+ Scrollbar *sb = (Scrollbar *)recordPtr;
return TtkWidgetGetOrientedLayout(
interp, theme, recordPtr, sb->scrollbar.orientObj);
}
@@ -76,7 +78,7 @@ static Ttk_Layout ScrollbarGetLayout(
*/
static void ScrollbarDoLayout(void *recordPtr)
{
- Scrollbar *sb = recordPtr;
+ Scrollbar *sb = (Scrollbar *)recordPtr;
WidgetCore *corePtr = &sb->core;
Ttk_Element thumb;
Ttk_Box thumbBox;
@@ -132,7 +134,7 @@ static int
ScrollbarSetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Scrollbar *scrollbar = recordPtr;
+ Scrollbar *scrollbar = (Scrollbar *)recordPtr;
Tcl_Obj *firstObj, *lastObj;
double first, last;
@@ -183,7 +185,7 @@ static int
ScrollbarGetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Scrollbar *scrollbar = recordPtr;
+ Scrollbar *scrollbar = (Scrollbar *)recordPtr;
Tcl_Obj *result[2];
if (objc != 2) {
@@ -206,7 +208,7 @@ static int
ScrollbarDeltaCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Scrollbar *sb = recordPtr;
+ Scrollbar *sb = (Scrollbar *)recordPtr;
double dx, dy;
double delta = 0.0;
@@ -246,7 +248,7 @@ static int
ScrollbarFractionCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Scrollbar *sb = recordPtr;
+ Scrollbar *sb = (Scrollbar *)recordPtr;
Ttk_Box b = sb->scrollbar.troughBox;
int minSize = sb->scrollbar.minSize;
double x, y;
@@ -294,7 +296,7 @@ static const Ttk_Ensemble ScrollbarCommands[] = {
/*------------------------------------------------------------------------
* +++ Widget specification.
*/
-static WidgetSpec ScrollbarWidgetSpec =
+static const WidgetSpec ScrollbarWidgetSpec =
{
"TScrollbar", /* className */
sizeof(Scrollbar), /* recordSize */
diff --git a/generic/ttk/ttkSeparator.c b/generic/ttk/ttkSeparator.c
index dae6d69..00605dc 100644
--- a/generic/ttk/ttkSeparator.c
+++ b/generic/ttk/ttkSeparator.c
@@ -22,10 +22,10 @@ typedef struct
SeparatorPart separator;
} Separator;
-static Tk_OptionSpec SeparatorOptionSpecs[] = {
+static const Tk_OptionSpec SeparatorOptionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
- Tk_Offset(Separator,separator.orientObj),
- Tk_Offset(Separator,separator.orient),
+ offsetof(Separator,separator.orientObj),
+ offsetof(Separator,separator.orient),
0,(ClientData)ttkOrientStrings,STYLE_CHANGED },
WIDGET_TAKEFOCUS_FALSE,
@@ -39,7 +39,7 @@ static Tk_OptionSpec SeparatorOptionSpecs[] = {
static Ttk_Layout SeparatorGetLayout(
Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
{
- Separator *sep = recordPtr;
+ Separator *sep = (Separator *)recordPtr;
return TtkWidgetGetOrientedLayout(
interp, theme, recordPtr, sep->separator.orientObj);
}
@@ -59,7 +59,7 @@ static const Ttk_Ensemble SeparatorCommands[] = {
/*
* Widget specification:
*/
-static WidgetSpec SeparatorWidgetSpec =
+static const WidgetSpec SeparatorWidgetSpec =
{
"TSeparator", /* className */
sizeof(Separator), /* recordSize */
@@ -83,7 +83,7 @@ TTK_END_LAYOUT
* Has no options or methods other than the standard ones.
*/
-static Tk_OptionSpec SizegripOptionSpecs[] = {
+static const Tk_OptionSpec SizegripOptionSpecs[] = {
WIDGET_TAKEFOCUS_FALSE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
@@ -97,7 +97,7 @@ static const Ttk_Ensemble SizegripCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec SizegripWidgetSpec =
+static const WidgetSpec SizegripWidgetSpec =
{
"TSizegrip", /* className */
sizeof(WidgetCore), /* recordSize */
diff --git a/generic/ttk/ttkSquare.c b/generic/ttk/ttkSquare.c
index 5302eb7..422afc3 100644
--- a/generic/ttk/ttkSquare.c
+++ b/generic/ttk/ttkSquare.c
@@ -48,31 +48,31 @@ typedef struct
* defined for all widgets.
*/
-static Tk_OptionSpec SquareOptionSpecs[] =
+static const Tk_OptionSpec SquareOptionSpecs[] =
{
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEFAULT_BORDERWIDTH, Tk_Offset(Square,square.borderWidthObj), -1,
+ DEFAULT_BORDERWIDTH, offsetof(Square,square.borderWidthObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_BORDER, "-foreground", "foreground", "Foreground",
- DEFAULT_BACKGROUND, Tk_Offset(Square,square.foregroundObj),
- -1, 0, 0, 0},
+ DEFAULT_BACKGROUND, offsetof(Square,square.foregroundObj),
+ TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- "50", Tk_Offset(Square,square.widthObj), -1, 0, 0,
+ "50", offsetof(Square,square.widthObj), TCL_INDEX_NONE, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- "50", Tk_Offset(Square,square.heightObj), -1, 0, 0,
+ "50", offsetof(Square,square.heightObj), TCL_INDEX_NONE, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-padding", "padding", "Pad", NULL,
- Tk_Offset(Square,square.paddingObj), -1,
+ offsetof(Square,square.paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- NULL, Tk_Offset(Square,square.reliefObj), -1, TK_OPTION_NULL_OK, 0, 0},
+ NULL, offsetof(Square,square.reliefObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- NULL, Tk_Offset(Square,square.anchorObj), -1, TK_OPTION_NULL_OK, 0, 0},
+ NULL, offsetof(Square,square.anchorObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
@@ -109,7 +109,7 @@ SquareDoLayout(void *clientData)
*/
if (squareNode) {
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
Tk_Anchor anchor = TK_ANCHOR_CENTER;
Ttk_Box b;
@@ -143,7 +143,7 @@ static const Ttk_Ensemble SquareCommands[] = {
* with Tk in the package initialization code (see bottom).
*/
-static WidgetSpec SquareWidgetSpec =
+static const WidgetSpec SquareWidgetSpec =
{
"TSquare", /* className */
sizeof(Square), /* recordSize */
@@ -176,19 +176,19 @@ typedef struct
Tcl_Obj *heightObj;
} SquareElement;
-static Ttk_ElementOptionSpec SquareElementOptions[] =
+static const Ttk_ElementOptionSpec SquareElementOptions[] =
{
- { "-background", TK_OPTION_BORDER, Tk_Offset(SquareElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(SquareElement,borderObj),
DEFAULT_BACKGROUND },
- { "-foreground", TK_OPTION_BORDER, Tk_Offset(SquareElement,foregroundObj),
+ { "-foreground", TK_OPTION_BORDER, offsetof(SquareElement,foregroundObj),
DEFAULT_BACKGROUND },
- { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(SquareElement,borderWidthObj),
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(SquareElement,borderWidthObj),
DEFAULT_BORDERWIDTH },
- { "-relief", TK_OPTION_RELIEF, Tk_Offset(SquareElement,reliefObj),
+ { "-relief", TK_OPTION_RELIEF, offsetof(SquareElement,reliefObj),
"raised" },
- { "-width", TK_OPTION_PIXELS, Tk_Offset(SquareElement,widthObj), "20"},
- { "-height", TK_OPTION_PIXELS, Tk_Offset(SquareElement,heightObj), "20"},
- { NULL, 0, 0, NULL }
+ { "-width", TK_OPTION_PIXELS, offsetof(SquareElement,widthObj), "20"},
+ { "-height", TK_OPTION_PIXELS, offsetof(SquareElement,heightObj), "20"},
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
/*
@@ -198,11 +198,12 @@ static Ttk_ElementOptionSpec SquareElementOptions[] =
*/
static void SquareElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- SquareElement *square = elementRecord;
+ SquareElement *square = (SquareElement *)elementRecord;
int borderWidth = 0;
+ (void)dummy;
Tcl_GetIntFromObj(NULL, square->borderWidthObj, &borderWidth);
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
@@ -215,12 +216,14 @@ static void SquareElementSize(
*/
static void SquareElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- SquareElement *square = elementRecord;
+ SquareElement *square = (SquareElement *)elementRecord;
Tk_3DBorder foreground = NULL;
int borderWidth = 1, relief = TK_RELIEF_FLAT;
+ (void)dummy;
+ (void)state;
foreground = Tk_Get3DBorderFromObj(tkwin, square->foregroundObj);
Tcl_GetIntFromObj(NULL, square->borderWidthObj, &borderWidth);
@@ -230,7 +233,7 @@ static void SquareElementDraw(
b.x, b.y, b.width, b.height, borderWidth, relief);
}
-static Ttk_ElementSpec SquareElementSpec =
+static const Ttk_ElementSpec SquareElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(SquareElement),
diff --git a/generic/ttk/ttkState.c b/generic/ttk/ttkState.c
index 9e5cf4b..a704fa4 100644
--- a/generic/ttk/ttkState.c
+++ b/generic/ttk/ttkState.c
@@ -145,14 +145,14 @@ static void StateSpecUpdateString(Tcl_Obj *objPtr)
len = Tcl_DStringLength(&result);
if (len) {
/* 'len' includes extra trailing ' ' */
- objPtr->bytes = ckalloc(len);
+ objPtr->bytes = (char *)ckalloc(len);
objPtr->length = len-1;
strncpy(objPtr->bytes, Tcl_DStringValue(&result), len-1);
objPtr->bytes[len-1] = '\0';
} else {
/* empty string */
objPtr->length = 0;
- objPtr->bytes = ckalloc(1);
+ objPtr->bytes = (char *)ckalloc(1);
*objPtr->bytes = '\0';
}
@@ -261,7 +261,7 @@ Ttk_StateMap Ttk_GetStateMapFromObj(
* Ttk_StateTableLooup --
* Look up an index from a statically allocated state table.
*/
-int Ttk_StateTableLookup(Ttk_StateTable *map, unsigned int state)
+int Ttk_StateTableLookup(const Ttk_StateTable *map, unsigned int state)
{
while ((state & map->onBits) != map->onBits
|| (~state & map->offBits) != map->offBits)
diff --git a/generic/ttk/ttkStubInit.c b/generic/ttk/ttkStubInit.c
index 87b33dc..31cdaa8 100644
--- a/generic/ttk/ttkStubInit.c
+++ b/generic/ttk/ttkStubInit.c
@@ -8,6 +8,18 @@
MODULE_SCOPE const TtkStubs ttkStubs;
+#if defined(TK_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8
+#define Ttk_GetOrientFromObj 0
+#endif
+
+#ifdef __GNUC__
+/*
+ * The rest of this file shouldn't warn about deprecated functions; they're
+ * there because we intend them to be so and know that this file is OK to
+ * touch those fields.
+ */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
/* !BEGIN!: Do not edit below this line. */
const TtkStubs ttkStubs = {
diff --git a/generic/ttk/ttkStubLib.c b/generic/ttk/ttkStubLib.c
index c17f1e9..5675416 100644
--- a/generic/ttk/ttkStubLib.c
+++ b/generic/ttk/ttkStubLib.c
@@ -36,10 +36,10 @@ TtkInitializeStubs(
int exact = 0;
const char *packageName = "Ttk";
const char *errMsg = NULL;
- ClientData pkgClientData = NULL;
+ void *pkgClientData = NULL;
const char *actualVersion = Tcl_PkgRequireEx(
interp, packageName, version, exact, &pkgClientData);
- const TtkStubs *stubsPtr = pkgClientData;
+ const TtkStubs *stubsPtr = (const TtkStubs *)pkgClientData;
if (!actualVersion) {
return NULL;
diff --git a/generic/ttk/ttkTagSet.c b/generic/ttk/ttkTagSet.c
index f0354d8..96e6c4e 100644
--- a/generic/ttk/ttkTagSet.c
+++ b/generic/ttk/ttkTagSet.c
@@ -19,7 +19,7 @@ struct TtkTag {
struct TtkTagTable {
Tk_Window tkwin; /* owner window */
- Tk_OptionSpec *optionSpecs; /* ... */
+ const Tk_OptionSpec *optionSpecs; /* ... */
Tk_OptionTable optionTable; /* ... */
int recordSize; /* size of tag record */
int nTags; /* #tags defined so far */
@@ -31,7 +31,7 @@ struct TtkTagTable {
*/
static Ttk_Tag NewTag(Ttk_TagTable tagTable, const char *tagName)
{
- Ttk_Tag tag = ckalloc(sizeof(*tag));
+ Ttk_Tag tag = (Ttk_Tag)ckalloc(sizeof(*tag));
tag->tagRecord = ckalloc(tagTable->recordSize);
memset(tag->tagRecord, 0, tagTable->recordSize);
/* Don't need Tk_InitOptions() here, all defaults should be NULL. */
@@ -53,9 +53,9 @@ static void DeleteTag(Ttk_TagTable tagTable, Ttk_Tag tag)
Ttk_TagTable Ttk_CreateTagTable(
Tcl_Interp *interp, Tk_Window tkwin,
- Tk_OptionSpec optionSpecs[], int recordSize)
+ const Tk_OptionSpec *optionSpecs, int recordSize)
{
- Ttk_TagTable tagTable = ckalloc(sizeof(*tagTable));
+ Ttk_TagTable tagTable = (Ttk_TagTable)ckalloc(sizeof(*tagTable));
tagTable->tkwin = tkwin;
tagTable->optionSpecs = optionSpecs;
tagTable->optionTable = Tk_CreateOptionTable(interp, optionSpecs);
@@ -72,7 +72,7 @@ void Ttk_DeleteTagTable(Ttk_TagTable tagTable)
entryPtr = Tcl_FirstHashEntry(&tagTable->tags, &search);
while (entryPtr != NULL) {
- DeleteTag(tagTable, Tcl_GetHashValue(entryPtr));
+ DeleteTag(tagTable, (Ttk_Tag)Tcl_GetHashValue(entryPtr));
entryPtr = Tcl_NextHashEntry(&search);
}
@@ -80,6 +80,17 @@ void Ttk_DeleteTagTable(Ttk_TagTable tagTable)
ckfree(tagTable);
}
+void Ttk_DeleteTagFromTable(Ttk_TagTable tagTable, Ttk_Tag tag)
+{
+ Tcl_HashEntry *entryPtr;
+
+ entryPtr = Tcl_FindHashEntry(&tagTable->tags, tag->tagName);
+ if (entryPtr != NULL) {
+ DeleteTag(tagTable, tag);
+ Tcl_DeleteHashEntry(entryPtr);
+ }
+}
+
Ttk_Tag Ttk_GetTag(Ttk_TagTable tagTable, const char *tagName)
{
int isNew = 0;
@@ -87,10 +98,10 @@ Ttk_Tag Ttk_GetTag(Ttk_TagTable tagTable, const char *tagName)
&tagTable->tags, tagName, &isNew);
if (isNew) {
- tagName = Tcl_GetHashKey(&tagTable->tags, entryPtr);
+ tagName = (char *)Tcl_GetHashKey(&tagTable->tags, entryPtr);
Tcl_SetHashValue(entryPtr, NewTag(tagTable,tagName));
}
- return Tcl_GetHashValue(entryPtr);
+ return (Ttk_Tag)Tcl_GetHashValue(entryPtr);
}
Ttk_Tag Ttk_GetTagFromObj(Ttk_TagTable tagTable, Tcl_Obj *objPtr)
@@ -113,7 +124,7 @@ Ttk_Tag Ttk_GetTagFromObj(Ttk_TagTable tagTable, Tcl_Obj *objPtr)
Ttk_TagSet Ttk_GetTagSetFromObj(
Tcl_Interp *interp, Ttk_TagTable tagTable, Tcl_Obj *objPtr)
{
- Ttk_TagSet tagset = ckalloc(sizeof(*tagset));
+ Ttk_TagSet tagset = (Ttk_TagSet)ckalloc(sizeof(*tagset));
Tcl_Obj **objv;
int i, objc;
@@ -128,7 +139,7 @@ Ttk_TagSet Ttk_GetTagSetFromObj(
return NULL;
}
- tagset->tags = ckalloc((objc+1) * sizeof(Ttk_Tag));
+ tagset->tags = (Ttk_Tag *)ckalloc((objc+1) * sizeof(Ttk_Tag));
for (i=0; i<objc; ++i) {
tagset->tags[i] = Ttk_GetTagFromObj(tagTable, objv[i]);
}
@@ -185,7 +196,7 @@ int Ttk_TagSetAdd(Ttk_TagSet tagset, Ttk_Tag tag)
return 0;
}
}
- tagset->tags = ckrealloc(tagset->tags,
+ tagset->tags = (Ttk_Tag *)ckrealloc(tagset->tags,
(tagset->nTags+1)*sizeof(tagset->tags[0]));
tagset->tags[tagset->nTags++] = tag;
return 1;
@@ -269,7 +280,7 @@ void Ttk_TagSetValues(Ttk_TagTable tagTable, Ttk_TagSet tagSet, void *record)
memset(record, 0, tagTable->recordSize);
for (i = 0; tagTable->optionSpecs[i].type != TK_OPTION_END; ++i) {
- Tk_OptionSpec *optionSpec = tagTable->optionSpecs + i;
+ const Tk_OptionSpec *optionSpec = tagTable->optionSpecs + i;
int offset = optionSpec->objOffset;
int prio = LOWEST_PRIORITY;
@@ -286,7 +297,7 @@ void Ttk_TagSetValues(Ttk_TagTable tagTable, Ttk_TagSet tagSet, void *record)
void Ttk_TagSetApplyStyle(
Ttk_TagTable tagTable, Ttk_Style style, Ttk_State state, void *record)
{
- Tk_OptionSpec *optionSpec = tagTable->optionSpecs;
+ const Tk_OptionSpec *optionSpec = tagTable->optionSpecs;
while (optionSpec->type != TK_OPTION_END) {
int offset = optionSpec->objOffset;
diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c
index 8640d13..a8745d7 100644
--- a/generic/ttk/ttkTheme.c
+++ b/generic/ttk/ttkTheme.c
@@ -15,13 +15,6 @@
#define PKG_ASSOC_KEY "Ttk"
-#ifdef MAC_OSX_TK
- extern void TkMacOSXFlushWindows(void);
- #define UPDATE_WINDOWS() TkMacOSXFlushWindows()
-#else
- #define UPDATE_WINDOWS()
-#endif
-
/*------------------------------------------------------------------------
* +++ Styles.
*
@@ -42,9 +35,9 @@ typedef struct Ttk_Style_
Ttk_ResourceCache cache; /* Back-pointer to resource cache */
} Style;
-static Style *NewStyle()
+static Style *NewStyle(void)
{
- Style *stylePtr = ckalloc(sizeof(Style));
+ Style *stylePtr = (Style *)ckalloc(sizeof(Style));
stylePtr->styleName = NULL;
stylePtr->parentStyle = NULL;
@@ -63,7 +56,7 @@ static void FreeStyle(Style *stylePtr)
entryPtr = Tcl_FirstHashEntry(&stylePtr->settingsTable, &search);
while (entryPtr != NULL) {
- Ttk_StateMap stateMap = Tcl_GetHashValue(entryPtr);
+ Ttk_StateMap stateMap = (Ttk_StateMap)Tcl_GetHashValue(entryPtr);
Tcl_DecrRefCount(stateMap);
entryPtr = Tcl_NextHashEntry(&search);
}
@@ -71,7 +64,7 @@ static void FreeStyle(Style *stylePtr)
entryPtr = Tcl_FirstHashEntry(&stylePtr->defaultsTable, &search);
while (entryPtr != NULL) {
- Tcl_Obj *defaultValue = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *defaultValue = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
Tcl_DecrRefCount(defaultValue);
entryPtr = Tcl_NextHashEntry(&search);
}
@@ -92,7 +85,7 @@ Tcl_Obj *Ttk_StyleMap(Ttk_Style style, const char *optionName, Ttk_State state)
Tcl_HashEntry *entryPtr =
Tcl_FindHashEntry(&style->settingsTable, optionName);
if (entryPtr) {
- Ttk_StateMap stateMap = Tcl_GetHashValue(entryPtr);
+ Ttk_StateMap stateMap = (Ttk_StateMap)Tcl_GetHashValue(entryPtr);
return Ttk_StateMapLookup(NULL, stateMap, state);
}
style = style->parentStyle;
@@ -110,7 +103,7 @@ Tcl_Obj *Ttk_StyleDefault(Ttk_Style style, const char *optionName)
Tcl_HashEntry *entryPtr =
Tcl_FindHashEntry(&style->defaultsTable, optionName);
if (entryPtr)
- return Tcl_GetHashValue(entryPtr);
+ return (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
style= style->parentStyle;
}
return 0;
@@ -124,7 +117,7 @@ typedef const Tk_OptionSpec **OptionMap;
struct Ttk_ElementClass_ {
const char *name; /* Points to hash table key */
- Ttk_ElementSpec *specPtr; /* Template provided during registration. */
+ const Ttk_ElementSpec *specPtr; /* Template provided during registration. */
void *clientData; /* Client data passed in at registration time */
void *elementRecord; /* Scratch buffer for element record storage */
int nResources; /* #Element options */
@@ -149,7 +142,7 @@ static const Tk_OptionSpec *TTKGetOptionSpec(
/* Make sure widget option has a Tcl_Obj* entry:
*/
- if (optionSpec->objOffset == TCL_AUTO_LENGTH) {
+ if (optionSpec->objOffset == TCL_INDEX_NONE) {
return 0;
}
@@ -183,12 +176,12 @@ static const Tk_OptionSpec *TTKGetOptionSpec(
static OptionMap
BuildOptionMap(Ttk_ElementClass *elementClass, Tk_OptionTable optionTable)
{
- OptionMap optionMap = ckalloc(
+ OptionMap optionMap = (OptionMap)ckalloc(
sizeof(const Tk_OptionSpec) * elementClass->nResources + 1);
int i;
for (i = 0; i < elementClass->nResources; ++i) {
- Ttk_ElementOptionSpec *e = elementClass->specPtr->options+i;
+ const Ttk_ElementOptionSpec *e = elementClass->specPtr->options+i;
optionMap[i] = TTKGetOptionSpec(e->optionName, optionTable, e->type);
}
@@ -211,7 +204,7 @@ GetOptionMap(Ttk_ElementClass *elementClass, Tk_OptionTable optionTable)
optionMap = BuildOptionMap(elementClass, optionTable);
Tcl_SetHashValue(entryPtr, optionMap);
} else {
- optionMap = Tcl_GetHashValue(entryPtr);
+ optionMap = (OptionMap)Tcl_GetHashValue(entryPtr);
}
return optionMap;
@@ -223,9 +216,9 @@ GetOptionMap(Ttk_ElementClass *elementClass, Tk_OptionTable optionTable)
* from the specified element specification.
*/
static Ttk_ElementClass *
-NewElementClass(const char *name, Ttk_ElementSpec *specPtr,void *clientData)
+NewElementClass(const char *name, const Ttk_ElementSpec *specPtr, void *clientData)
{
- Ttk_ElementClass *elementClass = ckalloc(sizeof(Ttk_ElementClass));
+ Ttk_ElementClass *elementClass = (Ttk_ElementClass *)ckalloc(sizeof(Ttk_ElementClass));
int i;
elementClass->name = name;
@@ -241,7 +234,7 @@ NewElementClass(const char *name, Ttk_ElementSpec *specPtr,void *clientData)
/* Initialize default values:
*/
- elementClass->defaultValues =
+ elementClass->defaultValues = (Tcl_Obj **)
ckalloc(elementClass->nResources * sizeof(Tcl_Obj *) + 1);
for (i=0; i < elementClass->nResources; ++i) {
const char *defaultValue = specPtr->options[i].defaultValue;
@@ -298,8 +291,14 @@ static void FreeElementClass(Ttk_ElementClass *elementClass)
* +++ Themes.
*/
-static int ThemeEnabled(Ttk_Theme theme, void *clientData) { return 1; }
+static int ThemeEnabled(Ttk_Theme theme, void *dummy)
+{
+ (void)theme;
+ (void)dummy;
+
/* Default ThemeEnabledProc -- always return true */
+ return 1;
+}
typedef struct Ttk_Theme_
{
@@ -314,7 +313,7 @@ typedef struct Ttk_Theme_
static Theme *NewTheme(Ttk_ResourceCache cache, Ttk_Theme parent)
{
- Theme *themePtr = ckalloc(sizeof(Theme));
+ Theme *themePtr = (Theme *)ckalloc(sizeof(Theme));
Tcl_HashEntry *entryPtr;
int unused;
@@ -331,7 +330,7 @@ static Theme *NewTheme(Ttk_ResourceCache cache, Ttk_Theme parent)
entryPtr = Tcl_CreateHashEntry(&themePtr->styleTable, ".", &unused);
themePtr->rootStyle = NewStyle();
themePtr->rootStyle->styleName =
- Tcl_GetHashKey(&themePtr->styleTable, entryPtr);
+ (const char *)Tcl_GetHashKey(&themePtr->styleTable, entryPtr);
themePtr->rootStyle->cache = themePtr->cache;
Tcl_SetHashValue(entryPtr, themePtr->rootStyle);
@@ -348,7 +347,7 @@ static void FreeTheme(Theme *themePtr)
*/
entryPtr = Tcl_FirstHashEntry(&themePtr->elementTable, &search);
while (entryPtr != NULL) {
- Ttk_ElementClass *elementClass = Tcl_GetHashValue(entryPtr);
+ Ttk_ElementClass *elementClass = (Ttk_ElementClass *)Tcl_GetHashValue(entryPtr);
FreeElementClass(elementClass);
entryPtr = Tcl_NextHashEntry(&search);
}
@@ -359,7 +358,7 @@ static void FreeTheme(Theme *themePtr)
*/
entryPtr = Tcl_FirstHashEntry(&themePtr->styleTable, &search);
while (entryPtr != NULL) {
- Style *stylePtr = Tcl_GetHashValue(entryPtr);
+ Style *stylePtr = (Style *)Tcl_GetHashValue(entryPtr);
FreeStyle(stylePtr);
entryPtr = Tcl_NextHashEntry(&search);
}
@@ -410,12 +409,13 @@ static void ThemeChangedProc(ClientData); /* Forward */
/* Ttk_StylePkgFree --
* Cleanup procedure for StylePackageData.
*/
-static void Ttk_StylePkgFree(ClientData clientData, Tcl_Interp *interp)
+static void Ttk_StylePkgFree(ClientData clientData, Tcl_Interp *dummy)
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
Tcl_HashSearch search;
Tcl_HashEntry *entryPtr;
Cleanup *cleanup;
+ (void)dummy;
/*
* Cancel any pending ThemeChanged calls:
@@ -429,7 +429,7 @@ static void Ttk_StylePkgFree(ClientData clientData, Tcl_Interp *interp)
*/
entryPtr = Tcl_FirstHashEntry(&pkgPtr->themeTable, &search);
while (entryPtr != NULL) {
- Theme *themePtr = Tcl_GetHashValue(entryPtr);
+ Theme *themePtr = (Theme *)Tcl_GetHashValue(entryPtr);
FreeTheme(themePtr);
entryPtr = Tcl_NextHashEntry(&search);
}
@@ -471,7 +471,7 @@ static void Ttk_StylePkgFree(ClientData clientData, Tcl_Interp *interp)
static StylePackageData *GetStylePackageData(Tcl_Interp *interp)
{
- return Tcl_GetAssocData(interp, PKG_ASSOC_KEY, NULL);
+ return (StylePackageData *)Tcl_GetAssocData(interp, PKG_ASSOC_KEY, NULL);
}
/*
@@ -486,8 +486,8 @@ static StylePackageData *GetStylePackageData(Tcl_Interp *interp)
void Ttk_RegisterCleanup(
Tcl_Interp *interp, ClientData clientData, Ttk_CleanupProc *cleanupProc)
{
- StylePackageData *pkgPtr = GetStylePackageData(interp);
- Cleanup *cleanup = ckalloc(sizeof(*cleanup));
+ StylePackageData *pkgPtr = (StylePackageData *)GetStylePackageData(interp);
+ Cleanup *cleanup = (Cleanup *)ckalloc(sizeof(*cleanup));
cleanup->clientData = clientData;
cleanup->cleanupProc = cleanupProc;
@@ -510,14 +510,16 @@ void Ttk_RegisterCleanup(
static void ThemeChangedProc(ClientData clientData)
{
static char ThemeChangedScript[] = "ttk::ThemeChanged";
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
int code = Tcl_EvalEx(pkgPtr->interp, ThemeChangedScript, -1, TCL_EVAL_GLOBAL);
if (code != TCL_OK) {
Tcl_BackgroundException(pkgPtr->interp, code);
}
pkgPtr->themeChangePending = 0;
- UPDATE_WINDOWS();
+#ifdef MAC_OSX_TK
+ XSync(NULL, False);
+#endif
}
/*
@@ -604,7 +606,7 @@ static Ttk_Theme LookupTheme(
return NULL;
}
- return Tcl_GetHashValue(entryPtr);
+ return (Ttk_Theme)Tcl_GetHashValue(entryPtr);
}
/*
@@ -712,12 +714,12 @@ Ttk_Style Ttk_GetStyle(Ttk_Theme themePtr, const char *styleName)
stylePtr->parentStyle = themePtr->rootStyle;
}
- stylePtr->styleName = Tcl_GetHashKey(&themePtr->styleTable, entryPtr);
+ stylePtr->styleName = (const char *)Tcl_GetHashKey(&themePtr->styleTable, entryPtr);
stylePtr->cache = stylePtr->parentStyle->cache;
Tcl_SetHashValue(entryPtr, stylePtr);
return stylePtr;
}
- return Tcl_GetHashValue(entryPtr);
+ return (Ttk_Style)Tcl_GetHashValue(entryPtr);
}
/* FindLayoutTemplate --
@@ -763,7 +765,7 @@ Ttk_ElementClass *Ttk_GetElement(Ttk_Theme themePtr, const char *elementName)
*/
entryPtr = Tcl_FindHashEntry(&themePtr->elementTable, elementName);
if (entryPtr) {
- return Tcl_GetHashValue(entryPtr);
+ return (Ttk_ElementClass *)Tcl_GetHashValue(entryPtr);
}
/*
@@ -774,7 +776,7 @@ Ttk_ElementClass *Ttk_GetElement(Ttk_Theme themePtr, const char *elementName)
entryPtr = Tcl_FindHashEntry(&themePtr->elementTable, dot);
}
if (entryPtr) {
- return Tcl_GetHashValue(entryPtr);
+ return (Ttk_ElementClass *)Tcl_GetHashValue(entryPtr);
}
/*
@@ -790,7 +792,7 @@ Ttk_ElementClass *Ttk_GetElement(Ttk_Theme themePtr, const char *elementName)
*/
entryPtr = Tcl_FindHashEntry(&themePtr->elementTable, "");
/* ASSERT: entryPtr != 0 */
- return Tcl_GetHashValue(entryPtr);
+ return (Ttk_ElementClass *)Tcl_GetHashValue(entryPtr);
}
const char *Ttk_ElementClassName(Ttk_ElementClass *elementClass)
@@ -807,7 +809,7 @@ int Ttk_RegisterElementFactory(
Ttk_ElementFactory factory, void *clientData)
{
StylePackageData *pkgPtr = GetStylePackageData(interp);
- FactoryRec *recPtr = ckalloc(sizeof(*recPtr));
+ FactoryRec *recPtr = (FactoryRec *)ckalloc(sizeof(*recPtr));
Tcl_HashEntry *entryPtr;
int newEntry;
@@ -828,12 +830,13 @@ int Ttk_RegisterElementFactory(
* (style element create $name) "from" $theme ?$element?
*/
static int Ttk_CloneElement(
- Tcl_Interp *interp, void *clientData,
+ Tcl_Interp *interp, void *dummy,
Ttk_Theme theme, const char *elementName,
int objc, Tcl_Obj *const objv[])
{
Ttk_Theme fromTheme;
Ttk_ElementClass *fromElement;
+ (void)dummy;
if (objc <= 0 || objc > 2) {
Tcl_WrongNumArgs(interp, 0, objv, "theme ?element?");
@@ -873,7 +876,7 @@ Ttk_ElementClass *Ttk_RegisterElement(
Tcl_Interp *interp, /* Where to leave error messages */
Ttk_Theme theme, /* Style engine providing the implementation. */
const char *name, /* Name of new element */
- Ttk_ElementSpec *specPtr, /* Static template information */
+ const Ttk_ElementSpec *specPtr, /* Static template information */
void *clientData) /* application-specific data */
{
Ttk_ElementClass *elementClass;
@@ -903,7 +906,7 @@ Ttk_ElementClass *Ttk_RegisterElement(
return 0;
}
- name = Tcl_GetHashKey(&theme->elementTable, entryPtr);
+ name = (char *)Tcl_GetHashKey(&theme->elementTable, entryPtr);
elementClass = NewElementClass(name, specPtr, clientData);
Tcl_SetHashValue(entryPtr, elementClass);
@@ -914,7 +917,7 @@ Ttk_ElementClass *Ttk_RegisterElement(
* Register a new element.
*/
int Ttk_RegisterElementSpec(Ttk_Theme theme,
- const char *name, Ttk_ElementSpec *specPtr, void *clientData)
+ const char *name, const Ttk_ElementSpec *specPtr, void *clientData)
{
return Ttk_RegisterElement(NULL, theme, name, specPtr, clientData)
? TCL_OK : TCL_ERROR;
@@ -987,7 +990,7 @@ int InitializeElementRecord(
OptionMap optionMap = GetOptionMap(eclass,optionTable);
int nResources = eclass->nResources;
Ttk_ResourceCache cache = style->cache;
- Ttk_ElementOptionSpec *elementOption = eclass->specPtr->options;
+ const Ttk_ElementOptionSpec *elementOption = eclass->specPtr->options;
int i;
for (i=0; i<nResources; ++i, ++elementOption) {
@@ -1142,7 +1145,7 @@ int TtkEnumerateHashTable(Tcl_Interp *interp, Tcl_HashTable *ht)
Tcl_HashEntry *entryPtr = Tcl_FirstHashEntry(ht, &search);
while (entryPtr != NULL) {
- Tcl_Obj *nameObj = Tcl_NewStringObj(Tcl_GetHashKey(ht, entryPtr),-1);
+ Tcl_Obj *nameObj = Tcl_NewStringObj((const char *)Tcl_GetHashKey(ht, entryPtr),-1);
Tcl_ListObjAppendElement(interp, result, nameObj);
entryPtr = Tcl_NextHashEntry(&search);
}
@@ -1162,8 +1165,8 @@ static Tcl_Obj* HashTableToDict(Tcl_HashTable *ht)
Tcl_HashEntry *entryPtr = Tcl_FirstHashEntry(ht, &search);
while (entryPtr != NULL) {
- Tcl_Obj *nameObj = Tcl_NewStringObj(Tcl_GetHashKey(ht, entryPtr),-1);
- Tcl_Obj *valueObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *nameObj = Tcl_NewStringObj((const char *)Tcl_GetHashKey(ht, entryPtr),-1);
+ Tcl_Obj *valueObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
Tcl_ListObjAppendElement(NULL, result, nameObj);
Tcl_ListObjAppendElement(NULL, result, valueObj);
entryPtr = Tcl_NextHashEntry(&search);
@@ -1184,7 +1187,7 @@ StyleMapCmd(
int objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument objects */
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
const char *styleName;
Style *stylePtr;
@@ -1248,7 +1251,7 @@ usage:
static int StyleConfigureCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
const char *styleName;
Style *stylePtr;
@@ -1303,7 +1306,7 @@ usage:
static int StyleLookupCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
Ttk_Style style = NULL;
const char *optionName;
@@ -1345,7 +1348,7 @@ static int StyleLookupCmd(
static int StyleThemeCurrentCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[])
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
Tcl_HashSearch search;
Tcl_HashEntry *entryPtr = NULL;
const char *name = NULL;
@@ -1357,9 +1360,9 @@ static int StyleThemeCurrentCmd(
entryPtr = Tcl_FirstHashEntry(&pkgPtr->themeTable, &search);
while (entryPtr != NULL) {
- Theme *ptr = Tcl_GetHashValue(entryPtr);
+ Theme *ptr = (Theme *)Tcl_GetHashValue(entryPtr);
if (ptr == pkgPtr->currentTheme) {
- name = Tcl_GetHashKey(&pkgPtr->themeTable, entryPtr);
+ name = (char *)Tcl_GetHashKey(&pkgPtr->themeTable, entryPtr);
break;
}
entryPtr = Tcl_NextHashEntry(&search);
@@ -1381,7 +1384,7 @@ static int StyleThemeCurrentCmd(
static int StyleThemeCreateCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
static const char *const optStrings[] =
{ "-parent", "-settings", NULL };
enum { OP_PARENT, OP_SETTINGS };
@@ -1445,7 +1448,10 @@ static int StyleThemeCreateCmd(
static int StyleThemeNamesCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
+ (void)objc;
+ (void)objv;
+
return TtkEnumerateHashTable(interp, &pkgPtr->themeTable);
}
@@ -1461,7 +1467,7 @@ StyleThemeSettingsCmd(
int objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument objects */
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme oldTheme = pkgPtr->currentTheme;
Ttk_Theme newTheme;
int status;
@@ -1487,7 +1493,7 @@ StyleThemeSettingsCmd(
static int StyleElementCreateCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
const char *elementName, *factoryName;
Tcl_HashEntry *entryPtr;
@@ -1510,7 +1516,7 @@ static int StyleElementCreateCmd(
return TCL_ERROR;
}
- recPtr = Tcl_GetHashValue(entryPtr);
+ recPtr = (FactoryRec *)Tcl_GetHashValue(entryPtr);
return recPtr->factory(interp, recPtr->clientData,
theme, elementName, objc - 5, objv + 5);
@@ -1522,7 +1528,7 @@ static int StyleElementCreateCmd(
static int StyleElementNamesCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
if (objc != 3) {
@@ -1538,7 +1544,7 @@ static int StyleElementNamesCmd(
static int StyleElementOptionsCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
const char *elementName;
Ttk_ElementClass *elementClass;
@@ -1551,8 +1557,8 @@ static int StyleElementOptionsCmd(
elementName = Tcl_GetString(objv[3]);
elementClass = Ttk_GetElement(theme, elementName);
if (elementClass) {
- Ttk_ElementSpec *specPtr = elementClass->specPtr;
- Ttk_ElementOptionSpec *option = specPtr->options;
+ const Ttk_ElementSpec *specPtr = elementClass->specPtr;
+ const Ttk_ElementOptionSpec *option = specPtr->options;
Tcl_Obj *result = Tcl_NewListObj(0,0);
while (option->optionName) {
@@ -1576,7 +1582,7 @@ static int StyleElementOptionsCmd(
static int StyleLayoutCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
const char *layoutName;
Ttk_LayoutTemplate layoutTemplate;
@@ -1619,7 +1625,7 @@ StyleThemeUseCmd(
int objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument objects */
{
- StylePackageData *pkgPtr = clientData;
+ StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme;
if (objc < 3 || objc > 4) {
@@ -1714,7 +1720,7 @@ void Ttk_StylePkgInit(Tcl_Interp *interp)
{
Tcl_Namespace *nsPtr;
- StylePackageData *pkgPtr = ckalloc(sizeof(StylePackageData));
+ StylePackageData *pkgPtr = (StylePackageData *)ckalloc(sizeof(StylePackageData));
pkgPtr->interp = interp;
Tcl_InitHashTable(&pkgPtr->themeTable, TCL_STRING_KEYS);
diff --git a/generic/ttk/ttkTheme.h b/generic/ttk/ttkTheme.h
index f087ce3..7f9f6e9 100644
--- a/generic/ttk/ttkTheme.h
+++ b/generic/ttk/ttkTheme.h
@@ -29,9 +29,13 @@ extern "C" {
* +++ Defaults for element option specifications.
*/
#define DEFAULT_FONT "TkDefaultFont"
+#ifdef MAC_OSX_TK
+#define DEFAULT_BACKGROUND "systemTextBackgroundColor"
+#define DEFAULT_FOREGROUND "systemTextColor"
+#else
#define DEFAULT_BACKGROUND "#d9d9d9"
#define DEFAULT_FOREGROUND "black"
-
+#endif
/*------------------------------------------------------------------------
* +++ Widget states.
* Keep in sync with stateNames[] in tkstate.c.
@@ -71,17 +75,11 @@ typedef struct
#define Ttk_ModifyState(state, spec) \
(((state) & ~(spec)->offbits) | (spec)->onbits)
-TTKAPI int Ttk_GetStateSpecFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_StateSpec *);
-TTKAPI Tcl_Obj *Ttk_NewStateSpecObj(unsigned int onbits,unsigned int offbits);
-
/*------------------------------------------------------------------------
* +++ State maps and state tables.
*/
typedef Tcl_Obj *Ttk_StateMap;
-TTKAPI Ttk_StateMap Ttk_GetStateMapFromObj(Tcl_Interp *, Tcl_Obj *);
-TTKAPI Tcl_Obj *Ttk_StateMapLookup(Tcl_Interp*, Ttk_StateMap, Ttk_State);
-
/*
* Table for looking up an integer index based on widget state:
*/
@@ -92,8 +90,6 @@ typedef struct
unsigned int offBits; /* Bits which must be cleared */
} Ttk_StateTable;
-TTKAPI int Ttk_StateTableLookup(Ttk_StateTable map[], Ttk_State);
-
/*------------------------------------------------------------------------
* +++ Padding.
* Used to represent internal padding and borders.
@@ -106,14 +102,6 @@ typedef struct
short bottom;
} Ttk_Padding;
-TTKAPI int Ttk_GetPaddingFromObj(Tcl_Interp*,Tk_Window,Tcl_Obj*,Ttk_Padding*);
-TTKAPI int Ttk_GetBorderFromObj(Tcl_Interp*,Tcl_Obj*,Ttk_Padding*);
-
-TTKAPI Ttk_Padding Ttk_MakePadding(short l, short t, short r, short b);
-TTKAPI Ttk_Padding Ttk_UniformPadding(short borderWidth);
-TTKAPI Ttk_Padding Ttk_AddPadding(Ttk_Padding, Ttk_Padding);
-TTKAPI Ttk_Padding Ttk_RelievePadding(Ttk_Padding, int relief, int n);
-
#define Ttk_PaddingWidth(p) ((p).left + (p).right)
#define Ttk_PaddingHeight(p) ((p).top + (p).bottom)
@@ -132,9 +120,6 @@ typedef struct /* Hey, this is an XRectangle! */
int height;
} Ttk_Box;
-TTKAPI Ttk_Box Ttk_MakeBox(int x, int y, int width, int height);
-TTKAPI int Ttk_BoxContains(Ttk_Box, int x, int y);
-
#define Ttk_WinBox(tkwin) Ttk_MakeBox(0,0,Tk_Width(tkwin),Tk_Height(tkwin))
/*------------------------------------------------------------------------
@@ -161,7 +146,6 @@ typedef unsigned int Ttk_Sticky;
#define TTK_FILL_Y (0xC) /* -sticky ns */
#define TTK_FILL_BOTH (0xF) /* -sticky nswe */
-TTKAPI int Ttk_GetStickyFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_Sticky *);
TTKAPI Tcl_Obj *Ttk_NewStickyObj(Ttk_Sticky);
/*
@@ -188,12 +172,6 @@ typedef unsigned int Ttk_PositionSpec; /* See below */
#define _TTK_MASK_STICK (0x0F) /* See Ttk_UnparseLayout() */
#define _TTK_MASK_PACK (0xF0) /* See Ttk_UnparseLayout(), packStrings */
-TTKAPI Ttk_Box Ttk_PackBox(Ttk_Box *cavity, int w, int h, Ttk_Side side);
-TTKAPI Ttk_Box Ttk_StickBox(Ttk_Box parcel, int w, int h, Ttk_Sticky sticky);
-TTKAPI Ttk_Box Ttk_AnchorBox(Ttk_Box parcel, int w, int h, Tk_Anchor anchor);
-TTKAPI Ttk_Box Ttk_PadBox(Ttk_Box b, Ttk_Padding p);
-TTKAPI Ttk_Box Ttk_ExpandBox(Ttk_Box b, Ttk_Padding p);
-TTKAPI Ttk_Box Ttk_PlaceBox(Ttk_Box *cavity, int w,int h, Ttk_Side,Ttk_Sticky);
TTKAPI Ttk_Box Ttk_PositionBox(Ttk_Box *cavity, int w, int h, Ttk_PositionSpec);
/*------------------------------------------------------------------------
@@ -207,21 +185,12 @@ typedef struct Ttk_Layout_ *Ttk_Layout;
typedef struct Ttk_LayoutNode_ *Ttk_Element;
typedef struct Ttk_Style_ *Ttk_Style;
-TTKAPI Ttk_Theme Ttk_GetTheme(Tcl_Interp *interp, const char *name);
-TTKAPI Ttk_Theme Ttk_GetDefaultTheme(Tcl_Interp *interp);
-TTKAPI Ttk_Theme Ttk_GetCurrentTheme(Tcl_Interp *interp);
-
-TTKAPI Ttk_Theme Ttk_CreateTheme(
- Tcl_Interp *interp, const char *name, Ttk_Theme parent);
-
typedef int (Ttk_ThemeEnabledProc)(Ttk_Theme theme, void *clientData);
MODULE_SCOPE void Ttk_SetThemeEnabledProc(Ttk_Theme, Ttk_ThemeEnabledProc, void *);
MODULE_SCOPE int Ttk_UseTheme(Tcl_Interp *, Ttk_Theme);
typedef void (Ttk_CleanupProc)(void *clientData);
-TTKAPI void Ttk_RegisterCleanup(
- Tcl_Interp *interp, void *deleteData, Ttk_CleanupProc *cleanupProc);
/*------------------------------------------------------------------------
* +++ Elements.
@@ -255,22 +224,15 @@ typedef struct Ttk_ElementOptionSpec
typedef struct Ttk_ElementSpec {
enum TTKStyleVersion2 version; /* Version of the style support. */
size_t elementSize; /* Size of element record */
- Ttk_ElementOptionSpec *options; /* List of options, NULL-terminated */
+ const Ttk_ElementOptionSpec *options; /* List of options, NULL-terminated */
Ttk_ElementSizeProc *size; /* Compute min size and padding */
Ttk_ElementDrawProc *draw; /* Draw the element */
} Ttk_ElementSpec;
-TTKAPI Ttk_ElementClass *Ttk_RegisterElement(
- Tcl_Interp *interp, Ttk_Theme theme, const char *elementName,
- Ttk_ElementSpec *, void *clientData);
-
typedef int (*Ttk_ElementFactory)
(Tcl_Interp *, void *clientData,
Ttk_Theme, const char *elementName, int objc, Tcl_Obj *const objv[]);
-TTKAPI int Ttk_RegisterElementFactory(
- Tcl_Interp *, const char *name, Ttk_ElementFactory, void *clientData);
-
/*
* Null element implementation:
* has no geometry or layout; may be used as a stub or placeholder.
@@ -284,7 +246,7 @@ MODULE_SCOPE void TtkNullElementSize
(void *, void *, Tk_Window, int *, int *, Ttk_Padding *);
MODULE_SCOPE void TtkNullElementDraw
(void *, void *, Tk_Window, Drawable, Ttk_Box, Ttk_State);
-MODULE_SCOPE Ttk_ElementOptionSpec TtkNullElementOptions[];
+MODULE_SCOPE const Ttk_ElementOptionSpec TtkNullElementOptions[];
MODULE_SCOPE Ttk_ElementSpec ttkNullElementSpec;
/*------------------------------------------------------------------------
@@ -311,9 +273,6 @@ typedef struct {
#define TTK_BEGIN_LAYOUT(name) static TTKLayoutInstruction name[] = {
#define TTK_END_LAYOUT { 0, _TTK_LAYOUT_END } };
-TTKAPI void Ttk_RegisterLayout(
- Ttk_Theme theme, const char *className, Ttk_LayoutSpec layoutSpec);
-
TTKAPI void Ttk_RegisterLayouts(
Ttk_Theme theme, Ttk_LayoutSpec layoutTable);
@@ -396,7 +355,7 @@ typedef enum /* -default option values */
TTK_BUTTON_DEFAULT_DISABLED /* not defaultable */
} Ttk_ButtonDefaultState;
-TTKAPI int Ttk_GetButtonDefaultStateFromObj(Tcl_Interp *, Tcl_Obj *, int *);
+TTKAPI int Ttk_GetButtonDefaultStateFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_ButtonDefaultState *);
typedef enum /* -compound option values */
{
@@ -410,13 +369,16 @@ typedef enum /* -compound option values */
TTK_COMPOUND_RIGHT /* image to right of text */
} Ttk_Compound;
-TTKAPI int Ttk_GetCompoundFromObj(Tcl_Interp *, Tcl_Obj *, int *);
+TTKAPI int Ttk_GetCompoundFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_Compound *);
typedef enum { /* -orient option values */
TTK_ORIENT_HORIZONTAL,
TTK_ORIENT_VERTICAL
} Ttk_Orient;
+MODULE_SCOPE int TtkGetOrientFromObj(Tcl_Interp *interp,
+ Tcl_Obj *objPtr, Ttk_Orient *orient);
+
/*------------------------------------------------------------------------
* +++ Utilities.
*/
diff --git a/generic/ttk/ttkTrace.c b/generic/ttk/ttkTrace.c
index 51006f8..7e02b58 100644
--- a/generic/ttk/ttkTrace.c
+++ b/generic/ttk/ttkTrace.c
@@ -26,26 +26,17 @@ static char *
VarTraceProc(
ClientData clientData, /* Widget record pointer */
Tcl_Interp *interp, /* Interpreter containing variable. */
- const char *name1, /* Name of variable. */
- const char *name2, /* Second part of variable name. */
+ const char *name1, /* (unused) */
+ const char *name2, /* (unused) */
int flags) /* Information about what happened. */
{
- Ttk_TraceHandle *tracePtr = clientData;
+ Ttk_TraceHandle *tracePtr = (Ttk_TraceHandle *)clientData;
const char *name, *value;
Tcl_Obj *valuePtr;
+ (void)name1;
+ (void)name2;
- if (flags & TCL_INTERP_DESTROYED) {
- return NULL;
- }
-
- /*
- * See ticket [5d991b82].
- */
-
- if (tracePtr->varnameObj == NULL) {
- Tcl_UntraceVar2(interp, name1, name2,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- VarTraceProc, clientData);
+ if (Tcl_InterpDeleted(interp)) {
return NULL;
}
@@ -96,7 +87,7 @@ Ttk_TraceHandle *Ttk_TraceVariable(
Ttk_TraceProc callback,
void *clientData)
{
- Ttk_TraceHandle *h = ckalloc(sizeof(*h));
+ Ttk_TraceHandle *h = (Ttk_TraceHandle *)ckalloc(sizeof(*h));
int status;
h->interp = interp;
diff --git a/generic/ttk/ttkTrack.c b/generic/ttk/ttkTrack.c
index fa2a7e0..b9aa776 100644
--- a/generic/ttk/ttkTrack.c
+++ b/generic/ttk/ttkTrack.c
@@ -16,11 +16,11 @@
* and is normally set to the ACTIVE state unless another element
* is currently being pressed.
*
- * The active element becomes "pressed" on <ButtonPress> events,
+ * The active element becomes "pressed" on <Button> events,
* and remains "active" and "pressed" until the corresponding
* <ButtonRelease> event.
*
- * TODO: Handle "chords" properly (e.g., <B1-ButtonPress-2>)
+ * TODO: Handle "chords" properly (e.g., <B1-Button-2>)
*/
#include "tkInt.h"
@@ -118,7 +118,7 @@ static const unsigned ElementStateMask =
static void
ElementStateEventProc(ClientData clientData, XEvent *ev)
{
- ElementStateTracker *es = clientData;
+ ElementStateTracker *es = (ElementStateTracker *)clientData;
Ttk_Layout layout = es->corePtr->layout;
Ttk_Element element;
@@ -173,7 +173,7 @@ ElementStateEventProc(ClientData clientData, XEvent *ev)
void TtkTrackElementState(WidgetCore *corePtr)
{
- ElementStateTracker *es = ckalloc(sizeof(*es));
+ ElementStateTracker *es = (ElementStateTracker *)ckalloc(sizeof(*es));
es->corePtr = corePtr;
es->tracking = 0;
es->activeElement = es->pressedElement = 0;
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index 7aad8ae..b484d1c 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -59,32 +59,35 @@ struct TreeItemRec {
#define ITEM_OPTION_TAGS_CHANGED 0x100
#define ITEM_OPTION_IMAGE_CHANGED 0x200
-static Tk_OptionSpec ItemOptionSpecs[] = {
+static const Tk_OptionSpec ItemOptionSpecs[] = {
{TK_OPTION_STRING, "-text", "text", "Text",
- "", Tk_Offset(TreeItem,textObj), -1,
+ "", offsetof(TreeItem,textObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-image", "image", "Image",
- NULL, Tk_Offset(TreeItem,imageObj), -1,
+ NULL, offsetof(TreeItem,imageObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,ITEM_OPTION_IMAGE_CHANGED },
{TK_OPTION_STRING, "-values", "values", "Values",
- NULL, Tk_Offset(TreeItem,valuesObj), -1,
+ NULL, offsetof(TreeItem,valuesObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_BOOLEAN, "-open", "open", "Open",
- "0", Tk_Offset(TreeItem,openObj), -1,
+ "0", offsetof(TreeItem,openObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-tags", "tags", "Tags",
- NULL, Tk_Offset(TreeItem,tagsObj), -1,
+ NULL, offsetof(TreeItem,tagsObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,ITEM_OPTION_TAGS_CHANGED },
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
};
+/* Forward declaration */
+static void RemoveTag(TreeItem *, Ttk_Tag);
+
/* + NewItem --
* Allocate a new, uninitialized, unlinked item
*/
static TreeItem *NewItem(void)
{
- TreeItem *item = ckalloc(sizeof(*item));
+ TreeItem *item = (TreeItem *)ckalloc(sizeof(*item));
item->entryPtr = 0;
item->parent = item->children = item->next = item->prev = NULL;
@@ -119,7 +122,7 @@ static void FreeItem(TreeItem *item)
ckfree(item);
}
-static void FreeItemCB(void *clientData) { FreeItem(clientData); }
+static void FreeItemCB(void *clientData) { FreeItem((TreeItem *)clientData); }
/* + DetachItem --
* Unlink an item from the tree.
@@ -187,27 +190,27 @@ typedef struct {
Tcl_Obj *fontObj;
} DisplayItem;
-static Tk_OptionSpec TagOptionSpecs[] = {
+static const Tk_OptionSpec TagOptionSpecs[] = {
{TK_OPTION_STRING, "-text", "text", "Text",
- NULL, Tk_Offset(DisplayItem,textObj), -1,
+ NULL, offsetof(DisplayItem,textObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_STRING, "-image", "image", "Image",
- NULL, Tk_Offset(DisplayItem,imageObj), -1,
+ NULL, offsetof(DisplayItem,imageObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- NULL, Tk_Offset(DisplayItem,anchorObj), -1,
+ NULL, offsetof(DisplayItem,anchorObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED}, /* <<NOTE-ANCHOR>> */
{TK_OPTION_COLOR, "-background", "windowColor", "WindowColor",
- NULL, Tk_Offset(DisplayItem,backgroundObj), -1,
+ NULL, offsetof(DisplayItem,backgroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
- NULL, Tk_Offset(DisplayItem,foregroundObj), -1,
+ NULL, offsetof(DisplayItem,foregroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_FONT, "-font", "font", "Font",
- NULL, Tk_Offset(DisplayItem,fontObj), -1,
+ NULL, offsetof(DisplayItem,fontObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
};
/*------------------------------------------------------------------------
@@ -271,42 +274,42 @@ static void FreeColumn(TreeColumn *column)
/* Don't touch column->data, it's scratch storage */
}
-static Tk_OptionSpec ColumnOptionSpecs[] = {
+static const Tk_OptionSpec ColumnOptionSpecs[] = {
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_COLWIDTH, -1, Tk_Offset(TreeColumn,width),
+ DEF_COLWIDTH, TCL_INDEX_NONE, offsetof(TreeColumn,width),
0,0,GEOMETRY_CHANGED },
{TK_OPTION_INT, "-minwidth", "minWidth", "MinWidth",
- DEF_MINWIDTH, -1, Tk_Offset(TreeColumn,minWidth),
+ DEF_MINWIDTH, TCL_INDEX_NONE, offsetof(TreeColumn,minWidth),
0,0,0 },
{TK_OPTION_BOOLEAN, "-stretch", "stretch", "Stretch",
- "1", -1, Tk_Offset(TreeColumn,stretch),
- 0,0,0 },
+ "1", TCL_INDEX_NONE, offsetof(TreeColumn,stretch),
+ 0,0,GEOMETRY_CHANGED },
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- "w", Tk_Offset(TreeColumn,anchorObj), -1, /* <<NOTE-ANCHOR>> */
+ "w", offsetof(TreeColumn,anchorObj), TCL_INDEX_NONE, /* <<NOTE-ANCHOR>> */
0,0,0 },
{TK_OPTION_STRING, "-id", "id", "ID",
- NULL, Tk_Offset(TreeColumn,idObj), -1,
+ NULL, offsetof(TreeColumn,idObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,READONLY_OPTION },
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
};
-static Tk_OptionSpec HeadingOptionSpecs[] = {
+static const Tk_OptionSpec HeadingOptionSpecs[] = {
{TK_OPTION_STRING, "-text", "text", "Text",
- "", Tk_Offset(TreeColumn,headingObj), -1,
+ "", offsetof(TreeColumn,headingObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-image", "image", "Image",
- "", Tk_Offset(TreeColumn,headingImageObj), -1,
+ "", offsetof(TreeColumn,headingImageObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- "center", Tk_Offset(TreeColumn,headingAnchorObj), -1,
+ "center", offsetof(TreeColumn,headingAnchorObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-command", "", "",
- "", Tk_Offset(TreeColumn,headingCommandObj), -1,
+ "", offsetof(TreeColumn,headingCommandObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_STRING, "state", "", "",
- "", Tk_Offset(TreeColumn,headingStateObj), -1,
+ "", offsetof(TreeColumn,headingStateObj), TCL_INDEX_NONE,
0,0,STATE_CHANGED },
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
};
/*------------------------------------------------------------------------
@@ -435,33 +438,33 @@ typedef struct {
static const char *const SelectModeStrings[] = { "none", "browse", "extended", NULL };
-static Tk_OptionSpec TreeviewOptionSpecs[] = {
+static const Tk_OptionSpec TreeviewOptionSpecs[] = {
{TK_OPTION_STRING, "-columns", "columns", "Columns",
- "", Tk_Offset(Treeview,tree.columnsObj), -1,
+ "", offsetof(Treeview,tree.columnsObj), TCL_INDEX_NONE,
0,0,COLUMNS_CHANGED | GEOMETRY_CHANGED /*| READONLY_OPTION*/ },
{TK_OPTION_STRING, "-displaycolumns","displayColumns","DisplayColumns",
- "#all", Tk_Offset(Treeview,tree.displayColumnsObj), -1,
+ "#all", offsetof(Treeview,tree.displayColumnsObj), TCL_INDEX_NONE,
0,0,DCOLUMNS_CHANGED | GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-show", "show", "Show",
- DEFAULT_SHOW, Tk_Offset(Treeview,tree.showObj), -1,
+ DEFAULT_SHOW, offsetof(Treeview,tree.showObj), TCL_INDEX_NONE,
0,0,SHOW_CHANGED | GEOMETRY_CHANGED },
{TK_OPTION_STRING_TABLE, "-selectmode", "selectMode", "SelectMode",
- "extended", Tk_Offset(Treeview,tree.selectModeObj), -1,
+ "extended", offsetof(Treeview,tree.selectModeObj), TCL_INDEX_NONE,
0,(ClientData)SelectModeStrings,0 },
{TK_OPTION_PIXELS, "-height", "height", "Height",
- DEF_TREE_ROWS, Tk_Offset(Treeview,tree.heightObj), -1,
+ DEF_TREE_ROWS, offsetof(Treeview,tree.heightObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-padding", "padding", "Pad",
- NULL, Tk_Offset(Treeview,tree.paddingObj), -1,
+ NULL, offsetof(Treeview,tree.paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- NULL, -1, Tk_Offset(Treeview, tree.xscroll.scrollCmd),
+ NULL, TCL_INDEX_NONE, offsetof(Treeview, tree.xscroll.scrollCmd),
TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},
{TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- NULL, -1, Tk_Offset(Treeview, tree.yscroll.scrollCmd),
+ NULL, TCL_INDEX_NONE, offsetof(Treeview, tree.yscroll.scrollCmd),
TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
@@ -525,7 +528,7 @@ static TreeColumn *GetColumn(
entryPtr = Tcl_FindHashEntry(
&tv->tree.columnNames, Tcl_GetString(columnIDObj));
if (entryPtr) {
- return Tcl_GetHashValue(entryPtr);
+ return (TreeColumn *)Tcl_GetHashValue(entryPtr);
}
/* Check for number:
@@ -586,7 +589,7 @@ static TreeItem *FindItem(
Tcl_SetErrorCode(interp, "TTK", "TREE", "ITEM", NULL);
return 0;
}
- return Tcl_GetHashValue(entryPtr);
+ return (TreeItem *)Tcl_GetHashValue(entryPtr);
}
/* + GetItemListFromObj --
@@ -607,7 +610,7 @@ static TreeItem **GetItemListFromObj(
return NULL;
}
- items = ckalloc((nElements + 1)*sizeof(TreeItem*));
+ items = (TreeItem **)ckalloc((nElements + 1)*sizeof(TreeItem*));
for (i = 0; i < nElements; ++i) {
items[i] = FindItem(interp, tv, elements[i]);
if (!items[i]) {
@@ -624,7 +627,7 @@ static TreeItem **GetItemListFromObj(
*/
static const char *ItemName(Treeview *tv, TreeItem *item)
{
- return Tcl_GetHashKey(&tv->tree.items, item->entryPtr);
+ return (const char *)Tcl_GetHashKey(&tv->tree.items, item->entryPtr);
}
/* + ItemID --
@@ -682,7 +685,7 @@ static int TreeviewInitColumns(Tcl_Interp *interp, Treeview *tv)
* Initialize columns array and columnNames hash table:
*/
tv->tree.nColumns = ncols;
- tv->tree.columns = ckalloc(tv->tree.nColumns * sizeof(TreeColumn));
+ tv->tree.columns = (TreeColumn *)ckalloc(tv->tree.nColumns * sizeof(TreeColumn));
for (i = 0; i < ncols; ++i) {
int isNew;
@@ -727,12 +730,12 @@ static int TreeviewInitDisplayColumns(Tcl_Interp *interp, Treeview *tv)
if (!strcmp(Tcl_GetString(tv->tree.displayColumnsObj), "#all")) {
ndcols = tv->tree.nColumns;
- displayColumns = ckalloc((ndcols+1) * sizeof(TreeColumn*));
+ displayColumns = (TreeColumn **)ckalloc((ndcols+1) * sizeof(TreeColumn*));
for (index = 0; index < ndcols; ++index) {
displayColumns[index+1] = tv->tree.columns + index;
}
} else {
- displayColumns = ckalloc((ndcols+1) * sizeof(TreeColumn*));
+ displayColumns = (TreeColumn **)ckalloc((ndcols+1) * sizeof(TreeColumn*));
for (index = 0; index < ndcols; ++index) {
displayColumns[index+1] = GetColumn(interp, tv, dcolumns[index]);
if (!displayColumns[index+1]) {
@@ -921,7 +924,7 @@ static void DragColumn(Treeview *tv, int i, int delta)
static TreeItem *IdentifyItem(Treeview *tv, int y); /*forward*/
-static const unsigned int TreeviewBindEventMask =
+static const unsigned long TreeviewBindEventMask =
KeyPressMask|KeyReleaseMask
| ButtonPressMask|ButtonReleaseMask
| PointerMotionMask|ButtonMotionMask
@@ -930,7 +933,7 @@ static const unsigned int TreeviewBindEventMask =
static void TreeviewBindEventProc(void *clientData, XEvent *event)
{
- Treeview *tv = clientData;
+ Treeview *tv = (Treeview *)clientData;
TreeItem *item = NULL;
Ttk_TagSet tagset;
@@ -982,7 +985,7 @@ static void TreeviewBindEventProc(void *clientData, XEvent *event)
static void TreeviewInitialize(Tcl_Interp *interp, void *recordPtr)
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
int unused;
tv->tree.itemOptionTable =
@@ -1049,7 +1052,7 @@ static void TreeviewInitialize(Tcl_Interp *interp, void *recordPtr)
static void TreeviewCleanup(void *recordPtr)
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Tk_DeleteEventHandler(tv->core.tkwin,
TreeviewBindEventMask, TreeviewBindEventProc, tv);
@@ -1064,7 +1067,7 @@ static void TreeviewCleanup(void *recordPtr)
TreeviewFreeColumns(tv);
if (tv->tree.displayColumns)
- Tcl_Free((ClientData)tv->tree.displayColumns);
+ ckfree((ClientData)tv->tree.displayColumns);
foreachHashEntry(&tv->tree.items, FreeItemCB);
Tcl_DeleteHashTable(&tv->tree.items);
@@ -1082,7 +1085,7 @@ static void TreeviewCleanup(void *recordPtr)
static int
TreeviewConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
unsigned showFlags = tv->tree.showFlags;
if (mask & COLUMNS_CHANGED) {
@@ -1230,13 +1233,13 @@ static int ConfigureColumn(
if (mask & GEOMETRY_CHANGED) {
if (!Tk_IsMapped(tv->core.tkwin)) {
TtkResizeWidget(&tv->core);
- }
- RecomputeSlack(tv);
+ } else {
+ RecomputeSlack(tv);
+ ResizeColumns(tv, TreeWidth(tv));
+ }
}
TtkRedisplayWidget(&tv->core);
- /* ASSERT: SLACKINVARIANT */
-
Tk_FreeSavedOptions(&savedOptions);
return TCL_OK;
@@ -1561,7 +1564,7 @@ static Ttk_Layout GetSublayout(
static Ttk_Layout TreeviewGetLayout(
Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr)
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Ttk_Layout treeLayout = TtkWidgetGetLayout(interp, themePtr, recordPtr);
Tcl_Obj *objPtr;
int unused;
@@ -1610,16 +1613,13 @@ static Ttk_Layout TreeviewGetLayout(
*/
static void TreeviewDoLayout(void *clientData)
{
- Treeview *tv = clientData;
+ Treeview *tv = (Treeview *)clientData;
int visibleRows;
- /* ASSERT: SLACKINVARIANT */
-
Ttk_PlaceLayout(tv->core.layout,tv->core.state,Ttk_WinBox(tv->core.tkwin));
tv->tree.treeArea = Ttk_ClientRegion(tv->core.layout, "treearea");
ResizeColumns(tv, tv->tree.treeArea.width);
- /* ASSERT: SLACKINVARIANT */
TtkScrolled(tv->tree.xscrollHandle,
tv->tree.xscroll.first,
@@ -1647,7 +1647,7 @@ static void TreeviewDoLayout(void *clientData)
*/
static int TreeviewSize(void *clientData, int *widthPtr, int *heightPtr)
{
- Treeview *tv = clientData;
+ Treeview *tv = (Treeview *)clientData;
int nRows, padHeight, padWidth;
Ttk_LayoutSize(tv->core.layout, tv->core.state, &padWidth, &padHeight);
@@ -1835,7 +1835,7 @@ static int DrawForest(
*/
static void TreeviewDisplay(void *clientData, Drawable d)
{
- Treeview *tv = clientData;
+ Treeview *tv = (Treeview *)clientData;
Ttk_DrawLayout(tv->core.layout, tv->core.state, d);
if (tv->tree.showFlags & SHOW_HEADINGS) {
@@ -1949,7 +1949,7 @@ static TreeItem *DeleteItems(TreeItem *item, TreeItem *delq)
static int TreeviewChildrenCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
Tcl_Obj *result;
@@ -2029,7 +2029,7 @@ static int TreeviewChildrenCommand(
static int TreeviewParentCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
if (objc != 3) {
@@ -2057,7 +2057,7 @@ static int TreeviewParentCommand(
static int TreeviewNextCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
if (objc != 3) {
@@ -2082,7 +2082,7 @@ static int TreeviewNextCommand(
static int TreeviewPrevCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
if (objc != 3) {
@@ -2107,7 +2107,7 @@ static int TreeviewPrevCommand(
static int TreeviewIndexCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
int index = 0;
@@ -2135,7 +2135,7 @@ static int TreeviewIndexCommand(
static int TreeviewExistsCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Tcl_HashEntry *entryPtr;
if (objc != 3) {
@@ -2144,7 +2144,7 @@ static int TreeviewExistsCommand(
}
entryPtr = Tcl_FindHashEntry(&tv->tree.items, Tcl_GetString(objv[2]));
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(entryPtr != 0));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(entryPtr != 0));
return TCL_OK;
}
@@ -2154,7 +2154,7 @@ static int TreeviewExistsCommand(
static int TreeviewBBoxCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item = 0;
TreeColumn *column = 0;
Ttk_Box bbox;
@@ -2197,6 +2197,7 @@ static int TreeviewHorribleIdentify(
int dColumnNumber;
char dcolbuf[16];
int x, y, x1;
+ (void)objc;
/* ASSERT: objc == 4 */
@@ -2231,7 +2232,9 @@ static int TreeviewHorribleIdentify(
Ttk_Element element;
BoundingBox(tv, item, NULL, &itemBox);
- PrepareItem(tv, item, &displayItem); /*@@@ FIX: -text, etc*/
+ PrepareItem(tv, item, &displayItem);
+ if (item->textObj) { displayItem.textObj = item->textObj; }
+ if (item->imageObj) { displayItem.imageObj = item->imageObj; }
Ttk_RebindSublayout(layout, &displayItem);
Ttk_PlaceLayout(layout, ItemState(tv,item), itemBox);
element = Ttk_IdentifyElement(layout, x, y);
@@ -2268,7 +2271,7 @@ static int TreeviewIdentifyCommand(
{ "region", "item", "column", "row", "element", NULL };
enum { I_REGION, I_ITEM, I_COLUMN, I_ROW, I_ELEMENT };
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
int submethod;
int x, y;
@@ -2343,7 +2346,9 @@ static int TreeviewIdentifyCommand(
return TCL_OK;
}
- PrepareItem(tv, item, &displayItem); /*@@@ FIX: fill in -text,etc */
+ PrepareItem(tv, item, &displayItem);
+ if (item->textObj) { displayItem.textObj = item->textObj; }
+ if (item->imageObj) { displayItem.imageObj = item->imageObj; }
Ttk_RebindSublayout(layout, &displayItem);
Ttk_PlaceLayout(layout, ItemState(tv,item), bbox);
element = Ttk_IdentifyElement(layout, x, y);
@@ -2368,7 +2373,7 @@ static int TreeviewIdentifyCommand(
static int TreeviewItemCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
if (objc < 3) {
@@ -2396,7 +2401,7 @@ static int TreeviewItemCommand(
static int TreeviewColumnCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeColumn *column;
if (objc < 3) {
@@ -2424,7 +2429,7 @@ static int TreeviewColumnCommand(
static int TreeviewHeadingCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Tk_OptionTable optionTable = tv->tree.headingOptionTable;
Tk_Window tkwin = tv->core.tkwin;
TreeColumn *column;
@@ -2454,7 +2459,7 @@ static int TreeviewHeadingCommand(
static int TreeviewSetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
TreeColumn *column;
int columnNumber;
@@ -2548,7 +2553,7 @@ static int TreeviewSetCommand(
static int TreeviewInsertCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *parent, *sibling, *newItem;
Tcl_HashEntry *entryPtr;
int isNew;
@@ -2629,7 +2634,7 @@ static int TreeviewInsertCommand(
static int TreeviewDetachCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem **items;
int i;
@@ -2676,9 +2681,9 @@ static int TreeviewDetachCommand(
static int TreeviewDeleteCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem **items, *delq;
- int i;
+ int i, selItemDeleted = 0;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "items");
@@ -2705,6 +2710,9 @@ static int TreeviewDeleteCommand(
*/
delq = 0;
for (i=0; items[i]; ++i) {
+ if (items[i]->state & TTK_STATE_SELECTED) {
+ selItemDeleted = 1;
+ }
delq = DeleteItems(items[i], delq);
}
@@ -2721,6 +2729,9 @@ static int TreeviewDeleteCommand(
}
ckfree(items);
+ if (selItemDeleted) {
+ TtkSendVirtualEvent(tv->core.tkwin, "TreeviewSelect");
+ }
TtkRedisplayWidget(&tv->core);
return TCL_OK;
}
@@ -2731,7 +2742,7 @@ static int TreeviewDeleteCommand(
static int TreeviewMoveCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item, *parent;
TreeItem *sibling;
@@ -2794,14 +2805,14 @@ static int TreeviewMoveCommand(
static int TreeviewXViewCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
return TtkScrollviewCommand(interp, objc, objv, tv->tree.xscrollHandle);
}
static int TreeviewYViewCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
return TtkScrollviewCommand(interp, objc, objv, tv->tree.yscrollHandle);
}
@@ -2811,7 +2822,7 @@ static int TreeviewYViewCommand(
static int TreeviewSeeCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item, *parent;
int rowNumber;
@@ -2833,16 +2844,15 @@ static int TreeviewSeeCommand(
TtkRedisplayWidget(&tv->core);
}
}
- tv->tree.yscroll.total = CountRows(tv->tree.root) - 1;
/* Make sure item is visible:
*/
rowNumber = RowNumber(tv, item);
if (rowNumber < tv->tree.yscroll.first) {
- TtkScrollTo(tv->tree.yscrollHandle, rowNumber);
+ TtkScrollTo(tv->tree.yscrollHandle, rowNumber, 1);
} else if (rowNumber >= tv->tree.yscroll.last) {
TtkScrollTo(tv->tree.yscrollHandle,
- tv->tree.yscroll.first + (1+rowNumber - tv->tree.yscroll.last));
+ tv->tree.yscroll.first + (1+rowNumber - tv->tree.yscroll.last), 1);
}
return TCL_OK;
@@ -2858,7 +2868,7 @@ static int TreeviewSeeCommand(
static int TreeviewDragCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
int left = tv->tree.treeArea.x - tv->tree.xscroll.first;
int i = FirstColumn(tv);
TreeColumn *column;
@@ -2880,7 +2890,6 @@ static int TreeviewDragCommand(
int right = left + c->width;
if (c == column) {
DragColumn(tv, i, newx - right);
- /* ASSERT: SLACKINVARIANT */
TtkRedisplayWidget(&tv->core);
return TCL_OK;
}
@@ -2893,6 +2902,20 @@ static int TreeviewDragCommand(
return TCL_ERROR;
}
+static int TreeviewDropCommand(
+ void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+{
+ Treeview *tv = (Treeview *)recordPtr;
+
+ if (objc != 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "drop");
+ return TCL_ERROR;
+ }
+ ResizeColumns(tv, TreeWidth(tv));
+ TtkRedisplayWidget(&tv->core);
+ return TCL_OK;
+}
+
/*------------------------------------------------------------------------
* +++ Widget commands -- focus and selection
*/
@@ -2902,7 +2925,7 @@ static int TreeviewDragCommand(
static int TreeviewFocusCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
if (objc == 2) {
if (tv->tree.focus) {
@@ -2934,13 +2957,13 @@ static int TreeviewSelectionCommand(
"set", "add", "remove", "toggle", NULL
};
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
int selop, i;
TreeItem *item, **items;
if (objc == 2) {
Tcl_Obj *result = Tcl_NewListObj(0,0);
- for (item = tv->tree.root->children; item; item=NextPreorder(item)) {
+ for (item = tv->tree.root->children; item; item = NextPreorder(item)) {
if (item->state & TTK_STATE_SELECTED)
Tcl_ListObjAppendElement(NULL, result, ItemID(tv, item));
}
@@ -2966,7 +2989,7 @@ static int TreeviewSelectionCommand(
switch (selop)
{
case SELECTION_SET:
- for (item=tv->tree.root; item; item=NextPreorder(item)) {
+ for (item=tv->tree.root; item; item = NextPreorder(item)) {
item->state &= ~TTK_STATE_SELECTED;
}
/*FALLTHRU*/
@@ -3003,7 +3026,7 @@ static int TreeviewSelectionCommand(
static int TreeviewTagBindCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Ttk_TagTable tagTable = tv->tree.tagTable;
Tk_BindingTable bindingTable = tv->tree.bindingTable;
Ttk_Tag tag;
@@ -3056,7 +3079,7 @@ static int TreeviewTagBindCommand(
static int TreeviewTagConfigureCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Ttk_TagTable tagTable = tv->tree.tagTable;
Ttk_Tag tag;
@@ -3082,12 +3105,40 @@ static int TreeviewTagConfigureCommand(
return Ttk_ConfigureTag(interp, tagTable, tag, objc - 4, objv + 4);
}
+/* + $tv tag delete $tag
+ */
+static int TreeviewTagDeleteCommand(
+ void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+{
+ Treeview *tv = (Treeview *)recordPtr;
+ Ttk_TagTable tagTable = tv->tree.tagTable;
+ TreeItem *item = tv->tree.root;
+ Ttk_Tag tag;
+
+ if (objc != 4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "tagName");
+ return TCL_ERROR;
+ }
+
+ tag = Ttk_GetTagFromObj(tagTable, objv[3]);
+ /* remove the tag from all items */
+ while (item) {
+ RemoveTag(item, tag);
+ item = NextPreorder(item);
+ }
+ /* then remove the tag from the tag table */
+ Ttk_DeleteTagFromTable(tagTable, tag);
+ TtkRedisplayWidget(&tv->core);
+
+ return TCL_OK;
+}
+
/* + $tv tag has $tag ?$item?
*/
static int TreeviewTagHasCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
if (objc == 4) { /* Return list of all items with tag */
Ttk_Tag tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[3]);
@@ -3110,7 +3161,7 @@ static int TreeviewTagHasCommand(
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(Ttk_TagSetContains(item->tagset, tag)));
+ Tcl_NewWideIntObj(Ttk_TagSetContains(item->tagset, tag)));
return TCL_OK;
} else {
Tcl_WrongNumArgs(interp, 3, objv, "tagName ?item?");
@@ -3123,7 +3174,7 @@ static int TreeviewTagHasCommand(
static int TreeviewTagNamesCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 3, objv, "");
@@ -3147,7 +3198,7 @@ static void AddTag(TreeItem *item, Ttk_Tag tag)
static int TreeviewTagAddCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Ttk_Tag tag;
TreeItem **items;
int i;
@@ -3187,7 +3238,7 @@ static void RemoveTag(TreeItem *item, Ttk_Tag tag)
static int TreeviewTagRemoveCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Ttk_Tag tag;
if (objc < 4) {
@@ -3211,7 +3262,7 @@ static int TreeviewTagRemoveCommand(
TreeItem *item = tv->tree.root;
while (item) {
RemoveTag(item, tag);
- item=NextPreorder(item);
+ item = NextPreorder(item);
}
}
@@ -3224,6 +3275,7 @@ static const Ttk_Ensemble TreeviewTagCommands[] = {
{ "add", TreeviewTagAddCommand,0 },
{ "bind", TreeviewTagBindCommand,0 },
{ "configure", TreeviewTagConfigureCommand,0 },
+ { "delete", TreeviewTagDeleteCommand,0 },
{ "has", TreeviewTagHasCommand,0 },
{ "names", TreeviewTagNamesCommand,0 },
{ "remove", TreeviewTagRemoveCommand,0 },
@@ -3242,6 +3294,7 @@ static const Ttk_Ensemble TreeviewCommands[] = {
{ "delete", TreeviewDeleteCommand,0 },
{ "detach", TreeviewDetachCommand,0 },
{ "drag", TreeviewDragCommand,0 },
+ { "drop", TreeviewDropCommand,0 },
{ "exists", TreeviewExistsCommand,0 },
{ "focus", TreeviewFocusCommand,0 },
{ "heading", TreeviewHeadingCommand,0 },
@@ -3268,7 +3321,7 @@ static const Ttk_Ensemble TreeviewCommands[] = {
* +++ Widget definition.
*/
-static WidgetSpec TreeviewWidgetSpec = {
+static const WidgetSpec TreeviewWidgetSpec = {
"Treeview", /* className */
sizeof(Treeview), /* recordSize */
TreeviewOptionSpecs, /* optionSpecs */
@@ -3327,23 +3380,25 @@ typedef struct {
Tcl_Obj *marginsObj;
} TreeitemIndicator;
-static Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = {
+static const Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = {
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
+ offsetof(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
{ "-indicatorsize", TK_OPTION_PIXELS,
- Tk_Offset(TreeitemIndicator,sizeObj), "12" },
+ offsetof(TreeitemIndicator,sizeObj), "12" },
{ "-indicatormargins", TK_OPTION_STRING,
- Tk_Offset(TreeitemIndicator,marginsObj), "2 2 4 2" },
- { NULL, 0, 0, NULL }
+ offsetof(TreeitemIndicator,marginsObj), "2 2 4 2" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void TreeitemIndicatorSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TreeitemIndicator *indicator = elementRecord;
+ TreeitemIndicator *indicator = (TreeitemIndicator *)elementRecord;
Ttk_Padding margins;
int size = 0;
+ (void)dummy;
+ (void)paddingPtr;
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginsObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
@@ -3353,15 +3408,16 @@ static void TreeitemIndicatorSize(
}
static void TreeitemIndicatorDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- TreeitemIndicator *indicator = elementRecord;
+ TreeitemIndicator *indicator = (TreeitemIndicator *)elementRecord;
ArrowDirection direction =
(state & TTK_STATE_OPEN) ? ARROW_DOWN : ARROW_RIGHT;
Ttk_Padding margins;
XColor *borderColor = Tk_GetColorFromObj(tkwin, indicator->colorObj);
XGCValues gcvalues; GC gc; unsigned mask;
+ (void)dummy;
if (state & TTK_STATE_LEAF) /* don't draw anything */
return;
@@ -3379,7 +3435,7 @@ static void TreeitemIndicatorDraw(
Tk_FreeGC(Tk_Display(tkwin), gc);
}
-static Ttk_ElementSpec TreeitemIndicatorElementSpec = {
+static const Ttk_ElementSpec TreeitemIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TreeitemIndicator),
TreeitemIndicatorOptions,
@@ -3396,26 +3452,29 @@ typedef struct {
Tcl_Obj *rowNumberObj;
} RowElement;
-static Ttk_ElementOptionSpec RowElementOptions[] = {
+static const Ttk_ElementOptionSpec RowElementOptions[] = {
{ "-background", TK_OPTION_COLOR,
- Tk_Offset(RowElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(RowElement,backgroundObj), DEFAULT_BACKGROUND },
{ "-rownumber", TK_OPTION_INT,
- Tk_Offset(RowElement,rowNumberObj), "0" },
- { NULL, 0, 0, NULL }
+ offsetof(RowElement,rowNumberObj), "0" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void RowElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- RowElement *row = elementRecord;
+ RowElement *row = (RowElement *)elementRecord;
XColor *color = Tk_GetColorFromObj(tkwin, row->backgroundObj);
GC gc = Tk_GCForColor(color, d);
+ (void)dummy;
+ (void)state;
+
XFillRectangle(Tk_Display(tkwin), d, gc,
b.x, b.y, b.width, b.height);
}
-static Ttk_ElementSpec RowElementSpec = {
+static const Ttk_ElementSpec RowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(RowElement),
RowElementOptions,
diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c
index c2f8d60..df6e6be 100644
--- a/generic/ttk/ttkWidget.c
+++ b/generic/ttk/ttkWidget.c
@@ -85,7 +85,7 @@ static void EndDrawing(Tk_Window tkwin, Drawable d)
#else
/* No double-buffering: draw directly into the window. */
static Drawable BeginDrawing(Tk_Window tkwin) { return Tk_WindowId(tkwin); }
-static void EndDrawing(Tk_Window tkwin, Drawable d) { }
+static void EndDrawing(Tk_Window tkwin, Drawable d) { (void)tkwin; (void)d;}
#endif
/* DrawWidget --
@@ -93,7 +93,7 @@ static void EndDrawing(Tk_Window tkwin, Drawable d) { }
*/
static void DrawWidget(ClientData recordPtr)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
corePtr->flags &= ~REDISPLAY_PENDING;
if (Tk_IsMapped(corePtr->tkwin)) {
@@ -152,7 +152,7 @@ static int
WidgetInstanceObjCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
const Ttk_Ensemble *commands = corePtr->widgetSpec->commands;
int status;
@@ -187,7 +187,7 @@ WidgetInstanceObjCmd(
static void
WidgetInstanceObjCmdDeleted(ClientData clientData)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
corePtr->widgetCmd = NULL;
if (corePtr->tkwin != NULL)
Tk_DestroyWindow(corePtr->tkwin);
@@ -262,7 +262,7 @@ static const unsigned CoreEventMask
static void CoreEventProc(ClientData clientData, XEvent *eventPtr)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
switch (eventPtr->type)
{
@@ -309,12 +309,15 @@ static void CoreEventProc(ClientData clientData, XEvent *eventPtr)
corePtr->state |= TTK_STATE_HOVER;
TtkRedisplayWidget(corePtr);
break;
- case VirtualEvent:
- if (!strcmp("ThemeChanged", ((XVirtualEvent *)(eventPtr))->name)) {
+ case VirtualEvent: {
+ const char *name = ((XVirtualEvent *)eventPtr)->name;
+ if ((name != NULL) && !strcmp("ThemeChanged", name)) {
(void)UpdateLayout(corePtr->interp, corePtr);
SizeChanged(corePtr);
TtkRedisplayWidget(corePtr);
}
+ break;
+ }
default:
/* can't happen... */
break;
@@ -329,12 +332,12 @@ static void CoreEventProc(ClientData clientData, XEvent *eventPtr)
*/
static void WidgetWorldChanged(ClientData clientData)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
SizeChanged(corePtr);
TtkRedisplayWidget(corePtr);
}
-static Tk_ClassProcs widgetClassProcs = {
+static const Tk_ClassProcs widgetClassProcs = {
sizeof(Tk_ClassProcs), /* size */
WidgetWorldChanged, /* worldChangedProc */
NULL, /* createProc */
@@ -349,7 +352,7 @@ static Tk_ClassProcs widgetClassProcs = {
int TtkWidgetConstructorObjCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetSpec *widgetSpec = clientData;
+ WidgetSpec *widgetSpec = (WidgetSpec *)clientData;
const char *className = widgetSpec->className;
Tk_OptionTable optionTable =
Tk_CreateOptionTable(interp, widgetSpec->optionSpecs);
@@ -385,7 +388,7 @@ int TtkWidgetConstructorObjCmd(
*/
recordPtr = ckalloc(widgetSpec->recordSize);
memset(recordPtr, 0, widgetSpec->recordSize);
- corePtr = recordPtr;
+ corePtr = (WidgetCore *)recordPtr;
corePtr->tkwin = tkwin;
corePtr->interp = interp;
@@ -460,7 +463,7 @@ error:
Ttk_Layout TtkWidgetGetLayout(
Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
const char *styleName = 0;
if (corePtr->styleObj)
@@ -482,17 +485,17 @@ Ttk_Layout TtkWidgetGetLayout(
Ttk_Layout TtkWidgetGetOrientedLayout(
Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr, Tcl_Obj *orientObj)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
const char *baseStyleName = 0;
Tcl_DString styleName;
- int orient = TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = TTK_ORIENT_HORIZONTAL;
Ttk_Layout layout;
Tcl_DStringInit(&styleName);
/* Prefix:
*/
- Ttk_GetOrientFromObj(NULL, orientObj, &orient);
+ TtkGetOrientFromObj(NULL, orientObj, &orient);
if (orient == TTK_ORIENT_HORIZONTAL)
Tcl_DStringAppend(&styleName, "Horizontal.", -1);
else
@@ -522,6 +525,8 @@ Ttk_Layout TtkWidgetGetOrientedLayout(
*/
void TtkNullInitialize(Tcl_Interp *interp, void *recordPtr)
{
+ (void)interp;
+ (void)recordPtr;
}
/* TtkNullPostConfigure --
@@ -529,6 +534,10 @@ void TtkNullInitialize(Tcl_Interp *interp, void *recordPtr)
*/
int TtkNullPostConfigure(Tcl_Interp *interp, void *clientData, int mask)
{
+ (void)interp;
+ (void)clientData;
+ (void)mask;
+
return TCL_OK;
}
@@ -538,7 +547,7 @@ int TtkNullPostConfigure(Tcl_Interp *interp, void *clientData, int mask)
*/
int TtkCoreConfigure(Tcl_Interp *interp, void *clientData, int mask)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
int status = TCL_OK;
if (mask & STYLE_CHANGED) {
@@ -553,6 +562,7 @@ int TtkCoreConfigure(Tcl_Interp *interp, void *clientData, int mask)
*/
void TtkNullCleanup(void *recordPtr)
{
+ (void)recordPtr;
return;
}
@@ -561,7 +571,7 @@ void TtkNullCleanup(void *recordPtr)
*/
void TtkWidgetDoLayout(void *clientData)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin));
}
@@ -570,7 +580,7 @@ void TtkWidgetDoLayout(void *clientData)
*/
void TtkWidgetDisplay(void *recordPtr, Drawable d)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_DrawLayout(corePtr->layout, corePtr->state, d);
}
@@ -579,7 +589,7 @@ void TtkWidgetDisplay(void *recordPtr, Drawable d)
*/
int TtkWidgetSize(void *recordPtr, int *widthPtr, int *heightPtr)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_LayoutSize(corePtr->layout, corePtr->state, widthPtr, heightPtr);
return 1;
}
@@ -593,7 +603,7 @@ int TtkWidgetSize(void *recordPtr, int *widthPtr, int *heightPtr)
int TtkWidgetCgetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Tcl_Obj *result;
if (objc != 3) {
@@ -613,7 +623,7 @@ int TtkWidgetCgetCommand(
int TtkWidgetConfigureCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Tcl_Obj *result;
if (objc == 2) {
@@ -683,7 +693,7 @@ int TtkWidgetConfigureCommand(
int TtkWidgetStateCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_StateSpec spec;
int status;
Ttk_State oldState, changed;
@@ -723,7 +733,7 @@ int TtkWidgetStateCommand(
int TtkWidgetInstateCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_State state = corePtr->state;
Ttk_StateSpec spec;
int status = TCL_OK;
@@ -738,7 +748,7 @@ int TtkWidgetInstateCommand(
if (objc == 3) {
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(Ttk_StateMatches(state,&spec)));
+ Tcl_NewWideIntObj(Ttk_StateMatches(state,&spec)));
} else if (objc == 4) {
if (Ttk_StateMatches(state,&spec)) {
status = Tcl_EvalObjEx(interp, objv[3], 0);
@@ -754,7 +764,7 @@ int TtkWidgetInstateCommand(
int TtkWidgetIdentifyCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_Element element;
static const char *const whatTable[] = { "element", NULL };
int x, y, what;
diff --git a/generic/ttk/ttkWidget.h b/generic/ttk/ttkWidget.h
index 798bcce..6837d89 100644
--- a/generic/ttk/ttkWidget.h
+++ b/generic/ttk/ttkWidget.h
@@ -117,21 +117,21 @@ MODULE_SCOPE int TtkWidgetConstructorObjCmd(
*/
#define WIDGET_TAKEFOCUS_TRUE \
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", \
- "ttk::takefocus", Tk_Offset(WidgetCore, takeFocusPtr), -1, 0,0,0 }
+ "ttk::takefocus", offsetof(WidgetCore, takeFocusPtr), TCL_INDEX_NONE, 0,0,0 }
#define WIDGET_TAKEFOCUS_FALSE \
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", \
- "", Tk_Offset(WidgetCore, takeFocusPtr), -1, 0,0,0 }
+ "", offsetof(WidgetCore, takeFocusPtr), TCL_INDEX_NONE, 0,0,0 }
/* WIDGET_INHERIT_OPTIONS(baseOptionSpecs) --
* Add this at the end of an OptionSpecs table to inherit
* the options from 'baseOptionSpecs'.
*/
#define WIDGET_INHERIT_OPTIONS(baseOptionSpecs) \
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0, (ClientData)baseOptionSpecs, 0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0, baseOptionSpecs, 0}
/* All widgets should inherit from ttkCoreOptionSpecs[].
*/
-MODULE_SCOPE Tk_OptionSpec ttkCoreOptionSpecs[];
+MODULE_SCOPE const Tk_OptionSpec ttkCoreOptionSpecs[];
/*
* Useful routines for use inside widget implementations:
@@ -195,7 +195,8 @@ MODULE_SCOPE void TtkFreeScrollHandle(ScrollHandle);
MODULE_SCOPE int TtkScrollviewCommand(
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], ScrollHandle);
-MODULE_SCOPE void TtkScrollTo(ScrollHandle, int newFirst);
+MODULE_SCOPE void TtkUpdateScrollInfo(ScrollHandle h);
+MODULE_SCOPE void TtkScrollTo(ScrollHandle, int newFirst, int updateScrollInfo);
MODULE_SCOPE void TtkScrolled(ScrollHandle, int first, int last, int total);
MODULE_SCOPE void TtkScrollbarUpdateRequired(ScrollHandle);
@@ -211,7 +212,7 @@ typedef struct TtkTagSet { /* TODO: make opaque */
} *Ttk_TagSet;
MODULE_SCOPE Ttk_TagTable Ttk_CreateTagTable(
- Tcl_Interp *, Tk_Window tkwin, Tk_OptionSpec[], int recordSize);
+ Tcl_Interp *, Tk_Window tkwin, const Tk_OptionSpec *, int recordSize);
MODULE_SCOPE void Ttk_DeleteTagTable(Ttk_TagTable);
MODULE_SCOPE Ttk_Tag Ttk_GetTag(Ttk_TagTable, const char *tagName);
@@ -225,6 +226,8 @@ MODULE_SCOPE int Ttk_EnumerateTagOptions(
MODULE_SCOPE int Ttk_EnumerateTags(Tcl_Interp *, Ttk_TagTable);
+MODULE_SCOPE void Ttk_DeleteTagFromTable(Ttk_TagTable, Ttk_Tag);
+
MODULE_SCOPE int Ttk_ConfigureTag(
Tcl_Interp *interp, Ttk_TagTable tagTable, Ttk_Tag tag,
int objc, Tcl_Obj *const objv[]);
@@ -246,9 +249,9 @@ MODULE_SCOPE void Ttk_TagSetApplyStyle(Ttk_TagTable,Ttk_Style,Ttk_State,void*);
* String tables for widget resource specifications:
*/
-MODULE_SCOPE const char *ttkOrientStrings[];
-MODULE_SCOPE const char *ttkCompoundStrings[];
-MODULE_SCOPE const char *ttkDefaultStrings[];
+MODULE_SCOPE const char *const ttkOrientStrings[];
+MODULE_SCOPE const char *const ttkCompoundStrings[];
+MODULE_SCOPE const char *const ttkDefaultStrings[];
/*
* ... other option types...
diff --git a/library/bgerror.tcl b/library/bgerror.tcl
index 574ad8b..d4d9b21 100644
--- a/library/bgerror.tcl
+++ b/library/bgerror.tcl
@@ -21,7 +21,8 @@ namespace eval ::tk::dialog::error {
if {[tk windowingsystem] eq "aqua"} {
option add *ErrorDialog*background systemAlertBackgroundActive \
widgetDefault
- option add *ErrorDialog*info.text.background white widgetDefault
+ option add *ErrorDialog*info.text.background \
+ systemTextBackgroundColor widgetDefault
option add *ErrorDialog*Button.highlightBackground \
systemAlertBackgroundActive widgetDefault
}
@@ -114,6 +115,7 @@ proc ::tk::dialog::error::bgerror {err {flag 1}} {
set windowingsystem [tk windowingsystem]
if {$windowingsystem eq "aqua"} {
if $flag {
+ set errorInfo $info
after 500 [list bgerror "$err" 0]
return
}
@@ -180,7 +182,7 @@ proc ::tk::dialog::error::bgerror {err {flag 1}} {
pack $W.text -side left -expand yes -fill both
$W.text insert 0.0 "$err\n$info"
$W.text mark set insert 0.0
- bind $W.text <ButtonPress-1> { focus %W }
+ bind $W.text <Button-1> { focus %W }
$W.text configure -state disabled
# 2. Fill the top part with bitmap and message
diff --git a/library/button.tcl b/library/button.tcl
index 80d8bf9..d824009 100644
--- a/library/button.tcl
+++ b/library/button.tcl
@@ -21,7 +21,7 @@ if {[tk windowingsystem] eq "aqua"} {
bind Radiobutton <Enter> {
tk::ButtonEnter %W
}
- bind Radiobutton <1> {
+ bind Radiobutton <Button-1> {
tk::ButtonDown %W
}
bind Radiobutton <ButtonRelease-1> {
@@ -30,7 +30,7 @@ if {[tk windowingsystem] eq "aqua"} {
bind Checkbutton <Enter> {
tk::ButtonEnter %W
}
- bind Checkbutton <1> {
+ bind Checkbutton <Button-1> {
tk::ButtonDown %W
}
bind Checkbutton <ButtonRelease-1> {
@@ -50,7 +50,7 @@ if {"win32" eq [tk windowingsystem]} {
bind Checkbutton <minus> {
tk::CheckRadioInvoke %W deselect
}
- bind Checkbutton <1> {
+ bind Checkbutton <Button-1> {
tk::CheckRadioDown %W
}
bind Checkbutton <ButtonRelease-1> {
@@ -63,7 +63,7 @@ if {"win32" eq [tk windowingsystem]} {
tk::ButtonLeave %W
}
- bind Radiobutton <1> {
+ bind Radiobutton <Button-1> {
tk::CheckRadioDown %W
}
bind Radiobutton <ButtonRelease-1> {
@@ -84,10 +84,10 @@ if {"x11" eq [tk windowingsystem]} {
tk::CheckRadioInvoke %W
}
}
- bind Checkbutton <1> {
+ bind Checkbutton <Button-1> {
tk::CheckInvoke %W
}
- bind Radiobutton <1> {
+ bind Radiobutton <Button-1> {
tk::CheckRadioInvoke %W
}
bind Checkbutton <Enter> {
@@ -127,7 +127,7 @@ bind Button <Enter> {
bind Button <Leave> {
tk::ButtonLeave %W
}
-bind Button <1> {
+bind Button <Button-1> {
tk::ButtonDown %W
}
bind Button <ButtonRelease-1> {
@@ -748,11 +748,15 @@ proc ::tk::CheckLeave {w} {
$w configure -state normal
}
- # Restore the original button "selected" color; assume that the user
- # wasn't monkeying around with things too much.
+ # Restore the original button "selected" color; but only if the user
+ # has not changed it in the meantime.
if {![$w cget -indicatoron] && [info exist Priv($w,selectcolor)]} {
- $w configure -selectcolor $Priv($w,selectcolor)
+ if {[$w cget -selectcolor] eq $Priv($w,selectcolor)
+ || ([info exist Priv($w,aselectcolor)] &&
+ [$w cget -selectcolor] eq $Priv($w,aselectcolor))} {
+ $w configure -selectcolor $Priv($w,selectcolor)
+ }
}
unset -nocomplain Priv($w,selectcolor) Priv($w,aselectcolor)
diff --git a/library/clrpick.tcl b/library/clrpick.tcl
index 600be16..d67c67f 100644
--- a/library/clrpick.tcl
+++ b/library/clrpick.tcl
@@ -316,7 +316,7 @@ proc ::tk::dialog::color::BuildDialog {w} {
# Accelerator bindings
bind $lab <<AltUnderlined>> [list focus $ent]
- bind $w <KeyPress-Escape> [list tk::ButtonInvoke $data(cancelBtn)]
+ bind $w <Escape> [list tk::ButtonInvoke $data(cancelBtn)]
bind $w <Alt-Key> [list tk::AltKeyInDialog $w %A]
wm protocol $w WM_DELETE_WINDOW [list tk::dialog::color::CancelCmd $w]
@@ -396,7 +396,7 @@ proc ::tk::dialog::color::DrawColorScale {w c {create 0}} {
# Draw the selection polygons
CreateSelector $w $sel $c
- $sel bind $data($c,index) <ButtonPress-1> \
+ $sel bind $data($c,index) <Button-1> \
[list tk::dialog::color::StartMove $w $sel $c %x $data(selPad) 1]
$sel bind $data($c,index) <B1-Motion> \
[list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)]
@@ -409,14 +409,14 @@ proc ::tk::dialog::color::DrawColorScale {w c {create 0}} {
set data($c,clickRegion) [$sel create rectangle 0 0 \
$data(canvasWidth) $height -fill {} -outline {}]
- bind $col <ButtonPress-1> \
+ bind $col <Button-1> \
[list tk::dialog::color::StartMove $w $sel $c %x $data(colorPad)]
bind $col <B1-Motion> \
[list tk::dialog::color::MoveSelector $w $sel $c %x $data(colorPad)]
bind $col <ButtonRelease-1> \
[list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(colorPad)]
- $sel bind $data($c,clickRegion) <ButtonPress-1> \
+ $sel bind $data($c,clickRegion) <Button-1> \
[list tk::dialog::color::StartMove $w $sel $c %x $data(selPad)]
$sel bind $data($c,clickRegion) <B1-Motion> \
[list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)]
diff --git a/library/console.tcl b/library/console.tcl
index 355a43b..eb8990a 100644
--- a/library/console.tcl
+++ b/library/console.tcl
@@ -416,60 +416,60 @@ proc ::tk::ConsoleBind {w} {
bind Console $ev [bind Text $ev]
}
## We really didn't want the newline insertion...
- bind Console <Control-Key-o> {}
+ bind Console <Control-o> {}
## ...or any Control-v binding (would block <<Paste>>)
- bind Console <Control-Key-v> {}
+ bind Console <Control-v> {}
# For the moment, transpose isn't enabled until the console
# gets and overhaul of how it handles input -- hobbs
- bind Console <Control-Key-t> {}
+ bind Console <Control-t> {}
# Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
# Otherwise, if a widget binding for one of these is defined, the
# <Keypress> class binding will also fire and insert the character
# which is wrong.
- bind Console <Alt-KeyPress> {# nothing }
- bind Console <Meta-KeyPress> {# nothing}
- bind Console <Control-KeyPress> {# nothing}
+ bind Console <Alt-Key> {# nothing }
+ bind Console <Meta-Key> {# nothing}
+ bind Console <Control-Key> {# nothing}
foreach {ev key} {
- <<Console_NextImmediate>> <Control-Key-n>
- <<Console_PrevImmediate>> <Control-Key-p>
- <<Console_PrevSearch>> <Control-Key-r>
- <<Console_NextSearch>> <Control-Key-s>
-
- <<Console_Expand>> <Key-Tab>
- <<Console_Expand>> <Key-Escape>
- <<Console_ExpandFile>> <Control-Shift-Key-F>
- <<Console_ExpandProc>> <Control-Shift-Key-P>
- <<Console_ExpandVar>> <Control-Shift-Key-V>
- <<Console_Tab>> <Control-Key-i>
- <<Console_Tab>> <Meta-Key-i>
- <<Console_Eval>> <Key-Return>
- <<Console_Eval>> <Key-KP_Enter>
-
- <<Console_Clear>> <Control-Key-l>
- <<Console_KillLine>> <Control-Key-k>
- <<Console_Transpose>> <Control-Key-t>
- <<Console_ClearLine>> <Control-Key-u>
- <<Console_SaveCommand>> <Control-Key-z>
- <<Console_FontSizeIncr>> <Control-Key-plus>
- <<Console_FontSizeDecr>> <Control-Key-minus>
+ <<Console_NextImmediate>> <Control-n>
+ <<Console_PrevImmediate>> <Control-p>
+ <<Console_PrevSearch>> <Control-r>
+ <<Console_NextSearch>> <Control-s>
+
+ <<Console_Expand>> <Tab>
+ <<Console_Expand>> <Escape>
+ <<Console_ExpandFile>> <Control-Shift-F>
+ <<Console_ExpandProc>> <Control-Shift-P>
+ <<Console_ExpandVar>> <Control-Shift-V>
+ <<Console_Tab>> <Control-i>
+ <<Console_Tab>> <Meta-i>
+ <<Console_Eval>> <Return>
+ <<Console_Eval>> <KP_Enter>
+
+ <<Console_Clear>> <Control-l>
+ <<Console_KillLine>> <Control-k>
+ <<Console_Transpose>> <Control-t>
+ <<Console_ClearLine>> <Control-u>
+ <<Console_SaveCommand>> <Control-z>
+ <<Console_FontSizeIncr>> <Control-plus>
+ <<Console_FontSizeDecr>> <Control-minus>
} {
event add $ev $key
bind Console $key {}
}
if {[tk windowingsystem] eq "aqua"} {
foreach {ev key} {
- <<Console_FontSizeIncr>> <Command-Key-plus>
- <<Console_FontSizeDecr>> <Command-Key-minus>
+ <<Console_FontSizeIncr>> <Command-plus>
+ <<Console_FontSizeDecr>> <Command-minus>
} {
event add $ev $key
bind Console $key {}
}
if {$::tk::console::useFontchooser} {
- bind Console <Command-Key-t> [list ::tk::console::FontchooserToggle]
+ bind Console <Command-t> [list ::tk::console::FontchooserToggle]
}
}
bind Console <<Console_Expand>> {
@@ -587,7 +587,7 @@ proc ::tk::ConsoleBind {w} {
bind Console <Insert> {
catch {tk::ConsoleInsert %W [::tk::GetSelection %W PRIMARY]}
}
- bind Console <KeyPress> {
+ bind Console <Key> {
tk::ConsoleInsert %W %A
}
bind Console <F9> {
@@ -629,28 +629,28 @@ proc ::tk::ConsoleBind {w} {
##
## Bindings for doing special things based on certain keys
##
- bind PostConsole <Key-parenright> {
+ bind PostConsole <parenright> {
if {"\\" ne [%W get insert-2c]} {
::tk::console::MatchPair %W \( \) promptEnd
}
}
- bind PostConsole <Key-bracketright> {
+ bind PostConsole <bracketright> {
if {"\\" ne [%W get insert-2c]} {
::tk::console::MatchPair %W \[ \] promptEnd
}
}
- bind PostConsole <Key-braceright> {
+ bind PostConsole <braceright> {
if {"\\" ne [%W get insert-2c]} {
::tk::console::MatchPair %W \{ \} promptEnd
}
}
- bind PostConsole <Key-quotedbl> {
+ bind PostConsole <quotedbl> {
if {"\\" ne [%W get insert-2c]} {
::tk::console::MatchQuote %W promptEnd
}
}
- bind PostConsole <KeyPress> {
+ bind PostConsole <Key> {
if {"%A" ne ""} {
::tk::console::TagProc %W
}
diff --git a/library/demos/arrow.tcl b/library/demos/arrow.tcl
index 5011f6f..3d0b406 100644
--- a/library/demos/arrow.tcl
+++ b/library/demos/arrow.tcl
@@ -135,9 +135,13 @@ set demo_arrowInfo(y) 150
set demo_arrowInfo(smallTips) {5 5 2}
set demo_arrowInfo(count) 0
if {[winfo depth $c] > 1} {
- set demo_arrowInfo(bigLineStyle) "-fill SkyBlue1"
- set demo_arrowInfo(boxStyle) "-fill {} -outline black -width 1"
- set demo_arrowInfo(activeStyle) "-fill red -outline black -width 1"
+ if {[tk windowingsystem] eq "aqua"} {
+ set demo_arrowInfo(bigLineStyle) "-fill systemSelectedTextBackgroundColor"
+ } else {
+ set demo_arrowInfo(bigLineStyle) "-fill LightSeaGreen"
+ }
+ set demo_arrowInfo(boxStyle) "-fill {} -width 1"
+ set demo_arrowInfo(activeStyle) "-fill red -width 1"
} else {
# Main widget program sets variable tk_demoDirectory
set demo_arrowInfo(bigLineStyle) "-fill black \
@@ -150,11 +154,11 @@ $c bind box <Enter> "$c itemconfigure current $demo_arrowInfo(activeStyle)"
$c bind box <Leave> "$c itemconfigure current $demo_arrowInfo(boxStyle)"
$c bind box <B1-Enter> " "
$c bind box <B1-Leave> " "
-$c bind box1 <1> {set demo_arrowInfo(motionProc) arrowMove1}
-$c bind box2 <1> {set demo_arrowInfo(motionProc) arrowMove2}
-$c bind box3 <1> {set demo_arrowInfo(motionProc) arrowMove3}
+$c bind box1 <Button-1> {set demo_arrowInfo(motionProc) arrowMove1}
+$c bind box2 <Button-1> {set demo_arrowInfo(motionProc) arrowMove2}
+$c bind box3 <Button-1> {set demo_arrowInfo(motionProc) arrowMove3}
$c bind box <B1-Motion> "\$demo_arrowInfo(motionProc) $c %x %y"
-bind $c <Any-ButtonRelease-1> "arrowSetup $c"
+bind $c <ButtonRelease-1> "arrowSetup $c"
# arrowMove1 --
# This procedure is called for each mouse motion event on box1 (the
diff --git a/library/demos/bind.tcl b/library/demos/bind.tcl
index 03f6d3b..9146362 100644
--- a/library/demos/bind.tcl
+++ b/library/demos/bind.tcl
@@ -63,16 +63,16 @@ $w.text insert end \
# Create bindings for tags.
foreach tag {d1 d2 d3 d4 d5 d6} {
- $w.text tag bind $tag <Any-Enter> "$w.text tag configure $tag $bold"
- $w.text tag bind $tag <Any-Leave> "$w.text tag configure $tag $normal"
+ $w.text tag bind $tag <Enter> "$w.text tag configure $tag $bold"
+ $w.text tag bind $tag <Leave> "$w.text tag configure $tag $normal"
}
# Main widget program sets variable tk_demoDirectory
-$w.text tag bind d1 <1> {source [file join $tk_demoDirectory items.tcl]}
-$w.text tag bind d2 <1> {source [file join $tk_demoDirectory plot.tcl]}
-$w.text tag bind d3 <1> {source [file join $tk_demoDirectory ctext.tcl]}
-$w.text tag bind d4 <1> {source [file join $tk_demoDirectory arrow.tcl]}
-$w.text tag bind d5 <1> {source [file join $tk_demoDirectory ruler.tcl]}
-$w.text tag bind d6 <1> {source [file join $tk_demoDirectory cscroll.tcl]}
+$w.text tag bind d1 <Button-1> {source [file join $tk_demoDirectory items.tcl]}
+$w.text tag bind d2 <Button-1> {source [file join $tk_demoDirectory plot.tcl]}
+$w.text tag bind d3 <Button-1> {source [file join $tk_demoDirectory ctext.tcl]}
+$w.text tag bind d4 <Button-1> {source [file join $tk_demoDirectory arrow.tcl]}
+$w.text tag bind d5 <Button-1> {source [file join $tk_demoDirectory ruler.tcl]}
+$w.text tag bind d6 <Button-1> {source [file join $tk_demoDirectory cscroll.tcl]}
$w.text mark set insert 0.0
$w.text configure -state disabled
diff --git a/library/demos/colors.tcl b/library/demos/colors.tcl
index 99dec92..fdfdc5b 100644
--- a/library/demos/colors.tcl
+++ b/library/demos/colors.tcl
@@ -32,7 +32,7 @@ listbox $w.frame.list -yscroll "$w.frame.scroll set" \
-width 20 -height 16 -setgrid 1
pack $w.frame.list $w.frame.scroll -side left -fill y -expand 1
-bind $w.frame.list <Double-1> {
+bind $w.frame.list <Double-Button-1> {
tk_setPalette [selection get]
}
$w.frame.list insert 0 gray60 gray70 gray80 gray85 gray90 gray95 \
diff --git a/library/demos/cscroll.tcl b/library/demos/cscroll.tcl
index f6e88f4..c0c30ee 100644
--- a/library/demos/cscroll.tcl
+++ b/library/demos/cscroll.tcl
@@ -47,32 +47,93 @@ for {set i 0} {$i < 20} {incr i} {
set x [expr {-10 + 3*$i}]
for {set j 0; set y -10} {$j < 10} {incr j; incr y 3} {
$c create rect ${x}c ${y}c [expr {$x+2}]c [expr {$y+2}]c \
- -outline black -fill $bg -tags rect
+ -fill $bg -tags rect
$c create text [expr {$x+1}]c [expr {$y+1}]c -text "$i,$j" \
-anchor center -tags text
}
}
-$c bind all <Any-Enter> "scrollEnter $c"
-$c bind all <Any-Leave> "scrollLeave $c"
-$c bind all <1> "scrollButton $c"
-bind $c <2> "$c scan mark %x %y"
+$c bind all <Enter> "scrollEnter $c"
+$c bind all <Leave> "scrollLeave $c"
+$c bind all <Button-1> "scrollButton $c"
+bind $c <Button-2> "$c scan mark %x %y"
bind $c <B2-Motion> "$c scan dragto %x %y"
if {[tk windowingsystem] eq "aqua"} {
bind $c <MouseWheel> {
- %W yview scroll [expr {- (%D)}] units
+ %W yview scroll [expr {-(%D)}] units
}
bind $c <Option-MouseWheel> {
- %W yview scroll [expr {-10 * (%D)}] units
+ %W yview scroll [expr {-10 * (%D)}] units
}
bind $c <Shift-MouseWheel> {
- %W xview scroll [expr {- (%D)}] units
+ %W xview scroll [expr {-(%D)}] units
}
bind $c <Shift-Option-MouseWheel> {
- %W xview scroll [expr {-10 * (%D)}] units
+ %W xview scroll [expr {-10 * (%D)}] units
+ }
+} else {
+ # We must make sure that positive and negative movements are rounded
+ # equally to integers, avoiding the problem that
+ # (int)1/30 = 0,
+ # but
+ # (int)-1/30 = -1
+ # The following code ensure equal +/- behaviour.
+ bind $c <MouseWheel> {
+ if {%D >= 0} {
+ %W yview scroll [expr {-%D/30}] units
+ } else {
+ %W yview scroll [expr {(29-%D)/30}] units
+ }
+ }
+ bind $c <Shift-MouseWheel> {
+ if {%D >= 0} {
+ %W xview scroll [expr {-%D/30}] units
+ } else {
+ %W xview scroll [expr {(29-%D)/30}] units
+ }
}
}
+if {[tk windowingsystem] eq "x11"} {
+ # Support for mousewheels on Linux/Unix commonly comes through mapping
+ # the wheel to the extended buttons. If you have a mousewheel, find
+ # Linux configuration info at:
+ # http://linuxreviews.org/howtos/xfree/mouse/
+ bind $c <Button-4> {
+ if {!$tk_strictMotif} {
+ %W yview scroll -5 units
+ }
+ }
+ bind $c <Shift-Button-4> {
+ if {!$tk_strictMotif} {
+ %W xview scroll -5 units
+ }
+ }
+ bind $c <Button-5> {
+ if {!$tk_strictMotif} {
+ %W yview scroll 5 units
+ }
+ }
+ bind $c <Shift-Button-5> {
+ if {!$tk_strictMotif} {
+ %W xview scroll 5 units
+ }
+ }
+ if {[package vsatisfies [package provide Tk] 8.7]} {
+ bind $c <Button-6> {
+ if {!$tk_strictMotif} {
+ %W xview scroll -5 units
+ }
+ }
+ bind $c <Button-7> {
+ if {!$tk_strictMotif} {
+ %W xview scroll 5 units
+ }
+ }
+ }
+}
+
+
proc scrollEnter canvas {
global oldFill
set id [$canvas find withtag current]
@@ -81,10 +142,11 @@ proc scrollEnter canvas {
}
set oldFill [lindex [$canvas itemconfig $id -fill] 4]
if {[winfo depth $canvas] > 1} {
- $canvas itemconfigure $id -fill SeaGreen1
- } else {
- $canvas itemconfigure $id -fill black
- $canvas itemconfigure [expr {$id+1}] -fill white
+ if {[tk windowingsystem] eq "aqua"} {
+ $canvas itemconfigure $id -fill systemSelectedTextBackgroundColor
+ } else {
+ $canvas itemconfigure $id -fill LightSeaGreen
+ }
}
}
@@ -95,11 +157,9 @@ proc scrollLeave canvas {
set id [expr {$id-1}]
}
$canvas itemconfigure $id -fill $oldFill
- $canvas itemconfigure [expr {$id+1}] -fill black
}
proc scrollButton canvas {
- global oldFill
set id [$canvas find withtag current]
if {[lsearch [$canvas gettags current] text] < 0} {
set id [expr {$id+1}]
diff --git a/library/demos/ctext.tcl b/library/demos/ctext.tcl
index 4b8c644..502c9d0 100644
--- a/library/demos/ctext.tcl
+++ b/library/demos/ctext.tcl
@@ -40,17 +40,17 @@ $c create rectangle 245 195 255 205 -outline black -fill red
# First, create the text item and give it bindings so it can be edited.
-$c addtag text withtag [$c create text 250 200 -text "This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been been defined to support editing (see above)." -width 440 -anchor n -font $textFont -justify left]
-$c bind text <1> "textB1Press $c %x %y"
+$c addtag text withtag [$c create text 250 200 -text "This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been defined to support editing (see above)." -width 440 -anchor n -font $textFont -justify left]
+$c bind text <Button-1> "textB1Press $c %x %y"
$c bind text <B1-Motion> "textB1Move $c %x %y"
-$c bind text <Shift-1> "$c select adjust current @%x,%y"
+$c bind text <Shift-Button-1> "$c select adjust current @%x,%y"
$c bind text <Shift-B1-Motion> "textB1Move $c %x %y"
-$c bind text <KeyPress> "textInsert $c %A"
+$c bind text <Key> "textInsert $c %A"
$c bind text <Return> "textInsert $c \\n"
$c bind text <Control-h> "textBs $c"
$c bind text <BackSpace> "textBs $c"
$c bind text <Delete> "textDel $c"
-$c bind text <2> "textPaste $c @%x,%y"
+$c bind text <Button-2> "textPaste $c @%x,%y"
# Next, create some items that allow the text's anchor position
# to be edited.
@@ -58,14 +58,14 @@ $c bind text <2> "textPaste $c @%x,%y"
proc mkTextConfigBox {w x y option value color} {
set item [$w create rect $x $y [expr {$x+30}] [expr {$y+30}] \
-outline black -fill $color -width 1]
- $w bind $item <1> "$w itemconf text $option $value"
+ $w bind $item <Button-1> "$w itemconf text $option $value"
$w addtag config withtag $item
}
proc mkTextConfigPie {w x y a option value color} {
set item [$w create arc $x $y [expr {$x+90}] [expr {$y+90}] \
-start [expr {$a-15}] -extent 30 -outline black -fill $color \
-width 1]
- $w bind $item <1> "$w itemconf text $option $value"
+ $w bind $item <Button-1> "$w itemconf text $option $value"
$w addtag config withtag $item
}
@@ -84,7 +84,7 @@ mkTextConfigBox $c [expr {$x+60}] [expr {$y+60}] -anchor nw $color
set item [$c create rect \
[expr {$x+40}] [expr {$y+40}] [expr {$x+50}] [expr {$y+50}] \
-outline black -fill red]
-$c bind $item <1> "$c itemconf text -anchor center"
+$c bind $item <Button-1> "$c itemconf text -anchor center"
$c create text [expr {$x+45}] [expr {$y-5}] \
-text {Text Position} -anchor s -font {Times 20} -fill brown
diff --git a/library/demos/entry1.tcl b/library/demos/entry1.tcl
index bd74310..58eda03 100644
--- a/library/demos/entry1.tcl
+++ b/library/demos/entry1.tcl
@@ -16,7 +16,7 @@ wm title $w "Entry Demonstration (no scrollbars)"
wm iconname $w "entry1"
positionWindow $w
-label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries by dragging with mouse button2 pressed."
+label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries by dragging with mouse the middle mouse button pressed."
pack $w.msg -side top
## See Code / Dismiss buttons
diff --git a/library/demos/entry2.tcl b/library/demos/entry2.tcl
index 10e45df..1423e3f 100644
--- a/library/demos/entry2.tcl
+++ b/library/demos/entry2.tcl
@@ -16,7 +16,7 @@ wm title $w "Entry Demonstration (with scrollbars)"
wm iconname $w "entry2"
positionWindow $w
-label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below, with a scrollbar for each entry. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries with the scrollbars, or by dragging with mouse button2 pressed."
+label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below, with a scrollbar for each entry. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries with the scrollbars, or by dragging with the middle mouse button pressed."
pack $w.msg -side top
## See Code / Dismiss buttons
diff --git a/library/demos/floor.tcl b/library/demos/floor.tcl
index c36979b..b5d3c64 100644
--- a/library/demos/floor.tcl
+++ b/library/demos/floor.tcl
@@ -99,7 +99,7 @@ proc roomChanged {w args} {
}
set new [eval \
"$w create polygon [$w coords $item] -fill $colors(active) \
- -tags highlight"]
+ -outline {} -tags highlight"]
$w raise $new marker
}
@@ -114,7 +114,7 @@ proc roomChanged {w args} {
# outline - Color to use for the floor's outline.
proc bg1 {w fill outline} {
- $w create poly 347 80 349 82 351 84 353 85 363 92 375 99 386 104 \
+ $w create polygon 347 80 349 82 351 84 353 85 363 92 375 99 386 104 \
386 129 398 129 398 162 484 162 484 129 559 129 559 133 725 \
133 725 129 802 129 802 389 644 389 644 391 559 391 559 327 \
508 327 508 311 484 311 484 278 395 278 395 288 400 288 404 \
@@ -127,7 +127,7 @@ proc bg1 {w fill outline} {
22 223 17 227 13 231 8 236 4 242 2 246 0 260 0 283 1 300 5 \
321 14 335 22 348 25 365 29 363 39 358 48 352 56 337 70 \
344 76 347 80 \
- -tags {floor1 bg} -fill $fill
+ -tags {floor1 bg} -fill $fill -outline {}
$w create line 386 129 398 129 -fill $outline -tags {floor1 bg}
$w create line 258 355 258 387 -fill $outline -tags {floor1 bg}
$w create line 60 387 60 391 -fill $outline -tags {floor1 bg}
@@ -239,12 +239,12 @@ proc bg1 {w fill outline} {
# outline - Color to use for the floor's outline.
proc bg2 {w fill outline} {
- $w create poly 559 129 484 129 484 162 398 162 398 129 315 129 \
+ $w create polygon 559 129 484 129 484 162 398 162 398 129 315 129 \
315 133 176 133 176 129 96 129 96 133 3 133 3 339 0 339 0 391 \
60 391 60 387 258 387 258 329 350 329 350 311 395 311 395 280 \
484 280 484 311 508 311 508 327 558 327 558 391 644 391 644 \
367 802 367 802 129 725 129 725 133 559 133 559 129 \
- -tags {floor2 bg} -fill $fill
+ -tags {floor2 bg} -fill $fill -outline {}
$w create line 350 311 350 329 -fill $outline -tags {floor2 bg}
$w create line 398 129 398 162 -fill $outline -tags {floor2 bg}
$w create line 802 367 802 129 -fill $outline -tags {floor2 bg}
@@ -294,12 +294,12 @@ proc bg2 {w fill outline} {
# outline - Color to use for the floor's outline.
proc bg3 {w fill outline} {
- $w create poly 159 300 107 300 107 248 159 248 159 129 96 129 96 \
+ $w create polygon 159 300 107 300 107 248 159 248 159 129 96 129 96 \
133 21 133 21 331 0 331 0 391 60 391 60 370 159 370 159 300 \
- -tags {floor3 bg} -fill $fill
- $w create poly 258 370 258 329 350 329 350 311 399 311 399 129 \
+ -tags {floor3 bg} -fill $fill -outline {}
+ $w create polygon 258 370 258 329 350 329 350 311 399 311 399 129 \
315 129 315 133 176 133 176 129 159 129 159 370 258 370 \
- -tags {floor3 bg} -fill $fill
+ -tags {floor3 bg} -fill $fill -outline {}
$w create line 96 133 96 129 -fill $outline -tags {floor3 bg}
$w create line 176 129 96 129 -fill $outline -tags {floor3 bg}
$w create line 176 129 176 133 -fill $outline -tags {floor3 bg}
@@ -333,195 +333,195 @@ proc bg3 {w fill outline} {
proc fg1 {w color} {
global floorLabels floorItems
- set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 375 246 375 172 341 172 341 246 -outline {} -tags {floor1 room}]
set floorLabels($i) 101
set {floorItems(101)} $i
$w create text 358 209 -text 101 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 307 240 339 240 339 206 307 206 -outline {} -tags {floor1 room}]
set floorLabels($i) {Pub Lift1}
set {floorItems(Pub Lift1)} $i
$w create text 323 223 -text {Pub Lift1} -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 339 205 307 205 307 171 339 171 -outline {} -tags {floor1 room}]
set floorLabels($i) {Priv Lift1}
set {floorItems(Priv Lift1)} $i
$w create text 323 188 -text {Priv Lift1} -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 42 389 42 337 1 337 1 389 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 42 389 42 337 1 337 1 389 -outline {} -tags {floor1 room}]
set floorLabels($i) 110
set {floorItems(110)} $i
$w create text 21.5 363 -text 110 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 59 389 59 385 90 385 90 337 44 337 44 389 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 59 389 59 385 90 385 90 337 44 337 44 389 -outline {} -tags {floor1 room}]
set floorLabels($i) 109
set {floorItems(109)} $i
$w create text 67 363 -text 109 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 51 300 51 253 6 253 6 300 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 51 300 51 253 6 253 6 300 -outline {} -tags {floor1 room}]
set floorLabels($i) 111
set {floorItems(111)} $i
$w create text 28.5 276.5 -text 111 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 98 248 98 309 79 309 79 248 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 98 248 98 309 79 309 79 248 -outline {} -tags {floor1 room}]
set floorLabels($i) 117B
set {floorItems(117B)} $i
$w create text 88.5 278.5 -text 117B -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 51 251 51 204 6 204 6 251 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 51 251 51 204 6 204 6 251 -outline {} -tags {floor1 room}]
set floorLabels($i) 112
set {floorItems(112)} $i
$w create text 28.5 227.5 -text 112 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 6 156 51 156 51 203 6 203 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 6 156 51 156 51 203 6 203 -outline {} -tags {floor1 room}]
set floorLabels($i) 113
set {floorItems(113)} $i
$w create text 28.5 179.5 -text 113 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 85 169 79 169 79 192 85 192 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 85 169 79 169 79 192 85 192 -outline {} -tags {floor1 room}]
set floorLabels($i) 117A
set {floorItems(117A)} $i
$w create text 82 180.5 -text 117A -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 77 302 77 168 53 168 53 302 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 77 302 77 168 53 168 53 302 -outline {} -tags {floor1 room}]
set floorLabels($i) 117
set {floorItems(117)} $i
$w create text 65 235 -text 117 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 51 155 51 115 6 115 6 155 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 51 155 51 115 6 115 6 155 -outline {} -tags {floor1 room}]
set floorLabels($i) 114
set {floorItems(114)} $i
$w create text 28.5 135 -text 114 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 95 115 53 115 53 168 95 168 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 95 115 53 115 53 168 95 168 -outline {} -tags {floor1 room}]
set floorLabels($i) 115
set {floorItems(115)} $i
$w create text 74 141.5 -text 115 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 87 113 87 27 10 27 10 113 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 87 113 87 27 10 27 10 113 -outline {} -tags {floor1 room}]
set floorLabels($i) 116
set {floorItems(116)} $i
$w create text 48.5 70 -text 116 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 89 91 128 91 128 113 89 113 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 89 91 128 91 128 113 89 113 -outline {} -tags {floor1 room}]
set floorLabels($i) 118
set {floorItems(118)} $i
$w create text 108.5 102 -text 118 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 178 128 178 132 216 132 216 91 163 91 163 112 149 112 149 128 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 178 128 178 132 216 132 216 91 163 91 163 112 149 112 149 128 -outline {} -tags {floor1 room}]
set floorLabels($i) 120
set {floorItems(120)} $i
$w create text 189.5 111.5 -text 120 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 79 193 87 193 87 169 136 169 136 192 156 192 156 169 175 169 175 246 79 246 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 79 193 87 193 87 169 136 169 136 192 156 192 156 169 175 169 175 246 79 246 -outline {} -tags {floor1 room}]
set floorLabels($i) 122
set {floorItems(122)} $i
$w create text 131 207.5 -text 122 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 138 169 154 169 154 191 138 191 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 138 169 154 169 154 191 138 191 -outline {} -tags {floor1 room}]
set floorLabels($i) 121
set {floorItems(121)} $i
$w create text 146 180 -text 121 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 99 300 126 300 126 309 99 309 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 99 300 126 300 126 309 99 309 -outline {} -tags {floor1 room}]
set floorLabels($i) 106A
set {floorItems(106A)} $i
$w create text 112.5 304.5 -text 106A -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 128 299 128 309 150 309 150 248 99 248 99 299 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 128 299 128 309 150 309 150 248 99 248 99 299 -outline {} -tags {floor1 room}]
set floorLabels($i) 105
set {floorItems(105)} $i
$w create text 124.5 278.5 -text 105 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 174 309 174 300 152 300 152 309 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 174 309 174 300 152 300 152 309 -outline {} -tags {floor1 room}]
set floorLabels($i) 106B
set {floorItems(106B)} $i
$w create text 163 304.5 -text 106B -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 176 299 176 309 216 309 216 248 152 248 152 299 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 176 299 176 309 216 309 216 248 152 248 152 299 -outline {} -tags {floor1 room}]
set floorLabels($i) 104
set {floorItems(104)} $i
$w create text 184 278.5 -text 104 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 138 385 138 337 91 337 91 385 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 138 385 138 337 91 337 91 385 -outline {} -tags {floor1 room}]
set floorLabels($i) 108
set {floorItems(108)} $i
$w create text 114.5 361 -text 108 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 256 337 140 337 140 385 256 385 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 256 337 140 337 140 385 256 385 -outline {} -tags {floor1 room}]
set floorLabels($i) 107
set {floorItems(107)} $i
$w create text 198 361 -text 107 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 300 353 300 329 260 329 260 353 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 300 353 300 329 260 329 260 353 -outline {} -tags {floor1 room}]
set floorLabels($i) Smoking
set {floorItems(Smoking)} $i
$w create text 280 341 -text Smoking -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 314 135 314 170 306 170 306 246 177 246 177 135 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 314 135 314 170 306 170 306 246 177 246 177 135 -outline {} -tags {floor1 room}]
set floorLabels($i) 123
set {floorItems(123)} $i
$w create text 245.5 190.5 -text 123 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 217 248 301 248 301 326 257 326 257 310 217 310 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 217 248 301 248 301 326 257 326 257 310 217 310 -outline {} -tags {floor1 room}]
set floorLabels($i) 103
set {floorItems(103)} $i
$w create text 259 287 -text 103 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 396 188 377 188 377 169 316 169 316 131 396 131 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 396 188 377 188 377 169 316 169 316 131 396 131 -outline {} -tags {floor1 room}]
set floorLabels($i) 124
set {floorItems(124)} $i
$w create text 356 150 -text 124 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 397 226 407 226 407 189 377 189 377 246 397 246 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 397 226 407 226 407 189 377 189 377 246 397 246 -outline {} -tags {floor1 room}]
set floorLabels($i) 125
set {floorItems(125)} $i
$w create text 392 217.5 -text 125 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 399 187 409 187 409 207 474 207 474 164 399 164 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 399 187 409 187 409 207 474 207 474 164 399 164 -outline {} -tags {floor1 room}]
set floorLabels($i) 126
set {floorItems(126)} $i
$w create text 436.5 185.5 -text 126 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 409 209 409 229 399 229 399 253 486 253 486 239 474 239 474 209 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 409 209 409 229 399 229 399 253 486 253 486 239 474 239 474 209 -outline {} -tags {floor1 room}]
set floorLabels($i) 127
set {floorItems(127)} $i
$w create text 436.5 231 -text 127 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 501 164 501 174 495 174 495 188 490 188 490 204 476 204 476 164 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 501 164 501 174 495 174 495 188 490 188 490 204 476 204 476 164 -outline {} -tags {floor1 room}]
set floorLabels($i) MShower
set {floorItems(MShower)} $i
$w create text 488.5 184 -text MShower -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 497 176 513 176 513 204 492 204 492 190 497 190 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 497 176 513 176 513 204 492 204 492 190 497 190 -outline {} -tags {floor1 room}]
set floorLabels($i) Closet
set {floorItems(Closet)} $i
$w create text 502.5 190 -text Closet -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 476 237 476 206 513 206 513 254 488 254 488 237 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 476 237 476 206 513 206 513 254 488 254 488 237 -outline {} -tags {floor1 room}]
set floorLabels($i) WShower
set {floorItems(WShower)} $i
$w create text 494.5 230 -text WShower -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 486 131 558 131 558 135 724 135 724 166 697 166 697 275 553 275 531 254 515 254 515 174 503 174 503 161 486 161 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 486 131 558 131 558 135 724 135 724 166 697 166 697 275 553 275 531 254 515 254 515 174 503 174 503 161 486 161 -outline {} -tags {floor1 room}]
set floorLabels($i) 130
set {floorItems(130)} $i
$w create text 638.5 205 -text 130 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 308 242 339 242 339 248 342 248 342 246 397 246 397 276 393 276 393 309 300 309 300 248 308 248 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 308 242 339 242 339 248 342 248 342 246 397 246 397 276 393 276 393 309 300 309 300 248 308 248 -outline {} -tags {floor1 room}]
set floorLabels($i) 102
set {floorItems(102)} $i
$w create text 367.5 278.5 -text 102 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 397 255 486 255 486 276 397 276 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 397 255 486 255 486 276 397 276 -outline {} -tags {floor1 room}]
set floorLabels($i) 128
set {floorItems(128)} $i
$w create text 441.5 265.5 -text 128 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 510 309 486 309 486 255 530 255 552 277 561 277 561 325 510 325 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 510 309 486 309 486 255 530 255 552 277 561 277 561 325 510 325 -outline {} -tags {floor1 room}]
set floorLabels($i) 129
set {floorItems(129)} $i
$w create text 535.5 293 -text 129 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 696 281 740 281 740 387 642 387 642 389 561 389 561 277 696 277 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 696 281 740 281 740 387 642 387 642 389 561 389 561 277 696 277 -outline {} -tags {floor1 room}]
set floorLabels($i) 133
set {floorItems(133)} $i
$w create text 628.5 335 -text 133 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 742 387 742 281 800 281 800 387 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 742 387 742 281 800 281 800 387 -outline {} -tags {floor1 room}]
set floorLabels($i) 132
set {floorItems(132)} $i
$w create text 771 334 -text 132 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 800 168 800 280 699 280 699 168 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 800 168 800 280 699 280 699 168 -outline {} -tags {floor1 room}]
set floorLabels($i) 134
set {floorItems(134)} $i
$w create text 749.5 224 -text 134 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 726 131 726 166 800 166 800 131 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 726 131 726 166 800 166 800 131 -outline {} -tags {floor1 room}]
set floorLabels($i) 135
set {floorItems(135)} $i
$w create text 763 148.5 -text 135 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 340 360 335 363 331 365 326 366 304 366 304 312 396 312 396 288 400 288 404 288 409 290 413 292 418 297 421 302 422 309 421 318 417 325 411 330 405 332 397 333 344 333 340 334 336 336 335 338 332 342 331 347 332 351 334 354 336 357 341 359 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 340 360 335 363 331 365 326 366 304 366 304 312 396 312 396 288 400 288 404 288 409 290 413 292 418 297 421 302 422 309 421 318 417 325 411 330 405 332 397 333 344 333 340 334 336 336 335 338 332 342 331 347 332 351 334 354 336 357 341 359 -outline {} -tags {floor1 room}]
set floorLabels($i) {Ramona Stair}
set {floorItems(Ramona Stair)} $i
$w create text 368 323 -text {Ramona Stair} -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 30 23 30 5 93 5 98 5 104 7 110 10 116 16 119 20 122 28 123 32 123 68 220 68 220 87 90 87 90 23 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 30 23 30 5 93 5 98 5 104 7 110 10 116 16 119 20 122 28 123 32 123 68 220 68 220 87 90 87 90 23 -outline {} -tags {floor1 room}]
set floorLabels($i) {University Stair}
set {floorItems(University Stair)} $i
$w create text 155 77.5 -text {University Stair} -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 282 37 295 40 312 49 323 56 337 70 352 56 358 48 363 39 365 29 348 25 335 22 321 14 300 5 283 1 260 0 246 0 242 2 236 4 231 8 227 13 223 17 221 22 220 34 260 34 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 282 37 295 40 312 49 323 56 337 70 352 56 358 48 363 39 365 29 348 25 335 22 321 14 300 5 283 1 260 0 246 0 242 2 236 4 231 8 227 13 223 17 221 22 220 34 260 34 -outline {} -tags {floor1 room}]
set floorLabels($i) {Plaza Stair}
set {floorItems(Plaza Stair)} $i
$w create text 317.5 28.5 -text {Plaza Stair} -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 220 34 260 34 282 37 295 40 312 49 323 56 337 70 350 83 365 94 377 100 386 104 386 128 220 128 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 220 34 260 34 282 37 295 40 312 49 323 56 337 70 350 83 365 94 377 100 386 104 386 128 220 128 -outline {} -tags {floor1 room}]
set floorLabels($i) {Plaza Deck}
set {floorItems(Plaza Deck)} $i
$w create text 303 81 -text {Plaza Deck} -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 257 336 77 336 6 336 6 301 77 301 77 310 257 310 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 257 336 77 336 6 336 6 301 77 301 77 310 257 310 -outline {} -tags {floor1 room}]
set floorLabels($i) 106
set {floorItems(106)} $i
$w create text 131.5 318.5 -text 106 -fill $color -anchor c -tags {floor1 label}
- set i [$w create polygon 146 110 162 110 162 91 130 91 130 115 95 115 95 128 114 128 114 151 157 151 157 153 112 153 112 130 97 130 97 168 175 168 175 131 146 131 -fill {} -tags {floor1 room}]
+ set i [$w create polygon 146 110 162 110 162 91 130 91 130 115 95 115 95 128 114 128 114 151 157 151 157 153 112 153 112 130 97 130 97 168 175 168 175 131 146 131 -outline {} -tags {floor1 room}]
set floorLabels($i) 119
set {floorItems(119)} $i
$w create text 143.5 133 -text 119 -fill $color -anchor c -tags {floor1 label}
@@ -696,207 +696,207 @@ proc fg1 {w color} {
proc fg2 {w color} {
global floorLabels floorItems
- set i [$w create polygon 748 188 755 188 755 205 758 205 758 222 800 222 800 168 748 168 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 748 188 755 188 755 205 758 205 758 222 800 222 800 168 748 168 -outline {} -tags {floor2 room}]
set floorLabels($i) 238
set {floorItems(238)} $i
$w create text 774 195 -text 238 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 726 188 746 188 746 166 800 166 800 131 726 131 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 726 188 746 188 746 166 800 166 800 131 726 131 -outline {} -tags {floor2 room}]
set floorLabels($i) 237
set {floorItems(237)} $i
$w create text 763 148.5 -text 237 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 497 187 497 204 559 204 559 324 641 324 643 324 643 291 641 291 641 205 696 205 696 291 694 291 694 314 715 314 715 291 715 205 755 205 755 190 724 190 724 187 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 497 187 497 204 559 204 559 324 641 324 643 324 643 291 641 291 641 205 696 205 696 291 694 291 694 314 715 314 715 291 715 205 755 205 755 190 724 190 724 187 -outline {} -tags {floor2 room}]
set floorLabels($i) 246
set {floorItems(246)} $i
$w create text 600 264 -text 246 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 694 279 643 279 643 314 694 314 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 694 279 643 279 643 314 694 314 -outline {} -tags {floor2 room}]
set floorLabels($i) 247
set {floorItems(247)} $i
$w create text 668.5 296.5 -text 247 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 232 250 308 250 308 242 339 242 339 246 397 246 397 255 476 255 476 250 482 250 559 250 559 274 482 274 482 278 396 278 396 274 232 274 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 232 250 308 250 308 242 339 242 339 246 397 246 397 255 476 255 476 250 482 250 559 250 559 274 482 274 482 278 396 278 396 274 232 274 -outline {} -tags {floor2 room}]
set floorLabels($i) 202
set {floorItems(202)} $i
$w create text 285.5 260 -text 202 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 53 228 53 338 176 338 233 338 233 196 306 196 306 180 175 180 175 169 156 169 156 196 176 196 176 228 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 53 228 53 338 176 338 233 338 233 196 306 196 306 180 175 180 175 169 156 169 156 196 176 196 176 228 -outline {} -tags {floor2 room}]
set floorLabels($i) 206
set {floorItems(206)} $i
$w create text 143 267 -text 206 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 51 277 6 277 6 338 51 338 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 51 277 6 277 6 338 51 338 -outline {} -tags {floor2 room}]
set floorLabels($i) 212
set {floorItems(212)} $i
$w create text 28.5 307.5 -text 212 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 557 276 486 276 486 309 510 309 510 325 557 325 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 557 276 486 276 486 309 510 309 510 325 557 325 -outline {} -tags {floor2 room}]
set floorLabels($i) 245
set {floorItems(245)} $i
$w create text 521.5 300.5 -text 245 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 560 389 599 389 599 326 560 326 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 560 389 599 389 599 326 560 326 -outline {} -tags {floor2 room}]
set floorLabels($i) 244
set {floorItems(244)} $i
$w create text 579.5 357.5 -text 244 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 601 389 601 326 643 326 643 389 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 601 389 601 326 643 326 643 389 -outline {} -tags {floor2 room}]
set floorLabels($i) 243
set {floorItems(243)} $i
$w create text 622 357.5 -text 243 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 688 316 645 316 645 365 688 365 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 688 316 645 316 645 365 688 365 -outline {} -tags {floor2 room}]
set floorLabels($i) 242
set {floorItems(242)} $i
$w create text 666.5 340.5 -text 242 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 802 367 759 367 759 226 802 226 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 802 367 759 367 759 226 802 226 -outline {} -tags {floor2 room}]
set floorLabels($i) {Barbecue Deck}
set {floorItems(Barbecue Deck)} $i
$w create text 780.5 296.5 -text {Barbecue Deck} -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 755 262 755 314 717 314 717 262 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 755 262 755 314 717 314 717 262 -outline {} -tags {floor2 room}]
set floorLabels($i) 240
set {floorItems(240)} $i
$w create text 736 288 -text 240 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 755 316 689 316 689 365 755 365 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 755 316 689 316 689 365 755 365 -outline {} -tags {floor2 room}]
set floorLabels($i) 241
set {floorItems(241)} $i
$w create text 722 340.5 -text 241 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 755 206 717 206 717 261 755 261 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 755 206 717 206 717 261 755 261 -outline {} -tags {floor2 room}]
set floorLabels($i) 239
set {floorItems(239)} $i
$w create text 736 233.5 -text 239 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 695 277 643 277 643 206 695 206 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 695 277 643 277 643 206 695 206 -outline {} -tags {floor2 room}]
set floorLabels($i) 248
set {floorItems(248)} $i
$w create text 669 241.5 -text 248 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 676 135 676 185 724 185 724 135 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 676 135 676 185 724 185 724 135 -outline {} -tags {floor2 room}]
set floorLabels($i) 236
set {floorItems(236)} $i
$w create text 700 160 -text 236 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 675 135 635 135 635 145 628 145 628 185 675 185 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 675 135 635 135 635 145 628 145 628 185 675 185 -outline {} -tags {floor2 room}]
set floorLabels($i) 235
set {floorItems(235)} $i
$w create text 651.5 160 -text 235 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 626 143 633 143 633 135 572 135 572 143 579 143 579 185 626 185 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 626 143 633 143 633 135 572 135 572 143 579 143 579 185 626 185 -outline {} -tags {floor2 room}]
set floorLabels($i) 234
set {floorItems(234)} $i
$w create text 606 160 -text 234 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 557 135 571 135 571 145 578 145 578 185 527 185 527 131 557 131 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 557 135 571 135 571 145 578 145 578 185 527 185 527 131 557 131 -outline {} -tags {floor2 room}]
set floorLabels($i) 233
set {floorItems(233)} $i
$w create text 552.5 158 -text 233 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 476 249 557 249 557 205 476 205 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 476 249 557 249 557 205 476 205 -outline {} -tags {floor2 room}]
set floorLabels($i) 230
set {floorItems(230)} $i
$w create text 516.5 227 -text 230 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 476 164 486 164 486 131 525 131 525 185 476 185 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 476 164 486 164 486 131 525 131 525 185 476 185 -outline {} -tags {floor2 room}]
set floorLabels($i) 232
set {floorItems(232)} $i
$w create text 500.5 158 -text 232 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 476 186 495 186 495 204 476 204 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 476 186 495 186 495 204 476 204 -outline {} -tags {floor2 room}]
set floorLabels($i) 229
set {floorItems(229)} $i
$w create text 485.5 195 -text 229 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 474 207 409 207 409 187 399 187 399 164 474 164 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 474 207 409 207 409 187 399 187 399 164 474 164 -outline {} -tags {floor2 room}]
set floorLabels($i) 227
set {floorItems(227)} $i
$w create text 436.5 185.5 -text 227 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 399 228 399 253 474 253 474 209 409 209 409 228 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 399 228 399 253 474 253 474 209 409 209 409 228 -outline {} -tags {floor2 room}]
set floorLabels($i) 228
set {floorItems(228)} $i
$w create text 436.5 231 -text 228 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 397 246 397 226 407 226 407 189 377 189 377 246 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 397 246 397 226 407 226 407 189 377 189 377 246 -outline {} -tags {floor2 room}]
set floorLabels($i) 226
set {floorItems(226)} $i
$w create text 392 217.5 -text 226 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 377 169 316 169 316 131 397 131 397 188 377 188 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 377 169 316 169 316 131 397 131 397 188 377 188 -outline {} -tags {floor2 room}]
set floorLabels($i) 225
set {floorItems(225)} $i
$w create text 356.5 150 -text 225 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 234 198 306 198 306 249 234 249 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 234 198 306 198 306 249 234 249 -outline {} -tags {floor2 room}]
set floorLabels($i) 224
set {floorItems(224)} $i
$w create text 270 223.5 -text 224 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 270 179 306 179 306 170 314 170 314 135 270 135 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 270 179 306 179 306 170 314 170 314 135 270 135 -outline {} -tags {floor2 room}]
set floorLabels($i) 223
set {floorItems(223)} $i
$w create text 292 157 -text 223 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 268 179 221 179 221 135 268 135 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 268 179 221 179 221 135 268 135 -outline {} -tags {floor2 room}]
set floorLabels($i) 222
set {floorItems(222)} $i
$w create text 244.5 157 -text 222 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 177 179 219 179 219 135 177 135 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 177 179 219 179 219 135 177 135 -outline {} -tags {floor2 room}]
set floorLabels($i) 221
set {floorItems(221)} $i
$w create text 198 157 -text 221 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 299 327 349 327 349 284 341 284 341 276 299 276 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 299 327 349 327 349 284 341 284 341 276 299 276 -outline {} -tags {floor2 room}]
set floorLabels($i) 204
set {floorItems(204)} $i
$w create text 324 301.5 -text 204 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 234 276 297 276 297 327 257 327 257 338 234 338 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 234 276 297 276 297 327 257 327 257 338 234 338 -outline {} -tags {floor2 room}]
set floorLabels($i) 205
set {floorItems(205)} $i
$w create text 265.5 307 -text 205 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 256 385 256 340 212 340 212 385 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 256 385 256 340 212 340 212 385 -outline {} -tags {floor2 room}]
set floorLabels($i) 207
set {floorItems(207)} $i
$w create text 234 362.5 -text 207 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 210 340 164 340 164 385 210 385 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 210 340 164 340 164 385 210 385 -outline {} -tags {floor2 room}]
set floorLabels($i) 208
set {floorItems(208)} $i
$w create text 187 362.5 -text 208 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 115 340 162 340 162 385 115 385 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 115 340 162 340 162 385 115 385 -outline {} -tags {floor2 room}]
set floorLabels($i) 209
set {floorItems(209)} $i
$w create text 138.5 362.5 -text 209 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 89 228 89 156 53 156 53 228 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 89 228 89 156 53 156 53 228 -outline {} -tags {floor2 room}]
set floorLabels($i) 217
set {floorItems(217)} $i
$w create text 71 192 -text 217 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 89 169 97 169 97 190 89 190 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 89 169 97 169 97 190 89 190 -outline {} -tags {floor2 room}]
set floorLabels($i) 217A
set {floorItems(217A)} $i
$w create text 93 179.5 -text 217A -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 89 156 89 168 95 168 95 135 53 135 53 156 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 89 156 89 168 95 168 95 135 53 135 53 156 -outline {} -tags {floor2 room}]
set floorLabels($i) 216
set {floorItems(216)} $i
$w create text 71 145.5 -text 216 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 51 179 51 135 6 135 6 179 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 51 179 51 135 6 135 6 179 -outline {} -tags {floor2 room}]
set floorLabels($i) 215
set {floorItems(215)} $i
$w create text 28.5 157 -text 215 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 51 227 6 227 6 180 51 180 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 51 227 6 227 6 180 51 180 -outline {} -tags {floor2 room}]
set floorLabels($i) 214
set {floorItems(214)} $i
$w create text 28.5 203.5 -text 214 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 51 275 6 275 6 229 51 229 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 51 275 6 275 6 229 51 229 -outline {} -tags {floor2 room}]
set floorLabels($i) 213
set {floorItems(213)} $i
$w create text 28.5 252 -text 213 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 114 340 67 340 67 385 114 385 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 114 340 67 340 67 385 114 385 -outline {} -tags {floor2 room}]
set floorLabels($i) 210
set {floorItems(210)} $i
$w create text 90.5 362.5 -text 210 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 59 389 59 385 65 385 65 340 1 340 1 389 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 59 389 59 385 65 385 65 340 1 340 1 389 -outline {} -tags {floor2 room}]
set floorLabels($i) 211
set {floorItems(211)} $i
$w create text 33 364.5 -text 211 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 393 309 350 309 350 282 342 282 342 276 393 276 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 393 309 350 309 350 282 342 282 342 276 393 276 -outline {} -tags {floor2 room}]
set floorLabels($i) 203
set {floorItems(203)} $i
$w create text 367.5 292.5 -text 203 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 99 191 91 191 91 226 174 226 174 198 154 198 154 192 109 192 109 169 99 169 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 99 191 91 191 91 226 174 226 174 198 154 198 154 192 109 192 109 169 99 169 -outline {} -tags {floor2 room}]
set floorLabels($i) 220
set {floorItems(220)} $i
$w create text 132.5 208.5 -text 220 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 339 205 307 205 307 171 339 171 -outline {} -tags {floor2 room}]
set floorLabels($i) {Priv Lift2}
set {floorItems(Priv Lift2)} $i
$w create text 323 188 -text {Priv Lift2} -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 307 240 339 240 339 206 307 206 -outline {} -tags {floor2 room}]
set floorLabels($i) {Pub Lift 2}
set {floorItems(Pub Lift 2)} $i
$w create text 323 223 -text {Pub Lift 2} -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 175 168 97 168 97 131 175 131 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 175 168 97 168 97 131 175 131 -outline {} -tags {floor2 room}]
set floorLabels($i) 218
set {floorItems(218)} $i
$w create text 136 149.5 -text 218 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 154 191 111 191 111 169 154 169 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 154 191 111 191 111 169 154 169 -outline {} -tags {floor2 room}]
set floorLabels($i) 219
set {floorItems(219)} $i
$w create text 132.5 180 -text 219 -fill $color -anchor c -tags {floor2 label}
- set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -tags {floor2 room}]
+ set i [$w create polygon 375 246 375 172 341 172 341 246 -outline {} -tags {floor2 room}]
set floorLabels($i) 201
set {floorItems(201)} $i
$w create text 358 209 -text 201 -fill $color -anchor c -tags {floor2 label}
@@ -1066,135 +1066,135 @@ proc fg2 {w color} {
proc fg3 {w color} {
global floorLabels floorItems
- set i [$w create polygon 89 228 89 180 70 180 70 228 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 89 228 89 180 70 180 70 228 -outline {} -tags {floor3 room}]
set floorLabels($i) 316
set {floorItems(316)} $i
$w create text 79.5 204 -text 316 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 115 368 162 368 162 323 115 323 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 115 368 162 368 162 323 115 323 -outline {} -tags {floor3 room}]
set floorLabels($i) 309
set {floorItems(309)} $i
$w create text 138.5 345.5 -text 309 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 164 323 164 368 211 368 211 323 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 164 323 164 368 211 368 211 323 -outline {} -tags {floor3 room}]
set floorLabels($i) 308
set {floorItems(308)} $i
$w create text 187.5 345.5 -text 308 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 256 368 212 368 212 323 256 323 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 256 368 212 368 212 323 256 323 -outline {} -tags {floor3 room}]
set floorLabels($i) 307
set {floorItems(307)} $i
$w create text 234 345.5 -text 307 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 244 276 297 276 297 327 260 327 260 321 244 321 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 244 276 297 276 297 327 260 327 260 321 244 321 -outline {} -tags {floor3 room}]
set floorLabels($i) 305
set {floorItems(305)} $i
$w create text 270.5 301.5 -text 305 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 251 219 251 203 244 203 244 219 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 251 219 251 203 244 203 244 219 -outline {} -tags {floor3 room}]
set floorLabels($i) 324B
set {floorItems(324B)} $i
$w create text 247.5 211 -text 324B -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 251 249 244 249 244 232 251 232 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 251 249 244 249 244 232 251 232 -outline {} -tags {floor3 room}]
set floorLabels($i) 324A
set {floorItems(324A)} $i
$w create text 247.5 240.5 -text 324A -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 223 135 223 179 177 179 177 135 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 223 135 223 179 177 179 177 135 -outline {} -tags {floor3 room}]
set floorLabels($i) 320
set {floorItems(320)} $i
$w create text 200 157 -text 320 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 114 368 114 323 67 323 67 368 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 114 368 114 323 67 323 67 368 -outline {} -tags {floor3 room}]
set floorLabels($i) 310
set {floorItems(310)} $i
$w create text 90.5 345.5 -text 310 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 23 277 23 321 68 321 68 277 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 23 277 23 321 68 321 68 277 -outline {} -tags {floor3 room}]
set floorLabels($i) 312
set {floorItems(312)} $i
$w create text 45.5 299 -text 312 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 23 229 68 229 68 275 23 275 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 23 229 68 229 68 275 23 275 -outline {} -tags {floor3 room}]
set floorLabels($i) 313
set {floorItems(313)} $i
$w create text 45.5 252 -text 313 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 68 227 23 227 23 180 68 180 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 68 227 23 227 23 180 68 180 -outline {} -tags {floor3 room}]
set floorLabels($i) 314
set {floorItems(314)} $i
$w create text 45.5 203.5 -text 314 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 95 179 95 135 23 135 23 179 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 95 179 95 135 23 135 23 179 -outline {} -tags {floor3 room}]
set floorLabels($i) 315
set {floorItems(315)} $i
$w create text 59 157 -text 315 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 99 226 99 204 91 204 91 226 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 99 226 99 204 91 204 91 226 -outline {} -tags {floor3 room}]
set floorLabels($i) 316B
set {floorItems(316B)} $i
$w create text 95 215 -text 316B -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 91 202 99 202 99 180 91 180 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 91 202 99 202 99 180 91 180 -outline {} -tags {floor3 room}]
set floorLabels($i) 316A
set {floorItems(316A)} $i
$w create text 95 191 -text 316A -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 97 169 109 169 109 192 154 192 154 198 174 198 174 226 101 226 101 179 97 179 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 97 169 109 169 109 192 154 192 154 198 174 198 174 226 101 226 101 179 97 179 -outline {} -tags {floor3 room}]
set floorLabels($i) 319
set {floorItems(319)} $i
$w create text 141.5 209 -text 319 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 65 368 58 368 58 389 1 389 1 333 23 333 23 323 65 323 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 65 368 58 368 58 389 1 389 1 333 23 333 23 323 65 323 -outline {} -tags {floor3 room}]
set floorLabels($i) 311
set {floorItems(311)} $i
$w create text 29.5 361 -text 311 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 154 191 111 191 111 169 154 169 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 154 191 111 191 111 169 154 169 -outline {} -tags {floor3 room}]
set floorLabels($i) 318
set {floorItems(318)} $i
$w create text 132.5 180 -text 318 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 175 168 97 168 97 131 175 131 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 175 168 97 168 97 131 175 131 -outline {} -tags {floor3 room}]
set floorLabels($i) 317
set {floorItems(317)} $i
$w create text 136 149.5 -text 317 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 274 194 274 221 306 221 306 194 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 274 194 274 221 306 221 306 194 -outline {} -tags {floor3 room}]
set floorLabels($i) 323
set {floorItems(323)} $i
$w create text 290 207.5 -text 323 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 306 222 274 222 274 249 306 249 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 306 222 274 222 274 249 306 249 -outline {} -tags {floor3 room}]
set floorLabels($i) 325
set {floorItems(325)} $i
$w create text 290 235.5 -text 325 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 263 179 224 179 224 135 263 135 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 263 179 224 179 224 135 263 135 -outline {} -tags {floor3 room}]
set floorLabels($i) 321
set {floorItems(321)} $i
$w create text 243.5 157 -text 321 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 314 169 306 169 306 192 273 192 264 181 264 135 314 135 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 314 169 306 169 306 192 273 192 264 181 264 135 314 135 -outline {} -tags {floor3 room}]
set floorLabels($i) 322
set {floorItems(322)} $i
$w create text 293.5 163.5 -text 322 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 307 240 339 240 339 206 307 206 -outline {} -tags {floor3 room}]
set floorLabels($i) {Pub Lift3}
set {floorItems(Pub Lift3)} $i
$w create text 323 223 -text {Pub Lift3} -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 339 205 307 205 307 171 339 171 -outline {} -tags {floor3 room}]
set floorLabels($i) {Priv Lift3}
set {floorItems(Priv Lift3)} $i
$w create text 323 188 -text {Priv Lift3} -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 350 284 376 284 376 276 397 276 397 309 350 309 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 350 284 376 284 376 276 397 276 397 309 350 309 -outline {} -tags {floor3 room}]
set floorLabels($i) 303
set {floorItems(303)} $i
$w create text 373.5 292.5 -text 303 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 272 203 272 249 252 249 252 230 244 230 244 221 252 221 252 203 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 272 203 272 249 252 249 252 230 244 230 244 221 252 221 252 203 -outline {} -tags {floor3 room}]
set floorLabels($i) 324
set {floorItems(324)} $i
$w create text 262 226 -text 324 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 299 276 299 327 349 327 349 284 341 284 341 276 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 299 276 299 327 349 327 349 284 341 284 341 276 -outline {} -tags {floor3 room}]
set floorLabels($i) 304
set {floorItems(304)} $i
$w create text 324 301.5 -text 304 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 375 246 375 172 341 172 341 246 -outline {} -tags {floor3 room}]
set floorLabels($i) 301
set {floorItems(301)} $i
$w create text 358 209 -text 301 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 397 246 377 246 377 185 397 185 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 397 246 377 246 377 185 397 185 -outline {} -tags {floor3 room}]
set floorLabels($i) 327
set {floorItems(327)} $i
$w create text 387 215.5 -text 327 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 316 131 316 169 377 169 377 185 397 185 397 131 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 316 131 316 169 377 169 377 185 397 185 397 131 -outline {} -tags {floor3 room}]
set floorLabels($i) 326
set {floorItems(326)} $i
$w create text 356.5 150 -text 326 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 308 251 242 251 242 274 342 274 342 282 375 282 375 274 397 274 397 248 339 248 339 242 308 242 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 308 251 242 251 242 274 342 274 342 282 375 282 375 274 397 274 397 248 339 248 339 242 308 242 -outline {} -tags {floor3 room}]
set floorLabels($i) 302
set {floorItems(302)} $i
$w create text 319.5 261 -text 302 -fill $color -anchor c -tags {floor3 label}
- set i [$w create polygon 70 321 242 321 242 200 259 200 259 203 272 203 272 193 263 180 242 180 175 180 175 169 156 169 156 196 177 196 177 228 107 228 70 228 70 275 107 275 107 248 160 248 160 301 107 301 107 275 70 275 -fill {} -tags {floor3 room}]
+ set i [$w create polygon 70 321 242 321 242 200 259 200 259 203 272 203 272 193 263 180 242 180 175 180 175 169 156 169 156 196 177 196 177 228 107 228 70 228 70 275 107 275 107 248 160 248 160 301 107 301 107 275 70 275 -outline {} -tags {floor3 room}]
set floorLabels($i) 306
set {floorItems(306)} $i
$w create text 200.5 284.5 -text 306 -fill $color -anchor c -tags {floor3 label}
@@ -1354,12 +1354,12 @@ floorDisplay $c 3
# Set up event bindings for canvas:
-$c bind floor1 <1> "floorDisplay $c 1"
-$c bind floor2 <1> "floorDisplay $c 2"
-$c bind floor3 <1> "floorDisplay $c 3"
+$c bind floor1 <Button-1> "floorDisplay $c 1"
+$c bind floor2 <Button-1> "floorDisplay $c 2"
+$c bind floor3 <Button-1> "floorDisplay $c 3"
$c bind room <Enter> "newRoom $c"
$c bind room <Leave> {set currentRoom ""}
-bind $c <2> "$c scan mark %x %y"
+bind $c <Button-2> "$c scan mark %x %y"
bind $c <B2-Motion> "$c scan dragto %x %y"
bind $c <Destroy> "unset currentRoom"
set currentRoom ""
diff --git a/library/demos/goldberg.tcl b/library/demos/goldberg.tcl
index 284b5c2..1cc52c6 100644
--- a/library/demos/goldberg.tcl
+++ b/library/demos/goldberg.tcl
@@ -105,7 +105,7 @@ proc DoDisplay {w} {
$w.c yview moveto .05
pack $w.c -in $w.screen -side top -fill both -expand 1
- bind $w.c <3> [list $w.pause invoke]
+ bind $w.c <Button-3> [list $w.pause invoke]
bind $w.c <Destroy> {
after cancel $animationCallbacks(goldberg)
unset animationCallbacks(goldberg)
@@ -162,7 +162,7 @@ proc DoCtrlFrame {w} {
grid $w.speed -in $w.ctrl -row 99 -sticky ew -pady {0 5}
pack $w.speed.scale -fill both -expand 1
grid $w.about -in $w.ctrl -row 100 -sticky ew
- bind $w.reset <3> {set S(mode) -1} ;# Debugging
+ bind $w.reset <Button-3> {set S(mode) -1} ;# Debugging
## See Code / Dismiss buttons hack!
set btns [addSeeDismiss $w.ctrl.buttons $w]
@@ -342,7 +342,7 @@ proc Draw0 {w} {
set xy {719 119 763 119}
$w.c create line $xy -tag I0 -fill $color -width 5 -arrow last \
-arrowshape {18 18 5}
- $w.c bind I0 <1> Start
+ $w.c bind I0 <Button-1> Start
}
proc Move0 {w {step {}}} {
set step [GetStep 0 $step]
@@ -372,7 +372,7 @@ proc Draw1 {w} {
set xy [box 812 122 9]
$w.c create oval $xy -tag I1 -fill $color2 -outline {}
- $w.c bind I1 <1> Start
+ $w.c bind I1 <Button-1> Start
}
proc Move1 {w {step {}}} {
set step [GetStep 1 $step]
@@ -1620,7 +1620,7 @@ proc Move26 {w {step {}}} {
$w.c delete I24 I26
$w.c create text 430 755 -anchor s -tag I26 \
-text "click to continue" -font {{Times Roman} 24 bold}
- bind $w.c <1> [list Reset $w]
+ bind $w.c <Button-1> [list Reset $w]
return 4
}
@@ -1675,7 +1675,7 @@ proc RotateC {x y Ox Oy beta} {
proc Reset {w} {
global S
DrawAll $w
- bind $w.c <1> {}
+ bind $w.c <Button-1> {}
set S(mode) $::MSTART
set S(active) 0
}
diff --git a/library/demos/image2.tcl b/library/demos/image2.tcl
index 2d7ba03..7af52be 100644
--- a/library/demos/image2.tcl
+++ b/library/demos/image2.tcl
@@ -95,7 +95,7 @@ listbox $w.f.list -width 20 -height 10 -yscrollcommand "$w.f.scroll set"
ttk::scrollbar $w.f.scroll -command "$w.f.list yview"
pack $w.f.list $w.f.scroll -side left -fill y -expand 1
$w.f.list insert 0 earth.gif earthris.gif teapot.ppm
-bind $w.f.list <Double-1> "loadImage $w %x %y"
+bind $w.f.list <Double-Button-1> "loadImage $w %x %y"
catch {image delete image2a}
image create photo image2a
diff --git a/library/demos/items.tcl b/library/demos/items.tcl
index 000e4cb..1370560 100644
--- a/library/demos/items.tcl
+++ b/library/demos/items.tcl
@@ -95,13 +95,13 @@ $c create line 12c 6c 13.5c 4.5c 16.5c 7.5c 18c 6c \
$c create text 25c .2c -text Polygons -anchor n
$c create polygon 21c 1.0c 22.5c 1.75c 24c 1.0c 23.25c 2.5c \
24c 4.0c 22.5c 3.25c 21c 4.0c 21.75c 2.5c -fill $green \
- -outline black -width 4 -tags item
+ -outline {} -width 4 -tags item
$c create polygon 25c 4c 25c 4c 25c 1c 26c 1c 27c 4c 28c 1c \
- 29c 1c 29c 4c 29c 4c -fill $red -smooth on -tags item
+ 29c 1c 29c 4c 29c 4c -fill $red -outline {} -smooth on -tags item
$c create polygon 22c 4.5c 25c 4.5c 25c 6.75c 28c 6.75c \
28c 5.25c 24c 5.25c 24c 6.0c 26c 6c 26c 7.5c 22c 7.5c \
-stipple @[file join $tk_demoDirectory images gray25.xbm] \
- -outline black -tags item
+ -fill $blue -outline {} -tags item
$c create text 5c 8.2c -text Rectangles -anchor n
$c create rectangle 1c 9.5c 4c 12.5c -outline $red -width 3m -tags item
@@ -126,8 +126,10 @@ $c create text 25.5c 11c -anchor w -font $font1 -fill $blue \
-text "Several lines,\n each centered\nindividually,\nand all anchored\nat the left edge." \
-justify center -tags item
$c create rectangle 24.9c 13.9c 25.1c 14.1c
+catch {
$c create text 25c 14c -font $font2 -anchor c -fill $red -angle 15 \
-text "Angled characters" -tags item
+}
$c create text 5c 16.2c -text Arcs -anchor n
$c create arc 0.5c 17c 7c 20c -fill $green -outline black \
@@ -140,13 +142,15 @@ $c create arc 0.5c 20c 9.5c 24c -width 4m -style pieslice \
$c create arc 5.5c 20.5c 9.5c 23.5c -width 4m -style chord \
-fill $blue -outline {} -start 45 -extent 270 -tags item
+$c create text 15c 16.2c -text "Bitmaps and Images" -anchor n
+catch {
image create photo items.ousterhout \
-file [file join $tk_demoDirectory images ouster.png]
image create photo items.ousterhout.active -format "png -alpha 0.5" \
-file [file join $tk_demoDirectory images ouster.png]
-$c create text 15c 16.2c -text "Bitmaps and Images" -anchor n
$c create image 13c 20c -tags item -image items.ousterhout \
-activeimage items.ousterhout.active
+}
$c create bitmap 17c 18.5c -tags item \
-bitmap @[file join $tk_demoDirectory images noletter.xbm]
$c create bitmap 17c 21.5c -tags item \
@@ -167,14 +171,14 @@ $c create text 28.5c 17.4c -text Scale: -anchor s
# Set up event bindings for canvas:
-$c bind item <Any-Enter> "itemEnter $c"
-$c bind item <Any-Leave> "itemLeave $c"
-bind $c <2> "$c scan mark %x %y"
+$c bind item <Enter> "itemEnter $c"
+$c bind item <Leave> "itemLeave $c"
+bind $c <Button-2> "$c scan mark %x %y"
bind $c <B2-Motion> "$c scan dragto %x %y"
-bind $c <3> "itemMark $c %x %y"
+bind $c <Button-3> "itemMark $c %x %y"
bind $c <B3-Motion> "itemStroke $c %x %y"
bind $c <<NextChar>> "itemsUnderArea $c"
-bind $c <1> "itemStartDrag $c %x %y"
+bind $c <Button-1> "itemStartDrag $c %x %y"
bind $c <B1-Motion> "itemDrag $c %x %y"
# Utility procedures for highlighting the item under the pointer:
diff --git a/library/demos/ixset b/library/demos/ixset
index 13235de..b2b3252 100644
--- a/library/demos/ixset
+++ b/library/demos/ixset
@@ -197,7 +197,7 @@ proc createwindows {} {
bind . <Return> {.buttons.ok flash; .buttons.ok invoke}
bind . <Escape> {.buttons.quit flash; .buttons.quit invoke}
- bind . <1> {
+ bind . <Button-1> {
if {![string match .buttons* %W]} {
.buttons.apply configure -state normal
.buttons.cancel configure -state normal
diff --git a/library/demos/knightstour.tcl b/library/demos/knightstour.tcl
index 6113db2..b5cffa8 100644
--- a/library/demos/knightstour.tcl
+++ b/library/demos/knightstour.tcl
@@ -175,7 +175,7 @@ proc CreateGUI {} {
wm withdraw $dlg
set f [ttk::frame $dlg.f]
set c [canvas $f.c -width 240 -height 240]
- text $f.txt -width 10 -height 1 -background white \
+ text $f.txt -width 10 -height 1 \
-yscrollcommand [list $f.vs set] -font {Arial 8}
ttk::scrollbar $f.vs -command [list $f.txt yview]
@@ -200,7 +200,7 @@ proc CreateGUI {} {
set coords [list [expr {$col * 30 + 4}] [expr {$row * 30 + 4}] \
[expr {$col * 30 + 30}] [expr {$row * 30 + 30}]]
$c create rectangle $coords -fill $fill -disabledfill $dfill \
- -width 2 -state disabled
+ -width 2 -state disabled -outline black
}
}
if {[tk windowingsystem] ne "x11"} {
@@ -218,7 +218,7 @@ proc CreateGUI {} {
-fill black -activefill "#600000"
}
$c moveto knight {*}[lrange [$c coords [expr {1 + int(rand() * 64)}]] 0 1]
- $c bind knight <ButtonPress-1> [namespace code [list DragStart %W %x %y]]
+ $c bind knight <Button-1> [namespace code [list DragStart %W %x %y]]
$c bind knight <Motion> [namespace code [list DragMotion %W %x %y]]
$c bind knight <ButtonRelease-1> [namespace code [list DragEnd %W %x %y]]
diff --git a/library/demos/paned1.tcl b/library/demos/paned1.tcl
index 783b7f3..6b21d35 100644
--- a/library/demos/paned1.tcl
+++ b/library/demos/paned1.tcl
@@ -26,7 +26,7 @@ pack $btns -side bottom -fill x
panedwindow $w.pane
pack $w.pane -side top -expand yes -fill both -pady 2 -padx 2m
-label $w.pane.left -text "This is the\nleft side" -bg yellow
-label $w.pane.right -text "This is the\nright side" -bg cyan
+label $w.pane.left -text "This is the\nleft side" -fg black -bg yellow
+label $w.pane.right -text "This is the\nright side" -fg black -bg cyan
$w.pane add $w.pane.left $w.pane.right
diff --git a/library/demos/pendulum.tcl b/library/demos/pendulum.tcl
index d344d8d..9833e8f 100644
--- a/library/demos/pendulum.tcl
+++ b/library/demos/pendulum.tcl
@@ -113,7 +113,7 @@ bind $w.c <Destroy> {
after cancel $animationCallbacks(pendulum)
unset animationCallbacks(pendulum)
}
-bind $w.c <1> {
+bind $w.c <Button-1> {
after cancel $animationCallbacks(pendulum)
showPendulum %W at %x %y
}
@@ -126,16 +126,16 @@ bind $w.c <ButtonRelease-1> {
}
bind $w.c <Configure> {
%W coords plate 0 25 %w 25
- set home [expr %w/2]
- %W coords pivot [expr $home-5] 20 [expr $home+5] 30
+ set home [expr {%w/2}]
+ %W coords pivot [expr {$home-5}] 20 [expr {$home+5}] 30
}
bind $w.k <Configure> {
- set psh [expr %h/2]
- set psw [expr %w/2]
- %W coords x_axis 2 $psh [expr %w-2] $psh
- %W coords y_axis $psw [expr %h-2] $psw 2
- %W coords label_dtheta [expr $psw-4] 6
- %W coords label_theta [expr %w-6] [expr $psh+4]
+ set psh [expr {%h/2}]
+ set psw [expr {%w/2}]
+ %W coords x_axis 2 $psh [expr {%w-2}] $psh
+ %W coords y_axis $psw [expr {%h-2}] $psw 2
+ %W coords label_dtheta [expr {$psw-4}] 6
+ %W coords label_theta [expr {%w-6}] [expr {$psh+4}]
}
# This procedure is the "business" part of the simulation that does
diff --git a/library/demos/plot.tcl b/library/demos/plot.tcl
index e7f0361..453b7a6 100644
--- a/library/demos/plot.tcl
+++ b/library/demos/plot.tcl
@@ -55,9 +55,9 @@ foreach point {
$c addtag point withtag $item
}
-$c bind point <Any-Enter> "$c itemconfig current -fill red"
-$c bind point <Any-Leave> "$c itemconfig current -fill SkyBlue2"
-$c bind point <1> "plotDown $c %x %y"
+$c bind point <Enter> "$c itemconfig current -fill red"
+$c bind point <Leave> "$c itemconfig current -fill SkyBlue2"
+$c bind point <Button-1> "plotDown $c %x %y"
$c bind point <ButtonRelease-1> "$c dtag selected"
bind $c <B1-Motion> "plotMove $c %x %y"
diff --git a/library/demos/ruler.tcl b/library/demos/ruler.tcl
index 557b680..0b78370 100644
--- a/library/demos/ruler.tcl
+++ b/library/demos/ruler.tcl
@@ -19,8 +19,13 @@ package require Tk
proc rulerMkTab {c x y} {
upvar #0 demo_rulerInfo v
- $c create polygon $x $y [expr {$x+$v(size)}] [expr {$y+$v(size)}] \
- [expr {$x-$v(size)}] [expr {$y+$v(size)}]
+ set newTab [$c create polygon $x $y \
+ [expr {$x+$v(size)}] [expr {$y+$v(size)}] \
+ [expr {$x-$v(size)}] [expr {$y+$v(size)}]]
+ set fill [$c itemcget $newTab -outline]
+ $c itemconfigure $newTab -fill $fill -outline {}
+ set v(normalStyle) "-fill $fill"
+ return $newTab
}
set w .ruler
@@ -47,7 +52,6 @@ set demo_rulerInfo(right) [winfo fpixels $c 13c]
set demo_rulerInfo(top) [winfo fpixels $c 1c]
set demo_rulerInfo(bottom) [winfo fpixels $c 1.5c]
set demo_rulerInfo(size) [winfo fpixels $c .2c]
-set demo_rulerInfo(normalStyle) "-fill black"
# Main widget program sets variable tk_demoDirectory
if {[winfo depth $c] > 1} {
set demo_rulerInfo(activeStyle) "-fill red -stipple {}"
@@ -69,14 +73,14 @@ for {set i 0} {$i < 12} {incr i} {
$c create text $x.15c .75c -text $i -anchor sw
}
$c addtag well withtag [$c create rect 13.2c 1c 13.8c 0.5c \
- -outline black -fill [lindex [$c config -bg] 4]]
+ -fill [lindex [$c config -bg] 4]]
$c addtag well withtag [rulerMkTab $c [winfo pixels $c 13.5c] \
[winfo pixels $c .65c]]
-$c bind well <1> "rulerNewTab $c %x %y"
-$c bind tab <1> "rulerSelectTab $c %x %y"
+$c bind well <Button-1> "rulerNewTab $c %x %y"
+$c bind tab <Button-1> "rulerSelectTab $c %x %y"
bind $c <B1-Motion> "rulerMoveTab $c %x %y"
-bind $c <Any-ButtonRelease-1> "rulerReleaseTab $c"
+bind $c <ButtonRelease-1> "rulerReleaseTab $c"
# rulerNewTab --
# Does all the work of creating a tab stop, including creating the
diff --git a/library/demos/square b/library/demos/square
index 1d7eb20..9f200ba 100644
--- a/library/demos/square
+++ b/library/demos/square
@@ -18,7 +18,7 @@ square .s
pack .s -expand yes -fill both
wm minsize . 1 1
-bind .s <1> {center %x %y}
+bind .s <Button-1> {center %x %y}
bind .s <B1-Motion> {center %x %y}
bind .s a animate
focus .s
@@ -27,7 +27,7 @@ focus .s
proc center {x y} {
set a [.s size]
- .s position [expr $x-($a/2)] [expr $y-($a/2)]
+ .s position [expr {$x-($a/2)}] [expr {$y-($a/2)}]
}
# The procedures below provide a simple form of animation where
diff --git a/library/demos/tcolor b/library/demos/tcolor
index 6e50c61..64e1a53 100644
--- a/library/demos/tcolor
+++ b/library/demos/tcolor
@@ -90,7 +90,7 @@ foreach i {
grid columnconfigure . 0 -weight 1
listbox .names.lb -width 20 -height 12 -yscrollcommand ".names.s set" \
-exportselection false
- bind .names.lb <Double-1> {
+ bind .names.lb <Double-Button-1> {
tc_loadNamedColor [.names.lb get [.names.lb curselection]]
}
scrollbar .names.s -orient vertical -command ".names.lb yview"
diff --git a/library/demos/text.tcl b/library/demos/text.tcl
index d1801d1..2736b88 100644
--- a/library/demos/text.tcl
+++ b/library/demos/text.tcl
@@ -57,8 +57,9 @@ can do to a text widget:
1. Scrolling. Use the scrollbar to adjust the view in the text window.
-2. Scanning. Press mouse button 2 in the text window and drag up or down.
-This will drag the text at high speed to allow you to scan its contents.
+2. Scanning. Press the middle mouse button in the text window and drag up
+or down. This will drag the text at high speed to allow you to scan its
+contents.
3. Insert text. Press mouse button 1 to set the insertion cursor, then
type text. What you type will be added to the widget.
@@ -77,7 +78,8 @@ text, in which case it will replace the selected text.
6. Copy the selection. To copy the selection into this window, select
what you want to copy (either here or in another application), then
-click button 2 to copy the selection to the point of the mouse cursor.
+click the middle mouse button to copy the selection to the point of the
+mouse cursor.
7. Edit. Text widgets support the standard Motif editing characters
plus many Emacs editing characters. Backspace and Control-h erase the
diff --git a/library/demos/toolbar.tcl b/library/demos/toolbar.tcl
index 0ae4669..cb2a495 100644
--- a/library/demos/toolbar.tcl
+++ b/library/demos/toolbar.tcl
@@ -31,7 +31,7 @@ ttk::separator $w.sep
ttk::frame $t.tearoff -cursor fleur
ttk::separator $t.tearoff.to -orient vertical
ttk::separator $t.tearoff.to2 -orient vertical
-pack $t.tearoff.to -fill y -expand 1 -padx 2 -side left
+pack $t.tearoff.to -fill y -expand 1 -padx 4 -side left
pack $t.tearoff.to2 -fill y -expand 1 -side left
ttk::frame $t.contents
grid $t.tearoff $t.contents -sticky nsew
@@ -79,7 +79,7 @@ text $w.txt -width 40 -height 10
interp alias {} doInsert {} $w.txt insert end ;# Make bindings easy to write
## Arrange contents
-grid $t.button $t.check $t.menu $t.combo -in $t.contents -padx 2 -sticky ns
+grid $t.button $t.check $t.menu $t.combo -in $t.contents -padx 2 -pady 4 -sticky ns
grid $t -sticky ew
grid $w.sep -sticky ew
grid $w.msg -sticky ew
diff --git a/library/demos/tree.tcl b/library/demos/tree.tcl
index 50dba9b..1cc70f8 100644
--- a/library/demos/tree.tcl
+++ b/library/demos/tree.tcl
@@ -76,7 +76,7 @@ ttk::scrollbar $w.vsb -orient vertical -command "$w.tree yview"
ttk::scrollbar $w.hsb -orient horizontal -command "$w.tree xview"
$w.tree heading \#0 -text "Directory Structure"
$w.tree heading size -text "File Size"
-$w.tree column size -stretch 0 -width 70
+$w.tree column size -width 70
populateRoots $w.tree
bind $w.tree <<TreeviewOpen>> {populateTree %W [%W focus]}
diff --git a/library/demos/ttkpane.tcl b/library/demos/ttkpane.tcl
index 7575d76..3f88987 100644
--- a/library/demos/ttkpane.tcl
+++ b/library/demos/ttkpane.tcl
@@ -104,7 +104,7 @@ if {[tk windowingsystem] ne "aqua"} {
pack $w.outer -fill both -expand 1
} else {
text $w.txt -wrap word -yscroll "$w.sb set" -width 30 -borderwidth 0
- scrollbar $w.sb -orient vertical -command "$w.txt yview"
+ ttk::scrollbar $w.sb -orient vertical -command "$w.txt yview"
pack $w.sb -side right -fill y -in $w.outer.inRight.bot
pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot
pack $w.outer -fill both -expand 1 -padx 10 -pady {6 10}
diff --git a/library/demos/twind.tcl b/library/demos/twind.tcl
index 39e5110..74f11eb 100644
--- a/library/demos/twind.tcl
+++ b/library/demos/twind.tcl
@@ -9,6 +9,14 @@ if {![info exists widgetDemo]} {
package require Tk
+# Make an Aqua button's fill color match its parent's background
+proc blend {bt} {
+ if {[tk windowingsystem] eq "aqua"} {
+ $bt configure -highlightbackground [[winfo parent $bt] cget -background]
+ }
+ return $bt
+}
+
set w .twind
catch {destroy $w}
toplevel $w
@@ -53,17 +61,19 @@ $t insert end "it. These are called \"embedded windows\", "
$t insert end "and they can consist of arbitrary widgets. "
$t insert end "For example, here are two embedded button "
$t insert end "widgets. You can click on the first button to "
-$t window create end -window $t.on
+$t window create end -window [blend $t.on]
$t insert end " horizontal scrolling, which also turns off "
$t insert end "word wrapping. Or, you can click on the second "
$t insert end "button to\n"
-$t window create end -window $t.off
+$t window create end -window [blend $t.off]
$t insert end " horizontal scrolling and turn back on word wrapping.\n\n"
$t insert end "Or, here is another example. If you "
$t window create end -create {
button %W.click -text "Click Here" -command "textWindPlot %W" \
- -cursor top_left_arrow}
+ -cursor top_left_arrow
+ blend %W.click
+}
$t insert end " a canvas displaying an x-y plot will appear right here."
$t mark set plot insert
@@ -72,7 +82,8 @@ $t insert end " You can drag the data points around with the mouse, "
$t insert end "or you can click here to "
$t window create end -create {
button %W.delete -text "Delete" -command "textWindDel %W" \
- -cursor top_left_arrow
+ -cursor top_left_arrow
+ blend %W.delete
}
$t insert end " the plot again.\n\n"
@@ -80,7 +91,8 @@ $t insert end "You can also create multiple text widgets each of which "
$t insert end "display the same underlying text. Click this button to "
$t window create end \
-create {button %W.peer -text "Make A Peer" -command "textMakePeer %W" \
- -cursor top_left_arrow} -padx 3
+ -cursor top_left_arrow
+ blend %W.peer} -padx 3
$t insert end " widget. Notice how peer widgets can have different "
$t insert end "font settings, and by default contain all the images "
$t insert end "of the 'parent', but that the embedded windows, "
@@ -92,7 +104,8 @@ $t insert end "designed to show up in all peers.) A good use of "
$t insert end "peers is for "
$t window create end \
-create {button %W.split -text "Split Windows" -command "textSplitWindow %W" \
- -cursor top_left_arrow} -padx 3
+ -cursor top_left_arrow
+ blend %W.split} -padx 3
$t insert end " \n\n"
$t insert end "Users of previous versions of Tk will also be interested "
@@ -128,11 +141,11 @@ foreach color {AntiqueWhite3 Bisque1 Bisque2 Bisque3 Bisque4
DarkSlateGray1 Aquamarine2 DarkSeaGreen2 SeaGreen1
Yellow1 IndianRed1 IndianRed2 Tan1 Tan4} {
button $t.color$i -text $color -cursor top_left_arrow -command \
- "$t configure -bg $color"
- $t window create end -window $t.color$i -padx 3 -pady 2
+ "changeBg $t $color"
+ $t window create end -window [blend $t.color$i] -padx 3 -pady 2
incr i
}
-$t tag add buttons $t.default end
+$t tag add buttons [blend $t.default] end
button $t.bigB -text "Big borders" -command "textWindBigB $t" \
-cursor top_left_arrow
@@ -153,12 +166,12 @@ set text_normal(pad) [$t cget -padx]
$t insert end "\nYou can also change the usual border width and "
$t insert end "highlightthickness and padding.\n"
-$t window create end -window $t.bigB
-$t window create end -window $t.smallB
-$t window create end -window $t.bigH
-$t window create end -window $t.smallH
-$t window create end -window $t.bigP
-$t window create end -window $t.smallP
+$t window create end -window [blend $t.bigB]
+$t window create end -window [blend $t.smallB]
+$t window create end -window [blend $t.bigH]
+$t window create end -window [blend $t.smallH]
+$t window create end -window [blend $t.bigP]
+$t window create end -window [blend $t.smallP]
$t insert end "\n\nFinally, images fit comfortably in text widgets too:"
@@ -189,7 +202,6 @@ proc textWindSmallP w {
$w configure -padx $::text_normal(pad) -pady $::text_normal(pad)
}
-
proc textWindOn w {
catch {destroy $w.scroll2}
set t $w.f.text
@@ -253,9 +265,9 @@ proc createPlot {t} {
$c addtag point withtag $item
}
- $c bind point <Any-Enter> "$c itemconfig current -fill red"
- $c bind point <Any-Leave> "$c itemconfig current -fill SkyBlue2"
- $c bind point <1> "embPlotDown $c %x %y"
+ $c bind point <Enter> "$c itemconfig current -fill red"
+ $c bind point <Leave> "$c itemconfig current -fill SkyBlue2"
+ $c bind point <Button-1> "embPlotDown $c %x %y"
$c bind point <ButtonRelease-1> "$c dtag selected"
bind $c <B1-Motion> "embPlotMove $c %x %y"
return $c
@@ -290,8 +302,20 @@ proc textWindDel t {
}
}
+proc changeBg {t c} {
+ $t configure -background $c
+ if {[tk windowingsystem] eq "aqua"} {
+ foreach b [$t window names] {
+ if {[winfo class $b] eq "Button"} {
+ $b configure -highlightbackground $c
+ }
+ }
+ }
+}
+
proc embDefBg t {
- $t configure -background [lindex [$t configure -background] 3]
+ set bg [lindex [$t configure -background] 3]
+ changeBg $t $bg
}
proc textMakePeer {parent} {
diff --git a/library/demos/unicodeout.tcl b/library/demos/unicodeout.tcl
index faa9f90..ca325a4 100644
--- a/library/demos/unicodeout.tcl
+++ b/library/demos/unicodeout.tcl
@@ -22,8 +22,8 @@ label $w.msg -font $font -wraplength 4i -anchor w -justify left \
below depends largely on what character sets you have installed,\
and what you see for characters that are not present varies greatly\
between platforms as well. The strings are written in Tcl using\
- UNICODE characters using the \\uXXXX escape so as to do so in a\
- portable fashion."
+ UNICODE characters using the \\uXXXX (or \\UXXXXXX) escape so as to\
+ do so in a portable fashion."
pack $w.msg -side top
## See Code / Dismiss buttons
@@ -109,10 +109,10 @@ if {[usePresentationFormsFor Arabic]} {
}
addSample $w "Trad. Chinese" "\u4E2D\u570B\u7684\u6F22\u5B57"
addSample $w "Simpl. Chinese" "\u6C49\u8BED"
-addSample $w French "Langue fran\u00E7aise"
+addSample $w French "Langue fran\xE7aise"
addSample $w Greek \
- "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE " \
- "\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1"
+ "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE " \
+ "\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1"
if {[usePresentationFormsFor Hebrew]} {
# Visual order (pre-layouted)
addSample $w Hebrew \
@@ -123,14 +123,23 @@ if {[usePresentationFormsFor Hebrew]} {
"\u05DB\u05EA\u05D1 \u05E2\u05D1\u05E8\u05D9\u05EA"
}
addSample $w Hindi \
- "\u0939\u093f\u0928\u094d\u0926\u0940 \u092d\u093e\u0937\u093e"
-addSample $w Icelandic "\u00CDslenska"
+ "\u0939\u093F\u0928\u094D\u0926\u0940 \u092D\u093E\u0937\u093E"
+addSample $w Icelandic "\xCDslenska"
addSample $w Japanese \
- "\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, " \
- "\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA"
+ "\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, " \
+ "\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA"
addSample $w Korean "\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00"
addSample $w Russian \
"\u0420\u0443\u0441\u0441\u043A\u0438\u0439 \u044F\u0437\u044B\u043A"
+if {([tk windowingsystem] ne "x11") || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))} {
+ if {[package vsatisfies [package provide Tcl] 8.7-]} {
+ addSample $w Emoji \
+ "\U1F600\U1F4A9\U1F44D\U1F1F3\U1F1F1"
+ } else {
+ addSample $w Emoji \
+ "\uD83D\uDE00\uD83D\uDCA9\uD83D\uDC4D\uD83C\uDDF3\uD83C\uDDF1"
+ }
+}
## We're done processing, so change things back to normal running...
destroy $w.wait
diff --git a/library/demos/widget b/library/demos/widget
index 6d0b045..e543846 100644
--- a/library/demos/widget
+++ b/library/demos/widget
@@ -83,12 +83,20 @@ image create photo ::img::print -format GIF -data {
# Note that this is run through the message catalog! This is because this is
# actually an image of a word.
-image create photo ::img::new -format GIF -data [mc {
- R0lGODlhHgAOALMPALMAANyIiOu7u8dEROaqqvru7sxVVeGZmbgREfXd3b0iItZ3
- d8IzM9FmZvDMzP///yH5BAEAAA8ALAAAAAAeAA4AAASa8MlJq7046827WVOCHEkw
- nANhUgJlEBIABJIwL3K+4IcUALCHjfbItYZDSgJgkBiYPmBMAUAkkLPKs/BAyLgM
- wAQwOAAY2ByCaw4QAFQSoDEePJ6DmU1xInYZTw5nOEFFdgVUelkVDTIMd3AKFGQ1
- MgI2AwEmQW8APZ0gdRONAks5nhIFVVxdAAkUAS2pAVwFl7ITB4UqHb0XEQA7
+image create photo ::img::new -format PNG -data [mc {
+ iVBORw0KGgoAAAANSUhEUgAAAB4AAAAOCAYAAAA45qw5AAACMElEQVR4AeVTAwxd
+ QRCc2tZHGtQ2w9q2bdsOa9u2bUW1bdt2Z372JZe6DapJLqtb3h7+T8yKi5j4CsYD
+ EUQXxETclT7kWOlH2VV+tFkdQHPSwksSISF+BauCqL0qgOcMWgGfgEkaMsHxqUBk
+ 3plE/sOnh/qDPAPJH/CKFBivGHWzFwBRnHhlqbu1Mh6CoFNnC/JshQ9p4YC2lrKt
+ DCAV+THiVejyhMjAbrNSrroiEfKR9g7ZfCgOog8QfnUQV62wAk68ndQ9ZbyoWO1H
+ Y6eDY1LCQL6a9ApOp9Hi1T0+gQq2JKMlky/oTKQliKWxEZvyG575kpW4pl1aZnQK
+ CLOVt45Lkp8uXp2SL8KO6uitNTZLdpK6s+I/eZbhpmsmWeOGOVQNKYLITzpKPAO3
+ tY7LSNZ7ccSLxX9y3uuOxRkg3dKESMoCHvL+GRVCutXsB3guLgDCeXOv4iWWkvwG
+ BaS+PmlpK6SI9ApI2oC2UtrwZQEkhkH+NtolVlQXJl1I+QltuU3XEc721bIRFpa8
+ IA5iqTo6vNNWmkNBLQbPeXwF2g17Q94nTQAfY3YzeY+WSu8MDzQ2kpELUhSGJUHE
+ 0zeR3rY1L+Xl5G/re+jbiK6KhThwwInsts1fbMUUcpZszKeVtggZEiGdZDe5AtHh
+ 7vL4CGiRvvKPS8FAvq9Nr4ZkFadR2y6kggu1z4vlyIbBp6BugQ8JLEg4bTkD9eMZ
+ QZ8hpJ3VvTtuvbWrY/ElvP/9R+Aj3603+iE3fkEAAAAASUVORK5CYII=
}]
#----------------------------------------------------------------
@@ -186,6 +194,10 @@ if {[winfo depth .] == 1} {
-foreground blue -underline 1
.t tag configure visited -lmargin1 1c -lmargin2 1c \
-foreground #303080 -underline 1
+ if {[tk windowingsystem] eq "aqua"} {
+ .t tag configure demo -foreground systemLinkColor
+ .t tag configure visited -foreground purple
+ }
.t tag configure hot -foreground red -underline 1
}
.t tag bind demo <ButtonRelease-1> {
diff --git a/library/dialog.tcl b/library/dialog.tcl
index c751621..a099d90 100644
--- a/library/dialog.tcl
+++ b/library/dialog.tcl
@@ -44,11 +44,6 @@ proc ::tk_dialog {w title text bitmap default args} {
}
set windowingsystem [tk windowingsystem]
- if {$windowingsystem eq "aqua"} {
- option add *Dialog*background systemDialogBackgroundActive widgetDefault
- option add *Dialog*Button.highlightBackground \
- systemDialogBackgroundActive widgetDefault
- }
# 1. Create the top-level window and divide it into top
# and bottom parts.
diff --git a/library/entry.tcl b/library/entry.tcl
index 6243d26..02384da 100644
--- a/library/entry.tcl
+++ b/library/entry.tcl
@@ -74,7 +74,7 @@ bind Entry <<TraverseIn>> {
# Standard Motif bindings:
-bind Entry <1> {
+bind Entry <Button-1> {
tk::EntryButton1 %W %x
%W selection clear
}
@@ -82,25 +82,25 @@ bind Entry <B1-Motion> {
set tk::Priv(x) %x
tk::EntryMouseSelect %W %x
}
-bind Entry <Double-1> {
+bind Entry <Double-Button-1> {
set tk::Priv(selectMode) word
tk::EntryMouseSelect %W %x
catch {%W icursor sel.last}
}
-bind Entry <Triple-1> {
+bind Entry <Triple-Button-1> {
set tk::Priv(selectMode) line
tk::EntryMouseSelect %W %x
catch {%W icursor sel.last}
}
-bind Entry <Shift-1> {
+bind Entry <Shift-Button-1> {
set tk::Priv(selectMode) char
%W selection adjust @%x
}
-bind Entry <Double-Shift-1> {
+bind Entry <Double-Shift-Button-1> {
set tk::Priv(selectMode) word
tk::EntryMouseSelect %W %x
}
-bind Entry <Triple-Shift-1> {
+bind Entry <Triple-Shift-Button-1> {
set tk::Priv(selectMode) line
tk::EntryMouseSelect %W %x
}
@@ -114,7 +114,7 @@ bind Entry <B1-Enter> {
bind Entry <ButtonRelease-1> {
tk::CancelRepeat
}
-bind Entry <Control-1> {
+bind Entry <Control-Button-1> {
%W icursor @%x
}
@@ -190,19 +190,19 @@ bind Entry <<SelectAll>> {
bind Entry <<SelectNone>> {
%W selection clear
}
-bind Entry <KeyPress> {
+bind Entry <Key> {
tk::CancelRepeat
tk::EntryInsert %W %A
}
# Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
# Otherwise, if a widget binding for one of these is defined, the
-# <KeyPress> class binding will also fire and insert the character,
+# <Key> class binding will also fire and insert the character,
# which is wrong. Ditto for Escape, Return, and Tab.
-bind Entry <Alt-KeyPress> {# nothing}
-bind Entry <Meta-KeyPress> {# nothing}
-bind Entry <Control-KeyPress> {# nothing}
+bind Entry <Alt-Key> {# nothing}
+bind Entry <Meta-Key> {# nothing}
+bind Entry <Control-Key> {# nothing}
bind Entry <Escape> {# nothing}
bind Entry <Return> {# nothing}
bind Entry <KP_Enter> {# nothing}
@@ -210,7 +210,7 @@ bind Entry <Tab> {# nothing}
bind Entry <Prior> {# nothing}
bind Entry <Next> {# nothing}
if {[tk windowingsystem] eq "aqua"} {
- bind Entry <Command-KeyPress> {# nothing}
+ bind Entry <Command-Key> {# nothing}
}
# Tk-on-Cocoa generates characters for these two keys. [Bug 2971663]
bind Entry <<NextLine>> {# nothing}
@@ -272,16 +272,48 @@ bind Entry <Meta-Delete> {
}
}
-# A few additional bindings of my own.
+# Bindings for IME text input and accents.
-bind Entry <2> {
- if {!$tk_strictMotif} {
- ::tk::EntryScanMark %W %x
+bind Entry <<TkStartIMEMarkedText>> {
+ dict set ::tk::Priv(IMETextMark) "%W" [%W index insert]
+}
+bind Entry <<TkEndIMEMarkedText>> {
+ if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } {
+ bell
+ } else {
+ %W selection range $mark insert
}
}
-bind Entry <B2-Motion> {
- if {!$tk_strictMotif} {
- ::tk::EntryScanDrag %W %x
+bind Entry <<TkClearIMEMarkedText>> {
+ %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert]
+}
+bind Entry <<TkAccentBackspace>> {
+ tk::EntryBackspace %W
+}
+
+# A few additional bindings of my own.
+
+if {[tk windowingsystem] ne "aqua"} {
+ bind Entry <Button-2> {
+ if {!$tk_strictMotif} {
+ ::tk::EntryScanMark %W %x
+ }
+ }
+ bind Entry <B2-Motion> {
+ if {!$tk_strictMotif} {
+ ::tk::EntryScanDrag %W %x
+ }
+ }
+} else {
+ bind Entry <Button-3> {
+ if {!$tk_strictMotif} {
+ ::tk::EntryScanMark %W %x
+ }
+ }
+ bind Entry <B3-Motion> {
+ if {!$tk_strictMotif} {
+ ::tk::EntryScanDrag %W %x
+ }
}
}
@@ -652,3 +684,12 @@ proc ::tk::EntryGetSelection {w} {
}
return $entryString
}
+
+
+
+
+
+
+
+
+
diff --git a/library/iconlist.tcl b/library/iconlist.tcl
index 62b0b2d..35b40b6 100644
--- a/library/iconlist.tcl
+++ b/library/iconlist.tcl
@@ -433,11 +433,11 @@ package require Tk 8.6
#
bind $canvas <Configure> [namespace code {my WhenIdle Arrange}]
- bind $canvas <1> [namespace code {my Btn1 %x %y}]
+ bind $canvas <Button-1> [namespace code {my Btn1 %x %y}]
bind $canvas <B1-Motion> [namespace code {my Motion1 %x %y}]
bind $canvas <B1-Leave> [namespace code {my Leave1 %x %y}]
- bind $canvas <Control-1> [namespace code {my CtrlBtn1 %x %y}]
- bind $canvas <Shift-1> [namespace code {my ShiftBtn1 %x %y}]
+ bind $canvas <Control-Button-1> [namespace code {my CtrlBtn1 %x %y}]
+ bind $canvas <Shift-Button-1> [namespace code {my ShiftBtn1 %x %y}]
bind $canvas <B1-Enter> [list tk::CancelRepeat]
bind $canvas <ButtonRelease-1> [list tk::CancelRepeat]
bind $canvas <Double-ButtonRelease-1> \
@@ -446,14 +446,27 @@ package require Tk 8.6
bind $canvas <Control-B1-Motion> {;}
bind $canvas <Shift-B1-Motion> [namespace code {my ShiftMotion1 %x %y}]
+ if {[tk windowingsystem] eq "aqua"} {
+ bind $canvas <Shift-MouseWheel> [namespace code {my MouseWheel [expr {40 * (%D)}]}]
+ bind $canvas <Option-Shift-MouseWheel> [namespace code {my MouseWheel [expr {400 * (%D)}]}]
+ } else {
+ bind $canvas <Shift-MouseWheel> [namespace code {my MouseWheel %D}]
+ }
+ if {[tk windowingsystem] eq "x11"} {
+ bind $canvas <Shift-Button-4> [namespace code {my MouseWheel 120}]
+ bind $canvas <Shift-Button-5> [namespace code {my MouseWheel -120}]
+ bind $canvas <Button-6> [namespace code {my MouseWheel 120}]
+ bind $canvas <Button-7> [namespace code {my MouseWheel -120}]
+ }
+
bind $canvas <<PrevLine>> [namespace code {my UpDown -1}]
bind $canvas <<NextLine>> [namespace code {my UpDown 1}]
bind $canvas <<PrevChar>> [namespace code {my LeftRight -1}]
bind $canvas <<NextChar>> [namespace code {my LeftRight 1}]
bind $canvas <Return> [namespace code {my ReturnKey}]
- bind $canvas <KeyPress> [namespace code {my KeyPress %A}]
- bind $canvas <Control-KeyPress> ";"
- bind $canvas <Alt-KeyPress> ";"
+ bind $canvas <Key> [namespace code {my KeyPress %A}]
+ bind $canvas <Control-Key> ";"
+ bind $canvas <Alt-Key> ";"
bind $canvas <FocusIn> [namespace code {my FocusIn}]
bind $canvas <FocusOut> [namespace code {my FocusOut}]
@@ -492,6 +505,22 @@ package require Tk 8.6
# ----------------------------------------------------------------------
# Event handlers
+ method MouseWheel {amount} {
+ if {$noScroll || $::tk_strictMotif} {
+ return
+ }
+ # We must make sure that positive and negative movements are rounded
+ # equally to integers, avoiding the problem that
+ # (int)1/120 = 0,
+ # but
+ # (int)-1/120 = -1
+ # The following code ensure equal +/- behaviour.
+ if {$amount > 0} {
+ $canvas xview scroll [expr {(-119-$amount) / 120}] units
+ } else {
+ $canvas xview scroll [expr {-($amount / 120)}] units
+ }
+ }
method Btn1 {x y} {
focus $canvas
set i [$w index @$x,$y]
diff --git a/library/listbox.tcl b/library/listbox.tcl
index 16e51bd..b653199 100644
--- a/library/listbox.tcl
+++ b/library/listbox.tcl
@@ -31,7 +31,7 @@
# can put "break"s in their bindings to avoid the error, but this check
# makes that unnecessary.
-bind Listbox <1> {
+bind Listbox <Button-1> {
if {[winfo exists %W]} {
tk::ListboxBeginSelect %W [%W index @%x,%y] 1
}
@@ -41,7 +41,7 @@ bind Listbox <1> {
# Among other things, this prevents errors if the user deletes the
# listbox on a double click.
-bind Listbox <Double-1> {
+bind Listbox <Double-Button-1> {
# Empty script
}
@@ -54,10 +54,10 @@ bind Listbox <ButtonRelease-1> {
tk::CancelRepeat
%W activate @%x,%y
}
-bind Listbox <Shift-1> {
+bind Listbox <Shift-Button-1> {
tk::ListboxBeginExtend %W [%W index @%x,%y]
}
-bind Listbox <Control-1> {
+bind Listbox <Control-Button-1> {
tk::ListboxBeginToggle %W [%W index @%x,%y]
}
bind Listbox <B1-Leave> {
@@ -169,7 +169,7 @@ bind Listbox <<SelectNone>> {
# Additional Tk bindings that aren't part of the Motif look and feel:
-bind Listbox <2> {
+bind Listbox <Button-2> {
%W scan mark %x %y
}
bind Listbox <B2-Motion> {
@@ -182,47 +182,71 @@ bind Listbox <B2-Motion> {
if {[tk windowingsystem] eq "aqua"} {
bind Listbox <MouseWheel> {
- %W yview scroll [expr {- (%D)}] units
+ %W yview scroll [expr {-(%D)}] units
}
bind Listbox <Option-MouseWheel> {
%W yview scroll [expr {-10 * (%D)}] units
}
bind Listbox <Shift-MouseWheel> {
- %W xview scroll [expr {- (%D)}] units
+ %W xview scroll [expr {-(%D)}] units
}
bind Listbox <Shift-Option-MouseWheel> {
%W xview scroll [expr {-10 * (%D)}] units
}
} else {
+ # We must make sure that positive and negative movements are rounded
+ # equally to integers, avoiding the problem that
+ # (int)1/30 = 0,
+ # but
+ # (int)-1/30 = -1
+ # The following code ensure equal +/- behaviour.
bind Listbox <MouseWheel> {
- %W yview scroll [expr {- (%D / 120) * 4}] units
+ if {%D >= 0} {
+ %W yview scroll [expr {-%D/30}] units
+ } else {
+ %W yview scroll [expr {(29-%D)/30}] units
+ }
}
bind Listbox <Shift-MouseWheel> {
- %W xview scroll [expr {- (%D / 120) * 4}] units
+ if {%D >= 0} {
+ %W xview scroll [expr {-%D/30}] units
+ } else {
+ %W xview scroll [expr {(29-%D)/30}] units
+ }
}
}
-if {"x11" eq [tk windowingsystem]} {
+if {[tk windowingsystem] eq "x11"} {
# Support for mousewheels on Linux/Unix commonly comes through mapping
# the wheel to the extended buttons. If you have a mousewheel, find
# Linux configuration info at:
# http://linuxreviews.org/howtos/xfree/mouse/
- bind Listbox <4> {
+ bind Listbox <Button-4> {
if {!$tk_strictMotif} {
%W yview scroll -5 units
}
}
- bind Listbox <Shift-4> {
+ bind Listbox <Shift-Button-4> {
if {!$tk_strictMotif} {
%W xview scroll -5 units
}
}
- bind Listbox <5> {
+ bind Listbox <Button-5> {
if {!$tk_strictMotif} {
%W yview scroll 5 units
}
}
- bind Listbox <Shift-5> {
+ bind Listbox <Shift-Button-5> {
+ if {!$tk_strictMotif} {
+ %W xview scroll 5 units
+ }
+ }
+ bind Listbox <Button-6> {
+ if {!$tk_strictMotif} {
+ %W xview scroll -5 units
+ }
+ }
+ bind Listbox <Button-7> {
if {!$tk_strictMotif} {
%W xview scroll 5 units
}
diff --git a/library/menu.tcl b/library/menu.tcl
index 8d06868..f1207dc 100644
--- a/library/menu.tcl
+++ b/library/menu.tcl
@@ -88,7 +88,7 @@ bind Menubutton <Enter> {
bind Menubutton <Leave> {
tk::MbLeave %W
}
-bind Menubutton <1> {
+bind Menubutton <Button-1> {
if {$tk::Priv(inMenubutton) ne ""} {
tk::MbPost $tk::Priv(inMenubutton) %X %Y
}
@@ -138,7 +138,7 @@ bind Menu <Leave> {
bind Menu <Motion> {
tk::MenuMotion %W %x %y %s
}
-bind Menu <ButtonPress> {
+bind Menu <Button> {
tk::MenuButtonDown %W
}
bind Menu <ButtonRelease> {
@@ -168,7 +168,7 @@ bind Menu <<PrevLine>> {
bind Menu <<NextLine>> {
tk::MenuDownArrow %W
}
-bind Menu <KeyPress> {
+bind Menu <Key> {
tk::TraverseWithinMenu %W %A
break
}
@@ -177,7 +177,7 @@ bind Menu <KeyPress> {
# implement keyboard menu traversal.
if {[tk windowingsystem] eq "x11"} {
- bind all <Alt-KeyPress> {
+ bind all <Alt-Key> {
tk::TraverseToMenu %W %A
}
@@ -185,7 +185,7 @@ if {[tk windowingsystem] eq "x11"} {
tk::FirstMenu %W
}
} else {
- bind Menubutton <Alt-KeyPress> {
+ bind Menubutton <Alt-Key> {
tk::TraverseToMenu %W %A
}
@@ -1178,15 +1178,6 @@ if {[tk windowingsystem] eq "aqua"} {
set entry 0
}
}
- if {$entry ne ""} {
- if {$entry == [$menu index last]} {
- set entryHeight [expr {[winfo reqheight $menu] \
- - [$menu yposition $entry]}]
- } else {
- set entryHeight [expr {[$menu yposition [expr {$entry+1}]] \
- - [$menu yposition $entry]}]
- }
- }
set x [winfo rootx $button]
set y [winfo rooty $button]
switch [$button cget -direction] {
diff --git a/library/msgbox.tcl b/library/msgbox.tcl
index 98603af..646c143 100644
--- a/library/msgbox.tcl
+++ b/library/msgbox.tcl
@@ -164,9 +164,6 @@ proc ::tk::MessageBox {args} {
"warning" {set data(-icon) "caution"}
"info" {set data(-icon) "note"}
}
- option add *Dialog*background systemDialogBackgroundActive widgetDefault
- option add *Dialog*Button.highlightBackground \
- systemDialogBackgroundActive widgetDefault
}
if {![winfo exists $data(-parent)]} {
diff --git a/library/obsolete.tcl b/library/obsolete.tcl
index 3ee7f28..e66c48d 100644
--- a/library/obsolete.tcl
+++ b/library/obsolete.tcl
@@ -103,7 +103,7 @@ proc ::tk::classic::restore_listbox {args} {
option add *Listbox.selectBorderWidth 1 $prio; # 0
}
# Remove focus into Listbox added for 8.5
- bind Listbox <1> {
+ bind Listbox <Button-1> {
if {[winfo exists %W]} {
tk::ListboxBeginSelect %W [%W index @%x,%y]
}
diff --git a/library/scale.tcl b/library/scale.tcl
index fb9b81b..cc0de20 100644
--- a/library/scale.tcl
+++ b/library/scale.tcl
@@ -34,7 +34,7 @@ bind Scale <Leave> {
%W configure -state normal
}
}
-bind Scale <1> {
+bind Scale <Button-1> {
tk::ScaleButtonDown %W %x %y
}
bind Scale <B1-Motion> {
@@ -47,7 +47,7 @@ bind Scale <ButtonRelease-1> {
tk::ScaleEndDrag %W
tk::ScaleActivate %W %x %y
}
-bind Scale <2> {
+bind Scale <Button-2> {
tk::ScaleButton2Down %W %x %y
}
bind Scale <B2-Motion> {
@@ -62,13 +62,13 @@ bind Scale <ButtonRelease-2> {
}
if {[tk windowingsystem] eq "win32"} {
# On Windows do the same with button 3, as that is the right mouse button
- bind Scale <3> [bind Scale <2>]
+ bind Scale <Button-3> [bind Scale <Button-2>]
bind Scale <B3-Motion> [bind Scale <B2-Motion>]
bind Scale <B3-Leave> [bind Scale <B2-Leave>]
bind Scale <B3-Enter> [bind Scale <B2-Enter>]
bind Scale <ButtonRelease-3> [bind Scale <ButtonRelease-2>]
}
-bind Scale <Control-1> {
+bind Scale <Control-Button-1> {
tk::ScaleControlPress %W %x %y
}
bind Scale <<PrevLine>> {
diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl
index 6f1caa2..8106b3d 100644
--- a/library/scrlbar.tcl
+++ b/library/scrlbar.tcl
@@ -39,7 +39,7 @@ bind Scrollbar <Leave> {
}
%W activate {}
}
-bind Scrollbar <1> {
+bind Scrollbar <Button-1> {
tk::ScrollButtonDown %W %x %y
}
bind Scrollbar <B1-Motion> {
@@ -57,13 +57,13 @@ bind Scrollbar <B1-Leave> {
bind Scrollbar <B1-Enter> {
# Prevents <Enter> binding from being invoked.
}
-bind Scrollbar <2> {
+bind Scrollbar <Button-2> {
tk::ScrollButton2Down %W %x %y
}
-bind Scrollbar <B1-2> {
+bind Scrollbar <B1-Button-2> {
# Do nothing, since button 1 is already down.
}
-bind Scrollbar <B2-1> {
+bind Scrollbar <B2-Button-1> {
# Do nothing, since button 2 is already down.
}
bind Scrollbar <B2-Motion> {
@@ -84,10 +84,10 @@ bind Scrollbar <B2-Leave> {
bind Scrollbar <B2-Enter> {
# Prevents <Enter> binding from being invoked.
}
-bind Scrollbar <Control-1> {
+bind Scrollbar <Control-Button-1> {
tk::ScrollTopBottom %W %x %y
}
-bind Scrollbar <Control-2> {
+bind Scrollbar <Control-Button-2> {
tk::ScrollTopBottom %W %x %y
}
@@ -128,42 +128,37 @@ bind Scrollbar <<LineEnd>> {
tk::ScrollToPos %W 1
}
}
-switch [tk windowingsystem] {
- "aqua" {
- bind Scrollbar <MouseWheel> {
- tk::ScrollByUnits %W v [expr {- (%D)}]
- }
- bind Scrollbar <Option-MouseWheel> {
- tk::ScrollByUnits %W v [expr {-10 * (%D)}]
- }
- bind Scrollbar <Shift-MouseWheel> {
- tk::ScrollByUnits %W h [expr {- (%D)}]
- }
- bind Scrollbar <Shift-Option-MouseWheel> {
- tk::ScrollByUnits %W h [expr {-10 * (%D)}]
- }
+
+if {[tk windowingsystem] eq "aqua"} {
+ bind Scrollbar <MouseWheel> {
+ tk::ScrollByUnits %W hv [expr {-(%D)}]
}
- "win32" {
- bind Scrollbar <MouseWheel> {
- tk::ScrollByUnits %W v [expr {- (%D / 120) * 4}]
- }
- bind Scrollbar <Shift-MouseWheel> {
- tk::ScrollByUnits %W h [expr {- (%D / 120) * 4}]
- }
+ bind Scrollbar <Option-MouseWheel> {
+ tk::ScrollByUnits %W hv [expr {-10 * (%D)}]
}
- "x11" {
- bind Scrollbar <MouseWheel> {
- tk::ScrollByUnits %W v [expr {- (%D /120 ) * 4}]
- }
- bind Scrollbar <Shift-MouseWheel> {
- tk::ScrollByUnits %W h [expr {- (%D /120 ) * 4}]
+} else {
+ # We must make sure that positive and negative movements are rounded
+ # equally to integers, avoiding the problem that
+ # (int)1/30 = 0,
+ # but
+ # (int)-1/30 = -1
+ # The following code ensure equal +/- behaviour.
+ bind Scrollbar <MouseWheel> {
+ if {%D >= 0} {
+ tk::ScrollByUnits %W hv [expr {-%D/30}]
+ } else {
+ tk::ScrollByUnits %W hv [expr {(29-%D)/30}]
}
- bind Scrollbar <4> {tk::ScrollByUnits %W v -5}
- bind Scrollbar <5> {tk::ScrollByUnits %W v 5}
- bind Scrollbar <Shift-4> {tk::ScrollByUnits %W h -5}
- bind Scrollbar <Shift-5> {tk::ScrollByUnits %W h 5}
}
}
+
+if {[tk windowingsystem] eq "x11"} {
+ bind Scrollbar <Button-4> {tk::ScrollByUnits %W hv -5}
+ bind Scrollbar <Button-5> {tk::ScrollByUnits %W hv 5}
+ bind Scrollbar <Button-6> {tk::ScrollByUnits %W hv -5}
+ bind Scrollbar <Button-7> {tk::ScrollByUnits %W hv 5}
+}
+
# tk::ScrollButtonDown --
# This procedure is invoked when a button is pressed in a scrollbar.
# It changes the way the scrollbar is displayed and takes actions
diff --git a/library/spinbox.tcl b/library/spinbox.tcl
index 1965ed8..909405e 100644
--- a/library/spinbox.tcl
+++ b/library/spinbox.tcl
@@ -79,31 +79,31 @@ bind Spinbox <<TraverseIn>> {
# Standard Motif bindings:
-bind Spinbox <1> {
+bind Spinbox <Button-1> {
::tk::spinbox::ButtonDown %W %x %y
}
bind Spinbox <B1-Motion> {
::tk::spinbox::Motion %W %x %y
}
-bind Spinbox <Double-1> {
+bind Spinbox <Double-Button-1> {
::tk::spinbox::ArrowPress %W %x %y
set tk::Priv(selectMode) word
::tk::spinbox::MouseSelect %W %x sel.first
}
-bind Spinbox <Triple-1> {
+bind Spinbox <Triple-Button-1> {
::tk::spinbox::ArrowPress %W %x %y
set tk::Priv(selectMode) line
::tk::spinbox::MouseSelect %W %x 0
}
-bind Spinbox <Shift-1> {
+bind Spinbox <Shift-Button-1> {
set tk::Priv(selectMode) char
%W selection adjust @%x
}
-bind Spinbox <Double-Shift-1> {
+bind Spinbox <Double-Shift-Button-1> {
set tk::Priv(selectMode) word
::tk::spinbox::MouseSelect %W %x
}
-bind Spinbox <Triple-Shift-1> {
+bind Spinbox <Triple-Shift-Button-1> {
set tk::Priv(selectMode) line
::tk::spinbox::MouseSelect %W %x
}
@@ -117,7 +117,7 @@ bind Spinbox <B1-Enter> {
bind Spinbox <ButtonRelease-1> {
::tk::spinbox::ButtonUp %W %x %y
}
-bind Spinbox <Control-1> {
+bind Spinbox <Control-Button-1> {
%W icursor @%x
}
@@ -200,18 +200,18 @@ bind Spinbox <<SelectAll>> {
bind Spinbox <<SelectNone>> {
%W selection clear
}
-bind Spinbox <KeyPress> {
+bind Spinbox <Key> {
::tk::EntryInsert %W %A
}
# Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
# Otherwise, if a widget binding for one of these is defined, the
-# <KeyPress> class binding will also fire and insert the character,
+# <Key> class binding will also fire and insert the character,
# which is wrong. Ditto for Escape, Return, and Tab.
-bind Spinbox <Alt-KeyPress> {# nothing}
-bind Spinbox <Meta-KeyPress> {# nothing}
-bind Spinbox <Control-KeyPress> {# nothing}
+bind Spinbox <Alt-Key> {# nothing}
+bind Spinbox <Meta-Key> {# nothing}
+bind Spinbox <Control-Key> {# nothing}
bind Spinbox <Escape> {# nothing}
bind Spinbox <Return> {# nothing}
bind Spinbox <KP_Enter> {# nothing}
@@ -219,7 +219,7 @@ bind Spinbox <Tab> {# nothing}
bind Spinbox <Prior> {# nothing}
bind Spinbox <Next> {# nothing}
if {[tk windowingsystem] eq "aqua"} {
- bind Spinbox <Command-KeyPress> {# nothing}
+ bind Spinbox <Command-Key> {# nothing}
}
# On Windows, paste is done using Shift-Insert. Shift-Insert already
@@ -280,14 +280,27 @@ bind Spinbox <Meta-Delete> {
# A few additional bindings of my own.
-bind Spinbox <2> {
- if {!$tk_strictMotif} {
- ::tk::EntryScanMark %W %x
+if {[tk windowingsystem] ne "aqua"} {
+ bind Spinbox <Button-2> {
+ if {!$tk_strictMotif} {
+ ::tk::EntryScanMark %W %x
+ }
}
-}
-bind Spinbox <B2-Motion> {
- if {!$tk_strictMotif} {
- ::tk::EntryScanDrag %W %x
+ bind Spinbox <B2-Motion> {
+ if {!$tk_strictMotif} {
+ ::tk::EntryScanDrag %W %x
+ }
+ }
+} else {
+ bind Spinbox <Button-3> {
+ if {!$tk_strictMotif} {
+ ::tk::EntryScanMark %W %x
+ }
+ }
+ bind Spinbox <B3-Motion> {
+ if {!$tk_strictMotif} {
+ ::tk::EntryScanDrag %W %x
+ }
}
}
diff --git a/library/tearoff.tcl b/library/tearoff.tcl
index b500023..c2d2d6b 100644
--- a/library/tearoff.tcl
+++ b/library/tearoff.tcl
@@ -154,7 +154,9 @@ proc ::tk::MenuDup {src dst type} {
# Copy tags to x, replacing each substring of src with dst.
while {[set index [string first $src $tags]] != -1} {
- append x [string range $tags 0 [expr {$index - 1}]]$dst
+ if {$index > 0} {
+ append x [string range $tags 0 [expr {$index - 1}]]$dst
+ }
set tags [string range $tags [expr {$index + $srcLen}] end]
}
append x $tags
@@ -169,7 +171,9 @@ proc ::tk::MenuDup {src dst type} {
# Copy script to x, replacing each substring of event with dst.
while {[set index [string first $event $script]] != -1} {
- append x [string range $script 0 [expr {$index - 1}]]
+ if {$index > 0} {
+ append x [string range $script 0 [expr {$index - 1}]]
+ }
append x $dst
set script [string range $script [expr {$index + $eventLen}] end]
}
diff --git a/library/text.tcl b/library/text.tcl
index e7cf061..28c6c20 100644
--- a/library/text.tcl
+++ b/library/text.tcl
@@ -38,9 +38,11 @@
# The code below creates the default class bindings for text widgets.
#-------------------------------------------------------------------------
+
+
# Standard Motif bindings:
-bind Text <1> {
+bind Text <Button-1> {
tk::TextButton1 %W %x %y
%W tag remove sel 0.0 end
}
@@ -49,26 +51,26 @@ bind Text <B1-Motion> {
set tk::Priv(y) %y
tk::TextSelectTo %W %x %y
}
-bind Text <Double-1> {
+bind Text <Double-Button-1> {
set tk::Priv(selectMode) word
tk::TextSelectTo %W %x %y
catch {%W mark set insert sel.first}
}
-bind Text <Triple-1> {
+bind Text <Triple-Button-1> {
set tk::Priv(selectMode) line
tk::TextSelectTo %W %x %y
catch {%W mark set insert sel.first}
}
-bind Text <Shift-1> {
+bind Text <Shift-Button-1> {
tk::TextResetAnchor %W @%x,%y
set tk::Priv(selectMode) char
tk::TextSelectTo %W %x %y
}
-bind Text <Double-Shift-1> {
+bind Text <Double-Shift-Button-1> {
set tk::Priv(selectMode) word
tk::TextSelectTo %W %x %y 1
}
-bind Text <Triple-Shift-1> {
+bind Text <Triple-Shift-Button-1> {
set tk::Priv(selectMode) line
tk::TextSelectTo %W %x %y
}
@@ -83,7 +85,8 @@ bind Text <B1-Enter> {
bind Text <ButtonRelease-1> {
tk::CancelRepeat
}
-bind Text <Control-1> {
+
+bind Text <Control-Button-1> {
%W mark set insert @%x,%y
# An operation that moves the insert mark without making it
# one end of the selection must insert an autoseparator
@@ -92,7 +95,7 @@ bind Text <Control-1> {
}
}
# stop an accidental double click triggering <Double-Button-1>
-bind Text <Double-Control-1> { # nothing }
+bind Text <Double-Control-Button-1> { # nothing }
# stop an accidental movement triggering <B1-Motion>
bind Text <Control-B1-Motion> { # nothing }
bind Text <<PrevChar>> {
@@ -289,22 +292,22 @@ bind Text <<PasteSelection>> {
bind Text <Insert> {
catch {tk::TextInsert %W [::tk::GetSelection %W PRIMARY]}
}
-bind Text <KeyPress> {
+bind Text <Key> {
tk::TextInsert %W %A
}
# Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
# Otherwise, if a widget binding for one of these is defined, the
-# <KeyPress> class binding will also fire and insert the character,
+# <Key> class binding will also fire and insert the character,
# which is wrong. Ditto for <Escape>.
-bind Text <Alt-KeyPress> {# nothing }
-bind Text <Meta-KeyPress> {# nothing}
-bind Text <Control-KeyPress> {# nothing}
+bind Text <Alt-Key> {# nothing }
+bind Text <Meta-Key> {# nothing}
+bind Text <Control-Key> {# nothing}
bind Text <Escape> {# nothing}
bind Text <KP_Enter> {# nothing}
if {[tk windowingsystem] eq "aqua"} {
- bind Text <Command-KeyPress> {# nothing}
+ bind Text <Command-Key> {# nothing}
}
# Additional emacs-like bindings:
@@ -388,6 +391,26 @@ bind Text <Meta-Delete> {
}
}
+# Bindings for IME text input.
+
+bind Text <<TkStartIMEMarkedText>> {
+ dict set ::tk::Priv(IMETextMark) "%W" [%W index insert]
+}
+bind Text <<TkEndIMEMarkedText>> {
+ if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } {
+ bell
+ } else {
+ %W tag add IMEmarkedtext $mark insert
+ %W tag configure IMEmarkedtext -underline on
+ }
+}
+bind Text <<TkClearIMEMarkedText>> {
+ %W delete IMEmarkedtext.first IMEmarkedtext.last
+}
+bind Text <<TkAccentBackspace>> {
+ %W delete insert-1c
+}
+
# Macintosh only bindings:
if {[tk windowingsystem] eq "aqua"} {
@@ -406,14 +429,27 @@ bind Text <Control-h> {
%W see insert
}
}
-bind Text <2> {
- if {!$tk_strictMotif} {
- tk::TextScanMark %W %x %y
+if {[tk windowingsystem] ne "aqua"} {
+ bind Text <Button-2> {
+ if {!$tk_strictMotif} {
+ tk::TextScanMark %W %x %y
+ }
}
-}
-bind Text <B2-Motion> {
- if {!$tk_strictMotif} {
- tk::TextScanDrag %W %x %y
+ bind Text <B2-Motion> {
+ if {!$tk_strictMotif} {
+ tk::TextScanDrag %W %x %y
+ }
+ }
+} else {
+ bind Text <Button-3> {
+ if {!$tk_strictMotif} {
+ tk::TextScanMark %W %x %y
+ }
+ }
+ bind Text <B3-Motion> {
+ if {!$tk_strictMotif} {
+ tk::TextScanDrag %W %x %y
+ }
}
}
set ::tk::Priv(prevPos) {}
@@ -459,27 +495,37 @@ if {[tk windowingsystem] eq "aqua"} {
}
}
-if {"x11" eq [tk windowingsystem]} {
+if {[tk windowingsystem] eq "x11"} {
# Support for mousewheels on Linux/Unix commonly comes through mapping
# the wheel to the extended buttons. If you have a mousewheel, find
# Linux configuration info at:
# http://linuxreviews.org/howtos/xfree/mouse/
- bind Text <4> {
+ bind Text <Button-4> {
if {!$tk_strictMotif} {
%W yview scroll -50 pixels
}
}
- bind Text <5> {
+ bind Text <Button-5> {
if {!$tk_strictMotif} {
%W yview scroll 50 pixels
}
}
- bind Text <Shift-4> {
+ bind Text <Shift-Button-4> {
+ if {!$tk_strictMotif} {
+ %W xview scroll -50 pixels
+ }
+ }
+ bind Text <Shift-Button-5> {
+ if {!$tk_strictMotif} {
+ %W xview scroll 50 pixels
+ }
+ }
+ bind Text <Button-6> {
if {!$tk_strictMotif} {
%W xview scroll -50 pixels
}
}
- bind Text <Shift-5> {
+ bind Text <Button-7> {
if {!$tk_strictMotif} {
%W xview scroll 50 pixels
}
@@ -891,11 +937,10 @@ proc ::tk::TextInsert {w s} {
# ::tk::TextUpDownLine --
# Returns the index of the character one display line above or below the
-# insertion cursor. There are two tricky things here. First, we want to
-# maintain the original x position across repeated operations, even though
-# some lines that will get passed through don't have enough characters to
-# cover the original column. Second, don't try to scroll past the
-# beginning or end of the text.
+# insertion cursor. There is a tricky thing here: we want to maintain the
+# original x position across repeated operations, even though some lines
+# that will get passed through don't have enough characters to cover the
+# original column.
#
# Arguments:
# w - The text window in which the cursor is to move.
@@ -912,11 +957,11 @@ proc ::tk::TextUpDownLine {w n} {
set lines [$w count -displaylines $Priv(textPosOrig) $i]
set new [$w index \
"$Priv(textPosOrig) + [expr {$lines + $n}] displaylines"]
- if {[$w compare $new == end] \
- || [$w compare $new == "insert display linestart"]} {
- set new $i
- }
set Priv(prevPos) $new
+ if {[$w compare $new == "end display lineend"] \
+ || [$w compare $new == "insert display linestart"]} {
+ set Priv(textPosOrig) $new
+ }
return $new
}
@@ -1205,7 +1250,6 @@ proc ::tk::TextScanDrag {w x y} {
$w scan dragto $x $y
}
}
-
# ::tk::TextUndoRedoProcessMarks --
#
# This proc is executed after an undo or redo action.
@@ -1247,7 +1291,11 @@ proc ::tk::TextUndoRedoProcessMarks {w} {
set nUndoMarks [llength $undoMarks]
set n [expr {$nUndoMarks / 2}]
set undoMarks [lsort -dictionary $undoMarks]
- set Lmarks [lrange $undoMarks 0 [expr {$n - 1}]]
+ if {$n > 0} {
+ set Lmarks [lrange $undoMarks 0 [expr {$n - 1}]]
+ } else {
+ set Lmarks {}
+ }
set Rmarks [lrange $undoMarks $n [llength $undoMarks]]
foreach Lmark $Lmarks Rmark $Rmarks {
lappend indices [$w index $Lmark] [$w index $Rmark]
@@ -1274,29 +1322,23 @@ proc ::tk::TextUndoRedoProcessMarks {w} {
# -> further second ranges do not need to be considered
# because ranges were sorted by increasing first index
set j $nUndoMarks
-
} else {
if {[$w compare $ir2 > $ir1]} {
# second range overlaps first range
# -> merge them into a single range
set indices [lreplace $indices end-1 end]
lappend indices $il1 $ir2
-
} else {
# second range is fully included in first range
# -> ignore it
-
}
# in both cases above, the second range shall be
# trimmed out from the list of ranges
set ind [lreplace $ind $j [expr {$j + 1}]]
incr j -2
incr nUndoMarks -2
-
}
-
}
-
}
return $indices
diff --git a/library/tk.tcl b/library/tk.tcl
index 757eb7a..311d316 100644
--- a/library/tk.tcl
+++ b/library/tk.tcl
@@ -11,7 +11,7 @@
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
# Verify that we have Tk binary and script components from the same release
-package require -exact Tk 8.7a2
+package require -exact Tk 8.7a4
# Create a ::tk namespace
namespace eval ::tk {
@@ -306,21 +306,21 @@ proc ::tk::EventMotifBindings {n1 dummy dummy} {
set op add
}
- event $op <<Cut>> <Control-Key-w> <Control-Lock-Key-W> <Shift-Key-Delete>
- event $op <<Copy>> <Meta-Key-w> <Meta-Lock-Key-W> <Control-Key-Insert>
- event $op <<Paste>> <Control-Key-y> <Control-Lock-Key-Y> <Shift-Key-Insert>
- event $op <<PrevChar>> <Control-Key-b> <Control-Lock-Key-B>
- event $op <<NextChar>> <Control-Key-f> <Control-Lock-Key-F>
- event $op <<PrevLine>> <Control-Key-p> <Control-Lock-Key-P>
- event $op <<NextLine>> <Control-Key-n> <Control-Lock-Key-N>
- event $op <<LineStart>> <Control-Key-a> <Control-Lock-Key-A>
- event $op <<LineEnd>> <Control-Key-e> <Control-Lock-Key-E>
- event $op <<SelectPrevChar>> <Control-Key-B> <Control-Lock-Key-b>
- event $op <<SelectNextChar>> <Control-Key-F> <Control-Lock-Key-f>
- event $op <<SelectPrevLine>> <Control-Key-P> <Control-Lock-Key-p>
- event $op <<SelectNextLine>> <Control-Key-N> <Control-Lock-Key-n>
- event $op <<SelectLineStart>> <Control-Key-A> <Control-Lock-Key-a>
- event $op <<SelectLineEnd>> <Control-Key-E> <Control-Lock-Key-e>
+ event $op <<Cut>> <Control-w> <Control-Lock-W> <Shift-Delete>
+ event $op <<Copy>> <Meta-w> <Meta-Lock-W> <Control-Insert>
+ event $op <<Paste>> <Control-y> <Control-Lock-Y> <Shift-Insert>
+ event $op <<PrevChar>> <Control-b> <Control-Lock-B>
+ event $op <<NextChar>> <Control-f> <Control-Lock-F>
+ event $op <<PrevLine>> <Control-p> <Control-Lock-P>
+ event $op <<NextLine>> <Control-n> <Control-Lock-N>
+ event $op <<LineStart>> <Control-a> <Control-Lock-A>
+ event $op <<LineEnd>> <Control-e> <Control-Lock-E>
+ event $op <<SelectPrevChar>> <Control-B> <Control-Lock-b>
+ event $op <<SelectNextChar>> <Control-F> <Control-Lock-f>
+ event $op <<SelectPrevLine>> <Control-P> <Control-Lock-p>
+ event $op <<SelectNextLine>> <Control-N> <Control-Lock-n>
+ event $op <<SelectLineStart>> <Control-A> <Control-Lock-a>
+ event $op <<SelectLineEnd>> <Control-E> <Control-Lock-e>
}
#----------------------------------------------------------------------
@@ -368,18 +368,18 @@ if {![llength [info command tk_chooseDirectory]]} {
switch -exact -- [tk windowingsystem] {
"x11" {
- event add <<Cut>> <Control-Key-x> <Key-F20> <Control-Lock-Key-X>
- event add <<Copy>> <Control-Key-c> <Key-F16> <Control-Lock-Key-C>
- event add <<Paste>> <Control-Key-v> <Key-F18> <Control-Lock-Key-V>
+ event add <<Cut>> <Control-x> <F20> <Control-Lock-X>
+ event add <<Copy>> <Control-c> <F16> <Control-Lock-C>
+ event add <<Paste>> <Control-v> <F18> <Control-Lock-V>
event add <<PasteSelection>> <ButtonRelease-2>
- event add <<Undo>> <Control-Key-z> <Control-Lock-Key-Z>
- event add <<Redo>> <Control-Key-Z> <Control-Lock-Key-z>
+ event add <<Undo>> <Control-z> <Control-Lock-Z>
+ event add <<Redo>> <Control-Z> <Control-Lock-z>
event add <<ContextMenu>> <Button-3>
# On Darwin/Aqua, buttons from left to right are 1,3,2. On Darwin/X11 with recent
# XQuartz as the X server, they are 1,2,3; other X servers may differ.
- event add <<SelectAll>> <Control-Key-slash>
- event add <<SelectNone>> <Control-Key-backslash>
+ event add <<SelectAll>> <Control-slash>
+ event add <<SelectNone>> <Control-backslash>
event add <<NextChar>> <Right>
event add <<SelectNextChar>> <Shift-Right>
event add <<PrevChar>> <Left>
@@ -400,7 +400,7 @@ switch -exact -- [tk windowingsystem] {
event add <<NextPara>> <Control-Down>
event add <<SelectPrevPara>> <Control-Shift-Up>
event add <<SelectNextPara>> <Control-Shift-Down>
- event add <<ToggleSelection>> <Control-ButtonPress-1>
+ event add <<ToggleSelection>> <Control-Button-1>
# Some OS's define a goofy (as in, not <Shift-Tab>) keysym that is
# returned when the user presses <Shift-Tab>. In order for tab
@@ -419,16 +419,16 @@ switch -exact -- [tk windowingsystem] {
set ::tk::AlwaysShowSelection 1
}
"win32" {
- event add <<Cut>> <Control-Key-x> <Shift-Key-Delete> <Control-Lock-Key-X>
- event add <<Copy>> <Control-Key-c> <Control-Key-Insert> <Control-Lock-Key-C>
- event add <<Paste>> <Control-Key-v> <Shift-Key-Insert> <Control-Lock-Key-V>
+ event add <<Cut>> <Control-x> <Shift-Delete> <Control-Lock-X>
+ event add <<Copy>> <Control-c> <Control-Insert> <Control-Lock-C>
+ event add <<Paste>> <Control-v> <Shift-Insert> <Control-Lock-V>
event add <<PasteSelection>> <ButtonRelease-2>
- event add <<Undo>> <Control-Key-z> <Control-Lock-Key-Z>
- event add <<Redo>> <Control-Key-y> <Control-Lock-Key-Y>
+ event add <<Undo>> <Control-z> <Control-Lock-Z>
+ event add <<Redo>> <Control-y> <Control-Lock-Y>
event add <<ContextMenu>> <Button-3>
- event add <<SelectAll>> <Control-Key-slash> <Control-Key-a> <Control-Lock-Key-A>
- event add <<SelectNone>> <Control-Key-backslash>
+ event add <<SelectAll>> <Control-slash> <Control-a> <Control-Lock-A>
+ event add <<SelectNone>> <Control-backslash>
event add <<NextChar>> <Right>
event add <<SelectNextChar>> <Shift-Right>
event add <<PrevChar>> <Left>
@@ -449,20 +449,19 @@ switch -exact -- [tk windowingsystem] {
event add <<NextPara>> <Control-Down>
event add <<SelectPrevPara>> <Control-Shift-Up>
event add <<SelectNextPara>> <Control-Shift-Down>
- event add <<ToggleSelection>> <Control-ButtonPress-1>
+ event add <<ToggleSelection>> <Control-Button-1>
}
"aqua" {
- event add <<Cut>> <Command-Key-x> <Key-F2> <Command-Lock-Key-X>
- event add <<Copy>> <Command-Key-c> <Key-F3> <Command-Lock-Key-C>
- event add <<Paste>> <Command-Key-v> <Key-F4> <Command-Lock-Key-V>
+ event add <<Cut>> <Command-x> <F2> <Command-Lock-X>
+ event add <<Copy>> <Command-c> <F3> <Command-Lock-C>
+ event add <<Paste>> <Command-v> <F4> <Command-Lock-V>
event add <<PasteSelection>> <ButtonRelease-3>
event add <<Clear>> <Clear>
event add <<ContextMenu>> <Button-2>
# Official bindings
# See http://support.apple.com/kb/HT1343
- event add <<SelectAll>> <Command-Key-a>
- event add <<SelectNone>> <Option-Command-Key-a>
+ event add <<SelectAll>> <Command-a>
event add <<Undo>> <Command-Key-z> <Command-Lock-Key-Z>
event add <<Redo>> <Shift-Command-Key-z> <Shift-Command-Lock-Key-z>
event add <<NextChar>> <Right> <Control-Key-f> <Control-Lock-Key-F>
@@ -473,21 +472,21 @@ switch -exact -- [tk windowingsystem] {
event add <<SelectNextWord>> <Shift-Option-Right>
event add <<PrevWord>> <Option-Left>
event add <<SelectPrevWord>> <Shift-Option-Left>
- event add <<LineStart>> <Home> <Command-Left> <Control-Key-a> <Control-Lock-Key-A>
- event add <<SelectLineStart>> <Shift-Home> <Shift-Command-Left> <Shift-Control-Key-A> <Shift-Control-Lock-Key-A>
- event add <<LineEnd>> <End> <Command-Right> <Control-Key-e> <Control-Lock-Key-E>
- event add <<SelectLineEnd>> <Shift-End> <Shift-Command-Right> <Shift-Control-Key-E> <Shift-Control-Lock-Key-E>
- event add <<PrevLine>> <Up> <Control-Key-p> <Control-Lock-Key-P>
- event add <<SelectPrevLine>> <Shift-Up> <Shift-Control-Key-P> <Shift-Control-Lock-Key-P>
- event add <<NextLine>> <Down> <Control-Key-n> <Control-Lock-Key-N>
- event add <<SelectNextLine>> <Shift-Down> <Shift-Control-Key-N> <Shift-Control-Lock-Key-N>
+ event add <<LineStart>> <Home> <Command-Left> <Control-a> <Control-Lock-A>
+ event add <<SelectLineStart>> <Shift-Home> <Shift-Command-Left> <Shift-Control-A> <Shift-Control-Lock-A>
+ event add <<LineEnd>> <End> <Command-Right> <Control-e> <Control-Lock-E>
+ event add <<SelectLineEnd>> <Shift-End> <Shift-Command-Right> <Shift-Control-E> <Shift-Control-Lock-E>
+ event add <<PrevLine>> <Up> <Control-p> <Control-Lock-P>
+ event add <<SelectPrevLine>> <Shift-Up> <Shift-Control-P> <Shift-Control-Lock-P>
+ event add <<NextLine>> <Down> <Control-n> <Control-Lock-N>
+ event add <<SelectNextLine>> <Shift-Down> <Shift-Control-N> <Shift-Control-Lock-N>
# Not official, but logical extensions of above. Also derived from
# bindings present in MS Word on OSX.
event add <<PrevPara>> <Option-Up>
event add <<NextPara>> <Option-Down>
event add <<SelectPrevPara>> <Shift-Option-Up>
event add <<SelectNextPara>> <Shift-Option-Down>
- event add <<ToggleSelection>> <Command-ButtonPress-1>
+ event add <<ToggleSelection>> <Command-Button-1>
}
}
@@ -676,7 +675,7 @@ proc ::tk::mcmaxamp {args} {
return $maxlen
}
-# For now, turn off the custom mdef proc for the mac:
+# For now, turn off the custom mdef proc for the Mac:
if {[tk windowingsystem] eq "aqua"} {
namespace eval ::tk::mac {
@@ -684,6 +683,22 @@ if {[tk windowingsystem] eq "aqua"} {
}
}
+
+if {[tk windowingsystem] eq "aqua"} {
+ #stub procedures to respond to "do script" Apple Events
+ proc ::tk::mac::DoScriptFile {file} {
+ source $file
+ }
+ proc ::tk::mac::DoScriptText {script} {
+ eval $script
+ }
+}
+
+# Create a dictionary to store the starting index of the IME marked
+# text in an Entry or Text widget.
+
+set ::tk::Priv(IMETextMark) [dict create]
+
# Run the Ttk themed widget set initialization
if {$::ttk::library ne ""} {
uplevel \#0 [list source $::ttk::library/ttk.tcl]
diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl
index f73fdc5..cf89287 100644
--- a/library/tkfbox.tcl
+++ b/library/tkfbox.tcl
@@ -463,7 +463,7 @@ proc ::tk::dialog::file::Create {w class} {
wm protocol $w WM_DELETE_WINDOW [list ::tk::dialog::file::CancelCmd $w]
$data(upBtn) configure -command [list ::tk::dialog::file::UpDirCmd $w]
$data(cancelBtn) configure -command [list ::tk::dialog::file::CancelCmd $w]
- bind $w <KeyPress-Escape> [list $data(cancelBtn) invoke]
+ bind $w <Escape> [list $data(cancelBtn) invoke]
bind $w <Alt-Key> [list tk::AltKeyInDialog $w %A]
# Set up event handlers specific to File or Directory Dialogs
diff --git a/library/ttk/aquaTheme.tcl b/library/ttk/aquaTheme.tcl
index a548d65..8bba226 100644
--- a/library/ttk/aquaTheme.tcl
+++ b/library/ttk/aquaTheme.tcl
@@ -7,45 +7,113 @@ namespace eval ttk::theme::aqua {
ttk::style configure . \
-font TkDefaultFont \
- -background systemWindowBody \
- -foreground systemModelessDialogActiveText \
- -selectbackground systemHighlight \
- -selectforeground systemModelessDialogActiveText \
+ -background systemWindowBackgroundColor \
+ -foreground systemLabelColor \
+ -selectbackground systemSelectedTextBackgroundColor \
+ -selectforeground systemSelectedTextColor \
-selectborderwidth 0 \
-insertwidth 1
ttk::style map . \
- -foreground {disabled systemModelessDialogInactiveText
- background systemModelessDialogInactiveText} \
- -selectbackground {background systemHighlightSecondary
- !focus systemHighlightSecondary} \
- -selectforeground {background systemModelessDialogInactiveText
- !focus systemDialogActiveText}
+ -foreground {
+ disabled systemDisabledControlTextColor
+ background systemLabelColor} \
+ -selectbackground {
+ background systemSelectedTextBackgroundColor
+ !focus systemSelectedTextBackgroundColor} \
+ -selectforeground {
+ background systemSelectedTextColor
+ !focus systemSelectedTextColor}
+
+ # Button
+ ttk::style configure TButton -anchor center -width -6 \
+ -foreground systemControlTextColor
+ ttk::style map TButton \
+ -foreground {
+ pressed white
+ {alternate !pressed !background} white}
+ ttk::style configure TMenubutton -anchor center -padding {2 0 0 2}
+ ttk::style configure Toolbutton -anchor center
+
+ # Entry
+ ttk::style configure TEntry \
+ -foreground systemTextColor \
+ -background systemTextBackgroundColor
+ ttk::style map TEntry \
+ -foreground {
+ disabled systemDisabledControlTextColor
+ } \
+ -selectforeground {
+ background systemTextColor
+ } \
+ -selectbackground {
+ background systemTextBackgroundColor
+ }
+
# Workaround for #1100117:
# Actually, on Aqua we probably shouldn't stipple images in
# disabled buttons even if it did work...
ttk::style configure . -stipple {}
- ttk::style configure TButton -anchor center -width -6
- ttk::style configure Toolbutton -padding 4
-
+ # Notebook
ttk::style configure TNotebook -tabmargins {10 0} -tabposition n
ttk::style configure TNotebook -padding {18 8 18 17}
ttk::style configure TNotebook.Tab -padding {12 3 12 2}
+ ttk::style configure TNotebook.Tab -foreground systemControlTextColor
+ ttk::style map TNotebook.Tab \
+ -foreground {
+ background systemControlTextColor
+ disabled systemDisabledControlTextColor
+ selected systemSelectedTabTextColor}
# Combobox:
- ttk::style configure TCombobox -postoffset {5 -2 -10 0}
+ ttk::style configure TCombobox \
+ -foreground systemTextColor \
+ -background systemTransparent
+ ttk::style map TCombobox \
+ -foreground {
+ disabled systemDisabledControlTextColor
+ } \
+ -selectforeground {
+ background systemTextColor
+ } \
+ -selectbackground {
+ background systemTransparent
+ }
+
+ # Spinbox
+ ttk::style configure TSpinbox \
+ -foreground systemTextColor \
+ -background systemTextBackgroundColor \
+ -selectforeground systemSelectedTextColor \
+ -selectbackground systemSelectedTextBackgroundColor
+ ttk::style map TSpinbox \
+ -foreground {
+ disabled systemDisabledControlTextColor
+ } \
+ -selectforeground {
+ !active systemTextColor
+ } \
+ -selectbackground {
+ !active systemTextBackgroundColor
+ !focus systemTextBackgroundColor
+ focus systemSelectedTextBackgroundColor
+ }
# Treeview:
- ttk::style configure Heading -font TkHeadingFont
- ttk::style configure Treeview -rowheight 18 -background White
+ ttk::style configure Heading \
+ -font TkHeadingFont \
+ -foreground systemTextColor \
+ -background systemWindowBackgroundColor
+ ttk::style configure Treeview -rowheight 18 \
+ -background systemTextBackgroundColor \
+ -foreground systemTextColor \
+ -fieldbackground systemTextBackgroundColor
ttk::style map Treeview \
- -background [list disabled systemDialogBackgroundInactive \
- {selected background} systemHighlightSecondary \
- selected systemHighlight] \
- -foreground [list disabled systemModelessDialogInactiveText \
- selected systemModelessDialogActiveText]
+ -background {
+ selected systemSelectedTextBackgroundColor
+ }
# Enable animation for ttk::progressbar widget:
ttk::style configure TProgressbar -period 100 -maxphase 255
diff --git a/library/ttk/button.tcl b/library/ttk/button.tcl
index 24065c2..e8c24a1 100644
--- a/library/ttk/button.tcl
+++ b/library/ttk/button.tcl
@@ -9,7 +9,7 @@
# we get a <Leave> event then, which turns off the "active" state)
#
# Normally, <ButtonRelease> and <ButtonN-Enter/Leave> events are
-# delivered to the widget which received the initial <ButtonPress>
+# delivered to the widget which received the initial <Button>
# event. However, Tk [grab]s (#1223103) and menu interactions
# (#1222605) can interfere with this. To guard against spurious
# <Button1-Enter> events, the <Button1-Enter> binding only sets
@@ -20,10 +20,10 @@ namespace eval ttk::button {}
bind TButton <Enter> { %W instate !disabled {%W state active} }
bind TButton <Leave> { %W state !active }
-bind TButton <Key-space> { ttk::button::activate %W }
+bind TButton <space> { ttk::button::activate %W }
bind TButton <<Invoke>> { ttk::button::activate %W }
-bind TButton <ButtonPress-1> \
+bind TButton <Button-1> \
{ %W instate !disabled { ttk::clickToFocus %W; %W state pressed } }
bind TButton <ButtonRelease-1> \
{ %W instate pressed { %W state !pressed; %W instate !disabled { %W invoke } } }
@@ -39,11 +39,11 @@ ttk::copyBindings TButton TRadiobutton
# ...plus a few more:
-bind TRadiobutton <KeyPress-Up> { ttk::button::RadioTraverse %W -1 }
-bind TRadiobutton <KeyPress-Down> { ttk::button::RadioTraverse %W +1 }
+bind TRadiobutton <Up> { ttk::button::RadioTraverse %W -1 }
+bind TRadiobutton <Down> { ttk::button::RadioTraverse %W +1 }
-# bind TCheckbutton <KeyPress-plus> { %W select }
-# bind TCheckbutton <KeyPress-minus> { %W deselect }
+# bind TCheckbutton <plus> { %W select }
+# bind TCheckbutton <minus> { %W deselect }
# activate --
# Simulate a button press: temporarily set the state to 'pressed',
diff --git a/library/ttk/combobox.tcl b/library/ttk/combobox.tcl
index c1b6da6..9af8c59 100644
--- a/library/ttk/combobox.tcl
+++ b/library/ttk/combobox.tcl
@@ -45,13 +45,13 @@ namespace eval ttk::combobox {
ttk::copyBindings TEntry TCombobox
-bind TCombobox <KeyPress-Down> { ttk::combobox::Post %W }
-bind TCombobox <KeyPress-Escape> { ttk::combobox::Unpost %W }
+bind TCombobox <Down> { ttk::combobox::Post %W }
+bind TCombobox <Escape> { ttk::combobox::Unpost %W }
-bind TCombobox <ButtonPress-1> { ttk::combobox::Press "" %W %x %y }
-bind TCombobox <Shift-ButtonPress-1> { ttk::combobox::Press "s" %W %x %y }
-bind TCombobox <Double-ButtonPress-1> { ttk::combobox::Press "2" %W %x %y }
-bind TCombobox <Triple-ButtonPress-1> { ttk::combobox::Press "3" %W %x %y }
+bind TCombobox <Button-1> { ttk::combobox::Press "" %W %x %y }
+bind TCombobox <Shift-Button-1> { ttk::combobox::Press "s" %W %x %y }
+bind TCombobox <Double-Button-1> { ttk::combobox::Press "2" %W %x %y }
+bind TCombobox <Triple-Button-1> { ttk::combobox::Press "3" %W %x %y }
bind TCombobox <B1-Motion> { ttk::combobox::Drag %W %x }
bind TCombobox <Motion> { ttk::combobox::Motion %W %x %y }
@@ -62,9 +62,9 @@ bind TCombobox <<TraverseIn>> { ttk::combobox::TraverseIn %W }
### Combobox listbox bindings.
#
bind ComboboxListbox <ButtonRelease-1> { ttk::combobox::LBSelected %W }
-bind ComboboxListbox <KeyPress-Return> { ttk::combobox::LBSelected %W }
-bind ComboboxListbox <KeyPress-Escape> { ttk::combobox::LBCancel %W }
-bind ComboboxListbox <KeyPress-Tab> { ttk::combobox::LBTab %W next }
+bind ComboboxListbox <Return> { ttk::combobox::LBSelected %W }
+bind ComboboxListbox <Escape> { ttk::combobox::LBCancel %W }
+bind ComboboxListbox <Tab> { ttk::combobox::LBTab %W next }
bind ComboboxListbox <<PrevWindow>> { ttk::combobox::LBTab %W prev }
bind ComboboxListbox <Destroy> { ttk::combobox::LBCleanup %W }
bind ComboboxListbox <Motion> { ttk::combobox::LBHover %W %x %y }
@@ -82,7 +82,7 @@ switch -- [tk windowingsystem] {
#
bind ComboboxPopdown <Map> { ttk::combobox::MapPopdown %W }
bind ComboboxPopdown <Unmap> { ttk::combobox::UnmapPopdown %W }
-bind ComboboxPopdown <ButtonPress> \
+bind ComboboxPopdown <Button> \
{ ttk::combobox::Unpost [winfo parent %W] }
### Option database settings.
@@ -106,7 +106,7 @@ switch -- [tk windowingsystem] {
### Binding procedures.
#
-## Press $mode $x $y -- ButtonPress binding for comboboxes.
+## Press $mode $x $y -- Button binding for comboboxes.
# Either post/unpost the listbox, or perform Entry widget binding,
# depending on widget state and location of button press.
#
@@ -135,7 +135,7 @@ proc ttk::combobox::Press {mode w x y} {
}
## Drag -- B1-Motion binding for comboboxes.
-# If the initial ButtonPress event was handled by Entry binding,
+# If the initial Button event was handled by Entry binding,
# perform Entry widget drag binding; otherwise nothing.
#
proc ttk::combobox::Drag {w x} {
@@ -149,12 +149,14 @@ proc ttk::combobox::Drag {w x} {
# Set cursor.
#
proc ttk::combobox::Motion {w x y} {
+ variable State
+ ttk::saveCursor $w State(userConfCursor) [ttk::cursor text]
if { [$w identify $x $y] eq "textarea"
&& [$w instate {!readonly !disabled}]
} {
ttk::setCursor $w text
} else {
- ttk::setCursor $w ""
+ ttk::setCursor $w $State(userConfCursor)
}
}
@@ -251,30 +253,16 @@ proc ttk::combobox::UnmapPopdown {w} {
ttk::releaseGrab $w
}
-###
-#
-
-namespace eval ::ttk::combobox {
- # @@@ Until we have a proper native scrollbar on Aqua, use
- # @@@ the regular Tk one. Use ttk::scrollbar on other platforms.
- variable scrollbar ttk::scrollbar
- if {[tk windowingsystem] eq "aqua"} {
- set scrollbar ::scrollbar
- }
-}
-
## PopdownWindow --
# Returns the popdown widget associated with a combobox,
# creating it if necessary.
#
proc ttk::combobox::PopdownWindow {cb} {
- variable scrollbar
-
if {![winfo exists $cb.popdown]} {
set poplevel [PopdownToplevel $cb.popdown]
set popdown [ttk::frame $poplevel.f -style ComboboxPopdownFrame]
- $scrollbar $popdown.sb \
+ ttk::scrollbar $popdown.sb \
-orient vertical -command [list $popdown.l yview]
listbox $popdown.l \
-listvariable ttk::combobox::Values($cb) \
diff --git a/library/ttk/cursors.tcl b/library/ttk/cursors.tcl
index 75f7791..9d1e1ae 100644
--- a/library/ttk/cursors.tcl
+++ b/library/ttk/cursors.tcl
@@ -99,23 +99,20 @@ namespace eval ttk {
}
"aqua" {
- if {[package vsatisfies [package provide Tk] 8.5]} {
- # appeared 2007-04-23, Tk 8.5a6
- array set Cursors {
- standard arrow
- text ibeam
- link pointinghand
- crosshair crosshair
- busy watch
- forbidden notallowed
-
- hresize resizeleftright
- vresize resizeupdown
- nresize resizeup
- sresize resizedown
- wresize resizeleft
- eresize resizeright
- }
+ array set Cursors {
+ standard arrow
+ text ibeam
+ link pointinghand
+ crosshair crosshair
+ busy watch
+ forbidden notallowed
+
+ hresize resizeleftright
+ vresize resizeupdown
+ nresize resizeup
+ sresize resizedown
+ wresize resizeleft
+ eresize resizeright
}
}
}
@@ -140,8 +137,30 @@ proc ttk::cursor {name} {
proc ttk::setCursor {w name} {
variable Cursors
- if {[$w cget -cursor] ne $Cursors($name)} {
- $w configure -cursor $Cursors($name)
+ if {[info exists Cursors($name)]} {
+ set cursorname $Cursors($name)
+ } else {
+ set cursorname $name
+ }
+ if {[$w cget -cursor] ne $cursorname} {
+ $w configure -cursor $cursorname
+ }
+}
+
+## ttk::saveCursor $w $saveVar $excludeList --
+# Set variable $saveVar to the -cursor value from widget $w,
+# if either:
+# a. $saveVar does not yet exist
+# b. the currently user-specified cursor for $w is not in
+# $excludeList
+
+proc ttk::saveCursor {w saveVar excludeList} {
+ upvar $saveVar sv
+ if {![info exists sv]} {
+ set sv [$w cget -cursor]
+ }
+ if {[$w cget -cursor] ni $excludeList} {
+ set sv [$w cget -cursor]
}
}
@@ -179,7 +198,7 @@ proc ttk::CursorSampler {f} {
if {[info exists argv0] && $argv0 eq [info script]} {
wm title . "[array size ::ttk::Cursors] cursors"
pack [ttk::CursorSampler .f] -expand true -fill both
- bind . <KeyPress-Escape> [list destroy .]
+ bind . <Escape> [list destroy .]
focus .f
}
diff --git a/library/ttk/entry.tcl b/library/ttk/entry.tcl
index c123bc9..4cdb5ac 100644
--- a/library/ttk/entry.tcl
+++ b/library/ttk/entry.tcl
@@ -40,20 +40,20 @@ option add *TEntry.cursor [ttk::cursor text] widgetDefault
#
# Removed the following standard Tk bindings:
#
-# <Control-Key-space>, <Control-Shift-Key-space>,
-# <Key-Select>, <Shift-Key-Select>:
+# <Control-space>, <Control-Shift-space>,
+# <Select>, <Shift-Select>:
# Ttk entry widget doesn't use selection anchor.
-# <Key-Insert>:
+# <Insert>:
# Inserts PRIMARY selection (on non-Windows platforms).
# This is inconsistent with typical platform bindings.
-# <Double-Shift-ButtonPress-1>, <Triple-Shift-ButtonPress-1>:
+# <Double-Shift-Button-1>, <Triple-Shift-Button-1>:
# These don't do the right thing to start with.
-# <Meta-Key-b>, <Meta-Key-d>, <Meta-Key-f>,
-# <Meta-Key-BackSpace>, <Meta-Key-Delete>:
+# <Meta-b>, <Meta-d>, <Meta-f>,
+# <Meta-BackSpace>, <Meta-Delete>:
# Judgment call. If <Meta> happens to be assigned to the Alt key,
# these could conflict with application accelerators.
# (Plus, who has a Meta key these days?)
-# <Control-Key-t>:
+# <Control-t>:
# Another judgment call. If anyone misses this, let me know
# and I'll put it back.
#
@@ -68,27 +68,34 @@ bind TEntry <<Clear>> { ttk::entry::Clear %W }
## Button1 bindings:
# Used for selection and navigation.
#
-bind TEntry <ButtonPress-1> { ttk::entry::Press %W %x }
-bind TEntry <Shift-ButtonPress-1> { ttk::entry::Shift-Press %W %x }
-bind TEntry <Double-ButtonPress-1> { ttk::entry::Select %W %x word }
-bind TEntry <Triple-ButtonPress-1> { ttk::entry::Select %W %x line }
+bind TEntry <Button-1> { ttk::entry::Press %W %x }
+bind TEntry <Shift-Button-1> { ttk::entry::Shift-Press %W %x }
+bind TEntry <Double-Button-1> { ttk::entry::Select %W %x word }
+bind TEntry <Triple-Button-1> { ttk::entry::Select %W %x line }
bind TEntry <B1-Motion> { ttk::entry::Drag %W %x }
-bind TEntry <B1-Leave> { ttk::entry::DragOut %W %m }
-bind TEntry <B1-Enter> { ttk::entry::DragIn %W }
-bind TEntry <ButtonRelease-1> { ttk::entry::Release %W }
+bind TEntry <B1-Leave> { ttk::entry::DragOut %W %m }
+bind TEntry <B1-Enter> { ttk::entry::DragIn %W }
+bind TEntry <ButtonRelease-1> { ttk::entry::Release %W }
bind TEntry <<ToggleSelection>> {
%W instate {!readonly !disabled} { %W icursor @%x ; focus %W }
}
-## Button2 bindings:
+## Button2 (Button3 on Aqua) bindings:
# Used for scanning and primary transfer.
-# Note: ButtonRelease-2 is mapped to <<PasteSelection>> in tk.tcl.
-#
-bind TEntry <ButtonPress-2> { ttk::entry::ScanMark %W %x }
-bind TEntry <B2-Motion> { ttk::entry::ScanDrag %W %x }
-bind TEntry <ButtonRelease-2> { ttk::entry::ScanRelease %W %x }
+# Note: ButtonRelease-2 (ButtonRelease-3 on Aqua)
+# is mapped to <<PasteSelection>> in tk.tcl.
+#
+if {[tk windowingsystem] ne "aqua"} {
+ bind TEntry <Button-2> { ttk::entry::ScanMark %W %x }
+ bind TEntry <B2-Motion> { ttk::entry::ScanDrag %W %x }
+ bind TEntry <ButtonRelease-2> { ttk::entry::ScanRelease %W %x }
+} else {
+ bind TEntry <Button-3> { ttk::entry::ScanMark %W %x }
+ bind TEntry <B3-Motion> { ttk::entry::ScanDrag %W %x }
+ bind TEntry <ButtonRelease-3> { ttk::entry::ScanRelease %W %x }
+}
bind TEntry <<PasteSelection>> { ttk::entry::ScanRelease %W %x }
## Keyboard navigation bindings:
@@ -114,26 +121,26 @@ bind TEntry <<TraverseIn>> { %W selection range 0 end; %W icursor end }
## Edit bindings:
#
-bind TEntry <KeyPress> { ttk::entry::Insert %W %A }
-bind TEntry <Key-Delete> { ttk::entry::Delete %W }
-bind TEntry <Key-BackSpace> { ttk::entry::Backspace %W }
+bind TEntry <Key> { ttk::entry::Insert %W %A }
+bind TEntry <Delete> { ttk::entry::Delete %W }
+bind TEntry <BackSpace> { ttk::entry::Backspace %W }
# Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
-# Otherwise, the <KeyPress> class binding will fire and insert the character.
+# Otherwise, the <Key> class binding will fire and insert the character.
# Ditto for Escape, Return, and Tab.
#
-bind TEntry <Alt-KeyPress> {# nothing}
-bind TEntry <Meta-KeyPress> {# nothing}
-bind TEntry <Control-KeyPress> {# nothing}
-bind TEntry <Key-Escape> {# nothing}
-bind TEntry <Key-Return> {# nothing}
-bind TEntry <Key-KP_Enter> {# nothing}
-bind TEntry <Key-Tab> {# nothing}
+bind TEntry <Alt-Key> {# nothing}
+bind TEntry <Meta-Key> {# nothing}
+bind TEntry <Control-Key> {# nothing}
+bind TEntry <Escape> {# nothing}
+bind TEntry <Return> {# nothing}
+bind TEntry <KP_Enter> {# nothing}
+bind TEntry <Tab> {# nothing}
# Argh. Apparently on Windows, the NumLock modifier is interpreted
# as a Command modifier.
if {[tk windowingsystem] eq "aqua"} {
- bind TEntry <Command-KeyPress> {# nothing}
+ bind TEntry <Command-Key> {# nothing}
}
# Tk-on-Cocoa generates characters for these two keys. [Bug 2971663]
bind TEntry <<PrevLine>> {# nothing}
@@ -141,9 +148,28 @@ bind TEntry <<NextLine>> {# nothing}
## Additional emacs-like bindings:
#
-bind TEntry <Control-Key-d> { ttk::entry::Delete %W }
-bind TEntry <Control-Key-h> { ttk::entry::Backspace %W }
-bind TEntry <Control-Key-k> { %W delete insert end }
+bind TEntry <Control-d> { ttk::entry::Delete %W }
+bind TEntry <Control-h> { ttk::entry::Backspace %W }
+bind TEntry <Control-k> { %W delete insert end }
+
+# Bindings for IME text input.
+
+bind TEntry <<TkStartIMEMarkedText>> {
+ dict set ::tk::Priv(IMETextMark) "%W" [%W index insert]
+}
+bind TEntry <<TkEndIMEMarkedText>> {
+ if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } {
+ bell
+ } else {
+ %W selection range $mark insert
+ }
+}
+bind TEntry <<TkClearIMEMarkedText>> {
+ %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert]
+}
+bind TEntry <<TkAccentBackspace>> {
+ ttk::entry::Backspace %W
+}
### Clipboard procedures.
#
@@ -211,7 +237,6 @@ proc ttk::entry::ClosestGap {w x} {
## See $index -- Make sure that the character at $index is visible.
#
proc ttk::entry::See {w {index insert}} {
- update idletasks ;# ensure scroll data up-to-date
set c [$w index $index]
# @@@ OR: check [$w index left] / [$w index right]
if {$c < [$w index @0] || $c >= [$w index @[winfo width $w]]} {
@@ -333,7 +358,7 @@ proc ttk::entry::Extend {w where} {
# Triple-clicking enters "line-select" mode.
#
-## Press -- ButtonPress-1 binding.
+## Press -- Button-1 binding.
# Set the insertion cursor, claim the input focus, set up for
# future drag operations.
#
@@ -350,7 +375,7 @@ proc ttk::entry::Press {w x} {
set State(anchor) [$w index insert]
}
-## Shift-Press -- Shift-ButtonPress-1 binding.
+## Shift-Press -- Shift-Button-1 binding.
# Extends the selection, sets anchor for future drag operations.
#
proc ttk::entry::Shift-Press {w x} {
@@ -499,7 +524,7 @@ proc ttk::entry::LineSelect {w _ _} {
### Button 2 binding procedures.
#
-## ScanMark -- ButtonPress-2 binding.
+## ScanMark -- Button-2 binding.
# Marks the start of a scan or primary transfer operation.
#
proc ttk::entry::ScanMark {w x} {
diff --git a/library/ttk/fonts.tcl b/library/ttk/fonts.tcl
index a2781c6..d819973 100644
--- a/library/ttk/fonts.tcl
+++ b/library/ttk/fonts.tcl
@@ -53,10 +53,6 @@
# Most other toolkits use medium weight for all UI elements,
# which is what we do now.
#
-# Font size specified in pixels on X11, not points.
-# This is Theoretically Wrong, but in practice works better; using
-# points leads to huge inconsistencies across different servers.
-#
namespace eval ttk {
@@ -131,10 +127,10 @@ switch -- [tk windowingsystem] {
set F(family) "Helvetica"
set F(fixed) "courier"
}
- set F(size) -12
- set F(ttsize) -10
- set F(capsize) -14
- set F(fixedsize) -12
+ set F(size) 10
+ set F(ttsize) 9
+ set F(capsize) 12
+ set F(fixedsize) 10
font configure TkDefaultFont -family $F(family) -size $F(size)
font configure TkTextFont -family $F(family) -size $F(size)
diff --git a/library/ttk/menubutton.tcl b/library/ttk/menubutton.tcl
index 648cdee..08b4a15 100644
--- a/library/ttk/menubutton.tcl
+++ b/library/ttk/menubutton.tcl
@@ -5,7 +5,7 @@
#
# Pulldown: Press menubutton, drag over menu, release to activate menu entry
# Popdown: Click menubutton to post menu
-# Keyboard: <Key-space> or accelerator key to post menu
+# Keyboard: <space> or accelerator key to post menu
#
# (In addition, when menu system is active, "dropdown" -- menu posts
# on mouse-over. Ttk menubuttons don't implement this).
@@ -19,7 +19,7 @@
# This won't work for Ttk menubuttons in pulldown mode,
# since we need to process the final <ButtonRelease> event,
# and this might be delivered to the menu. So instead we
-# rely on the passive grab that occurs on <ButtonPress> events,
+# rely on the passive grab that occurs on <Button> events,
# and transition to popdown mode when the mouse is released
# or dragged outside the menubutton.
#
@@ -46,58 +46,127 @@ namespace eval ttk {
bind TMenubutton <Enter> { %W instate !disabled {%W state active } }
bind TMenubutton <Leave> { %W state !active }
-bind TMenubutton <Key-space> { ttk::menubutton::Popdown %W }
+bind TMenubutton <space> { ttk::menubutton::Popdown %W }
bind TMenubutton <<Invoke>> { ttk::menubutton::Popdown %W }
if {[tk windowingsystem] eq "x11"} {
- bind TMenubutton <ButtonPress-1> { ttk::menubutton::Pulldown %W }
+ bind TMenubutton <Button-1> { ttk::menubutton::Pulldown %W }
bind TMenubutton <ButtonRelease-1> { ttk::menubutton::TransferGrab %W }
bind TMenubutton <B1-Leave> { ttk::menubutton::TransferGrab %W }
} else {
- bind TMenubutton <ButtonPress-1> \
+ bind TMenubutton <Button-1> \
{ %W state pressed ; ttk::menubutton::Popdown %W }
bind TMenubutton <ButtonRelease-1> \
{ if {[winfo exists %W]} { %W state !pressed } }
}
# PostPosition --
-# Returns the x and y coordinates where the menu
-# should be posted, based on the menubutton and menu size
-# and -direction option.
+# Returns x and y coordinates and a menu item index.
+# If the index is not an empty string the menu should
+# be posted so that the upper left corner of the indexed
+# menu item is located at the point (x, y). Otherwise
+# the top left corner of the menu itself should be located
+# at that point.
#
# TODO: adjust menu width to be at least as wide as the button
# for -direction above, below.
#
-proc ttk::menubutton::PostPosition {mb menu} {
- set x [winfo rootx $mb]
- set y [winfo rooty $mb]
- set dir [$mb cget -direction]
- set bw [winfo width $mb]
- set bh [winfo height $mb]
- set mw [winfo reqwidth $menu]
- set mh [winfo reqheight $menu]
- set sw [expr {[winfo screenwidth $menu] - $bw - $mw}]
- set sh [expr {[winfo screenheight $menu] - $bh - $mh}]
-
- switch -- $dir {
- above { if {$y >= $mh} { incr y -$mh } { incr y $bh } }
- below { if {$y <= $sh} { incr y $bh } { incr y -$mh } }
- left { if {$x >= $mw} { incr x -$mw } { incr x $bw } }
- right { if {$x <= $sw} { incr x $bw } { incr x -$mw } }
- flush {
- # post menu atop menubutton.
- # If there's a menu entry whose label matches the
- # menubutton -text, assume this is an optionmenu
- # and place that entry over the menubutton.
- set index [FindMenuEntry $menu [$mb cget -text]]
- if {$index ne ""} {
- incr y -[$menu yposition $index]
+if {[tk windowingsystem] eq "aqua"} {
+ proc ::ttk::menubutton::PostPosition {mb menu} {
+ set menuPad 5
+ set buttonPad 1
+ set bevelPad 4
+ set mh [winfo reqheight $menu]
+ set bh [expr {[winfo height $mb]} + $buttonPad]
+ set bbh [expr {[winfo height $mb]} + $bevelPad]
+ set mw [winfo reqwidth $menu]
+ set bw [winfo width $mb]
+ set dF [expr {[winfo width $mb] - [winfo reqwidth $menu] - $menuPad}]
+ set entry ""
+ set entry [::tk::MenuFindName $menu [$mb cget -text]]
+ if {$entry eq ""} {
+ set entry 0
+ }
+ set x [winfo rootx $mb]
+ set y [winfo rooty $mb]
+ switch [$mb cget -direction] {
+ above {
+ set entry ""
+ incr y [expr {-$mh + 2 * $menuPad}]
+ }
+ below {
+ set entry ""
+ incr y $bh
+ }
+ left {
+ incr y $menuPad
+ incr x -$mw
+ }
+ right {
+ incr y $menuPad
+ incr x $bw
+ }
+ default {
+ incr y $bbh
}
}
+ return [list $x $y $entry]
+ }
+} else {
+ proc ::ttk::menubutton::PostPosition {mb menu} {
+ set mh [expr {[winfo reqheight $menu]}]
+ set bh [expr {[winfo height $mb]}]
+ set mw [expr {[winfo reqwidth $menu]}]
+ set bw [expr {[winfo width $mb]}]
+ set dF [expr {[winfo width $mb] - [winfo reqwidth $menu]}]
+ if {[tk windowingsystem] eq "win32"} {
+ incr mh 6
+ incr mw 16
+ }
+ set entry {}
+ set entry [::tk::MenuFindName $menu [$mb cget -text]]
+ if {$entry eq {}} {
+ set entry 0
+ }
+ set x [winfo rootx $mb]
+ set y [winfo rooty $mb]
+ switch [$mb cget -direction] {
+ above {
+ set entry {}
+ incr y -$mh
+ # if we go offscreen to the top, show as 'below'
+ if {$y < [winfo vrooty $mb]} {
+ set y [expr {[winfo vrooty $mb] + [winfo rooty $mb]\
+ + [winfo reqheight $mb]}]
+ }
+ }
+ below {
+ set entry {}
+ incr y $bh
+ # if we go offscreen to the bottom, show as 'above'
+ if {($y + $mh) > ([winfo vrooty $mb] + [winfo vrootheight $mb])} {
+ set y [expr {[winfo vrooty $mb] + [winfo vrootheight $mb] \
+ + [winfo rooty $mb] - $mh}]
+ }
+ }
+ left {
+ incr x -$mw
+ }
+ right {
+ incr x $bw
+ }
+ default {
+ if {[$mb cget -style] eq ""} {
+ incr x [expr {([winfo width $mb] - \
+ [winfo reqwidth $menu])/ 2}]
+ } else {
+ incr y $bh
+ }
+ }
+ }
+ return [list $x $y $entry]
}
-
- return [list $x $y]
}
# Popdown --
@@ -107,8 +176,8 @@ proc ttk::menubutton::Popdown {mb} {
if {[$mb instate disabled] || [set menu [$mb cget -menu]] eq ""} {
return
}
- foreach {x y} [PostPosition $mb $menu] { break }
- tk_popup $menu $x $y
+ foreach {x y entry} [PostPosition $mb $menu] { break }
+ tk_popup $menu $x $y $entry
}
# Pulldown (X11 only) --
@@ -121,13 +190,17 @@ proc ttk::menubutton::Pulldown {mb} {
if {[$mb instate disabled] || [set menu [$mb cget -menu]] eq ""} {
return
}
- foreach {x y} [PostPosition $mb $menu] { break }
set State(pulldown) 1
set State(oldcursor) [$mb cget -cursor]
$mb state pressed
$mb configure -cursor [$menu cget -cursor]
- $menu post $x $y
+ foreach {x y entry} [PostPosition $mb $menu] { break }
+ if {$entry ne {}} {
+ $menu post $x $y $entry
+ } else {
+ $menu post $x $y
+ }
tk_menuSetFocus $menu
}
@@ -143,6 +216,7 @@ proc ttk::menubutton::TransferGrab {mb} {
set State(pulldown) 0
set menu [$mb cget -menu]
+ foreach {x y entry} [PostPosition $mb $menu] { break }
tk_popup $menu [winfo rootx $menu] [winfo rooty $menu]
}
}
diff --git a/library/ttk/notebook.tcl b/library/ttk/notebook.tcl
index 92efe40..c5340a5 100644
--- a/library/ttk/notebook.tcl
+++ b/library/ttk/notebook.tcl
@@ -6,11 +6,11 @@ namespace eval ttk::notebook {
variable TLNotebooks ;# See enableTraversal
}
-bind TNotebook <ButtonPress-1> { ttk::notebook::Press %W %x %y }
-bind TNotebook <Key-Right> { ttk::notebook::CycleTab %W 1; break }
-bind TNotebook <Key-Left> { ttk::notebook::CycleTab %W -1; break }
-bind TNotebook <Control-Key-Tab> { ttk::notebook::CycleTab %W 1; break }
-bind TNotebook <Control-Shift-Key-Tab> { ttk::notebook::CycleTab %W -1; break }
+bind TNotebook <Button-1> { ttk::notebook::Press %W %x %y }
+bind TNotebook <Right> { ttk::notebook::CycleTab %W 1; break }
+bind TNotebook <Left> { ttk::notebook::CycleTab %W -1; break }
+bind TNotebook <Control-Tab> { ttk::notebook::CycleTab %W 1; break }
+bind TNotebook <Control-Shift-Tab> { ttk::notebook::CycleTab %W -1; break }
catch {
bind TNotebook <Control-ISO_Left_Tab> { ttk::notebook::CycleTab %W -1; break }
}
@@ -43,7 +43,7 @@ proc ttk::notebook::ActivateTab {w tab} {
}
# Press $nb $x $y --
-# ButtonPress-1 binding for notebook widgets.
+# Button-1 binding for notebook widgets.
# Activate the tab under the mouse cursor, if any.
#
proc ttk::notebook::Press {w x y} {
@@ -105,18 +105,18 @@ proc ttk::notebook::enableTraversal {nb} {
if {![info exists TLNotebooks($top)]} {
# Augment $top bindings:
#
- bind $top <Control-Key-Next> {+ttk::notebook::TLCycleTab %W 1}
- bind $top <Control-Key-Prior> {+ttk::notebook::TLCycleTab %W -1}
- bind $top <Control-Key-Tab> {+ttk::notebook::TLCycleTab %W 1}
- bind $top <Control-Shift-Key-Tab> {+ttk::notebook::TLCycleTab %W -1}
+ bind $top <Control-Next> {+ttk::notebook::TLCycleTab %W 1}
+ bind $top <Control-Prior> {+ttk::notebook::TLCycleTab %W -1}
+ bind $top <Control-Tab> {+ttk::notebook::TLCycleTab %W 1}
+ bind $top <Control-Shift-Tab> {+ttk::notebook::TLCycleTab %W -1}
catch {
- bind $top <Control-Key-ISO_Left_Tab> {+ttk::notebook::TLCycleTab %W -1}
+ bind $top <Control-ISO_Left_Tab> {+ttk::notebook::TLCycleTab %W -1}
}
if {[tk windowingsystem] eq "aqua"} {
- bind $top <Option-KeyPress> \
+ bind $top <Option-Key> \
+[list ttk::notebook::MnemonicActivation $top %K]
} else {
- bind $top <Alt-KeyPress> \
+ bind $top <Alt-Key> \
+[list ttk::notebook::MnemonicActivation $top %K]
}
bind $top <Destroy> {+ttk::notebook::TLCleanup %W}
@@ -182,7 +182,7 @@ proc ttk::notebook::TLCycleTab {w dir} {
}
# MnemonicActivation $nb $key --
-# Alt-KeyPress binding procedure for mnemonic activation.
+# Alt-Key binding procedure for mnemonic activation.
# Scan all notebooks in specified toplevel for a tab with the
# the specified mnemonic. If found, activate it and return TCL_BREAK.
#
diff --git a/library/ttk/panedwindow.tcl b/library/ttk/panedwindow.tcl
index a2e073b..0fd9bd7 100644
--- a/library/ttk/panedwindow.tcl
+++ b/library/ttk/panedwindow.tcl
@@ -15,7 +15,7 @@ namespace eval ttk::panedwindow {
## Bindings:
#
-bind TPanedwindow <ButtonPress-1> { ttk::panedwindow::Press %W %x %y }
+bind TPanedwindow <Button-1> { ttk::panedwindow::Press %W %x %y }
bind TPanedwindow <B1-Motion> { ttk::panedwindow::Drag %W %x %y }
bind TPanedwindow <ButtonRelease-1> { ttk::panedwindow::Release %W %x %y }
@@ -62,13 +62,22 @@ proc ttk::panedwindow::Release {w x y} {
#
proc ttk::panedwindow::ResetCursor {w} {
variable State
+
+ ttk::saveCursor $w State(userConfCursor) \
+ [list [ttk::cursor hresize] [ttk::cursor vresize]]
+
if {!$State(pressed)} {
- ttk::setCursor $w {}
+ ttk::setCursor $w $State(userConfCursor)
}
}
proc ttk::panedwindow::SetCursor {w x y} {
- set cursor ""
+ variable State
+
+ ttk::saveCursor $w State(userConfCursor) \
+ [list [ttk::cursor hresize] [ttk::cursor vresize]]
+
+ set cursor $State(userConfCursor)
if {[llength [$w identify $x $y]]} {
# Assume we're over a sash.
switch -- [$w cget -orient] {
diff --git a/library/ttk/scale.tcl b/library/ttk/scale.tcl
index 62c85bf..61c4136 100644
--- a/library/ttk/scale.tcl
+++ b/library/ttk/scale.tcl
@@ -9,15 +9,15 @@ namespace eval ttk::scale {
}
}
-bind TScale <ButtonPress-1> { ttk::scale::Press %W %x %y }
+bind TScale <Button-1> { ttk::scale::Press %W %x %y }
bind TScale <B1-Motion> { ttk::scale::Drag %W %x %y }
bind TScale <ButtonRelease-1> { ttk::scale::Release %W %x %y }
-bind TScale <ButtonPress-2> { ttk::scale::Jump %W %x %y }
+bind TScale <Button-2> { ttk::scale::Jump %W %x %y }
bind TScale <B2-Motion> { ttk::scale::Drag %W %x %y }
bind TScale <ButtonRelease-2> { ttk::scale::Release %W %x %y }
-bind TScale <ButtonPress-3> { ttk::scale::Jump %W %x %y }
+bind TScale <Button-3> { ttk::scale::Jump %W %x %y }
bind TScale <B3-Motion> { ttk::scale::Drag %W %x %y }
bind TScale <ButtonRelease-3> { ttk::scale::Release %W %x %y }
@@ -52,7 +52,7 @@ proc ttk::scale::Press {w x y} {
}
}
-# scale::Jump -- ButtonPress-2/3 binding for scale acts like
+# scale::Jump -- Button-2/3 binding for scale acts like
# Press except that clicking in the trough jumps to the
# clicked position.
proc ttk::scale::Jump {w x y} {
diff --git a/library/ttk/scrollbar.tcl b/library/ttk/scrollbar.tcl
index 17d729d..7537491 100644
--- a/library/ttk/scrollbar.tcl
+++ b/library/ttk/scrollbar.tcl
@@ -2,24 +2,6 @@
# Bindings for TScrollbar widget
#
-# Still don't have a working ttk::scrollbar under OSX -
-# Swap in a [tk::scrollbar] on that platform,
-# unless user specifies -class or -style.
-#
-if {[tk windowingsystem] eq "aqua"} {
- rename ::ttk::scrollbar ::ttk::_scrollbar
- proc ttk::scrollbar {w args} {
- set constructor ::tk::scrollbar
- foreach {option _} $args {
- if {$option eq "-class" || $option eq "-style"} {
- set constructor ::ttk::_scrollbar
- break
- }
- }
- return [$constructor $w {*}$args]
- }
-}
-
namespace eval ttk::scrollbar {
variable State
# State(xPress) --
@@ -27,14 +9,32 @@ namespace eval ttk::scrollbar {
# State(first) -- value of -first at start of drag.
}
-bind TScrollbar <ButtonPress-1> { ttk::scrollbar::Press %W %x %y }
+bind TScrollbar <Button-1> { ttk::scrollbar::Press %W %x %y }
bind TScrollbar <B1-Motion> { ttk::scrollbar::Drag %W %x %y }
bind TScrollbar <ButtonRelease-1> { ttk::scrollbar::Release %W %x %y }
-bind TScrollbar <ButtonPress-2> { ttk::scrollbar::Jump %W %x %y }
+bind TScrollbar <Button-2> { ttk::scrollbar::Jump %W %x %y }
bind TScrollbar <B2-Motion> { ttk::scrollbar::Drag %W %x %y }
bind TScrollbar <ButtonRelease-2> { ttk::scrollbar::Release %W %x %y }
+# Redirect scrollwheel bindings to the scrollbar widget
+#
+# The shift-bindings scroll left/right (not up/down)
+# if a widget has both possibilities
+set eventList [list <MouseWheel>]
+switch [tk windowingsystem] {
+ aqua {
+ lappend eventList <Option-MouseWheel>
+ }
+ x11 {
+ lappend eventList <Button-4> <Button-5> <Button-6> <Button-7>
+ }
+}
+foreach event $eventList {
+ bind TScrollbar $event [bind Scrollbar $event]
+}
+unset eventList event
+
proc ttk::scrollbar::Scroll {w n units} {
set cmd [$w cget -command]
if {$cmd ne ""} {
@@ -101,7 +101,7 @@ proc ttk::scrollbar::Release {w x y} {
ttk::CancelRepeat
}
-# scrollbar::Jump -- ButtonPress-2 binding for scrollbars.
+# scrollbar::Jump -- Button-2 binding for scrollbars.
# Behaves exactly like scrollbar::Press, except that
# clicking in the trough jumps to the the selected position.
#
diff --git a/library/ttk/sizegrip.tcl b/library/ttk/sizegrip.tcl
index 24a67c6..080ab2d 100644
--- a/library/ttk/sizegrip.tcl
+++ b/library/ttk/sizegrip.tcl
@@ -32,7 +32,7 @@ namespace eval ttk::sizegrip {
}
}
-bind TSizegrip <ButtonPress-1> { ttk::sizegrip::Press %W %X %Y }
+bind TSizegrip <Button-1> { ttk::sizegrip::Press %W %X %Y }
bind TSizegrip <B1-Motion> { ttk::sizegrip::Drag %W %X %Y }
bind TSizegrip <ButtonRelease-1> { ttk::sizegrip::Release %W %X %Y }
diff --git a/library/ttk/spinbox.tcl b/library/ttk/spinbox.tcl
index 1aa0ccb..5db1d03 100644
--- a/library/ttk/spinbox.tcl
+++ b/library/ttk/spinbox.tcl
@@ -12,13 +12,13 @@ namespace eval ttk::spinbox { }
ttk::copyBindings TEntry TSpinbox
bind TSpinbox <Motion> { ttk::spinbox::Motion %W %x %y }
-bind TSpinbox <ButtonPress-1> { ttk::spinbox::Press %W %x %y }
+bind TSpinbox <Button-1> { ttk::spinbox::Press %W %x %y }
bind TSpinbox <ButtonRelease-1> { ttk::spinbox::Release %W }
bind TSpinbox <Double-Button-1> { ttk::spinbox::DoubleClick %W %x %y }
bind TSpinbox <Triple-Button-1> {} ;# disable TEntry triple-click
-bind TSpinbox <KeyPress-Up> { event generate %W <<Increment>> }
-bind TSpinbox <KeyPress-Down> { event generate %W <<Decrement>> }
+bind TSpinbox <Up> { event generate %W <<Increment>> }
+bind TSpinbox <Down> { event generate %W <<Decrement>> }
bind TSpinbox <<Increment>> { ttk::spinbox::Spin %W +1 }
bind TSpinbox <<Decrement>> { ttk::spinbox::Spin %W -1 }
@@ -29,12 +29,14 @@ ttk::bindMouseWheel TSpinbox [list ttk::spinbox::MouseWheel %W]
# Sets cursor.
#
proc ttk::spinbox::Motion {w x y} {
+ variable State
+ ttk::saveCursor $w State(userConfCursor) [ttk::cursor text]
if { [$w identify $x $y] eq "textarea"
&& [$w instate {!readonly !disabled}]
} {
ttk::setCursor $w text
} else {
- ttk::setCursor $w ""
+ ttk::setCursor $w $State(userConfCursor)
}
}
@@ -81,6 +83,7 @@ proc ttk::spinbox::Release {w} {
# or <<Decrement> (+1, down) events.
#
proc ttk::spinbox::MouseWheel {w dir} {
+ if {[$w instate disabled]} { return }
if {$dir < 0} {
event generate $w <<Increment>>
} else {
@@ -132,6 +135,7 @@ proc ttk::spinbox::Adjust {w v min max} {
# -from, -to, and -increment.
#
proc ttk::spinbox::Spin {w dir} {
+ if {[$w instate disabled]} { return }
set nvalues [llength [set values [$w cget -values]]]
set value [$w get]
if {$nvalues} {
diff --git a/library/ttk/treeview.tcl b/library/ttk/treeview.tcl
index 52fb559..62fc630 100644
--- a/library/ttk/treeview.tcl
+++ b/library/ttk/treeview.tcl
@@ -28,20 +28,20 @@ namespace eval ttk::treeview {
bind Treeview <Motion> { ttk::treeview::Motion %W %x %y }
bind Treeview <B1-Leave> { #nothing }
bind Treeview <Leave> { ttk::treeview::ActivateHeading {} {}}
-bind Treeview <ButtonPress-1> { ttk::treeview::Press %W %x %y }
-bind Treeview <Double-ButtonPress-1> { ttk::treeview::DoubleClick %W %x %y }
+bind Treeview <Button-1> { ttk::treeview::Press %W %x %y }
+bind Treeview <Double-Button-1> { ttk::treeview::DoubleClick %W %x %y }
bind Treeview <ButtonRelease-1> { ttk::treeview::Release %W %x %y }
bind Treeview <B1-Motion> { ttk::treeview::Drag %W %x %y }
-bind Treeview <KeyPress-Up> { ttk::treeview::Keynav %W up }
-bind Treeview <KeyPress-Down> { ttk::treeview::Keynav %W down }
-bind Treeview <KeyPress-Right> { ttk::treeview::Keynav %W right }
-bind Treeview <KeyPress-Left> { ttk::treeview::Keynav %W left }
-bind Treeview <KeyPress-Prior> { %W yview scroll -1 pages }
-bind Treeview <KeyPress-Next> { %W yview scroll 1 pages }
-bind Treeview <KeyPress-Return> { ttk::treeview::ToggleFocus %W }
-bind Treeview <KeyPress-space> { ttk::treeview::ToggleFocus %W }
-
-bind Treeview <Shift-ButtonPress-1> \
+bind Treeview <Up> { ttk::treeview::Keynav %W up }
+bind Treeview <Down> { ttk::treeview::Keynav %W down }
+bind Treeview <Right> { ttk::treeview::Keynav %W right }
+bind Treeview <Left> { ttk::treeview::Keynav %W left }
+bind Treeview <Prior> { %W yview scroll -1 pages }
+bind Treeview <Next> { %W yview scroll 1 pages }
+bind Treeview <Return> { ttk::treeview::ToggleFocus %W }
+bind Treeview <space> { ttk::treeview::ToggleFocus %W }
+
+bind Treeview <Shift-Button-1> \
{ ttk::treeview::Select %W %x %y extend }
bind Treeview <<ToggleSelection>> \
{ ttk::treeview::Select %W %x %y toggle }
@@ -102,7 +102,11 @@ proc ttk::treeview::Keynav {w dir} {
# Sets cursor, active element ...
#
proc ttk::treeview::Motion {w x y} {
- set cursor {}
+ variable State
+
+ ttk::saveCursor $w State(userConfCursor) [ttk::cursor hresize]
+
+ set cursor $State(userConfCursor)
set activeHeading {}
switch -- [$w identify region $x $y] {
@@ -121,7 +125,17 @@ proc ttk::treeview::ActivateHeading {w heading} {
if {$w != $State(activeWidget) || $heading != $State(activeHeading)} {
if {[winfo exists $State(activeWidget)] && $State(activeHeading) != {}} {
- $State(activeWidget) heading $State(activeHeading) state !active
+ # It may happen that $State(activeHeading) no longer corresponds
+ # to an existing display column. This happens for instance when
+ # changing -displaycolumns in a bound script when this change
+ # triggers a <Leave> event. A proc checking if the display column
+ # $State(activeHeading) is really still present or not could be
+ # written but it would need to check several special cases:
+ # a. -displaycolumns "#all" or being an explicit columns list
+ # b. column #0 display is not governed by the -displaycolumn
+ # list but by the value of the -show option
+ # --> Let's rather catch the following line.
+ catch {$State(activeWidget) heading $State(activeHeading) state !active}
}
if {$heading != {}} {
$w heading $heading state active
@@ -141,7 +155,7 @@ proc ttk::treeview::Select {w x y op} {
}
}
-## DoubleClick -- Double-ButtonPress-1 binding.
+## DoubleClick -- Double-Button-1 binding.
#
proc ttk::treeview::DoubleClick {w x y} {
if {[set row [$w identify row $x $y]] ne ""} {
@@ -151,7 +165,7 @@ proc ttk::treeview::DoubleClick {w x y} {
}
}
-## Press -- ButtonPress binding.
+## Press -- Button binding.
#
proc ttk::treeview::Press {w x y} {
focus $w
@@ -205,7 +219,7 @@ proc ttk::treeview::resize.drag {w x} {
}
proc ttk::treeview::resize.release {w x} {
- # no-op
+ $w drop
}
### Heading activation.
@@ -251,9 +265,9 @@ proc ttk::treeview::SelectOp {w item op} {
## -selectmode none:
#
-proc ttk::treeview::select.choose.none {w item} { $w focus $item }
-proc ttk::treeview::select.toggle.none {w item} { $w focus $item }
-proc ttk::treeview::select.extend.none {w item} { $w focus $item }
+proc ttk::treeview::select.choose.none {w item} { $w focus $item; $w see $item }
+proc ttk::treeview::select.toggle.none {w item} { $w focus $item; $w see $item }
+proc ttk::treeview::select.extend.none {w item} { $w focus $item; $w see $item }
## -selectmode browse:
#
@@ -336,6 +350,12 @@ proc ttk::treeview::CloseItem {w item} {
## Toggle -- toggle opened/closed state of item
#
proc ttk::treeview::Toggle {w item} {
+ # don't allow toggling on indicators that
+ # are not present in front of leaf items
+ if {[$w children $item] == {}} {
+ return
+ }
+ # not a leaf, toggle!
if {[$w item $item -open]} {
CloseItem $w $item
} else {
diff --git a/library/ttk/utils.tcl b/library/ttk/utils.tcl
index 7cc1bb7..e0ab45b 100644
--- a/library/ttk/utils.tcl
+++ b/library/ttk/utils.tcl
@@ -58,7 +58,7 @@ proc ttk::traverseTo {w} {
}
## ttk::clickToFocus $w --
-# Utility routine, used in <ButtonPress-1> bindings --
+# Utility routine, used in <Button-1> bindings --
# Assign keyboard focus to the specified widget if -takefocus is enabled.
#
proc ttk::clickToFocus {w} {
@@ -300,17 +300,23 @@ proc ttk::copyBindings {from to} {
#
proc ttk::bindMouseWheel {bindtag callback} {
- switch -- [tk windowingsystem] {
- x11 {
- bind $bindtag <ButtonPress-4> "$callback -1"
- bind $bindtag <ButtonPress-5> "$callback +1"
- }
- win32 {
- bind $bindtag <MouseWheel> [append callback { [expr {-(%D/120)}]}]
- }
- aqua {
- bind $bindtag <MouseWheel> [append callback { [expr {-(%D)}]} ]
- }
+ if {[tk windowingsystem] eq "x11"} {
+ bind $bindtag <Button-4> "$callback -1"
+ bind $bindtag <Button-5> "$callback +1"
+ }
+ if {[tk windowingsystem] eq "aqua"} {
+ bind $bindtag <MouseWheel> [append callback { [expr {-(%D)}]} ]
+ bind $bindtag <Option-MouseWheel> [append callback { [expr {-10 *(%D)}]} ]
+ } else {
+ # We must make sure that positive and negative movements are rounded
+ # equally to integers, avoiding the problem that
+ # (int)1/120 = 0,
+ # but
+ # (int)-1/120 = -1
+ # The following code ensure equal +/- behaviour.
+ bind $bindtag <MouseWheel> [append callback { [
+ expr {%D>=0 ? (-%D/120) : ((119-%D)/120)}
+ ]}]
}
}
@@ -322,28 +328,45 @@ proc ttk::bindMouseWheel {bindtag callback} {
# standard scrollbar protocol.
#
-switch -- [tk windowingsystem] {
- x11 {
- bind TtkScrollable <ButtonPress-4> { %W yview scroll -5 units }
- bind TtkScrollable <ButtonPress-5> { %W yview scroll 5 units }
- bind TtkScrollable <Shift-ButtonPress-4> { %W xview scroll -5 units }
- bind TtkScrollable <Shift-ButtonPress-5> { %W xview scroll 5 units }
+if {[tk windowingsystem] eq "x11"} {
+ bind TtkScrollable <Button-4> { %W yview scroll -5 units }
+ bind TtkScrollable <Button-5> { %W yview scroll 5 units }
+ bind TtkScrollable <Shift-Button-4> { %W xview scroll -5 units }
+ bind TtkScrollable <Shift-Button-5> { %W xview scroll 5 units }
+}
+if {[tk windowingsystem] eq "aqua"} {
+ bind TtkScrollable <MouseWheel> {
+ %W yview scroll [expr {-(%D)}] units
}
- win32 {
- bind TtkScrollable <MouseWheel> \
- { %W yview scroll [expr {-(%D/120)}] units }
- bind TtkScrollable <Shift-MouseWheel> \
- { %W xview scroll [expr {-(%D/120)}] units }
+ bind TtkScrollable <Shift-MouseWheel> {
+ %W xview scroll [expr {-(%D)}] units
}
- aqua {
- bind TtkScrollable <MouseWheel> \
- { %W yview scroll [expr {-(%D)}] units }
- bind TtkScrollable <Shift-MouseWheel> \
- { %W xview scroll [expr {-(%D)}] units }
- bind TtkScrollable <Option-MouseWheel> \
- { %W yview scroll [expr {-10*(%D)}] units }
- bind TtkScrollable <Shift-Option-MouseWheel> \
- { %W xview scroll [expr {-10*(%D)}] units }
+ bind TtkScrollable <Option-MouseWheel> {
+ %W yview scroll [expr {-10 * (%D)}] units
+ }
+ bind TtkScrollable <Shift-Option-MouseWheel> {
+ %W xview scroll [expr {-10 * (%D)}] units
+ }
+} else {
+ # We must make sure that positive and negative movements are rounded
+ # equally to integers, avoiding the problem that
+ # (int)1/120 = 0,
+ # but
+ # (int)-1/120 = -1
+ # The following code ensure equal +/- behaviour.
+ bind TtkScrollable <MouseWheel> {
+ if {%D >= 0} {
+ %W yview scroll [expr {-%D/120}] units
+ } else {
+ %W yview scroll [expr {(119-%D)/120}] units
+ }
+ }
+ bind TtkScrollable <Shift-MouseWheel> {
+ if {%D >= 0} {
+ %W xview scroll [expr {-%D/120}] units
+ } else {
+ %W xview scroll [expr {(119-%D)/120}] units
+ }
}
}
diff --git a/library/ttk/xpTheme.tcl b/library/ttk/xpTheme.tcl
index 4c4f680..da7b422 100644
--- a/library/ttk/xpTheme.tcl
+++ b/library/ttk/xpTheme.tcl
@@ -28,13 +28,6 @@ namespace eval ttk::theme::xpnative {
ttk::style map TNotebook.Tab \
-expand [list selected {2 2 2 2}]
- # Treeview:
- ttk::style configure Heading -font TkHeadingFont
- ttk::style configure Treeview -background SystemWindow
- ttk::style map Treeview \
- -background [list selected SystemHighlight] \
- -foreground [list selected SystemHighlightText] ;
-
ttk::style configure TLabelframe.Label -foreground "#0046d5"
# OR: -padding {3 3 3 6}, which some apps seem to use.
diff --git a/library/xmfbox.tcl b/library/xmfbox.tcl
index f1daea0..0aaae38 100644
--- a/library/xmfbox.tcl
+++ b/library/xmfbox.tcl
@@ -906,9 +906,9 @@ proc ::tk::MotifFDialog_CancelCmd {w} {
}
proc ::tk::ListBoxKeyAccel_Set {w} {
- bind Listbox <Any-KeyPress> ""
+ bind Listbox <Key> ""
bind $w <Destroy> [list tk::ListBoxKeyAccel_Unset $w]
- bind $w <Any-KeyPress> [list tk::ListBoxKeyAccel_Key $w %A]
+ bind $w <Key> [list tk::ListBoxKeyAccel_Key $w %A]
}
proc ::tk::ListBoxKeyAccel_Unset {w} {
diff --git a/macosx/GNUmakefile b/macosx/GNUmakefile
index 39e5962..e753c29 100644
--- a/macosx/GNUmakefile
+++ b/macosx/GNUmakefile
@@ -25,6 +25,7 @@ EXTRA_CONFIGURE_ARGS ?=
EXTRA_MAKE_ARGS ?=
INSTALL_PATH ?= /Library/Frameworks
+TCL_INSTALL_PATH ?= ${INSTALL_PATH}/Tcl.framework
APPLICATION_INSTALL_PATH ?= /Applications/Utilities
PREFIX ?= /usr/local
BINDIR ?= ${PREFIX}/bin
@@ -107,7 +108,7 @@ TCL_VERSION := ${VERSION}
wish := wish
WISH = wish${VERSION}
-BUILD_TARGET := all tktest
+BUILD_TARGET := binaries libraries tktest
INSTALL_TARGET := install
ifneq ($(wildcard $(subst ${space},\ ,${TCL_BUILD_DIR})/tclConfig.sh),)
@@ -115,7 +116,7 @@ TCL_DIR := ${TCL_BUILD_DIR}
TCL_FRAMEWORK_DIR := ${TCL_BUILD_DIR}/..
MAKE_VARS :=
else
-TCL_DIR := ${TCL_FRAMEWORK_DIR}/Tcl.framework
+TCL_DIR := ${TCL_INSTALL_PATH}
TCL_EXE := ${TCLSH_DIR}/tclsh${TCL_VERSION}
MAKE_VARS := TCL_EXE
export DYLD_FRAMEWORK_PATH := ${TCL_FRAMEWORK_DIR}
@@ -225,22 +226,6 @@ ifeq (${EMBEDDED_BUILD},1)
@rm -f "${INSTALL_ROOT}${BINDIR}/${WISH}" && \
rmdir -p "${INSTALL_ROOT}${BINDIR}" 2>&- || true
else
-# redo prebinding (when not building for Mac OS X 10.4 or later only)
- @if [ "`echo "$${MACOSX_DEPLOYMENT_TARGET}" | \
- awk -F '10\\.' '{print int($$2)}'`" -lt 4 -a "`echo "$${CFLAGS}" | \
- awk -F '-mmacosx-version-min=10\\.' '{print int($$2)}'`" -lt 4 ]; \
- then cd ${INSTALL_ROOT}/; \
- if [ ! -d usr/lib ]; then mkdir -p usr && ln -fs /usr/lib usr/ && RM_USRLIB=1; fi; \
- if [ -n "${TK_X11}" -a ! -d usr/X11R6 ]; then mkdir -p usr && ln -fs /usr/X11R6 usr/ && RM_USRX11=1; fi; \
- if [ ! -d System ]; then ln -fs /System . && RM_SYSTEM=1; fi; \
- if [ ! -d "./${LIBDIR}/Tcl.framework" ]; then ln -fs "${TCL_FRAMEWORK_DIR}/Tcl.framework" "./${LIBDIR}"; RM_TCL=1; fi; \
- redo_prebinding -r . "./${TK_FMWK_DIR}/${PRODUCT_NAME}"; \
- if [ -z "${TK_X11}" ]; then redo_prebinding -r . "./${TK_FMWK_DIR}/Resources/Wish.app/Contents/MacOS/Wish"; \
- else redo_prebinding -r . "./${BINDIR}/${WISH}"; fi; \
- if [ -n "$${RM_USRLIB:-}" ]; then rm -f usr/lib; rmdir -p usr 2>&-; fi; \
- if [ -n "$${RM_USRX11:-}" ]; then rm -f usr/X11R6; rmdir -p usr 2>&-; fi; \
- if [ -n "$${RM_SYSTEM:-}" ]; then rm -f System; fi; \
- if [ -n "$${RM_TCL:-}" ]; then rm -f "./${LIBDIR}/Tcl.framework"; fi; fi
# install wish symbolic link
@ln -fs ${WISH} "${INSTALL_ROOT}${BINDIR}/${wish}"
endif
diff --git a/macosx/README b/macosx/README
index 1f5d8a1..a3f10b6 100644
--- a/macosx/README
+++ b/macosx/README
@@ -16,19 +16,17 @@ before asking on the list, many questions have already been answered).
http://groups.google.com/group/comp.lang.tcl/
- The Tcl'ers Wiki also has many pages dealing with Tcl & Tk on macOS, see
- http://wiki.tcl.tk/_/ref?N=3753
- http://wiki.tcl.tk/_/ref?N=8361
+ https://wiki.tcl-lang.org/page/MacOS
- Please report bugs with Tk on macOS to the tracker:
- http://core.tcl.tk/tk/reportlist
+ https://core.tcl-lang.org/tk/reportlist
2. Using Tcl/Tk on macOS
---------------------------
- There are two versions of Tk available on macOS: TkAqua using the native
-aqua widgets and look&feel, and TkX11 using the traditional unix X11 wigets.
-TkX11 requires an X11 server to be installed, such as Apple's X11 (which is
-available as an optional or default install on recent macOS).
+aqua widgets and look&feel, and TkX11 using the traditional unix X11 widgets.
+TkX11 requires an X11 server to be installed, such as XQuartz (available from www.xquartz.org).
TkAqua and TkX11 can be distinguished at runtime via [tk windowingsystem].
- At a minimum, macOS 10.3 is required to run Tcl and TkX11.
@@ -51,19 +49,14 @@ brings up the Tk console window at startup. This is the case when double
clicking Wish in the Finder (or using 'open Wish.app' from the Terminal).
- Tcl extensions can be installed in any of:
- $HOME/Library/Tcl /Library/Tcl /System/Library/Tcl
- $HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks
+ $HOME/Library/Tcl /Library/Tcl
+ $HOME/Library/Frameworks /Library/Frameworks
(searched in that order).
Given a potential package directory $pkg, Tcl on OSX checks for the file
$pkg/Resources/Scripts/pkgIndex.tcl as well as the usual $pkg/pkgIndex.tcl.
This allows building extensions as frameworks with all script files contained in
the Resources/Scripts directory of the framework.
-- [load]able binary extensions can linked as either ordinary shared libraries
-(.dylib) or as MachO bundles (since 8.4.10/8.5a3); bundles have the advantage
-that they are [load]ed more efficiently from a tcl VFS (no temporary copy to the
-native filesystem required).
-
- The 'deploy' target of macosx/GNUmakefile installs the html manpages into the
standard documentation location in the Tcl/Tk frameworks:
Tcl.framework/Resources/Documentation/Reference/Tcl
@@ -72,7 +65,7 @@ No nroff manpages are installed by default by the GNUmakefile.
- The Tcl and Tk frameworks can be installed in any of the system's standard
framework directories:
- $HOME/Library/Frameworks /Library/Frameworks /System/Library/Frameworks
+ $HOME/Library/Frameworks /Library/Frameworks
- ${prefix}/bin/wish8.x is a script that calls a copy of 'Wish' contained in
Tk.framework/Resources
@@ -87,28 +80,6 @@ particular PATH may not be what you expect. (Wish started by LaunchServices
inherits loginwindow's environment variables, which are essentially those set in
$HOME/.MacOSX/environment.plist, and are unrelated to those set in your shell).
-- TkAqua drawing is antialiased by default, but (outline) linewidth can be used
-to control whether a line/shape is drawn antialiased. The antialiasing threshold
-is 0 by default (i.e. antialias everything), it can be changed by setting
- set tk::mac::CGAntialiasLimit <limit>
-in your script before drawing, in which case lines (or shapes with outlines)
-thinner than <limit> pixels will not be antialiased.
-
-- Text antialiasing by default uses the standard OS antialising settings.
-Setting the global variable '::tk::mac::antialiasedtext' allows to control text
-antialiasing from Tcl: a value of 1 enables AA, 0 disables AA and -1 restores
-the default behaviour of respecting the OS settings.
-
-- Scrollbars: There are two scrollbar variants in Aqua, normal & small. The
-normal scrollbar has a small dimension of 15, the small variant 11.
-Access to the small variant was added in Tk 8.4.2.
-
-- The default metrics of native buttons, radiobuttons, checkboxes and
-menubuttons in the Cocoa-based Tk 8.5.7 and later preserve compatibility with
-the older Carbon-based implementation, you can turn off the compatibility
-metrics to get more native-looking spacing by setting:
- set tk::mac::useCompatibilityMetrics 0
-
- TkAqua provides access to native OS X images via the Tk native bitmap facility
(including any image file readable by NSImage). A native bitmap name is
interpreted as follows (in order):
@@ -184,10 +155,28 @@ Note that not all attributes are valid for all window classes. Support for the
support for some legacy Carbon-specific classes and attributes was removed
(they are still accepted by the command but no longer have any effect).
-- Another command available in the tk::unsupported::MacWindowStyle namespace is
-tk::unsupported::MacWindowStyle tabbingid window ?newId? which can be used to
-get or set the tabbingIdentifier for the NSWindow associated with a Tk Window.
-See section 3 for details.
+- Another command available in the tk::unsupported::MacWindowStyle namespace is:
+ tk::unsupported::MacWindowStyle tabbingid window ?newId?
+which can be used to get or set the tabbingIdentifier for the NSWindow
+associated with a Tk Window. See section 3 for details.
+
+- The command:
+ tk::unsupported::MacWindowStyle appearance window ?newAppearance?
+is available when Tk is built and run on macOS 10.14 (Mojave) or later. In
+that case the Ttk widgets all support the "Dark Mode" appearance which was
+introduced in 10.14. The command accepts the following values for the optional
+newAppearance option: "aqua", "darkaqua", or "auto". If the appearance is set
+to aqua or darkaqua then the window will be displayed with the corresponding
+appearance independent of any preferences settings. If it is set to "auto"
+the appearance will be determined by the preferences. This command can be
+used to opt out of Dark Mode on a per-window basis. It may be best to run the "update" command before setting the appearance property, to allow the event loop to run.
+
+
+- To determine the current appearance of a window in macOS 10.14 (Mojave) and
+higher, one can use the command:
+ tk::unsupported::MacWindowStyle isdark
+The boolean return value is true if the window is currently displayed with the
+dark appearance.
- If you want to use Remote Debugging with Xcode, you need to set the
environment variable XCNOSTDIN to 1 in the Executable editor for Wish. That will
@@ -275,13 +264,51 @@ ensure that we maintain consistency, changing the tabbingIdentifier of a window
which is already displayed as a tab will also cause it to become a separate
window.
-
-4. Building Tcl/Tk on macOS
+4. Ttk, Dark Mode and semantic colors
+---------------------------------------
+
+With the release of OSX 10.14 (Mojave), Apple introduced the DarkAqua
+appearance. Part of the implementation of the Dark Mode was to make
+some of the named NSColors have dynamic values. Apple calls these
+"semantic colors" because the name does not specify a specific color,
+but rather refers to the context in which the color should be used.
+Tk now provides the following semantic colors as system colors:
+systemTextColor, systemTextBackgroundColor, systemSelectedTextColor,
+systemSelectedTextBackgroundColor, systemControlTextColor,
+systemDisabledControlTextColor, systemLabelColor, systemLinkColor, and
+systemControlAccentColor. All of these except the last three were
+present in OSX 10.0 (and those three are simulated in systems where they
+do not exist). The change in 10.14 was that the RGB color value of
+these colors became dynamic, meaning that the color value can change
+when the application appearance changes. In particular, when a user
+selects Dark Mode in the system preferences these colors change
+appearance. For example systemTextColor is dark in Aqua and light in
+DarkAqua. One additional color, systemSelectedTabTextColor, does not
+exist in macOS but is used by Tk to match the different colors used
+for Notebook tab text in different OS versions.
+
+The default background and foreground colors of most of the Tk widgets
+have been set to semantic colors, which means that the widgets will change
+appearance, and remain usable, when Dark Mode is selected in the system
+preferences. However, to get a close match to the native Dark Mode style it
+is recommended to use Ttk widgets when possible.
+
+Apple's tab view and GroupBox objects delimit their content by
+displaying it within a rounded rectangle with a background color that
+contrasts with the background of the containing object. This means
+that the background color of a Ttk widget depends on how deeply it is
+nested inside of other widgets that use contrasting backgrounds. To
+support this, there are 8 contrasting system colors named
+systemWindowBackgroundColor, and systemWindowBackgroundColor1 - 7.
+The systemWindowBackgroundColor is the standard background for a
+dialog window and the others match the contrasting background colors
+used in ttk::notebooks and ttk::labelframes which are nested to the
+corresponding depth.
+
+5. Building Tcl/Tk on macOS
------------------------------
-- At least macOS 10.3 is required to build Tcl and TkX11, and macOS 10.6
-is required to build TkAqua. The XCode application provides everything
-needed to build Tk, but it is not necessary to install the full XCode.
+- macOS 10.6 is required to build TkAqua and TkX11. The XCode application provides everything needed to build Tk, but it is not necessary to install the full XCode.
It suffices to install the Command Line Tools package, which can be done
by running the command:
xcode-select --install
@@ -340,17 +367,6 @@ need to manually change the TCL_SRCROOT and TK_SRCROOT settings by editing your
${USER}.pbxuser file (located inside the Tk.xcodeproj bundle directory) with a
text editor.
-- To build universal binaries outside of the Xcode IDE, set CFLAGS as follows:
- export CFLAGS="-arch i386 -arch x86_64 -arch ppc"
-This requires macOS 10.4 and Xcode 2.4 (or Xcode 2.2 if -arch x86_64 is
-omitted, but _not_ Xcode 2.1) and will work on any architecture (on PowerPC
-Tiger you need to add "-isysroot /Developer/SDKs/MacOSX10.4u.sdk").
-Note that configure requires CFLAGS to contain a least one architecture that can
-be run on the build machine (i.e. ppc on G3/G4, ppc or ppc64 on G5, ppc or i386
-on Core and ppc, i386 or x86_64 on Core2/Xeon).
-Universal builds of Tcl TEA extensions are also possible with CFLAGS set as
-above, they will be [load]able by universal as well as thin binaries of Tcl.
-
- To enable weak-linking, set the MACOSX_DEPLOYMENT_TARGET environment variable
to the minimal OS version the binaries should be able to run on, e.g:
export MACOSX_DEPLOYMENT_TARGET=10.6
@@ -473,7 +489,7 @@ The macOS Tk application does not call the [NSApp run] method at
all. Instead it uses the event loop built in to Tk. So the
application must take care to replicate the important features of the
method ourselves. The way that autorelease pools are handled is
-discussed in 4.2 below. Here we discuss the event handling itself.
+discussed in 5.2 below. Here we discuss the event handling itself.
The Tcl event loop simply consists of repeated calls to TclDoOneEvent.
Each call to TclDoOneEvent begins by collecting all pending events from
@@ -506,7 +522,7 @@ event to the Tcl queue.
In order to carry out the job of managing autorelease pools, which
would normally be handled by the [NSApp run] method, a private
-NSAUtoreleasePool* property is added to the TkApplication subclass of
+NSAutoreleasePool* property is added to the TkApplication subclass of
NSApplication. The TkpInit function calls [NSApp _setup] which
initializes this property by creating an NSAutoreleasePool prior to
calling [NSApp finishLaunching]. This mimics the behavior of the
@@ -531,7 +547,7 @@ in nested calls to CheckProc.
One additional minor caveat for developers is that there are several
steps of the Tk initialization which precede the call to TkpInit.
Notably, the font package is initialized first. Since there is no
-NSAUtoreleasePool in scope prior to calling TkpInit, the functions
+NSAutoreleasePool in scope prior to calling TkpInit, the functions
called in these preliminary stages need to create and drain their own
NSAutoreleasePools whenever they call methods of Appkit objects
(e.g. NSFont).
@@ -551,7 +567,7 @@ window. (Normally, the clipping rectangle is the same as the bounding
rectangle, but drawing can be clipped to a smaller rectangle by
calling TkpClipDrawableToRect.) The aboveVisRgn is the intersection of
the window's bounding rectangle with the bounding rectangle of the
-parent window. Much of the code in tkMacOSXSubindows.c is devoted to
+parent window. Much of the code in tkMacOSXSubwindows.c is devoted to
rebuilding these clipping regions whenever something changes in the
layout of the windows. This turns out to be a tricky thing to do and
it is extremely prone to errors which can be difficult to trace.
@@ -646,13 +662,63 @@ source and destination rectangles for the scrolling. The embedded
windows are redrawn within the DisplayText function by some
conditional code which is only used for macOS.
-6. Virtual events on 10.14
----------------------------
+6.0 Virtual events on 10.14
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
10.14 supports system appearance changes, and has added a "Dark Mode"
-that casts all window frames and menus as black. Tk 8.6.9 supports Dark
-Mode by having the window decorations, menus, and dialogs automatically
-take on the appropriate appearance when the system appearance is changed.
-Because the window content itself is drawn by Tk, it will not change when
-the system mode changes.
-
+that casts all window frames and menus as black. Tk 8.6.9 has added two
+virtual events, <<LightAqua>> and <<DarkAqua>>, to allow you to update
+your Tk app's appearance when the system appearance changes. Just bind
+your appearance-updating code to these virtual events and you will see
+it triggered when the system appearance toggles between dark and light.
+
+7.0 Mac Services
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+With 8.6.10, Tk supports the Mac's NSServices API, documented at
+https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/SysServices/introduction.html#//apple_ref/doc/uid/10000101-SW1
+and in TIP 536 and Tk's man page. Tk presents a simple,
+straightforward API to implement the Services functionality.
+
+The Tk implementation of the NSServices API is intended for standalone
+applications, such as one wrapped by the standalone version of Wish
+and re-named into a different application. In particular such an
+application would specify its own unique CFBundleIdentifier in its
+Info.plist file. During development, however, if Wish itself is being
+used as the receiver, it may be necessary to take some care to ensure
+that the correct version of Wish.app is available as a receiver of
+NSServices data.
+
+When one macOS app uses NSServices to send data to another app that is
+not running, LaunchServices will launch the receiver. LaunchServices
+assumes that the CFBundleIdentifier uniquely identifies an app among
+all of the apps installed on a system. But this may not be the case
+for Wish.app if, for example, you have compiled Tk from source at some
+time in the past. In that case the Tk build directory will contain
+its own copy of Wish.app that will be visible to LaunchServices. It
+may be necessary when testing your app to take some steps to ensure
+that LaunchServices is launching the correct Wish.app. Instructions
+for doing this are provided below.
+
+The command line tool which manages the LaunchServices database has
+an amazingly unwieldy path name. So, first, run this command:
+
+alias lsregister='/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister'
+
+Then you can reset the LaunchServices database like this:
+
+$ lsregister -kill
+$ lsregister -seed
+
+To find out which versions of Wish.app have been located by
+LaunchServices, run:
+
+$ lsregister -dump | grep path | grep Wish
+
+If more than one version of Wish is showing up in this list, eliminate
+all of the unintended targets by running
+
+lsregister -u /path/to/bad/Wish.app
+
+Continue this until only the correct version of Wish shows up in the
+list.
diff --git a/macosx/Tk.xcode/project.pbxproj b/macosx/Tk.xcode/project.pbxproj
index a45b5e7..9598af9 100644
--- a/macosx/Tk.xcode/project.pbxproj
+++ b/macosx/Tk.xcode/project.pbxproj
@@ -1043,7 +1043,6 @@
F966BBD208F27A3B005CB29B /* tkMacOSXEmbed.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEmbed.c; sourceTree = "<group>"; };
F966BBD308F27A3B005CB29B /* tkMacOSXEntry.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEntry.c; sourceTree = "<group>"; };
F966BBD408F27A3B005CB29B /* tkMacOSXEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEvent.c; sourceTree = "<group>"; };
- F966BBD508F27A3B005CB29B /* tkMacOSXEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXEvent.h; sourceTree = "<group>"; };
F966BBD608F27A3B005CB29B /* tkMacOSXFont.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXFont.c; sourceTree = "<group>"; };
F966BBD708F27A3B005CB29B /* tkMacOSXHLEvents.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXHLEvents.c; sourceTree = "<group>"; };
F966BBD808F27A3B005CB29B /* tkMacOSXInit.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXInit.c; sourceTree = "<group>"; };
@@ -2584,7 +2583,6 @@
F966BBD208F27A3B005CB29B /* tkMacOSXEmbed.c */,
F966BBD308F27A3B005CB29B /* tkMacOSXEntry.c */,
F966BBD408F27A3B005CB29B /* tkMacOSXEvent.c */,
- F966BBD508F27A3B005CB29B /* tkMacOSXEvent.h */,
F966BBD608F27A3B005CB29B /* tkMacOSXFont.c */,
F93E5EFD09CF8711008FA367 /* tkMacOSXFont.h */,
F966BBD708F27A3B005CB29B /* tkMacOSXHLEvents.c */,
diff --git a/macosx/Tk.xcodeproj/project.pbxproj b/macosx/Tk.xcodeproj/project.pbxproj
index f004bd8..121c8a0 100644
--- a/macosx/Tk.xcodeproj/project.pbxproj
+++ b/macosx/Tk.xcodeproj/project.pbxproj
@@ -1043,7 +1043,6 @@
F966BBD208F27A3B005CB29B /* tkMacOSXEmbed.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEmbed.c; sourceTree = "<group>"; };
F966BBD308F27A3B005CB29B /* tkMacOSXEntry.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEntry.c; sourceTree = "<group>"; };
F966BBD408F27A3B005CB29B /* tkMacOSXEvent.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXEvent.c; sourceTree = "<group>"; };
- F966BBD508F27A3B005CB29B /* tkMacOSXEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tkMacOSXEvent.h; sourceTree = "<group>"; };
F966BBD608F27A3B005CB29B /* tkMacOSXFont.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXFont.c; sourceTree = "<group>"; };
F966BBD708F27A3B005CB29B /* tkMacOSXHLEvents.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXHLEvents.c; sourceTree = "<group>"; };
F966BBD808F27A3B005CB29B /* tkMacOSXInit.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = tkMacOSXInit.c; sourceTree = "<group>"; };
@@ -2584,7 +2583,6 @@
F966BBD208F27A3B005CB29B /* tkMacOSXEmbed.c */,
F966BBD308F27A3B005CB29B /* tkMacOSXEntry.c */,
F966BBD408F27A3B005CB29B /* tkMacOSXEvent.c */,
- F966BBD508F27A3B005CB29B /* tkMacOSXEvent.h */,
F966BBD608F27A3B005CB29B /* tkMacOSXFont.c */,
F93E5EFD09CF8711008FA367 /* tkMacOSXFont.h */,
F966BBD708F27A3B005CB29B /* tkMacOSXHLEvents.c */,
diff --git a/macosx/Wish-Info.plist.in b/macosx/Wish-Info.plist.in
index d2fc388..59a6e1a 100644
--- a/macosx/Wish-Info.plist.in
+++ b/macosx/Wish-Info.plist.in
@@ -8,75 +8,101 @@
this file, and for a DISCLAIMER OF ALL WARRANTIES.
-->
<plist version="1.0">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleDocumentTypes</key>
+ <dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
<array>
- <dict>
- <key>CFBundleTypeExtensions</key>
- <array>
- <string>tcl</string>
- <string>TCL</string>
- <string>*</string>
- </array>
- <key>CFBundleTypeMIMETypes</key>
- <array>
- <string>application/x-tcl</string>
- <string>text/plain</string>
- </array>
- <key>CFBundleTypeName</key>
- <string>NSStringPboardType</string>
- <key>CFBundleTypeOSTypes</key>
- <array>
- <string>TEXT</string>
- <string>****</string>
- </array>
- <key>CFBundleTypeRole</key>
- <string>Viewer</string>
- </dict>
+ <string>tcl</string>
+ <string>TCL</string>
+ <string>*</string>
</array>
- <key>CFBundleExecutable</key>
- <string>Wish</string>
- <key>CFBundleGetInfoString</key>
- <string>Wish Shell @TK_VERSION@@TK_PATCH_LEVEL@,
- Copyright © 1989-@TK_YEAR@ Tcl Core Team,
- Copyright © 1989-@TK_YEAR@ Contributors,
- Copyright © 2011-@TK_YEAR@ Kevin Walzer/WordTech
- Communications LLC,
- Copyright © 2014-@TK_YEAR@ Marc Culler,
- Copyright © 2002-@TK_YEAR@ Daniel A. Steffen,
- Copyright © 2001-2009 Apple Inc.,
- Copyright © 2001-2002 Jim Ingham &amp; Ian Reid</string>
- <key>CFBundleIconFile</key>
- <string>Wish.icns</string>
- <key>CFBundleIdentifier</key>
- <string>com.tcltk.wish</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleLocalizations</key>
+ <key>CFBundleTypeMIMETypes</key>
+ <array>
+ <string>application/x-tcl</string>
+ <string>text/plain</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>NSStringPboardType</string>
+ <key>CFBundleTypeOSTypes</key>
<array>
- @CFBUNDLELOCALIZATIONS@
+ <string>TEXT</string>
+ <string>****</string>
</array>
- <key>CFBundleName</key>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
+ </dict>
+ </array>
+ <key>CFBundleURLTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>foo</string>
+ </array>
+ <key>CFBundleURLName</key>
+ <string>Get Foo</string>
+ </dict>
+ </array>
+ <key>CFBundleExecutable</key>
+ <string>Wish</string>
+ <key>CFBundleGetInfoString</key>
+ <string>Wish Shell @TK_VERSION@@TK_PATCH_LEVEL@,
+ Copyright © 1989-@TK_YEAR@ Tcl Core Team,
+ Copyright © 1989-@TK_YEAR@ Contributors,
+ Copyright © 2011-@TK_YEAR@ Kevin Walzer/WordTech Communications LLC,
+ Copyright © 2014-@TK_YEAR@ Marc Culler,
+ Copyright © 2002-@TK_YEAR@ Daniel A. Steffen,
+ Copyright © 2001-2009 Apple Inc.,
+ Copyright © 2001-2002 Jim Ingham &amp; Ian Reid</string>
+ <key>CFBundleIconFile</key>
+ <string>Wish.icns</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.tcltk.wish</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleLocalizations</key>
+ <array>
+ @CFBUNDLELOCALIZATIONS@
+ </array>
+ <key>CFBundleName</key>
+ <string>Wish</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>@TK_VERSION@@TK_PATCH_LEVEL@</string>
+ <key>CFBundleSignature</key>
+ <string>WiSH</string>
+ <key>CFBundleVersion</key>
+ <string>@TK_VERSION@@TK_PATCH_LEVEL@</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>10.6.0</string>
+ <key>LSRequiresCarbon</key>
+ <true/>
+ <key>NSAppleScriptEnabled</key>
+ <true/>
+ <key>OSAScriptingDefinition</key>
+ <string>Wish.sdef</string>
+ <key>NSHighResolutionCapable</key>
+ <string>True</string>
+ <key>NSServices</key>
+ <array>
+ <dict>
+ <key>NSMessage</key>
+ <string>provideService</string>
+ <key>NSPortName</key>
<string>Wish</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>@TK_VERSION@@TK_PATCH_LEVEL@</string>
- <key>CFBundleSignature</key>
- <string>WiSH</string>
- <key>CFBundleVersion</key>
- <string>@TK_VERSION@@TK_PATCH_LEVEL@</string>
- <key>LSMinimumSystemVersion</key>
- <string>10.6.0</string>
- <key>LSRequiresCarbon</key>
- <true/>
- <key>NSAppleScriptEnabled</key>
- <true/>
- <key>OSAScriptingDefinition</key>
- <string>Wish.sdef</string>
- <key>NSHighResolutionCapable</key>
- <string>True</string>
-</dict>
+ <key>NSSendTypes</key>
+ <array>
+ <string>NSStringPboardType</string>
+ <string>NSPasteboardTypeString</string>
+ </array>
+ </dict>
+ </array>
+ </dict>
</plist>
diff --git a/macosx/Wish.sdef b/macosx/Wish.sdef
index 8873e95..6639f70 100644
--- a/macosx/Wish.sdef
+++ b/macosx/Wish.sdef
@@ -33,5 +33,14 @@
<type type="text"/>
</result>
</command>
+ <command name="open location" code="GURLGURL"
+ description="Open a URL.">
+ <direct-parameter description="URL" type="text">
+ <type type="text"/>
+ </direct-parameter>
+ <result description="Result">
+ <type type="text"/>
+ </result>
+ </command>
</suite>
</dictionary>
diff --git a/macosx/tkMacOSX.h b/macosx/tkMacOSX.h
index 05ea6c2..a9e3082 100644
--- a/macosx/tkMacOSX.h
+++ b/macosx/tkMacOSX.h
@@ -26,7 +26,7 @@
typedef int (Tk_MacOSXEmbedRegisterWinProc) (long winID, Tk_Window window);
typedef void* (Tk_MacOSXEmbedGetGrafPortProc) (Tk_Window window);
typedef int (Tk_MacOSXEmbedMakeContainerExistProc) (Tk_Window window);
-typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, TkRegion rgn);
+typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, Region rgn);
typedef void (Tk_MacOSXEmbedGetOffsetInParentProc) (Tk_Window window, void *ulCorner);
#include "tkPlatDecls.h"
diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c
index f779097..a63a1b6 100644
--- a/macosx/tkMacOSXBitmap.c
+++ b/macosx/tkMacOSXBitmap.c
@@ -44,11 +44,14 @@ static BuiltInIcon builtInIcons[] = {
{"stop", kAlertStopIcon},
{"note", kAlertNoteIcon},
{"caution", kAlertCautionIcon},
- {NULL}
+ {NULL, 0}
};
#define builtInIconSize 32
+#define OSTYPE_TO_UTI(x) (NSString *)UTTypeCreatePreferredIdentifierForTag( \
+ kUTTagClassOSType, UTCreateStringForOSType(x), nil)
+
static Tcl_HashTable iconBitmapTable = {};
typedef struct {
int kind, width, height;
@@ -97,7 +100,7 @@ TkpDefineNativeBitmaps(void)
name = Tk_GetUid(builtInPtr->name);
predefHashPtr = Tcl_CreateHashEntry(tablePtr, name, &isNew);
if (isNew) {
- TkPredefBitmap *predefPtr = ckalloc(sizeof(TkPredefBitmap));
+ TkPredefBitmap *predefPtr = (TkPredefBitmap *)ckalloc(sizeof(TkPredefBitmap));
predefPtr->source = UINT2PTR(builtInPtr->iconType);
predefPtr->width = builtInIconSize;
@@ -107,14 +110,15 @@ TkpDefineNativeBitmaps(void)
}
}
}
+
/*
*----------------------------------------------------------------------
*
- * GetBitmapForIcon --
+ * PixmapFromImage --
*
* Results:
- * Bitmap for the given IconRef.
+ * Returns a Pixmap with an NSImage drawn into it.
*
* Side effects:
* None.
@@ -123,9 +127,9 @@ TkpDefineNativeBitmaps(void)
*/
static Pixmap
-GetBitmapForIcon(
+PixmapFromImage(
Display *display,
- IconRef icon,
+ NSImage* image,
CGSize size)
{
TkMacOSXDrawingContext dc;
@@ -134,18 +138,22 @@ GetBitmapForIcon(
pixmap = Tk_GetPixmap(display, None, size.width, size.height, 0);
if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) {
if (dc.context) {
- const CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1,
- .tx = 0, .ty = size.height };
- const CGRect r = { .origin = { .x = 0, .y = 0 }, .size = size };
-
+ CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1,
+ .tx = 0, .ty = size.height};
CGContextConcatCTM(dc.context, t);
- PlotIconRefInContext(dc.context, &r, kAlignAbsoluteCenter,
- kTransformNone, NULL, kPlotIconRefNormalFlags, icon);
+ [NSGraphicsContext saveGraphicsState];
+ [NSGraphicsContext setCurrentContext:[NSGraphicsContext
+ graphicsContextWithGraphicsPort:dc.context
+ flipped:NO]];
+ [image drawAtPoint:NSZeroPoint fromRect:NSZeroRect
+ operation:NSCompositeCopy fraction:1.0];
+ [NSGraphicsContext restoreGraphicsState];
}
TkMacOSXRestoreDrawingContext(&dc);
}
return pixmap;
}
+
/*
*----------------------------------------------------------------------
@@ -168,22 +176,14 @@ TkpCreateNativeBitmap(
Display *display,
const void *source) /* Info about the icon to build. */
{
- Pixmap pixmap;
- IconRef icon;
- OSErr err;
-
- err = ChkErr(GetIconRef, kOnSystemDisk, kSystemIconsCreator,
- (unsigned int)PTR2UINT(source), &icon);
- if (err == noErr) {
- pixmap = GetBitmapForIcon(display, icon, CGSizeMake(builtInIconSize,
- builtInIconSize));
- ReleaseIconRef(icon);
- } else {
- pixmap = Tk_GetPixmap(display, None, builtInIconSize,
- builtInIconSize, 0);
- }
+ NSString *iconUTI = OSTYPE_TO_UTI(PTR2UINT(source));
+ NSImage *iconImage = [[NSWorkspace sharedWorkspace]
+ iconForFileType: iconUTI];
+ CGSize size = CGSizeMake(builtInIconSize, builtInIconSize);
+ Pixmap pixmap = PixmapFromImage(display, iconImage, NSSizeToCGSize(size));
return pixmap;
}
+
/*
*----------------------------------------------------------------------
@@ -219,6 +219,7 @@ OSTypeFromString(const char *s, OSType *t) {
Tcl_FreeEncoding(encoding);
return result;
}
+
/*
*----------------------------------------------------------------------
@@ -309,50 +310,16 @@ TkpGetNativeAppBitmap(
}
}
if (image) {
- TkMacOSXDrawingContext dc;
- int depth = 0;
-
-#ifdef MAC_OSX_TK_TODO
- for (NSImageRep *r in [image representations]) {
- NSInteger bitsPerSample = [r bitsPerSample];
- if (bitsPerSample && bitsPerSample > depth) {
- depth = bitsPerSample;
- };
- }
- if (depth == 1) {
- /* TODO: convert BW NSImage to CGImageMask */
- }
-#endif
- pixmap = Tk_GetPixmap(display, None, size.width, size.height, depth);
*width = size.width;
*height = size.height;
- if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) {
- if (dc.context) {
- CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1,
- .tx = 0, .ty = size.height};
-
- CGContextConcatCTM(dc.context, t);
- [NSGraphicsContext saveGraphicsState];
- [NSGraphicsContext setCurrentContext:[NSGraphicsContext
- graphicsContextWithGraphicsPort:dc.context flipped:NO]];
- [image drawAtPoint:NSZeroPoint fromRect:NSZeroRect
- operation:NSCompositeCopy fraction:1.0];
- [NSGraphicsContext restoreGraphicsState];
- }
- TkMacOSXRestoreDrawingContext(&dc);
- }
+ pixmap = PixmapFromImage(display, image, NSSizeToCGSize(size));
} else if (name) {
OSType iconType;
if (OSTypeFromString(name, &iconType) == TCL_OK) {
- IconRef icon;
- OSErr err = ChkErr(GetIconRef, kOnSystemDisk, kSystemIconsCreator,
- iconType, &icon);
- if (err == noErr) {
- pixmap = GetBitmapForIcon(display, icon, NSSizeToCGSize(size));
- *width = size.width;
- *height = size.height;
- ReleaseIconRef(icon);
- }
+ NSString *iconUTI = OSTYPE_TO_UTI(iconType);
+ NSImage *iconImage = [[NSWorkspace sharedWorkspace]
+ iconForFileType: iconUTI];
+ pixmap = PixmapFromImage(display, iconImage, NSSizeToCGSize(size));
}
}
return pixmap;
@@ -376,7 +343,7 @@ TkpGetNativeAppBitmap(
int
TkMacOSXIconBitmapObjCmd(
- ClientData clientData, /* Unused. */
+ ClientData dummy, /* Unused. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -385,6 +352,7 @@ TkMacOSXIconBitmapObjCmd(
int i = 1, len, isNew, result = TCL_ERROR;
const char *name, *value;
IconBitmap ib, *iconBitmap;
+ (void)dummy;
if (objc != 6) {
Tcl_WrongNumArgs(interp, 1, objv, "name width height "
@@ -431,7 +399,7 @@ TkMacOSXIconBitmapObjCmd(
}
}
#endif
- ib.value = ckalloc(len + 1);
+ ib.value = (char *)ckalloc(len + 1);
strcpy(ib.value, value);
if (!iconBitmapTable.buckets) {
Tcl_InitHashTable(&iconBitmapTable, TCL_STRING_KEYS);
@@ -441,7 +409,7 @@ TkMacOSXIconBitmapObjCmd(
iconBitmap = Tcl_GetHashValue(hPtr);
ckfree(iconBitmap->value);
} else {
- iconBitmap = ckalloc(sizeof(IconBitmap));
+ iconBitmap = (IconBitmap *)ckalloc(sizeof(IconBitmap));
Tcl_SetHashValue(hPtr, iconBitmap);
}
*iconBitmap = ib;
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c
index c0b83f2..aa45895 100644
--- a/macosx/tkMacOSXButton.c
+++ b/macosx/tkMacOSXButton.c
@@ -1,8 +1,8 @@
/*
* tkMacOSXButton.c --
*
- * This file implements the Macintosh specific portion of the
- * button widgets.
+ * This file implements the Macintosh specific portion of the button
+ * widgets.
*
* Copyright (c) 1996-1997 by Sun Microsystems, Inc.
* Copyright 2001, Apple Computer, Inc.
@@ -70,20 +70,23 @@ typedef struct {
* Forward declarations for procedures defined later in this file:
*/
-
-static void ButtonBackgroundDrawCB (const HIRect *btnbounds, MacButton *ptr,
- SInt16 depth, Boolean isColorDev);
-static void ButtonContentDrawCB (const HIRect *bounds, ThemeButtonKind kind,
- const HIThemeButtonDrawInfo *info, MacButton *ptr, SInt16 depth,
- Boolean isColorDev);
-static void ButtonEventProc(ClientData clientData, XEvent *eventPtr);
-static void TkMacOSXComputeButtonParams (TkButton * butPtr, ThemeButtonKind* btnkind,
- HIThemeButtonDrawInfo* drawinfo);
-static int TkMacOSXComputeButtonDrawParams (TkButton * butPtr, DrawParams * dpPtr);
-static void TkMacOSXDrawButton (MacButton *butPtr, GC gc, Pixmap pixmap);
-static void DrawButtonImageAndText(TkButton* butPtr);
-static void PulseDefaultButtonProc(ClientData clientData);
-
+static void ButtonBackgroundDrawCB(const HIRect *btnbounds,
+ MacButton *ptr, SInt16 depth, Boolean isColorDev);
+static void ButtonContentDrawCB(const HIRect *bounds,
+ ThemeButtonKind kind,
+ const HIThemeButtonDrawInfo *info, MacButton *ptr,
+ SInt16 depth, Boolean isColorDev);
+static void ButtonEventProc(ClientData clientData,
+ XEvent *eventPtr);
+static void TkMacOSXComputeButtonParams(TkButton *butPtr,
+ ThemeButtonKind *btnkind,
+ HIThemeButtonDrawInfo *drawinfo);
+static int TkMacOSXComputeButtonDrawParams(TkButton *butPtr,
+ DrawParams * dpPtr);
+static void TkMacOSXDrawButton(MacButton *butPtr, GC gc,
+ Pixmap pixmap);
+static void DrawButtonImageAndText(TkButton *butPtr);
+static void PulseDefaultButtonProc(ClientData clientData);
/*
* The class procedure table for the button widgets.
@@ -92,18 +95,20 @@ static void PulseDefaultButtonProc(ClientData clientData);
const Tk_ClassProcs tkpButtonProcs = {
sizeof(Tk_ClassProcs), /* size */
TkButtonWorldChanged, /* worldChangedProc */
+ NULL,
+ NULL
};
static int bCount;
-
+
/*
*----------------------------------------------------------------------
*
* TkpButtonSetDefaults --
*
- * This procedure is invoked before option tables are created for
- * buttons. It modifies some of the default values to match the current
- * values defined for this platform.
+ * This procedure is invoked before option tables are created for buttons.
+ * It modifies some of the default values to match the current values
+ * defined for this platform.
*
* Results:
* Some of the default values in *specPtr are modified.
@@ -117,9 +122,8 @@ static int bCount;
void
TkpButtonSetDefaults()
{
-/*No-op.*/
+ /*No-op.*/
}
-
/*
*----------------------------------------------------------------------
@@ -141,10 +145,10 @@ TkButton *
TkpCreateButton(
Tk_Window tkwin)
{
- MacButton *macButtonPtr = (MacButton *) ckalloc(sizeof(MacButton));
+ MacButton *macButtonPtr = (MacButton *)ckalloc(sizeof(MacButton));
Tk_CreateEventHandler(tkwin, ActivateMask,
- ButtonEventProc, (ClientData) macButtonPtr);
+ ButtonEventProc, macButtonPtr);
macButtonPtr->id = bCount++;
macButtonPtr->flags = FIRST_DRAW;
macButtonPtr->btnkind = kThemePushButton;
@@ -152,7 +156,7 @@ TkpCreateButton(
bzero(&macButtonPtr->drawinfo, sizeof(macButtonPtr->drawinfo));
bzero(&macButtonPtr->lastdrawinfo, sizeof(macButtonPtr->lastdrawinfo));
- return (TkButton *)macButtonPtr;
+ return (TkButton *) macButtonPtr;
}
/*
@@ -160,15 +164,15 @@ TkpCreateButton(
*
* TkpDisplayButton --
*
- * This procedure is invoked to display a button widget. It is
- * normally invoked as an idle handler.
+ * This procedure is invoked to display a button widget. It is normally
+ * invoked as an idle handler.
*
* Results:
* None.
*
* Side effects:
- * Commands are output to X to display the button in its
- * current mode. The REDRAW_PENDING flag is cleared.
+ * Commands are output to X to display the button in its current mode. The
+ * REDRAW_PENDING flag is cleared.
*
*----------------------------------------------------------------------
*/
@@ -177,8 +181,8 @@ void
TkpDisplayButton(
ClientData clientData) /* Information about widget. */
{
- MacButton *macButtonPtr = (MacButton *) clientData;
- TkButton *butPtr = (TkButton *) clientData;
+ MacButton *macButtonPtr = clientData;
+ TkButton *butPtr = clientData;
Tk_Window tkwin = butPtr->tkwin;
Pixmap pixmap;
DrawParams* dpPtr = &macButtonPtr->drawParams;
@@ -189,20 +193,19 @@ TkpDisplayButton(
return;
}
pixmap = (Pixmap) Tk_WindowId(tkwin);
- TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin));
-
- if (TkMacOSXComputeButtonDrawParams(butPtr, dpPtr) ) {
- macButtonPtr->useTkText = 0;
- } else {
- macButtonPtr->useTkText = 1;
- }
-
/*
* Set up clipping region. Make sure the we are using the port
* for this button, or we will set the wrong window's clip.
*/
+ TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin));
+
+ if (TkMacOSXComputeButtonDrawParams(butPtr, dpPtr)) {
+ macButtonPtr->useTkText = 0;
+ } else {
+ macButtonPtr->useTkText = 1;
+ }
if (macButtonPtr->useTkText) {
if (butPtr->type == TYPE_BUTTON) {
Tk_Fill3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0,
@@ -212,26 +215,42 @@ TkpDisplayButton(
Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
}
- /* Display image or bitmap or text for labels or custom controls. */
+ /*
+ * Display image or bitmap or text for labels or custom controls.
+ */
+
DrawButtonImageAndText(butPtr);
- needhighlight = 1;
+ needhighlight = 1;
} else {
- /* Draw the native portion of the buttons. */
+ /*
+ * Draw the native portion of the buttons.
+ */
+
TkMacOSXDrawButton(macButtonPtr, dpPtr->gc, pixmap);
- /* Draw highlight border, if needed. */
+ /*
+ * Ask for the highlight border, if needed.
+ */
+
if (butPtr->highlightWidth < 3) {
needhighlight = 1;
}
}
- /* Draw highlight border, if needed. */
+ /*
+ * Draw highlight border, if needed.
+ */
+
if (needhighlight) {
- if ((butPtr->flags & GOT_FOCUS)) {
- Tk_Draw3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0,
- Tk_Width(tkwin), Tk_Height(tkwin),
- butPtr->highlightWidth, TK_RELIEF_SOLID);
- }
+ GC gc = NULL;
+ if ((butPtr->flags & GOT_FOCUS) && butPtr->highlightColorPtr) {
+ gc = Tk_GCForColor(butPtr->highlightColorPtr, pixmap);
+ } else if (butPtr->type == TYPE_LABEL) {
+ gc = Tk_GCForColor(Tk_3DBorderColor(butPtr->highlightBorder), pixmap);
+ }
+ if (gc) {
+ TkMacOSXDrawSolidBorder(tkwin, gc, 0, butPtr->highlightWidth);
+ }
}
}
@@ -240,9 +259,9 @@ TkpDisplayButton(
*
* TkpComputeButtonGeometry --
*
- * After changes in a button's text or bitmap, this procedure
- * recomputes the button's geometry and passes this information
- * along to the geometry manager for the window.
+ * After changes in a button's text or bitmap, this procedure recomputes
+ * the button's geometry and passes this information along to the geometry
+ * manager for the window.
*
* Results:
* None.
@@ -259,7 +278,7 @@ TkpComputeButtonGeometry(
{
int width = 0, height = 0, charWidth = 1, haveImage = 0, haveText = 0;
int txtWidth = 0, txtHeight = 0;
- MacButton *mbPtr = (MacButton*)butPtr;
+ MacButton *mbPtr = (MacButton *) butPtr;
Tk_FontMetrics fm;
char *text = Tcl_GetString(butPtr->textPtr);
@@ -270,21 +289,27 @@ TkpComputeButtonGeometry(
*/
if (butPtr->indicatorOn) {
- switch (butPtr->type) {
- case TYPE_RADIO_BUTTON:
- GetThemeMetric(kThemeMetricRadioButtonWidth, (SInt32 *)&butPtr->indicatorDiameter);
- break;
- case TYPE_CHECK_BUTTON:
- GetThemeMetric(kThemeMetricCheckBoxWidth, (SInt32 *)&butPtr->indicatorDiameter);
- break;
- default:
- break;
- }
- /* Allow 2px extra space next to the indicator. */
- butPtr->indicatorSpace = butPtr->indicatorDiameter + 2;
+ switch (butPtr->type) {
+ case TYPE_RADIO_BUTTON:
+ GetThemeMetric(kThemeMetricRadioButtonWidth,
+ (SInt32 *) &butPtr->indicatorDiameter);
+ break;
+ case TYPE_CHECK_BUTTON:
+ GetThemeMetric(kThemeMetricCheckBoxWidth,
+ (SInt32 *) &butPtr->indicatorDiameter);
+ break;
+ default:
+ break;
+ }
+
+ /*
+ * Allow 2px extra space next to the indicator.
+ */
+
+ butPtr->indicatorSpace = butPtr->indicatorDiameter + 2;
} else {
- butPtr->indicatorSpace = 0;
- butPtr->indicatorDiameter = 0;
+ butPtr->indicatorSpace = 0;
+ butPtr->indicatorDiameter = 0;
}
if (butPtr->image != NULL) {
@@ -295,57 +320,57 @@ TkpComputeButtonGeometry(
haveImage = 1;
}
- if (strlen(text) > 0) {
+ if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) {
Tk_FreeTextLayout(butPtr->textLayout);
butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont,
- Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength,
- butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight);
+ text, -1, butPtr->wrapLength, butPtr->justify, 0,
+ &butPtr->textWidth, &butPtr->textHeight);
txtWidth = butPtr->textWidth + 2*butPtr->padX;
txtHeight = butPtr->textHeight + 2*butPtr->padY;
haveText = 1;
}
- if (haveImage && haveText) { /* Image and Text */
- switch ((enum compound) butPtr->compound) {
+ if (haveImage) {
+ if (haveText) { /* Image and Text */
+ switch ((enum compound) butPtr->compound) {
case COMPOUND_TOP:
case COMPOUND_BOTTOM:
-
/*
- * Image is above or below text.
- */
+ * Image is above or below text.
+ */
height += txtHeight + butPtr->padY;
width = (width > txtWidth ? width : txtWidth);
break;
case COMPOUND_LEFT:
case COMPOUND_RIGHT:
-
/*
- * Image is left or right of text.
- */
+ * Image is left or right of text.
+ */
width += txtWidth + 2*butPtr->padX;
height = (height > txtHeight ? height : txtHeight);
break;
case COMPOUND_CENTER:
-
/*
- * Image and text are superimposed.
- */
+ * Image and text are superimposed.
+ */
width = (width > txtWidth ? width : txtWidth);
height = (height > txtHeight ? height : txtHeight);
break;
default:
break;
+ }
}
- width += butPtr->indicatorSpace;
- } else if (haveImage) { /* Image only */
+ /* Image with or without text */
width = butPtr->width > 0 ? butPtr->width : width + butPtr->indicatorSpace;
height = butPtr->height > 0 ? butPtr->height : height;
if (butPtr->type == TYPE_BUTTON) {
- /* Allow room to shift the image. */
+ /*
+ * Allow room to shift the image.
+ */
width += 2;
height += 2;
}
@@ -375,20 +400,20 @@ TkpComputeButtonGeometry(
width += butPtr->inset*2;
height += butPtr->inset*2;
if ([NSApp macMinorVersion] == 6) {
- width += 12;
+ width += 12;
}
if (mbPtr->btnkind == kThemePushButton) {
HIRect tmpRect;
HIRect contBounds;
/*
- * A PushButton has a minimum size. We make sure that we
- * are not underestimating the size by requesting the content
- * size of a Pushbutton whose overall size is our content size
- * expanded by the standard padding.
+ * A PushButton has a minimum size. We make sure that we are not
+ * underestimating the size by requesting the content size of a
+ * Pushbutton whose overall size is our content size expanded by the
+ * standard padding.
*/
-
- tmpRect = CGRectMake(0, 0, width + 2*HI_PADX, height + 2*HI_PADY);
+
+ tmpRect = CGRectMake(0, 0, width + 2*HI_PADX, height + 2*HI_PADY);
HIThemeGetButtonContentBounds(&tmpRect, &mbPtr->drawinfo, &contBounds);
if (height < contBounds.size.height) {
height = contBounds.size.height;
@@ -402,53 +427,45 @@ TkpComputeButtonGeometry(
Tk_GeometryRequest(butPtr->tkwin, width, height);
Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset);
}
-
+
/*
*----------------------------------------------------------------------
*
* DrawButtonImageAndText --
*
- * Draws the image and text associated with a button or label.
+ * Draws the image and text associated with a button or label.
*
* Results:
- * None.
+ * None.
*
* Side effects:
- * The image and text are drawn.
+ * The image and text are drawn.
*
*----------------------------------------------------------------------
*/
static void
DrawButtonImageAndText(
- TkButton* butPtr)
+ TkButton *butPtr)
{
- MacButton *mbPtr = (MacButton*)butPtr;
- Tk_Window tkwin = butPtr->tkwin;
- Pixmap pixmap;
- int haveImage = 0;
- int haveText = 0;
- int imageWidth = 0;
- int imageHeight = 0;
- int imageXOffset = 0;
- int imageYOffset = 0;
- int textXOffset = 0;
- int textYOffset = 0;
- int width = 0;
- int height = 0;
- int fullWidth = 0;
- int fullHeight = 0;
- int pressed = 0;
-
+ MacButton *mbPtr = (MacButton *) butPtr;
+ Tk_Window tkwin = butPtr->tkwin;
+ Pixmap pixmap;
+ int haveImage = 0, haveText = 0, pressed = 0;
+ int imageWidth = 0, imageHeight = 0;
+ int imageXOffset = 0, imageYOffset = 0;
+ int textXOffset = 0, textYOffset = 0;
+ int width = 0, height = 0;
+ int fullWidth = 0, fullHeight = 0;
+ DrawParams *dpPtr = &mbPtr->drawParams;
if (tkwin == NULL || !Tk_IsMapped(tkwin)) {
return;
}
- DrawParams* dpPtr = &mbPtr->drawParams;
- pixmap = (Pixmap)Tk_WindowId(tkwin);
+ pixmap = (Pixmap) Tk_WindowId(tkwin);
- if (butPtr->image != None) {
+ if (butPtr->image != NULL) {
Tk_SizeOfImage(butPtr->image, &width, &height);
haveImage = 1;
} else if (butPtr->bitmap != None) {
@@ -456,74 +473,64 @@ DrawButtonImageAndText(
haveImage = 1;
}
- imageWidth = width;
+ imageWidth = width;
imageHeight = height;
if (mbPtr->drawinfo.state == kThemeStatePressed) {
- /* Offset bitmaps by a bit when the button is pressed. */
pressed = 1;
}
haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);
- if (haveImage && haveText) { /* Image and Text */
- int x;
- int y;
- textXOffset = 0;
- textYOffset = 0;
- fullWidth = 0;
- fullHeight = 0;
+ if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { /* Image and Text */
+ int x, y;
switch ((enum compound) butPtr->compound) {
case COMPOUND_TOP:
- case COMPOUND_BOTTOM: {
- /* Image is above or below text */
- if (butPtr->compound == COMPOUND_TOP) {
- textYOffset = height + butPtr->padY;
- } else {
- imageYOffset = butPtr->textHeight + butPtr->padY;
- }
- fullHeight = height + butPtr->textHeight + butPtr->padY;
- fullWidth = (width > butPtr->textWidth ? width :
- butPtr->textWidth);
- textXOffset = (fullWidth - butPtr->textWidth)/2;
- imageXOffset = (fullWidth - width)/2;
- break;
- }
+ case COMPOUND_BOTTOM:
+ /* Image is above or below text */
+ if (butPtr->compound == COMPOUND_TOP) {
+ textYOffset = height + butPtr->padY;
+ } else {
+ imageYOffset = butPtr->textHeight + butPtr->padY;
+ }
+ fullHeight = height + butPtr->textHeight + butPtr->padY;
+ fullWidth = (width > butPtr->textWidth ? width : butPtr->textWidth);
+ textXOffset = (fullWidth - butPtr->textWidth)/2;
+ imageXOffset = (fullWidth - width)/2;
+ break;
case COMPOUND_LEFT:
- case COMPOUND_RIGHT: {
- /*
- * Image is left or right of text
- */
-
- if (butPtr->compound == COMPOUND_LEFT) {
- textXOffset = width + butPtr->padX;
- } else {
- imageXOffset = butPtr->textWidth + butPtr->padX;
- }
- fullWidth = butPtr->textWidth + butPtr->padX + width;
- fullHeight = (height > butPtr->textHeight ? height :
- butPtr->textHeight);
- textYOffset = (fullHeight - butPtr->textHeight)/2;
- imageYOffset = (fullHeight - height)/2;
- break;
- }
- case COMPOUND_CENTER: {
- /*
- * Image and text are superimposed
- */
-
- fullWidth = (width > butPtr->textWidth ? width :
- butPtr->textWidth);
- fullHeight = (height > butPtr->textHeight ? height :
- butPtr->textHeight);
- textXOffset = (fullWidth - butPtr->textWidth)/2;
- imageXOffset = (fullWidth - width)/2;
- textYOffset = (fullHeight - butPtr->textHeight)/2;
- imageYOffset = (fullHeight - height)/2;
- break;
- }
+ case COMPOUND_RIGHT:
+ /*
+ * Image is left or right of text
+ */
+
+ if (butPtr->compound == COMPOUND_LEFT) {
+ textXOffset = width + butPtr->padX;
+ } else {
+ imageXOffset = butPtr->textWidth + butPtr->padX;
+ }
+ fullWidth = butPtr->textWidth + butPtr->padX + width;
+ fullHeight = (height > butPtr->textHeight ? height :
+ butPtr->textHeight);
+ textYOffset = (fullHeight - butPtr->textHeight)/2;
+ imageYOffset = (fullHeight - height)/2;
+ break;
+ case COMPOUND_CENTER:
+ /*
+ * Image and text are superimposed
+ */
+
+ fullWidth = (width > butPtr->textWidth ? width :
+ butPtr->textWidth);
+ fullHeight = (height > butPtr->textHeight ? height :
+ butPtr->textHeight);
+ textXOffset = (fullWidth - butPtr->textWidth)/2;
+ imageXOffset = (fullWidth - width)/2;
+ textYOffset = (fullHeight - butPtr->textHeight)/2;
+ imageYOffset = (fullHeight - height)/2;
+ break;
default:
- break;
+ break;
}
TkComputeAnchor(butPtr->anchor, tkwin,
@@ -547,79 +554,74 @@ DrawButtonImageAndText(
imageYOffset += y;
if (butPtr->image != NULL) {
- if ((butPtr->selectImage != NULL) &&
- (butPtr->flags & SELECTED)) {
- Tk_RedrawImage(butPtr->selectImage, 0, 0,
- width, height, pixmap, imageXOffset, imageYOffset);
- } else if ((butPtr->tristateImage != NULL) &&
- (butPtr->flags & TRISTATED)) {
- Tk_RedrawImage(butPtr->tristateImage, 0, 0,
- width, height, pixmap, imageXOffset, imageYOffset);
- } else {
- Tk_RedrawImage(butPtr->image, 0, 0, width,
- height, pixmap, imageXOffset, imageYOffset);
- }
+ if ((butPtr->selectImage != NULL) &&
+ (butPtr->flags & SELECTED)) {
+ Tk_RedrawImage(butPtr->selectImage, 0, 0,
+ width, height, pixmap, imageXOffset, imageYOffset);
+ } else if ((butPtr->tristateImage != NULL) &&
+ (butPtr->flags & TRISTATED)) {
+ Tk_RedrawImage(butPtr->tristateImage, 0, 0,
+ width, height, pixmap, imageXOffset, imageYOffset);
+ } else {
+ Tk_RedrawImage(butPtr->image, 0, 0, width,
+ height, pixmap, imageXOffset, imageYOffset);
+ }
} else {
- XSetClipOrigin(butPtr->display, dpPtr->gc,
- imageXOffset, imageYOffset);
- XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc,
- 0, 0, (unsigned int) width, (unsigned int) height,
- imageXOffset, imageYOffset, 1);
- XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0);
+ XSetClipOrigin(butPtr->display, dpPtr->gc,
+ imageXOffset, imageYOffset);
+ XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc,
+ 0, 0, (unsigned int) width, (unsigned int) height,
+ imageXOffset, imageYOffset, 1);
+ XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0);
}
-
y += 1; /* Tweak to match native buttons. */
- Tk_DrawTextLayout(butPtr->display, pixmap,
- dpPtr->gc, butPtr->textLayout,
- x + textXOffset, y + textYOffset, 0, -1);
+ Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, butPtr->textLayout,
+ x + textXOffset, y + textYOffset, 0, -1);
Tk_UnderlineTextLayout(butPtr->display, pixmap, dpPtr->gc,
butPtr->textLayout,
x + textXOffset, y + textYOffset,
butPtr->underline);
} else if (haveImage) { /* Image only */
- int x = 0;
- int y;
+ int x = 0, y;
+
TkComputeAnchor(butPtr->anchor, tkwin,
- butPtr->padX + butPtr->borderWidth,
- butPtr->padY + butPtr->borderWidth,
- width + butPtr->indicatorSpace,
- height, &x, &y);
+ butPtr->padX + butPtr->borderWidth,
+ butPtr->padY + butPtr->borderWidth,
+ width + butPtr->indicatorSpace, height, &x, &y);
x += butPtr->indicatorSpace;
if (pressed) {
- x += dpPtr->offset;
- y += dpPtr->offset;
+ x += dpPtr->offset;
+ y += dpPtr->offset;
}
imageXOffset += x;
imageYOffset += y;
if (butPtr->image != NULL) {
-
- if ((butPtr->selectImage != NULL) &&
- (butPtr->flags & SELECTED)) {
- Tk_RedrawImage(butPtr->selectImage, 0, 0, width,
- height, pixmap, imageXOffset, imageYOffset);
- } else if ((butPtr->tristateImage != NULL) &&
- (butPtr->flags & TRISTATED)) {
- Tk_RedrawImage(butPtr->tristateImage, 0, 0, width,
- height, pixmap, imageXOffset, imageYOffset);
- } else {
- Tk_RedrawImage(butPtr->image, 0, 0, width, height,
- pixmap, imageXOffset, imageYOffset);
- }
+ if ((butPtr->selectImage != NULL) &&
+ (butPtr->flags & SELECTED)) {
+ Tk_RedrawImage(butPtr->selectImage, 0, 0, width,
+ height, pixmap, imageXOffset, imageYOffset);
+ } else if ((butPtr->tristateImage != NULL) &&
+ (butPtr->flags & TRISTATED)) {
+ Tk_RedrawImage(butPtr->tristateImage, 0, 0, width,
+ height, pixmap, imageXOffset, imageYOffset);
+ } else {
+ Tk_RedrawImage(butPtr->image, 0, 0, width, height,
+ pixmap, imageXOffset, imageYOffset);
+ }
} else {
- XSetClipOrigin(butPtr->display, dpPtr->gc, x, y);
- XCopyPlane(butPtr->display, butPtr->bitmap,
- pixmap, dpPtr->gc,
- 0, 0, (unsigned int) width,
- (unsigned int) height,
- imageXOffset, imageYOffset, 1);
- XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0);
+ XSetClipOrigin(butPtr->display, dpPtr->gc, x, y);
+ XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, dpPtr->gc,
+ 0, 0, (unsigned int) width, (unsigned int) height,
+ imageXOffset, imageYOffset, 1);
+ XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0);
}
} else { /* Text only */
int x, y;
+
TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
- butPtr->textWidth + butPtr->indicatorSpace,
- butPtr->textHeight, &x, &y);
+ butPtr->textWidth + butPtr->indicatorSpace,
+ butPtr->textHeight, &x, &y);
x += butPtr->indicatorSpace;
y += 1; /* Tweak to match native buttons */
Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, butPtr->textLayout,
@@ -628,9 +630,9 @@ DrawButtonImageAndText(
/*
* If the button is disabled with a stipple rather than a special
- * foreground color, generate the stippled effect. If the widget
- * is selected and we use a different background color when selected,
- * must temporarily modify the GC so the stippling is the right color.
+ * foreground color, generate the stippled effect. If the widget is
+ * selected and we use a different background color when selected, must
+ * temporarily modify the GC so the stippling is the right color.
*/
if (mbPtr->useTkText) {
@@ -668,18 +670,15 @@ DrawButtonImageAndText(
*/
if (dpPtr->relief != TK_RELIEF_FLAT) {
- int inset = butPtr->highlightWidth;
- Tk_Draw3DRectangle(tkwin, pixmap, dpPtr->border, inset, inset,
- Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset,
- butPtr->borderWidth, dpPtr->relief);
+ int inset = butPtr->highlightWidth;
+
+ Tk_Draw3DRectangle(tkwin, pixmap, dpPtr->border, inset, inset,
+ Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset,
+ butPtr->borderWidth, dpPtr->relief);
}
}
-
- }
-
-
-
-
+}
+
/*
*----------------------------------------------------------------------
*
@@ -701,6 +700,7 @@ TkpDestroyButton(
TkButton *butPtr)
{
MacButton *mbPtr = (MacButton *) butPtr; /* Mac button. */
+
if (mbPtr->defaultPulseHandler) {
Tcl_DeleteTimerHandler(mbPtr->defaultPulseHandler);
}
@@ -711,9 +711,8 @@ TkpDestroyButton(
*
* TkMacOSXDrawButton --
*
- * This function draws the tk button using Mac controls
- * In addition, this code may apply custom colors passed
- * in the TkButton.
+ * This function draws the tk button using Mac controls. In addition,
+ * this code may apply custom colors passed in the TkButton.
*
* Results:
* None.
@@ -732,23 +731,20 @@ TkMacOSXDrawButton(
Pixmap pixmap) /* The pixmap we are drawing into - needed
* for the bevel button */
{
- TkButton * butPtr = ( TkButton *)mbPtr;
- TkWindow * winPtr;
- HIRect cntrRect;
+ TkButton *butPtr = (TkButton *) mbPtr;
+ TkWindow *winPtr = (TkWindow *) butPtr->tkwin;
+ HIRect cntrRect;
TkMacOSXDrawingContext dc;
- DrawParams* dpPtr = &mbPtr->drawParams;
+ DrawParams *dpPtr = &mbPtr->drawParams;
int useNewerHITools = 1;
-
- winPtr = (TkWindow *)butPtr->tkwin;
+ (void)gc;
TkMacOSXComputeButtonParams(butPtr, &mbPtr->btnkind, &mbPtr->drawinfo);
- cntrRect = CGRectMake(winPtr->privatePtr->xOff,
- winPtr->privatePtr->yOff,
- Tk_Width(butPtr->tkwin),
- Tk_Height(butPtr->tkwin));
+ cntrRect = CGRectMake(winPtr->privatePtr->xOff, winPtr->privatePtr->yOff,
+ Tk_Width(butPtr->tkwin), Tk_Height(butPtr->tkwin));
- cntrRect = CGRectInset(cntrRect, butPtr->inset, butPtr->inset);
+ cntrRect = CGRectInset(cntrRect, butPtr->inset, butPtr->inset);
if (useNewerHITools == 1) {
HIRect contHIRec;
@@ -762,7 +758,7 @@ TkMacOSXDrawButton(
hiinfo.version = 0;
hiinfo.state = mbPtr->drawinfo.state;
- hiinfo.kind = mbPtr->btnkind;
+ hiinfo.kind = mbPtr->btnkind;
hiinfo.value = mbPtr->drawinfo.value;
hiinfo.adornment = mbPtr->drawinfo.adornment;
hiinfo.animation.time.current = CFAbsoluteTimeGetCurrent();
@@ -770,13 +766,24 @@ TkMacOSXDrawButton(
hiinfo.animation.time.start = hiinfo.animation.time.current;
}
- HIThemeDrawButton(&cntrRect, &hiinfo, dc.context, kHIThemeOrientationNormal,
- &contHIRec);
+ /*
+ * To avoid buttons with white text on a white background, we set the
+ * state to inactive in Dark Mode unless the button is pressed or is a
+ * -default active button. This isn't perfect but it is mostly usable.
+ * Using a ttk::button would be a much better choice, however.
+ */
+
+ if (TkMacOSXInDarkMode(butPtr->tkwin) &&
+ mbPtr->drawinfo.state != kThemeStatePressed &&
+ !(mbPtr->drawinfo.adornment & kThemeAdornmentDefault)) {
+ hiinfo.state = kThemeStateInactive;
+ }
+ HIThemeDrawButton(&cntrRect, &hiinfo, dc.context,
+ kHIThemeOrientationNormal, &contHIRec);
TkMacOSXRestoreDrawingContext(&dc);
ButtonContentDrawCB(&contHIRec, mbPtr->btnkind, &mbPtr->drawinfo,
- (MacButton *)mbPtr, 32, true);
-
+ (MacButton *) mbPtr, 32, true);
} else {
if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) {
return;
@@ -792,8 +799,8 @@ TkMacOSXDrawButton(
*
* ButtonBackgroundDrawCB --
*
- * This function draws the background that
- * lies under checkboxes and radiobuttons.
+ * This function draws the background that lies under checkboxes and
+ * radiobuttons.
*
* Results:
* None.
@@ -803,32 +810,36 @@ TkMacOSXDrawButton(
*
*--------------------------------------------------------------
*/
+
static void
-ButtonBackgroundDrawCB (
- const HIRect * btnbounds,
+ButtonBackgroundDrawCB(
+ const HIRect *btnbounds,
MacButton *ptr,
SInt16 depth,
Boolean isColorDev)
{
- MacButton* mbPtr = (MacButton*)ptr;
- TkButton* butPtr = (TkButton*)mbPtr;
- Tk_Window tkwin = butPtr->tkwin;
+ MacButton *mbPtr = (MacButton *) ptr;
+ TkButton *butPtr = (TkButton *) mbPtr;
+ Tk_Window tkwin = butPtr->tkwin;
Pixmap pixmap;
int usehlborder = 0;
+ (void)btnbounds;
+ (void)depth;
+ (void)isColorDev;
if (tkwin == NULL || !Tk_IsMapped(tkwin)) {
return;
}
- pixmap = (Pixmap)Tk_WindowId(tkwin);
+ pixmap = (Pixmap) Tk_WindowId(tkwin);
if (butPtr->type != TYPE_LABEL) {
switch (mbPtr->btnkind) {
- case kThemeSmallBevelButton:
- case kThemeBevelButton:
- case kThemeRoundedBevelButton:
- case kThemePushButton:
- usehlborder = 1;
- break;
+ case kThemeSmallBevelButton:
+ case kThemeBevelButton:
+ case kThemeRoundedBevelButton:
+ case kThemePushButton:
+ usehlborder = 1;
+ break;
}
}
if (usehlborder) {
@@ -864,17 +875,23 @@ ButtonContentDrawCB (
SInt16 depth,
Boolean isColorDev)
{
- TkButton *butPtr = (TkButton *)ptr;
- Tk_Window tkwin = butPtr->tkwin;
+ TkButton *butPtr = (TkButton *) ptr;
+ Tk_Window tkwin = butPtr->tkwin;
+ (void)btnbounds;
+ (void)kind;
+ (void)drawinfo;
+ (void)depth;
+ (void)isColorDev;
if (tkwin == NULL || !Tk_IsMapped(tkwin)) {
return;
}
/*
- * Overlay Tk elements over button native region: drawing elements
- * within button boundaries/native region causes unpredictable metrics.
+ * Overlay Tk elements over button native region: drawing elements within
+ * button boundaries/native region causes unpredictable metrics.
*/
+
DrawButtonImageAndText( butPtr);
}
@@ -883,8 +900,8 @@ ButtonContentDrawCB (
*
* ButtonEventProc --
*
- * This procedure is invoked by the Tk dispatcher for various
- * events on buttons.
+ * This procedure is invoked by the Tk dispatcher for various events on
+ * buttons.
*
* Results:
* None.
@@ -900,8 +917,8 @@ ButtonEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkButton *buttonPtr = (TkButton *) clientData;
- MacButton *mbPtr = (MacButton *) clientData;
+ TkButton *buttonPtr = clientData;
+ MacButton *mbPtr = clientData;
if (eventPtr->type == ActivateNotify
|| eventPtr->type == DeactivateNotify) {
@@ -914,7 +931,7 @@ ButtonEventProc(
mbPtr->flags &= ~ACTIVE;
}
if ((buttonPtr->flags & REDRAW_PENDING) == 0) {
- Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) buttonPtr);
+ Tcl_DoWhenIdle(TkpDisplayButton, buttonPtr);
buttonPtr->flags |= REDRAW_PENDING;
}
}
@@ -925,9 +942,9 @@ ButtonEventProc(
*
* TkMacOSXComputeButtonParams --
*
- * This procedure computes the various parameters used
- * when creating a Carbon Appearance control.
- * These are determined by the various tk button parameters
+ * This procedure computes the various parameters used when creating a
+ * Carbon Appearance control. These are determined by the various tk
+ * button parameters
*
* Results:
* None.
@@ -940,11 +957,11 @@ ButtonEventProc(
static void
TkMacOSXComputeButtonParams(
- TkButton * butPtr,
- ThemeButtonKind* btnkind,
- HIThemeButtonDrawInfo *drawinfo)
+ TkButton *butPtr,
+ ThemeButtonKind *btnkind,
+ HIThemeButtonDrawInfo *drawinfo)
{
- MacButton *mbPtr = (MacButton *)butPtr;
+ MacButton *mbPtr = (MacButton *) butPtr;
if (butPtr->borderWidth <= 2) {
*btnkind = kThemeSmallBevelButton;
@@ -958,47 +975,46 @@ TkMacOSXComputeButtonParams(
if ((butPtr->image == None) && (butPtr->bitmap == None)) {
switch (butPtr->type) {
- case TYPE_BUTTON:
- *btnkind = kThemePushButton;
- break;
- case TYPE_RADIO_BUTTON:
- if (butPtr->borderWidth <= 1) {
- *btnkind = kThemeSmallRadioButton;
- } else {
- *btnkind = kThemeRadioButton;
- }
- break;
- case TYPE_CHECK_BUTTON:
- if (butPtr->borderWidth <= 1) {
- *btnkind = kThemeSmallCheckBox;
- } else {
- *btnkind = kThemeCheckBox;
- }
- break;
+ case TYPE_BUTTON:
+ *btnkind = kThemePushButton;
+ break;
+ case TYPE_RADIO_BUTTON:
+ if (butPtr->borderWidth <= 1) {
+ *btnkind = kThemeSmallRadioButton;
+ } else {
+ *btnkind = kThemeRadioButton;
+ }
+ break;
+ case TYPE_CHECK_BUTTON:
+ if (butPtr->borderWidth <= 1) {
+ *btnkind = kThemeSmallCheckBox;
+ } else {
+ *btnkind = kThemeCheckBox;
+ }
+ break;
}
}
if (butPtr->indicatorOn) {
switch (butPtr->type) {
- case TYPE_RADIO_BUTTON:
- if (butPtr->borderWidth <= 1) {
- *btnkind = kThemeSmallRadioButton;
- } else {
- *btnkind = kThemeRadioButton;
- }
- break;
- case TYPE_CHECK_BUTTON:
- if (butPtr->borderWidth <= 1) {
- *btnkind = kThemeSmallCheckBox;
- } else {
- *btnkind = kThemeCheckBox;
- }
- break;
+ case TYPE_RADIO_BUTTON:
+ if (butPtr->borderWidth <= 1) {
+ *btnkind = kThemeSmallRadioButton;
+ } else {
+ *btnkind = kThemeRadioButton;
+ }
+ break;
+ case TYPE_CHECK_BUTTON:
+ if (butPtr->borderWidth <= 1) {
+ *btnkind = kThemeSmallCheckBox;
+ } else {
+ *btnkind = kThemeCheckBox;
+ }
+ break;
}
} else {
if (butPtr->type == TYPE_RADIO_BUTTON ||
- butPtr->type == TYPE_CHECK_BUTTON
- ) {
+ butPtr->type == TYPE_CHECK_BUTTON) {
if (*btnkind == kThemePushButton) {
*btnkind = kThemeBevelButton;
}
@@ -1037,11 +1053,19 @@ TkMacOSXComputeButtonParams(
drawinfo->adornment = kThemeAdornmentNone;
if (butPtr->defaultState == DEFAULT_ACTIVE) {
- drawinfo->adornment |= kThemeAdornmentDefault;
- if (!mbPtr->defaultPulseHandler) {
+ if (drawinfo->state != kThemeStatePressed) {
+ drawinfo->adornment |= kThemeAdornmentDefault;
+ }
+
+ /*
+ * Older macOS systems (10.9 and earlier) use an animation to
+ * indicate the active button. This is simulated by redrawing
+ * the button periodically.
+ */
+
+ if (!mbPtr->defaultPulseHandler && ([NSApp macMinorVersion] <= 9)) {
mbPtr->defaultPulseHandler = Tcl_CreateTimerHandler(
- PULSE_TIMER_MSECS, PulseDefaultButtonProc,
- (ClientData) butPtr);
+ PULSE_TIMER_MSECS, PulseDefaultButtonProc, butPtr);
}
} else if (mbPtr->defaultPulseHandler) {
Tcl_DeleteTimerHandler(mbPtr->defaultPulseHandler);
@@ -1058,9 +1082,8 @@ TkMacOSXComputeButtonParams(
*
* TkMacOSXComputeButtonDrawParams --
*
- * This procedure computes the various parameters used
- * when drawing a button
- * These are determined by the various tk button parameters
+ * This procedure computes the various parameters used when drawing a
+ * button. These are determined by the various tk button parameters
*
* Results:
* 1 if control will be used, 0 otherwise.
@@ -1076,7 +1099,7 @@ TkMacOSXComputeButtonDrawParams(
TkButton *butPtr,
DrawParams *dpPtr)
{
- MacButton *mbPtr = (MacButton *)butPtr;
+ MacButton *mbPtr = (MacButton *) butPtr;
dpPtr->hasImageOrBitmap = ((butPtr->image != NULL)
|| (butPtr->bitmap != None));
@@ -1085,12 +1108,12 @@ TkMacOSXComputeButtonDrawParams(
dpPtr->offset = 0;
if (dpPtr->hasImageOrBitmap) {
switch (mbPtr->btnkind) {
- case kThemeSmallBevelButton:
- case kThemeBevelButton:
- case kThemeRoundedBevelButton:
- case kThemePushButton:
- dpPtr->offset = 1;
- break;
+ case kThemeSmallBevelButton:
+ case kThemeBevelButton:
+ case kThemeRoundedBevelButton:
+ case kThemePushButton:
+ dpPtr->offset = 1;
+ break;
}
}
}
@@ -1101,6 +1124,13 @@ TkMacOSXComputeButtonDrawParams(
} else if (butPtr->type == TYPE_BUTTON && butPtr->state == STATE_ACTIVE) {
dpPtr->gc = butPtr->activeTextGC;
dpPtr->border = butPtr->activeBorder;
+ } else if ((mbPtr->drawinfo.adornment & kThemeAdornmentDefault) &&
+ mbPtr->drawinfo.state == kThemeStateActive) {
+ /*
+ * This is a "-default active" button in the front window.
+ */
+
+ dpPtr->gc = butPtr->activeTextGC;
} else {
dpPtr->gc = butPtr->normalTextGC;
}
@@ -1111,8 +1141,8 @@ TkMacOSXComputeButtonDrawParams(
}
/*
- * Override the relief specified for the button if this is a
- * checkbutton or radiobutton and there's no indicator.
+ * Override the relief specified for the button if this is a checkbutton or
+ * radiobutton and there's no indicator.
*/
dpPtr->relief = butPtr->relief;
@@ -1124,22 +1154,18 @@ TkMacOSXComputeButtonDrawParams(
}
}
- if (butPtr->type != TYPE_LABEL &&
- (butPtr->type == TYPE_BUTTON ||
- butPtr->indicatorOn ||
- dpPtr->hasImageOrBitmap)) {
-
+ if (butPtr->type != TYPE_LABEL && (butPtr->type == TYPE_BUTTON ||
+ butPtr->indicatorOn || dpPtr->hasImageOrBitmap)) {
/*
* Draw this widget as a native control.
*/
-
+
return 1;
} else {
-
/*
* Draw this widget from scratch.
*/
-
+
return 0;
}
}
@@ -1160,15 +1186,24 @@ TkMacOSXComputeButtonDrawParams(
*
*--------------------------------------------------------------
*/
+
static void
PulseDefaultButtonProc(ClientData clientData)
{
- MacButton *mbPtr = (MacButton *)clientData;
+ MacButton *mbPtr = clientData;
+
TkpDisplayButton(clientData);
+ /*
+ * Fix 40ada90762: any idle calls to TkpDisplayButton need to be canceled
+ * in case the button is destroyed and has its data freed before the idle
+ * event is handled (DestroyButton only cancels calls when REDRAW_PENDING
+ * is set, which is not the case after calling TkpDisplayButton directly).
+ */
+ Tcl_CancelIdleCall(TkpDisplayButton, clientData);
mbPtr->defaultPulseHandler = Tcl_CreateTimerHandler(
PULSE_TIMER_MSECS, PulseDefaultButtonProc, clientData);
}
-
+
/*
* Local Variables:
* mode: objc
diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c
index efd3c69..7df5bb9 100644
--- a/macosx/tkMacOSXClipboard.c
+++ b/macosx/tkMacOSXClipboard.c
@@ -35,10 +35,9 @@ static Tk_Window clipboardOwner = NULL;
targetPtr->type == dispPtr->utf8Atom) {
for (TkClipboardBuffer *cbPtr = targetPtr->firstBufferPtr;
cbPtr; cbPtr = cbPtr->nextPtr) {
- NSString *s = [[NSString alloc] initWithBytesNoCopy:
- cbPtr->buffer length:cbPtr->length
- encoding:NSUTF8StringEncoding freeWhenDone:NO];
-
+ NSString *s = [[TKNSString alloc]
+ initWithTclUtfBytes:cbPtr->buffer
+ length:cbPtr->length];
[string appendString:s];
[s release];
}
@@ -123,8 +122,9 @@ TkSelGetSelection(
{
int result = TCL_ERROR;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
+ int haveExternalClip =
+ ([[NSPasteboard generalPasteboard] changeCount] != changeCount);
- int haveExternalClip = ([[NSPasteboard generalPasteboard] changeCount] != changeCount);
if (dispPtr && (haveExternalClip || dispPtr->clipboardActive)
&& selection == dispPtr->clipboardAtom
&& (target == XA_STRING || target == dispPtr->utf8Atom)) {
@@ -136,12 +136,20 @@ TkSelGetSelection(
if (type) {
string = [pb stringForType:type];
}
- result = proc(clientData, interp, string ? [string UTF8String] : "");
+ if (string) {
+ if (target == dispPtr->utf8Atom) {
+ result = proc(clientData, interp, string.UTF8String);
+ } else if (target == XA_STRING) {
+ const char *latin1 = [string
+ cStringUsingEncoding:NSISOLatin1StringEncoding];
+ result = proc(clientData, interp, latin1);
+ }
+ }
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "%s selection doesn't exist or form \"%s\" not defined",
- Tk_GetAtomName(tkwin, selection),
- Tk_GetAtomName(tkwin, target)));
+ "%s selection doesn't exist or form \"%s\" not defined",
+ Tk_GetAtomName(tkwin, selection),
+ Tk_GetAtomName(tkwin, target)));
Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", NULL);
}
return result;
@@ -172,11 +180,13 @@ XSetSelectionOwner(
Time time) /* The current time? */
{
TkDisplay *dispPtr = TkGetDisplayList();
+ (void)time;
if (dispPtr && selection == dispPtr->clipboardAtom) {
clipboardOwner = owner ? Tk_IdToWindow(display, owner) : NULL;
if (!dispPtr->clipboardActive) {
NSPasteboard *pb = [NSPasteboard generalPasteboard];
+
changeCount = [pb declareTypes:[NSArray array] owner:NSApp];
}
}
@@ -188,8 +198,8 @@ XSetSelectionOwner(
*
* TkMacOSXSelDeadWindow --
*
- * This function is invoked just before a TkWindow is deleted. It
- * performs selection-related cleanup.
+ * This function is invoked just before a TkWindow is deleted. It performs
+ * selection-related cleanup.
*
* Results:
* None.
@@ -233,6 +243,8 @@ TkSelUpdateClipboard(
/* Info about the content. */
{
NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ (void)winPtr;
+ (void)targetPtr;
changeCount = [pb addTypes:[NSArray arrayWithObject:NSStringPboardType]
owner:NSApp];
@@ -257,7 +269,7 @@ TkSelUpdateClipboard(
void
TkSelEventProc(
Tk_Window tkwin, /* Window for which event was targeted. */
- register XEvent *eventPtr) /* X event: either SelectionClear,
+ XEvent *eventPtr) /* X event: either SelectionClear,
* SelectionRequest, or SelectionNotify. */
{
if (eventPtr->type == SelectionClear) {
@@ -285,8 +297,9 @@ TkSelEventProc(
void
TkSelPropProc(
- register XEvent *eventPtr) /* X PropertyChange event. */
+ XEvent *eventPtr) /* X PropertyChange event. */
{
+ (void)eventPtr;
}
/*
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
index 459ca47..40b537e 100644
--- a/macosx/tkMacOSXColor.c
+++ b/macosx/tkMacOSXColor.c
@@ -17,11 +17,32 @@
#include "tkMacOSXPrivate.h"
#include "tkColor.h"
+/*
+ * The colorType specifies how the color value should be interpreted. For the
+ * unique rgbColor entry, the RGB values are generated from the pixel value of
+ * an XColor. The ttkBackground and semantic types are dynamic, meaning
+ * that they change when dark mode is enabled on OSX 10.13 and later.
+ */
+
+enum colorType {
+ clearColor, /* There should be only one of these. */
+ rgbColor, /* There should be only one of these. */
+ appearance, /* There should be only one of these. */
+ HIBrush, /* The value is a HITheme brush color table index. */
+ HIText, /* The value is a HITheme text color table index. */
+ HIBackground, /* The value is a HITheme background color table index. */
+ ttkBackground, /* The value can be used as a parameter.*/
+ semantic, /* The value can be used as a parameter.*/
+};
+
+/*
+
+ */
+
struct SystemColorMapEntry {
const char *name;
- ThemeBrush brush;
- ThemeTextColor textColor;
- ThemeBackgroundKind background;
+ enum colorType type;
+ long value;
}; /* unsigned char pixelCode; */
/*
@@ -32,157 +53,181 @@ struct SystemColorMapEntry {
#define MIN_PIXELCODE 30
static const struct SystemColorMapEntry systemColorMap[] = {
- { "Transparent", 0, 0, 0 }, /* 30: TRANSPARENT_PIXEL */
- { "Highlight", kThemeBrushPrimaryHighlightColor, 0, 0 }, /* 31: HIGHLIGHT_PIXEL */
- { "HighlightSecondary", kThemeBrushSecondaryHighlightColor, 0, 0 }, /* 32: HIGHLIGHT_SECONDARY_PIXEL */
- { "HighlightText", kThemeBrushBlack, 0, 0 }, /* 33: HIGHLIGHT_TEXT_PIXEL */
- { "HighlightAlternate", kThemeBrushAlternatePrimaryHighlightColor, 0, 0 }, /* 34: HIGHLIGHT_ALTERNATE_PIXEL */
- { "ButtonText", 0, kThemeTextColorPushButtonActive, 0 }, /* 35: CONTROL_TEXT_PIXEL */
- { "PrimaryHighlightColor", kThemeBrushPrimaryHighlightColor, 0, 0 }, /* 36 */
- { "ButtonFace", kThemeBrushButtonFaceActive, 0, 0 }, /* 37: CONTROL_BODY_PIXEL */
- { "SecondaryHighlightColor", kThemeBrushSecondaryHighlightColor, 0, 0 }, /* 38 */
- { "ButtonFrame", kThemeBrushButtonFrameActive, 0, 0 }, /* 39: CONTROL_FRAME_PIXEL */
- { "AlternatePrimaryHighlightColor", kThemeBrushAlternatePrimaryHighlightColor, 0, 0 }, /* 40 */
- { "WindowBody", kThemeBrushDocumentWindowBackground, 0, 0 }, /* 41: WINDOW_BODY_PIXEL */
- { "SheetBackground", kThemeBrushSheetBackground, 0, 0 }, /* 42 */
- { "MenuActive", kThemeBrushMenuBackgroundSelected, 0, 0 }, /* 43: MENU_ACTIVE_PIXEL */
- { "Black", kThemeBrushBlack, 0, 0 }, /* 44 */
- { "MenuActiveText", 0, kThemeTextColorMenuItemSelected, 0 }, /* 45: MENU_ACTIVE_TEXT_PIXEL */
- { "White", kThemeBrushWhite, 0, 0 }, /* 46 */
- { "Menu", kThemeBrushMenuBackground, 0, 0 }, /* 47: MENU_BACKGROUND_PIXEL */
- { "DialogBackgroundActive", kThemeBrushDialogBackgroundActive, 0, 0 }, /* 48 */
- { "MenuDisabled", 0, kThemeTextColorMenuItemDisabled, 0 }, /* 49: MENU_DISABLED_PIXEL */
- { "DialogBackgroundInactive", kThemeBrushDialogBackgroundInactive, 0, 0 }, /* 50 */
- { "MenuText", 0, kThemeTextColorMenuItemActive, 0 }, /* 51: MENU_TEXT_PIXEL */
- { "AppearanceColor", 0, 0, 0 }, /* 52: APPEARANCE_PIXEL */
- { "AlertBackgroundActive", kThemeBrushAlertBackgroundActive, 0, 0 }, /* 53 */
- { "AlertBackgroundInactive", kThemeBrushAlertBackgroundInactive, 0, 0 }, /* 54 */
- { "ModelessDialogBackgroundActive", kThemeBrushModelessDialogBackgroundActive, 0, 0 }, /* 55 */
- { "ModelessDialogBackgroundInactive", kThemeBrushModelessDialogBackgroundInactive, 0, 0 }, /* 56 */
- { "UtilityWindowBackgroundActive", kThemeBrushUtilityWindowBackgroundActive, 0, 0 }, /* 57 */
- { "UtilityWindowBackgroundInactive", kThemeBrushUtilityWindowBackgroundInactive, 0, 0 }, /* 58 */
- { "ListViewSortColumnBackground", kThemeBrushListViewSortColumnBackground, 0, 0 }, /* 59 */
- { "ListViewBackground", kThemeBrushListViewBackground, 0, 0 }, /* 60 */
- { "IconLabelBackground", kThemeBrushIconLabelBackground, 0, 0 }, /* 61 */
- { "ListViewSeparator", kThemeBrushListViewSeparator, 0, 0 }, /* 62 */
- { "ChasingArrows", kThemeBrushChasingArrows, 0, 0 }, /* 63 */
- { "DragHilite", kThemeBrushDragHilite, 0, 0 }, /* 64 */
- { "DocumentWindowBackground", kThemeBrushDocumentWindowBackground, 0, 0 }, /* 65 */
- { "FinderWindowBackground", kThemeBrushFinderWindowBackground, 0, 0 }, /* 66 */
- { "ScrollBarDelimiterActive", kThemeBrushScrollBarDelimiterActive, 0, 0 }, /* 67 */
- { "ScrollBarDelimiterInactive", kThemeBrushScrollBarDelimiterInactive, 0, 0 }, /* 68 */
- { "FocusHighlight", kThemeBrushFocusHighlight, 0, 0 }, /* 69 */
- { "PopupArrowActive", kThemeBrushPopupArrowActive, 0, 0 }, /* 70 */
- { "PopupArrowPressed", kThemeBrushPopupArrowPressed, 0, 0 }, /* 71 */
- { "PopupArrowInactive", kThemeBrushPopupArrowInactive, 0, 0 }, /* 72 */
- { "AppleGuideCoachmark", kThemeBrushAppleGuideCoachmark, 0, 0 }, /* 73 */
- { "IconLabelBackgroundSelected", kThemeBrushIconLabelBackgroundSelected, 0, 0 }, /* 74 */
- { "StaticAreaFill", kThemeBrushStaticAreaFill, 0, 0 }, /* 75 */
- { "ActiveAreaFill", kThemeBrushActiveAreaFill, 0, 0 }, /* 76 */
- { "ButtonFrameActive", kThemeBrushButtonFrameActive, 0, 0 }, /* 77 */
- { "ButtonFrameInactive", kThemeBrushButtonFrameInactive, 0, 0 }, /* 78 */
- { "ButtonFaceActive", kThemeBrushButtonFaceActive, 0, 0 }, /* 79 */
- { "ButtonFaceInactive", kThemeBrushButtonFaceInactive, 0, 0 }, /* 80 */
- { "ButtonFacePressed", kThemeBrushButtonFacePressed, 0, 0 }, /* 81 */
- { "ButtonActiveDarkShadow", kThemeBrushButtonActiveDarkShadow, 0, 0 }, /* 82 */
- { "ButtonActiveDarkHighlight", kThemeBrushButtonActiveDarkHighlight, 0, 0 }, /* 83 */
- { "ButtonActiveLightShadow", kThemeBrushButtonActiveLightShadow, 0, 0 }, /* 84 */
- { "ButtonActiveLightHighlight", kThemeBrushButtonActiveLightHighlight, 0, 0 }, /* 85 */
- { "ButtonInactiveDarkShadow", kThemeBrushButtonInactiveDarkShadow, 0, 0 }, /* 86 */
- { "ButtonInactiveDarkHighlight", kThemeBrushButtonInactiveDarkHighlight, 0, 0 }, /* 87 */
- { "ButtonInactiveLightShadow", kThemeBrushButtonInactiveLightShadow, 0, 0 }, /* 88 */
- { "ButtonInactiveLightHighlight", kThemeBrushButtonInactiveLightHighlight, 0, 0 }, /* 89 */
- { "ButtonPressedDarkShadow", kThemeBrushButtonPressedDarkShadow, 0, 0 }, /* 90 */
- { "ButtonPressedDarkHighlight", kThemeBrushButtonPressedDarkHighlight, 0, 0 }, /* 91 */
- { "ButtonPressedLightShadow", kThemeBrushButtonPressedLightShadow, 0, 0 }, /* 92 */
- { "ButtonPressedLightHighlight", kThemeBrushButtonPressedLightHighlight, 0, 0 }, /* 93 */
- { "BevelActiveLight", kThemeBrushBevelActiveLight, 0, 0 }, /* 94 */
- { "BevelActiveDark", kThemeBrushBevelActiveDark, 0, 0 }, /* 95 */
- { "BevelInactiveLight", kThemeBrushBevelInactiveLight, 0, 0 }, /* 96 */
- { "BevelInactiveDark", kThemeBrushBevelInactiveDark, 0, 0 }, /* 97 */
- { "NotificationWindowBackground", kThemeBrushNotificationWindowBackground, 0, 0 }, /* 98 */
- { "MovableModalBackground", kThemeBrushMovableModalBackground, 0, 0 }, /* 99 */
- { "SheetBackgroundOpaque", kThemeBrushSheetBackgroundOpaque, 0, 0 }, /* 100 */
- { "DrawerBackground", kThemeBrushDrawerBackground, 0, 0 }, /* 101 */
- { "ToolbarBackground", kThemeBrushToolbarBackground, 0, 0 }, /* 102 */
- { "SheetBackgroundTransparent", kThemeBrushSheetBackgroundTransparent, 0, 0 }, /* 103 */
- { "MenuBackground", kThemeBrushMenuBackground, 0, 0 }, /* 104 */
- { "Pixel", 0, 0, 0 }, /* 105: PIXEL_MAGIC */
- { "MenuBackgroundSelected", kThemeBrushMenuBackgroundSelected, 0, 0 }, /* 106 */
- { "ListViewOddRowBackground", kThemeBrushListViewOddRowBackground, 0, 0 }, /* 107 */
- { "ListViewEvenRowBackground", kThemeBrushListViewEvenRowBackground, 0, 0 }, /* 108 */
- { "ListViewColumnDivider", kThemeBrushListViewColumnDivider, 0, 0 }, /* 109 */
- { "BlackText", 0, kThemeTextColorBlack, 0 }, /* 110 */
- { "DialogActiveText", 0, kThemeTextColorDialogActive, 0 }, /* 111 */
- { "DialogInactiveText", 0, kThemeTextColorDialogInactive, 0 }, /* 112 */
- { "AlertActiveText", 0, kThemeTextColorAlertActive, 0 }, /* 113 */
- { "AlertInactiveText", 0, kThemeTextColorAlertInactive, 0 }, /* 114 */
- { "ModelessDialogActiveText", 0, kThemeTextColorModelessDialogActive, 0 }, /* 115 */
- { "ModelessDialogInactiveText", 0, kThemeTextColorModelessDialogInactive, 0 }, /* 116 */
- { "WindowHeaderActiveText", 0, kThemeTextColorWindowHeaderActive, 0 }, /* 117 */
- { "WindowHeaderInactiveText", 0, kThemeTextColorWindowHeaderInactive, 0 }, /* 118 */
- { "PlacardActiveText", 0, kThemeTextColorPlacardActive, 0 }, /* 119 */
- { "PlacardInactiveText", 0, kThemeTextColorPlacardInactive, 0 }, /* 120 */
- { "PlacardPressedText", 0, kThemeTextColorPlacardPressed, 0 }, /* 121 */
- { "PushButtonActiveText", 0, kThemeTextColorPushButtonActive, 0 }, /* 122 */
- { "PushButtonInactiveText", 0, kThemeTextColorPushButtonInactive, 0 }, /* 123 */
- { "PushButtonPressedText", 0, kThemeTextColorPushButtonPressed, 0 }, /* 124 */
- { "BevelButtonActiveText", 0, kThemeTextColorBevelButtonActive, 0 }, /* 125 */
- { "BevelButtonInactiveText", 0, kThemeTextColorBevelButtonInactive, 0 }, /* 126 */
- { "BevelButtonPressedText", 0, kThemeTextColorBevelButtonPressed, 0 }, /* 127 */
- { "PopupButtonActiveText", 0, kThemeTextColorPopupButtonActive, 0 }, /* 128 */
- { "PopupButtonInactiveText", 0, kThemeTextColorPopupButtonInactive, 0 }, /* 129 */
- { "PopupButtonPressedText", 0, kThemeTextColorPopupButtonPressed, 0 }, /* 130 */
- { "IconLabelText", 0, kThemeTextColorIconLabel, 0 }, /* 131 */
- { "ListViewText", 0, kThemeTextColorListView, 0 }, /* 132 */
- { "DocumentWindowTitleActiveText", 0, kThemeTextColorDocumentWindowTitleActive, 0 }, /* 133 */
- { "DocumentWindowTitleInactiveText", 0, kThemeTextColorDocumentWindowTitleInactive, 0 }, /* 134 */
- { "MovableModalWindowTitleActiveText", 0, kThemeTextColorMovableModalWindowTitleActive, 0 }, /* 135 */
- { "MovableModalWindowTitleInactiveText",0, kThemeTextColorMovableModalWindowTitleInactive, 0 }, /* 136 */
- { "UtilityWindowTitleActiveText", 0, kThemeTextColorUtilityWindowTitleActive, 0 }, /* 137 */
- { "UtilityWindowTitleInactiveText", 0, kThemeTextColorUtilityWindowTitleInactive, 0 }, /* 138 */
- { "PopupWindowTitleActiveText", 0, kThemeTextColorPopupWindowTitleActive, 0 }, /* 139 */
- { "PopupWindowTitleInactiveText", 0, kThemeTextColorPopupWindowTitleInactive, 0 }, /* 140 */
- { "RootMenuActiveText", 0, kThemeTextColorRootMenuActive, 0 }, /* 141 */
- { "RootMenuSelectedText", 0, kThemeTextColorRootMenuSelected, 0 }, /* 142 */
- { "RootMenuDisabledText", 0, kThemeTextColorRootMenuDisabled, 0 }, /* 143 */
- { "MenuItemActiveText", 0, kThemeTextColorMenuItemActive, 0 }, /* 144 */
- { "MenuItemSelectedText", 0, kThemeTextColorMenuItemSelected, 0 }, /* 145 */
- { "MenuItemDisabledText", 0, kThemeTextColorMenuItemDisabled, 0 }, /* 146 */
- { "PopupLabelActiveText", 0, kThemeTextColorPopupLabelActive, 0 }, /* 147 */
- { "PopupLabelInactiveText", 0, kThemeTextColorPopupLabelInactive, 0 }, /* 148 */
- { "TabFrontActiveText", 0, kThemeTextColorTabFrontActive, 0 }, /* 149 */
- { "TabNonFrontActiveText", 0, kThemeTextColorTabNonFrontActive, 0 }, /* 150 */
- { "TabNonFrontPressedText", 0, kThemeTextColorTabNonFrontPressed, 0 }, /* 151 */
- { "TabFrontInactiveText", 0, kThemeTextColorTabFrontInactive, 0 }, /* 152 */
- { "TabNonFrontInactiveText", 0, kThemeTextColorTabNonFrontInactive, 0 }, /* 153 */
- { "IconLabelSelectedText", 0, kThemeTextColorIconLabelSelected, 0 }, /* 154 */
- { "BevelButtonStickyActiveText", 0, kThemeTextColorBevelButtonStickyActive, 0 }, /* 155 */
- { "BevelButtonStickyInactiveText", 0, kThemeTextColorBevelButtonStickyInactive, 0 }, /* 156 */
- { "NotificationText", 0, kThemeTextColorNotification, 0 }, /* 157 */
- { "SystemDetailText", 0, kThemeTextColorSystemDetail, 0 }, /* 158 */
- { "WhiteText", 0, kThemeTextColorWhite, 0 }, /* 159 */
- { "TabPaneBackground", 0, 0, kThemeBackgroundTabPane }, /* 160 */
- { "PlacardBackground", 0, 0, kThemeBackgroundPlacard }, /* 161 */
- { "WindowHeaderBackground", 0, 0, kThemeBackgroundWindowHeader }, /* 162 */
- { "ListViewWindowHeaderBackground", 0, 0, kThemeBackgroundListViewWindowHeader }, /* 163 */
- { "SecondaryGroupBoxBackground", 0, 0, kThemeBackgroundSecondaryGroupBox }, /* 164 */
- { "MetalBackground", 0, 0, kThemeBackgroundMetal }, /* 165 */
- { NULL, 0, 0, 0 }
+ { "Transparent", clearColor, 0 }, /* 30: TRANSPARENT_PIXEL */
+ { "Highlight", HIBrush, kThemeBrushPrimaryHighlightColor }, /* 31 */
+ { "HighlightSecondary", HIBrush, kThemeBrushSecondaryHighlightColor }, /* 32 */
+ { "HighlightText", HIBrush, kThemeBrushBlack }, /* 33 */
+ { "HighlightAlternate", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, /* 34 */
+ { "ButtonText", HIText, kThemeTextColorPushButtonActive }, /* 35 */
+ { "PrimaryHighlightColor", HIBrush, kThemeBrushPrimaryHighlightColor }, /* 36 */
+ { "ButtonFace", HIBrush, kThemeBrushButtonFaceActive }, /* 37 */
+ { "SecondaryHighlightColor", HIBrush, kThemeBrushSecondaryHighlightColor }, /* 38 */
+ { "ButtonFrame", HIBrush, kThemeBrushButtonFrameActive }, /* 39 */
+ { "AlternatePrimaryHighlightColor", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, /* 40 */
+ { "WindowBody", HIBrush, kThemeBrushDocumentWindowBackground }, /* 41 */
+ { "SheetBackground", HIBrush, kThemeBrushSheetBackground }, /* 42 */
+ { "MenuActive", HIBrush, kThemeBrushMenuBackgroundSelected }, /* 43 */
+ { "Black", HIBrush, kThemeBrushBlack }, /* 44 */
+ { "MenuActiveText", HIText, kThemeTextColorMenuItemSelected }, /* 45 */
+ { "White", HIBrush, kThemeBrushWhite }, /* 46 */
+ { "Menu", HIBrush, kThemeBrushMenuBackground }, /* 47 */
+ { "DialogBackgroundActive", HIBrush, kThemeBrushDialogBackgroundActive }, /* 48 */
+ { "MenuDisabled", HIText, kThemeTextColorMenuItemDisabled }, /* 49 */
+ { "DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive }, /* 50 */
+ { "MenuText", HIText, kThemeTextColorMenuItemActive }, /* 51 */
+ { "AppearanceColor", appearance, 0 }, /* 52: APPEARANCE_PIXEL */
+ { "AlertBackgroundActive", HIBrush, kThemeBrushAlertBackgroundActive }, /* 53 */
+ { "AlertBackgroundInactive", HIBrush, kThemeBrushAlertBackgroundInactive }, /* 54 */
+ { "ModelessDialogBackgroundActive", HIBrush, kThemeBrushModelessDialogBackgroundActive }, /* 55 */
+ { "ModelessDialogBackgroundInactive", HIBrush, kThemeBrushModelessDialogBackgroundInactive }, /* 56 */
+ { "UtilityWindowBackgroundActive", HIBrush, kThemeBrushUtilityWindowBackgroundActive }, /* 57 */
+ { "UtilityWindowBackgroundInactive", HIBrush, kThemeBrushUtilityWindowBackgroundInactive }, /* 58 */
+ { "ListViewSortColumnBackground", HIBrush, kThemeBrushListViewSortColumnBackground }, /* 59 */
+ { "ListViewBackground", HIBrush, kThemeBrushListViewBackground }, /* 60 */
+ { "IconLabelBackground", HIBrush, kThemeBrushIconLabelBackground }, /* 61 */
+ { "ListViewSeparator", HIBrush, kThemeBrushListViewSeparator }, /* 62 */
+ { "ChasingArrows", HIBrush, kThemeBrushChasingArrows }, /* 63 */
+ { "DragHilite", HIBrush, kThemeBrushDragHilite }, /* 64 */
+ { "DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground }, /* 65 */
+ { "FinderWindowBackground", HIBrush, kThemeBrushFinderWindowBackground }, /* 66 */
+ { "ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive }, /* 67 */
+ { "ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive }, /* 68 */
+ { "FocusHighlight", HIBrush, kThemeBrushFocusHighlight }, /* 69 */
+ { "PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive }, /* 70 */
+ { "PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed }, /* 71 */
+ { "PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive }, /* 72 */
+ { "AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark }, /* 73 */
+ { "IconLabelBackgroundSelected", HIBrush, kThemeBrushIconLabelBackgroundSelected }, /* 74 */
+ { "StaticAreaFill", HIBrush, kThemeBrushStaticAreaFill }, /* 75 */
+ { "ActiveAreaFill", HIBrush, kThemeBrushActiveAreaFill }, /* 76 */
+ { "ButtonFrameActive", HIBrush, kThemeBrushButtonFrameActive }, /* 77 */
+ { "ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive }, /* 78 */
+ { "ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive }, /* 79 */
+ { "ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive }, /* 80 */
+ { "ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed }, /* 81 */
+ { "ButtonActiveDarkShadow", HIBrush, kThemeBrushButtonActiveDarkShadow }, /* 82 */
+ { "ButtonActiveDarkHighlight", HIBrush, kThemeBrushButtonActiveDarkHighlight }, /* 83 */
+ { "ButtonActiveLightShadow", HIBrush, kThemeBrushButtonActiveLightShadow }, /* 84 */
+ { "ButtonActiveLightHighlight", HIBrush, kThemeBrushButtonActiveLightHighlight }, /* 85 */
+ { "ButtonInactiveDarkShadow", HIBrush, kThemeBrushButtonInactiveDarkShadow }, /* 86 */
+ { "ButtonInactiveDarkHighlight", HIBrush, kThemeBrushButtonInactiveDarkHighlight }, /* 87 */
+ { "ButtonInactiveLightShadow", HIBrush, kThemeBrushButtonInactiveLightShadow }, /* 88 */
+ { "ButtonInactiveLightHighlight", HIBrush, kThemeBrushButtonInactiveLightHighlight }, /* 89 */
+ { "ButtonPressedDarkShadow", HIBrush, kThemeBrushButtonPressedDarkShadow }, /* 90 */
+ { "ButtonPressedDarkHighlight", HIBrush, kThemeBrushButtonPressedDarkHighlight }, /* 91 */
+ { "ButtonPressedLightShadow", HIBrush, kThemeBrushButtonPressedLightShadow }, /* 92 */
+ { "ButtonPressedLightHighlight", HIBrush, kThemeBrushButtonPressedLightHighlight }, /* 93 */
+ { "BevelActiveLight", HIBrush, kThemeBrushBevelActiveLight }, /* 94 */
+ { "BevelActiveDark", HIBrush, kThemeBrushBevelActiveDark }, /* 95 */
+ { "BevelInactiveLight", HIBrush, kThemeBrushBevelInactiveLight }, /* 96 */
+ { "BevelInactiveDark", HIBrush, kThemeBrushBevelInactiveDark }, /* 97 */
+ { "NotificationWindowBackground", HIBrush, kThemeBrushNotificationWindowBackground }, /* 98 */
+ { "MovableModalBackground", HIBrush, kThemeBrushMovableModalBackground }, /* 99 */
+ { "SheetBackgroundOpaque", HIBrush, kThemeBrushSheetBackgroundOpaque }, /* 100 */
+ { "DrawerBackground", HIBrush, kThemeBrushDrawerBackground }, /* 101 */
+ { "ToolbarBackground", HIBrush, kThemeBrushToolbarBackground }, /* 102 */
+ { "SheetBackgroundTransparent", HIBrush, kThemeBrushSheetBackgroundTransparent }, /* 103 */
+ { "MenuBackground", HIBrush, kThemeBrushMenuBackground }, /* 104 */
+ { "Pixel", rgbColor, 0 }, /* 105: PIXEL_MAGIC */
+ { "MenuBackgroundSelected", HIBrush, kThemeBrushMenuBackgroundSelected }, /* 106 */
+ { "ListViewOddRowBackground", HIBrush, kThemeBrushListViewOddRowBackground }, /* 107 */
+ { "ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground }, /* 108 */
+ { "ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider }, /* 109 */
+ { "BlackText", HIText, kThemeTextColorBlack }, /* 110 */
+ { "DialogActiveText", HIText, kThemeTextColorDialogActive }, /* 111 */
+ { "DialogInactiveText", HIText, kThemeTextColorDialogInactive }, /* 112 */
+ { "AlertActiveText", HIText, kThemeTextColorAlertActive }, /* 113 */
+ { "AlertInactiveText", HIText, kThemeTextColorAlertInactive }, /* 114 */
+ { "ModelessDialogActiveText", HIText, kThemeTextColorModelessDialogActive }, /* 115 */
+ { "ModelessDialogInactiveText", HIText, kThemeTextColorModelessDialogInactive }, /* 116 */
+ { "WindowHeaderActiveText", HIText, kThemeTextColorWindowHeaderActive }, /* 117 */
+ { "WindowHeaderInactiveText", HIText, kThemeTextColorWindowHeaderInactive }, /* 118 */
+ { "PlacardActiveText", HIText, kThemeTextColorPlacardActive }, /* 119 */
+ { "PlacardInactiveText", HIText, kThemeTextColorPlacardInactive }, /* 120 */
+ { "PlacardPressedText", HIText, kThemeTextColorPlacardPressed }, /* 121 */
+ { "PushButtonActiveText", HIText, kThemeTextColorPushButtonActive }, /* 122 */
+ { "PushButtonInactiveText", HIText, kThemeTextColorPushButtonInactive }, /* 123 */
+ { "PushButtonPressedText", HIText, kThemeTextColorPushButtonPressed }, /* 124 */
+ { "BevelButtonActiveText", HIText, kThemeTextColorBevelButtonActive }, /* 125 */
+ { "BevelButtonInactiveText", HIText, kThemeTextColorBevelButtonInactive }, /* 126 */
+ { "BevelButtonPressedText", HIText, kThemeTextColorBevelButtonPressed }, /* 127 */
+ { "PopupButtonActiveText", HIText, kThemeTextColorPopupButtonActive }, /* 128 */
+ { "PopupButtonInactiveText", HIText, kThemeTextColorPopupButtonInactive }, /* 129 */
+ { "PopupButtonPressedText", HIText, kThemeTextColorPopupButtonPressed }, /* 130 */
+ { "IconLabelText", HIText, kThemeTextColorIconLabel }, /* 131 */
+ { "ListViewText", HIText, kThemeTextColorListView }, /* 132 */
+ { "DocumentWindowTitleActiveText", HIText, kThemeTextColorDocumentWindowTitleActive }, /* 133 */
+ { "DocumentWindowTitleInactiveText", HIText, kThemeTextColorDocumentWindowTitleInactive }, /* 134 */
+ { "MovableModalWindowTitleActiveText", HIText, kThemeTextColorMovableModalWindowTitleActive }, /* 135 */
+ { "MovableModalWindowTitleInactiveText",HIText, kThemeTextColorMovableModalWindowTitleInactive }, /* 136 */
+ { "UtilityWindowTitleActiveText", HIText, kThemeTextColorUtilityWindowTitleActive }, /* 137 */
+ { "UtilityWindowTitleInactiveText", HIText, kThemeTextColorUtilityWindowTitleInactive }, /* 138 */
+ { "PopupWindowTitleActiveText", HIText, kThemeTextColorPopupWindowTitleActive }, /* 139 */
+ { "PopupWindowTitleInactiveText", HIText, kThemeTextColorPopupWindowTitleInactive }, /* 140 */
+ { "RootMenuActiveText", HIText, kThemeTextColorRootMenuActive }, /* 141 */
+ { "RootMenuSelectedText", HIText, kThemeTextColorRootMenuSelected }, /* 142 */
+ { "RootMenuDisabledText", HIText, kThemeTextColorRootMenuDisabled }, /* 143 */
+ { "MenuItemActiveText", HIText, kThemeTextColorMenuItemActive }, /* 144 */
+ { "MenuItemSelectedText", HIText, kThemeTextColorMenuItemSelected }, /* 145 */
+ { "MenuItemDisabledText", HIText, kThemeTextColorMenuItemDisabled }, /* 146 */
+ { "PopupLabelActiveText", HIText, kThemeTextColorPopupLabelActive }, /* 147 */
+ { "PopupLabelInactiveText", HIText, kThemeTextColorPopupLabelInactive }, /* 148 */
+ { "TabFrontActiveText", HIText, kThemeTextColorTabFrontActive }, /* 149 */
+ { "TabNonFrontActiveText", HIText, kThemeTextColorTabNonFrontActive }, /* 150 */
+ { "TabNonFrontPressedText", HIText, kThemeTextColorTabNonFrontPressed }, /* 151 */
+ { "TabFrontInactiveText", HIText, kThemeTextColorTabFrontInactive }, /* 152 */
+ { "TabNonFrontInactiveText", HIText, kThemeTextColorTabNonFrontInactive }, /* 153 */
+ { "IconLabelSelectedText", HIText, kThemeTextColorIconLabelSelected }, /* 154 */
+ { "BevelButtonStickyActiveText", HIText, kThemeTextColorBevelButtonStickyActive }, /* 155 */
+ { "BevelButtonStickyInactiveText", HIText, kThemeTextColorBevelButtonStickyInactive }, /* 156 */
+ { "NotificationText", HIText, kThemeTextColorNotification }, /* 157 */
+ { "SystemDetailText", HIText, kThemeTextColorSystemDetail }, /* 158 */
+ { "WhiteText", HIText, kThemeTextColorWhite }, /* 159 */
+ { "TabPaneBackground", HIBackground, kThemeBackgroundTabPane }, /* 160 */
+ { "PlacardBackground", HIBackground, kThemeBackgroundPlacard }, /* 161 */
+ { "WindowHeaderBackground", HIBackground, kThemeBackgroundWindowHeader }, /* 162 */
+ { "ListViewWindowHeaderBackground", HIBackground, kThemeBackgroundListViewWindowHeader }, /* 163 */
+ { "SecondaryGroupBoxBackground", HIBackground, kThemeBackgroundSecondaryGroupBox }, /* 164 */
+ { "MetalBackground", HIBackground, kThemeBackgroundMetal }, /* 165 */
+
+ /*
+ * Colors based on "semantic" NSColors.
+ */
+
+ { "WindowBackgroundColor", ttkBackground, 0 }, /* 166 */
+ { "WindowBackgroundColor1", ttkBackground, 1 }, /* 167 */
+ { "WindowBackgroundColor2", ttkBackground, 2 }, /* 168 */
+ { "WindowBackgroundColor3", ttkBackground, 3 }, /* 169 */
+ { "WindowBackgroundColor4", ttkBackground, 4 }, /* 170 */
+ { "WindowBackgroundColor5", ttkBackground, 5 }, /* 171 */
+ { "WindowBackgroundColor6", ttkBackground, 6 }, /* 172 */
+ { "WindowBackgroundColor7", ttkBackground, 7 }, /* 173 */
+ { "TextColor", semantic, 0 }, /* 174 */
+ { "SelectedTextColor", semantic, 1 }, /* 175 */
+ { "LabelColor", semantic, 2 }, /* 176 */
+ { "ControlTextColor", semantic, 3 }, /* 177 */
+ { "DisabledControlTextColor", semantic, 4 }, /* 178 */
+ { "SelectedTabTextColor", semantic, 5 }, /* 179 */
+ { "TextBackgroundColor", semantic, 6 }, /* 180 */
+ { "SelectedTextBackgroundColor", semantic, 7 }, /* 181 */
+ { "ControlAccentColor", semantic, 8 }, /* 182 */
+ /* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */
+ { "SecondaryLabelColor", ttkBackground, 14 }, /* 183 */
+ { "LinkColor", semantic, 9 }, /* 184 */
+ { NULL, 0, 0 }
};
-#define MAX_PIXELCODE 165
+#define FIRST_SEMANTIC_COLOR 166
+#define MAX_PIXELCODE 184
/*
*----------------------------------------------------------------------
*
- * GetThemeFromPixelCode --
+ * GetEntryFromPixelCode --
*
- * When given a pixel code corresponding to a theme system color,
- * set one of brush, textColor or background to the corresponding
- * Appearance Mgr theme constant.
+ * Extract a SystemColorMapEntry from the table.
*
* Results:
- * Returns false if not a real pixel, true otherwise.
+ * Returns false if the code is out of bounds.
*
* Side effects:
* None.
@@ -190,36 +235,28 @@ static const struct SystemColorMapEntry systemColorMap[] = {
*----------------------------------------------------------------------
*/
-static int
-GetThemeFromPixelCode(
+static bool
+GetEntryFromPixelCode(
unsigned char code,
- ThemeBrush *brush,
- ThemeTextColor *textColor,
- ThemeBackgroundKind *background)
+ struct SystemColorMapEntry *entry)
{
if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE) {
- *brush = systemColorMap[code - MIN_PIXELCODE].brush;
- *textColor = systemColorMap[code - MIN_PIXELCODE].textColor;
- *background = systemColorMap[code - MIN_PIXELCODE].background;
+ *entry = systemColorMap[code - MIN_PIXELCODE];
+ return true;
} else {
- *brush = 0;
- *textColor = 0;
- *background = 0;
- }
- if (!*brush && !*textColor && !*background && code != PIXEL_MAGIC &&
- code != TRANSPARENT_PIXEL) {
return false;
- } else {
- return true;
}
}
/*
*----------------------------------------------------------------------
*
- * GetThemeColor --
+ * SetCGColorComponents --
*
- * Get RGB color for a given system color or pixel value.
+ * Set the components of a CGColorRef from an XColor pixel value and a
+ * system color map entry. The pixel value is only used in the case where
+ * the color is of type rgbColor. In that case the normalized XColor RGB
+ * values are copied into the CGColorRef.
*
* Results:
* OSStatus
@@ -230,60 +267,212 @@ GetThemeFromPixelCode(
*----------------------------------------------------------------------
*/
+static NSColorSpace* sRGB = NULL;
+static CGFloat windowBackground[4] =
+ {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0};
+
static OSStatus
-GetThemeColor(
+SetCGColorComponents(
+ struct SystemColorMapEntry entry,
unsigned long pixel,
- ThemeBrush brush,
- ThemeTextColor textColor,
- ThemeBackgroundKind background,
CGColorRef *c)
{
OSStatus err = noErr;
+ NSColor *bgColor, *color = nil;
+ CGFloat rgba[4] = {0, 0, 0, 1};
- if (brush) {
- err = ChkErr(HIThemeBrushCreateCGColor, brush, c);
- /*} else if (textColor) {
- err = ChkErr(GetThemeTextColor, textColor, 32, true, c);*/
- } else {
- CGFloat rgba[4] = {0, 0, 0, 1};
-
- switch ((pixel >> 24) & 0xff) {
- case PIXEL_MAGIC: {
- unsigned short red, green, blue;
- red = (pixel >> 16) & 0xff;
- green = (pixel >> 8) & 0xff;
- blue = (pixel ) & 0xff;
- red |= red << 8;
- green |= green << 8;
- blue |= blue << 8;
- rgba[0] = red / 65535.0;
- rgba[1] = green / 65535.0;
- rgba[2] = blue / 65535.0;
+ if (!sRGB) {
+ sRGB = [NSColorSpace sRGBColorSpace];
+ }
+
+ /*
+ * This function is called before our autorelease pool is set up,
+ * so it needs its own pool.
+ */
+
+ NSAutoreleasePool *pool = [NSAutoreleasePool new];
+
+ switch (entry.type) {
+ case HIBrush:
+ err = ChkErr(HIThemeBrushCreateCGColor, entry.value, c);
+ return err;
+ case rgbColor:
+ rgba[0] = ((pixel >> 16) & 0xff) / 255.0;
+ rgba[1] = ((pixel >> 8) & 0xff) / 255.0;
+ rgba[2] = ((pixel ) & 0xff) / 255.0;
+ break;
+ case ttkBackground:
+
+ /*
+ * Prior to OSX 10.14, getComponents returns black when applied to
+ * windowBackGroundColor.
+ */
+
+ if ([NSApp macMinorVersion] < 14) {
+ for (int i=0; i<3; i++) {
+ rgba[i] = windowBackground[i];
+ }
+ } else {
+ bgColor = [[NSColor windowBackgroundColor] colorUsingColorSpace:sRGB];
+ [bgColor getComponents: rgba];
+ }
+ if (rgba[0] + rgba[1] + rgba[2] < 1.5) {
+ for (int i=0; i<3; i++) {
+ rgba[i] += entry.value*8.0 / 255.0;
+ }
+ } else {
+ for (int i=0; i<3; i++) {
+ rgba[i] -= entry.value*8.0 / 255.0;
+ }
+ }
+ break;
+ case semantic:
+ switch (entry.value) {
+ case 0:
+ color = [[NSColor textColor] colorUsingColorSpace:sRGB];
break;
+ case 1:
+ color = [[NSColor selectedTextColor] colorUsingColorSpace:sRGB];
+ break;
+ case 2:
+ if ([NSApp macMinorVersion] > 9) {
+#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090
+ color = [[NSColor labelColor] colorUsingColorSpace:sRGB];
+#endif
+ } else {
+ color = [[NSColor textColor] colorUsingColorSpace:sRGB];
+ }
+ break;
+ case 3:
+ color = [[NSColor controlTextColor] colorUsingColorSpace:sRGB];
+ break;
+ case 4:
+ color = [[NSColor disabledControlTextColor]
+ colorUsingColorSpace:sRGB];
+ break;
+ case 5:
+ if ([NSApp macMinorVersion] > 6) {
+ color = [[NSColor whiteColor] colorUsingColorSpace:sRGB];
+ } else {
+ color = [[NSColor blackColor] colorUsingColorSpace:sRGB];
+ }
+ break;
+ case 6:
+ color = [[NSColor textBackgroundColor] colorUsingColorSpace:sRGB];
+ break;
+ case 7:
+ color = [[NSColor selectedTextBackgroundColor]
+ colorUsingColorSpace:sRGB];
+ break;
+ case 8:
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
+ if (@available(macOS 14, *)) {
+ color = [[NSColor controlAccentColor] colorUsingColorSpace:sRGB];
+#else
+ if(false) {
+#endif
+ } else {
+ color = [[NSColor
+ colorForControlTint:[NSColor currentControlTint]]
+ colorUsingColorSpace: sRGB];
+ }
+ break;
+ case 9:
+ if ([NSApp macMinorVersion] >= 10) {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
+ color = [[NSColor linkColor] colorUsingColorSpace:sRGB];
+#endif
+ } else {
+ color = [[NSColor blueColor] colorUsingColorSpace:sRGB];
+ }
+ break;
+ default:
+ if ([NSApp macMinorVersion] >= 10) {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
+ color = [[NSColor labelColor] colorUsingColorSpace:sRGB];
+#endif
+ } else {
+ color = [[NSColor textColor] colorUsingColorSpace:sRGB];
}
- case TRANSPARENT_PIXEL:
- rgba[3] = 0.0;
break;
}
+ [color getComponents: rgba];
+ break;
+ case clearColor:
+ rgba[3] = 0.0;
+ break;
- static CGColorSpaceRef deviceRGBSpace = NULL;
- if (!deviceRGBSpace) {
- deviceRGBSpace = CGColorSpaceCreateDeviceRGB();
- }
- *c = CGColorCreate(deviceRGBSpace, rgba );
+ /*
+ * There are no HITheme functions which convert Text or background colors
+ * to CGColors. (GetThemeTextColor has been removed, and it was never
+ * possible with backgrounds.) If we get one of these we return black.
+ */
+
+ case HIText:
+ case HIBackground:
+ default:
+ break;
}
+ *c = CGColorCreate(sRGB.CGColorSpace, rgba);
+ [pool drain];
return err;
}
/*
*----------------------------------------------------------------------
*
+ * TkMacOSXInDarkMode --
+ *
+ * Tests whether the given window's NSView has a DarkAqua Appearance.
+ *
+ * Results:
+ * Returns true if the NSView is in DarkMode, false if not.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+MODULE_SCOPE Bool
+TkMacOSXInDarkMode(Tk_Window tkwin)
+{
+ int result = false;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
+ static NSAppearanceName darkAqua = @"NSAppearanceNameDarkAqua";
+
+ if ([NSApp macMinorVersion] >= 14) {
+ TkWindow *winPtr = (TkWindow*) tkwin;
+ NSView *view = nil;
+ if (winPtr && winPtr->privatePtr) {
+ view = TkMacOSXDrawableView(winPtr->privatePtr);
+ }
+ if (view) {
+ result = [view.effectiveAppearance.name isEqualToString:darkAqua];
+ } else {
+ result = [[NSAppearance currentAppearance].name
+ isEqualToString:darkAqua];
+ }
+ }
+#endif
+
+ return result;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkSetMacColor --
*
- * Creates a CGColorRef from a X style pixel value.
+ * Sets the components of a CGColorRef from an XColor pixel value.
+ * The high order byte of the pixel value is used as an index into
+ * the system color table, and then SetCGColorComponents is called
+ * with the table entry and the pixel value.
*
* Results:
- * Returns false if not a real pixel, true otherwise.
+ * Returns false if the high order byte is not a valid index, true
+ * otherwise.
*
* Side effects:
* The variable macColor is set to a new CGColorRef, the caller is
@@ -299,14 +488,10 @@ TkSetMacColor(
{
CGColorRef *color = (CGColorRef*)macColor;
OSStatus err = -1;
- ThemeBrush brush;
- ThemeTextColor textColor;
- ThemeBackgroundKind background;
-
- if (GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush, &textColor,
- &background)) {
- err = ChkErr(GetThemeColor, pixel, brush, textColor, background,
- color);
+ struct SystemColorMapEntry entry;
+
+ if (GetEntryFromPixelCode((pixel >> 24) & 0xff, &entry)) {
+ err = ChkErr(SetCGColorComponents, entry, pixel, color);
}
return (err == noErr);
}
@@ -321,7 +506,7 @@ TkSetMacColor(
* Results:
* None resp. retained CGColorRef for CopyCachedColor()
*
- * Side effects:
+ * Side effects:M
* None.
*
*----------------------------------------------------------------------
@@ -450,6 +635,7 @@ TkMacOSXGetNSColor(
if (cgColor) {
NSColorSpace *colorSpace = [[NSColorSpace alloc]
initWithCGColorSpace:CGColorGetColorSpace(cgColor)];
+
nsColor = [NSColor colorWithColorSpace:colorSpace
components:CGColorGetComponents(cgColor)
count:CGColorGetNumberOfComponents(cgColor)];
@@ -484,48 +670,52 @@ TkMacOSXSetColorInContext(
unsigned long pixel,
CGContextRef context)
{
- OSStatus err = -1;
- CGColorRef cgColor = CopyCachedColor(gc, pixel);
- ThemeBrush brush;
- ThemeTextColor textColor;
- ThemeBackgroundKind background;
-
- if (!cgColor && GetThemeFromPixelCode((pixel >> 24) & 0xff, &brush,
- &textColor, &background)) {
- if (brush) {
- err = ChkErr(HIThemeSetFill, brush, NULL, context,
+ OSStatus err = noErr;
+ CGColorRef cgColor = nil;
+ struct SystemColorMapEntry entry;
+ CGRect rect;
+ int code = (pixel >> 24) & 0xff;
+ HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};;
+
+ if (code < FIRST_SEMANTIC_COLOR) {
+ cgColor = CopyCachedColor(gc, pixel);
+ }
+ if (!cgColor && GetEntryFromPixelCode(code, &entry)) {
+ switch (entry.type) {
+ case HIBrush:
+ err = ChkErr(HIThemeSetFill, entry.value, NULL, context,
kHIThemeOrientationNormal);
if (err == noErr) {
- err = ChkErr(HIThemeSetStroke, brush, NULL, context,
+ err = ChkErr(HIThemeSetStroke, entry.value, NULL, context,
kHIThemeOrientationNormal);
}
- } else if (textColor) {
- err = ChkErr(HIThemeSetTextFill, textColor, NULL, context,
+ break;
+ case HIText:
+ err = ChkErr(HIThemeSetTextFill, entry.value, NULL, context,
kHIThemeOrientationNormal);
- } else if (background) {
- CGRect rect = CGContextGetClipBoundingBox(context);
- HIThemeBackgroundDrawInfo info = { 0, kThemeStateActive,
- background };
-
+ break;
+ case HIBackground:
+ info.kind = entry.value;
+ rect = CGContextGetClipBoundingBox(context);
err = ChkErr(HIThemeApplyBackground, &rect, &info,
context, kHIThemeOrientationNormal);
+ break;
+ default:
+ err = ChkErr(SetCGColorComponents, entry, pixel, &cgColor);
+ if (err == noErr) {
+ SetCachedColor(gc, pixel, cgColor);
+ }
+ break;
}
- if (err == noErr) {
- return;
- }
- err = ChkErr(GetThemeColor, pixel, brush, textColor, background,
- &cgColor);
- if (err == noErr) {
- SetCachedColor(gc, pixel, cgColor);
- }
- } else if (!cgColor) {
- TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
}
if (cgColor) {
CGContextSetFillColorWithColor(context, cgColor);
CGContextSetStrokeColorWithColor(context, cgColor);
CGColorRelease(cgColor);
}
+ if (err != noErr) {
+ TkMacOSXDbgMsg("Ignored unknown pixel value 0x%lx", pixel);
+ }
}
/*
@@ -549,7 +739,7 @@ TkMacOSXSetColorInContext(
TkColor *
TkpGetColor(
Tk_Window tkwin, /* Window in which color will be used. */
- Tk_Uid name) /* Name of color to allocated (in form
+ Tk_Uid name) /* Name of color to be allocated (in form
* suitable for passing to XParseColor). */
{
Display *display = tkwin != None ? Tk_Display(tkwin) : NULL;
@@ -561,22 +751,21 @@ TkpGetColor(
* Check to see if this is a system color. Otherwise, XParseColor
* will do all the work.
*/
+
if (strncasecmp(name, "system", 6) == 0) {
Tcl_Obj *strPtr = Tcl_NewStringObj(name+6, -1);
int idx, result;
result = Tcl_GetIndexFromObjStruct(NULL, strPtr, systemColorMap,
- sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx);
+ sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx);
Tcl_DecrRefCount(strPtr);
if (result == TCL_OK) {
OSStatus err;
CGColorRef c;
unsigned char pixelCode = idx + MIN_PIXELCODE;
- ThemeBrush brush = systemColorMap[idx].brush;
- ThemeTextColor textColor = systemColorMap[idx].textColor;
- ThemeBackgroundKind background = systemColorMap[idx].background;
+ struct SystemColorMapEntry entry = systemColorMap[idx];
- err = ChkErr(GetThemeColor, 0, brush, textColor, background, &c);
+ err = ChkErr(SetCGColorComponents, entry, 0, &c);
if (err == noErr) {
const size_t n = CGColorGetNumberOfComponents(c);
const CGFloat *rgba = CGColorGetComponents(c);
@@ -591,12 +780,12 @@ TkpGetColor(
color.red = color.green = color.blue = rgba[0] * 65535.0;
break;
default:
- Tcl_Panic("CGColor with %d components", (int) n);
+ Tcl_Panic("CGColor with %d components", (int) n);
}
color.pixel = ((((((pixelCode << 8)
- | ((color.red >> 8) & 0xff)) << 8)
- | ((color.green >> 8) & 0xff)) << 8)
- | ((color.blue >> 8) & 0xff));
+ | ((color.red >> 8) & 0xff)) << 8)
+ | ((color.green >> 8) & 0xff)) << 8)
+ | ((color.blue >> 8) & 0xff));
CGColorRelease(c);
goto validXColor;
}
@@ -609,7 +798,7 @@ TkpGetColor(
}
validXColor:
- tkColPtr = ckalloc(sizeof(TkColor));
+ tkColPtr = (TkColor *)ckalloc(sizeof(TkColor));
tkColPtr->color = color;
return tkColPtr;
@@ -643,7 +832,8 @@ TkpGetColorByValue(
XColor *colorPtr) /* Red, green, and blue fields indicate
* desired color. */
{
- TkColor *tkColPtr = ckalloc(sizeof(TkColor));
+ TkColor *tkColPtr = (TkColor *)ckalloc(sizeof(TkColor));
+ (void)tkwin;
tkColPtr->color.red = colorPtr->red;
tkColPtr->color.green = colorPtr->green;
@@ -675,6 +865,8 @@ XAllocColor(
Colormap map, /* Not used. */
XColor *colorPtr) /* XColor struct to modify. */
{
+ (void)map;
+
display->request++;
colorPtr->pixel = TkpGetPixel(colorPtr);
return 1;
@@ -688,6 +880,10 @@ XCreateColormap(
int alloc) /* Not used. */
{
static Colormap index = 1;
+ (void)display;
+ (void)window;
+ (void)visual;
+ (void)alloc;
/*
* Just return a new value each time.
@@ -700,6 +896,9 @@ XFreeColormap(
Display* display, /* Display. */
Colormap colormap) /* Colormap. */
{
+ (void)display;
+ (void)colormap;
+
return Success;
}
@@ -711,6 +910,12 @@ XFreeColors(
int npixels, /* Number of pixels. */
unsigned long planes) /* Number of pixel planes. */
{
+ (void)display;
+ (void)colormap;
+ (void)pixels;
+ (void)npixels;
+ (void)planes;
+
/*
* The Macintosh version of Tk uses TrueColor. Nothing
* needs to be done to release colors as there really is
diff --git a/macosx/tkMacOSXConfig.c b/macosx/tkMacOSXConfig.c
index 841fc54..34a1fc9 100644
--- a/macosx/tkMacOSXConfig.c
+++ b/macosx/tkMacOSXConfig.c
@@ -39,6 +39,10 @@ TkpGetSystemDefault(
const char *dbName, /* The option database name. */
const char *className) /* The name of the option class. */
{
+ (void)tkwin;
+ (void)dbName;
+ (void)className;
+
return NULL;
}
diff --git a/macosx/tkMacOSXConstants.h b/macosx/tkMacOSXConstants.h
index 0badf1a..e019ea1 100644
--- a/macosx/tkMacOSXConstants.h
+++ b/macosx/tkMacOSXConstants.h
@@ -19,6 +19,10 @@
#define NSFullScreenWindowMask (1 << 14)
#endif
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1090
+typedef NSInteger NSModalResponse;
+#endif
+
/*
* Let's raise a glass for the project manager who improves our lives by
* generating deprecation warnings about pointless changes of the names
@@ -79,22 +83,8 @@
#define NSInformationalAlertStyle NSAlertStyleInformational
#define NSCriticalAlertStyle NSAlertStyleCritical
#define NSCenterTextAlignment NSTextAlignmentCenter
-#define NSDeviceIndependentModifierFlagsMask NSEventModifierFlagDeviceIndependentFlagsMask
-#define NSCommandKeyMask NSEventModifierFlagCommand
-#define NSShiftKeyMask NSEventModifierFlagShift
-#define NSAlphaShiftKeyMask NSEventModifierFlagCapsLock
-#define NSAlternateKeyMask NSEventModifierFlagOption
-#define NSControlKeyMask NSEventModifierFlagControl
-#define NSNumericPadKeyMask NSEventModifierFlagNumericPad
-#define NSFunctionKeyMask NSEventModifierFlagFunction
-#define NSKeyUp NSEventTypeKeyUp
-#define NSKeyDown NSEventTypeKeyDown
-#define NSFlagsChanged NSEventTypeFlagsChanged
-#define NSAlphaShiftKeyMask NSEventModifierFlagCapsLock
-#define NSShiftKeyMask NSEventModifierFlagShift
#define NSAnyEventMask NSEventMaskAny
#define NSApplicationDefinedMask NSEventMaskApplicationDefined
-#define NSTexturedBackgroundWindowMask NSWindowStyleMaskTexturedBackground
#define NSUtilityWindowMask NSWindowStyleMaskUtilityWindow
#define NSNonactivatingPanelMask NSWindowStyleMaskNonactivatingPanel
#define NSDocModalWindowMask NSWindowStyleMaskDocModalWindow
diff --git a/macosx/tkMacOSXCursor.c b/macosx/tkMacOSXCursor.c
index b6394b7..812f54e 100644
--- a/macosx/tkMacOSXCursor.c
+++ b/macosx/tkMacOSXCursor.c
@@ -54,138 +54,138 @@ struct CursorName {
#define MacXCursorData(n) ((id)tkMacOSXXCursors[TK_MAC_XCURSOR_##n])
static const struct CursorName cursorNames[] = {
- {"none", NONE, nil},
- {"arrow", SELECTOR, @"arrowCursor"},
- {"top_left_arrow", SELECTOR, @"arrowCursor"},
- {"left_ptr", SELECTOR, @"arrowCursor"},
- {"copyarrow", SELECTOR, @"dragCopyCursor", @"_copyDragCursor"},
- {"aliasarrow", SELECTOR, @"dragLinkCursor", @"_linkDragCursor"},
- {"contextualmenuarrow", SELECTOR, @"contextualMenuCursor"},
- {"movearrow", SELECTOR, @"_moveCursor"},
- {"ibeam", SELECTOR, @"IBeamCursor"},
- {"text", SELECTOR, @"IBeamCursor"},
- {"xterm", SELECTOR, @"IBeamCursor"},
- {"cross", SELECTOR, @"crosshairCursor"},
- {"crosshair", SELECTOR, @"crosshairCursor"},
- {"cross-hair", SELECTOR, @"crosshairCursor"},
- {"tcross", SELECTOR, @"crosshairCursor"},
- {"hand", SELECTOR, @"openHandCursor"},
- {"openhand", SELECTOR, @"openHandCursor"},
- {"closedhand", SELECTOR, @"closedHandCursor"},
- {"fist", SELECTOR, @"closedHandCursor"},
- {"pointinghand", SELECTOR, @"pointingHandCursor"},
- {"resize", SELECTOR, @"arrowCursor"},
- {"resizeleft", SELECTOR, @"resizeLeftCursor"},
- {"resizeright", SELECTOR, @"resizeRightCursor"},
- {"resizeleftright", SELECTOR, @"resizeLeftRightCursor"},
- {"resizeup", SELECTOR, @"resizeUpCursor"},
- {"resizedown", SELECTOR, @"resizeDownCursor"},
- {"resizeupdown", SELECTOR, @"resizeUpDownCursor"},
- {"resizebottomleft", SELECTOR, @"_bottomLeftResizeCursor"},
- {"resizetopleft", SELECTOR, @"_topLeftResizeCursor"},
- {"resizebottomright", SELECTOR, @"_bottomRightResizeCursor"},
- {"resizetopright", SELECTOR, @"_topRightResizeCursor"},
- {"notallowed", SELECTOR, @"operationNotAllowedCursor"},
- {"poof", SELECTOR, @"disappearingItemCursor"},
- {"wait", SELECTOR, @"busyButClickableCursor"},
- {"spinning", SELECTOR, @"busyButClickableCursor"},
- {"countinguphand", SELECTOR, @"busyButClickableCursor"},
- {"countingdownhand", SELECTOR, @"busyButClickableCursor"},
- {"countingupanddownhand", SELECTOR, @"busyButClickableCursor"},
+ {"none", NONE, nil, nil, {0, 0}},
+ {"arrow", SELECTOR, @"arrowCursor", nil, {0, 0}},
+ {"top_left_arrow", SELECTOR, @"arrowCursor", nil, {0, 0}},
+ {"left_ptr", SELECTOR, @"arrowCursor", nil, {0, 0}},
+ {"copyarrow", SELECTOR, @"dragCopyCursor", @"_copyDragCursor", {0, 0}},
+ {"aliasarrow", SELECTOR, @"dragLinkCursor", @"_linkDragCursor", {0, 0}},
+ {"contextualmenuarrow", SELECTOR, @"contextualMenuCursor", nil, {0, 0}},
+ {"movearrow", SELECTOR, @"_moveCursor", nil, {0, 0}},
+ {"ibeam", SELECTOR, @"IBeamCursor", nil, {0, 0}},
+ {"text", SELECTOR, @"IBeamCursor", nil, {0, 0}},
+ {"xterm", SELECTOR, @"IBeamCursor", nil, {0, 0}},
+ {"cross", SELECTOR, @"crosshairCursor", nil, {0, 0}},
+ {"crosshair", SELECTOR, @"crosshairCursor", nil, {0, 0}},
+ {"cross-hair", SELECTOR, @"crosshairCursor", nil, {0, 0}},
+ {"tcross", SELECTOR, @"crosshairCursor", nil, {0, 0}},
+ {"hand", SELECTOR, @"openHandCursor", nil, {0, 0}},
+ {"openhand", SELECTOR, @"openHandCursor", nil, {0, 0}},
+ {"closedhand", SELECTOR, @"closedHandCursor", nil, {0, 0}},
+ {"fist", SELECTOR, @"closedHandCursor", nil, {0, 0}},
+ {"pointinghand", SELECTOR, @"pointingHandCursor", nil, {0, 0}},
+ {"resize", SELECTOR, @"arrowCursor", nil, {0, 0}},
+ {"resizeleft", SELECTOR, @"resizeLeftCursor", nil, {0, 0}},
+ {"resizeright", SELECTOR, @"resizeRightCursor", nil, {0, 0}},
+ {"resizeleftright", SELECTOR, @"resizeLeftRightCursor", nil, {0, 0}},
+ {"resizeup", SELECTOR, @"resizeUpCursor", nil, {0, 0}},
+ {"resizedown", SELECTOR, @"resizeDownCursor", nil, {0, 0}},
+ {"resizeupdown", SELECTOR, @"resizeUpDownCursor", nil, {0, 0}},
+ {"resizebottomleft", SELECTOR, @"_bottomLeftResizeCursor", nil, {0, 0}},
+ {"resizetopleft", SELECTOR, @"_topLeftResizeCursor", nil, {0, 0}},
+ {"resizebottomright", SELECTOR, @"_bottomRightResizeCursor", nil, {0, 0}},
+ {"resizetopright", SELECTOR, @"_topRightResizeCursor", nil, {0, 0}},
+ {"notallowed", SELECTOR, @"operationNotAllowedCursor", nil, {0, 0}},
+ {"poof", SELECTOR, @"disappearingItemCursor", nil, {0, 0}},
+ {"wait", SELECTOR, @"busyButClickableCursor", nil, {0, 0}},
+ {"spinning", SELECTOR, @"busyButClickableCursor", nil, {0, 0}},
+ {"countinguphand", SELECTOR, @"busyButClickableCursor", nil, {0, 0}},
+ {"countingdownhand", SELECTOR, @"busyButClickableCursor", nil, {0, 0}},
+ {"countingupanddownhand", SELECTOR, @"busyButClickableCursor", nil, {0, 0}},
{"help", IMAGENAMED, @"NSHelpCursor", nil, {8, 8}},
-// {"hand", IMAGEBITMAP, MacCursorData(hand)},
- {"bucket", IMAGEBITMAP, MacCursorData(bucket)},
- {"cancel", IMAGEBITMAP, MacCursorData(cancel)},
-// {"resize", IMAGEBITMAP, MacCursorData(resize)},
- {"eyedrop", IMAGEBITMAP, MacCursorData(eyedrop)},
- {"eyedrop-full", IMAGEBITMAP, MacCursorData(eyedrop_full)},
- {"zoom-in", IMAGEBITMAP, MacCursorData(zoom_in)},
- {"zoom-out", IMAGEBITMAP, MacCursorData(zoom_out)},
- {"X_cursor", IMAGEBITMAP, MacXCursorData(X_cursor)},
-// {"arrow", IMAGEBITMAP, MacXCursorData(arrow)},
- {"based_arrow_down", IMAGEBITMAP, MacXCursorData(based_arrow_down)},
- {"based_arrow_up", IMAGEBITMAP, MacXCursorData(based_arrow_up)},
- {"boat", IMAGEBITMAP, MacXCursorData(boat)},
- {"bogosity", IMAGEBITMAP, MacXCursorData(bogosity)},
- {"bottom_left_corner", IMAGEBITMAP, MacXCursorData(bottom_left_corner)},
- {"bottom_right_corner", IMAGEBITMAP, MacXCursorData(bottom_right_corner)},
- {"bottom_side", IMAGEBITMAP, MacXCursorData(bottom_side)},
- {"bottom_tee", IMAGEBITMAP, MacXCursorData(bottom_tee)},
- {"box_spiral", IMAGEBITMAP, MacXCursorData(box_spiral)},
- {"center_ptr", IMAGEBITMAP, MacXCursorData(center_ptr)},
- {"circle", IMAGEBITMAP, MacXCursorData(circle)},
- {"clock", IMAGEBITMAP, MacXCursorData(clock)},
- {"coffee_mug", IMAGEBITMAP, MacXCursorData(coffee_mug)},
-// {"cross", IMAGEBITMAP, MacXCursorData(cross)},
- {"cross_reverse", IMAGEBITMAP, MacXCursorData(cross_reverse)},
-// {"crosshair", IMAGEBITMAP, MacXCursorData(crosshair)},
- {"diamond_cross", IMAGEBITMAP, MacXCursorData(diamond_cross)},
- {"dot", IMAGEBITMAP, MacXCursorData(dot)},
- {"dotbox", IMAGEBITMAP, MacXCursorData(dotbox)},
- {"double_arrow", IMAGEBITMAP, MacXCursorData(double_arrow)},
- {"draft_large", IMAGEBITMAP, MacXCursorData(draft_large)},
- {"draft_small", IMAGEBITMAP, MacXCursorData(draft_small)},
- {"draped_box", IMAGEBITMAP, MacXCursorData(draped_box)},
- {"exchange", IMAGEBITMAP, MacXCursorData(exchange)},
- {"fleur", IMAGEBITMAP, MacXCursorData(fleur)},
- {"gobbler", IMAGEBITMAP, MacXCursorData(gobbler)},
- {"gumby", IMAGEBITMAP, MacXCursorData(gumby)},
- {"hand1", IMAGEBITMAP, MacXCursorData(hand1)},
- {"hand2", IMAGEBITMAP, MacXCursorData(hand2)},
- {"heart", IMAGEBITMAP, MacXCursorData(heart)},
- {"icon", IMAGEBITMAP, MacXCursorData(icon)},
- {"iron_cross", IMAGEBITMAP, MacXCursorData(iron_cross)},
-// {"left_ptr", IMAGEBITMAP, MacXCursorData(left_ptr)},
- {"left_side", IMAGEBITMAP, MacXCursorData(left_side)},
- {"left_tee", IMAGEBITMAP, MacXCursorData(left_tee)},
- {"leftbutton", IMAGEBITMAP, MacXCursorData(leftbutton)},
- {"ll_angle", IMAGEBITMAP, MacXCursorData(ll_angle)},
- {"lr_angle", IMAGEBITMAP, MacXCursorData(lr_angle)},
- {"man", IMAGEBITMAP, MacXCursorData(man)},
- {"middlebutton", IMAGEBITMAP, MacXCursorData(middlebutton)},
- {"mouse", IMAGEBITMAP, MacXCursorData(mouse)},
- {"pencil", IMAGEBITMAP, MacXCursorData(pencil)},
- {"pirate", IMAGEBITMAP, MacXCursorData(pirate)},
- {"plus", IMAGEBITMAP, MacXCursorData(plus)},
- {"question_arrow", IMAGEBITMAP, MacXCursorData(question_arrow)},
- {"right_ptr", IMAGEBITMAP, MacXCursorData(right_ptr)},
- {"right_side", IMAGEBITMAP, MacXCursorData(right_side)},
- {"right_tee", IMAGEBITMAP, MacXCursorData(right_tee)},
- {"rightbutton", IMAGEBITMAP, MacXCursorData(rightbutton)},
- {"rtl_logo", IMAGEBITMAP, MacXCursorData(rtl_logo)},
- {"sailboat", IMAGEBITMAP, MacXCursorData(sailboat)},
- {"sb_down_arrow", IMAGEBITMAP, MacXCursorData(sb_down_arrow)},
- {"sb_h_double_arrow", IMAGEBITMAP, MacXCursorData(sb_h_double_arrow)},
- {"sb_left_arrow", IMAGEBITMAP, MacXCursorData(sb_left_arrow)},
- {"sb_right_arrow", IMAGEBITMAP, MacXCursorData(sb_right_arrow)},
- {"sb_up_arrow", IMAGEBITMAP, MacXCursorData(sb_up_arrow)},
- {"sb_v_double_arrow", IMAGEBITMAP, MacXCursorData(sb_v_double_arrow)},
- {"shuttle", IMAGEBITMAP, MacXCursorData(shuttle)},
- {"sizing", IMAGEBITMAP, MacXCursorData(sizing)},
- {"spider", IMAGEBITMAP, MacXCursorData(spider)},
- {"spraycan", IMAGEBITMAP, MacXCursorData(spraycan)},
- {"star", IMAGEBITMAP, MacXCursorData(star)},
- {"target", IMAGEBITMAP, MacXCursorData(target)},
-// {"tcross", IMAGEBITMAP, MacXCursorData(tcross)},
-// {"top_left_arrow", IMAGEBITMAP, MacXCursorData(top_left_arrow)},
- {"top_left_corner", IMAGEBITMAP, MacXCursorData(top_left_corner)},
- {"top_right_corner", IMAGEBITMAP, MacXCursorData(top_right_corner)},
- {"top_side", IMAGEBITMAP, MacXCursorData(top_side)},
- {"top_tee", IMAGEBITMAP, MacXCursorData(top_tee)},
- {"trek", IMAGEBITMAP, MacXCursorData(trek)},
- {"ul_angle", IMAGEBITMAP, MacXCursorData(ul_angle)},
- {"umbrella", IMAGEBITMAP, MacXCursorData(umbrella)},
- {"ur_angle", IMAGEBITMAP, MacXCursorData(ur_angle)},
- {"watch", IMAGEBITMAP, MacXCursorData(watch)},
-// {"xterm", IMAGEBITMAP, MacXCursorData(xterm)},
- {NULL}
+// {"hand", IMAGEBITMAP, MacCursorData(hand), nil, {0, 0}},
+ {"bucket", IMAGEBITMAP, MacCursorData(bucket), nil, {0, 0}},
+ {"cancel", IMAGEBITMAP, MacCursorData(cancel), nil, {0, 0}},
+// {"resize", IMAGEBITMAP, MacCursorData(resize), nil, {0, 0}},
+ {"eyedrop", IMAGEBITMAP, MacCursorData(eyedrop), nil, {0, 0}},
+ {"eyedrop-full", IMAGEBITMAP, MacCursorData(eyedrop_full), nil, {0, 0}},
+ {"zoom-in", IMAGEBITMAP, MacCursorData(zoom_in), nil, {0, 0}},
+ {"zoom-out", IMAGEBITMAP, MacCursorData(zoom_out), nil, {0, 0}},
+ {"X_cursor", IMAGEBITMAP, MacXCursorData(X_cursor), nil, {0, 0}},
+// {"arrow", IMAGEBITMAP, MacXCursorData(arrow), nil, {0, 0}},
+ {"based_arrow_down", IMAGEBITMAP, MacXCursorData(based_arrow_down), nil, {0, 0}},
+ {"based_arrow_up", IMAGEBITMAP, MacXCursorData(based_arrow_up), nil, {0, 0}},
+ {"boat", IMAGEBITMAP, MacXCursorData(boat), nil, {0, 0}},
+ {"bogosity", IMAGEBITMAP, MacXCursorData(bogosity), nil, {0, 0}},
+ {"bottom_left_corner", IMAGEBITMAP, MacXCursorData(bottom_left_corner), nil, {0, 0}},
+ {"bottom_right_corner", IMAGEBITMAP, MacXCursorData(bottom_right_corner), nil, {0, 0}},
+ {"bottom_side", IMAGEBITMAP, MacXCursorData(bottom_side), nil, {0, 0}},
+ {"bottom_tee", IMAGEBITMAP, MacXCursorData(bottom_tee), nil, {0, 0}},
+ {"box_spiral", IMAGEBITMAP, MacXCursorData(box_spiral), nil, {0, 0}},
+ {"center_ptr", IMAGEBITMAP, MacXCursorData(center_ptr), nil, {0, 0}},
+ {"circle", IMAGEBITMAP, MacXCursorData(circle), nil, {0, 0}},
+ {"clock", IMAGEBITMAP, MacXCursorData(clock), nil, {0, 0}},
+ {"coffee_mug", IMAGEBITMAP, MacXCursorData(coffee_mug), nil, {0, 0}},
+// {"cross", IMAGEBITMAP, MacXCursorData(cross), nil, {0, 0}},
+ {"cross_reverse", IMAGEBITMAP, MacXCursorData(cross_reverse), nil, {0, 0}},
+// {"crosshair", IMAGEBITMAP, MacXCursorData(crosshair), nil, {0, 0}},
+ {"diamond_cross", IMAGEBITMAP, MacXCursorData(diamond_cross), nil, {0, 0}},
+ {"dot", IMAGEBITMAP, MacXCursorData(dot), nil, {0, 0}},
+ {"dotbox", IMAGEBITMAP, MacXCursorData(dotbox), nil, {0, 0}},
+ {"double_arrow", IMAGEBITMAP, MacXCursorData(double_arrow), nil, {0, 0}},
+ {"draft_large", IMAGEBITMAP, MacXCursorData(draft_large), nil, {0, 0}},
+ {"draft_small", IMAGEBITMAP, MacXCursorData(draft_small), nil, {0, 0}},
+ {"draped_box", IMAGEBITMAP, MacXCursorData(draped_box), nil, {0, 0}},
+ {"exchange", IMAGEBITMAP, MacXCursorData(exchange), nil, {0, 0}},
+ {"fleur", IMAGEBITMAP, MacXCursorData(fleur), nil, {0, 0}},
+ {"gobbler", IMAGEBITMAP, MacXCursorData(gobbler), nil, {0, 0}},
+ {"gumby", IMAGEBITMAP, MacXCursorData(gumby), nil, {0, 0}},
+ {"hand1", IMAGEBITMAP, MacXCursorData(hand1), nil, {0, 0}},
+ {"hand2", IMAGEBITMAP, MacXCursorData(hand2), nil, {0, 0}},
+ {"heart", IMAGEBITMAP, MacXCursorData(heart), nil, {0, 0}},
+ {"icon", IMAGEBITMAP, MacXCursorData(icon), nil, {0, 0}},
+ {"iron_cross", IMAGEBITMAP, MacXCursorData(iron_cross), nil, {0, 0}},
+// {"left_ptr", IMAGEBITMAP, MacXCursorData(left_ptr), nil, {0, 0}},
+ {"left_side", IMAGEBITMAP, MacXCursorData(left_side), nil, {0, 0}},
+ {"left_tee", IMAGEBITMAP, MacXCursorData(left_tee), nil, {0, 0}},
+ {"leftbutton", IMAGEBITMAP, MacXCursorData(leftbutton), nil, {0, 0}},
+ {"ll_angle", IMAGEBITMAP, MacXCursorData(ll_angle), nil, {0, 0}},
+ {"lr_angle", IMAGEBITMAP, MacXCursorData(lr_angle), nil, {0, 0}},
+ {"man", IMAGEBITMAP, MacXCursorData(man), nil, {0, 0}},
+ {"middlebutton", IMAGEBITMAP, MacXCursorData(middlebutton), nil, {0, 0}},
+ {"mouse", IMAGEBITMAP, MacXCursorData(mouse), nil, {0, 0}},
+ {"pencil", IMAGEBITMAP, MacXCursorData(pencil), nil, {0, 0}},
+ {"pirate", IMAGEBITMAP, MacXCursorData(pirate), nil, {0, 0}},
+ {"plus", IMAGEBITMAP, MacXCursorData(plus), nil, {0, 0}},
+ {"question_arrow", IMAGEBITMAP, MacXCursorData(question_arrow), nil, {0, 0}},
+ {"right_ptr", IMAGEBITMAP, MacXCursorData(right_ptr), nil, {0, 0}},
+ {"right_side", IMAGEBITMAP, MacXCursorData(right_side), nil, {0, 0}},
+ {"right_tee", IMAGEBITMAP, MacXCursorData(right_tee), nil, {0, 0}},
+ {"rightbutton", IMAGEBITMAP, MacXCursorData(rightbutton), nil, {0, 0}},
+ {"rtl_logo", IMAGEBITMAP, MacXCursorData(rtl_logo), nil, {0, 0}},
+ {"sailboat", IMAGEBITMAP, MacXCursorData(sailboat), nil, {0, 0}},
+ {"sb_down_arrow", IMAGEBITMAP, MacXCursorData(sb_down_arrow), nil, {0, 0}},
+ {"sb_h_double_arrow", IMAGEBITMAP, MacXCursorData(sb_h_double_arrow), nil, {0, 0}},
+ {"sb_left_arrow", IMAGEBITMAP, MacXCursorData(sb_left_arrow), nil, {0, 0}},
+ {"sb_right_arrow", IMAGEBITMAP, MacXCursorData(sb_right_arrow), nil, {0, 0}},
+ {"sb_up_arrow", IMAGEBITMAP, MacXCursorData(sb_up_arrow), nil, {0, 0}},
+ {"sb_v_double_arrow", IMAGEBITMAP, MacXCursorData(sb_v_double_arrow), nil, {0, 0}},
+ {"shuttle", IMAGEBITMAP, MacXCursorData(shuttle), nil, {0, 0}},
+ {"sizing", IMAGEBITMAP, MacXCursorData(sizing), nil, {0, 0}},
+ {"spider", IMAGEBITMAP, MacXCursorData(spider), nil, {0, 0}},
+ {"spraycan", IMAGEBITMAP, MacXCursorData(spraycan), nil, {0, 0}},
+ {"star", IMAGEBITMAP, MacXCursorData(star), nil, {0, 0}},
+ {"target", IMAGEBITMAP, MacXCursorData(target), nil, {0, 0}},
+// {"tcross", IMAGEBITMAP, MacXCursorData(tcross), nil, {0, 0}},
+// {"top_left_arrow", IMAGEBITMAP, MacXCursorData(top_left_arrow), nil, {0, 0}},
+ {"top_left_corner", IMAGEBITMAP, MacXCursorData(top_left_corner), nil, {0, 0}},
+ {"top_right_corner", IMAGEBITMAP, MacXCursorData(top_right_corner), nil, {0, 0}},
+ {"top_side", IMAGEBITMAP, MacXCursorData(top_side), nil, {0, 0}},
+ {"top_tee", IMAGEBITMAP, MacXCursorData(top_tee), nil, {0, 0}},
+ {"trek", IMAGEBITMAP, MacXCursorData(trek), nil, {0, 0}},
+ {"ul_angle", IMAGEBITMAP, MacXCursorData(ul_angle), nil, {0, 0}},
+ {"umbrella", IMAGEBITMAP, MacXCursorData(umbrella), nil, {0, 0}},
+ {"ur_angle", IMAGEBITMAP, MacXCursorData(ur_angle), nil, {0, 0}},
+ {"watch", IMAGEBITMAP, MacXCursorData(watch), nil, {0, 0}},
+// {"xterm", IMAGEBITMAP, MacXCursorData(xterm), nil, {0, 0}},
+ {NULL, 0, nil, nil, {0, 0}}
};
/*
* Declarations of static variables used in this file.
*/
-static TkMacOSXCursor * gCurrentCursor = NULL;
+static TkMacOSXCursor *gCurrentCursor = NULL;
/* A pointer to the current cursor. */
static int gResizeOverride = false;
/* A boolean indicating whether we should use
@@ -194,7 +194,7 @@ static int gTkOwnsCursor = true;/* A boolean indicating whether Tk owns the
* cursor. If not (for instance, in the case
* where a Tk window is embedded in another
* app's window, and the cursor is out of the
- * tk window, we will not attempt to adjust
+ * Tk window, we will not attempt to adjust
* the cursor. */
/*
@@ -278,6 +278,7 @@ FindCursorByName(
kCGColorSpaceGenericGray);
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL,
bitmap, pix*pix/8, NULL);
+
if (provider) {
img = CGImageCreate(pix, pix, 1, 1, pix/8, colorspace,
kCGBitmapByteOrderDefault, provider, decodeWB, 0,
@@ -299,14 +300,22 @@ FindCursorByName(
initWithCGImage:maskedImg];
CFRelease(maskedImg);
}
- if (mask) { CFRelease(mask); }
- if (img) { CFRelease(img); }
- if (colorspace) { CFRelease(colorspace); }
+ if (mask) {
+ CFRelease(mask);
+ }
+ if (img) {
+ CFRelease(img);
+ }
+ if (colorspace) {
+ CFRelease(colorspace);
+ }
if (bitmapImageRep) {
image = [[NSImage alloc] initWithSize:NSMakeSize(pix, pix)];
[image addRepresentation:bitmapImageRep];
+ [image setTemplate:YES];
[bitmapImageRep release];
}
+
uint16_t *hotSpotData = (uint16_t*)(bitmap + 2*pix*pix/8);
hotSpot.y = CFSwapInt16BigToHost(*hotSpotData++);
hotSpot.x = CFSwapInt16BigToHost(*hotSpotData);
@@ -373,6 +382,7 @@ TkGetCursorByName(
TkMacOSXCursor *macCursorPtr = NULL;
const char **argv = NULL;
int argc;
+ (void)tkwin;
/*
* All cursor names are valid lists of one element (for
@@ -381,7 +391,7 @@ TkGetCursorByName(
if (Tcl_SplitList(interp, string, &argc, &argv) == TCL_OK) {
if (argc) {
- macCursorPtr = ckalloc(sizeof(TkMacOSXCursor));
+ macCursorPtr = (TkMacOSXCursor *)ckalloc(sizeof(TkMacOSXCursor));
macCursorPtr->info.cursor = (Tk_Cursor) macCursorPtr;
macCursorPtr->macCursor = nil;
macCursorPtr->type = 0;
@@ -428,6 +438,16 @@ TkCreateCursorFromData(
XColor fgColor, /* Foreground color for cursor. */
XColor bgColor) /* Background color for cursor. */
{
+ (void)tkwin;
+ (void)source;
+ (void)mask;
+ (void)width;
+ (void)height;
+ (void)xHot;
+ (void)yHot;
+ (void)fgColor;
+ (void)bgColor;
+
return NULL;
}
diff --git a/macosx/tkMacOSXDebug.c b/macosx/tkMacOSXDebug.c
index 78008f0..fc01ef4 100644
--- a/macosx/tkMacOSXDebug.c
+++ b/macosx/tkMacOSXDebug.c
@@ -64,7 +64,7 @@ TkMacOSXGetNamedDebugSymbol(
for (i = 0; i < n; i++) {
if (module && *module) {
/* Find image with given module name */
- char *name;
+ const char *name;
const char *path = _dyld_get_image_name(i);
if (!path) {
diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h
index f5ffbbf..efaaa91 100644
--- a/macosx/tkMacOSXDefault.h
+++ b/macosx/tkMacOSXDefault.h
@@ -23,7 +23,9 @@
/*
* The definitions below provide symbolic names for the default colors.
* NORMAL_BG - Normal background color.
+ * NORMAL_FG - Normal foreground color.
* ACTIVE_BG - Background color when widget is active.
+ * ACTIVE_FG - Foreground color when widget is active.
* SELECT_BG - Background color for selected text.
* SELECT_FG - Foreground color for selected text.
* TROUGH - Background color for troughs in scales and scrollbars.
@@ -33,12 +35,14 @@
#define BLACK "Black"
#define WHITE "White"
-#define NORMAL_BG "systemWindowBody"
-#define ACTIVE_BG "systemButtonFacePressed"
-#define ACTIVE_FG "systemPushButtonPressedText"
-#define SELECT_BG "systemHighlight"
-#define SELECT_FG NULL
-#define INACTIVE_SELECT_BG "systemHighlightSecondary"
+#define NORMAL_BG "systemWindowBackgroundColor"
+#define TEXT_BG "systemTextBackgroundColor"
+#define NORMAL_FG "systemTextColor"
+#define ACTIVE_BG "systemWindowBackgroundColor"
+#define ACTIVE_FG "systemTextColor"
+#define SELECT_BG "systemSelectedTextBackgroundColor"
+#define SELECT_FG "systemSelectedTextColor"
+#define INACTIVE_SELECT_BG "systemSelectedTextBackgroundColor"
#define TROUGH "#c3c3c3"
#define INDICATOR "#b03060"
#define DISABLED "#a3a3a3"
@@ -50,11 +54,10 @@
#define DEF_BUTTON_ANCHOR "center"
#define DEF_BUTTON_ACTIVE_BG_COLOR ACTIVE_BG
#define DEF_BUTTON_ACTIVE_BG_MONO BLACK
-#define DEF_BUTTON_ACTIVE_FG_COLOR ACTIVE_FG
-#define DEF_CHKRAD_ACTIVE_FG_COLOR DEF_BUTTON_ACTIVE_FG_COLOR
+#define DEF_BUTTON_ACTIVE_FG_COLOR WHITE
+#define DEF_CHKRAD_ACTIVE_FG_COLOR ACTIVE_FG
#define DEF_BUTTON_ACTIVE_FG_MONO WHITE
-/* #define DEF_BUTTON_BG_COLOR "systemButtonFace"*/
-#define DEF_BUTTON_BG_COLOR WHITE
+#define DEF_BUTTON_BG_COLOR NORMAL_BG
#define DEF_BUTTON_BG_MONO WHITE
#define DEF_BUTTON_BITMAP ""
#define DEF_BUTTON_BORDER_WIDTH "2"
@@ -64,7 +67,7 @@
#define DEF_BUTTON_DEFAULT "disabled"
#define DEF_BUTTON_DISABLED_FG_COLOR DISABLED
#define DEF_BUTTON_DISABLED_FG_MONO ""
-#define DEF_BUTTON_FG "systemButtonText"
+#define DEF_BUTTON_FG NORMAL_FG
#define DEF_CHKRAD_FG DEF_BUTTON_FG
#define DEF_BUTTON_FONT "TkDefaultFont"
#define DEF_BUTTON_HEIGHT "0"
@@ -169,7 +172,7 @@
#define MAC_OSX_ENTRY_RELIEF TK_RELIEF_SUNKEN
#define MAC_OSX_ENTRY_SELECT_RELIEF TK_RELIEF_FLAT
-#define DEF_ENTRY_BG_COLOR NORMAL_BG
+#define DEF_ENTRY_BG_COLOR TEXT_BG
#define DEF_ENTRY_BG_MONO WHITE
#define DEF_ENTRY_BORDER_WIDTH "2"
#define DEF_ENTRY_CURSOR "xterm"
@@ -178,17 +181,15 @@
#define DEF_ENTRY_DISABLED_FG DISABLED
#define DEF_ENTRY_EXPORT_SELECTION "1"
#define DEF_ENTRY_FONT "TkTextFont"
-#define DEF_ENTRY_FG BLACK
+#define DEF_ENTRY_FG NORMAL_FG
#define DEF_ENTRY_HIGHLIGHT_BG NORMAL_BG
#define DEF_ENTRY_HIGHLIGHT BLACK
-/* #define DEF_ENTRY_HIGHLIGHT_WIDTH "3" */
#define DEF_ENTRY_HIGHLIGHT_WIDTH "3"
-#define DEF_ENTRY_INSERT_BG BLACK
+#define DEF_ENTRY_INSERT_BG NORMAL_FG
#define DEF_ENTRY_INSERT_BD_COLOR "0"
#define DEF_ENTRY_INSERT_BD_MONO "0"
#define DEF_ENTRY_INSERT_OFF_TIME "300"
#define DEF_ENTRY_INSERT_ON_TIME "600"
-/* #define DEF_ENTRY_INSERT_WIDTH "2" */
#define DEF_ENTRY_INSERT_WIDTH "1"
#define DEF_ENTRY_JUSTIFY "left"
#define DEF_ENTRY_PLACEHOLDER ""
@@ -196,7 +197,6 @@
#define DEF_ENTRY_READONLY_BG_COLOR NORMAL_BG
#define DEF_ENTRY_READONLY_BG_MONO WHITE
#define DEF_ENTRY_RELIEF "sunken"
-/* #define DEF_ENTRY_RELIEF "solid" */
#define DEF_ENTRY_SCROLL_COMMAND ""
#define DEF_ENTRY_SELECT_COLOR SELECT_BG
#define DEF_ENTRY_SELECT_MONO BLACK
@@ -215,7 +215,9 @@
*/
#define DEF_FRAME_BG_COLOR NORMAL_BG
+#define DEF_FRAME_BG_IMAGE NULL
#define DEF_FRAME_BG_MONO WHITE
+#define DEF_FRAME_BG_TILE "0"
#define DEF_FRAME_BORDER_WIDTH "0"
#define DEF_FRAME_CLASS "Frame"
#define DEF_FRAME_COLORMAP ""
@@ -239,7 +241,7 @@
#define DEF_LABELFRAME_BORDER_WIDTH "2"
#define DEF_LABELFRAME_CLASS "Labelframe"
#define DEF_LABELFRAME_RELIEF "groove"
-#define DEF_LABELFRAME_FG "systemButtonText"
+#define DEF_LABELFRAME_FG NORMAL_FG
#define DEF_LABELFRAME_FONT "TkDefaultFont"
#define DEF_LABELFRAME_TEXT ""
#define DEF_LABELFRAME_LABELANCHOR "nw"
@@ -249,14 +251,14 @@
*/
#define DEF_LISTBOX_ACTIVE_STYLE "dotbox"
-#define DEF_LISTBOX_BG_COLOR WHITE
+#define DEF_LISTBOX_BG_COLOR TEXT_BG
#define DEF_LISTBOX_BG_MONO WHITE
#define DEF_LISTBOX_BORDER_WIDTH "1"
#define DEF_LISTBOX_CURSOR ""
#define DEF_LISTBOX_DISABLED_FG DISABLED
#define DEF_LISTBOX_EXPORT_SELECTION "1"
#define DEF_LISTBOX_FONT "TkTextFont"
-#define DEF_LISTBOX_FG BLACK
+#define DEF_LISTBOX_FG NORMAL_FG
#define DEF_LISTBOX_HEIGHT "10"
#define DEF_LISTBOX_HIGHLIGHT_BG NORMAL_BG
#define DEF_LISTBOX_HIGHLIGHT BLACK
@@ -339,9 +341,9 @@
#define DEF_MENUBUTTON_ANCHOR "w"
#define DEF_MENUBUTTON_ACTIVE_BG_COLOR ACTIVE_BG
-#define DEF_MENUBUTTON_ACTIVE_BG_MONO BLACK
+#define DEF_MENUBUTTON_ACTIVE_BG_MONO WHITE
#define DEF_MENUBUTTON_ACTIVE_FG_COLOR ACTIVE_FG
-#define DEF_MENUBUTTON_ACTIVE_FG_MONO WHITE
+#define DEF_MENUBUTTON_ACTIVE_FG_MONO BLACK
#define DEF_MENUBUTTON_BG_COLOR NORMAL_BG
#define DEF_MENUBUTTON_BG_MONO WHITE
#define DEF_MENUBUTTON_BITMAP ""
@@ -351,7 +353,7 @@
#define DEF_MENUBUTTON_DISABLED_FG_COLOR DISABLED
#define DEF_MENUBUTTON_DISABLED_FG_MONO ""
#define DEF_MENUBUTTON_FONT "TkDefaultFont"
-#define DEF_MENUBUTTON_FG BLACK
+#define DEF_MENUBUTTON_FG NORMAL_FG
#define DEF_MENUBUTTON_HEIGHT "0"
#define DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR DEF_MENUBUTTON_BG_COLOR
#define DEF_MENUBUTTON_HIGHLIGHT_BG_MONO DEF_MENUBUTTON_BG_MONO
@@ -382,7 +384,7 @@
#define DEF_MESSAGE_BG_MONO WHITE
#define DEF_MESSAGE_BORDER_WIDTH "1"
#define DEF_MESSAGE_CURSOR ""
-#define DEF_MESSAGE_FG BLACK
+#define DEF_MESSAGE_FG NORMAL_FG
#define DEF_MESSAGE_FONT "TkDefaultFont"
#define DEF_MESSAGE_HIGHLIGHT_BG NORMAL_BG
#define DEF_MESSAGE_HIGHLIGHT BLACK
@@ -446,7 +448,7 @@
#define DEF_SCALE_CURSOR ""
#define DEF_SCALE_DIGITS "0"
#define DEF_SCALE_FONT "TkDefaultFont"
-#define DEF_SCALE_FG_COLOR BLACK
+#define DEF_SCALE_FG_COLOR NORMAL_FG
#define DEF_SCALE_FG_MONO BLACK
#define DEF_SCALE_FROM "0"
#define DEF_SCALE_HIGHLIGHT_BG_COLOR DEF_SCALE_BG_COLOR
@@ -503,19 +505,19 @@
*/
#define DEF_TEXT_AUTO_SEPARATORS "1"
-#define DEF_TEXT_BG_COLOR NORMAL_BG
+#define DEF_TEXT_BG_COLOR TEXT_BG
#define DEF_TEXT_BG_MONO WHITE
#define DEF_TEXT_BLOCK_CURSOR "0"
#define DEF_TEXT_BORDER_WIDTH "0"
#define DEF_TEXT_CURSOR "xterm"
-#define DEF_TEXT_FG BLACK
+#define DEF_TEXT_FG NORMAL_FG
#define DEF_TEXT_EXPORT_SELECTION "1"
#define DEF_TEXT_FONT "TkFixedFont"
#define DEF_TEXT_HEIGHT "24"
#define DEF_TEXT_HIGHLIGHT_BG NORMAL_BG
#define DEF_TEXT_HIGHLIGHT BLACK
#define DEF_TEXT_HIGHLIGHT_WIDTH "3"
-#define DEF_TEXT_INSERT_BG BLACK
+#define DEF_TEXT_INSERT_BG NORMAL_FG
#define DEF_TEXT_INSERT_BD_COLOR "0"
#define DEF_TEXT_INSERT_BD_MONO "0"
#define DEF_TEXT_INSERT_OFF_TIME "300"
@@ -555,6 +557,14 @@
#define DEF_CANVTEXT_FONT "TkDefaultFont"
/*
+ * Defaults for canvas items
+ * (arcs, bitmaps, lines, polygons, rectangles, and ovals):
+ */
+
+#define DEF_CANVBMAP_FG NORMAL_FG
+#define DEF_CANVITEM_OUTLINE NORMAL_FG
+
+/*
* Defaults for toplevels (most of the defaults for frames also apply
* to toplevels):
*/
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index c3778f1..898547e 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -22,31 +22,39 @@
#else
#define modalOK NSModalResponseOK
#define modalCancel NSModalResponseCancel
-#endif
+#endif // MAC_OS_X_VERSION_MIN_REQUIRED < 1090
#define modalOther -1
#define modalError -2
-/*Vars for filtering in "open file" and "save file" dialogs.*/
-typedef struct {
- bool doFileTypes; // show the accessory view which displays the filter menu
- bool preselectFilter; // a filter was selected by the typevariable
- bool userHasSelectedFilter; // The user has changed the filter in the accessory view
-
- NSMutableArray *fileTypeNames; // array of names, e.g. "Text document"
- NSMutableArray *fileTypeExtensions; // array of allowed extensions per name, e.g. "txt", "doc"
- NSMutableArray *fileTypeLabels; // displayed string, e.g. "Text document (.txt, .doc)"
- NSMutableArray *fileTypeAllowsAll; // boolean if the all pattern (*.*) is included
-
- NSMutableArray *allowedExtensions; // set of all allowed extensions
- bool allowedExtensionsAllowAll; // set of all allowed extensions includes *.*
+/*
+ * Vars for filtering in "open file" and "save file" dialogs.
+ */
- NSUInteger fileTypeIndex; // index of currently selected filter
+typedef struct {
+ bool doFileTypes; /* Show the accessory view which
+ * displays the filter menu */
+ bool preselectFilter; /* A filter was selected by the
+ * typevariable. */
+ bool userHasSelectedFilter; /* The user has changed the filter in
+ * the accessory view. */
+ NSMutableArray *fileTypeNames; /* Array of names, e.g. "Text
+ * document". */
+ NSMutableArray *fileTypeExtensions; /* Array of allowed extensions per
+ * name, e.g. "txt", "doc". */
+ NSMutableArray *fileTypeLabels; /* Displayed string, e.g. "Text
+ * document (.txt, .doc)". */
+ NSMutableArray *fileTypeAllowsAll; /* Boolean if the all pattern (*.*) is
+ * included. */
+ NSMutableArray *allowedExtensions; /* Set of all allowed extensions. */
+ bool allowedExtensionsAllowAll; /* Set of all allowed extensions
+ * includes *.* */
+ NSUInteger fileTypeIndex; /* Index of currently selected
+ * filter. */
} filepanelFilterInfo;
-filepanelFilterInfo filterInfo;
-
-NSOpenPanel *openpanel;
-NSSavePanel *savepanel;
+static filepanelFilterInfo filterInfo;
+static NSOpenPanel *openpanel;
+static NSSavePanel *savepanel;
static const char *const colorOptionStrings[] = {
"-initialcolor", "-parent", "-title", NULL
@@ -166,10 +174,15 @@ static const short alertNativeButtonIndexAndTypeToButtonIndex[][3] = {
};
/*
- * Construct a file URL from directory and filename. Either may
- * be nil. If both are nil, returns nil.
+ * Construct a file URL from directory and filename. Either may be nil. If both
+ * are nil, returns nil.
*/
-static NSURL *getFileURL(NSString *directory, NSString *filename) {
+
+static NSURL *
+getFileURL(
+ NSString *directory,
+ NSString *filename)
+{
NSURL *url = nil;
if (directory) {
url = [NSURL fileURLWithPath:directory isDirectory:YES];
@@ -184,8 +197,25 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) {
@implementation TKApplication(TKDialog)
+- (BOOL)panel:(id)sender shouldEnableURL:(NSURL *)url {
+ (void)sender;
+ (void)url;
+ return YES;
+}
+
+- (void)panel:(id)sender didChangeToDirectoryURL:(NSURL *)url {
+ (void)sender; (void)url;
+}
+
+- (BOOL)panel:(id)sender validateURL:(NSURL *)url error:(NSError **)outError {
+ (void)sender; (void)url;
+ *outError = nil;
+ return YES;
+}
+
- (void) tkFilePanelDidEnd: (NSSavePanel *) panel
- returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
+ returnCode: (NSModalResponse) returnCode
+ contextInfo: (void *) contextInfo
{
FilePanelCallbackInfo *callbackInfo = contextInfo;
@@ -207,7 +237,7 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) {
callbackInfo->cmdObj, &objc, &objv);
if (result == TCL_OK && objc) {
- tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
+ tmpv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc);
tmpv[objc] = resultObj;
TkBackgroundEvalObjv(callbackInfo->interp, objc + 1, tmpv,
@@ -229,7 +259,6 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) {
}
}
-
- (void) tkAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode
contextInfo: (void *) contextInfo
{
@@ -246,7 +275,7 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) {
callbackInfo->cmdObj, &objc, &objv);
if (result == TCL_OK && objc) {
- tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
+ tmpv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc);
tmpv[objc] = resultObj;
TkBackgroundEvalObjv(callbackInfo->interp, objc + 1, tmpv,
@@ -272,12 +301,18 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) {
if ([[filterInfo.fileTypeAllowsAll objectAtIndex:filterInfo.fileTypeIndex] boolValue]) {
[openpanel setAllowsOtherFileTypes:YES];
- /* setAllowsOtherFileTypes might have no effect; it's inherited from the
- * NSSavePanel, where it has the effect that it does not append an extension
- * Setting the allowed file types to nil allows selecting any file */
+
+ /*
+ * setAllowsOtherFileTypes might have no effect; it's inherited from
+ * the NSSavePanel, where it has the effect that it does not append an
+ * extension. Setting the allowed file types to nil allows selecting
+ * any file.
+ */
+
[openpanel setAllowedFileTypes:nil];
} else {
- NSMutableArray *allowedtypes = [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex];
+ NSMutableArray *allowedtypes =
+ [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex];
[openpanel setAllowedFileTypes:allowedtypes];
[openpanel setAllowsOtherFileTypes:NO];
}
@@ -293,7 +328,8 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) {
[savepanel setAllowsOtherFileTypes:YES];
[savepanel setAllowedFileTypes:nil];
} else {
- NSMutableArray *allowedtypes = [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex];
+ NSMutableArray *allowedtypes =
+ [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex];
[savepanel setAllowedFileTypes:allowedtypes];
[savepanel setAllowsOtherFileTypes:NO];
}
@@ -305,6 +341,31 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) {
#pragma mark -
+static NSInteger showOpenSavePanel(
+ NSSavePanel *panel,
+ NSWindow *parent,
+ FilePanelCallbackInfo *callbackInfo)
+{
+ NSInteger modalReturnCode;
+
+ if (parent && ![parent attachedSheet]) {
+ [panel beginSheetModalForWindow:parent
+ completionHandler:^(NSModalResponse returnCode) {
+ [NSApp tkFilePanelDidEnd:panel
+ returnCode:returnCode
+ contextInfo:callbackInfo ];
+ }];
+
+ modalReturnCode = callbackInfo->cmdObj ? modalOther :
+ [panel runModal];
+ } else {
+ modalReturnCode = [panel runModal];
+ [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode
+ contextInfo:callbackInfo];
+ }
+ return modalReturnCode;
+}
+
/*
*----------------------------------------------------------------------
*
@@ -384,6 +445,7 @@ Tk_ChooseColorObjCmd(
[colorPanel _setUseModalAppearance:YES];
if (title) {
NSString *s = [[NSString alloc] initWithUTF8String:title];
+
[colorPanel setTitle:s];
[s release];
}
@@ -415,9 +477,17 @@ end:
return result;
}
-/* dissect the -filetype nested lists and store the information
- * in the filterInfo structure */
-int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVariablePtr) {
+/*
+ * Dissect the -filetype nested lists and store the information in the
+ * filterInfo structure.
+ */
+
+static int
+parseFileFilters(
+ Tcl_Interp *interp,
+ Tcl_Obj *fileTypesPtr,
+ Tcl_Obj *typeVariablePtr)
+{
if (!fileTypesPtr) {
filterInfo.doFileTypes = false;
@@ -425,6 +495,7 @@ int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVar
}
FileFilterList fl;
+
TkInitFileFilters(&fl);
if (TkGetFileFilters(interp, &fl, fileTypesPtr, 0) != TCL_OK) {
TkFreeFileFilters(&fl);
@@ -445,11 +516,12 @@ int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVar
if (filterInfo.doFileTypes) {
for (FileFilter *filterPtr = fl.filters; filterPtr;
filterPtr = filterPtr->next) {
- NSString * name = [[NSString alloc] initWithUTF8String: filterPtr -> name];
+ NSString *name = [[NSString alloc] initWithUTF8String: filterPtr->name];
+
[filterInfo.fileTypeNames addObject:name];
[name release];
- NSMutableArray * clauseextensions = [NSMutableArray array];
- NSMutableArray * displayextensions = [NSMutableArray array];
+ NSMutableArray *clauseextensions = [NSMutableArray array];
+ NSMutableArray *displayextensions = [NSMutableArray array];
bool allowsAll = NO;
for (FileFilterClause *clausePtr = filterPtr->clauses; clausePtr;
@@ -460,7 +532,7 @@ int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVar
const char *str = globPtr->pattern;
while (*str && (*str == '*' || *str == '.')) {
str++;
- }
+ }
if (*str) {
NSString *extension = [[NSString alloc] initWithUTF8String:str];
if (![filterInfo.allowedExtensions containsObject:extension]) {
@@ -472,7 +544,10 @@ int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVar
[extension release];
} else {
- // it is the all pattern (*, .* or *.*)
+ /*
+ * It is the all pattern (*, .* or *.*)
+ */
+
allowsAll = YES;
filterInfo.allowedExtensionsAllowAll = YES;
[displayextensions addObject:@"*"];
@@ -482,27 +557,39 @@ int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVar
[filterInfo.fileTypeExtensions addObject:clauseextensions];
[filterInfo.fileTypeAllowsAll addObject:[NSNumber numberWithBool:allowsAll]];
- NSMutableString * label = [[NSMutableString alloc] initWithString:name];
+ NSMutableString *label = [[NSMutableString alloc] initWithString:name];
[label appendString:@" ("];
[label appendString:[displayextensions componentsJoinedByString:@", "]];
[label appendString:@")"];
[filterInfo.fileTypeLabels addObject:label];
[label release];
-
}
- /* Check if the typevariable exists and matches one of the names */
+ /*
+ * Check if the typevariable exists and matches one of the names.
+ */
+
filterInfo.preselectFilter = false;
filterInfo.userHasSelectedFilter = false;
if (typeVariablePtr) {
- /* extract the variable content as a NSString */
- Tcl_Obj *selectedFileTypeObj = Tcl_ObjGetVar2(interp, typeVariablePtr, NULL, TCL_GLOBAL_ONLY);
+ /*
+ * Extract the variable content as a NSString.
+ */
+
+ Tcl_Obj *selectedFileTypeObj = Tcl_ObjGetVar2(interp,
+ typeVariablePtr, NULL, TCL_GLOBAL_ONLY);
+
+ /*
+ * Check that the typevariable exists.
+ */
- /* check that the typevariable exists */
if (selectedFileTypeObj != NULL) {
- const char *selectedFileType = Tcl_GetString(selectedFileTypeObj);
- NSString *selectedFileTypeStr = [[NSString alloc] initWithUTF8String:selectedFileType];
- NSUInteger index = [filterInfo.fileTypeNames indexOfObject:selectedFileTypeStr];
+ const char *selectedFileType =
+ Tcl_GetString(selectedFileTypeObj);
+ NSString *selectedFileTypeStr =
+ [[NSString alloc] initWithUTF8String:selectedFileType];
+ NSUInteger index =
+ [filterInfo.fileTypeNames indexOfObject:selectedFileTypeStr];
if (index != NSNotFound) {
filterInfo.fileTypeIndex = index;
@@ -517,17 +604,24 @@ int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVar
return TCL_OK;
}
-bool filterCompatible(NSString *extension, int filterIndex) {
- NSMutableArray *allowedExtensions = [filterInfo.fileTypeExtensions objectAtIndex: filterIndex];
+static bool
+filterCompatible(
+ NSString *extension,
+ int filterIndex)
+{
+ NSMutableArray *allowedExtensions =
+ [filterInfo.fileTypeExtensions objectAtIndex: filterIndex];
+
+ /*
+ * If this contains the all pattern, accept any extension.
+ */
- /* If this contains the all pattern, accept any extension */
if ([[filterInfo.fileTypeAllowsAll objectAtIndex:filterIndex] boolValue]) {
return true;
}
return [allowedExtensions containsObject: extension];
}
-
/*
*----------------------------------------------------------------------
@@ -627,22 +721,24 @@ Tk_GetOpenFileObjCmd(
break;
}
}
-
if (title) {
[openpanel setTitle:title];
- /* From OSX 10.11, the title string is silently ignored in the open panel.
- * Prepend the title to the message in this case
- * NOTE should be conditional on OSX version, but
- * -mmacosx-version-min does not revert this behaviour*/
+ /*
+ * From OSX 10.11, the title string is silently ignored in the open
+ * panel. Prepend the title to the message in this case.
+ */
- if (message) {
- NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
- [message release];
- [title release];
- message = fullmessage;
- } else {
- message = title;
+ if ([NSApp macMinorVersion] > 10) {
+ if (message) {
+ NSString *fullmessage =
+ [[NSString alloc] initWithFormat:@"%@\n%@", title, message];
+ [message release];
+ [title release];
+ message = fullmessage;
+ } else {
+ message = title;
+ }
}
}
@@ -658,117 +754,124 @@ Tk_GetOpenFileObjCmd(
}
if (filterInfo.doFileTypes) {
- NSView *accessoryView = [[NSView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 300, 32.0)];
- NSTextField *label = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 60, 22)];
+ NSTextField *label = [[NSTextField alloc]
+ initWithFrame:NSMakeRect(0, 0, 60, 22)];
+ NSPopUpButton *popupButton = [[NSPopUpButton alloc]
+ initWithFrame:NSMakeRect(50.0, 2, 240, 22.0) pullsDown:NO];
+ NSView *accessoryView = [[NSView alloc]
+ initWithFrame:NSMakeRect(0.0, 0.0, 300, 32.0)];
+
[label setEditable:NO];
[label setStringValue:@"Filter:"];
[label setBordered:NO];
[label setBezeled:NO];
[label setDrawsBackground:NO];
-
- NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(50.0, 2, 240, 22.0) pullsDown:NO];
[popupButton addItemsWithTitles:filterInfo.fileTypeLabels];
[popupButton setAction:@selector(selectFormat:)];
-
[accessoryView addSubview:label];
[accessoryView addSubview:popupButton];
-
if (filterInfo.preselectFilter) {
- /* A specific filter was selected from the typevariable. Select it and
- * open the accessory view */
+
+ /*
+ * A specific filter was selected from the typevariable. Select it
+ * and open the accessory view.
+ */
+
[popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
- /* on OSX > 10.11, the optons are not visible by default. Ergo allow all file types
+
+ /*
+ * On OSX > 10.11, the options are not visible by default. Ergo
+ * allow all file types
[openpanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
*/
+
[openpanel setAllowedFileTypes:filterInfo.allowedExtensions];
} else {
[openpanel setAllowedFileTypes:filterInfo.allowedExtensions];
}
-
if (filterInfo.allowedExtensionsAllowAll) {
[openpanel setAllowsOtherFileTypes:YES];
} else {
[openpanel setAllowsOtherFileTypes:NO];
}
-
[openpanel setAccessoryView:accessoryView];
} else {
- /* No filters are given. Allow picking all files */
+ /*
+ * No filters are given. Allow picking all files.
+ */
+
[openpanel setAllowsOtherFileTypes:YES];
}
-
if (cmdObj) {
- callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
if (Tcl_IsShared(cmdObj)) {
cmdObj = Tcl_DuplicateObj(cmdObj);
}
Tcl_IncrRefCount(cmdObj);
}
-
+ callbackInfo = (FilePanelCallbackInfo *)ckalloc(sizeof(FilePanelCallbackInfo));
callbackInfo->cmdObj = cmdObj;
callbackInfo->interp = interp;
callbackInfo->multiple = multiple;
- parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
- if (haveParentOption && parent && ![parent attachedSheet]) {
- parentIsKey = [parent isKeyWindow];
- if (directory || filename ) {
- NSURL * fileURL = getFileURL(directory, filename);
- [openpanel setDirectoryURL:fileURL];
- }
+ if (directory || filename) {
+ NSURL *fileURL = getFileURL(directory, filename);
- [openpanel beginSheetModalForWindow:parent
- completionHandler:^(NSInteger returnCode)
- { [NSApp tkFilePanelDidEnd:openpanel
- returnCode:returnCode
- contextInfo:callbackInfo ]; } ];
- modalReturnCode = cmdObj ? modalOther : [NSApp runModalForWindow:openpanel];
+ [openpanel setDirectoryURL:fileURL];
+ }
+ if (haveParentOption) {
+ parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
+ parentIsKey = parent && [parent isKeyWindow];
} else {
- if (directory || filename ) {
- NSURL * fileURL = getFileURL(directory, filename);
- [openpanel setDirectoryURL:fileURL];
- }
-
- modalReturnCode = [openpanel runModal];
- [NSApp tkFilePanelDidEnd:openpanel returnCode:modalReturnCode
- contextInfo:callbackInfo];
+ parent = nil;
+ parentIsKey = False;
}
+ modalReturnCode = showOpenSavePanel(openpanel, parent, callbackInfo);
result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
if (parentIsKey) {
[parent makeKeyWindow];
}
-
- if ((typeVariablePtr && (modalReturnCode == NSOKButton)) &&
- filterInfo.doFileTypes) {
+ if ((typeVariablePtr && (modalReturnCode == NSOKButton))
+ && filterInfo.doFileTypes) {
/*
- * The -typevariable must be set to the selected file type, if the dialog was not cancelled
+ * The -typevariable must be set to the selected file type, if the
+ * dialog was not cancelled.
*/
+
NSUInteger selectedFilterIndex = filterInfo.fileTypeIndex;
NSString *selectedFilter = NULL;
+
if (filterInfo.userHasSelectedFilter) {
selectedFilterIndex = filterInfo.fileTypeIndex;
selectedFilter = [filterInfo.fileTypeNames objectAtIndex:selectedFilterIndex];
} else {
- /* Difficult case: the user has not touched the filter settings, but we must
- * return something in the typevariable. First check if the preselected type is compatible
- * with the selected file, otherwise choose the first compatible type from the list,
- * finally fall back to the empty string */
+ /*
+ * Difficult case: the user has not touched the filter settings,
+ * but we must return something in the typevariable. First check if
+ * the preselected type is compatible with the selected file,
+ * otherwise choose the first compatible type from the list,
+ * finally fall back to the empty string.
+ */
+
NSURL *selectedFile;
+ NSString *extension;
if (multiple) {
- // Use the first file in the case of multiple selection
- // Anyway it is not overly useful here
+ /*
+ * Use the first file in the case of multiple selection.
+ * Anyway it is not overly useful here.
+ */
selectedFile = [[openpanel URLs] objectAtIndex:0];
} else {
selectedFile = [openpanel URL];
}
- NSString *extension = [selectedFile pathExtension];
+ extension = [selectedFile pathExtension];
+
if (filterInfo.preselectFilter &&
- filterCompatible(extension, filterInfo.fileTypeIndex)) {
+ filterCompatible(extension, filterInfo.fileTypeIndex)) {
selectedFilterIndex = filterInfo.fileTypeIndex; // The preselection from the typevariable
selectedFilter = [filterInfo.fileTypeNames objectAtIndex:selectedFilterIndex];
} else {
- // scan the list
NSUInteger i;
+
for (i = 0; i < [filterInfo.fileTypeNames count]; i++) {
if (filterCompatible(extension, i)) {
selectedFilterIndex = i;
@@ -780,19 +883,15 @@ Tk_GetOpenFileObjCmd(
} else {
selectedFilter = @"";
}
-
}
}
-
Tcl_ObjSetVar2(interp, typeVariablePtr, NULL,
- Tcl_NewStringObj([selectedFilter UTF8String], -1), TCL_GLOBAL_ONLY);
+ Tcl_NewStringObj([selectedFilter UTF8String], -1),
+ TCL_GLOBAL_ONLY);
}
-
-
- end:
+ end:
return result;
}
-
/*
*----------------------------------------------------------------------
@@ -807,6 +906,7 @@ Tk_GetOpenFileObjCmd(
*
* Side effects:
* See user documentation.
+ *
*----------------------------------------------------------------------
*/
@@ -828,7 +928,7 @@ Tk_GetSaveFileObjCmd(
NSString *directory = nil, *filename = nil, *defaultType = nil;
NSString *message = nil, *title = nil;
NSWindow *parent;
- savepanel = [NSSavePanel savePanel];
+ savepanel = [NSSavePanel savePanel];
NSInteger modalReturnCode = modalError;
BOOL parentIsKey = NO;
@@ -906,13 +1006,17 @@ Tk_GetSaveFileObjCmd(
if (title) {
[savepanel setTitle:title];
- /* From OSX 10.11, the title string is silently ignored, if the save panel is a sheet.
- * Prepend the title to the message in this case
- * NOTE should be conditional on OSX version, but
- * -mmacosx-version-min does not revert this behaviour*/
+ /*
+ * From OSX 10.11, the title string is silently ignored, if the save
+ * panel is a sheet. Prepend the title to the message in this case.
+ * NOTE: should be conditional on OSX version, but -mmacosx-version-min
+ * does not revert this behaviour.
+ */
+
if (haveParentOption) {
if (message) {
- NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
+ NSString *fullmessage =
+ [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
[message release];
[title release];
message = fullmessage;
@@ -932,15 +1036,20 @@ Tk_GetSaveFileObjCmd(
}
if (filterInfo.doFileTypes) {
- NSView *accessoryView = [[NSView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 300, 32.0)];
- NSTextField *label = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 60, 22)];
+ NSView *accessoryView = [[NSView alloc]
+ initWithFrame:NSMakeRect(0.0, 0.0, 300, 32.0)];
+ NSTextField *label = [[NSTextField alloc]
+ initWithFrame:NSMakeRect(0, 0, 60, 22)];
+
[label setEditable:NO];
[label setStringValue:NSLocalizedString(@"Format:", nil)];
[label setBordered:NO];
[label setBezeled:NO];
[label setDrawsBackground:NO];
- NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(50.0, 2, 340, 22.0) pullsDown:NO];
+ NSPopUpButton *popupButton = [[NSPopUpButton alloc]
+ initWithFrame:NSMakeRect(50.0, 2, 340, 22.0) pullsDown:NO];
+
[popupButton addItemsWithTitles:filterInfo.fileTypeLabels];
[popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
[popupButton setAction:@selector(saveFormat:)];
@@ -953,10 +1062,14 @@ Tk_GetSaveFileObjCmd(
[savepanel setAllowedFileTypes:[filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]];
[savepanel setAllowsOtherFileTypes:filterInfo.allowedExtensionsAllowAll];
} else if (defaultType) {
- /* If no filetypes are given, defaultextension is an alternative way
- * to specify the attached extension. Just propose this extension,
- * but don't display an accessory view */
+ /*
+ * If no filetypes are given, defaultextension is an alternative way to
+ * specify the attached extension. Just propose this extension, but
+ * don't display an accessory view.
+ */
+
NSMutableArray *AllowedFileTypes = [NSMutableArray array];
+
[AllowedFileTypes addObject:defaultType];
[savepanel setAllowedFileTypes:AllowedFileTypes];
[savepanel setAllowsOtherFileTypes:YES];
@@ -966,63 +1079,57 @@ Tk_GetSaveFileObjCmd(
[savepanel setExtensionHidden:NO];
if (cmdObj) {
- callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
if (Tcl_IsShared(cmdObj)) {
cmdObj = Tcl_DuplicateObj(cmdObj);
}
Tcl_IncrRefCount(cmdObj);
}
+ callbackInfo = (FilePanelCallbackInfo *)ckalloc(sizeof(FilePanelCallbackInfo));
callbackInfo->cmdObj = cmdObj;
callbackInfo->interp = interp;
callbackInfo->multiple = 0;
- parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
- if (haveParentOption && parent && ![parent attachedSheet]) {
- parentIsKey = [parent isKeyWindow];
- if (directory) {
- [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
- }
- /*check for file name, otherwise set to empty string; crashes with uncaught exception if set to nil*/
- if (filename) {
- [savepanel setNameFieldStringValue:filename];
- } else {
- [savepanel setNameFieldStringValue:@""];
- }
- [savepanel beginSheetModalForWindow:parent
- completionHandler:^(NSInteger returnCode)
- { [NSApp tkFilePanelDidEnd:savepanel
- returnCode:returnCode
- contextInfo:callbackInfo ]; } ];
- modalReturnCode = cmdObj ? modalOther : [NSApp runModalForWindow:savepanel];
+ if (directory) {
+ [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
+ }
+
+ /*
+ * Check for file name and set to the empty string if nil. This prevents a crash
+ * with an uncaught exception.
+ */
+
+ if (filename) {
+ [savepanel setNameFieldStringValue:filename];
} else {
- if (directory) {
- [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
- }
- /*check for file name, otherwise set to empty string; crashes with uncaught exception if set to nil*/
- if (filename) {
- [savepanel setNameFieldStringValue:filename];
- } else {
- [savepanel setNameFieldStringValue:@""];
- }
- modalReturnCode = [savepanel runModal];
- [NSApp tkFilePanelDidEnd:savepanel returnCode:modalReturnCode
- contextInfo:callbackInfo];
+ [savepanel setNameFieldStringValue:@""];
}
+ if (haveParentOption) {
+ parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
+ parentIsKey = parent && [parent isKeyWindow];
+ } else {
+ parent = nil;
+ parentIsKey = False;
+ }
+ modalReturnCode = showOpenSavePanel(savepanel, parent, callbackInfo);
result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
if (parentIsKey) {
[parent makeKeyWindow];
}
- if ((typeVariablePtr && (modalReturnCode == NSOKButton)) && filterInfo.doFileTypes) {
+ if (typeVariablePtr && (modalReturnCode == NSOKButton)
+ && filterInfo.doFileTypes) {
/*
- * The -typevariable must be set to the selected file type, if the dialog was not cancelled
+ * The -typevariable must be set to the selected file type, if the
+ * dialog was not cancelled.
*/
- NSString * selectedFilter = [filterInfo.fileTypeNames objectAtIndex:filterInfo.fileTypeIndex];
+
+ NSString *selectedFilter =
+ [filterInfo.fileTypeNames objectAtIndex:filterInfo.fileTypeIndex];
Tcl_ObjSetVar2(interp, typeVariablePtr, NULL,
- Tcl_NewStringObj([selectedFilter UTF8String], -1), TCL_GLOBAL_ONLY);
+ Tcl_NewStringObj([selectedFilter UTF8String], -1),
+ TCL_GLOBAL_ONLY);
}
-
end:
return result;
}
@@ -1121,35 +1228,34 @@ Tk_ChooseDirectoryObjCmd(
[panel setCanChooseDirectories:YES];
[panel setCanCreateDirectories:!mustexist];
if (cmdObj) {
- callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
if (Tcl_IsShared(cmdObj)) {
cmdObj = Tcl_DuplicateObj(cmdObj);
}
Tcl_IncrRefCount(cmdObj);
}
+ callbackInfo = (FilePanelCallbackInfo *)ckalloc(sizeof(FilePanelCallbackInfo));
callbackInfo->cmdObj = cmdObj;
callbackInfo->interp = interp;
callbackInfo->multiple = 0;
- /*check for directory value, set to root if not specified; otherwise crashes with exception because of nil string parameter*/
+
+ /*
+ * Check for directory value, set to root if not specified; otherwise
+ * crashes with exception because of nil string parameter.
+ */
+
if (!directory) {
directory = @"/";
}
parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
- if (haveParentOption && parent && ![parent attachedSheet]) {
- parentIsKey = [parent isKeyWindow];
- [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
- [panel beginSheetModalForWindow:parent
- completionHandler:^(NSInteger returnCode)
- { [NSApp tkFilePanelDidEnd:panel
- returnCode:returnCode
- contextInfo:callbackInfo ]; } ];
- modalReturnCode = cmdObj ? modalOther : [NSApp runModalForWindow:panel];
+ [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
+ if (haveParentOption) {
+ parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
+ parentIsKey = parent && [parent isKeyWindow];
} else {
- [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
- modalReturnCode = [panel runModal];
- [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode
- contextInfo:callbackInfo];
+ parent = nil;
+ parentIsKey = False;
}
+ modalReturnCode = showOpenSavePanel(panel, parent, callbackInfo);
result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
if (parentIsKey) {
[parent makeKeyWindow];
@@ -1201,11 +1307,12 @@ TkAboutDlg(void)
*/
NSString *version = @"Tcl " TCL_PATCH_LEVEL " & Tk " TCL_PATCH_LEVEL;
- NSString *url = @"www.tcl-lang.org";
+ NSString *url = @"www.tcl-lang.org";
NSTextView *credits = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,300,300)];
NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
NSDictionary *textAttributes = [NSDictionary dictionaryWithObject:font
forKey:NSFontAttributeName];
+
[credits insertText: [[NSAttributedString alloc]
initWithString:[NSString stringWithFormat: @"\n"
"Tcl and Tk are distributed under a modified BSD license: "
@@ -1219,11 +1326,13 @@ TkAboutDlg(void)
"%1$C 1998-2000 Jim Ingham & Ray Johnson\n\n"
"%1$C 1998-2000 Scriptics Inc.\n\n"
"%1$C 1996-1997 Sun Microsystems Inc.", 0xA9, year]
- attributes:textAttributes]
- replacementRange:NSMakeRange(0,0)];
+ attributes:textAttributes]
+ replacementRange:NSMakeRange(0,0)];
[credits setDrawsBackground:NO];
[credits setEditable:NO];
- NSAlert *about = [[NSAlert alloc] init];
+
+ NSAlert *about = [[NSAlert alloc] init];
+
[[about window] setTitle:@"About Tcl & Tk"];
[about setMessageText: version];
[about setInformativeText:url];
@@ -1250,11 +1359,13 @@ TkAboutDlg(void)
int
TkMacOSXStandardAboutPanelObjCmd(
- ClientData clientData, /* Unused. */
+ ClientData dummy, /* Unused. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
+ (void)dummy;
+
if (objc > 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
@@ -1378,7 +1489,8 @@ Tk_MessageBoxObjCmd(
*/
if (Tcl_GetIndexFromObjStruct(interp, objv[indexDefaultOption + 1],
- alertButtonStrings, sizeof(char *), "-default value", TCL_EXACT, &index) != TCL_OK) {
+ alertButtonStrings, sizeof(char *), "-default value",
+ TCL_EXACT, &index) != TCL_OK) {
goto end;
}
@@ -1399,7 +1511,7 @@ Tk_MessageBoxObjCmd(
[alert setAlertStyle:alertStyles[iconIndex]];
i = 0;
while (i < 3 && alertButtonNames[typeIndex][i]) {
- [alert addButtonWithTitle:(NSString*)alertButtonNames[typeIndex][i++]];
+ [alert addButtonWithTitle:(NSString*) alertButtonNames[typeIndex][i++]];
}
buttons = [alert buttons];
for (NSButton *b in buttons) {
@@ -1414,24 +1526,25 @@ Tk_MessageBoxObjCmd(
[[buttons objectAtIndex: defaultNativeButtonIndex-1]
setKeyEquivalent: @"\r"];
if (cmdObj) {
- callbackInfo = ckalloc(sizeof(AlertCallbackInfo));
if (Tcl_IsShared(cmdObj)) {
cmdObj = Tcl_DuplicateObj(cmdObj);
}
Tcl_IncrRefCount(cmdObj);
}
+ callbackInfo = (AlertCallbackInfo *)ckalloc(sizeof(AlertCallbackInfo));
callbackInfo->cmdObj = cmdObj;
callbackInfo->interp = interp;
callbackInfo->typeIndex = typeIndex;
parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
if (haveParentOption && parent && ![parent attachedSheet]) {
parentIsKey = [parent isKeyWindow];
-#if MAC_OS_X_VERSION_MIN_REQUIRED > 1090
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
[alert beginSheetModalForWindow:parent
- completionHandler:^(NSModalResponse returnCode)
- { [NSApp tkAlertDidEnd:alert
- returnCode:returnCode
- contextInfo:callbackInfo ]; } ];
+ completionHandler:^(NSModalResponse returnCode) {
+ [NSApp tkAlertDidEnd:alert
+ returnCode:returnCode
+ contextInfo:callbackInfo];
+ }];
#else
[alert beginSheetModalForWindow:parent
modalDelegate:NSApp
@@ -1439,7 +1552,7 @@ Tk_MessageBoxObjCmd(
contextInfo:callbackInfo];
#endif
modalReturnCode = cmdObj ? 0 :
- [NSApp runModalForWindow:[alert window]];
+ [alert runModal];
} else {
modalReturnCode = [alert runModal];
[NSApp tkAlertDidEnd:alert returnCode:modalReturnCode
@@ -1462,7 +1575,7 @@ Tk_MessageBoxObjCmd(
*----------------------------------------------------------------------
*/
-#include "tkMacOSXEvent.h"
+#include "tkMacOSXInt.h"
#include "tkMacOSXFont.h"
typedef struct FontchooserData {
@@ -1471,7 +1584,10 @@ typedef struct FontchooserData {
Tk_Window parent;
} FontchooserData;
-enum FontchooserEvent { FontchooserClosed, FontchooserSelection };
+enum FontchooserEvent {
+ FontchooserClosed,
+ FontchooserSelection
+};
static void FontchooserEvent(int kind);
static Tcl_Obj * FontchooserCget(FontchooserData *fcdPtr,
@@ -1516,6 +1632,7 @@ enum FontchooserOption {
- (void) changeFont: (id) sender
{
NSFontManager *fm = [NSFontManager sharedFontManager];
+ (void)sender;
if ([fm currentFontAction] == NSViaPanelFontAction) {
NSFont *font = [fm convertFont:fontPanelFont];
@@ -1541,6 +1658,8 @@ enum FontchooserOption {
- (NSUInteger) validModesForFontPanel: (NSFontPanel *) fontPanel
{
+ (void)fontPanel;
+
return (NSFontPanelStandardModesMask & ~NSFontPanelAllEffectsModeMask) |
NSFontPanelUnderlineEffectModeMask |
NSFontPanelStrikethroughEffectModeMask;
@@ -1563,8 +1682,8 @@ enum FontchooserOption {
*
* FontchooserEvent --
*
- * This processes events generated by user interaction with the
- * font panel.
+ * This processes events generated by user interaction with the font
+ * panel.
*
* Results:
* None.
@@ -1604,7 +1723,7 @@ FontchooserEvent(
result = Tcl_ListObjGetElements(fontchooserInterp,
fcdPtr->cmdObj, &objc, &objv);
if (result == TCL_OK) {
- tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
+ tmpv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc);
tmpv[objc] = fontObj;
TkBackgroundEvalObjv(fontchooserInterp, objc + 1, tmpv,
@@ -1623,9 +1742,8 @@ FontchooserEvent(
*
* FontchooserCget --
*
- * Helper for the FontchooserConfigure command to return the
- * current value of any of the options (which may be NULL in
- * the structure)
+ * Helper for the FontchooserConfigure command to return the current value
+ * of any of the options (which may be NULL in the structure).
*
* Results:
* Tcl object of option value.
@@ -1674,8 +1792,8 @@ FontchooserCget(
}
break;
case FontchooserVisible:
- resObj = Tcl_NewBooleanObj([[[NSFontManager sharedFontManager]
- fontPanel:NO] isVisible]);
+ resObj = Tcl_NewWideIntObj([[[NSFontManager sharedFontManager]
+ fontPanel:NO] isVisible] != 0);
break;
default:
resObj = Tcl_NewObj();
@@ -1688,8 +1806,8 @@ FontchooserCget(
*
* FontchooserConfigureCmd --
*
- * Implementation of the 'tk fontchooser configure' ensemble command.
- * See the user documentation for what it does.
+ * Implementation of the 'tk fontchooser configure' ensemble command. See
+ * the user documentation for what it does.
*
* Results:
* See the user documentation.
@@ -1822,7 +1940,8 @@ FontchooserConfigureCmd(
[fm setSelectedAttributes:fontPanelFontAttributes
isMultiple:NO];
if ([fp isVisible]) {
- TkSendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged", NULL);
+ TkSendVirtualEvent(fcdPtr->parent,
+ "TkFontchooserFontChanged", NULL);
}
break;
case FontchooserCmd:
@@ -1850,9 +1969,9 @@ FontchooserConfigureCmd(
*
* FontchooserShowCmd --
*
- * Implements the 'tk fontchooser show' ensemble command. The
- * per-interp configuration data for the dialog is held in an interp
- * associated structure.
+ * Implements the 'tk fontchooser show' ensemble command. The per-interp
+ * configuration data for the dialog is held in an interp associated
+ * structure.
*
* Results:
* See the user documentation.
@@ -1872,14 +1991,18 @@ FontchooserShowCmd(
{
FontchooserData *fcdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser",
NULL);
+ (void)objc;
+ (void)objv;
if (fcdPtr->parent == None) {
fcdPtr->parent = (Tk_Window) clientData;
Tk_CreateEventHandler(fcdPtr->parent, StructureNotifyMask,
FontchooserParentEventHandler, fcdPtr);
}
+
NSFontManager *fm = [NSFontManager sharedFontManager];
NSFontPanel *fp = [fm fontPanel:YES];
+
if ([fp delegate] != NSApp) {
[fp setDelegate:NSApp];
}
@@ -1897,8 +2020,8 @@ FontchooserShowCmd(
*
* FontchooserHideCmd --
*
- * Implementation of the 'tk fontchooser hide' ensemble. See the
- * user documentation for details.
+ * Implementation of the 'tk fontchooser hide' ensemble. See the user
+ * documentation for details.
*
* Results:
* See the user documentation.
@@ -1911,12 +2034,17 @@ FontchooserShowCmd(
static int
FontchooserHideCmd(
- ClientData clientData, /* Main window */
+ ClientData dummy, /* Main window */
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
NSFontPanel *fp = [[NSFontManager sharedFontManager] fontPanel:NO];
+ (void)dummy;
+ (void)interp;
+ (void)objc;
+ (void)objv;
+
if ([fp isVisible]) {
[fp orderOut:NSApp];
}
@@ -1950,7 +2078,7 @@ FontchooserParentEventHandler(
if (eventPtr->type == DestroyNotify) {
Tk_DeleteEventHandler(fcdPtr->parent, StructureNotifyMask,
FontchooserParentEventHandler, fcdPtr);
- fcdPtr->parent = None;
+ fcdPtr->parent = NULL;
FontchooserHideCmd(NULL, NULL, 0, NULL);
}
}
@@ -1997,8 +2125,8 @@ DeleteFontchooserData(
*
* TkInitFontchooser --
*
- * Associate the font chooser configuration data with the Tcl
- * interpreter. There is one font chooser per interp.
+ * Associate the font chooser configuration data with the Tcl interpreter.
+ * There is one font chooser per interp.
*
* Results:
* None.
@@ -2012,9 +2140,10 @@ DeleteFontchooserData(
MODULE_SCOPE int
TkInitFontchooser(
Tcl_Interp *interp,
- ClientData clientData)
+ ClientData dummy)
{
- FontchooserData *fcdPtr = ckalloc(sizeof(FontchooserData));
+ FontchooserData *fcdPtr = (FontchooserData *)ckalloc(sizeof(FontchooserData));
+ (void)dummy;
bzero(fcdPtr, sizeof(FontchooserData));
Tcl_SetAssocData(interp, "::tk::fontchooser", DeleteFontchooserData,
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index faad137..66027cd 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -1,9 +1,8 @@
/*
* tkMacOSXDraw.c --
*
- * This file contains functions that perform drawing to
- * Xlib windows. Most of the functions simple emulate
- * Xlib functions.
+ * This file contains functions that perform drawing to Xlib windows. Most
+ * of the functions simply emulate Xlib functions.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
@@ -31,7 +30,7 @@
#endif
*/
-#define radians(d) ((d) * (M_PI/180.0))
+#define radians(d) ((d) * (M_PI/180.0))
/*
* Non-antialiased CG drawing looks better and more like X11 drawing when using
@@ -40,7 +39,7 @@
#define NON_AA_CG_OFFSET .999
static int cgAntiAliasLimit = 0;
-#define notAA(w) ((w) < cgAntiAliasLimit)
+#define notAA(w) ((w) < cgAntiAliasLimit)
static int useThemedToplevel = 0;
static int useThemedFrame = 0;
@@ -74,6 +73,7 @@ TkMacOSXInitCGDrawing(
int limit)
{
static Boolean initialized = FALSE;
+ (void)enable;
if (!initialized) {
initialized = TRUE;
@@ -119,24 +119,24 @@ TkMacOSXInitCGDrawing(
* replacement is [NSView cacheDisplayInRect: toBitmapImageRep:] and that
* is what is being used here. However, that method only works when the
* view has a valid CGContext, and a view is only guaranteed to have a
- * valid context during a call to [NSView drawRect]. To further
- * complicate matters, cacheDisplayInRect calls [NSView drawRect].
- * Essentially it is asking the view to draw a subrectangle of itself into
- * a special graphics context which is linked to the BitmapImageRep. But
- * our implementation of [NSView drawRect] does not allow recursive calls.
- * If called recursively it returns immediately without doing any drawing.
+ * valid context during a call to [NSView drawRect]. To further complicate
+ * matters, cacheDisplayInRect calls [NSView drawRect]. Essentially it is
+ * asking the view to draw a subrectangle of itself into a special
+ * graphics context which is linked to the BitmapImageRep. But our
+ * implementation of [NSView drawRect] does not allow recursive calls. If
+ * called recursively it returns immediately without doing any drawing.
* So the bottom line is that this function either returns a NULL pointer
- * or a black image. To make it useful would require a significant amount
- * of rewriting of the drawRect method. Perhaps the next release of OSX
+ * or a black image. To make it useful would require a significant amount
+ * of rewriting of the drawRect method. Perhaps the next release of OSX
* will include some more helpful ways of doing this.
*
* Results:
- * Returns an NSBitmapRep representing the image of the given
- * rectangle of the given drawable. This object is retained.
- * The caller is responsible for releasing it.
+ * Returns an NSBitmapRep representing the image of the given rectangle of
+ * the given drawable. This object is retained. The caller is responsible
+ * for releasing it.
*
- * NOTE: The x,y coordinates should be relative to a coordinate system with
- * origin at the top left, as used by XImage and CGImage, not bottom
+ * NOTE: The x,y coordinates should be relative to a coordinate system
+ * with origin at the top left, as used by XImage and CGImage, not bottom
* left as used by NSView.
*
* Side effects:
@@ -144,46 +144,46 @@ TkMacOSXInitCGDrawing(
*
*----------------------------------------------------------------------
*/
-NSBitmapImageRep*
+
+NSBitmapImageRep *
TkMacOSXBitmapRepFromDrawableRect(
- Drawable drawable,
- int x,
- int y,
- unsigned int width,
- unsigned int height)
+ Drawable drawable,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height)
{
MacDrawable *mac_drawable = (MacDrawable *) drawable;
CGContextRef cg_context = NULL;
- CGImageRef cg_image=NULL, sub_cg_image = NULL;
+ CGImageRef cg_image = NULL, sub_cg_image = NULL;
NSBitmapImageRep *bitmap_rep = NULL;
- NSView *view=NULL;
- if ( mac_drawable->flags & TK_IS_PIXMAP ) {
-
+ NSView *view = NULL;
+ if (mac_drawable->flags & TK_IS_PIXMAP) {
/*
* This MacDrawable is a bitmap, so its view is NULL.
*/
- cg_context = TkMacOSXGetCGContextForDrawable(drawable);
CGRect image_rect = CGRectMake(x, y, width, height);
- cg_image = CGBitmapContextCreateImage( (CGContextRef) cg_context);
+
+ cg_context = TkMacOSXGetCGContextForDrawable(drawable);
+ cg_image = CGBitmapContextCreateImage((CGContextRef) cg_context);
sub_cg_image = CGImageCreateWithImageInRect(cg_image, image_rect);
- if ( sub_cg_image ) {
+ if (sub_cg_image) {
bitmap_rep = [NSBitmapImageRep alloc];
[bitmap_rep initWithCGImage:sub_cg_image];
}
- if ( cg_image ) {
+ if (cg_image) {
CGImageRelease(cg_image);
}
- } else if ( (view = TkMacOSXDrawableView(mac_drawable)) ) {
-
+ } else if ((view = TkMacOSXDrawableView(mac_drawable)) != NULL) {
/*
* Convert Tk top-left to NSView bottom-left coordinates.
*/
int view_height = [view bounds].size.height;
NSRect view_rect = NSMakeRect(x + mac_drawable->xOff,
- view_height - height - y - mac_drawable->yOff,
- width, height);
+ view_height - height - y - mac_drawable->yOff,
+ width, height);
/*
* Attempt to copy from the view to a bitmapImageRep. If the view does
@@ -218,21 +218,20 @@ TkMacOSXBitmapRepFromDrawableRect(
* None.
*
* Side effects:
- * Data is moved from a window or bitmap to a second window or
- * bitmap.
+ * Data is moved from a window or bitmap to a second window or bitmap.
*
*----------------------------------------------------------------------
*/
-void
+int
XCopyArea(
Display *display, /* Display. */
Drawable src, /* Source drawable. */
Drawable dst, /* Destination drawable. */
- GC gc, /* GC to use. */
+ GC gc, /* GC to use. */
int src_x, /* X & Y, width & height */
int src_y, /* define the source rectangle */
- unsigned int width, /* that will be copied. */
+ unsigned int width, /* that will be copied. */
unsigned int height,
int dest_x, /* Dest X & Y on dest rect. */
int dest_y)
@@ -245,44 +244,44 @@ XCopyArea(
display->request++;
if (!width || !height) {
- return;
+ return BadDrawable;
}
if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) {
- return;
TkMacOSXDbgMsg("Failed to setup drawing context.");
+ return BadDrawable;
}
- if ( dc.context ) {
- if (srcDraw->flags & TK_IS_PIXMAP) {
- img = TkMacOSXCreateCGImageWithDrawable(src);
- }else if (TkMacOSXDrawableWindow(src)) {
- bitmap_rep = TkMacOSXBitmapRepFromDrawableRect(src,
- src_x, src_y, width, height);
- if ( bitmap_rep ) {
- img = [bitmap_rep CGImage];
- }
- } else {
- TkMacOSXDbgMsg("Invalid source drawable - neither window nor pixmap.");
- }
+ if (!dc.context) {
+ TkMacOSXDbgMsg("Invalid destination drawable - no context.");
+ return BadDrawable;
+ }
- if (img) {
- bounds = CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height);
- srcRect = CGRectMake(src_x, src_y, width, height);
- dstRect = CGRectMake(dest_x, dest_y, width, height);
- TkMacOSXDrawCGImage(dst, gc, dc.context, img,
- gc->foreground, gc->background, bounds, srcRect, dstRect);
- CFRelease(img);
- } else {
- TkMacOSXDbgMsg("Failed to construct CGImage.");
+ if (srcDraw->flags & TK_IS_PIXMAP) {
+ img = TkMacOSXCreateCGImageWithDrawable(src);
+ } else if (TkMacOSXDrawableWindow(src)) {
+ bitmap_rep = TkMacOSXBitmapRepFromDrawableRect(src,
+ src_x, src_y, width, height);
+ if (bitmap_rep) {
+ img = [bitmap_rep CGImage];
}
+ } else {
+ TkMacOSXDbgMsg("Invalid source drawable - neither window nor pixmap.");
+ }
+ if (img) {
+ bounds = CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height);
+ srcRect = CGRectMake(src_x, src_y, width, height);
+ dstRect = CGRectMake(dest_x, dest_y, width, height);
+ TkMacOSXDrawCGImage(dst, gc, dc.context, img,
+ gc->foreground, gc->background, bounds, srcRect, dstRect);
+ CFRelease(img);
} else {
- TkMacOSXDbgMsg("Invalid destination drawable - no context.");
- return;
+ TkMacOSXDbgMsg("Failed to construct CGImage.");
}
TkMacOSXRestoreDrawingContext(&dc);
+ return Success;
}
/*
@@ -290,10 +289,9 @@ XCopyArea(
*
* XCopyPlane --
*
- * Copies a bitmap from a source drawable to a destination
- * drawable. The plane argument specifies which bit plane of
- * the source contains the bitmap. Note that this implementation
- * ignores the gc->function.
+ * Copies a bitmap from a source drawable to a destination drawable. The
+ * plane argument specifies which bit plane of the source contains the
+ * bitmap. Note that this implementation ignores the gc->function.
*
* Results:
* None.
@@ -304,7 +302,7 @@ XCopyArea(
*----------------------------------------------------------------------
*/
-void
+int
XCopyPlane(
Display *display, /* Display. */
Drawable src, /* Source drawable. */
@@ -325,38 +323,59 @@ XCopyPlane(
display->request++;
if (!width || !height) {
/* TkMacOSXDbgMsg("Drawing of empty area requested"); */
- return;
+ return BadDrawable;
}
if (plane != 1) {
Tcl_Panic("Unexpected plane specified for XCopyPlane");
}
if (srcDraw->flags & TK_IS_PIXMAP) {
if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) {
- return;
+ return BadDrawable;
}
+
CGContextRef context = dc.context;
+
if (context) {
CGImageRef img = TkMacOSXCreateCGImageWithDrawable(src);
+
if (img) {
TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask;
unsigned long imageBackground = gc->background;
- if (clipPtr && clipPtr->type == TKP_CLIP_PIXMAP){
+
+ if (clipPtr && clipPtr->type == TKP_CLIP_PIXMAP) {
srcRect = CGRectMake(src_x, src_y, width, height);
- CGImageRef mask = TkMacOSXCreateCGImageWithDrawable(clipPtr->value.pixmap);
- CGImageRef submask = CGImageCreateWithImageInRect(img, srcRect);
+ CGImageRef mask = TkMacOSXCreateCGImageWithDrawable(
+ clipPtr->value.pixmap);
+ CGImageRef submask = CGImageCreateWithImageInRect(
+ img, srcRect);
CGRect rect = CGRectMake(dest_x, dest_y, width, height);
+
rect = CGRectOffset(rect, dstDraw->xOff, dstDraw->yOff);
CGContextSaveGState(context);
- /* Move the origin of the destination to top left. */
- CGContextTranslateCTM(context, 0, rect.origin.y + CGRectGetMaxY(rect));
+
+ /*
+ * Move the origin of the destination to top left.
+ */
+
+ CGContextTranslateCTM(context,
+ 0, rect.origin.y + CGRectGetMaxY(rect));
CGContextScaleCTM(context, 1, -1);
- /* Fill with the background color, clipping to the mask. */
+
+ /*
+ * Fill with the background color, clipping to the mask.
+ */
+
CGContextClipToMask(context, rect, submask);
TkMacOSXSetColorInContext(gc, gc->background, dc.context);
CGContextFillRect(context, rect);
- /* Fill with the foreground color, clipping to the
- intersection of img and mask. */
- CGImageRef subimage = CGImageCreateWithImageInRect(img, srcRect);
+
+ /*
+ * Fill with the foreground color, clipping to the
+ * intersection of img and mask.
+ */
+
+ CGImageRef subimage = CGImageCreateWithImageInRect(
+ img, srcRect);
CGContextClipToMask(context, rect, subimage);
TkMacOSXSetColorInContext(gc, gc->foreground, context);
CGContextFillRect(context, rect);
@@ -366,22 +385,32 @@ XCopyPlane(
CGImageRelease(submask);
CGImageRelease(subimage);
} else {
- bounds = CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height);
+ bounds = CGRectMake(0, 0,
+ srcDraw->size.width, srcDraw->size.height);
srcRect = CGRectMake(src_x, src_y, width, height);
dstRect = CGRectMake(dest_x, dest_y, width, height);
- TkMacOSXDrawCGImage(dst, gc, dc.context, img, gc->foreground,
- imageBackground, bounds, srcRect, dstRect);
+ TkMacOSXDrawCGImage(dst, gc, dc.context, img,
+ gc->foreground, imageBackground, bounds,
+ srcRect, dstRect);
CGImageRelease(img);
}
- } else { /* no image */
+ } else {
+ /* no image */
TkMacOSXDbgMsg("Invalid source drawable");
}
} else {
- TkMacOSXDbgMsg("Invalid destination drawable - could not get a bitmap context.");
+ TkMacOSXDbgMsg("Invalid destination drawable - "
+ "could not get a bitmap context.");
}
TkMacOSXRestoreDrawingContext(&dc);
- } else { /* source drawable is a window, not a Pixmap */
- XCopyArea(display, src, dst, gc, src_x, src_y, width, height, dest_x, dest_y);
+ return Success;
+ } else {
+ /*
+ * Source drawable is a Window, not a Pixmap.
+ */
+
+ return XCopyArea(display, src, dst, gc, src_x, src_y, width, height,
+ dest_x, dest_y);
}
}
@@ -430,7 +459,7 @@ TkMacOSXCreateCGImageWithDrawable(
*----------------------------------------------------------------------
*/
-static NSImage*
+static NSImage *
CreateNSImageWithPixmap(
Pixmap pixmap,
int width,
@@ -466,16 +495,19 @@ CreateNSImageWithPixmap(
*----------------------------------------------------------------------
*/
-NSImage*
+NSImage *
TkMacOSXGetNSImageWithTkImage(
Display *display,
Tk_Image image,
int width,
int height)
{
- Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0);
+ Pixmap pixmap;
NSImage *nsImage;
-
+ if (width == 0 || height == 0) {
+ return nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0,0)];
+ }
+ pixmap = Tk_GetPixmap(display, None, width, height, 0);
Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0);
nsImage = CreateNSImageWithPixmap(pixmap, width, height);
Tk_FreePixmap(display, pixmap);
@@ -499,7 +531,7 @@ TkMacOSXGetNSImageWithTkImage(
*----------------------------------------------------------------------
*/
-NSImage*
+NSImage *
TkMacOSXGetNSImageWithBitmap(
Display *display,
Pixmap bitmap,
@@ -550,25 +582,26 @@ TkMacOSXGetCGContextForDrawable(
CGColorSpaceRef colorspace = NULL;
CGBitmapInfo bitmapInfo =
#ifdef __LITTLE_ENDIAN__
- kCGBitmapByteOrder32Host;
+ kCGBitmapByteOrder32Host;
#else
- kCGBitmapByteOrderDefault;
+ kCGBitmapByteOrderDefault;
#endif
char *data;
- CGRect bounds = CGRectMake(0, 0, macDraw->size.width, macDraw->size.height);
+ CGRect bounds = CGRectMake(0, 0,
+ macDraw->size.width, macDraw->size.height);
if (macDraw->flags & TK_IS_BW_PIXMAP) {
bitsPerPixel = 8;
- bitmapInfo = (CGBitmapInfo)kCGImageAlphaOnly;
+ bitmapInfo = (CGBitmapInfo) kCGImageAlphaOnly;
} else {
colorspace = CGColorSpaceCreateDeviceRGB();
bitsPerPixel = 32;
bitmapInfo |= kCGImageAlphaPremultipliedFirst;
}
- bytesPerRow = ((size_t) macDraw->size.width * bitsPerPixel + 127) >> 3
- & ~15;
+ bytesPerRow = ((size_t)
+ macDraw->size.width * bitsPerPixel + 127) >> 3 & ~15;
len = macDraw->size.height * bytesPerRow;
- data = ckalloc(len);
+ data = (char *)ckalloc(len);
bzero(data, len);
macDraw->context = CGBitmapContextCreate(data, macDraw->size.width,
macDraw->size.height, bitsPerComponent, bytesPerRow,
@@ -630,8 +663,8 @@ TkMacOSXDrawCGImage(
dstBounds = CGRectOffset(dstBounds, macDraw->xOff, macDraw->yOff);
if (CGImageIsMask(image)) {
if (macDraw->flags & TK_IS_BW_PIXMAP) {
-
- /* Set fill color to black; background comes from the context,
+ /*
+ * Set fill color to black; background comes from the context,
* or is transparent.
*/
@@ -655,11 +688,13 @@ TkMacOSXDrawCGImage(
CGContextSetRGBFillColor(context, 0, 1, 0, 0.1);
CGContextFillRect(context, dstBounds);
CGContextStrokeRect(context, dstBounds);
+
CGPoint p[4] = {dstBounds.origin,
CGPointMake(CGRectGetMaxX(dstBounds), CGRectGetMaxY(dstBounds)),
CGPointMake(CGRectGetMinX(dstBounds), CGRectGetMaxY(dstBounds)),
CGPointMake(CGRectGetMaxX(dstBounds), CGRectGetMinY(dstBounds))
};
+
CGContextStrokeLineSegments(context, p, 4);
CGContextRestoreGState(context);
TkMacOSXDbgMsg("Drawing CGImage at (x=%f, y=%f), (w=%f, h=%f)",
@@ -736,12 +771,13 @@ XDrawLines(
CGContextAddLineToPoint(dc.context, prevx, prevy);
}
}
+
/*
- * In the case of closed polylines, the first and last points
- * are the same. We want miter or bevel join be rendered also
- * at this point, this needs telling CoreGraphics that the
- * path is closed.
+ * In the case of closed polylines, the first and last points are the
+ * same. We want miter or bevel join be rendered also at this point,
+ * this needs telling CoreGraphics that the path is closed.
*/
+
if ((points[0].x == points[npoints-1].x) &&
(points[0].y == points[npoints-1].y)) {
CGContextClosePath(dc.context);
@@ -818,12 +854,12 @@ XDrawSegments(
*----------------------------------------------------------------------
*/
-void
+int
XFillPolygon(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Drawable d, /* Draw on this. */
GC gc, /* Use this GC. */
- XPoint* points, /* Array of points. */
+ XPoint *points, /* Array of points. */
int npoints, /* Number of points. */
int shape, /* Shape to draw. */
int mode) /* Drawing mode. */
@@ -831,10 +867,11 @@ XFillPolygon(
MacDrawable *macWin = (MacDrawable *) d;
TkMacOSXDrawingContext dc;
int i;
+ (void)shape;
display->request++;
if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
- return;
+ return BadDrawable;
}
if (dc.context) {
double prevx, prevy;
@@ -858,6 +895,7 @@ XFillPolygon(
CGContextEOFillPath(dc.context);
}
TkMacOSXRestoreDrawingContext(&dc);
+ return Success;
}
/*
@@ -876,7 +914,7 @@ XFillPolygon(
*----------------------------------------------------------------------
*/
-void
+int
XDrawRectangle(
Display *display, /* Display. */
Drawable d, /* Draw on this. */
@@ -890,43 +928,40 @@ XDrawRectangle(
int lw = gc->line_width;
if (width == 0 || height == 0) {
- return;
+ return BadDrawable;
}
display->request++;
if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
- return;
+ return BadDrawable;
}
if (dc.context) {
CGRect rect;
double o = (lw % 2) ? .5 : 0;
rect = CGRectMake(
- macWin->xOff + x + o,
- macWin->yOff + y + o,
+ macWin->xOff + x + o, macWin->yOff + y + o,
width, height);
CGContextStrokeRect(dc.context, rect);
}
TkMacOSXRestoreDrawingContext(&dc);
+ return Success;
}
-#ifdef TK_MACOSXDRAW_UNUSED
/*
*----------------------------------------------------------------------
*
* XDrawRectangles --
*
- * Draws the outlines of the specified rectangles as if a
- * five-point PolyLine protocol request were specified for each
- * rectangle:
+ * Draws the outlines of the specified rectangles as if a five-point
+ * PolyLine protocol request were specified for each rectangle:
*
* [x,y] [x+width,y] [x+width,y+height] [x,y+height] [x,y]
*
- * For the specified rectangles, these functions do not draw a
- * pixel more than once. XDrawRectangles draws the rectangles in
- * the order listed in the array. If rectangles intersect, the
- * intersecting pixels are drawn multiple times. Draws a
- * rectangle.
+ * For the specified rectangles, these functions do not draw a pixel more
+ * than once. XDrawRectangles draws the rectangles in the order listed in
+ * the array. If rectangles intersect, the intersecting pixels are drawn
+ * multiple times. Draws a rectangle.
*
* Results:
* None.
@@ -937,7 +972,7 @@ XDrawRectangle(
*----------------------------------------------------------------------
*/
-void
+int
XDrawRectangles(
Display *display,
Drawable drawable,
@@ -951,8 +986,8 @@ XDrawRectangles(
int i, lw = gc->line_width;
display->request++;
- if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
- return;
+ if (!TkMacOSXSetupDrawingContext(drawable, gc, 1, &dc)) {
+ return BadDrawable;
}
if (dc.context) {
CGRect rect;
@@ -970,8 +1005,8 @@ XDrawRectangles(
}
}
TkMacOSXRestoreDrawingContext(&dc);
+ return Success;
}
-#endif
/*
*----------------------------------------------------------------------
@@ -991,7 +1026,7 @@ XDrawRectangles(
int
XFillRectangles(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Drawable d, /* Draw on this. */
GC gc, /* Use this GC. */
XRectangle *rectangles, /* Rectangle array. */
@@ -1027,6 +1062,54 @@ XFillRectangles(
/*
*----------------------------------------------------------------------
*
+ * TkMacOSXDrawSolidBorder --
+ *
+ * Draws a border rectangle of specified thickness inside the bounding
+ * rectangle of a Tk Window. The border rectangle can be inset within the
+ * bounding rectangle. For a highlight border the inset should be 0, but
+ * for a solid border around the actual window the inset should equal the
+ * thickness of the highlight border. The color of the border rectangle
+ * is the foreground color of the graphics context passed to the function.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Draws a rectangular border inside the bounding rectangle of a window.
+ *
+ *----------------------------------------------------------------------
+ */
+
+MODULE_SCOPE void
+TkMacOSXDrawSolidBorder(
+ Tk_Window tkwin,
+ GC gc,
+ int inset,
+ int thickness)
+{
+ Drawable d = Tk_WindowId(tkwin);
+ TkMacOSXDrawingContext dc;
+ CGRect outerRect, innerRect;
+
+ if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
+ return;
+ }
+ if (dc.context) {
+ outerRect = CGRectMake(Tk_X(tkwin), Tk_Y(tkwin),
+ Tk_Width(tkwin), Tk_Height(tkwin));
+ outerRect = CGRectInset(outerRect, inset, inset);
+ innerRect = CGRectInset(outerRect, thickness, thickness);
+ CGContextBeginPath(dc.context);
+ CGContextAddRect(dc.context, outerRect);
+ CGContextAddRect(dc.context, innerRect);
+ CGContextEOFillPath(dc.context);
+ }
+ TkMacOSXRestoreDrawingContext(&dc);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* XDrawArc --
*
* Draw an arc.
@@ -1040,9 +1123,9 @@ XFillRectangles(
*----------------------------------------------------------------------
*/
-void
+int
XDrawArc(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Drawable d, /* Draw on this. */
GC gc, /* Use this GC. */
int x, int y, /* Upper left of bounding rect. */
@@ -1056,12 +1139,12 @@ XDrawArc(
int lw = gc->line_width;
if (width == 0 || height == 0 || angle2 == 0) {
- return;
+ return BadDrawable;
}
display->request++;
if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
- return;
+ return BadDrawable;
}
if (dc.context) {
CGRect rect;
@@ -1091,22 +1174,21 @@ XDrawArc(
}
}
TkMacOSXRestoreDrawingContext(&dc);
+ return Success;
}
-#ifdef TK_MACOSXDRAW_UNUSED
/*
*----------------------------------------------------------------------
*
* XDrawArcs --
*
- * Draws multiple circular or elliptical arcs. Each arc is
- * specified by a rectangle and two angles. The center of the
- * circle or ellipse is the center of the rect- angle, and the
- * major and minor axes are specified by the width and height.
- * Positive angles indicate counterclock- wise motion, and
- * negative angles indicate clockwise motion. If the magnitude
- * of angle2 is greater than 360 degrees, XDrawArcs truncates it
- * to 360 degrees.
+ * Draws multiple circular or elliptical arcs. Each arc is specified by a
+ * rectangle and two angles. The center of the circle or ellipse is the
+ * center of the rect- angle, and the major and minor axes are specified
+ * by the width and height. Positive angles indicate counterclock- wise
+ * motion, and negative angles indicate clockwise motion. If the magnitude
+ * of angle2 is greater than 360 degrees, XDrawArcs truncates it to 360
+ * degrees.
*
* Results:
* None.
@@ -1117,7 +1199,7 @@ XDrawArc(
*----------------------------------------------------------------------
*/
-void
+int
XDrawArcs(
Display *display,
Drawable d,
@@ -1125,7 +1207,6 @@ XDrawArcs(
XArc *arcArr,
int nArcs)
{
-
MacDrawable *macWin = (MacDrawable *) d;
TkMacOSXDrawingContext dc;
XArc *arcPtr;
@@ -1133,7 +1214,7 @@ XDrawArcs(
display->request++;
if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
- return;
+ return BadDrawable;
}
if (dc.context) {
CGRect rect;
@@ -1174,8 +1255,8 @@ XDrawArcs(
}
}
TkMacOSXRestoreDrawingContext(&dc);
+ return Success;
}
-#endif
/*
*----------------------------------------------------------------------
@@ -1193,9 +1274,9 @@ XDrawArcs(
*----------------------------------------------------------------------
*/
-void
+int
XFillArc(
- Display* display, /* Display. */
+ Display *display, /* Display. */
Drawable d, /* Draw on this. */
GC gc, /* Use this GC. */
int x, int y, /* Upper left of bounding rect. */
@@ -1209,12 +1290,12 @@ XFillArc(
int lw = gc->line_width;
if (width == 0 || height == 0 || angle2 == 0) {
- return;
+ return BadDrawable;
}
display->request++;
if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
- return;
+ return BadDrawable;
}
if (dc.context) {
CGRect rect;
@@ -1253,9 +1334,9 @@ XFillArc(
}
}
TkMacOSXRestoreDrawingContext(&dc);
+ return Success;
}
-#ifdef TK_MACOSXDRAW_UNUSED
/*
*----------------------------------------------------------------------
*
@@ -1272,7 +1353,7 @@ XFillArc(
*----------------------------------------------------------------------
*/
-void
+int
XFillArcs(
Display *display,
Drawable d,
@@ -1287,7 +1368,7 @@ XFillArcs(
display->request++;
if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) {
- return;
+ return BadDrawable;
}
if (dc.context) {
CGRect rect;
@@ -1335,38 +1416,20 @@ XFillArcs(
}
}
TkMacOSXRestoreDrawingContext(&dc);
+ return Success;
}
-#endif
-
-#ifdef TK_MACOSXDRAW_UNUSED
-/*
- *----------------------------------------------------------------------
- *
- * XMaxRequestSize --
- *
- *----------------------------------------------------------------------
- */
-
-long
-XMaxRequestSize(
- Display *display)
-{
- return (SHRT_MAX / 4);
-}
-#endif
/*
*----------------------------------------------------------------------
*
* TkScrollWindow --
*
- * Scroll a rectangle of the specified window and accumulate
- * a damage region.
+ * Scroll a rectangle of the specified window and accumulate a damage
+ * region.
*
* Results:
- * Returns 0 if the scroll generated no additional damage.
- * Otherwise, sets the region that needs to be repainted after
- * scrolling and returns 1.
+ * Returns 0 if the scroll generated no additional damage. Otherwise, sets
+ * the region that needs to be repainted after scrolling and returns 1.
*
* Side effects:
* Scrolls the bits in the window.
@@ -1381,51 +1444,68 @@ TkScrollWindow(
int x, int y, /* Position rectangle to be scrolled. */
int width, int height,
int dx, int dy, /* Distance rectangle should be moved. */
- TkRegion damageRgn) /* Region to accumulate damage in. */
+ Region damageRgn) /* Region to accumulate damage in. */
{
Drawable drawable = Tk_WindowId(tkwin);
MacDrawable *macDraw = (MacDrawable *) drawable;
- TKContentView *view = (TKContentView *)TkMacOSXDrawableView(macDraw);
+ TKContentView *view = (TKContentView *) TkMacOSXDrawableView(macDraw);
CGRect srcRect, dstRect;
HIShapeRef dmgRgn = NULL, extraRgn = NULL;
NSRect bounds, visRect, scrollSrc, scrollDst;
int result = 0;
+ (void)gc;
+
+ if (view) {
+ /*
+ * Get the scroll area in NSView coordinates (origin at bottom left).
+ */
- if ( view ) {
- /* Get the scroll area in NSView coordinates (origin at bottom left). */
bounds = [view bounds];
scrollSrc = NSMakeRect(macDraw->xOff + x,
- bounds.size.height - height - (macDraw->yOff + y),
- width, height);
+ bounds.size.height - height - (macDraw->yOff + y),
+ width, height);
scrollDst = NSOffsetRect(scrollSrc, dx, -dy);
- /* Limit scrolling to the window content area. */
+ /*
+ * Limit scrolling to the window content area.
+ */
+
visRect = [view visibleRect];
scrollSrc = NSIntersectionRect(scrollSrc, visRect);
scrollDst = NSIntersectionRect(scrollDst, visRect);
- if ( !NSIsEmptyRect(scrollSrc) && !NSIsEmptyRect(scrollDst) ) {
+ if (!NSIsEmptyRect(scrollSrc) && !NSIsEmptyRect(scrollDst)) {
/*
* Mark the difference between source and destination as damaged.
- * This region is described in NSView coordinates (y=0 at the bottom)
- * and converted to Tk coordinates later.
+ * This region is described in NSView coordinates (y=0 at the
+ * bottom) and converted to Tk coordinates later.
*/
srcRect = CGRectMake(x, y, width, height);
dstRect = CGRectOffset(srcRect, dx, dy);
- /* Compute the damage. */
+ /*
+ * Compute the damage.
+ */
+
dmgRgn = HIShapeCreateMutableWithRect(&srcRect);
extraRgn = HIShapeCreateWithRect(&dstRect);
- ChkErr(HIShapeDifference, dmgRgn, extraRgn, (HIMutableShapeRef) dmgRgn);
+ ChkErr(HIShapeDifference, dmgRgn, extraRgn,
+ (HIMutableShapeRef) dmgRgn);
result = HIShapeIsEmpty(dmgRgn) ? 0 : 1;
- /* Convert to Tk coordinates, offset by the window origin. */
+ /*
+ * Convert to Tk coordinates, offset by the window origin.
+ */
+
TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn);
if (extraRgn) {
CFRelease(extraRgn);
}
- /* Scroll the rectangle. */
+ /*
+ * Scroll the rectangle.
+ */
+
[view scrollRect:scrollSrc by:NSMakeSize(dx, -dy)];
}
} else {
@@ -1460,6 +1540,9 @@ TkMacOSXSetUpGraphicsPort(
GC gc, /* GC to apply to current port. */
void *destPort)
{
+ (void)gc;
+ (void)destPort;
+
Tcl_Panic("TkMacOSXSetUpGraphicsPort: Obsolete, no more QD!");
}
@@ -1472,8 +1555,8 @@ TkMacOSXSetUpGraphicsPort(
* Set up a drawing context for the given drawable and GC.
*
* Results:
- * Boolean indicating whether it is ok to draw; if false, drawing
- * context was not setup, so do not attempt to draw and do not call
+ * Boolean indicating whether it is ok to draw; if false, drawing context
+ * was not setup, so do not attempt to draw and do not call
* TkMacOSXRestoreDrawingContext().
*
* Side effects:
@@ -1486,18 +1569,19 @@ Bool
TkMacOSXSetupDrawingContext(
Drawable d,
GC gc,
- int useCG, /* advisory only ! */
+ int useCG, /* advisory only ! */
TkMacOSXDrawingContext *dcPtr)
{
- MacDrawable *macDraw = ((MacDrawable*)d);
+ MacDrawable *macDraw = (MacDrawable *) d;
Bool canDraw = true;
NSWindow *win = NULL;
TkMacOSXDrawingContext dc = {};
CGRect clipBounds;
+ (void)useCG;
/*
- * If the drawable is not a pixmap and it has an associated
- * NSWindow then we know we are drawing to a window.
+ * If the drawable is not a pixmap and it has an associated NSWindow then
+ * we know we are drawing to a window.
*/
if (!(macDraw->flags & TK_IS_PIXMAP)) {
@@ -1516,9 +1600,8 @@ TkMacOSXSetupDrawingContext(
}
/*
- * If we already have a CGContext, use it. Otherwise, if we
- * are drawing to a window then we can get one from the
- * window.
+ * If we already have a CGContext, use it. Otherwise, if we are drawing to
+ * a window then we can get one from the window.
*/
dc.context = TkMacOSXGetCGContextForDrawable(d);
@@ -1526,35 +1609,54 @@ TkMacOSXSetupDrawingContext(
dc.portBounds = clipBounds = CGContextGetClipBoundingBox(dc.context);
} else if (win) {
NSView *view = TkMacOSXDrawableView(macDraw);
- if (view) {
-
- /*
- * We can only draw into the view when the current CGContext is
- * valid and belongs to the view. Validity can only be guaranteed
- * inside of a view's drawRect or setFrame methods. The isDrawing
- * attribute tells us whether we are being called from one of those
- * methods.
- *
- * If the CGContext is not valid, or belongs to a different View,
- * then we mark our view as needing display and return failure.
- * It should get drawn in a later call to drawRect.
- */
- if (view != [NSView focusView]) {
- [view setNeedsDisplay:YES];
- canDraw = false;
- goto end;
- }
- dc.view = view;
- dc.context = GET_CGCONTEXT;
- dc.portBounds = NSRectToCGRect([view bounds]);
- if (dc.clipRgn) {
- clipBounds = CGContextGetClipBoundingBox(dc.context);
- }
- } else {
+ if (!view) {
Tcl_Panic("TkMacOSXSetupDrawingContext(): "
"no NSView to draw into !");
}
+
+ /*
+ * We can only draw into the view when the current CGContext is valid
+ * and belongs to the view. Validity can only be guaranteed inside of
+ * a view's drawRect or setFrame methods. The isDrawing attribute
+ * tells us whether we are being called from one of those methods.
+ *
+ * If the CGContext is not valid then we mark our view as needing
+ * display in the bounding rectangle of the clipping region and
+ * return failure. That rectangle should get drawn in a later call
+ * to drawRect.
+ *
+ * As an exception to the above, if mouse buttons are pressed at the
+ * moment when we fail to obtain a valid context we schedule the entire
+ * view for a redraw rather than just the clipping region. The purpose
+ * of this is to make sure that scrollbars get updated correctly.
+ */
+
+ if (![NSApp isDrawing] || view != [NSView focusView]) {
+ NSRect bounds = [view bounds];
+ NSRect dirtyNS = bounds;
+ if ([NSEvent pressedMouseButtons]) {
+ [view setNeedsDisplay:YES];
+ } else {
+ CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0,
+ .ty = dirtyNS.size.height};
+ if (dc.clipRgn) {
+ CGRect dirtyCG = NSRectToCGRect(dirtyNS);
+ HIShapeGetBounds(dc.clipRgn, &dirtyCG);
+ dirtyNS = NSRectToCGRect(CGRectApplyAffineTransform(dirtyCG, t));
+ }
+ [view setNeedsDisplayInRect:dirtyNS];
+ }
+ canDraw = false;
+ goto end;
+ }
+
+ dc.view = view;
+ dc.context = GET_CGCONTEXT;
+ dc.portBounds = NSRectToCGRect([view bounds]);
+ if (dc.clipRgn) {
+ clipBounds = CGContextGetClipBoundingBox(dc.context);
+ }
} else {
Tcl_Panic("TkMacOSXSetupDrawingContext(): "
"no context to draw into !");
@@ -1565,8 +1667,13 @@ TkMacOSXSetupDrawingContext(
*/
if (dc.context) {
- CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0,
- .ty = dc.portBounds.size.height};
+ CGAffineTransform t = {
+ .a = 1, .b = 0,
+ .c = 0, .d = -1,
+ .tx = 0,
+ .ty = dc.portBounds.size.height
+ };
+
dc.portBounds.origin.x += macDraw->xOff;
dc.portBounds.origin.y += macDraw->yOff;
CGContextSaveGState(dc.context);
@@ -1581,6 +1688,7 @@ TkMacOSXSetupDrawingContext(
CGContextRestoreGState(dc.context);
#endif /* TK_MAC_DEBUG_DRAWING */
CGRect r;
+
if (!HIShapeIsRectangular(dc.clipRgn) || !CGRectContainsRect(
*HIShapeGetBounds(dc.clipRgn, &r),
CGRectApplyAffineTransform(clipBounds, t))) {
@@ -1608,21 +1716,28 @@ TkMacOSXSetupDrawingContext(
CGContextSetPatternPhase(dc.context, CGSizeMake(
dc.portBounds.size.width, dc.portBounds.size.height));
}
- if(gc->function != GXcopy) {
+ if (gc->function != GXcopy) {
TkMacOSXDbgMsg("Logical functions other than GXcopy are "
"not supported for CG drawing!");
}
- /* When should we antialias? */
+
+ /*
+ * When should we antialias?
+ */
+
shouldAntialias = !notAA(gc->line_width);
if (!shouldAntialias) {
- /* Make non-antialiased CG drawing look more like X11 */
+ /*
+ * Make non-antialiased CG drawing look more like X11.
+ */
+
w -= (gc->line_width ? NON_AA_CG_OFFSET : 0);
}
CGContextSetShouldAntialias(dc.context, shouldAntialias);
CGContextSetLineWidth(dc.context, w);
if (gc->line_style != LineSolid) {
int num = 0;
- char *p = &(gc->dashes);
+ char *p = &gc->dashes;
CGFloat dashOffset = gc->dash_offset;
CGFloat lengths[10];
@@ -1632,13 +1747,13 @@ TkMacOSXSetupDrawingContext(
}
CGContextSetLineDash(dc.context, dashOffset, lengths, num);
}
- if ((unsigned)gc->cap_style < sizeof(cgCap)/sizeof(CGLineCap)) {
+ if ((unsigned) gc->cap_style < sizeof(cgCap)/sizeof(CGLineCap)) {
CGContextSetLineCap(dc.context,
- cgCap[(unsigned)gc->cap_style]);
+ cgCap[(unsigned) gc->cap_style]);
}
if ((unsigned)gc->join_style < sizeof(cgJoin)/sizeof(CGLineJoin)) {
CGContextSetLineJoin(dc.context,
- cgJoin[(unsigned)gc->join_style]);
+ cgJoin[(unsigned) gc->join_style]);
}
}
}
@@ -1647,8 +1762,11 @@ end:
#ifdef TK_MAC_DEBUG_DRAWING
if (!canDraw && win != NULL) {
TkWindow *winPtr = TkMacOSXGetTkWindow(win);
- if (winPtr) fprintf(stderr, "Cannot draw in %s - postponing.\n",
- Tk_PathName(winPtr));
+
+ if (winPtr) {
+ fprintf(stderr, "Cannot draw in %s - postponing.\n",
+ Tk_PathName(winPtr));
+ }
}
#endif
if (!canDraw && dc.clipRgn) {
@@ -1719,7 +1837,10 @@ TkMacOSXGetClipRgn(
TkMacOSXUpdateClipRgn(macDraw->winPtr);
#ifdef TK_MAC_DEBUG_DRAWING
TkMacOSXDbgMsg("%s", macDraw->winPtr->pathName);
+
NSView *view = TkMacOSXDrawableView(macDraw);
+ CGContextRef context = GET_CGCONTEXT;
+
CGContextSaveGState(context);
CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0,
-1.0, 0.0, [view bounds].size.height));
@@ -1743,8 +1864,8 @@ TkMacOSXGetClipRgn(
*
* TkMacOSXSetUpClippingRgn --
*
- * Set up the clipping region so that drawing only occurs on the
- * specified X subwindow.
+ * Set up the clipping region so that drawing only occurs on the specified
+ * X subwindow.
*
* Results:
* None.
@@ -1759,6 +1880,7 @@ void
TkMacOSXSetUpClippingRgn(
Drawable drawable) /* Drawable to update. */
{
+ (void)drawable;
}
/*
@@ -1766,8 +1888,8 @@ TkMacOSXSetUpClippingRgn(
*
* TkpClipDrawableToRect --
*
- * Clip all drawing into the drawable d to the given rectangle.
- * If width or height are negative, reset to no clipping.
+ * Clip all drawing into the drawable d to the given rectangle. If width
+ * or height are negative, reset to no clipping.
*
* Results:
* None.
@@ -1786,6 +1908,7 @@ TkpClipDrawableToRect(
int width, int height)
{
MacDrawable *macDraw = (MacDrawable *) d;
+ (void)display;
if (macDraw->drawRgn) {
CFRelease(macDraw->drawRgn);
@@ -1832,13 +1955,13 @@ ClipToGC(
HIShapeRef *clipRgnPtr) /* must point to initialized variable */
{
if (gc && gc->clip_mask &&
- ((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) {
- TkRegion gcClip = ((TkpClipMask*)gc->clip_mask)->value.region;
+ ((TkpClipMask *) gc->clip_mask)->type == TKP_CLIP_REGION) {
+ Region gcClip = ((TkpClipMask *) gc->clip_mask)->value.region;
int xOffset = ((MacDrawable *) d)->xOff + gc->clip_x_origin;
int yOffset = ((MacDrawable *) d)->yOff + gc->clip_y_origin;
HIShapeRef clipRgn = *clipRgnPtr, gcClipRgn;
- TkMacOSXOffsetRegion(gcClip, xOffset, yOffset);
+ XOffsetRegion(gcClip, xOffset, yOffset);
gcClipRgn = TkMacOSXGetNativeRegion(gcClip);
if (clipRgn) {
*clipRgnPtr = HIShapeCreateIntersection(gcClipRgn, clipRgn);
@@ -1847,7 +1970,7 @@ ClipToGC(
*clipRgnPtr = HIShapeCreateCopy(gcClipRgn);
}
CFRelease(gcClipRgn);
- TkMacOSXOffsetRegion(gcClip, -xOffset, -yOffset);
+ XOffsetRegion(gcClip, -xOffset, -yOffset);
}
}
@@ -1856,10 +1979,9 @@ ClipToGC(
*
* TkMacOSXMakeStippleMap --
*
- * Given a drawable and a stipple pattern this function draws the
- * pattern repeatedly over the drawable. The drawable can then
- * be used as a mask for bit-bliting a stipple pattern over an
- * object.
+ * Given a drawable and a stipple pattern this function draws the pattern
+ * repeatedly over the drawable. The drawable can then be used as a mask
+ * for bit-bliting a stipple pattern over an object.
*
* Results:
* A BitMap data structure.
@@ -1875,6 +1997,9 @@ TkMacOSXMakeStippleMap(
Drawable drawable, /* Window to apply stipple. */
Drawable stipple) /* The stipple pattern. */
{
+ (void)drawable;
+ (void)stipple;
+
return NULL;
}
@@ -1883,12 +2008,12 @@ TkMacOSXMakeStippleMap(
*
* TkpDrawHighlightBorder --
*
- * This procedure draws a rectangular ring around the outside of
- * a widget to indicate that it has received the input focus.
+ * This procedure draws a rectangular ring around the outside of a widget
+ * to indicate that it has received the input focus.
*
- * On the Macintosh, this puts a 1 pixel border in the bgGC color
- * between the widget and the focus ring, except in the case where
- * highlightWidth is 1, in which case the border is left out.
+ * On the Macintosh, this puts a 1 pixel border in the bgGC color between
+ * the widget and the focus ring, except in the case where highlightWidth
+ * is 1, in which case the border is left out.
*
* For proper Mac L&F, use highlightWidth of 3.
*
@@ -1896,8 +2021,8 @@ TkMacOSXMakeStippleMap(
* None.
*
* Side effects:
- * A rectangle "width" pixels wide is drawn in "drawable",
- * corresponding to the outer area of "tkwin".
+ * A rectangle "width" pixels wide is drawn in "drawable", corresponding
+ * to the outer area of "tkwin".
*
*----------------------------------------------------------------------
*/
@@ -1924,10 +2049,10 @@ TkpDrawHighlightBorder (
/*
*----------------------------------------------------------------------
*
- * TkpDrawFrame --
+ * TkpDrawFrameEx --
*
- * This procedure draws the rectangular frame area. If the user
- * has requested themeing, it draws with the background theme.
+ * This procedure draws the rectangular frame area. If the user has
+ * requested themeing, it draws with the background theme.
*
* Results:
* None.
@@ -1939,8 +2064,9 @@ TkpDrawHighlightBorder (
*/
void
-TkpDrawFrame(
+TkpDrawFrameEx(
Tk_Window tkwin,
+ Drawable drawable,
Tk_3DBorder border,
int highlightWidth,
int borderWidth,
@@ -1958,11 +2084,9 @@ TkpDrawFrame(
}
}
- Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin),
- border, highlightWidth, highlightWidth,
- Tk_Width(tkwin) - 2 * highlightWidth,
- Tk_Height(tkwin) - 2 * highlightWidth,
- borderWidth, relief);
+ Tk_Fill3DRectangle(tkwin, drawable, border, highlightWidth,
+ highlightWidth, Tk_Width(tkwin) - 2 * highlightWidth,
+ Tk_Height(tkwin) - 2 * highlightWidth, borderWidth, relief);
}
/*
diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c
index b23f33b..5afb408 100644
--- a/macosx/tkMacOSXEmbed.c
+++ b/macosx/tkMacOSXEmbed.c
@@ -90,7 +90,7 @@ Tk_MacOSXSetEmbedHandler(
Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc)
{
if (tkMacOSXEmbedHandler == NULL) {
- tkMacOSXEmbedHandler = ckalloc(sizeof(TkMacOSXEmbedHandler));
+ tkMacOSXEmbedHandler = (TkMacOSXEmbedHandler *)ckalloc(sizeof(TkMacOSXEmbedHandler));
}
tkMacOSXEmbedHandler->registerWinProc = registerWinProc;
tkMacOSXEmbedHandler->getPortProc = getPortProc;
@@ -121,6 +121,7 @@ TkpMakeWindow(
Window parent)
{
MacDrawable *macWin;
+ (void)parent;
/*
* If this window is marked as embedded then the window structure should
@@ -134,7 +135,7 @@ TkpMakeWindow(
* Allocate sub window
*/
- macWin = ckalloc(sizeof(MacDrawable));
+ macWin = (MacDrawable *)ckalloc(sizeof(MacDrawable));
if (macWin == NULL) {
winPtr->privatePtr = NULL;
return None;
@@ -306,7 +307,7 @@ TkpUseWindow(
* Make the embedded window.
*/
- macWin = ckalloc(sizeof(MacDrawable));
+ macWin = (MacDrawable *)ckalloc(sizeof(MacDrawable));
if (macWin == NULL) {
winPtr->privatePtr = NULL;
return TCL_ERROR;
@@ -334,15 +335,15 @@ TkpUseWindow(
macWin->flags |= TK_EMBEDDED;
macWin->xOff = parent->winPtr->privatePtr->xOff +
- parent->winPtr->changes.border_width +
- winPtr->changes.x;
+ parent->winPtr->changes.border_width +
+ winPtr->changes.x;
macWin->yOff = parent->winPtr->privatePtr->yOff +
- parent->winPtr->changes.border_width +
- winPtr->changes.y;
+ parent->winPtr->changes.border_width +
+ winPtr->changes.y;
/*
- * Finish filling up the container structure with the embedded
- * window's information.
+ * Finish filling up the container structure with the embedded window's
+ * information.
*/
containerPtr->embedded = (Window) macWin;
@@ -353,8 +354,8 @@ TkpUseWindow(
* tkwin is eventually deleted.
*/
- Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc,
- winPtr);
+ Tk_CreateEventHandler(tkwin, StructureNotifyMask,
+ EmbeddedEventProc, winPtr);
return TCL_OK;
}
@@ -392,7 +393,7 @@ TkpMakeContainer(
*/
Tk_MakeWindowExist(tkwin);
- containerPtr = ckalloc(sizeof(Container));
+ containerPtr = (Container *)ckalloc(sizeof(Container));
containerPtr->parent = Tk_WindowId(tkwin);
containerPtr->parentPtr = winPtr;
containerPtr->embedded = None;
@@ -559,7 +560,7 @@ TkpClaimFocus(
int
TkpTestembedCmd(
- ClientData clientData, /* Main window for application. */
+ ClientData dummy, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -569,6 +570,7 @@ TkpTestembedCmd(
Tcl_DString dString;
char buffer[50];
Tcl_Interp *embeddedInterp = NULL, *parentInterp = NULL;
+ (void)dummy;
if ((objc > 1) && (strcmp(Tcl_GetString(objv[1]), "all") == 0)) {
all = 1;
@@ -588,16 +590,25 @@ TkpTestembedCmd(
continue;
}
Tcl_DStringStartSublist(&dString);
- /* Parent id */
+
+ /*
+ * Parent id
+ */
+
if (containerPtr->parent == None) {
Tcl_DStringAppendElement(&dString, "");
} else if (all) {
- sprintf(buffer, "0x%" TCL_Z_MODIFIER "x", (size_t) containerPtr->parent);
+ sprintf(buffer, "0x%" TCL_Z_MODIFIER "x",
+ (size_t) containerPtr->parent);
Tcl_DStringAppendElement(&dString, buffer);
} else {
Tcl_DStringAppendElement(&dString, "XXX");
}
- /* Parent pathName */
+
+ /*
+ * Parent pathName
+ */
+
if (containerPtr->parentPtr == NULL ||
parentInterp != interp) {
Tcl_DStringAppendElement(&dString, "");
@@ -605,11 +616,17 @@ TkpTestembedCmd(
Tcl_DStringAppendElement(&dString,
containerPtr->parentPtr->pathName);
}
+
/*
* On X11 embedded is a wrapper, which does not exist on macOS.
*/
+
Tcl_DStringAppendElement(&dString, "");
- /* Embedded window pathName */
+
+ /*
+ * Embedded window pathName
+ */
+
if (containerPtr->embeddedPtr == NULL ||
embeddedInterp != interp) {
Tcl_DStringAppendElement(&dString, "");
@@ -652,6 +669,9 @@ TkpRedirectKeyEvent(
XEvent *eventPtr) /* X event to redirect (should be KeyPress or
* KeyRelease). */
{
+ (void)winPtr;
+ (void)eventPtr;
+
/* TODO: Implement this or decide it definitely needs no implementation */
}
@@ -768,6 +788,7 @@ ContainerEventProc(
/*
* When the interpreter is being dismantled this can be nil.
*/
+
return;
}
@@ -833,7 +854,9 @@ ContainerEventProc(
eventPtr->xmaprequest.window);
} else if (eventPtr->type == DestroyNotify) {
/*
- * The embedded application is gone. Destroy the container window.
+ * It is not clear whether the container should be destroyed
+ * when an embedded window is destroyed. See ticket [67384bce7d].
+ * Here we are following unix, by destroying the container.
*/
Tk_DestroyWindow((Tk_Window) winPtr);
@@ -920,6 +943,7 @@ EmbedActivateProc(
XEvent *eventPtr) /* ResizeRequest event. */
{
Container *containerPtr = clientData;
+
if (containerPtr->embeddedPtr != NULL) {
if (eventPtr->type == ActivateNotify) {
TkGenerateActivateEvents(containerPtr->embeddedPtr,1);
@@ -1024,11 +1048,10 @@ EmbedGeometryRequest(
/*
* Forward the requested size into our geometry management hierarchy via
* the container window. We need to send a Configure event back to the
- * embedded application if we decide not to honor its request; to make
- * this happen, process all idle event handlers synchronously here (so
- * that the geometry managers have had a chance to do whatever they want
- * to do), and if the window's size didn't change then generate a
- * configure event.
+ * embedded application if we decide not to honor its request; to make this
+ * happen, process all idle event handlers synchronously here (so that the
+ * geometry managers have had a chance to do whatever they want to do), and
+ * if the window's size didn't change then generate a configure event.
*/
Tk_GeometryRequest((Tk_Window) winPtr, width, height);
@@ -1050,8 +1073,8 @@ EmbedGeometryRequest(
* application of its current size and location. This procedure is called
* when the embedded application made a geometry request that we did not
* grant, so that the embedded application knows that its geometry didn't
- * change after all. It is a response to ConfigureRequest events, which
- * we do not currently synthesize on the Mac
+ * change after all. It is a response to ConfigureRequest events, which we
+ * do not currently synthesize on the Mac
*
* Results:
* None.
@@ -1066,6 +1089,7 @@ static void
EmbedSendConfigure(
Container *containerPtr) /* Information about the embedding. */
{
+ (void)containerPtr;
}
/*
@@ -1111,8 +1135,8 @@ EmbedWindowDeleted(
containerPtr->parentPtr->flags & TK_BOTH_HALVES) {
XEvent event;
- event.xany.serial =
- LastKnownRequestProcessed(Tk_Display(containerPtr->parentPtr));
+ event.xany.serial = LastKnownRequestProcessed(
+ Tk_Display(containerPtr->parentPtr));
event.xany.send_event = False;
event.xany.display = Tk_Display(containerPtr->parentPtr);
@@ -1173,12 +1197,14 @@ void
TkpShowBusyWindow(
TkBusy busy)
{
+ (void)busy;
}
void
TkpHideBusyWindow(
TkBusy busy)
{
+ (void)busy;
}
void
@@ -1186,6 +1212,8 @@ TkpMakeTransparentWindowExist(
Tk_Window tkwin, /* Token for window. */
Window parent) /* Parent window. */
{
+ (void)tkwin;
+ (void)parent;
}
void
@@ -1196,6 +1224,11 @@ TkpCreateBusy(
Tk_Window tkParent,
TkBusy busy)
{
+ (void)winPtr;
+ (void)tkRef;
+ (void)parentPtr;
+ (void)tkParent;
+ (void)busy;
}
/*
diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c
index a1c5d60..7915f6f 100644
--- a/macosx/tkMacOSXEntry.c
+++ b/macosx/tkMacOSXEntry.c
@@ -124,16 +124,17 @@ TkpDrawEntryBorderAndFocus(
int incDecWidth;
/*
- * Temporarily change the width of the widget so that the same code can
- * be used for drawing the Entry portion of the Spinbox as is used to
- * draw an ordinary Entry. The width must be restored before
- * returning.
+ * If native spinbox buttons are going to be drawn, then temporarily
+ * change the width of the widget so that the same code can be used
+ * for drawing the Entry portion of the Spinbox as is used to draw
+ * an ordinary Entry. The width must be restored before returning.
*/
oldWidth = Tk_Width(tkwin);
- ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH,
- &incDecWidth);
- Tk_Width(tkwin) -= incDecWidth + 1;
+ if (ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH,
+ &incDecWidth) != 0) {
+ Tk_Width(tkwin) -= incDecWidth + 1;
+ }
}
/*
@@ -186,10 +187,10 @@ TkpDrawEntryBorderAndFocus(
* have to implement it.
*
* Results:
- * 1 if it has drawn the border, 0 if not.
+ * 1 if it has drawn the buttons, 0 if not.
*
* Side effects:
- * May draw the entry border into pixmap.
+ * May draw the buttons into pixmap.
*
*--------------------------------------------------------------
*/
@@ -258,9 +259,9 @@ TkpDrawSpinboxButtons(
*/
bgGC = Tk_GCForColor(sbPtr->entry.highlightBgColorPtr, d);
- rects[0].x = bounds.origin.x;
+ rects[0].x = Tk_Width(tkwin) - incDecWidth - 1;
rects[0].y = 0;
- rects[0].width = Tk_Width(tkwin);
+ rects[0].width = incDecWidth + 1;
rects[0].height = Tk_Height(tkwin);
XFillRectangles(Tk_Display(tkwin), d, bgGC, rects, 1);
diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c
index b9c9b6a..af68eb6 100644
--- a/macosx/tkMacOSXEvent.c
+++ b/macosx/tkMacOSXEvent.c
@@ -12,7 +12,7 @@
*/
#include "tkMacOSXPrivate.h"
-#include "tkMacOSXEvent.h"
+#include "tkMacOSXInt.h"
#include "tkMacOSXDebug.h"
#include "tkMacOSXConstants.h"
@@ -110,9 +110,9 @@ enum {
/*
*----------------------------------------------------------------------
*
- * TkMacOSXFlushWindows --
+ * XSync --
*
- * This routine is a stub called by XSync, which is called during the Tk
+ * This routine is a stub called XSync, which is called during the Tk
* update command. The language specification does not require that the
* update command be synchronous but many of the tests implicitly assume
* that it is. It is definitely asynchronous on macOS since many idle
@@ -128,18 +128,24 @@ enum {
*----------------------------------------------------------------------
*/
-MODULE_SCOPE void
-TkMacOSXFlushWindows(void)
+int
+XSync(
+ Display *display,
+ Bool discard)
{
- if (Tk_GetNumMainWindows() == 0) {
- return;
+ (void)discard;
+
+ if (display) {
+ display->request++;
}
- while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){}
- for (NSWindow *w in [NSApp orderedWindows]) {
- [w display];
+ if (Tk_GetNumMainWindows() != 0) {
+ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){}
+ for (NSWindow *w in [NSApp orderedWindows]) {
+ [w display];
+ }
}
+ return Success;
}
-
/*
* Local Variables:
diff --git a/macosx/tkMacOSXEvent.h b/macosx/tkMacOSXEvent.h
deleted file mode 100644
index 46d1585..0000000
--- a/macosx/tkMacOSXEvent.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * tkMacOSXEvent.h --
- *
- * Declarations of Macintosh specific functions for implementing the
- * Mac OS X Notifier.
- *
- * Copyright 2001-2009, Apple Inc.
- * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- */
-
-#ifndef _TKMACEVENT
-#define _TKMACEVENT
-
-#ifndef _TKMACINT
-#include "tkMacOSXInt.h"
-#endif
-
-MODULE_SCOPE void TkMacOSXFlushWindows(void);
-
-#endif
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index 353ad6b..7527429 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -1,8 +1,8 @@
/*
* tkMacOSXFont.c --
*
- * Contains the Macintosh implementation of the platform-independant
- * font package interface.
+ * Contains the Macintosh implementation of the platform-independent font
+ * package interface.
*
* Copyright 2002-2004 Benjamin Riefenstahl, Benjamin.Riefenstahl@epost.de
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
@@ -32,9 +32,8 @@
*/
typedef struct {
- TkFont font; /* Stuff used by generic font package. Must
- * be first in structure. */
-
+ TkFont font; /* Stuff used by generic font package. Must be
+ * first in structure. */
NSFont *nsFont;
NSDictionary *nsAttributes;
} MacFont;
@@ -57,25 +56,25 @@ struct SystemFontMapEntry {
#define ThemeFont(n, ...) { kTheme##n##Font, "system" #n "Font", ##__VA_ARGS__ }
static const struct SystemFontMapEntry systemFontMap[] = {
ThemeFont(System, "TkDefaultFont", "TkIconFont"),
- ThemeFont(EmphasizedSystem, "TkCaptionFont"),
+ ThemeFont(EmphasizedSystem, "TkCaptionFont", NULL),
ThemeFont(SmallSystem, "TkHeadingFont", "TkTooltipFont"),
- ThemeFont(SmallEmphasizedSystem),
- ThemeFont(Application, "TkTextFont"),
- ThemeFont(Label, "TkSmallCaptionFont"),
- ThemeFont(Views),
- ThemeFont(MenuTitle),
- ThemeFont(MenuItem, "TkMenuFont"),
- ThemeFont(MenuItemMark),
- ThemeFont(MenuItemCmdKey),
- ThemeFont(WindowTitle),
- ThemeFont(PushButton),
- ThemeFont(UtilityWindowTitle),
- ThemeFont(AlertHeader),
- ThemeFont(Toolbar),
- ThemeFont(MiniSystem),
- { kThemeSystemFontDetail, "systemDetailSystemFont" },
- { kThemeSystemFontDetailEmphasized, "systemDetailEmphasizedSystemFont" },
- { -1, NULL }
+ ThemeFont(SmallEmphasizedSystem, NULL, NULL),
+ ThemeFont(Application, "TkTextFont", NULL),
+ ThemeFont(Label, "TkSmallCaptionFont", NULL),
+ ThemeFont(Views, NULL, NULL),
+ ThemeFont(MenuTitle, NULL, NULL),
+ ThemeFont(MenuItem, "TkMenuFont", NULL),
+ ThemeFont(MenuItemMark, NULL, NULL),
+ ThemeFont(MenuItemCmdKey, NULL, NULL),
+ ThemeFont(WindowTitle, NULL, NULL),
+ ThemeFont(PushButton, NULL, NULL),
+ ThemeFont(UtilityWindowTitle, NULL, NULL),
+ ThemeFont(AlertHeader, NULL, NULL),
+ ThemeFont(Toolbar, NULL, NULL),
+ ThemeFont(MiniSystem, NULL, NULL),
+ { kThemeSystemFontDetail, "systemDetailSystemFont", NULL, NULL },
+ { kThemeSystemFontDetailEmphasized, "systemDetailEmphasizedSystemFont", NULL, NULL },
+ { -1, NULL, NULL, NULL }
};
#undef ThemeFont
@@ -83,21 +82,108 @@ static int antialiasedTextEnabled = -1;
static NSCharacterSet *whitespaceCharacterSet = nil;
static NSCharacterSet *lineendingCharacterSet = nil;
-static void GetTkFontAttributesForNSFont(NSFont *nsFont,
- TkFontAttributes *faPtr);
-static NSFont *FindNSFont(const char *familyName, NSFontTraitMask traits,
- NSInteger weight, CGFloat size, int fallbackToDefault);
-static void InitFont(NSFont *nsFont, const TkFontAttributes *reqFaPtr,
- MacFont * fontPtr);
-static int CreateNamedSystemFont(Tcl_Interp *interp, Tk_Window tkwin,
- const char* name, TkFontAttributes *faPtr);
-static void DrawCharsInContext(Display *display, Drawable drawable, GC gc,
- Tk_Font tkfont, const char *source, int numBytes, int rangeStart,
- int rangeLength, int x, int y, double angle);
+static void GetTkFontAttributesForNSFont(NSFont *nsFont,
+ TkFontAttributes *faPtr);
+static NSFont * FindNSFont(const char *familyName,
+ NSFontTraitMask traits, NSInteger weight,
+ CGFloat size, int fallbackToDefault);
+static void InitFont(NSFont *nsFont,
+ const TkFontAttributes *reqFaPtr,
+ MacFont *fontPtr);
+static int CreateNamedSystemFont(Tcl_Interp *interp,
+ Tk_Window tkwin, const char *name,
+ TkFontAttributes *faPtr);
+static void DrawCharsInContext(Display *display, Drawable drawable,
+ GC gc, Tk_Font tkfont, const char *source,
+ int numBytes, int rangeStart, int rangeLength,
+ int x, int y, double angle);
#pragma mark -
#pragma mark Font Helpers:
+/*
+ * To avoid an extra copy, a TKNSString object wraps a Tcl_DString with an
+ * NSString that uses the DString's buffer as its character buffer. It can be
+ * constructed from a Tcl_DString and it has a DString property that handles
+ * converting from an NSString to a Tcl_DString.
+ */
+
+@implementation TKNSString
+
+- (instancetype)initWithTclUtfBytes:(const void *)bytes
+ length:(NSUInteger)len
+{
+ self = [self init];
+ if (self) {
+ Tcl_DStringInit(&_ds);
+ Tcl_UtfToChar16DString(bytes, len, &_ds);
+ _string = [[NSString alloc]
+ initWithCharactersNoCopy:(unichar *)Tcl_DStringValue(&_ds)
+ length:Tcl_DStringLength(&_ds)>>1
+ freeWhenDone:NO];
+ self.UTF8String = _string.UTF8String;
+ }
+ return self;
+}
+
+- (instancetype)initWithString:(NSString *)aString
+{
+ self = [self init];
+ if (self) {
+ _string = [[NSString alloc] initWithString:aString];
+ self.UTF8String = _string.UTF8String;
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ Tcl_DStringFree(&_ds);
+ [_string release];
+ [super dealloc];
+}
+
+- (NSUInteger)length
+{
+ return _string.length;
+}
+
+- (unichar)characterAtIndex:(NSUInteger)index
+{
+ return [_string characterAtIndex:index];
+}
+
+# ifndef __clang__
+@synthesize DString = _ds;
+#endif
+
+- (Tcl_DString)DString
+{
+ if ( _ds.string == NULL) {
+
+ /*
+ * The DString has not been initialized. Construct it from
+ * our string's unicode characters.
+ */
+ char *p;
+ NSUInteger index;
+
+ Tcl_DStringInit(&_ds);
+ Tcl_DStringSetLength(&_ds, 3 * [_string length]);
+ p = Tcl_DStringValue(&_ds);
+ for (index = 0; index < [_string length]; index++) {
+ p += Tcl_UniCharToUtf([_string characterAtIndex: index], p);
+ }
+ Tcl_DStringSetLength(&_ds, p - Tcl_DStringValue(&_ds));
+ }
+ return _ds;
+}
+
+#ifndef __clang__
+@synthesize UTF8String = _UTF8String;
+#endif
+@end
+
#define GetNSFontTraitsFromTkFontAttributes(faPtr) \
((faPtr)->weight == TK_FW_BOLD ? NSBoldFontMask : NSUnboldFontMask) | \
((faPtr)->slant == TK_FS_ITALIC ? NSItalicFontMask : NSUnitalicFontMask)
@@ -125,11 +211,11 @@ GetTkFontAttributesForNSFont(
{
NSFontTraitMask traits = [[NSFontManager sharedFontManager]
traitsOfFont:nsFont];
-
faPtr->family = Tk_GetUid([[nsFont familyName] UTF8String]);
faPtr->size = [nsFont pointSize];
faPtr->weight = (traits & NSBoldFontMask ? TK_FW_BOLD : TK_FW_NORMAL);
faPtr->slant = (traits & NSItalicFontMask ? TK_FS_ITALIC : TK_FS_ROMAN);
+
}
/*
@@ -173,6 +259,18 @@ FindNSFont(
size = [defaultFont pointSize];
}
nsFont = [fm fontWithFamily:family traits:traits weight:weight size:size];
+
+ /*
+ * A second bug in NSFontManager that Apple created for the Catalina OS
+ * causes requests as above to sometimes return fonts with additional
+ * traits that were not requested, even though fonts without those unwanted
+ * traits exist on the system. See bug [90d555e088]. As a workaround
+ * we ask the font manager to remove any unrequested traits.
+ */
+
+ if (nsFont) {
+ nsFont = [fm convertFont:nsFont toNotHaveTrait:~traits];
+ }
if (!nsFont) {
NSArray *availableFamilies = [fm availableFontFamilies];
NSString *caseFamily = nil;
@@ -232,7 +330,7 @@ InitFont(
int ascent, descent/*, dontAA*/;
static const UniChar ch[] = {'.', 'W', ' ', 0xc4, 0xc1, 0xc2, 0xc3, 0xc7};
/* ., W, Space, Auml, Aacute, Acirc, Atilde, Ccedilla */
- #define nCh (sizeof(ch) / sizeof(UniChar))
+#define nCh (sizeof(ch) / sizeof(UniChar))
CGGlyph glyphs[nCh];
CGRect boundingRects[nCh];
@@ -244,7 +342,11 @@ InitFont(
TkInitFontAttributes(faPtr);
}
fontPtr->nsFont = nsFont;
- // some don't like antialiasing on fixed-width even if bigger than limit
+
+ /*
+ * Some don't like antialiasing on fixed-width even if bigger than limit
+ */
+
// dontAA = [nsFont isFixedPitch] && fontPtr->font.fa.size <= 10;
if (antialiasedTextEnabled >= 0/* || dontAA*/) {
renderingMode = (antialiasedTextEnabled == 0/* || dontAA*/) ?
@@ -294,7 +396,7 @@ InitFont(
NSLigatureAttributeName,
[NSNumber numberWithDouble:kern], NSKernAttributeName, nil];
fontPtr->nsAttributes = [nsAttributes retain];
- #undef nCh
+#undef nCh
}
/*
@@ -336,7 +438,7 @@ CreateNamedSystemFont(
*
* This procedure is called when an application is created. It
* initializes all the structures that are used by the
- * platform-dependant code on a per application basis.
+ * platform-dependent code on a per application basis.
* Note that this is called before TkpInit() !
*
* Results:
@@ -358,10 +460,14 @@ TkpFontPkgInit(
NSFont *nsFont;
TkFontAttributes fa;
NSMutableCharacterSet *cs;
- /* Since we called before TkpInit, we need our own autorelease pool. */
+ /*
+ * Since we called before TkpInit, we need our own autorelease pool.
+ */
NSAutoreleasePool *pool = [NSAutoreleasePool new];
- /* force this for now */
+ /*
+ * Force this for now.
+ */
if (!mainPtr->winPtr->mainPtr) {
mainPtr->winPtr->mainPtr = mainPtr;
}
@@ -383,10 +489,25 @@ TkpFontPkgInit(
systemFont++;
}
TkInitFontAttributes(&fa);
+#if 0
+
+ /*
+ * In macOS 10.15.1 Apple introduced a bug in NSFontManager which caused
+ * it to not recognize the familyName ".SF NSMono" which is the familyName
+ * of the default fixed pitch system fault on that system. See bug [855049e799].
+ * As a workaround we call [NSFont userFixedPitchFontOfSize:11] instead.
+ * This returns a user font in the "Menlo" family.
+ */
+
nsFont = (NSFont*) CTFontCreateUIFontForLanguage(fixedPitch, 11, NULL);
+#else
+ nsFont = [NSFont userFixedPitchFontOfSize:11];
+#endif
if (nsFont) {
GetTkFontAttributesForNSFont(nsFont, &fa);
+#if 0
CFRelease(nsFont);
+#endif
} else {
fa.family = Tk_GetUid("Monaco");
fa.size = 11;
@@ -413,17 +534,17 @@ TkpFontPkgInit(
* Map a platform-specific native font name to a TkFont.
*
* Results:
- * The return value is a pointer to a TkFont that represents the
- * native font. If a native font by the given name could not be
- * found, the return value is NULL.
+ * The return value is a pointer to a TkFont that represents the native
+ * font. If a native font by the given name could not be found, the return
+ * value is NULL.
*
- * Every call to this procedure returns a new TkFont structure, even
- * if the name has already been seen before. The caller should call
+ * Every call to this procedure returns a new TkFont structure, even if
+ * the name has already been seen before. The caller should call
* TkpDeleteFont() when the font is no longer needed.
*
- * The caller is responsible for initializing the memory associated
- * with the generic TkFont when this function returns and releasing
- * the contents of the generics TkFont before calling TkpDeleteFont().
+ * The caller is responsible for initializing the memory associated with
+ * the generic TkFont when this function returns and releasing the
+ * contents of the generics TkFont before calling TkpDeleteFont().
*
* Side effects:
* None.
@@ -439,6 +560,7 @@ TkpGetNativeFont(
MacFont *fontPtr = NULL;
ThemeFontID themeFontId;
CTFontRef ctFont;
+ (void)tkwin;
if (strcmp(name, SYSTEMFONT_NAME) == 0) {
themeFontId = kThemeSystemFont;
@@ -449,10 +571,10 @@ TkpGetNativeFont(
} else {
return NULL;
}
- ctFont = CTFontCreateUIFontForLanguage(HIThemeGetUIFontType(
- themeFontId), 0, NULL);
+ ctFont = CTFontCreateUIFontForLanguage(
+ HIThemeGetUIFontType(themeFontId), 0, NULL);
if (ctFont) {
- fontPtr = ckalloc(sizeof(MacFont));
+ fontPtr = (MacFont *)ckalloc(sizeof(MacFont));
InitFont((NSFont*) ctFont, NULL, fontPtr);
}
@@ -468,19 +590,18 @@ TkpGetNativeFont(
* closest matching attributes.
*
* Results:
- * The return value is a pointer to a TkFont that represents the font
- * with the desired attributes. If a font with the desired attributes
- * could not be constructed, some other font will be substituted
- * automatically.
+ * The return value is a pointer to a TkFont that represents the font with
+ * the desired attributes. If a font with the desired attributes could not
+ * be constructed, some other font will be substituted automatically.
*
- * Every call to this procedure returns a new TkFont structure, even
- * if the specified attributes have already been seen before. The
- * caller should call TkpDeleteFont() to free the platform- specific
- * data when the font is no longer needed.
+ * Every call to this procedure returns a new TkFont structure, even if
+ * the specified attributes have already been seen before. The caller
+ * should call TkpDeleteFont() to free the platform- specific data when
+ * the font is no longer needed.
*
- * The caller is responsible for initializing the memory associated
- * with the generic TkFont when this function returns and releasing
- * the contents of the generic TkFont before calling TkpDeleteFont().
+ * The caller is responsible for initializing the memory associated with
+ * the generic TkFont when this function returns and releasing the
+ * contents of the generic TkFont before calling TkpDeleteFont().
*
* Side effects:
* None.
@@ -492,16 +613,16 @@ TkFont *
TkpGetFontFromAttributes(
TkFont *tkFontPtr, /* If non-NULL, store the information in this
* existing TkFont structure, rather than
- * allocating a new structure to hold the
- * font; the existing contents of the font
- * will be released. If NULL, a new TkFont
- * structure is allocated. */
+ * allocating a new structure to hold the font;
+ * the existing contents of the font will be
+ * released. If NULL, a new TkFont structure is
+ * allocated. */
Tk_Window tkwin, /* For display where font will be used. */
const TkFontAttributes *faPtr)
/* Set of attributes to match. */
{
MacFont *fontPtr;
- int points = (int)(TkFontGetPoints(tkwin, faPtr->size) + 0.5);
+ int points = (int) (TkFontGetPoints(tkwin, faPtr->size) + 0.5);
NSFontTraitMask traits = GetNSFontTraitsFromTkFontAttributes(faPtr);
NSInteger weight = (faPtr->weight == TK_FW_BOLD ? 9 : 5);
NSFont *nsFont;
@@ -521,7 +642,7 @@ TkpGetFontFromAttributes(
Tcl_Panic("Could not determine NSFont from TkFontAttributes");
}
if (tkFontPtr == NULL) {
- fontPtr = ckalloc(sizeof(MacFont));
+ fontPtr = (MacFont *)ckalloc(sizeof(MacFont));
} else {
fontPtr = (MacFont *) tkFontPtr;
TkpDeleteFont(tkFontPtr);
@@ -538,9 +659,9 @@ TkpGetFontFromAttributes(
* TkpDeleteFont --
*
* Called to release a font allocated by TkpGetNativeFont() or
- * TkpGetFontFromAttributes(). The caller should have already
- * released the fields of the TkFont that are used exclusively by the
- * generic TkFont code.
+ * TkpGetFontFromAttributes(). The caller should have already released the
+ * fields of the TkFont that are used exclusively by the generic TkFont
+ * code.
*
* Results:
* TkFont is deallocated.
@@ -567,8 +688,8 @@ TkpDeleteFont(
*
* TkpGetFontFamilies --
*
- * Return information about the font families that are available on
- * the display of the given window.
+ * Return information about the font families that are available on the
+ * display of the given window.
*
* Results:
* Modifies interp's result object to hold a list of all the available
@@ -587,6 +708,7 @@ TkpGetFontFamilies(
{
Tcl_Obj *resultPtr = Tcl_NewListObj(0, NULL);
NSArray *list = [[NSFontManager sharedFontManager] availableFontFamilies];
+ (void)tkwin;
for (NSString *family in list) {
Tcl_ListObjAppendElement(NULL, resultPtr,
@@ -600,12 +722,12 @@ TkpGetFontFamilies(
*
* TkpGetSubFonts --
*
- * A function used by the testing package for querying the actual
- * screen fonts that make up a font object.
+ * A function used by the testing package for querying the actual screen
+ * fonts that make up a font object.
*
* Results:
- * Modifies interp's result object to hold a list containing the names
- * of the screen fonts that make up the given font object.
+ * Modifies interp's result object to hold a list containing the names of
+ * the screen fonts that make up the given font object.
*
* Side effects:
* None.
@@ -642,8 +764,8 @@ TkpGetSubFonts(
*
* TkpGetFontAttrsForChar --
*
- * Retrieve the font attributes of the actual font used to render a
- * given character.
+ * Retrieve the font attributes of the actual font used to render a given
+ * character.
*
* Results:
* None.
@@ -666,6 +788,7 @@ TkpGetFontAttrsForChar(
*faPtr = fontPtr->font.fa;
if (nsFont && ![[nsFont coveredCharacterSet] characterIsMember:c]) {
UTF16Char ch = (UTF16Char) c;
+ (void)tkwin;
nsFont = [nsFont bestMatchingFontForCharacters:&ch
length:1 attributes:nil actualCoveredLength:NULL];
@@ -745,10 +868,9 @@ Tk_MeasureChars(
* all the characters on the line for context.
*
* Results:
- * The return value is the number of bytes from source that
- * fit into the span that extends from 0 to maxLength. *lengthPtr is
- * filled with the x-coordinate of the right edge of the last
- * character that did fit.
+ * The return value is the number of bytes from source that fit into the
+ * span that extends from 0 to maxLength. *lengthPtr is filled with the
+ * x-coordinate of the right edge of the last character that did fit.
*
* Side effects:
* None.
@@ -774,11 +896,11 @@ TkpMeasureCharsInContext(
* TK_PARTIAL_OK means include the last char
* which only partially fits on this line.
* TK_WHOLE_WORDS means stop on a word
- * boundary, if possible. TK_AT_LEAST_ONE
- * means return at least one character even
- * if no characters fit. If TK_WHOLE_WORDS
- * and TK_AT_LEAST_ONE are set and the first
- * word doesn't fit, we return at least one
+ * boundary, if possible. TK_AT_LEAST_ONE means
+ * return at least one character even if no
+ * characters fit. If TK_WHOLE_WORDS and
+ * TK_AT_LEAST_ONE are set and the first word
+ * doesn't fit, we return at least one
* character or whatever characters fit into
* maxLength. TK_ISOLATE_END means that the
* last character should not be considered in
@@ -808,8 +930,7 @@ TkpMeasureCharsInContext(
if (maxLength > 32767) {
maxLength = 32767;
}
- string = [[NSString alloc] initWithBytesNoCopy:(void*)source
- length:numBytes encoding:NSUTF8StringEncoding freeWhenDone:NO];
+ string = [[TKNSString alloc] initWithTclUtfBytes:source length:numBytes];
if (!string) {
length = 0;
fit = rangeLength;
@@ -864,14 +985,13 @@ TkpMeasureCharsInContext(
}
/*
- * If there is no line breakpoint in the source string between
- * its start and the index position that fits in maxWidth, then
+ * If there is no line breakpoint in the source string between its
+ * start and the index position that fits in maxWidth, then
* CTTypesetterSuggestLineBreak() returns that very last index.
- * However if the TK_WHOLE_WORDS flag is set, we want to break
- * at a word boundary. In this situation, unless TK_AT_LEAST_ONE
- * is set, we must report that zero chars actually fit (in other
- * words the smallest word of the source string is still larger
- * than maxWidth).
+ * However if the TK_WHOLE_WORDS flag is set, we want to break at a
+ * word boundary. In this situation, unless TK_AT_LEAST_ONE is set, we
+ * must report that zero chars actually fit (in other words the
+ * smallest word of the source string is still larger than maxWidth).
*/
if ((index >= start) && (index < len) &&
@@ -903,9 +1023,12 @@ TkpMeasureCharsInContext(
CFRelease(line);
}
- /* The call to CTTypesetterSuggestClusterBreak above will always
- return at least one character regardless of whether it exceeded
- it or not. Clean that up now. */
+ /*
+ * The call to CTTypesetterSuggestClusterBreak above will always return
+ * at least one character regardless of whether it exceeded it or not.
+ * Clean that up now.
+ */
+
while (width > maxWidth && !(flags & TK_PARTIAL_OK)
&& index > start+(flags & TK_AT_LEAST_ONE)) {
range.length = --index;
@@ -946,7 +1069,7 @@ done:
* actual implementation in TkpDrawCharsInContext().
*
* Results:
- * None.
+ * None.
*
* Side effects:
* Information gets drawn on the screen.
@@ -964,8 +1087,8 @@ Tk_DrawChars(
const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. All Tk meta-characters
* (tabs, control characters, and newlines)
- * should be stripped out of the string that
- * is passed to this function. If they are not
+ * should be stripped out of the string that is
+ * passed to this function. If they are not
* stripped out, they will be displayed as
* regular printing characters. */
int numBytes, /* Number of bytes in string. */
@@ -986,8 +1109,8 @@ TkDrawAngledChars(
const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. All Tk meta-characters
* (tabs, control characters, and newlines)
- * should be stripped out of the string that
- * is passed to this function. If they are not
+ * should be stripped out of the string that is
+ * passed to this function. If they are not
* stripped out, they will be displayed as
* regular printing characters. */
int numBytes, /* Number of bytes in string. */
@@ -1029,8 +1152,8 @@ TkpDrawCharsInContext(
const char * source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. All Tk meta-characters
* (tabs, control characters, and newlines)
- * should be stripped out of the string that
- * is passed to this function. If they are not
+ * should be stripped out of the string that is
+ * passed to this function. If they are not
* stripped out, they will be displayed as
* regular printing characters. */
int numBytes, /* Number of bytes in string. */
@@ -1040,6 +1163,7 @@ TkpDrawCharsInContext(
* whole (not just the range) string when
* drawing. */
{
+ (void)display;
DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes,
rangeStart, rangeLength, x, y, 0.0);
}
@@ -1054,8 +1178,8 @@ DrawCharsInContext(
const char * source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. All Tk meta-characters
* (tabs, control characters, and newlines)
- * should be stripped out of the string that
- * is passed to this function. If they are not
+ * should be stripped out of the string that is
+ * passed to this function. If they are not
* stripped out, they will be displayed as
* regular printing characters. */
int numBytes, /* Number of bytes in string. */
@@ -1071,26 +1195,27 @@ DrawCharsInContext(
NSMutableDictionary *attributes;
NSAttributedString *attributedString;
CTTypesetterRef typesetter;
- CFIndex start, len;
- CTLineRef line;
+ CFIndex start, length;
+ CTLineRef line, full=nil;
MacDrawable *macWin = (MacDrawable *) drawable;
TkMacOSXDrawingContext drawingContext;
CGContextRef context;
CGColorRef fg;
NSFont *nsFont;
CGAffineTransform t;
- int h;
+ CGFloat width, height, textX = (CGFloat) x, textY = (CGFloat) y;
+ (void)display;
- if (rangeStart < 0 || rangeLength <= 0 ||
- rangeStart + rangeLength > numBytes ||
- !TkMacOSXSetupDrawingContext(drawable, gc, 1, &drawingContext)) {
+ if (rangeStart < 0 || rangeLength <= 0 ||
+ rangeStart + rangeLength > numBytes ||
+ !TkMacOSXSetupDrawingContext(drawable, gc, 1, &drawingContext)) {
return;
}
- string = [[NSString alloc] initWithBytesNoCopy:(void*)source
- length:numBytes encoding:NSUTF8StringEncoding freeWhenDone:NO];
+ string = [[TKNSString alloc] initWithTclUtfBytes:source length:numBytes];
if (!string) {
return;
}
+
context = drawingContext.context;
fg = TkMacOSXCreateCGColor(gc, gc->foreground);
attributes = [fontPtr->nsAttributes mutableCopy];
@@ -1104,28 +1229,36 @@ DrawCharsInContext(
attributes:attributes];
typesetter = CTTypesetterCreateWithAttributedString(
(CFAttributedStringRef)attributedString);
- x += macWin->xOff;
- y += macWin->yOff;
- h = drawingContext.portBounds.size.height;
- y = h - y;
- t = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, h);
+ textX += (CGFloat) macWin->xOff;
+ textY += (CGFloat) macWin->yOff;
+ height = drawingContext.portBounds.size.height;
+ textY = height - textY;
+ t = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, height);
if (angle != 0.0) {
- t = CGAffineTransformTranslate(CGAffineTransformRotate(
- CGAffineTransformTranslate(t, x, y), angle*PI/180.0), -x, -y);
+ t = CGAffineTransformTranslate(
+ CGAffineTransformRotate(
+ CGAffineTransformTranslate(t, textX, textY), angle*PI/180.0),
+ -textX, -textY);
}
CGContextConcatCTM(context, t);
- CGContextSetTextPosition(context, x, y);
start = Tcl_NumUtfChars(source, rangeStart);
- len = Tcl_NumUtfChars(source, rangeStart + rangeLength);
+ length = Tcl_NumUtfChars(source, rangeStart + rangeLength) - start;
+ line = CTTypesetterCreateLine(typesetter, CFRangeMake(start, length));
if (start > 0) {
- CGRect clipRect = CGRectInfinite, startBounds;
- line = CTTypesetterCreateLine(typesetter, CFRangeMake(0, start));
- startBounds = CTLineGetImageBounds(line, context);
- CFRelease(line);
- clipRect.origin.x = startBounds.origin.x + startBounds.size.width;
- CGContextClipToRect(context, clipRect);
+
+ /*
+ * We are only drawing part of the string. To compute the x coordinate
+ * of the part we are drawing we subtract its typographical length from
+ * the typographical length of the full string. This accounts for the
+ * kerning after the initial part of the string.
+ */
+
+ full = CTTypesetterCreateLine(typesetter, CFRangeMake(0, start + length));
+ width = CTLineGetTypographicBounds(full, NULL, NULL, NULL);
+ CFRelease(full);
+ textX += (width - CTLineGetTypographicBounds(line, NULL, NULL, NULL));
}
- line = CTTypesetterCreateLine(typesetter, CFRangeMake(0, len));
+ CGContextSetTextPosition(context, textX, textY);
CTLineDraw(line, context);
CFRelease(line);
CFRelease(typesetter);
@@ -1206,6 +1339,9 @@ TkMacOSXIsCharacterMissing(
Tk_Font tkfont, /* The font we are looking in. */
unsigned int searchChar) /* The character we are looking for. */
{
+ (void)tkfont;
+ (void)searchChar;
+
return 0;
}
@@ -1241,9 +1377,10 @@ TkMacOSXFontDescriptionForNSFontAndNSFontAttributes(
NSUnderlineStyleAttributeName];
id strikethrough = [nsAttributes objectForKey:
NSStrikethroughStyleAttributeName];
+
objv[i++] = Tcl_NewStringObj(familyName, -1);
- objv[i++] = Tcl_NewIntObj([nsFont pointSize]);
-#define S(s) Tcl_NewStringObj(STRINGIFY(s),(int)(sizeof(STRINGIFY(s))-1))
+ objv[i++] = Tcl_NewWideIntObj([nsFont pointSize]);
+#define S(s) Tcl_NewStringObj(STRINGIFY(s), (int)(sizeof(STRINGIFY(s))-1))
objv[i++] = (traits & NSBoldFontMask) ? S(bold) : S(normal);
objv[i++] = (traits & NSItalicFontMask) ? S(italic) : S(roman);
if ([underline respondsToSelector:@selector(intValue)] &&
@@ -1267,8 +1404,9 @@ TkMacOSXFontDescriptionForNSFontAndNSFontAttributes(
* TkMacOSXUseAntialiasedText --
*
* Enables or disables application-wide use of antialiased text (where
- * available). Sets up a linked Tcl global variable to allow
- * disabling of antialiased text from tcl.
+ * available). Sets up a linked Tcl global variable to allow disabling of
+ * antialiased text from Tcl.
+ *
* The possible values for this variable are:
*
* -1 - Use system default as configurable in "System Prefs" -> "General".
diff --git a/macosx/tkMacOSXFont.h b/macosx/tkMacOSXFont.h
index 08380c4..7fc9265 100644
--- a/macosx/tkMacOSXFont.h
+++ b/macosx/tkMacOSXFont.h
@@ -1,7 +1,7 @@
/*
* tkMacOSXFont.h --
*
- * Contains the Macintosh implementation of the platform-independant
+ * Contains the Macintosh implementation of the platform-independent
* font package interface.
*
* Copyright (c) 1990-1994 The Regents of the University of California.
diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c
index 9b874a5..e2ff0f1 100644
--- a/macosx/tkMacOSXHLEvents.c
+++ b/macosx/tkMacOSXHLEvents.c
@@ -1,13 +1,13 @@
/*
* tkMacOSXHLEvents.c --
*
- * Implements high level event support for the Macintosh. Currently, the
- * only event that really does anything is the Quit event.
+ * Implements high level event support for the Macintosh.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright (c) 2015 Marc Culler
+ * Copyright (c) 2015-2019 Marc Culler
+ * Copyright (c) 2019 Kevin Walzer/WordTech Communications LLC.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -30,26 +30,47 @@ typedef struct KillEvent {
} KillEvent;
/*
+ * When processing an AppleEvent as an idle task, a pointer to one
+ * of these structs is passed as the clientData.
+ */
+
+typedef struct AppleEventInfo {
+ Tcl_Interp *interp;
+ const char *procedure;
+ Tcl_DString command;
+ NSAppleEventDescriptor *replyEvent; /* Only used for DoScriptText. */
+} AppleEventInfo;
+
+/*
* Static functions used only in this file.
*/
-static void tkMacOSXProcessFiles(NSAppleEventDescriptor* event,
- NSAppleEventDescriptor* replyEvent,
- Tcl_Interp *interp,
- const char* procedure);
static int MissedAnyParameters(const AppleEvent *theEvent);
static int ReallyKillMe(Tcl_Event *eventPtr, int flags);
+static void ProcessAppleEvent(ClientData clientData);
+
+/*
+ * Names of the procedures which can be used to process AppleEvents.
+ */
+
+static const char* openDocumentProc = "::tk::mac::OpenDocument";
+static const char* launchURLProc = "::tk::mac::LaunchURL";
+static const char* printDocProc = "::tk::mac::PrintDocument";
+static const char* scriptFileProc = "::tk::mac::DoScriptFile";
+static const char* scriptTextProc = "::tk::mac::DoScriptText";
#pragma mark TKApplication(TKHLEvents)
@implementation TKApplication(TKHLEvents)
- (void) terminate: (id) sender
{
+ (void)sender;
[self handleQuitApplicationEvent:Nil withReplyEvent:Nil];
}
- (void) preferences: (id) sender
{
+ (void)sender;
[self handleShowPreferencesEvent:Nil withReplyEvent:Nil];
}
@@ -57,6 +78,8 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags);
withReplyEvent: (NSAppleEventDescriptor *)replyEvent
{
KillEvent *eventPtr;
+ (void)event;
+ (void)replyEvent;
if (_eventInterp) {
/*
@@ -67,7 +90,7 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags);
* quickly as possible.
*/
- eventPtr = ckalloc(sizeof(KillEvent));
+ eventPtr = (KillEvent *)ckalloc(sizeof(KillEvent));
eventPtr->header.proc = ReallyKillMe;
eventPtr->interp = _eventInterp;
@@ -78,9 +101,10 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags);
- (void) handleOpenApplicationEvent: (NSAppleEventDescriptor *)event
withReplyEvent: (NSAppleEventDescriptor *)replyEvent
{
- Tcl_Interp *interp = _eventInterp;
+ (void)event;
+ (void)replyEvent;
- if (interp &&
+ if (_eventInterp &&
Tcl_FindCommand(_eventInterp, "::tk::mac::OpenApplication", NULL, 0)){
int code = Tcl_EvalEx(_eventInterp, "::tk::mac::OpenApplication",
-1, TCL_EVAL_GLOBAL);
@@ -93,6 +117,9 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags);
- (void) handleReopenApplicationEvent: (NSAppleEventDescriptor *)event
withReplyEvent: (NSAppleEventDescriptor *)replyEvent
{
+ (void)event;
+ (void)replyEvent;
+
[NSApp activateIgnoringOtherApps: YES];
if (_eventInterp && Tcl_FindCommand(_eventInterp,
"::tk::mac::ReopenApplication", NULL, 0)) {
@@ -107,6 +134,9 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags);
- (void) handleShowPreferencesEvent: (NSAppleEventDescriptor *)event
withReplyEvent: (NSAppleEventDescriptor *)replyEvent
{
+ (void)event;
+ (void)replyEvent;
+
if (_eventInterp &&
Tcl_FindCommand(_eventInterp, "::tk::mac::ShowPreferences", NULL, 0)){
int code = Tcl_EvalEx(_eventInterp, "::tk::mac::ShowPreferences",
@@ -120,160 +150,6 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags);
- (void) handleOpenDocumentsEvent: (NSAppleEventDescriptor *)event
withReplyEvent: (NSAppleEventDescriptor *)replyEvent
{
- tkMacOSXProcessFiles(event, replyEvent, _eventInterp, "::tk::mac::OpenDocument");
-}
-
-- (void) handlePrintDocumentsEvent: (NSAppleEventDescriptor *)event
- withReplyEvent: (NSAppleEventDescriptor *)replyEvent
-{
- tkMacOSXProcessFiles(event, replyEvent, _eventInterp, "::tk::mac::PrintDocument");
-}
-
-- (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event
- withReplyEvent: (NSAppleEventDescriptor *)replyEvent
-{
- OSStatus err;
- const AEDesc *theDesc = nil;
- DescType type = 0, initialType = 0;
- Size actual;
- int tclErr = -1;
- char URLBuffer[1 + URL_MAX_LENGTH];
- char errString[128];
- char typeString[5];
-
- /*
- * The DoScript event receives one parameter that should be text data or a
- * fileURL.
- */
-
- theDesc = [event aeDesc];
- if (theDesc == nil) {
- return;
- }
-
- err = AEGetParamPtr(theDesc, keyDirectObject, typeWildCard, &initialType,
- NULL, 0, NULL);
- if (err != noErr) {
- sprintf(errString, "AEDoScriptHandler: GetParamDesc error %d", (int)err);
- AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyErrorString, typeChar,
- errString, strlen(errString));
- return;
- }
-
- if (MissedAnyParameters((AppleEvent*)theDesc)) {
- sprintf(errString, "AEDoScriptHandler: extra parameters");
- AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyErrorString, typeChar,
- errString, strlen(errString));
- return;
- }
-
- if (initialType == typeFileURL || initialType == typeAlias) {
- /*
- * The descriptor can be coerced to a file url. Source the file, or
- * pass the path as a string argument to ::tk::mac::DoScriptFile if
- * that procedure exists.
- */
- err = AEGetParamPtr(theDesc, keyDirectObject, typeFileURL, &type,
- (Ptr) URLBuffer, URL_MAX_LENGTH, &actual);
- if (err == noErr && actual > 0){
- URLBuffer[actual] = '\0';
- NSString *urlString = [NSString stringWithUTF8String:(char*)URLBuffer];
- NSURL *fileURL = [NSURL URLWithString:urlString];
- Tcl_DString command;
- Tcl_DStringInit(&command);
- if (Tcl_FindCommand(_eventInterp, "::tk::mac::DoScriptFile", NULL, 0)){
- Tcl_DStringAppend(&command, "::tk::mac::DoScriptFile", -1);
- } else {
- Tcl_DStringAppend(&command, "source", -1);
- }
- Tcl_DStringAppendElement(&command, [[fileURL path] UTF8String]);
- tclErr = Tcl_EvalEx(_eventInterp, Tcl_DStringValue(&command),
- Tcl_DStringLength(&command), TCL_EVAL_GLOBAL);
- }
- } else if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type,
- NULL, 0, &actual)) {
- if (actual > 0) {
- /*
- * The descriptor can be coerced to UTF8 text. Evaluate as Tcl, or
- * or pass the text as a string argument to ::tk::mac::DoScriptText
- * if that procedure exists.
- */
- char *data = ckalloc(actual + 1);
- if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type,
- data, actual, NULL)) {
- if (Tcl_FindCommand(_eventInterp, "::tk::mac::DoScriptText", NULL, 0)){
- Tcl_DString command;
- Tcl_DStringInit(&command);
- Tcl_DStringAppend(&command, "::tk::mac::DoScriptText", -1);
- Tcl_DStringAppendElement(&command, data);
- tclErr = Tcl_EvalEx(_eventInterp, Tcl_DStringValue(&command),
- Tcl_DStringLength(&command), TCL_EVAL_GLOBAL);
- } else {
- tclErr = Tcl_EvalEx(_eventInterp, data, actual, TCL_EVAL_GLOBAL);
- }
- }
- ckfree(data);
- }
- } else {
- /*
- * The descriptor can not be coerced to a fileURL or UTF8 text.
- */
- for (int i = 0; i < 4; i++) {
- typeString[i] = ((char*)&initialType)[3-i];
- }
- typeString[4] = '\0';
- sprintf(errString, "AEDoScriptHandler: invalid script type '%s', "
- "must be coercable to 'furl' or 'utf8'", typeString);
- AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyErrorString, typeChar, errString,
- strlen(errString));
- }
- /*
- * If we ran some Tcl code, put the result in the reply.
- */
- if (tclErr >= 0) {
- int reslen;
- const char *result =
- Tcl_GetStringFromObj(Tcl_GetObjResult(_eventInterp), &reslen);
- if (tclErr == TCL_OK) {
- AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyDirectObject, typeChar,
- result, reslen);
- } else {
- AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyErrorString, typeChar,
- result, reslen);
- AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyErrorNumber, typeSInt32,
- (Ptr) &tclErr,sizeof(int));
- }
- }
- return;
-}
-@end
-
-#pragma mark -
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXProcessFiles --
- *
- * Extract a list of fileURLs from an AppleEvent and call the specified
- * procedure with the file paths as arguments.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The event is handled by running the procedure.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-tkMacOSXProcessFiles(
- NSAppleEventDescriptor* event,
- NSAppleEventDescriptor* replyEvent,
- Tcl_Interp *interp,
- const char* procedure)
-{
Tcl_Encoding utf8;
const AEDesc *fileSpecDesc = nil;
AEDesc contents;
@@ -283,14 +159,14 @@ tkMacOSXProcessFiles(
Size actual;
long count, index;
AEKeyword keyword;
- Tcl_DString command, pathName;
- int code;
+ Tcl_DString pathName;
+ (void)replyEvent;
/*
- * Do nothing if we don't have an interpreter or the procedure doesn't exist.
+ * Do nothing if we don't have an interpreter.
*/
- if (!interp || !Tcl_FindCommand(interp, procedure, NULL, 0)) {
+ if (!_eventInterp) {
return;
}
@@ -320,12 +196,14 @@ tkMacOSXProcessFiles(
}
/*
- * Construct a Tcl command which calls the procedure, passing the
- * paths contained in the AppleEvent as arguments.
+ * Construct a Tcl expression which calls the ::tk::mac::OpenDocument
+ * procedure, passing the paths contained in the AppleEvent as arguments.
*/
- Tcl_DStringInit(&command);
- Tcl_DStringAppend(&command, procedure, -1);
+ AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo));
+ Tcl_DString *openCommand = &AEInfo->command;
+ Tcl_DStringInit(openCommand);
+ Tcl_DStringAppend(openCommand, openDocumentProc, -1);
utf8 = Tcl_GetEncoding(NULL, "utf-8");
for (index = 1; index <= count; index++) {
@@ -342,23 +220,207 @@ tkMacOSXProcessFiles(
continue;
}
Tcl_ExternalToUtfDString(utf8, [[fileURL path] UTF8String], -1, &pathName);
- Tcl_DStringAppendElement(&command, Tcl_DStringValue(&pathName));
+ Tcl_DStringAppendElement(openCommand, Tcl_DStringValue(&pathName));
Tcl_DStringFree(&pathName);
}
Tcl_FreeEncoding(utf8);
AEDisposeDesc(&contents);
+ AEInfo->interp = _eventInterp;
+ AEInfo->procedure = openDocumentProc;
+ AEInfo->replyEvent = nil;
+ Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
+}
+
+- (void) handlePrintDocumentsEvent: (NSAppleEventDescriptor *)event
+ withReplyEvent: (NSAppleEventDescriptor *)replyEvent
+{
+ NSString* file = [[event paramDescriptorForKeyword:keyDirectObject]
+ stringValue];
+ const char *printFile = [file UTF8String];
+ AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo));
+ Tcl_DString *printCommand = &AEInfo->command;
+ (void)replyEvent;
+
+ Tcl_DStringInit(printCommand);
+ Tcl_DStringAppend(printCommand, printDocProc, -1);
+ Tcl_DStringAppendElement(printCommand, printFile);
+ AEInfo->interp = _eventInterp;
+ AEInfo->procedure = printDocProc;
+ AEInfo->replyEvent = nil;
+ Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
+}
+
+- (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event
+ withReplyEvent: (NSAppleEventDescriptor *)replyEvent
+{
+ OSStatus err;
+ const AEDesc *theDesc = nil;
+ DescType type = 0, initialType = 0;
+ Size actual;
+ char URLBuffer[1 + URL_MAX_LENGTH];
+ char errString[128];
/*
- * Handle the event by evaluating the Tcl expression we constructed.
+ * The DoScript event receives one parameter that should be text data or a
+ * fileURL.
*/
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&command),
- Tcl_DStringLength(&command), TCL_EVAL_GLOBAL);
+ theDesc = [event aeDesc];
+ if (theDesc == nil) {
+ return;
+ }
+
+ err = AEGetParamPtr(theDesc, keyDirectObject, typeWildCard, &initialType,
+ NULL, 0, NULL);
+ if (err != noErr) {
+ sprintf(errString, "AEDoScriptHandler: GetParamDesc error %d", (int)err);
+ AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyErrorString,
+ typeChar, errString, strlen(errString));
+ return;
+ }
+
+ if (MissedAnyParameters((AppleEvent*)theDesc)) {
+ sprintf(errString, "AEDoScriptHandler: extra parameters");
+ AEPutParamPtr((AppleEvent*)[replyEvent aeDesc], keyErrorString,
+ typeChar,errString, strlen(errString));
+ return;
+ }
+
+ if (initialType == typeFileURL || initialType == typeAlias) {
+
+ /*
+ * This descriptor can be coerced to a file url. Construct a Tcl
+ * expression which passes the file path as a string argument to
+ * ::tk::mac::DoScriptFile.
+ */
+
+ if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeFileURL, &type,
+ (Ptr) URLBuffer, URL_MAX_LENGTH, &actual)) {
+ if (actual > 0) {
+ URLBuffer[actual] = '\0';
+ NSString *urlString = [NSString stringWithUTF8String:(char*)URLBuffer];
+ NSURL *fileURL = [NSURL URLWithString:urlString];
+ AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo));
+ Tcl_DString *scriptFileCommand = &AEInfo->command;
+ Tcl_DStringInit(scriptFileCommand);
+ Tcl_DStringAppend(scriptFileCommand, scriptFileProc, -1);
+ Tcl_DStringAppendElement(scriptFileCommand, [[fileURL path] UTF8String]);
+ AEInfo->interp = _eventInterp;
+ AEInfo->procedure = scriptFileProc;
+ AEInfo->replyEvent = nil;
+ Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
+ }
+ }
+ } else if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type,
+ NULL, 0, &actual)) {
+ /*
+ * The descriptor cannot be coerced to a file URL but can be coerced to
+ * text. Construct a Tcl expression which passes the text as a string
+ * argument to ::tk::mac::DoScriptText.
+ */
+
+ if (actual > 0) {
+ char *data = (char *)ckalloc(actual + 1);
+ if (noErr == AEGetParamPtr(theDesc, keyDirectObject,
+ typeUTF8Text, &type,
+ data, actual, NULL)) {
+ AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo));
+ Tcl_DString *scriptTextCommand = &AEInfo->command;
+ Tcl_DStringInit(scriptTextCommand);
+ Tcl_DStringAppend(scriptTextCommand, scriptTextProc, -1);
+ Tcl_DStringAppendElement(scriptTextCommand, data);
+ AEInfo->interp = _eventInterp;
+ AEInfo->procedure = scriptTextProc;
+ if (Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) {
+ AEInfo->replyEvent = replyEvent;
+ ProcessAppleEvent((ClientData)AEInfo);
+ } else {
+ AEInfo->replyEvent = nil;
+ Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
+ }
+ }
+ }
+ }
+}
+
+- (void)handleURLEvent:(NSAppleEventDescriptor*)event
+ withReplyEvent:(NSAppleEventDescriptor*)replyEvent
+{
+ NSString* url = [[event paramDescriptorForKeyword:keyDirectObject]
+ stringValue];
+ const char *cURL=[url UTF8String];
+ AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo));
+ Tcl_DString *launchCommand = &AEInfo->command;
+ (void)replyEvent;
+
+ Tcl_DStringInit(launchCommand);
+ Tcl_DStringAppend(launchCommand, launchURLProc, -1);
+ Tcl_DStringAppendElement(launchCommand, cURL);
+ AEInfo->interp = _eventInterp;
+ AEInfo->procedure = launchURLProc;
+ AEInfo->replyEvent = nil;
+ Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo);
+}
+
+@end
+
+#pragma mark -
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ProcessAppleEvent --
+ *
+ * Usually used as an idle task which evaluates a Tcl expression generated
+ * from an AppleEvent. If the AppleEventInfo passed as the client data
+ * has a non-null replyEvent, the result of evaluating the expression will
+ * be added to the reply. This must not be done when this function is
+ * called as an idle task, but is done when handling DoScriptText events
+ * when this function is called directly.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The expression will be evaluated and the clientData will be freed.
+ * The replyEvent may be modified to contain the result of evaluating
+ * a Tcl expression.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void ProcessAppleEvent(
+ ClientData clientData)
+{
+ int code;
+ AppleEventInfo *AEInfo = (AppleEventInfo*) clientData;
+ if (!AEInfo->interp ||
+ !Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) {
+ return;
+ }
+ code = Tcl_EvalEx(AEInfo->interp, Tcl_DStringValue(&AEInfo->command),
+ Tcl_DStringLength(&AEInfo->command), TCL_EVAL_GLOBAL);
if (code != TCL_OK) {
- Tcl_BackgroundException(interp, code);
+ Tcl_BackgroundException(AEInfo->interp, code);
}
- Tcl_DStringFree(&command);
+
+ if (AEInfo->replyEvent && code >= 0) {
+ int reslen;
+ const char *result = Tcl_GetStringFromObj(Tcl_GetObjResult(AEInfo->interp),
+ &reslen);
+ if (code == TCL_OK) {
+ AEPutParamPtr((AppleEvent*)[AEInfo->replyEvent aeDesc],
+ keyDirectObject, typeChar, result, reslen);
+ } else {
+ AEPutParamPtr((AppleEvent*)[AEInfo->replyEvent aeDesc],
+ keyErrorString, typeChar, result, reslen);
+ AEPutParamPtr((AppleEvent*)[AEInfo->replyEvent aeDesc],
+ keyErrorNumber, typeSInt32, (Ptr) &code, sizeof(int));
+ }
+ }
+ Tcl_DStringFree(&AEInfo->command);
+ ckfree(clientData);
}
/*
@@ -380,10 +442,11 @@ tkMacOSXProcessFiles(
void
TkMacOSXInitAppleEvents(
- Tcl_Interp *interp) /* not used */
+ Tcl_Interp *dummy) /* not used */
{
NSAppleEventManager *aeManager = [NSAppleEventManager sharedAppleEventManager];
static Boolean initialized = FALSE;
+ (void)dummy;
if (!initialized) {
initialized = TRUE;
@@ -409,12 +472,17 @@ TkMacOSXInitAppleEvents(
forEventClass:kCoreEventClass andEventID:kAEOpenDocuments];
[aeManager setEventHandler:NSApp
- andSelector:@selector(handleOpenDocumentsEvent:withReplyEvent:)
+ andSelector:@selector(handlePrintDocumentsEvent:withReplyEvent:)
forEventClass:kCoreEventClass andEventID:kAEPrintDocuments];
[aeManager setEventHandler:NSApp
andSelector:@selector(handleDoScriptEvent:withReplyEvent:)
forEventClass:kAEMiscStandards andEventID:kAEDoScript];
+
+ [aeManager setEventHandler:NSApp
+ andSelector:@selector(handleURLEvent:withReplyEvent:)
+ forEventClass:kInternetEventClass andEventID:kAEGetURL];
+
}
}
@@ -490,6 +558,7 @@ ReallyKillMe(
Tcl_Interp *interp = ((KillEvent *) eventPtr)->interp;
int quit = Tcl_FindCommand(interp, "::tk::mac::Quit", NULL, 0)!=NULL;
int code = Tcl_EvalEx(interp, quit ? "::tk::mac::Quit" : "exit", -1, TCL_EVAL_GLOBAL);
+ (void)flags;
if (code != TCL_OK) {
/*
@@ -529,8 +598,7 @@ MissedAnyParameters(
typeWildCard, &returnedType, NULL, 0, &actualSize);
return (err != errAEDescNotFound);
-}
-
+}
/*
* Local Variables:
diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c
index 38f4a70..07a20ac 100644
--- a/macosx/tkMacOSXImage.c
+++ b/macosx/tkMacOSXImage.c
@@ -21,9 +21,11 @@ int
_XInitImageFuncPtrs(
XImage *image)
{
+ (void)image;
+
return 0;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -42,6 +44,9 @@ _XInitImageFuncPtrs(
*/
static void ReleaseData(void *info, const void *data, size_t size) {
+ (void)data;
+ (void)size;
+
ckfree(info);
}
@@ -72,7 +77,7 @@ TkMacOSXCreateCGImageWithXImage(
if (image->bitmap_bit_order != MSBFirst) {
char *srcPtr = image->data + image->xoffset;
char *endPtr = srcPtr + len;
- char *destPtr = (data = ckalloc(len));
+ char *destPtr = (data = (char *)ckalloc(len));
while (srcPtr < endPtr) {
*destPtr++ = xBitReverseTable[(unsigned char)(*(srcPtr++))];
@@ -81,14 +86,15 @@ TkMacOSXCreateCGImageWithXImage(
data = memcpy(ckalloc(len), image->data + image->xoffset, len);
}
if (data) {
- provider = CGDataProviderCreateWithData(data, data, len, releaseData);
+ provider = CGDataProviderCreateWithData(data, data, len,
+ releaseData);
}
if (provider) {
- img = CGImageMaskCreate(image->width, image->height, bitsPerComponent,
- bitsPerPixel, image->bytes_per_line, provider, decode, 0);
+ img = CGImageMaskCreate(image->width, image->height,
+ bitsPerComponent, bitsPerPixel, image->bytes_per_line,
+ provider, decode, 0);
}
- } else if (image->format == ZPixmap && image->bits_per_pixel == 32) {
-
+ } else if ((image->format == ZPixmap) && (image->bits_per_pixel == 32)) {
/*
* Color image
*/
@@ -96,7 +102,6 @@ TkMacOSXCreateCGImageWithXImage(
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
if (image->width == 0 && image->height == 0) {
-
/*
* CGCreateImage complains on early macOS releases.
*/
@@ -106,11 +111,12 @@ TkMacOSXCreateCGImageWithXImage(
bitsPerComponent = 8;
bitsPerPixel = 32;
bitmapInfo = (image->byte_order == MSBFirst ?
- kCGBitmapByteOrder32Little : kCGBitmapByteOrder32Big);
+ kCGBitmapByteOrder32Little : kCGBitmapByteOrder32Big);
bitmapInfo |= kCGImageAlphaLast;
data = memcpy(ckalloc(len), image->data + image->xoffset, len);
if (data) {
- provider = CGDataProviderCreateWithData(data, data, len, releaseData);
+ provider = CGDataProviderCreateWithData(data, data, len,
+ releaseData);
}
if (provider) {
img = CGImageCreate(image->width, image->height, bitsPerComponent,
@@ -127,7 +133,6 @@ TkMacOSXCreateCGImageWithXImage(
return img;
}
-
/*
*----------------------------------------------------------------------
*
@@ -176,18 +181,18 @@ XGetImage(
unsigned int scalefactor=1, scaled_height=height, scaled_width=width;
NSWindow *win = TkMacOSXDrawableWindow(drawable);
static enum {unknown, no, yes} has_retina = unknown;
+ (void)plane_mask;
if (win && has_retina == unknown) {
#ifdef __clang__
- has_retina = [win respondsToSelector:@selector(backingScaleFactor)]?
- yes : no;
+ has_retina = [win respondsToSelector:@selector(backingScaleFactor)] ?
+ yes : no;
#else
has_retina = no;
#endif
}
if (has_retina == yes) {
-
/*
* We only allow scale factors 1 or 2, as Apple currently does.
*/
@@ -205,7 +210,7 @@ XGetImage(
}
bitmap_rep = TkMacOSXBitmapRepFromDrawableRect(drawable,
- x, y, width, height);
+ x, y, width, height);
if (!bitmap_rep) {
TkMacOSXDbgMsg("XGetImage: Failed to construct NSBitmapRep");
return NULL;
@@ -213,13 +218,13 @@ XGetImage(
bitmap_fmt = [bitmap_rep bitmapFormat];
size = [bitmap_rep bytesPerPlane];
bytes_per_row = [bitmap_rep bytesPerRow];
- bitmap = ckalloc(size);
- if (!bitmap ||
- (bitmap_fmt != 0 && bitmap_fmt != 1) ||
- [bitmap_rep samplesPerPixel] != 4 ||
- [bitmap_rep isPlanar] != 0 ||
- bytes_per_row < 4 * scaled_width ||
- size != bytes_per_row*scaled_height ) {
+ bitmap = (char *)ckalloc(size);
+ if (!bitmap
+ || (bitmap_fmt != 0 && bitmap_fmt != 1)
+ || [bitmap_rep samplesPerPixel] != 4
+ || [bitmap_rep isPlanar] != 0
+ || bytes_per_row < 4 * scaled_width
+ || size != bytes_per_row * scaled_height) {
TkMacOSXDbgMsg("XGetImage: Unrecognized bitmap format");
CFRelease(bitmap_rep);
return NULL;
@@ -228,8 +233,8 @@ XGetImage(
CFRelease(bitmap_rep);
/*
- * When Apple extracts a bitmap from an NSView, it may be in
- * either BGRA or ABGR format. For an XImage we need RGBA.
+ * When Apple extracts a bitmap from an NSView, it may be in either
+ * BGRA or ABGR format. For an XImage we need RGBA.
*/
struct pixel_fmt pixel = bitmap_fmt == 0 ? bgra : abgr;
@@ -248,16 +253,16 @@ XGetImage(
}
}
imagePtr = XCreateImage(display, NULL, depth, format, offset,
- (char*)bitmap, scaled_width, scaled_height,
- bitmap_pad, bytes_per_row);
+ (char*) bitmap, scaled_width, scaled_height,
+ bitmap_pad, bytes_per_row);
if (scalefactor == 2) {
imagePtr->pixelpower = 1;
}
} else {
/*
- * There are some calls to XGetImage in the generic Tk
- * code which pass an XYPixmap rather than a ZPixmap.
- * XYPixmaps should be handled here.
+ * There are some calls to XGetImage in the generic Tk code which pass
+ * an XYPixmap rather than a ZPixmap. XYPixmaps should be handled
+ * here.
*/
TkMacOSXDbgMsg("XGetImage does not handle XYPixmaps at the moment.");
}
@@ -323,40 +328,40 @@ ImageGetPixel(
+ (((image->xoffset + x) * image->bits_per_pixel) / NBBY);
switch (image->bits_per_pixel) {
- case 32: {
- r = (*((unsigned int*) srcPtr) >> 16) & 0xff;
- g = (*((unsigned int*) srcPtr) >> 8) & 0xff;
- b = (*((unsigned int*) srcPtr) ) & 0xff;
- /*if (image->byte_order == LSBFirst) {
- r = srcPtr[2]; g = srcPtr[1]; b = srcPtr[0];
- } else {
- r = srcPtr[1]; g = srcPtr[2]; b = srcPtr[3];
- }*/
- break;
- }
- case 16:
- r = (*((unsigned short*) srcPtr) >> 7) & 0xf8;
- g = (*((unsigned short*) srcPtr) >> 2) & 0xf8;
- b = (*((unsigned short*) srcPtr) << 3) & 0xf8;
- break;
- case 8:
- r = (*srcPtr << 2) & 0xc0;
- g = (*srcPtr << 4) & 0xc0;
- b = (*srcPtr << 6) & 0xc0;
- r |= r >> 2 | r >> 4 | r >> 6;
- g |= g >> 2 | g >> 4 | g >> 6;
- b |= b >> 2 | b >> 4 | b >> 6;
- break;
- case 4: {
- unsigned char c = (x % 2) ? *srcPtr : (*srcPtr >> 4);
- r = (c & 0x04) ? 0xff : 0;
- g = (c & 0x02) ? 0xff : 0;
- b = (c & 0x01) ? 0xff : 0;
- break;
- }
- case 1:
- r = g = b = ((*srcPtr) & (0x80 >> (x % 8))) ? 0xff : 0;
- break;
+ case 32:
+ r = (*((unsigned int*) srcPtr) >> 16) & 0xff;
+ g = (*((unsigned int*) srcPtr) >> 8) & 0xff;
+ b = (*((unsigned int*) srcPtr) ) & 0xff;
+ /*if (image->byte_order == LSBFirst) {
+ r = srcPtr[2]; g = srcPtr[1]; b = srcPtr[0];
+ } else {
+ r = srcPtr[1]; g = srcPtr[2]; b = srcPtr[3];
+ }*/
+ break;
+ case 16:
+ r = (*((unsigned short*) srcPtr) >> 7) & 0xf8;
+ g = (*((unsigned short*) srcPtr) >> 2) & 0xf8;
+ b = (*((unsigned short*) srcPtr) << 3) & 0xf8;
+ break;
+ case 8:
+ r = (*srcPtr << 2) & 0xc0;
+ g = (*srcPtr << 4) & 0xc0;
+ b = (*srcPtr << 6) & 0xc0;
+ r |= r >> 2 | r >> 4 | r >> 6;
+ g |= g >> 2 | g >> 4 | g >> 6;
+ b |= b >> 2 | b >> 4 | b >> 6;
+ break;
+ case 4: {
+ unsigned char c = (x % 2) ? *srcPtr : (*srcPtr >> 4);
+
+ r = (c & 0x04) ? 0xff : 0;
+ g = (c & 0x02) ? 0xff : 0;
+ b = (c & 0x01) ? 0xff : 0;
+ break;
+ }
+ case 1:
+ r = g = b = ((*srcPtr) & (0x80 >> (x % 8))) ? 0xff : 0;
+ break;
}
}
return (PIXEL_MAGIC << 24) | (r << 16) | (g << 8) | b;
@@ -389,6 +394,7 @@ ImagePutPixel(
unsigned char *dstPtr = ((unsigned char*) image->data)
+ (y * image->bytes_per_line)
+ (((image->xoffset + x) * image->bits_per_pixel) / NBBY);
+
if (image->bits_per_pixel == 32) {
*((unsigned int*) dstPtr) = pixel;
} else {
@@ -420,7 +426,7 @@ ImagePutPixel(
}
return 0;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -451,8 +457,10 @@ XCreateImage(
int bytes_per_line)
{
XImage *ximage;
+ (void)visual;
+
display->request++;
- ximage = ckalloc(sizeof(XImage));
+ ximage = (XImage *)ckalloc(sizeof(XImage));
ximage->height = height;
ximage->width = width;
@@ -461,9 +469,12 @@ XCreateImage(
ximage->format = format;
ximage->data = data;
ximage->obdata = NULL;
- /* The default pixelpower is 0. This must be explicitly set to 1 in the
+
+ /*
+ * The default pixelpower is 0. This must be explicitly set to 1 in the
* case of an XImage extracted from a Retina display.
*/
+
ximage->pixelpower = 0;
if (format == ZPixmap) {
@@ -476,7 +487,10 @@ XCreateImage(
if (bitmap_pad) {
ximage->bitmap_pad = bitmap_pad;
} else {
- /* Use 16 byte alignment for best Quartz perfomance */
+ /*
+ * Use 16 byte alignment for best Quartz perfomance.
+ */
+
ximage->bitmap_pad = 128;
}
if (bytes_per_line) {
@@ -509,11 +523,11 @@ XCreateImage(
/*
*----------------------------------------------------------------------
*
- * TkPutImage --
+ * XPutImage --
*
- * Copies a rectangular subimage of an XImage into a drawable.
- * Currently this is only called by TkImgPhotoDisplay, using
- * a Window as the drawable.
+ * Copies a rectangular subimage of an XImage into a drawable. Currently
+ * this is only called by TkImgPhotoDisplay, using a Window as the
+ * drawable.
*
* Results:
* None.
@@ -525,9 +539,7 @@ XCreateImage(
*/
int
-TkPutImage(
- unsigned long *colors, /* Unused on Macintosh. */
- int ncolors, /* Unused on Macintosh. */
+XPutImage(
Display* display, /* Display. */
Drawable drawable, /* Drawable to place image on. */
GC gc, /* GC to use. */
@@ -559,13 +571,15 @@ TkPutImage(
}
if (img) {
- /* If the XImage has big pixels, the source is rescaled to reflect
+ /*
+ * If the XImage has big pixels, the source is rescaled to reflect
* the actual pixel dimensions. This is not currently used, but
* could arise if the image were copied from a retina monitor and
* redrawn on an ordinary monitor.
*/
int pp = image->pixelpower;
+
bounds = CGRectMake(0, 0, image->width, image->height);
srcRect = CGRectMake(src_x<<pp, src_y<<pp, width<<pp, height<<pp);
dstRect = CGRectMake(dest_x, dest_y, width, height);
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 3c02d92..881fb1b 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -28,6 +28,13 @@ static char tkLibPath[PATH_MAX + 1] = "";
static char scriptPath[PATH_MAX + 1] = "";
+/*
+ * Forward declarations...
+ */
+
+static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
+ int objc, Tcl_Obj *const objv[]);
+
#pragma mark TKApplication(TKInit)
@implementation TKApplication
@@ -45,7 +52,7 @@ static char scriptPath[PATH_MAX + 1] = "";
@implementation TKApplication(TKInit)
- (void) _resetAutoreleasePool
{
- if([self poolLock] == 0) {
+ if ([self poolLock] == 0) {
[_mainPool drain];
_mainPool = [NSAutoreleasePool new];
} else {
@@ -75,7 +82,7 @@ static char scriptPath[PATH_MAX + 1] = "";
#define observe(n, s) \
[nc addObserver:self selector:@selector(s) name:(n) object:nil]
observe(NSApplicationDidBecomeActiveNotification, applicationActivate:);
- observe(NSApplicationDidResignActiveNotification, applicationDeactivate:);
+ observe(NSApplicationWillResignActiveNotification, applicationDeactivate:);
observe(NSApplicationDidUnhideNotification, applicationShowHide:);
observe(NSApplicationDidHideNotification, applicationShowHide:);
observe(NSApplicationDidChangeScreenParametersNotification, displayChanged:);
@@ -85,6 +92,7 @@ static char scriptPath[PATH_MAX + 1] = "";
-(void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
+ (void)aNotification;
/*
* Initialize notifications.
@@ -116,19 +124,25 @@ static char scriptPath[PATH_MAX + 1] = "";
-(void)applicationDidFinishLaunching:(NSNotification *)notification
{
+ (void)notification;
+
/*
- * It is not safe to force activation of the NSApp until this
- * method is called. Activating too early can cause the menu
- * bar to be unresponsive.
+ * It is not safe to force activation of the NSApp until this method is
+ * called. Activating too early can cause the menu bar to be unresponsive.
+ * The call to activateIgnoringOtherApps was moved here to avoid this.
+ * However, with the release of macOS 10.15 (Catalina) that was no longer
+ * sufficient. (See ticket bf93d098d7.) The call to setActivationPolicy
+ * needed to be moved into this function as well.
*/
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
[NSApp activateIgnoringOtherApps: YES];
/*
- * Process events to ensure that the root window is fully
- * initialized. See ticket 56a1823c73.
+ * Process events to ensure that the root window is fully initialized. See
+ * ticket 56a1823c73.
*/
-
+
[NSApp _lockAutoreleasePool];
while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {}
[NSApp _unlockAutoreleasePool];
@@ -151,7 +165,7 @@ static char scriptPath[PATH_MAX + 1] = "";
* Record the OS version we are running on.
*/
int minorVersion;
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 101000
Gestalt(gestaltSystemVersionMinor, (SInt32*)&minorVersion);
#else
NSOperatingSystemVersion systemVersion;
@@ -173,15 +187,10 @@ static char scriptPath[PATH_MAX + 1] = "";
[self setDelegate:self];
/*
- * Make sure we are allowed to open windows.
- */
-
- [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
-
- /*
* If no icon has been set from an Info.plist file, use the Wish icon from
* the Tk framework.
*/
+
NSString *iconFile = [[NSBundle mainBundle] objectForInfoDictionaryKey:
@"CFBundleIconFile"];
if (!iconFile) {
@@ -310,8 +319,8 @@ TkpInit(
}
/*
- * Instantiate our NSApplication object. This needs to be
- * done before we check whether to open a console window.
+ * Instantiate our NSApplication object. This needs to be done before
+ * we check whether to open a console window.
*/
NSAutoreleasePool *pool = [NSAutoreleasePool new];
@@ -325,8 +334,44 @@ TkpInit(
[TKApplication sharedApplication];
[pool drain];
[NSApp _setup:interp];
+
+ /*
+ * WARNING: The finishLaunching method runs asynchronously, apparently
+ * in a separate thread. This creates a race between the
+ * initialization of the NSApplication and the initialization of Tk.
+ * If Tk wins the race bad things happen with the root window (see
+ * below). If the NSApplication wins then an AppleEvent created during
+ * launch, e.g. by dropping a file icon on the application icon, will
+ * be delivered before the procedure meant to to handle the AppleEvent
+ * has been defined. This is now handled by processing the AppleEvent
+ * as an idle task. See tkMacOSXHLEvents.c.
+ */
+
[NSApp finishLaunching];
+ /*
+ * Create a Tk event source based on the Appkit event queue.
+ */
+
+ Tk_MacOSXSetupTkNotifier();
+
+ /*
+ * If Tk initialization wins the race, the root window is mapped before
+ * the NSApplication is initialized. This can cause bad things to
+ * happen. The root window can open off screen with no way to make it
+ * appear on screen until the app icon is clicked. This will happen if
+ * a Tk application opens a modal window in its startup script (see
+ * ticket 56a1823c73). In other cases, an empty root window can open
+ * on screen and remain visible for a noticeable amount of time while
+ * the Tk initialization finishes (see ticket d1989fb7cf). The call
+ * below forces Tk to block until the Appkit event queue has been
+ * created. This seems to be sufficient to ensure that the
+ * NSApplication initialization wins the race, avoiding these bad
+ * window behaviors.
+ */
+
+ Tcl_DoOneEvent(TCL_WINDOW_EVENTS | TCL_DONT_WAIT);
+
/*
* If we don't have a TTY and stdin is a special character file of
* length 0, (e.g. /dev/null, which is what Finder sets when double
@@ -342,8 +387,8 @@ TkpInit(
Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDERR));
/*
- * Only show the console if we don't have a startup script
- * and tcl_interactive hasn't been set already.
+ * Only show the console if we don't have a startup script and
+ * tcl_interactive hasn't been set already.
*/
if (Tcl_GetStartupScript(NULL) == NULL) {
@@ -360,9 +405,14 @@ TkpInit(
}
}
- }
+ /*
+ * Initialize the NSServices object here. Apple's docs say to do this
+ * in applicationDidFinishLaunching, but the Tcl interpreter is not
+ * initialized until this function call.
+ */
- Tk_MacOSXSetupTkNotifier();
+ TkMacOSXServices_Init(interp);
+ }
if (tkLibPath[0] != '\0') {
Tcl_SetVar2(interp, "tk_library", NULL, tkLibPath, TCL_GLOBAL_ONLY);
@@ -377,15 +427,8 @@ TkpInit(
TkMacOSXStandardAboutPanelObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap",
TkMacOSXIconBitmapObjCmd, NULL, NULL);
-
- /*
- * Workaround for 3efbe4a397; console not accepting keyboard input on 10.14
- * if displayed before main window. This places console in background and it
- * accepts input after being raised.
- */
-
- while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}
-
+ Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath",
+ TkMacOSXGetAppPathCmd, NULL, NULL);
return TCL_OK;
}
@@ -429,6 +472,56 @@ TkpGetAppName(
/*
*----------------------------------------------------------------------
*
+ * TkMacOSXGetAppPathCmd --
+ *
+ * Returns the path of the Wish application bundle.
+ *
+ * Results:
+ * Returns the application path.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TkMacOSXGetAppPathCmd(
+ ClientData dummy,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *const objv[])
+{
+ (void)dummy;
+
+ if (objc != 1) {
+ Tcl_WrongNumArgs(interp, 1, objv, NULL);
+ return TCL_ERROR;
+ }
+
+ /*
+ * Get the application path URL and convert it to a string path reference.
+ */
+
+ CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());
+ CFStringRef appPath =
+ CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
+
+ /*
+ * Convert (and copy) the string reference into a Tcl result.
+ */
+
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ CFStringGetCStringPtr(appPath, CFStringGetSystemEncoding()), -1));
+
+ CFRelease(mainBundleURL);
+ CFRelease(appPath);
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkpDisplayWarning --
*
* This routines is called from Tk_Main to display warning messages that
@@ -492,7 +585,7 @@ TkMacOSXDefaultStartupScript(void)
CFURLRef scriptFldrURL;
char startupScript[PATH_MAX + 1];
- if (CFURLGetFileSystemRepresentation (appMainURL, true,
+ if (CFURLGetFileSystemRepresentation(appMainURL, true,
(unsigned char *) startupScript, PATH_MAX)) {
Tcl_SetStartupScript(Tcl_NewStringObj(startupScript,-1), NULL);
scriptFldrURL = CFURLCreateCopyDeletingLastPathComponent(NULL,
@@ -533,6 +626,8 @@ TkMacOSXGetNamedSymbol(
const char* symbol)
{
void *addr = dlsym(RTLD_NEXT, symbol);
+ (void)module;
+
if (!addr) {
(void) dlerror(); /* Clear dlfcn error state */
}
@@ -540,46 +635,6 @@ TkMacOSXGetNamedSymbol(
}
/*
- *----------------------------------------------------------------------
- *
- * TkMacOSXGetStringObjFromCFString --
- *
- * Get a string object from a CFString as efficiently as possible.
- *
- * Results:
- * New string object or NULL if conversion failed.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-MODULE_SCOPE Tcl_Obj*
-TkMacOSXGetStringObjFromCFString(
- CFStringRef str)
-{
- Tcl_Obj *obj = NULL;
- const char *c = CFStringGetCStringPtr(str, kCFStringEncodingUTF8);
-
- if (c) {
- obj = Tcl_NewStringObj(c, -1);
- } else {
- CFRange all = CFRangeMake(0, CFStringGetLength(str));
- CFIndex len;
-
- if (CFStringGetBytes(str, all, kCFStringEncodingUTF8, 0, false, NULL,
- 0, &len) > 0 && len < INT_MAX) {
- obj = Tcl_NewObj();
- Tcl_SetObjLength(obj, len);
- CFStringGetBytes(str, all, kCFStringEncodingUTF8, 0, false,
- (UInt8*) obj->bytes, len, NULL);
- }
- }
- return obj;
-}
-
-/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index d942286..bd669c0 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -71,6 +71,7 @@ struct TkWindowPrivate {
* gone. */
struct TkWindowPrivate *toplevel;
/* Pointer to the toplevel datastruct. */
+ CGFloat fillRGBA[4]; /* Background used by the ttk FillElement */
int flags; /* Various state see defines below. */
};
typedef struct TkWindowPrivate MacDrawable;
@@ -86,6 +87,7 @@ typedef struct TkWindowPrivate MacDrawable;
#define TK_IS_PIXMAP 0x10
#define TK_IS_BW_PIXMAP 0x20
#define TK_DO_NOT_DRAW 0x40
+#define TTK_HAS_CONTRASTING_BG 0x80
/*
* I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags
@@ -189,18 +191,15 @@ MODULE_SCOPE void TkpFreeGCCache(GC gc);
*/
MODULE_SCOPE void TkMacOSXDefaultStartupScript(void);
-#if 0
-MODULE_SCOPE int XSetClipRectangles(Display *d, GC gc, int clip_x_origin,
- int clip_y_origin, XRectangle* rectangles, int n, int ordering);
-#endif
MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x,
int y, int width, int height);
-MODULE_SCOPE void TkpRetainRegion(TkRegion r);
-MODULE_SCOPE void TkpReleaseRegion(TkRegion r);
+MODULE_SCOPE void TkpRetainRegion(Region r);
+MODULE_SCOPE void TkpReleaseRegion(Region r);
MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta);
MODULE_SCOPE Bool TkpAppIsDrawing(void);
MODULE_SCOPE void TkpDisplayWindow(Tk_Window tkwin);
-MODULE_SCOPE Bool TkTestAppIsDrawing(void);
+MODULE_SCOPE Bool TkTestLogDisplay(void);
+MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin);
/*
* Include the stubbed internal platform-specific API.
@@ -209,3 +208,12 @@ MODULE_SCOPE Bool TkTestAppIsDrawing(void);
#include "tkIntPlatDecls.h"
#endif /* _TKMACINT */
+
+/*
+ * Local Variables:
+ * mode: objc
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c
index 543e7ab..cd369ed 100644
--- a/macosx/tkMacOSXKeyEvent.c
+++ b/macosx/tkMacOSXKeyEvent.c
@@ -7,39 +7,38 @@
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
* Copyright (c) 2012 Adrian Robert.
- * Copyright 2015 Marc Culler.
+ * Copyright 2015-2020 Marc Culler.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
-#include "tkMacOSXEvent.h"
+#include "tkMacOSXInt.h"
#include "tkMacOSXConstants.h"
+#include "tkMacOSXWm.h"
+
+/*
+ * See tkMacOSXPrivate.h for macros related to key event processing.
+ */
/*
#ifdef TK_MAC_DEBUG
#define TK_MAC_DEBUG_KEYBOARD
#endif
*/
-#define NS_KEYLOG 0
-static Tk_Window keyboardGrabWinPtr = NULL;
- /* Current keyboard grab window. */
-static NSWindow *keyboardGrabNSWindow = nil;
- /* NSWindow for the current keyboard grab window. */
+#define NS_KEYLOG 0
+#define XEVENT_MOD_MASK (ControlMask | Mod1Mask | Mod3Mask | Mod4Mask)
+static Tk_Window keyboardGrabWinPtr = NULL; /* Current keyboard grab window. */
+static NSWindow *keyboardGrabNSWindow = nil; /* Its underlying NSWindow.*/
static NSModalSession modalSession = nil;
-
static BOOL processingCompose = NO;
-static BOOL finishedCompose = NO;
-
+static Tk_Window composeWin = NULL;
static int caret_x = 0, caret_y = 0, caret_height = 0;
-
-static void setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state);
-static unsigned isFunctionKey(unsigned int code);
-
-unsigned short releaseCode;
-
+static void setupXEvent(XEvent *xEvent, Tk_Window tkwin, NSUInteger modifiers);
+static void setXEventPoint(XEvent *xEvent, Tk_Window tkwin, NSWindow *w);
+static NSUInteger textInputModifiers;
#pragma mark TKApplication(TKKeyEvent)
@@ -50,423 +49,629 @@ unsigned short releaseCode;
#ifdef TK_MAC_DEBUG_EVENTS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
#endif
- NSWindow* w;
- NSEventType type = [theEvent type];
+ NSWindow *w = [theEvent window];
+ TkWindow *winPtr = TkMacOSXGetTkWindow(w), *grabWinPtr, *focusWinPtr;
+ Tk_Window tkwin = (Tk_Window) winPtr;
+ NSEventType type = [theEvent type];
+ NSUInteger virtual = [theEvent keyCode];
NSUInteger modifiers = ([theEvent modifierFlags] &
NSDeviceIndependentModifierFlagsMask);
- NSUInteger len = 0;
- BOOL repeat = NO;
- unsigned short keyCode = [theEvent keyCode];
- NSString *characters = nil, *charactersIgnoringModifiers = nil;
+ XEvent xEvent;
+ MacKeycode macKC;
+ UniChar keychar = 0;
+ Bool can_input_text, has_modifiers = NO, use_text_input = NO;
static NSUInteger savedModifiers = 0;
- static NSMutableArray *nsEvArray;
+ static NSMutableArray *nsEvArray = nil;
- if (nsEvArray == nil)
- {
+ if (nsEvArray == nil) {
nsEvArray = [[NSMutableArray alloc] initWithCapacity: 1];
processingCompose = NO;
- }
+ }
+ if (!winPtr) {
+ return theEvent;
+ }
- w = [theEvent window];
- TkWindow *winPtr = TkMacOSXGetTkWindow(w);
- Tk_Window tkwin = (Tk_Window) winPtr;
- XEvent xEvent;
+ /*
+ * If a local grab is in effect, key events for windows in the
+ * grabber's application are redirected to the grabber. Key events
+ * for other applications are delivered normally. If a global
+ * grab is in effect all key events are redirected to the grabber.
+ */
- if (!winPtr) {
+ grabWinPtr = winPtr->dispPtr->grabWinPtr;
+ if (grabWinPtr) {
+ if (winPtr->dispPtr->grabFlags || /* global grab */
+ grabWinPtr->mainPtr == winPtr->mainPtr){ /* same application */
+ winPtr =winPtr->dispPtr->focusPtr;
+ tkwin = (Tk_Window) winPtr;
+ }
+ }
+
+ /*
+ * Extract the unicode character from KeyUp and KeyDown events.
+ */
+
+ if (type == NSKeyUp || type == NSKeyDown) {
+ if ([[theEvent characters] length] > 0) {
+ keychar = [[theEvent characters] characterAtIndex:0];
+
+ /*
+ * Currently, real keys always send BMP characters, but who knows?
+ */
+
+ if (CFStringIsSurrogateHighCharacter(keychar)) {
+ UniChar lowChar = [[theEvent characters] characterAtIndex:1];
+ keychar = CFStringGetLongCharacterForSurrogatePair(
+ keychar, lowChar);
+ }
+ } else {
+
+ /*
+ * This is a dead key, such as Option-e, so it should go to the
+ * TextInputClient.
+ */
+
+ use_text_input = YES;
+ }
+
+ /*
+ * Apple uses 0x10 for unrecognized keys.
+ */
+
+ if (keychar == 0x10) {
+ keychar = UNKNOWN_KEYCHAR;
+ }
+
+#if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1
+ TKLog(@"-[%@(%p) %s] repeat=%d mods=%x char=%x code=%lu c=%d type=%d",
+ [self class], self, _cmd,
+ (type == NSKeyDown) && [theEvent isARepeat], modifiers, keychar,
+ virtual, w, type);
+#endif
+
+ }
+
+ /*
+ * Build a skeleton XEvent. We need to build it here, even if we will not
+ * send it, so we can pass it to TkFocusKeyEvent to determine whether the
+ * target widget can input text.
+ */
+
+ setupXEvent(&xEvent, tkwin, modifiers);
+ has_modifiers = xEvent.xkey.state & XEVENT_MOD_MASK;
+ focusWinPtr = TkFocusKeyEvent(winPtr, &xEvent);
+ if (focusWinPtr == NULL) {
+ TKContentView *contentView = [w contentView];
+
+ /*
+ * This NSEvent is being sent to a window which does not have focus.
+ * This could mean, for example, that the user deactivated the Tk app
+ * while the NSTextInputClient's popup character selection window was
+ * still open. We attempt to abandon any ongoing composition operation
+ * and discard the event.
+ */
+
+ [contentView cancelComposingText];
return theEvent;
}
+ can_input_text = ((focusWinPtr->flags & TK_CAN_INPUT_TEXT) != 0);
+
+#if (NS_KEYLOG)
+ TKLog(@"keyDown: %s compose sequence.\n",
+ processingCompose == YES ? "Continue" : "Begin");
+#endif
+
+ /*
+ * Decide whether this event should be processed with the NSTextInputClient
+ * protocol.
+ */
+
+ if (processingCompose ||
+ (type == NSKeyDown && can_input_text && !has_modifiers &&
+ IS_PRINTABLE(keychar))
+ ) {
+ use_text_input = YES;
+ }
/*
- * Control-Tab and Control-Shift-Tab are used to switch tabs in a tabbed
- * window. We do not want to generate an Xevent for these since that might
- * cause the deselected tab to be reactivated.
+ * If we are processing this KeyDown event as an NSTextInputClient we do
+ * not queue an XEvent. We pass the NSEvent to our interpretKeyEvents
+ * method. When the composition sequence is complete, the callback method
+ * insertText: replacementRange will be called. That method generates a
+ * keyPress XEvent with the selected character.
*/
- if (keyCode == 48 && (modifiers & NSControlKeyMask) == NSControlKeyMask) {
+ if (use_text_input) {
+ textInputModifiers = modifiers;
+
+ /*
+ * In IME the Enter key is used to terminate a composition sequence.
+ * When there are multiple choices of input text available, and the
+ * user's selected choice is not the default, it may be necessary to
+ * hit the Enter key multiple times before the text is accepted and
+ * rendered (See ticket 39de9677aa]). So when sending an Enter key
+ * during composition, we continue sending Enter keys until the
+ * inputText method has cleared the processingCompose flag.
+ */
+
+ if (processingCompose && [theEvent keyCode] == 36) {
+ [nsEvArray addObject: theEvent];
+ while(processingCompose) {
+ [[w contentView] interpretKeyEvents: nsEvArray];
+ }
+ [nsEvArray removeObject: theEvent];
+ } else {
+ [nsEvArray addObject: theEvent];
+ [[w contentView] interpretKeyEvents: nsEvArray];
+ [nsEvArray removeObject: theEvent];
+ }
return theEvent;
}
+ /*
+ * We are not handling this event as an NSTextInputClient, so we need to
+ * finish constructing the XEvent and queue it.
+ */
+
+ macKC.v.o_s = ((modifiers & NSShiftKeyMask ? INDEX_SHIFT : 0) |
+ (modifiers & NSAlternateKeyMask ? INDEX_OPTION : 0));
+ macKC.v.virtual = virtual;
switch (type) {
+ case NSFlagsChanged:
+
+ /*
+ * This XEvent is a simulated KeyPress or KeyRelease event for a
+ * modifier key. To determine the type, note that the highest bit
+ * where the flags differ is 1 if and only if it is a KeyPress. The
+ * modifiers are saved so we can detect the next flag change.
+ */
+
+ xEvent.xany.type = modifiers > savedModifiers ? KeyPress : KeyRelease;
+ savedModifiers = modifiers;
+
+ /*
+ * Set the keychar to MOD_KEYCHAR as a signal to TkpGetKeySym (see
+ * tkMacOSXKeyboard.c) that this is a modifier key event.
+ */
+
+ keychar = MOD_KEYCHAR;
+ break;
case NSKeyUp:
- /*Fix for bug #1ba71a86bb: key release firing on key press.*/
- setupXEvent(&xEvent, w, 0);
xEvent.xany.type = KeyRelease;
- xEvent.xkey.keycode = releaseCode;
- xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
+ break;
case NSKeyDown:
- repeat = [theEvent isARepeat];
- characters = [theEvent characters];
- charactersIgnoringModifiers = [theEvent charactersIgnoringModifiers];
- len = [charactersIgnoringModifiers length];
- case NSFlagsChanged:
-
-#if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1
- TKLog(@"-[%@(%p) %s] r=%d mods=%u '%@' '%@' code=%u c=%d %@ %d", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode,([charactersIgnoringModifiers length] == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0], w, type);
-#endif
+ xEvent.xany.type = KeyPress;
break;
-
default:
return theEvent; /* Unrecognized key event. */
}
+ macKC.v.keychar = keychar;
+ xEvent.xkey.keycode = macKC.uint;
+ setXEventPoint(&xEvent, tkwin, w);
- /* Create an Xevent to add to the Tk queue. */
- if (!processingCompose) {
- unsigned int state = 0;
-
- if (modifiers & NSAlphaShiftKeyMask) {
- state |= LockMask;
- }
- if (modifiers & NSShiftKeyMask) {
- state |= ShiftMask;
- }
- if (modifiers & NSControlKeyMask) {
- state |= ControlMask;
- }
- if (modifiers & NSCommandKeyMask) {
- state |= Mod1Mask; /* command key */
- }
- if (modifiers & NSAlternateKeyMask) {
- state |= Mod2Mask; /* option key */
- }
- if (modifiers & NSNumericPadKeyMask) {
- state |= Mod3Mask;
- }
- if (modifiers & NSFunctionKeyMask) {
- state |= Mod4Mask;
- }
-
- /*
- * Events are only received for the front Window on the Macintosh.
- * So to build an XEvent we look up the Tk window associated to the
- * Front window. If a different window has a local grab we ignore
- * the event.
- */
-
- TkWindow *winPtr = TkMacOSXGetTkWindow(w);
- Tk_Window tkwin = (Tk_Window) winPtr;
-
- if (tkwin) {
- TkWindow *grabWinPtr = winPtr->dispPtr->grabWinPtr;
- if (grabWinPtr &&
- grabWinPtr != winPtr &&
- !winPtr->dispPtr->grabFlags && /* this means the grab is local. */
- grabWinPtr->mainPtr == winPtr->mainPtr) {
- return theEvent;
- }
- } else {
- tkwin = (Tk_Window) winPtr->dispPtr->focusPtr;
- }
- if (!tkwin) {
- TkMacOSXDbgMsg("tkwin == NULL");
- return theEvent; /* Give up. No window for this event. */
- }
-
- /*
- * If it's a function key, or we have modifiers other than Shift or Alt,
- * pass it straight to Tk. Otherwise we'll send for input processing.
- */
-
- int code = (len == 0) ?
- 0 : [charactersIgnoringModifiers characterAtIndex: 0];
- if (type != NSKeyDown || isFunctionKey(code)
- || (len > 0 && state & (ControlMask | Mod1Mask | Mod3Mask | Mod4Mask))) {
-
- XEvent xEvent;
- setupXEvent(&xEvent, w, state);
-
- if (type == NSFlagsChanged) {
- if (savedModifiers > modifiers) {
- xEvent.xany.type = KeyRelease;
- } else {
- xEvent.xany.type = KeyPress;
- }
-
- /*
- * Use special '-1' to signify a special keycode to our platform
- * specific code in tkMacOSXKeyboard.c. This is rather like what
- * happens on Windows.
- */
-
- xEvent.xany.send_event = -1;
-
- /*
- * Set keycode (which was zero) to the changed modifier
- */
-
- xEvent.xkey.keycode = (modifiers ^ savedModifiers);
- } else {
- if (type == NSKeyUp || repeat) {
- xEvent.xany.type = KeyRelease;
- } else {
- xEvent.xany.type = KeyPress;
- }
-
- /* For command key, take input manager's word so things
- like dvorak / qwerty layout work. */
- if ((modifiers & NSCommandKeyMask) == NSCommandKeyMask
- && (modifiers & NSAlternateKeyMask) != NSAlternateKeyMask
- && len > 0 && !isFunctionKey(code)) {
- // head off keycode-based translation in tkMacOSXKeyboard.c
- xEvent.xkey.nbytes = [characters length]; //len
- }
-
- if ([characters length] > 0) {
- xEvent.xkey.keycode =
- (keyCode << 16) | (UInt16) [characters characterAtIndex:0];
- if (![characters getCString:xEvent.xkey.trans_chars
- maxLength:XMaxTransChars encoding:NSUTF8StringEncoding]) {
- /* prevent SF bug 2907388 (crash on some composite chars) */
- //PENDING: we might not need this anymore
- TkMacOSXDbgMsg("characters too long");
- return theEvent;
- }
- }
-
- if (repeat) {
- Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
- xEvent.xany.type = KeyPress;
- xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
- }
- }
- Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
- savedModifiers = modifiers;
- return theEvent;
- } /* if send straight to TK */
-
- } /* if not processing compose */
-
- if (type == NSKeyDown) {
- if (NS_KEYLOG)
- fprintf (stderr, "keyDown: %s compose sequence.\n",
- processingCompose == YES ? "Continue" : "Begin");
- processingCompose = YES;
- [nsEvArray addObject: theEvent];
- [[w contentView] interpretKeyEvents: nsEvArray];
- [nsEvArray removeObject: theEvent];
- }
-
- savedModifiers = modifiers;
+ /*
+ * Finally we can queue the XEvent, inserting a KeyRelease before a
+ * repeated KeyPress.
+ */
+ if (type == NSKeyDown && [theEvent isARepeat]) {
+ xEvent.xany.type = KeyRelease;
+ Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+ xEvent.xany.type = KeyPress;
+ }
+ if (xEvent.xany.type == KeyPress) {
+ }
+ Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
return theEvent;
}
@end
-
@implementation TKContentView
-/* <NSTextInput> implementation (called through interpretKeyEvents:]). */
-/* <NSTextInput>: called when done composing;
- NOTE: also called when we delete over working text, followed immed.
- by doCommandBySelector: deleteBackward: */
+-(id)init {
+ self = [super init];
+ if (self) {
+ _needsRedisplay = NO;
+ }
+ return self;
+}
+
+/*
+ * Implementation of the NSTextInputClient protocol.
+ */
+
+/* [NSTextInputClient inputText: replacementRange:] is called by
+ * interpretKeyEvents when a composition sequence is complete. It is also
+ * called when we delete working text. In that case the call is followed
+ * immediately by doCommandBySelector: deleteBackward:
+ */
- (void)insertText: (id)aString
+ replacementRange: (NSRange)repRange
{
- int i, len = [(NSString *)aString length];
- XEvent xEvent;
+ int i, len, state;
+ XEvent xEvent;
+ NSString *str, *keystr, *lower;
+ TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
+ Tk_Window tkwin = (Tk_Window) winPtr;
+ Bool sendingIMEText = NO;
- if (NS_KEYLOG)
- TKLog (@"insertText '%@'\tlen = %d", aString, len);
- processingCompose = NO;
- finishedCompose = YES;
+ str = ([aString isKindOfClass: [NSAttributedString class]]) ?
+ [aString string] : aString;
+ len = [str length];
- /* first, clear any working text */
- if (privateWorkingText != nil)
- [self deleteWorkingText];
+ if (NS_KEYLOG) {
+ TKLog(@"insertText '%@'\tlen = %d", aString, len);
+ }
- /* now insert the string as keystrokes */
- setupXEvent(&xEvent, [self window], 0);
- xEvent.xany.type = KeyPress;
-
- for (i =0; i<len; i++)
- {
- xEvent.xkey.keycode = (UInt16) [aString characterAtIndex: i];
- [[aString substringWithRange: NSMakeRange(i,1)]
- getCString: xEvent.xkey.trans_chars
- maxLength: XMaxTransChars encoding: NSUTF8StringEncoding];
- xEvent.xkey.nbytes = strlen(xEvent.xkey.trans_chars);
- xEvent.xany.type = KeyPress;
- releaseCode = (UInt16) [aString characterAtIndex: 0];
- Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
- }
- releaseCode = (UInt16) [aString characterAtIndex: 0];
+ /*
+ * Clear any working text.
+ */
+
+ if (privateWorkingText != nil) {
+ sendingIMEText = YES;
+ [self deleteWorkingText];
+ }
+
+ /*
+ * Insert the string as a sequence of keystrokes.
+ */
+
+ setupXEvent(&xEvent, tkwin, textInputModifiers);
+ setXEventPoint(&xEvent, tkwin, [self window]);
+ xEvent.xany.type = KeyPress;
+
+ /*
+ * Apple evidently sets location to 0 to signal that an accented letter has
+ * been selected from the accent menu. An unaccented letter has already
+ * been displayed and we need to erase it before displaying the accented
+ * letter.
+ */
+
+ if (repRange.location == 0) {
+ Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr;
+ TkSendVirtualEvent(focusWin, "TkAccentBackspace", NULL);
+ }
+
+ /*
+ * Next we generate an XEvent for each unicode character in our string.
+ * This string could contain non-BMP characters, for example if the
+ * emoji palette was used.
+ *
+ * NSString uses UTF-16 internally, which means that a non-BMP character is
+ * represented by a sequence of two 16-bit "surrogates". We record this in
+ * the XEvent by setting the low order 21-bits of the keycode to the UCS-32
+ * value value of the character and the virtual keycode in the high order
+ * byte to the special value NON_BMP.
+ */
+
+ state = xEvent.xkey.state;
+ for (i = 0; i < len; i++) {
+ UniChar keychar;
+ MacKeycode macKC = {0};
+
+ keychar = [str characterAtIndex:i];
+ macKC.v.keychar = keychar;
+ if (CFStringIsSurrogateHighCharacter(keychar)) {
+ UniChar lowChar = [str characterAtIndex:++i];
+ macKC.v.keychar = CFStringGetLongCharacterForSurrogatePair(
+ (UniChar)keychar, lowChar);
+ macKC.v.virtual = NON_BMP_VIRTUAL;
+ } else if (repRange.location == 0 || sendingIMEText) {
+ macKC.v.virtual = REPLACEMENT_VIRTUAL;
+ } else {
+ macKC.uint = TkMacOSXAddVirtual(macKC.uint);
+ xEvent.xkey.state |= INDEX2STATE(macKC.x.xvirtual);
+ }
+ keystr = [[NSString alloc] initWithCharacters:&keychar length:1];
+ lower = [keystr lowercaseString];
+ if (![keystr isEqual: lower]) {
+ macKC.v.o_s |= INDEX_SHIFT;
+ xEvent.xkey.state |= ShiftMask;
+ }
+ if (xEvent.xkey.state & Mod2Mask) {
+ macKC.v.o_s |= INDEX_OPTION;
+ }
+ xEvent.xkey.keycode = macKC.uint;
+ xEvent.xany.type = KeyPress;
+ Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+ xEvent.xkey.state = state;
+ }
}
+/*
+ * This required method is allowed to return nil.
+ */
-/* <NSTextInput>: inserts display of composing characters */
-- (void)setMarkedText: (id)aString selectedRange: (NSRange)selRange
+- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)theRange
+ actualRange:(NSRangePointer)thePointer
{
- NSString *str = [aString respondsToSelector: @selector (string)] ?
- [aString string] : aString;
- if (NS_KEYLOG)
- TKLog (@"setMarkedText '%@' len =%lu range %lu from %lu", str,
- (unsigned long) [str length], (unsigned long) selRange.length,
- (unsigned long) selRange.location);
-
- if (privateWorkingText != nil)
- [self deleteWorkingText];
- if ([str length] == 0)
- return;
-
- processingCompose = YES;
- privateWorkingText = [str copy];
+ (void)theRange;
+ (void)thePointer;
- //PENDING: insert workingText underlined
+ return nil;
}
+/*
+ * This method is supposed to insert (or replace selected text with) the string
+ * argument. If the argument is an NSString, it should be displayed with a
+ * distinguishing appearance, e.g underlined.
+ */
-- (BOOL)hasMarkedText
+- (void)setMarkedText: (id)aString
+ selectedRange: (NSRange)selRange
+ replacementRange: (NSRange)repRange
{
- return privateWorkingText != nil;
+ TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
+ Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr;
+ NSString *temp;
+ NSString *str;
+ (void)selRange;
+
+ str = ([aString isKindOfClass: [NSAttributedString class]]) ?
+ [aString string] : aString;
+ if (focusWin) {
+
+ /*
+ * Remember the widget where the composition is happening, in case it
+ * gets defocussed during the composition.
+ */
+
+ composeWin = focusWin;
+ } else {
+ return;
+ }
+ if (NS_KEYLOG) {
+ TKLog(@"setMarkedText '%@' len =%lu range %lu from %lu", str,
+ (unsigned long) [str length], (unsigned long) selRange.length,
+ (unsigned long) selRange.location);
+ }
+
+ if (privateWorkingText != nil) {
+ [self deleteWorkingText];
+ }
+
+ if ([str length] == 0) {
+ return;
+ }
+
+ /*
+ * Use our insertText method to display the marked text.
+ */
+
+ TkSendVirtualEvent(focusWin, "TkStartIMEMarkedText", NULL);
+ processingCompose = YES;
+ temp = [str copy];
+ [self insertText: temp replacementRange:repRange];
+ privateWorkingText = temp;
+ TkSendVirtualEvent(focusWin, "TkEndIMEMarkedText", NULL);
}
+- (BOOL)hasMarkedText
+{
+ return privateWorkingText != nil;
+}
- (NSRange)markedRange
{
- NSRange rng = privateWorkingText != nil
- ? NSMakeRange (0, [privateWorkingText length]) : NSMakeRange (NSNotFound, 0);
- if (NS_KEYLOG)
- TKLog (@"markedRange request");
- return rng;
-}
+ NSRange rng = privateWorkingText != nil
+ ? NSMakeRange(0, [privateWorkingText length])
+ : NSMakeRange(NSNotFound, 0);
+ if (NS_KEYLOG) {
+ TKLog(@"markedRange request");
+ }
+ return rng;
+}
- (void)unmarkText
{
- if (NS_KEYLOG)
- TKLog (@"unmark (accept) text");
- [self deleteWorkingText];
- processingCompose = NO;
+ if (NS_KEYLOG) {
+ TKLog(@"unmarkText");
+ }
+ [self deleteWorkingText];
+ processingCompose = NO;
}
+/*
+ * Called by the system to get a position for popup character selection windows
+ * such as a Character Palette, or a selection menu for IME.
+ */
-/* used to position char selection windows, etc. */
- (NSRect)firstRectForCharacterRange: (NSRange)theRange
+ actualRange: (NSRangePointer)thePointer
{
- NSRect rect;
- NSPoint pt;
-
- pt.x = caret_x;
- pt.y = caret_y;
-
- pt = [self convertPoint: pt toView: nil];
- pt = [[self window] tkConvertPointToScreen: pt];
- pt.y -= caret_height;
-
- rect.origin = pt;
- rect.size.width = caret_height;
- rect.size.height = caret_height;
- return rect;
+ NSRect rect;
+ NSPoint pt;
+ (void)theRange;
+ (void)thePointer;
+
+ pt.x = caret_x;
+ pt.y = caret_y;
+
+ pt = [self convertPoint: pt toView: nil];
+ pt = [[self window] tkConvertPointToScreen: pt];
+ pt.y -= caret_height;
+
+ rect.origin = pt;
+ rect.size.width = 0;
+ rect.size.height = caret_height;
+ return rect;
}
-
- (NSInteger)conversationIdentifier
{
- return (NSInteger)self;
+ return (NSInteger) self;
}
-
- (void)doCommandBySelector: (SEL)aSelector
{
- if (NS_KEYLOG)
- TKLog (@"doCommandBySelector: %@", NSStringFromSelector (aSelector));
- processingCompose = NO;
- if (aSelector == @selector (deleteBackward:))
- {
- /* happens when user backspaces over an ongoing composition:
- throw a 'delete' into the event queue */
- XEvent xEvent;
- setupXEvent(&xEvent, [self window], 0);
- xEvent.xany.type = KeyPress;
- xEvent.xkey.nbytes = 1;
- xEvent.xkey.keycode = (0x33 << 16) | 0x7F;
- xEvent.xkey.trans_chars[0] = 0x7F;
- xEvent.xkey.trans_chars[1] = 0x0;
- Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
+ if (NS_KEYLOG) {
+ TKLog(@"doCommandBySelector: %@", NSStringFromSelector(aSelector));
+ }
+ processingCompose = NO;
+ if (aSelector == @selector (deleteBackward:)) {
+ TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
+ Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr;
+ TkSendVirtualEvent(focusWin, "TkAccentBackspace", NULL);
}
}
-
- (NSArray *)validAttributesForMarkedText
{
- static NSArray *arr = nil;
- if (arr == nil) arr = [NSArray new];
- /* [[NSArray arrayWithObject: NSUnderlineStyleAttributeName] retain]; */
- return arr;
+ static NSArray *arr = nil;
+ if (arr == nil) {
+ arr = [[NSArray alloc] initWithObjects:
+ NSUnderlineStyleAttributeName,
+ NSUnderlineColorAttributeName,
+ nil];
+ [arr retain];
+ }
+ return arr;
}
-
- (NSRange)selectedRange
{
- if (NS_KEYLOG)
- TKLog (@"selectedRange request");
- return NSMakeRange (NSNotFound, 0);
+ if (NS_KEYLOG) {
+ TKLog(@"selectedRange request");
+ }
+ return NSMakeRange(0, 0);
}
-
- (NSUInteger)characterIndexForPoint: (NSPoint)thePoint
{
- if (NS_KEYLOG)
- TKLog (@"characterIndexForPoint request");
- return 0;
+ (void)thePoint;
+ if (NS_KEYLOG) {
+ TKLog(@"characterIndexForPoint request");
+ }
+ return NSNotFound;
}
-
- (NSAttributedString *)attributedSubstringFromRange: (NSRange)theRange
{
- static NSAttributedString *str = nil;
- if (str == nil) str = [NSAttributedString new];
- if (NS_KEYLOG)
- TKLog (@"attributedSubstringFromRange request");
- return str;
+ static NSAttributedString *str = nil;
+ (void)theRange;
+
+ if (str == nil) {
+ str = [NSAttributedString new];
+ }
+ if (NS_KEYLOG) {
+ TKLog(@"attributedSubstringFromRange request");
+ }
+ return str;
}
-/* End <NSTextInput> impl. */
+/* End of NSTextInputClient implementation. */
+
+@synthesize needsRedisplay = _needsRedisplay;
@end
@implementation TKContentView(TKKeyEvent)
-/* delete display of composing characters [not in <NSTextInput>] */
+
+/*
+ * Tell the widget to erase the displayed composing characters. This
+ * is not part of the NSTextInputClient protocol.
+ */
+
- (void)deleteWorkingText
{
- if (privateWorkingText == nil)
- return;
- if (NS_KEYLOG)
- TKLog(@"deleteWorkingText len = %lu\n",
- (unsigned long)[privateWorkingText length]);
- [privateWorkingText release];
- privateWorkingText = nil;
- processingCompose = NO;
-
- //PENDING: delete working text
+ if (privateWorkingText == nil) {
+ return;
+ } else {
+
+ if (NS_KEYLOG) {
+ TKLog(@"deleteWorkingText len = %lu\n",
+ (unsigned long)[privateWorkingText length]);
+ }
+
+ [privateWorkingText release];
+ privateWorkingText = nil;
+ processingCompose = NO;
+ if (composeWin) {
+ TkSendVirtualEvent(composeWin, "TkClearIMEMarkedText", NULL);
+ }
+ }
}
-@end
+- (void)cancelComposingText
+{
+ if (NS_KEYLOG) {
+ TKLog(@"cancelComposingText");
+ }
+ [self deleteWorkingText];
+ processingCompose = NO;
+}
+@end
/*
- * Set up basic fields in xevent for keyboard input.
+ * Set up basic fields in xevent for keyboard input.
*/
+
static void
-setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state)
+setupXEvent(XEvent *xEvent, Tk_Window tkwin, NSUInteger modifiers)
{
- TkWindow *winPtr = TkMacOSXGetTkWindow(w);
- Tk_Window tkwin = (Tk_Window) winPtr;
- if (!winPtr) {
+ unsigned int state = 0;
+ Display *display = Tk_Display(tkwin);
+
+ if (tkwin == NULL) {
return;
}
-
+ if (modifiers) {
+ state = (modifiers & NSAlphaShiftKeyMask ? LockMask : 0) |
+ (modifiers & NSShiftKeyMask ? ShiftMask : 0) |
+ (modifiers & NSControlKeyMask ? ControlMask : 0) |
+ (modifiers & NSCommandKeyMask ? Mod1Mask : 0) |
+ (modifiers & NSAlternateKeyMask ? Mod2Mask : 0) |
+ (modifiers & NSNumericPadKeyMask ? Mod3Mask : 0) |
+ (modifiers & NSFunctionKeyMask ? Mod4Mask : 0) ;
+ }
memset(xEvent, 0, sizeof(XEvent));
- xEvent->xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
- xEvent->xany.send_event = false;
+ xEvent->xany.serial = LastKnownRequestProcessed(display);
xEvent->xany.display = Tk_Display(tkwin);
xEvent->xany.window = Tk_WindowId(tkwin);
- xEvent->xkey.root = XRootWindow(Tk_Display(tkwin), 0);
- xEvent->xkey.subwindow = None;
+ xEvent->xkey.root = XRootWindow(display, 0);
xEvent->xkey.time = TkpGetMS();
xEvent->xkey.state = state;
xEvent->xkey.same_screen = true;
- xEvent->xkey.trans_chars[0] = 0;
- xEvent->xkey.nbytes = 0;
+ /* No need to initialize other fields implicitly here,
+ * because of the memset() above. */
+}
+
+static void
+setXEventPoint(
+ XEvent *xEvent,
+ Tk_Window tkwin,
+ NSWindow *w)
+{
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ NSPoint local = [w mouseLocationOutsideOfEventStream];
+ NSPoint global = [w tkConvertPointToScreen: local];
+ int win_x, win_y;
+
+ if (Tk_IsEmbedded(winPtr)) {
+ TkWindow *contPtr = TkpGetOtherWindow(winPtr);
+ if (Tk_IsTopLevel(contPtr)) {
+ local.x -= contPtr->wmInfoPtr->xInParent;
+ local.y -= contPtr->wmInfoPtr->yInParent;
+ } else {
+ TkWindow *topPtr = TkMacOSXGetHostToplevel(winPtr)->winPtr;
+ local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x);
+ local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y);
+ }
+ } else if (winPtr->wmInfoPtr != NULL) {
+ local.x -= winPtr->wmInfoPtr->xInParent;
+ local.y -= winPtr->wmInfoPtr->yInParent;
+ }
+ tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y);
+ local.x = win_x;
+ local.y = win_y;
+ global.y = TkMacOSXZeroScreenHeight() - global.y;
+ xEvent->xbutton.x = local.x;
+ xEvent->xbutton.y = local.y;
+ xEvent->xbutton.x_root = global.x;
+ xEvent->xbutton.y_root = global.y;
}
#pragma mark -
@@ -497,12 +702,17 @@ XGrabKeyboard(
Time time)
{
keyboardGrabWinPtr = Tk_IdToWindow(display, grab_window);
- TkWindow *captureWinPtr = (TkWindow *)TkMacOSXGetCapture();
+ TkWindow *captureWinPtr = (TkWindow *) TkpGetCapture();
+ (void)owner_events;
+ (void)pointer_mode;
+ (void)keyboard_mode;
+ (void)time;
+
if (keyboardGrabWinPtr && captureWinPtr) {
NSWindow *w = TkMacOSXDrawableWindow(grab_window);
MacDrawable *macWin = (MacDrawable *) grab_window;
- if (w && macWin->toplevel->winPtr == (TkWindow*) captureWinPtr) {
+ if (w && macWin->toplevel->winPtr == (TkWindow *) captureWinPtr) {
if (modalSession) {
Tcl_Panic("XGrabKeyboard: already grabbed");
}
@@ -530,11 +740,14 @@ XGrabKeyboard(
*----------------------------------------------------------------------
*/
-void
+int
XUngrabKeyboard(
Display* display,
Time time)
{
+ (void)display;
+ (void)time;
+
if (modalSession) {
[NSApp endModalSession:modalSession];
modalSession = nil;
@@ -544,6 +757,7 @@ XUngrabKeyboard(
keyboardGrabNSWindow = nil;
}
keyboardGrabWinPtr = NULL;
+ return Success;
}
/*
@@ -571,15 +785,22 @@ TkMacOSXGetModalSession(void)
*
* Tk_SetCaretPos --
*
- * This enables correct placement of the XIM caret. This is called by
- * widgets to indicate their cursor placement, and the caret location is
- * used by TkpGetString to place the XIM caret.
+ * This enables correct placement of the popups used for character
+ * selection by the NSTextInputClient. It gets called by text entry
+ * widgets whenever the cursor is drawn. It does nothing if the widget's
+ * NSWindow is not the current KeyWindow. Otherwise it udpates the
+ * display's caret structure and records the caret geometry in static
+ * variables for use by the NSTextInputClient implementation. Any
+ * widget passed to this function will be marked as being able to input
+ * text by setting the TK_CAN_INPUT_TEXT flag.
*
* Results:
* None
*
* Side effects:
- * None
+ * Sets the CAN_INPUT_TEXT flag on the widget passed as tkwin. May update
+ * the display's caret structure as well as the static variables caret_x,
+ * caret_y and caret_height.
*
*----------------------------------------------------------------------
*/
@@ -591,27 +812,40 @@ Tk_SetCaretPos(
int y,
int height)
{
- TkCaret *caretPtr = &(((TkWindow *) tkwin)->dispPtr->caret);
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ TkCaret *caretPtr = &(winPtr->dispPtr->caret);
+ NSWindow *w = TkMacOSXDrawableWindow(Tk_WindowId(tkwin));
/*
- * Prevent processing anything if the values haven't changed. Windows only
- * has one display, so we can do this with statics.
+ * Register this widget as being capable of text input, so we know we
+ * should process (appropriate) key events for this window with the
+ * NSTextInputClient protocol.
*/
- if ((caretPtr->winPtr == ((TkWindow *) tkwin))
- && (caretPtr->x == x) && (caretPtr->y == y)) {
+ winPtr->flags |= TK_CAN_INPUT_TEXT;
+ if (w && ![w isKeyWindow]) {
return;
}
+ if ((caretPtr->winPtr == winPtr
+ && caretPtr->x == x) && (caretPtr->y == y)) {
+ return;
+ }
+
+ /*
+ * Update the display's caret information.
+ */
- caretPtr->winPtr = ((TkWindow *) tkwin);
+ caretPtr->winPtr = winPtr;
caretPtr->x = x;
caretPtr->y = y;
caretPtr->height = height;
/*
- * As in Windows, adjust to the toplevel to get the coords right.
+ * Record the caret geometry in static variables for use when processing
+ * key events. We use the TKContextView coordinate system for this.
*/
+ caret_height = height;
while (!Tk_IsTopLevel(tkwin)) {
x += Tk_X(tkwin);
y += Tk_Y(tkwin);
@@ -620,88 +854,10 @@ Tk_SetCaretPos(
return;
}
}
-
- /* But adjust for fact that NS uses flipped view. */
- y = Tk_Height(tkwin) - y;
-
caret_x = x;
- caret_y = y;
- caret_height = height;
+ caret_y = Tk_Height(tkwin) - y;
}
-
-static unsigned convert_ns_to_X_keysym[] =
-{
- NSHomeFunctionKey, 0x50,
- NSLeftArrowFunctionKey, 0x51,
- NSUpArrowFunctionKey, 0x52,
- NSRightArrowFunctionKey, 0x53,
- NSDownArrowFunctionKey, 0x54,
- NSPageUpFunctionKey, 0x55,
- NSPageDownFunctionKey, 0x56,
- NSEndFunctionKey, 0x57,
- NSBeginFunctionKey, 0x58,
- NSSelectFunctionKey, 0x60,
- NSPrintFunctionKey, 0x61,
- NSExecuteFunctionKey, 0x62,
- NSInsertFunctionKey, 0x63,
- NSUndoFunctionKey, 0x65,
- NSRedoFunctionKey, 0x66,
- NSMenuFunctionKey, 0x67,
- NSFindFunctionKey, 0x68,
- NSHelpFunctionKey, 0x6A,
- NSBreakFunctionKey, 0x6B,
-
- NSF1FunctionKey, 0xBE,
- NSF2FunctionKey, 0xBF,
- NSF3FunctionKey, 0xC0,
- NSF4FunctionKey, 0xC1,
- NSF5FunctionKey, 0xC2,
- NSF6FunctionKey, 0xC3,
- NSF7FunctionKey, 0xC4,
- NSF8FunctionKey, 0xC5,
- NSF9FunctionKey, 0xC6,
- NSF10FunctionKey, 0xC7,
- NSF11FunctionKey, 0xC8,
- NSF12FunctionKey, 0xC9,
- NSF13FunctionKey, 0xCA,
- NSF14FunctionKey, 0xCB,
- NSF15FunctionKey, 0xCC,
- NSF16FunctionKey, 0xCD,
- NSF17FunctionKey, 0xCE,
- NSF18FunctionKey, 0xCF,
- NSF19FunctionKey, 0xD0,
- NSF20FunctionKey, 0xD1,
- NSF21FunctionKey, 0xD2,
- NSF22FunctionKey, 0xD3,
- NSF23FunctionKey, 0xD4,
- NSF24FunctionKey, 0xD5,
-
- NSBackspaceCharacter, 0x08, /* 8: Not on some KBs. */
- NSDeleteCharacter, 0xFF, /* 127: Big 'delete' key upper right. */
- NSDeleteFunctionKey, 0x9F, /* 63272: Del forw key off main array. */
-
- NSTabCharacter, 0x09,
- 0x19, 0x09, /* left tab->regular since pass shift */
- NSCarriageReturnCharacter, 0x0D,
- NSNewlineCharacter, 0x0D,
- NSEnterCharacter, 0x8D,
-
- 0x1B, 0x1B /* escape */
-};
-
-
-static unsigned isFunctionKey(unsigned code)
-{
- const unsigned last_keysym = (sizeof (convert_ns_to_X_keysym)
- / sizeof (convert_ns_to_X_keysym[0]));
- unsigned keysym;
- for (keysym = 0; keysym < last_keysym; keysym += 2)
- if (code == convert_ns_to_X_keysym[keysym])
- return 0xFF00 | convert_ns_to_X_keysym[keysym+1];
- return 0;
- }
-
/*
* Local Variables:
* mode: objc
diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c
index 5899064..ca2a9e5 100644
--- a/macosx/tkMacOSXKeyboard.c
+++ b/macosx/tkMacOSXKeyboard.c
@@ -6,133 +6,144 @@
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright (c) 2020 Marc Culler
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXPrivate.h"
-#include "tkMacOSXEvent.h"
+#include "tkMacOSXInt.h"
#include "tkMacOSXConstants.h"
+#include "tkMacOSXKeysyms.h"
+
/*
- * A couple of simple definitions to make code a bit more self-explaining.
- *
- * For the assignments of Mod1==meta==command and Mod2==alt==option, see also
- * tkMacOSXMouseEvent.c.
+ * About keyboards
+ * ---------------
+ * Keyboards are complicated. This long comment is an attempt to provide
+ * enough information about them to make it possible to read and understand
+ * the code in this file.
+ *
+ * Every key on a keyboard is identified by a number between 0 and 127. In
+ * macOS, pressing or releasing a key on the keyboard generates an NSEvent of
+ * type KeyDown, KeyUp or FlagsChanged. The 8-bit identifier of the key that
+ * was involved in this event is provided in the attribute [NSEvent keyCode].
+ * Apple also refers to this number as a "Virtual KeyCode". In this file, to
+ * avoid confusion with other uses of the word keycode, we will refer to this
+ * key identifier as a "virtual keycode", usually the value of a variable named
+ * "virtual".
+ *
+ * Some of the keys on a keyboard, such as the Shift, Option, Command or
+ * Control keys, are "modifier" keys. The effect of pressing or releasing a
+ * key depends on three quantities:
+ * - which key is being pressed or released
+ * - which modifier keys are being held down at the moment
+ * - the current keyboard layout
+ * If the key is a modifier key then the effect of pressing or releasing it is
+ * only to change the list of which modifier keys are being held down. Apple
+ * reports this by sending an NSEvent of type FlagsChanged. X11 reports this
+ * as a KeyPress or KeyRelease event for the modifier key. Note that there may
+ * be combinations of modifier key states and key presses which have no effect.
+ *
+ * In X11 every meaningful effect from a key action is identified by a 16 bit
+ * value known as a keysym. Every keysym has an associated string name, also
+ * known as a keysym. The Tk bind command uses the X11 keysym string to
+ * specify a key event which should invoke a certain action and it provides the
+ * numeric and symbolic keysyms to the bound proc as %N and %K respectively.
+ * An X11 XEvent which reports a KeyPress or KeyRelease does not include the
+ * keysym. Instead it includes a platform-specific numerical value called a
+ * keycode which is available to the bound procedure as %k. A platform port of
+ * Tk must provide functions which convert between keycodes and numerical
+ * keysyms. Conversion between numerical and symbolic keysyms is provided by
+ * the generic Tk code, although platforms are allowed to provide their own by
+ * defining the XKeysymToString and XStringToKeysym functions and undefining
+ * the macro REDO_KEYSYM_LOOKUP. This macOS port uses the conversion provided
+ * by the generic code.
+ *
+ * When the keyboard focus is on a Tk widget which provides text input, there
+ * are some X11 KeyPress events which cause text to be inserted. We will call
+ * these "printable" events. The UCS-32 character stored in the keycode field
+ * of an XKeyEvent depends on more than the three items above. It may also
+ * depend on the sequence of keypresses that preceded the one being reported by
+ * the XKeyEvent. For example, on macOS an <Alt-e> event does not cause text
+ * to be inserted but a following <a> event causes an accented 'a' to be
+ * inserted. The events in such a composition sequence, other than the final
+ * one, are known as "dead-key" events.
+ *
+ * MacOS packages the information described above in a different way. Every
+ * meaningful effect from a key action *other than changing the state of
+ * modifier keys* is identified by a unicode string which is provided as the
+ * [NSEvent characters] attribute of a KeyDown or KeyUp event. FlagsChanged
+ * events do not have characters. In principle, the characters attribute could
+ * be an arbitrary unicode string but in practice it is always a single UTF-16
+ * character which we usually store in a variable named keychar. While the
+ * keychar is a legal unicode code point, it does not necessarily represent a
+ * glyph. MacOS uses unicode code points in the private-use range 0xF700-0xF8FF
+ * for non-printable events which have no associated ASCII code point. For
+ * example, pressing the F2 key generates an NSEvent with the character 0xF705,
+ * the Backspace key produces 0x7F (ASCII del) and the Delete key produces
+ * 0xF728.
+ *
+ * With the exception of modifier keys, it is possible to translate between
+ * numerical X11 keysyms and macOS keychars; this file constructs Tcl hash
+ * tables to do this job, using data defined in the file tkMacOSXKeysyms.h.
+ * The code here adopts the convention that the keychar of any modifier key
+ * is MOD_KEYCHAR. Keys which do not appear on any Macintosh keyboard, such
+ * as the Menu key on PC keyboards, are assigned UNKNOWN_KEYCHAR.
+ *
+ * The macosx platform-specific scheme for generating a keycode when mapping an
+ * NSEvent of type KeyUp, KeyDown or FlagsChanged to an XEvent of type KeyPress
+ * or KeyRelease is as follows:
+ * keycode = (virtual << 24) | index << 22 | keychar
+ * where index is a 2-bit quantity whose bits indicate the state of the Option
+ * and Shift keys.
+ *
+ * A few remarks are in order. First, we are using 32 bits for the keycode and
+ * we are allowing room for up to 22 bits for the keychar. This means that
+ * there is enough room in the keycode to hold a UTF-32 character, which only
+ * requires 21 bits. Second, the KeyCode type for the keycode field in an
+ * XEvent is currently defined as unsigned int, which was modified from the
+ * unsigned short used in X11 in order to accomodate macOS. Finally, there is
+ * no obstruction to generating KeyPress events for keys that represent letters
+ * which do not exist on the current keyboard layout. And different keyboard
+ * layouts can assign a given letter to different keys. So we need a
+ * convention for what value to assign to "virtual" when computing the keycode
+ * for a generated event. The convention used here is as follows: If there is
+ * a key on the current keyboard which produces the keychar, use the virtual
+ * keycode of that key. Otherwise set virtual = NO_VIRTUAL.
*/
-#define LATIN1_MAX 255
-#define MAC_KEYCODE_MAX 0x7F
-#define MAC_KEYCODE_MASK 0x7F
-#define COMMAND_MASK Mod1Mask
-#define OPTION_MASK Mod2Mask
+/*
+ * See tkMacOSXPrivate.h for macros and structures related to key event processing.
+ */
/*
- * Tables enumerating the special keys defined on Mac keyboards. These are
- * necessary for correct keysym mappings for all keys where the keysyms are
- * not identical with their ASCII or Latin-1 code points.
+ * Hash tables and array used to translate between various key attributes.
*/
-typedef struct {
- int keycode; /* Macintosh keycode. */
- KeySym keysym; /* X windows keysym. */
-} KeyInfo;
+static Tcl_HashTable special2keysym; /* Special virtual keycode to keysym */
+static Tcl_HashTable keysym2keycode; /* keysym to XEvent keycode */
+static Tcl_HashTable keysym2unichar; /* keysym to unichar */
+static Tcl_HashTable unichar2keysym; /* unichar to X11 keysym */
+static Tcl_HashTable unichar2xvirtual; /* unichar to virtual with index */
+static UniChar xvirtual2unichar[512]; /* virtual with index to unichar */
/*
- * Notes on keyArray:
- *
- * 0x34, XK_Return - Powerbooks use this and some keymaps define it.
- *
- * 0x4C, XK_Return - XFree86 and Apple's X11 call this one XK_KP_Enter.
- *
- * 0x47, XK_Clear - This key is NumLock when used on PCs, but Mac
- * applications don't use it like that, nor does Apple's X11.
- *
- * All other keycodes are taken from the published ADB keyboard layouts.
+ * Flags.
*/
-static KeyInfo keyArray[] = {
- {0x24, XK_Return},
- {0x30, XK_Tab},
- {0x33, XK_BackSpace},
- {0x34, XK_Return},
- {0x35, XK_Escape},
-
- {0x47, XK_Clear},
- {0x4C, XK_KP_Enter},
-
- {0x72, XK_Help},
- {0x73, XK_Home},
- {0x74, XK_Page_Up},
- {0x75, XK_Delete},
- {0x77, XK_End},
- {0x79, XK_Page_Down},
-
- {0x7B, XK_Left},
- {0x7C, XK_Right},
- {0x7D, XK_Down},
- {0x7E, XK_Up},
-
- {0, 0}
-};
-
-static KeyInfo virtualkeyArray[] = {
- {122, XK_F1},
- {120, XK_F2},
- {99, XK_F3},
- {118, XK_F4},
- {96, XK_F5},
- {97, XK_F6},
- {98, XK_F7},
- {100, XK_F8},
- {101, XK_F9},
- {109, XK_F10},
- {103, XK_F11},
- {111, XK_F12},
- {105, XK_F13},
- {107, XK_F14},
- {113, XK_F15},
- {0, 0}
-};
-
-#define NUM_MOD_KEYCODES 14
-static KeyCode modKeyArray[NUM_MOD_KEYCODES] = {
- XK_Shift_L,
- XK_Shift_R,
- XK_Control_L,
- XK_Control_R,
- XK_Caps_Lock,
- XK_Shift_Lock,
- XK_Meta_L,
- XK_Meta_R,
- XK_Alt_L,
- XK_Alt_R,
- XK_Super_L,
- XK_Super_R,
- XK_Hyper_L,
- XK_Hyper_R,
-};
-
-static int initialized = 0;
-static Tcl_HashTable keycodeTable; /* keyArray hashed by keycode value. */
-static Tcl_HashTable vkeyTable; /* virtualkeyArray hashed by virtual
- * keycode value. */
-
-static int latin1Table[LATIN1_MAX+1]; /* Reverse mapping table for
- * controls, ASCII and Latin-1. */
-
-static int keyboardChanged = 1;
+static BOOL initialized = NO;
+static BOOL keyboardChanged = YES;
/*
* Prototypes for static functions used in this file.
*/
-static void InitKeyMaps (void);
-static void InitLatin1Table(Display *display);
-static int XKeysymToMacKeycode(Display *display, KeySym keysym);
-static int KeycodeToUnicode(UniChar * uniChars, int maxChars,
- UInt16 keyaction, UInt32 keycode, UInt32 modifiers,
+static void InitHashTables(void);
+static void UpdateKeymaps(void);
+static int KeyDataToUnicode(UniChar *uniChars, int maxChars,
+ UInt16 keyaction, UInt32 virtual, UInt32 modifiers,
UInt32 * deadKeyStatePtr);
#pragma mark TKApplication(TKKeyboard)
@@ -140,10 +151,12 @@ static int KeycodeToUnicode(UniChar * uniChars, int maxChars,
@implementation TKApplication(TKKeyboard)
- (void) keyboardChanged: (NSNotification *) notification
{
+ (void)notification;
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
- keyboardChanged = 1;
+ keyboardChanged = YES;
+ UpdateKeymaps();
}
@end
@@ -152,14 +165,10 @@ static int KeycodeToUnicode(UniChar * uniChars, int maxChars,
/*
*----------------------------------------------------------------------
*
- * InitKeyMaps --
+ * InitHashTables --
*
* Creates hash tables used by some of the functions in this file.
*
- * FIXME: As keycodes are defined to be in the limited range 0-127, it
- * would be easier and more efficient to use directly initialized plain
- * arrays and drop this function.
- *
* Results:
* None.
*
@@ -170,84 +179,117 @@ static int KeycodeToUnicode(UniChar * uniChars, int maxChars,
*/
static void
-InitKeyMaps(void)
+InitHashTables(void)
{
Tcl_HashEntry *hPtr;
- KeyInfo *kPtr;
- int dummy;
-
- Tcl_InitHashTable(&keycodeTable, TCL_ONE_WORD_KEYS);
- for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
- hPtr = Tcl_CreateHashEntry(&keycodeTable, INT2PTR(kPtr->keycode),
- &dummy);
+ const KeyInfo *kPtr;
+ const KeysymInfo *ksPtr;
+ int dummy, index;
+
+ Tcl_InitHashTable(&special2keysym, TCL_ONE_WORD_KEYS);
+ Tcl_InitHashTable(&keysym2keycode, TCL_ONE_WORD_KEYS);
+ for (kPtr = keyArray; kPtr->virtual != 0; kPtr++) {
+ MacKeycode macKC;
+ macKC.v.o_s = 0;
+ hPtr = Tcl_CreateHashEntry(&special2keysym, INT2PTR(kPtr->virtual),
+ &dummy);
Tcl_SetHashValue(hPtr, INT2PTR(kPtr->keysym));
+ hPtr = Tcl_CreateHashEntry(&keysym2keycode, INT2PTR(kPtr->keysym),
+ &dummy);
+ macKC.v.virtual = kPtr->virtual;
+ macKC.v.keychar = kPtr->keychar;
+ Tcl_SetHashValue(hPtr, INT2PTR(macKC.uint));
+
+ /*
+ * The Carbon framework does not work for finding the unicode character
+ * of a special key. But that does not depend on the keyboard layout,
+ * so we can record the information here.
+ */
+
+ for (index = 3; index >= 0; index--) {
+ macKC.v.o_s = index;
+ xvirtual2unichar[macKC.x.xvirtual] = macKC.x.keychar;
+ }
}
- Tcl_InitHashTable(&vkeyTable, TCL_ONE_WORD_KEYS);
- for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) {
- hPtr = Tcl_CreateHashEntry(&vkeyTable, INT2PTR(kPtr->keycode),
- &dummy);
- Tcl_SetHashValue(hPtr, INT2PTR(kPtr->keysym));
+ Tcl_InitHashTable(&keysym2unichar, TCL_ONE_WORD_KEYS);
+ Tcl_InitHashTable(&unichar2keysym, TCL_ONE_WORD_KEYS);
+ for (ksPtr = keysymTable; ksPtr->keysym != 0; ksPtr++) {
+ hPtr = Tcl_CreateHashEntry(&keysym2unichar, INT2PTR(ksPtr->keysym),
+ &dummy);
+ Tcl_SetHashValue(hPtr, INT2PTR(ksPtr->keycode));
+ hPtr = Tcl_CreateHashEntry(&unichar2keysym, INT2PTR(ksPtr->keycode),
+ &dummy);
+ Tcl_SetHashValue(hPtr, INT2PTR(ksPtr->keysym));
}
- initialized = 1;
+ UpdateKeymaps();
+ initialized = YES;
}
/*
*----------------------------------------------------------------------
*
- * InitLatin1Table --
+ * UpdateKeymaps --
*
- * Creates a simple table to be used for mapping from keysyms to keycodes.
- * Always needs to be called before using latin1Table, because the
- * keyboard layout may have changed, and than the table must be
- * re-computed.
+ * Called when the keyboard changes to update the hash tables that provide
+ * maps between unicode characters and virtual keycodes with indexes. In
+ * order for the map from characters to virtual keycodes to be
+ * well-defined we have to ignore virtual keycodes for keypad keys, since
+ * each keypad key has the same character as the corresponding key on the
+ * main keyboard.
*
* Results:
* None.
*
* Side effects:
- * Sets the global latin1Table.
+ * Initializes, if necessary, and updates the unichar2xvirtual hash table
+ * and the xvirtual2unichar array.
*
*----------------------------------------------------------------------
*/
static void
-InitLatin1Table(
- Display *display)
+UpdateKeymaps()
{
- int keycode;
- KeySym keysym;
- int state;
- int modifiers;
-
- memset(latin1Table, 0, sizeof(latin1Table));
+ static Bool keymapInitialized = false;
+ Tcl_HashEntry *hPtr;
+ int virtual, index, dummy;
+ if (!keymapInitialized) {
+ Tcl_InitHashTable(&unichar2xvirtual, TCL_ONE_WORD_KEYS);
+ keymapInitialized = true;
+ } else {
+ Tcl_DeleteHashTable(&unichar2xvirtual);
+ Tcl_InitHashTable(&unichar2xvirtual, TCL_ONE_WORD_KEYS);
+ }
/*
- * In the common X11 implementations, a keymap has four columns
- * "plain", "Shift", "Mode_switch" and "Mode_switch + Shift". We don't
- * use "Mode_switch", but we use "Option" instead. (This is similar to
- * Apple's X11 implementation, where "Mode_switch" is used as an alias
- * for "Option".)
- *
- * So here we go through all 4 columns of the keymap and find all
- * Latin-1 compatible keycodes. We go through the columns back-to-front
- * from the more exotic columns to the more simple, so that simple
- * keycode-modifier combinations are preferred in the resulting table.
+ * This loop goes backwards so that a lookup by keychar will provide the
+ * minimal modifier mask. Simpler combinations will overwrite more complex
+ * ones when constructing the table.
*/
- for (state = 3; state >= 0; state--) {
- modifiers = 0;
- if (state & 1) {
- modifiers |= shiftKey;
- }
- if (state & 2) {
- modifiers |= optionKey;
- }
-
- for (keycode = 0; keycode <= MAC_KEYCODE_MAX; keycode++) {
- keysym = XKeycodeToKeysym(display,keycode<<16,state);
- if (keysym <= LATIN1_MAX) {
- latin1Table[keysym] = keycode | modifiers;
+ for (index = 3; index >= 0; index--) {
+ for (virtual = 0; virtual < 128; virtual++) {
+ MacKeycode macKC;
+ macKC.v = (keycode_v) {.virtual = virtual, .o_s = index, .keychar = 0};
+ int modifiers = INDEX2CARBON(index), result;
+ UniChar keychar = 0;
+ result = KeyDataToUnicode(&keychar, 1, kUCKeyActionDown, virtual,
+ modifiers, NULL);
+ if (keychar == 0x10) {
+
+ /*
+ * This is a special key, handled in InitHashTables.
+ */
+
+ continue;
}
+ macKC.v.keychar = keychar;
+ if (! ON_KEYPAD(virtual)) {
+ hPtr = Tcl_CreateHashEntry(&unichar2xvirtual,
+ INT2PTR(macKC.x.keychar), &dummy);
+ Tcl_SetHashValue(hPtr, INT2PTR(macKC.x.xvirtual));
+ }
+ xvirtual2unichar[macKC.x.xvirtual] = macKC.x.keychar;
}
}
}
@@ -255,37 +297,40 @@ InitLatin1Table(
/*
*----------------------------------------------------------------------
*
- * KeycodeToUnicode --
+ * KeyDataToUnicode --
*
- * Given MacOS key event data this function generates the Unicode
- * characters. It does this using OS resources and APIs.
+ * Given MacOS key event data this function generates the keychar. It
+ * does this by using OS resources from the Carbon framework. Note that
+ * the Carbon functions used here are not aware of the keychars in the
+ * private-use range which macOS now uses for special keys. For those
+ * keys this function returns 0x10 (ASCII dle).
*
* The parameter deadKeyStatePtr can be NULL, if no deadkey handling is
- * needed.
+ * needed (which is always the case here).
*
- * This function is called from XKeycodeToKeysym() in tkMacOSKeyboard.c.
+ * This function is called in XKeycodeToKeysym and UpdateKeymaps.
*
* Results:
* The number of characters generated if any, 0 if we are waiting for
- * another byte of a dead-key sequence. Fills in the uniChars array with a
- * Unicode string.
+ * another byte of a dead-key sequence.
*
* Side Effects:
- * None
+ * Fills in the uniChars array with a Unicode string.
*
*----------------------------------------------------------------------
*/
+
static int
-KeycodeToUnicode(
+KeyDataToUnicode(
UniChar *uniChars,
int maxChars,
UInt16 keyaction,
- UInt32 keycode,
+ UInt32 virtual,
UInt32 modifiers,
UInt32 *deadKeyStatePtr)
{
- static const void *uchr = NULL;
+ static const void *layoutData = NULL;
static UInt32 keyboardType = 0;
UniCharCount actuallength = 0;
@@ -298,34 +343,32 @@ KeycodeToUnicode(
currentKeyboardLayout, kTISPropertyUnicodeKeyLayoutData);
if (keyLayoutData) {
- uchr = CFDataGetBytePtr(keyLayoutData);
+ layoutData = CFDataGetBytePtr(keyLayoutData);
keyboardType = LMGetKbdType();
}
CFRelease(currentKeyboardLayout);
}
keyboardChanged = 0;
}
- if (uchr) {
+ if (layoutData) {
OptionBits options = 0;
UInt32 dummyState;
OSStatus err;
- keycode &= 0xFF;
+ virtual &= 0xFF;
modifiers = (modifiers >> 8) & 0xFF;
-
if (!deadKeyStatePtr) {
options = kUCKeyTranslateNoDeadKeysMask;
dummyState = 0;
deadKeyStatePtr = &dummyState;
}
-
- err = ChkErr(UCKeyTranslate, uchr, keycode, keyaction, modifiers,
+ err = ChkErr(UCKeyTranslate, layoutData, virtual, keyaction, modifiers,
keyboardType, options, deadKeyStatePtr, maxChars,
&actuallength, uniChars);
-
if (!actuallength && *deadKeyStatePtr) {
+
/*
- * More data later
+ * We are waiting for another key.
*/
return 0;
@@ -343,11 +386,14 @@ KeycodeToUnicode(
*
* XKeycodeToKeysym --
*
- * Translate from a system-dependent keycode to a system-independent
- * keysym.
+ * This is a stub function which translates from the keycode used in an
+ * XEvent to a numerical keysym. On macOS, the display parameter is
+ * ignored and only the the virtual keycode stored in the .virtual bitfield
+ * of a MacKeycode.v.
*
* Results:
- * Returns the translated keysym, or NoSymbol on failure.
+ * Returns the corresponding numerical keysym, or NoSymbol if the keysym
+ * cannot be found.
*
* Side effects:
* None.
@@ -356,77 +402,84 @@ KeycodeToUnicode(
*/
KeySym
-XKeycodeToKeysym(
- Display* display,
- KeyCode keycode,
+XkbKeycodeToKeysym(
+ TCL_UNUSED(Display *),
+ unsigned int keycode,
+ TCL_UNUSED(int),
int index)
{
- register Tcl_HashEntry *hPtr;
- int newKeycode;
- UniChar newChar;
-
- (void) display; /*unused*/
+ Tcl_HashEntry *hPtr;
+ MacKeycode macKC;
+ int modifiers, result;
+ UniChar keychar = 0;
if (!initialized) {
- InitKeyMaps();
+ InitHashTables();
}
+ macKC.uint = keycode;
+ macKC.v.o_s = index;
/*
- * When determining what keysym to produce we first check to see if the key
- * is a function key. We then check to see if the character is another
- * non-printing key. Finally, we return the key syms for all ASCII and
- * Latin-1 chars.
+ * First check if the virtual keycode corresponds to a special key, such as
+ * an Fn function key or Tab, Backspace, Home, End, etc.
*/
- newKeycode = keycode >> 16;
-
- if ((keycode & 0xFFFF) >= 0xF700) { /* NSEvent.h function key unicodes */
- hPtr = Tcl_FindHashEntry(&vkeyTable, INT2PTR(newKeycode));
- if (hPtr != NULL) {
- return (KeySym) Tcl_GetHashValue(hPtr);
- }
- }
- hPtr = Tcl_FindHashEntry(&keycodeTable, INT2PTR(newKeycode));
+ hPtr = Tcl_FindHashEntry(&special2keysym, INT2PTR(macKC.v.virtual));
if (hPtr != NULL) {
return (KeySym) Tcl_GetHashValue(hPtr);
}
/*
- * Add in the Mac modifier flags for shift and option.
+ * If the virtual value in this keycode does not correspond to an actual
+ * key in the current keyboard layout, try using its keychar to look up a
+ * keysym.
*/
- if (index & 1) {
- newKeycode |= shiftKey;
- }
- if (index & 2) {
- newKeycode |= optionKey;
+ if (macKC.v.virtual > 127) {
+ hPtr = Tcl_FindHashEntry(&unichar2keysym, INT2PTR(macKC.v.keychar));
+ if (hPtr != NULL) {
+ return (KeySym) Tcl_GetHashValue(hPtr);
+ }
}
- newChar = 0;
- KeycodeToUnicode(&newChar, 1, kUCKeyActionDown, newKeycode & 0x00FF,
- newKeycode & 0xFF00, NULL);
-
/*
- * X11 keysyms are identical to Unicode for ASCII and Latin-1. Give up for
- * other characters for now.
+ * If the virtual keycode does belong to a key, use the virtual and the
+ * Option-Shift from index to look up a keychar by using the Carbon
+ * Framework; then translate the keychar to a keysym using the
+ * unicode2keysym hash table.
*/
- if ((newChar >= XK_space) && (newChar <= LATIN1_MAX)) {
- return newChar;
+ modifiers = INDEX2CARBON(macKC.v.o_s);
+ result = KeyDataToUnicode(&keychar, 1, kUCKeyActionDown, macKC.v.virtual,
+ modifiers, NULL);
+ if (result) {
+ hPtr = Tcl_FindHashEntry(&unichar2keysym, INT2PTR(keychar));
+ if (hPtr != NULL) {
+ return (KeySym) Tcl_GetHashValue(hPtr);
+ }
}
-
return NoSymbol;
}
+
+KeySym
+XKeycodeToKeysym(
+ TCL_UNUSED(Display *),
+ unsigned int keycode,
+ int index)
+{
+ return XkbKeycodeToKeysym(NULL, keycode, 0, index);
+}
/*
*----------------------------------------------------------------------
*
* TkpGetString --
*
- * Retrieve the string equivalent for the given keyboard event.
+ * This is a stub function which retrieves the string stored in the
+ * transchars field of an XEvent and converts it to a Tcl_DString.
*
* Results:
- * Returns the UTF string.
+ * Returns a pointer to the string value of the DString.
*
* Side effects:
* None.
@@ -443,8 +496,18 @@ TkpGetString(
* result. */
{
(void) winPtr; /*unused*/
+ MacKeycode macKC;
+ char utfChars[8];
+ int length = 0;
+
+ macKC.uint = eventPtr->xkey.keycode;
+ if (IS_PRINTABLE(macKC.v.keychar)) {
+ length = TkUniCharToUtf(macKC.v.keychar, utfChars);
+ }
+ utfChars[length] = 0;
+
Tcl_DStringInit(dsPtr);
- return Tcl_DStringAppend(dsPtr, eventPtr->xkey.trans_chars, -1);
+ return Tcl_DStringAppend(dsPtr, utfChars, length);
}
/*
@@ -452,10 +515,11 @@ TkpGetString(
*
* XGetModifierMapping --
*
- * Fetch the current keycodes used as modifiers.
+ * X11 stub function to get the keycodes used as modifiers. This
+ * is never called by the macOS port.
*
* Results:
- * Returns a new modifier map.
+ * Returns a newly allocated modifier map.
*
* Side effects:
* Allocates a new modifier map data structure.
@@ -465,17 +529,11 @@ TkpGetString(
XModifierKeymap *
XGetModifierMapping(
- Display *display)
+ TCL_UNUSED(Display *))
{
XModifierKeymap *modmap;
- (void) display; /*unused*/
-
- /*
- * MacOSX doesn't use the key codes for the modifiers for anything, and we
- * don't generate them either. So there is no modifier map.
- */
- modmap = ckalloc(sizeof(XModifierKeymap));
+ modmap = (XModifierKeymap *)ckalloc(sizeof(XModifierKeymap));
modmap->max_keypermod = 0;
modmap->modifiermap = NULL;
return modmap;
@@ -486,7 +544,8 @@ XGetModifierMapping(
*
* XFreeModifiermap --
*
- * Deallocate a modifier map that was created by XGetModifierMapping.
+ * Deallocates a modifier map that was created by XGetModifierMapping.
+ * This is also never called by the macOS port.
*
* Results:
* None.
@@ -513,10 +572,10 @@ XFreeModifiermap(
*
* XKeysymToString, XStringToKeysym --
*
- * These X window functions map keysyms to strings & strings to keysyms.
- * However, Tk already does this for the most common keysyms. Therefore,
- * these functions only need to support keysyms that will be specific to
- * the Macintosh. Currently, there are none.
+ * These X11 stub functions map keysyms to strings & strings to keysyms.
+ * A platform can do its own conversion by defining these and undefining
+ * REDO_KEYSYM_LOOKUP. The macOS port defines REDO_KEYSYM_LOOKUP so these
+ * are never called and Tk does the conversion for us.
*
* Results:
* None.
@@ -531,6 +590,8 @@ char *
XKeysymToString(
KeySym keysym)
{
+ (void)keysym;
+
return NULL;
}
@@ -538,20 +599,25 @@ KeySym
XStringToKeysym(
const char* string)
{
+ (void)string;
+
return NoSymbol;
}
/*
*----------------------------------------------------------------------
*
- * XKeysymToMacKeycode --
+ * XKeysymToKeycode --
*
- * An internal function like XKeysymToKeycode but only generating the Mac
- * specific keycode plus the modifiers Shift and Option.
+ * This is a stub function which converts a numerical keysym to the
+ * platform-specific keycode used in a KeyPress or KeyRelease XEvent.
+ * For macOS the keycode is an unsigned int with bitfields described
+ * in the definition of the MacKeycode type.
*
* Results:
- * A Mac keycode with the actual keycode in the low byte and Mac-style
- * modifier bits in the high byte.
+ *
+ * A macOS KeyCode. See the description of keycodes at the top of this
+ * file and the definition of the MacKeycode type in tkMacOSXPrivate.h.
*
* Side effects:
* None.
@@ -559,103 +625,52 @@ XStringToKeysym(
*----------------------------------------------------------------------
*/
-static int
-XKeysymToMacKeycode(
- Display *display,
+KeyCode
+XKeysymToKeycode(
+ TCL_UNUSED(Display *),
KeySym keysym)
{
- KeyInfo *kPtr;
- if (keysym <= LATIN1_MAX) {
- /*
- * Handle keysyms in the Latin-1 range where keysym and Unicode
- * character code point are the same.
- */
-
- if (keyboardChanged) {
- InitLatin1Table(display);
- keyboardChanged = 0;
- }
- return latin1Table[keysym];
- }
-
- /*
- * Handle special keys from our exception tables. Don't mind if this is
- * slow, neither the test suite nor [event generate] need to be optimized
- * (we hope).
- */
-
- for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
- if (kPtr->keysym == keysym) {
- return kPtr->keycode;
- }
- }
- for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) {
- if (kPtr->keysym == keysym) {
- return kPtr->keycode;
- }
+ Tcl_HashEntry *hPtr;
+ MacKeycode macKC;
+ if (!initialized) {
+ InitHashTables();
}
/*
- * Modifier keycodes only come from generated events. No translation
- * is needed.
+ * First check for a special key.
*/
- for (int i=0; i < NUM_MOD_KEYCODES; i++) {
- if (keysym == modKeyArray[i]) {
- return keysym;
- }
+ hPtr = Tcl_FindHashEntry(&keysym2keycode, INT2PTR(keysym));
+ if (hPtr != NULL) {
+ return (KeyCode) Tcl_GetHashValue(hPtr);
}
/*
- * For other keysyms (not Latin-1 and not special keys), we'd need a
- * generic keysym-to-unicode table. We don't have that, so we give up here.
+ * Initialize the keycode as if the keysym cannot be converted to anything
+ * else.
*/
- return 0;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * XKeysymToKeycode --
- *
- * The function XKeysymToKeycode takes an X11 keysym and converts it into
- * a Mac keycode. It is in the stubs table for compatibility but not used
- * anywhere in the core.
- *
- * Results:
- * A 32 bit keycode with the the mac keycode (without modifiers) in the
- * higher 16 bits of the keycode and the ASCII or Latin-1 code in the
- * lower 8 bits of the keycode.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-KeyCode
-XKeysymToKeycode(
- Display* display,
- KeySym keysym)
-{
- int macKeycode = XKeysymToMacKeycode(display, keysym);
- KeyCode result;
+ macKC.v.virtual = NO_VIRTUAL;
+ macKC.v.o_s = 0;
+ macKC.v.keychar = 0;
/*
- * See also TkpSetKeycodeAndState. The 0x0010 magic is used in
- * XKeycodeToKeysym. For special keys like XK_Return the lower 8 bits of
- * the keysym are usually a related ASCII control code.
+ * If the keysym is recognized fill in the keychar. Also fill in the
+ * xvirtual field if the key exists on the current keyboard.
*/
- if ((keysym >= XK_F1) && (keysym <= XK_F35)) {
- result = 0x0010;
- } else {
- result = 0x00FF & keysym;
+ hPtr = (Tcl_HashEntry *) Tcl_FindHashEntry(&keysym2unichar,
+ INT2PTR(keysym));
+ if (hPtr != NULL) {
+ unsigned long data = (unsigned long) Tcl_GetHashValue(hPtr);
+ macKC.x.keychar = (unsigned int) data;
+ hPtr = Tcl_FindHashEntry(&unichar2xvirtual, INT2PTR(macKC.x.keychar));
+ if (hPtr != NULL) {
+ unsigned long data = (unsigned long) Tcl_GetHashValue(hPtr);
+ macKC.x.xvirtual = (unsigned int) data;
+ }
}
- result |= (macKeycode & MAC_KEYCODE_MASK) << 16;
-
- return result;
+ return (KeyCode) macKC.uint;
}
/*
@@ -663,66 +678,68 @@ XKeysymToKeycode(
*
* TkpSetKeycodeAndState --
*
- * The function TkpSetKeycodeAndState takes a keysym and fills in the
- * appropriate members of an XEvent. It is similar to XKeysymToKeycode,
- * but it also sets the modifier mask in the XEvent. It is used by [event
- * generate] and it is in the stubs table.
+ * This function accepts a keysym and an XEvent and sets some fields of
+ * the XEvent. It is used by the event generate command.
*
* Results:
- * Fills an XEvent, sets the member xkey.keycode with a keycode
- * formatted the same as XKeysymToKeycode and the member xkey.state with
- * the modifiers implied by the keysym. Also fills in xkey.trans_chars,
- * so that the actual characters can be retrieved later.
+ * None
*
* Side effects:
- * None.
+ *
+ * Modifies the XEvent. Sets the xkey.keycode to a keycode value formatted
+ * by XKeysymToKeycode and updates the shift and option flags in
+ * xkey.state if either of those modifiers is required to generate the
+ * keysym.
*
*----------------------------------------------------------------------
*/
-
void
TkpSetKeycodeAndState(
- Tk_Window tkwin,
+ TCL_UNUSED(Tk_Window),
KeySym keysym,
XEvent *eventPtr)
{
if (keysym == NoSymbol) {
eventPtr->xkey.keycode = 0;
- } else if ( modKeyArray[0] <= keysym &&
- keysym <= modKeyArray[NUM_MOD_KEYCODES - 1]) {
- /*
- * Keysyms for pure modifiers only arise in generated events.
- * We should just copy them to the keycode.
- */
- eventPtr->xkey.keycode = keysym;
} else {
- Display *display = Tk_Display(tkwin);
- int macKeycode = XKeysymToMacKeycode(display, keysym);
+ int eventIndex = STATE2INDEX(eventPtr->xkey.state);
+ MacKeycode macKC;
+ macKC.uint = XKeysymToKeycode(NULL, keysym);
/*
- * See also XKeysymToKeycode.
+ * We have a virtual keycode and a minimal choice for Shift and Option
+ * modifiers which generates the keychar that corresponds to the
+ * specified keysym. But we might not have the correct keychar yet,
+ * because the xEvent may have specified modifiers beyond our minimal
+ * set. For example, the events described by <Oslash>, <Shift-oslash>,
+ * <Shift-Option-O> and <Shift-Option-o> should all produce the same
+ * uppercase Danish O. So we may need to add the extra modifiers and
+ * do another lookup for the keychar. We don't want to do this for
+ * special keys, however.
*/
- if ((keysym >= XK_F1) && (keysym <= XK_F35)) {
- eventPtr->xkey.keycode = 0x0010;
- } else {
- eventPtr->xkey.keycode = 0x00FF & keysym;
- }
- eventPtr->xkey.keycode |= (macKeycode & MAC_KEYCODE_MASK) << 16;
- if (shiftKey & macKeycode) {
- eventPtr->xkey.state |= ShiftMask;
- }
- if (optionKey & macKeycode) {
- eventPtr->xkey.state |= OPTION_MASK;
+ if (macKC.v.o_s != eventIndex) {
+ macKC.v.o_s |= eventIndex;
}
-
- if (keysym <= LATIN1_MAX) {
- int done = Tcl_UniCharToUtf(keysym, eventPtr->xkey.trans_chars);
-
- eventPtr->xkey.trans_chars[done] = 0;
- } else {
- eventPtr->xkey.trans_chars[0] = 0;
+ if (macKC.v.keychar < 0xF700) {
+ UniChar keychar = macKC.v.keychar;
+ NSString *str, *lower, *upper;
+ if (macKC.v.virtual != NO_VIRTUAL) {
+ macKC.x.keychar = xvirtual2unichar[macKC.x.xvirtual];
+ } else {
+ str = [[NSString alloc] initWithCharacters:&keychar length:1];
+ lower = [str lowercaseString];
+ upper = [str uppercaseString];
+ if (![str isEqual: lower]) {
+ macKC.v.o_s |= INDEX_SHIFT;
+ }
+ if (macKC.v.o_s & INDEX_SHIFT) {
+ macKC.v.keychar = [upper characterAtIndex:0];
+ }
+ }
}
+ eventPtr->xkey.keycode = macKC.uint;
+ eventPtr->xkey.state |= INDEX2STATE(macKC.v.o_s);
}
}
@@ -731,16 +748,17 @@ TkpSetKeycodeAndState(
*
* TkpGetKeySym --
*
- * Given an X KeyPress or KeyRelease event, map the keycode in the event
- * into a keysym.
+ * This is a stub function called in tkBind.c. Given a KeyPress or
+ * KeyRelease XEvent, it maps the keycode in the event to a numerical
+ * keysym.
*
* Results:
* The return value is the keysym corresponding to eventPtr, or NoSymbol
* if no matching keysym could be found.
*
* Side effects:
- * In the first call for a given display, keycode-to-keysym maps get
- * loaded.
+ * In the first call for a given display, calls TkpInitKeymapInfo.
+ *
*
*----------------------------------------------------------------------
*/
@@ -752,6 +770,8 @@ TkpGetKeySym(
{
KeySym sym;
int index;
+ MacKeycode macKC;
+ macKC.uint = eventPtr->xkey.keycode;
/*
* Refresh the mapping information if it's stale.
@@ -762,101 +782,63 @@ TkpGetKeySym(
}
/*
- * Handle pure modifier keys specially. We use -1 as a signal for
- * this.
+ * Modifier key events have a special mac keycode (see tkProcessKeyEvent).
*/
- if (eventPtr->xany.send_event == -1) {
- int modifier = eventPtr->xkey.keycode & NSDeviceIndependentModifierFlagsMask;
-
- if (modifier == NSCommandKeyMask) {
+ if (macKC.v.keychar == MOD_KEYCHAR) {
+ switch (macKC.v.virtual) {
+ case 54:
+ return XK_Meta_R;
+ case 55:
return XK_Meta_L;
- } else if (modifier == NSShiftKeyMask) {
+ case 56:
return XK_Shift_L;
- } else if (modifier == NSAlphaShiftKeyMask) {
+ case 57:
return XK_Caps_Lock;
- } else if (modifier == NSAlternateKeyMask) {
+ case 58:
return XK_Alt_L;
- } else if (modifier == NSControlKeyMask) {
+ case 59:
return XK_Control_L;
- } else if (modifier == NSNumericPadKeyMask) {
- return XK_Num_Lock;
- } else if (modifier == NSFunctionKeyMask) {
- return XK_Super_L;
-/*
- } else if (modifier == rightShiftKey) {
+ case 60:
return XK_Shift_R;
- } else if (modifier == rightOptionKey) {
+ case 61:
return XK_Alt_R;
- } else if (modifier == rightControlKey) {
+ case 62:
return XK_Control_R;
-*/
- } else {
- /*
- * If we get here, we probably need to implement something new.
- */
-
+ case 63:
+ return XK_Super_L;
+ default:
return NoSymbol;
}
}
- /* If nbytes has been set, it's not a function key, but a regular key that
- has been translated in tkMacOSXKeyEvent.c; just use that. */
- if (eventPtr->xkey.nbytes) {
- return eventPtr->xkey.keycode & 0xFFFF;
- }
-
/*
* Figure out which of the four slots in the keymap vector to use for this
* key. Refer to Xlib documentation for more info on how this computation
- * works. (Note: We use "Option" in keymap columns 2 and 3 where other
- * implementations have "Mode_switch".)
+ * works.
*/
- index = 0;
-
- /*
- * We want Option key combinations to use their base chars as keysyms, so
- * we ignore the option modifier here.
- */
-
-#if 0
- if (eventPtr->xkey.state & OPTION_MASK) {
- index |= 2;
- }
-#endif
-
- if ((eventPtr->xkey.state & ShiftMask)
- || (/* (dispPtr->lockUsage != LU_IGNORE)
- && */ (eventPtr->xkey.state & LockMask))) {
- index |= 1;
+ index = STATE2INDEX(eventPtr->xkey.state);
+ if (eventPtr->xkey.state & LockMask) {
+ index |= INDEX_SHIFT;
}
/*
- * First try of the actual translation.
+ * First do the straightforward lookup.
*/
- sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, index);
+ sym = XkbKeycodeToKeysym(dispPtr->display, macKC.uint, 0, index);
/*
- * Special handling: If the key was shifted because of Lock, but lock is
- * only caps lock, not shift lock, and the shifted keysym isn't upper-case
- * alphabetic, then switch back to the unshifted keysym.
+ * Special handling: If the key was shifted because of Lock, which is only
+ * caps lock on macOS, not shift lock, and if the shifted keysym isn't
+ * upper-case alphabetic, then switch back to the unshifted keysym.
*/
- if ((index & 1) && !(eventPtr->xkey.state & ShiftMask)
- /*&& (dispPtr->lockUsage == LU_CAPS)*/ ) {
- /*
- * FIXME: Keysyms are only identical to Unicode for ASCII and Latin-1,
- * so we can't use Tcl_UniCharIsUpper() for keysyms outside that range.
- * This may be a serious problem here.
- */
-
- if ((sym == NoSymbol) || (sym > LATIN1_MAX)
- || !Tcl_UniCharIsUpper(sym)) {
- index &= ~1;
- sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode,
- index);
+ if ((index & INDEX_SHIFT) && !(eventPtr->xkey.state & ShiftMask)) {
+ if ((sym == NoSymbol) || !Tcl_UniCharIsUpper(sym)) {
+ sym = XkbKeycodeToKeysym(dispPtr->display, macKC.uint, 0,
+ index & ~INDEX_SHIFT);
}
}
@@ -865,9 +847,9 @@ TkpGetKeySym(
* no keysym defined, then use the keysym for the unshifted key.
*/
- if ((index & 1) && (sym == NoSymbol)) {
- sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode,
- index & ~1);
+ if ((index & INDEX_SHIFT) && (sym == NoSymbol)) {
+ sym = XkbKeycodeToKeysym(dispPtr->display, macKC.uint, 0,
+ index & ~INDEX_SHIFT);
}
return sym;
}
@@ -877,15 +859,14 @@ TkpGetKeySym(
*
* TkpInitKeymapInfo --
*
- * This procedure is invoked to scan keymap information to recompute stuff
- * that's important for binding, such as the modifier key (if any) that
- * corresponds to the "Mode_switch" keysym.
+ * This procedure initializes fields in the display that pertain
+ * to modifier keys.
*
* Results:
* None.
*
* Side effects:
- * Keymap-related information in dispPtr is updated.
+ * Modifier key information in dispPtr is initialized.
*
*--------------------------------------------------------------
*/
@@ -898,35 +879,32 @@ TkpInitKeymapInfo(
dispPtr->bindInfoStale = 0;
/*
- * Behaviours that are variable on X11 are defined constant on MacOSX.
- * lockUsage is only used above in TkpGetKeySym(), nowhere else currently.
+ * On macOS the caps lock key is always interpreted to mean that alphabetic
+ * keys become uppercase but other keys do not get shifted. (X11 allows
+ * a configuration option which makes the caps lock equivalent to holding
+ * down the shift key.)
* There is no offical "Mode_switch" key.
*/
dispPtr->lockUsage = LU_CAPS;
+
+ /* This field is no longer used by tkBind.c */
+
dispPtr->modeModMask = 0;
-#if 0
- /*
- * With this, <Alt> and <Meta> become synonyms for <Command> and <Option>
- * in bindings like they are (and always have been) in the keysyms that
- * are reported by KeyPress events. But the init scripts like text.tcl
- * have some disabling bindings for <Meta>, so we don't want this without
- * some changes in those scripts. See also bug #700311.
+ /* The Alt and Meta keys are interchanged on Macintosh keyboards compared
+ * to PC keyboards. These fields could be set to make the Alt key on a PC
+ * keyboard behave likd an Alt key. That would also require interchanging
+ * Mod1Mask and Mod2Mask in tkMacOSXKeyEvent.c.
*/
- dispPtr->altModMask = OPTION_MASK;
- dispPtr->metaModMask = COMMAND_MASK;
-#else
dispPtr->altModMask = 0;
dispPtr->metaModMask = 0;
-#endif
/*
- * MacOSX doesn't create a key event when a modifier key is pressed or
- * released. However, it is possible to generate key events for
- * modifier keys, and this is done in the tests. So we construct an array
- * containing the keycodes of the standard modifier keys from static data.
+ * The modKeyCodes table lists the keycodes that appear in KeyPress or
+ * KeyRelease XEvents for modifier keys. In tkBind.c this table is
+ * searched to determine whether an XEvent corresponds to a modifier key.
*/
if (dispPtr->modKeyCodes != NULL) {
@@ -935,11 +913,56 @@ TkpInitKeymapInfo(
dispPtr->numModKeyCodes = NUM_MOD_KEYCODES;
dispPtr->modKeyCodes = (KeyCode *)ckalloc(NUM_MOD_KEYCODES * sizeof(KeyCode));
for (int i = 0; i < NUM_MOD_KEYCODES; i++) {
- dispPtr->modKeyCodes[i] = modKeyArray[i];
+ dispPtr->modKeyCodes[i] = XKeysymToKeycode(NULL, modKeyArray[i]);
}
}
/*
+ *--------------------------------------------------------------
+ *
+ * TkMacOSXAddVirtual --
+ *
+ * This procedure is an internal utility which accepts an unsigned int
+ * that has been partially filled as a MacKeycode, having the Option and
+ * Shift state set in the o_s field and the keychar field set but with the
+ * virtual keycode blank. It looks up the virtual keycode for the keychar
+ * (possibly NO_VIRTUAL) and returns an unsigned int which is a complete
+ * MacKeycode with the looked up virtual keycode added. This is used when
+ * creating XEvents for the unicode characters which are generated by the
+ * NSTextInputClient.
+ *
+ * Results:
+ * An unsigned int which is a complete MacKeycode, including a virtual
+ * keycode which matches the Option-Shift state and keychar.
+ *
+ * Side effects:
+ * None
+ *
+ *--------------------------------------------------------------
+ */
+unsigned
+TkMacOSXAddVirtual(
+ unsigned int keycode)
+{
+ MacKeycode macKC;
+ Tcl_HashEntry *hPtr;
+ macKC.uint = keycode;
+
+ if (!initialized) {
+ InitHashTables();
+ }
+
+ hPtr = (Tcl_HashEntry *) Tcl_FindHashEntry(&unichar2xvirtual,
+ INT2PTR(macKC.v.keychar));
+ if (hPtr != NULL) {
+ unsigned long data = (unsigned long) Tcl_GetHashValue(hPtr);
+ macKC.x.xvirtual = (unsigned int) data;
+ } else {
+ macKC.v.virtual = NO_VIRTUAL;
+ }
+ return macKC.uint;
+}
+/*
* Local Variables:
* mode: objc
* c-basic-offset: 4
diff --git a/macosx/tkMacOSXKeysyms.h b/macosx/tkMacOSXKeysyms.h
new file mode 100644
index 0000000..726f318
--- /dev/null
+++ b/macosx/tkMacOSXKeysyms.h
@@ -0,0 +1,1308 @@
+/*
+ * tkMacOSXKeysyms.h --
+ *
+ * Contains data used for processing key events, some of which was
+ * moved from tkMacOSXKeyboard.c.
+ *
+ * Copyright (c) 1990-1994 The Regents of the University of California.
+ * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright (c) 2020 Marc Culler
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+#ifndef TKMACOSXKEYSYMS_H
+#define TKMACOSXKEYSYMS_H 1
+
+/*
+ * This table enumerates the keys on Mac keyboards which do not represent
+ * letters. This is static data -- these keys do not change when the keyboard
+ * layout changes. The unicode representation of a special key which is not a
+ * modifier and does not have an ASCII code point lies in the reserved range
+ * 0xF700 - 0xF8FF.
+ *
+ * The table includes every key listed in Apple's documentation of Function-Key
+ * Unicodes which is not marked as "Not on most Macintosh keyboards", as well
+ * as F20, which is reported to be usable in scripts even though it does not
+ * appear on any Macintosh keyboard.
+ */
+
+typedef struct {
+ int virtual; /* value of [NSEvent keyCode] */
+ KeySym keysym; /* X11 keysym */
+ KeyCode keychar; /* XEvent keycode & 0xFFFF */
+} KeyInfo;
+
+static const KeyInfo keyArray[] = {
+ {36, XK_Return, NSNewlineCharacter},
+ {48, XK_Tab, NSTabCharacter},
+ {51, XK_BackSpace, NSDeleteCharacter},
+ {52, XK_Return, NSNewlineCharacter}, /* Used on some Powerbooks */
+ {53, XK_Escape, 0x1B},
+ {54, XK_Meta_R, MOD_KEYCHAR},
+ {55, XK_Meta_L, MOD_KEYCHAR},
+ {56, XK_Shift_L, MOD_KEYCHAR},
+ {57, XK_Caps_Lock, MOD_KEYCHAR},
+ {58, XK_Alt_L, MOD_KEYCHAR},
+ {59, XK_Control_L, MOD_KEYCHAR},
+ {60, XK_Shift_R, MOD_KEYCHAR},
+ {61, XK_Alt_R, MOD_KEYCHAR},
+ {62, XK_Control_R, MOD_KEYCHAR},
+ {63, XK_Super_L, MOD_KEYCHAR},
+ {64, XK_F17, NSF17FunctionKey},
+ {65, XK_KP_Decimal, '.'},
+ {67, XK_KP_Multiply, '*'},
+ {69, XK_KP_Add, '+'},
+ {71, XK_Clear, NSClearLineFunctionKey}, /* Numlock on PC */
+ {75, XK_KP_Divide, '/'},
+ {76, XK_KP_Enter, NSEnterCharacter}, /* Fn Return */
+ {78, XK_KP_Subtract, '-'},
+ {79, XK_F18, NSF18FunctionKey},
+ {80, XK_F19, NSF19FunctionKey},
+ {81, XK_KP_Equal, '='},
+ {82, XK_KP_0, '0'},
+ {83, XK_KP_1, '1'},
+ {84, XK_KP_2, '2'},
+ {85, XK_KP_3, '3'},
+ {86, XK_KP_4, '4'},
+ {87, XK_KP_5, '5'},
+ {88, XK_KP_6, '6'},
+ {89, XK_KP_7, '7'},
+ {90, XK_F20, NSF20FunctionKey}, /* For scripting only */
+ {91, XK_KP_8, '8'},
+ {92, XK_KP_9, '9'},
+ {96, XK_F5, NSF5FunctionKey},
+ {97, XK_F6, NSF6FunctionKey},
+ {98, XK_F7, NSF7FunctionKey},
+ {99, XK_F3, NSF3FunctionKey},
+ {100, XK_F8, NSF8FunctionKey},
+ {101, XK_F9, NSF9FunctionKey},
+ {103, XK_F11, NSF11FunctionKey},
+ {105, XK_F13, NSF13FunctionKey},
+ {106, XK_F16, NSF16FunctionKey},
+ {107, XK_F14, NSF14FunctionKey},
+ {109, XK_F10, NSF10FunctionKey},
+ {110, XK_Menu, UNKNOWN_KEYCHAR},
+ {111, XK_F12, NSF12FunctionKey},
+ {113, XK_F15, NSF15FunctionKey},
+ {114, XK_Help, NSHelpFunctionKey},
+ {115, XK_Home, NSHomeFunctionKey}, /* Fn Left */
+ {116, XK_Page_Up, NSPageUpFunctionKey}, /* Fn Up */
+ {117, XK_Delete, NSDeleteFunctionKey}, /* Fn Deleete */
+ {118, XK_F4, NSF4FunctionKey},
+ {119, XK_End, NSEndFunctionKey}, /* Fn Right */
+ {120, XK_F2, NSF2FunctionKey},
+ {121, XK_Page_Down, NSPageDownFunctionKey}, /* Fn Down */
+ {122, XK_F1, NSF1FunctionKey},
+ {123, XK_Left, NSLeftArrowFunctionKey},
+ {124, XK_Right, NSRightArrowFunctionKey},
+ {125, XK_Down, NSDownArrowFunctionKey},
+ {126, XK_Up, NSUpArrowFunctionKey},
+ {0, 0, 0}
+};
+
+/*
+ * X11 keysyms for modifier keys, in order. This list includes keys
+ * which do not appear on Apple keyboards, such as Shift_Lock and
+ * Super_R. While most systems don't provide events for the "fn"
+ * function key, Apple does. We map it to Super_L when processing a
+ * FlagsChanged NSEvent.
+ */
+
+#define NUM_MOD_KEYCODES 14
+static const KeyCode modKeyArray[NUM_MOD_KEYCODES] = {
+ XK_Shift_L,
+ XK_Shift_R,
+ XK_Control_L,
+ XK_Control_R,
+ XK_Caps_Lock,
+ XK_Shift_Lock,
+ XK_Meta_L,
+ XK_Meta_R,
+ XK_Alt_L,
+ XK_Alt_R,
+ XK_Super_L,
+ XK_Super_R,
+ XK_Hyper_L,
+ XK_Hyper_R,
+};
+
+/*
+ * This table pairs X11 Keysyms for alphanumeric characters with the
+ * unicode code point for that letter.
+ * The data comes from http://www.cl.cam.ac.uk/~mgk25/ucs/keysyms.txt
+ */
+
+typedef struct KeysymInfo {
+ KeySym keysym;
+ KeyCode keycode;
+} KeysymInfo;
+
+const KeysymInfo keysymTable[] = {
+ {0x0020, 0x0020}, /* space */
+ {0x0021, 0x0021}, /* exclam */
+ {0x0022, 0x0022}, /* quotedbl */
+ {0x0023, 0x0023}, /* numbersign */
+ {0x0024, 0x0024}, /* dollar */
+ {0x0025, 0x0025}, /* percent */
+ {0x0026, 0x0026}, /* ampersand */
+ {0x0027, 0x0027}, /* apostrophe */
+ {0x0028, 0x0028}, /* parenleft */
+ {0x0029, 0x0029}, /* parenright */
+ {0x002a, 0x002a}, /* asterisk */
+ {0x002b, 0x002b}, /* plus */
+ {0x002c, 0x002c}, /* comma */
+ {0x002d, 0x002d}, /* minus */
+ {0x002e, 0x002e}, /* period */
+ {0x002f, 0x002f}, /* slash */
+ {0x0030, 0x0030}, /* 0 */
+ {0x0031, 0x0031}, /* 1 */
+ {0x0032, 0x0032}, /* 2 */
+ {0x0033, 0x0033}, /* 3 */
+ {0x0034, 0x0034}, /* 4 */
+ {0x0035, 0x0035}, /* 5 */
+ {0x0036, 0x0036}, /* 6 */
+ {0x0037, 0x0037}, /* 7 */
+ {0x0038, 0x0038}, /* 8 */
+ {0x0039, 0x0039}, /* 9 */
+ {0x003a, 0x003a}, /* colon */
+ {0x003b, 0x003b}, /* semicolon */
+ {0x003c, 0x003c}, /* less */
+ {0x003d, 0x003d}, /* equal */
+ {0x003e, 0x003e}, /* greater */
+ {0x003f, 0x003f}, /* question */
+ {0x0040, 0x0040}, /* at */
+ {0x0041, 0x0041}, /* A */
+ {0x0042, 0x0042}, /* B */
+ {0x0043, 0x0043}, /* C */
+ {0x0044, 0x0044}, /* D */
+ {0x0045, 0x0045}, /* E */
+ {0x0046, 0x0046}, /* F */
+ {0x0047, 0x0047}, /* G */
+ {0x0048, 0x0048}, /* H */
+ {0x0049, 0x0049}, /* I */
+ {0x004a, 0x004a}, /* J */
+ {0x004b, 0x004b}, /* K */
+ {0x004c, 0x004c}, /* L */
+ {0x004d, 0x004d}, /* M */
+ {0x004e, 0x004e}, /* N */
+ {0x004f, 0x004f}, /* O */
+ {0x0050, 0x0050}, /* P */
+ {0x0051, 0x0051}, /* Q */
+ {0x0052, 0x0052}, /* R */
+ {0x0053, 0x0053}, /* S */
+ {0x0054, 0x0054}, /* T */
+ {0x0055, 0x0055}, /* U */
+ {0x0056, 0x0056}, /* V */
+ {0x0057, 0x0057}, /* W */
+ {0x0058, 0x0058}, /* X */
+ {0x0059, 0x0059}, /* Y */
+ {0x005a, 0x005a}, /* Z */
+ {0x005b, 0x005b}, /* bracketleft */
+ {0x005c, 0x005c}, /* backslash */
+ {0x005d, 0x005d}, /* bracketright */
+ {0x005e, 0x005e}, /* asciicircum */
+ {0x005f, 0x005f}, /* underscore */
+ {0x0060, 0x0060}, /* grave */
+ {0x0061, 0x0061}, /* a */
+ {0x0062, 0x0062}, /* b */
+ {0x0063, 0x0063}, /* c */
+ {0x0064, 0x0064}, /* d */
+ {0x0065, 0x0065}, /* e */
+ {0x0066, 0x0066}, /* f */
+ {0x0067, 0x0067}, /* g */
+ {0x0068, 0x0068}, /* h */
+ {0x0069, 0x0069}, /* i */
+ {0x006a, 0x006a}, /* j */
+ {0x006b, 0x006b}, /* k */
+ {0x006c, 0x006c}, /* l */
+ {0x006d, 0x006d}, /* m */
+ {0x006e, 0x006e}, /* n */
+ {0x006f, 0x006f}, /* o */
+ {0x0070, 0x0070}, /* p */
+ {0x0071, 0x0071}, /* q */
+ {0x0072, 0x0072}, /* r */
+ {0x0073, 0x0073}, /* s */
+ {0x0074, 0x0074}, /* t */
+ {0x0075, 0x0075}, /* u */
+ {0x0076, 0x0076}, /* v */
+ {0x0077, 0x0077}, /* w */
+ {0x0078, 0x0078}, /* x */
+ {0x0079, 0x0079}, /* y */
+ {0x007a, 0x007a}, /* z */
+ {0x007b, 0x007b}, /* braceleft */
+ {0x007c, 0x007c}, /* bar */
+ {0x007d, 0x007d}, /* braceright */
+ {0x007e, 0x007e}, /* asciitilde */
+ {0x00a0, 0x00a0}, /* nobreakspace */
+ {0x00a1, 0x00a1}, /* exclamdown */
+ {0x00a2, 0x00a2}, /* cent */
+ {0x00a3, 0x00a3}, /* sterling */
+ {0x00a4, 0x00a4}, /* currency */
+ {0x00a5, 0x00a5}, /* yen */
+ {0x00a6, 0x00a6}, /* brokenbar */
+ {0x00a7, 0x00a7}, /* section */
+ {0x00a8, 0x00a8}, /* diaeresis */
+ {0x00a9, 0x00a9}, /* copyright */
+ {0x00aa, 0x00aa}, /* ordfeminine */
+ {0x00ab, 0x00ab}, /* guillemotleft */
+ {0x00ac, 0x00ac}, /* notsign */
+ {0x00ad, 0x00ad}, /* hyphen */
+ {0x00ae, 0x00ae}, /* registered */
+ {0x00af, 0x00af}, /* macron */
+ {0x00b0, 0x00b0}, /* degree */
+ {0x00b1, 0x00b1}, /* plusminus */
+ {0x00b2, 0x00b2}, /* twosuperior */
+ {0x00b3, 0x00b3}, /* threesuperior */
+ {0x00b4, 0x00b4}, /* acute */
+ {0x00b5, 0x00b5}, /* mu */
+ {0x00b6, 0x00b6}, /* paragraph */
+ {0x00b7, 0x00b7}, /* periodcentered */
+ {0x00b8, 0x00b8}, /* cedilla */
+ {0x00b9, 0x00b9}, /* onesuperior */
+ {0x00ba, 0x00ba}, /* masculine */
+ {0x00bb, 0x00bb}, /* guillemotright */
+ {0x00bc, 0x00bc}, /* onequarter */
+ {0x00bd, 0x00bd}, /* onehalf */
+ {0x00be, 0x00be}, /* threequarters */
+ {0x00bf, 0x00bf}, /* questiondown */
+ {0x00c0, 0x00c0}, /* Agrave */
+ {0x00c1, 0x00c1}, /* Aacute */
+ {0x00c2, 0x00c2}, /* Acircumflex */
+ {0x00c3, 0x00c3}, /* Atilde */
+ {0x00c4, 0x00c4}, /* Adiaeresis */
+ {0x00c5, 0x00c5}, /* Aring */
+ {0x00c6, 0x00c6}, /* AE */
+ {0x00c7, 0x00c7}, /* Ccedilla */
+ {0x00c8, 0x00c8}, /* Egrave */
+ {0x00c9, 0x00c9}, /* Eacute */
+ {0x00ca, 0x00ca}, /* Ecircumflex */
+ {0x00cb, 0x00cb}, /* Ediaeresis */
+ {0x00cc, 0x00cc}, /* Igrave */
+ {0x00cd, 0x00cd}, /* Iacute */
+ {0x00ce, 0x00ce}, /* Icircumflex */
+ {0x00cf, 0x00cf}, /* Idiaeresis */
+ {0x00d0, 0x00d0}, /* ETH */
+ {0x00d1, 0x00d1}, /* Ntilde */
+ {0x00d2, 0x00d2}, /* Ograve */
+ {0x00d3, 0x00d3}, /* Oacute */
+ {0x00d4, 0x00d4}, /* Ocircumflex */
+ {0x00d5, 0x00d5}, /* Otilde */
+ {0x00d6, 0x00d6}, /* Odiaeresis */
+ {0x00d7, 0x00d7}, /* multiply */
+ {0x00d8, 0x00d8}, /* Ooblique */
+ {0x00d9, 0x00d9}, /* Ugrave */
+ {0x00da, 0x00da}, /* Uacute */
+ {0x00db, 0x00db}, /* Ucircumflex */
+ {0x00dc, 0x00dc}, /* Udiaeresis */
+ {0x00dd, 0x00dd}, /* Yacute */
+ {0x00de, 0x00de}, /* THORN */
+ {0x00df, 0x00df}, /* ssharp */
+ {0x00e0, 0x00e0}, /* agrave */
+ {0x00e1, 0x00e1}, /* aacute */
+ {0x00e2, 0x00e2}, /* acircumflex */
+ {0x00e3, 0x00e3}, /* atilde */
+ {0x00e4, 0x00e4}, /* adiaeresis */
+ {0x00e5, 0x00e5}, /* aring */
+ {0x00e6, 0x00e6}, /* ae */
+ {0x00e7, 0x00e7}, /* ccedilla */
+ {0x00e8, 0x00e8}, /* egrave */
+ {0x00e9, 0x00e9}, /* eacute */
+ {0x00ea, 0x00ea}, /* ecircumflex */
+ {0x00eb, 0x00eb}, /* ediaeresis */
+ {0x00ec, 0x00ec}, /* igrave */
+ {0x00ed, 0x00ed}, /* iacute */
+ {0x00ee, 0x00ee}, /* icircumflex */
+ {0x00ef, 0x00ef}, /* idiaeresis */
+ {0x00f0, 0x00f0}, /* eth */
+ {0x00f1, 0x00f1}, /* ntilde */
+ {0x00f2, 0x00f2}, /* ograve */
+ {0x00f3, 0x00f3}, /* oacute */
+ {0x00f4, 0x00f4}, /* ocircumflex */
+ {0x00f5, 0x00f5}, /* otilde */
+ {0x00f6, 0x00f6}, /* odiaeresis */
+ {0x00f7, 0x00f7}, /* division */
+ {0x00f8, 0x00f8}, /* oslash */
+ {0x00f9, 0x00f9}, /* ugrave */
+ {0x00fa, 0x00fa}, /* uacute */
+ {0x00fb, 0x00fb}, /* ucircumflex */
+ {0x00fc, 0x00fc}, /* udiaeresis */
+ {0x00fd, 0x00fd}, /* yacute */
+ {0x00fe, 0x00fe}, /* thorn */
+ {0x00ff, 0x00ff}, /* ydiaeresis */
+ {0x01a1, 0x0104}, /* Aogonek */
+ {0x01a2, 0x02d8}, /* breve */
+ {0x01a3, 0x0141}, /* Lstroke */
+ {0x01a5, 0x013d}, /* Lcaron */
+ {0x01a6, 0x015a}, /* Sacute */
+ {0x01a9, 0x0160}, /* Scaron */
+ {0x01aa, 0x015e}, /* Scedilla */
+ {0x01ab, 0x0164}, /* Tcaron */
+ {0x01ac, 0x0179}, /* Zacute */
+ {0x01ae, 0x017d}, /* Zcaron */
+ {0x01af, 0x017b}, /* Zabovedot */
+ {0x01b1, 0x0105}, /* aogonek */
+ {0x01b2, 0x02db}, /* ogonek */
+ {0x01b3, 0x0142}, /* lstroke */
+ {0x01b5, 0x013e}, /* lcaron */
+ {0x01b6, 0x015b}, /* sacute */
+ {0x01b7, 0x02c7}, /* caron */
+ {0x01b9, 0x0161}, /* scaron */
+ {0x01ba, 0x015f}, /* scedilla */
+ {0x01bb, 0x0165}, /* tcaron */
+ {0x01bc, 0x017a}, /* zacute */
+ {0x01bd, 0x02dd}, /* doubleacute */
+ {0x01be, 0x017e}, /* zcaron */
+ {0x01bf, 0x017c}, /* zabovedot */
+ {0x01c0, 0x0154}, /* Racute */
+ {0x01c3, 0x0102}, /* Abreve */
+ {0x01c5, 0x0139}, /* Lacute */
+ {0x01c6, 0x0106}, /* Cacute */
+ {0x01c8, 0x010c}, /* Ccaron */
+ {0x01ca, 0x0118}, /* Eogonek */
+ {0x01cc, 0x011a}, /* Ecaron */
+ {0x01cf, 0x010e}, /* Dcaron */
+ {0x01d0, 0x0110}, /* Dstroke */
+ {0x01d1, 0x0143}, /* Nacute */
+ {0x01d2, 0x0147}, /* Ncaron */
+ {0x01d5, 0x0150}, /* Odoubleacute */
+ {0x01d8, 0x0158}, /* Rcaron */
+ {0x01d9, 0x016e}, /* Uring */
+ {0x01db, 0x0170}, /* Udoubleacute */
+ {0x01de, 0x0162}, /* Tcedilla */
+ {0x01e0, 0x0155}, /* racute */
+ {0x01e3, 0x0103}, /* abreve */
+ {0x01e5, 0x013a}, /* lacute */
+ {0x01e6, 0x0107}, /* cacute */
+ {0x01e8, 0x010d}, /* ccaron */
+ {0x01ea, 0x0119}, /* eogonek */
+ {0x01ec, 0x011b}, /* ecaron */
+ {0x01ef, 0x010f}, /* dcaron */
+ {0x01f0, 0x0111}, /* dstroke */
+ {0x01f1, 0x0144}, /* nacute */
+ {0x01f2, 0x0148}, /* ncaron */
+ {0x01f5, 0x0151}, /* odoubleacute */
+ {0x01f8, 0x0159}, /* rcaron */
+ {0x01f9, 0x016f}, /* uring */
+ {0x01fb, 0x0171}, /* udoubleacute */
+ {0x01fe, 0x0163}, /* tcedilla */
+ {0x01ff, 0x02d9}, /* abovedot */
+ {0x02a1, 0x0126}, /* Hstroke */
+ {0x02a6, 0x0124}, /* Hcircumflex */
+ {0x02a9, 0x0130}, /* Iabovedot */
+ {0x02ab, 0x011e}, /* Gbreve */
+ {0x02ac, 0x0134}, /* Jcircumflex */
+ {0x02b1, 0x0127}, /* hstroke */
+ {0x02b6, 0x0125}, /* hcircumflex */
+ {0x02b9, 0x0131}, /* idotless */
+ {0x02bb, 0x011f}, /* gbreve */
+ {0x02bc, 0x0135}, /* jcircumflex */
+ {0x02c5, 0x010a}, /* Cabovedot */
+ {0x02c6, 0x0108}, /* Ccircumflex */
+ {0x02d5, 0x0120}, /* Gabovedot */
+ {0x02d8, 0x011c}, /* Gcircumflex */
+ {0x02dd, 0x016c}, /* Ubreve */
+ {0x02de, 0x015c}, /* Scircumflex */
+ {0x02e5, 0x010b}, /* cabovedot */
+ {0x02e6, 0x0109}, /* ccircumflex */
+ {0x02f5, 0x0121}, /* gabovedot */
+ {0x02f8, 0x011d}, /* gcircumflex */
+ {0x02fd, 0x016d}, /* ubreve */
+ {0x02fe, 0x015d}, /* scircumflex */
+ {0x03a2, 0x0138}, /* kra */
+ {0x03a3, 0x0156}, /* Rcedilla */
+ {0x03a5, 0x0128}, /* Itilde */
+ {0x03a6, 0x013b}, /* Lcedilla */
+ {0x03aa, 0x0112}, /* Emacron */
+ {0x03ab, 0x0122}, /* Gcedilla */
+ {0x03ac, 0x0166}, /* Tslash */
+ {0x03b3, 0x0157}, /* rcedilla */
+ {0x03b5, 0x0129}, /* itilde */
+ {0x03b6, 0x013c}, /* lcedilla */
+ {0x03ba, 0x0113}, /* emacron */
+ {0x03bb, 0x0123}, /* gcedilla */
+ {0x03bc, 0x0167}, /* tslash */
+ {0x03bd, 0x014a}, /* ENG */
+ {0x03bf, 0x014b}, /* eng */
+ {0x03c0, 0x0100}, /* Amacron */
+ {0x03c7, 0x012e}, /* Iogonek */
+ {0x03cc, 0x0116}, /* Eabovedot */
+ {0x03cf, 0x012a}, /* Imacron */
+ {0x03d1, 0x0145}, /* Ncedilla */
+ {0x03d2, 0x014c}, /* Omacron */
+ {0x03d3, 0x0136}, /* Kcedilla */
+ {0x03d9, 0x0172}, /* Uogonek */
+ {0x03dd, 0x0168}, /* Utilde */
+ {0x03de, 0x016a}, /* Umacron */
+ {0x03e0, 0x0101}, /* amacron */
+ {0x03e7, 0x012f}, /* iogonek */
+ {0x03ec, 0x0117}, /* eabovedot */
+ {0x03ef, 0x012b}, /* imacron */
+ {0x03f1, 0x0146}, /* ncedilla */
+ {0x03f2, 0x014d}, /* omacron */
+ {0x03f3, 0x0137}, /* kcedilla */
+ {0x03f9, 0x0173}, /* uogonek */
+ {0x03fd, 0x0169}, /* utilde */
+ {0x03fe, 0x016b}, /* umacron */
+ {0x047e, 0x203e}, /* overline */
+ {0x04a1, 0x3002}, /* kana_fullstop */
+ {0x04a2, 0x300c}, /* kana_openingbracket */
+ {0x04a3, 0x300d}, /* kana_closingbracket */
+ {0x04a4, 0x3001}, /* kana_comma */
+ {0x04a5, 0x30fb}, /* kana_conjunctive */
+ {0x04a6, 0x30f2}, /* kana_WO */
+ {0x04a7, 0x30a1}, /* kana_a */
+ {0x04a8, 0x30a3}, /* kana_i */
+ {0x04a9, 0x30a5}, /* kana_u */
+ {0x04aa, 0x30a7}, /* kana_e */
+ {0x04ab, 0x30a9}, /* kana_o */
+ {0x04ac, 0x30e3}, /* kana_ya */
+ {0x04ad, 0x30e5}, /* kana_yu */
+ {0x04ae, 0x30e7}, /* kana_yo */
+ {0x04af, 0x30c3}, /* kana_tsu */
+ {0x04b0, 0x30fc}, /* prolongedsound */
+ {0x04b1, 0x30a2}, /* kana_A */
+ {0x04b2, 0x30a4}, /* kana_I */
+ {0x04b3, 0x30a6}, /* kana_U */
+ {0x04b4, 0x30a8}, /* kana_E */
+ {0x04b5, 0x30aa}, /* kana_O */
+ {0x04b6, 0x30ab}, /* kana_KA */
+ {0x04b7, 0x30ad}, /* kana_KI */
+ {0x04b8, 0x30af}, /* kana_KU */
+ {0x04b9, 0x30b1}, /* kana_KE */
+ {0x04ba, 0x30b3}, /* kana_KO */
+ {0x04bb, 0x30b5}, /* kana_SA */
+ {0x04bc, 0x30b7}, /* kana_SHI */
+ {0x04bd, 0x30b9}, /* kana_SU */
+ {0x04be, 0x30bb}, /* kana_SE */
+ {0x04bf, 0x30bd}, /* kana_SO */
+ {0x04c0, 0x30bf}, /* kana_TA */
+ {0x04c1, 0x30c1}, /* kana_CHI */
+ {0x04c2, 0x30c4}, /* kana_TSU */
+ {0x04c3, 0x30c6}, /* kana_TE */
+ {0x04c4, 0x30c8}, /* kana_TO */
+ {0x04c5, 0x30ca}, /* kana_NA */
+ {0x04c6, 0x30cb}, /* kana_NI */
+ {0x04c7, 0x30cc}, /* kana_NU */
+ {0x04c8, 0x30cd}, /* kana_NE */
+ {0x04c9, 0x30ce}, /* kana_NO */
+ {0x04ca, 0x30cf}, /* kana_HA */
+ {0x04cb, 0x30d2}, /* kana_HI */
+ {0x04cc, 0x30d5}, /* kana_FU */
+ {0x04cd, 0x30d8}, /* kana_HE */
+ {0x04ce, 0x30db}, /* kana_HO */
+ {0x04cf, 0x30de}, /* kana_MA */
+ {0x04d0, 0x30df}, /* kana_MI */
+ {0x04d1, 0x30e0}, /* kana_MU */
+ {0x04d2, 0x30e1}, /* kana_ME */
+ {0x04d3, 0x30e2}, /* kana_MO */
+ {0x04d4, 0x30e4}, /* kana_YA */
+ {0x04d5, 0x30e6}, /* kana_YU */
+ {0x04d6, 0x30e8}, /* kana_YO */
+ {0x04d7, 0x30e9}, /* kana_RA */
+ {0x04d8, 0x30ea}, /* kana_RI */
+ {0x04d9, 0x30eb}, /* kana_RU */
+ {0x04da, 0x30ec}, /* kana_RE */
+ {0x04db, 0x30ed}, /* kana_RO */
+ {0x04dc, 0x30ef}, /* kana_WA */
+ {0x04dd, 0x30f3}, /* kana_N */
+ {0x04de, 0x309b}, /* voicedsound */
+ {0x04df, 0x309c}, /* semivoicedsound */
+ {0x05ac, 0x060c}, /* Arabic_comma */
+ {0x05bb, 0x061b}, /* Arabic_semicolon */
+ {0x05bf, 0x061f}, /* Arabic_question_mark */
+ {0x05c1, 0x0621}, /* Arabic_hamza */
+ {0x05c2, 0x0622}, /* Arabic_maddaonalef */
+ {0x05c3, 0x0623}, /* Arabic_hamzaonalef */
+ {0x05c4, 0x0624}, /* Arabic_hamzaonwaw */
+ {0x05c5, 0x0625}, /* Arabic_hamzaunderalef */
+ {0x05c6, 0x0626}, /* Arabic_hamzaonyeh */
+ {0x05c7, 0x0627}, /* Arabic_alef */
+ {0x05c8, 0x0628}, /* Arabic_beh */
+ {0x05c9, 0x0629}, /* Arabic_tehmarbuta */
+ {0x05ca, 0x062a}, /* Arabic_teh */
+ {0x05cb, 0x062b}, /* Arabic_theh */
+ {0x05cc, 0x062c}, /* Arabic_jeem */
+ {0x05cd, 0x062d}, /* Arabic_hah */
+ {0x05ce, 0x062e}, /* Arabic_khah */
+ {0x05cf, 0x062f}, /* Arabic_dal */
+ {0x05d0, 0x0630}, /* Arabic_thal */
+ {0x05d1, 0x0631}, /* Arabic_ra */
+ {0x05d2, 0x0632}, /* Arabic_zain */
+ {0x05d3, 0x0633}, /* Arabic_seen */
+ {0x05d4, 0x0634}, /* Arabic_sheen */
+ {0x05d5, 0x0635}, /* Arabic_sad */
+ {0x05d6, 0x0636}, /* Arabic_dad */
+ {0x05d7, 0x0637}, /* Arabic_tah */
+ {0x05d8, 0x0638}, /* Arabic_zah */
+ {0x05d9, 0x0639}, /* Arabic_ain */
+ {0x05da, 0x063a}, /* Arabic_ghain */
+ {0x05e0, 0x0640}, /* Arabic_tatweel */
+ {0x05e1, 0x0641}, /* Arabic_feh */
+ {0x05e2, 0x0642}, /* Arabic_qaf */
+ {0x05e3, 0x0643}, /* Arabic_kaf */
+ {0x05e4, 0x0644}, /* Arabic_lam */
+ {0x05e5, 0x0645}, /* Arabic_meem */
+ {0x05e6, 0x0646}, /* Arabic_noon */
+ {0x05e7, 0x0647}, /* Arabic_ha */
+ {0x05e8, 0x0648}, /* Arabic_waw */
+ {0x05e9, 0x0649}, /* Arabic_alefmaksura */
+ {0x05ea, 0x064a}, /* Arabic_yeh */
+ {0x05eb, 0x064b}, /* Arabic_fathatan */
+ {0x05ec, 0x064c}, /* Arabic_dammatan */
+ {0x05ed, 0x064d}, /* Arabic_kasratan */
+ {0x05ee, 0x064e}, /* Arabic_fatha */
+ {0x05ef, 0x064f}, /* Arabic_damma */
+ {0x05f0, 0x0650}, /* Arabic_kasra */
+ {0x05f1, 0x0651}, /* Arabic_shadda */
+ {0x05f2, 0x0652}, /* Arabic_sukun */
+ {0x06a1, 0x0452}, /* Serbian_dje */
+ {0x06a2, 0x0453}, /* Macedonia_gje */
+ {0x06a3, 0x0451}, /* Cyrillic_io */
+ {0x06a4, 0x0454}, /* Ukrainian_ie */
+ {0x06a5, 0x0455}, /* Macedonia_dse */
+ {0x06a6, 0x0456}, /* Ukrainian_i */
+ {0x06a7, 0x0457}, /* Ukrainian_yi */
+ {0x06a8, 0x0458}, /* Cyrillic_je */
+ {0x06a9, 0x0459}, /* Cyrillic_lje */
+ {0x06aa, 0x045a}, /* Cyrillic_nje */
+ {0x06ab, 0x045b}, /* Serbian_tshe */
+ {0x06ac, 0x045c}, /* Macedonia_kje */
+ {0x06ae, 0x045e}, /* Byelorussian_shortu */
+ {0x06af, 0x045f}, /* Cyrillic_dzhe */
+ {0x06b0, 0x2116}, /* numerosign */
+ {0x06b1, 0x0402}, /* Serbian_DJE */
+ {0x06b2, 0x0403}, /* Macedonia_GJE */
+ {0x06b3, 0x0401}, /* Cyrillic_IO */
+ {0x06b4, 0x0404}, /* Ukrainian_IE */
+ {0x06b5, 0x0405}, /* Macedonia_DSE */
+ {0x06b6, 0x0406}, /* Ukrainian_I */
+ {0x06b7, 0x0407}, /* Ukrainian_YI */
+ {0x06b8, 0x0408}, /* Cyrillic_JE */
+ {0x06b9, 0x0409}, /* Cyrillic_LJE */
+ {0x06ba, 0x040a}, /* Cyrillic_NJE */
+ {0x06bb, 0x040b}, /* Serbian_TSHE */
+ {0x06bc, 0x040c}, /* Macedonia_KJE */
+ {0x06be, 0x040e}, /* Byelorussian_SHORTU */
+ {0x06bf, 0x040f}, /* Cyrillic_DZHE */
+ {0x06c0, 0x044e}, /* Cyrillic_yu */
+ {0x06c1, 0x0430}, /* Cyrillic_a */
+ {0x06c2, 0x0431}, /* Cyrillic_be */
+ {0x06c3, 0x0446}, /* Cyrillic_tse */
+ {0x06c4, 0x0434}, /* Cyrillic_de */
+ {0x06c5, 0x0435}, /* Cyrillic_ie */
+ {0x06c6, 0x0444}, /* Cyrillic_ef */
+ {0x06c7, 0x0433}, /* Cyrillic_ghe */
+ {0x06c8, 0x0445}, /* Cyrillic_ha */
+ {0x06c9, 0x0438}, /* Cyrillic_i */
+ {0x06ca, 0x0439}, /* Cyrillic_shorti */
+ {0x06cb, 0x043a}, /* Cyrillic_ka */
+ {0x06cc, 0x043b}, /* Cyrillic_el */
+ {0x06cd, 0x043c}, /* Cyrillic_em */
+ {0x06ce, 0x043d}, /* Cyrillic_en */
+ {0x06cf, 0x043e}, /* Cyrillic_o */
+ {0x06d0, 0x043f}, /* Cyrillic_pe */
+ {0x06d1, 0x044f}, /* Cyrillic_ya */
+ {0x06d2, 0x0440}, /* Cyrillic_er */
+ {0x06d3, 0x0441}, /* Cyrillic_es */
+ {0x06d4, 0x0442}, /* Cyrillic_te */
+ {0x06d5, 0x0443}, /* Cyrillic_u */
+ {0x06d6, 0x0436}, /* Cyrillic_zhe */
+ {0x06d7, 0x0432}, /* Cyrillic_ve */
+ {0x06d8, 0x044c}, /* Cyrillic_softsign */
+ {0x06d9, 0x044b}, /* Cyrillic_yeru */
+ {0x06da, 0x0437}, /* Cyrillic_ze */
+ {0x06db, 0x0448}, /* Cyrillic_sha */
+ {0x06dc, 0x044d}, /* Cyrillic_e */
+ {0x06dd, 0x0449}, /* Cyrillic_shcha */
+ {0x06de, 0x0447}, /* Cyrillic_che */
+ {0x06df, 0x044a}, /* Cyrillic_hardsign */
+ {0x06e0, 0x042e}, /* Cyrillic_YU */
+ {0x06e1, 0x0410}, /* Cyrillic_A */
+ {0x06e2, 0x0411}, /* Cyrillic_BE */
+ {0x06e3, 0x0426}, /* Cyrillic_TSE */
+ {0x06e4, 0x0414}, /* Cyrillic_DE */
+ {0x06e5, 0x0415}, /* Cyrillic_IE */
+ {0x06e6, 0x0424}, /* Cyrillic_EF */
+ {0x06e7, 0x0413}, /* Cyrillic_GHE */
+ {0x06e8, 0x0425}, /* Cyrillic_HA */
+ {0x06e9, 0x0418}, /* Cyrillic_I */
+ {0x06ea, 0x0419}, /* Cyrillic_SHORTI */
+ {0x06eb, 0x041a}, /* Cyrillic_KA */
+ {0x06ec, 0x041b}, /* Cyrillic_EL */
+ {0x06ed, 0x041c}, /* Cyrillic_EM */
+ {0x06ee, 0x041d}, /* Cyrillic_EN */
+ {0x06ef, 0x041e}, /* Cyrillic_O */
+ {0x06f0, 0x041f}, /* Cyrillic_PE */
+ {0x06f1, 0x042f}, /* Cyrillic_YA */
+ {0x06f2, 0x0420}, /* Cyrillic_ER */
+ {0x06f3, 0x0421}, /* Cyrillic_ES */
+ {0x06f4, 0x0422}, /* Cyrillic_TE */
+ {0x06f5, 0x0423}, /* Cyrillic_U */
+ {0x06f6, 0x0416}, /* Cyrillic_ZHE */
+ {0x06f7, 0x0412}, /* Cyrillic_VE */
+ {0x06f8, 0x042c}, /* Cyrillic_SOFTSIGN */
+ {0x06f9, 0x042b}, /* Cyrillic_YERU */
+ {0x06fa, 0x0417}, /* Cyrillic_ZE */
+ {0x06fb, 0x0428}, /* Cyrillic_SHA */
+ {0x06fc, 0x042d}, /* Cyrillic_E */
+ {0x06fd, 0x0429}, /* Cyrillic_SHCHA */
+ {0x06fe, 0x0427}, /* Cyrillic_CHE */
+ {0x06ff, 0x042a}, /* Cyrillic_HARDSIGN */
+ {0x07a1, 0x0386}, /* Greek_ALPHAaccent */
+ {0x07a2, 0x0388}, /* Greek_EPSILONaccent */
+ {0x07a3, 0x0389}, /* Greek_ETAaccent */
+ {0x07a4, 0x038a}, /* Greek_IOTAaccent */
+ {0x07a5, 0x03aa}, /* Greek_IOTAdiaeresis */
+ {0x07a7, 0x038c}, /* Greek_OMICRONaccent */
+ {0x07a8, 0x038e}, /* Greek_UPSILONaccent */
+ {0x07a9, 0x03ab}, /* Greek_UPSILONdieresis */
+ {0x07ab, 0x038f}, /* Greek_OMEGAaccent */
+ {0x07ae, 0x0385}, /* Greek_accentdieresis */
+ {0x07af, 0x2015}, /* Greek_horizbar */
+ {0x07b1, 0x03ac}, /* Greek_alphaaccent */
+ {0x07b2, 0x03ad}, /* Greek_epsilonaccent */
+ {0x07b3, 0x03ae}, /* Greek_etaaccent */
+ {0x07b4, 0x03af}, /* Greek_iotaaccent */
+ {0x07b5, 0x03ca}, /* Greek_iotadieresis */
+ {0x07b6, 0x0390}, /* Greek_iotaaccentdieresis */
+ {0x07b7, 0x03cc}, /* Greek_omicronaccent */
+ {0x07b8, 0x03cd}, /* Greek_upsilonaccent */
+ {0x07b9, 0x03cb}, /* Greek_upsilondieresis */
+ {0x07ba, 0x03b0}, /* Greek_upsilonaccentdieresis */
+ {0x07bb, 0x03ce}, /* Greek_omegaaccent */
+ {0x07c1, 0x0391}, /* Greek_ALPHA */
+ {0x07c2, 0x0392}, /* Greek_BETA */
+ {0x07c3, 0x0393}, /* Greek_GAMMA */
+ {0x07c4, 0x0394}, /* Greek_DELTA */
+ {0x07c5, 0x0395}, /* Greek_EPSILON */
+ {0x07c6, 0x0396}, /* Greek_ZETA */
+ {0x07c7, 0x0397}, /* Greek_ETA */
+ {0x07c8, 0x0398}, /* Greek_THETA */
+ {0x07c9, 0x0399}, /* Greek_IOTA */
+ {0x07ca, 0x039a}, /* Greek_KAPPA */
+ {0x07cb, 0x039b}, /* Greek_LAMDA */
+ {0x07cc, 0x039c}, /* Greek_MU */
+ {0x07cd, 0x039d}, /* Greek_NU */
+ {0x07ce, 0x039e}, /* Greek_XI */
+ {0x07cf, 0x039f}, /* Greek_OMICRON */
+ {0x07d0, 0x03a0}, /* Greek_PI */
+ {0x07d1, 0x03a1}, /* Greek_RHO */
+ {0x07d2, 0x03a3}, /* Greek_SIGMA */
+ {0x07d4, 0x03a4}, /* Greek_TAU */
+ {0x07d5, 0x03a5}, /* Greek_UPSILON */
+ {0x07d6, 0x03a6}, /* Greek_PHI */
+ {0x07d7, 0x03a7}, /* Greek_CHI */
+ {0x07d8, 0x03a8}, /* Greek_PSI */
+ {0x07d9, 0x03a9}, /* Greek_OMEGA */
+ {0x07e1, 0x03b1}, /* Greek_alpha */
+ {0x07e2, 0x03b2}, /* Greek_beta */
+ {0x07e3, 0x03b3}, /* Greek_gamma */
+ {0x07e4, 0x03b4}, /* Greek_delta */
+ {0x07e5, 0x03b5}, /* Greek_epsilon */
+ {0x07e6, 0x03b6}, /* Greek_zeta */
+ {0x07e7, 0x03b7}, /* Greek_eta */
+ {0x07e8, 0x03b8}, /* Greek_theta */
+ {0x07e9, 0x03b9}, /* Greek_iota */
+ {0x07ea, 0x03ba}, /* Greek_kappa */
+ {0x07eb, 0x03bb}, /* Greek_lambda */
+ {0x07ec, 0x03bc}, /* Greek_mu */
+ {0x07ed, 0x03bd}, /* Greek_nu */
+ {0x07ee, 0x03be}, /* Greek_xi */
+ {0x07ef, 0x03bf}, /* Greek_omicron */
+ {0x07f0, 0x03c0}, /* Greek_pi */
+ {0x07f1, 0x03c1}, /* Greek_rho */
+ {0x07f2, 0x03c3}, /* Greek_sigma */
+ {0x07f3, 0x03c2}, /* Greek_finalsmallsigma */
+ {0x07f4, 0x03c4}, /* Greek_tau */
+ {0x07f5, 0x03c5}, /* Greek_upsilon */
+ {0x07f6, 0x03c6}, /* Greek_phi */
+ {0x07f7, 0x03c7}, /* Greek_chi */
+ {0x07f8, 0x03c8}, /* Greek_psi */
+ {0x07f9, 0x03c9}, /* Greek_omega */
+ {0x08a1, 0x23b7}, /* leftradical */
+ {0x08a4, 0x2320}, /* topintegral */
+ {0x08a5, 0x2321}, /* botintegral */
+ {0x08a7, 0x23a1}, /* topleftsqbracket */
+ {0x08a8, 0x23a3}, /* botleftsqbracket */
+ {0x08a9, 0x23a4}, /* toprightsqbracket */
+ {0x08aa, 0x23a6}, /* botrightsqbracket */
+ {0x08ab, 0x239b}, /* topleftparens */
+ {0x08ac, 0x239d}, /* botleftparens */
+ {0x08ad, 0x239e}, /* toprightparens */
+ {0x08ae, 0x23a0}, /* botrightparens */
+ {0x08af, 0x23a8}, /* leftmiddlecurlybrace */
+ {0x08b0, 0x23ac}, /* rightmiddlecurlybrace */
+ {0x08bc, 0x2264}, /* lessthanequal */
+ {0x08bd, 0x2260}, /* notequal */
+ {0x08be, 0x2265}, /* greaterthanequal */
+ {0x08bf, 0x222b}, /* integral */
+ {0x08c0, 0x2234}, /* therefore */
+ {0x08c1, 0x221d}, /* variation */
+ {0x08c2, 0x221e}, /* infinity */
+ {0x08c5, 0x2207}, /* nabla */
+ {0x08c8, 0x223c}, /* approximate */
+ {0x08c9, 0x2243}, /* similarequal */
+ {0x08cd, 0x21d4}, /* ifonlyif */
+ {0x08ce, 0x21d2}, /* implies */
+ {0x08cf, 0x2261}, /* identical */
+ {0x08d6, 0x221a}, /* radical */
+ {0x08da, 0x2282}, /* includedin */
+ {0x08db, 0x2283}, /* includes */
+ {0x08dc, 0x2229}, /* intersection */
+ {0x08dd, 0x222a}, /* union */
+ {0x08de, 0x2227}, /* logicaland */
+ {0x08df, 0x2228}, /* logicalor */
+ {0x08ef, 0x2202}, /* partialderivative */
+ {0x08f6, 0x0192}, /* function */
+ {0x08fb, 0x2190}, /* leftarrow */
+ {0x08fc, 0x2191}, /* uparrow */
+ {0x08fd, 0x2192}, /* rightarrow */
+ {0x08fe, 0x2193}, /* downarrow */
+ {0x09e0, 0x25c6}, /* soliddiamond */
+ {0x09e1, 0x2592}, /* checkerboard */
+ {0x09e2, 0x2409}, /* ht */
+ {0x09e3, 0x240c}, /* ff */
+ {0x09e4, 0x240d}, /* cr */
+ {0x09e5, 0x240a}, /* lf */
+ {0x09e8, 0x2424}, /* nl */
+ {0x09e9, 0x240b}, /* vt */
+ {0x09ea, 0x2518}, /* lowrightcorner */
+ {0x09eb, 0x2510}, /* uprightcorner */
+ {0x09ec, 0x250c}, /* upleftcorner */
+ {0x09ed, 0x2514}, /* lowleftcorner */
+ {0x09ee, 0x253c}, /* crossinglines */
+ {0x09ef, 0x23ba}, /* horizlinescan1 */
+ {0x09f0, 0x23bb}, /* horizlinescan3 */
+ {0x09f1, 0x2500}, /* horizlinescan5 */
+ {0x09f2, 0x23bc}, /* horizlinescan7 */
+ {0x09f3, 0x23bd}, /* horizlinescan9 */
+ {0x09f4, 0x251c}, /* leftt */
+ {0x09f5, 0x2524}, /* rightt */
+ {0x09f6, 0x2534}, /* bott */
+ {0x09f7, 0x252c}, /* topt */
+ {0x09f8, 0x2502}, /* vertbar */
+ {0x0aa1, 0x2003}, /* emspace */
+ {0x0aa2, 0x2002}, /* enspace */
+ {0x0aa3, 0x2004}, /* em3space */
+ {0x0aa4, 0x2005}, /* em4space */
+ {0x0aa5, 0x2007}, /* digitspace */
+ {0x0aa6, 0x2008}, /* punctspace */
+ {0x0aa7, 0x2009}, /* thinspace */
+ {0x0aa8, 0x200a}, /* hairspace */
+ {0x0aa9, 0x2014}, /* emdash */
+ {0x0aaa, 0x2013}, /* endash */
+ {0x0aae, 0x2026}, /* ellipsis */
+ {0x0aaf, 0x2025}, /* doubbaselinedot */
+ {0x0ab0, 0x2153}, /* onethird */
+ {0x0ab1, 0x2154}, /* twothirds */
+ {0x0ab2, 0x2155}, /* onefifth */
+ {0x0ab3, 0x2156}, /* twofifths */
+ {0x0ab4, 0x2157}, /* threefifths */
+ {0x0ab5, 0x2158}, /* fourfifths */
+ {0x0ab6, 0x2159}, /* onesixth */
+ {0x0ab7, 0x215a}, /* fivesixths */
+ {0x0ab8, 0x2105}, /* careof */
+ {0x0abb, 0x2012}, /* figdash */
+ {0x0ac3, 0x215b}, /* oneeighth */
+ {0x0ac4, 0x215c}, /* threeeighths */
+ {0x0ac5, 0x215d}, /* fiveeighths */
+ {0x0ac6, 0x215e}, /* seveneighths */
+ {0x0ac9, 0x2122}, /* trademark */
+ {0x0ad0, 0x2018}, /* leftsinglequotemark */
+ {0x0ad1, 0x2019}, /* rightsinglequotemark */
+ {0x0ad2, 0x201c}, /* leftdoublequotemark */
+ {0x0ad3, 0x201d}, /* rightdoublequotemark */
+ {0x0ad4, 0x211e}, /* prescription */
+ {0x0ad6, 0x2032}, /* minutes */
+ {0x0ad7, 0x2033}, /* seconds */
+ {0x0ad9, 0x271d}, /* latincross */
+ {0x0aec, 0x2663}, /* club */
+ {0x0aed, 0x2666}, /* diamond */
+ {0x0aee, 0x2665}, /* heart */
+ {0x0af0, 0x2720}, /* maltesecross */
+ {0x0af1, 0x2020}, /* dagger */
+ {0x0af2, 0x2021}, /* doubledagger */
+ {0x0af3, 0x2713}, /* checkmark */
+ {0x0af4, 0x2717}, /* ballotcross */
+ {0x0af5, 0x266f}, /* musicalsharp */
+ {0x0af6, 0x266d}, /* musicalflat */
+ {0x0af7, 0x2642}, /* malesymbol */
+ {0x0af8, 0x2640}, /* femalesymbol */
+ {0x0af9, 0x260e}, /* telephone */
+ {0x0afa, 0x2315}, /* telephonerecorder */
+ {0x0afb, 0x2117}, /* phonographcopyright */
+ {0x0afc, 0x2038}, /* caret */
+ {0x0afd, 0x201a}, /* singlelowquotemark */
+ {0x0afe, 0x201e}, /* doublelowquotemark */
+ {0x0bc2, 0x22a5}, /* downtack */
+ {0x0bc4, 0x230a}, /* downstile */
+ {0x0bca, 0x2218}, /* jot */
+ {0x0bcc, 0x2395}, /* quad */
+ {0x0bce, 0x22a4}, /* uptack */
+ {0x0bcf, 0x25cb}, /* circle */
+ {0x0bd3, 0x2308}, /* upstile */
+ {0x0bdc, 0x22a2}, /* lefttack */
+ {0x0bfc, 0x22a3}, /* righttack */
+ {0x0cdf, 0x2017}, /* hebrew_doublelowline */
+ {0x0ce0, 0x05d0}, /* hebrew_aleph */
+ {0x0ce1, 0x05d1}, /* hebrew_bet */
+ {0x0ce2, 0x05d2}, /* hebrew_gimel */
+ {0x0ce3, 0x05d3}, /* hebrew_dalet */
+ {0x0ce4, 0x05d4}, /* hebrew_he */
+ {0x0ce5, 0x05d5}, /* hebrew_waw */
+ {0x0ce6, 0x05d6}, /* hebrew_zain */
+ {0x0ce7, 0x05d7}, /* hebrew_chet */
+ {0x0ce8, 0x05d8}, /* hebrew_tet */
+ {0x0ce9, 0x05d9}, /* hebrew_yod */
+ {0x0cea, 0x05da}, /* hebrew_finalkaph */
+ {0x0ceb, 0x05db}, /* hebrew_kaph */
+ {0x0cec, 0x05dc}, /* hebrew_lamed */
+ {0x0ced, 0x05dd}, /* hebrew_finalmem */
+ {0x0cee, 0x05de}, /* hebrew_mem */
+ {0x0cef, 0x05df}, /* hebrew_finalnun */
+ {0x0cf0, 0x05e0}, /* hebrew_nun */
+ {0x0cf1, 0x05e1}, /* hebrew_samech */
+ {0x0cf2, 0x05e2}, /* hebrew_ayin */
+ {0x0cf3, 0x05e3}, /* hebrew_finalpe */
+ {0x0cf4, 0x05e4}, /* hebrew_pe */
+ {0x0cf5, 0x05e5}, /* hebrew_finalzade */
+ {0x0cf6, 0x05e6}, /* hebrew_zade */
+ {0x0cf7, 0x05e7}, /* hebrew_qoph */
+ {0x0cf8, 0x05e8}, /* hebrew_resh */
+ {0x0cf9, 0x05e9}, /* hebrew_shin */
+ {0x0cfa, 0x05ea}, /* hebrew_taw */
+ {0x0da1, 0x0e01}, /* Thai_kokai */
+ {0x0da2, 0x0e02}, /* Thai_khokhai */
+ {0x0da3, 0x0e03}, /* Thai_khokhuat */
+ {0x0da4, 0x0e04}, /* Thai_khokhwai */
+ {0x0da5, 0x0e05}, /* Thai_khokhon */
+ {0x0da6, 0x0e06}, /* Thai_khorakhang */
+ {0x0da7, 0x0e07}, /* Thai_ngongu */
+ {0x0da8, 0x0e08}, /* Thai_chochan */
+ {0x0da9, 0x0e09}, /* Thai_choching */
+ {0x0daa, 0x0e0a}, /* Thai_chochang */
+ {0x0dab, 0x0e0b}, /* Thai_soso */
+ {0x0dac, 0x0e0c}, /* Thai_chochoe */
+ {0x0dad, 0x0e0d}, /* Thai_yoying */
+ {0x0dae, 0x0e0e}, /* Thai_dochada */
+ {0x0daf, 0x0e0f}, /* Thai_topatak */
+ {0x0db0, 0x0e10}, /* Thai_thothan */
+ {0x0db1, 0x0e11}, /* Thai_thonangmontho */
+ {0x0db2, 0x0e12}, /* Thai_thophuthao */
+ {0x0db3, 0x0e13}, /* Thai_nonen */
+ {0x0db4, 0x0e14}, /* Thai_dodek */
+ {0x0db5, 0x0e15}, /* Thai_totao */
+ {0x0db6, 0x0e16}, /* Thai_thothung */
+ {0x0db7, 0x0e17}, /* Thai_thothahan */
+ {0x0db8, 0x0e18}, /* Thai_thothong */
+ {0x0db9, 0x0e19}, /* Thai_nonu */
+ {0x0dba, 0x0e1a}, /* Thai_bobaimai */
+ {0x0dbb, 0x0e1b}, /* Thai_popla */
+ {0x0dbc, 0x0e1c}, /* Thai_phophung */
+ {0x0dbd, 0x0e1d}, /* Thai_fofa */
+ {0x0dbe, 0x0e1e}, /* Thai_phophan */
+ {0x0dbf, 0x0e1f}, /* Thai_fofan */
+ {0x0dc0, 0x0e20}, /* Thai_phosamphao */
+ {0x0dc1, 0x0e21}, /* Thai_moma */
+ {0x0dc2, 0x0e22}, /* Thai_yoyak */
+ {0x0dc3, 0x0e23}, /* Thai_rorua */
+ {0x0dc4, 0x0e24}, /* Thai_ru */
+ {0x0dc5, 0x0e25}, /* Thai_loling */
+ {0x0dc6, 0x0e26}, /* Thai_lu */
+ {0x0dc7, 0x0e27}, /* Thai_wowaen */
+ {0x0dc8, 0x0e28}, /* Thai_sosala */
+ {0x0dc9, 0x0e29}, /* Thai_sorusi */
+ {0x0dca, 0x0e2a}, /* Thai_sosua */
+ {0x0dcb, 0x0e2b}, /* Thai_hohip */
+ {0x0dcc, 0x0e2c}, /* Thai_lochula */
+ {0x0dcd, 0x0e2d}, /* Thai_oang */
+ {0x0dce, 0x0e2e}, /* Thai_honokhuk */
+ {0x0dcf, 0x0e2f}, /* Thai_paiyannoi */
+ {0x0dd0, 0x0e30}, /* Thai_saraa */
+ {0x0dd1, 0x0e31}, /* Thai_maihanakat */
+ {0x0dd2, 0x0e32}, /* Thai_saraaa */
+ {0x0dd3, 0x0e33}, /* Thai_saraam */
+ {0x0dd4, 0x0e34}, /* Thai_sarai */
+ {0x0dd5, 0x0e35}, /* Thai_saraii */
+ {0x0dd6, 0x0e36}, /* Thai_saraue */
+ {0x0dd7, 0x0e37}, /* Thai_sarauee */
+ {0x0dd8, 0x0e38}, /* Thai_sarau */
+ {0x0dd9, 0x0e39}, /* Thai_sarauu */
+ {0x0dda, 0x0e3a}, /* Thai_phinthu */
+ {0x0ddf, 0x0e3f}, /* Thai_baht */
+ {0x0de0, 0x0e40}, /* Thai_sarae */
+ {0x0de1, 0x0e41}, /* Thai_saraae */
+ {0x0de2, 0x0e42}, /* Thai_sarao */
+ {0x0de3, 0x0e43}, /* Thai_saraaimaimuan */
+ {0x0de4, 0x0e44}, /* Thai_saraaimaimalai */
+ {0x0de5, 0x0e45}, /* Thai_lakkhangyao */
+ {0x0de6, 0x0e46}, /* Thai_maiyamok */
+ {0x0de7, 0x0e47}, /* Thai_maitaikhu */
+ {0x0de8, 0x0e48}, /* Thai_maiek */
+ {0x0de9, 0x0e49}, /* Thai_maitho */
+ {0x0dea, 0x0e4a}, /* Thai_maitri */
+ {0x0deb, 0x0e4b}, /* Thai_maichattawa */
+ {0x0dec, 0x0e4c}, /* Thai_thanthakhat */
+ {0x0ded, 0x0e4d}, /* Thai_nikhahit */
+ {0x0df0, 0x0e50}, /* Thai_leksun */
+ {0x0df1, 0x0e51}, /* Thai_leknung */
+ {0x0df2, 0x0e52}, /* Thai_leksong */
+ {0x0df3, 0x0e53}, /* Thai_leksam */
+ {0x0df4, 0x0e54}, /* Thai_leksi */
+ {0x0df5, 0x0e55}, /* Thai_lekha */
+ {0x0df6, 0x0e56}, /* Thai_lekhok */
+ {0x0df7, 0x0e57}, /* Thai_lekchet */
+ {0x0df8, 0x0e58}, /* Thai_lekpaet */
+ {0x0df9, 0x0e59}, /* Thai_lekkao */
+ {0x13bc, 0x0152}, /* OE */
+ {0x13bd, 0x0153}, /* oe */
+ {0x13be, 0x0178}, /* Ydiaeresis */
+ {0x20a0, 0x20a0}, /* EcuSign */
+ {0x20a1, 0x20a1}, /* ColonSign */
+ {0x20a2, 0x20a2}, /* CruzeiroSign */
+ {0x20a3, 0x20a3}, /* FFrancSign */
+ {0x20a4, 0x20a4}, /* LiraSign */
+ {0x20a5, 0x20a5}, /* MillSign */
+ {0x20a6, 0x20a6}, /* NairaSign */
+ {0x20a7, 0x20a7}, /* PesetaSign */
+ {0x20a8, 0x20a8}, /* RupeeSign */
+ {0x20a9, 0x20a9}, /* WonSign */
+ {0x20aa, 0x20aa}, /* NewSheqelSign */
+ {0x20ab, 0x20ab}, /* DongSign */
+ {0x20ac, 0x20ac}, /* EuroSign */
+ {0x06ad, 0x0491}, /* Ukrainian_ghe_with_upturn */
+ {0x06bd, 0x0490}, /* Ukrainian_GHE_WITH_UPTURN */
+ {0x14a2, 0x0587}, /* Armenian_ligature_ew */
+ {0x14a3, 0x0589}, /* Armenian_verjaket */
+ {0x14aa, 0x055d}, /* Armenian_but */
+ {0x14ad, 0x058a}, /* Armenian_yentamna */
+ {0x14af, 0x055c}, /* Armenian_amanak */
+ {0x14b0, 0x055b}, /* Armenian_shesht */
+ {0x14b1, 0x055e}, /* Armenian_paruyk */
+ {0x14b2, 0x0531}, /* Armenian_AYB */
+ {0x14b3, 0x0561}, /* Armenian_ayb */
+ {0x14b4, 0x0532}, /* Armenian_BEN */
+ {0x14b5, 0x0562}, /* Armenian_ben */
+ {0x14b6, 0x0533}, /* Armenian_GIM */
+ {0x14b7, 0x0563}, /* Armenian_gim */
+ {0x14b8, 0x0534}, /* Armenian_DA */
+ {0x14b9, 0x0564}, /* Armenian_da */
+ {0x14ba, 0x0535}, /* Armenian_YECH */
+ {0x14bb, 0x0565}, /* Armenian_yech */
+ {0x14bc, 0x0536}, /* Armenian_ZA */
+ {0x14bd, 0x0566}, /* Armenian_za */
+ {0x14be, 0x0537}, /* Armenian_E */
+ {0x14bf, 0x0567}, /* Armenian_e */
+ {0x14c0, 0x0538}, /* Armenian_AT */
+ {0x14c1, 0x0568}, /* Armenian_at */
+ {0x14c2, 0x0539}, /* Armenian_TO */
+ {0x14c3, 0x0569}, /* Armenian_to */
+ {0x14c4, 0x053a}, /* Armenian_ZHE */
+ {0x14c5, 0x056a}, /* Armenian_zhe */
+ {0x14c6, 0x053b}, /* Armenian_INI */
+ {0x14c7, 0x056b}, /* Armenian_ini */
+ {0x14c8, 0x053c}, /* Armenian_LYUN */
+ {0x14c9, 0x056c}, /* Armenian_lyun */
+ {0x14ca, 0x053d}, /* Armenian_KHE */
+ {0x14cb, 0x056d}, /* Armenian_khe */
+ {0x14cc, 0x053e}, /* Armenian_TSA */
+ {0x14cd, 0x056e}, /* Armenian_tsa */
+ {0x14ce, 0x053f}, /* Armenian_KEN */
+ {0x14cf, 0x056f}, /* Armenian_ken */
+ {0x14d0, 0x0540}, /* Armenian_HO */
+ {0x14d1, 0x0570}, /* Armenian_ho */
+ {0x14d2, 0x0541}, /* Armenian_DZA */
+ {0x14d3, 0x0571}, /* Armenian_dza */
+ {0x14d4, 0x0542}, /* Armenian_GHAT */
+ {0x14d5, 0x0572}, /* Armenian_ghat */
+ {0x14d6, 0x0543}, /* Armenian_TCHE */
+ {0x14d7, 0x0573}, /* Armenian_tche */
+ {0x14d8, 0x0544}, /* Armenian_MEN */
+ {0x14d9, 0x0574}, /* Armenian_men */
+ {0x14da, 0x0545}, /* Armenian_HI */
+ {0x14db, 0x0575}, /* Armenian_hi */
+ {0x14dc, 0x0546}, /* Armenian_NU */
+ {0x14dd, 0x0576}, /* Armenian_nu */
+ {0x14de, 0x0547}, /* Armenian_SHA */
+ {0x14df, 0x0577}, /* Armenian_sha */
+ {0x14e0, 0x0548}, /* Armenian_VO */
+ {0x14e1, 0x0578}, /* Armenian_vo */
+ {0x14e2, 0x0549}, /* Armenian_CHA */
+ {0x14e3, 0x0579}, /* Armenian_cha */
+ {0x14e4, 0x054a}, /* Armenian_PE */
+ {0x14e5, 0x057a}, /* Armenian_pe */
+ {0x14e6, 0x054b}, /* Armenian_JE */
+ {0x14e7, 0x057b}, /* Armenian_je */
+ {0x14e8, 0x054c}, /* Armenian_RA */
+ {0x14e9, 0x057c}, /* Armenian_ra */
+ {0x14ea, 0x054d}, /* Armenian_SE */
+ {0x14eb, 0x057d}, /* Armenian_se */
+ {0x14ec, 0x054e}, /* Armenian_VEV */
+ {0x14ed, 0x057e}, /* Armenian_vev */
+ {0x14ee, 0x054f}, /* Armenian_TYUN */
+ {0x14ef, 0x057f}, /* Armenian_tyun */
+ {0x14f0, 0x0550}, /* Armenian_RE */
+ {0x14f1, 0x0580}, /* Armenian_re */
+ {0x14f2, 0x0551}, /* Armenian_TSO */
+ {0x14f3, 0x0581}, /* Armenian_tso */
+ {0x14f4, 0x0552}, /* Armenian_VYUN */
+ {0x14f5, 0x0582}, /* Armenian_vyun */
+ {0x14f6, 0x0553}, /* Armenian_PYUR */
+ {0x14f7, 0x0583}, /* Armenian_pyur */
+ {0x14f8, 0x0554}, /* Armenian_KE */
+ {0x14f9, 0x0584}, /* Armenian_ke */
+ {0x14fa, 0x0555}, /* Armenian_O */
+ {0x14fb, 0x0585}, /* Armenian_o */
+ {0x14fc, 0x0556}, /* Armenian_FE */
+ {0x14fd, 0x0586}, /* Armenian_fe */
+ {0x14fe, 0x055a}, /* Armenian_apostrophe */
+ {0x15d0, 0x10d0}, /* Georgian_an */
+ {0x15d1, 0x10d1}, /* Georgian_ban */
+ {0x15d2, 0x10d2}, /* Georgian_gan */
+ {0x15d3, 0x10d3}, /* Georgian_don */
+ {0x15d4, 0x10d4}, /* Georgian_en */
+ {0x15d5, 0x10d5}, /* Georgian_vin */
+ {0x15d6, 0x10d6}, /* Georgian_zen */
+ {0x15d7, 0x10d7}, /* Georgian_tan */
+ {0x15d8, 0x10d8}, /* Georgian_in */
+ {0x15d9, 0x10d9}, /* Georgian_kan */
+ {0x15da, 0x10da}, /* Georgian_las */
+ {0x15db, 0x10db}, /* Georgian_man */
+ {0x15dc, 0x10dc}, /* Georgian_nar */
+ {0x15dd, 0x10dd}, /* Georgian_on */
+ {0x15de, 0x10de}, /* Georgian_par */
+ {0x15df, 0x10df}, /* Georgian_zhar */
+ {0x15e0, 0x10e0}, /* Georgian_rae */
+ {0x15e1, 0x10e1}, /* Georgian_san */
+ {0x15e2, 0x10e2}, /* Georgian_tar */
+ {0x15e3, 0x10e3}, /* Georgian_un */
+ {0x15e4, 0x10e4}, /* Georgian_phar */
+ {0x15e5, 0x10e5}, /* Georgian_khar */
+ {0x15e6, 0x10e6}, /* Georgian_ghan */
+ {0x15e7, 0x10e7}, /* Georgian_qar */
+ {0x15e8, 0x10e8}, /* Georgian_shin */
+ {0x15e9, 0x10e9}, /* Georgian_chin */
+ {0x15ea, 0x10ea}, /* Georgian_can */
+ {0x15eb, 0x10eb}, /* Georgian_jil */
+ {0x15ec, 0x10ec}, /* Georgian_cil */
+ {0x15ed, 0x10ed}, /* Georgian_char */
+ {0x15ee, 0x10ee}, /* Georgian_xan */
+ {0x15ef, 0x10ef}, /* Georgian_jhan */
+ {0x15f0, 0x10f0}, /* Georgian_hae */
+ {0x15f1, 0x10f1}, /* Georgian_he */
+ {0x15f2, 0x10f2}, /* Georgian_hie */
+ {0x15f3, 0x10f3}, /* Georgian_we */
+ {0x15f4, 0x10f4}, /* Georgian_har */
+ {0x15f5, 0x10f5}, /* Georgian_hoe */
+ {0x15f6, 0x10f6}, /* Georgian_fi */
+ {0x12a1, 0x1e02}, /* Babovedot */
+ {0x12a2, 0x1e03}, /* babovedot */
+ {0x12a6, 0x1e0a}, /* Dabovedot */
+ {0x12a8, 0x1e80}, /* Wgrave */
+ {0x12aa, 0x1e82}, /* Wacute */
+ {0x12ab, 0x1e0b}, /* dabovedot */
+ {0x12ac, 0x1ef2}, /* Ygrave */
+ {0x12b0, 0x1e1e}, /* Fabovedot */
+ {0x12b1, 0x1e1f}, /* fabovedot */
+ {0x12b4, 0x1e40}, /* Mabovedot */
+ {0x12b5, 0x1e41}, /* mabovedot */
+ {0x12b7, 0x1e56}, /* Pabovedot */
+ {0x12b8, 0x1e81}, /* wgrave */
+ {0x12b9, 0x1e57}, /* pabovedot */
+ {0x12ba, 0x1e83}, /* wacute */
+ {0x12bb, 0x1e60}, /* Sabovedot */
+ {0x12bc, 0x1ef3}, /* ygrave */
+ {0x12bd, 0x1e84}, /* Wdiaeresis */
+ {0x12be, 0x1e85}, /* wdiaeresis */
+ {0x12bf, 0x1e61}, /* sabovedot */
+ {0x12d0, 0x0174}, /* Wcircumflex */
+ {0x12d7, 0x1e6a}, /* Tabovedot */
+ {0x12de, 0x0176}, /* Ycircumflex */
+ {0x12f0, 0x0175}, /* wcircumflex */
+ {0x12f7, 0x1e6b}, /* tabovedot */
+ {0x12fe, 0x0177}, /* ycircumflex */
+ {0x0590, 0x06f0}, /* Farsi_0 */
+ {0x0591, 0x06f1}, /* Farsi_1 */
+ {0x0592, 0x06f2}, /* Farsi_2 */
+ {0x0593, 0x06f3}, /* Farsi_3 */
+ {0x0594, 0x06f4}, /* Farsi_4 */
+ {0x0595, 0x06f5}, /* Farsi_5 */
+ {0x0596, 0x06f6}, /* Farsi_6 */
+ {0x0597, 0x06f7}, /* Farsi_7 */
+ {0x0598, 0x06f8}, /* Farsi_8 */
+ {0x0599, 0x06f9}, /* Farsi_9 */
+ {0x05a5, 0x066a}, /* Arabic_percent */
+ {0x05a6, 0x0670}, /* Arabic_superscript_alef */
+ {0x05a7, 0x0679}, /* Arabic_tteh */
+ {0x05a8, 0x067e}, /* Arabic_peh */
+ {0x05a9, 0x0686}, /* Arabic_tcheh */
+ {0x05aa, 0x0688}, /* Arabic_ddal */
+ {0x05ab, 0x0691}, /* Arabic_rreh */
+ {0x05ae, 0x06d4}, /* Arabic_fullstop */
+ {0x05b0, 0x0660}, /* Arabic_0 */
+ {0x05b1, 0x0661}, /* Arabic_1 */
+ {0x05b2, 0x0662}, /* Arabic_2 */
+ {0x05b3, 0x0663}, /* Arabic_3 */
+ {0x05b4, 0x0664}, /* Arabic_4 */
+ {0x05b5, 0x0665}, /* Arabic_5 */
+ {0x05b6, 0x0666}, /* Arabic_6 */
+ {0x05b7, 0x0667}, /* Arabic_7 */
+ {0x05b8, 0x0668}, /* Arabic_8 */
+ {0x05b9, 0x0669}, /* Arabic_9 */
+ {0x05f3, 0x0653}, /* Arabic_madda_above */
+ {0x05f4, 0x0654}, /* Arabic_hamza_above */
+ {0x05f5, 0x0655}, /* Arabic_hamza_below */
+ {0x05f6, 0x0698}, /* Arabic_jeh */
+ {0x05f7, 0x06a4}, /* Arabic_veh */
+ {0x05f8, 0x06a9}, /* Arabic_keheh */
+ {0x05f9, 0x06af}, /* Arabic_gaf */
+ {0x05fa, 0x06ba}, /* Arabic_noon_ghunna */
+ {0x05fb, 0x06be}, /* Arabic_heh_doachashmee */
+ {0x05fc, 0x06cc}, /* Farsi_yeh */
+ {0x05fd, 0x06d2}, /* Arabic_yeh_baree */
+ {0x05fe, 0x06c1}, /* Arabic_heh_goal */
+ {0x0680, 0x0492}, /* Cyrillic_GHE_bar */
+ {0x0681, 0x0496}, /* Cyrillic_ZHE_descender */
+ {0x0682, 0x049a}, /* Cyrillic_KA_descender */
+ {0x0683, 0x049c}, /* Cyrillic_KA_vertstroke */
+ {0x0684, 0x04a2}, /* Cyrillic_EN_descender */
+ {0x0685, 0x04ae}, /* Cyrillic_U_straight */
+ {0x0686, 0x04b0}, /* Cyrillic_U_straight_bar */
+ {0x0687, 0x04b2}, /* Cyrillic_HA_descender */
+ {0x0688, 0x04b6}, /* Cyrillic_CHE_descender */
+ {0x0689, 0x04b8}, /* Cyrillic_CHE_vertstroke */
+ {0x068a, 0x04ba}, /* Cyrillic_SHHA */
+ {0x068c, 0x04d8}, /* Cyrillic_SCHWA */
+ {0x068d, 0x04e2}, /* Cyrillic_I_macron */
+ {0x068e, 0x04e8}, /* Cyrillic_O_bar */
+ {0x068f, 0x04ee}, /* Cyrillic_U_macron */
+ {0x0690, 0x0493}, /* Cyrillic_ghe_bar */
+ {0x0691, 0x0497}, /* Cyrillic_zhe_descender */
+ {0x0692, 0x049b}, /* Cyrillic_ka_descender */
+ {0x0693, 0x049d}, /* Cyrillic_ka_vertstroke */
+ {0x0694, 0x04a3}, /* Cyrillic_en_descender */
+ {0x0695, 0x04af}, /* Cyrillic_u_straight */
+ {0x0696, 0x04b1}, /* Cyrillic_u_straight_bar */
+ {0x0697, 0x04b3}, /* Cyrillic_ha_descender */
+ {0x0698, 0x04b7}, /* Cyrillic_che_descender */
+ {0x0699, 0x04b9}, /* Cyrillic_che_vertstroke */
+ {0x069a, 0x04bb}, /* Cyrillic_shha */
+ {0x069c, 0x04d9}, /* Cyrillic_schwa */
+ {0x069d, 0x04e3}, /* Cyrillic_i_macron */
+ {0x069e, 0x04e9}, /* Cyrillic_o_bar */
+ {0x069f, 0x04ef}, /* Cyrillic_u_macron */
+ {0x16a3, 0x1e8a}, /* Xabovedot */
+ {0x16a6, 0x012c}, /* Ibreve */
+ {0x16a9, 0x01b5}, /* Zstroke */
+ {0x16aa, 0x01e6}, /* Gcaron */
+ {0x16af, 0x019f}, /* Obarred */
+ {0x16b3, 0x1e8b}, /* xabovedot */
+ {0x16b6, 0x012d}, /* ibreve */
+ {0x16b9, 0x01b6}, /* zstroke */
+ {0x16ba, 0x01e7}, /* gcaron */
+ {0x16bd, 0x01d2}, /* ocaron */
+ {0x16bf, 0x0275}, /* obarred */
+ {0x16c6, 0x018f}, /* SCHWA */
+ {0x16f6, 0x0259}, /* schwa */
+ {0x16d1, 0x1e36}, /* Lbelowdot */
+ {0x16e1, 0x1e37}, /* lbelowdot */
+ {0x1ea0, 0x1ea0}, /* Abelowdot */
+ {0x1ea1, 0x1ea1}, /* abelowdot */
+ {0x1ea2, 0x1ea2}, /* Ahook */
+ {0x1ea3, 0x1ea3}, /* ahook */
+ {0x1ea4, 0x1ea4}, /* Acircumflexacute */
+ {0x1ea5, 0x1ea5}, /* acircumflexacute */
+ {0x1ea6, 0x1ea6}, /* Acircumflexgrave */
+ {0x1ea7, 0x1ea7}, /* acircumflexgrave */
+ {0x1ea8, 0x1ea8}, /* Acircumflexhook */
+ {0x1ea9, 0x1ea9}, /* acircumflexhook */
+ {0x1eaa, 0x1eaa}, /* Acircumflextilde */
+ {0x1eab, 0x1eab}, /* acircumflextilde */
+ {0x1eac, 0x1eac}, /* Acircumflexbelowdot */
+ {0x1ead, 0x1ead}, /* acircumflexbelowdot */
+ {0x1eae, 0x1eae}, /* Abreveacute */
+ {0x1eaf, 0x1eaf}, /* abreveacute */
+ {0x1eb0, 0x1eb0}, /* Abrevegrave */
+ {0x1eb1, 0x1eb1}, /* abrevegrave */
+ {0x1eb2, 0x1eb2}, /* Abrevehook */
+ {0x1eb3, 0x1eb3}, /* abrevehook */
+ {0x1eb4, 0x1eb4}, /* Abrevetilde */
+ {0x1eb5, 0x1eb5}, /* abrevetilde */
+ {0x1eb6, 0x1eb6}, /* Abrevebelowdot */
+ {0x1eb7, 0x1eb7}, /* abrevebelowdot */
+ {0x1eb8, 0x1eb8}, /* Ebelowdot */
+ {0x1eb9, 0x1eb9}, /* ebelowdot */
+ {0x1eba, 0x1eba}, /* Ehook */
+ {0x1ebb, 0x1ebb}, /* ehook */
+ {0x1ebc, 0x1ebc}, /* Etilde */
+ {0x1ebd, 0x1ebd}, /* etilde */
+ {0x1ebe, 0x1ebe}, /* Ecircumflexacute */
+ {0x1ebf, 0x1ebf}, /* ecircumflexacute */
+ {0x1ec0, 0x1ec0}, /* Ecircumflexgrave */
+ {0x1ec1, 0x1ec1}, /* ecircumflexgrave */
+ {0x1ec2, 0x1ec2}, /* Ecircumflexhook */
+ {0x1ec3, 0x1ec3}, /* ecircumflexhook */
+ {0x1ec4, 0x1ec4}, /* Ecircumflextilde */
+ {0x1ec5, 0x1ec5}, /* ecircumflextilde */
+ {0x1ec6, 0x1ec6}, /* Ecircumflexbelowdot */
+ {0x1ec7, 0x1ec7}, /* ecircumflexbelowdot */
+ {0x1ec8, 0x1ec8}, /* Ihook */
+ {0x1ec9, 0x1ec9}, /* ihook */
+ {0x1eca, 0x1eca}, /* Ibelowdot */
+ {0x1ecb, 0x1ecb}, /* ibelowdot */
+ {0x1ecc, 0x1ecc}, /* Obelowdot */
+ {0x1ecd, 0x1ecd}, /* obelowdot */
+ {0x1ece, 0x1ece}, /* Ohook */
+ {0x1ecf, 0x1ecf}, /* ohook */
+ {0x1ed0, 0x1ed0}, /* Ocircumflexacute */
+ {0x1ed1, 0x1ed1}, /* ocircumflexacute */
+ {0x1ed2, 0x1ed2}, /* Ocircumflexgrave */
+ {0x1ed3, 0x1ed3}, /* ocircumflexgrave */
+ {0x1ed4, 0x1ed4}, /* Ocircumflexhook */
+ {0x1ed5, 0x1ed5}, /* ocircumflexhook */
+ {0x1ed6, 0x1ed6}, /* Ocircumflextilde */
+ {0x1ed7, 0x1ed7}, /* ocircumflextilde */
+ {0x1ed8, 0x1ed8}, /* Ocircumflexbelowdot */
+ {0x1ed9, 0x1ed9}, /* ocircumflexbelowdot */
+ {0x1eda, 0x1eda}, /* Ohornacute */
+ {0x1edb, 0x1edb}, /* ohornacute */
+ {0x1edc, 0x1edc}, /* Ohorngrave */
+ {0x1edd, 0x1edd}, /* ohorngrave */
+ {0x1ede, 0x1ede}, /* Ohornhook */
+ {0x1edf, 0x1edf}, /* ohornhook */
+ {0x1ee0, 0x1ee0}, /* Ohorntilde */
+ {0x1ee1, 0x1ee1}, /* ohorntilde */
+ {0x1ee2, 0x1ee2}, /* Ohornbelowdot */
+ {0x1ee3, 0x1ee3}, /* ohornbelowdot */
+ {0x1ee4, 0x1ee4}, /* Ubelowdot */
+ {0x1ee5, 0x1ee5}, /* ubelowdot */
+ {0x1ee6, 0x1ee6}, /* Uhook */
+ {0x1ee7, 0x1ee7}, /* uhook */
+ {0x1ee8, 0x1ee8}, /* Uhornacute */
+ {0x1ee9, 0x1ee9}, /* uhornacute */
+ {0x1eea, 0x1eea}, /* Uhorngrave */
+ {0x1eeb, 0x1eeb}, /* uhorngrave */
+ {0x1eec, 0x1eec}, /* Uhornhook */
+ {0x1eed, 0x1eed}, /* uhornhook */
+ {0x1eee, 0x1eee}, /* Uhorntilde */
+ {0x1eef, 0x1eef}, /* uhorntilde */
+ {0x1ef0, 0x1ef0}, /* Uhornbelowdot */
+ {0x1ef1, 0x1ef1}, /* uhornbelowdot */
+ {0x1ef4, 0x1ef4}, /* Ybelowdot */
+ {0x1ef5, 0x1ef5}, /* ybelowdot */
+ {0x1ef6, 0x1ef6}, /* Yhook */
+ {0x1ef7, 0x1ef7}, /* yhook */
+ {0x1ef8, 0x1ef8}, /* Ytilde */
+ {0x1ef9, 0x1ef9}, /* ytilde */
+ {0x1efa, 0x01a0}, /* Ohorn */
+ {0x1efb, 0x01a1}, /* ohorn */
+ {0x1efc, 0x01af}, /* Uhorn */
+ {0x1efd, 0x01b0}, /* uhorn */
+ {0, 0}
+};
+
+#endif
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index 227c379..1ed9408 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -41,7 +41,7 @@ static const struct {
SPECIALMENU(help, HELP),
SPECIALMENU(apple, APPLE),
SPECIALMENU(window, WINDOWS),
- {NULL}
+ {NULL, 0, 0}
};
#undef SPECIALMENU
@@ -58,7 +58,7 @@ static const struct {
MODIFIER(Command, NSCommandKeyMask),
MODIFIER(Cmd, NSCommandKeyMask),
MODIFIER(Meta, NSCommandKeyMask),
- {NULL}
+ {NULL, 0, 0}
};
#undef MODIFIER
@@ -86,7 +86,7 @@ static const struct {
ACCEL(Help, NSHelpFunctionKey),
ACCEL(Power, 0x233d),
ACCEL(Eject, 0xf804),
- {NULL}
+ {NULL, 0, 0}
};
#undef ACCEL
#undef sl
@@ -193,10 +193,10 @@ static int ModifierCharWidth(Tk_Font tkfont);
- (void) insertItem: (NSMenuItem *) newItem atIndex: (NSInteger) index
{
if (_tkMenu && index >= 0) {
- if ((NSUInteger)index <= _tkOffset) {
+ if ((NSUInteger) index <= _tkOffset) {
_tkOffset++;
} else {
- NSAssert((NSUInteger)index >= _tkItemCount + _tkOffset,
+ NSAssert((NSUInteger) index >= _tkItemCount + _tkOffset,
@"Cannot insert in the middle of Tk menu");
}
}
@@ -206,9 +206,9 @@ static int ModifierCharWidth(Tk_Font tkfont);
- (void) removeItemAtIndex: (NSInteger) index
{
if (_tkMenu && index >= 0) {
- if ((NSUInteger)index < _tkOffset) {
+ if ((NSUInteger) index < _tkOffset) {
_tkOffset--;
- } else if ((NSUInteger)index < _tkItemCount + _tkOffset) {
+ } else if ((NSUInteger) index < _tkItemCount + _tkOffset) {
_tkItemCount--;
}
}
@@ -221,7 +221,7 @@ static int ModifierCharWidth(Tk_Font tkfont);
action:@selector(tkMenuItemInvoke:) keyEquivalent:@""];
[menuItem setTarget:self];
- [menuItem setTag:(NSInteger)mePtr];
+ [menuItem setTag:(NSInteger) mePtr];
return menuItem;
}
@end
@@ -252,15 +252,16 @@ static int ModifierCharWidth(Tk_Font tkfont);
*/
if ([sender isKindOfClass:[NSMenuItem class]]) {
- NSMenuItem *menuItem = (NSMenuItem *)sender;
- TkMenu *menuPtr = (TkMenu *)_tkMenu;
- TkMenuEntry *mePtr = (TkMenuEntry *)[menuItem tag];
+ NSMenuItem *menuItem = (NSMenuItem *) sender;
+ TkMenu *menuPtr = (TkMenu *) _tkMenu;
+ TkMenuEntry *mePtr = (TkMenuEntry *) [menuItem tag];
if (menuPtr && mePtr) {
Tcl_Interp *interp = menuPtr->interp;
- /*Add time for errors to fire if necessary. This is sub-optimal
- *but avoids issues with Tcl/Cocoa event loop integration.
+ /*
+ * Add time for errors to fire if necessary. This is sub-optimal
+ * but avoids issues with Tcl/Cocoa event loop integration.
*/
//Tcl_Sleep(100);
@@ -286,6 +287,8 @@ static int ModifierCharWidth(Tk_Font tkfont);
- (BOOL) menuHasKeyEquivalent: (NSMenu *) menu forEvent: (NSEvent *) event
target: (id *) target action: (SEL *) action
{
+ (void)menu;
+
/*
* Use lowercaseString when comparing keyEquivalents since the notion of
* a shifted upper case letter does not make much sense.
@@ -305,8 +308,8 @@ static int ModifierCharWidth(Tk_Font tkfont);
return NO;
} else if (modifiers == (NSControlKeyMask | NSShiftKeyMask) &&
[event keyCode] == 48) {
-
- /* Starting with OSX 10.12 Control-Tab and Control-Shift-Tab are used
+ /*
+ * Starting with OSX 10.12 Control-Tab and Control-Shift-Tab are used
* to select window tabs. But for some even more mysterious reason the
* Control-Shift-Tab event has character 0x19 = NSBackTabCharacter
* rather than 0x09 = NSTabCharacter. At the same time, the
@@ -317,7 +320,6 @@ static int ModifierCharWidth(Tk_Font tkfont);
key = @"\t";
} else if (([event modifierFlags] & NSCommandKeyMask) == NSCommandKeyMask) {
-
/*
* If the command modifier is set, use the full character string so
* things like the dvorak / qwerty layout will work.
@@ -343,6 +345,8 @@ static int ModifierCharWidth(Tk_Font tkfont);
- (void) menuWillOpen: (NSMenu *) menu
{
+ (void)menu;
+
if (_tkMenu) {
//RecursivelyClearActiveMenu(_tkMenu);
GenerateMenuSelectEvent((TKMenu *)[self supermenu],
@@ -352,6 +356,8 @@ static int ModifierCharWidth(Tk_Font tkfont);
- (void) menuDidClose: (NSMenu *) menu
{
+ (void)menu;
+
if (_tkMenu) {
RecursivelyClearActiveMenu(_tkMenu);
}
@@ -359,6 +365,8 @@ static int ModifierCharWidth(Tk_Font tkfont);
- (void) menu: (NSMenu *) menu willHighlightItem: (NSMenuItem *) item
{
+ (void)menu;
+
if (_tkMenu) {
GenerateMenuSelectEvent(self, item);
}
@@ -367,6 +375,7 @@ static int ModifierCharWidth(Tk_Font tkfont);
- (void) menuNeedsUpdate: (NSMenu *) menu
{
TkMenu *menuPtr = (TkMenu *) _tkMenu;
+ (void)menu;
if (menuPtr) {
Tcl_Interp *interp = menuPtr->interp;
@@ -392,6 +401,7 @@ static int ModifierCharWidth(Tk_Font tkfont);
- (void) menuBeginTracking: (NSNotification *) notification
{
+ (void)notification;
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
@@ -401,6 +411,7 @@ static int ModifierCharWidth(Tk_Font tkfont);
- (void) menuEndTracking: (NSNotification *) notification
{
+ (void)notification;
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
@@ -628,6 +639,10 @@ TkpConfigureMenuEntry(
&imageHeight);
image = TkMacOSXGetNSImageWithBitmap(mePtr->menuPtr->display, bitmap,
gc, imageWidth, imageHeight);
+ if (gc->foreground == defaultFg) {
+ // Use a semantic foreground color by default
+ [image setTemplate:YES];
+ }
}
[menuItem setImage:image];
if ((!image || mePtr->compound != COMPOUND_NONE) && mePtr->labelPtr &&
@@ -650,7 +665,7 @@ TkpConfigureMenuEntry(
gc->foreground!=defaultFg? gc->foreground:gc->background);
attributes = [[attributes mutableCopy] autorelease];
- [(NSMutableDictionary *)attributes setObject:color
+ [(NSMutableDictionary *) attributes setObject:color
forKey:NSForegroundColorAttributeName];
}
if (attributes) {
@@ -690,21 +705,31 @@ TkpConfigureMenuEntry(
[submenu setTitle:title];
if ([menuItem isEnabled]) {
- /* This menuItem might have been previously disabled (XXX:
- track this), which would have disabled entries; we must
- re-enable the entries here. */
- int i = 0;
- NSArray *itemArray = [submenu itemArray];
- for (NSMenuItem *item in itemArray) {
- TkMenuEntry *submePtr = menuRefPtr->menuPtr->entries[i];
- /* Work around an apparent bug where itemArray can have
- more items than the menu's entries[] array. */
- if (i >= menuRefPtr->menuPtr->numEntries) break;
- [item setEnabled: !(submePtr->state == ENTRY_DISABLED)];
- i++;
- }
- }
+ /*
+ * This menuItem might have been previously disabled (XXX:
+ * track this), which would have disabled entries; we must
+ * re-enable the entries here.
+ */
+
+ int i = 0;
+ NSArray *itemArray = [submenu itemArray];
+
+ for (NSMenuItem *item in itemArray) {
+ TkMenuEntry *submePtr = menuRefPtr->menuPtr->entries[i];
+
+ /*
+ * Work around an apparent bug where itemArray can have
+ * more items than the menu's entries[] array.
+ */
+
+ if (i >= (int) menuRefPtr->menuPtr->numEntries) {
+ break;
+ }
+ [item setEnabled: !(submePtr->state == ENTRY_DISABLED)];
+ i++;
+ }
+ }
}
}
}
@@ -755,10 +780,10 @@ TkpDestroyMenuEntry(
*
* TkpPostMenu --
*
- * Posts a menu on the screen. If entry is < 0 then the menu is
- * drawn so its top left corner is located at the point with
- * screen coordinates (x, y). Otherwise the top left corner of
- * the specified entry is located at that point.
+ * Posts a menu on the screen. If entry is < 0 then the menu is drawn so
+ * its top left corner is located at the point with screen coordinates
+ * (x,y). Otherwise the top left corner of the specified entry is located
+ * at that point.
*
* Results:
* Returns a standard Tcl result.
@@ -771,7 +796,7 @@ TkpDestroyMenuEntry(
int
TkpPostMenu(
- Tcl_Interp *interp, /* The interpreter this menu lives in */
+ TCL_UNUSED(Tcl_Interp *), /* The interpreter this menu lives in */
TkMenu *menuPtr, /* The menu we are posting */
int x, int y, /* The screen coordinates where the top left
* corner of the menu, or of the specified
@@ -779,20 +804,35 @@ TkpPostMenu(
int index)
{
int result;
- Tk_Window root = Tk_MainWindow(interp);
+ Tk_Window realWin = menuPtr->tkwin;
+ TkWindow *realWinPtr;
+ NSView *realWinView;
- if (root == NULL) {
- return TCL_ERROR;
+ while (1) {
+ if (realWin == NULL) {
+ return TCL_ERROR;
+ }
+ /*
+ * Fix for bug 07cfc9f03e: use the view for the parent real (non-menu)
+ * toplevel window, rather than always using the root window.
+ * This allows menus to appear on a separate monitor than the root
+ * window, and to use the appearance of their parent real window
+ * rather than the appearance of the root window.
+ */
+ realWinPtr = (TkWindow*) realWin;
+ realWinView = TkMacOSXDrawableView(realWinPtr->privatePtr);
+ if (realWinView != nil) {
+ break;
+ }
+ realWin = Tk_Parent(realWin);
}
- Drawable d = Tk_WindowId(root);
- NSView *rootview = TkMacOSXGetRootControl(d);
- NSWindow *win = [rootview window];
+ NSWindow *win = [realWinView window];
NSView *view = [win contentView];
NSMenu *menu = (NSMenu *) menuPtr->platformData;
NSInteger itemIndex = index;
NSInteger numItems = [menu numberOfItems];
NSMenuItem *item = nil;
- NSPoint location = NSMakePoint(x, tkMacOSXZeroScreenHeight - y);
+ NSPoint location = NSMakePoint(x, TkMacOSXZeroScreenHeight() - y);
inPostMenu = 1;
result = TkPreprocessMenu(menuPtr);
@@ -806,7 +846,7 @@ TkpPostMenu(
if (itemIndex >= 0) {
item = [menu itemAtIndex:itemIndex];
}
-
+
/*
* The post commands could have deleted the menu, which means we are dead
* and should go away.
@@ -828,13 +868,13 @@ TkpPostMenu(
*
* TkpPostTearoffMenu --
*
- * Tearoff menus are not supported on the Mac. This placeholder
- * function, which is simply a copy of the unix function, posts a
- * completely useless window with a black background on the screen. If
- * entry is < 0 then the window is positioned so that its top left corner
- * is located at the point with screen coordinates (x, y). Otherwise the
- * window position is offset so that top left corner of the specified
- * entry would be located at that point, if there actually were a menu.
+ * Tearoff menus are not supported on the Mac. This placeholder function,
+ * which is simply a copy of the unix function, posts a completely useless
+ * window with a black background on the screen. If entry is < 0 then the
+ * window is positioned so that its top left corner is located at the
+ * point with screen coordinates (x, y). Otherwise the window position is
+ * offset so that top left corner of the specified entry would be located
+ * at that point, if there actually were a menu.
*
* Mac menus steal all mouse or keyboard input from the application until
* the menu is dismissed, with or without a selection, by a mouse or key
@@ -853,7 +893,7 @@ TkpPostMenu(
int
TkpPostTearoffMenu(
- Tcl_Interp *interp, /* The interpreter this menu lives in */
+ TCL_UNUSED(Tcl_Interp *), /* The interpreter this menu lives in */
TkMenu *menuPtr, /* The menu we are posting */
int x, int y, int index) /* The screen coordinates where the top left
* corner of the menu, or of the specified
@@ -862,7 +902,7 @@ TkpPostTearoffMenu(
int vRootX, vRootY, vRootWidth, vRootHeight;
int result;
- if (index >= menuPtr->numEntries) {
+ if (index >= (int) menuPtr->numEntries) {
index = menuPtr->numEntries - 1;
}
if (index >= 0) {
@@ -960,12 +1000,12 @@ TkpSetWindowMenuBar(
*
* TkpSetMainMenubar --
*
- * Puts the menu associated with a window into the menubar. Should only
- * be called when the window is in front.
+ * Puts the menu associated with a window into the menubar. Should only be
+ * called when the window is in front.
*
* This is a no-op on all other platforms. On OS X it is a no-op when
- * passed a NULL menuName or a nonexistent menuName, with an exception
- * for the first call in a new interpreter. In that special case, passing a
+ * passed a NULL menuName or a nonexistent menuName, with an exception for
+ * the first call in a new interpreter. In that special case, passing a
* NULL menuName installs the default menu.
*
* Results:
@@ -993,19 +1033,21 @@ TkpSetMainMenubar(
*/
if (Tk_IsEmbedded(winPtr)) {
- return;
- }
+ return;
+ }
if (menuName) {
Tk_Window menubar = NULL;
+
if (winPtr->wmInfoPtr &&
- winPtr->wmInfoPtr->menuPtr &&
- winPtr->wmInfoPtr->menuPtr->masterMenuPtr) {
+ winPtr->wmInfoPtr->menuPtr &&
+ winPtr->wmInfoPtr->menuPtr->masterMenuPtr) {
menubar = winPtr->wmInfoPtr->menuPtr->masterMenuPtr->tkwin;
}
/*
- * Attempt to find the NSMenu directly. If that fails, ask Tk to find it.
+ * Attempt to find the NSMenu directly. If that fails, ask Tk to find
+ * it.
*/
if (menubar != NULL && strcmp(menuName, Tk_PathName(menubar)) == 0) {
@@ -1013,6 +1055,7 @@ TkpSetMainMenubar(
} else {
TkMenuReferences *menuRefPtr = TkFindMenuReferences(interp,
menuName);
+
if (menuRefPtr && menuRefPtr->menuPtr &&
menuRefPtr->menuPtr->platformData) {
menu = (TKMenu *) menuRefPtr->menuPtr->platformData;
@@ -1021,11 +1064,10 @@ TkpSetMainMenubar(
}
/*
- * If we couldn't find a menu, do nothing unless the window belongs
- * to a different application. In that case, install the default
- * menubar.
+ * If we couldn't find a menu, do nothing unless the window belongs to a
+ * different application. In that case, install the default menubar.
*/
-
+
if (menu || interp != currentInterp) {
[NSApp tkSetMainMenu:menu];
}
@@ -1038,8 +1080,8 @@ TkpSetMainMenubar(
* CheckForSpecialMenu --
*
* Given a menu, check to see whether or not it is a cascade in a menubar
- * with one of the special names ".apple", ".help" or ".window". If it
- * is, the entry that points to this menu will be marked.
+ * with one of the special names ".apple", ".help" or ".window". If it is,
+ * the entry that points to this menu will be marked.
*
* Results:
* None.
@@ -1230,11 +1272,12 @@ TkpComputeStandardMenuGeometry(
/*
* Do nothing if this menu is a clone.
*/
+
if (menuPtr->tkwin == NULL || menuPtr->masterMenuPtr != menuPtr) {
return;
}
-
- menuSize = [(NSMenu *)menuPtr->platformData size];
+
+ menuSize = [(NSMenu *) menuPtr->platformData size];
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr,
&borderWidth);
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr,
@@ -1248,16 +1291,16 @@ TkpComputeStandardMenuGeometry(
* want to do it intelligently. We are going to precalculate them and pass
* them down to all of the measuring and drawing routines. We will measure
* the font metrics of the menu once. If an entry does not have its own
- * font set, then we give the geometry/drawing routines the menu's font
- * and metrics. If an entry has its own font, we will measure that font
- * and give all of the geometry/drawing the entry's font and metrics.
+ * font set, then we give the geometry/drawing routines the menu's font and
+ * metrics. If an entry has its own font, we will measure that font and
+ * give all of the geometry/drawing the entry's font and metrics.
*/
menuFont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr);
Tk_GetFontMetrics(menuFont, &menuMetrics);
menuModifierCharWidth = ModifierCharWidth(menuFont);
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int) menuPtr->numEntries; i++) {
mePtr = menuPtr->entries[i];
if (mePtr->type == CASCADE_ENTRY || mePtr->accelLength > 0) {
haveAccel = 1;
@@ -1265,7 +1308,7 @@ TkpComputeStandardMenuGeometry(
}
}
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int) menuPtr->numEntries; i++) {
mePtr = menuPtr->entries[i];
if (mePtr->type == TEAROFF_ENTRY) {
continue;
@@ -1295,6 +1338,7 @@ TkpComputeStandardMenuGeometry(
NSMenuItem *menuItem = (NSMenuItem *) mePtr->platformEntryData;
int haveImage = 0, width = 0, height = 0;
+
if (mePtr->image) {
Tk_SizeOfImage(mePtr->image, &width, &height);
haveImage = 1;
@@ -1302,6 +1346,7 @@ TkpComputeStandardMenuGeometry(
} else if (mePtr->bitmapPtr) {
Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin,
mePtr->bitmapPtr);
+
Tk_SizeOfBitmap(menuPtr->display, bitmap, &width, &height);
haveImage = 1;
height += 2; /* tweak */
@@ -1413,7 +1458,7 @@ GenerateMenuSelectEvent(
if (menuPtr) {
int index = [menu tkIndexOfItem:menuItem];
- if (index < 0 || index >= menuPtr->numEntries ||
+ if (index < 0 || index >= (int) menuPtr->numEntries ||
(menuPtr->entries[index])->state == ENTRY_DISABLED) {
TkActivateMenuEntry(menuPtr, -1);
} else {
@@ -1492,7 +1537,7 @@ RecursivelyClearActiveMenu(
int i;
TkActivateMenuEntry(menuPtr, -1);
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int) menuPtr->numEntries; i++) {
TkMenuEntry *mePtr = menuPtr->entries[i];
if (mePtr->type == CASCADE_ENTRY
@@ -1527,7 +1572,10 @@ TkMacOSXClearMenubarActive(void)
if (mainMenu && [mainMenu isKindOfClass:[TKMenu class]]) {
TkMenu *menuPtr = [(TKMenu *) mainMenu tkMenu];
- if (menuPtr && menuPtr->numEntries && menuPtr->entries) {
+ if (menuPtr &&
+ !(menuPtr->menuFlags & MENU_DELETION_PENDING) &&
+ menuPtr->numEntries > 0 &&
+ menuPtr->entries != NULL) {
RecursivelyClearActiveMenu(menuPtr);
}
}
@@ -1654,8 +1702,8 @@ TkpMenuThreadInit(void)
void
TkpMenuNotifyToplevelCreate(
- Tcl_Interp *interp, /* The interp the menu lives in. */
- const char *menuName) /* The name of the menu to reconfigure. */
+ TCL_UNUSED(Tcl_Interp *), /* The interp the menu lives in. */
+ TCL_UNUSED(const char *)) /* The name of the menu to reconfigure. */
{
/*
* Nothing to do.
@@ -1683,8 +1731,8 @@ TkpMenuNotifyToplevelCreate(
void
TkpInitializeMenuBindings(
- Tcl_Interp *interp, /* The interpreter to set. */
- Tk_BindingTable bindingTable)
+ TCL_UNUSED(Tcl_Interp *), /* The interpreter to set. */
+ TCL_UNUSED(Tk_BindingTable))
/* The table to add to. */
{
/*
@@ -1737,17 +1785,17 @@ TkpComputeMenubarGeometry(
void
TkpDrawMenuEntry(
- TkMenuEntry *mePtr, /* The entry to draw */
- Drawable d, /* What to draw into */
- Tk_Font tkfont, /* Precalculated font for menu */
- const Tk_FontMetrics *menuMetricsPtr,
+ TCL_UNUSED(TkMenuEntry *), /* The entry to draw */
+ TCL_UNUSED(Drawable), /* What to draw into */
+ TCL_UNUSED(Tk_Font), /* Precalculated font for menu */
+ TCL_UNUSED(const Tk_FontMetrics *),
/* Precalculated metrics for menu */
- int x, /* X-coordinate of topleft of entry */
- int y, /* Y-coordinate of topleft of entry */
- int width, /* Width of the entry rectangle */
- int height, /* Height of the current rectangle */
- int strictMotif, /* Boolean flag */
- int drawArrow) /* Whether or not to draw the cascade arrow
+ TCL_UNUSED(int), /* X-coordinate of topleft of entry */
+ TCL_UNUSED(int), /* Y-coordinate of topleft of entry */
+ TCL_UNUSED(int), /* Width of the entry rectangle */
+ TCL_UNUSED(int), /* Height of the current rectangle */
+ TCL_UNUSED(int), /* Boolean flag */
+ TCL_UNUSED(int)) /* Whether or not to draw the cascade arrow
* for cascade items. */
{
}
@@ -1781,7 +1829,7 @@ TkMacOSXPreprocessMenu(void)
* TkMacOSXUseID --
*
* Take the ID out of the available list for new menus. Used by the
- * default menu bar's menus so that they do not get created at the tk
+ * default menu bar's menus so that they do not get created at the Tk
* level. See TkMacOSXGetNewMenuID for more information.
*
* Results:
@@ -1796,7 +1844,7 @@ TkMacOSXPreprocessMenu(void)
int
TkMacOSXUseMenuID(
- short macID) /* The id to take out of the table */
+ TCL_UNUSED(short)) /* The id to take out of the table */
{
return TCL_OK;
}
@@ -1806,8 +1854,7 @@ TkMacOSXUseMenuID(
*
* TkMacOSXDispatchMenuEvent --
*
- * Given a menu id and an item, dispatches the command associated with
- * it.
+ * Given a menu id and an item, dispatches the command associated with it.
*
* Results:
* None.
@@ -1820,8 +1867,8 @@ TkMacOSXUseMenuID(
int
TkMacOSXDispatchMenuEvent(
- int menuID, /* The menu id of the menu we are invoking */
- int index) /* The one-based index of the item that was
+ TCL_UNUSED(int), /* The menu id of the menu we are invoking */
+ TCL_UNUSED(int)) /* The one-based index of the item that was
* selected. */
{
return TCL_ERROR;
@@ -1857,9 +1904,10 @@ TkMacOSXHandleTearoffMenu(void)
*
* TkMacOSXSetHelpMenuItemCount --
*
- * Has to be called after the first call to InsertMenu. Sets up the
- * global variable for the number of items in the unmodified help menu.
- * NB. Nobody uses this any more, since you can get the number of system
+ * Has to be called after the first call to InsertMenu. Sets up the global
+ * variable for the number of items in the unmodified help menu.
+ *
+ * NB: Nobody uses this any more, since you can get the number of system
* help items from HMGetHelpMenu trivially. But it is in the stubs
* table...
*
diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c
index b2b4b76..1e88f3a 100644
--- a/macosx/tkMacOSXMenubutton.c
+++ b/macosx/tkMacOSXMenubutton.c
@@ -1,8 +1,8 @@
/*
* tkMacOSXMenubutton.c --
*
- * This file implements the Macintosh specific portion of the
- * menubutton widget.
+ * This file implements the Macintosh specific portion of the menubutton
+ * widget.
*
* Copyright (c) 1996 by Sun Microsystems, Inc.
* Copyright 2001, Apple Computer, Inc.
@@ -32,7 +32,6 @@ typedef struct {
int hasImageOrBitmap;
} DrawParams;
-
/*
* Declaration of Mac specific button structure.
*/
@@ -50,21 +49,24 @@ typedef struct MacMenuButton {
* Forward declarations for static functions defined later in this file:
*/
-static void MenuButtonEventProc(ClientData clientData, XEvent *eventPtr);
-static void MenuButtonBackgroundDrawCB (MacMenuButton *ptr, SInt16 depth,
- Boolean isColorDev);
-static void MenuButtonContentDrawCB (ThemeButtonKind kind,
- const HIThemeButtonDrawInfo * info,
- MacMenuButton *ptr, SInt16 depth,
- Boolean isColorDev);
-static void MenuButtonEventProc ( ClientData clientData, XEvent *eventPtr);
-static void TkMacOSXComputeMenuButtonParams (TkMenuButton * butPtr,
- ThemeButtonKind* btnkind,
- HIThemeButtonDrawInfo* drawinfo);
-static void TkMacOSXComputeMenuButtonDrawParams (TkMenuButton * butPtr,
- DrawParams * dpPtr);
-static void TkMacOSXDrawMenuButton (MacMenuButton *butPtr, GC gc, Pixmap pixmap);
-static void DrawMenuButtonImageAndText(TkMenuButton* butPtr);
+static void MenuButtonEventProc(ClientData clientData,
+ XEvent *eventPtr);
+static void MenuButtonBackgroundDrawCB(MacMenuButton *ptr,
+ SInt16 depth, Boolean isColorDev);
+static void MenuButtonContentDrawCB(ThemeButtonKind kind,
+ const HIThemeButtonDrawInfo *info,
+ MacMenuButton *ptr, SInt16 depth,
+ Boolean isColorDev);
+static void MenuButtonEventProc(ClientData clientData,
+ XEvent *eventPtr);
+static void TkMacOSXComputeMenuButtonParams(TkMenuButton *butPtr,
+ ThemeButtonKind *btnkind,
+ HIThemeButtonDrawInfo *drawinfo);
+static void TkMacOSXComputeMenuButtonDrawParams(
+ TkMenuButton *butPtr, DrawParams *dpPtr);
+static void TkMacOSXDrawMenuButton(MacMenuButton *butPtr, GC gc,
+ Pixmap pixmap);
+static void DrawMenuButtonImageAndText(TkMenuButton *butPtr);
/*
* The structure below defines menubutton class behavior by means of
@@ -74,6 +76,8 @@ static void DrawMenuButtonImageAndText(TkMenuButton* butPtr);
Tk_ClassProcs tkpMenubuttonClass = {
sizeof(Tk_ClassProcs), /* size */
TkMenuButtonWorldChanged, /* worldChangedProc */
+ NULL,
+ NULL
};
/*
@@ -131,10 +135,9 @@ TkMenuButton *
TkpCreateMenuButton(
Tk_Window tkwin)
{
- MacMenuButton *mbPtr = (MacMenuButton *) ckalloc(sizeof(MacMenuButton));
+ MacMenuButton *mbPtr = (MacMenuButton *)ckalloc(sizeof(MacMenuButton));
- Tk_CreateEventHandler(tkwin, ActivateMask, MenuButtonEventProc,
- (ClientData) mbPtr);
+ Tk_CreateEventHandler(tkwin, ActivateMask, MenuButtonEventProc, mbPtr);
mbPtr->flags = FIRST_DRAW;
mbPtr->btnkind = kThemePopupButton;
bzero(&mbPtr->drawinfo, sizeof(mbPtr->drawinfo));
@@ -153,8 +156,7 @@ TkpCreateMenuButton(
* None.
*
* Side effects:
- * Commands are output to X to display the menubutton in its
- * current mode.
+ * Commands are output to X to display the menubutton in its current mode.
*
*----------------------------------------------------------------------
*/
@@ -163,11 +165,11 @@ void
TkpDisplayMenuButton(
ClientData clientData) /* Information about widget. */
{
- MacMenuButton *mbPtr = (MacMenuButton *)clientData;
- TkMenuButton *butPtr = (TkMenuButton *) clientData;
- Tk_Window tkwin = butPtr->tkwin;
+ MacMenuButton *mbPtr = clientData;
+ TkMenuButton *butPtr = clientData;
+ Tk_Window tkwin = butPtr->tkwin;
Pixmap pixmap;
- DrawParams* dpPtr = &mbPtr->drawParams;
+ DrawParams *dpPtr = &mbPtr->drawParams;
butPtr->flags &= ~REDRAW_PENDING;
if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
@@ -179,22 +181,27 @@ TkpDisplayMenuButton(
TkMacOSXComputeMenuButtonDrawParams(butPtr, dpPtr);
/*
- * set up clipping region. Make sure the we are using the port
- * for this button, or we will set the wrong window's clip.
+ * Set up clipping region. Make sure the we are using the port for this
+ * button, or we will set the wrong window's clip.
*/
TkMacOSXSetUpClippingRgn(pixmap);
- /* Draw the native portion of the buttons. */
+ /*
+ * Draw the native portion of the buttons.
+ */
+
TkMacOSXDrawMenuButton(mbPtr, dpPtr->gc, pixmap);
- /* Draw highlight border, if needed. */
+ /*
+ * Draw highlight border, if needed.
+ */
+
if (butPtr->highlightWidth < 3) {
- if ((butPtr->flags & GOT_FOCUS)) {
- Tk_Draw3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0,
- Tk_Width(tkwin), Tk_Height(tkwin),
- butPtr->highlightWidth, TK_RELIEF_SOLID);
- }
+ if (butPtr->flags & GOT_FOCUS) {
+ GC gc = Tk_GCForColor(butPtr->highlightColorPtr, pixmap);
+ TkMacOSXDrawSolidBorder(tkwin, gc, 0, butPtr->highlightWidth);
+ }
}
}
@@ -203,8 +210,8 @@ TkpDisplayMenuButton(
*
* TkpDestroyMenuButton --
*
- * Free data structures associated with the menubutton control.
- * This is a no-op on the Mac.
+ * Free data structures associated with the menubutton control. This is a
+ * no-op on the Mac.
*
* Results:
* None.
@@ -217,7 +224,7 @@ TkpDisplayMenuButton(
void
TkpDestroyMenuButton(
- TkMenuButton *mbPtr)
+ TCL_UNUSED(TkMenuButton *))
{
}
@@ -241,7 +248,7 @@ TkpDestroyMenuButton(
void
TkpComputeMenuButtonGeometry(butPtr)
- register TkMenuButton *butPtr; /* Widget record for menu button. */
+ TkMenuButton *butPtr; /* Widget record for menu button. */
{
int width, height, avgWidth, haveImage = 0, haveText = 0;
int txtWidth, txtHeight;
@@ -279,44 +286,42 @@ TkpComputeMenuButtonGeometry(butPtr)
}
/*
- * If the button is compound (ie, it shows both an image and text),
- * the new geometry is a combination of the image and text geometry.
- * We only honor the compound bit if the button has both text and an
- * image, because otherwise it is not really a compound button.
+ * If the button is compound (ie, it shows both an image and text), the new
+ * geometry is a combination of the image and text geometry. We only honor
+ * the compound bit if the button has both text and an image, because
+ * otherwise it is not really a compound button.
*/
if (haveImage && haveText) {
switch ((enum compound) butPtr->compound) {
- case COMPOUND_TOP:
- case COMPOUND_BOTTOM: {
- /*
- * Image is above or below text
- */
-
- height += txtHeight + butPtr->padY;
- width = (width > txtWidth ? width : txtWidth);
- break;
- }
- case COMPOUND_LEFT:
- case COMPOUND_RIGHT: {
- /*
- * Image is left or right of text
- */
-
- width += txtWidth + butPtr->padX;
- height = (height > txtHeight ? height : txtHeight);
- break;
- }
- case COMPOUND_CENTER: {
- /*
- * Image and text are superimposed
- */
-
- width = (width > txtWidth ? width : txtWidth);
- height = (height > txtHeight ? height : txtHeight);
- break;
- }
- case COMPOUND_NONE: {break;}
+ case COMPOUND_TOP:
+ case COMPOUND_BOTTOM:
+ /*
+ * Image is above or below text
+ */
+
+ height += txtHeight + butPtr->padY;
+ width = (width > txtWidth ? width : txtWidth);
+ break;
+ case COMPOUND_LEFT:
+ case COMPOUND_RIGHT:
+ /*
+ * Image is left or right of text
+ */
+
+ width += txtWidth + butPtr->padX;
+ height = (height > txtHeight ? height : txtHeight);
+ break;
+ case COMPOUND_CENTER:
+ /*
+ * Image and text are superimposed
+ */
+
+ width = (width > txtWidth ? width : txtWidth);
+ height = (height > txtHeight ? height : txtHeight);
+ break;
+ case COMPOUND_NONE:
+ break;
}
if (butPtr->width > 0) {
@@ -345,7 +350,7 @@ TkpComputeMenuButtonGeometry(butPtr)
}
}
}
-
+
butPtr->inset = highlightWidth + butPtr->borderWidth;
width += LEFT_INSET + RIGHT_INSET + 2*butPtr->inset;
height += 2*butPtr->inset;
@@ -371,34 +376,26 @@ TkpComputeMenuButtonGeometry(butPtr)
*/
void
DrawMenuButtonImageAndText(
- TkMenuButton* butPtr)
+ TkMenuButton *butPtr)
{
- MacMenuButton *mbPtr = (MacMenuButton*)butPtr;
- Tk_Window tkwin = butPtr->tkwin;
- Pixmap pixmap;
- int haveImage = 0;
- int haveText = 0;
- int imageWidth = 0;
- int imageHeight = 0;
- int imageXOffset = 0;
- int imageYOffset = 0;
- int textXOffset = 0;
- int textYOffset = 0;
- int width = 0;
- int height = 0;
- int fullWidth = 0;
- int fullHeight = 0;
- int pressed;
+ MacMenuButton *mbPtr = (MacMenuButton *) butPtr;
+ Tk_Window tkwin = butPtr->tkwin;
+ Pixmap pixmap;
+ int haveImage = 0, haveText = 0;
+ int imageWidth = 0, imageHeight = 0;
+ int imageXOffset = 0, imageYOffset = 0;
+ int textXOffset = 0, textYOffset = 0;
+ int width = 0, height = 0;
+ int fullWidth = 0, fullHeight = 0;
if (tkwin == NULL || !Tk_IsMapped(tkwin)) {
return;
}
- DrawParams* dpPtr = &mbPtr->drawParams;
- pixmap = (Pixmap)Tk_WindowId(tkwin);
-
+ DrawParams *dpPtr = &mbPtr->drawParams;
+ pixmap = (Pixmap) Tk_WindowId(tkwin);
- if (butPtr->image != None) {
+ if (butPtr->image != NULL) {
Tk_SizeOfImage(butPtr->image, &width, &height);
haveImage = 1;
} else if (butPtr->bitmap != None) {
@@ -406,86 +403,80 @@ DrawMenuButtonImageAndText(
haveImage = 1;
}
- imageWidth = width;
+ imageWidth = width;
imageHeight = height;
- if (mbPtr->drawinfo.state == kThemeStatePressed) {
- /* Offset bitmaps by a bit when the button is pressed. */
- pressed = 1;
- }
-
haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);
if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) {
- int x = 0;
- int y = 0;
+ int x = 0, y = 0;
+
textXOffset = 0;
textYOffset = 0;
fullWidth = 0;
fullHeight = 0;
switch ((enum compound) butPtr->compound) {
- case COMPOUND_TOP:
- case COMPOUND_BOTTOM: {
- /* Image is above or below text */
- if (butPtr->compound == COMPOUND_TOP) {
- textYOffset = height + butPtr->padY;
- } else {
- imageYOffset = butPtr->textHeight + butPtr->padY;
- }
- fullHeight = height + butPtr->textHeight + butPtr->padY;
- fullWidth = (width > butPtr->textWidth ?
- width : butPtr->textWidth);
- textXOffset = (fullWidth - butPtr->textWidth)/2;
- imageXOffset = (fullWidth - width)/2;
- break;
- }
- case COMPOUND_LEFT:
- case COMPOUND_RIGHT: {
- /*
- * Image is left or right of text
- */
-
- if (butPtr->compound == COMPOUND_LEFT) {
- textXOffset = width + butPtr->padX - 2;
- } else {
- imageXOffset = butPtr->textWidth + butPtr->padX;
- }
- fullWidth = butPtr->textWidth + butPtr->padX + width;
- fullHeight = (height > butPtr->textHeight ? height :
- butPtr->textHeight);
- textYOffset = (fullHeight - butPtr->textHeight)/2;
- imageYOffset = (fullHeight - height)/2;
- break;
- }
- case COMPOUND_CENTER: {
- /*
- * Image and text are superimposed
- */
-
- fullWidth = (width > butPtr->textWidth ? width :
- butPtr->textWidth);
- fullHeight = (height > butPtr->textHeight ? height :
- butPtr->textHeight);
- textXOffset = (fullWidth - butPtr->textWidth)/2;
- imageXOffset = (fullWidth - width)/2;
- textYOffset = (fullHeight - butPtr->textHeight)/2;
- imageYOffset = (fullHeight - height)/2;
- break;
- }
- case COMPOUND_NONE: {break;}
+ case COMPOUND_TOP:
+ case COMPOUND_BOTTOM:
+ /*
+ * Image is above or below text.
+ */
+
+ if (butPtr->compound == COMPOUND_TOP) {
+ textYOffset = height + butPtr->padY;
+ } else {
+ imageYOffset = butPtr->textHeight + butPtr->padY;
+ }
+ fullHeight = height + butPtr->textHeight + butPtr->padY;
+ fullWidth = (width > butPtr->textWidth ?
+ width : butPtr->textWidth);
+ textXOffset = (fullWidth - butPtr->textWidth)/2;
+ imageXOffset = (fullWidth - width)/2;
+ break;
+ case COMPOUND_LEFT:
+ case COMPOUND_RIGHT:
+ /*
+ * Image is left or right of text
+ */
+
+ if (butPtr->compound == COMPOUND_LEFT) {
+ textXOffset = width + butPtr->padX - 2;
+ } else {
+ imageXOffset = butPtr->textWidth + butPtr->padX;
+ }
+ fullWidth = butPtr->textWidth + butPtr->padX + width;
+ fullHeight = (height > butPtr->textHeight ? height :
+ butPtr->textHeight);
+ textYOffset = (fullHeight - butPtr->textHeight)/2;
+ imageYOffset = (fullHeight - height)/2;
+ break;
+ case COMPOUND_CENTER:
+ /*
+ * Image and text are superimposed
+ */
+
+ fullWidth = (width > butPtr->textWidth ? width : butPtr->textWidth);
+ fullHeight = (height > butPtr->textHeight ? height :
+ butPtr->textHeight);
+ textXOffset = (fullWidth - butPtr->textWidth) / 2;
+ imageXOffset = (fullWidth - width) / 2;
+ textYOffset = (fullHeight - butPtr->textHeight) / 2;
+ imageYOffset = (fullHeight - height) / 2;
+ break;
+ case COMPOUND_NONE:
+ break;
}
TkComputeAnchor(butPtr->anchor, tkwin,
- butPtr->padX + butPtr->inset,
- butPtr->padY + butPtr->inset,
+ butPtr->padX + butPtr->inset, butPtr->padY + butPtr->inset,
fullWidth, fullHeight, &x, &y);
imageXOffset = LEFT_INSET;
imageYOffset += y;
textYOffset -= 1;
if (butPtr->image != NULL) {
- Tk_RedrawImage(butPtr->image, 0, 0, width,
- height, pixmap, imageXOffset, imageYOffset);
+ Tk_RedrawImage(butPtr->image, 0, 0, width,
+ height, pixmap, imageXOffset, imageYOffset);
} else {
XSetClipOrigin(butPtr->display, dpPtr->gc,
imageXOffset, imageYOffset);
@@ -499,12 +490,12 @@ DrawMenuButtonImageAndText(
dpPtr->gc, butPtr->textLayout,
x + textXOffset, y + textYOffset, 0, -1);
Tk_UnderlineTextLayout(butPtr->display, pixmap, dpPtr->gc,
- butPtr->textLayout,
- x + textXOffset, y + textYOffset,
+ butPtr->textLayout, x + textXOffset, y + textYOffset,
butPtr->underline);
} else {
+ int x, y;
+
if (haveImage) {
- int x, y;
TkComputeAnchor(butPtr->anchor, tkwin,
butPtr->padX + butPtr->borderWidth,
butPtr->padY + butPtr->borderWidth,
@@ -524,27 +515,24 @@ DrawMenuButtonImageAndText(
XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0);
}
} else {
- int x, y;
textXOffset = LEFT_INSET;
TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
- butPtr->textWidth, butPtr->textHeight, &x, &y);
+ butPtr->textWidth, butPtr->textHeight, &x, &y);
Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc,
- butPtr->textLayout, textXOffset, y, 0, -1);
+ butPtr->textLayout, textXOffset, y, 0, -1);
y += butPtr->textHeight/2;
- }
+ }
}
}
-
-
-
+
/*
*--------------------------------------------------------------
*
* TkMacOSXDrawMenuButton --
*
- * This function draws the tk menubutton using Mac controls
- * In addition, this code may apply custom colors passed
- * in the TkMenubutton.
+ * This function draws the tk menubutton using Mac controls. In
+ * addition, this code may apply custom colors passed in the
+ * TkMenubutton.
*
* Results:
* None.
@@ -554,43 +542,38 @@ DrawMenuButtonImageAndText(
*
*--------------------------------------------------------------
*/
+
static void
TkMacOSXDrawMenuButton(
MacMenuButton *mbPtr, /* Mac menubutton. */
- GC gc, /* The GC we are drawing into - needed for
- * the bevel button */
- Pixmap pixmap) /* The pixmap we are drawing into - needed
- * for the bevel button */
+ TCL_UNUSED(GC), /* The GC we are drawing into - not used */
+ Pixmap pixmap) /* The pixmap we are drawing into - needed for the
+ * bevel button */
{
- TkMenuButton * butPtr = ( TkMenuButton *)mbPtr;
- TkWindow * winPtr;
- HIRect cntrRect;
+ TkMenuButton *butPtr = (TkMenuButton *) mbPtr;
+ TkWindow *winPtr = (TkWindow *) butPtr->tkwin;
+ HIRect cntrRect;
TkMacOSXDrawingContext dc;
- DrawParams* dpPtr = &mbPtr->drawParams;
+ DrawParams *dpPtr = &mbPtr->drawParams;
int useNewerHITools = 1;
- winPtr = (TkWindow *)butPtr->tkwin;
-
TkMacOSXComputeMenuButtonParams(butPtr, &mbPtr->btnkind, &mbPtr->drawinfo);
cntrRect = CGRectMake(winPtr->privatePtr->xOff, winPtr->privatePtr->yOff,
- Tk_Width(butPtr->tkwin),
- Tk_Height(butPtr->tkwin));
+ Tk_Width(butPtr->tkwin), Tk_Height(butPtr->tkwin));
if (useNewerHITools == 1) {
HIRect contHIRec;
static HIThemeButtonDrawInfo hiinfo;
- MenuButtonBackgroundDrawCB((MacMenuButton*) mbPtr, 32, true);
-
+ MenuButtonBackgroundDrawCB(mbPtr, 32, true);
if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) {
return;
}
-
hiinfo.version = 0;
hiinfo.state = mbPtr->drawinfo.state;
- hiinfo.kind = mbPtr->btnkind;
+ hiinfo.kind = mbPtr->btnkind;
hiinfo.value = mbPtr->drawinfo.value;
hiinfo.adornment = mbPtr->drawinfo.adornment;
hiinfo.animation.time.current = CFAbsoluteTimeGetCurrent();
@@ -598,11 +581,22 @@ TkMacOSXDrawMenuButton(
hiinfo.animation.time.start = hiinfo.animation.time.current;
}
+ /*
+ * To avoid menubuttons with white text on a white background, we
+ * always set the state to inactive in Dark Mode. It isn't perfect but
+ * it is usable. Using a ttk::menubutton would be a better choice,
+ * however.
+ */
+
+ if (TkMacOSXInDarkMode(butPtr->tkwin)) {
+ hiinfo.state = kThemeStateInactive;
+ }
+
HIThemeDrawButton(&cntrRect, &hiinfo, dc.context,
- kHIThemeOrientationNormal, &contHIRec);
+ kHIThemeOrientationNormal, &contHIRec);
TkMacOSXRestoreDrawingContext(&dc);
- MenuButtonContentDrawCB( mbPtr->btnkind, &mbPtr->drawinfo,
- (MacMenuButton *)mbPtr, 32, true);
+ MenuButtonContentDrawCB(mbPtr->btnkind, &mbPtr->drawinfo,
+ mbPtr, 32, true);
} else {
if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) {
return;
@@ -617,33 +611,34 @@ TkMacOSXDrawMenuButton(
*
* MenuButtonBackgroundDrawCB --
*
- * This function draws the background that
- * lies under checkboxes and radiobuttons.
+ * This function draws the background that lies under checkboxes and
+ * radiobuttons.
*
* Results:
- * None.
+ * None.
*
* Side effects:
- * The background gets updated to the current color.
+ * The background gets updated to the current color.
*
*--------------------------------------------------------------
*/
+
static void
MenuButtonBackgroundDrawCB (
MacMenuButton *ptr,
- SInt16 depth,
- Boolean isColorDev)
+ TCL_UNUSED(SInt16),
+ TCL_UNUSED(Boolean))
{
- TkMenuButton* butPtr = (TkMenuButton*)ptr;
- Tk_Window tkwin = butPtr->tkwin;
+ TkMenuButton* butPtr = (TkMenuButton *) ptr;
+ Tk_Window tkwin = butPtr->tkwin;
Pixmap pixmap;
+
if (tkwin == NULL || !Tk_IsMapped(tkwin)) {
return;
}
- pixmap = (Pixmap)Tk_WindowId(tkwin);
-
+ pixmap = (Pixmap) Tk_WindowId(tkwin);
Tk_Fill3DRectangle(tkwin, pixmap, butPtr->normalBorder, 0, 0,
- Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
+ Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
}
/*
@@ -651,26 +646,27 @@ MenuButtonBackgroundDrawCB (
*
* MenuButtonContentDrawCB --
*
- * This function draws the label and image for the button.
+ * This function draws the label and image for the button.
*
* Results:
- * None.
+ * None.
*
* Side effects:
- * The content of the button gets updated.
+ * The content of the button gets updated.
*
*--------------------------------------------------------------
*/
+
static void
MenuButtonContentDrawCB (
- ThemeButtonKind kind,
- const HIThemeButtonDrawInfo *drawinfo,
+ TCL_UNUSED(ThemeButtonKind),
+ TCL_UNUSED(const HIThemeButtonDrawInfo *),
MacMenuButton *ptr,
- SInt16 depth,
- Boolean isColorDev)
+ TCL_UNUSED(SInt16),
+ TCL_UNUSED(Boolean))
{
- TkMenuButton *butPtr = (TkMenuButton *)ptr;
- Tk_Window tkwin = butPtr->tkwin;
+ TkMenuButton *butPtr = (TkMenuButton *) ptr;
+ Tk_Window tkwin = butPtr->tkwin;
if (tkwin == NULL || !Tk_IsMapped(tkwin)) {
return;
@@ -683,8 +679,8 @@ MenuButtonContentDrawCB (
*
* MenuButtonEventProc --
*
- * This procedure is invoked by the Tk dispatcher for various
- * events on buttons.
+ * This procedure is invoked by the Tk dispatcher for various events on
+ * buttons.
*
* Results:
* None.
@@ -700,8 +696,8 @@ MenuButtonEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkMenuButton *buttonPtr = (TkMenuButton *) clientData;
- MacMenuButton *mbPtr = (MacMenuButton *) clientData;
+ TkMenuButton *buttonPtr = clientData;
+ MacMenuButton *mbPtr = clientData;
if (eventPtr->type == ActivateNotify
|| eventPtr->type == DeactivateNotify) {
@@ -725,9 +721,9 @@ MenuButtonEventProc(
*
* TkMacOSXComputeMenuButtonParams --
*
- * This procedure computes the various parameters used
- * when creating a Carbon Appearance control.
- * These are determined by the various tk button parameters
+ * This procedure computes the various parameters used when creating a
+ * Carbon Appearance control. These are determined by the various Tk
+ * button parameters
*
* Results:
* None.
@@ -740,11 +736,11 @@ MenuButtonEventProc(
static void
TkMacOSXComputeMenuButtonParams(
- TkMenuButton * butPtr,
- ThemeButtonKind* btnkind,
+ TkMenuButton *butPtr,
+ ThemeButtonKind *btnkind,
HIThemeButtonDrawInfo *drawinfo)
{
- MacMenuButton *mbPtr = (MacMenuButton *)butPtr;
+ MacMenuButton *mbPtr = (MacMenuButton *) butPtr;
if (butPtr->image || butPtr->bitmap || butPtr->text) {
/* TODO: allow for Small and Mini menubuttons. */
@@ -789,25 +785,25 @@ TkMacOSXComputeMenuButtonParams(
*
* TkMacOSXComputeMenuButtonDrawParams --
*
- * This procedure selects an appropriate drawing context for
- * drawing a menubutton.
+ * This procedure selects an appropriate drawing context for drawing a
+ * menubutton.
*
* Results:
- * None.
+ * None.
*
* Side effects:
- * Sets the button draw parameters.
+ * Sets the button draw parameters.
*
*----------------------------------------------------------------------
*/
static void
TkMacOSXComputeMenuButtonDrawParams(
- TkMenuButton * butPtr,
- DrawParams * dpPtr)
+ TkMenuButton *butPtr,
+ DrawParams *dpPtr)
{
- dpPtr->hasImageOrBitmap = ((butPtr->image != NULL) ||
- (butPtr->bitmap != None));
+ dpPtr->hasImageOrBitmap =
+ ((butPtr->image != NULL) || (butPtr->bitmap != None));
dpPtr->border = butPtr->normalBorder;
if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) {
dpPtr->gc = butPtr->disabledGC;
@@ -818,7 +814,7 @@ TkMacOSXComputeMenuButtonDrawParams(
dpPtr->gc = butPtr->normalTextGC;
}
}
-
+
/*
* Local Variables:
* mode: objc
diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c
index 7d77d23..1029704 100644
--- a/macosx/tkMacOSXMenus.c
+++ b/macosx/tkMacOSXMenus.c
@@ -70,9 +70,8 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
[NSMenuItem itemWithTitle:
[NSString stringWithFormat:@"About %@", aboutName]
action:@selector(orderFrontStandardAboutPanel:)] atIndex:0];
-
- TKMenu *fileMenu = [TKMenu menuWithTitle:@"File" menuItems:
- [NSArray arrayWithObjects:
+ _defaultFileMenuItems =
+ [[NSArray arrayWithObjects:
[NSMenuItem itemWithTitle:
[NSString stringWithFormat:@"Source%C", 0x2026]
action:@selector(tkSource:)],
@@ -80,7 +79,10 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
action:@selector(tkDemo:)],
[NSMenuItem itemWithTitle:@"Close" action:@selector(performClose:)
target:nil keyEquivalent:@"w"],
- nil]];
+ nil] retain];
+ _demoMenuItem = [_defaultFileMenuItems objectAtIndex:1];
+ TKMenu *fileMenu = [TKMenu menuWithTitle:@"File"
+ menuItems: _defaultFileMenuItems];
TKMenu *editMenu = [TKMenu menuWithTitle:@"Edit" menuItems:
[NSArray arrayWithObjects:
[NSMenuItem itemWithTitle:@"Undo" action:@selector(undo:)
@@ -141,16 +143,13 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
[_defaultWindowsMenuItems retain];
TKMenu *windowsMenu = [TKMenu menuWithTitle:@"Window" menuItems:
_defaultWindowsMenuItems];
-
_defaultHelpMenuItems = [[NSArray arrayWithObjects:
[NSMenuItem itemWithTitle:
[NSString stringWithFormat:@"%@ Help", applicationName]
action:@selector(showHelp:) keyEquivalent:@"?"],
nil] retain];
-
TKMenu *helpMenu = [TKMenu menuWithTitle:@"Help" menuItems:
_defaultHelpMenuItems];
-
[self setServicesMenu:_servicesMenu];
[self setWindowsMenu:windowsMenu];
_defaultMainMenu = [[TKMenu menuWithTitle:@"" submenus:[NSArray
@@ -169,6 +168,7 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
[_defaultHelpMenuItems release];
[_defaultWindowsMenuItems release];
[_defaultApplicationMenuItems release];
+ [_defaultFileMenuItems release];
[super dealloc];
}
@@ -177,7 +177,6 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
SEL action = [anItem action];
if (sel_isEqual(action, @selector(preferences:))) {
-
return (_eventInterp && Tcl_FindCommand(_eventInterp,
"::tk::mac::ShowPreferences", NULL, 0));
} else if (sel_isEqual(action, @selector(tkDemo:))) {
@@ -200,6 +199,8 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
- (void) orderFrontStandardAboutPanel: (id) sender
{
+ (void)sender;
+
if (!_eventInterp || !Tcl_FindCommand(_eventInterp, "tkAboutDialog",
NULL, 0) || (GetCurrentEventKeyModifiers() & optionKey)) {
TkAboutDlg();
@@ -232,6 +233,8 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
- (void) tkSource: (id) sender
{
+ (void)sender;
+
if (_eventInterp) {
if (Tcl_EvalEx(_eventInterp, "tk_getOpenFile -filetypes {"
"{{TCL Scripts} {.tcl} TEXT} {{Text Files} {} TEXT}}",
@@ -257,12 +260,15 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
- (void) tkDemo: (id) sender
{
+ (void)sender;
+
if (_eventInterp) {
Tcl_Obj *path = GetWidgetDemoPath(_eventInterp);
if (path) {
Tcl_IncrRefCount(path);
+ [_demoMenuItem setHidden:YES];
int code = Tcl_FSEvalFileEx(_eventInterp, path, NULL);
if (code != TCL_OK) {
@@ -281,6 +287,8 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
- (BOOL) validateUserInterfaceItem: (id <NSValidatedUserInterfaceItem>) anItem
{
+ (void)anItem;
+
return YES;
}
@@ -322,19 +330,18 @@ static Tcl_Obj *
GetWidgetDemoPath(
Tcl_Interp *interp)
{
- Tcl_Obj *libpath, *result = NULL;
+ Tcl_Obj *result = NULL;
- libpath = Tcl_GetVar2Ex(interp, "tk_library", NULL, TCL_GLOBAL_ONLY);
- if (libpath) {
- Tcl_Obj *demo[2] = { Tcl_NewStringObj("demos", 5),
- Tcl_NewStringObj("widget", 6) };
+ if (Tcl_EvalEx(interp, "::tk::pkgconfig get demodir,runtime",
+ -1, TCL_EVAL_GLOBAL) == TCL_OK) {
+ Tcl_Obj *libpath, *demo[1] = { Tcl_NewStringObj("widget", 6) };
+ libpath = Tcl_GetObjResult(interp);
Tcl_IncrRefCount(libpath);
- result = Tcl_FSJoinToPath(libpath, 2, demo);
+ result = Tcl_FSJoinToPath(libpath, 1, demo);
Tcl_DecrRefCount(libpath);
- } else {
- Tcl_ResetResult(interp);
}
+ Tcl_ResetResult(interp);
return result;
}
@@ -356,9 +363,9 @@ GetWidgetDemoPath(
void
TkMacOSXHandleMenuSelect(
- short theMenu,
- unsigned short theItem,
- int optionKeyPressed)
+ TCL_UNUSED(short),
+ TCL_UNUSED(unsigned short),
+ TCL_UNUSED(int))
{
Tcl_Panic("TkMacOSXHandleMenuSelect: Obsolete, no more Carbon!");
}
@@ -381,7 +388,7 @@ TkMacOSXHandleMenuSelect(
void
TkMacOSXInitMenus(
- Tcl_Interp *interp)
+ TCL_UNUSED(Tcl_Interp *))
{
[NSApp _setupMenus];
}
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 2d5d152..7dcfa10 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -13,7 +13,7 @@
#include "tkMacOSXPrivate.h"
#include "tkMacOSXWm.h"
-#include "tkMacOSXEvent.h"
+#include "tkMacOSXInt.h"
#include "tkMacOSXDebug.h"
#include "tkMacOSXConstants.h"
@@ -24,17 +24,19 @@ typedef struct {
Point global;
Point local;
} MouseEventData;
-static Tk_Window captureWinPtr = NULL; /* Current capture window; may be NULL. */
+static Tk_Window captureWinPtr = NULL; /* Current capture window; may be
+ * NULL. */
static int GenerateButtonEvent(MouseEventData *medPtr);
static unsigned int ButtonModifiers2State(UInt32 buttonState,
- UInt32 keyModifiers);
+ UInt32 keyModifiers);
#pragma mark TKApplication(TKMouseEvent)
enum {
NSWindowWillMoveEventType = 20
};
+
/*
* In OS X 10.6 an NSEvent of type NSMouseMoved would always have a non-Nil
* window attribute pointing to the active window. As of 10.8 this behavior
@@ -48,113 +50,186 @@ enum {
@implementation TKApplication(TKMouseEvent)
- (NSEvent *) tkProcessMouseEvent: (NSEvent *) theEvent
{
-#ifdef TK_MAC_DEBUG_EVENTS
- TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
-#endif
- NSWindow* eventWindow = [theEvent window];
- NSEventType eventType = [theEvent type];
+ NSWindow *eventWindow = [theEvent window];
+ NSEventType eventType = [theEvent type];
+ TkWindow *winPtr = NULL, *grabWinPtr;
+ Tk_Window tkwin;
+ NSPoint local, global;
+ NSInteger button = -1;
#if 0
- NSTrackingArea *trackingArea = nil;
+ NSTrackingArea *trackingArea = nil;
NSInteger eventNumber, clickCount, buttonNumber;
#endif
+ [NSEvent stopPeriodicEvents];
+
+#ifdef TK_MAC_DEBUG_EVENTS
+ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
+#endif
switch (eventType) {
- case NSMouseEntered:
- case NSMouseExited:
- case NSCursorUpdate:
case NSLeftMouseDown:
- case NSLeftMouseUp:
case NSRightMouseDown:
- case NSRightMouseUp:
case NSOtherMouseDown:
- case NSOtherMouseUp:
case NSLeftMouseDragged:
case NSRightMouseDragged:
case NSOtherMouseDragged:
+ button = [theEvent buttonNumber] + Button1;
+ case NSMouseEntered:
+ case NSMouseExited:
+ case NSCursorUpdate:
+ case NSLeftMouseUp:
+ case NSRightMouseUp:
+ case NSOtherMouseUp:
case NSMouseMoved:
case NSTabletPoint:
case NSTabletProximity:
case NSScrollWheel:
- break;
+ break;
default: /* Unrecognized mouse event. */
return theEvent;
}
- /* Remember the window in case we need it next time. */
- if (eventWindow && eventWindow != _windowWithMouse) {
- if (_windowWithMouse) {
- [_windowWithMouse release];
- }
- _windowWithMouse = eventWindow;
- [_windowWithMouse retain];
- }
+ /*
+ * Compute the mouse position in Tk screen coordinates (global) and in the
+ * Tk coordinates of its containing Tk Window (local). If a grab is in effect,
+ * the local coordinates should be relative to the grab window.
+ */
- /* Create an Xevent to add to the Tk queue. */
- NSPoint global, local = [theEvent locationInWindow];
- if (eventWindow) { /* local will be in window coordinates. */
+ if (eventWindow) {
+ local = [theEvent locationInWindow];
+
+ /*
+ * Do not send ButtonPress XEvents for MouseDown NSEvents that start a
+ * resize. (The MouseUp will be handled during LiveResize.) See
+ * ticket [d72abe6b54].
+ */
+
+ if (eventType == NSLeftMouseDown &&
+ ([eventWindow styleMask] & NSResizableWindowMask) &&
+ [NSApp macMinorVersion] > 6) {
+ NSRect frame = [eventWindow frame];
+ if (local.x < 3 || local.x > frame.size.width - 3 || local.y < 3) {
+ return theEvent;
+ }
+ }
global = [eventWindow tkConvertPointToScreen: local];
+ tkwin = TkpGetCapture();
+ if (tkwin) {
+ winPtr = (TkWindow *) tkwin;
+ eventWindow = TkMacOSXDrawableWindow(winPtr->window);
+ if (eventWindow) {
+ local = [eventWindow tkConvertPointFromScreen: global];
+ } else {
+ return theEvent;
+ }
+ }
local.y = [eventWindow frame].size.height - local.y;
- global.y = tkMacOSXZeroScreenHeight - global.y;
- } else { /* local will be in screen coordinates. */
- if (_windowWithMouse ) {
- eventWindow = _windowWithMouse;
- global = local;
- local = [eventWindow tkConvertPointFromScreen: local];
- local.y = [eventWindow frame].size.height - local.y;
- global.y = tkMacOSXZeroScreenHeight - global.y;
- } else { /* We have no window. Use the screen???*/
- local.y = tkMacOSXZeroScreenHeight - local.y;
- global = local;
+ global.y = TkMacOSXZeroScreenHeight() - global.y;
+ } else {
+
+ /*
+ * If the event has no NSWindow, the location is in screen coordinates.
+ */
+
+ global = [theEvent locationInWindow];
+ tkwin = TkpGetCapture();
+ if (tkwin) {
+ winPtr = (TkWindow *) tkwin;
+ eventWindow = TkMacOSXDrawableWindow(winPtr->window);
+ } else {
+ eventWindow = [NSApp mainWindow];
+ }
+ if (!eventWindow) {
+ return theEvent;
}
+ local = [eventWindow tkConvertPointFromScreen: global];
+ local.y = [eventWindow frame].size.height - local.y;
+ global.y = TkMacOSXZeroScreenHeight() - global.y;
}
- TkWindow *winPtr = TkMacOSXGetTkWindow(eventWindow);
- Tk_Window tkwin = (Tk_Window) winPtr;
+ /*
+ * If we still don't have a window, try using the toplevel that
+ * manages the NSWindow.
+ */
- if (tkwin) {
- TkWindow *grabWinPtr = winPtr->dispPtr->grabWinPtr;
- if (grabWinPtr &&
- grabWinPtr != winPtr &&
- !winPtr->dispPtr->grabFlags && /* this means the grab is local. */
- grabWinPtr->mainPtr == winPtr->mainPtr) {
- return theEvent;
- }
- } else {
- tkwin = TkMacOSXGetCapture();
+ if (!tkwin) {
+ winPtr = TkMacOSXGetTkWindow(eventWindow);
+ tkwin = (Tk_Window) winPtr;
}
if (!tkwin) {
+
+ /*
+ * We can't find a window for this event. We have to ignore it.
+ */
+
+#ifdef TK_MAC_DEBUG_EVENTS
TkMacOSXDbgMsg("tkwin == NULL");
- return theEvent; /* Give up. No window for this event. */
+#endif
+ return theEvent;
+ }
+
+ /*
+ * Ignore the event if a local grab is in effect and the Tk event window is
+ * not in the grabber's subtree.
+ */
+
+ grabWinPtr = winPtr->dispPtr->grabWinPtr;
+ if (grabWinPtr && /* There is a grab in effect ... */
+ !winPtr->dispPtr->grabFlags && /* and it is a local grab ... */
+ grabWinPtr->mainPtr == winPtr->mainPtr){ /* in the same application. */
+ Tk_Window tkwin2, tkEventWindow = Tk_CoordsToWindow(global.x, global.y, tkwin);
+ if (!tkEventWindow) {
+ return theEvent;
+ }
+ for (tkwin2 = tkEventWindow;
+ !Tk_IsTopLevel(tkwin2);
+ tkwin2 = Tk_Parent(tkwin2)) {
+ if (tkwin2 == (Tk_Window) grabWinPtr) {
+ break;
+ }
+ }
+ if (tkwin2 != (Tk_Window) grabWinPtr) {
+ return theEvent;
+ }
+ }
+
+ /*
+ * Convert local from NSWindow flipped coordinates to the toplevel's
+ * coordinates.
+ */
+
+ if (Tk_IsEmbedded(winPtr)) {
+ TkWindow *contPtr = TkpGetOtherWindow(winPtr);
+ if (Tk_IsTopLevel(contPtr)) {
+ local.x -= contPtr->wmInfoPtr->xInParent;
+ local.y -= contPtr->wmInfoPtr->yInParent;
+ } else {
+ TkWindow *topPtr = TkMacOSXGetHostToplevel(winPtr)->winPtr;
+ local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x);
+ local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y);
+ }
} else {
- winPtr = (TkWindow *)tkwin;
+ local.x -= winPtr->wmInfoPtr->xInParent;
+ local.y -= winPtr->wmInfoPtr->yInParent;
}
- local.x -= winPtr->wmInfoPtr->xInParent;
- local.y -= winPtr->wmInfoPtr->yInParent;
+ /*
+ * Use the toplevel coordinates to find the containing Tk window. Then
+ * convert local into the coordinates of that window. (The converted
+ * local coordinates are only needed for scrollwheel events.)
+ */
int win_x, win_y;
tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y);
+ local.x = win_x;
+ local.y = win_y;
+
+ /*
+ * Generate an XEvent for this mouse event.
+ */
unsigned int state = 0;
- NSInteger button = [theEvent buttonNumber];
- EventRef eventRef = (EventRef)[theEvent eventRef];
- UInt32 buttons;
- OSStatus err = GetEventParameter(eventRef, kEventParamMouseChord,
- typeUInt32, NULL, sizeof(UInt32), NULL, &buttons);
-
- if (err == noErr) {
- state |= (buttons & ((1<<5) - 1)) << 8;
- } else if (button < 5) {
- switch (eventType) {
- case NSLeftMouseDown:
- case NSRightMouseDown:
- case NSLeftMouseDragged:
- case NSRightMouseDragged:
- case NSOtherMouseDown:
- state |= 1 << (button + 8);
- break;
- default:
- break;
- }
+ if (button > 0) {
+ state |= TkGetButtonMask(button);
}
NSUInteger modifiers = [theEvent modifierFlags];
@@ -182,11 +257,22 @@ enum {
}
if (eventType != NSScrollWheel) {
+
+ /*
+ * For normal mouse events, Tk_UpdatePointer will send the XEvent.
+ */
+
#ifdef TK_MAC_DEBUG_EVENTS
- TKLog(@"UpdatePointer %p x %f.0 y %f.0 %d", tkwin, global.x, global.y, state);
+ TKLog(@"UpdatePointer %p x %f.0 y %f.0 %d",
+ tkwin, global.x, global.y, state);
#endif
Tk_UpdatePointer(tkwin, global.x, global.y, state);
- } else { /* handle scroll wheel event */
+ } else {
+
+ /*
+ * For scroll wheel events we need to send the XEvent here.
+ */
+
CGFloat delta;
int coarseDelta;
XEvent xEvent;
@@ -203,7 +289,7 @@ enum {
delta = [theEvent deltaY];
if (delta != 0.0) {
coarseDelta = (delta > -1.0 && delta < 1.0) ?
- (signbit(delta) ? -1 : 1) : lround(delta);
+ (signbit(delta) ? -1 : 1) : lround(delta);
xEvent.xbutton.state = state;
xEvent.xkey.keycode = coarseDelta;
xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
@@ -212,7 +298,7 @@ enum {
delta = [theEvent deltaX];
if (delta != 0.0) {
coarseDelta = (delta > -1.0 && delta < 1.0) ?
- (signbit(delta) ? -1 : 1) : lround(delta);
+ (signbit(delta) ? -1 : 1) : lround(delta);
xEvent.xbutton.state = state | ShiftMask;
xEvent.xkey.keycode = coarseDelta;
xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
@@ -309,10 +395,12 @@ ButtonModifiers2State(
unsigned int state;
/*
- * Tk supports at most 5 buttons.
+ * Tk on OSX supports at most 9 buttons.
*/
- state = (buttonState & ((1<<5) - 1)) << 8;
+ state = (buttonState & 0x7F) * Button1Mask;
+ /* Handle buttons 8/9 */
+ state |= (buttonState & 0x180) * (Button8Mask >> 7);
if (keyModifiers & alphaLock) {
state |= LockMask;
@@ -372,6 +460,9 @@ XQueryPointer(
{
int getGlobal = (root_x_return && root_y_return);
int getLocal = (win_x_return && win_y_return && w != None);
+ (void)display;
+ (void)root_return;
+ (void)child_return;
if (getGlobal || getLocal) {
NSPoint global = [NSEvent mouseLocation];
@@ -395,7 +486,7 @@ XQueryPointer(
}
if (getGlobal) {
*root_x_return = global.x;
- *root_y_return = tkMacOSXZeroScreenHeight - global.y;
+ *root_y_return = TkMacOSXZeroScreenHeight() - global.y;
}
}
if (mask_return) {
@@ -447,7 +538,7 @@ TkGenerateButtonEventForXPointer(
* TkGenerateButtonEvent --
*
* Given a global x & y position and the button key status this procedure
- * generates the appropiate X button event. It also handles the state
+ * generates the appropriate X button event. It also handles the state
* changes needed to implement implicit grabs.
*
* Results:
@@ -479,7 +570,7 @@ TkGenerateButtonEvent(
med.local = med.global;
if (win) {
- NSPoint local = NSMakePoint(x, tkMacOSXZeroScreenHeight - y);
+ NSPoint local = NSMakePoint(x, TkMacOSXZeroScreenHeight() - y);
local = [win tkConvertPointFromScreen:local];
local.y = [win frame].size.height - local.y;
@@ -488,7 +579,7 @@ TkGenerateButtonEvent(
local.y -= macWin->winPtr->wmInfoPtr->yInParent;
}
med.local.h = local.x;
- med.local.v = tkMacOSXZeroScreenHeight - local.y;
+ med.local.v = TkMacOSXZeroScreenHeight() - local.y;
}
return GenerateButtonEvent(&med);
@@ -521,6 +612,7 @@ GenerateButtonEvent(
TkDisplay *dispPtr;
#if UNUSED
+
/*
* ButtonDown events will always occur in the front window. ButtonUp
* events, however, may occur anywhere on the screen. ButtonUp events
@@ -531,7 +623,7 @@ GenerateButtonEvent(
if ((medPtr->activeNonFloating == NULL)
|| ((!(TkpIsWindowFloating(medPtr->whichWin))
&& (medPtr->activeNonFloating != medPtr->whichWin))
- && TkMacOSXGetCapture() == NULL)) {
+ && TkpGetCapture() == NULL)) {
return false;
}
#endif
@@ -553,32 +645,46 @@ TkpWarpPointer(
TkDisplay *dispPtr)
{
CGPoint pt;
- UInt32 buttonState;
+ NSPoint loc;
+ int wNum;
if (dispPtr->warpWindow) {
int x, y;
-
+ TkWindow *winPtr = (TkWindow *) dispPtr->warpWindow;
+ TkWindow *topPtr = winPtr->privatePtr->toplevel->winPtr;
+ NSWindow *w = TkMacOSXDrawableWindow(winPtr->window);
+ wNum = [w windowNumber];
Tk_GetRootCoords(dispPtr->warpWindow, &x, &y);
pt.x = x + dispPtr->warpX;
pt.y = y + dispPtr->warpY;
+ loc.x = dispPtr->warpX;
+ loc.y = Tk_Height(topPtr) - dispPtr->warpY;
} else {
- pt.x = dispPtr->warpX;
+ wNum = 0;
+ pt.x = loc.x = dispPtr->warpX;
pt.y = dispPtr->warpY;
+ loc.y = TkMacOSXZeroScreenHeight() - pt.y;
}
/*
- * Tell the OSX core to generate the events to make it happen.
+ * Generate an NSEvent of type NSMouseMoved.
+ *
+ * It is not clear why this is necessary. For example, calling
+ * event generate $w <Motion> -warp 1 -x $X -y $Y
+ * will cause two <Motion> events to be added to the Tcl queue.
*/
- buttonState = [NSEvent pressedMouseButtons];
- CGEventType type = kCGEventMouseMoved;
- CGEventRef theEvent = CGEventCreateMouseEvent(NULL,
- type,
- pt,
- buttonState);
CGWarpMouseCursorPosition(pt);
- CGEventPost(kCGHIDEventTap, theEvent);
- CFRelease(theEvent);
+ NSEvent *warpEvent = [NSEvent mouseEventWithType:NSMouseMoved
+ location:loc
+ modifierFlags:0
+ timestamp:GetCurrentEventTime()
+ windowNumber:wNum
+ context:nil
+ eventNumber:0
+ clickCount:1
+ pressure:0.0];
+ [NSApp postEvent:warpEvent atStart:NO];
}
/*
@@ -606,13 +712,14 @@ TkpSetCapture(
while (winPtr && !Tk_IsTopLevel(winPtr)) {
winPtr = winPtr->parentPtr;
}
+ [NSEvent stopPeriodicEvents];
captureWinPtr = (Tk_Window) winPtr;
}
/*
*----------------------------------------------------------------------
*
- * TkMacOSXGetCapture --
+ * TkpGetCapture --
*
* Results:
* Returns the current grab window
@@ -624,13 +731,11 @@ TkpSetCapture(
*/
Tk_Window
-TkMacOSXGetCapture(void)
+TkpGetCapture(void)
{
return captureWinPtr;
}
-
-
/*
* Local Variables:
* mode: objc
diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c
index 3a32527..82ded8a 100644
--- a/macosx/tkMacOSXNotify.c
+++ b/macosx/tkMacOSXNotify.c
@@ -14,7 +14,7 @@
*/
#include "tkMacOSXPrivate.h"
-#include "tkMacOSXEvent.h"
+#include "tkMacOSXInt.h"
#include "tkMacOSXConstants.h"
#include <tclInt.h>
#import <objc/objc-auto.h>
@@ -33,7 +33,7 @@ static void TkMacOSXEventsSetupProc(ClientData clientData, int flags);
static void TkMacOSXEventsCheckProc(ClientData clientData, int flags);
#ifdef TK_MAC_DEBUG_EVENTS
-static char* Tk_EventName[39] = {
+static const char *Tk_EventName[39] = {
"",
"",
"KeyPress", /*2*/
@@ -136,17 +136,52 @@ void DebugPrintQueue(void)
/*
* Since the contentView is the first responder for a Tk Window, it is
- * responsible for sending events up the responder chain. We also check
- * the pasteboard here.
+ * responsible for sending events up the responder chain. We also check the
+ * pasteboard here.
*/
- (void) sendEvent: (NSEvent *) theEvent
{
+
+ /*
+ * Workaround for an Apple bug. When an accented character is selected
+ * from an NSTextInputClient popup character viewer with the mouse, Apple
+ * sends an event of type NSAppKitDefined and subtype 21. If that event is
+ * sent up the responder chain it causes Apple to print a warning to the
+ * console log and, extremely obnoxiously, also to stderr, which says
+ * "Window move completed without beginning." Apparently they are sending
+ * the "move completed" event without having sent the "move began" event of
+ * subtype 20, and then announcing their error on our stderr. Also, of
+ * course, no movement is occurring. The popup is not movable and is just
+ * being closed. The bug has been reported to Apple. If they ever fix it,
+ * this block should be removed.
+ */
+
+ if ([theEvent type] == NSAppKitDefined) {
+ static Bool aWindowIsMoving = NO;
+ switch([theEvent subtype]) {
+ case 20:
+ aWindowIsMoving = YES;
+ break;
+ case 21:
+ if (aWindowIsMoving) {
+ aWindowIsMoving = NO;
+ break;
+ } else {
+ // printf("Bug!!!!\n");
+ return;
+ }
+ default:
+ break;
+ }
+ }
[super sendEvent:theEvent];
[NSApp tkCheckPasteboard];
+
#ifdef TK_MAC_DEBUG_EVENTS
fprintf(stderr, "Sending event of type %d\n", (int)[theEvent type]);
DebugPrintQueue();
#endif
+
}
@end
@@ -173,7 +208,7 @@ GetRunLoopMode(NSModalSession modalSession)
if (modalSession) {
runLoopMode = NSModalPanelRunLoopMode;
- } else if (TkMacOSXGetCapture()) {
+ } else if (TkpGetCapture()) {
runLoopMode = NSEventTrackingRunLoopMode;
}
if (!runLoopMode) {
@@ -190,8 +225,8 @@ GetRunLoopMode(NSModalSession modalSession)
*
* Tk_MacOSXSetupTkNotifier --
*
- * This procedure is called during Tk initialization to create
- * the event source for TkAqua events.
+ * This procedure is called during Tk initialization to create the event
+ * source for TkAqua events.
*
* Results:
* None.
@@ -224,8 +259,7 @@ Tk_MacOSXSetupTkNotifier(void)
"first [load] of TkAqua has to occur in the main thread!");
}
Tcl_CreateEventSource(TkMacOSXEventsSetupProc,
- TkMacOSXEventsCheckProc,
- NULL);
+ TkMacOSXEventsCheckProc, NULL);
TkCreateExitHandler(TkMacOSXNotifyExitHandler, NULL);
Tcl_SetServiceMode(TCL_SERVICE_ALL);
TclMacOSXNotifierAddRunLoopMode(NSEventTrackingRunLoopMode);
@@ -253,13 +287,13 @@ Tk_MacOSXSetupTkNotifier(void)
static void
TkMacOSXNotifyExitHandler(
- ClientData clientData) /* Not used. */
+ ClientData dummy) /* Not used. */
{
+ (void)dummy;
TSD_INIT();
Tcl_DeleteEventSource(TkMacOSXEventsSetupProc,
- TkMacOSXEventsCheckProc,
- NULL);
+ TkMacOSXEventsCheckProc, NULL);
tsdPtr->initialized = 0;
}
@@ -268,42 +302,66 @@ TkMacOSXNotifyExitHandler(
*
* TkMacOSXEventsSetupProc --
*
- * This procedure implements the setup part of the MacOSX event
- * source. It is invoked by Tcl_DoOneEvent before calling
- * TkMacOSXEventsProc to process all queued NSEvents. In our
- * case, all we need to do is to set the Tcl MaxBlockTime to
- * 0 before starting the loop to process all queued NSEvents.
+ * This procedure implements the setup part of the MacOSX event source. It
+ * is invoked by Tcl_DoOneEvent before calling TkMacOSXEventsProc to
+ * process all queued NSEvents. In our case, all we need to do is to set
+ * the Tcl MaxBlockTime to 0 before starting the loop to process all
+ * queued NSEvents.
*
* Results:
* None.
*
* Side effects:
*
- * If NSEvents are queued, then the maximum block time will be set
- * to 0 to ensure that control returns immediately to Tcl.
+ * If NSEvents are queued, then the maximum block time will be set to 0 to
+ * ensure that control returns immediately to Tcl.
*
*----------------------------------------------------------------------
*/
static void
TkMacOSXEventsSetupProc(
- ClientData clientData,
+ ClientData dummy,
int flags)
{
+ static Bool havePeriodicEvents = NO;
NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode];
- /* runloopMode will be nil if we are in a Tcl event loop. */
+ (void)dummy;
+
+ /*
+ * runloopMode will be nil if we are in a Tcl event loop.
+ */
+
if (flags & TCL_WINDOW_EVENTS && !runloopMode) {
static const Tcl_Time zeroBlockTime = { 0, 0 };
[NSApp _resetAutoreleasePool];
- /* Call this with dequeue=NO -- just checking if the queue is empty. */
- NSEvent *currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask
- untilDate:[NSDate distantPast]
- inMode:GetRunLoopMode(TkMacOSXGetModalSession())
- dequeue:NO];
+
+ /*
+ * Call this with dequeue=NO -- just checking if the queue is empty.
+ */
+
+ NSEvent *currentEvent =
+ [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:[NSDate distantPast]
+ inMode:GetRunLoopMode(TkMacOSXGetModalSession())
+ dequeue:NO];
if (currentEvent) {
if (currentEvent.type > 0) {
Tcl_SetMaxBlockTime(&zeroBlockTime);
+ [NSEvent stopPeriodicEvents];
+ havePeriodicEvents = NO;
}
+ } else if (!havePeriodicEvents){
+
+ /*
+ * When the user is not generating events we schedule a "hearbeat"
+ * event to fire every 0.1 seconds. This helps to make the vwait
+ * command more responsive when there is no user input, e.g. when
+ * running the test suite.
+ */
+
+ havePeriodicEvents = YES;
+ [NSEvent startPeriodicEventsAfterDelay:0.0 withPeriod:0.1];
}
}
}
@@ -313,52 +371,67 @@ TkMacOSXEventsSetupProc(
*
* TkMacOSXEventsCheckProc --
*
- * This procedure loops through all NSEvents waiting in the
- * TKApplication event queue, generating X events from them.
+ * This procedure loops through all NSEvents waiting in the TKApplication
+ * event queue, generating X events from them.
*
* Results:
* None.
*
* Side effects:
- * NSevents are used to generate X events, which are added to the
- * Tcl event queue.
+ * NSevents are used to generate X events, which are added to the Tcl
+ * event queue.
*
*----------------------------------------------------------------------
*/
static void
TkMacOSXEventsCheckProc(
- ClientData clientData,
+ ClientData dummy,
int flags)
{
NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode];
- /* runloopMode will be nil if we are in a Tcl event loop. */
+ (void)dummy;
+
+ /*
+ * runloopMode will be nil if we are in a Tcl event loop.
+ */
+
if (flags & TCL_WINDOW_EVENTS && !runloopMode) {
NSEvent *currentEvent = nil;
NSEvent *testEvent = nil;
NSModalSession modalSession;
- /* It is possible for the SetupProc to be called before this function
+
+ /*
+ * It is possible for the SetupProc to be called before this function
* returns. This happens, for example, when we process an event which
* opens a modal window. To prevent premature release of our
* application-wide autorelease pool by a nested call to the SetupProc,
* we must lock it here.
*/
+
[NSApp _lockAutoreleasePool];
do {
modalSession = TkMacOSXGetModalSession();
- testEvent = [NSApp nextEventMatchingMask:NSAnyEventMask
- untilDate:[NSDate distantPast]
- inMode:GetRunLoopMode(modalSession)
- dequeue:NO];
- /* We must not steal any events during LiveResize. */
+ testEvent = [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:[NSDate distantPast]
+ inMode:GetRunLoopMode(modalSession)
+ dequeue:NO];
+
+ /*
+ * We must not steal any events during LiveResize.
+ */
+
if (testEvent && [[testEvent window] inLiveResize]) {
break;
}
currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask
- untilDate:[NSDate distantPast]
- inMode:GetRunLoopMode(modalSession)
- dequeue:YES];
+ untilDate:[NSDate distantPast]
+ inMode:GetRunLoopMode(modalSession)
+ dequeue:YES];
if (currentEvent) {
- /* Generate Xevents. */
+ /*
+ * Generate Xevents.
+ */
+
int oldServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
NSEvent *processedEvent = [NSApp tkProcessEvent:currentEvent];
Tcl_SetServiceMode(oldServiceMode);
@@ -372,16 +445,18 @@ TkMacOSXEventsCheckProc(
[NSApp sendEvent:currentEvent];
}
}
-
} else {
break;
}
} while (1);
- /* Now we can unlock the pool. */
+
+ /*
+ * Now we can unlock the pool.
+ */
+
[NSApp _unlockAutoreleasePool];
}
}
-
/*
* Local Variables:
diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h
index bd48bd5..28010ec 100644
--- a/macosx/tkMacOSXPort.h
+++ b/macosx/tkMacOSXPort.h
@@ -1,7 +1,7 @@
/*
* tkMacOSXPort.h --
*
- * This file is included by all of the Tk C files. It contains
+ * This file is included by all of the Tk C files. It contains
* information that may be configuration-dependent, such as
* #includes for system include files and a few other things.
*
@@ -17,13 +17,15 @@
#define _TKMACPORT
#include <stdio.h>
-#include <ctype.h>
+#include <pwd.h>
+#include <assert.h>
+#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
+#include <ctype.h>
#include <math.h>
-#include <pwd.h>
-#include <stdlib.h>
#include <string.h>
+#include <limits.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/file.h>
#ifdef HAVE_SYS_SELECT_H
@@ -47,6 +49,9 @@
# include <inttypes.h>
#endif
#include <unistd.h>
+#if defined(__GNUC__) && !defined(__cplusplus)
+# pragma GCC diagnostic ignored "-Wc++-compat"
+#endif
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <X11/keysym.h>
@@ -106,19 +111,6 @@
#define REDO_KEYSYM_LOOKUP
/*
- * Defines for X functions that are used by Tk but are treated as
- * no-op functions on the Macintosh.
- */
-
-#define XFlush(display)
-#define XFree(data) {if ((data) != NULL) ckfree(data);}
-#define XGrabServer(display)
-#define XNoOp(display) {display->request++;}
-#define XUngrabServer(display)
-#define XSynchronize(display, bool) {display->request++;}
-#define XVisualIDFromVisual(visual) (visual->visualid)
-
-/*
* The following functions are not used on the Mac, so we stub them out.
*/
@@ -128,17 +120,6 @@
#define TkpSync(display)
/*
- * The following macro returns the pixel value that corresponds to the
- * RGB values in the given XColor structure.
- */
-
-#define PIXEL_MAGIC ((unsigned char) 0x69)
-#define TkpGetPixel(p) ((((((PIXEL_MAGIC << 8) \
- | (((p)->red >> 8) & 0xff)) << 8) \
- | (((p)->green >> 8) & 0xff)) << 8) \
- | (((p)->blue >> 8) & 0xff))
-
-/*
* This macro stores a representation of the window handle in a string.
*/
@@ -159,19 +140,20 @@
*/
#define TRANSPARENT_PIXEL 30
-#define HIGHLIGHT_PIXEL 31
-#define HIGHLIGHT_SECONDARY_PIXEL 32
-#define HIGHLIGHT_TEXT_PIXEL 33
-#define HIGHLIGHT_ALTERNATE_PIXEL 34
-#define CONTROL_TEXT_PIXEL 35
-#define CONTROL_BODY_PIXEL 37
-#define CONTROL_FRAME_PIXEL 39
-#define WINDOW_BODY_PIXEL 41
-#define MENU_ACTIVE_PIXEL 43
-#define MENU_ACTIVE_TEXT_PIXEL 45
-#define MENU_BACKGROUND_PIXEL 47
-#define MENU_DISABLED_PIXEL 49
-#define MENU_TEXT_PIXEL 51
#define APPEARANCE_PIXEL 52
+#define PIXEL_MAGIC ((unsigned char) 0x69)
+
+/*
+ * The following macro returns the pixel value that corresponds to the
+ * 16-bit RGB values in the given XColor structure.
+ * The format is: (PIXEL_MAGIC << 24) | (R << 16) | (G << 8) | B
+ * where each of R, G and B is the high order byte of a 16-bit component.
+ */
+
+#define TkpGetPixel(p) ((((((PIXEL_MAGIC << 8) \
+ | (((p)->red >> 8) & 0xff)) << 8) \
+ | (((p)->green >> 8) & 0xff)) << 8) \
+ | (((p)->blue >> 8) & 0xff))
+
#endif /* _TKMACPORT */
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h
index 105317d..079e033 100644
--- a/macosx/tkMacOSXPrivate.h
+++ b/macosx/tkMacOSXPrivate.h
@@ -19,6 +19,10 @@
#error Objective-C compiler required
#endif
+#ifndef __clang__
+#define instancetype id
+#endif
+
#define TextStyle MacTextStyle
#import <ApplicationServices/ApplicationServices.h>
#import <Cocoa/Cocoa.h>
@@ -115,14 +119,83 @@
* Macro abstracting use of TkMacOSXGetNamedSymbol to init named symbols.
*/
+#define UNINITIALISED_SYMBOL ((void*)(-1L))
#define TkMacOSXInitNamedSymbol(module, ret, symbol, ...) \
- static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \
- if (symbol == (void*)(-1L)) { \
+ static ret (* symbol)(__VA_ARGS__) = UNINITIALISED_SYMBOL; \
+ if (symbol == UNINITIALISED_SYMBOL) { \
symbol = TkMacOSXGetNamedSymbol(STRINGIFY(module), \
STRINGIFY(symbol)); \
}
/*
+ * The structure of a 32-bit XEvent keycode on macOS. It may be viewed as
+ * an unsigned int or as having either two or three bitfields.
+ */
+
+typedef struct keycode_v_t {
+ unsigned keychar: 22; /* UCS-32 character */
+ unsigned o_s: 2; /* State of Option and Shift keys. */
+ unsigned virtual: 8; /* 8-bit virtual keycode - identifies a key. */
+} keycode_v;
+
+typedef struct keycode_x_t {
+ unsigned keychar: 22; /* UCS-32 character */
+ unsigned xvirtual: 10; /* Combines o_s and virtual. This 10-bit integer
+ * is used as a key for looking up the character
+ * produced when pressing a key with a particular
+ * Shift and Option modifier state. */
+} keycode_x;
+
+typedef union MacKeycode_t {
+ unsigned int uint;
+ keycode_v v;
+ keycode_x x;
+} MacKeycode;
+
+/*
+ * Macros used in tkMacOSXKeyboard.c and tkMacOSXKeyEvent.c.
+ * Note that 0x7f is del and 0xF8FF is the Apple Logo character.
+ */
+
+#define ON_KEYPAD(virtual) ((virtual >= 0x41) && (virtual <= 0x5C))
+#define IS_PRINTABLE(keychar) ((keychar >= 0x20) && (keychar != 0x7f) && \
+ ((keychar < 0xF700) || keychar >= 0xF8FF))
+
+/*
+ * An "index" is 2-bit bitfield showing the state of the Option and Shift
+ * keys. It is used as an index when building the keymaps and it
+ * is the value of the o_s bitfield of a keycode_v.
+ */
+
+#define INDEX_SHIFT 1
+#define INDEX_OPTION 2
+#define INDEX2STATE(index) ((index & INDEX_SHIFT ? ShiftMask : 0) | \
+ (index & INDEX_OPTION ? Mod2Mask : 0))
+#define INDEX2CARBON(index) ((index & INDEX_SHIFT ? shiftKey : 0) | \
+ (index & INDEX_OPTION ? optionKey : 0))
+#define STATE2INDEX(state) ((state & ShiftMask ? INDEX_SHIFT : 0) | \
+ (state & Mod2Mask ? INDEX_OPTION : 0))
+
+/*
+ * Special values for the virtual bitfield. Actual virtual keycodes are < 128.
+ */
+
+#define NO_VIRTUAL 0xFF /* Not generated by a key or the NSText"InputClient. */
+#define REPLACEMENT_VIRTUAL 0x80 /* A BMP char sent by the NSTextInputClient. */
+#define NON_BMP_VIRTUAL 0x81 /* A non-BMP char sent by the NSTextInputClient. */
+
+/*
+ * A special character is used in the keycode for simulated modifier KeyPress
+ * or KeyRelease XEvents. It is near the end of the private-use range but
+ * different from the UniChar 0xF8FF which Apple uses for their logo character.
+ * A different special character is used for keys, like the Menu key, which do
+ * not appear on Macintosh keyboards.
+ */
+
+#define MOD_KEYCHAR 0xF8FE
+#define UNKNOWN_KEYCHAR 0xF8FD
+
+/*
* Structure encapsulating current drawing environment.
*/
@@ -137,22 +210,15 @@ typedef struct TkMacOSXDrawingContext {
* Variables internal to TkAqua.
*/
-MODULE_SCOPE CGFloat tkMacOSXZeroScreenHeight;
-MODULE_SCOPE CGFloat tkMacOSXZeroScreenTop;
MODULE_SCOPE long tkMacOSXMacOSXVersion;
/*
* Prototypes for TkMacOSXRegion.c.
*/
-#if 0
-MODULE_SCOPE void TkMacOSXEmtpyRegion(TkRegion r);
-MODULE_SCOPE int TkMacOSXIsEmptyRegion(TkRegion r);
-#endif
-MODULE_SCOPE HIShapeRef TkMacOSXGetNativeRegion(TkRegion r);
-MODULE_SCOPE void TkMacOSXSetWithNativeRegion(TkRegion r,
+MODULE_SCOPE HIShapeRef TkMacOSXGetNativeRegion(Region r);
+MODULE_SCOPE void TkMacOSXSetWithNativeRegion(Region r,
HIShapeRef rgn);
-MODULE_SCOPE void TkMacOSXOffsetRegion(TkRegion r, short dx, short dy);
MODULE_SCOPE HIShapeRef TkMacOSXHIShapeCreateEmpty(void);
MODULE_SCOPE HIMutableShapeRef TkMacOSXHIShapeCreateMutableWithRect(
const CGRect *inRect);
@@ -177,6 +243,8 @@ MODULE_SCOPE OSStatus TkMacOSHIShapeUnion(HIShapeRef inShape1,
MODULE_SCOPE void * TkMacOSXGetNamedSymbol(const char *module,
const char *symbol);
MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display);
+MODULE_SCOPE CGFloat TkMacOSXZeroScreenHeight();
+MODULE_SCOPE CGFloat TkMacOSXZeroScreenTop();
MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp,
int enable);
MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable,
@@ -219,7 +287,6 @@ MODULE_SCOPE NSImage* TkMacOSXGetNSImageWithBitmap(Display *display,
Pixmap bitmap, GC gc, int width, int height);
MODULE_SCOPE CGColorRef TkMacOSXCreateCGColor(GC gc, unsigned long pixel);
MODULE_SCOPE NSColor* TkMacOSXGetNSColor(GC gc, unsigned long pixel);
-MODULE_SCOPE Tcl_Obj * TkMacOSXGetStringObjFromCFString(CFStringRef str);
MODULE_SCOPE TkWindow* TkMacOSXGetTkWindow(NSWindow *w);
MODULE_SCOPE NSFont* TkMacOSXNSFontForFont(Tk_Font tkfont);
MODULE_SCOPE NSDictionary* TkMacOSXNSFontAttributesForFont(Tk_Font tkfont);
@@ -233,6 +300,13 @@ MODULE_SCOPE int TkMacOSXStandardAboutPanelObjCmd(ClientData clientData,
MODULE_SCOPE int TkMacOSXIconBitmapObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
+MODULE_SCOPE void TkMacOSXDrawSolidBorder(Tk_Window tkwin, GC gc,
+ int inset, int thickness);
+MODULE_SCOPE int TkMacOSXServices_Init(Tcl_Interp *interp);
+MODULE_SCOPE int TkMacOSXRegisterServiceWidgetObjCmd(ClientData clientData,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *const objv[]);
+MODULE_SCOPE unsigned TkMacOSXAddVirtual(unsigned int keycode);
#pragma mark Private Objective-C Classes
@@ -259,9 +333,9 @@ VISIBILITY_HIDDEN
Tcl_Interp *_eventInterp;
NSMenu *_servicesMenu;
TKMenu *_defaultMainMenu, *_defaultApplicationMenu;
+ NSMenuItem *_demoMenuItem;
NSArray *_defaultApplicationMenuItems, *_defaultWindowsMenuItems;
- NSArray *_defaultHelpMenuItems;
- NSWindow *_windowWithMouse;
+ NSArray *_defaultHelpMenuItems, *_defaultFileMenuItems;
NSAutoreleasePool *_mainPool;
#ifdef __i386__
/* The Objective C runtime used on i386 requires this. */
@@ -287,6 +361,8 @@ VISIBILITY_HIDDEN
@interface TKApplication(TKWindowEvent) <NSApplicationDelegate>
- (void) _setupWindowNotifications;
@end
+@interface TKApplication(TKDialog) <NSOpenSavePanelDelegate>
+@end
@interface TKApplication(TKMenu)
- (void)tkSetMainMenu:(TKMenu *)menu;
@end
@@ -327,27 +403,33 @@ VISIBILITY_HIDDEN
withReplyEvent: (NSAppleEventDescriptor *)replyEvent;
- (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event
withReplyEvent: (NSAppleEventDescriptor *)replyEvent;
+- (void)handleURLEvent: (NSAppleEventDescriptor*)event
+ withReplyEvent: (NSAppleEventDescriptor*)replyEvent;
@end
VISIBILITY_HIDDEN
-@interface TKContentView : NSView <NSTextInput>
+/*
+ * Subclass TKContentView from NSTextInputClient to enable composition and
+ * input from the Character Palette.
+ */
+
+@interface TKContentView : NSView <NSTextInputClient>
{
+@private
NSString *privateWorkingText;
+ Bool _needsRedisplay;
}
+@property Bool needsRedisplay;
@end
@interface TKContentView(TKKeyEvent)
- (void) deleteWorkingText;
+- (void) cancelComposingText;
@end
@interface TKContentView(TKWindowEvent)
-- (void) drawRect: (NSRect) rect;
- (void) generateExposeEvents: (HIShapeRef) shape;
- (void) tkToolbarButton: (id) sender;
-- (BOOL) isOpaque;
-- (BOOL) wantsDefaultClipping;
-- (BOOL) acceptsFirstResponder;
-- (void) keyDown: (NSEvent *) theEvent;
@end
@interface NSWindow(TKWm)
@@ -416,8 +498,53 @@ VISIBILITY_HIDDEN
- (void) setAppleMenu: (NSMenu *) menu;
@end
-#endif /* _TKMACPRIV */
+/*
+ * These methods are exposed because they are needed to prevent zombie windows
+ * on systems with a TouchBar. The TouchBar Key-Value observer holds a
+ * reference to the key window, which prevents deallocation of the key window
+ * when it is closed.
+ */
+
+@interface NSApplication(TkWm)
+- (id) _setKeyWindow: (NSWindow *) window;
+- (id) _setMainWindow: (NSWindow *) window;
+@end
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * TKNSString --
+ *
+ * When Tcl is compiled with TCL_UTF_MAX = 3 (the default for 8.6) it cannot
+ * deal directly with UTF-8 encoded non-BMP characters, since their UTF-8
+ * encoding requires 4 bytes. Instead, when using these versions of Tcl, Tk
+ * uses the CESU-8 encoding internally. This encoding is similar to UTF-8
+ * except that it allows encoding surrogate characters as 3-byte sequences
+ * using the same algorithm which UTF-8 uses for non-surrogates. This means
+ * that a non-BMP character is encoded as a string of length 6. Apple's
+ * NSString class does not provide a constructor which accepts a CESU-8 encoded
+ * byte sequence as initial data. So we add a new class which does provide
+ * such a constructor. It also has a DString property which is a DString whose
+ * string pointer is a byte sequence encoding the NSString with the current Tk
+ * encoding, namely UTF-8 if TCL_UTF_MAX >= 4 or CESU-8 if TCL_UTF_MAX = 3.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+@interface TKNSString:NSString {
+@private
+ Tcl_DString _ds;
+ NSString *_string;
+}
+@property const char *UTF8String;
+@property (readonly) Tcl_DString DString;
+- (instancetype)initWithTclUtfBytes:(const void *)bytes
+ length:(NSUInteger)len;
+@end
+
+#endif /* _TKMACPRIV */
+
/*
* Local Variables:
* mode: objc
diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c
index 0f2a74a..0a5ff6d 100644
--- a/macosx/tkMacOSXRegion.c
+++ b/macosx/tkMacOSXRegion.c
@@ -17,7 +17,7 @@
/*
*----------------------------------------------------------------------
*
- * TkCreateRegion --
+ * XCreateRegion --
*
* Implements the equivelent of the X window function XCreateRegion. See
* Xwindow documentation for more details.
@@ -31,16 +31,16 @@
*----------------------------------------------------------------------
*/
-TkRegion
-TkCreateRegion(void)
+Region
+XCreateRegion(void)
{
- return (TkRegion) HIShapeCreateMutable();
+ return (Region) HIShapeCreateMutable();
}
/*
*----------------------------------------------------------------------
*
- * TkDestroyRegion --
+ * XDestroyRegion --
*
* Implements the equivelent of the X window function XDestroyRegion. See
* Xwindow documentation for more details.
@@ -54,19 +54,20 @@ TkCreateRegion(void)
*----------------------------------------------------------------------
*/
-void
-TkDestroyRegion(
- TkRegion r)
+int
+XDestroyRegion(
+ Region r)
{
if (r) {
CFRelease(r);
}
+ return Success;
}
/*
*----------------------------------------------------------------------
*
- * TkIntersectRegion --
+ * XIntersectRegion --
*
* Implements the equivalent of the X window function XIntersectRegion.
* See Xwindow documentation for more details.
@@ -80,20 +81,21 @@ TkDestroyRegion(
*----------------------------------------------------------------------
*/
-void
-TkIntersectRegion(
- TkRegion sra,
- TkRegion srb,
- TkRegion dr_return)
+int
+XIntersectRegion(
+ Region sra,
+ Region srb,
+ Region dr_return)
{
ChkErr(HIShapeIntersect, (HIShapeRef) sra, (HIShapeRef) srb,
(HIMutableShapeRef) dr_return);
+ return Success;
}
/*
*----------------------------------------------------------------------
*
- * TkSubtractRegion --
+ * XSubtractRegion --
*
* Implements the equivalent of the X window function XSubtractRegion.
* See X window documentation for more details.
@@ -107,20 +109,21 @@ TkIntersectRegion(
*----------------------------------------------------------------------
*/
-void
-TkSubtractRegion(
- TkRegion sra,
- TkRegion srb,
- TkRegion dr_return)
+int
+XSubtractRegion(
+ Region sra,
+ Region srb,
+ Region dr_return)
{
ChkErr(HIShapeDifference, (HIShapeRef) sra, (HIShapeRef) srb,
(HIMutableShapeRef) dr_return);
+ return Success;
}
/*
*----------------------------------------------------------------------
*
- * TkUnionRectWithRegion --
+ * XUnionRectWithRegion --
*
* Implements the equivelent of the X window function
* XUnionRectWithRegion. See Xwindow documentation for more details.
@@ -134,11 +137,11 @@ TkSubtractRegion(
*----------------------------------------------------------------------
*/
-void
-TkUnionRectWithRegion(
+int
+XUnionRectWithRegion(
XRectangle* rectangle,
- TkRegion src_region,
- TkRegion dest_region_return)
+ Region src_region,
+ Region dest_region_return)
{
const CGRect r = CGRectMake(rectangle->x, rectangle->y,
rectangle->width, rectangle->height);
@@ -153,6 +156,7 @@ TkUnionRectWithRegion(
(HIMutableShapeRef) dest_region_return);
CFRelease(rectRgn);
}
+ return Success;
}
/*
@@ -171,9 +175,9 @@ TkUnionRectWithRegion(
*----------------------------------------------------------------------
*/
-int
+static int
TkMacOSXIsEmptyRegion(
- TkRegion r)
+ Region r)
{
return HIShapeIsEmpty((HIMutableShapeRef) r) ? 1 : 0;
}
@@ -181,14 +185,14 @@ TkMacOSXIsEmptyRegion(
/*
*----------------------------------------------------------------------
*
- * TkRectInRegion --
+ * XRectInRegion --
*
* Implements the equivelent of the X window function XRectInRegion. See
* Xwindow documentation for more details.
*
* Results:
- * Returns RectanglePart or RectangleOut. Note that this is not a
- * complete implementation since it doesn't test for RectangleIn.
+ * Returns RectanglePart or RectangleOut. Note that this is not a complete
+ * implementation since it doesn't test for RectangleIn.
*
* Side effects:
* None.
@@ -197,27 +201,27 @@ TkMacOSXIsEmptyRegion(
*/
int
-TkRectInRegion(
- TkRegion region,
+XRectInRegion(
+ Region region,
int x,
int y,
unsigned int width,
unsigned int height)
{
- if ( TkMacOSXIsEmptyRegion(region) ) {
- return RectangleOut;
- }
- else {
+ if (TkMacOSXIsEmptyRegion(region)) {
+ return RectangleOut;
+ } else {
const CGRect r = CGRectMake(x, y, width, height);
+
return HIShapeIntersectsRect((HIShapeRef) region, &r) ?
- RectanglePart : RectangleOut;
+ RectanglePart : RectangleOut;
}
}
/*
*----------------------------------------------------------------------
*
- * TkClipBox --
+ * XClipBox --
*
* Implements the equivelent of the X window function XClipBox. See
* Xwindow documentation for more details.
@@ -231,10 +235,10 @@ TkRectInRegion(
*----------------------------------------------------------------------
*/
-void
-TkClipBox(
- TkRegion r,
- XRectangle* rect_return)
+int
+XClipBox(
+ Region r,
+ XRectangle *rect_return)
{
CGRect rect;
@@ -243,6 +247,7 @@ TkClipBox(
rect_return->y = rect.origin.y;
rect_return->width = rect.size.width;
rect_return->height = rect.size.height;
+ return Success;
}
/*
@@ -264,7 +269,7 @@ TkClipBox(
void
TkpBuildRegionFromAlphaData(
- TkRegion region, /* Region to update. */
+ Region region, /* Region to update. */
unsigned int x, /* Where in region to update. */
unsigned int y, /* Where in region to update. */
unsigned int width, /* Size of rectangle to update. */
@@ -305,7 +310,7 @@ TkpBuildRegionFromAlphaData(
rect.y = y + y1;
rect.width = end - x1;
rect.height = 1;
- TkUnionRectWithRegion(&rect, region, region);
+ XUnionRectWithRegion(&rect, region, region);
}
}
dataPtr += lineStride;
@@ -330,7 +335,7 @@ TkpBuildRegionFromAlphaData(
void
TkpRetainRegion(
- TkRegion r)
+ Region r)
{
CFRetain(r);
}
@@ -353,7 +358,7 @@ TkpRetainRegion(
void
TkpReleaseRegion(
- TkRegion r)
+ Region r)
{
CFRelease(r);
}
@@ -376,7 +381,7 @@ TkpReleaseRegion(
void
TkMacOSXSetEmptyRegion(
- TkRegion r)
+ Region r)
{
ChkErr(HIShapeSetEmpty, (HIMutableShapeRef) r);
}
@@ -399,7 +404,7 @@ TkMacOSXSetEmptyRegion(
HIShapeRef
TkMacOSXGetNativeRegion(
- TkRegion r)
+ Region r)
{
return (HIShapeRef) CFRetain(r);
}
@@ -422,7 +427,7 @@ TkMacOSXGetNativeRegion(
void
TkMacOSXSetWithNativeRegion(
- TkRegion r,
+ Region r,
HIShapeRef rgn)
{
ChkErr(TkMacOSXHIShapeSetWithShape, (HIMutableShapeRef) r, rgn);
@@ -431,7 +436,7 @@ TkMacOSXSetWithNativeRegion(
/*
*----------------------------------------------------------------------
*
- * TkMacOSXOffsetRegion --
+ * XOffsetRegion --
*
* Offsets region by given distances.
*
@@ -444,13 +449,14 @@ TkMacOSXSetWithNativeRegion(
*----------------------------------------------------------------------
*/
-void
-TkMacOSXOffsetRegion(
- TkRegion r,
- short dx,
- short dy)
+int
+XOffsetRegion(
+ Region r,
+ int dx,
+ int dy)
{
ChkErr(HIShapeOffset, (HIMutableShapeRef) r, dx, dy);
+ return Success;
}
/*
diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c
index 8a6a96b..2e33622 100644
--- a/macosx/tkMacOSXScale.c
+++ b/macosx/tkMacOSXScale.c
@@ -51,10 +51,10 @@ static ControlActionUPP scaleActionProc = NULL; /* Pointer to func. */
* Forward declarations for procedures defined later in this file:
*/
-static void MacScaleEventProc(ClientData clientData, XEvent *eventPtr);
-static pascal void ScaleActionProc(ControlRef theControl,
- ControlPartCode partCode);
-
+static void MacScaleEventProc(ClientData clientData,
+ XEvent *eventPtr);
+static pascal void ScaleActionProc(ControlRef theControl,
+ ControlPartCode partCode);
/*
*----------------------------------------------------------------------
@@ -76,7 +76,7 @@ TkScale *
TkpCreateScale(
Tk_Window tkwin)
{
- MacScale *macScalePtr = ckalloc(sizeof(MacScale));
+ MacScale *macScalePtr = (MacScale *)ckalloc(sizeof(MacScale));
macScalePtr->scaleHandle = NULL;
if (scaleActionProc == NULL) {
@@ -84,7 +84,7 @@ TkpCreateScale(
}
Tk_CreateEventHandler(tkwin, ButtonPressMask,
- MacScaleEventProc, (ClientData) macScalePtr);
+ MacScaleEventProc, macScalePtr);
return (TkScale *) macScalePtr;
}
@@ -125,8 +125,8 @@ TkpDestroyScale(
*
* TkpDisplayScale --
*
- * This procedure is invoked as an idle handler to redisplay
- * the contents of a scale widget.
+ * This procedure is invoked as an idle handler to redisplay the contents
+ * of a scale widget.
*
* Results:
* None.
@@ -141,12 +141,12 @@ void
TkpDisplayScale(
ClientData clientData) /* Widget record for scale. */
{
- TkScale *scalePtr = (TkScale *) clientData;
+ TkScale *scalePtr = clientData;
Tk_Window tkwin = scalePtr->tkwin;
Tcl_Interp *interp = scalePtr->interp;
int result;
char string[TCL_DOUBLE_SPACE];
- MacScale *macScalePtr = (MacScale *) clientData;
+ MacScale *macScalePtr = clientData;
Rect r;
WindowRef windowRef;
CGrafPtr destPort, savePort;
@@ -168,9 +168,9 @@ TkpDisplayScale(
* Invoke the scale's command if needed.
*/
- Tcl_Preserve((ClientData) scalePtr);
+ Tcl_Preserve(scalePtr);
if ((scalePtr->flags & INVOKE_COMMAND) && (scalePtr->command != NULL)) {
- Tcl_Preserve((ClientData) interp);
+ Tcl_Preserve(interp);
if (snprintf(string, TCL_DOUBLE_SPACE, scalePtr->format,
scalePtr->value) < 0) {
string[TCL_DOUBLE_SPACE - 1] = '\0';
@@ -185,19 +185,18 @@ TkpDisplayScale(
Tcl_AddErrorInfo(interp, "\n (command executed by scale)");
Tcl_BackgroundException(interp, result);
}
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
}
scalePtr->flags &= ~INVOKE_COMMAND;
if (scalePtr->flags & SCALE_DELETED) {
- Tcl_Release((ClientData) scalePtr);
+ Tcl_Release(scalePtr);
return;
}
- Tcl_Release((ClientData) scalePtr);
+ Tcl_Release(scalePtr);
/*
- * Now handle the part of redisplay that is the same for
- * horizontal and vertical scales: border and traversal
- * highlight.
+ * Now handle the part of redisplay that is the same for horizontal and
+ * vertical scales: border and traversal highlight.
*/
if (scalePtr->highlightWidth != 0) {
@@ -229,7 +228,7 @@ TkpDisplayScale(
#define MAC_OSX_SCROLL_WIDTH 10
if (scalePtr->orient == ORIENT_HORIZONTAL) {
- int offset = (Tk_Height(tkwin) - MAC_OSX_SCROLL_WIDTH)/2;
+ int offset = (Tk_Height(tkwin) - MAC_OSX_SCROLL_WIDTH) / 2;
if (offset < 0) {
offset = 0;
@@ -240,7 +239,7 @@ TkpDisplayScale(
r.right = macDraw->xOff+Tk_Width(tkwin) - scalePtr->inset;
r.bottom = macDraw->yOff + offset + MAC_OSX_SCROLL_WIDTH/2;
} else {
- int offset = (Tk_Width(tkwin) - MAC_OSX_SCROLL_WIDTH)/2;
+ int offset = (Tk_Width(tkwin) - MAC_OSX_SCROLL_WIDTH) / 2;
if (offset < 0) {
offset = 0;
@@ -249,7 +248,7 @@ TkpDisplayScale(
r.left = macDraw->xOff + offset;
r.top = macDraw->yOff + scalePtr->inset;
r.right = macDraw->xOff + offset + MAC_OSX_SCROLL_WIDTH/2;
- r.bottom = macDraw->yOff+Tk_Height(tkwin) - scalePtr->inset;
+ r.bottom = macDraw->yOff + Tk_Height(tkwin) - scalePtr->inset;
}
if (macScalePtr->scaleHandle == NULL) {
@@ -273,7 +272,7 @@ TkpDisplayScale(
CreateSliderControl(windowRef, &r, initialValue, minValue, maxValue,
kControlSliderPointsDownOrRight, numTicks, 1, scaleActionProc,
- &(macScalePtr->scaleHandle));
+ &macScalePtr->scaleHandle);
SetControlReference(macScalePtr->scaleHandle, (UInt32) scalePtr);
if (IsWindowActive(windowRef)) {
@@ -290,8 +289,8 @@ TkpDisplayScale(
* Finally draw the control.
*/
- SetControlVisibility(macScalePtr->scaleHandle,true,true);
- HiliteControl(macScalePtr->scaleHandle,0);
+ SetControlVisibility(macScalePtr->scaleHandle, true, true);
+ HiliteControl(macScalePtr->scaleHandle, 0);
Draw1Control(macScalePtr->scaleHandle);
if (portChanged) {
@@ -306,13 +305,12 @@ done:
*
* TkpScaleElement --
*
- * Determine which part of a scale widget lies under a given
- * point.
+ * Determine which part of a scale widget lies under a given point.
*
* Results:
- * The return value is either TROUGH1, SLIDER, TROUGH2, or
- * OTHER, depending on which of the scale's active elements
- * (if any) is under the point at (x,y).
+ * The return value is either TROUGH1, SLIDER, TROUGH2, or OTHER,
+ * depending on which of the scale's active elements (if any) is under the
+ * point at (x,y).
*
* Side effects:
* None.
@@ -357,22 +355,22 @@ TkpScaleElement(
#endif
switch (part) {
- case inSlider:
- return SLIDER;
- case inInc:
- if (scalePtr->orient == ORIENT_VERTICAL) {
- return TROUGH1;
- } else {
- return TROUGH2;
- }
- case inDecr:
- if (scalePtr->orient == ORIENT_VERTICAL) {
- return TROUGH2;
- } else {
- return TROUGH1;
- }
- default:
- return OTHER;
+ case inSlider:
+ return SLIDER;
+ case inInc:
+ if (scalePtr->orient == ORIENT_VERTICAL) {
+ return TROUGH1;
+ } else {
+ return TROUGH2;
+ }
+ case inDecr:
+ if (scalePtr->orient == ORIENT_VERTICAL) {
+ return TROUGH2;
+ } else {
+ return TROUGH1;
+ }
+ default:
+ return OTHER;
}
}
@@ -381,15 +379,15 @@ TkpScaleElement(
*
* MacScaleEventProc --
*
- * This procedure is invoked by the Tk dispatcher for
- * ButtonPress events on scales.
+ * This procedure is invoked by the Tk dispatcher for ButtonPress events
+ * on scales.
*
* Results:
* None.
*
* Side effects:
- * When the window gets deleted, internal structures get
- * cleaned up. When it gets exposed, it is redisplayed.
+ * When the window gets deleted, internal structures get cleaned up. When
+ * it gets exposed, it is redisplayed.
*
*--------------------------------------------------------------
*/
@@ -411,9 +409,9 @@ MacScaleEventProc(
#endif
/*
- * To call Macintosh control routines we must have the port
- * set to the window containing the control. We will then test
- * which part of the control was hit and act accordingly.
+ * To call Macintosh control routines we must have the port set to the
+ * window containing the control. We will then test which part of the
+ * control was hit and act accordingly.
*/
destPort = TkMacOSXGetDrawablePort(Tk_WindowId(macScalePtr->info.tkwin));
@@ -461,8 +459,8 @@ MacScaleEventProc(
* ScaleActionProc --
*
* Callback procedure used by the Macintosh toolbox call
- * HandleControlClick. This call will update the display
- * while the scrollbar is being manipulated by the user.
+ * HandleControlClick. This call will update the display while the
+ * scrollbar is being manipulated by the user.
*
* Results:
* None.
@@ -486,9 +484,9 @@ ScaleActionProc(
#endif
value = GetControlValue(theControl);
TkScaleSetValue(scalePtr, value, 1, 1);
- Tcl_Preserve((ClientData) scalePtr);
+ Tcl_Preserve(scalePtr);
TkMacOSXRunTclEventLoop();
- Tcl_Release((ClientData) scalePtr);
+ Tcl_Release(scalePtr);
}
#endif
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c
index 4a108db..a49ec55 100644
--- a/macosx/tkMacOSXScrlbr.c
+++ b/macosx/tkMacOSXScrlbr.c
@@ -8,7 +8,8 @@
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
* Copyright (c) 2015 Kevin Walzer/WordTech Commununications LLC.
- * Copyright (c) 2018 Marc Culler
+ * Copyright (c) 2018-2019 Marc Culler
+ *
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
@@ -17,28 +18,29 @@
#include "tkScrollbar.h"
#include "tkMacOSXPrivate.h"
-
-#define MIN_SCROLLBAR_VALUE 0
-
/*
* Minimum slider length, in pixels (designed to make sure that the slider is
* always easy to grab with the mouse).
*/
-#define MIN_SLIDER_LENGTH 5
+#define MIN_SLIDER_LENGTH 18
+#define MIN_GAP 4
+
+/*
+ * Borrowed from ttkMacOSXTheme.c to provide appropriate scaling.
+ */
-/*Borrowed from ttkMacOSXTheme.c to provide appropriate scaling.*/
#ifdef __LP64__
-#define RangeToFactor(maximum) (((double) (INT_MAX >> 1)) / (maximum))
+#define RangeToFactor(maximum) (((double) (INT_MAX >> 1)) / (maximum))
#else
-#define RangeToFactor(maximum) (((double) (LONG_MAX >> 1)) / (maximum))
+#define RangeToFactor(maximum) (((double) (LONG_MAX >> 1)) / (maximum))
#endif /* __LP64__ */
/*
* Apple reversed the scroll direction with the release of OSX 10.7 Lion.
*/
-#define SNOW_LEOPARD_STYLE (NSAppKitVersionNumber < 1138)
+#define SNOW_LEOPARD_STYLE (NSAppKitVersionNumber < 1138)
/*
* Declaration of an extended scrollbar structure with Mac specific additions.
@@ -50,7 +52,7 @@ typedef struct MacScrollbar {
GC copyGC; /* Used for copying from pixmap onto screen. */
Bool buttonDown; /* Is the mouse button down? */
Bool mouseOver; /* Is the pointer over the scrollbar. */
- HIThemeTrackDrawInfo info; /* Controls how the scrollbar is drawn. */
+ HIThemeTrackDrawInfo info; /* Controls how the scrollbar is drawn. */
} MacScrollbar;
/* Used to initialize a MacScrollbar's info field. */
@@ -69,33 +71,36 @@ HIThemeTrackDrawInfo defaultInfo = {
const Tk_ClassProcs tkpScrollbarProcs = {
sizeof(Tk_ClassProcs), /* size */
- NULL, /* worldChangedProc */
- NULL, /* createProc */
- NULL /* modalProc */
+ NULL, /* worldChangedProc */
+ NULL, /* createProc */
+ NULL /* modalProc */
};
+/*
+ * Information on scrollbar layout, metrics, and draw info.
+ */
-/* Information on scrollbar layout, metrics, and draw info.*/
typedef struct ScrollbarMetrics {
SInt32 width, minThumbHeight;
int minHeight, topArrowHeight, bottomArrowHeight;
NSControlSize controlSize;
} ScrollbarMetrics;
-
static ScrollbarMetrics metrics = {
- 15, 54, 26, 14, 14, kControlSizeNormal /* kThemeScrollBarMedium */
+ /* kThemeScrollBarMedium */
+ 15, MIN_SLIDER_LENGTH, 26, 14, 14, kControlSizeNormal
};
-
/*
* Declarations of static functions defined later in this file:
*/
-static void ScrollbarEventProc(ClientData clientData, XEvent *eventPtr);
-static int ScrollbarEvent(TkScrollbar *scrollPtr, XEvent *eventPtr);
-static void UpdateControlValues(TkScrollbar *scrollPtr);
-
+static void ScrollbarEventProc(ClientData clientData,
+ XEvent *eventPtr);
+static int ScrollbarEvent(TkScrollbar *scrollPtr,
+ XEvent *eventPtr);
+static void UpdateControlValues(TkScrollbar *scrollPtr);
+
/*
*----------------------------------------------------------------------
*
@@ -114,9 +119,8 @@ static void UpdateControlValues(TkScrollbar *scrollPtr);
TkScrollbar *
TkpCreateScrollbar(
- Tk_Window tkwin)
+ Tk_Window tkwin)
{
-
MacScrollbar *scrollPtr = (MacScrollbar *)ckalloc(sizeof(MacScrollbar));
scrollPtr->troughGC = NULL;
@@ -125,15 +129,15 @@ TkpCreateScrollbar(
scrollPtr->buttonDown = false;
Tk_CreateEventHandler(tkwin,
- ExposureMask |
- StructureNotifyMask |
- FocusChangeMask |
- ButtonPressMask |
- ButtonReleaseMask |
- EnterWindowMask |
- LeaveWindowMask |
- VisibilityChangeMask,
- ScrollbarEventProc, scrollPtr);
+ ExposureMask |
+ StructureNotifyMask |
+ FocusChangeMask |
+ ButtonPressMask |
+ ButtonReleaseMask |
+ EnterWindowMask |
+ LeaveWindowMask |
+ VisibilityChangeMask,
+ ScrollbarEventProc, scrollPtr);
return (TkScrollbar *) scrollPtr;
}
@@ -144,8 +148,8 @@ TkpCreateScrollbar(
* TkpDisplayScrollbar --
*
* This procedure redraws the contents of a scrollbar window. It is
- * invoked as a do-when-idle handler, so it only runs when there's
- * nothing else for the application to do.
+ * invoked as a do-when-idle handler, so it only runs when there's nothing
+ * else for the application to do.
*
* Results:
* None.
@@ -156,36 +160,130 @@ TkpCreateScrollbar(
*--------------------------------------------------------------
*/
+#if MAC_OS_X_VERSION_MAX_ALLOWED > 1080
+
+/*
+ * This stand-alone drawing function is used on macOS 10.9 and newer because
+ * the HIToolbox does not draw the scrollbar thumb at the expected size on
+ * those systems. The thumb is drawn too large, causing a mouse click on the
+ * thumb to be interpreted as a mouse click in the trough.
+ */
+
+static void drawMacScrollbar(
+ TkScrollbar *scrollPtr,
+ MacScrollbar *msPtr,
+ CGContextRef context)
+{
+ MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin);
+ NSView *view = TkMacOSXDrawableView(macWin);
+ CGPathRef path;
+ CGPoint inner[2], outer[2], thumbOrigin;
+ CGSize thumbSize;
+ CGRect troughBounds = msPtr->info.bounds;
+ troughBounds.origin.y = [view bounds].size.height -
+ (troughBounds.origin.y + troughBounds.size.height);
+ if (scrollPtr->vertical) {
+ thumbOrigin.x = troughBounds.origin.x + MIN_GAP;
+ thumbOrigin.y = troughBounds.origin.y + scrollPtr->sliderFirst;
+ thumbSize.width = troughBounds.size.width - 2*MIN_GAP + 1;
+ thumbSize.height = scrollPtr->sliderLast - scrollPtr->sliderFirst;
+ inner[0] = troughBounds.origin;
+ inner[1] = CGPointMake(inner[0].x,
+ inner[0].y + troughBounds.size.height);
+ outer[0] = CGPointMake(inner[0].x + troughBounds.size.width - 1,
+ inner[0].y);
+ outer[1] = CGPointMake(outer[0].x, inner[1].y);
+ } else {
+ thumbOrigin.x = troughBounds.origin.x + scrollPtr->sliderFirst;
+ thumbOrigin.y = troughBounds.origin.y + MIN_GAP;
+ thumbSize.width = scrollPtr->sliderLast - scrollPtr->sliderFirst;
+ thumbSize.height = troughBounds.size.height - 2*MIN_GAP + 1;
+ inner[0] = troughBounds.origin;
+ inner[1] = CGPointMake(inner[0].x + troughBounds.size.width,
+ inner[0].y + 1);
+ outer[0] = CGPointMake(inner[0].x,
+ inner[0].y + troughBounds.size.height);
+ outer[1] = CGPointMake(inner[1].x, outer[0].y);
+ }
+ CGContextSetShouldAntialias(context, false);
+ CGContextSetGrayFillColor(context, 250.0 / 255, 1.0);
+ CGContextFillRect(context, troughBounds);
+ CGContextSetGrayStrokeColor(context, 232.0 / 255, 1.0);
+ CGContextStrokeLineSegments(context, inner, 2);
+ CGContextSetGrayStrokeColor(context, 238.0 / 255, 1.0);
+ CGContextStrokeLineSegments(context, outer, 2);
+
+ /*
+ * Do not display the thumb unless scrolling is possible, in accordance
+ * with macOS behavior.
+ *
+ * Native scrollbars and Ttk scrollbars are always 15 pixels wide, but we
+ * allow Tk scrollbars to have any width, even if it looks bad. To prevent
+ * sporadic assertion errors when drawing skinny thumbs we must make sure
+ * the radius is at most half the width.
+ */
+
+ if (scrollPtr->firstFraction > 0.0 || scrollPtr->lastFraction < 1.0) {
+ CGRect thumbBounds = {thumbOrigin, thumbSize};
+ int width = scrollPtr->vertical ? thumbSize.width : thumbSize.height;
+ int radius = width >= 8 ? 4 : width >> 1;
+ path = CGPathCreateWithRoundedRect(thumbBounds, radius, radius, NULL);
+ CGContextBeginPath(context);
+ CGContextAddPath(context, path);
+ if (msPtr->info.trackInfo.scrollbar.pressState != 0) {
+ CGContextSetGrayFillColor(context, 133.0 / 255, 1.0);
+ } else {
+ CGContextSetGrayFillColor(context, 200.0 / 255, 1.0);
+ }
+ CGContextSetShouldAntialias(context, true);
+ CGContextFillPath(context);
+ CFRelease(path);
+ }
+}
+#endif
+
void
TkpDisplayScrollbar(
- ClientData clientData) /* Information about window. */
+ ClientData clientData) /* Information about window. */
{
- register TkScrollbar *scrollPtr = (TkScrollbar *) clientData;
+ TkScrollbar *scrollPtr = clientData;
MacScrollbar *msPtr = (MacScrollbar *) scrollPtr;
- register Tk_Window tkwin = scrollPtr->tkwin;
+ Tk_Window tkwin = scrollPtr->tkwin;
TkWindow *winPtr = (TkWindow *) tkwin;
TkMacOSXDrawingContext dc;
scrollPtr->flags &= ~REDRAW_PENDING;
if (tkwin == NULL || !Tk_IsMapped(tkwin)) {
- return;
+ return;
}
- MacDrawable *macWin = (MacDrawable *) winPtr->window;
+ MacDrawable *macWin = (MacDrawable *) winPtr->window;
NSView *view = TkMacOSXDrawableView(macWin);
- if (!view ||
- macWin->flags & TK_DO_NOT_DRAW ||
- !TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) {
- return;
+
+ if ((view == NULL)
+ || (macWin->flags & TK_DO_NOT_DRAW)
+ || !TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) {
+ return;
}
+ /*
+ * Transform NSView coordinates to CoreGraphics coordinates.
+ */
+
CGFloat viewHeight = [view bounds].size.height;
- CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0,
- .ty = viewHeight};
+ CGAffineTransform t = {
+ .a = 1, .b = 0,
+ .c = 0, .d = -1,
+ .tx = 0, .ty = viewHeight
+ };
+
CGContextConcatCTM(dc.context, t);
- /*Draw a 3D rectangle to provide a base for the native scrollbar.*/
+ /*
+ * Draw a 3D rectangle to provide a base for the native scrollbar.
+ */
+
if (scrollPtr->highlightWidth != 0) {
GC fgGC, bgGC;
@@ -196,32 +294,46 @@ TkpDisplayScrollbar(
fgGC = bgGC;
}
TkpDrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth,
- (Pixmap) macWin);
+ (Pixmap) macWin);
}
Tk_Draw3DRectangle(tkwin, (Pixmap) macWin, scrollPtr->bgBorder,
- scrollPtr->highlightWidth, scrollPtr->highlightWidth,
- Tk_Width(tkwin) - 2*scrollPtr->highlightWidth,
- Tk_Height(tkwin) - 2*scrollPtr->highlightWidth,
- scrollPtr->borderWidth, scrollPtr->relief);
+ scrollPtr->highlightWidth, scrollPtr->highlightWidth,
+ Tk_Width(tkwin) - 2*scrollPtr->highlightWidth,
+ Tk_Height(tkwin) - 2*scrollPtr->highlightWidth,
+ scrollPtr->borderWidth, scrollPtr->relief);
Tk_Fill3DRectangle(tkwin, (Pixmap) macWin, scrollPtr->bgBorder,
- scrollPtr->inset, scrollPtr->inset,
- Tk_Width(tkwin) - 2*scrollPtr->inset,
- Tk_Height(tkwin) - 2*scrollPtr->inset, 0, TK_RELIEF_FLAT);
+ scrollPtr->inset, scrollPtr->inset,
+ Tk_Width(tkwin) - 2*scrollPtr->inset,
+ Tk_Height(tkwin) - 2*scrollPtr->inset, 0, TK_RELIEF_FLAT);
+
+ /*
+ * Update values and then draw the native scrollbar over the rectangle.
+ */
- /* Update values and then draw the native scrollbar over the rectangle.*/
UpdateControlValues(scrollPtr);
if (SNOW_LEOPARD_STYLE) {
- HIThemeDrawTrack (&(msPtr->info), 0, dc.context, kHIThemeOrientationInverted);
+ HIThemeDrawTrack(&msPtr->info, 0, dc.context,
+ kHIThemeOrientationInverted);
+ } else if ([NSApp macMinorVersion] <= 8) {
+ HIThemeDrawTrack(&msPtr->info, 0, dc.context,
+ kHIThemeOrientationNormal);
} else {
- HIThemeDrawTrack (&(msPtr->info), 0, dc.context, kHIThemeOrientationNormal);
+#if MAC_OS_X_VERSION_MAX_ALLOWED > 1080
+
+ /*
+ * Switch back to NSView coordinates and draw a modern scrollbar.
+ */
+
+ CGContextConcatCTM(dc.context, t);
+ drawMacScrollbar(scrollPtr, msPtr, dc.context);
+#endif
}
TkMacOSXRestoreDrawingContext(&dc);
-
scrollPtr->flags &= ~REDRAW_PENDING;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -240,65 +352,63 @@ TkpDisplayScrollbar(
*----------------------------------------------------------------------
*/
-
-
extern void
TkpComputeScrollbarGeometry(
- register TkScrollbar *scrollPtr)
- /* Scrollbar whose geometry may have
- * changed. */
+ TkScrollbar *scrollPtr)
+ /* Scrollbar whose geometry may have
+ * changed. */
{
-
- /*
- * The code below is borrowed from tkUnixScrlbr.c but has been adjusted to
- * account for some differences between macOS and X11. The Unix scrollbar
- * has an arrow button on each end. On macOS 10.6 (Snow Leopard) the
- * scrollbars by default have both arrow buttons at the bottom or right.
- * (There is a preferences setting to use the Unix layout, but we are not
- * supporting that!) On more recent versions of macOS there are no arrow
- * buttons at all. The case of no arrow buttons can be handled as a special
- * case of having both buttons at the end, but where scrollPtr->arrowLength
- * happens to be zero. To adjust for having both arrows at the same end we
- * shift the scrollbar up by the arrowLength.
- */
+ /*
+ * The code below is borrowed from tkUnixScrlbr.c but has been adjusted to
+ * account for some differences between macOS and X11. The Unix scrollbar
+ * has an arrow button on each end. On macOS 10.6 (Snow Leopard) the
+ * scrollbars by default have both arrow buttons at the bottom or right.
+ * (There is a preferences setting to use the Unix layout, but we are not
+ * supporting that!) On more recent versions of macOS there are no arrow
+ * buttons at all. The case of no arrow buttons can be handled as a special
+ * case of having both buttons at the end, but where scrollPtr->arrowLength
+ * happens to be zero. To adjust for having both arrows at the same end we
+ * shift the scrollbar up by the arrowLength.
+ */
int fieldLength;
if (scrollPtr->highlightWidth < 0) {
- scrollPtr->highlightWidth = 0;
+ scrollPtr->highlightWidth = 0;
}
scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth;
if ([NSApp macMinorVersion] == 6) {
- scrollPtr->arrowLength = scrollPtr->width;
+ scrollPtr->arrowLength = scrollPtr->width;
} else {
- scrollPtr->arrowLength = 0;
+ scrollPtr->arrowLength = 0;
}
fieldLength = (scrollPtr->vertical ? Tk_Height(scrollPtr->tkwin)
- : Tk_Width(scrollPtr->tkwin))
- - 2*(scrollPtr->arrowLength + scrollPtr->inset);
+ : Tk_Width(scrollPtr->tkwin))
+ - 2*(scrollPtr->arrowLength + scrollPtr->inset);
if (fieldLength < 0) {
- fieldLength = 0;
+ fieldLength = 0;
}
scrollPtr->sliderFirst = fieldLength*scrollPtr->firstFraction;
scrollPtr->sliderLast = fieldLength*scrollPtr->lastFraction;
/*
- * Adjust the slider so that some piece of it is always displayed in the
- * scrollbar and so that it has at least a minimal width (so it can be
- * grabbed with the mouse).
+ * Adjust the slider so that it has at least a minimal size and so there
+ * is a small gap on either end which can be used to scroll by one page.
*/
- if (scrollPtr->sliderFirst > fieldLength - MIN_SLIDER_LENGTH) {
- scrollPtr->sliderFirst = fieldLength - MIN_SLIDER_LENGTH;
+ if (scrollPtr->sliderFirst < MIN_GAP) {
+ scrollPtr->sliderFirst = MIN_GAP;
+ scrollPtr->sliderLast += MIN_GAP;
}
- if (scrollPtr->sliderFirst < 0) {
- scrollPtr->sliderFirst = 0;
+ if (scrollPtr->sliderLast > fieldLength - MIN_GAP) {
+ scrollPtr->sliderLast = fieldLength - MIN_GAP;
+ scrollPtr->sliderFirst -= MIN_GAP;
}
- if (scrollPtr->sliderLast < scrollPtr->sliderFirst + MIN_SLIDER_LENGTH) {
- scrollPtr->sliderLast = scrollPtr->sliderFirst + MIN_SLIDER_LENGTH;
+ if (scrollPtr->sliderFirst > fieldLength - MIN_SLIDER_LENGTH) {
+ scrollPtr->sliderFirst = fieldLength - MIN_SLIDER_LENGTH;
}
- if (scrollPtr->sliderLast > fieldLength) {
- scrollPtr->sliderLast = fieldLength;
+ if (scrollPtr->sliderLast < scrollPtr->sliderFirst + MIN_SLIDER_LENGTH) {
+ scrollPtr->sliderLast = scrollPtr->sliderFirst + MIN_SLIDER_LENGTH;
}
scrollPtr->sliderFirst += -scrollPtr->arrowLength + scrollPtr->inset;
scrollPtr->sliderLast += scrollPtr->inset;
@@ -310,20 +420,20 @@ TkpComputeScrollbarGeometry(
* be redisplayed.
*/
- if (scrollPtr->vertical) {
- Tk_GeometryRequest(scrollPtr->tkwin,
- scrollPtr->width + 2*scrollPtr->inset,
- 2*(scrollPtr->arrowLength + scrollPtr->borderWidth
- + scrollPtr->inset) + metrics.minThumbHeight);
+ if (scrollPtr->vertical) {
+ Tk_GeometryRequest(scrollPtr->tkwin,
+ scrollPtr->width + 2*scrollPtr->inset,
+ 2*(scrollPtr->arrowLength + scrollPtr->borderWidth
+ + scrollPtr->inset) + metrics.minThumbHeight);
} else {
- Tk_GeometryRequest(scrollPtr->tkwin,
- 2*(scrollPtr->arrowLength + scrollPtr->borderWidth
- + scrollPtr->inset) + metrics.minThumbHeight,
- scrollPtr->width + 2*scrollPtr->inset);
+ Tk_GeometryRequest(scrollPtr->tkwin,
+ 2*(scrollPtr->arrowLength + scrollPtr->borderWidth
+ + scrollPtr->inset) + metrics.minThumbHeight,
+ scrollPtr->width + 2*scrollPtr->inset);
}
Tk_SetInternalBorder(scrollPtr->tkwin, scrollPtr->inset);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -342,9 +452,9 @@ TkpComputeScrollbarGeometry(
void
TkpDestroyScrollbar(
- TkScrollbar *scrollPtr)
+ TkScrollbar *scrollPtr)
{
- MacScrollbar *macScrollPtr = (MacScrollbar *)scrollPtr;
+ MacScrollbar *macScrollPtr = (MacScrollbar *) scrollPtr;
if (macScrollPtr->troughGC != None) {
Tk_FreeGC(scrollPtr->display, macScrollPtr->troughGC);
@@ -353,15 +463,15 @@ TkpDestroyScrollbar(
Tk_FreeGC(scrollPtr->display, macScrollPtr->copyGC);
}
}
-
+
/*
*----------------------------------------------------------------------
*
* TkpConfigureScrollbar --
*
- * This procedure is called after the generic code has finished
- * processing configuration options, in order to configure platform
- * specific options. There are no such option on the Mac, however.
+ * This procedure is called after the generic code has finished processing
+ * configuration options, in order to configure platform specific options.
+ * There are no such option on the Mac, however.
*
* Results:
* None.
@@ -374,11 +484,12 @@ TkpDestroyScrollbar(
void
TkpConfigureScrollbar(
- register TkScrollbar *scrollPtr)
+ TkScrollbar *scrollPtr)
{
-
+ (void)scrollPtr;
+ /* empty */
}
-
+
/*
*--------------------------------------------------------------
*
@@ -399,33 +510,32 @@ TkpConfigureScrollbar(
int
TkpScrollbarPosition(
- register TkScrollbar *scrollPtr,
+ TkScrollbar *scrollPtr,
/* Scrollbar widget record. */
int x, int y) /* Coordinates within scrollPtr's window. */
{
-
- /*
- * The code below is borrowed from tkUnixScrlbr.c and needs no adjustment
- * since it does not involve the arrow buttons.
- */
+ /*
+ * The code below is borrowed from tkUnixScrlbr.c and needs no adjustment
+ * since it does not involve the arrow buttons.
+ */
int length, width, tmp;
- register const int inset = scrollPtr->inset;
+ const int inset = scrollPtr->inset;
if (scrollPtr->vertical) {
- length = Tk_Height(scrollPtr->tkwin);
- width = Tk_Width(scrollPtr->tkwin);
+ length = Tk_Height(scrollPtr->tkwin);
+ width = Tk_Width(scrollPtr->tkwin);
} else {
- tmp = x;
- x = y;
- y = tmp;
- length = Tk_Width(scrollPtr->tkwin);
- width = Tk_Height(scrollPtr->tkwin);
+ tmp = x;
+ x = y;
+ y = tmp;
+ length = Tk_Width(scrollPtr->tkwin);
+ width = Tk_Height(scrollPtr->tkwin);
}
if (x < inset || x >= width - inset ||
- y < inset || y >= length - inset) {
- return OUTSIDE;
+ y < inset || y >= length - inset) {
+ return OUTSIDE;
}
/*
@@ -436,31 +546,34 @@ TkpScrollbarPosition(
*/
if (y < scrollPtr->sliderFirst + scrollPtr->arrowLength) {
- return TOP_GAP;
- }
- if (y < scrollPtr->sliderLast) {
- return SLIDER;
- }
- if (y < length - (2*scrollPtr->arrowLength + inset)) {
- return BOTTOM_GAP;
- }
- /* On systems newer than 10.6 we have already returned. */
- if (y < length - (scrollPtr->arrowLength + inset)) {
- return TOP_ARROW;
- }
- return BOTTOM_ARROW;
-}
+ return TOP_GAP;
+ }
+ if (y < scrollPtr->sliderLast) {
+ return SLIDER;
+ }
+ if (y < length - (2*scrollPtr->arrowLength + inset)) {
+ return BOTTOM_GAP;
+ }
+
+ /*
+ * On systems newer than 10.6 we have already returned.
+ */
+ if (y < length - (scrollPtr->arrowLength + inset)) {
+ return TOP_ARROW;
+ }
+ return BOTTOM_ARROW;
+}
+
/*
*--------------------------------------------------------------
*
* UpdateControlValues --
*
- * This procedure updates the Macintosh scrollbar control to
- * display the values defined by the Tk scrollbar. This is the
- * key interface to the Mac-native scrollbar; the Unix bindings
- * drive scrolling in the Tk window and all the Mac scrollbar has
- * to do is redraw itself.
+ * This procedure updates the Macintosh scrollbar control to display the
+ * values defined by the Tk scrollbar. This is the key interface to the
+ * Mac-native scrollbar; the Unix bindings drive scrolling in the Tk
+ * window and all the Mac scrollbar has to do is redraw itself.
*
* Results:
* None.
@@ -473,20 +586,21 @@ TkpScrollbarPosition(
static void
UpdateControlValues(
- TkScrollbar *scrollPtr) /* Scrollbar data struct. */
+ TkScrollbar *scrollPtr) /* Scrollbar data struct. */
{
- MacScrollbar *msPtr = (MacScrollbar *)scrollPtr;
+ MacScrollbar *msPtr = (MacScrollbar *) scrollPtr;
Tk_Window tkwin = scrollPtr->tkwin;
MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin);
double dViewSize;
- HIRect contrlRect;
+ HIRect contrlRect;
short width, height;
NSView *view = TkMacOSXDrawableView(macWin);
CGFloat viewHeight = [view bounds].size.height;
NSRect frame;
+
frame = NSMakeRect(macWin->xOff, macWin->yOff, Tk_Width(tkwin),
- Tk_Height(tkwin));
+ Tk_Height(tkwin));
frame = NSInsetRect(frame, scrollPtr->inset, scrollPtr->inset);
frame.origin.y = viewHeight - (frame.origin.y + frame.size.height);
@@ -494,7 +608,7 @@ UpdateControlValues(
msPtr->info.bounds = contrlRect;
width = contrlRect.size.width;
- height = contrlRect.size.height;
+ height = contrlRect.size.height - scrollPtr->arrowLength;
/*
* Ensure we set scrollbar control bounds only once all size adjustments
@@ -503,9 +617,9 @@ UpdateControlValues(
msPtr->info.bounds = contrlRect;
if (scrollPtr->vertical) {
- msPtr->info.attributes &= ~kThemeTrackHorizontal;
+ msPtr->info.attributes &= ~kThemeTrackHorizontal;
} else {
- msPtr->info.attributes |= kThemeTrackHorizontal;
+ msPtr->info.attributes |= kThemeTrackHorizontal;
}
/*
@@ -518,69 +632,71 @@ UpdateControlValues(
* the view area.
*/
- double maximum = 100, factor;
- factor = RangeToFactor(maximum);
- dViewSize = (scrollPtr->lastFraction - scrollPtr->firstFraction)
- * factor;
- msPtr->info.max = MIN_SCROLLBAR_VALUE +
- factor - dViewSize;
+ double factor = RangeToFactor(100.0);
+ dViewSize = (scrollPtr->lastFraction - scrollPtr->firstFraction) * factor;
+ msPtr->info.max = factor - dViewSize;
msPtr->info.trackInfo.scrollbar.viewsize = dViewSize;
if (scrollPtr->vertical) {
- if (SNOW_LEOPARD_STYLE) {
- msPtr->info.value = factor * scrollPtr->firstFraction;
- } else {
- msPtr->info.value = msPtr->info.max - factor * scrollPtr->firstFraction;
- }
+ if (SNOW_LEOPARD_STYLE) {
+ msPtr->info.value = factor * scrollPtr->firstFraction;
+ } else {
+ msPtr->info.value = msPtr->info.max -
+ factor * scrollPtr->firstFraction;
+ }
} else {
- msPtr->info.value = MIN_SCROLLBAR_VALUE + factor * scrollPtr->firstFraction;
+ msPtr->info.value = factor * scrollPtr->firstFraction;
}
- if((scrollPtr->firstFraction <= 0.0 && scrollPtr->lastFraction >= 1.0)
- || height <= metrics.minHeight) {
+ if ((scrollPtr->firstFraction <= 0.0 && scrollPtr->lastFraction >= 1.0)
+ || height <= metrics.minHeight) {
msPtr->info.enableState = kThemeTrackHideTrack;
} else {
msPtr->info.enableState = kThemeTrackActive;
- msPtr->info.attributes = kThemeTrackShowThumb | kThemeTrackThumbRgnIsNotGhost;
+ msPtr->info.attributes =
+ kThemeTrackShowThumb | kThemeTrackThumbRgnIsNotGhost;
}
-
}
-
+
/*
*--------------------------------------------------------------
*
* ScrollbarEvent --
*
- * This procedure is invoked in response to <ButtonPress>, <ButtonRelease>,
- * <EnterNotify>, and <LeaveNotify> events. The Scrollbar appearance is
- * modified for each event.
+ * This procedure is invoked in response to <ButtonPress>,
+ * <ButtonRelease>, <EnterNotify>, and <LeaveNotify> events. The
+ * Scrollbar appearance is modified for each event.
*
*--------------------------------------------------------------
*/
static int
-ScrollbarEvent(TkScrollbar *scrollPtr, XEvent *eventPtr)
+ScrollbarEvent(
+ TkScrollbar *scrollPtr,
+ XEvent *eventPtr)
{
- MacScrollbar *msPtr = (MacScrollbar *)scrollPtr;
-
- /* The pressState does not indicate whether the moused button was
- * pressed at some location in the Scrollbar. Rather, it indicates
- * that the scrollbar should appear as if it were pressed in that
- * location. The standard Mac behavior is that once the button is
- * pressed inside the Scrollbar the appearance should not change until
- * the button is released, even if the mouse moves outside of the
- * scrollbar. However, if the mouse lies over the scrollbar but the
- * button is not pressed then the appearance should be the same as if
- * the button had been pressed on the slider, i.e. kThemeThumbPressed.
- * See the file Appearance.r, or HIToolbox.bridgesupport on 10.14.
+ MacScrollbar *msPtr = (MacScrollbar *) scrollPtr;
+
+ /*
+ * The pressState does not indicate whether the moused button was pressed
+ * at some location in the Scrollbar. Rather, it indicates that the
+ * scrollbar should appear as if it were pressed in that location. The
+ * standard Mac behavior is that once the button is pressed inside the
+ * Scrollbar the appearance should not change until the button is released,
+ * even if the mouse moves outside of the scrollbar. However, if the mouse
+ * lies over the scrollbar but the button is not pressed then the
+ * appearance should be the same as if the button had been pressed on the
+ * slider, i.e. kThemeThumbPressed. See the file Appearance.r, or
+ * HIToolbox.bridgesupport on 10.14.
*/
if (eventPtr->type == ButtonPress) {
msPtr->buttonDown = true;
UpdateControlValues(scrollPtr);
+
int where = TkpScrollbarPosition(scrollPtr,
- eventPtr->xbutton.x,
- eventPtr->xbutton.y);
- switch(where) {
+ eventPtr->xbutton.x, eventPtr->xbutton.y);
+
+ switch (where) {
case OUTSIDE:
msPtr->info.trackInfo.scrollbar.pressState = 0;
break;
@@ -591,14 +707,21 @@ ScrollbarEvent(TkScrollbar *scrollPtr, XEvent *eventPtr)
msPtr->info.trackInfo.scrollbar.pressState = kThemeThumbPressed;
break;
case BOTTOM_GAP:
- msPtr->info.trackInfo.scrollbar.pressState = kThemeBottomTrackPressed;
+ msPtr->info.trackInfo.scrollbar.pressState =
+ kThemeBottomTrackPressed;
break;
case TOP_ARROW:
- /* This looks wrong and the docs say it is wrong but it works. */
- msPtr->info.trackInfo.scrollbar.pressState = kThemeTopInsideArrowPressed;
+
+ /*
+ * This looks wrong and the docs say it is wrong but it works.
+ */
+
+ msPtr->info.trackInfo.scrollbar.pressState =
+ kThemeTopInsideArrowPressed;
break;
case BOTTOM_ARROW:
- msPtr->info.trackInfo.scrollbar.pressState = kThemeBottomOutsideArrowPressed;
+ msPtr->info.trackInfo.scrollbar.pressState =
+ kThemeBottomOutsideArrowPressed;
break;
}
}
@@ -620,11 +743,10 @@ ScrollbarEvent(TkScrollbar *scrollPtr, XEvent *eventPtr)
msPtr->info.trackInfo.scrollbar.pressState = 0;
}
}
+ TkScrollbarEventuallyRedraw(scrollPtr);
return TCL_OK;
}
-
-
-
+
/*
*--------------------------------------------------------------
*
@@ -645,8 +767,8 @@ ScrollbarEvent(TkScrollbar *scrollPtr, XEvent *eventPtr)
static void
ScrollbarEventProc(
- ClientData clientData, /* Information about window. */
- XEvent *eventPtr) /* Information about event. */
+ ClientData clientData, /* Information about window. */
+ XEvent *eventPtr) /* Information about event. */
{
TkScrollbar *scrollPtr = clientData;
@@ -668,7 +790,7 @@ ScrollbarEventProc(
TkScrollbarEventProc(clientData, eventPtr);
}
}
-
+
/*
* Local Variables:
* mode: objc
diff --git a/macosx/tkMacOSXSend.c b/macosx/tkMacOSXSend.c
index 1fdf048..71a86df 100644
--- a/macosx/tkMacOSXSend.c
+++ b/macosx/tkMacOSXSend.c
@@ -51,7 +51,7 @@ typedef struct RegisteredInterp {
* A registry of all interpreters for a display is kept in a property
* "InterpRegistry" on the root window of the display. It is organized as a
* series of zero or more concatenated strings (in no particular order), each
- * of the form
+ * of the form:
* window space name '\0'
* where "window" is the hex id of the comm. window to use to talk to an
* interpreter named "name".
@@ -78,7 +78,7 @@ typedef struct NameRegistry {
* XFree; zero means use ckfree. */
} NameRegistry;
-static int initialized = 0; /* A flag to denote if we have initialized
+static int initialized = 0; /* A flag to denote if we have initialized
* yet. */
static RegisteredInterp *interpListPtr = NULL;
@@ -281,9 +281,9 @@ Tk_SetAppName(
* We have found a unique name. Now add it to the registry.
*/
- riPtr = ckalloc(sizeof(RegisteredInterp));
+ riPtr = (RegisteredInterp *)ckalloc(sizeof(RegisteredInterp));
riPtr->interp = interp;
- riPtr->name = ckalloc(strlen(actualName) + 1);
+ riPtr->name = (char *)ckalloc(strlen(actualName) + 1);
riPtr->nextPtr = interpListPtr;
interpListPtr = riPtr;
strcpy(riPtr->name, actualName);
@@ -320,7 +320,7 @@ Tk_SetAppName(
int
Tk_SendObjCmd(
- ClientData clientData, /* Used only for deletion */
+ ClientData dummy, /* Not used */
Tcl_Interp *interp, /* The interp we are sending from */
int objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* The arguments */
@@ -332,6 +332,7 @@ Tk_SendObjCmd(
RegisteredInterp *riPtr;
Tcl_Obj *listObjPtr;
int result = TCL_OK;
+ (void)dummy;
for (i = 1; i < (objc - 1); ) {
stringRep = Tcl_GetString(objv[i]);
@@ -466,6 +467,7 @@ TkGetInterpNames(
{
Tcl_Obj *listObjPtr;
RegisteredInterp *riPtr;
+ (void)tkwin;
listObjPtr = Tcl_NewListObj(0, NULL);
riPtr = interpListPtr;
@@ -498,10 +500,9 @@ TkGetInterpNames(
static int
SendInit(
- Tcl_Interp *interp) /* Interpreter to use for error reporting (no
- * errors are ever returned, but the
- * interpreter is needed anyway). */
+ Tcl_Interp *dummy) /* Not used */
{
+ (void)dummy;
return TCL_OK;
}
diff --git a/macosx/tkMacOSXServices.c b/macosx/tkMacOSXServices.c
new file mode 100644
index 0000000..974fec1
--- /dev/null
+++ b/macosx/tkMacOSXServices.c
@@ -0,0 +1,165 @@
+/*
+ * tkMacOSXServices.c --
+ *\
+ * This file allows the integration of Tk and the Cocoa NSServices API.
+ *
+ * Copyright (c) 2010-2019 Kevin Walzer/WordTech Communications LLC.
+ * Copyright (c) 2019 Marc Culler.
+ * Copyright (c) 2010 Adrian Robert.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+#include <tkInt.h>
+#include <tkMacOSXInt.h>
+
+/*
+ * Event proc which calls the PerformService procedure.
+ */
+
+static int
+ServicesEventProc(
+ Tcl_Event *event,
+ int flags)
+{
+ TkMainInfo *info = TkGetMainInfoList();
+ (void)event;
+ (void)flags;
+
+ Tcl_GlobalEval(info->interp, "::tk::mac::PerformService");
+ return 1;
+}
+
+/*
+ * The Wish application can send the current selection in the Tk clipboard
+ * to other applications which accept messages of type NSString. The TkService
+ * object provides this service via its provideService method. (The method
+ * must be specified in the application's Info.plist file for this to work.)
+ */
+
+@interface TkService : NSObject {
+
+}
+
++ (void) initialize;
+- (void) provideService:(NSPasteboard *)pboard
+ userData:(NSString *)data
+ error:(NSString **)error;
+- (BOOL) writeSelectionToPasteboard:(NSPasteboard *)pboard
+ types:(NSArray *)types;
+
+@end
+
+/*
+ * Class methods.
+ */
+
+@implementation TkService
+
++ (void) initialize {
+ NSArray *sendTypes = [NSArray arrayWithObjects:@"NSStringPboardType",
+ @"NSPasteboardTypeString", nil];
+ [NSApp registerServicesMenuSendTypes:sendTypes returnTypes:sendTypes];
+ return;
+}
+
+/*
+ * Get the current Tk selection and copy it to the system pasteboard.
+ */
+
+- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard
+ types:(NSArray *)types
+{
+ NSArray *typesDeclared = nil;
+ NSString *pboardType = nil;
+ TkMainInfo *info = TkGetMainInfoList();
+
+ for (NSString *typeString in types) {
+ if ([typeString isEqualToString:@"NSStringPboardType"] ||
+ [typeString isEqualToString:@"NSPasteboardTypeString"]) {
+ typesDeclared = [NSArray arrayWithObject:typeString];
+ pboardType = typeString;
+ break;
+ }
+ }
+ if (!typesDeclared) {
+ return NO;
+ }
+ Tcl_Eval(info->interp, "selection get");
+
+ char *copystring = Tcl_GetString(Tcl_GetObjResult(info->interp));
+ NSString *writestring = [NSString stringWithUTF8String:copystring];
+
+ [pboard declareTypes:typesDeclared owner:nil];
+ return [pboard setString:writestring forType:pboardType];
+}
+
+/*
+ * This is the method that actually calls the Tk service; it must be specified
+ * in Info.plist.
+ */
+
+- (void)provideService:(NSPasteboard *)pboard
+ userData:(NSString *)data
+ error:(NSString **)error
+{
+ NSString *pboardString = nil, *pboardType = nil;
+ NSArray *types = [pboard types];
+ Tcl_Event *event;
+ (void)data;
+ (void)error;
+
+ /*
+ * Get a string from the private pasteboard and copy it to the general
+ * pasteboard to make it available to other applications.
+ */
+
+ for (NSString *typeString in types) {
+ if ([typeString isEqualToString:@"NSStringPboardType"] ||
+ [typeString isEqualToString:@"NSPasteboardTypeString"]) {
+ pboardString = [pboard stringForType:typeString];
+ pboardType = typeString;
+ break;
+ }
+ }
+ if (pboardString) {
+ NSPasteboard *generalpasteboard = [NSPasteboard generalPasteboard];
+ [generalpasteboard declareTypes:[NSArray arrayWithObjects:pboardType, nil]
+ owner:nil];
+ [generalpasteboard setString:pboardString forType:pboardType];
+ event = (Tcl_Event *)ckalloc(sizeof(Tcl_Event));
+ event->proc = ServicesEventProc;
+ Tcl_QueueEvent((Tcl_Event *)event, TCL_QUEUE_TAIL);
+ }
+}
+@end
+
+/*
+
+ * Instantiate a TkService object and register it with the NSApplication.
+ * This is called exactly one time from TkpInit.
+ */
+
+int
+TkMacOSXServices_Init(
+ Tcl_Interp *dummy)
+{
+ (void)dummy;
+ /*
+ * Initialize an instance of TkService and register it with the NSApp.
+ */
+
+ TkService *service = [[TkService alloc] init];
+ [NSApp setServicesProvider:service];
+ return TCL_OK;
+}
+
+/*
+ * Local Variables:
+ * mode: objc
+ * c-basic-offset: 4
+ * fill-column: 79
+ * coding: utf-8
+ * End:
+ */
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 805d58f..611afd7 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -49,12 +49,13 @@ static void NotifyVisibility(TkWindow *winPtr, XEvent *eventPtr);
*----------------------------------------------------------------------
*/
-void
+int
XDestroyWindow(
Display *display, /* Display. */
Window window) /* Window. */
{
MacDrawable *macWin = (MacDrawable *) window;
+ (void)display;
/*
* Remove any dangling pointers that may exist if the window we are
@@ -65,35 +66,41 @@ XDestroyWindow(
TkMacOSXSelDeadWindow(macWin->winPtr);
macWin->toplevel->referenceCount--;
- if (!Tk_IsTopLevel(macWin->winPtr) ) {
+ if (!Tk_IsTopLevel(macWin->winPtr)) {
TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
if (macWin->winPtr->parentPtr != NULL) {
TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr->parentPtr);
}
if (macWin->visRgn) {
CFRelease(macWin->visRgn);
+ macWin->visRgn = NULL;
}
if (macWin->aboveVisRgn) {
CFRelease(macWin->aboveVisRgn);
+ macWin->aboveVisRgn = NULL;
}
if (macWin->drawRgn) {
CFRelease(macWin->drawRgn);
+ macWin->drawRgn = NULL;
}
if (macWin->toplevel->referenceCount == 0) {
ckfree(macWin->toplevel);
}
ckfree(macWin);
- return;
+ return Success;
}
if (macWin->visRgn) {
CFRelease(macWin->visRgn);
+ macWin->visRgn = NULL;
}
if (macWin->aboveVisRgn) {
CFRelease(macWin->aboveVisRgn);
+ macWin->aboveVisRgn = NULL;
}
if (macWin->drawRgn) {
CFRelease(macWin->drawRgn);
+ macWin->drawRgn = NULL;
}
macWin->view = nil;
@@ -105,6 +112,7 @@ XDestroyWindow(
if (macWin->toplevel->referenceCount == 0) {
ckfree(macWin->toplevel);
}
+ return Success;
}
/*
@@ -124,12 +132,14 @@ XDestroyWindow(
*----------------------------------------------------------------------
*/
-void
+int
XMapWindow(
Display *display, /* Display. */
Window window) /* Window. */
{
MacDrawable *macWin = (MacDrawable *) window;
+ TkWindow *winPtr = macWin->winPtr;
+ NSWindow *win = TkMacOSXDrawableWindow(window);
XEvent event;
/*
@@ -145,50 +155,40 @@ XMapWindow(
}
display->request++;
- macWin->winPtr->flags |= TK_MAPPED;
- if (Tk_IsTopLevel(macWin->winPtr)) {
- if (!Tk_IsEmbedded(macWin->winPtr)) {
- NSWindow *win = TkMacOSXDrawableWindow(window);
+ winPtr->flags |= TK_MAPPED;
+ if (Tk_IsTopLevel(winPtr)) {
+ if (!Tk_IsEmbedded(winPtr)) {
/*
- * We want to activate Tk when a toplevel is mapped
- * but we must not supply YES here. This is because
- * during Tk initialization the root window is mapped
- * before applicationDidFinishLaunching returns. Forcing
- * the app to activate too early can make the menu bar
- * unresponsive.
+ * We want to activate Tk when a toplevel is mapped but we must not
+ * supply YES here. This is because during Tk initialization the
+ * root window is mapped before applicationDidFinishLaunching
+ * returns. Forcing the app to activate too early can make the menu
+ * bar unresponsive.
*/
- TkMacOSXApplyWindowAttributes(macWin->winPtr, win);
+ TkMacOSXApplyWindowAttributes(winPtr, win);
[win setExcludedFromWindowsMenu:NO];
[NSApp activateIgnoringOtherApps:NO];
[[win contentView] setNeedsDisplay:YES];
- if ( [win canBecomeKeyWindow] ) {
+ if ([win canBecomeKeyWindow]) {
[win makeKeyAndOrderFront:NSApp];
} else {
[win orderFrontRegardless];
}
-
- /*
- * In some cases the toplevel will not be drawn unless we process
- * all pending events now. See ticket 56a1823c73.
- */
-
- [NSApp _lockAutoreleasePool];
- while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {}
- [NSApp _unlockAutoreleasePool];
} else {
+ TkWindow *contWinPtr = TkpGetOtherWindow(winPtr);
/*
* Rebuild the container's clipping region and display
* the window.
*/
- TkWindow *contWinPtr = TkpGetOtherWindow(macWin->winPtr);
- TkMacOSXInvalClipRgns((Tk_Window)contWinPtr);
+ TkMacOSXInvalClipRgns((Tk_Window) contWinPtr);
TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
}
- TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr);
+
+ TkMacOSXInvalClipRgns((Tk_Window) winPtr);
/*
* We only need to send the MapNotify event for toplevel windows.
@@ -201,18 +201,22 @@ XMapWindow(
event.xmap.window = window;
event.xmap.type = MapNotify;
event.xmap.event = window;
- event.xmap.override_redirect = macWin->winPtr->atts.override_redirect;
+ event.xmap.override_redirect = winPtr->atts.override_redirect;
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
-
} else {
/*
- * Rebuild the parent's clipping region and display the window.
- *
+ * For non-toplevel windows, rebuild the parent's clipping region
+ * and redisplay the window.
*/
- TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr->parentPtr);
- TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
+ TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr);
+ }
+
+ if ([NSApp isDrawing]) {
+ [[win contentView] setNeedsRedisplay:YES];
+ } else {
+ [[win contentView] setNeedsDisplay:YES];
}
/*
@@ -223,13 +227,8 @@ XMapWindow(
event.xany.display = display;
event.xvisibility.type = VisibilityNotify;
event.xvisibility.state = VisibilityUnobscured;
- NotifyVisibility(macWin->winPtr, &event);
-
- /*
- * This seems to be needed to ensure that all subwindows get displayed.
- */
-
- GenerateConfigureNotify(macWin->winPtr, 1);
+ NotifyVisibility(winPtr, &event);
+ return Success;
}
/*
@@ -283,7 +282,7 @@ NotifyVisibility(
*----------------------------------------------------------------------
*/
-void
+int
XUnmapWindow(
Display *display, /* Display. */
Window window) /* Window. */
@@ -291,13 +290,13 @@ XUnmapWindow(
MacDrawable *macWin = (MacDrawable *) window;
TkWindow *winPtr = macWin->winPtr;
TkWindow *parentPtr = winPtr->parentPtr;
+ NSWindow *win = TkMacOSXDrawableWindow(window);
XEvent event;
display->request++;
if (Tk_IsTopLevel(winPtr)) {
if (!Tk_IsEmbedded(winPtr) &&
winPtr->wmInfoPtr->hints.initial_state!=IconicState) {
- NSWindow *win = TkMacOSXDrawableWindow(window);
[win orderOut:nil];
}
TkMacOSXInvalClipRgns((Tk_Window) winPtr);
@@ -316,20 +315,27 @@ XUnmapWindow(
event.xunmap.from_configure = false;
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
} else {
-
/*
* Rebuild the visRgn clip region for the parent so it will be allowed
- * to draw in the space from which this subwindow was removed.
+ * to draw in the space from which this subwindow was removed and then
+ * redraw the window.
*/
if (parentPtr && parentPtr->privatePtr->visRgn) {
- TkMacOSXInvalidateViewRegion(TkMacOSXDrawableView(parentPtr->privatePtr),
- parentPtr->privatePtr->visRgn);
+ TkMacOSXInvalidateViewRegion(
+ TkMacOSXDrawableView(parentPtr->privatePtr),
+ parentPtr->privatePtr->visRgn);
}
TkMacOSXInvalClipRgns((Tk_Window) parentPtr);
TkMacOSXUpdateClipRgn(parentPtr);
}
winPtr->flags &= ~TK_MAPPED;
+ if ([NSApp isDrawing]) {
+ [[win contentView] setNeedsRedisplay:YES];
+ } else {
+ [[win contentView] setNeedsDisplay:YES];
+ }
+ return Success;
}
/*
@@ -349,7 +355,7 @@ XUnmapWindow(
*----------------------------------------------------------------------
*/
-void
+int
XResizeWindow(
Display *display, /* Display. */
Window window, /* Window. */
@@ -357,11 +363,14 @@ XResizeWindow(
unsigned int height)
{
MacDrawable *macWin = (MacDrawable *) window;
+
display->request++;
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
NSWindow *w = macWin->winPtr->wmInfoPtr->window;
+
if (w) {
NSRect r = [w contentRectForFrameRect:[w frame]];
+
r.origin.y += r.size.height - height;
r.size.width = width;
r.size.height = height;
@@ -370,6 +379,7 @@ XResizeWindow(
} else {
MoveResizeWindow(macWin);
}
+ return Success;
}
/*
@@ -377,8 +387,8 @@ XResizeWindow(
*
* XMoveResizeWindow --
*
- * Move or resize a given X window. See X windows documentation
- * for further details.
+ * Move or resize a given X window. See X windows documentation for
+ * further details.
*
* Results:
* None.
@@ -389,7 +399,7 @@ XResizeWindow(
*----------------------------------------------------------------------
*/
-void
+int
XMoveResizeWindow(
Display *display, /* Display. */
Window window, /* Window. */
@@ -402,27 +412,30 @@ XMoveResizeWindow(
display->request++;
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
NSWindow *w = macWin->winPtr->wmInfoPtr->window;
- if (w) {
- /* We explicitly convert everything to doubles so we don't get
+ if (w) {
+ /*
+ * We explicitly convert everything to doubles so we don't get
* surprised (again) by what happens when you do arithmetic with
* unsigned ints.
*/
- CGFloat X = (CGFloat)x;
- CGFloat Y = (CGFloat)y;
- CGFloat Width = (CGFloat)width;
- CGFloat Height = (CGFloat)height;
- CGFloat XOff = (CGFloat)macWin->winPtr->wmInfoPtr->xInParent;
- CGFloat YOff = (CGFloat)macWin->winPtr->wmInfoPtr->yInParent;
- NSRect r = NSMakeRect(X + XOff,
- tkMacOSXZeroScreenHeight - Y - YOff - Height,
- Width, Height);
+ CGFloat X = (CGFloat) x;
+ CGFloat Y = (CGFloat) y;
+ CGFloat Width = (CGFloat) width;
+ CGFloat Height = (CGFloat) height;
+ CGFloat XOff = (CGFloat) macWin->winPtr->wmInfoPtr->xInParent;
+ CGFloat YOff = (CGFloat) macWin->winPtr->wmInfoPtr->yInParent;
+ NSRect r = NSMakeRect(
+ X + XOff, TkMacOSXZeroScreenHeight() - Y - YOff - Height,
+ Width, Height);
+
[w setFrame:[w frameRectForContentRect:r] display:YES];
}
} else {
MoveResizeWindow(macWin);
}
+ return Success;
}
/*
@@ -430,8 +443,7 @@ XMoveResizeWindow(
*
* XMoveWindow --
*
- * Move a given X window. See X windows documentation for further
- * details.
+ * Move a given X window. See X windows documentation for further details.
*
* Results:
* None.
@@ -442,7 +454,7 @@ XMoveResizeWindow(
*----------------------------------------------------------------------
*/
-void
+int
XMoveWindow(
Display *display, /* Display. */
Window window, /* Window. */
@@ -453,12 +465,15 @@ XMoveWindow(
display->request++;
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
NSWindow *w = macWin->winPtr->wmInfoPtr->window;
+
if (w) {
- [w setFrameTopLeftPoint:NSMakePoint(x, tkMacOSXZeroScreenHeight - y)];
+ [w setFrameTopLeftPoint: NSMakePoint(
+ x, TkMacOSXZeroScreenHeight() - y)];
}
} else {
MoveResizeWindow(macWin);
}
+ return Success;
}
/*
@@ -495,7 +510,6 @@ MoveResizeWindow(
if (contWinPtr) {
macParent = contWinPtr->privatePtr;
} else {
-
/*
* Here we should handle out of process embedding. At this point,
* we are assuming that the changes.x,y is not maintained, if you
@@ -504,7 +518,6 @@ MoveResizeWindow(
*/
}
} else {
-
/*
* TODO: update all xOff & yOffs
*/
@@ -585,7 +598,7 @@ GenerateConfigureNotify(
*----------------------------------------------------------------------
*/
-void
+int
XRaiseWindow(
Display *display, /* Display. */
Window window) /* Window. */
@@ -596,14 +609,13 @@ XRaiseWindow(
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
TkWmRestackToplevel(macWin->winPtr, Above, NULL);
} else {
-
/*
* TODO: this should generate damage
*/
}
+ return Success;
}
-#if 0
/*
*----------------------------------------------------------------------
*
@@ -620,7 +632,7 @@ XRaiseWindow(
*----------------------------------------------------------------------
*/
-void
+int
XLowerWindow(
Display *display, /* Display. */
Window window) /* Window. */
@@ -631,13 +643,12 @@ XLowerWindow(
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
TkWmRestackToplevel(macWin->winPtr, Below, NULL);
} else {
-
- /*
+ /*
* TODO: this should generate damage
*/
}
+ return Success;
}
-#endif
/*
*----------------------------------------------------------------------
@@ -657,7 +668,7 @@ XLowerWindow(
*----------------------------------------------------------------------
*/
-void
+int
XConfigureWindow(
Display *display, /* Display. */
Window w, /* Window. */
@@ -666,6 +677,7 @@ XConfigureWindow(
{
MacDrawable *macWin = (MacDrawable *) w;
TkWindow *winPtr = macWin->winPtr;
+ (void)values;
display->request++;
@@ -694,14 +706,17 @@ XConfigureWindow(
TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr);
TkMacOSXWinBounds(winPtr, &bounds);
r = NSMakeRect(bounds.left,
- [view bounds].size.height - bounds.bottom,
- bounds.right - bounds.left, bounds.bottom - bounds.top);
+ [view bounds].size.height - bounds.bottom,
+ bounds.right - bounds.left, bounds.bottom - bounds.top);
[view setNeedsDisplayInRect:r];
}
}
- /* TkGenWMMoveRequestEvent(macWin->winPtr,
- macWin->winPtr->changes.x, macWin->winPtr->changes.y); */
+#if 0
+ TkGenWMMoveRequestEvent(macWin->winPtr,
+ macWin->winPtr->changes.x, macWin->winPtr->changes.y);
+#endif
+ return Success;
}
/*
@@ -723,14 +738,14 @@ XConfigureWindow(
void
TkMacOSXSetDrawingEnabled(
- TkWindow *winPtr,
- int flag)
+ TkWindow *winPtr,
+ int flag)
{
TkWindow *childPtr;
MacDrawable *macWin = winPtr->privatePtr;
if (macWin) {
- if (flag ) {
+ if (flag) {
macWin->flags &= ~TK_DO_NOT_DRAW;
} else {
macWin->flags |= TK_DO_NOT_DRAW;
@@ -738,8 +753,8 @@ TkMacOSXSetDrawingEnabled(
}
/*
- * Set the flag for all children & their descendants, excluding
- * Toplevels. (??? Do we need to exclude Toplevels?)
+ * Set the flag for all children & their descendants, excluding Toplevels.
+ * (??? Do we need to exclude Toplevels?)
*/
childPtr = winPtr->childList;
@@ -842,7 +857,7 @@ TkMacOSXUpdateClipRgn(
ChkErr(HIShapeIntersect,
win2Ptr->privatePtr->aboveVisRgn, rgn, rgn);
} else if (tkMacOSXEmbedHandler != NULL) {
- TkRegion r = TkCreateRegion();
+ Region r = XCreateRegion();
HIShapeRef visRgn;
tkMacOSXEmbedHandler->getClipProc((Tk_Window) winPtr, r);
@@ -903,7 +918,6 @@ TkMacOSXUpdateClipRgn(
}
CFRelease(rgn);
} else {
-
/*
* An unmapped window has empty clip regions to prevent any
* (erroneous) drawing into it or its children from becoming
@@ -933,8 +947,8 @@ TkMacOSXUpdateClipRgn(
* TkMacOSXVisableClipRgn --
*
* This function returns the Macintosh clipping region for the given
- * window. The caller is responsible for disposing of the returned
- * region via TkDestroyRegion().
+ * window. The caller is responsible for disposing of the returned region
+ * via XDestroyRegion().
*
* Results:
* The region.
@@ -945,14 +959,14 @@ TkMacOSXUpdateClipRgn(
*----------------------------------------------------------------------
*/
-TkRegion
+Region
TkMacOSXVisableClipRgn(
TkWindow *winPtr)
{
if (winPtr->privatePtr->flags & TK_CLIP_INVALID) {
TkMacOSXUpdateClipRgn(winPtr);
}
- return (TkRegion)HIShapeCreateMutableCopy(winPtr->privatePtr->visRgn);
+ return (Region) HIShapeCreateMutableCopy(winPtr->privatePtr->visRgn);
}
/*
@@ -972,9 +986,15 @@ TkMacOSXVisableClipRgn(
*/
static OSStatus
-InvalViewRect(int msg, HIShapeRef rgn, const CGRect *rect, void *ref) {
+InvalViewRect(
+ int msg,
+ HIShapeRef rgn,
+ const CGRect *rect,
+ void *ref)
+{
static CGAffineTransform t;
NSView *view = ref;
+ (void)rgn;
if (!view) {
return paramErr;
@@ -1052,7 +1072,7 @@ TkMacOSXInvalidateWindow(
*----------------------------------------------------------------------
*/
-NSWindow*
+NSWindow *
TkMacOSXDrawableWindow(
Drawable drawable)
{
@@ -1070,6 +1090,7 @@ TkMacOSXDrawableWindow(
result = macWin->winPtr->wmInfoPtr->window;
} else if (macWin->toplevel && (macWin->toplevel->flags & TK_EMBEDDED)) {
TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
+
if (contWinPtr) {
result = TkMacOSXDrawableWindow((Drawable) contWinPtr->privatePtr);
}
@@ -1104,6 +1125,8 @@ void *
TkMacOSXGetDrawablePort(
Drawable drawable)
{
+ (void)drawable;
+
return NULL;
}
@@ -1123,7 +1146,7 @@ TkMacOSXGetDrawablePort(
*----------------------------------------------------------------------
*/
-NSView*
+NSView *
TkMacOSXDrawableView(
MacDrawable *macWin)
{
@@ -1137,6 +1160,7 @@ TkMacOSXDrawableView(
result = macWin->toplevel->view;
} else {
TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
+
if (contWinPtr) {
result = TkMacOSXDrawableView(contWinPtr->privatePtr);
}
@@ -1164,7 +1188,6 @@ void *
TkMacOSXGetRootControl(
Drawable drawable)
{
-
/*
* will probably need to fix this up for embedding
*/
@@ -1281,7 +1304,8 @@ TkMacOSXWinBounds(
TkWindow *winPtr,
void *bounds)
{
- Rect *b = (Rect *)bounds;
+ Rect *b = (Rect *) bounds;
+
b->left = winPtr->privatePtr->xOff;
b->top = winPtr->privatePtr->yOff;
b->right = b->left + winPtr->changes.width;
@@ -1345,7 +1369,6 @@ UpdateOffsets(
TkWindow *childPtr;
if (winPtr->privatePtr == NULL) {
-
/*
* We haven't called Tk_MakeWindowExist for this window yet. The offset
* information will be postponed and calulated at that time. (This will
@@ -1404,11 +1427,12 @@ Tk_GetPixmap(
int depth) /* Bits per pixel for pixmap. */
{
MacDrawable *macPix;
+ (void)d;
if (display != NULL) {
display->request++;
}
- macPix = ckalloc(sizeof(MacDrawable));
+ macPix = (MacDrawable *)ckalloc(sizeof(MacDrawable));
macPix->winPtr = NULL;
macPix->xOff = 0;
macPix->yOff = 0;
diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c
index b7923b0..2d22824 100644
--- a/macosx/tkMacOSXTest.c
+++ b/macosx/tkMacOSXTest.c
@@ -13,13 +13,21 @@
*/
#include "tkMacOSXPrivate.h"
+#include "tkMacOSXConstants.h"
/*
* Forward declarations of procedures defined later in this file:
*/
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080
static int DebuggerObjCmd (ClientData dummy, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ int objc, Tcl_Obj *const objv[]);
+#endif
+static int PressButtonObjCmd (ClientData dummy, Tcl_Interp *interp,
+ int objc, Tcl_Obj *const objv[]);
+static int InjectKeyEventObjCmd (ClientData dummy, Tcl_Interp *interp,
+ int objc, Tcl_Obj *const objv[]);
+
/*
*----------------------------------------------------------------------
@@ -46,8 +54,11 @@ TkplatformtestInit(
* Add commands for platform specific tests on MacOS here.
*/
- Tcl_CreateObjCommand(interp, "debugger", DebuggerObjCmd,
- (ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080
+ Tcl_CreateObjCommand(interp, "debugger", DebuggerObjCmd, NULL, NULL);
+#endif
+ Tcl_CreateObjCommand(interp, "pressbutton", PressButtonObjCmd, NULL, NULL);
+ Tcl_CreateObjCommand(interp, "injectkeyevent", InjectKeyEventObjCmd, NULL, NULL);
return TCL_OK;
}
@@ -57,7 +68,8 @@ TkplatformtestInit(
*
* DebuggerObjCmd --
*
- * This procedure simply calls the low level debugger.
+ * This procedure simply calls the low level debugger, which was
+ * deprecated in OSX 10.8.
*
* Results:
* A standard Tcl result.
@@ -68,6 +80,7 @@ TkplatformtestInit(
*----------------------------------------------------------------------
*/
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080
static int
DebuggerObjCmd(
ClientData clientData, /* Not used. */
@@ -78,22 +91,26 @@ DebuggerObjCmd(
Debugger();
return TCL_OK;
}
+#endif
/*
*----------------------------------------------------------------------
*
- * TkTestAppIsDrawing --
- *
- * A test widget display procedure which records calls can use this to
- * detect whether it is being called from within [NSView drawRect].
- * If so, it probably should not be recording the call since it was
- * probably generated spontaneously by the window manager rather than
- * by an explicit call to update. This is just a wrapper for the NSApp
- * property.
+ * TkTestLogDisplay --
*
+ * The test image display procedure calls this to determine whether it
+ * should write a log message recording that it has being run. On OSX
+ * 10.14 and later, only calls to the display procedure which occur inside
+ * of the drawRect method should be logged, since those are the only ones
+ * which actually draw anything. On earlier systems the opposite is true.
+ * The calls from within the drawRect method are redundant, since the
+ * first time the display procedure is run it will do the drawing and that
+ * first call will usually not occur inside of drawRect.
*
* Results:
- * Returns true if and only if called from within [NSView drawRect].
+ * On OSX 10.14 and later, returns true if and only if called from
+ * within [NSView drawRect]. On earlier systems returns false if
+ * and only if called from with [NSView drawRect].
*
* Side effects:
* None
@@ -101,11 +118,219 @@ DebuggerObjCmd(
*----------------------------------------------------------------------
*/
MODULE_SCOPE Bool
-TkTestAppIsDrawing(void) {
- return [NSApp isDrawing];
+TkTestLogDisplay(void) {
+ if ([NSApp macMinorVersion] >= 14) {
+ return [NSApp isDrawing];
+ } else {
+ return ![NSApp isDrawing];
+ }
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * PressButtonObjCmd --
+ *
+ * This Tcl command simulates a button press at a specific screen
+ * location. It injects NSEvents into the NSApplication event queue,
+ * as opposed to adding events to the Tcl queue as event generate
+ * would do. One application is for testing the grab command.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+PressButtonObjCmd(
+ ClientData dummy,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *const objv[])
+{
+ int x = 0, y = 0, i, value, wNum;
+ CGPoint pt;
+ NSPoint loc;
+ NSEvent *motion, *press, *release;
+ NSArray *screens = [NSScreen screens];
+ CGFloat ScreenHeight = 0;
+ enum {X=1, Y};
+ (void)dummy;
+ if (screens && [screens count]) {
+ ScreenHeight = [[screens objectAtIndex:0] frame].size.height;
+ }
+
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "x y");
+ return TCL_ERROR;
+ }
+ for (i = 1; i < objc; i++) {
+ if (Tcl_GetIntFromObj(interp,objv[i],&value) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ switch (i) {
+ case X:
+ x = value;
+ break;
+ case Y:
+ y = value;
+ break;
+ default:
+ break;
+ }
+ }
+ pt.x = loc.x = x;
+ pt.y = y;
+ loc.y = ScreenHeight - y;
+ wNum = 0;
+ CGWarpMouseCursorPosition(pt);
+ motion = [NSEvent mouseEventWithType:NSMouseMoved
+ location:loc
+ modifierFlags:0
+ timestamp:GetCurrentEventTime()
+ windowNumber:wNum
+ context:nil
+ eventNumber:0
+ clickCount:1
+ pressure:0.0];
+ [NSApp postEvent:motion atStart:NO];
+ press = [NSEvent mouseEventWithType:NSLeftMouseDown
+ location:loc
+ modifierFlags:0
+ timestamp:GetCurrentEventTime()
+ windowNumber:wNum
+ context:nil
+ eventNumber:1
+ clickCount:1
+ pressure:0.0];
+ [NSApp postEvent:press atStart:NO];
+ release = [NSEvent mouseEventWithType:NSLeftMouseUp
+ location:loc
+ modifierFlags:0
+ timestamp:GetCurrentEventTime()
+ windowNumber:wNum
+ context:nil
+ eventNumber:2
+ clickCount:1
+ pressure:0.0];
+ [NSApp postEvent:release atStart:NO];
+ return TCL_OK;
+}
+
+static int
+InjectKeyEventObjCmd(
+ ClientData dummy,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *const objv[])
+{
+ static const char *const optionStrings[] = {
+ "press", "release", "flagschanged", NULL};
+ NSUInteger types[3] = {NSKeyDown, NSKeyUp, NSFlagsChanged};
+ static const char *const argStrings[] = {
+ "-shift", "-control", "-option", "-command", "-function", "-x", "-y", NULL};
+ enum args {KEYEVENT_SHIFT, KEYEVENT_CONTROL, KEYEVENT_OPTION, KEYEVENT_COMMAND,
+ KEYEVENT_FUNCTION, KEYEVENT_X, KEYEVENT_Y};
+ int i, index, keysym, mods = 0, x = 0, y = 0;
+ NSString *chars = nil, *unmod = nil, *upper, *lower;
+ NSEvent *keyEvent;
+ NSUInteger type;
+ MacKeycode macKC;
+ (void)dummy;
+
+ if (objc < 3) {
+ wrongArgs:
+ Tcl_WrongNumArgs(interp, 1, objv, "option keysym ?arg?");
+ return TCL_ERROR;
+ }
+ if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
+ &index) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ type = types[index];
+ if (Tcl_GetIntFromObj(interp, objv[2], &keysym) != TCL_OK) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "keysym must be an integer"));
+ Tcl_SetErrorCode(interp, "TK", "TEST", "INJECT", "KEYSYM", NULL);
+ return TCL_ERROR;
+ }
+ macKC.uint = XKeysymToKeycode(NULL, keysym);
+ for (i = 3; i < objc; i++) {
+ if (Tcl_GetIndexFromObjStruct(interp, objv[i], argStrings,
+ sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ switch ((enum args) index) {
+ case KEYEVENT_SHIFT:
+ mods |= NSShiftKeyMask;
+ break;
+ case KEYEVENT_CONTROL:
+ mods |= NSControlKeyMask;
+ break;
+ case KEYEVENT_OPTION:
+ mods |= NSAlternateKeyMask;
+ break;
+ case KEYEVENT_COMMAND:
+ mods |= NSCommandKeyMask;
+ break;
+ case KEYEVENT_FUNCTION:
+ mods |= NSFunctionKeyMask;
+ break;
+ case KEYEVENT_X:
+ if (++i >= objc) {
+ goto wrongArgs;
+ }
+ if (Tcl_GetIntFromObj(interp,objv[i], &x) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ break;
+ case KEYEVENT_Y:
+ if (++i >= objc) {
+ goto wrongArgs;
+ }
+ if (Tcl_GetIntFromObj(interp,objv[i], &y) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ break;
+ }
+ }
+ if (type != NSFlagsChanged) {
+ UniChar keychar = macKC.v.keychar;
+ chars = [[NSString alloc] initWithCharacters: &keychar length:1];
+ upper = [chars uppercaseString];
+ lower = [chars lowercaseString];
+ if (![upper isEqual: lower] && [chars isEqual: upper]) {
+ mods |= NSShiftKeyMask;
+ }
+ if (mods & NSShiftKeyMask) {
+ chars = upper;
+ unmod = lower;
+ macKC.v.o_s |= INDEX_SHIFT;
+ } else {
+ unmod = chars;
+ }
+ if (macKC.v.o_s & INDEX_OPTION) {
+ mods |= NSAlternateKeyMask;
+ }
+ }
+ keyEvent = [NSEvent keyEventWithType:type
+ location:NSMakePoint(x, y)
+ modifierFlags:mods
+ timestamp:GetCurrentEventTime()
+ windowNumber:0
+ context:nil
+ characters:chars
+ charactersIgnoringModifiers:unmod
+ isARepeat:NO
+ keyCode:macKC.v.virtual];
+ [NSApp postEvent:keyEvent atStart:NO];
+ return TCL_OK;
+}
/*
* Local Variables:
* mode: objc
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 212381e..71e687b 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -15,7 +15,7 @@
#include "tkMacOSXPrivate.h"
#include "tkMacOSXWm.h"
-#include "tkMacOSXEvent.h"
+#include "tkMacOSXInt.h"
#include "tkMacOSXDebug.h"
#include "tkMacOSXConstants.h"
@@ -68,7 +68,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
BOOL movedOnly = [[notification name]
- isEqualToString:NSWindowDidMoveNotification];
+ isEqualToString:NSWindowDidMoveNotification];
NSWindow *w = [notification object];
TkWindow *winPtr = TkMacOSXGetTkWindow(w);
@@ -78,7 +78,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
int x, y, width = -1, height = -1, flags = 0;
x = bounds.origin.x;
- y = tkMacOSXZeroScreenHeight - (bounds.origin.y + bounds.size.height);
+ y = TkMacOSXZeroScreenHeight() - (bounds.origin.y + bounds.size.height);
if (winPtr->changes.x != x || winPtr->changes.y != y) {
flags |= TK_LOCATION_CHANGED;
} else {
@@ -91,7 +91,6 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
flags |= TK_SIZE_CHANGED;
}
if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) {
-
/*
* Propagate geometry changes immediately.
*/
@@ -140,11 +139,12 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
- (NSRect)windowWillUseStandardFrame:(NSWindow *)window
defaultFrame:(NSRect)newFrame
{
+ (void)window;
/*
- * This method needs to be implemented in order for [NSWindow isZoomed]
- * to give the correct answer. But it suffices to always validate
- * every request.
+ * This method needs to be implemented in order for [NSWindow isZoomed] to
+ * give the correct answer. But it suffices to always validate every
+ * request.
*/
return newFrame;
@@ -153,13 +153,13 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
- (NSSize)window:(NSWindow *)window
willUseFullScreenContentSize:(NSSize)proposedSize
{
-
+ (void)window;
/*
- * We don't need to change the proposed size, but we do need to
- * implement this method. Otherwise the full screen window will
- * be sized to the screen's visibleFrame, leaving black bands at
- * the top and bottom.
+ * We don't need to change the proposed size, but we do need to implement
+ * this method. Otherwise the full screen window will be sized to the
+ * screen's visibleFrame, leaving black bands at the top and bottom.
*/
+
return proposedSize;
}
@@ -201,21 +201,16 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
if (winPtr) {
TkGenWMDestroyEvent((Tk_Window) winPtr);
- if (_windowWithMouse == w) {
- _windowWithMouse = nil;
- [w release];
- }
}
/*
- * If necessary, TkGenWMDestroyEvent() handles [close]ing the window,
- * so can always return NO from -windowShouldClose: for a Tk window.
+ * If necessary, TkGenWMDestroyEvent() handles [close]ing the window, so
+ * can always return NO from -windowShouldClose: for a Tk window.
*/
return (winPtr ? NO : YES);
}
-
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
- (void) windowDragStart: (NSNotification *) notification
@@ -256,7 +251,6 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
}
}
-
#endif /* TK_MAC_DEBUG_NOTIFICATIONS */
- (void) _setupWindowNotifications
@@ -297,22 +291,59 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
- (void) applicationActivate: (NSNotification *) notification
{
+ (void)notification;
+
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
[NSApp tkCheckPasteboard];
+
+ /*
+ * When the application is activated with Command-Tab it will create a
+ * zombie window for every Tk window which has been withdrawn. So iterate
+ * through the list of windows and order out any withdrawn window.
+ */
+
+ for (NSWindow *win in [NSApp windows]) {
+ TkWindow *winPtr = TkMacOSXGetTkWindow(win);
+ if (!winPtr || !winPtr->wmInfoPtr) {
+ continue;
+ }
+ if (winPtr->wmInfoPtr->hints.initial_state == WithdrawnState) {
+ [win orderOut:nil];
+ }
+ }
}
- (void) applicationDeactivate: (NSNotification *) notification
{
+ (void)notification;
+
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
+
+ /*
+ * To prevent zombie windows on systems with a TouchBar, set the key window
+ * to nil if the current key window is not visible. This allows a closed
+ * Help or About window to be deallocated so it will not reappear as a
+ * zombie when the app is reactivated.
+ */
+
+ NSWindow *keywindow = [NSApp keyWindow];
+ if (keywindow && ![keywindow isVisible]) {
+ [NSApp _setKeyWindow:nil];
+ [NSApp _setMainWindow:nil];
+ }
+
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender
hasVisibleWindows:(BOOL)flag
{
+ (void)sender;
+ (void)flag;
+
/*
* Allowing the default response means that withdrawn windows will get
* displayed on the screen with unresponsive title buttons. We don't
@@ -345,6 +376,8 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
- (void) displayChanged: (NSNotification *) notification
{
+ (void)notification;
+
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
@@ -363,11 +396,11 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
*
* TkpAppIsDrawing --
*
- * A widget display procedure can call this to determine whether it
- * is being run inside of the drawRect method. This is needed for
- * some tests, especially of the Text widget, which record data in
- * a global Tcl variable and assume that display procedures will be
- * run in a predictable sequence as Tcl idle tasks.
+ * A widget display procedure can call this to determine whether it is
+ * being run inside of the drawRect method. This is needed for some tests,
+ * especially of the Text widget, which record data in a global Tcl
+ * variable and assume that display procedures will be run in a
+ * predictable sequence as Tcl idle tasks.
*
* Results:
* True only while running the drawRect method of a TKContentView;
@@ -377,11 +410,11 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
*
*----------------------------------------------------------------------
*/
+
MODULE_SCOPE Bool
TkpAppIsDrawing(void) {
return [NSApp isDrawing];
}
-
/*
*----------------------------------------------------------------------
@@ -670,12 +703,10 @@ TkGenWMConfigureEvent(
if ((flags & TK_SIZE_CHANGED) && !(wmPtr->flags & WM_SYNC_PENDING) &&
((width != Tk_Width(tkwin)) || (height != Tk_Height(tkwin)))) {
if ((wmPtr->width == -1) && (width == winPtr->reqWidth)) {
-
/*
* Don't set external width, since the user didn't change it
* from what the widgets asked for.
*/
-
} else if (wmPtr->gridWin != NULL) {
wmPtr->width = wmPtr->reqGridWidth
+ (width - winPtr->reqWidth)/wmPtr->widthInc;
@@ -687,12 +718,10 @@ TkGenWMConfigureEvent(
}
if ((wmPtr->height == -1) && (height == winPtr->reqHeight)) {
-
/*
* Don't set external height, since the user didn't change it
* from what the widgets asked for.
*/
-
} else if (wmPtr->gridWin != NULL) {
wmPtr->height = wmPtr->reqGridHeight
+ (height - winPtr->reqHeight)/wmPtr->heightInc;
@@ -708,7 +737,6 @@ TkGenWMConfigureEvent(
}
}
-
/*
* Now set up the changes structure. Under X we wait for the
* ConfigureNotify to set these values. On the Mac we know imediatly that
@@ -866,7 +894,10 @@ Tk_MacOSXIsAppInFront(void)
*
*/
-/*Restrict event processing to Expose events.*/
+/*
+ * Restrict event processing to Expose events.
+ */
+
static Tk_RestrictAction
ExposeRestrictProc(
ClientData arg,
@@ -876,21 +907,50 @@ ExposeRestrictProc(
? TK_PROCESS_EVENT : TK_DEFER_EVENT);
}
-/*Restrict event processing to ConfigureNotify events.*/
+/*
+ * Restrict event processing to ConfigureNotify events.
+ */
+
static Tk_RestrictAction
ConfigureRestrictProc(
- ClientData arg,
+ TCL_UNUSED(void *),
XEvent *eventPtr)
{
return (eventPtr->type==ConfigureNotify ? TK_PROCESS_EVENT : TK_DEFER_EVENT);
}
+/*
+ * If a window gets mapped inside the drawRect method, this will be run as an
+ * idle task, after drawRect returns, to clean up the mess.
+ */
+
+static void
+RedisplayView(
+ ClientData clientdata)
+{
+ NSView *view = (NSView *) clientdata;
+
+ /*
+ * Make sure that we are not trying to displaying a view that no longer
+ * exists. Must call [NSApp windows] because [NSApp orderedWindows] excludes
+ * floating/utility windows and other window panels.
+ */
+
+ for (NSWindow *w in [NSApp windows]) {
+ if ([w contentView] == view) {
+ [view setNeedsDisplay:YES];
+ break;
+ }
+ }
+}
+
@implementation TKContentView(TKWindowEvent)
- (void) drawRect: (NSRect) rect
{
const NSRect *rectsBeingDrawn;
NSInteger rectsBeingDrawnCount;
+ (void)rect;
#ifdef TK_MAC_DEBUG_DRAWING
TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
@@ -899,8 +959,8 @@ ConfigureRestrictProc(
#endif
/*
- * We do not allow recursive calls to drawRect, but we only log
- * them on OSX > 10.13, where they should never happen.
+ * We do not allow recursive calls to drawRect, but we only log them on OSX
+ * > 10.13, where they should never happen.
*/
if ([NSApp isDrawing]) {
@@ -931,6 +991,11 @@ ConfigureRestrictProc(
CFRelease(drawShape);
[NSApp setIsDrawing: NO];
+ if ([self needsRedisplay]) {
+ [self setNeedsRedisplay:NO];
+ Tcl_DoWhenIdle(RedisplayView, self);
+ }
+
#ifdef TK_MAC_DEBUG_DRAWING
fprintf(stderr, "drawRect: done.\n");
#endif
@@ -955,9 +1020,9 @@ ConfigureRestrictProc(
Tk_RestrictProc *oldProc;
/*
- * This can be called from outside the Tk event loop.
- * Since it calls Tcl_DoOneEvent, we need to make sure we
- * don't clobber the AutoreleasePool set up by the caller.
+ * This can be called from outside the Tk event loop. Since it calls
+ * Tcl_DoOneEvent, we need to make sure we don't clobber the
+ * AutoreleasePool set up by the caller.
*/
[NSApp _lockAutoreleasePool];
@@ -973,7 +1038,7 @@ ConfigureRestrictProc(
*/
TkGenWMConfigureEvent(tkwin, Tk_X(tkwin), Tk_Y(tkwin), width, height,
- TK_SIZE_CHANGED | TK_MACOSX_HANDLE_EVENT_IMMEDIATELY);
+ TK_SIZE_CHANGED | TK_MACOSX_HANDLE_EVENT_IMMEDIATELY);
oldProc = Tk_RestrictEvents(ConfigureRestrictProc, NULL, &oldArg);
Tk_RestrictEvents(oldProc, oldArg, &oldArg);
@@ -1061,16 +1126,15 @@ ConfigureRestrictProc(
}
/*
- * This method is called when a user changes between light and dark mode.
- * The implementation here generates a Tk virtual event which can be bound
- * to a function that redraws the window in an appropriate style.
+ * This method is called when a user changes between light and dark mode. The
+ * implementation here generates a Tk virtual event which can be bound to a
+ * function that redraws the window in an appropriate style.
*/
- (void) viewDidChangeEffectiveAppearance
{
XVirtualEvent event;
int x, y;
- NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
NSWindow *w = [self window];
TkWindow *winPtr = TkMacOSXGetTkWindow(w);
Tk_Window tkwin = (Tk_Window) winPtr;
@@ -1091,21 +1155,17 @@ ConfigureRestrictProc(
&event.x_root, &event.y_root, &x, &y, &event.state);
Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y);
event.same_screen = true;
- if (osxMode == nil) {
- event.name = Tk_GetUid("LightAqua");
- Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
- return;
- }
- if ([osxMode isEqual:@"Dark"]) {
+ if (TkMacOSXInDarkMode(tkwin)) {
event.name = Tk_GetUid("DarkAqua");
- Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
- return;
+ } else {
+ event.name = Tk_GetUid("LightAqua");
}
+ Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
}
/*
- * This is no-op on 10.7 and up because Apple has removed this widget,
- * but we are leaving it here for backwards compatibility.
+ * This is no-op on 10.7 and up because Apple has removed this widget, but we
+ * are leaving it here for backwards compatibility.
*/
- (void) tkToolbarButton: (id) sender
@@ -1117,6 +1177,8 @@ ConfigureRestrictProc(
int x, y;
TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
Tk_Window tkwin = (Tk_Window) winPtr;
+ (void)sender;
+
if (!winPtr){
return;
}
@@ -1154,13 +1216,36 @@ ConfigureRestrictProc(
return YES;
}
+/*
+ * This keyDown method does nothing, which is a huge improvement over the
+ * default keyDown method which beeps every time a key is pressed.
+ */
+
- (void) keyDown: (NSEvent *) theEvent
{
+ (void)theEvent;
#ifdef TK_MAC_DEBUG_EVENTS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
#endif
}
+/*
+ * When the services menu is opened this is called for each Responder in
+ * the Responder chain until a service provider is found. The TkContentView
+ * should be the first (and generally only) Responder in the chain. We
+ * return the TkServices object that was created in TkpInit.
+ */
+
+- (id)validRequestorForSendType:(NSString *)sendType
+ returnType:(NSString *)returnType
+{
+ if ([sendType isEqualToString:@"NSStringPboardType"] ||
+ [sendType isEqualToString:@"NSPasteboardTypeString"]) {
+ return [NSApp servicesProvider];
+ }
+ return [super validRequestorForSendType:sendType returnType:returnType];
+}
+
@end
/*
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index a607ae5..f24b8d4 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -3,14 +3,13 @@
*
* This module takes care of the interactions between a Tk-based
* application and the window manager. Among other things, it implements
- * the "wm" command and passes geometry information to the window
- * manager.
+ * the "wm" command and passes geometry information to the window manager.
*
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
* Copyright (c) 2010 Kevin Walzer/WordTech Communications LLC.
- * Copyright (c) 2017-2018 Marc Culler.
+ * Copyright (c) 2017-2019 Marc Culler.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -19,10 +18,16 @@
#include "tkMacOSXPrivate.h"
#include "tkScrollbar.h"
#include "tkMacOSXWm.h"
-#include "tkMacOSXEvent.h"
+#include "tkMacOSXInt.h"
#include "tkMacOSXDebug.h"
#include "tkMacOSXConstants.h"
+/*
+ * Setting this to 1 prints when each window is freed, setting it to 2 adds
+ * dumps of the autorelease pools, and setting it to 3 also shows each retain
+ * and release.
+ */
+
#define DEBUG_ZOMBIES 0
/*
@@ -55,7 +60,6 @@
| tkCanJoinAllSpacesAttribute | tkMoveToActiveSpaceAttribute \
| tkNonactivatingPanelAttribute | tkHUDWindowAttribute)
-
static const struct {
const UInt64 validAttrs, defaultAttrs, forceOnAttrs, forceOffAttrs;
int flags; NSUInteger styleMask;
@@ -311,6 +315,8 @@ static int WmWinStyle(Tcl_Interp *interp, TkWindow *winPtr,
int objc, Tcl_Obj *const objv[]);
static int WmWinTabbingId(Tcl_Interp *interp, TkWindow *winPtr,
int objc, Tcl_Obj *const objv[]);
+static int WmWinAppearance(Tcl_Interp *interp, TkWindow *winPtr,
+ int objc, Tcl_Obj *const objv[]);
static void ApplyWindowAttributeFlagChanges(TkWindow *winPtr,
NSWindow *macWindow, UInt64 oldAttributes,
int oldFlags, int create, int initial);
@@ -340,18 +346,12 @@ static void RemoveTransient(TkWindow *winPtr);
#else
- (NSPoint) tkConvertPointToScreen: (NSPoint) point
{
- NSRect pointrect;
- pointrect.origin = point;
- pointrect.size.width = 0;
- pointrect.size.height = 0;
+ NSRect pointrect = {point, {0,0}};
return [self convertRectToScreen:pointrect].origin;
}
- (NSPoint) tkConvertPointFromScreen: (NSPoint)point
{
- NSRect pointrect;
- pointrect.origin = point;
- pointrect.size.width = 0;
- pointrect.size.height = 0;
+ NSRect pointrect = {point, {0,0}};
return [self convertRectFromScreen:pointrect].origin;
}
#endif
@@ -363,7 +363,6 @@ static void RemoveTransient(TkWindow *winPtr);
#pragma mark TKWindow(TKWm)
@implementation TKWindow: NSWindow
-
@end
@implementation TKWindow(TKWm)
@@ -391,11 +390,13 @@ static void RemoveTransient(TkWindow *winPtr);
if ([self styleMask] & NSFullScreenWindowMask) {
frameRect = [NSWindow frameRectForContentRect:NSZeroRect
- styleMask:[self styleMask]];
+ styleMask:[self styleMask]];
} else {
frameRect = [self frameRectForContentRect:NSZeroRect];
}
+
WmInfo *wmPtr = winPtr->wmInfoPtr;
+
wmPtr->xInParent = -frameRect.origin.x;
wmPtr->yInParent = frameRect.origin.y + frameRect.size.height;
wmPtr->parentWidth = winPtr->changes.width + frameRect.size.width;
@@ -434,7 +435,8 @@ static void RemoveTransient(TkWindow *winPtr);
- (BOOL) canBecomeKeyWindow
{
TkWindow *winPtr = TkMacOSXGetTkWindow(self);
- if (!winPtr) {
+
+ if (!winPtr || !winPtr->wmInfoPtr) {
return NO;
}
return (winPtr->wmInfoPtr &&
@@ -451,7 +453,7 @@ static void RemoveTransient(TkWindow *winPtr);
if (title == nil) {
title = "unnamed window";
}
- if (DEBUG_ZOMBIES > 1){
+ if (DEBUG_ZOMBIES > 2) {
fprintf(stderr, "Retained <%s>. Count is: %lu\n",
title, [self retainCount]);
}
@@ -465,7 +467,7 @@ static void RemoveTransient(TkWindow *winPtr);
if (title == nil) {
title = "unnamed window";
}
- if (DEBUG_ZOMBIES > 1){
+ if (DEBUG_ZOMBIES > 2) {
fprintf(stderr, "Autoreleased <%s>. Count is %lu\n",
title, [self retainCount]);
}
@@ -477,7 +479,7 @@ static void RemoveTransient(TkWindow *winPtr);
if (title == nil) {
title = "unnamed window";
}
- if (DEBUG_ZOMBIES > 1){
+ if (DEBUG_ZOMBIES > 2) {
fprintf(stderr, "Releasing <%s>. Count is %lu\n",
title, [self retainCount]);
}
@@ -489,14 +491,13 @@ static void RemoveTransient(TkWindow *winPtr);
if (title == nil) {
title = "unnamed window";
}
- if (DEBUG_ZOMBIES > 0){
+ if (DEBUG_ZOMBIES > 0) {
fprintf(stderr, ">>>> Freeing <%s>. Count is %lu\n",
title, [self retainCount]);
}
[super dealloc];
}
-
#endif
@end
@@ -612,7 +613,7 @@ FrontWindowAtPoint(
int x,
int y)
{
- NSPoint p = NSMakePoint(x, tkMacOSXZeroScreenHeight - y);
+ NSPoint p = NSMakePoint(x, TkMacOSXZeroScreenHeight() - y);
NSArray *windows = [NSApp orderedWindows];
TkWindow *winPtr = NULL;
@@ -622,7 +623,8 @@ FrontWindowAtPoint(
WmInfo *wmPtr = winPtr->wmInfoPtr;
NSRect windowFrame = [w frame];
NSRect contentFrame = [w frame];
- contentFrame.size.height = [[w contentView] frame].size.height;
+
+ contentFrame.size.height = [[w contentView] frame].size.height;
/*
* For consistency with other platforms, points in the
* title bar are not considered to be contained in the
@@ -630,7 +632,7 @@ FrontWindowAtPoint(
*/
if ((wmPtr->hints.initial_state == NormalState ||
- wmPtr->hints.initial_state == ZoomState)) {
+ wmPtr->hints.initial_state == ZoomState)) {
if (NSMouseInRect(p, contentFrame, NO)) {
return winPtr;
} else if (NSMouseInRect(p, windowFrame, NO)) {
@@ -663,7 +665,7 @@ void
TkWmNewWindow(
TkWindow *winPtr) /* Newly-created top-level window. */
{
- WmInfo *wmPtr = ckalloc(sizeof(WmInfo));
+ WmInfo *wmPtr = (WmInfo *)ckalloc(sizeof(WmInfo));
wmPtr->winPtr = winPtr;
wmPtr->reparent = None;
@@ -883,6 +885,7 @@ TkWmDeadWindow(
TkWindow *winPtr) /* Top-level window that's being deleted. */
{
WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2;
+ NSWindow *ourNSWindow;
if (wmPtr == NULL) {
return;
@@ -938,9 +941,10 @@ TkWmDeadWindow(
*/
for (Transient *transientPtr = wmPtr->transientPtr;
- transientPtr != NULL; transientPtr = transientPtr->nextPtr) {
+ transientPtr != NULL; transientPtr = transientPtr->nextPtr) {
TkWindow *winPtr2 = transientPtr->winPtr;
- TkWindow *masterPtr = (TkWindow *)TkGetTransientMaster(winPtr2);
+ TkWindow *masterPtr = (TkWindow *) TkGetTransientMaster(winPtr2);
+
if (masterPtr == winPtr) {
wmPtr2 = winPtr2->wmInfoPtr;
wmPtr2->master = NULL;
@@ -949,77 +953,93 @@ TkWmDeadWindow(
while (wmPtr->transientPtr != NULL) {
Transient *transientPtr = wmPtr->transientPtr;
+
wmPtr->transientPtr = transientPtr->nextPtr;
ckfree(transientPtr);
}
/*
- * Delete the Mac window and remove it from the windowTable. The window
- * could be nil if the window was never mapped. However, we don't do this
- * for embedded windows, they don't go in the window list, and they do not
- * own their portPtr's.
+ * Unregister the NSWindow and remove all references to it from the Tk
+ * data structures. If the NSWindow is a child, disassociate it from
+ * the parent. Then close and release the NSWindow.
*/
- NSWindow *window = wmPtr->window;
+ ourNSWindow = wmPtr->window;
+ if (ourNSWindow && !Tk_IsEmbedded(winPtr)) {
+ NSWindow *parent = [ourNSWindow parentWindow];
+ TkMacOSXUnregisterMacWindow(ourNSWindow);
+ if (winPtr->window) {
+ ((MacDrawable *) winPtr->window)->view = nil;
+ }
+ wmPtr->window = NULL;
- if (window && !Tk_IsEmbedded(winPtr) ) {
- NSWindow *parent = [window parentWindow];
if (parent) {
- [parent removeChildWindow:window];
+ [parent removeChildWindow:ourNSWindow];
}
-#if DEBUG_ZOMBIES > 0
+
+#if DEBUG_ZOMBIES > 1
{
- const char *title = [[window title] UTF8String];
+ const char *title = [[ourNSWindow title] UTF8String];
if (title == nil) {
title = "unnamed window";
}
fprintf(stderr, ">>>> Closing <%s>. Count is: %lu\n", title,
- [window retainCount]);
+ [ourNSWindow retainCount]);
}
#endif
- [window close];
- TkMacOSXUnregisterMacWindow(window);
- if (winPtr->window) {
- ((MacDrawable *) winPtr->window)->view = nil;
- }
- wmPtr->window = NULL;
- [window release];
-
- /* Activate the highest window left on the screen. */
- NSArray *windows = [NSApp orderedWindows];
- for (id nswindow in windows) {
- TkWindow *winPtr2 = TkMacOSXGetTkWindow(nswindow);
- if (winPtr2 && nswindow != window) {
- WmInfo *wmPtr = winPtr2->wmInfoPtr;
- BOOL minimized = (wmPtr->hints.initial_state == IconicState ||
- wmPtr->hints.initial_state == WithdrawnState);
- /*
- * If no windows are left on the screen and the next
- * window is iconified or withdrawn, we don't want to
- * make it be the KeyWindow because that would cause
- * it to be displayed on the screen.
- */
- if ([nswindow canBecomeKeyWindow] && !minimized) {
- [nswindow makeKeyAndOrderFront:NSApp];
- break;
- }
+
+ /*
+ * When a window is closed we want to move the focus to the next
+ * highest window. Apple's documentation says that calling the
+ * orderOut method of the key window will accomplish this. But
+ * experiment shows that this is not the case. So we have to reset the
+ * key window ourselves. When the window is the last one on the screen
+ * there is no choice for a new key window. Moreover, if the host
+ * computer has a TouchBar then the TouchBar holds a reference to the
+ * key window which prevents it from being deallocated until it stops
+ * being the key window. On these systems the only option for
+ * preventing zombies is to set the key window to nil.
+ */
+
+ for (NSWindow *w in [NSApp orderedWindows]) {
+ TkWindow *winPtr2 = TkMacOSXGetTkWindow(w);
+ BOOL isOnScreen;
+
+ if (!winPtr2 || !winPtr2->wmInfoPtr) {
+ continue;
+ }
+ wmPtr2 = winPtr2->wmInfoPtr;
+ isOnScreen = (wmPtr2->hints.initial_state != IconicState &&
+ wmPtr2->hints.initial_state != WithdrawnState);
+ if (w != ourNSWindow && isOnScreen && [w canBecomeKeyWindow]) {
+ [w makeKeyAndOrderFront:NSApp];
+ break;
}
}
+
/*
- * Process all window events immediately to force the closed window to
- * be deallocated. But don't do this for the root window as that is
- * unnecessary and can lead to segfaults.
+ * Prevent zombies on systems with a TouchBar.
*/
- if (winPtr->parentPtr) {
- while (Tk_DoOneEvent(TK_WINDOW_EVENTS|TK_DONT_WAIT)) {}
+
+ if (ourNSWindow == [NSApp keyWindow]) {
+ [NSApp _setKeyWindow:nil];
+ [NSApp _setMainWindow:nil];
}
+ [ourNSWindow close];
+ [ourNSWindow release];
[NSApp _resetAutoreleasePool];
-#if DEBUG_ZOMBIES > 0
+#if DEBUG_ZOMBIES > 1
fprintf(stderr, "================= Pool dump ===================\n");
[NSAutoreleasePool showPools];
#endif
+
}
+
+ /*
+ * Deallocate the wmInfo and clear the wmInfoPtr.
+ */
+
ckfree(wmPtr);
winPtr->wmInfoPtr = NULL;
}
@@ -1045,7 +1065,7 @@ TkWmDeadWindow(
void
TkWmSetClass(
- TkWindow *winPtr) /* Newly-created top-level window. */
+ TCL_UNUSED(TkWindow *)) /* Newly-created top-level window. */
{
return;
}
@@ -1067,7 +1087,6 @@ TkWmSetClass(
*----------------------------------------------------------------------
*/
-/* ARGSUSED */
int
Tk_WmObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
@@ -1114,7 +1133,7 @@ Tk_WmObjCmd(
return TCL_ERROR;
}
if (objc == 2) {
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(wmTracing));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(wmTracing != 0));
return TCL_OK;
}
return Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing);
@@ -1232,13 +1251,13 @@ Tk_WmObjCmd(
static int
WmAspectCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int numer1, denom1, numer2, denom2;
if ((objc != 3) && (objc != 7)) {
@@ -1250,10 +1269,10 @@ WmAspectCmd(
if (wmPtr->sizeHintsFlags & PAspect) {
Tcl_Obj *results[4];
- results[0] = Tcl_NewIntObj(wmPtr->minAspect.x);
- results[1] = Tcl_NewIntObj(wmPtr->minAspect.y);
- results[2] = Tcl_NewIntObj(wmPtr->maxAspect.x);
- results[3] = Tcl_NewIntObj(wmPtr->maxAspect.y);
+ results[0] = Tcl_NewWideIntObj(wmPtr->minAspect.x);
+ results[1] = Tcl_NewWideIntObj(wmPtr->minAspect.y);
+ results[2] = Tcl_NewWideIntObj(wmPtr->maxAspect.x);
+ results[3] = Tcl_NewWideIntObj(wmPtr->maxAspect.y);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
@@ -1336,7 +1355,7 @@ WmSetAttribute(
if (Tcl_GetBooleanFromObj(interp, value, &boolean) != TCL_OK) {
return TCL_ERROR;
}
- if (boolean != ((wmPtr->flags & WM_FULLSCREEN) != 0)) {
+ if (boolean != (([macWindow styleMask] & NSFullScreenWindowMask) != 0)) {
#if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070)
[macWindow toggleFullScreen:macWindow];
#else
@@ -1453,23 +1472,23 @@ WmGetAttribute(
result = Tcl_NewDoubleObj([macWindow alphaValue]);
break;
case WMATT_FULLSCREEN:
- result = Tcl_NewBooleanObj(wmPtr->flags & WM_FULLSCREEN);
+ result = Tcl_NewBooleanObj([macWindow styleMask] & NSFullScreenWindowMask);
break;
case WMATT_MODIFIED:
- result = Tcl_NewBooleanObj([macWindow isDocumentEdited]);
+ result = Tcl_NewWideIntObj([macWindow isDocumentEdited] != 0);
break;
case WMATT_NOTIFY:
- result = Tcl_NewBooleanObj(tkMacOSXWmAttrNotifyVal);
+ result = Tcl_NewWideIntObj(tkMacOSXWmAttrNotifyVal != 0);
break;
case WMATT_TITLEPATH:
result = Tcl_NewStringObj([[macWindow representedFilename] UTF8String],
-1);
break;
case WMATT_TOPMOST:
- result = Tcl_NewBooleanObj(wmPtr->flags & WM_TOPMOST);
+ result = Tcl_NewWideIntObj((wmPtr->flags & WM_TOPMOST) != 0);
break;
case WMATT_TRANSPARENT:
- result = Tcl_NewBooleanObj(wmPtr->flags & WM_TRANSPARENT);
+ result = Tcl_NewWideIntObj((wmPtr->flags & WM_TRANSPARENT) != 0);
break;
case WMATT_TYPE:
result = Tcl_NewStringObj("unsupported", -1);
@@ -1500,7 +1519,7 @@ WmGetAttribute(
static int
WmAttributesCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
@@ -1527,7 +1546,7 @@ WmAttributesCmd(
WmGetAttribute(winPtr, macWindow, attribute));
}
Tcl_SetObjResult(interp, result);
- } else if (objc == 4) { /* wm attributes $win -attribute */
+ } else if (objc == 4) { /* wm attributes $win -attribute */
if (Tcl_GetIndexFromObjStruct(interp, objv[3], WmAttributeNames,
sizeof(char *), "attribute", 0, &attribute) != TCL_OK) {
return TCL_ERROR;
@@ -1572,13 +1591,13 @@ WmAttributesCmd(
static int
WmClientCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
char *argv3;
int length;
@@ -1604,7 +1623,7 @@ WmClientCmd(
if (wmPtr->clientMachine != NULL) {
ckfree(wmPtr->clientMachine);
}
- wmPtr->clientMachine = ckalloc(length + 1);
+ wmPtr->clientMachine = (char *)ckalloc(length + 1);
strcpy(wmPtr->clientMachine, argv3);
return TCL_OK;
}
@@ -1634,7 +1653,7 @@ WmColormapwindowsCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
TkWindow **cmapList, *winPtr2;
int i, windowObjc, gotToplevel = 0;
Tcl_Obj **windowObjv, *resultObj;
@@ -1661,7 +1680,7 @@ WmColormapwindowsCmd(
!= TCL_OK) {
return TCL_ERROR;
}
- cmapList = ckalloc((windowObjc+1) * sizeof(TkWindow*));
+ cmapList = (TkWindow **)ckalloc((windowObjc+1) * sizeof(TkWindow*));
for (i = 0; i < windowObjc; i++) {
if (TkGetWindowFromObj(interp, tkwin, windowObjv[i],
(Tk_Window *) &winPtr2) != TCL_OK) {
@@ -1717,13 +1736,13 @@ WmColormapwindowsCmd(
static int
WmCommandCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int len;
if ((objc != 3) && (objc != 4)) {
@@ -1736,7 +1755,7 @@ WmCommandCmd(
}
return TCL_OK;
}
- if (Tcl_GetString(objv[3])[0] == 0) {
+ if (*Tcl_GetString(objv[3]) == '\0') {
if (wmPtr->commandObj != NULL) {
Tcl_DecrRefCount(wmPtr->commandObj);
wmPtr->commandObj = NULL;
@@ -1774,13 +1793,13 @@ WmCommandCmd(
static int
WmDeiconifyCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
if (objc != 3) {
@@ -1817,13 +1836,14 @@ WmDeiconifyCmd(
*/
for (Transient *transientPtr = wmPtr->transientPtr;
- transientPtr != NULL; transientPtr = transientPtr->nextPtr) {
+ transientPtr != NULL; transientPtr = transientPtr->nextPtr) {
TkWindow *winPtr2 = transientPtr->winPtr;
WmInfo *wmPtr2 = winPtr2->wmInfoPtr;
- TkWindow *masterPtr = (TkWindow *)TkGetTransientMaster(winPtr2);
+ TkWindow *masterPtr = (TkWindow *) TkGetTransientMaster(winPtr2);
+
if (masterPtr == winPtr) {
- if ((wmPtr2->hints.initial_state == WithdrawnState &&
- (transientPtr->flags & WITHDRAWN_BY_MASTER) != 0)) {
+ if ((wmPtr2->hints.initial_state == WithdrawnState) &&
+ ((transientPtr->flags & WITHDRAWN_BY_MASTER) != 0)) {
TkpWmSetState(winPtr2, NormalState);
transientPtr->flags &= ~WITHDRAWN_BY_MASTER;
}
@@ -1852,13 +1872,13 @@ WmDeiconifyCmd(
static int
WmFocusmodelCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"active", "passive", NULL };
enum options {
@@ -1906,13 +1926,13 @@ WmFocusmodelCmd(
static int
WmForgetCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel or Frame to work with */
- Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument objects. */
+ TCL_UNUSED(Tcl_Interp *), /* Current interpreter. */
+ TCL_UNUSED(int), /* Number of arguments. */
+ TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */
{
- register Tk_Window frameWin = (Tk_Window) winPtr;
+ Tk_Window frameWin = (Tk_Window) winPtr;
if (Tk_IsTopLevel(frameWin)) {
MacDrawable *macWin;
@@ -1972,14 +1992,15 @@ WmForgetCmd(
static int
WmFrameCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Window window;
+ char buf[TCL_INTEGER_SPACE];
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -1989,7 +2010,8 @@ WmFrameCmd(
if (window == None) {
window = Tk_WindowId((Tk_Window) winPtr);
}
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%x", (unsigned) window));
+ sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)window);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1));
return TCL_OK;
}
@@ -2012,13 +2034,13 @@ WmFrameCmd(
static int
WmGeometryCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
char xSign = '+', ySign = '+';
int width, height, x = wmPtr->x, y= wmPtr->y;
@@ -2083,13 +2105,13 @@ WmGeometryCmd(
static int
WmGridCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int reqWidth, reqHeight, widthInc, heightInc;
const char *errorMsg;
@@ -2102,10 +2124,10 @@ WmGridCmd(
if (wmPtr->sizeHintsFlags & PBaseSize) {
Tcl_Obj *results[4];
- results[0] = Tcl_NewIntObj(wmPtr->reqGridWidth);
- results[1] = Tcl_NewIntObj(wmPtr->reqGridHeight);
- results[2] = Tcl_NewIntObj(wmPtr->widthInc);
- results[3] = Tcl_NewIntObj(wmPtr->heightInc);
+ results[0] = Tcl_NewWideIntObj(wmPtr->reqGridWidth);
+ results[1] = Tcl_NewWideIntObj(wmPtr->reqGridHeight);
+ results[2] = Tcl_NewWideIntObj(wmPtr->widthInc);
+ results[3] = Tcl_NewWideIntObj(wmPtr->heightInc);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
@@ -2183,7 +2205,7 @@ WmGroupCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window tkwin2;
char *argv3;
int length;
@@ -2216,7 +2238,7 @@ WmGroupCmd(
}
wmPtr->hints.window_group = Tk_WindowId(tkwin2);
wmPtr->hints.flags |= WindowGroupHint;
- wmPtr->leaderName = ckalloc(length + 1);
+ wmPtr->leaderName = (char *)ckalloc(length + 1);
strcpy(wmPtr->leaderName, argv3);
}
return TCL_OK;
@@ -2241,13 +2263,13 @@ WmGroupCmd(
static int
WmIconbitmapCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Pixmap pixmap;
char *str;
int len;
@@ -2310,13 +2332,13 @@ WmIconbitmapCmd(
static int
WmIconifyCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
return TCL_ERROR;
@@ -2359,11 +2381,11 @@ WmIconifyCmd(
*/
for (Transient *transientPtr = wmPtr->transientPtr;
- transientPtr != NULL; transientPtr = transientPtr->nextPtr) {
+ transientPtr != NULL; transientPtr = transientPtr->nextPtr) {
TkWindow *winPtr2 = transientPtr->winPtr;
- TkWindow *masterPtr = (TkWindow *)TkGetTransientMaster(winPtr2);
+ TkWindow *masterPtr = (TkWindow *) TkGetTransientMaster(winPtr2);
if (masterPtr == winPtr &&
- winPtr2->wmInfoPtr->hints.initial_state != WithdrawnState) {
+ winPtr2->wmInfoPtr->hints.initial_state != WithdrawnState) {
TkpWmSetState(winPtr2, WithdrawnState);
transientPtr->flags |= WITHDRAWN_BY_MASTER;
}
@@ -2397,7 +2419,7 @@ WmIconmaskCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Pixmap pixmap;
char *argv3;
@@ -2451,13 +2473,13 @@ WmIconmaskCmd(
static int
WmIconnameCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
int length;
@@ -2476,7 +2498,7 @@ WmIconnameCmd(
ckfree(wmPtr->iconName);
}
argv3 = Tcl_GetStringFromObj(objv[3], &length);
- wmPtr->iconName = ckalloc(length + 1);
+ wmPtr->iconName = (char *)ckalloc(length + 1);
strcpy(wmPtr->iconName, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);
@@ -2512,6 +2534,7 @@ WmIconphotoCmd(
{
Tk_Image tk_icon;
int width, height, isDefault = 0;
+ NSImage *newIcon = NULL;
if (objc < 4) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -2519,26 +2542,35 @@ WmIconphotoCmd(
return TCL_ERROR;
}
- /*Parse args.*/
+ /*
+ * Parse args.
+ */
+
if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) {
isDefault = 1;
if (objc == 4) {
Tcl_WrongNumArgs(interp, 2, objv,
- "window ?-default? image1 ?image2 ...?");
+ "window ?-default? image1 ?image2 ...?");
return TCL_ERROR;
}
}
- /*Get icon name. We only use the first icon name because macOS does not
- support multiple images in Tk photos.*/
+ /*
+ * Get icon name. We only use the first icon name because macOS does not
+ * support multiple images in Tk photos.
+ */
+
char *icon;
if (strcmp(Tcl_GetString(objv[3]), "-default") == 0) {
icon = Tcl_GetString(objv[4]);
- } else {
+ } else {
icon = Tcl_GetString(objv[3]);
}
- /*Get image and convert to NSImage that can be displayed as icon.*/
+ /*
+ * Get image and convert to NSImage that can be displayed as icon.
+ */
+
tk_icon = Tk_GetImage(interp, tkwin, icon, NULL, NULL);
if (tk_icon == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -2548,11 +2580,16 @@ WmIconphotoCmd(
return TCL_ERROR;
}
- NSImage *newIcon;
Tk_SizeOfImage(tk_icon, &width, &height);
- newIcon = TkMacOSXGetNSImageWithTkImage(winPtr->display, tk_icon, width, height);
+ if (width != 0 && height != 0) {
+ newIcon = TkMacOSXGetNSImageWithTkImage(winPtr->display, tk_icon,
+ width, height);
+ }
Tk_FreeImage(tk_icon);
if (newIcon == NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "failed to create an iconphoto with image \"%s\"", icon));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "IMAGE", NULL);
return TCL_ERROR;
}
[NSApp setApplicationIconImage: newIcon];
@@ -2578,13 +2615,13 @@ WmIconphotoCmd(
static int
WmIconpositionCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y;
if ((objc != 3) && (objc != 5)) {
@@ -2596,8 +2633,8 @@ WmIconpositionCmd(
if (wmPtr->hints.flags & IconPositionHint) {
Tcl_Obj *results[2];
- results[0] = Tcl_NewIntObj(wmPtr->hints.icon_x);
- results[1] = Tcl_NewIntObj(wmPtr->hints.icon_y);
+ results[0] = Tcl_NewWideIntObj(wmPtr->hints.icon_x);
+ results[1] = Tcl_NewWideIntObj(wmPtr->hints.icon_y);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
}
return TCL_OK;
@@ -2607,7 +2644,7 @@ WmIconpositionCmd(
wmPtr->hints.flags &= ~IconPositionHint;
} else {
if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK)
- || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)){
+ || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)) {
return TCL_ERROR;
}
wmPtr->hints.icon_x = x;
@@ -2642,7 +2679,7 @@ WmIconwindowCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window tkwin2;
WmInfo *wmPtr2;
@@ -2706,14 +2743,13 @@ WmIconwindowCmd(
wmPtr->icon = tkwin2;
wmPtr2->iconFor = (Tk_Window) winPtr;
if (!(wmPtr2->flags & WM_NEVER_MAPPED)) {
-
/*
* If the window is in normal or zoomed state, the icon should be
* unmapped.
*/
if (wmPtr->hints.initial_state == NormalState ||
- wmPtr->hints.initial_state == ZoomState) {
+ wmPtr->hints.initial_state == ZoomState) {
Tk_UnmapWindow(tkwin2);
}
}
@@ -2740,14 +2776,14 @@ WmIconwindowCmd(
static int
WmManageCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel or Frame to work with */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument objects. */
+ TCL_UNUSED(int), /* Number of arguments. */
+ TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */
{
- register Tk_Window frameWin = (Tk_Window) winPtr;
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ Tk_Window frameWin = (Tk_Window) winPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (!Tk_IsTopLevel(frameWin)) {
MacDrawable *macWin = (MacDrawable *) winPtr->window;
@@ -2768,8 +2804,6 @@ WmManageCmd(
Tk_MakeWindowExist((Tk_Window) winPtr);
macWin = (MacDrawable *) winPtr->window;
}
- TkWmMapWindow(winPtr);
- Tk_UnmapWindow(frameWin);
}
wmPtr = winPtr->wmInfoPtr;
winPtr->flags &= ~TK_MAPPED;
@@ -2780,6 +2814,7 @@ WmManageCmd(
winPtr->flags |=
(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
TkMapTopFrame(frameWin);
+ TkWmMapWindow(winPtr);
} else if (Tk_IsTopLevel(frameWin)) {
/* Already managed by wm - ignore it */
}
@@ -2805,13 +2840,13 @@ WmManageCmd(
static int
WmMaxsizeCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
if ((objc != 3) && (objc != 5)) {
@@ -2823,8 +2858,8 @@ WmMaxsizeCmd(
Tcl_Obj *results[2];
GetMaxSize(winPtr, &width, &height);
- results[0] = Tcl_NewIntObj(width);
- results[1] = Tcl_NewIntObj(height);
+ results[0] = Tcl_NewWideIntObj(width);
+ results[1] = Tcl_NewWideIntObj(height);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
@@ -2859,13 +2894,13 @@ WmMaxsizeCmd(
static int
WmMinsizeCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
if ((objc != 3) && (objc != 5)) {
@@ -2877,8 +2912,8 @@ WmMinsizeCmd(
Tcl_Obj *results[2];
GetMinSize(winPtr, &width, &height);
- results[0] = Tcl_NewIntObj(width);
- results[1] = Tcl_NewIntObj(height);
+ results[0] = Tcl_NewWideIntObj(width);
+ results[1] = Tcl_NewWideIntObj(height);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
@@ -2913,7 +2948,7 @@ WmMinsizeCmd(
static int
WmOverrideredirectCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
@@ -2929,8 +2964,8 @@ WmOverrideredirectCmd(
}
if (objc == 3) {
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
- Tk_Attributes((Tk_Window) winPtr)->override_redirect));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
+ Tk_Attributes((Tk_Window) winPtr)->override_redirect != 0));
return TCL_OK;
}
@@ -2962,13 +2997,13 @@ WmOverrideredirectCmd(
static int
WmPositionfromCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"program", "user", NULL };
enum options {
@@ -3028,14 +3063,14 @@ WmPositionfromCmd(
static int
WmProtocolCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- register ProtocolHandler *protPtr, *prevPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ ProtocolHandler *protPtr, *prevPtr;
Atom protocol;
char *cmd;
int cmdLength;
@@ -3084,7 +3119,7 @@ WmProtocolCmd(
*/
for (protPtr = wmPtr->protPtr, prevPtr = NULL; protPtr != NULL;
- prevPtr = protPtr, protPtr = protPtr->nextPtr) {
+ prevPtr = protPtr, protPtr = protPtr->nextPtr) {
if (protPtr->protocol == protocol) {
if (prevPtr == NULL) {
wmPtr->protPtr = protPtr->nextPtr;
@@ -3099,12 +3134,12 @@ WmProtocolCmd(
}
cmd = Tcl_GetStringFromObj(objv[4], &cmdLength);
if (cmdLength > 0) {
- protPtr = ckalloc(sizeof(ProtocolHandler));
+ protPtr = (ProtocolHandler *)ckalloc(sizeof(ProtocolHandler));
protPtr->protocol = protocol;
protPtr->nextPtr = wmPtr->protPtr;
wmPtr->protPtr = protPtr;
protPtr->interp = interp;
- protPtr->command = ckalloc(cmdLength+1);
+ protPtr->command = (char *)ckalloc(cmdLength+1);
strcpy(protPtr->command, cmd);
}
return TCL_OK;
@@ -3129,13 +3164,13 @@ WmProtocolCmd(
static int
WmResizableCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
UInt64 oldAttributes = wmPtr->attributes;
int oldFlags = wmPtr->flags;
@@ -3148,8 +3183,10 @@ WmResizableCmd(
if (objc == 3) {
Tcl_Obj *results[2];
- results[0] = Tcl_NewBooleanObj(!(wmPtr->flags & WM_WIDTH_NOT_RESIZABLE));
- results[1] = Tcl_NewBooleanObj(!(wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE));
+ results[0] = Tcl_NewWideIntObj(
+ (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) == 0);
+ results[1] = Tcl_NewWideIntObj(
+ (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) == 0);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
@@ -3206,13 +3243,13 @@ WmResizableCmd(
static int
WmSizefromCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"program", "user", NULL };
enum options {
@@ -3295,18 +3332,18 @@ WmStackorderCmd(
if (objc == 3) {
windows = TkWmStackorderToplevel(winPtr);
- if (windows == NULL) {
- Tcl_Panic("TkWmStackorderToplevel failed");
- }
-
- resultObj = Tcl_NewObj();
- for (windowPtr = windows; *windowPtr ; windowPtr++) {
- Tcl_ListObjAppendElement(NULL, resultObj,
+ if (windows != NULL) {
+ resultObj = Tcl_NewObj();
+ for (windowPtr = windows; *windowPtr ; windowPtr++) {
+ Tcl_ListObjAppendElement(NULL, resultObj,
TkNewWindowObj((Tk_Window) *windowPtr));
+ }
+ Tcl_SetObjResult(interp, resultObj);
+ ckfree(windows);
+ return TCL_OK;
+ } else {
+ return TCL_ERROR;
}
- Tcl_SetObjResult(interp, resultObj);
- ckfree(windows);
- return TCL_OK;
} else {
TkWindow *winPtr2;
int index1 = -1, index2 = -1, result;
@@ -3374,7 +3411,7 @@ WmStackorderCmd(
} else { /* OPT_ISBELOW */
result = index1 < index2;
}
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(result != 0));
return TCL_OK;
}
}
@@ -3398,13 +3435,13 @@ WmStackorderCmd(
static int
WmStateCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"normal", "iconic", "withdrawn", "zoomed", NULL };
enum options {
@@ -3437,14 +3474,17 @@ WmStateCmd(
return TCL_ERROR;
}
- if (index == OPT_NORMAL) {
+ switch (index) {
+ case OPT_NORMAL:
TkpWmSetState(winPtr, NormalState);
/*
* This varies from 'wm deiconify' because it does not force the
* window to be raised and receive focus
*/
- } else if (index == OPT_ICONIC) {
+
+ break;
+ case OPT_ICONIC:
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't iconify \"%s\": override-redirect flag is set",
@@ -3462,10 +3502,13 @@ WmStateCmd(
return TCL_ERROR;
}
TkpWmSetState(winPtr, IconicState);
- } else if (index == OPT_WITHDRAWN) {
+ break;
+ case OPT_WITHDRAWN:
TkpWmSetState(winPtr, WithdrawnState);
- } else { /* OPT_ZOOMED */
+ break;
+ default: /* OPT_ZOOMED */
TkpWmSetState(winPtr, ZoomState);
+ break;
}
} else if (wmPtr->iconFor != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("icon", -1));
@@ -3512,13 +3555,13 @@ WmStateCmd(
static int
WmTitleCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
char *argv3;
int length;
@@ -3566,7 +3609,7 @@ WmTransientCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window master;
TkWindow *masterPtr, *w;
WmInfo *wmPtr2;
@@ -3583,16 +3626,14 @@ WmTransientCmd(
}
return TCL_OK;
}
- if (Tcl_GetString(objv[3])[0] == '\0') {
+ if (*Tcl_GetString(objv[3]) == '\0') {
RemoveTransient(winPtr);
-
} else {
if (TkGetWindowFromObj(interp, tkwin, objv[3], &master) != TCL_OK) {
return TCL_ERROR;
}
masterPtr = (TkWindow*) master;
while (!Tk_TopWinHierarchy(masterPtr)) {
-
/*
* Ensure that the master window is actually a Tk toplevel.
*/
@@ -3610,7 +3651,11 @@ WmTransientCmd(
}
wmPtr2 = masterPtr->wmInfoPtr;
- /* Under some circumstances, wmPtr2 is NULL here */
+
+ /*
+ * Under some circumstances, wmPtr2 is NULL here.
+ */
+
if (wmPtr2 != NULL && wmPtr2->iconFor != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't make \"%s\" a master: it is an icon for %s",
@@ -3620,7 +3665,7 @@ WmTransientCmd(
}
for (w = masterPtr; w != NULL && w->wmInfoPtr != NULL;
- w = (TkWindow *)w->wmInfoPtr->master) {
+ w = (TkWindow *)w->wmInfoPtr->master) {
if (w == winPtr) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"setting \"%s\" as master creates a transient/master cycle",
@@ -3633,12 +3678,12 @@ WmTransientCmd(
/*
* Add the transient to the master's list, if it not already there.
*/
-
+
for (transient = wmPtr2->transientPtr;
transient != NULL && transient->winPtr != winPtr;
transient = transient->nextPtr) {}
if (transient == NULL) {
- transient = ckalloc(sizeof(Transient));
+ transient = (Transient *)ckalloc(sizeof(Transient));
transient->winPtr = winPtr;
transient->flags = 0;
transient->nextPtr = wmPtr2->transientPtr;
@@ -3650,33 +3695,33 @@ WmTransientCmd(
*/
if ((wmPtr2->hints.initial_state == WithdrawnState ||
- wmPtr2->hints.initial_state == IconicState) &&
- wmPtr->hints.initial_state != WithdrawnState){
+ wmPtr2->hints.initial_state == IconicState) &&
+ wmPtr->hints.initial_state != WithdrawnState) {
TkpWmSetState(winPtr, WithdrawnState);
transient->flags |= WITHDRAWN_BY_MASTER;
}
- wmPtr->master = (Tk_Window)masterPtr;
+ wmPtr->master = (Tk_Window) masterPtr;
}
ApplyMasterOverrideChanges(winPtr, NULL);
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
* RemoveTransient --
*
- * Clears the transient's master record and removes the transient
- * from the master's list.
+ * Clears the transient's master record and removes the transient from the
+ * master's list.
*
* Results:
* None
*
* Side effects:
* References to a master are removed from the transient's wmInfo
- * structure and references to the transient are removed from its
- * master's wmInfo.
+ * structure and references to the transient are removed from its master's
+ * wmInfo.
*
*----------------------------------------------------------------------
*/
@@ -3687,34 +3732,34 @@ RemoveTransient(
{
WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2;
TkWindow *masterPtr;
- Transient *T, *temp;
-
+ Transient *transPtr, *temp;
+
if (wmPtr == NULL || wmPtr->master == NULL) {
return;
}
- masterPtr = (TkWindow*)wmPtr->master;
+ masterPtr = (TkWindow *)wmPtr->master;
wmPtr2 = masterPtr->wmInfoPtr;
if (wmPtr2 == NULL) {
return;
}
wmPtr->master = NULL;
- T = wmPtr2->transientPtr;
- while (T != NULL) {
- if (T->winPtr != winPtr) {
+ transPtr = wmPtr2->transientPtr;
+ while (transPtr != NULL) {
+ if (transPtr->winPtr != winPtr) {
break;
}
- temp = T->nextPtr;
- ckfree(T);
- T = temp;
+ temp = transPtr->nextPtr;
+ ckfree(transPtr);
+ transPtr = temp;
}
- wmPtr2->transientPtr = T;
- while (T != NULL) {
- if (T->nextPtr && T->nextPtr->winPtr == winPtr) {
- temp = T->nextPtr;
- T->nextPtr = temp->nextPtr;
+ wmPtr2->transientPtr = transPtr;
+ while (transPtr != NULL) {
+ if (transPtr->nextPtr && transPtr->nextPtr->winPtr == winPtr) {
+ temp = transPtr->nextPtr;
+ transPtr->nextPtr = temp->nextPtr;
ckfree(temp);
} else {
- T = T->nextPtr;
+ transPtr = transPtr->nextPtr;
}
}
}
@@ -3738,13 +3783,13 @@ RemoveTransient(
static int
WmWithdrawCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -3762,18 +3807,20 @@ WmWithdrawCmd(
TkpWmSetState(winPtr, WithdrawnState);
NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
- [win orderOut:nil];
+ [win orderOut:NSApp];
[win setExcludedFromWindowsMenu:YES];
/*
* If this window has a transient, the transient must also be withdrawn.
*/
+
for (Transient *transientPtr = wmPtr->transientPtr;
- transientPtr != NULL; transientPtr = transientPtr->nextPtr) {
+ transientPtr != NULL; transientPtr = transientPtr->nextPtr) {
TkWindow *winPtr2 = transientPtr->winPtr;
- TkWindow *masterPtr = (TkWindow *)TkGetTransientMaster(winPtr2);
+ TkWindow *masterPtr = (TkWindow *) TkGetTransientMaster(winPtr2);
+
if (masterPtr == winPtr &&
- winPtr2->wmInfoPtr->hints.initial_state != WithdrawnState) {
+ winPtr2->wmInfoPtr->hints.initial_state != WithdrawnState) {
TkpWmSetState(winPtr2, WithdrawnState);
transientPtr->flags |= WITHDRAWN_BY_MASTER;
}
@@ -3781,10 +3828,10 @@ WmWithdrawCmd(
return TCL_OK;
}
-
+
/*
- * Invoked by those wm subcommands that affect geometry.
- * Schedules a geometry update.
+ * Invoked by those wm subcommands that affect geometry. Schedules a geometry
+ * update.
*/
static void
@@ -3871,14 +3918,13 @@ Tk_SetGrid(
/*
* If gridding was previously off, then forget about any window size
- * requests made by the user or via "wm geometry": these are in pixel
- * units and there's no easy way to translate them to grid units since the
- * new requested size of the top-level window in pixels may not yet have
- * been registered yet (it may filter up the hierarchy in DoWhenIdle
- * handlers). However, if the window has never been mapped yet then just
- * leave the window size alone: assume that it is intended to be in grid
- * units but just happened to have been specified before this procedure
- * was called.
+ * requests made by the user or via "wm geometry": these are in pixel units
+ * and there's no easy way to translate them to grid units since the new
+ * requested size of the top-level window in pixels may not yet have been
+ * registered yet (it may filter up the hierarchy in DoWhenIdle handlers).
+ * However, if the window has never been mapped yet then just leave the
+ * window size alone: assume that it is intended to be in grid units but
+ * just happened to have been specified before this procedure was called.
*/
if ((wmPtr->gridWin == NULL) && !(wmPtr->flags & WM_NEVER_MAPPED)) {
@@ -4029,10 +4075,9 @@ TopLevelEventProc(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static void
TopLevelReqProc(
- ClientData dummy, /* Not used. */
+ TCL_UNUSED(void *), /* Not used. */
Tk_Window tkwin) /* Information about window. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
@@ -4399,9 +4444,10 @@ ParseGeometry(
if (flags & WM_NEGATIVE_X) {
int borderwidth = wmPtr->parentWidth - winPtr->changes.width;
int newWidth = width == -1 ? winPtr->changes.width : width;
+
x = (x == -1) ?
- wmPtr->x + winPtr->changes.width - newWidth :
- wmPtr->vRootWidth - x - newWidth - borderwidth;
+ wmPtr->x + winPtr->changes.width - newWidth :
+ wmPtr->vRootWidth - x - newWidth - borderwidth;
}
if (x == -1) {
x = wmPtr->x;
@@ -4409,9 +4455,10 @@ ParseGeometry(
if (flags & WM_NEGATIVE_Y) {
int borderheight = wmPtr->parentHeight - winPtr->changes.height;
int newHeight = height == -1 ? winPtr->changes.height : height;
+
y = (y == -1) ?
- wmPtr->y + winPtr->changes.height - newHeight :
- wmPtr->vRootHeight - y - newHeight - borderheight;
+ wmPtr->y + winPtr->changes.height - newHeight :
+ wmPtr->vRootHeight - y - newHeight - borderheight;
}
if (y == -1) {
y = wmPtr->y;
@@ -4538,8 +4585,7 @@ Tk_GetRootCoords(
*
* Results:
* The return result is either a token for the window corresponding to
- * rootX and rootY, or else NULL to indicate that there is no such
- * window.
+ * rootX and rootY, or else NULL to indicate that there is no such window.
*
* Side effects:
* None.
@@ -4943,9 +4989,10 @@ TkWmRestackToplevel(
/*
* If the Tk windows has no drawable, or is withdrawn do nothing.
*/
+
if (winPtr->window == None ||
- wmPtr == NULL ||
- wmPtr->hints.initial_state == WithdrawnState) {
+ wmPtr == NULL ||
+ wmPtr->hints.initial_state == WithdrawnState) {
return;
}
macWindow = TkMacOSXDrawableWindow(winPtr->window);
@@ -4954,30 +5001,33 @@ TkWmRestackToplevel(
}
if (otherPtr) {
/*
- * When otherPtr is non-NULL, if the other window has no
- * drawable or is withdrawn, do nothing.
+ * When otherPtr is non-NULL, if the other window has no drawable or is
+ * withdrawn, do nothing.
*/
+
WmInfo *otherWmPtr = otherPtr->wmInfoPtr;
if (winPtr->window == None ||
- otherWmPtr == NULL ||
- otherWmPtr->hints.initial_state == WithdrawnState) {
- return;
+ otherWmPtr == NULL ||
+ otherWmPtr->hints.initial_state == WithdrawnState) {
+ return;
}
otherMacWindow = TkMacOSXDrawableWindow(otherPtr->window);
if (otherMacWindow == nil) {
return;
- } else {
- /*
- * If the other window is OK, get its number.
- */
- otherNumber = [otherMacWindow windowNumber];
}
+
+ /*
+ * If the other window is OK, get its number.
+ */
+
+ otherNumber = [otherMacWindow windowNumber];
}
/*
- * Just let the Mac window manager deal with all the subtleties
- * of keeping track of off-screen windows, etc.
+ * Just let the Mac window manager deal with all the subtleties of keeping
+ * track of off-screen windows, etc.
*/
+
[macWindow orderWindow:macAboveBelow relativeTo:otherNumber];
}
@@ -5050,7 +5100,7 @@ TkWmAddToColormapWindows(
* add the toplevel itself as the last element of the list.
*/
- newPtr = ckalloc((count+2) * sizeof(TkWindow *));
+ newPtr = (TkWindow **)ckalloc((count+2) * sizeof(TkWindow *));
if (count > 0) {
memcpy(newPtr, oldPtr, count * sizeof(TkWindow *));
}
@@ -5162,7 +5212,7 @@ TkWmRemoveFromColormapWindows(
void
TkGetPointerCoords(
- Tk_Window tkwin, /* Toplevel window that identifies screen on
+ TCL_UNUSED(Tk_Window), /* Toplevel window that identifies screen on
* which lookup is to be done. */
int *xPtr, int *yPtr) /* Store pointer coordinates here. */
{
@@ -5176,8 +5226,8 @@ TkGetPointerCoords(
*
* This function calculates the initial bounds for a new Mac toplevel
* window. Unless the geometry is specified by the user this code will
- * auto place the windows in a cascade diagonially across the main
- * monitor of the Mac.
+ * auto place the windows in a cascade diagonially across the main monitor
+ * of the Mac.
*
* Results:
* Window bounds.
@@ -5202,7 +5252,7 @@ InitialWindowBounds(
cascadePoint = [macWindow cascadeTopLeftFromPoint:cascadePoint];
frame = [macWindow frame];
wmPtr->x = frame.origin.x;
- wmPtr->y = tkMacOSXZeroScreenHeight - (frame.origin.y +
+ wmPtr->y = TkMacOSXZeroScreenHeight() - (frame.origin.y +
frame.size.height);
}
return NSMakeRect(wmPtr->x, wmPtr->y, winPtr->changes.width,
@@ -5270,8 +5320,8 @@ TkMacOSXResizable(
int
TkMacOSXGrowToplevel(
- void *whichWindow,
- XPoint start)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(XPoint))
{
return false;
}
@@ -5418,7 +5468,6 @@ TkMacOSXIsWindowZoomed(
NSWindow *macWindow = TkMacOSXDrawableWindow(winPtr->window);
return [macWindow isZoomed];
}
-
/*
*----------------------------------------------------------------------
@@ -5474,7 +5523,7 @@ TkMacOSXZoomToplevel(
/*
*----------------------------------------------------------------------
*
- * TkUnsupported1Cmd --
+ * TkUnsupported1ObjCmd --
*
* This procedure is invoked to process the
* "::tk::unsupported::MacWindowStyle" Tcl command. This command allows
@@ -5489,7 +5538,6 @@ TkMacOSXZoomToplevel(
*----------------------------------------------------------------------
*/
-/* ARGSUSED */
int
TkUnsupported1ObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
@@ -5498,10 +5546,10 @@ TkUnsupported1ObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *const subcmds[] = {
- "style", "tabbingid", NULL
+ "style", "tabbingid", "appearance", "isdark", NULL
};
enum SubCmds {
- TKMWS_STYLE, TKMWS_TABID
+ TKMWS_STYLE, TKMWS_TABID, TKMWS_APPEARANCE, TKMWS_ISDARK
};
Tk_Window tkwin = clientData;
TkWindow *winPtr;
@@ -5512,7 +5560,6 @@ TkUnsupported1ObjCmd(
return TCL_ERROR;
}
-
winPtr = (TkWindow *)
Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin);
if (winPtr == NULL) {
@@ -5529,26 +5576,55 @@ TkUnsupported1ObjCmd(
sizeof(char *), "option", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
- if (((enum SubCmds) index) == TKMWS_STYLE) {
+ switch((enum SubCmds) index) {
+ case TKMWS_STYLE:
if ((objc < 3) || (objc > 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?class attributes?");
return TCL_ERROR;
}
return WmWinStyle(interp, winPtr, objc, objv);
- } else if (((enum SubCmds) index) == TKMWS_TABID) {
+ case TKMWS_TABID:
if ([NSApp macMinorVersion] < 12) {
- Tcl_AddErrorInfo(interp,
- "\n (TabbingIdentifiers only exist on OSX 10.12 or later)");
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Tabbing identifiers did not exist until OSX 10.12.", -1));
+ Tcl_SetErrorCode(interp, "TK", "WINDOWSTYLE", "TABBINGID", NULL);
return TCL_ERROR;
}
if ((objc < 3) || (objc > 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "tabbingid window ?newid?");
+ Tcl_WrongNumArgs(interp, 2, objv, "window ?newid?");
return TCL_ERROR;
}
return WmWinTabbingId(interp, winPtr, objc, objv);
+ case TKMWS_APPEARANCE:
+ if ([NSApp macMinorVersion] < 9) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Window appearances did not exist until OSX 10.9.", -1));
+ Tcl_SetErrorCode(interp, "TK", "WINDOWSTYLE", "APPEARANCE", NULL);
+ return TCL_ERROR;
+ }
+ if ((objc < 3) || (objc > 4)) {
+ Tcl_WrongNumArgs(interp, 2, objv, "window ?appearancename?");
+ return TCL_ERROR;
+ }
+ if (objc == 4 && [NSApp macMinorVersion] < 14) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Window appearances cannot be changed before OSX 10.14.",
+ -1));
+ Tcl_SetErrorCode(interp, "TK", "WINDOWSTYLE", "APPEARANCE", NULL);
+ return TCL_ERROR;
+ }
+ return WmWinAppearance(interp, winPtr, objc, objv);
+ case TKMWS_ISDARK:
+ if ((objc != 3)) {
+ Tcl_WrongNumArgs(interp, 2, objv, "window");
+ return TCL_ERROR;
+ }
+ Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
+ TkMacOSXInDarkMode((Tk_Window) winPtr)));
+ return TCL_OK;
+ default:
+ return TCL_ERROR;
}
- /* won't be reached */
- return TCL_ERROR;
}
/*
@@ -5597,14 +5673,14 @@ WmWinStyle(
{ "altPlain", kAltPlainWindowClass },
{ "simple", kSimpleWindowClass },
{ "drawer", kDrawerWindowClass },
- { NULL }
+ { NULL, 0 }
};
static const struct StrIntMap compositeAttrMap[] = {
{ "none", kWindowNoAttributes },
{ "standardDocument", kWindowStandardDocumentAttributes },
{ "standardFloating", kWindowStandardFloatingAttributes },
{ "fullZoom", kWindowFullZoomAttribute },
- { NULL }
+ { NULL, 0 }
};
/*
@@ -5641,7 +5717,7 @@ WmWinStyle(
{ "moveToActiveSpace", tkMoveToActiveSpaceAttribute },
{ "nonActivating", tkNonactivatingPanelAttribute },
{ "hud", tkHUDWindowAttribute },
- { NULL }
+ { NULL, 0 }
};
int index, i;
@@ -5742,8 +5818,9 @@ WmWinStyle(
* This procedure is invoked to process the
* "::tk::unsupported::MacWindowStyle tabbingid" subcommand. The command
* allows you to get or set the tabbingIdentifier for the NSWindow
- * associated with a Tk Window. The syntax is:
- * tk::unsupported::MacWindowStyle tabbingid window ?newId?
+ * associated with a Tk Window. The syntax is:
+ *
+ * tk::unsupported::MacWindowStyle tabbingid window ?newId?
*
* Results:
* Returns the tabbingIdentifier of the window prior to calling this
@@ -5754,9 +5831,8 @@ WmWinStyle(
* Windows may only be grouped together as tabs if they all have the same
* tabbingIdentifier. In particular, by giving a window a unique
* tabbingIdentifier one can prevent it from becoming a tab in any other
- * window. Note, however, that changing the tabbingIdentifier of a window
- * which is already a tab does not cause it to become a separate window.
- *
+ * window. Changing the tabbingIdentifier of a window which is already
+ * a tab causes it to become a separate window.
*
*----------------------------------------------------------------------
*/
@@ -5777,7 +5853,8 @@ WmWinTabbingId(
result = Tcl_NewStringObj(idString.UTF8String, [idString length]);
}
if (result == NULL) {
- Tcl_Panic("Failed to read tabbing identifier.");
+ NSLog(@"Failed to read tabbing identifier; try calling update idletasks before getting/setting the tabbing identifier of the window.");
+ return TCL_OK;
}
Tcl_SetObjResult(interp, result);
if (objc == 3) {
@@ -5794,7 +5871,11 @@ WmWinTabbingId(
* same frame must have the same tabbingIdentifier.
*/
- if ([idString compare:newIdString] != NSOrderedSame && [win tab]) {
+ if ([idString compare:newIdString] != NSOrderedSame
+#if MAC_OS_X_VERSION_MIN_REQUIRED > 101200
+ && [win tab]
+#endif
+ ) {
[win moveTabToNewWindow:nil];
}
return TCL_OK;
@@ -5806,6 +5887,109 @@ WmWinTabbingId(
/*
*----------------------------------------------------------------------
*
+ * WmWinAppearance --
+ *
+ * This procedure is invoked to process the
+ * "::tk::unsupported::MacWindowStyle appearance" subcommand. The command
+ * allows you to get or set the appearance for the NSWindow associated
+ * with a Tk Window. The syntax is:
+ *
+ * tk::unsupported::MacWindowStyle tabbingid window ?newAppearance?
+ *
+ * Allowed appearance names are "aqua", "darkaqua", and "auto".
+ *
+ * Results:
+ * Returns the appearance setting of the window prior to calling this
+ * function.
+ *
+ * Side effects:
+ * The underlying NSWindow's appearance property is set to the specified
+ * value if the optional newAppearance argument is supplied. Otherwise the
+ * window's appearance property is not changed. If the appearance is set
+ * to aqua or darkaqua then the window will use the associated
+ * NSAppearance even if the user has selected a different appearance with
+ * the system preferences. If it is set to auto then the appearance
+ * property is set to nil, meaning that the preferences will determine the
+ * appearance.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+WmWinAppearance(
+ Tcl_Interp *interp, /* Current interpreter. */
+ TkWindow *winPtr, /* Window to be manipulated. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj * const objv[]) /* Argument objects. */
+{
+#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090
+ static const char *const appearanceStrings[] = {
+ "aqua", "darkaqua", "auto", NULL
+ };
+ enum appearances {
+ APPEARANCE_AQUA, APPEARANCE_DARKAQUA, APPEARANCE_AUTO
+ };
+ Tcl_Obj *result = NULL;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
+ NSAppearanceName appearance;
+#else
+ NSString *appearance;
+#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
+
+ const char *resultString = "unrecognized";
+ NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
+ if (win) {
+ appearance = win.appearance.name;
+ if (appearance == nil) {
+ resultString = appearanceStrings[APPEARANCE_AUTO];
+ } else if (appearance == NSAppearanceNameAqua) {
+ resultString = appearanceStrings[APPEARANCE_AQUA];
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
+ } else if (@available(macOS 10.14, *)) {
+ if (appearance == NSAppearanceNameDarkAqua) {
+ resultString = appearanceStrings[APPEARANCE_DARKAQUA];
+ }
+#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
+ }
+ result = Tcl_NewStringObj(resultString, strlen(resultString));
+ }
+ if (result == NULL) {
+ NSLog(@"Failed to read appearance name; try calling update idletasks before getting/setting the appearance of the window.");
+ return TCL_OK;
+ }
+ if (objc == 4) {
+ int index;
+ if (Tcl_GetIndexFromObjStruct(interp, objv[3], appearanceStrings,
+ sizeof(char *), "appearancename", 0, &index) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ switch ((enum appearances) index) {
+ case APPEARANCE_AQUA:
+ win.appearance = [NSAppearance appearanceNamed:
+ NSAppearanceNameAqua];
+ break;
+ case APPEARANCE_DARKAQUA:
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
+ if (@available(macOS 10.14, *)) {
+ win.appearance = [NSAppearance appearanceNamed:
+ NSAppearanceNameDarkAqua];
+ }
+#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
+ break;
+ default:
+ win.appearance = nil;
+ }
+ }
+ Tcl_SetObjResult(interp, result);
+ return TCL_OK;
+#else // MAC_OS_X_VERSION_MAX_ALLOWED > 1090
+ return TCL_ERROR;
+#endif
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkpMakeMenuWindow --
*
* Configure the window to be either a undecorated pull-down (or pop-up)
@@ -5874,8 +6058,8 @@ TkMacOSXMakeRealWindowExist(
macWin = (MacDrawable *) winPtr->window;
/*
- * If this is embedded, make sure its container's toplevel exists,
- * then return...
+ * If this is embedded, make sure its container's toplevel exists, then
+ * return...
*/
if (Tk_IsEmbedded(winPtr)) {
@@ -5904,8 +6088,8 @@ TkMacOSXMakeRealWindowExist(
}
/*
- * If this is an override-redirect window, the NSWindow is created
- * first as a document window then converted to a simple window.
+ * If this is an override-redirect window, the NSWindow is created first as
+ * a document window then converted to a simple window.
*/
if (overrideRedirect) {
@@ -5939,7 +6123,7 @@ TkMacOSXMakeRealWindowExist(
NSRect structureRect = [winClass frameRectForContentRect:NSZeroRect
styleMask:styleMask];
NSRect contentRect = NSMakeRect(5 - structureRect.origin.x,
- tkMacOSXZeroScreenHeight - (tkMacOSXZeroScreenTop + 5 +
+ TkMacOSXZeroScreenHeight() - (TkMacOSXZeroScreenTop() + 5 +
structureRect.origin.y + structureRect.size.height + 200), 200, 200);
NSWindow *window = [[winClass alloc] initWithContentRect:contentRect
styleMask:styleMask backing:NSBackingStoreBuffered defer:YES];
@@ -5959,8 +6143,8 @@ TkMacOSXMakeRealWindowExist(
if ((styleMask & (NSTexturedBackgroundWindowMask|NSHUDWindowMask)) &&
!(styleMask & NSDocModalWindowMask)) {
/*
- * Workaround for [Bug 2824538]: Textured windows are draggable
- * from opaque content.
+ * Workaround for [Bug 2824538]: Textured windows are draggable from
+ * opaque content.
*/
[window setMovableByWindowBackground:NO];
}
@@ -5969,9 +6153,9 @@ TkMacOSXMakeRealWindowExist(
macWin->view = window.contentView;
TkMacOSXApplyWindowAttributes(winPtr, window);
NSRect geometry = InitialWindowBounds(winPtr, window);
- geometry.size.width += structureRect.size.width;
+ geometry.size.width += structureRect.size.width;
geometry.size.height += structureRect.size.height;
- geometry.origin.y = tkMacOSXZeroScreenHeight - (geometry.origin.y +
+ geometry.origin.y = TkMacOSXZeroScreenHeight() - (geometry.origin.y +
geometry.size.height);
[window setFrame:geometry display:YES];
TkMacOSXRegisterOffScreenWindow((Window) macWin, window);
@@ -5979,6 +6163,7 @@ TkMacOSXMakeRealWindowExist(
macWin->flags |= TK_HOST_EXISTS;
if (overrideRedirect) {
XSetWindowAttributes atts;
+
atts.override_redirect = True;
Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts);
ApplyMasterOverrideChanges(winPtr, NULL);
@@ -5990,9 +6175,9 @@ TkMacOSXMakeRealWindowExist(
*
* TkpDisplayWindow --
*
- * Mark the contentView of this window as needing display so the
- * window will be drawn by the window manager. If this is called
- * within the drawRect method, do nothing.
+ * Mark the contentView of this window as needing display so the window
+ * will be drawn by the window manager. If this is called within the
+ * drawRect method, do nothing.
*
* Results:
* None.
@@ -6006,8 +6191,9 @@ TkMacOSXMakeRealWindowExist(
MODULE_SCOPE void
TkpDisplayWindow(Tk_Window tkwin) {
if (![NSApp isDrawing]) {
- TkWindow *winPtr = (TkWindow*)tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
NSWindow *w = TkMacOSXDrawableWindow(winPtr->window);
+
[[w contentView] setNeedsDisplay: YES];
}
}
@@ -6017,8 +6203,8 @@ TkpDisplayWindow(Tk_Window tkwin) {
*
* TkMacOSXRegisterOffScreenWindow --
*
- * This function adds the passed in Off Screen Port to the hash table
- * that maps Mac windows to root X windows.
+ * This function adds the passed in Off Screen Port to the hash table that
+ * maps Mac windows to root X windows.
*
* Results:
* None.
@@ -6357,16 +6543,17 @@ TkpGetMS(void)
*----------------------------------------------------------------------
*/
-void
+int
XSetInputFocus(
- Display* display,
- Window focus,
- int revert_to,
- Time time)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(int),
+ TCL_UNUSED(Time))
{
/*
* Don't need to do a thing. Tk manages the focus for us.
*/
+ return Success;
}
/*
@@ -6402,13 +6589,14 @@ TkpChangeFocus(
return 0;
}
- if (Tk_IsTopLevel(winPtr) && !Tk_IsEmbedded(winPtr) ){
+ if (Tk_IsTopLevel(winPtr) && !Tk_IsEmbedded(winPtr)) {
NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
+
TkWmRestackToplevel(winPtr, Above, NULL);
- if (force ) {
+ if (force) {
[NSApp activateIgnoringOtherApps:YES];
}
- if ( win && [win canBecomeKeyWindow] ) {
+ if (win && [win canBecomeKeyWindow]) {
[win makeKeyAndOrderFront:NSApp];
}
}
@@ -6454,7 +6642,7 @@ WmStackorderToplevelWrapperMap(
Tcl_HashEntry *hPtr;
int newEntry;
- if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr)
+ if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) && !Tk_IsEmbedded(winPtr)
&& (winPtr->display == display)) {
hPtr = Tcl_CreateHashEntry(table,
(char*) TkMacOSXDrawableWindow(winPtr->window), &newEntry);
@@ -6475,8 +6663,8 @@ WmStackorderToplevelWrapperMap(
* This procedure returns the stack order of toplevel windows.
*
* Results:
- * An array of pointers to tk window objects in stacking order or else
- * NULL if there was an error.
+ * A NULL terminated array of pointers to tk window objects in stacking
+ * order or else NULL if there was an error.
*
* Side effects:
* None.
@@ -6491,57 +6679,24 @@ TkWmStackorderToplevel(
TkWindow *childWinPtr, **windows, **windowPtr;
Tcl_HashTable table;
Tcl_HashEntry *hPtr;
- Tcl_HashSearch search;
-
- /*
- * Map mac windows to a TkWindow of the wrapped toplevel.
- */
-
- Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS);
- WmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table);
-
- windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *));
-
- /*
- * Special cases: If zero or one toplevels were mapped there is no need to
- * enumerate Windows.
- */
-
- switch (table.numEntries) {
- case 0:
- windows[0] = NULL;
- goto done;
- case 1:
- hPtr = Tcl_FirstHashEntry(&table, &search);
- windows[0] = Tcl_GetHashValue(hPtr);
- windows[1] = NULL;
- goto done;
- }
-
NSArray *macWindows = [NSApp orderedWindows];
+ NSArray* backToFront = [[macWindows reverseObjectEnumerator] allObjects];
NSInteger windowCount = [macWindows count];
- if (!windowCount) {
- ckfree(windows);
- windows = NULL;
- } else {
- windowPtr = windows + table.numEntries;
- *windowPtr-- = NULL;
- for (NSWindow *w in macWindows) {
+ windows = windowPtr = (TkWindow **)ckalloc((windowCount + 1) * sizeof(TkWindow *));
+ if (windows != NULL) {
+ Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS);
+ WmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table);
+ for (NSWindow *w in backToFront) {
hPtr = Tcl_FindHashEntry(&table, (char*) w);
if (hPtr != NULL) {
childWinPtr = Tcl_GetHashValue(hPtr);
- *windowPtr-- = childWinPtr;
+ *windowPtr++ = childWinPtr;
}
}
- if (windowPtr != windows-1) {
- Tcl_Panic("num matched toplevel windows does not equal num "
- "children");
- }
+ *windowPtr = NULL;
+ Tcl_DeleteHashTable(&table);
}
-
- done:
- Tcl_DeleteHashTable(&table);
return windows;
}
@@ -6567,6 +6722,7 @@ TkMacOSXApplyWindowAttributes(
NSWindow *macWindow)
{
WmInfo *wmPtr = winPtr->wmInfoPtr;
+
ApplyWindowAttributeFlagChanges(winPtr, macWindow, 0, 0, 0, 1);
if (wmPtr->master != NULL || winPtr->atts.override_redirect) {
ApplyMasterOverrideChanges(winPtr, macWindow);
@@ -6606,18 +6762,16 @@ ApplyWindowAttributeFlagChanges(
if (changedAttributes || wmPtr->flags != oldFlags || initial) {
if (!macWindow) {
if (winPtr->window == None) {
- if (create) {
- Tk_MakeWindowExist((Tk_Window) winPtr);
- } else {
+ if (!create) {
return;
}
+ Tk_MakeWindowExist((Tk_Window) winPtr);
}
if (!TkMacOSXHostToplevelExists(winPtr)) {
- if (create) {
- TkMacOSXMakeRealWindowExist(winPtr);
- } else {
+ if (!create) {
return;
}
+ TkMacOSXMakeRealWindowExist(winPtr);
}
macWindow = TkMacOSXDrawableWindow(winPtr->window);
}
@@ -6654,6 +6808,7 @@ ApplyWindowAttributeFlagChanges(
if ((newAttributes & kWindowToolbarButtonAttribute) &&
![macWindow toolbar]) {
NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@""];
+
[toolbar setVisible:NO];
[macWindow setToolbar:toolbar];
[toolbar release];
@@ -6697,29 +6852,30 @@ ApplyWindowAttributeFlagChanges(
#if !(MAC_OS_X_VERSION_MAX_ALLOWED < 101000)
if (!(macWindow.styleMask & NSUtilityWindowMask)) {
-
/*
* Exclude overrideredirect, transient, and "help"-styled
* windows from moving into their own fullscreen space.
- *
*/
if ((winPtr->atts.override_redirect) ||
- (wmPtr->master != NULL) ||
- (winPtr->wmInfoPtr->macClass == kHelpWindowClass)) {
+ (wmPtr->master != NULL) ||
+ (winPtr->wmInfoPtr->macClass == kHelpWindowClass)) {
b |= (NSWindowCollectionBehaviorCanJoinAllSpaces |
- NSWindowCollectionBehaviorFullScreenAuxiliary);
+ NSWindowCollectionBehaviorFullScreenAuxiliary);
} else {
- NSSize screenSize = [[macWindow screen]frame].size;
+ NSSize screenSize = [[macWindow screen] frame].size;
b |= NSWindowCollectionBehaviorFullScreenPrimary;
- /* The default max size has height less than the screen height.
- * This causes the window manager to refuse to allow the window
- * to be resized when it is a split window. To work around
- * this we make the max size equal to the screen size.
+ /*
+ * The default max size has height less than the screen
+ * height. This causes the window manager to refuse to
+ * allow the window to be resized when it is a split
+ * window. To work around this we make the max size equal
+ * to the screen size. (For 10.11 and up, only)
*/
-
- [macWindow setMaxFullScreenContentSize:screenSize];
+ if ([NSApp macMinorVersion] > 10) {
+ [macWindow setMaxFullScreenContentSize:screenSize];
+ }
}
}
#endif
@@ -6749,6 +6905,7 @@ ApplyWindowAttributeFlagChanges(
*/
NSRect structureRect = [macWindow frameRectForContentRect:NSZeroRect];
+
wmPtr->xInParent = -structureRect.origin.x;
wmPtr->yInParent = structureRect.origin.y + structureRect.size.height;
wmPtr->parentWidth = winPtr->changes.width + structureRect.size.width;
@@ -6824,7 +6981,7 @@ ApplyMasterOverrideChanges(
}
if (macWindow) {
structureRect = [NSWindow frameRectForContentRect:NSZeroRect
- styleMask:styleMask];
+ styleMask:styleMask];
/*
* Synchronize the wmInfoPtr to match the new window configuration
@@ -6848,6 +7005,7 @@ ApplyMasterOverrideChanges(
}
} else {
const char *title = winPtr->wmInfoPtr->titleUid;
+
if (!title) {
title = winPtr->nameUid;
}
@@ -6857,11 +7015,12 @@ ApplyMasterOverrideChanges(
wmPtr->flags &= ~WM_TOPMOST;
}
if (wmPtr->master != None) {
- TkWindow *masterWinPtr = (TkWindow *)wmPtr->master;
- if (masterWinPtr && masterWinPtr->window != None &&
- TkMacOSXHostToplevelExists(masterWinPtr)) {
+ TkWindow *masterWinPtr = (TkWindow *) wmPtr->master;
+
+ if (masterWinPtr && (masterWinPtr->window != None)
+ && TkMacOSXHostToplevelExists(masterWinPtr)) {
NSWindow *masterMacWin = TkMacOSXDrawableWindow(
- masterWinPtr->window);
+ masterWinPtr->window);
/*
* Try to add the transient window as a child window of the
@@ -6872,10 +7031,8 @@ ApplyMasterOverrideChanges(
* zombie. So we only do this if the parent is visible.
*/
- if (masterMacWin &&
- [masterMacWin isVisible] &&
- (winPtr->flags & TK_MAPPED)) {
-
+ if (masterMacWin && [masterMacWin isVisible]
+ && (winPtr->flags & TK_MAPPED)) {
/*
* If the transient is already a child of some other window,
* remove it.
@@ -6887,8 +7044,8 @@ ApplyMasterOverrideChanges(
}
[masterMacWin addChildWindow:macWindow
- ordered:NSWindowAbove];
- }
+ ordered:NSWindowAbove];
+ }
}
} else {
parentWindow = [macWindow parentWindow];
@@ -7079,6 +7236,7 @@ RemapWindows(
MacDrawable *parentWin)
{
TkWindow *childPtr;
+
/*
* Remove the OS specific window. It will get rebuilt when the window gets
* Mapped.
@@ -7096,7 +7254,10 @@ RemapWindows(
#endif
}
- /* Repeat for all the children */
+ /*
+ * Repeat for all the children.
+ */
+
for (childPtr = winPtr->childList; childPtr != NULL;
childPtr = childPtr->nextPtr) {
RemapWindows(childPtr, (MacDrawable *) winPtr->window);
diff --git a/macosx/tkMacOSXWm.h b/macosx/tkMacOSXWm.h
index 5f07fe6..20bbb6d 100644
--- a/macosx/tkMacOSXWm.h
+++ b/macosx/tkMacOSXWm.h
@@ -43,7 +43,7 @@ typedef struct ProtocolHandler {
typedef struct Transient {
TkWindow *winPtr;
int flags;
- struct Transient *nextPtr;
+ struct Transient *nextPtr;
} Transient;
#define WITHDRAWN_BY_MASTER 0x1
diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c
index 9c8ea68..4912583 100644
--- a/macosx/tkMacOSXXStubs.c
+++ b/macosx/tkMacOSXXStubs.c
@@ -16,7 +16,7 @@
*/
#include "tkMacOSXPrivate.h"
-#include "tkMacOSXEvent.h"
+#include "tkMacOSXInt.h"
#include <IOKit/IOKitLib.h>
#include <IOKit/hidsystem/IOHIDShared.h>
@@ -33,9 +33,6 @@
#define ROOT_ID 10
-CGFloat tkMacOSXZeroScreenHeight = 0;
-CGFloat tkMacOSXZeroScreenTop = 0;
-
/*
* Declarations of static variables used in this file.
*/
@@ -90,13 +87,9 @@ TkMacOSXDisplayChanged(
nsScreens = [NSScreen screens];
if (nsScreens && [nsScreens count]) {
NSScreen *s = [nsScreens objectAtIndex:0];
- NSRect bounds = [s frame], visible = [s visibleFrame];
+ NSRect bounds = [s frame];
NSRect maxBounds = NSZeroRect;
- tkMacOSXZeroScreenHeight = bounds.size.height;
- tkMacOSXZeroScreenTop = tkMacOSXZeroScreenHeight -
- (visible.origin.y + visible.size.height);
-
screen->root_depth = NSBitsPerPixelFromDepth([s depth]);
screen->width = bounds.size.width;
screen->height = bounds.size.height;
@@ -113,7 +106,68 @@ TkMacOSXDisplayChanged(
/*
*----------------------------------------------------------------------
*
- * TkpOpenDisplay --
+ * TkMacOSXZeroScreenHeight --
+ *
+ * Replacement for the tkMacOSXZeroScreenHeight variable to avoid
+ * caching values from NSScreen (fixes bug aea00be199).
+ *
+ * Results:
+ * Returns the height of screen 0 (the screen assigned the menu bar
+ * in System Preferences), or 0.0 if getting [NSScreen screens] fails.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+CGFloat
+TkMacOSXZeroScreenHeight()
+{
+ NSArray *nsScreens = [NSScreen screens];
+ if (nsScreens && [nsScreens count]) {
+ NSScreen *s = [nsScreens objectAtIndex:0];
+ NSRect bounds = [s frame];
+ return bounds.size.height;
+ }
+ return 0.0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXZeroScreenTop --
+ *
+ * Replacement for the tkMacOSXZeroScreenTop variable to avoid
+ * caching values from visibleFrame.
+ *
+ * Results:
+ * Returns how far below the top of screen 0 to draw
+ * (i.e. the height of the menu bar if it is always shown),
+ * or 0.0 if getting [NSScreen screens] fails.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+CGFloat
+TkMacOSXZeroScreenTop()
+{
+ NSArray *nsScreens = [NSScreen screens];
+ if (nsScreens && [nsScreens count]) {
+ NSScreen *s = [nsScreens objectAtIndex:0];
+ NSRect bounds = [s frame], visible = [s visibleFrame];
+ return bounds.size.height - (visible.origin.y + visible.size.height);
+ }
+ return 0.0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpOpenDisplay/XkbOpenDisplay --
*
* Create the Display structure and fill it with device specific
* information.
@@ -132,11 +186,6 @@ TkpOpenDisplay(
const char *display_name)
{
Display *display;
- Screen *screen;
- int fd = 0;
- static NSRect maxBounds = {{0, 0}, {0, 0}};
- static char vendor[25] = "";
- NSArray *cgVers;
NSAutoreleasePool *pool = [NSAutoreleasePool new];
if (gMacDisplay != NULL) {
@@ -147,8 +196,49 @@ TkpOpenDisplay(
}
}
- display = ckalloc(sizeof(Display));
- screen = ckalloc(sizeof(Screen));
+ display = XkbOpenDisplay((char *)display_name, NULL, NULL, NULL, NULL, NULL);
+
+ /*
+ * Initialize screen bits that may change
+ */
+
+ TkMacOSXDisplayChanged(display);
+
+ gMacDisplay = (TkDisplay *)ckalloc(sizeof(TkDisplay));
+
+ /*
+ * This is the quickest way to make sure that all the *Init flags get
+ * properly initialized
+ */
+
+ bzero(gMacDisplay, sizeof(TkDisplay));
+ gMacDisplay->display = display;
+ [pool drain];
+
+ /*
+ * Key map info must be available immediately, because of "send event".
+ */
+ TkpInitKeymapInfo(gMacDisplay);
+
+ return gMacDisplay;
+}
+
+Display *
+XkbOpenDisplay(
+ TCL_UNUSED(const char *),
+ int *ev_rtrn,
+ int *err_rtrn,
+ int *major_rtrn,
+ int *minor_rtrn,
+ int *reason)
+{
+ Display *display = (Display *)ckalloc(sizeof(Display));
+ Screen *screen = (Screen *)ckalloc(sizeof(Screen));
+ int fd = 0;
+ NSArray *cgVers;
+ static char vendor[25] = "";
+ static NSRect maxBounds = {{0, 0}, {0, 0}};
+
bzero(display, sizeof(Display));
bzero(screen, sizeof(Screen));
@@ -161,6 +251,24 @@ TkpOpenDisplay(
display->default_screen = 0;
display->display_name = (char *) macScreenName;
+ /*
+ * These screen bits never change
+ */
+ screen->root = ROOT_ID;
+ screen->display = display;
+ screen->black_pixel = 0x00000000 | PIXEL_MAGIC << 24;
+ screen->white_pixel = 0x00FFFFFF | PIXEL_MAGIC << 24;
+ screen->ext_data = (XExtData *) &maxBounds;
+
+ screen->root_visual = (Visual *)ckalloc(sizeof(Visual));
+ screen->root_visual->visualid = 0;
+ screen->root_visual->c_class = TrueColor;
+ screen->root_visual->red_mask = 0x00FF0000;
+ screen->root_visual->green_mask = 0x0000FF00;
+ screen->root_visual->blue_mask = 0x000000FF;
+ screen->root_visual->bits_per_rgb = 24;
+ screen->root_visual->map_entries = 256;
+
cgVers = [[[NSBundle bundleWithIdentifier:@"com.apple.CoreGraphics"]
objectForInfoDictionaryKey:@"CFBundleShortVersionString"]
componentsSeparatedByString:@"."];
@@ -178,7 +286,7 @@ TkpOpenDisplay(
{
int major, minor, patch;
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 101000
Gestalt(gestaltSystemVersionMajor, (SInt32*)&major);
Gestalt(gestaltSystemVersionMinor, (SInt32*)&minor);
Gestalt(gestaltSystemVersionBugFix, (SInt32*)&patch);
@@ -191,42 +299,16 @@ TkpOpenDisplay(
display->release = major << 16 | minor << 8 | patch;
}
- /*
- * These screen bits never change
- */
- screen->root = ROOT_ID;
- screen->display = display;
- screen->black_pixel = 0x00000000 | PIXEL_MAGIC << 24;
- screen->white_pixel = 0x00FFFFFF | PIXEL_MAGIC << 24;
- screen->ext_data = (XExtData *) &maxBounds;
- screen->root_visual = ckalloc(sizeof(Visual));
- screen->root_visual->visualid = 0;
- screen->root_visual->class = TrueColor;
- screen->root_visual->red_mask = 0x00FF0000;
- screen->root_visual->green_mask = 0x0000FF00;
- screen->root_visual->blue_mask = 0x000000FF;
- screen->root_visual->bits_per_rgb = 24;
- screen->root_visual->map_entries = 256;
+ if (ev_rtrn) *ev_rtrn = 0;
+ if (err_rtrn) *err_rtrn = 0;
+ if (major_rtrn) *major_rtrn = 0;
+ if (minor_rtrn) *minor_rtrn = 0;
+ if (reason) *reason = 0;
- /*
- * Initialize screen bits that may change
- */
-
- TkMacOSXDisplayChanged(display);
-
- gMacDisplay = ckalloc(sizeof(TkDisplay));
-
- /*
- * This is the quickest way to make sure that all the *Init flags get
- * properly initialized
- */
-
- bzero(gMacDisplay, sizeof(TkDisplay));
- gMacDisplay->display = display;
- [pool drain];
- return gMacDisplay;
+ return display;
}
+
/*
*----------------------------------------------------------------------
@@ -327,7 +409,7 @@ TkClipCleanup(
static XID
MacXIdAlloc(
- Display *display) /* Display for which to allocate. */
+ TCL_UNUSED(Display *)) /* Display for which to allocate. */
{
static long int cur_id = 100;
/*
@@ -357,8 +439,8 @@ MacXIdAlloc(
static int
DefaultErrorHandler(
- Display* display,
- XErrorEvent* err_evt)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(XErrorEvent *))
{
/*
* This call should never be called. Tk replaces it with its own error
@@ -371,8 +453,8 @@ DefaultErrorHandler(
char *
XGetAtomName(
- Display * display,
- Atom atom)
+ Display *display,
+ TCL_UNUSED(Atom))
{
display->request++;
return NULL;
@@ -380,7 +462,7 @@ XGetAtomName(
XErrorHandler
XSetErrorHandler(
- XErrorHandler handler)
+ TCL_UNUSED(XErrorHandler))
{
return DefaultErrorHandler;
}
@@ -388,7 +470,7 @@ XSetErrorHandler(
Window
XRootWindow(
Display *display,
- int screen_number)
+ TCL_UNUSED(int))
{
display->request++;
return ROOT_ID;
@@ -429,33 +511,35 @@ XGetGeometry(
return 1;
}
-void
+int
XChangeProperty(
- Display* display,
- Window w,
- Atom property,
- Atom type,
- int format,
- int mode,
- _Xconst unsigned char* data,
- int nelements)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(Atom),
+ TCL_UNUSED(Atom),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(_Xconst unsigned char *),
+ TCL_UNUSED(int))
{
Debugger();
+ return Success;
}
-void
+int
XSelectInput(
- Display* display,
- Window w,
- long event_mask)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(long))
{
Debugger();
+ return Success;
}
int
XBell(
- Display* display,
- int percent)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(int))
{
NSBeep();
return Success;
@@ -464,9 +548,9 @@ XBell(
#if 0
void
XSetWMNormalHints(
- Display* display,
- Window w,
- XSizeHints* hints)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(XSizeHints *))
{
/*
* Do nothing. Shouldn't even be called.
@@ -487,7 +571,7 @@ XAllocSizeHints(void)
GContext
XGContextFromGC(
- GC gc)
+ TCL_UNUSED(GC))
{
/*
* TODO: currently a no-op
@@ -498,21 +582,22 @@ XGContextFromGC(
Status
XSendEvent(
- Display* display,
- Window w,
- Bool propagate,
- long event_mask,
- XEvent* event_send)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(Bool),
+ TCL_UNUSED(long),
+ TCL_UNUSED(XEvent *))
{
Debugger();
return 0;
}
-void
+int
XClearWindow(
- Display* display,
- Window w)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window))
{
+ return Success;
}
/*
@@ -524,6 +609,7 @@ XDrawPoint(
int x,
int y)
{
+ return Success;
}
int
@@ -535,28 +621,29 @@ XDrawPoints(
int npoints,
int mode)
{
+ return Success;
}
*/
int
XWarpPointer(
- Display* display,
- Window src_w,
- Window dest_w,
- int src_x,
- int src_y,
- unsigned int src_width,
- unsigned int src_height,
- int dest_x,
- int dest_y)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(unsigned int),
+ TCL_UNUSED(unsigned int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int))
{
return Success;
}
-void
+int
XQueryColor(
- Display* display,
- Colormap colormap,
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Colormap),
XColor* def_in_out)
{
unsigned long p;
@@ -572,12 +659,101 @@ XQueryColor(
d->blue = (b << 8) | b;
d->flags = DoRed|DoGreen|DoBlue;
d->pad = 0;
+ return Success;
}
-void
+Bool
+XTranslateCoordinates(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int *),
+ TCL_UNUSED(int *),
+ TCL_UNUSED(Window *))
+{
+ return 0;
+}
+
+int
+XSetCommand(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(char **),
+ TCL_UNUSED(int))
+{
+ return Success;
+}
+
+int
+XGetWindowAttributes(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(XWindowAttributes *))
+{
+ return Success;
+}
+
+Status
+XGetWMColormapWindows(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(Window **),
+ TCL_UNUSED(int *))
+{
+ return Success;
+}
+
+int
+XIconifyWindow(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(int))
+{
+ return Success;
+}
+
+XHostAddress *
+XListHosts(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(int *),
+ TCL_UNUSED(Bool *))
+{
+ return NULL;
+}
+
+int
+XLookupColor(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Colormap),
+ TCL_UNUSED(_Xconst char *),
+ TCL_UNUSED(XColor *),
+ TCL_UNUSED(XColor *))
+{
+ return Success;
+}
+
+int
+XNextEvent(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(XEvent *))
+{
+ return Success;
+}
+
+int
+XPutBackEvent(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(XEvent *))
+{
+ return Success;
+}
+
+int
XQueryColors(
- Display* display,
- Colormap colormap,
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Colormap),
XColor* defs_in_out,
int ncolors)
{
@@ -597,17 +773,17 @@ XQueryColors(
d->flags = DoRed|DoGreen|DoBlue;
d->pad = 0;
}
+ return Success;
}
int
-XQueryTree(display, w, root_return, parent_return, children_return,
- nchildren_return)
- Display* display;
- Window w;
- Window* root_return;
- Window* parent_return;
- Window** children_return;
- unsigned int* nchildren_return;
+XQueryTree(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(Window *),
+ TCL_UNUSED(Window *),
+ TCL_UNUSED(Window **),
+ TCL_UNUSED(unsigned int *))
{
return 0;
}
@@ -616,17 +792,17 @@ XQueryTree(display, w, root_return, parent_return, children_return,
int
XGetWindowProperty(
Display *display,
- Window w,
- Atom property,
- long long_offset,
- long long_length,
- Bool delete,
- Atom req_type,
+ TCL_UNUSED(Window),
+ TCL_UNUSED(Atom),
+ TCL_UNUSED(long),
+ TCL_UNUSED(long),
+ TCL_UNUSED(Bool),
+ TCL_UNUSED(Atom),
Atom *actual_type_return,
int *actual_format_return,
unsigned long *nitems_return,
unsigned long *bytes_after_return,
- unsigned char ** prop_return)
+ TCL_UNUSED(unsigned char **))
{
display->request++;
*actual_type_return = None;
@@ -635,30 +811,63 @@ XGetWindowProperty(
return 0;
}
-void
+int
+XWindowEvent(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(long),
+ TCL_UNUSED(XEvent *))
+{
+ return Success;
+}
+
+int
+XWithdrawWindow(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(int))
+{
+ return Success;
+}
+
+int
+XmbLookupString(
+ TCL_UNUSED(XIC),
+ TCL_UNUSED(XKeyPressedEvent *),
+ TCL_UNUSED(char *),
+ TCL_UNUSED(int),
+ TCL_UNUSED(KeySym *),
+ TCL_UNUSED(Status *))
+{
+ return Success;
+}
+
+int
XRefreshKeyboardMapping(
- XMappingEvent *x)
+ TCL_UNUSED(XMappingEvent *))
{
/* used by tkXEvent.c */
Debugger();
+ return Success;
}
-void
+int
XSetIconName(
Display* display,
- Window w,
- const char *icon_name)
+ TCL_UNUSED(Window),
+ TCL_UNUSED(const char *))
{
/*
* This is a no-op, no icon name for Macs.
*/
display->request++;
+ return Success;
}
-void
+int
XForceScreenSaver(
Display* display,
- int mode)
+ TCL_UNUSED(int))
{
/*
* This function is just a no-op. It is defined to reset the screen saver.
@@ -667,16 +876,7 @@ XForceScreenSaver(
*/
display->request++;
-}
-
-int
-XSync(
- Display *display,
- Bool flag)
-{
- TkMacOSXFlushWindows();
- display->request++;
- return 0;
+ return Success;
}
#if 0
@@ -690,18 +890,18 @@ XSetClipRectangles(
int n,
int ordering)
{
- TkRegion clipRgn = TkCreateRegion();
+ Region clipRgn = XCreateRegion();
while (n--) {
XRectangle rect = *rectangles;
rect.x += clip_x_origin;
rect.y += clip_y_origin;
- TkUnionRectWithRegion(&rect, clipRgn, clipRgn);
+ XUnionRectWithRegion(&rect, clipRgn, clipRgn);
rectangles++;
}
- TkSetRegion(d, gc, clipRgn);
- TkDestroyRegion(clipRgn);
+ XSetRegion(d, gc, clipRgn);
+ XDestroyRegion(clipRgn);
return 1;
}
#endif
@@ -762,90 +962,179 @@ TkGetServerInfo(
*----------------------------------------------------------------------
*/
-void
+int
XChangeWindowAttributes(
- Display *display,
- Window w,
- unsigned long value_mask,
- XSetWindowAttributes *attributes)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(unsigned long),
+ TCL_UNUSED(XSetWindowAttributes *))
{
+ return Success;
}
-void
+int
XSetWindowBackground(
- Display *display,
- Window window,
- unsigned long value)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(unsigned long))
{
+ return Success;
}
-void
+int
XSetWindowBackgroundPixmap(
- Display *display,
- Window w,
- Pixmap background_pixmap)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(Pixmap))
{
+ return Success;
}
-void
+int
XSetWindowBorder(
- Display *display,
- Window w,
- unsigned long border_pixel)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(unsigned long))
{
+ return Success;
}
-void
+int
XSetWindowBorderPixmap(
- Display *display,
- Window w,
- Pixmap border_pixmap)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(Pixmap))
{
+ return Success;
}
-void
+int
XSetWindowBorderWidth(
- Display *display,
- Window w,
- unsigned int width)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(unsigned int))
{
+ return Success;
}
-void
+int
XSetWindowColormap(
- Display *display,
- Window w,
- Colormap colormap)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(Colormap))
{
Debugger();
+ return Success;
}
Status
XStringListToTextProperty(
- char **list,
- int count,
- XTextProperty *text_prop_return)
+ TCL_UNUSED(char **),
+ TCL_UNUSED(int),
+ TCL_UNUSED(XTextProperty *))
{
Debugger();
- return (Status) 0;
+ return Success;
}
void
XSetWMClientMachine(
- Display *display,
- Window w,
- XTextProperty *text_prop)
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(XTextProperty *))
{
Debugger();
}
XIC
-XCreateIC(void)
+XCreateIC(TCL_UNUSED(XIM), ...)
{
Debugger();
return (XIC) 0;
}
+int
+XDeleteProperty(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Window),
+ TCL_UNUSED(Atom))
+{
+ return Success;
+}
+
+int
+XGetInputFocus(
+ Display *display,
+ TCL_UNUSED(Window *),
+ TCL_UNUSED(int *))
+{
+ display->request++;
+ return Success;
+}
+
+VisualID
+XVisualIDFromVisual(
+ Visual *visual)
+{
+ return visual->visualid;
+}
+
+XAfterFunction
+XSynchronize(
+ Display *display,
+ TCL_UNUSED(Bool))
+{
+ display->request++;
+ return NULL;
+}
+
+int
+XUngrabServer(
+ TCL_UNUSED(Display *))
+{
+ return 0;
+}
+
+int
+XFreeCursor(
+ TCL_UNUSED(Display *),
+ TCL_UNUSED(Cursor))
+{
+ return Success;
+}
+
+int
+XNoOp(
+ Display *display)
+{
+ display->request++;
+ return 0;
+}
+
+int
+XGrabServer(
+ TCL_UNUSED(Display *))
+{
+ return 0;
+}
+
+int
+XFree(
+ void *data)
+{
+ if ((data) != NULL) {
+ ckfree(data);
+ }
+ return 0;
+}
+
+int
+XFlush(
+ TCL_UNUSED(Display *))
+{
+ return 0;
+}
+
/*
*----------------------------------------------------------------------
*
@@ -865,7 +1154,7 @@ XCreateIC(void)
const char *
TkGetDefaultScreenName(
- Tcl_Interp *interp, /* Not used. */
+ TCL_UNUSED(Tcl_Interp *),
const char *screenName) /* If NULL, use default string. */
{
if ((screenName == NULL) || (screenName[0] == '\0')) {
@@ -892,7 +1181,7 @@ TkGetDefaultScreenName(
long
Tk_GetUserInactiveTime(
- Display *dpy)
+ TCL_UNUSED(Display *))
{
io_registry_entry_t regEntry;
CFMutableDictionaryRef props = NULL;
@@ -958,7 +1247,7 @@ Tk_GetUserInactiveTime(
void
Tk_ResetUserInactiveTime(
- Display *dpy)
+ TCL_UNUSED(Display *))
{
lastInactivityReset = TkpGetMS();
}
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index f9611c5..72649f6 100644
--- a/macosx/ttkMacOSXTheme.c
+++ b/macosx/ttkMacOSXTheme.c
@@ -1,13 +1,14 @@
/*
* ttkMacOSXTheme.c --
*
- * Tk theme engine for Mac OSX, using the Appearance Manager API.
+ * Tk theme engine for Mac OSX, using the Appearance Manager API.
*
* Copyright (c) 2004 Joe English
* Copyright (c) 2005 Neil Madden
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
* Copyright 2008-2009, Apple Inc.
* Copyright 2009 Kevin Walzer/WordTech Communications LLC.
+ * Copyright 2019 Marc Culler
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -15,34 +16,35 @@
* See also:
*
* <URL: http://developer.apple.com/documentation/Carbon/Reference/
- * Appearance_Manager/appearance_manager/APIIndex.html >
+ * Appearance_Manager/appearance_manager/APIIndex.html >
*
* Notes:
- * "Active" means different things in Mac and Tk terminology --
- * On Aqua, widgets are "Active" if they belong to the foreground window,
- * "Inactive" if they are in a background window.
- * Tk uses the term "active" to mean that the mouse cursor
- * is over a widget; aka "hover", "prelight", or "hot-tracked".
- * Aqua doesn't use this kind of feedback.
+ * "Active" means different things in Mac and Tk terminology --
+ * On Aqua, widgets are "Active" if they belong to the foreground window,
+ * "Inactive" if they are in a background window. Tk uses the term
+ * "active" to mean that the mouse cursor is over a widget; aka "hover",
+ * "prelight", or "hot-tracked". Aqua doesn't use this kind of feedback.
*
- * The QuickDraw/Carbon coordinate system is relative to the
- * top-level window, not to the Tk_Window. BoxToRect()
- * accounts for this.
+ * The QuickDraw/Carbon coordinate system is relative to the top-level
+ * window, not to the Tk_Window. BoxToRect() accounts for this.
*/
#include "tkMacOSXPrivate.h"
#include "ttk/ttkTheme.h"
+#include <math.h>
/*
- * Use this version in the core:
+ * Macros for handling drawing contexts.
*/
-#define BEGIN_DRAWING(d) { \
+
+#define BEGIN_DRAWING(d) { \
TkMacOSXDrawingContext dc; \
if (!TkMacOSXSetupDrawingContext((d), NULL, 1, &dc)) {return;}
#define END_DRAWING \
- TkMacOSXRestoreDrawingContext(&dc); }
+ TkMacOSXRestoreDrawingContext(&dc);}
#define HIOrientation kHIThemeOrientationNormal
+#define NoThemeMetric 0xFFFFFFFF
#ifdef __LP64__
#define RangeToFactor(maximum) (((double) (INT_MAX >> 1)) / (maximum))
@@ -50,24 +52,114 @@
#define RangeToFactor(maximum) (((double) (LONG_MAX >> 1)) / (maximum))
#endif /* __LP64__ */
+#define TTK_STATE_FIRST_TAB TTK_STATE_USER1
+#define TTK_STATE_LAST_TAB TTK_STATE_USER2
+#define TTK_TREEVIEW_STATE_SORTARROW TTK_STATE_USER1
+
+/*
+ * Colors and gradients used in Dark Mode.
+ */
+
+static CGFloat darkButtonFace[4] = {
+ 112.0 / 255, 113.0 / 255, 115.0 / 255, 1.0
+};
+static CGFloat darkPressedBevelFace[4] = {
+ 135.0 / 255, 136.0 / 255, 138.0 / 255, 1.0
+};
+static CGFloat darkSelectedBevelFace[4] = {
+ 162.0 / 255, 163.0 / 255, 165.0 / 255, 1.0
+};
+static CGFloat darkDisabledButtonFace[4] = {
+ 86.0 / 255, 87.0 / 255, 89.0 / 255, 1.0
+};
+static CGFloat darkInactiveSelectedTab[4] = {
+ 159.0 / 255, 160.0 / 255, 161.0 / 255, 1.0
+};
+static CGFloat darkFocusRing[4] = {
+ 38.0 / 255, 113.0 / 255, 159.0 / 255, 1.0
+};
+static CGFloat darkFocusRingTop[4] = {
+ 50.0 / 255, 124.0 / 255, 171.0 / 255, 1.0
+};
+static CGFloat darkFocusRingBottom[4] = {
+ 57.0 / 255, 130.0 / 255, 176.0 / 255, 1.0
+};
+static CGFloat darkTabSeparator[4] = {0.0, 0.0, 0.0, 0.25};
+static CGFloat darkTrack[4] = {1.0, 1.0, 1.0, 0.25};
+static CGFloat darkFrameTop[4] = {1.0, 1.0, 1.0, 0.0625};
+static CGFloat darkFrameBottom[4] = {1.0, 1.0, 1.0, 0.125};
+static CGFloat darkFrameAccent[4] = {0.0, 0.0, 0.0, 0.0625};
+static CGFloat darkTopGradient[8] = {
+ 1.0, 1.0, 1.0, 0.3,
+ 1.0, 1.0, 1.0, 0.0
+};
+static CGFloat darkBackgroundGradient[8] = {
+ 0.0, 0.0, 0.0, 0.1,
+ 0.0, 0.0, 0.0, 0.25
+};
+static CGFloat darkInactiveGradient[8] = {
+ 89.0 / 255, 90.0 / 255, 93.0 / 255, 1.0,
+ 119.0 / 255, 120.0 / 255, 122.0 / 255, 1.0
+};
+static CGFloat darkSelectedGradient[8] = {
+ 23.0 / 255, 111.0 / 255, 232.0 / 255, 1.0,
+ 20.0 / 255, 94.0 / 255, 206.0 / 255, 1.0
+};
+static CGFloat pressedPushButtonGradient[8] = {
+ 35.0 / 255, 123.0 / 255, 244.0 / 255, 1.0,
+ 30.0 / 255, 114.0 / 255, 235.0 / 255, 1.0
+};
+
+/*
+ * When building on systems earlier than 10.8 there is no reasonable way to
+ * convert an NSColor to a CGColor. We do run-time checking of the OS version,
+ * and never need the CGColor property on older systems, so we can use this
+ * CGCOLOR macro, which evaluates to NULL without raising compiler warnings.
+ * Similarly, we never draw rounded rectangles on older systems which did not
+ * have CGPathCreateWithRoundedRect, so we just redefine it to return NULL.
+ */
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
+#define CGCOLOR(nscolor) nscolor.CGColor
+#else
+#define CGCOLOR(nscolor) (0 ? (CGColorRef) nscolor : NULL)
+#define CGPathCreateWithRoundedRect(w, x, y, z) NULL
+#endif
+
+/*
+ * If we try to draw a rounded rectangle with too large of a radius
+ * CoreGraphics will raise a fatal exception. This macro returns if
+ * the width or height is less than twice the radius. Presumably this
+ * only happens when a widget has not yet been configured and has size
+ * 1x1.
+ */
+
+#define CHECK_RADIUS(radius, bounds) \
+ if (radius > bounds.size.width / 2 || radius > bounds.size.height / 2) { \
+ return; \
+ }
+
/*----------------------------------------------------------------------
* +++ Utilities.
*/
/*
* BoxToRect --
- * Convert a Ttk_Box in Tk coordinates relative to the given Drawable
- * to a native Rect relative to the containing port.
+ * Convert a Ttk_Box in Tk coordinates relative to the given Drawable
+ * to a native Rect relative to the containing port.
*/
-static inline CGRect BoxToRect(Drawable d, Ttk_Box b)
+
+static inline CGRect BoxToRect(
+ Drawable d,
+ Ttk_Box b)
{
- MacDrawable *md = (MacDrawable*)d;
+ MacDrawable *md = (MacDrawable *) d;
CGRect rect;
- rect.origin.y = b.y + md->yOff;
- rect.origin.x = b.x + md->xOff;
- rect.size.height = b.height;
- rect.size.width = b.width;
+ rect.origin.y = b.y + md->yOff;
+ rect.origin.x = b.x + md->xOff;
+ rect.size.height = b.height;
+ rect.size.width = b.width;
return rect;
}
@@ -77,72 +169,1123 @@ static inline CGRect BoxToRect(Drawable d, Ttk_Box b)
*/
static Ttk_StateTable ThemeStateTable[] = {
+ {kThemeStateActive, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0},
{kThemeStateUnavailable, TTK_STATE_DISABLED, 0},
{kThemeStatePressed, TTK_STATE_PRESSED, 0},
{kThemeStateInactive, TTK_STATE_BACKGROUND, 0},
{kThemeStateActive, 0, 0}
-/* Others: Not sure what these are supposed to mean.
- Up/Down have something to do with "little arrow" increment controls...
- Dunno what a "Rollover" is.
- NEM: Rollover is TTK_STATE_ACTIVE... but we don't handle that yet, by the
- looks of things
- {kThemeStateRollover, 0, 0},
- {kThemeStateUnavailableInactive, 0, 0}
- {kThemeStatePressedUp, 0, 0},
- {kThemeStatePressedDown, 0, 0}
-*/
+
+ /* Others: Not sure what these are supposed to mean. Up/Down have
+ * something to do with "little arrow" increment controls... Dunno what
+ * a "Rollover" is.
+ * NEM: Rollover is TTK_STATE_ACTIVE... but we don't handle that yet, by
+ * the looks of things
+ *
+ * {kThemeStateRollover, 0, 0},
+ * {kThemeStateUnavailableInactive, 0, 0}
+ * {kThemeStatePressedUp, 0, 0},
+ * {kThemeStatePressedDown, 0, 0}
+ */
};
/*----------------------------------------------------------------------
- * +++ Button element: Used for elements drawn with DrawThemeButton.
+ * NormalizeButtonBounds --
+ *
+ * Apple's Human Interface Guidelines only allow three specific heights
+ * for most buttons: Regular, small and mini. We always use the regular
+ * size. However, Ttk may provide an arbitrary bounding rectangle. We
+ * always draw the button centered vertically on the rectangle, and
+ * having the same width as the rectangle. This function returns the
+ * actual bounding rectangle that will be used in drawing the button.
+ *
+ * The BevelButton is allowed to have arbitrary size, and also has
+ * external padding. This is handled separately here.
+ */
+
+static CGRect NormalizeButtonBounds(
+ SInt32 heightMetric,
+ CGRect bounds)
+{
+ SInt32 height;
+
+ if (heightMetric != (SInt32) NoThemeMetric) {
+ ChkErr(GetThemeMetric, heightMetric, &height);
+ bounds.origin.y += (bounds.size.height - height) / 2;
+ bounds.size.height = height;
+ }
+ return bounds;
+}
+
+/*----------------------------------------------------------------------
+ * +++ Backgrounds
+ *
+ * Support for contrasting background colors when GroupBoxes or Tabbed
+ * panes are nested inside each other. Early versions of macOS used ridged
+ * borders, so do not need contrasting backgrounds.
*/
/*
- * Extra margins to account for drop shadow.
+ * For systems older than 10.14, [NSColor windowBackGroundColor] generates
+ * garbage when called from this function. In 10.14 it works correctly, and
+ * must be used in order to have a background color which responds to Dark
+ * Mode. So we use this hard-wired RGBA color on the older systems which don't
+ * support Dark Mode anyway.
*/
-static Ttk_Padding ButtonMargins = {2,2,2,2};
-#define NoThemeMetric 0xFFFFFFFF
+static CGFloat windowBackground[4] = {
+ 235.0 / 255, 235.0 / 255, 235.0 / 255, 1.0
+};
+static CGFloat whiteRGBA[4] = {1.0, 1.0, 1.0, 1.0};
+static CGFloat blackRGBA[4] = {0.0, 0.0, 0.0, 1.0};
+
+/*----------------------------------------------------------------------
+ * GetBackgroundColor --
+ *
+ * Fills the array rgba with the color coordinates for a background color.
+ * Start with the background color of a window's geometry master, or the
+ * standard ttk window background if there is no master. If the contrast
+ * parameter is nonzero, modify this color to be darker, for the aqua
+ * appearance, or lighter for the DarkAqua appearance. This is primarily
+ * used by the Fill and Background elements.
+ */
+
+static void GetBackgroundColor(
+ CGContextRef context,
+ Tk_Window tkwin,
+ int contrast,
+ CGFloat *rgba)
+{
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *masterPtr = (TkWindow *) TkGetGeomMaster(tkwin);
+ (void)context;
+
+ while (masterPtr && masterPtr->privatePtr) {
+ if (masterPtr->privatePtr->flags & TTK_HAS_CONTRASTING_BG) {
+ break;
+ }
+ masterPtr = (TkWindow *) TkGetGeomMaster(masterPtr);
+ }
+ if (masterPtr && masterPtr->privatePtr) {
+ for (int i = 0; i < 4; i++) {
+ rgba[i] = masterPtr->privatePtr->fillRGBA[i];
+ }
+ } else {
+ if ([NSApp macMinorVersion] > 13) {
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *windowColor = [[NSColor windowBackgroundColor]
+ colorUsingColorSpace: deviceRGB];
+ [windowColor getComponents: rgba];
+ } else {
+ for (int i = 0; i < 4; i++) {
+ rgba[i] = windowBackground[i];
+ }
+ }
+ }
+ if (contrast) {
+ int isDark = (rgba[0] + rgba[1] + rgba[2] < 1.5);
+
+ if (isDark) {
+ for (int i = 0; i < 3; i++) {
+ rgba[i] += 8.0 / 255.0;
+ }
+ } else {
+ for (int i = 0; i < 3; i++) {
+ rgba[i] -= 8.0 / 255.0;
+ }
+ }
+ if (winPtr->privatePtr) {
+ winPtr->privatePtr->flags |= TTK_HAS_CONTRASTING_BG;
+ for (int i = 0; i < 4; i++) {
+ winPtr->privatePtr->fillRGBA[i] = rgba[i];
+ }
+ }
+ }
+}
+
+
+/*----------------------------------------------------------------------
+ * +++ Single Arrow Buttons --
+ *
+ * Used in ListHeaders and Comboboxes.
+ */
+
+static void DrawDownArrow(
+ CGContextRef context,
+ CGRect bounds,
+ CGFloat inset,
+ CGFloat size,
+ CGFloat *rgba)
+{
+ CGFloat x, y;
+
+ CGContextSetRGBStrokeColor(context, rgba[0], rgba[1], rgba[2], rgba[3]);
+ CGContextSetLineWidth(context, 1.5);
+ x = bounds.origin.x + inset;
+ y = bounds.origin.y + trunc(bounds.size.height / 2);
+ CGContextBeginPath(context);
+ CGPoint arrow[3] = {
+ {x, y - size / 4}, {x + size / 2, y + size / 4},
+ {x + size, y - size / 4}
+ };
+ CGContextAddLines(context, arrow, 3);
+ CGContextStrokePath(context);
+}
+
+static void DrawUpArrow(
+ CGContextRef context,
+ CGRect bounds,
+ CGFloat inset,
+ CGFloat size,
+ CGFloat *rgba)
+{
+ CGFloat x, y;
+
+ CGContextSetRGBStrokeColor(context, rgba[0], rgba[1], rgba[2], rgba[3]);
+ CGContextSetLineWidth(context, 1.5);
+ x = bounds.origin.x + inset;
+ y = bounds.origin.y + trunc(bounds.size.height / 2);
+ CGContextBeginPath(context);
+ CGPoint arrow[3] = {
+ {x, y + size / 4}, {x + size / 2, y - size / 4},
+ {x + size, y + size / 4}
+ };
+ CGContextAddLines(context, arrow, 3);
+ CGContextStrokePath(context);
+}
+
+/*----------------------------------------------------------------------
+ * +++ Double Arrow Buttons --
+ *
+ * Used in MenuButtons and SpinButtons.
+ */
+
+static void DrawUpDownArrows(
+ CGContextRef context,
+ CGRect bounds,
+ CGFloat inset,
+ CGFloat size,
+ CGFloat *rgba)
+{
+ CGFloat x, y;
+
+ CGContextSetRGBStrokeColor(context, rgba[0], rgba[1], rgba[2], rgba[3]);
+ CGContextSetLineWidth(context, 1.5);
+ x = bounds.origin.x + inset;
+ y = bounds.origin.y + trunc(bounds.size.height / 2);
+ CGContextBeginPath(context);
+ CGPoint bottomArrow[3] =
+ {{x, y + 2}, {x + size / 2, y + 2 + size / 2}, {x + size, y + 2}};
+ CGContextAddLines(context, bottomArrow, 3);
+ CGPoint topArrow[3] =
+ {{x, y - 2}, {x + size / 2, y - 2 - size / 2}, {x + size, y - 2}};
+ CGContextAddLines(context, topArrow, 3);
+ CGContextStrokePath(context);
+}
+
+
+/*----------------------------------------------------------------------
+ * +++ FillButtonBackground --
+ *
+ * Fills a rounded rectangle with a transparent black gradient.
+ * This is a no-op if building on 10.8 or older.
+ */
+
+static void FillButtonBackground(
+ CGContextRef context,
+ CGRect bounds,
+ CGFloat radius)
+{
+ CHECK_RADIUS(radius, bounds)
+
+ CGPathRef path;
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ CGGradientRef backgroundGradient = CGGradientCreateWithColorComponents(
+ deviceRGB.CGColorSpace, darkBackgroundGradient, NULL, 2);
+ CGPoint backgroundEnd = {
+ bounds.origin.x,
+ bounds.origin.y + bounds.size.height
+ };
+ CGContextBeginPath(context);
+ path = CGPathCreateWithRoundedRect(bounds, radius, radius, NULL);
+ CGContextAddPath(context, path);
+ CGContextClip(context);
+ CGContextDrawLinearGradient(context, backgroundGradient,
+ bounds.origin, backgroundEnd, 0);
+ CFRelease(path);
+ CFRelease(backgroundGradient);
+}
+
+/*----------------------------------------------------------------------
+ * +++ HighlightButtonBorder --
+ *
+ * Accent the top border of a rounded rectangle with a transparent
+ * white gradient.
+ */
+
+static void HighlightButtonBorder(
+ CGContextRef context,
+ CGRect bounds)
+{
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ CGPoint topEnd = {bounds.origin.x, bounds.origin.y + 3};
+ CGGradientRef topGradient = CGGradientCreateWithColorComponents(
+ deviceRGB.CGColorSpace, darkTopGradient, NULL, 2);
+
+ CGContextSaveGState(context);
+ CGContextBeginPath(context);
+ CGContextAddArc(context, bounds.origin.x + 4, bounds.origin.y + 4,
+ 4, PI, 3 * PI / 2, 0);
+ CGContextAddArc(context, bounds.origin.x + bounds.size.width - 4,
+ bounds.origin.y + 4, 4, 3 * PI / 2, 0, 0);
+ CGContextReplacePathWithStrokedPath(context);
+ CGContextClip(context);
+ CGContextDrawLinearGradient(context, topGradient, bounds.origin, topEnd,
+ 0.0);
+ CGContextRestoreGState(context);
+ CFRelease(topGradient);
+}
+
+/*----------------------------------------------------------------------
+ * DrawGroupBox --
+ *
+ * This is a standalone drawing procedure which draws the contrasting
+ * rounded rectangular box for LabelFrames and Notebook panes used in
+ * more recent versions of macOS.
+ */
+
+static void DrawGroupBox(
+ CGRect bounds,
+ CGContextRef context,
+ Tk_Window tkwin)
+{
+ CHECK_RADIUS(4, bounds)
+
+ CGPathRef path;
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *borderColor, *bgColor;
+ static CGFloat border[4] = {1.0, 1.0, 1.0, 0.25};
+ CGFloat fill[4];
+
+ GetBackgroundColor(context, tkwin, 1, fill);
+ bgColor = [NSColor colorWithColorSpace: deviceRGB components: fill
+ count: 4];
+ CGContextSetFillColorSpace(context, deviceRGB.CGColorSpace);
+ CGContextSetFillColorWithColor(context, CGCOLOR(bgColor));
+ path = CGPathCreateWithRoundedRect(bounds, 4, 4, NULL);
+ CGContextClipToRect(context, bounds);
+ CGContextBeginPath(context);
+ CGContextAddPath(context, path);
+ CGContextFillPath(context);
+ borderColor = [NSColor colorWithColorSpace: deviceRGB components: border
+ count: 4];
+ CGContextSetFillColorWithColor(context, CGCOLOR(borderColor));
+ [borderColor getComponents: fill];
+ CGContextSetRGBFillColor(context, fill[0], fill[1], fill[2], fill[3]);
+
+ CGContextBeginPath(context);
+ CGContextAddPath(context, path);
+ CGContextReplacePathWithStrokedPath(context);
+ CGContextFillPath(context);
+ CFRelease(path);
+}
+
+/*----------------------------------------------------------------------
+ * SolidFillRoundedRectangle --
+ *
+ * Fill a rounded rectangle with a specified solid color.
+ */
+
+static void SolidFillRoundedRectangle(
+ CGContextRef context,
+ CGRect bounds,
+ CGFloat radius,
+ NSColor *color)
+{
+ CGPathRef path;
+ CHECK_RADIUS(radius, bounds)
+
+ CGContextSetFillColorWithColor(context, CGCOLOR(color));
+ path = CGPathCreateWithRoundedRect(bounds, radius, radius, NULL);
+ CGContextBeginPath(context);
+ CGContextAddPath(context, path);
+ CGContextFillPath(context);
+ CFRelease(path);
+}
+
+/*----------------------------------------------------------------------
+ * +++ DrawListHeader --
+ *
+ * This is a standalone drawing procedure which draws column headers for
+ * a Treeview in the Aqua appearance. The HITheme headers have not
+ * matched the native ones since OSX 10.8. Note that the header image is
+ * ignored, but we draw arrows according to the state.
+ */
+
+static void DrawListHeader(
+ CGRect bounds,
+ CGContextRef context,
+ Tk_Window tkwin,
+ int state)
+{
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *strokeColor, *bgColor;
+ static CGFloat borderRGBA[4] = {
+ 200.0 / 255, 200.0 / 255, 200.0 / 255, 1.0
+ };
+ static CGFloat separatorRGBA[4] = {
+ 220.0 / 255, 220.0 / 255, 220.0 / 255, 1.0
+ };
+ static CGFloat activeBgRGBA[4] = {
+ 238.0 / 255, 238.0 / 255, 238.0 / 255, 1.0
+ };
+ static CGFloat inactiveBgRGBA[4] = {
+ 246.0 / 255, 246.0 / 255, 246.0 / 255, 1.0
+ };
+
+ /*
+ * Apple changes the background of a list header when the window is not
+ * active. But Ttk does not indicate that in the state of a TreeHeader.
+ * So we have to query the Apple window manager.
+ */
+
+ NSWindow *win = TkMacOSXDrawableWindow(Tk_WindowId(tkwin));
+ CGFloat *bgRGBA = [win isKeyWindow] ? activeBgRGBA : inactiveBgRGBA;
+ CGFloat x = bounds.origin.x, y = bounds.origin.y;
+ CGFloat w = bounds.size.width, h = bounds.size.height;
+ CGPoint top[2] = {{x, y + 1}, {x + w, y + 1}};
+ CGPoint bottom[2] = {{x, y + h}, {x + w, y + h}};
+ CGPoint separator[2] = {{x + w - 1, y + 3}, {x + w - 1, y + h - 3}};
+
+ bgColor = [NSColor colorWithColorSpace: deviceRGB
+ components: bgRGBA
+ count: 4];
+ CGContextSaveGState(context);
+ CGContextSetShouldAntialias(context, false);
+ CGContextSetFillColorSpace(context, deviceRGB.CGColorSpace);
+ CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace);
+ CGContextBeginPath(context);
+ CGContextSetFillColorWithColor(context, CGCOLOR(bgColor));
+ CGContextAddRect(context, bounds);
+ CGContextFillPath(context);
+ strokeColor = [NSColor colorWithColorSpace: deviceRGB
+ components: separatorRGBA
+ count: 4];
+ CGContextSetStrokeColorWithColor(context, CGCOLOR(strokeColor));
+ CGContextAddLines(context, separator, 2);
+ CGContextStrokePath(context);
+ strokeColor = [NSColor colorWithColorSpace: deviceRGB
+ components: borderRGBA
+ count: 4];
+ CGContextSetStrokeColorWithColor(context, CGCOLOR(strokeColor));
+ CGContextAddLines(context, top, 2);
+ CGContextStrokePath(context);
+ CGContextAddLines(context, bottom, 2);
+ CGContextStrokePath(context);
+ CGContextRestoreGState(context);
+
+ if (state & TTK_TREEVIEW_STATE_SORTARROW) {
+ CGRect arrowBounds = bounds;
+ arrowBounds.origin.x = bounds.origin.x + bounds.size.width - 16;
+ arrowBounds.size.width = 16;
+ if (state & TTK_STATE_ALTERNATE) {
+ DrawUpArrow(context, arrowBounds, 3, 8, blackRGBA);
+ } else if (state & TTK_STATE_SELECTED) {
+ DrawDownArrow(context, arrowBounds, 3, 8, blackRGBA);
+ }
+ }
+}
+
+/*----------------------------------------------------------------------
+ * +++ Drawing procedures for widgets in Apple's "Dark Mode" (10.14 and up).
+ *
+ * The HIToolbox does not support Dark Mode, and apparently never will,
+ * so to make widgets look "native" we have to provide analogues of the
+ * HITheme drawing functions to be used in DarkAqua. We continue to use
+ * HITheme in Aqua, since it understands earlier versions of the OS.
+ *
+ * Drawing the dark widgets requires NSColors that were introduced in OSX
+ * 10.14, so we make some of these functions be no-ops when building on
+ * systems older than 10.14.
+ */
+
+/*----------------------------------------------------------------------
+ * GradientFillRoundedRectangle --
+ *
+ * Fill a rounded rectangle with a specified gradient.
+ */
+
+static void GradientFillRoundedRectangle(
+ CGContextRef context,
+ CGRect bounds,
+ CGFloat radius,
+ CGFloat *colors,
+ int numColors)
+{
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ CGPathRef path;
+ CHECK_RADIUS(radius, bounds)
+
+ CGPoint end = {
+ bounds.origin.x,
+ bounds.origin.y + bounds.size.height
+ };
+ CGGradientRef gradient = CGGradientCreateWithColorComponents(
+ deviceRGB.CGColorSpace, colors, NULL, numColors);
+
+ path = CGPathCreateWithRoundedRect(bounds, radius, radius, NULL);
+ CGContextBeginPath(context);
+ CGContextAddPath(context, path);
+ CGContextClip(context);
+ CGContextDrawLinearGradient(context, gradient, bounds.origin, end, 0);
+ CFRelease(path);
+ CFRelease(gradient);
+}
+
+/*----------------------------------------------------------------------
+ * +++ DrawDarkButton --
+ *
+ * This is a standalone drawing procedure which draws PushButtons and
+ * PopupButtons in the Dark Mode style.
+ */
+
+static void DrawDarkButton(
+ CGRect bounds,
+ ThemeButtonKind kind,
+ Ttk_State state,
+ CGContextRef context)
+{
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *faceColor;
+
+ /*
+ * To match the appearance of Apple's buttons we need to increase the
+ * height by 1 pixel.
+ */
+
+ bounds.size.height += 1;
+
+ CGContextClipToRect(context, bounds);
+ FillButtonBackground(context, bounds, 5);
+
+ /*
+ * Fill the button face with the appropriate color.
+ */
+
+ bounds = CGRectInset(bounds, 1, 1);
+ if (kind == kThemePushButton && (state & TTK_STATE_PRESSED)) {
+ GradientFillRoundedRectangle(context, bounds, 4,
+ pressedPushButtonGradient, 2);
+ } else if (kind == kThemePushButton &&
+ (state & TTK_STATE_ALTERNATE) &&
+ !(state & TTK_STATE_BACKGROUND)) {
+ GradientFillRoundedRectangle(context, bounds, 4,
+ darkSelectedGradient, 2);
+ } else {
+ if (state & TTK_STATE_DISABLED) {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkDisabledButtonFace
+ count: 4];
+ } else {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkButtonFace
+ count: 4];
+ }
+ SolidFillRoundedRectangle(context, bounds, 4, faceColor);
+ }
+
+ /*
+ * If this is a popup, draw the arrow button.
+ */
+
+ if ((kind == kThemePopupButton) | (kind == kThemeComboBox)) {
+ CGRect arrowBounds = bounds;
+ arrowBounds.size.width = 16;
+ arrowBounds.origin.x += bounds.size.width - 16;
+
+ /*
+ * If the toplevel is front, paint the button blue.
+ */
+
+ if (!(state & TTK_STATE_BACKGROUND) &&
+ !(state & TTK_STATE_DISABLED)) {
+ GradientFillRoundedRectangle(context, arrowBounds, 4,
+ darkSelectedGradient, 2);
+ }
+ if (kind == kThemePopupButton) {
+ DrawUpDownArrows(context, arrowBounds, 3, 7, whiteRGBA);
+ } else {
+ DrawDownArrow(context, arrowBounds, 4, 8, whiteRGBA);
+ }
+ }
+
+ HighlightButtonBorder(context, bounds);
+}
+
+/*----------------------------------------------------------------------
+ * +++ DrawDarkIncDecButton --
+ *
+ * This is a standalone drawing procedure which draws an IncDecButton
+ * (as used in a Spinbox) in the Dark Mode style.
+ */
+
+static void DrawDarkIncDecButton(
+ CGRect bounds,
+ ThemeDrawState drawState,
+ Ttk_State state,
+ CGContextRef context)
+{
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *faceColor;
+
+ bounds = CGRectInset(bounds, 0, -1);
+ CGContextClipToRect(context, bounds);
+ FillButtonBackground(context, bounds, 6);
+
+ /*
+ * Fill the button face with the appropriate color.
+ */
+
+ bounds = CGRectInset(bounds, 1, 1);
+ if (state & TTK_STATE_DISABLED) {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkDisabledButtonFace
+ count: 4];
+ } else {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkButtonFace
+ count: 4];
+ }
+ SolidFillRoundedRectangle(context, bounds, 4, faceColor);
+
+ /*
+ * If pressed, paint the appropriate half blue.
+ */
+
+ if (state & TTK_STATE_PRESSED) {
+ CGRect clip = bounds;
+ clip.size.height /= 2;
+ CGContextSaveGState(context);
+ if (drawState == kThemeStatePressedDown) {
+ clip.origin.y += clip.size.height;
+ }
+ CGContextClipToRect(context, clip);
+ GradientFillRoundedRectangle(context, bounds, 5,
+ darkSelectedGradient, 2);
+ CGContextRestoreGState(context);
+ }
+ DrawUpDownArrows(context, bounds, 3, 5, whiteRGBA);
+ HighlightButtonBorder(context, bounds);
+}
+
+/*----------------------------------------------------------------------
+ * +++ DrawDarkBevelButton --
+ *
+ * This is a standalone drawing procedure which draws RoundedBevelButtons
+ * in the Dark Mode style.
+ */
+
+static void DrawDarkBevelButton(
+ CGRect bounds,
+ Ttk_State state,
+ CGContextRef context)
+{
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *faceColor;
+
+ CGContextClipToRect(context, bounds);
+ FillButtonBackground(context, bounds, 5);
+
+ /*
+ * Fill the button face with the appropriate color.
+ */
+
+ bounds = CGRectInset(bounds, 1, 1);
+ if (state & TTK_STATE_PRESSED) {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkPressedBevelFace
+ count: 4];
+ } else if ((state & TTK_STATE_DISABLED) ||
+ (state & TTK_STATE_ALTERNATE)) {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkDisabledButtonFace
+ count: 4];
+ } else if (state & TTK_STATE_SELECTED) {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkSelectedBevelFace
+ count: 4];
+ } else {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkButtonFace
+ count: 4];
+ }
+ SolidFillRoundedRectangle(context, bounds, 4, faceColor);
+ HighlightButtonBorder(context, bounds);
+}
+
+/*----------------------------------------------------------------------
+ * +++ DrawDarkCheckBox --
+ *
+ * This is a standalone drawing procedure which draws Checkboxes in the
+ * Dark Mode style.
+ */
+
+static void DrawDarkCheckBox(
+ CGRect bounds,
+ Ttk_State state,
+ CGContextRef context)
+{
+ CGRect checkbounds = {{0, bounds.size.height / 2 - 8}, {16, 16}};
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *stroke;
+ CGFloat x, y;
+
+ bounds = CGRectOffset(checkbounds, bounds.origin.x, bounds.origin.y);
+ x = bounds.origin.x;
+ y = bounds.origin.y;
+
+ CGContextClipToRect(context, bounds);
+ FillButtonBackground(context, bounds, 4);
+ bounds = CGRectInset(bounds, 1, 1);
+ if (!(state & TTK_STATE_BACKGROUND) &&
+ !(state & TTK_STATE_DISABLED) &&
+ ((state & TTK_STATE_SELECTED) || (state & TTK_STATE_ALTERNATE))) {
+ GradientFillRoundedRectangle(context, bounds, 3,
+ darkSelectedGradient, 2);
+ } else {
+ GradientFillRoundedRectangle(context, bounds, 3,
+ darkInactiveGradient, 2);
+ }
+ HighlightButtonBorder(context, bounds);
+ if ((state & TTK_STATE_SELECTED) || (state & TTK_STATE_ALTERNATE)) {
+ CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace);
+ if (state & TTK_STATE_DISABLED) {
+ stroke = [NSColor disabledControlTextColor];
+ } else {
+ stroke = [NSColor controlTextColor];
+ }
+ CGContextSetStrokeColorWithColor(context, CGCOLOR(stroke));
+ }
+ if (state & TTK_STATE_SELECTED) {
+ CGContextSetLineWidth(context, 1.5);
+ CGContextBeginPath(context);
+ CGPoint check[3] = {{x + 4, y + 8}, {x + 7, y + 11}, {x + 11, y + 4}};
+ CGContextAddLines(context, check, 3);
+ CGContextStrokePath(context);
+ } else if (state & TTK_STATE_ALTERNATE) {
+ CGContextSetLineWidth(context, 2.0);
+ CGContextBeginPath(context);
+ CGPoint bar[2] = {{x + 4, y + 8}, {x + 12, y + 8}};
+ CGContextAddLines(context, bar, 2);
+ CGContextStrokePath(context);
+ }
+}
+
+/*----------------------------------------------------------------------
+ * +++ DrawDarkRadioButton --
+ *
+ * This is a standalone drawing procedure which draws RadioButtons
+ * in the Dark Mode style.
+ */
+
+static void DrawDarkRadioButton(
+ CGRect bounds,
+ Ttk_State state,
+ CGContextRef context)
+{
+ CGRect checkbounds = {{0, bounds.size.height / 2 - 9}, {18, 18}};
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *fill;
+ CGFloat x, y;
+
+ bounds = CGRectOffset(checkbounds, bounds.origin.x, bounds.origin.y);
+ x = bounds.origin.x;
+ y = bounds.origin.y;
+
+ CGContextClipToRect(context, bounds);
+ FillButtonBackground(context, bounds, 9);
+ bounds = CGRectInset(bounds, 1, 1);
+ if (!(state & TTK_STATE_BACKGROUND) &&
+ !(state & TTK_STATE_DISABLED) &&
+ ((state & TTK_STATE_SELECTED) || (state & TTK_STATE_ALTERNATE))) {
+ GradientFillRoundedRectangle(context, bounds, 8,
+ darkSelectedGradient, 2);
+ } else {
+ GradientFillRoundedRectangle(context, bounds, 8,
+ darkInactiveGradient, 2);
+ }
+ HighlightButtonBorder(context, bounds);
+ if ((state & TTK_STATE_SELECTED) || (state & TTK_STATE_ALTERNATE)) {
+ CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace);
+ if (state & TTK_STATE_DISABLED) {
+ fill = [NSColor disabledControlTextColor];
+ } else {
+ fill = [NSColor controlTextColor];
+ }
+ CGContextSetFillColorWithColor(context, CGCOLOR(fill));
+ }
+ if (state & TTK_STATE_SELECTED) {
+ CGContextBeginPath(context);
+ CGRect dot = {{x + 6, y + 6}, {6, 6}};
+ CGContextAddEllipseInRect(context, dot);
+ CGContextFillPath(context);
+ } else if (state & TTK_STATE_ALTERNATE) {
+ CGRect bar = {{x + 5, y + 8}, {8, 2}};
+ CGContextFillRect(context, bar);
+ }
+}
+
+/*----------------------------------------------------------------------
+ * +++ DrawDarkTab --
+ *
+ * This is a standalone drawing procedure which draws Tabbed Pane
+ * Tabs in the Dark Mode style.
+ */
+
+static void DrawDarkTab(
+ CGRect bounds,
+ Ttk_State state,
+ CGContextRef context)
+{
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *faceColor, *stroke;
+ CGRect originalBounds = bounds;
+
+ CGContextSetLineWidth(context, 1.0);
+ CGContextClipToRect(context, bounds);
+
+ /*
+ * Extend the bounds to one or both sides so the rounded part will be
+ * clipped off.
+ */
+
+ if (!(state & TTK_STATE_FIRST_TAB)) {
+ bounds.origin.x -= 10;
+ bounds.size.width += 10;
+ }
+
+ if (!(state & TTK_STATE_LAST_TAB)) {
+ bounds.size.width += 10;
+ }
+
+ /*
+ * Fill the tab face with the appropriate color or gradient. Use a solid
+ * color if the tab is not selected, otherwise use a blue or gray
+ * gradient.
+ */
+
+ bounds = CGRectInset(bounds, 1, 1);
+ if (!(state & TTK_STATE_SELECTED)) {
+ if (state & TTK_STATE_DISABLED) {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkDisabledButtonFace
+ count: 4];
+ } else {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkButtonFace
+ count: 4];
+ }
+ SolidFillRoundedRectangle(context, bounds, 4, faceColor);
+
+ /*
+ * Draw a separator line on the left side of the tab if it
+ * not first.
+ */
+
+ if (!(state & TTK_STATE_FIRST_TAB)) {
+ CGContextSaveGState(context);
+ CGContextSetShouldAntialias(context, false);
+ stroke = [NSColor colorWithColorSpace: deviceRGB
+ components: darkTabSeparator
+ count: 4];
+ CGContextSetStrokeColorWithColor(context, CGCOLOR(stroke));
+ CGContextBeginPath(context);
+ CGContextMoveToPoint(context, originalBounds.origin.x,
+ originalBounds.origin.y + 1);
+ CGContextAddLineToPoint(context, originalBounds.origin.x,
+ originalBounds.origin.y + originalBounds.size.height - 1);
+ CGContextStrokePath(context);
+ CGContextRestoreGState(context);
+ }
+ } else {
+
+ /*
+ * This is the selected tab; paint it blue. If it is first, cover up
+ * the separator line drawn by the second one. (The selected tab is
+ * always drawn last.)
+ */
+
+ if ((state & TTK_STATE_FIRST_TAB) && !(state & TTK_STATE_LAST_TAB)) {
+ bounds.size.width += 1;
+ }
+ if (!(state & TTK_STATE_BACKGROUND)) {
+ GradientFillRoundedRectangle(context, bounds, 4,
+ darkSelectedGradient, 2);
+ } else {
+ faceColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkInactiveSelectedTab
+ count: 4];
+ SolidFillRoundedRectangle(context, bounds, 4, faceColor);
+ }
+ HighlightButtonBorder(context, bounds);
+ }
+}
+
+/*----------------------------------------------------------------------
+ * +++ DrawDarkSeparator --
+ *
+ * This is a standalone drawing procedure which draws a separator widget
+ * in Dark Mode.
+ */
+
+static void DrawDarkSeparator(
+ CGRect bounds,
+ CGContextRef context,
+ Tk_Window tkwin)
+{
+ static CGFloat fill[4] = {1.0, 1.0, 1.0, 0.3};
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *fillColor = [NSColor colorWithColorSpace: deviceRGB
+ components: fill
+ count:4];
+ (void)tkwin;
+
+ CGContextSetFillColorWithColor(context, CGCOLOR(fillColor));
+ CGContextFillRect(context, bounds);
+}
+
+/*----------------------------------------------------------------------
+ * +++ DrawDarkFocusRing --
+ *
+ * This is a standalone drawing procedure which draws a focus ring around
+ * an Entry widget in Dark Mode.
+ */
+
+static void DrawDarkFocusRing(
+ CGRect bounds,
+ CGContextRef context)
+{
+ CGRect insetBounds = CGRectInset(bounds, -3, -3);
+ CHECK_RADIUS(4, insetBounds)
+
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *strokeColor;
+ NSColor *fillColor = [NSColor colorWithColorSpace:deviceRGB
+ components:darkFocusRing
+ count:4];
+ CGFloat x = bounds.origin.x, y = bounds.origin.y;
+ CGFloat w = bounds.size.width, h = bounds.size.height;
+ CGPoint topPart[4] = {
+ {x, y + h}, {x, y + 1}, {x + w - 1, y + 1}, {x + w - 1, y + h}
+ };
+ CGPoint bottom[2] = {{x, y + h}, {x + w, y + h}};
+
+ CGContextSaveGState(context);
+ CGContextSetShouldAntialias(context, false);
+ CGContextBeginPath(context);
+ strokeColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkFocusRingTop
+ count: 4];
+ CGContextSetStrokeColorWithColor(context, CGCOLOR(strokeColor));
+ CGContextAddLines(context, topPart, 4);
+ CGContextStrokePath(context);
+ strokeColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkFocusRingBottom
+ count: 4];
+ CGContextSetStrokeColorWithColor(context, CGCOLOR(strokeColor));
+ CGContextAddLines(context, bottom, 2);
+ CGContextStrokePath(context);
+ CGContextSetShouldAntialias(context, true);
+ CGContextSetFillColorWithColor(context, CGCOLOR(fillColor));
+ CGPathRef path = CGPathCreateWithRoundedRect(insetBounds, 4, 4, NULL);
+ CGContextBeginPath(context);
+ CGContextAddPath(context, path);
+ CGContextAddRect(context, bounds);
+ CGContextEOFillPath(context);
+ CGContextRestoreGState(context);
+}
+/*----------------------------------------------------------------------
+ * +++ DrawDarkFrame --
+ *
+ * This is a standalone drawing procedure which draws various
+ * types of borders in Dark Mode.
+ */
+
+static void DrawDarkFrame(
+ CGRect bounds,
+ CGContextRef context,
+ HIThemeFrameKind kind)
+{
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *stroke;
+
+ CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace);
+ CGFloat x = bounds.origin.x, y = bounds.origin.y;
+ CGFloat w = bounds.size.width, h = bounds.size.height;
+ CGPoint topPart[4] = {
+ {x, y + h - 1}, {x, y + 1}, {x + w, y + 1}, {x + w, y + h - 1}
+ };
+ CGPoint bottom[2] = {{x, y + h}, {x + w, y + h}};
+ CGPoint accent[2] = {{x, y + 1}, {x + w, y + 1}};
+
+ switch (kind) {
+ case kHIThemeFrameTextFieldSquare:
+ CGContextSaveGState(context);
+ CGContextSetShouldAntialias(context, false);
+ CGContextBeginPath(context);
+ stroke = [NSColor colorWithColorSpace: deviceRGB
+ components: darkFrameTop
+ count: 4];
+ CGContextSetStrokeColorWithColor(context, CGCOLOR(stroke));
+ CGContextAddLines(context, topPart, 4);
+ CGContextStrokePath(context);
+ stroke = [NSColor colorWithColorSpace: deviceRGB
+ components: darkFrameBottom
+ count: 4];
+ CGContextSetStrokeColorWithColor(context, CGCOLOR(stroke));
+ CGContextAddLines(context, bottom, 2);
+ CGContextStrokePath(context);
+ stroke = [NSColor colorWithColorSpace: deviceRGB
+ components: darkFrameAccent
+ count: 4];
+ CGContextSetStrokeColorWithColor(context, CGCOLOR(stroke));
+ CGContextAddLines(context, accent, 2);
+ CGContextStrokePath(context);
+ CGContextRestoreGState(context);
+ break;
+ default:
+ break;
+ }
+}
+
+/*----------------------------------------------------------------------
+ * +++ DrawListHeader --
+ *
+ * This is a standalone drawing procedure which draws column
+ * headers for a Treeview in the Dark Mode.
+ */
+
+static void DrawDarkListHeader(
+ CGRect bounds,
+ CGContextRef context,
+ Tk_Window tkwin,
+ int state)
+{
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *stroke;
+ (void)tkwin;
+
+ CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace);
+ CGFloat x = bounds.origin.x, y = bounds.origin.y;
+ CGFloat w = bounds.size.width, h = bounds.size.height;
+ CGPoint top[2] = {{x, y}, {x + w, y}};
+ CGPoint bottom[2] = {{x, y + h}, {x + w, y + h}};
+ CGPoint separator[2] = {{x + w, y + 3}, {x + w, y + h - 3}};
+
+ CGContextSaveGState(context);
+ CGContextSetShouldAntialias(context, false);
+ stroke = [NSColor colorWithColorSpace: deviceRGB
+ components: darkFrameBottom
+ count: 4];
+ CGContextSetStrokeColorWithColor(context, CGCOLOR(stroke));
+ CGContextBeginPath(context);
+ CGContextAddLines(context, top, 2);
+ CGContextStrokePath(context);
+ CGContextAddLines(context, bottom, 2);
+ CGContextStrokePath(context);
+ CGContextAddLines(context, separator, 2);
+ CGContextStrokePath(context);
+ CGContextRestoreGState(context);
+
+ if (state & TTK_TREEVIEW_STATE_SORTARROW) {
+ CGRect arrowBounds = bounds;
+
+ arrowBounds.origin.x = bounds.origin.x + bounds.size.width - 16;
+ arrowBounds.size.width = 16;
+ if (state & TTK_STATE_ALTERNATE) {
+ DrawUpArrow(context, arrowBounds, 3, 8, whiteRGBA);
+ } else if (state & TTK_STATE_SELECTED) {
+ DrawDownArrow(context, arrowBounds, 3, 8, whiteRGBA);
+ }
+ }
+}
+
+/*----------------------------------------------------------------------
+ * +++ Button element: Used for elements drawn with DrawThemeButton.
+ */
+
+/*
+ * When Ttk draws the various types of buttons, a pointer to one of these
+ * is passed as the clientData.
+ */
typedef struct {
ThemeButtonKind kind;
ThemeMetric heightMetric;
} ThemeButtonParams;
-
static ThemeButtonParams
- PushButtonParams = { kThemePushButton, kThemeMetricPushButtonHeight },
- CheckBoxParams = { kThemeCheckBox, kThemeMetricCheckBoxHeight },
- RadioButtonParams = { kThemeRadioButton, kThemeMetricRadioButtonHeight },
- BevelButtonParams = { kThemeBevelButton, NoThemeMetric },
- PopupButtonParams = { kThemePopupButton, kThemeMetricPopupButtonHeight },
- DisclosureParams = { kThemeDisclosureButton, kThemeMetricDisclosureTriangleHeight },
- ListHeaderParams = { kThemeListHeaderButton, kThemeMetricListHeaderHeight };
-
+ PushButtonParams = {kThemePushButton, kThemeMetricPushButtonHeight},
+ CheckBoxParams = {kThemeCheckBox, kThemeMetricCheckBoxHeight},
+ RadioButtonParams = {kThemeRadioButton, kThemeMetricRadioButtonHeight},
+ BevelButtonParams = {kThemeRoundedBevelButton, NoThemeMetric},
+ PopupButtonParams = {kThemePopupButton, kThemeMetricPopupButtonHeight},
+ DisclosureParams = {
+ kThemeDisclosureButton, kThemeMetricDisclosureTriangleHeight
+},
+ ListHeaderParams =
+{kThemeListHeaderButton, kThemeMetricListHeaderHeight};
static Ttk_StateTable ButtonValueTable[] = {
- { kThemeButtonMixed, TTK_STATE_ALTERNATE, 0 },
- { kThemeButtonOn, TTK_STATE_SELECTED, 0 },
- { kThemeButtonOff, 0, 0 }
-/* Others: kThemeDisclosureRight, kThemeDisclosureDown, kThemeDisclosureLeft */
-};
+ {kThemeButtonOff, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0},
+ {kThemeButtonMixed, TTK_STATE_ALTERNATE, 0},
+ {kThemeButtonOn, TTK_STATE_SELECTED, 0},
+ {kThemeButtonOff, 0, 0}
+ /*
+ * Others: kThemeDisclosureRight, kThemeDisclosureDown,
+ * kThemeDisclosureLeft
+ */
+
+};
static Ttk_StateTable ButtonAdornmentTable[] = {
- { kThemeAdornmentDefault| kThemeAdornmentFocus,
- TTK_STATE_ALTERNATE| TTK_STATE_FOCUS, 0 },
- { kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0 },
- { kThemeAdornmentFocus, TTK_STATE_FOCUS, 0 },
- { kThemeAdornmentNone, 0, 0 }
+ {kThemeAdornmentNone, TTK_STATE_ALTERNATE | TTK_STATE_BACKGROUND, 0},
+ {kThemeAdornmentDefault | kThemeAdornmentFocus,
+ TTK_STATE_ALTERNATE | TTK_STATE_FOCUS, 0},
+ {kThemeAdornmentFocus, TTK_STATE_FOCUS, 0},
+ {kThemeAdornmentDefault, TTK_STATE_ALTERNATE, 0},
+ {kThemeAdornmentNone, 0, 0}
};
-/*
- * computeButtonDrawInfo --
- * Fill in an appearance manager HIThemeButtonDrawInfo record.
+/*----------------------------------------------------------------------
+ * +++ computeButtonDrawInfo --
+ *
+ * Fill in an appearance manager HIThemeButtonDrawInfo record.
*/
+
static inline HIThemeButtonDrawInfo computeButtonDrawInfo(
- ThemeButtonParams *params, Ttk_State state)
+ ThemeButtonParams *params,
+ Ttk_State state,
+ TCL_UNUSED(Tk_Window))
{
+
+ /*
+ * See ButtonElementDraw for the explanation of why we always draw
+ * PushButtons in the active state.
+ */
+
+ SInt32 HIThemeState;
+
+ HIThemeState = Ttk_StateTableLookup(ThemeStateTable, state);
+ switch (params->kind) {
+ case kThemePushButton:
+ HIThemeState &= ~kThemeStateInactive;
+ HIThemeState |= kThemeStateActive;
+ break;
+ default:
+ break;
+ }
+
const HIThemeButtonDrawInfo info = {
.version = 0,
- .state = Ttk_StateTableLookup(ThemeStateTable, state),
+ .state = HIThemeState,
.kind = params ? params->kind : 0,
.value = Ttk_StateTableLookup(ButtonValueTable, state),
.adornment = Ttk_StateTableLookup(ButtonAdornmentTable, state),
@@ -150,66 +1293,163 @@ static inline HIThemeButtonDrawInfo computeButtonDrawInfo(
return info;
}
-static void ButtonElementSizeNoPadding(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+/*----------------------------------------------------------------------
+ * +++ Button elements.
+ */
+
+static void ButtonElementMinSize(
+ void *clientData,
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ TCL_UNUSED(Ttk_Padding *))
{
- ThemeButtonParams *params = clientData;
+ ThemeButtonParams *params = (ThemeButtonParams *)clientData;
if (params->heightMetric != NoThemeMetric) {
- SInt32 height;
+ ChkErr(GetThemeMetric, params->heightMetric, minHeight);
+
+ /*
+ * The theme height does not include the 1-pixel border around
+ * the button, although it does include the 1-pixel shadow at
+ * the bottom.
+ */
- ChkErr(GetThemeMetric, params->heightMetric, &height);
- *heightPtr = height;
+ *minHeight += 2;
+
+ /*
+ * The minwidth must be 0 to force the generic ttk code to compute the
+ * correct text layout. For example, a non-zero value will cause the
+ * text to be left justified, no matter what -anchor setting is used in
+ * the style.
+ */
+
+ *minWidth = 0;
}
}
static void ButtonElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ void *clientData,
+ void *elementRecord,
+ Tk_Window tkwin,
+ int *minWidth,
+ int *minHeight,
+ Ttk_Padding *paddingPtr)
{
ThemeButtonParams *params = clientData;
- const HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, 0);
+ const HIThemeButtonDrawInfo info =
+ computeButtonDrawInfo(params, 0, tkwin);
static const CGRect scratchBounds = {{0, 0}, {100, 100}};
- CGRect contentBounds;
+ CGRect contentBounds, backgroundBounds;
+ int verticalPad;
- ButtonElementSizeNoPadding(
- clientData, elementRecord, tkwin,
- widthPtr, heightPtr, paddingPtr);
+ ButtonElementMinSize(clientData, elementRecord, tkwin,
+ minWidth, minHeight, paddingPtr);
/*
- * To compute internal padding, query the appearance manager
- * for the content bounds of a dummy rectangle, then use
- * the difference as the padding.
+ * Given a hypothetical bounding rectangle for a button, HIToolbox will
+ * compute a bounding rectangle for the button contents and a bounding
+ * rectangle for the button background. The background bounds are large
+ * enough to contain the image of the button in any state, which might
+ * include highlight borders, shadows, etc. The content rectangle is not
+ * centered vertically within the background rectangle, presumably because
+ * shadows only appear on the bottom. Nonetheless, when HITools is asked
+ * to draw a button with a certain bounding rectangle it draws the button
+ * centered within the rectangle.
+ *
+ * To compute the effective padding around a button we request the
+ * content and bounding rectangles for a 100x100 button and use the
+ * padding between those. However, we symmetrize the padding on the
+ * top and bottom, because that is how the button will be drawn.
*/
+
ChkErr(HIThemeGetButtonContentBounds,
&scratchBounds, &info, &contentBounds);
-
- paddingPtr->left = CGRectGetMinX(contentBounds);
- paddingPtr->top = CGRectGetMinY(contentBounds);
- paddingPtr->right = CGRectGetMaxX(scratchBounds) - CGRectGetMaxX(contentBounds) + 1;
- paddingPtr->bottom = CGRectGetMaxY(scratchBounds) - CGRectGetMaxY(contentBounds);
-
- /*
- * Now add a little extra padding to account for drop shadows.
- * @@@ SHOULD: call GetThemeButtonBackgroundBounds() instead.
- */
-
- *paddingPtr = Ttk_AddPadding(*paddingPtr, ButtonMargins);
- *widthPtr += Ttk_PaddingWidth(ButtonMargins);
- *heightPtr += Ttk_PaddingHeight(ButtonMargins);
+ ChkErr(HIThemeGetButtonBackgroundBounds,
+ &scratchBounds, &info, &backgroundBounds);
+ paddingPtr->left = contentBounds.origin.x - backgroundBounds.origin.x;
+ paddingPtr->right =
+ CGRectGetMaxX(backgroundBounds) - CGRectGetMaxX(contentBounds);
+ verticalPad = backgroundBounds.size.height - contentBounds.size.height;
+ paddingPtr->top = paddingPtr->bottom = verticalPad / 2;
}
static void ButtonElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+ void *clientData,
+ TCL_UNUSED(void *),
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
ThemeButtonParams *params = clientData;
- CGRect bounds = BoxToRect(d, Ttk_PadBox(b, ButtonMargins));
- const HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, state);
+ CGRect bounds = BoxToRect(d, b);
+ HIThemeButtonDrawInfo info = computeButtonDrawInfo(params, state, tkwin);
+
+ bounds = NormalizeButtonBounds(params->heightMetric, bounds);
BEGIN_DRAWING(d)
- ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
+ if (TkMacOSXInDarkMode(tkwin)) {
+ switch (info.kind) {
+ case kThemePushButton:
+ case kThemePopupButton:
+ DrawDarkButton(bounds, info.kind, state, dc.context);
+ break;
+ case kThemeCheckBox:
+ DrawDarkCheckBox(bounds, state, dc.context);
+ break;
+ case kThemeRadioButton:
+ DrawDarkRadioButton(bounds, state, dc.context);
+ break;
+ case kThemeRoundedBevelButton:
+ DrawDarkBevelButton(bounds, state, dc.context);
+ break;
+ default:
+ ChkErr(HIThemeDrawButton, &bounds, &info, dc.context,
+ HIOrientation, NULL);
+ }
+ } else if (info.kind == kThemePushButton &&
+ (state & TTK_STATE_PRESSED)) {
+ bounds.size.height += 2;
+ if ([NSApp macMinorVersion] > 8) {
+ GradientFillRoundedRectangle(dc.context, bounds, 4,
+ pressedPushButtonGradient, 2);
+ }
+ } else {
+
+ /*
+ * Apple's PushButton and PopupButton do not change their fill color
+ * when the window is inactive. However, except in 10.7 (Lion), the
+ * color of the arrow button on a PopupButton does change. For some
+ * reason HITheme fills inactive buttons with a transparent color that
+ * allows the window background to show through, leading to
+ * inconsistent behavior. We work around this by filling behind an
+ * inactive PopupButton with a text background color before asking
+ * HIToolbox to draw it. For PushButtons, we simply draw them in the
+ * active state.
+ */
+
+ if (info.kind == kThemePopupButton &&
+ (state & TTK_STATE_BACKGROUND)) {
+ CGRect innerBounds = CGRectInset(bounds, 1, 1);
+ NSColor *whiteRGBA = [NSColor whiteColor];
+ SolidFillRoundedRectangle(dc.context, innerBounds, 4, whiteRGBA);
+ }
+
+ /*
+ * A BevelButton with mixed value is drawn borderless, which does make
+ * much sense for us.
+ */
+
+ if (info.kind == kThemeRoundedBevelButton &&
+ info.value == kThemeButtonMixed) {
+ info.value = kThemeButtonOff;
+ info.state = kThemeStateInactive;
+ }
+ ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
+ NULL);
+ }
END_DRAWING
}
@@ -225,35 +1465,27 @@ static Ttk_ElementSpec ButtonElementSpec = {
* +++ Notebook elements.
*/
-
/* Tab position logic, c.f. ttkNotebook.c TabState() */
-
-#define TTK_STATE_NOTEBOOK_FIRST TTK_STATE_USER1
-#define TTK_STATE_NOTEBOOK_LAST TTK_STATE_USER2
static Ttk_StateTable TabStyleTable[] = {
- { kThemeTabFrontInactive, TTK_STATE_SELECTED|TTK_STATE_BACKGROUND},
- { kThemeTabNonFrontInactive, TTK_STATE_BACKGROUND},
- { kThemeTabFrontUnavailable, TTK_STATE_DISABLED|TTK_STATE_SELECTED},
- { kThemeTabNonFrontUnavailable, TTK_STATE_DISABLED},
- { kThemeTabFront, TTK_STATE_SELECTED},
- { kThemeTabNonFrontPressed, TTK_STATE_PRESSED},
- { kThemeTabNonFront, 0}
+ {kThemeTabFrontInactive, TTK_STATE_SELECTED | TTK_STATE_BACKGROUND, 0},
+ {kThemeTabNonFrontInactive, TTK_STATE_BACKGROUND, 0},
+ {kThemeTabFrontUnavailable, TTK_STATE_DISABLED | TTK_STATE_SELECTED, 0},
+ {kThemeTabNonFrontUnavailable, TTK_STATE_DISABLED, 0},
+ {kThemeTabFront, TTK_STATE_SELECTED, 0},
+ {kThemeTabNonFrontPressed, TTK_STATE_PRESSED, 0},
+ {kThemeTabNonFront, 0, 0}
};
-
static Ttk_StateTable TabAdornmentTable[] = {
- { kHIThemeTabAdornmentNone,
- TTK_STATE_NOTEBOOK_FIRST|TTK_STATE_NOTEBOOK_LAST},
- {kHIThemeTabAdornmentTrailingSeparator, TTK_STATE_NOTEBOOK_FIRST},
- {kHIThemeTabAdornmentNone, TTK_STATE_NOTEBOOK_LAST},
- {kHIThemeTabAdornmentTrailingSeparator, 0 },
+ {kHIThemeTabAdornmentNone, TTK_STATE_FIRST_TAB | TTK_STATE_LAST_TAB, 0},
+ {kHIThemeTabAdornmentTrailingSeparator, TTK_STATE_FIRST_TAB, 0},
+ {kHIThemeTabAdornmentNone, TTK_STATE_LAST_TAB, 0},
+ {kHIThemeTabAdornmentTrailingSeparator, 0, 0},
};
-
static Ttk_StateTable TabPositionTable[] = {
- { kHIThemeTabPositionOnly,
- TTK_STATE_NOTEBOOK_FIRST|TTK_STATE_NOTEBOOK_LAST},
- { kHIThemeTabPositionFirst, TTK_STATE_NOTEBOOK_FIRST},
- { kHIThemeTabPositionLast, TTK_STATE_NOTEBOOK_LAST},
- { kHIThemeTabPositionMiddle, 0 },
+ {kHIThemeTabPositionOnly, TTK_STATE_FIRST_TAB | TTK_STATE_LAST_TAB, 0},
+ {kHIThemeTabPositionFirst, TTK_STATE_FIRST_TAB, 0},
+ {kHIThemeTabPositionLast, TTK_STATE_LAST_TAB, 0},
+ {kHIThemeTabPositionMiddle, 0, 0},
};
/*
@@ -271,7 +1503,8 @@ static Ttk_StateTable TabPositionTable[] = {
* should be placed so that there are equal margins of space before and after
* it. The guidelines below provide the specifications you should use for tab
* labels:
- * - Regular size: System font. Center in tab, leaving 12 pixels on each side.
+ * - Regular size: System font. Center in tab, leaving 12 pixels on each
+ *side.
* - Small: Small system font. Center in tab, leaving 10 pixels on each side.
* - Mini: Mini system font. Center in tab, leaving 8 pixels on each side.
*
@@ -285,6 +1518,7 @@ static Ttk_StateTable TabPositionTable[] = {
* the tab view, leave enough space below the tab view so the controls are 20
* pixels above the bottom edge of the window and 12 pixels between the tab
* view and the controls.
+ *
* If you choose to extend the tab view sides and bottom so that they meet the
* window sides and bottom, you should leave a margin of at least 20 pixels
* between the content in the tab view and the tab-view edges.
@@ -295,17 +1529,25 @@ static Ttk_StateTable TabPositionTable[] = {
*/
static void TabElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ TCL_UNUSED(int *),
+ int *minHeight,
+ Ttk_Padding *paddingPtr)
{
- GetThemeMetric(kThemeMetricLargeTabHeight, (SInt32 *)heightPtr);
+ GetThemeMetric(kThemeMetricLargeTabHeight, (SInt32 *) minHeight);
*paddingPtr = Ttk_MakePadding(0, 0, 0, 2);
}
static void TabElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
CGRect bounds = BoxToRect(d, b);
HIThemeTabDrawInfo info = {
@@ -319,7 +1561,12 @@ static void TabElementDraw(
};
BEGIN_DRAWING(d)
- ChkErr(HIThemeDrawTab, &bounds, &info, dc.context, HIOrientation, NULL);
+ if (TkMacOSXInDarkMode(tkwin)) {
+ DrawDarkTab(bounds, state, dc.context);
+ } else {
+ ChkErr(HIThemeDrawTab, &bounds, &info, dc.context, HIOrientation,
+ NULL);
+ }
END_DRAWING
}
@@ -334,31 +1581,46 @@ static Ttk_ElementSpec TabElementSpec = {
/*
* Notebook panes:
*/
+
static void PaneElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ TCL_UNUSED(int *),
+ TCL_UNUSED(int *),
+ Ttk_Padding *paddingPtr)
{
*paddingPtr = Ttk_MakePadding(9, 5, 9, 9);
}
static void PaneElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
CGRect bounds = BoxToRect(d, b);
- HIThemeTabPaneDrawInfo info = {
- .version = 1,
- .state = Ttk_StateTableLookup(ThemeStateTable, state),
- .direction = kThemeTabNorth,
- .size = kHIThemeTabSizeNormal,
- .kind = kHIThemeTabKindNormal,
- .adornment = kHIThemeTabPaneAdornmentNormal,
- };
bounds.origin.y -= kThemeMetricTabFrameOverlap;
bounds.size.height += kThemeMetricTabFrameOverlap;
BEGIN_DRAWING(d)
- ChkErr(HIThemeDrawTabPane, &bounds, &info, dc.context, HIOrientation);
+ if ([NSApp macMinorVersion] > 8) {
+ DrawGroupBox(bounds, dc.context, tkwin);
+ } else {
+ HIThemeTabPaneDrawInfo info = {
+ .version = 1,
+ .state = Ttk_StateTableLookup(ThemeStateTable, state),
+ .direction = kThemeTabNorth,
+ .size = kHIThemeTabSizeNormal,
+ .kind = kHIThemeTabKindNormal,
+ .adornment = kHIThemeTabPaneAdornmentNormal,
+ };
+ bounds.origin.y -= kThemeMetricTabFrameOverlap;
+ bounds.size.height += kThemeMetricTabFrameOverlap;
+ ChkErr(HIThemeDrawTabPane, &bounds, &info, dc.context, HIOrientation);
+ }
END_DRAWING
}
@@ -370,36 +1632,49 @@ static Ttk_ElementSpec PaneElementSpec = {
PaneElementDraw
};
-/*
- * Labelframe borders:
- * Use "primary group box ..."
- * Quoth DrawThemePrimaryGroup reference:
- * "The primary group box frame is drawn inside the specified
- * rectangle and is a maximum of 2 pixels thick."
+/*----------------------------------------------------------------------
+ * +++ Labelframe elements --
*
- * "Maximum of 2 pixels thick" is apparently a lie;
- * looks more like 4 to me with shading.
+ * Labelframe borders: Use "primary group box ..." Quoth
+ * DrawThemePrimaryGroup reference: "The primary group box frame is drawn
+ * inside the specified rectangle and is a maximum of 2 pixels thick."
+ *
+ * "Maximum of 2 pixels thick" is apparently a lie; looks more like 4 to me
+ * with shading.
*/
+
static void GroupElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ TCL_UNUSED(int *),
+ TCL_UNUSED(int *),
+ Ttk_Padding *paddingPtr)
{
*paddingPtr = Ttk_UniformPadding(4);
}
static void GroupElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
CGRect bounds = BoxToRect(d, b);
- const HIThemeGroupBoxDrawInfo info = {
- .version = 0,
- .state = Ttk_StateTableLookup(ThemeStateTable, state),
- .kind = kHIThemeGroupBoxKindPrimaryOpaque,
- };
BEGIN_DRAWING(d)
- ChkErr(HIThemeDrawGroupBox, &bounds, &info, dc.context, HIOrientation);
+ if ([NSApp macMinorVersion] > 8) {
+ DrawGroupBox(bounds, dc.context, tkwin);
+ } else {
+ const HIThemeGroupBoxDrawInfo info = {
+ .version = 0,
+ .state = Ttk_StateTableLookup(ThemeStateTable, state),
+ .kind = kHIThemeGroupBoxKindPrimaryOpaque,
+ };
+ ChkErr(HIThemeDrawGroupBox, &bounds, &info, dc.context, HIOrientation);
+ }
END_DRAWING
}
@@ -412,56 +1687,118 @@ static Ttk_ElementSpec GroupElementSpec = {
};
/*----------------------------------------------------------------------
- * +++ Entry element --
- * 3 pixels padding for focus rectangle
- * 2 pixels padding for EditTextFrame
+ * +++ Entry elements --
+ *
+ * 3 pixels padding for focus rectangle
+ * 2 pixels padding for EditTextFrame
*/
typedef struct {
- Tcl_Obj *backgroundObj;
+ Tcl_Obj *backgroundObj;
+ Tcl_Obj *fieldbackgroundObj;
} EntryElement;
+#define ENTRY_DEFAULT_BACKGROUND "systemTextBackgroundColor"
+
static Ttk_ElementOptionSpec EntryElementOptions[] = {
- { "-background", TK_OPTION_BORDER,
- Tk_Offset(EntryElement,backgroundObj), "white" },
+ {"-background", TK_OPTION_BORDER,
+ offsetof(EntryElement, backgroundObj), ENTRY_DEFAULT_BACKGROUND},
+ {"-fieldbackground", TK_OPTION_BORDER,
+ offsetof(EntryElement, fieldbackgroundObj), ENTRY_DEFAULT_BACKGROUND},
{0}
};
static void EntryElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ TCL_UNUSED(int *),
+ TCL_UNUSED(int *),
+ Ttk_Padding *paddingPtr)
{
- *paddingPtr = Ttk_UniformPadding(5);
+ *paddingPtr = Ttk_MakePadding(7, 5, 7, 6);
}
static void EntryElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+ TCL_UNUSED(void *),
+ void *elementRecord,
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
EntryElement *e = elementRecord;
- Tk_3DBorder backgroundPtr = Tk_Get3DBorderFromObj(tkwin,e->backgroundObj);
Ttk_Box inner = Ttk_PadBox(b, Ttk_UniformPadding(3));
CGRect bounds = BoxToRect(d, inner);
- const HIThemeFrameDrawInfo info = {
- .version = 0,
- .kind = kHIThemeFrameTextFieldSquare,
- .state = Ttk_StateTableLookup(ThemeStateTable, state),
- .isFocused = state & TTK_STATE_FOCUS,
- };
+ NSColor *background;
+ Tk_3DBorder backgroundPtr = NULL;
+ static const char *defaultBG = ENTRY_DEFAULT_BACKGROUND;
- /*
- * Erase w/background color:
- */
- XFillRectangle(Tk_Display(tkwin), d,
- Tk_3DBorderGC(tkwin, backgroundPtr, TK_3D_FLAT_GC),
- inner.x,inner.y, inner.width, inner.height);
+ if (TkMacOSXInDarkMode(tkwin)) {
+ BEGIN_DRAWING(d)
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ CGFloat fill[4];
+ GetBackgroundColor(dc.context, tkwin, 1, fill);
+
+ /*
+ * Lighten the background to provide contrast.
+ */
+
+ for (int i = 0; i < 3; i++) {
+ fill[i] += 9.0 / 255.0;
+ }
+ background = [NSColor colorWithColorSpace: deviceRGB
+ components: fill
+ count: 4];
+ CGContextSetFillColorWithColor(dc.context, CGCOLOR(background));
+ CGContextFillRect(dc.context, bounds);
+ if (state & TTK_STATE_FOCUS) {
+ DrawDarkFocusRing(bounds, dc.context);
+ } else {
+ DrawDarkFrame(bounds, dc.context, kHIThemeFrameTextFieldSquare);
+ }
+ END_DRAWING
+ } else {
+ const HIThemeFrameDrawInfo info = {
+ .version = 0,
+ .kind = kHIThemeFrameTextFieldSquare,
+ .state = Ttk_StateTableLookup(ThemeStateTable, state),
+ .isFocused = state & TTK_STATE_FOCUS,
+ };
- BEGIN_DRAWING(d)
- ChkErr(HIThemeDrawFrame, &bounds, &info, dc.context, HIOrientation);
- /*if (state & TTK_STATE_FOCUS) {
- ChkErr(DrawThemeFocusRect, &bounds, 1);
- }*/
- END_DRAWING
+ /*
+ * Earlier versions of the Aqua theme ignored the -fieldbackground
+ * option and used the -background as if it were -fieldbackground.
+ * Here we are enabling -fieldbackground. For backwards
+ * compatibility, if -fieldbackground is set to the default color and
+ * -background is set to a different color then we use -background as
+ * -fieldbackground.
+ */
+
+ if (0 != strcmp(Tcl_GetString(e->fieldbackgroundObj), defaultBG)) {
+ backgroundPtr =
+ Tk_Get3DBorderFromObj(tkwin, e->fieldbackgroundObj);
+ } else if (0 != strcmp(Tcl_GetString(e->backgroundObj), defaultBG)) {
+ backgroundPtr = Tk_Get3DBorderFromObj(tkwin, e->backgroundObj);
+ }
+ if (backgroundPtr != NULL) {
+ XFillRectangle(Tk_Display(tkwin), d,
+ Tk_3DBorderGC(tkwin, backgroundPtr, TK_3D_FLAT_GC),
+ inner.x, inner.y, inner.width, inner.height);
+ }
+ BEGIN_DRAWING(d)
+ if (backgroundPtr == NULL) {
+ if ([NSApp macMinorVersion] > 8) {
+ background = [NSColor textBackgroundColor];
+ CGContextSetFillColorWithColor(dc.context, CGCOLOR(background));
+ } else {
+ CGContextSetRGBFillColor(dc.context, 1.0, 1.0, 1.0, 1.0);
+ }
+ CGContextFillRect(dc.context, bounds);
+ }
+ ChkErr(HIThemeDrawFrame, &bounds, &info, dc.context, HIOrientation);
+ END_DRAWING
+ }
}
static Ttk_ElementSpec EntryElementSpec = {
@@ -473,30 +1810,49 @@ static Ttk_ElementSpec EntryElementSpec = {
};
/*----------------------------------------------------------------------
- * +++ Combobox:
+ * +++ Combobox elements --
*
* NOTES:
- * kThemeMetricComboBoxLargeDisclosureWidth -> 17
- * Padding and margins guesstimated by trial-and-error.
+ * The HIToolbox has incomplete and inconsistent support for ComboBoxes.
+ * There is no constant available to get the height of a ComboBox with
+ * GetThemeMetric. In fact, ComboBoxes are the same (fixed) height as
+ * PopupButtons and PushButtons, but they have no shadow at the bottom.
+ * As a result, they are drawn 1 pixel above the center of the bounds
+ * rectangle rather than being centered like the other buttons. One can
+ * request background bounds for a ComboBox, and it is reported with
+ * height 23, while the actual button face, including its 1-pixel border
+ * has height 21. Attempting to request the content bounds returns a 0x0
+ * rectangle. Measurement indicates that the arrow button has width 18.
+ *
+ * With no help available from HIToolbox, we have to use hard-wired
+ * constants for the padding. We shift the bounding rectangle downward by
+ * 1 pixel to account for the fact that the button is not centered.
*/
-static Ttk_Padding ComboboxPadding = { 2, 3, 17, 1 };
-static Ttk_Padding ComboboxMargins = { 3, 3, 4, 4 };
+static Ttk_Padding ComboboxPadding = {4, 2, 20, 2};
static void ComboboxElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ Ttk_Padding *paddingPtr)
{
- *widthPtr = 0;
- *heightPtr = 0;
- *paddingPtr = Ttk_AddPadding(ComboboxMargins, ComboboxPadding);
+ *minWidth = 24;
+ *minHeight = 23;
+ *paddingPtr = ComboboxPadding;
}
static void ComboboxElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
- CGRect bounds = BoxToRect(d, Ttk_PadBox(b, ComboboxMargins));
+ CGRect bounds = BoxToRect(d, b);
const HIThemeButtonDrawInfo info = {
.version = 0,
.state = Ttk_StateTableLookup(ThemeStateTable, state),
@@ -506,6 +1862,18 @@ static void ComboboxElementDraw(
};
BEGIN_DRAWING(d)
+ bounds.origin.y += 1;
+ if (TkMacOSXInDarkMode(tkwin)) {
+ bounds.size.height += 1;
+ DrawDarkButton(bounds, info.kind, state, dc.context);
+ } else if ([NSApp macMinorVersion] > 8) {
+ if ((state & TTK_STATE_BACKGROUND) &&
+ !(state & TTK_STATE_DISABLED)) {
+ NSColor *background = [NSColor textBackgroundColor];
+ CGRect innerBounds = CGRectInset(bounds, 1, 2);
+ SolidFillRoundedRectangle(dc.context, innerBounds, 4, background);
+ }
+ }
ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
END_DRAWING
}
@@ -518,123 +1886,220 @@ static Ttk_ElementSpec ComboboxElementSpec = {
ComboboxElementDraw
};
+/*----------------------------------------------------------------------
+ * +++ Spinbutton elements --
+ *
+ * From Apple HIG, part III, section "Controls", "The Stepper Control":
+ * there should be 2 pixels of space between the stepper control (AKA
+ * IncDecButton, AKA "little arrows") and the text field it modifies.
+ *
+ * Ttk expects the up and down arrows to be distinct elements but
+ * HIToolbox draws them as one widget with two different pressed states.
+ * We work around this by defining them as separate elements in the
+ * layout, but making each one have a drawing method which also draws the
+ * other one. The down button does no drawing when not pressed, and when
+ * pressed draws the entire IncDecButton in its "pressed down" state.
+ * The up button draws the entire IncDecButton when not pressed and when
+ * pressed draws the IncDecButton in its "pressed up" state. NOTE: This
+ * means that when the down button is pressed the IncDecButton will be
+ * drawn twice, first in unpressed state by the up arrow and then in
+ * "pressed down" state by the down button. The drawing must be done in
+ * that order. So the up button must be listed first in the layout.
+ */
+static Ttk_Padding SpinbuttonMargins = {0, 0, 2, 0};
+static void SpinButtonUpElementSize(
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ TCL_UNUSED(Ttk_Padding *))
+{
+ SInt32 s;
+ ChkErr(GetThemeMetric, kThemeMetricLittleArrowsWidth, &s);
+ *minWidth = s + Ttk_PaddingWidth(SpinbuttonMargins);
+ ChkErr(GetThemeMetric, kThemeMetricLittleArrowsHeight, &s);
+ *minHeight = (s + Ttk_PaddingHeight(SpinbuttonMargins)) / 2;
+}
-/*----------------------------------------------------------------------
- * +++ Spinbuttons.
- *
- * From Apple HIG, part III, section "Controls", "The Stepper Control":
- * there should be 2 pixels of space between the stepper control
- * (AKA IncDecButton, AKA "little arrows") and the text field it modifies.
- */
+static void SpinButtonUpElementDraw(
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
+{
+ CGRect bounds = BoxToRect(d, Ttk_PadBox(b, SpinbuttonMargins));
+ int infoState;
-static Ttk_Padding SpinbuttonMargins = {2,0,2,0};
-static void SpinButtonElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ bounds.size.height *= 2;
+ if (state & TTK_STATE_PRESSED) {
+ infoState = kThemeStatePressedUp;
+ } else {
+ infoState = Ttk_StateTableLookup(ThemeStateTable, state);
+ }
+ const HIThemeButtonDrawInfo info = {
+ .version = 0,
+ .state = infoState,
+ .kind = kThemeIncDecButton,
+ .value = Ttk_StateTableLookup(ButtonValueTable, state),
+ .adornment = kThemeAdornmentNone,
+ };
+ BEGIN_DRAWING(d)
+ if (TkMacOSXInDarkMode(tkwin)) {
+ DrawDarkIncDecButton(bounds, infoState, state, dc.context);
+ } else {
+ ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
+ NULL);
+ }
+ END_DRAWING
+}
+
+static Ttk_ElementSpec SpinButtonUpElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(NullElement),
+ TtkNullElementOptions,
+ SpinButtonUpElementSize,
+ SpinButtonUpElementDraw
+};
+static void SpinButtonDownElementSize(
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ TCL_UNUSED(Ttk_Padding *))
{
SInt32 s;
ChkErr(GetThemeMetric, kThemeMetricLittleArrowsWidth, &s);
- *widthPtr = s + Ttk_PaddingWidth(SpinbuttonMargins);
+ *minWidth = s + Ttk_PaddingWidth(SpinbuttonMargins);
ChkErr(GetThemeMetric, kThemeMetricLittleArrowsHeight, &s);
- *heightPtr = s + Ttk_PaddingHeight(SpinbuttonMargins);
+ *minHeight = (s + Ttk_PaddingHeight(SpinbuttonMargins)) / 2;
}
-static void SpinButtonElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+static void SpinButtonDownElementDraw(
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
CGRect bounds = BoxToRect(d, Ttk_PadBox(b, SpinbuttonMargins));
- /* @@@ can't currently distinguish PressedUp (== Pressed) from PressedDown;
- * ignore this bit for now [see #2219588]
- */
+ int infoState = 0;
+
+ bounds.origin.y -= bounds.size.height;
+ bounds.size.height *= 2;
+ if (state & TTK_STATE_PRESSED) {
+ infoState = kThemeStatePressedDown;
+ } else {
+ return;
+ }
const HIThemeButtonDrawInfo info = {
.version = 0,
- .state = Ttk_StateTableLookup(ThemeStateTable, state & ~TTK_STATE_PRESSED),
+ .state = infoState,
.kind = kThemeIncDecButton,
.value = Ttk_StateTableLookup(ButtonValueTable, state),
.adornment = kThemeAdornmentNone,
};
BEGIN_DRAWING(d)
- ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
+ if (TkMacOSXInDarkMode(tkwin)) {
+ DrawDarkIncDecButton(bounds, infoState, state, dc.context);
+ } else {
+ ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
+ NULL);
+ }
END_DRAWING
}
-static Ttk_ElementSpec SpinButtonElementSpec = {
+static Ttk_ElementSpec SpinButtonDownElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
- SpinButtonElementSize,
- SpinButtonElementDraw
+ SpinButtonDownElementSize,
+ SpinButtonDownElementDraw
};
-
/*----------------------------------------------------------------------
* +++ DrawThemeTrack-based elements --
- * Progress bars and scales. (See also: <<NOTE-TRACKS>>)
+ *
+ * Progress bars and scales. (See also: <<NOTE-TRACKS>>)
+ */
+
+/*
+ * Apple does not change the appearance of a slider when the window becomes
+ * inactive. So we shouldn't either.
*/
static Ttk_StateTable ThemeTrackEnableTable[] = {
- { kThemeTrackDisabled, TTK_STATE_DISABLED, 0 },
- { kThemeTrackInactive, TTK_STATE_BACKGROUND, 0 },
- { kThemeTrackActive, 0, 0 }
+ {kThemeTrackDisabled, TTK_STATE_DISABLED, 0},
+ {kThemeTrackActive, TTK_STATE_BACKGROUND, 0},
+ {kThemeTrackActive, 0, 0}
/* { kThemeTrackNothingToScroll, ?, ? }, */
};
-typedef struct { /* TrackElement client data */
- ThemeTrackKind kind;
- SInt32 thicknessMetric;
+typedef struct { /* TrackElement client data */
+ ThemeTrackKind kind;
+ SInt32 thicknessMetric;
} TrackElementData;
static TrackElementData ScaleData = {
kThemeSlider, kThemeMetricHSliderHeight
};
-
typedef struct {
- Tcl_Obj *fromObj; /* minimum value */
- Tcl_Obj *toObj; /* maximum value */
- Tcl_Obj *valueObj; /* current value */
- Tcl_Obj *orientObj; /* horizontal / vertical */
+ Tcl_Obj *fromObj; /* minimum value */
+ Tcl_Obj *toObj; /* maximum value */
+ Tcl_Obj *valueObj; /* current value */
+ Tcl_Obj *orientObj; /* horizontal / vertical */
} TrackElement;
static Ttk_ElementOptionSpec TrackElementOptions[] = {
- { "-from", TK_OPTION_DOUBLE, Tk_Offset(TrackElement,fromObj) },
- { "-to", TK_OPTION_DOUBLE, Tk_Offset(TrackElement,toObj) },
- { "-value", TK_OPTION_DOUBLE, Tk_Offset(TrackElement,valueObj) },
- { "-orient", TK_OPTION_STRING, Tk_Offset(TrackElement,orientObj) },
- {0,0,0}
+ {"-from", TK_OPTION_DOUBLE, offsetof(TrackElement, fromObj), NULL},
+ {"-to", TK_OPTION_DOUBLE, offsetof(TrackElement, toObj), NULL},
+ {"-value", TK_OPTION_DOUBLE, offsetof(TrackElement, valueObj), NULL},
+ {"-orient", TK_OPTION_STRING, offsetof(TrackElement, orientObj), NULL},
+ {0, 0, 0, NULL}
};
-
static void TrackElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ void *clientData,
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ TCL_UNUSED(Ttk_Padding *))
{
- TrackElementData *data = clientData;
- SInt32 size = 24; /* reasonable default ... */
+ TrackElementData *data = (TrackElementData *)clientData;
+ SInt32 size = 24; /* reasonable default ... */
ChkErr(GetThemeMetric, data->thicknessMetric, &size);
- *widthPtr = *heightPtr = size;
+ *minWidth = *minHeight = size;
}
static void TrackElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+ void *clientData,
+ void *elementRecord,
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
TrackElementData *data = clientData;
TrackElement *elem = elementRecord;
- int orientation = TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
double from = 0, to = 100, value = 0, factor;
- Ttk_GetOrientFromObj(NULL, elem->orientObj, &orientation);
+ TtkGetOrientFromObj(NULL, elem->orientObj, &orientation);
Tcl_GetDoubleFromObj(NULL, elem->fromObj, &from);
Tcl_GetDoubleFromObj(NULL, elem->toObj, &to);
Tcl_GetDoubleFromObj(NULL, elem->valueObj, &value);
- factor = RangeToFactor(to - from);
+ factor = RangeToFactor(to);
HIThemeTrackDrawInfo info = {
.version = 0,
@@ -644,20 +2109,35 @@ static void TrackElementDraw(
.max = to * factor,
.value = value * factor,
.attributes = kThemeTrackShowThumb |
- (orientation == TTK_ORIENT_HORIZONTAL ?
- kThemeTrackHorizontal : 0),
+ (orientation == TTK_ORIENT_HORIZONTAL ?
+ kThemeTrackHorizontal : 0),
.enableState = Ttk_StateTableLookup(ThemeTrackEnableTable, state),
.trackInfo.progress.phase = 0,
};
if (info.kind == kThemeSlider) {
info.trackInfo.slider.pressState = state & TTK_STATE_PRESSED ?
- kThemeThumbPressed : 0;
- info.trackInfo.slider.thumbDir = kThemeThumbPlain;
+ kThemeThumbPressed : 0;
+ if (state & TTK_STATE_ALTERNATE) {
+ info.trackInfo.slider.thumbDir = kThemeThumbDownward;
+ } else {
+ info.trackInfo.slider.thumbDir = kThemeThumbPlain;
+ }
}
-
-
BEGIN_DRAWING(d)
+ if (TkMacOSXInDarkMode(tkwin)) {
+ CGRect bounds = BoxToRect(d, b);
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *trackColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkTrack
+ count: 4];
+ if (orientation == TTK_ORIENT_HORIZONTAL) {
+ bounds = CGRectInset(bounds, 1, bounds.size.height / 2 - 2);
+ } else {
+ bounds = CGRectInset(bounds, bounds.size.width / 2 - 3, 2);
+ }
+ SolidFillRoundedRectangle(dc.context, bounds, 2, trackColor);
+ }
ChkErr(HIThemeDrawTrack, &info, NULL, dc.context, HIOrientation);
END_DRAWING
}
@@ -670,21 +2150,24 @@ static Ttk_ElementSpec TrackElementSpec = {
TrackElementDraw
};
-/*
- * Slider element -- <<NOTE-TRACKS>>
+/*----------------------------------------------------------------------
+ * Slider elements -- <<NOTE-TRACKS>>
+ *
* Has geometry only. The Scale widget adjusts the position of this element,
* and uses it for hit detection. In the Aqua theme, the slider is actually
* drawn as part of the trough element.
*
- * Also buggy: The geometry here is a Wild-Assed-Guess; I can't
- * figure out how to get the Appearance Manager to tell me the
- * slider size.
*/
+
static void SliderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ TCL_UNUSED(Ttk_Padding *))
{
- *widthPtr = *heightPtr = 24;
+ *minWidth = *minHeight = 24;
}
static Ttk_ElementSpec SliderElementSpec = {
@@ -696,7 +2179,7 @@ static Ttk_ElementSpec SliderElementSpec = {
};
/*----------------------------------------------------------------------
- * +++ Progress bar element (new):
+ * +++ Progress bar elements --
*
* @@@ NOTE: According to an older revision of the Aqua reference docs,
* @@@ the 'phase' field is between 0 and 4. Newer revisions say
@@ -704,46 +2187,54 @@ static Ttk_ElementSpec SliderElementSpec = {
*/
typedef struct {
- Tcl_Obj *orientObj; /* horizontal / vertical */
- Tcl_Obj *valueObj; /* current value */
- Tcl_Obj *maximumObj; /* maximum value */
- Tcl_Obj *phaseObj; /* animation phase */
- Tcl_Obj *modeObj; /* progress bar mode */
+ Tcl_Obj *orientObj; /* horizontal / vertical */
+ Tcl_Obj *valueObj; /* current value */
+ Tcl_Obj *maximumObj; /* maximum value */
+ Tcl_Obj *phaseObj; /* animation phase */
+ Tcl_Obj *modeObj; /* progress bar mode */
} PbarElement;
static Ttk_ElementOptionSpec PbarElementOptions[] = {
- { "-orient", TK_OPTION_STRING,
- Tk_Offset(PbarElement,orientObj), "horizontal" },
- { "-value", TK_OPTION_DOUBLE,
- Tk_Offset(PbarElement,valueObj), "0" },
- { "-maximum", TK_OPTION_DOUBLE,
- Tk_Offset(PbarElement,maximumObj), "100" },
- { "-phase", TK_OPTION_INT,
- Tk_Offset(PbarElement,phaseObj), "0" },
- { "-mode", TK_OPTION_STRING,
- Tk_Offset(PbarElement,modeObj), "determinate" },
- {0,0,0,0}
+ {"-orient", TK_OPTION_STRING,
+ offsetof(PbarElement, orientObj), "horizontal"},
+ {"-value", TK_OPTION_DOUBLE,
+ offsetof(PbarElement, valueObj), "0"},
+ {"-maximum", TK_OPTION_DOUBLE,
+ offsetof(PbarElement, maximumObj), "100"},
+ {"-phase", TK_OPTION_INT,
+ offsetof(PbarElement, phaseObj), "0"},
+ {"-mode", TK_OPTION_STRING,
+ offsetof(PbarElement, modeObj), "determinate"},
+ {0, 0, 0, 0}
};
-
static void PbarElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ TCL_UNUSED(Ttk_Padding *))
{
- SInt32 size = 24; /* @@@ Check HIG for correct default */
+ SInt32 size = 24; /* @@@ Check HIG for correct default */
ChkErr(GetThemeMetric, kThemeMetricLargeProgressBarThickness, &size);
- *widthPtr = *heightPtr = size;
+ *minWidth = *minHeight = size;
}
static void PbarElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+ TCL_UNUSED(void *),
+ void *elementRecord,
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
PbarElement *pbar = elementRecord;
- int orientation = TTK_ORIENT_HORIZONTAL, phase = 0;
+ Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
+ int phase = 0;
double value = 0, maximum = 100, factor;
- Ttk_GetOrientFromObj(NULL, pbar->orientObj, &orientation);
+ TtkGetOrientFromObj(NULL, pbar->orientObj, &orientation);
Tcl_GetDoubleFromObj(NULL, pbar->valueObj, &value);
Tcl_GetDoubleFromObj(NULL, pbar->maximumObj, &maximum);
Tcl_GetIntFromObj(NULL, pbar->phaseObj, &phase);
@@ -751,20 +2242,35 @@ static void PbarElementDraw(
HIThemeTrackDrawInfo info = {
.version = 0,
- .kind = (!strcmp("indeterminate", Tcl_GetString(pbar->modeObj)) && value) ?
- kThemeIndeterminateBar : kThemeProgressBar,
+ .kind =
+ (!strcmp("indeterminate",
+ Tcl_GetString(pbar->modeObj)) && value) ?
+ kThemeIndeterminateBar : kThemeProgressBar,
.bounds = BoxToRect(d, b),
.min = 0,
.max = maximum * factor,
.value = value * factor,
.attributes = kThemeTrackShowThumb |
- (orientation == TTK_ORIENT_HORIZONTAL ?
- kThemeTrackHorizontal : 0),
+ (orientation == TTK_ORIENT_HORIZONTAL ?
+ kThemeTrackHorizontal : 0),
.enableState = Ttk_StateTableLookup(ThemeTrackEnableTable, state),
.trackInfo.progress.phase = phase,
};
BEGIN_DRAWING(d)
+ if (TkMacOSXInDarkMode(tkwin)) {
+ CGRect bounds = BoxToRect(d, b);
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *trackColor = [NSColor colorWithColorSpace: deviceRGB
+ components: darkTrack
+ count: 4];
+ if (orientation == TTK_ORIENT_HORIZONTAL) {
+ bounds = CGRectInset(bounds, 1, bounds.size.height / 2 - 3);
+ } else {
+ bounds = CGRectInset(bounds, bounds.size.width / 2 - 3, 1);
+ }
+ SolidFillRoundedRectangle(dc.context, bounds, 3, trackColor);
+ }
ChkErr(HIThemeDrawTrack, &info, NULL, dc.context, HIOrientation);
END_DRAWING
}
@@ -778,33 +2284,303 @@ static Ttk_ElementSpec PbarElementSpec = {
};
/*----------------------------------------------------------------------
+ * +++ Scrollbar elements
+ */
+
+typedef struct
+{
+ Tcl_Obj *orientObj;
+} ScrollbarElement;
+
+static Ttk_ElementOptionSpec ScrollbarElementOptions[] = {
+ {"-orient", TK_OPTION_STRING,
+ offsetof(ScrollbarElement, orientObj), "horizontal"},
+ {0, 0, 0, 0}
+};
+static void TroughElementSize(
+ TCL_UNUSED(void *),
+ void *elementRecord,
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ Ttk_Padding *paddingPtr)
+{
+ ScrollbarElement *scrollbar = elementRecord;
+ Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
+ SInt32 thickness = 15;
+
+ TtkGetOrientFromObj(NULL, scrollbar->orientObj, &orientation);
+ ChkErr(GetThemeMetric, kThemeMetricScrollBarWidth, &thickness);
+ if (orientation == TTK_ORIENT_HORIZONTAL) {
+ *minHeight = thickness;
+ if ([NSApp macMinorVersion] > 7) {
+ *paddingPtr = Ttk_MakePadding(4, 4, 4, 3);
+ }
+ } else {
+ *minWidth = thickness;
+ if ([NSApp macMinorVersion] > 7) {
+ *paddingPtr = Ttk_MakePadding(4, 4, 3, 4);
+ }
+ }
+}
+
+static CGFloat lightTrough[4] = {250.0 / 255, 250.0 / 255, 250.0 / 255, 1.0};
+static CGFloat darkTrough[4] = {45.0 / 255, 46.0 / 255, 49.0 / 255, 1.0};
+static CGFloat lightInactiveThumb[4] = {
+ 200.0 / 255, 200.0 / 255, 200.0 / 255, 1.0
+};
+static CGFloat lightActiveThumb[4] = {
+ 133.0 / 255, 133.0 / 255, 133.0 / 255, 1.0
+};
+static CGFloat darkInactiveThumb[4] = {
+ 116.0 / 255, 117.0 / 255, 118.0 / 255, 1.0
+};
+static CGFloat darkActiveThumb[4] = {
+ 158.0 / 255, 158.0 / 255, 159.0 / 255, 1.0
+};
+static void TroughElementDraw(
+ TCL_UNUSED(void *),
+ void *elementRecord,
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ TCL_UNUSED(Ttk_State))
+{
+ ScrollbarElement *scrollbar = elementRecord;
+ Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
+ CGRect bounds = BoxToRect(d, b);
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *troughColor;
+ CGFloat *rgba = TkMacOSXInDarkMode(tkwin) ? darkTrough : lightTrough;
+
+ TtkGetOrientFromObj(NULL, scrollbar->orientObj, &orientation);
+ if (orientation == TTK_ORIENT_HORIZONTAL) {
+ bounds = CGRectInset(bounds, 0, 1);
+ } else {
+ bounds = CGRectInset(bounds, 1, 0);
+ }
+ troughColor = [NSColor colorWithColorSpace: deviceRGB
+ components: rgba
+ count: 4];
+ BEGIN_DRAWING(d)
+ if ([NSApp macMinorVersion] > 8) {
+ CGContextSetFillColorWithColor(dc.context, CGCOLOR(troughColor));
+ } else {
+ ChkErr(HIThemeSetFill, kThemeBrushDocumentWindowBackground, NULL,
+ dc.context, HIOrientation);
+ }
+ CGContextFillRect(dc.context, bounds);
+ END_DRAWING
+}
+
+static Ttk_ElementSpec TroughElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(ScrollbarElement),
+ ScrollbarElementOptions,
+ TroughElementSize,
+ TroughElementDraw
+};
+static void ThumbElementSize(
+ TCL_UNUSED(void *),
+ void *elementRecord,
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ TCL_UNUSED(Ttk_Padding *))
+{
+ ScrollbarElement *scrollbar = elementRecord;
+ Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
+
+ TtkGetOrientFromObj(NULL, scrollbar->orientObj, &orientation);
+ if (orientation == TTK_ORIENT_VERTICAL) {
+ *minHeight = 18;
+ *minWidth = 8;
+ } else {
+ *minHeight = 8;
+ *minWidth = 18;
+ }
+}
+
+static void ThumbElementDraw(
+ TCL_UNUSED(void *),
+ void *elementRecord,
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
+{
+ ScrollbarElement *scrollbar = elementRecord;
+ Ttk_Orient orientation = TTK_ORIENT_HORIZONTAL;
+
+ TtkGetOrientFromObj(NULL, scrollbar->orientObj, &orientation);
+
+ /*
+ * In order to make ttk scrollbars work correctly it is necessary to be
+ * able to display the thumb element at the size and location which the ttk
+ * scrollbar widget requests. The algorithm that HIToolbox uses to
+ * determine the thumb geometry from the input values of min, max, value
+ * and viewSize is undocumented. A seemingly natural algorithm is
+ * implemented below. This code uses that algorithm for older OS versions,
+ * because using HITools also handles drawing the buttons and 3D thumb used
+ * on those systems. For newer systems the cleanest approach is to just
+ * draw the thumb directly.
+ */
+
+ if ([NSApp macMinorVersion] > 8) {
+ CGRect thumbBounds = BoxToRect(d, b);
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *thumbColor;
+ CGFloat *rgba;
+ if ((orientation == TTK_ORIENT_HORIZONTAL &&
+ thumbBounds.size.width >= Tk_Width(tkwin) - 8) ||
+ (orientation == TTK_ORIENT_VERTICAL &&
+ thumbBounds.size.height >= Tk_Height(tkwin) - 8)) {
+ return;
+ }
+ int isDark = TkMacOSXInDarkMode(tkwin);
+ if ((state & TTK_STATE_PRESSED) ||
+ (state & TTK_STATE_HOVER)) {
+ rgba = isDark ? darkActiveThumb : lightActiveThumb;
+ } else {
+ rgba = isDark ? darkInactiveThumb : lightInactiveThumb;
+ }
+ thumbColor = [NSColor colorWithColorSpace: deviceRGB
+ components: rgba
+ count: 4];
+ BEGIN_DRAWING(d)
+ SolidFillRoundedRectangle(dc.context, thumbBounds, 4, thumbColor);
+ END_DRAWING
+ } else {
+ double thumbSize, trackSize, visibleSize, factor, fraction;
+ MacDrawable *macWin = (MacDrawable *) Tk_WindowId(tkwin);
+ CGRect troughBounds = {{macWin->xOff, macWin->yOff},
+ {Tk_Width(tkwin), Tk_Height(tkwin)}};
+
+ /*
+ * The info struct has integer fields, which will be converted to
+ * floats in the drawing routine. All of values provided in the info
+ * struct, namely min, max, value, and viewSize are only defined up to
+ * an arbitrary scale factor. To avoid roundoff error we scale so
+ * that the viewSize is a large float which is smaller than the
+ * largest int.
+ */
+
+ HIThemeTrackDrawInfo info = {
+ .version = 0,
+ .bounds = troughBounds,
+ .min = 0,
+ .attributes = kThemeTrackShowThumb |
+ kThemeTrackThumbRgnIsNotGhost,
+ .enableState = kThemeTrackActive
+ };
+ factor = RangeToFactor(100.0);
+ if (orientation == TTK_ORIENT_HORIZONTAL) {
+ trackSize = troughBounds.size.width;
+ thumbSize = b.width;
+ fraction = b.x / trackSize;
+ } else {
+ trackSize = troughBounds.size.height;
+ thumbSize = b.height;
+ fraction = b.y / trackSize;
+ }
+ visibleSize = (thumbSize / trackSize) * factor;
+ info.max = factor - visibleSize;
+ info.trackInfo.scrollbar.viewsize = visibleSize;
+ if ([NSApp macMinorVersion] < 8 ||
+ orientation == TTK_ORIENT_HORIZONTAL) {
+ info.value = factor * fraction;
+ } else {
+ info.value = info.max - factor * fraction;
+ }
+ if ((state & TTK_STATE_PRESSED) ||
+ (state & TTK_STATE_HOVER)) {
+ info.trackInfo.scrollbar.pressState = kThemeThumbPressed;
+ } else {
+ info.trackInfo.scrollbar.pressState = 0;
+ }
+ if (orientation == TTK_ORIENT_HORIZONTAL) {
+ info.attributes |= kThemeTrackHorizontal;
+ } else {
+ info.attributes &= ~kThemeTrackHorizontal;
+ }
+ BEGIN_DRAWING(d)
+ HIThemeDrawTrack(&info, 0, dc.context, kHIThemeOrientationNormal);
+ END_DRAWING
+ }
+}
+
+static Ttk_ElementSpec ThumbElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(ScrollbarElement),
+ ScrollbarElementOptions,
+ ThumbElementSize,
+ ThumbElementDraw
+};
+static void ArrowElementSize(
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ TCL_UNUSED(Ttk_Padding *))
+{
+ if ([NSApp macMinorVersion] < 8) {
+ *minHeight = *minWidth = 14;
+ } else {
+ *minHeight = *minWidth = -1;
+ }
+}
+
+static Ttk_ElementSpec ArrowElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(ScrollbarElement),
+ ScrollbarElementOptions,
+ ArrowElementSize,
+ TtkNullElementDraw
+};
+
+/*----------------------------------------------------------------------
* +++ Separator element.
*
- * DrawThemeSeparator() guesses the orientation of the line from
- * the width and height of the rectangle, so the same element can
- * can be used for horizontal, vertical, and general separators.
+ * DrawThemeSeparator() guesses the orientation of the line from the width
+ * and height of the rectangle, so the same element can can be used for
+ * horizontal, vertical, and general separators.
*/
static void SeparatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ TCL_UNUSED(Ttk_Padding *))
{
- *widthPtr = *heightPtr = 1;
+ *minWidth = *minHeight = 1;
}
static void SeparatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, unsigned int state)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ unsigned int state)
{
CGRect bounds = BoxToRect(d, b);
const HIThemeSeparatorDrawInfo info = {
.version = 0,
- /* Separator only supports kThemeStateActive, kThemeStateInactive */
- .state = Ttk_StateTableLookup(ThemeStateTable, state & TTK_STATE_BACKGROUND),
+ /* Separator only supports kThemeStateActive, kThemeStateInactive */
+ .state = Ttk_StateTableLookup(ThemeStateTable,
+ state & TTK_STATE_BACKGROUND),
};
BEGIN_DRAWING(d)
- ChkErr(HIThemeDrawSeparator, &bounds, &info, dc.context, HIOrientation);
+ if (TkMacOSXInDarkMode(tkwin)) {
+ DrawDarkSeparator(bounds, dc.context, tkwin);
+ } else {
+ ChkErr(HIThemeDrawSeparator, &bounds, &info, dc.context,
+ HIOrientation);
+ }
END_DRAWING
}
@@ -817,14 +2593,19 @@ static Ttk_ElementSpec SeparatorElementSpec = {
};
/*----------------------------------------------------------------------
- * +++ Size grip element.
+ * +++ Size grip elements -- (obsolete)
*/
+
static const ThemeGrowDirection sizegripGrowDirection
- = kThemeGrowRight|kThemeGrowDown;
+ = kThemeGrowRight | kThemeGrowDown;
static void SizegripElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ TCL_UNUSED(Ttk_Padding *))
{
HIThemeGrowBoxDrawInfo info = {
.version = 0,
@@ -836,26 +2617,32 @@ static void SizegripElementSize(
CGRect bounds = CGRectZero;
ChkErr(HIThemeGetGrowBoxBounds, &bounds.origin, &info, &bounds);
- *widthPtr = bounds.size.width;
- *heightPtr = bounds.size.height;
+ *minWidth = bounds.size.width;
+ *minHeight = bounds.size.height;
}
static void SizegripElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, unsigned int state)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ Drawable d,
+ Ttk_Box b,
+ unsigned int state)
{
CGRect bounds = BoxToRect(d, b);
HIThemeGrowBoxDrawInfo info = {
.version = 0,
- /* Grow box only supports kThemeStateActive, kThemeStateInactive */
- .state = Ttk_StateTableLookup(ThemeStateTable, state & TTK_STATE_BACKGROUND),
+ /* Grow box only supports kThemeStateActive, kThemeStateInactive */
+ .state = Ttk_StateTableLookup(ThemeStateTable,
+ state & TTK_STATE_BACKGROUND),
.kind = kHIThemeGrowBoxKindNormal,
.direction = sizegripGrowDirection,
.size = kHIThemeGrowBoxSizeNormal,
};
BEGIN_DRAWING(d)
- ChkErr(HIThemeDrawGrowBox, &bounds.origin, &info, dc.context, HIOrientation);
+ ChkErr(HIThemeDrawGrowBox, &bounds.origin, &info, dc.context,
+ HIOrientation);
END_DRAWING
}
@@ -868,40 +2655,93 @@ static Ttk_ElementSpec SizegripElementSpec = {
};
/*----------------------------------------------------------------------
- * +++ Background and fill elements.
+ * +++ Background and fill elements --
*
- * This isn't quite right: In Aqua, the correct background for
- * a control depends on what kind of container it belongs to,
- * and the type of the top-level window.
+ * Before drawing any ttk widget, its bounding rectangle is filled with a
+ * background color. This color must match the background color of the
+ * containing widget to avoid looking ugly. The need for care when doing
+ * this is exacerbated by the fact that ttk enforces its "native look" by
+ * not allowing user control of the background or highlight colors of ttk
+ * widgets.
*
- * Also: patterned backgrounds should be aligned with the coordinate
- * system of the top-level window. If we're drawing into an
- * off-screen graphics port this leads to alignment glitches.
+ * This job is made more complicated in recent versions of macOS by the
+ * fact that the Appkit GroupBox (used for ttk LabelFrames) and
+ * TabbedPane (used for the Notebook widget) both place their content
+ * inside a rectangle with rounded corners that has a color which
+ * contrasts with the dialog background color. Moreover, although the
+ * Apple human interface guidelines recommend against doing so, there are
+ * times when one wants to nest these widgets, for example placing a
+ * GroupBox inside of a TabbedPane. To have the right contrast, each
+ * level of nesting requires a different color.
+ *
+ * Previous Tk releases used the HIThemeDrawGroupBox routine to draw
+ * GroupBoxes and TabbedPanes. This meant that the best that could be
+ * done was to set the GroupBox to be of kind
+ * kHIThemeGroupBoxKindPrimaryOpaque, and set its fill color to be the
+ * system background color. If widgets inside the box were drawn with
+ * the system background color the backgrounds would match. But this
+ * produces a GroupBox with no contrast, the only visual clue being a
+ * faint highlighting around the top of the GroupBox. Moreover, the
+ * TabbedPane does not have an Opaque version, so while it is drawn
+ * inside a contrasting rounded rectangle, the widgets inside the pane
+ * needed to be enclosed in a frame with the system background
+ * color. This added a visual artifact since the frame's background color
+ * does not match the Pane's background color. That code has now been
+ * replaced with the standalone drawing procedure macOSXDrawGroupBox,
+ * which draws a rounded rectangle with an appropriate contrasting
+ * background color.
+ *
+ * Patterned backgrounds, which are now obsolete, should be aligned with
+ * the coordinate system of the top-level window. Apparently failing to
+ * do this used to cause graphics anomalies when drawing into an
+ * off-screen graphics port. The code for handling this is currently
+ * commented out.
*/
static void FillElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
CGRect bounds = BoxToRect(d, b);
- ThemeBrush brush = (state & TTK_STATE_BACKGROUND)
+
+ if ([NSApp macMinorVersion] > 8) {
+ NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
+ NSColor *bgColor;
+ CGFloat fill[4];
+ BEGIN_DRAWING(d)
+ GetBackgroundColor(dc.context, tkwin, 0, fill);
+ bgColor = [NSColor colorWithColorSpace: deviceRGB components: fill
+ count: 4];
+ CGContextSetFillColorSpace(dc.context, deviceRGB.CGColorSpace);
+ CGContextSetFillColorWithColor(dc.context, CGCOLOR(bgColor));
+ CGContextFillRect(dc.context, bounds);
+ END_DRAWING
+ } else {
+ ThemeBrush brush = (state & TTK_STATE_BACKGROUND)
? kThemeBrushModelessDialogBackgroundInactive
: kThemeBrushModelessDialogBackgroundActive;
-
- BEGIN_DRAWING(d)
- ChkErr(HIThemeSetFill, brush, NULL, dc.context, HIOrientation);
- //QDSetPatternOrigin(PatternOrigin(tkwin, d));
- CGContextFillRect(dc.context, bounds);
- END_DRAWING
+ BEGIN_DRAWING(d)
+ ChkErr(HIThemeSetFill, brush, NULL, dc.context, HIOrientation);
+ //QDSetPatternOrigin(PatternOrigin(tkwin, d));
+ CGContextFillRect(dc.context, bounds);
+ END_DRAWING
+ }
}
static void BackgroundElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, unsigned int state)
+ void *clientData,
+ void *elementRecord,
+ Tk_Window tkwin,
+ Drawable d,
+ TCL_UNUSED(Ttk_Box),
+ unsigned int state)
{
- FillElementDraw(
- clientData, elementRecord, tkwin,
- d, Ttk_WinBox(tkwin), state);
+ FillElementDraw(clientData, elementRecord, tkwin, d, Ttk_WinBox(tkwin),
+ state);
}
static Ttk_ElementSpec FillElementSpec = {
@@ -911,7 +2751,6 @@ static Ttk_ElementSpec FillElementSpec = {
TtkNullElementSize,
FillElementDraw
};
-
static Ttk_ElementSpec BackgroundElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -923,19 +2762,24 @@ static Ttk_ElementSpec BackgroundElementSpec = {
/*----------------------------------------------------------------------
* +++ ToolbarBackground element -- toolbar style for frames.
*
- * This is very similar to the normal background element, but uses a
- * different ThemeBrush in order to get the lighter pinstripe effect
- * used in toolbars. We use SetThemeBackground() rather than
- * ApplyThemeBackground() in order to get the right style.
+ * This is very similar to the normal background element, but uses a
+ * different ThemeBrush in order to get the lighter pinstripe effect
+ * used in toolbars. We use SetThemeBackground() rather than
+ * ApplyThemeBackground() in order to get the right style.
*
- * <URL: http://developer.apple.com/documentation/Carbon/Reference/
- * Appearance_Manager/appearance_manager/constant_7.html#/
- * /apple_ref/doc/uid/TP30000243/C005321>
+ * <URL: http://developer.apple.com/documentation/Carbon/Reference/
+ * Appearance_Manager/appearance_manager/constant_7.html#/
+ * /apple_ref/doc/uid/TP30000243/C005321>
*
*/
+
static void ToolbarBackgroundElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ Tk_Window tkwin,
+ Drawable d,
+ TCL_UNUSED(Ttk_Box),
+ TCL_UNUSED(Ttk_State))
{
ThemeBrush brush = kThemeBrushToolbarBackground;
CGRect bounds = BoxToRect(d, Ttk_WinBox(tkwin));
@@ -956,30 +2800,121 @@ static Ttk_ElementSpec ToolbarBackgroundElementSpec = {
};
/*----------------------------------------------------------------------
- * +++ Treeview header
- * Redefine the header to use a kThemeListHeaderButton.
+ * +++ Field elements --
+ *
+ * Used for the Treeview widget. This is like the BackgroundElement
+ * except that the fieldbackground color is configureable.
+ */
+
+typedef struct {
+ Tcl_Obj *backgroundObj;
+} FieldElement;
+
+static Ttk_ElementOptionSpec FieldElementOptions[] = {
+ {"-fieldbackground", TK_OPTION_BORDER,
+ offsetof(FieldElement, backgroundObj), "white"},
+ {NULL, 0, 0, NULL}
+};
+
+static void FieldElementDraw(
+ TCL_UNUSED(void *),
+ void *elementRecord,
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ TCL_UNUSED(Ttk_State))
+{
+ FieldElement *e = elementRecord;
+ Tk_3DBorder backgroundPtr =
+ Tk_Get3DBorderFromObj(tkwin, e->backgroundObj);
+
+ XFillRectangle(Tk_Display(tkwin), d,
+ Tk_3DBorderGC(tkwin, backgroundPtr, TK_3D_FLAT_GC),
+ b.x, b.y, b.width, b.height);
+}
+
+static Ttk_ElementSpec FieldElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(FieldElement),
+ FieldElementOptions,
+ TtkNullElementSize,
+ FieldElementDraw
+};
+
+/*----------------------------------------------------------------------
+ * +++ Treeview headers --
+ *
+ * On systems older than 10.9 The header is a kThemeListHeaderButton drawn
+ * by HIToolbox. On newer systems those buttons do not match the Apple
+ * buttons, so we draw them from scratch.
*/
-#define TTK_TREEVIEW_STATE_SORTARROW TTK_STATE_USER1
static Ttk_StateTable TreeHeaderValueTable[] = {
- { kThemeButtonOn, TTK_STATE_ALTERNATE},
- { kThemeButtonOn, TTK_STATE_SELECTED},
- { kThemeButtonOff, 0}
+ {kThemeButtonOn, TTK_STATE_ALTERNATE, 0},
+ {kThemeButtonOn, TTK_STATE_SELECTED, 0},
+ {kThemeButtonOff, 0, 0}
};
+
static Ttk_StateTable TreeHeaderAdornmentTable[] = {
- { kThemeAdornmentHeaderButtonSortUp,
- TTK_STATE_ALTERNATE|TTK_TREEVIEW_STATE_SORTARROW},
- { kThemeAdornmentDefault,
- TTK_STATE_SELECTED|TTK_TREEVIEW_STATE_SORTARROW},
- { kThemeAdornmentHeaderButtonNoSortArrow, TTK_STATE_ALTERNATE},
- { kThemeAdornmentHeaderButtonNoSortArrow, TTK_STATE_SELECTED},
- { kThemeAdornmentFocus, TTK_STATE_FOCUS},
- { kThemeAdornmentNone, 0}
+ {kThemeAdornmentHeaderButtonSortUp,
+ TTK_STATE_ALTERNATE | TTK_TREEVIEW_STATE_SORTARROW, 0},
+ {kThemeAdornmentDefault,
+ TTK_STATE_SELECTED | TTK_TREEVIEW_STATE_SORTARROW, 0},
+ {kThemeAdornmentHeaderButtonNoSortArrow, TTK_STATE_ALTERNATE, 0},
+ {kThemeAdornmentHeaderButtonNoSortArrow, TTK_STATE_SELECTED, 0},
+ {kThemeAdornmentFocus, TTK_STATE_FOCUS, 0},
+ {kThemeAdornmentNone, 0, 0}
+};
+
+static void TreeAreaElementSize (
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ TCL_UNUSED(int *),
+ TCL_UNUSED(int *),
+ Ttk_Padding *paddingPtr)
+{
+
+ /*
+ * Padding is needed to get the heading text to align correctly, since the
+ * widget expects the heading to be the same height as a row.
+ */
+
+ if ([NSApp macMinorVersion] > 8) {
+ paddingPtr->top = 4;
+ }
+}
+
+static Ttk_ElementSpec TreeAreaElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(NullElement),
+ TtkNullElementOptions,
+ TreeAreaElementSize,
+ TtkNullElementDraw
};
+static void TreeHeaderElementSize(
+ void *clientData,
+ void *elementRecord,
+ Tk_Window tkwin,
+ int *minWidth,
+ int *minHeight,
+ Ttk_Padding *paddingPtr)
+{
+ if ([NSApp macMinorVersion] > 8) {
+ *minHeight = 24;
+ } else {
+ ButtonElementSize(clientData, elementRecord, tkwin, minWidth,
+ minHeight, paddingPtr);
+ }
+}
static void TreeHeaderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+ void *clientData,
+ TCL_UNUSED(void *),
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
ThemeButtonParams *params = clientData;
CGRect bounds = BoxToRect(d, b);
@@ -992,7 +2927,23 @@ static void TreeHeaderElementDraw(
};
BEGIN_DRAWING(d)
- ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
+ if ([NSApp macMinorVersion] > 8) {
+
+ /*
+ * Compensate for the padding added in TreeHeaderElementSize, so
+ * the larger heading will be drawn at the top of the widget.
+ */
+
+ bounds.origin.y -= 4;
+ if (TkMacOSXInDarkMode(tkwin)) {
+ DrawDarkListHeader(bounds, dc.context, tkwin, state);
+ } else {
+ DrawListHeader(bounds, dc.context, tkwin, state);
+ }
+ } else {
+ ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
+ NULL);
+ }
END_DRAWING
}
@@ -1000,48 +2951,59 @@ static Ttk_ElementSpec TreeHeaderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
- ButtonElementSizeNoPadding,
+ TreeHeaderElementSize,
TreeHeaderElementDraw
};
-/*
- * Disclosure triangle:
+/*----------------------------------------------------------------------
+ * +++ Disclosure triangles --
*/
-#define TTK_TREEVIEW_STATE_OPEN TTK_STATE_USER1
-#define TTK_TREEVIEW_STATE_LEAF TTK_STATE_USER2
+
+#define TTK_TREEVIEW_STATE_OPEN TTK_STATE_USER1
+#define TTK_TREEVIEW_STATE_LEAF TTK_STATE_USER2
static Ttk_StateTable DisclosureValueTable[] = {
- { kThemeDisclosureDown, TTK_TREEVIEW_STATE_OPEN, 0 },
- { kThemeDisclosureRight, 0, 0 },
+ {kThemeDisclosureDown, TTK_TREEVIEW_STATE_OPEN, 0},
+ {kThemeDisclosureRight, 0, 0},
};
-
static void DisclosureElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
+ int *minWidth,
+ int *minHeight,
+ TCL_UNUSED(Ttk_Padding *))
{
SInt32 s;
ChkErr(GetThemeMetric, kThemeMetricDisclosureTriangleWidth, &s);
- *widthPtr = s;
+ *minWidth = s;
ChkErr(GetThemeMetric, kThemeMetricDisclosureTriangleHeight, &s);
- *heightPtr = s;
+ *minHeight = s;
}
static void DisclosureElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, Ttk_State state)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(void *),
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
if (!(state & TTK_TREEVIEW_STATE_LEAF)) {
+ int triangleState = TkMacOSXInDarkMode(tkwin) ?
+ kThemeStateInactive : kThemeStateActive;
CGRect bounds = BoxToRect(d, b);
const HIThemeButtonDrawInfo info = {
.version = 0,
- .state = Ttk_StateTableLookup(ThemeStateTable, state),
+ .state = triangleState,
.kind = kThemeDisclosureTriangle,
.value = Ttk_StateTableLookup(DisclosureValueTable, state),
.adornment = kThemeAdornmentDrawIndicatorOnly,
};
BEGIN_DRAWING(d)
- ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL);
+ ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation,
+ NULL);
END_DRAWING
}
}
@@ -1055,7 +3017,7 @@ static Ttk_ElementSpec DisclosureElementSpec = {
};
/*----------------------------------------------------------------------
- * +++ Widget layouts.
+ * +++ Widget layouts --
*/
TTK_BEGIN_LAYOUT_TABLE(LayoutTable)
@@ -1065,64 +3027,90 @@ TTK_LAYOUT("Toolbar",
TTK_LAYOUT("TButton",
TTK_GROUP("Button.button", TTK_FILL_BOTH,
- TTK_GROUP("Button.padding", TTK_FILL_BOTH,
- TTK_NODE("Button.label", TTK_FILL_BOTH))))
+ TTK_GROUP("Button.padding", TTK_FILL_BOTH,
+ TTK_NODE("Button.label", TTK_FILL_BOTH))))
TTK_LAYOUT("TRadiobutton",
TTK_GROUP("Radiobutton.button", TTK_FILL_BOTH,
- TTK_GROUP("Radiobutton.padding", TTK_FILL_BOTH,
- TTK_NODE("Radiobutton.label", TTK_PACK_LEFT))))
+ TTK_GROUP("Radiobutton.padding", TTK_FILL_BOTH,
+ TTK_NODE("Radiobutton.label", TTK_PACK_LEFT))))
TTK_LAYOUT("TCheckbutton",
TTK_GROUP("Checkbutton.button", TTK_FILL_BOTH,
- TTK_GROUP("Checkbutton.padding", TTK_FILL_BOTH,
- TTK_NODE("Checkbutton.label", TTK_PACK_LEFT))))
+ TTK_GROUP("Checkbutton.padding", TTK_FILL_BOTH,
+ TTK_NODE("Checkbutton.label", TTK_PACK_LEFT))))
TTK_LAYOUT("TMenubutton",
TTK_GROUP("Menubutton.button", TTK_FILL_BOTH,
- TTK_GROUP("Menubutton.padding", TTK_FILL_BOTH,
- TTK_NODE("Menubutton.label", TTK_PACK_LEFT))))
+ TTK_GROUP("Menubutton.padding", TTK_FILL_BOTH,
+ TTK_NODE("Menubutton.label", TTK_PACK_LEFT))))
TTK_LAYOUT("TCombobox",
- TTK_GROUP("Combobox.button", TTK_PACK_TOP|TTK_FILL_X,
- TTK_GROUP("Combobox.padding", TTK_FILL_BOTH,
- TTK_NODE("Combobox.textarea", TTK_FILL_X))))
+ TTK_GROUP("Combobox.button", TTK_FILL_BOTH,
+ TTK_GROUP("Combobox.padding", TTK_FILL_BOTH,
+ TTK_NODE("Combobox.textarea", TTK_FILL_BOTH))))
/* Notebook tabs -- no focus ring */
TTK_LAYOUT("Tab",
TTK_GROUP("Notebook.tab", TTK_FILL_BOTH,
- TTK_GROUP("Notebook.padding", TTK_EXPAND|TTK_FILL_BOTH,
- TTK_NODE("Notebook.label", TTK_EXPAND|TTK_FILL_BOTH))))
+ TTK_GROUP("Notebook.padding", TTK_EXPAND | TTK_FILL_BOTH,
+ TTK_NODE("Notebook.label", TTK_EXPAND | TTK_FILL_BOTH))))
-/* Progress bars -- track only */
+/* Spinbox -- buttons 2px to the right of the field. */
TTK_LAYOUT("TSpinbox",
- TTK_NODE("Spinbox.spinbutton", TTK_PACK_RIGHT|TTK_STICK_E)
- TTK_GROUP("Spinbox.field", TTK_EXPAND|TTK_FILL_X,
- TTK_NODE("Spinbox.textarea", TTK_EXPAND|TTK_FILL_X)))
+ TTK_GROUP("Spinbox.buttons", TTK_PACK_RIGHT,
+ TTK_NODE("Spinbox.uparrow", TTK_PACK_TOP | TTK_STICK_E)
+ TTK_NODE("Spinbox.downarrow", TTK_PACK_BOTTOM | TTK_STICK_E))
+ TTK_GROUP("Spinbox.field", TTK_EXPAND | TTK_FILL_X,
+ TTK_NODE("Spinbox.textarea", TTK_EXPAND | TTK_FILL_X)))
+/* Progress bars -- track only */
TTK_LAYOUT("TProgressbar",
- TTK_NODE("Progressbar.track", TTK_EXPAND|TTK_FILL_BOTH))
+ TTK_NODE("Progressbar.track", TTK_EXPAND | TTK_FILL_BOTH))
+
+/* Treeview -- no border. */
+TTK_LAYOUT("Treeview",
+ TTK_GROUP("Treeview.field", TTK_FILL_BOTH,
+ TTK_GROUP("Treeview.padding", TTK_FILL_BOTH,
+ TTK_NODE("Treeview.treearea", TTK_FILL_BOTH))))
/* Tree heading -- no border, fixed height */
TTK_LAYOUT("Heading",
- TTK_NODE("Treeheading.cell", TTK_FILL_X)
+ TTK_NODE("Treeheading.cell", TTK_FILL_BOTH)
TTK_NODE("Treeheading.image", TTK_PACK_RIGHT)
- TTK_NODE("Treeheading.text", 0))
+ TTK_NODE("Treeheading.text", TTK_PACK_TOP))
/* Tree items -- omit focus ring */
TTK_LAYOUT("Item",
TTK_GROUP("Treeitem.padding", TTK_FILL_BOTH,
- TTK_NODE("Treeitem.indicator", TTK_PACK_LEFT)
- TTK_NODE("Treeitem.image", TTK_PACK_LEFT)
- TTK_NODE("Treeitem.text", TTK_PACK_LEFT)))
+ TTK_NODE("Treeitem.indicator", TTK_PACK_LEFT)
+ TTK_NODE("Treeitem.image", TTK_PACK_LEFT)
+ TTK_NODE("Treeitem.text", TTK_PACK_LEFT)))
+
+/* Scrollbar Layout -- Buttons at the bottom (Snow Leopard and Lion only) */
+
+TTK_LAYOUT("Vertical.TScrollbar",
+ TTK_GROUP("Vertical.Scrollbar.trough", TTK_FILL_Y,
+ TTK_NODE("Vertical.Scrollbar.thumb",
+ TTK_PACK_TOP | TTK_EXPAND | TTK_FILL_BOTH)
+ TTK_NODE("Vertical.Scrollbar.downarrow", TTK_PACK_BOTTOM)
+ TTK_NODE("Vertical.Scrollbar.uparrow", TTK_PACK_BOTTOM)))
+
+TTK_LAYOUT("Horizontal.TScrollbar",
+ TTK_GROUP("Horizontal.Scrollbar.trough", TTK_FILL_X,
+ TTK_NODE("Horizontal.Scrollbar.thumb",
+ TTK_PACK_LEFT | TTK_EXPAND | TTK_FILL_BOTH)
+ TTK_NODE("Horizontal.Scrollbar.rightarrow", TTK_PACK_RIGHT)
+ TTK_NODE("Horizontal.Scrollbar.leftarrow", TTK_PACK_RIGHT)))
TTK_END_LAYOUT_TABLE
/*----------------------------------------------------------------------
- * +++ Initialization.
+ * +++ Initialization --
*/
-static int AquaTheme_Init(Tcl_Interp *interp)
+static int AquaTheme_Init(
+ Tcl_Interp *interp)
{
Ttk_Theme themePtr = Ttk_CreateTheme(interp, "aqua", NULL);
@@ -1133,8 +3121,11 @@ static int AquaTheme_Init(Tcl_Interp *interp)
/*
* Elements:
*/
- Ttk_RegisterElementSpec(themePtr, "background", &BackgroundElementSpec, 0);
+
+ Ttk_RegisterElementSpec(themePtr, "background", &BackgroundElementSpec,
+ 0);
Ttk_RegisterElementSpec(themePtr, "fill", &FillElementSpec, 0);
+ Ttk_RegisterElementSpec(themePtr, "field", &FieldElementSpec, 0);
Ttk_RegisterElementSpec(themePtr, "Toolbar.background",
&ToolbarBackgroundElementSpec, 0);
@@ -1148,8 +3139,10 @@ static int AquaTheme_Init(Tcl_Interp *interp)
&ButtonElementSpec, &BevelButtonParams);
Ttk_RegisterElementSpec(themePtr, "Menubutton.button",
&ButtonElementSpec, &PopupButtonParams);
- Ttk_RegisterElementSpec(themePtr, "Spinbox.spinbutton",
- &SpinButtonElementSpec, 0);
+ Ttk_RegisterElementSpec(themePtr, "Spinbox.uparrow",
+ &SpinButtonUpElementSpec, 0);
+ Ttk_RegisterElementSpec(themePtr, "Spinbox.downarrow",
+ &SpinButtonDownElementSpec, 0);
Ttk_RegisterElementSpec(themePtr, "Combobox.button",
&ComboboxElementSpec, 0);
Ttk_RegisterElementSpec(themePtr, "Treeitem.indicator",
@@ -1157,33 +3150,63 @@ static int AquaTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElementSpec(themePtr, "Treeheading.cell",
&TreeHeaderElementSpec, &ListHeaderParams);
+ Ttk_RegisterElementSpec(themePtr, "Treeview.treearea",
+ &TreeAreaElementSpec, 0);
Ttk_RegisterElementSpec(themePtr, "Notebook.tab", &TabElementSpec, 0);
Ttk_RegisterElementSpec(themePtr, "Notebook.client", &PaneElementSpec, 0);
- Ttk_RegisterElementSpec(themePtr, "Labelframe.border",&GroupElementSpec,0);
- Ttk_RegisterElementSpec(themePtr, "Entry.field",&EntryElementSpec,0);
- Ttk_RegisterElementSpec(themePtr, "Spinbox.field",&EntryElementSpec,0);
+ Ttk_RegisterElementSpec(themePtr, "Labelframe.border", &GroupElementSpec,
+ 0);
+ Ttk_RegisterElementSpec(themePtr, "Entry.field", &EntryElementSpec, 0);
+ Ttk_RegisterElementSpec(themePtr, "Spinbox.field", &EntryElementSpec, 0);
- Ttk_RegisterElementSpec(themePtr, "separator",&SeparatorElementSpec,0);
- Ttk_RegisterElementSpec(themePtr, "hseparator",&SeparatorElementSpec,0);
- Ttk_RegisterElementSpec(themePtr, "vseparator",&SeparatorElementSpec,0);
+ Ttk_RegisterElementSpec(themePtr, "separator", &SeparatorElementSpec, 0);
+ Ttk_RegisterElementSpec(themePtr, "hseparator", &SeparatorElementSpec, 0);
+ Ttk_RegisterElementSpec(themePtr, "vseparator", &SeparatorElementSpec, 0);
- Ttk_RegisterElementSpec(themePtr, "sizegrip",&SizegripElementSpec,0);
+ Ttk_RegisterElementSpec(themePtr, "sizegrip", &SizegripElementSpec, 0);
/*
* <<NOTE-TRACKS>>
- * The Progressbar widget adjusts the size of the pbar element.
- * In the Aqua theme, the appearance manager computes the bar geometry;
- * we do all the drawing in the ".track" element and leave the .pbar out.
+ * In some themes the Layouts for a progress bar has a trough element and a
+ * pbar element. But in our case the appearance manager draws both parts
+ * of the progress bar, so we just have a single element called ".track".
+ */
+
+ Ttk_RegisterElementSpec(themePtr, "Progressbar.track", &PbarElementSpec,
+ 0);
+
+ Ttk_RegisterElementSpec(themePtr, "Scale.trough", &TrackElementSpec,
+ &ScaleData);
+ Ttk_RegisterElementSpec(themePtr, "Scale.slider", &SliderElementSpec, 0);
+
+ Ttk_RegisterElementSpec(themePtr, "Vertical.Scrollbar.trough",
+ &TroughElementSpec, 0);
+ Ttk_RegisterElementSpec(themePtr, "Vertical.Scrollbar.thumb",
+ &ThumbElementSpec, 0);
+ Ttk_RegisterElementSpec(themePtr, "Horizontal.Scrollbar.trough",
+ &TroughElementSpec, 0);
+ Ttk_RegisterElementSpec(themePtr, "Horizontal.Scrollbar.thumb",
+ &ThumbElementSpec, 0);
+
+ /*
+ * If we are not in Snow Leopard or Lion the arrows won't actually be
+ * displayed.
*/
- Ttk_RegisterElementSpec(themePtr,"Scale.trough",
- &TrackElementSpec, &ScaleData);
- Ttk_RegisterElementSpec(themePtr,"Scale.slider",&SliderElementSpec,0);
- Ttk_RegisterElementSpec(themePtr,"Progressbar.track", &PbarElementSpec, 0);
+
+ Ttk_RegisterElementSpec(themePtr, "Vertical.Scrollbar.uparrow",
+ &ArrowElementSpec, 0);
+ Ttk_RegisterElementSpec(themePtr, "Vertical.Scrollbar.downarrow",
+ &ArrowElementSpec, 0);
+ Ttk_RegisterElementSpec(themePtr, "Horizontal.Scrollbar.leftarrow",
+ &ArrowElementSpec, 0);
+ Ttk_RegisterElementSpec(themePtr, "Horizontal.Scrollbar.rightarrow",
+ &ArrowElementSpec, 0);
/*
* Layouts:
*/
+
Ttk_RegisterLayouts(themePtr, LayoutTable);
Tcl_PkgProvide(interp, "ttk::theme::aqua", TTK_VERSION);
@@ -1191,11 +3214,12 @@ static int AquaTheme_Init(Tcl_Interp *interp)
}
MODULE_SCOPE
-int Ttk_MacOSXPlatformInit(Tcl_Interp *interp)
+int Ttk_MacOSXPlatformInit(
+ Tcl_Interp *interp)
{
return AquaTheme_Init(interp);
}
-
+
/*
* Local Variables:
* mode: objc
@@ -1204,4 +3228,3 @@ int Ttk_MacOSXPlatformInit(Tcl_Interp *interp)
* coding: utf-8
* End:
*/
-
diff --git a/tests/arc.tcl b/tests/arc.tcl
index d0a93ea..2887047 100644
--- a/tests/arc.tcl
+++ b/tests/arc.tcl
@@ -52,7 +52,7 @@ set outline black
.t.c addtag arc withtag all
.t.c addtag circle withtag [.t.c create oval 320 200 340 220 -fill MistyRose3]
-.t.c bind arc <Any-Enter> {
+.t.c bind arc <Enter> {
set prevFill [lindex [.t.c itemconf current -fill] 4]
set prevOutline [lindex [.t.c itemconf current -outline] 4]
if {($prevFill != "") || ($prevOutline == "")} {
@@ -62,9 +62,9 @@ set outline black
.t.c itemconf current -outline $outline2
}
}
-.t.c bind arc <Any-Leave> {.t.c itemconf current -fill $prevFill -outline $prevOutline}
+.t.c bind arc <Leave> {.t.c itemconf current -fill $prevFill -outline $prevOutline}
-bind .t.c <1> {markarea %x %y}
+bind .t.c <Button-1> {markarea %x %y}
bind .t.c <B1-Motion> {strokearea %x %y}
proc markarea {x y} {
@@ -89,17 +89,17 @@ bind .t.c <Control-f> {
puts stdout "Overlapping: [.t.c find overl $areaX1 $areaY1 $areaX2 $areaY2]"
}
-bind .t.c <3> {puts stdout "%x %y"}
+bind .t.c <Button-3> {puts stdout "%x %y"}
# The code below allows the circle to be move by shift-dragging.
-bind .t.c <Shift-1> {
+bind .t.c <Shift-Button-1> {
set curx %x
set cury %y
}
bind .t.c <Shift-B1-Motion> {
- .t.c move circle [expr %x-$curx] [expr %y-$cury]
+ .t.c move circle [expr {%x-$curx}] [expr {%y-$cury}]
set curx %x
set cury %y
}
@@ -127,7 +127,7 @@ bind .t.c a {
}
incr i $delta
c -start $i
- c -extent [expr 360-2*$i]
+ c -extent [expr {360-2*$i}]
after 20
update
}
diff --git a/tests/bind.test b/tests/bind.test
index 50289b5..adc628a 100644
--- a/tests/bind.test
+++ b/tests/bind.test
@@ -22,7 +22,7 @@ foreach event [bind Test] {
bind Test $event {}
}
foreach event [bind all] {
- bind all $event {}
+ bind all $event {}
}
proc unsetBindings {} {
@@ -34,19 +34,6 @@ proc unsetBindings {} {
bind .t <Enter> {}
}
-# This function fills the pattern matcher's ring buffer with events of
-# the specified type. This can be used when testing with generated
-# events to make sure that there are no stray events in the ring
-# buffer which might cause the pattern matcher to find unintended
-# matches. The size of the ring buffer is EVENT_BUFFER_SIZE, which is
-# currently set to 30 (or 45 on macOS). If this changes, the code
-# below will need to change.
-proc clearRingBuffer {{event}} {
- for {set i 0} {$i < 45} {incr i} {
- event generate . $event
- }
-}
-
# move the mouse pointer away of the testing area
# otherwise some spurious events may pollute the tests
toplevel .top
@@ -310,9 +297,9 @@ test bind-5.1 {Tk_CreateBindingTable procedure} -body {
test bind-6.1 {Tk_DeleteBindTable procedure} -body {
canvas .t.c
- .t.c bind foo <1> {string 1}
+ .t.c bind foo <Button-1> {string 1}
.t.c create rectangle 0 0 100 100
- .t.c bind 1 <2> {string 2}
+ .t.c bind 1 <Button-2> {string 2}
destroy .t.c
} -cleanup {
destroy .t.c
@@ -325,17 +312,17 @@ test bind-7.1 {Tk_CreateBinding procedure: bad binding} -body {
} -returnCodes error -result {no event type or button # or keysym}
test bind-7.3 {Tk_CreateBinding procedure: append} -body {
canvas .t.c
- .t.c bind foo <1> "button 1"
- .t.c bind foo <1> "+more button 1"
- .t.c bind foo <1>
+ .t.c bind foo <Button-1> "button 1"
+ .t.c bind foo <Button-1> "+more button 1"
+ .t.c bind foo <Button-1>
} -cleanup {
destroy .t.c
} -result {button 1
more button 1}
test bind-7.4 {Tk_CreateBinding procedure: append to non-existing} -body {
canvas .t.c
- .t.c bind foo <1> "+button 1"
- .t.c bind foo <1>
+ .t.c bind foo <Button-1> "+button 1"
+ .t.c bind foo <Button-1>
} -cleanup {
destroy .t.c
} -result {button 1}
@@ -355,11 +342,11 @@ test bind-9.2 {Tk_DeleteBinding procedure} -setup {
} -body {
frame .t.f -class Test -width 150 -height 100
foreach i {a b c d} {
- bind .t.f $i "binding for $i"
+ bind .t.f $i "binding for $i"
}
foreach i {b d a c} {
- bind .t.f $i {}
- lappend result [lsort [bind .t.f]]
+ bind .t.f $i {}
+ lappend result [lsort [bind .t.f]]
}
return $result
} -cleanup {
@@ -369,12 +356,12 @@ test bind-9.3 {Tk_DeleteBinding procedure} -setup {
set result {}
} -body {
frame .t.f -class Test -width 150 -height 100
- foreach i {<1> <Meta-1> <Control-1> <Double-Alt-1>} {
- bind .t.f $i "binding for $i"
+ foreach i {<Button-1> <Meta-Button-1> <Control-Button-1> <Double-Alt-Button-1>} {
+ bind .t.f $i "binding for $i"
}
- foreach i {<Control-1> <Double-Alt-1> <1> <Meta-1>} {
- bind .t.f $i {}
- lappend result [lsort [bind .t.f]]
+ foreach i {<Control-Button-1> <Double-Alt-Button-1> <Button-1> <Meta-Button-1>} {
+ bind .t.f $i {}
+ lappend result [lsort [bind .t.f]]
}
return $result
} -cleanup {
@@ -398,7 +385,7 @@ test bind-10.2 {Tk_GetBinding procedure} -body {
test bind-11.1 {Tk_GetAllBindings procedure} -body {
frame .t.f
foreach i "! a \\\{ ~ <Delete> <space> <<Paste>> <Tab> <Linefeed> <less> <Meta-a> <Acircumflex>" {
- bind .t.f $i Test
+ bind .t.f $i Test
}
lsort [bind .t.f]
} -cleanup {
@@ -406,8 +393,8 @@ test bind-11.1 {Tk_GetAllBindings procedure} -body {
} -result {! <<Paste>> <Key-Acircumflex> <Key-Delete> <Key-Linefeed> <Key-Tab> <Key-less> <Key-space> <Meta-Key-a> a \{ ~}
test bind-11.2 {Tk_GetAllBindings procedure} -body {
frame .t.f
- foreach i "<Double-1> <Triple-1> <Meta-Control-a> <Double-Alt-Enter> <1>" {
- bind .t.f $i Test
+ foreach i "<Double-Button-1> <Triple-Button-1> <Meta-Control-a> <Double-Alt-Enter> <Button-1>" {
+ bind .t.f $i Test
}
lsort [bind .t.f]
} -cleanup {
@@ -415,8 +402,8 @@ test bind-11.2 {Tk_GetAllBindings procedure} -body {
} -result {<Button-1> <Control-Meta-Key-a> <Double-Alt-Enter> <Double-Button-1> <Triple-Button-1>}
test bind-11.3 {Tk_GetAllBindings procedure} -body {
frame .t.f
- foreach i "<Double-Triple-1> abcd a<Leave>b" {
- bind .t.f $i Test
+ foreach i "<Double-Triple-Button-1> abcd a<Leave>b" {
+ bind .t.f $i Test
}
lsort [bind .t.f]
} -cleanup {
@@ -430,8 +417,8 @@ test bind-12.1 {Tk_DeleteAllBindings procedure} -body {
} -result {}
test bind-12.2 {Tk_DeleteAllBindings procedure} -body {
frame .t.f -class Test -width 150 -height 100
- foreach i "a b c <Meta-1> <Alt-a> <Control-a>" {
- bind .t.f $i x
+ foreach i "a b c <Meta-Button-1> <Alt-a> <Control-a>" {
+ bind .t.f $i x
}
destroy .t.f
} -result {}
@@ -443,23 +430,23 @@ test bind-13.1 {Tk_BindEvent procedure} -setup {
update
set x {}
} -body {
- bind Test <KeyPress> {lappend x "%W %K Test KeyPress"}
- bind all <KeyPress> {lappend x "%W %K all KeyPress"}
+ bind Test <Key> {lappend x "%W %K Test Key"}
+ bind all <Key> {lappend x "%W %K all Key"}
bind Test : {lappend x "%W %K Test :"}
bind all _ {lappend x "%W %K all _"}
bind .t.f : {lappend x "%W %K .t.f :"}
- event generate .t.f <Key-colon>
- event generate .t.f <Key-plus>
- event generate .t.f <Key-underscore>
+ event generate .t.f <colon>
+ event generate .t.f <plus>
+ event generate .t.f <underscore>
return $x
} -cleanup {
destroy .t.f
- bind all <KeyPress> {}
- bind Test <KeyPress> {}
+ bind all <Key> {}
+ bind Test <Key> {}
bind all _ {}
bind Test : {}
-} -result {{.t.f colon .t.f :} {.t.f colon Test :} {.t.f colon all KeyPress} {.t.f plus Test KeyPress} {.t.f plus all KeyPress} {.t.f underscore Test KeyPress} {.t.f underscore all _}}
+} -result {{.t.f colon .t.f :} {.t.f colon Test :} {.t.f colon all Key} {.t.f plus Test Key} {.t.f plus all Key} {.t.f underscore Test Key} {.t.f underscore all _}}
test bind-13.2 {Tk_BindEvent procedure} -setup {
frame .t.f -class Test -width 150 -height 100
@@ -468,16 +455,16 @@ test bind-13.2 {Tk_BindEvent procedure} -setup {
update
set x {}
} -body {
- bind Test <KeyPress> {lappend x "%W %K Test press any"; break}
- bind all <KeyPress> {continue; lappend x "%W %K all press any"}
+ bind Test <Key> {lappend x "%W %K Test press any"; break}
+ bind all <Key> {continue; lappend x "%W %K all press any"}
bind .t.f : {lappend x "%W %K .t.f pressed colon"}
- event generate .t.f <Key-colon>
+ event generate .t.f <colon>
return $x
} -cleanup {
destroy .t.f
- bind all <KeyPress> {}
- bind Test <KeyPress> {}
+ bind all <Key> {}
+ bind Test <Key> {}
} -result {{.t.f colon .t.f pressed colon} {.t.f colon Test press any}}
test bind-13.3 {Tk_BindEvent procedure} -setup {
@@ -488,14 +475,14 @@ test bind-13.3 {Tk_BindEvent procedure} -setup {
update
set x {}
} -body {
- bind Test <KeyPress> {lappend x "%W %K Test press any"; error Test}
+ bind Test <Key> {lappend x "%W %K Test press any"; error Test}
bind .t.f : {lappend x "%W %K .t.f pressed colon"}
- event generate .t.f <Key-colon>
+ event generate .t.f <colon>
update
list $x $errorInfo
} -cleanup {
destroy .t.f
- bind Test <KeyPress> {}
+ bind Test <Key> {}
rename bgerror {}
} -result {{{.t.f colon .t.f pressed colon} {.t.f colon Test press any}} {Test
while executing
@@ -504,7 +491,7 @@ test bind-13.3 {Tk_BindEvent procedure} -setup {
test bind-13.4 {Tk_BindEvent procedure} -setup {
proc foo {} {
set x 44
- event generate .t.f <Key-colon>
+ event generate .t.f <colon>
}
frame .t.f -class Test -width 150 -height 100
pack .t.f
@@ -547,7 +534,7 @@ test bind-13.7 {Tk_BindEvent procedure} -setup {
bind .t.f : {lappend x "%W (.t.f binding)"}
bind Test : {lappend x "%W (Test binding)"}
bind all : {bind .t.f : {}; lappend x "%W (all binding)"}
- event generate .t.f <Key-colon>
+ event generate .t.f <colon>
return $x
} -cleanup {
bind Test : {}
@@ -564,7 +551,7 @@ test bind-13.8 {Tk_BindEvent procedure} -setup {
bind .t.f : {lappend x "%W (.t.f binding)"}
bind Test : {lappend x "%W (Test binding)"}
bind all : {destroy .t.f; lappend x "%W (all binding)"}
- event generate .t.f <Key-colon>
+ event generate .t.f <colon>
return $x
} -cleanup {
bind Test : {}
@@ -579,14 +566,14 @@ test bind-13.9 {Tk_BindEvent procedure} -setup {
update
set x {}
} -body {
- bind .t.f <1> {lappend x "%W z (.t.f <1> binding)"}
- bind .t.f <ButtonPress> {lappend x "%W z (.t.f <ButtonPress> binding)"}
+ bind .t.f <Button-1> {lappend x "%W z (.t.f <Button-1> binding)"}
+ bind .t.f <Button> {lappend x "%W z (.t.f <Button> binding)"}
event generate .t.f <Button-1>
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
-} -result {{.t.f z (.t.f <1> binding)} {.t.f z (.t.f <ButtonPress> binding)}}
+} -result {{.t.f z (.t.f <Button-1> binding)} {.t.f z (.t.f <Button> binding)}}
test bind-13.10 {Tk_BindEvent procedure: ignore NotifyInferior} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
@@ -629,9 +616,9 @@ test bind-13.12 {Tk_BindEvent procedure: collapse repeating modifiers} -setup {
} -body {
bind .t.f <Key> "lappend x %K%#"
bind .t.f <KeyRelease> "lappend x %K%#"
- event generate .t.f <Key-Shift_L> -serial 100 -when tail
+ event generate .t.f <Shift_L> -serial 100 -when tail
event generate .t.f <KeyRelease-Shift_L> -serial 101 -when tail
- event generate .t.f <Key-Shift_L> -serial 102 -when tail
+ event generate .t.f <Shift_L> -serial 102 -when tail
event generate .t.f <KeyRelease-Shift_L> -serial 103 -when tail
update
} -cleanup {
@@ -948,13 +935,13 @@ test bind-13.33 {Tk_BindEvent procedure: many C bindings cause realloc} -setup {
set x {}
} -body {
bindtags .t.f {a b c d e f g h i j k l m n o p}
- foreach p [bindtags .t.f] {
- bind $p <1> "lappend x $p"
+ foreach p [bindtags .t.f] {
+ bind $p <Button-1> "lappend x $p"
}
- event generate .t.f <1>
+ event generate .t.f <Button-1>
return $x
} -cleanup {
- foreach p [bindtags .t.f] {bind $p <1> {}}
+ foreach p [bindtags .t.f] {bind $p <Button-1> {}}
destroy .t.f
} -result {a b c d e f g h i j k l m n o p}
test bind-13.34 {Tk_BindEvent procedure: multiple tags} -setup {
@@ -979,8 +966,8 @@ test bind-13.35 {Tk_BindEvent procedure: execute binding} -setup {
update
set x {}
} -body {
- bind .t.f <1> {lappend x 1}
- event generate .t.f <1>
+ bind .t.f <Button-1> {lappend x 1}
+ event generate .t.f <Button-1>
return $x
} -cleanup {
destroy .t.f
@@ -992,13 +979,13 @@ test bind-13.38 {Tk_BindEvent procedure: binding gets to run} -setup {
update
set x {}
} -body {
- bind Test <1> {lappend x Test}
- bind .t.f <1> {lappend x .t.f}
- event generate .t.f <1>
+ bind Test <Button-1> {lappend x Test}
+ bind .t.f <Button-1> {lappend x .t.f}
+ event generate .t.f <Button-1>
return $x
} -cleanup {
destroy .t.f
- bind Test <1> {}
+ bind Test <Button-1> {}
} -result {.t.f Test}
test bind-13.41 {Tk_BindEvent procedure: continue in script} -setup {
frame .t.f -class Test -width 150 -height 100
@@ -1107,7 +1094,7 @@ test bind-15.4 {MatchPatterns procedure, ignoring type mismatches} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-1>
event generate .t.f <ButtonRelease-1>
@@ -1139,10 +1126,10 @@ test bind-15.6 {MatchPatterns procedure, ignoring type mismatches} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-1>
- event generate .t.f <Key-a>
+ event generate .t.f <a>
event generate .t.f <ButtonRelease-1>
event generate .t.f <Button-1>
event generate .t.f <ButtonRelease-1>
@@ -1156,10 +1143,10 @@ test bind-15.7 {MatchPatterns procedure, ignoring type mismatches} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-1>
- event generate .t.f <Key-Shift_L>
+ event generate .t.f <Shift_L>
event generate .t.f <ButtonRelease-1>
event generate .t.f <Button-1>
event generate .t.f <ButtonRelease-1>
@@ -1175,9 +1162,9 @@ test bind-15.8 {MatchPatterns procedure, ignoring type mismatches} -setup {
} -body {
bind .t.f ab {set x 1}
set x 0
- event generate .t.f <Key-a>
- event generate .t.f <Key-c>
- event generate .t.f <Key-b>
+ event generate .t.f <a>
+ event generate .t.f <c>
+ event generate .t.f <b>
return $x
} -cleanup {
destroy .t.f
@@ -1190,7 +1177,7 @@ test bind-15.9 {MatchPatterns procedure, modifier checks} -setup {
} -body {
bind .t.f <M1-M2-Key> {set x 1}
set x 0
- event generate .t.f <Key-a> -state 0x18
+ event generate .t.f <a> -state 0x18
return $x
} -cleanup {
destroy .t.f
@@ -1203,7 +1190,7 @@ test bind-15.10 {MatchPatterns procedure, modifier checks} -setup {
} -body {
bind .t.f <M1-M2-Key> {set x 1}
set x 0
- event generate .t.f <Key-a> -state 0xfc
+ event generate .t.f <a> -state 0xfc
return $x
} -cleanup {
destroy .t.f
@@ -1216,7 +1203,7 @@ test bind-15.11 {MatchPatterns procedure, modifier checks} -setup {
} -body {
bind .t.f <M1-M2-Key> {set x 1}
set x 0
- event generate .t.f <Key-a> -state 0x8
+ event generate .t.f <a> -state 0x8
return $x
} -cleanup {
destroy .t.f
@@ -1233,9 +1220,9 @@ test bind-15.12 {MatchPatterns procedure, ignore modifier presses and releases}
# differently on some platforms.
bind .t.f aB {set x 1}
set x 0
- event generate .t.f <Key-a>
- event generate .t.f <Key-Shift_L>
- event generate .t.f <Key-b> -state 1
+ event generate .t.f <a>
+ event generate .t.f <Shift_L>
+ event generate .t.f <b> -state 1
return $x
} -cleanup {
destroy .t.f
@@ -1248,8 +1235,8 @@ test bind-15.13 {MatchPatterns procedure, checking detail} -setup {
} -body {
bind .t.f ab {set x 1}
set x 0
- event generate .t.f <Key-a>
- event generate .t.f <Key-c>
+ event generate .t.f <a>
+ event generate .t.f <c>
return $x
} -cleanup {
destroy .t.f
@@ -1260,7 +1247,7 @@ test bind-15.14 {MatchPatterns procedure, checking "nearby"} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-2>
event generate .t.f <ButtonRelease-2>
@@ -1277,7 +1264,7 @@ test bind-15.15 {MatchPatterns procedure, checking "nearby"} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-2>
event generate .t.f <ButtonRelease-2>
@@ -1294,7 +1281,7 @@ test bind-15.16 {MatchPatterns procedure, checking "nearby"} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-2>
event generate .t.f <ButtonRelease-2>
@@ -1311,7 +1298,7 @@ test bind-15.17 {MatchPatterns procedure, checking "nearby"} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-2>
event generate .t.f <ButtonRelease-2>
@@ -1328,7 +1315,7 @@ test bind-15.18 {MatchPatterns procedure, checking "nearby"} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-2>
event generate .t.f <ButtonRelease-2>
@@ -1345,7 +1332,7 @@ test bind-15.19 {MatchPatterns procedure, checking "nearby"} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-2>
event generate .t.f <ButtonRelease-2>
@@ -1362,7 +1349,7 @@ test bind-15.20 {MatchPatterns procedure, checking "nearby"} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-2>
event generate .t.f <ButtonRelease-2>
@@ -1379,7 +1366,7 @@ test bind-15.21 {MatchPatterns procedure, checking "nearby"} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-2>
event generate .t.f <ButtonRelease-2>
@@ -1395,9 +1382,8 @@ test bind-15.22 {MatchPatterns procedure, time wrap-around} -setup {
pack .t.f
focus -force .t.f
update
- clearRingBuffer <Key>
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-1> -time -100
event generate .t.f <Button-1> -time 200
@@ -1411,9 +1397,8 @@ test bind-15.23 {MatchPatterns procedure, time wrap-around} -setup {
pack .t.f
focus -force .t.f
update
- clearRingBuffer <Key>
} -body {
- bind .t.f <Double-1> {set x 1}
+ bind .t.f <Double-Button-1> {set x 1}
set x 0
event generate .t.f <Button-1> -time -100
event generate .t.f <Button-1> -time 500
@@ -1428,7 +1413,6 @@ test bind-15.24 {MatchPatterns procedure, virtual event} -setup {
focus -force .t.f
update
set x {}
- clearRingBuffer <Key>
} -body {
event add <<Paste>> <Button-1>
bind .t.f <<Paste>> {lappend x paste}
@@ -1445,7 +1429,6 @@ test bind-15.25 {MatchPatterns procedure, reject a virtual event} -setup {
focus -force .t.f
update
set x {}
- clearRingBuffer <Key>
} -body {
event add <<Paste>> <Shift-Button-1>
bind .t.f <<Paste>> {lappend x paste}
@@ -1462,7 +1445,6 @@ test bind-15.26 {MatchPatterns procedure, reject a virtual event} -setup {
focus -force .t.f
update
set x {}
- clearRingBuffer <Key>
} -body {
event add <<V1>> <Button>
event add <<V2>> <Button-1>
@@ -1489,9 +1471,8 @@ test bind-15.27 {MatchPatterns procedure, conflict resolution} -setup {
pack .t.f
focus -force .t.f
update
- clearRingBuffer <Button>
} -body {
- bind .t.f <KeyPress> {set x 0}
+ bind .t.f <Key> {set x 0}
bind .t.f 1 {set x 1}
set x none
event generate .t.f <Key-1>
@@ -1504,9 +1485,8 @@ test bind-15.28 {MatchPatterns procedure, conflict resolution} -setup {
pack .t.f
focus -force .t.f
update
- clearRingBuffer <Button>
} -body {
- bind .t.f <KeyPress> {set x 0}
+ bind .t.f <Key> {set x 0}
bind .t.f 1 {set x 1}
set x none
event generate .t.f <Key-2>
@@ -1519,9 +1499,8 @@ test bind-15.29 {MatchPatterns procedure, conflict resolution} -setup {
pack .t.f
focus -force .t.f
update
- clearRingBuffer <Button>
} -body {
- bind .t.f <KeyPress> {lappend x 0}
+ bind .t.f <Key> {lappend x 0}
bind .t.f 1 {lappend x 1}
bind .t.f 21 {lappend x 2}
set x none
@@ -1537,10 +1516,9 @@ test bind-15.30 {MatchPatterns procedure, conflict resolution} -setup {
pack .t.f
focus -force .t.f
update
- clearRingBuffer <Key>
} -body {
- bind .t.f <ButtonPress> {set x 0}
- bind .t.f <1> {set x 1}
+ bind .t.f <Button> {set x 0}
+ bind .t.f <Button-1> {set x 1}
set x none
event generate .t.f <Button-1>
event generate .t.f <ButtonRelease-1>
@@ -1554,11 +1532,10 @@ test bind-15.31 {MatchPatterns procedure, conflict resolution} -setup {
focus -force .t.f
update
set x {}
- clearRingBuffer <Button>
} -body {
bind .t.f <M1-Key> {set x 0}
bind .t.f <M2-Key> {set x 1}
- event generate .t.f <Key-a> -state 0x18
+ event generate .t.f <a> -state 0x18
return $x
} -cleanup {
destroy .t.f
@@ -1568,12 +1545,11 @@ test bind-15.32 {MatchPatterns procedure, conflict resolution} -setup {
pack .t.f
focus -force .t.f
update
- clearRingBuffer <Button>
} -body {
bind .t.f <M2-Key> {set x 0}
bind .t.f <M1-Key> {set x 1}
set x none
- event generate .t.f <Key-a> -state 0x18
+ event generate .t.f <a> -state 0x18
return $x
} -cleanup {
destroy .t.f
@@ -1584,11 +1560,10 @@ test bind-15.33 {MatchPatterns procedure, conflict resolution} -setup {
focus -force .t.f
update
set x {}
- clearRingBuffer <Key>
} -body {
- bind .t.f <1> {lappend x single}
- bind Test <1> {lappend x single(Test)}
- bind Test <Double-1> {lappend x double(Test)}
+ bind .t.f <Button-1> {lappend x single}
+ bind Test <Button-1> {lappend x single(Test)}
+ bind Test <Double-Button-1> {lappend x double(Test)}
event generate .t.f <Button-1>
event generate .t.f <Button-1>
event generate .t.f <Button-1>
@@ -1596,8 +1571,8 @@ test bind-15.33 {MatchPatterns procedure, conflict resolution} -setup {
set x
} -cleanup {
destroy .t.f
- bind Test <1> {}
- bind Test <Double-1> {}
+ bind Test <Button-1> {}
+ bind Test <Double-Button-1> {}
} -result {single single(Test) single double(Test) single double(Test)}
@@ -1934,7 +1909,7 @@ test bind-16.26 {ExpandPercents procedure} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <1> {set x "%s"}
+ bind .t.f <Button-1> {set x "%s"}
set x none
event generate .t.f <Button-1> -state 1402
event generate .t.f <ButtonRelease-1>
@@ -2058,18 +2033,18 @@ test bind-16.35 {ExpandPercents procedure} -constraints {
set x {}
} -body {
bind .t.f <Key> {lappend x "%A"}
- event generate .t.f <Key-a>
- event generate .t.f <Key-A> -state 1
- event generate .t.f <Key-Tab>
- event generate .t.f <Key-Return>
- event generate .t.f <Key-F1>
- event generate .t.f <Key-Shift_L>
- event generate .t.f <Key-space>
- event generate .t.f <Key-dollar> -state 1
- event generate .t.f <Key-braceleft> -state 1
- event generate .t.f <Key-Multi_key>
- event generate .t.f <Key-e>
- event generate .t.f <Key-apostrophe>
+ event generate .t.f <a>
+ event generate .t.f <A> -state 1
+ event generate .t.f <Tab>
+ event generate .t.f <Return>
+ event generate .t.f <F1>
+ event generate .t.f <Shift_L>
+ event generate .t.f <space>
+ event generate .t.f <dollar> -state 1
+ event generate .t.f <braceleft> -state 1
+ event generate .t.f <Multi_key>
+ event generate .t.f <e>
+ event generate .t.f <apostrophe>
set x
} -cleanup {
destroy .t.f
@@ -2110,14 +2085,14 @@ test bind-16.38 {ExpandPercents procedure} -constraints {
set x {}
} -body {
bind .t.f <Key> {lappend x %K}
- event generate .t.f <Key-a>
- event generate .t.f <Key-A> -state 1
- event generate .t.f <Key-Tab>
- event generate .t.f <Key-F1>
- event generate .t.f <Key-Shift_L>
- event generate .t.f <Key-space>
- event generate .t.f <Key-dollar> -state 1
- event generate .t.f <Key-braceleft> -state 1
+ event generate .t.f <a>
+ event generate .t.f <A> -state 1
+ event generate .t.f <Tab>
+ event generate .t.f <F1>
+ event generate .t.f <Shift_L>
+ event generate .t.f <space>
+ event generate .t.f <dollar> -state 1
+ event generate .t.f <braceleft> -state 1
set x
} -cleanup {
destroy .t.f
@@ -2130,7 +2105,7 @@ test bind-16.39 {ExpandPercents procedure} -setup {
} -body {
bind .t.f <Key> {set x "%N"}
set x none
- event generate .t.f <Key-space>
+ event generate .t.f <space>
set x
} -cleanup {
destroy .t.f
@@ -2143,7 +2118,7 @@ test bind-16.40 {ExpandPercents procedure} -setup {
} -body {
bind .t.f <Key> {set x "%S"}
set x none
- event generate .t.f <Key-space> -subwindow .t
+ event generate .t.f <space> -subwindow .t
set x
} -cleanup {
destroy .t.f
@@ -2216,7 +2191,7 @@ test bind-16.45 {ExpandPercents procedure} -setup {
bind Entry <Key> {set y "%M"}
bind all <Key> {set z "%M"}
set x none; set y none; set z none
- event gen .t.e <Key-a>
+ event gen .t.e <a>
list $x $y $z
} -cleanup {
destroy .t.e
@@ -2232,13 +2207,12 @@ test bind-16.46 {ExpandPercents procedure} -setup {
focus -force .t.e
foreach p [event info] {event delete $p}
update
- clearRingBuffer <Button>
} -body {
bind all <Key> {set z "%M"}
bind Entry <Key> {set y "%M"}
bind .t.e <Key> {set x "%M"}
set x none; set y none; set z none
- event gen .t.e <Key-a>
+ event gen .t.e <a>
list $x $y $z
} -cleanup {
destroy .t.e
@@ -2272,13 +2246,13 @@ test bind-17.5 {event command: add 2} -body {
} -result {<Button-2> <Control-Key-v>}
test bind-17.6 {event command: add with error} -body {
- event add <<Paste>> <Control-v> <Button-2> abc <xyz> <1>
+ event add <<Paste>> <Control-v> <Button-2> abc <xyz> <Button-1>
} -cleanup {
event delete <<Paste>>
} -returnCodes error -result {bad event type or keysym "xyz"}
test bind-17.7 {event command: add with error} -body {
event delete <<Paste>>
- catch {event add <<Paste>> <Control-v> <Button-2> abc <xyz> <1>}
+ catch {event add <<Paste>> <Control-v> <Button-2> abc <xyz> <Button-1>}
lsort [event info <<Paste>>]
} -cleanup {
event delete <<Paste>>
@@ -2289,11 +2263,12 @@ test bind-17.8 {event command: delete} -body {
} -returnCodes error -result {wrong # args: should be "event delete virtual ?sequence ...?"}
test bind-17.9 {event command: delete many} -body {
event delete <<Paste>>
- event add <<Paste>> <3> <1> <2> t
- event delete <<Paste>> <1> <2>
+ event add <<Paste>> <Button-3> <Button-1> <Button-2> t
+ event delete <<Paste>> <Button-1> <Button-2>
lsort [event info <<Paste>>]
} -cleanup {
- event delete <<Paste>> <3> t
+ event delete <<Paste>>
+ event delete <<Paste>> <Button-3> t
} -result {<Button-3> t}
test bind-17.10 {event command: delete all} -body {
event add <<Paste>> a b
@@ -2341,8 +2316,8 @@ test bind-17.16 {event command: generate} -setup {
update
set x {}
} -body {
- bind .t.f <1> "lappend x 1"
- event generate .t.f <1>
+ bind .t.f <Button-1> "lappend x 1"
+ event generate .t.f <Button-1>
set x
} -cleanup {
destroy .t.f
@@ -2590,6 +2565,7 @@ test bind-19.15 {DeleteVirtualEvent procedure: owned by many, first} -setup {
pack [frame .t.f -class Test -width 150 -height 100]
pack [frame .t.g -class Test -width 150 -height 100]
pack [frame .t.h -class Test -width 150 -height 100]
+ after 250 ;# we need a bit time to ensure that .t.h is mapped (<TODO>: fix this race condition)
focus -force .t.f
update
set x {}
@@ -2626,6 +2602,7 @@ test bind-19.16 {DeleteVirtualEvent procedure: owned by many, middle} -setup {
pack [frame .t.f -class Test -width 150 -height 100]
pack [frame .t.g -class Test -width 150 -height 100]
pack [frame .t.h -class Test -width 150 -height 100]
+ after 250 ;# we need a bit time to ensure that .t.h is mapped (<TODO>: fix this race condition)
focus -force .t.f
update
set x {}
@@ -2662,6 +2639,7 @@ test bind-19.17 {DeleteVirtualEvent procedure: owned by many, last} -setup {
pack [frame .t.f -class Test -width 150 -height 100]
pack [frame .t.g -class Test -width 150 -height 100]
pack [frame .t.h -class Test -width 150 -height 100]
+ after 250 ;# we need a bit time to ensure that .t.h is mapped (<TODO>: fix this race condition)
focus -force .t.f
update
set x {}
@@ -2706,7 +2684,7 @@ test bind-20.2 {GetVirtualEvent procedure: non-existent event} -body {
test bind-20.3 {GetVirtualEvent procedure: owns 1} -setup {
event delete <<xyz>>
} -body {
- event add <<xyz>> <Control-Key-v>
+ event add <<xyz>> <Control-v>
event info <<xyz>>
} -cleanup {
event delete <<xyz>>
@@ -2737,7 +2715,7 @@ test bind-21.3 {GetAllVirtualEvents procedure: many events} -body {
event add <<xyz>> <Control-v>
event add <<xyz>> <Button-2>
event add <<abc>> <Control-v>
- event add <<def>> <Key-F6>
+ event add <<def>> <F6>
lsort [event info]
} -cleanup {
event delete <<xyz>>
@@ -2774,7 +2752,7 @@ test bind-22.5 {HandleEventGenerate} -body {
} -returnCodes error -result {bad event type or keysym "xyz"}
test bind-22.6 {HandleEventGenerate} -body {
event generate . <Double-Button-1>
-} -returnCodes error -result {Double or Triple modifier not allowed}
+} -returnCodes error -result {Double, Triple, or Quadruple modifier not allowed}
test bind-22.7 {HandleEventGenerate} -body {
event generate . xyz
} -returnCodes error -result {only one event specification allowed}
@@ -2806,7 +2784,7 @@ test bind-22.10 {HandleEventGenerate} -setup {
set x {}
} -body {
bind .t.f <Key> {set x "%s %K"}
- event generate .t.f <Control-Key-space>
+ event generate .t.f <Control-space>
set x
} -cleanup {
destroy .t.f
@@ -3928,7 +3906,7 @@ test bind-22.92 {HandleEventGenerate: options <Key> -sendevent 43} -setup {
return $x
} -cleanup {
destroy .t.f
-} -result {43}
+} -result {1}
test bind-22.93 {HandleEventGenerate: options <Key> -serial xyz} -setup {
frame .t.f -class Test -width 150 -height 100
@@ -4942,7 +4920,7 @@ test bind-24.3 {FindSequence procedure: virtual allowed} -setup {
destroy .t.f
} -result {}
test bind-24.4 {FindSequence procedure: virtual not allowed} -body {
- event add <<Paste>> <<Alive>>
+ event add <<Paste>> <<Alive>>
} -returnCodes error -result {virtual event not allowed in definition of another virtual event}
test bind-24.5 {FindSequence procedure, multiple bindings} -setup {
frame .t.f -class Test -width 150 -height 100
@@ -4950,10 +4928,10 @@ test bind-24.5 {FindSequence procedure, multiple bindings} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <1> {lappend x single}
- bind .t.f <Double-1> {lappend x double}
- bind .t.f <Triple-1> {lappend x triple}
- bind .t.f <Quadruple-1> {lappend x quadruple}
+ bind .t.f <Button-1> {lappend x single}
+ bind .t.f <Double-Button-1> {lappend x double}
+ bind .t.f <Triple-Button-1> {lappend x triple}
+ bind .t.f <Quadruple-Button-1> {lappend x quadruple}
set x press
event generate .t.f <Button-1>
event generate .t.f <ButtonRelease-1>
@@ -5121,9 +5099,13 @@ test bind-25.3 {ParseEventDescription procedure} -setup {
} -cleanup {
destroy .t.f
} -result a
-test bind-25.4 {ParseEventDescription} -body {
- bind .t <<Shift-Paste>> {puts hi}
- bind .t
+test bind-25.4 {ParseEventDescription} -setup {
+ frame .t.f -class Test -width 150 -height 100
+} -body {
+ bind .t.f <<Shift-Paste>> {puts hi}
+ bind .t.f
+} -cleanup {
+ destroy .t.f
} -result {<<Shift-Paste>>}
# Assorted error cases in event sequence parsing
@@ -5170,310 +5152,346 @@ test bind-25.17 {ParseEventDescription} -body {
# Modifier canonicalization tests
test bind-25.18 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
bind .t.f {<Control- a>} foo
- bind .t.f
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Control-Key-a>
test bind-25.19 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Shift-a> foo
- bind .t.f
+ bind .t.f <Shift-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Shift-Key-a>
test bind-25.20 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Lock-a> foo
- bind .t.f
+ bind .t.f <Lock-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Lock-Key-a>
test bind-25.21 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Meta---a> foo
- bind .t.f
+ bind .t.f <Meta---a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Meta-Key-a>
test bind-25.22 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <M-a> foo
- bind .t.f
+ bind .t.f <M-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Meta-Key-a>
test bind-25.23 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Alt-a> foo
- bind .t.f
+ bind .t.f <Alt-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Alt-Key-a>
test bind-25.24 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <B1-a> foo
- bind .t.f
+ bind .t.f <B1-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <B1-Key-a>
test bind-25.25 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <B2-a> foo
- bind .t.f
+ bind .t.f <B2-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <B2-Key-a>
test bind-25.26 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <B3-a> foo
- bind .t.f
+ bind .t.f <B3-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <B3-Key-a>
test bind-25.27 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <B4-a> foo
- bind .t.f
+ bind .t.f <B4-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <B4-Key-a>
test bind-25.28 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <B5-a> foo
- bind .t.f
+ bind .t.f <B5-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <B5-Key-a>
test bind-25.29 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Button1-a> foo
- bind .t.f
+ bind .t.f <Button1-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <B1-Key-a>
test bind-25.30 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Button2-a> foo
- bind .t.f
+ bind .t.f <Button2-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <B2-Key-a>
test bind-25.31 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Button3-a> foo
- bind .t.f
+ bind .t.f <Button3-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <B3-Key-a>
test bind-25.32 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Button4-a> foo
- bind .t.f
+ bind .t.f <Button4-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <B4-Key-a>
test bind-25.33 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Button5-a> foo
- bind .t.f
+ bind .t.f <Button5-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <B5-Key-a>
test bind-25.34 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <M1-a> foo
- bind .t.f
+ bind .t.f <M1-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Mod1-Key-a>
test bind-25.35 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <M2-a> foo
- bind .t.f
+ bind .t.f <M2-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Mod2-Key-a>
test bind-25.36 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <M3-a> foo
- bind .t.f
+ bind .t.f <M3-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Mod3-Key-a>
test bind-25.37 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <M4-a> foo
- bind .t.f
+ bind .t.f <M4-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Mod4-Key-a>
test bind-25.38 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <M5-a> foo
- bind .t.f
+ bind .t.f <M5-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Mod5-Key-a>
test bind-25.39 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Mod1-a> foo
- bind .t.f
+ bind .t.f <Mod1-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Mod1-Key-a>
test bind-25.40 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Mod2-a> foo
- bind .t.f
+ bind .t.f <Mod2-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Mod2-Key-a>
test bind-25.41 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Mod3-a> foo
- bind .t.f
+ bind .t.f <Mod3-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Mod3-Key-a>
test bind-25.42 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Mod4-a> foo
- bind .t.f
+ bind .t.f <Mod4-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Mod4-Key-a>
test bind-25.43 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Mod5-a> foo
- bind .t.f
+ bind .t.f <Mod5-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Mod5-Key-a>
test bind-25.44 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Double-a> foo
- bind .t.f
+ bind .t.f <Double-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Double-Key-a>
test bind-25.45 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Triple-a> foo
- bind .t.f
+ bind .t.f <Triple-a> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Triple-Key-a>
test bind-25.46 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f {<Double 1>} foo
- bind .t.f
+ bind .t.f {<Double 1>} foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Double-Button-1>
test bind-25.47 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Triple-1> foo
- bind .t.f
+ bind .t.f <Triple-1> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Triple-Button-1>
test bind-25.48 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f {<M1-M2 M3-M4 B1-Control-a>} foo
- bind .t.f
+ bind .t.f {<M1-M2 M3-M4 B1-Control-a>} foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Control-B1-Mod1-Mod2-Mod3-Mod4-Key-a>
test bind-25.49 {modifier names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
- bind .t.f <Extended-Return> foo
- bind .t.f
+ bind .t.f <Extended-Return> foo
+ bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <Extended-Key-Return>
+test bind-25.50 {modifier names} -setup {
+ frame .t.f -class Test -width 150 -height 100
+} -body {
+ bind .t.f <Button6-a> foo
+ bind .t.f
+} -cleanup {
+ destroy .t.f
+} -result <B6-Key-a>
+
+test bind-25.51 {modifier names} -setup {
+ frame .t.f -class Test -width 150 -height 100
+} -body {
+ bind .t.f <Button7-a> foo
+ bind .t.f
+} -cleanup {
+ destroy .t.f
+} -result <B7-Key-a>
+
+test bind-25.52 {modifier names} -setup {
+ frame .t.f -class Test -width 150 -height 100
+} -body {
+ bind .t.f <Button8-a> foo
+ bind .t.f
+} -cleanup {
+ destroy .t.f
+} -result <B8-Key-a>
+
+test bind-25.53 {modifier names} -setup {
+ frame .t.f -class Test -width 150 -height 100
+} -body {
+ bind .t.f <Button9-a> foo
+ bind .t.f
+} -cleanup {
+ destroy .t.f
+} -result <B9-Key-a>
+
test bind-26.1 {event names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
bind .t.f <FocusIn> {nothing}
bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <FocusIn>
test bind-26.2 {event names} -setup {
- frame .t.f -class Test -width 150 -height 100
+ frame .t.f -class Test -width 150 -height 100
} -body {
bind .t.f <FocusOut> {nothing}
bind .t.f
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result <FocusOut>
test bind-26.3 {event names} -setup {
frame .t.f -class Test -width 150 -height 100
@@ -5495,12 +5513,12 @@ test bind-26.4 {event names: Motion} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Motion> "set x {event Motion}"
- set x xyzzy
- event generate .t.f <Motion>
- list $x [bind .t.f]
+ bind .t.f <Motion> "set x {event Motion}"
+ set x xyzzy
+ event generate .t.f <Motion>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Motion} <Motion>}
test bind-26.5 {event names: Button} -setup {
@@ -5509,12 +5527,12 @@ test bind-26.5 {event names: Button} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Button> "set x {event Button}"
- set x xyzzy
- event generate .t.f <Button>
- list $x [bind .t.f]
+ bind .t.f <Button> "set x {event Button}"
+ set x xyzzy
+ event generate .t.f <Button>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Button} <Button>}
test bind-26.6 {event names: ButtonPress} -setup {
@@ -5523,12 +5541,12 @@ test bind-26.6 {event names: ButtonPress} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <ButtonPress> "set x {event ButtonPress}"
- set x xyzzy
- event generate .t.f <ButtonPress>
- list $x [bind .t.f]
+ bind .t.f <ButtonPress> "set x {event ButtonPress}"
+ set x xyzzy
+ event generate .t.f <ButtonPress>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event ButtonPress} <Button>}
test bind-26.7 {event names: ButtonRelease} -setup {
@@ -5537,12 +5555,12 @@ test bind-26.7 {event names: ButtonRelease} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <ButtonRelease> "set x {event ButtonRelease}"
- set x xyzzy
- event generate .t.f <ButtonRelease>
- list $x [bind .t.f]
+ bind .t.f <ButtonRelease> "set x {event ButtonRelease}"
+ set x xyzzy
+ event generate .t.f <ButtonRelease>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event ButtonRelease} <ButtonRelease>}
test bind-26.8 {event names: Colormap} -setup {
@@ -5551,12 +5569,12 @@ test bind-26.8 {event names: Colormap} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Colormap> "set x {event Colormap}"
- set x xyzzy
- event generate .t.f <Colormap>
- list $x [bind .t.f]
+ bind .t.f <Colormap> "set x {event Colormap}"
+ set x xyzzy
+ event generate .t.f <Colormap>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Colormap} <Colormap>}
test bind-26.9 {event names: Enter} -setup {
@@ -5565,12 +5583,12 @@ test bind-26.9 {event names: Enter} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Enter> "set x {event Enter}"
- set x xyzzy
- event generate .t.f <Enter>
- list $x [bind .t.f]
+ bind .t.f <Enter> "set x {event Enter}"
+ set x xyzzy
+ event generate .t.f <Enter>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Enter} <Enter>}
test bind-26.10 {event names: Leave} -setup {
@@ -5579,12 +5597,12 @@ test bind-26.10 {event names: Leave} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Leave> "set x {event Leave}"
- set x xyzzy
- event generate .t.f <Leave>
- list $x [bind .t.f]
+ bind .t.f <Leave> "set x {event Leave}"
+ set x xyzzy
+ event generate .t.f <Leave>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Leave} <Leave>}
test bind-26.11 {event names: Expose} -setup {
@@ -5593,12 +5611,12 @@ test bind-26.11 {event names: Expose} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Expose> "set x {event Expose}"
- set x xyzzy
- event generate .t.f <Expose>
- list $x [bind .t.f]
+ bind .t.f <Expose> "set x {event Expose}"
+ set x xyzzy
+ event generate .t.f <Expose>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Expose} <Expose>}
test bind-26.12 {event names: Key} -setup {
@@ -5607,12 +5625,12 @@ test bind-26.12 {event names: Key} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Key> "set x {event Key}"
- set x xyzzy
- event generate .t.f <Key>
- list $x [bind .t.f]
+ bind .t.f <Key> "set x {event Key}"
+ set x xyzzy
+ event generate .t.f <Key>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Key} <Key>}
test bind-26.13 {event names: KeyPress} -setup {
@@ -5621,12 +5639,12 @@ test bind-26.13 {event names: KeyPress} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <KeyPress> "set x {event KeyPress}"
- set x xyzzy
- event generate .t.f <KeyPress>
- list $x [bind .t.f]
+ bind .t.f <KeyPress> "set x {event KeyPress}"
+ set x xyzzy
+ event generate .t.f <KeyPress>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event KeyPress} <Key>}
test bind-26.14 {event names: KeyRelease} -setup {
@@ -5635,12 +5653,12 @@ test bind-26.14 {event names: KeyRelease} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <KeyRelease> "set x {event KeyRelease}"
- set x xyzzy
- event generate .t.f <KeyRelease>
- list $x [bind .t.f]
+ bind .t.f <KeyRelease> "set x {event KeyRelease}"
+ set x xyzzy
+ event generate .t.f <KeyRelease>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event KeyRelease} <KeyRelease>}
test bind-26.15 {event names: Property} -setup {
@@ -5649,12 +5667,12 @@ test bind-26.15 {event names: Property} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Property> "set x {event Property}"
- set x xyzzy
- event generate .t.f <Property>
- list $x [bind .t.f]
+ bind .t.f <Property> "set x {event Property}"
+ set x xyzzy
+ event generate .t.f <Property>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Property} <Property>}
test bind-26.16 {event names: Visibility} -setup {
@@ -5663,12 +5681,12 @@ test bind-26.16 {event names: Visibility} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Visibility> "set x {event Visibility}"
- set x xyzzy
- event generate .t.f <Visibility>
- list $x [bind .t.f]
+ bind .t.f <Visibility> "set x {event Visibility}"
+ set x xyzzy
+ event generate .t.f <Visibility>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Visibility} <Visibility>}
test bind-26.17 {event names: Activate} -setup {
@@ -5677,12 +5695,12 @@ test bind-26.17 {event names: Activate} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Activate> "set x {event Activate}"
- set x xyzzy
- event generate .t.f <Activate>
- list $x [bind .t.f]
+ bind .t.f <Activate> "set x {event Activate}"
+ set x xyzzy
+ event generate .t.f <Activate>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Activate} <Activate>}
test bind-26.18 {event names: Deactivate} -setup {
@@ -5691,12 +5709,12 @@ test bind-26.18 {event names: Deactivate} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Deactivate> "set x {event Deactivate}"
- set x xyzzy
- event generate .t.f <Deactivate>
- list $x [bind .t.f]
+ bind .t.f <Deactivate> "set x {event Deactivate}"
+ set x xyzzy
+ event generate .t.f <Deactivate>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Deactivate} <Deactivate>}
@@ -5707,12 +5725,12 @@ test bind-26.19 {event names: Circulate} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Circulate> "set x {event Circulate}"
- set x xyzzy
- event generate .t.f <Circulate>
- list $x [bind .t.f]
+ bind .t.f <Circulate> "set x {event Circulate}"
+ set x xyzzy
+ event generate .t.f <Circulate>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Circulate} <Circulate>}
test bind-26.20 {event names: Configure} -setup {
@@ -5721,12 +5739,12 @@ test bind-26.20 {event names: Configure} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Configure> "set x {event Configure}"
- set x xyzzy
- event generate .t.f <Configure>
- list $x [bind .t.f]
+ bind .t.f <Configure> "set x {event Configure}"
+ set x xyzzy
+ event generate .t.f <Configure>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Configure} <Configure>}
test bind-26.21 {event names: Gravity} -setup {
@@ -5735,12 +5753,12 @@ test bind-26.21 {event names: Gravity} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Gravity> "set x {event Gravity}"
- set x xyzzy
- event generate .t.f <Gravity>
- list $x [bind .t.f]
+ bind .t.f <Gravity> "set x {event Gravity}"
+ set x xyzzy
+ event generate .t.f <Gravity>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Gravity} <Gravity>}
test bind-26.22 {event names: Map} -setup {
@@ -5749,12 +5767,12 @@ test bind-26.22 {event names: Map} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Map> "set x {event Map}"
- set x xyzzy
- event generate .t.f <Map>
- list $x [bind .t.f]
+ bind .t.f <Map> "set x {event Map}"
+ set x xyzzy
+ event generate .t.f <Map>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Map} <Map>}
test bind-26.23 {event names: Reparent} -setup {
@@ -5763,12 +5781,12 @@ test bind-26.23 {event names: Reparent} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Reparent> "set x {event Reparent}"
- set x xyzzy
- event generate .t.f <Reparent>
- list $x [bind .t.f]
+ bind .t.f <Reparent> "set x {event Reparent}"
+ set x xyzzy
+ event generate .t.f <Reparent>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Reparent} <Reparent>}
test bind-26.24 {event names: Unmap} -setup {
@@ -5777,12 +5795,12 @@ test bind-26.24 {event names: Unmap} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Unmap> "set x {event Unmap}"
- set x xyzzy
- event generate .t.f <Unmap>
- list $x [bind .t.f]
+ bind .t.f <Unmap> "set x {event Unmap}"
+ set x xyzzy
+ event generate .t.f <Unmap>
+ list $x [bind .t.f]
} -cleanup {
- destroy .t.f
+ destroy .t.f
} -result {{event Unmap} <Unmap>}
@@ -5791,7 +5809,7 @@ test bind-27.1 {button names} -body {
} -returnCodes error -result {specified button "1" for non-button event}
test bind-27.2 {button names} -body {
bind .t <Button-10> foo
-} -returnCodes error -result {bad event type or keysym "10"}
+} -returnCodes error -result {bad button number "10"}
test bind-27.3 {button names} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
@@ -5926,7 +5944,7 @@ test bind-28.2 {keysym names} -body {
bind .t <Gorp> foo
} -returnCodes error -result {bad event type or keysym "Gorp"}
test bind-28.3 {keysym names} -body {
- bind .t <Key-Stupid> foo
+ bind .t <Stupid> foo
} -returnCodes error -result {bad event type or keysym "Stupid"}
test bind-28.4 {keysym names} -body {
frame .t.f -class Test -width 150 -height 100
@@ -5942,10 +5960,10 @@ test bind-28.5 {keysym names} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Key-colon> "lappend x \"keysym received\""
- bind .t.f <Key-underscore> "lappend x {bad binding match}"
+ bind .t.f <colon> "lappend x \"keysym received\""
+ bind .t.f <underscore> "lappend x {bad binding match}"
set x [lsort [bind .t.f]]
- event generate .t.f <Key-colon> ;# -state 0
+ event generate .t.f <colon> ;# -state 0
set x
} -cleanup {
destroy .t.f
@@ -5956,10 +5974,10 @@ test bind-28.6 {keysym names} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Key-Return> "lappend x \"keysym Return\""
- bind .t.f <Key-x> "lappend x {bad binding match}"
+ bind .t.f <Return> "lappend x \"keysym Return\""
+ bind .t.f <x> "lappend x {bad binding match}"
set x [lsort [bind .t.f]]
- event generate .t.f <Key-Return> -state 0
+ event generate .t.f <Return> -state 0
set x
} -cleanup {
destroy .t.f
@@ -5970,10 +5988,10 @@ test bind-28.7 {keysym names} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Key-X> "lappend x \"keysym X\""
- bind .t.f <Key-x> "lappend x {bad binding match}"
+ bind .t.f <X> "lappend x \"keysym X\""
+ bind .t.f <x> "lappend x {bad binding match}"
set x [lsort [bind .t.f]]
- event generate .t.f <Key-X> -state 1
+ event generate .t.f <X> -state 1
set x
} -cleanup {
destroy .t.f
@@ -5984,17 +6002,45 @@ test bind-28.8 {keysym names} -setup {
focus -force .t.f
update
} -body {
- bind .t.f <Key-X> "lappend x \"keysym X\""
- bind .t.f <Key-x> "lappend x {bad binding match}"
+ bind .t.f <X> "lappend x \"keysym X\""
+ bind .t.f <x> "lappend x {bad binding match}"
set x [lsort [bind .t.f]]
- event generate .t.f <Key-X> -state 1
+ event generate .t.f <X> -state 1
set x
} -cleanup {
destroy .t.f
} -result {X x {keysym X}}
+test bind-28.9 {keysym names, Eth -> ETH} -body {
+ frame .t.f -class Test -width 150 -height 100
+ bind .t.f <Eth> foo
+ bind .t.f
+} -cleanup {
+ destroy .t.f
+} -result {<Key-ETH>}
+test bind-28.10 {keysym names, Ooblique -> Oslash} -body {
+ frame .t.f -class Test -width 150 -height 100
+ bind .t.f <Ooblique> foo
+ bind .t.f
+} -cleanup {
+ destroy .t.f
+} -result {<Key-Oslash>}
+test bind-28.11 {keysym names, gcedilla} -body {
+ frame .t.f -class Test -width 150 -height 100
+ bind .t.f <gcedilla> foo
+ bind .t.f
+} -cleanup {
+ destroy .t.f
+} -result {<Key-gcedilla>}
+test bind-28.12 {keysym names, Greek_IOTAdiaeresis -> Greek_IOTAdieresis} -body {
+ frame .t.f -class Test -width 150 -height 100
+ bind .t.f <Greek_IOTAdiaeresis> foo
+ bind .t.f
+} -cleanup {
+ destroy .t.f
+} -result {<Key-Greek_IOTAdieresis>}
-test bind-29.1 {Tk_BackgroundError procedure} -setup {
+test bind-29.1 {Tcl_BackgroundError procedure} -setup {
proc bgerror msg {
global x errorInfo
set x [list $msg $errorInfo]
@@ -6018,7 +6064,7 @@ test bind-29.1 {Tk_BackgroundError procedure} -setup {
"error "This is a test""
(command bound to event)}}
-test bind-29.2 {Tk_BackgroundError procedure} -setup {
+test bind-29.2 {Tcl_BackgroundError procedure} -setup {
proc do {} {
event generate .t.f <Button>
event generate .t.f <ButtonRelease>
@@ -6182,7 +6228,7 @@ test bind-31.7 {virtual event user_data field - unshared, asynch} -setup {
destroy .t.f
} -result {{} {} {TestUserData >b<}}
-test bind-32 {-warp, window was destroyed before the idle callback DoWarp} -setup {
+test bind-32.1 {-warp, window was destroyed before the idle callback DoWarp} -setup {
frame .t.f
pack .t.f
focus -force .t.f
@@ -6194,12 +6240,691 @@ test bind-32 {-warp, window was destroyed before the idle callback DoWarp} -setu
update ; # shall simply not crash
} -cleanup {
} -result {}
+test bind-32.2 {detection of double click should not fail} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ bind .t.f <Double-Button-1> { set x "Double" }
+ update
+ set x {}
+} -body {
+ event generate .t.f <Button-1>
+ event generate .t.f <ButtonRelease-1>
+ # Simulate a lot of intervening exposure events. The old implementation
+ # that used an event ring overflowed, and the double click was not detected.
+ # But new implementation should work properly.
+ for {set i 0} {$i < 1000} {incr i} {
+ event generate .t.f <Expose>
+ }
+ event generate .t.f <Button-1>
+ event generate .t.f <ButtonRelease-1>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {Double}
+test bind-32.3 {should trigger best match of modifier states} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Alt-Control-A> { lappend x "Alt-Control" }
+ bind .t.f <Shift-Control-A> { lappend x "Shift-Control" }
+ bind .t.f <Shift-A> { lappend x "Shift" }
+ event generate .t.f <Alt-Control-A>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {Shift-Control}
+test bind-32.4 {should not trigger Double-1} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Double-Button-1> { set x "Double" }
+ event generate .t.f <Button-1> -time current
+ after 1000
+ event generate .t.f <Button-1> -time current
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {}
+test bind-32.5 {should trigger Quadruple-1} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Quadruple-Button-1> { set x "Quadruple" }
+ bind .t.f <Triple-Button-1> { set x "Triple" }
+ bind .t.f <Double-Button-1> { set x "Double" }
+ bind .t.f <Button-1> { set x "Single" }
+ # Old implementation triggered "Double", but new implementation
+ # triggers "Quadruple", the latter behavior conforms to other toolkits.
+ event generate .t.f <Button-1> -time 0
+ event generate .t.f <Button-1> -time 400
+ event generate .t.f <Button-1> -time 800
+ event generate .t.f <Button-1> -time 1200
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {Quadruple}
+test bind-32.6 {problem with sendevent} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ # Old implementation was losing sendevent value
+ bind .t.f <FocusIn> { set x "sendevent=%E" }
+ event generate .t.f <FocusIn> -sendevent 1
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {sendevent=1}
+test bind-32.7 {test sequences} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Double-Button-1> { lappend x "Double" }
+ bind .t.f <Button-1><Button-1><a> { lappend x "11" }
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <a>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {Double 11}
+test bind-32.8 {test sequences} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <a><Button-1><Double-Button-1><Button-1><a> { lappend x "Double" }
+ event generate .t.f <a>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <a>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {Double}
+test bind-32.9 {trigger events for modifier keys} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Key> { set x "Key" }
+ event generate .t.f <Key> -keysym Caps_Lock
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {Key}
+test bind-32.10 {reset key state when destroying window} -setup {
+ set x {}
+} -body {
+ pack [frame .t.f]; update; focus -force .t.f
+ bind .t.f <A> { set x "A" }
+ event generate .t.f <A>
+ event generate .t.f <A>
+ destroy .t.f; update
+ pack [frame .t.f]; update; focus -force .t.f
+ bind .t.f <A> { set x "A" }
+ bind .t.f <Double-A> { set x "AA" }
+ event generate .t.f <A>
+ destroy .t.f
+ set x
+} -result {A}
+test bind-32.11 {match detailed virtual} -setup {
+ pack [frame .t.f -class Test]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ event add <<TestControlButton1>> <Control-Button-1>
+ bind Test <<TestControlButton1>> { set x "Control-Button-1" }
+ bind Test <Button-1> { set x "Button-1" }
+ bind .t.f <Button-1> { set x "Button-1" }
+ event generate .t.f <Control-Button-1>
+ set x
+} -cleanup {
+ destroy .t.f
+ event delete <<TestControlButton1>>
+ bind Test <Button-1> {#}
+} -result {Control-Button-1}
+test bind-32.12 {don't detect repetition when window has changed} -setup {
+ pack [frame .t.f]
+ pack [frame .t.g]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Button-1> { set x "1" }
+ bind .t.f <Double-Button-1> { set x "11" }
+ event generate .t.f <Button-1>
+ event generate .t.g <Button-1>
+ event generate .t.f <Button-1>
+ set x
+} -cleanup {
+ destroy .t.f
+ destroy .t.g
+} -result {1}
+test bind-32.13 {don't detect repetition when window has changed} -setup {
+ pack [frame .t.f]
+ pack [frame .t.g]
+ update
+ set x {}
+} -body {
+ bind .t.f <A> { set x "A" }
+ bind .t.f <Double-A> { set x "AA" }
+ focus -force .t.f; event generate .t.f <A>
+ focus -force .t.g; event generate .t.g <A>
+ focus -force .t.f; event generate .t.f <A>
+ set x
+} -cleanup {
+ destroy .t.f
+ destroy .t.g
+} -result {A}
+test bind-32.14 {don't detect repetition when window has changed} -setup {
+ pack [frame .t.f]
+ pack [frame .t.g]
+ update
+ set x {}
+} -body {
+ bind .t.f <Button-1> { set x "1" }
+ bind .t.f <Double-Button-1> { set x "11" }
+ focus -force .t.f; event generate .t.f <Button-1>
+ focus -force .t.g; event generate .t.g <Button-1>
+ focus -force .t.f; event generate .t.f <Button-1>
+ set x
+} -cleanup {
+ destroy .t.f
+ destroy .t.g
+} -result {1}
+test bind-32.15 {reset button state when destroying window} -setup {
+ set x {}
+} -body {
+ pack [frame .t.f]; update; focus -force .t.f
+ bind .t.f <Button-1> { set x "1" }
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ destroy .t.f; update
+ pack [frame .t.f]; update; focus -force .t.f
+ bind .t.f <Button-1> { set x "1" }
+ bind .t.f <Double-Button-1> { set x "11" }
+ event generate .t.f <Button-1>
+ destroy .t.f
+ set x
+} -result {1}
+test bind-33.1 {prefer longest match} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <a><Button-1><Button-1> { lappend x "a11" }
+ bind .t.f <Double-Button-1> { lappend x "Double" }
+ event generate .t.f <a>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {a11}
+test bind-33.2 {prefer most specific event} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Double-Button-1> { lappend x "Double" }
+ bind .t.f <Button-1><Button-1> { lappend x "11" }
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {Double}
+test bind-33.3 {prefer most specific event} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <a><Double-Button-1><a> { lappend x "Double" }
+ bind .t.f <a><Button-1><Button-1><a> { lappend x "11" }
+ event generate .t.f <a>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <a>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {Double}
+test bind-33.4 {prefer most specific event} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Button-1><Button-1> { lappend x "11" }
+ bind .t.f <Double-Button-1> { lappend x "Double" }
+ event generate .t.f <Button-1> -time 0
+ event generate .t.f <Button-1> -time 1000
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {11}
+test bind-33.5 {prefer most specific event} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Button-1><Button-1> { lappend x "11" }
+ bind .t.f <Double-Button> { lappend x "Double" }
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {11}
+test bind-33.6 {prefer most specific event} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <a><Button-1><Button-1><Button-1><Button-1><a> { lappend x "1111" }
+ bind .t.f <a><Button><Double-Button><Button><a> { lappend x "Any-Double-Any" }
+ event generate .t.f <a>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <a>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {1111}
+test bind-33.7 {prefer most specific event} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Button-1><a> { lappend x "1" }
+ bind .t.f <Button><a> { lappend x "Any" }
+ event generate .t.f <Button-1>
+ event generate .t.f <a>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {1}
+test bind-33.8 {prefer most specific event} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Double-Button-1><a> { lappend x "1" }
+ bind .t.f <Button><Button><a> { lappend x "Any" }
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <a>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {1}
+test bind-33.9 {prefer last in case of homogeneous equal patterns} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Button-1><Button-2><Button-2><Double-Button-1> { lappend x "first" }
+ bind .t.f <Button-1><Double-Button-2><Button-1><Button-1> { lappend x "last" }
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-2>
+ event generate .t.f <Button-2>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {last}
+test bind-33.10 {prefer last in case of homogeneous equal patterns} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Button-1><Double-Button-2><Button-1><Button-1> { lappend x "first" }
+ bind .t.f <Button-1><Button-2><Button-2><Double-Button-1> { lappend x "last" }
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-2>
+ event generate .t.f <Button-2>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {last}
+test bind-33.11 {should prefer most specific} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Button-2><Double-Button-1><Double-Button-2><Double-Button-1><Button-2><Button-2> { lappend x "first" }
+ bind .t.f <Button-2><Button-1><Button-1><Button-2><Button-2><Double-Button-1><Double-Button-2> { lappend x "last" }
+ event generate .t.f <Button-2>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-2>
+ event generate .t.f <Button-2>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-2>
+ event generate .t.f <Button-2>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {first}
+test bind-33.12 {prefer last in case of homogeneous equal patterns} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Control-Button-1><Button-1> { lappend x "first" }
+ bind .t.f <Button-1><Control-Button-1> { lappend x "last" }
+ event generate .t.f <Control-Button-1>
+ event generate .t.f <Control-Button-1>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {last}
+test bind-33.13 {prefer last in case of homogeneous equal patterns} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Button-1><Control-1> { lappend x "first" }
+ bind .t.f <Control-1><Button-1> { lappend x "last" }
+ event generate .t.f <Control-Button-1>
+ event generate .t.f <Control-Button-1>
+ set x
+} -cleanup {
+ destroy .t.f
+ # Old implementation failed, and returned "first", but this was wrong,
+ # because both bindings are homogeneous equal, so the most recently defined
+ # must be preferred.
+} -result {last}
+test bind-33.14 {prefer last in case of homogeneous equal patterns} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Button-1><Button><Button-1><Button> { lappend x "first" }
+ bind .t.f <Button><Button-1><Button><Button-1> { lappend x "last" }
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {last}
+test bind-33.15 {prefer last in case of homogeneous equal patterns} -setup {
+ pack [frame .t.f]
+ focus -force .t.f
+ update
+ set x {}
+} -body {
+ bind .t.f <Button><Button-1><Button><Button-1> { lappend x "first" }
+ bind .t.f <Button-1><Button><Button-1><Button> { lappend x "last" }
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ event generate .t.f <Button-1>
+ set x
+} -cleanup {
+ destroy .t.f
+ # Old implementation failed, and returned "first", but this was wrong,
+ # because both bindings are homogeneous equal, so the most recently defined
+ # must be preferred.
+} -result {last}
+
+test bind-34.1 {-warp works relatively to a window} -setup {
+ toplevel .top
+ wm geometry .top +100+100
+ update
+} -body {
+ # In order to avoid platform-dependent coordinate results due to
+ # decorations and borders, this test warps the pointer twice
+ # relatively to a window that moved in the meantime, and checks
+ # how much the pointer moved
+ wm geometry .top +200+200
+ update
+ event generate .top <Motion> -x 20 -y 20 -warp 1
+ update idletasks ; # DoWarp is an idle callback
+ after 50 ; # Win specific - wait for SendInput to be executed
+ set pointerPos1 [winfo pointerxy .t]
+ wm geometry .top +600+600
+ update
+ event generate .top <Motion> -x 20 -y 20 -warp 1
+ update idletasks ; # DoWarp is an idle callback
+ after 50 ; # Win specific - wait for SendInput to be executed
+ set pointerPos2 [winfo pointerxy .t]
+ # from the first warped position to the second one, the mouse
+ # pointer should have moved the same amount as the window moved
+ set res 1
+ foreach pos1 $pointerPos1 pos2 $pointerPos2 {
+ if {$pos1 != [expr {$pos2 - 400}]} {
+ set res [list $pointerPos1 $pointerPos2]
+ }
+ }
+ set res
+} -cleanup {
+ destroy .top
+} -result {1}
+test bind-34.2 {-warp works relatively to the screen} -setup {
+} -body {
+ # Contrary to bind-34.1, we're directly checking screen coordinates
+ event generate {} <Motion> -x 20 -y 20 -warp 1
+ update idletasks ; # DoWarp is an idle callback
+ after 50 ; # Win specific - wait for SendInput to be executed
+ set res [winfo pointerxy .]
+ event generate {} <Motion> -x 200 -y 200 -warp 1
+ update idletasks ; # DoWarp is an idle callback
+ after 50 ; # Win specific - wait for SendInput to be executed
+ lappend res {*}[winfo pointerxy .]
+} -cleanup {
+} -result {20 20 200 200}
+test bind-34.3 {-warp works with null or negative coordinates} -setup {
+ # On some OS/WM, at least Linux with KDE, the "Screen edges" feature
+ # provides hot spots that can be associated with some action.
+ # When activated, the WM will not allow warping to happen on top of
+ # a hot spot (which would trigger the corresponding action as an
+ # unwanted effect) but will warp the pointer to the hot spot limit only.
+ if {[tk windowingsystem] eq "x11"} {
+ set halo 1
+ } else {
+ set halo 0
+ }
+ set res {}
+} -body {
+ event generate {} <Motion> -x 0 -y 0 -warp 1
+ update idletasks ; # DoWarp is an idle callback
+ after 50 ; # Win specific - wait for SendInput to be executed
+ foreach dim [winfo pointerxy .] {
+ if {$dim <= $halo} {
+ lappend res ok
+ } else {
+ lappend res $dim
+ }
+ }
+ event generate {} <Motion> -x 100 -y 100 -warp 1
+ update idletasks ; after 50
+ event generate {} <Motion> -x -1 -y -1 -warp 1
+ update idletasks ; after 50
+ foreach dim [winfo pointerxy .] {
+ if {$dim <= $halo} {
+ lappend res ok
+ } else {
+ lappend res $dim
+ }
+ }
+ set res
+} -cleanup {
+} -result {ok ok ok ok}
+
+set keyInfo {}
+set numericKeysym {}
+proc testKey {window event type mods} {
+ global keyInfo numericKeysym
+ set keyInfo {}
+ set numericKeysym {}
+ bind $window <KeyPress> {
+ set keyInfo [format "%K,0x%%X,0x%%X,%A" %N %k]
+ set numericKeysym %N
+ }
+ focus -force $window
+ update
+ event generate $window $event
+ if {$keyInfo == {}} {
+ vwait keyInfo
+ }
+ set save $keyInfo
+ set keyInfo {}
+ set injectcmd [list injectkeyevent $type $numericKeysym]
+ foreach {option} $mods {
+ lappend injectcmd $option
+ }
+ eval $injectcmd
+ if {$keyInfo == {}} {
+ vwait keyInfo
+ }
+ if {$save != $keyInfo} {
+ return "[format "0x%x" $numericKeysym] ($mods): $save != $keyInfo"
+ }
+ return pass
+}
+proc testKeyWithMods {window keysym type} {
+ set result [testKey $window "<$keysym>" $type {}]
+ if {$result != {pass}} {
+ return $result
+ }
+ set result [testKey $window "<Shift-$keysym>" $type {-shift}]
+ if {$result != {pass}} {
+ return $result
+ }
+ set result [testKey $window "<Option-$keysym>" $type {-option}]
+ if {$result != {pass}} {
+ return $result
+ }
+ set result [testKey $window "<Shift-Option-$keysym>" $type {-shift -option}]
+ if {$result != {pass}} {
+ return $result
+ }
+ return pass
+}
+test bind-35.0 {Generated and real key events agree} -constraints {aqua} -body {
+ foreach k {o O F2 Home Right Greek_sigma Greek_ALPHA} {
+ set result [testKeyWithMods . $k press]
+ if {$result != "pass"} {
+ return $result
+ }
+ }
+ return pass
+} -cleanup {
+} -result pass
+
+test bind-35.1 {Key events agree for entry widgets} -constraints {aqua} -setup {
+ toplevel .new
+ entry .new.e
+ pack .new.e
+} -body {
+ foreach k {o O F2 Home Right Greek_sigma Greek_ALPHA Menu} {
+ set result [testKeyWithMods .new.e $k press]
+ if {$result != "pass"} {
+ return $result
+ }
+ }
+ return pass
+} -cleanup {
+ destroy .new.e
+ destroy .new
+} -result pass
+
+test bind-35.2 {Can bind to function keys} -constraints {aqua} -body {
+ global keyInfo numericKeysym
+ bind . <KeyPress> {}
+ bind . <KeyPress> {
+ lappend keyInfo %K
+ set numericKeysym %N
+ }
+ set keyInfo {}
+ set numericKeysym {}
+ focus -force .
+ event generate . <F2>
+ injectkeyevent press $numericKeysym -function
+ vwait keyInfo
+ return $keyInfo
+} -cleanup {
+} -result {F2 F2}
+
+test bind-35.3 {Events agree for modifier keys} -constraints {aqua} -setup {
+} -body {
+ global keyInfo numericalKeysym
+ set result {}
+ bind . <KeyPress> {
+ set keyInfo [format "%K,0x%%X,0x%%X,%A" %N %k]
+ set numericalKeysym [format "0x%x" %N]
+ }
+ foreach event {
+ {<Control_L> -control}
+ {<Control_R> -control}
+ {<Alt_L> -option}
+ {<Alt_R> -option}
+ {<Meta_L> -command}
+ {<Meta_R> -command}
+ {<Shift_L> -shift}
+ {<Shift_R> -shift}
+ } {
+ set keyInfo {}
+ event generate . [lindex $event 0]
+ if {$keyInfo == {}} {
+ vwait keyInfo
+ }
+ set save $keyInfo
+ injectkeyevent flagschanged $numericKeysym [lindex $event 1]
+ if {$keyInfo == {}} {
+ vwait keyInfo
+ }
+ if {$save != $keyInfo} {
+ return "$save != $keyInfo"
+ }
+ }
+ return pass
+} -cleanup {
+} -result pass
# cleanup
cleanupTests
return
+# vi:set ts=4 sw=4 et:
# Local Variables:
# mode: tcl
# End:
diff --git a/tests/bugs.tcl b/tests/bugs.tcl
deleted file mode 100644
index 55e5f84..0000000
--- a/tests/bugs.tcl
+++ /dev/null
@@ -1,41 +0,0 @@
-# This file is a Tcl script to test out various known bugs that will
-# cause Tk to crash. This file ends with .tcl instead of .test to make
-# sure it isn't run when you type "source all". We currently are not
-# shipping this file with the rest of the source release.
-#
-# Copyright (c) 1996 Sun Microsystems, Inc.
-#
-# See the file "license.terms" for information on usage and redistribution
-# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-
-if {[info procs test] != "test"} {
- source defs
-}
-
-test crash-1.0 {imgPhoto} {
- image create photo p1
- image create photo p2
- catch {image create photo p2 -file bogus}
- p1 copy p2
- label .l -image p1
- destroy .l
- set foo ""
-} {}
-
-test crash-1.1 {color} {
- . configure -bg rgb:345
- set foo ""
-} {}
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/button.test b/tests/button.test
index 47d4296..f3292b31 100644
--- a/tests/button.test
+++ b/tests/button.test
@@ -3444,12 +3444,12 @@ test button-5.24 {ConfigureButton - computing geometry} -constraints {
set expectedwidth [expr {$textwidth + 2*[.b cget -borderwidth] \
+ 2*[.b cget -highlightthickness] + 2*[.b cget -padx]}]
incr expectedwidth 2 ; # added (hardcoded) in tkUnixButton.c
- set result [expr $expectedwidth == [winfo reqwidth .b]]
+ set result [expr {$expectedwidth == [winfo reqwidth .b]}]
set linespace [lindex [font metrics [.b cget -font] -displayof .b] 5]
set expectedheight [expr {$linespace + 2*[.b cget -borderwidth] \
+ 2*[.b cget -highlightthickness] + 2*[.b cget -pady]}]
incr expectedheight 2 ; # added (hardcoded) in tkUnixButton.c
- lappend result [expr $expectedheight == [winfo reqheight .b]]
+ lappend result [expr {$expectedheight == [winfo reqheight .b]}]
# 2. button with a bitmap image
# there is no access to characteristics the predefined bitmaps,
# so define one as an image (copied from questhead.xbm)
@@ -3468,11 +3468,11 @@ test button-5.24 {ConfigureButton - computing geometry} -constraints {
set expectedwidth [expr {[image width $myquesthead] + 2*[.b cget -borderwidth] \
+ 2*[.b cget -highlightthickness]}]
incr expectedwidth 2 ; # added (hardcoded) in tkUnixButton.c
- lappend result [expr $expectedwidth == [winfo reqwidth .b]]
+ lappend result [expr {$expectedwidth == [winfo reqwidth .b]}]
set expectedheight [expr {[image height $myquesthead] + 2*[.b cget -borderwidth] \
+ 2*[.b cget -highlightthickness]}]
incr expectedheight 2 ; # added (hardcoded) in tkUnixButton.c
- lappend result [expr $expectedheight == [winfo reqheight .b]]
+ lappend result [expr {$expectedheight == [winfo reqheight .b]}]
} -cleanup {
destroy .b
} -result {1 1 1 1}
@@ -3958,6 +3958,45 @@ test button-14.1 {bug fix: [011706ec42] tk::ButtonInvoke unsafe wrt widget destr
destroy .top.b .top
} -result {}
+test button-15.1 {Bug [5d991b822e]} {
+ # Want this not to segfault
+ set var INIT
+ button .b -textvariable var
+ trace add variable var unset {apply {args {
+ .b configure -textvariable {}
+ }}}
+ pack .b
+ bind .b <Configure> {unset var}
+ update
+ destroy .b
+} {}
+test button-15.2 {Bug [5d991b822e]} {
+ # Want this not to leak traces
+ set var INIT
+ button .b -textvariable var
+ trace add variable var unset {apply {args {
+ .b configure -textvariable new
+ }}}
+ pack .b
+ bind .b <Configure> {unset -nocomplain var}
+ update
+ destroy .b
+ unset new
+} {}
+test button-15.3 {Bug [5d991b822e]} {
+ # Want this not to leak traces
+ set var INIT
+ checkbutton .b -variable var
+ trace add variable var unset {apply {args {
+ .b configure -variable {}
+ }}}
+ pack .b
+ bind .b <Configure> {unset var}
+ update
+ destroy .b
+} {}
+
+
imageFinish
cleanupTests
return
diff --git a/tests/canvImg.test b/tests/canvImg.test
index 84992f2..d6ed9a8 100644
--- a/tests/canvImg.test
+++ b/tests/canvImg.test
@@ -156,23 +156,30 @@ test canvImg-4.1 {ConfiugreImage procedure} -constraints testImageType -setup {
.c delete all
image delete foo
} -result {{{foo free}} {}}
-test canvImg-4.2 {ConfiugreImage procedure} -constraints testImageType -setup {
+test canvImg-4.2 {ConfigureImage procedure} -constraints testImageType -setup {
.c delete all
} -body {
- image create test foo -variable x
+ image create test foo -variable x
image create test foo2 -variable y
foo2 changed 0 0 0 0 80 60
.c create image 50 100 -image foo -tags i1 -anchor nw
update
set x {}
set y {}
+ set timer [after 300 {lappend y "timed out"}]
.c itemconfigure i1 -image foo2
+ update idletasks
update
+ # On MacOS we need to wait for the test image display procedure to run.
+ while {"timed out" ni $y && [lindex $y end 1] ne "display"} {
+ vwait y
+ }
+ after cancel timer
list $x $y [.c bbox i1]
} -cleanup {
- .c delete all
- image delete foo
- image delete foo2
+ .c delete all
+ image delete foo
+ image delete foo2
} -result {{{foo free}} {{foo2 get} {foo2 display 0 0 80 60}} {50 100 130 160}}
test canvImg-4.3 {ConfiugreImage procedure} -constraints testImageType -setup {
.c delete all
@@ -720,36 +727,48 @@ test canvImg-9.1 {DisplayImage procedure} -constraints testImageType -setup {
image delete foo
} -result {75 150 105 165}
+if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} {
+ # Aqua >= 10.14 will redraw the entire image.
+ set result_10_1 {{foo display 0 0 30 15}}
+} else {
+ set result_10_1 {{foo display 2 4 6 8}}
+}
test canvImg-10.1 {TranslateImage procedure} -constraints testImageType -setup {
.c delete all
update
} -body {
- image create test foo -variable x
+ image create test foo -variable x
.c create image 50 100 -image foo -tags image -anchor nw
update
set x {}
+ set timer [after 500 {lappend x "timed out"}]
foo changed 2 4 6 8 30 15
+ vwait x
+ after cancel $timer
update
return $x
} -cleanup {
- .c delete all
- image delete foo
-} -result {{foo display 2 4 6 8}}
+ .c delete all
+ image delete foo
+} -result $result_10_1
test canvImg-11.1 {TranslateImage procedure} -constraints testImageType -setup {
.c delete all
update
} -body {
- image create test foo -variable x
+ image create test foo -variable x
.c create image 50 100 -image foo -tags image -anchor nw
update
set x {}
+ set timer [after 500 {lappend x "timed out"}]
foo changed 2 4 6 8 40 50
+ vwait x
+ after cancel $timer
update
return $x
} -cleanup {
- .c delete all
- image delete foo
+ .c delete all
+ image delete foo
} -result {{foo display 0 0 40 50}}
test canvImg-11.2 {ImageChangedProc procedure} -constraints {
testImageType
@@ -766,6 +785,12 @@ test canvImg-11.2 {ImageChangedProc procedure} -constraints {
.c delete all
image delete foo
} -result {30 75 70 125}
+if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} {
+ # Aqua >= 10.14 will redraw the entire image.
+ set result_11_3 {{foo2 display 0 0 80 60}}
+} else {
+ set result_11_3 {{foo2 display 0 0 20 40}}
+}
test canvImg-11.3 {ImageChangedProc procedure} -constraints {
testImageType
} -setup {
@@ -773,21 +798,22 @@ test canvImg-11.3 {ImageChangedProc procedure} -constraints {
update
} -body {
image create test foo -variable x
- image create test foo2 -variable y
+ image create test foo2 -variable z
foo changed 0 0 0 0 40 50
foo2 changed 0 0 0 0 80 60
-
.c create image 50 100 -image foo -tags image -anchor nw
.c create image 70 110 -image foo2 -anchor nw
- update
- set y {}
+ update idletasks
+ set z {}
+ set timer [after 500 {lappend z "timed out"}]
image create test foo -variable x
- update
- return $y
+ vwait x
+ after cancel $timer
+ return $z
} -cleanup {
- .c delete all
- image delete foo foo2
-} -result {{foo2 display 0 0 20 40}}
+ .c delete all
+ image delete foo foo2
+} -result $result_11_3
# cleanup
imageFinish
diff --git a/tests/canvPs.test b/tests/canvPs.test
index c7ba958..eb09af9 100644
--- a/tests/canvPs.test
+++ b/tests/canvPs.test
@@ -19,17 +19,17 @@ pack .c
update
test canvPs-1.1 {test writing to a file} -constraints {
- unixOrPc
+ unixOrWin
} -setup {
set foo [makeFile {} foo.ps]
} -body {
- .c postscript -file $foo
- file exists $foo
+ set res [.c postscript -file $foo]
+ lappend res [file exists $foo]
} -cleanup {
removeFile foo.ps
} -result 1
test canvPs-1.2 {test writing to a file, idempotency} -constraints {
- unixOrPc
+ unixOrWin
} -setup {
set foo [makeFile {} foo.ps]
set bar [makeFile {} bar.ps]
@@ -48,21 +48,21 @@ test canvPs-1.2 {test writing to a file, idempotency} -constraints {
test canvPs-2.1 {test writing to a channel} -constraints {
- unixOrPc
+ unixOrWin
} -setup {
set foo [makeFile {} foo.ps]
file delete $foo
} -body {
set chan [open $foo w]
fconfigure $chan -translation lf
- .c postscript -channel $chan
+ set res [.c postscript -channel $chan]
close $chan
- file exists $foo
+ lappend res [file exists $foo]
} -cleanup {
removeFile foo.ps
} -result 1
test canvPs-2.2 {test writing to channel, idempotency} -constraints {
- unixOrPc
+ unixOrWin
} -setup {
set foo [makeFile {} foo.ps]
set bar [makeFile {} bar.ps]
diff --git a/tests/canvText.test b/tests/canvText.test
index c04cb63..20cbff4 100644
--- a/tests/canvText.test
+++ b/tests/canvText.test
@@ -269,7 +269,7 @@ test canvText-6.1 {ComputeTextBbox procedure} -constraints fonts -setup {
.c create text 0 0 -tag test
.c itemconfig test -font $font -text 0
expr {[.c itemconfig test -anchor n; .c bbox test] \
- eq "[expr -$ax/2-1] 0 [expr $ax/2+1] $ay"}
+ eq "[expr {-$ax/2-1}] 0 [expr {$ax/2+1}] $ay"}
} -cleanup {
.c delete test
} -result 1
@@ -282,7 +282,7 @@ test canvText-6.2 {ComputeTextBbox procedure} -constraints fonts -setup {
.c create text 0 0 -tag test
.c itemconfig test -font $font -text 0
expr {[.c itemconfig test -anchor nw; .c bbox test] \
- eq "-1 0 [expr $ax+1] $ay"}
+ eq "-1 0 [expr {$ax+1}] $ay"}
} -cleanup {
.c delete test
} -result 1
@@ -803,6 +803,25 @@ test canvText-14.6 {select clear errors} -setup {
} -cleanup {
.c delete test
} -returnCodes error -result "wrong \# args: should be \".c select clear\""
+test canvText-14.7 {GetTextIndex procedure: pixel index with non-default scrollregion} -setup {
+ canvas .cc
+ .cc create text 50 80 -tag test -text Hello -anchor nw -font "Arial 30"
+ foreach {xmin ymin xmax ymax} [.cc bbox test] {}
+} -body {
+ # default -scrollregion
+ set res [.cc index test @$xmin,$ymin]
+ lappend res [.cc index test @$xmax,$ymax]
+ # -scrollregion with positive upper left corner
+ .cc configure -scrollregion {50 50 700 900}
+ lappend res [.cc index test @$xmin,$ymin]
+ lappend res [.cc index test @$xmax,$ymax]
+ # -scrollregion with negative upper left corner
+ .cc configure -scrollregion {-100 -100 700 900}
+ lappend res [.cc index test @$xmin,$ymin]
+ lappend res [.cc index test @$xmax,$ymax]
+} -cleanup {
+ destroy .cc
+} -result {0 5 0 5 0 5}
test canvText-15.1 {SetTextCursor procedure} -setup {
.c create text 0 0 -tag test
@@ -945,6 +964,20 @@ test canvText-20.1 {angled text bounding box} -setup {
rename transpose {}
} -result {ok ok ok}
+test canvText-20.2 {crash on angled text selection (X11, without xft) - bug 2712f43f6e} -setup {
+ destroy .c
+ canvas .c -background bisque -selectforeground green2
+ grid .c
+ set id [.c create text 50 150 -anchor w -text "Angled text" \
+ -angle 30 -font {Helvetica 32} -fill darkblue]
+} -body {
+ .c select clear
+ .c select from $id 0
+ .c select to $id 8 ; update ; # used to crash on X11 (--disable-xft build only)
+} -cleanup {
+ destroy .c
+} -result {}
+
# cleanup
cleanupTests
return
diff --git a/tests/canvas.test b/tests/canvas.test
index e8dc332..5086389 100644
--- a/tests/canvas.test
+++ b/tests/canvas.test
@@ -227,6 +227,16 @@ test canvas-2.4 {CanvasWidgetCmd, xview option} -constraints nonPortable -body {
update
lappend x [.c xview]
} -result {{0.6 0.9} {0.66 0.96}}
+test canvas-2.5 {CanvasWidgetCmd, raise/lower option, no error on non-existing tags} -setup {
+ .c create line 0 0 10 10 -tags aline
+} -body {
+ .c raise aline noline
+ .c raise bline aline
+ .c lower aline noline
+ .c lower bline aline
+} -cleanup {
+ .c delete aline
+} -result {}
catch {destroy .c}
# Canvas used in 3.* test cases
@@ -356,9 +366,9 @@ test canvas-9.1 {canvas id creation and deletion} -setup {
for {set i 0} {$i < $size} {incr i} {
set x [expr {-10 + 3*$i}]
for {set j 0; set y -10} {$j < 10} {incr j; incr y 3} {
- .c create rect ${x}c ${y}c [expr $x+2]c [expr $y+2]c \
+ .c create rect ${x}c ${y}c [expr {$x+2}]c [expr {$y+2}]c \
-outline black -fill blue -tags rect
- .c create text [expr $x+1]c [expr $y+1]c -text "$i,$j" \
+ .c create text [expr {$x+1}]c [expr {$y+1}]c -text "$i,$j" \
-anchor center -tags text
}
}
@@ -574,7 +584,7 @@ test canvas-13.1 {canvas delete during event, SF bug-228024} -body {
set ::x {}
# do this many times to improve chances of triggering the crash
for {set i 0} {$i < 30} {incr i} {
- event generate .c <1> -x 100 -y 100
+ event generate .c <Button-1> -x 100 -y 100
event generate .c <ButtonRelease-1> -x 100 -y 100
}
return $::x
@@ -952,6 +962,48 @@ test canvas-19.11 {rchars method - errors} -setup {
destroy .c
} -returnCodes error -result {bad index "foo"}
+test canvas-20.1 {addtag/dtag - no shuffling of tag sequence} -setup {
+ canvas .c
+ .c create text 100 100 -text Hello
+} -body {
+ for {set i 1} {$i < 5} {incr i} {
+ .c addtag tag$i all
+ }
+ # [.c addtags] only adds tags that are not already present
+ .c addtag tag1 all ; # no effect
+ set res [list [.c gettags 1]]
+ .c dtag 1 tag2
+ lappend res [.c gettags 1]
+} -cleanup {
+ destroy .c
+} -result {{tag1 tag2 tag3 tag4} {tag1 tag3 tag4}}
+test canvas-20.2 {tag deletion - multiple tags with same name, no shuffling} -setup {
+ canvas .c
+ .c create text 100 100 -text Hello
+} -body {
+ # [.c itemconfigure -tags] lets the user add duplicate tags
+ # this is not a problem although inconsistent with [.c addtags]
+ .c itemconfigure 1 -tags {tagA tagB tagA tagA tagC tagA}
+ set res [list [.c gettags 1]]
+ .c dtag 1 tagA
+ lappend res [.c gettags 1]
+} -cleanup {
+ destroy .c
+} -result {{tagA tagB tagA tagA tagC tagA} {tagB tagC}}
+test canvas-20.3 {tag deletion - all tags match} -setup {
+ canvas .c
+ .c create text 100 100 -text Hello
+} -body {
+ # [.c itemconfigure -tags] lets the user add duplicate tags
+ # this is not a problem although inconsistent with [.c addtags]
+ .c itemconfigure 1 -tags {tagA tagA tagA tagA tagA tagA}
+ set res [list [.c gettags 1]]
+ .c dtag 1 tagA
+ lappend res [.c gettags 1]
+} -cleanup {
+ destroy .c
+} -result {{tagA tagA tagA tagA tagA tagA} {}}
+
# Procedure used in test cases 20.1 20.2 20.3
proc matchPixels {pixels expected} {
set matched 1
@@ -1040,6 +1092,207 @@ test canvas-20.3 {canvas image with subsample and zoom} -setup {
image delete testimage
} -result 1
+test canvas-21.1 {canvas very small arc} -setup {
+ catch {destroy .c}
+ canvas .c
+} -body {
+ # no Inf or NaN must be generated even for very small arcs
+ .c create arc 0 100 0 100 -height 100 -style arc -outline "" -tags arc1
+ set arcBox [.c bbox arc1]
+ .c create arc 0 100 0 100 -height 100 -style arc -outline blue -tags arc2
+ set outlinedArcBox [.c bbox arc2]
+ set coords [.c coords arc1]
+ set start [.c itemcget arc1 -start]
+ set extent [.c itemcget arc1 -extent]
+ set width [.c itemcget arc1 -width]
+ set height [.c itemcget arc1 -height]
+ list $arcBox $outlinedArcBox $coords $start $extent $width $height
+} -result {{-1 99 1 101} {-2 98 2 102} {0.0 100.0 0.0 100.0} 0.0 0.0 1.0 0.0}
+
+
+destroy .c
+test canvas-21.1 {canvas rotate} -setup {
+ pack [canvas .c]
+} -body {
+ .c create line 50 50 50 100 100 100
+ .c rotate all 75 75 90
+ lmap c [.c coords all] {format %.2f $c}
+} -cleanup {
+ destroy .c
+} -result {50.00 100.00 100.00 100.00 100.00 50.00}
+test canvas-21.2 {canvas rotate} -setup {
+ pack [canvas .c]
+} -body {
+ .c create line 50 50 50 100 100 100
+ .c rotate all 75 75 -10
+ lmap c [.c coords all] {format %.2f $c}
+} -cleanup {
+ destroy .c
+} -result {54.72 46.04 46.04 95.28 95.28 103.96}
+test canvas-21.3 {canvas rotate: syntax} -setup {
+ pack [canvas .c]
+} -body {
+ .c rotate all 75 75
+} -returnCodes error -cleanup {
+ destroy .c
+} -result {wrong # args: should be ".c rotate tagOrId x y angle"}
+test canvas-21.4 {canvas rotate: syntax} -setup {
+ pack [canvas .c]
+} -body {
+ .c rotate all 75 75 123 123
+} -returnCodes error -cleanup {
+ destroy .c
+} -result {wrong # args: should be ".c rotate tagOrId x y angle"}
+test canvas-21.5 {canvas rotate: syntax} -setup {
+ pack [canvas .c]
+} -body {
+ .c rotate {!} 1 1 1
+} -returnCodes error -cleanup {
+ destroy .c
+} -result {missing tag in tag search expression}
+test canvas-21.6 {canvas rotate: syntax} -setup {
+ pack [canvas .c]
+} -body {
+ .c rotate all x 1 1
+} -returnCodes error -cleanup {
+ destroy .c
+} -result {bad screen distance "x"}
+test canvas-21.7 {canvas rotate: syntax} -setup {
+ pack [canvas .c]
+} -body {
+ .c rotate all 1 x 1
+} -returnCodes error -cleanup {
+ destroy .c
+} -result {bad screen distance "x"}
+test canvas-21.8 {canvas rotate: syntax} -setup {
+ pack [canvas .c]
+} -body {
+ .c rotate all 1 1 x
+} -returnCodes error -cleanup {
+ destroy .c
+} -result {expected floating-point number but got "x"}
+test canvas-21.9 {canvas rotate: nothing to rotate} -setup {
+ pack [canvas .c]
+} -body {
+ .c rotate all 75 75 10
+} -cleanup {
+ destroy .c
+} -result {}
+test canvas-21.10 {canvas rotate: multiple things to rotate} -setup {
+ pack [canvas .c]
+} -body {
+ .c create line 50 50 50 100 -tag a
+ .c create line 50 50 100 50 -tag b
+ .c rotate all 75 75 45
+ list [lmap c [.c coords a] {format %.2f $c}] [lmap c [.c coords b] {format %.2f $c}]
+} -cleanup {
+ destroy .c
+} -result {{39.64 75.00 75.00 110.36} {39.64 75.00 75.00 39.64}}
+
+test canvas-22.1 {canvas rotate: arc item rotation behaviour} -setup {
+ pack [canvas .c]
+} -body {
+ .c create arc 50 50 75 75 -start 45 -extent 90
+ .c rotate all 100 100 90
+ list [lmap c [.c coords all] {format %.2f $c}] \
+ [lmap o {-start -extent} {.c itemcget all $o}] \
+ [.c bbox all]
+} -cleanup {
+ destroy .c
+} -result {{50.00 125.00 75.00 150.00} {45.0 90.0} {52 123 73 140}}
+test canvas-22.2 {canvas rotate: bitmap item rotation behaviour} -setup {
+ pack [canvas .c]
+} -body {
+ .c create bitmap 50 50 -bitmap info -anchor se
+ .c rotate all 100 100 90
+ list [lmap c [.c coords all] {format %.2f $c}] \
+ [lmap o {-bitmap -anchor} {.c itemcget all $o}] \
+ [.c bbox all]
+} -cleanup {
+ destroy .c
+} -result {{50.00 150.00} {info se} {42 129 50 150}}
+test canvas-22.3 {canvas rotate: image item rotation behaviour} -setup {
+ pack [canvas .c]
+ image create photo dummy -width 50 -height 50
+} -body {
+ .c create image 50 50 -image dummy -anchor se
+ .c rotate all 100 100 90
+ list [lmap c [.c coords all] {format %.2f $c}] \
+ [lmap o {-image -anchor} {.c itemcget all $o}] \
+ [.c bbox all]
+} -cleanup {
+ destroy .c
+ image delete dummy
+} -result {{50.00 150.00} {dummy se} {0 100 50 150}}
+test canvas-22.4 {canvas rotate: line item rotation behaviour} -setup {
+ pack [canvas .c]
+} -body {
+ .c create line 50 50 75 50 50 75 75 75
+ .c rotate all 100 100 90
+ list [lmap c [.c coords all] {format %.2f $c}] \
+ [lmap o {} {.c itemcget all $o}] \
+ [.c bbox all]
+} -cleanup {
+ destroy .c
+} -result {{50.00 150.00 50.00 125.00 75.00 150.00 75.00 125.00} {} {48 123 77 152}}
+test canvas-22.5 {canvas rotate: oval item rotation behaviour} -setup {
+ pack [canvas .c]
+} -body {
+ .c create oval 50 50 65 85
+ .c rotate all 100 100 90
+ list [lmap c [.c coords all] {format %.2f $c}] \
+ [lmap o {} {.c itemcget all $o}] \
+ [.c bbox all]
+} -cleanup {
+ destroy .c
+} -result {{60.00 125.00 75.00 160.00} {} {59 124 76 161}}
+test canvas-22.6 {canvas rotate: polygon item rotation behaviour} -setup {
+ pack [canvas .c]
+} -body {
+ .c create polygon 50 50 75 50 50 75 75 75
+ .c rotate all 100 100 90
+ list [lmap c [.c coords all] {format %.2f $c}] \
+ [lmap o {} {.c itemcget all $o}] \
+ [.c bbox all]
+} -cleanup {
+ destroy .c
+} -result {{50.00 150.00 50.00 125.00 75.00 150.00 75.00 125.00} {} {48 123 77 152}}
+test canvas-22.7 {canvas rotate: rectangle item rotation behaviour} -setup {
+ pack [canvas .c]
+} -body {
+ .c create rectangle 50 50 75 75
+ .c rotate all 100 100 90
+ list [lmap c [.c coords all] {format %.2f $c}] \
+ [lmap o {} {.c itemcget all $o}] \
+ [.c bbox all]
+} -cleanup {
+ destroy .c
+} -result {{50.00 125.00 75.00 150.00} {} {49 124 76 151}}
+test canvas-22.8 {canvas rotate: text item rotation behaviour} -setup {
+ pack [canvas .c]
+} -body {
+ .c create text 50 50 -text foo -angle 45
+ .c rotate all 100 100 90
+ list [lmap c [.c coords all] {format %.2f $c}] \
+ [lmap o {-text -angle} {.c itemcget all $o}]
+ # [.c bbox all]
+ # No testing of text bounding box; fonts too variable!
+} -cleanup {
+ destroy .c
+} -result {{50.00 150.00} {foo 45.0}}
+test canvas-22.9 {canvas rotate: window item rotation behaviour} -setup {
+ pack [canvas .c]
+} -body {
+ .c create window 50 50 -window [frame .c.f -width 25 -height 25] \
+ -anchor se
+ .c rotate all 100 100 90
+ list [lmap c [.c coords all] {format %.2f $c}] \
+ [lmap o {} {.c itemcget all $o}] \
+ [.c bbox all]
+} -cleanup {
+ destroy .c
+} -result {{50.00 150.00} {} {25 125 50 150}}
+
# cleanup
imageCleanup
cleanupTests
diff --git a/tests/choosedir.test b/tests/choosedir.test
index f67a721..c6cc632 100644
--- a/tests/choosedir.test
+++ b/tests/choosedir.test
@@ -26,7 +26,7 @@ proc ToEnterDirsByKey {parent dirs} {
proc PressButton {btn} {
event generate $btn <Enter>
- event generate $btn <1> -x 5 -y 5
+ event generate $btn <Button-1> -x 5 -y 5
event generate $btn <ButtonRelease-1> -x 5 -y 5
}
@@ -68,7 +68,7 @@ proc SendButtonPress {parent btn type} {
event generate $w <Enter>
focus $w
event generate $button <Enter>
- event generate $w <KeyPress> -keysym Return
+ event generate $w <Key> -keysym Return
}
}
diff --git a/tests/clrpick.test b/tests/clrpick.test
index c15308b..0900962 100644
--- a/tests/clrpick.test
+++ b/tests/clrpick.test
@@ -97,7 +97,7 @@ proc ToChooseColorByKey {parent r g b} {
proc PressButton {btn} {
event generate $btn <Enter>
- event generate $btn <1> -x 5 -y 5
+ event generate $btn <Button-1> -x 5 -y 5
event generate $btn <ButtonRelease-1> -x 5 -y 5
}
@@ -137,7 +137,7 @@ proc SendButtonPress {parent btn type} {
event generate $w <Enter>
focus $w
event generate $button <Enter>
- event generate $w <KeyPress> -keysym Return
+ event generate $w <Key> -keysym Return
}
}
diff --git a/tests/cmap.tcl b/tests/cmap.tcl
index cca4c24..ea19131 100644
--- a/tests/cmap.tcl
+++ b/tests/cmap.tcl
@@ -19,7 +19,7 @@ proc colors {w redInc greenInc blueInc} {
for {set x 0} {$x < 8} {incr x} {
frame $w.f$x,$y -width 40 -height 40 -bd 2 -relief raised \
-bg [format #%02x%02x%02x $red $green $blue]
- place $w.f$x,$y -x [expr 40*$x] -y [expr 40*$y]
+ place $w.f$x,$y -x [expr {40*$x}] -y [expr {40*$y}]
incr red $redInc
incr green $greenInc
incr blue $blueInc
diff --git a/tests/constraints.tcl b/tests/constraints.tcl
index a87499d..c77fb00 100644
--- a/tests/constraints.tcl
+++ b/tests/constraints.tcl
@@ -190,7 +190,7 @@ testConstraint nonUnixUserInteraction [expr {
[testConstraint userInteraction] ||
([testConstraint unix] && [testConstraint notAqua])
}]
-testConstraint haveDISPLAY [info exists env(DISPLAY)]
+testConstraint haveDISPLAY [expr {[info exists env(DISPLAY)] && [testConstraint x11]}]
testConstraint altDisplay [info exists env(TK_ALT_DISPLAY)]
testConstraint noExceed [expr {
![testConstraint unix] || [catch {font actual "\{xyz"}]
diff --git a/tests/dialog.test b/tests/dialog.test
index 78b6620..2d88103 100644
--- a/tests/dialog.test
+++ b/tests/dialog.test
@@ -25,7 +25,7 @@ test dialog-2.1 {tk_dialog operation} -setup {
update
}
event generate $btn <Enter>
- event generate $btn <1> -x 5 -y 5
+ event generate $btn <Button-1> -x 5 -y 5
event generate $btn <ButtonRelease-1> -x 5 -y 5
}
} -body {
@@ -41,7 +41,7 @@ test dialog-2.2 {tk_dialog operation} -setup {
proc HitReturn {w} {
event generate $w <Enter>
focus -force $w
- event generate $w <KeyPress> -keysym Return
+ event generate $w <Key> -keysym Return
}
} -body {
set x [after 5000 [list set tk::Priv(button) "no response"]]
diff --git a/tests/entry.test b/tests/entry.test
index 7065343..b92c894 100644
--- a/tests/entry.test
+++ b/tests/entry.test
@@ -1435,7 +1435,7 @@ test entry-3.71 {EntryWidgetCmd procedure, "xview" widget command} -setup {
.e xview scroll 24
} -cleanup {
destroy .e
-} -returnCodes error -result {wrong # args: should be ".e xview scroll number units|pages"}
+} -returnCodes error -result {wrong # args: should be ".e xview scroll number pages|units"}
test entry-3.72 {EntryWidgetCmd procedure, "xview" widget command} -setup {
entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
pack .e
@@ -1512,7 +1512,7 @@ test entry-3.77 {EntryWidgetCmd procedure, "xview" widget command} -setup {
.e xview scroll 23 foobars
} -cleanup {
destroy .e
-} -returnCodes error -result {bad argument "foobars": must be units or pages}
+} -returnCodes error -result {bad argument "foobars": must be pages or units}
test entry-3.78 {EntryWidgetCmd procedure, "xview" widget command} -setup {
entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
pack .e
@@ -1688,11 +1688,13 @@ test entry-5.7 {ConfigureEntry procedure} -setup {
} -body {
.e configure -font {Courier -12} -width 4 -xscrollcommand scroll
.e insert end "01234567890"
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
.e configure -width 5
format {%.6f %.6f} {*}$scrollInfo
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {0.000000 0.363636}
@@ -1933,10 +1935,12 @@ test entry-7.1 {InsertChars procedure} -setup {
.e configure -textvariable contents -xscrollcommand scroll
.e insert 0 abcde
.e insert 2 XXX
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {abXXXcde abXXXcde {0.000000 1.000000}}
test entry-7.2 {InsertChars procedure} -setup {
@@ -1948,10 +1952,12 @@ test entry-7.2 {InsertChars procedure} -setup {
.e configure -textvariable contents -xscrollcommand scroll
.e insert 0 abcde
.e insert 500 XXX
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {abcdeXXX abcdeXXX {0.000000 1.000000}}
test entry-7.3 {InsertChars procedure} -setup {
entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
@@ -2080,10 +2086,12 @@ test entry-8.1 {DeleteChars procedure} -setup {
.e configure -textvariable contents -xscrollcommand scroll
.e insert 0 abcde
.e delete 2 4
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {abe abe {0.000000 1.000000}}
test entry-8.2 {DeleteChars procedure} -setup {
unset -nocomplain contents
@@ -2094,10 +2102,12 @@ test entry-8.2 {DeleteChars procedure} -setup {
.e configure -textvariable contents -xscrollcommand scroll
.e insert 0 abcde
.e delete -2 2
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {cde cde {0.000000 1.000000}}
test entry-8.3 {DeleteChars procedure} -setup {
unset -nocomplain contents
@@ -2108,10 +2118,12 @@ test entry-8.3 {DeleteChars procedure} -setup {
.e configure -textvariable contents -xscrollcommand scroll
.e insert 0 abcde
.e delete 3 1000
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {abc abc {0.000000 1.000000}}
test entry-8.4 {DeleteChars procedure} -setup {
entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
@@ -2954,30 +2966,36 @@ test entry-17.1 {EntryUpdateScrollbar procedure} -body {
pack .e
.e delete 0 end
.e insert 0 123
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
format {%.6f %.6f} {*}$scrollInfo
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {0.000000 1.000000}
test entry-17.2 {EntryUpdateScrollbar procedure} -body {
entry .e -width 10 -xscrollcommand scroll -font {Courier -12}
pack .e
.e insert 0 0123456789abcdef
.e xview 3
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
format {%.6f %.6f} {*}$scrollInfo
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {0.187500 0.812500}
test entry-17.3 {EntryUpdateScrollbar procedure} -body {
entry .e -width 10 -xscrollcommand scroll -font {Courier -12}
pack .e
.e insert 0 abcdefghijklmnopqrs
.e xview 6
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
format {%.6f %.6f} {*}$scrollInfo
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {0.315789 0.842105}
test entry-17.4 {EntryUpdateScrollbar procedure} -setup {
proc bgerror msg {
@@ -2987,7 +3005,7 @@ test entry-17.4 {EntryUpdateScrollbar procedure} -setup {
} -body {
entry .e -width 5 -xscrollcommand thisisnotacommand
pack .e
- update
+ vwait x
list $x $errorInfo
} -cleanup {
destroy .e
@@ -3529,6 +3547,34 @@ test entry-24.1 {textvariable lives in a non-existing namespace} -setup {
destroy .e
} -result {can't trace "thisnsdoesntexist::myvar": parent namespace doesn't exist}
+test entry-25.1 {Bug [5d991b822e]} {
+ # Want this not to segfault, or write to variable with empty name
+ set var INIT
+ entry .b -textvariable var
+ trace add variable var unset {apply {args {
+ .b configure -textvariable {}
+ }}}
+ pack .b
+ bind .b <Configure> {unset var}
+ update
+ destroy .b
+ info exists {}
+} 0
+test entry-25.2 {Bug [5d991b822e]} {
+ # Want this not to leak traces
+ set var INIT
+ entry .b -textvariable var
+ trace add variable var unset {apply {args {
+ .b configure -textvariable new
+ }}}
+ pack .b
+ bind .b <Configure> {unset -nocomplain var}
+ update
+ destroy .b
+ unset new
+} {}
+
+
# Gathered comments about lacks
# XXX Still need to write tests for EntryBlinkProc, EntryFocusProc,
# and EntryTextVarProc.
diff --git a/tests/event.test b/tests/event.test
index f874065..2e53196 100644
--- a/tests/event.test
+++ b/tests/event.test
@@ -111,7 +111,7 @@ proc _keypress_lookup {char} {
}
}
-# Lookup and generate a pair of KeyPress and KeyRelease events
+# Lookup and generate a pair of Key and KeyRelease events
proc _keypress {win key} {
set keysym [_keypress_lookup $key]
@@ -124,7 +124,7 @@ proc _keypress {win key} {
if {[focus] != $win} {
focus -force $win
}
- event generate $win <KeyPress-$keysym>
+ event generate $win <Key-$keysym>
_pause 50
if {[focus] != $win} {
focus -force $win
@@ -194,10 +194,10 @@ test event-1.1 {Tk_HandleEvent procedure, filter events for dead windows} -setup
update
bind .b <Destroy> {
lappend x destroy
- event generate .b <1>
+ event generate .b <Button-1>
event generate .b <ButtonRelease-1>
}
- bind .b <1> {
+ bind .b <Button-1> {
lappend x button
}
@@ -245,6 +245,8 @@ test event-2.2(keypress) {type into entry widget and then delete some text} -set
set e [entry $t.e]
pack $e
tkwait visibility $e
+ # Avoid a hang when macOS puts the mouse pointer on the green button
+ wm geometry .t +200+100
_keypress_string $e MELLO
_keypress $e BackSpace
_keypress $e BackSpace
@@ -267,7 +269,7 @@ test event-2.3(keypress) {type into entry widget, triple click, hit Delete key,
event generate $e <Enter>
for {set i 0} {$i < 3} {incr i} {
_pause 100
- event generate $e <ButtonPress-1>
+ event generate $e <Button-1>
_pause 100
event generate $e <ButtonRelease-1>
}
@@ -321,7 +323,7 @@ test event-2.6(keypress) {type into text widget, triple click,
event generate $e <Enter>
for {set i 0} {$i < 3} {incr i} {
_pause 100
- event generate $e <ButtonPress-1>
+ event generate $e <Button-1>
_pause 100
event generate $e <ButtonRelease-1>
}
@@ -353,7 +355,7 @@ test event-3.1(click-drag) {click and drag in a text widget, this tests
# Click down to set the insert cursor position
event generate $e <Enter>
- event generate $e <ButtonPress-1> -x $anchor_x -y $anchor_y
+ event generate $e <Button-1> -x $anchor_x -y $anchor_y
# Save the position of the insert cursor
lappend result [$e index insert]
@@ -379,7 +381,7 @@ test event-3.1(click-drag) {click and drag in a text widget, this tests
# Now click and click and drag to the left, over "Tcl/Tk selection"
- event generate $e <ButtonPress-1> -x $current_x -y $current_y
+ event generate $e <Button-1> -x $current_x -y $current_y
while {[$e compare $current >= [list $anchor - 4 char]]} {
foreach {current_x current_y} [_text_ind_to_x_y $e $current] break
@@ -420,7 +422,7 @@ test event-3.1(click-drag) {click and drag in a text widget, this tests
# Click down to set the insert cursor position
event generate $e <Enter>
- event generate $e <ButtonPress-1> -x $anchor_x -y $anchor_y
+ event generate $e <Button-1> -x $anchor_x -y $anchor_y
# Save the position of the insert cursor
lappend result [$e index insert]
@@ -446,7 +448,7 @@ test event-3.1(click-drag) {click and drag in a text widget, this tests
# Now click and click and drag to the left, over "Tcl/Tk selection"
- event generate $e <ButtonPress-1> -x $current_x -y $current_y
+ event generate $e <Button-1> -x $current_x -y $current_y
while {$current >= ($anchor - 4)} {
foreach {current_x current_y} [_text_ind_to_x_y $e $current] break
@@ -485,11 +487,11 @@ test event-4.1(double-click-drag) {click down, click up, click down again,
# Click down, release, then click down again
event generate $e <Enter>
- event generate $e <ButtonPress-1> -x $anchor_x -y $anchor_y
+ event generate $e <Button-1> -x $anchor_x -y $anchor_y
_pause 50
event generate $e <ButtonRelease-1> -x $anchor_x -y $anchor_y
_pause 50
- event generate $e <ButtonPress-1> -x $anchor_x -y $anchor_y
+ event generate $e <Button-1> -x $anchor_x -y $anchor_y
_pause 50
# Save the highlighted text
@@ -556,11 +558,11 @@ test event-4.2(double-click-drag) {click down, click up, click down again,
# Click down, release, then click down again
event generate $e <Enter>
- event generate $e <ButtonPress-1> -x $anchor_x -y $anchor_y
+ event generate $e <Button-1> -x $anchor_x -y $anchor_y
_pause 50
event generate $e <ButtonRelease-1> -x $anchor_x -y $anchor_y
_pause 50
- event generate $e <ButtonPress-1> -x $anchor_x -y $anchor_y
+ event generate $e <Button-1> -x $anchor_x -y $anchor_y
_pause 50
set result [list]
@@ -628,17 +630,17 @@ test event-5.1(triple-click-drag) {Triple click and drag across lines in a
event generate $e <Enter>
- event generate $e <ButtonPress-1> -x $anchor_x -y $anchor_y
+ event generate $e <Button-1> -x $anchor_x -y $anchor_y
_pause 50
event generate $e <ButtonRelease-1> -x $anchor_x -y $anchor_y
_pause 50
- event generate $e <ButtonPress-1> -x $anchor_x -y $anchor_y
+ event generate $e <Button-1> -x $anchor_x -y $anchor_y
_pause 50
event generate $e <ButtonRelease-1> -x $anchor_x -y $anchor_y
_pause 50
- event generate $e <ButtonPress-1> -x $anchor_x -y $anchor_y
+ event generate $e <Button-1> -x $anchor_x -y $anchor_y
_pause 50
set result [list]
@@ -678,7 +680,7 @@ test event-6.1(button-state) {button press in a window that is then
} -body {
set t [toplevel .t]
- event generate $t <ButtonPress-1>
+ event generate $t <Button-1>
destroy $t
set t [toplevel .t]
set motion nomotion
@@ -717,11 +719,11 @@ test event-7.1(double-click) {A double click on a lone character
# Double click near left hand egde of the letter A
event generate $e <Enter>
- event generate $e <ButtonPress-1> -x $left_x -y $left_y
+ event generate $e <Button-1> -x $left_x -y $left_y
_pause 50
event generate $e <ButtonRelease-1> -x $left_x -y $left_y
_pause 50
- event generate $e <ButtonPress-1> -x $left_x -y $left_y
+ event generate $e <Button-1> -x $left_x -y $left_y
_pause 50
event generate $e <ButtonRelease-1> -x $left_x -y $left_y
_pause 50
@@ -732,18 +734,18 @@ test event-7.1(double-click) {A double click on a lone character
# Clear selection by clicking at 0,0
- event generate $e <ButtonPress-1> -x 0 -y 0
+ event generate $e <Button-1> -x 0 -y 0
_pause 50
event generate $e <ButtonRelease-1> -x 0 -y 0
_pause 50
# Double click near right hand edge of the letter A
- event generate $e <ButtonPress-1> -x $right_x -y $right_y
+ event generate $e <Button-1> -x $right_x -y $right_y
_pause 50
event generate $e <ButtonRelease-1> -x $right_x -y $right_y
_pause 50
- event generate $e <ButtonPress-1> -x $right_x -y $right_y
+ event generate $e <Button-1> -x $right_x -y $right_y
_pause 50
event generate $e <ButtonRelease-1> -x $right_x -y $right_y
_pause 50
@@ -783,11 +785,11 @@ test event-7.2(double-click) {A double click on a lone character
# Double click near left hand egde of the letter A
event generate $e <Enter>
- event generate $e <ButtonPress-1> -x $left_x -y $left_y
+ event generate $e <Button-1> -x $left_x -y $left_y
_pause 50
event generate $e <ButtonRelease-1> -x $left_x -y $left_y
_pause 50
- event generate $e <ButtonPress-1> -x $left_x -y $left_y
+ event generate $e <Button-1> -x $left_x -y $left_y
_pause 50
event generate $e <ButtonRelease-1> -x $left_x -y $left_y
_pause 50
@@ -798,18 +800,18 @@ test event-7.2(double-click) {A double click on a lone character
# Clear selection by clicking at 0,0
- event generate $e <ButtonPress-1> -x 0 -y 0
+ event generate $e <Button-1> -x 0 -y 0
_pause 50
event generate $e <ButtonRelease-1> -x 0 -y 0
_pause 50
# Double click near right hand edge of the letter A
- event generate $e <ButtonPress-1> -x $right_x -y $right_y
+ event generate $e <Button-1> -x $right_x -y $right_y
_pause 50
event generate $e <ButtonRelease-1> -x $right_x -y $right_y
_pause 50
- event generate $e <ButtonPress-1> -x $right_x -y $right_y
+ event generate $e <Button-1> -x $right_x -y $right_y
_pause 50
event generate $e <ButtonRelease-1> -x $right_x -y $right_y
_pause 50
@@ -832,7 +834,7 @@ test event-8 {event generate with keysyms corresponding to
set e [entry $t.e]
pack $e
tkwait visibility $e
- bind $e <KeyPress> {lappend res keycode: %k keysym: %K}
+ bind $e <Key> {lappend res keycode: %k keysym: %K}
focus -force $e
update
event generate $e <diaeresis>
@@ -858,6 +860,7 @@ test event-8 {event generate with keysyms corresponding to
} -result {OK}
# cleanup
+update
unset -nocomplain keypress_lookup
rename _init_keypress_lookup {}
rename _keypress_lookup {}
diff --git a/tests/filebox.test b/tests/filebox.test
index e373d73..ee00160 100644
--- a/tests/filebox.test
+++ b/tests/filebox.test
@@ -48,7 +48,7 @@ proc ToEnterFileByKey {parent fileName fileDir} {
proc PressButton {btn} {
event generate $btn <Enter>
- event generate $btn <1> -x 5 -y 5
+ event generate $btn <Button-1> -x 5 -y 5
event generate $btn <ButtonRelease-1> -x 5 -y 5
}
@@ -93,7 +93,7 @@ proc SendButtonPress {parent btn type} {
event generate $w <Enter>
focus $w
event generate $button <Enter>
- event generate $w <KeyPress> -keysym Return
+ event generate $w <Key> -keysym Return
}
}
diff --git a/tests/focus.test b/tests/focus.test
index 73bb9fd..7da289d 100644
--- a/tests/focus.test
+++ b/tests/focus.test
@@ -64,7 +64,7 @@ bind all <FocusIn> {
bind all <FocusOut> {
append focusInfo "out %W %d\n"
}
-bind all <KeyPress> {
+bind all <Key> {
append focusInfo "press %W %K"
}
focusSetup
@@ -316,7 +316,7 @@ test focus-2.6 {TkFocusFilterEvent procedure, FocusIn events} -constraints {
event gen [testwrapper .t] <FocusIn> -detail NotifyAncestor
set focusInfo {}
set x [focus]
- event gen . <KeyPress-x>
+ event gen . <x>
list $x $focusInfo
} -result {.t.b1 {press .t.b1 x}}
test focus-2.7 {TkFocusFilterEvent procedure, FocusOut events} -constraints {
@@ -617,7 +617,7 @@ test focus-5.1 {ChangeXFocus procedure, don't take focus unless have it} -constr
destroy .t
bind all <FocusIn> {}
bind all <FocusOut> {}
-bind all <KeyPress> {}
+bind all <Key> {}
fixfocus
@@ -730,6 +730,26 @@ test focus-6.2 {miscellaneous - embedded application in different process} -cons
bind all <FocusOut> {}
} -result {{.t.f2.e1 {} {focus out .t.f2.e1 NotifyNonlinear} {focus out .t.f2 NotifyNonlinearVirtual} {focus in .t.f1 NotifyNonlinear} | {focus out .t.f1 NotifyNonlinear} {focus in .t.f2 NotifyNonlinearVirtual} {focus in .t.f2.e1 NotifyNonlinear}} {{focus in . NotifyVirtual} {focus in .e1 NotifyAncestor} | {focus out .e1 NotifyAncestor} {focus out . NotifyVirtual}}}
+test focus-7.1 {TkSetFocusWin procedure, unmapped windows} -setup {
+ # TkSetFocusWin handles the case of not yet mapped windows
+ # by not setting the focus on them right at the time it is
+ # requested, but by scheduling an event handler that will
+ # set the focus later once it gets mapped. The purpose of
+ # this test is to check that event scheduling and deletion
+ # work as expected (bug [08e2f8e6f0]).
+ toplevel .top
+ spinbox .top.s1
+ spinbox .top.s2
+ spinbox .top.s3
+ grid .top.s1 .top.s2 .top.s3
+} -body {
+ focus -force .top.s2
+ focus -force .top.s3
+ update
+ focus
+} -cleanup {
+ destroy .top
+} -result {.top.s3}
deleteWindows
diff --git a/tests/font.test b/tests/font.test
index 09c2dc6..9f279dd 100644
--- a/tests/font.test
+++ b/tests/font.test
@@ -11,6 +11,9 @@ namespace import ::tcltest::*
eval tcltest::configure $argv
tcltest::loadTestedCommands
+# Some tests require support for 4-byte UTF-8 sequences
+testConstraint fullutf [expr {[format %c 0x010000] != "\uFFFD"}]
+testConstraint utfcompat [expr {([string length "\U10000"] == 2) && [package vsatisfies [package provide Tcl] 8]}]
set defaultfontlist [font names]
@@ -151,12 +154,15 @@ test font-4.12 {font command: actual} -body {
test font-4.13 {font command: actual} -body {
font actual {-family times} -- \udc00
} -match glob -result {*}
-test font-4.14 {font command: actual} -constraints win -body {
- font actual {-family times} -family -- \ud800\udc00
+test font-4.14 {font command: actual} -constraints {utfcompat win} -body {
+ font actual {-family times} -family -- \uD800\uDC00
} -result {times}
test font-4.15 {font command: actual} -body {
font actual {-family times} -- \udc00\ud800
} -returnCodes 1 -match glob -result {expected a single character but got "*"}
+test font-4.16 {font command: actual} -constraints {fullutf win} -body {
+ font actual {-family times} -family -- \U10000
+} -result {times}
test font-5.1 {font command: configure} -body {
@@ -2250,7 +2256,7 @@ test font-38.10 {ParseFontNameObj procedure: arguments} -body {
font actual {times xyz xyz}
} -returnCodes error -result {expected integer but got "xyz"}
test font-38.11 {ParseFontNameObj procedure: stylelist loop} -constraints {
- unixOrPc
+ unixOrWin
} -body {
lrange [font actual {times 12 bold italic overstrike underline}] 4 end
} -result {-weight bold -slant italic -underline 1 -overstrike 1}
diff --git a/tests/frame.test b/tests/frame.test
index e1eb5e4..bdeb2e9 100644
--- a/tests/frame.test
+++ b/tests/frame.test
@@ -1,5 +1,5 @@
-# This file is a Tcl script to test out the "frame" and "toplevel"
-# commands of Tk. It is organized in the standard fashion for Tcl
+# This file is a Tcl script to test out the "frame", "labelframe" and
+# "toplevel" commands of Tk. It is organized in the standard fashion for Tcl
# tests.
#
# Copyright (c) 1994 The Regents of the University of California.
@@ -9,12 +9,14 @@
package require tcltest 2.2
namespace import ::tcltest::*
-eval tcltest::configure $argv
+tcltest::configure {*}$argv
tcltest::loadTestedCommands
+tcltest::testConstraint x11 [expr {[tk windowingsystem] eq "x11"}]
+
# eatColors --
-# Creates a toplevel window and allocates enough colors in it to
-# use up all the slots in the colormap.
+# Creates a toplevel window and allocates enough colors in it to use up all
+# the slots in an 8-bit colormap.
#
# Arguments:
# w - Name of toplevel window to create.
@@ -27,10 +29,10 @@ proc eatColors {w} {
pack $w.c
for {set y 0} {$y < 8} {incr y} {
for {set x 0} {$x < 40} {incr x} {
- set color [format #%02x%02x%02x [expr $x*6] [expr $y*30] 0]
- $w.c create rectangle [expr 10*$x] [expr 20*$y] \
- [expr 10*$x + 10] [expr 20*$y + 20] -outline {} \
- -fill $color
+ set color [format #%02x%02x%02x [expr {$x*6}] [expr {$y*30}] 0]
+ $w.c create rectangle [expr {10*$x}] [expr {20*$y}] \
+ [expr {10*$x + 10}] [expr {20*$y + 20}] -outline {} \
+ -fill $color
}
}
update
@@ -38,8 +40,8 @@ proc eatColors {w} {
# colorsFree --
#
-# Returns 1 if there appear to be free colormap entries in a window,
-# 0 otherwise.
+# Returns 1 if there appear to be free colormap entries in a window, 0
+# otherwise.
#
# Arguments:
# w - Name of window in which to check.
@@ -47,14 +49,36 @@ proc eatColors {w} {
# to see if there are colormap entries free.
proc colorsFree {w {red 31} {green 245} {blue 192}} {
- set vals [winfo rgb $w [format #%02x%02x%02x $red $green $blue]]
- expr ([lindex $vals 0]/256 == $red) && ([lindex $vals 1]/256 == $green) \
- && ([lindex $vals 2]/256 == $blue)
+ lassign [winfo rgb $w [format "#%02x%02x%02x" $red $green $blue]] r g b
+ expr {($r/256 == $red) && ($g/256 == $green) && ($b/256 == $blue)}
}
+# uniq --
+#
+# Returns the unique items of a list in the order they first appear.
+#
+# Arguments:
+# list - The list to uniq-ify.
+proc uniq {list} {
+ set d {}
+ foreach item $list {
+ dict set d $item {}
+ }
+ return [dict keys $d]
+}
+# optnames --
+#
+# Returns the option names out of a list of option details.
+#
+# Arguments:
+# options - The option detail list.
+proc optnames {options} {
+ lsort [lmap desc $options {lindex $desc 0}]
+}
+
test frame-1.1 {frame configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
frame .f -class NewFrame
.f configure -class
@@ -66,12 +90,11 @@ test frame-1.2 {frame configuration options} -setup {
} -body {
frame .f -class NewFrame
.f configure -class Different
-} -cleanup {
+} -returnCodes error -cleanup {
deleteWindows
-} -returnCodes error -result {can't modify -class option after widget is created}
-
+} -result {can't modify -class option after widget is created}
test frame-1.3 {frame configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
frame .f -colormap new
.f configure -colormap
@@ -83,12 +106,11 @@ test frame-1.4 {frame configuration options} -setup {
} -body {
frame .f -colormap new
.f configure -colormap .
-} -cleanup {
+} -returnCodes error -cleanup {
deleteWindows
-} -returnCodes error -result {can't modify -colormap option after widget is created}
-
+} -result {can't modify -colormap option after widget is created}
test frame-1.5 {frame configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
frame .f -visual default
.f configure -visual
@@ -100,19 +122,18 @@ test frame-1.6 {frame configuration options} -setup {
} -body {
frame .f -visual default
.f configure -visual best
-} -cleanup {
+} -returnCodes error -cleanup {
deleteWindows
-} -returnCodes error -result {can't modify -visual option after widget is created}
-
+} -result {can't modify -visual option after widget is created}
test frame-1.7 {frame configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
frame .f -screen bogus
} -cleanup {
deleteWindows
} -returnCodes error -result {unknown option "-screen"}
test frame-1.8 {frame configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
frame .f -container true
} -cleanup {
@@ -127,22 +148,22 @@ test frame-1.9 {frame configuration options} -setup {
deleteWindows
} -result {-container container Container 0 1}
test frame-1.10 {frame configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
frame .f -container bogus
} -cleanup {
deleteWindows
} -returnCodes error -result {expected boolean value but got "bogus"}
test frame-1.11 {frame configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
frame .f
.f configure -container 1
-} -cleanup {
+} -returnCodes error -cleanup {
deleteWindows
-} -returnCodes error -result {can't modify -container option after widget is created}
+} -result {can't modify -container option after widget is created}
test frame-1.12 {frame configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
# Make sure all options can be set to the default value
frame .f
@@ -152,11 +173,11 @@ test frame-1.12 {frame configuration options} -setup {
lappend opts [lindex $opt 0] [lindex $opt 4]
}
}
- eval frame .g $opts
- destroy .f .g
+ frame .g {*}$opts
} -cleanup {
+ destroy .f .g
deleteWindows
-} -result {}
+} -result .g
destroy .f
frame .f
@@ -165,7 +186,7 @@ test frame-1.13 {frame configuration options} -body {
lindex [.f configure -background] 4
} -cleanup {
.f configure -background [lindex [.f configure -background] 3]
-} -result {#ff0000}
+} -result "#ff0000"
test frame-1.14 {frame configuration options} -body {
.f configure -background non-existent
} -returnCodes error -result {unknown color name "non-existent"}
@@ -183,7 +204,7 @@ test frame-1.17 {frame configuration options} -body {
lindex [.f configure -bg] 4
} -cleanup {
.f configure -bg [lindex [.f configure -bg] 3]
-} -result {#00ff00}
+} -result "#00ff00"
test frame-1.18 {frame configuration options} -body {
.f configure -bg non-existent
} -returnCodes error -result {unknown color name "non-existent"}
@@ -219,7 +240,7 @@ test frame-1.25 {frame configuration options} -body {
lindex [.f configure -highlightbackground] 4
} -cleanup {
.f configure -highlightbackground [lindex [.f configure -highlightbackground] 3]
-} -result {#112233}
+} -result "#112233"
test frame-1.26 {frame configuration options} -body {
.f configure -highlightbackground ugly
} -returnCodes error -result {unknown color name "ugly"}
@@ -228,7 +249,7 @@ test frame-1.27 {frame configuration options} -body {
lindex [.f configure -highlightcolor] 4
} -cleanup {
.f configure -highlightcolor [lindex [.f configure -highlightcolor] 3]
-} -result {#123456}
+} -result "#123456"
test frame-1.28 {frame configuration options} -body {
.f configure -highlightcolor non-existent
} -returnCodes error -result {unknown color name "non-existent"}
@@ -265,9 +286,9 @@ test frame-1.35 {frame configuration options} -body {
} -cleanup {
.f configure -relief [lindex [.f configure -relief] 3]
} -result {ridge}
-test frame-1.36 {frame configuration options} -body {
+test frame-1.36 {frame configuration options} -returnCodes error -body {
.f configure -relief badValue
-} -returnCodes error -result {bad relief "badValue": must be flat, groove, raised, ridge, solid, or sunken}
+} -result {bad relief "badValue": must be flat, groove, raised, ridge, solid, or sunken}
test frame-1.37 {frame configuration options} -body {
.f configure -takefocus {any string}
lindex [.f configure -takefocus] 4
@@ -285,9 +306,8 @@ test frame-1.39 {frame configuration options} -body {
} -returnCodes error -result {bad screen distance "badValue"}
destroy .f
-
test frame-2.1 {toplevel configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t -width 200 -height 100 -class NewClass
wm geometry .t +0+0
@@ -301,12 +321,11 @@ test frame-2.2 {toplevel configuration options} -setup {
toplevel .t -width 200 -height 100 -class NewClass
wm geometry .t +0+0
.t configure -class Another
-} -cleanup {
+} -returnCodes error -cleanup {
deleteWindows
-} -returnCodes error -result {can't modify -class option after widget is created}
-
+} -result {can't modify -class option after widget is created}
test frame-2.3 {toplevel configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t -width 200 -height 100 -colormap new
wm geometry .t +0+0
@@ -320,23 +339,21 @@ test frame-2.4 {toplevel configuration options} -setup {
toplevel .t -width 200 -height 100 -colormap new
wm geometry .t +0+0
.t configure -colormap .
-} -cleanup {
+} -returnCodes error -cleanup {
deleteWindows
-} -returnCodes error -result {can't modify -colormap option after widget is created}
-
+} -result {can't modify -colormap option after widget is created}
test frame-2.5 {toplevel configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t -width 200 -height 100
wm geometry .t +0+0
.t configure -container 1
-} -cleanup {
+} -returnCodes error -cleanup {
deleteWindows
-} -returnCodes error -result {can't modify -container option after widget is created}
+} -result {can't modify -container option after widget is created}
test frame-2.6 {toplevel configuration options} -setup {
deleteWindows
} -body {
- catch {destroy .t}
toplevel .t -width 200 -height 100
wm geometry .t +0+0
catch {.t configure -container 1}
@@ -344,34 +361,25 @@ test frame-2.6 {toplevel configuration options} -setup {
} -cleanup {
deleteWindows
} -result {-container container Container 0 0}
-
test frame-2.7 {toplevel configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t -width 200 -height 100 -colormap bogus
} -cleanup {
deleteWindows
} -returnCodes error -result {bad window path name "bogus"}
-
-
-test frame-2.8 {toplevel configuration options} -constraints {
- win
-} -setup {
- deleteWindows
+test frame-2.8 {toplevel configuration options} -constraints win -setup {
+ deleteWindows
} -body {
- catch {destroy .t}
toplevel .t -width 200 -height 100
wm geometry .t +0+0
.t configure -use 0x44022
} -cleanup {
deleteWindows
} -returnCodes error -result {window "0x44022" doesn't exist}
-test frame-2.9 {toplevel configuration options} -constraints {
- win
-} -setup {
+test frame-2.9 {toplevel configuration options} -constraints win -setup {
deleteWindows
} -body {
- catch {destroy .t}
toplevel .t -width 200 -height 100
wm geometry .t +0+0
catch {.t configure -use 0x44022}
@@ -379,25 +387,18 @@ test frame-2.9 {toplevel configuration options} -constraints {
} -cleanup {
deleteWindows
} -result {-use use Use {} {}}
-
-test frame-2.10 {toplevel configuration options} -constraints {
- nonwin
-} -setup {
+test frame-2.10 {toplevel configuration options} -constraints nonwin -setup {
deleteWindows
} -body {
- catch {destroy .t}
toplevel .t -width 200 -height 100
wm geometry .t +0+0
.t configure -use 0x44022
} -cleanup {
deleteWindows
} -returnCodes error -result {can't modify -use option after widget is created}
-test frame-2.11 {toplevel configuration options} -constraints {
- nonwin
-} -setup {
- deleteWindows
+test frame-2.11 {toplevel configuration options} -constraints nonwin -setup {
+ deleteWindows
} -body {
- catch {destroy .t}
toplevel .t -width 200 -height 100
wm geometry .t +0+0
catch {.t configure -use 0x44022}
@@ -405,11 +406,9 @@ test frame-2.11 {toplevel configuration options} -constraints {
} -cleanup {
deleteWindows
} -result {-use use Use {} {}}
-
test frame-2.12 {toplevel configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
- catch {destroy .t}
toplevel .t -width 200 -height 100 -visual default
wm geometry .t +0+0
.t configure -visual
@@ -419,58 +418,59 @@ test frame-2.12 {toplevel configuration options} -setup {
test frame-2.13 {toplevel configuration options} -setup {
deleteWindows
} -body {
- catch {destroy .t}
toplevel .t -width 200 -height 100 -visual default
wm geometry .t +0+0
.t configure -visual best
-} -cleanup {
+} -returnCodes error -cleanup {
deleteWindows
-} -returnCodes error -result {can't modify -visual option after widget is created}
-
+} -result {can't modify -visual option after widget is created}
test frame-2.14 {toplevel configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t -width 200 -height 100 -visual who_knows?
-} -cleanup {
+} -returnCodes error -cleanup {
+ deleteWindows
+} -result {unknown or ambiguous visual name "who_knows?": class must be best, directcolor, grayscale, greyscale, pseudocolor, staticcolor, staticgray, staticgrey, truecolor, or default}
+set expectedScreen ""
+if {[tcltest::testConstraint haveDISPLAY]} {
+ set expectedScreen [list -screen screen Screen {} $env(DISPLAY)]
+}
+test frame-2.15 {toplevel configuration options} -constraints {x11 haveDISPLAY} -setup {
deleteWindows
-} -returnCodes error -result {unknown or ambiguous visual name "who_knows?": class must be best, directcolor, grayscale, greyscale, pseudocolor, staticcolor, staticgray, staticgrey, truecolor, or default}
-test frame-2.15 {toplevel configuration options} -constraints haveDISPLAY -setup {
- deleteWindows
} -body {
toplevel .t -width 200 -height 100 -screen $env(DISPLAY)
wm geometry .t +0+0
- string compare [.t configure -screen] "-screen screen Screen {} $env(DISPLAY)"
+ .t configure -screen
} -cleanup {
deleteWindows
-} -result {0}
-test frame-2.16 {toplevel configuration options} -constraints haveDISPLAY -setup {
+} -result $expectedScreen
+test frame-2.16 {toplevel configuration options} -constraints {x11 haveDISPLAY} -setup {
deleteWindows
} -body {
toplevel .t -width 200 -height 100 -screen $env(DISPLAY)
wm geometry .t +0+0
.t configure -screen another
-} -cleanup {
+} -returnCodes error -cleanup {
deleteWindows
-} -returnCodes error -result {can't modify -screen option after widget is created}
-
+} -result {can't modify -screen option after widget is created}
test frame-2.17 {toplevel configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t -width 200 -height 100 -screen bogus
} -cleanup {
deleteWindows
} -returnCodes error -result {couldn't connect to display "bogus"}
test frame-2.18 {toplevel configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t -container 1 -width 300 -height 120
wm geometry .t +0+0
toplevel .x -container 1 -use [winfo id .t]
-} -cleanup {
+} -returnCodes error -cleanup {
deleteWindows
-} -returnCodes error -result {windows cannot have both the -use and the -container option set}
+} -result {windows cannot have both the -use and the -container option set}
test frame-2.19 {toplevel configuration options} -setup {
- deleteWindows
+ deleteWindows
set opts {}
} -body {
# Make sure all options can be set to the default value
@@ -480,12 +480,11 @@ test frame-2.19 {toplevel configuration options} -setup {
lappend opts [lindex $opt 0] [lindex $opt 4]
}
}
- eval toplevel .g $opts
- destroy .f .g
+ toplevel .g {*}$opts
} -cleanup {
+ destroy .f .g
deleteWindows
-} -result {}
-
+} -result .g
destroy .t
toplevel .t -width 300 -height 150
@@ -494,7 +493,7 @@ update
test frame-2.20 {toplevel configuration options} -body {
.t configure -background #ff0000
lindex [.t configure -background] 4
-} -result {#ff0000}
+} -result "#ff0000"
test frame-2.21 {toplevel configuration options} -body {
.t configure -background non-existent
} -returnCodes error -result {unknown color name "non-existent"}
@@ -508,7 +507,7 @@ test frame-2.23 {toplevel configuration options} -body {
test frame-2.24 {toplevel configuration options} -body {
.t configure -bg #00ff00
lindex [.t configure -bg] 4
-} -result {#00ff00}
+} -result "#00ff00"
test frame-2.25 {toplevel configuration options} -body {
.t configure -bg non-existent
} -returnCodes error -result {unknown color name "non-existent"}
@@ -536,7 +535,7 @@ test frame-2.31 {toplevel configuration options} -body {
test frame-2.32 {toplevel configuration options} -body {
.t configure -highlightcolor #123456
lindex [.t configure -highlightcolor] 4
-} -result {#123456}
+} -result "#123456"
test frame-2.33 {toplevel configuration options} -body {
.t configure -highlightcolor non-existent
} -returnCodes error -result {unknown color name "non-existent"}
@@ -565,9 +564,9 @@ test frame-2.40 {toplevel configuration options} -body {
.t configure -relief ridge
lindex [.t configure -relief] 4
} -result {ridge}
-test frame-2.41 {toplevel configuration options} -body {
+test frame-2.41 {toplevel configuration options} -returnCodes error -body {
.t configure -relief badValue
-} -returnCodes error -result {bad relief "badValue": must be flat, groove, raised, ridge, solid, or sunken}
+} -result {bad relief "badValue": must be flat, groove, raised, ridge, solid, or sunken}
test frame-2.42 {toplevel configuration options} -body {
.t configure -width 32
lindex [.t configure -width] 4
@@ -577,12 +576,11 @@ test frame-2.43 {toplevel configuration options} -body {
} -returnCodes error -result {bad screen distance "badValue"}
destroy .t
-
-test frame-3.1 {TkCreateFrame procedure} -body {
+test frame-3.1 {TkCreateFrame procedure} -returnCodes error -body {
frame
-} -returnCodes error -result {wrong # args: should be "frame pathName ?-option value ...?"}
+} -result {wrong # args: should be "frame pathName ?-option value ...?"}
test frame-3.2 {TkCreateFrame procedure} -setup {
- deleteWindows
+ deleteWindows
frame .f
} -body {
.f configure -class
@@ -590,7 +588,7 @@ test frame-3.2 {TkCreateFrame procedure} -setup {
deleteWindows
} -result {-class class Class Frame Frame}
test frame-3.3 {TkCreateFrame procedure} -setup {
- deleteWindows
+ deleteWindows
toplevel .t
wm geometry .t +0+0
} -body {
@@ -599,7 +597,7 @@ test frame-3.3 {TkCreateFrame procedure} -setup {
deleteWindows
} -result {-class class Class Toplevel Toplevel}
test frame-3.4 {TkCreateFrame procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t -width 350 -class NewClass -bg black -visual default -height 90
wm geometry .t +0+0
@@ -610,21 +608,10 @@ test frame-3.4 {TkCreateFrame procedure} -setup {
} -cleanup {
deleteWindows
} -result {350 black 90}
-
# Be sure that the -class, -colormap, and -visual options are processed
# before configuring the widget.
test frame-3.5 {TkCreateFrame procedure} -setup {
- deleteWindows
-} -body {
- option add *NewFrame.background #123456
- frame .f -class NewFrame
- lindex [.f configure -background] 4
-} -cleanup {
deleteWindows
- option clear
-} -result {#123456}
-test frame-3.6 {TkCreateFrame procedure} -setup {
- deleteWindows
} -body {
option add *NewFrame.background #123456
frame .f -class NewFrame
@@ -634,7 +621,7 @@ test frame-3.6 {TkCreateFrame procedure} -setup {
option clear
} -result {#123456}
test frame-3.7 {TkCreateFrame procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
option add *NewFrame.background #332211
option add *f.class NewFrame
@@ -645,7 +632,7 @@ test frame-3.7 {TkCreateFrame procedure} -setup {
option clear
} -result {NewFrame #332211}
test frame-3.8 {TkCreateFrame procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
option add *Silly.background #122334
option add *f.Class Silly
@@ -658,7 +645,7 @@ test frame-3.8 {TkCreateFrame procedure} -setup {
test frame-3.9 {TkCreateFrame procedure, -use option} -constraints {
unix
} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t -container 1 -width 300 -height 120
wm geometry .t +0+0
@@ -668,6 +655,12 @@ test frame-3.9 {TkCreateFrame procedure, -use option} -constraints {
[expr {[winfo rooty .x] - [winfo rooty .t]}] \
[winfo width .t] [winfo height .t]
} -cleanup {
+ # This call to update idletasks was added to prevent a crash that was
+ # observed on OSX 10.12 (Sierra) only. Any change, such as using the
+ # Development version to make debugging symbols available, adding a print
+ # statement, or calling update idletasks here, would make the test pass
+ # with no segfault.
+ update idletasks
deleteWindows
} -result {0 0 140 300}
test frame-3.10 {TkCreateFrame procedure, -use option} -constraints {
@@ -677,9 +670,19 @@ test frame-3.10 {TkCreateFrame procedure, -use option} -constraints {
} -body {
toplevel .t -container 1 -width 300 -height 120
wm geometry .t +0+0
+ if {[tk windowingsystem] eq "aqua"} {
+ update idletasks
+ } else {
+ update
+ }
option add *x.use [winfo id .t]
toplevel .x -width 140 -height 300 -bg green
- tkwait visibility .x
+ if {[tk windowingsystem] eq "aqua"} {
+ update idletasks
+ } else {
+ tkwait visibility .x
+ update
+ }
list [expr {[winfo rootx .x] - [winfo rootx .t]}] \
[expr {[winfo rooty .x] - [winfo rooty .t]}] \
[winfo width .t] [winfo height .t]
@@ -687,42 +690,40 @@ test frame-3.10 {TkCreateFrame procedure, -use option} -constraints {
destroy .t
option clear
} -result {0 0 140 300}
-
-# The tests below require specific display characteristics (i.e. that
-# they are run on a pseudocolor display of depth 8). Even so, they
-# are non-portable: some machines don't seem to ever run out of
-# colors.
+# The tests below require specific display characteristics (i.e. that they are
+# run on a pseudocolor display of depth 8). Even so, they are non-portable:
+# some machines don't seem to ever run out of colors.
if {[testConstraint defaultPseudocolor8]} {
eatColors .t1
}
test frame-3.11 {TkCreateFrame procedure} -constraints {
- defaultPseudocolor8 nonPortable
+ defaultPseudocolor8 nonPortable
} -setup {
- deleteWindows
+ destroy .t
} -body {
toplevel .t -width 300 -height 200 -bg #475601
wm geometry .t +0+0
update
colorsFree .t
} -cleanup {
- deleteWindows
+ destroy .t
} -result {0}
test frame-3.12 {TkCreateFrame procedure} -constraints {
- defaultPseudocolor8 nonPortable
+ defaultPseudocolor8 nonPortable
} -setup {
- deleteWindows
+ destroy .t
} -body {
toplevel .t -width 300 -height 200 -bg #475601 -colormap new
wm geometry .t +0+0
update
colorsFree .t
} -cleanup {
- deleteWindows
+ destroy .t
} -result {1}
test frame-3.13 {TkCreateFrame procedure} -constraints {
- defaultPseudocolor8 nonPortable
+ defaultPseudocolor8 nonPortable
} -setup {
- deleteWindows
+ destroy .t
} -body {
option add *t.class Toplevel2
option add *Toplevel2.colormap new
@@ -732,12 +733,12 @@ test frame-3.13 {TkCreateFrame procedure} -constraints {
option clear
colorsFree .t
} -cleanup {
- deleteWindows
+ destroy .t
} -result {1}
test frame-3.14 {TkCreateFrame procedure} -constraints {
- defaultPseudocolor8 nonPortable
+ defaultPseudocolor8 nonPortable
} -setup {
- deleteWindows
+ destroy .t
} -body {
option add *t.class Toplevel3
option add *Toplevel3.Colormap new
@@ -747,12 +748,12 @@ test frame-3.14 {TkCreateFrame procedure} -constraints {
option clear
colorsFree .t
} -cleanup {
- deleteWindows
+ destroy .t
} -result {1}
test frame-3.15 {TkCreateFrame procedure, -use and -colormap} -constraints {
defaultPseudocolor8 unix nonPortable
} -setup {
- deleteWindows
+ destroy .t
} -body {
toplevel .t -container 1 -width 300 -height 120
wm geometry .t +0+0
@@ -763,21 +764,21 @@ test frame-3.15 {TkCreateFrame procedure, -use and -colormap} -constraints {
destroy .t
} -result {0 1}
test frame-3.16 {TkCreateFrame procedure} -constraints {
- defaultPseudocolor8 nonPortable
+ defaultPseudocolor8 nonPortable
} -setup {
- deleteWindows
+ destroy .t
} -body {
toplevel .t -width 300 -height 200 -bg #475601 -visual default
wm geometry .t +0+0
update
colorsFree .t
} -cleanup {
- deleteWindows
+ destroy .t
} -result {0}
test frame-3.17 {TkCreateFrame procedure} -constraints {
- defaultPseudocolor8 nonPortable
+ defaultPseudocolor8 nonPortable
} -setup {
- deleteWindows
+ destroy .t
} -body {
toplevel .t -width 300 -height 200 -bg #475601 -visual default \
-colormap new
@@ -785,24 +786,24 @@ test frame-3.17 {TkCreateFrame procedure} -constraints {
update
colorsFree .t
} -cleanup {
- deleteWindows
+ destroy .t
} -result {1}
test frame-3.18 {TkCreateFrame procedure} -constraints {
- defaultPseudocolor8 haveGrayscale8 nonPortable
+ defaultPseudocolor8 haveGrayscale8 nonPortable
} -setup {
- deleteWindows
+ destroy .t
} -body {
toplevel .t -visual {grayscale 8} -width 300 -height 200 -bg #434343
wm geometry .t +0+0
update
colorsFree .t 131 131 131
} -cleanup {
- deleteWindows
+ destroy .t
} -result {1}
test frame-3.19 {TkCreateFrame procedure} -constraints {
- defaultPseudocolor8 haveGrayscale8 nonPortable
+ defaultPseudocolor8 haveGrayscale8 nonPortable
} -setup {
- deleteWindows
+ destroy .t
} -body {
option add *t.class T4
option add *T4.visual {grayscale 8}
@@ -812,14 +813,13 @@ test frame-3.19 {TkCreateFrame procedure} -constraints {
option clear
list [colorsFree .t 131 131 131] [lindex [.t configure -visual] 4]
} -cleanup {
- deleteWindows
+ destroy .t
} -result {1 {grayscale 8}}
test frame-3.20 {TkCreateFrame procedure} -constraints {
- defaultPseudocolor8 haveGrayscale8 nonPortable
+ defaultPseudocolor8 haveGrayscale8 nonPortable
} -setup {
- deleteWindows
+ destroy .t
} -body {
- set x ok
option add *t.class T5
option add *T5.Visual {grayscale 8}
toplevel .t -width 300 -height 200 -bg #434343
@@ -828,27 +828,25 @@ test frame-3.20 {TkCreateFrame procedure} -constraints {
option clear
list [colorsFree .t 131 131 131] [lindex [.t configure -visual] 4]
} -cleanup {
- deleteWindows
+ destroy .t
} -result {1 {grayscale 8}}
test frame-3.21 {TkCreateFrame procedure} -constraints {
- defaultPseudocolor8 haveGrayscale8 nonPortable
+ defaultPseudocolor8 haveGrayscale8 nonPortable
} -setup {
- deleteWindows
+ destroy .t
} -body {
- set x ok
toplevel .t -visual {grayscale 8} -width 300 -height 200 -bg #434343
wm geometry .t +0+0
update
colorsFree .t 131 131 131
} -cleanup {
- deleteWindows
+ destroy .t
} -result {1}
if {[testConstraint defaultPseudocolor8]} {
destroy .t1
}
-
test frame-3.22 {TkCreateFrame procedure, default dimensions} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t
wm geometry .t +0+0
@@ -873,22 +871,20 @@ test frame-3.24 {TkCreateFrame procedure} -setup {
wm geometry .t +0+0
} -returnCodes error -result {unknown option "-bogus"}
-
test frame-4.1 {TkCreateFrame procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
catch {frame .f -gorp glob}
winfo exists .f
} -result 0
test frame-4.2 {TkCreateFrame procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
list [frame .f -width 200 -height 100] [winfo exists .f]
} -cleanup {
deleteWindows
} -result {.f 1}
-
frame .f -highlightcolor black
test frame-5.1 {FrameWidgetCommand procedure} -body {
.f
@@ -916,10 +912,9 @@ test frame-5.7 {FrameWidgetCommand procedure, cget option} -setup {
} -cleanup {
destroy .t
} -returnCodes ok -match glob -result *
-
test frame-5.8 {FrameWidgetCommand procedure, configure option} -body {
- llength [.f configure]
-} -result {18}
+ optnames [.f configure]
+} -result {-background -backgroundimage -bd -bg -bgimg -borderwidth -class -colormap -container -cursor -height -highlightbackground -highlightcolor -highlightthickness -padx -pady -relief -takefocus -tile -visual -width}
test frame-5.9 {FrameWidgetCommand procedure, configure option} -body {
.f configure -gorp
} -returnCodes error -result {unknown option "-gorp"}
@@ -933,12 +928,12 @@ test frame-5.12 {FrameWidgetCommand procedure} -body {
.f swizzle
} -returnCodes error -result {bad option "swizzle": must be cget or configure}
test frame-5.13 {FrameWidgetCommand procedure, configure option} -body {
- llength [. configure]
-} -result {21}
+ optnames [. configure]
+} -result {-background -backgroundimage -bd -bg -bgimg -borderwidth -class -colormap -container -cursor -height -highlightbackground -highlightcolor -highlightthickness -menu -padx -pady -relief -screen -takefocus -tile -use -visual -width}
destroy .f
test frame-6.1 {ConfigureFrame procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
frame .f -width 150
list [winfo reqwidth .f] [winfo reqheight .f]
@@ -946,7 +941,7 @@ test frame-6.1 {ConfigureFrame procedure} -setup {
deleteWindows
} -result {150 1}
test frame-6.2 {ConfigureFrame procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
frame .f -height 97
list [winfo reqwidth .f] [winfo reqheight .f]
@@ -954,7 +949,7 @@ test frame-6.2 {ConfigureFrame procedure} -setup {
deleteWindows
} -result {1 97}
test frame-6.3 {ConfigureFrame procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
frame .f
set result {}
@@ -968,7 +963,7 @@ test frame-6.3 {ConfigureFrame procedure} -setup {
} -result {1 1 100 180 100 180}
test frame-7.1 {FrameEventProc procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
frame .frame2
set result [info commands .frame2]
@@ -976,7 +971,7 @@ test frame-7.1 {FrameEventProc procedure} -setup {
lappend result [info commands .frame2]
} -result {.frame2 {}}
test frame-7.2 {FrameEventProc procedure} -setup {
- deleteWindows
+ deleteWindows
set x {}
} -body {
frame .f1 -bg #543210
@@ -990,7 +985,7 @@ test frame-7.2 {FrameEventProc procedure} -setup {
} -result {.f1 #543210 {} {}}
test frame-8.1 {FrameCmdDeletedProc procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
frame .f1
rename .f1 {}
@@ -999,7 +994,7 @@ test frame-8.1 {FrameCmdDeletedProc procedure} -setup {
deleteWindows
} -result {{} {}}
test frame-8.2 {FrameCmdDeletedProc procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .f1 -menu .m
wm geometry .f1 +0+0
@@ -1014,7 +1009,6 @@ test frame-8.2 {FrameCmdDeletedProc procedure} -setup {
# This one fails with the dash-patch!!!! Still don't know why :-(
#
#test frame-8.3 {FrameCmdDeletedProc procedure} -setup {
-# eval destroy [winfo children .]
# deleteWindows
#} -body {
# toplevel .f1 -menu .m
@@ -1025,12 +1019,11 @@ test frame-8.2 {FrameCmdDeletedProc procedure} -setup {
# update
# list [info command .f*] [winfo children .]
#} -cleanup {
-# eval destroy [winfo children .]
# deleteWindows
#} -result {{} .m}
test frame-9.1 {MapFrame procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t -width 100 -height 400
wm geometry .t +0+0
@@ -1041,7 +1034,7 @@ test frame-9.1 {MapFrame procedure} -setup {
deleteWindows
} -result {0 1}
test frame-9.2 {MapFrame procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t -width 100 -height 400
wm geometry .t +0+0
@@ -1050,7 +1043,7 @@ test frame-9.2 {MapFrame procedure} -setup {
winfo exists .t
} -result {0}
test frame-9.3 {MapFrame procedure, window deleted while mapping} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t2 -width 200 -height 200
wm geometry .t2 +0+0
@@ -1066,22 +1059,17 @@ test frame-9.3 {MapFrame procedure, window deleted while mapping} -setup {
deleteWindows
} -result {0}
-
test frame-10.1 {frame widget vs hidden commands} -setup {
- deleteWindows
+ deleteWindows
} -body {
- set l [interp hidden]
frame .t
interp hide {} .t
destroy .t
- set res1 [list [winfo children .] [interp hidden]]
- set res2 [list {} $l]
- expr {$res1 eq $res2}
-} -result 1
-
+ list [winfo children .] [lsort [interp hidden]]
+} -result [list {} [lsort [interp hidden]]]
test frame-11.1 {TkInstallFrameMenu} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add cascade -menu .m1.system
@@ -1092,9 +1080,9 @@ test frame-11.1 {TkInstallFrameMenu} -setup {
deleteWindows
} -result {.t}
test frame-11.2 {TkInstallFrameMenu - frame renamed} -setup {
- deleteWindows
-} -body {
+ deleteWindows
catch {rename foo {}}
+} -body {
menu .m1
.m1 add cascade -menu .m1.system
menu .m1.system -tearoff 0
@@ -1105,9 +1093,8 @@ test frame-11.2 {TkInstallFrameMenu - frame renamed} -setup {
deleteWindows
} -result {}
-
test frame-12.1 {FrameWorldChanged procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
# Test -bd -padx and -pady
frame .f -borderwidth 2 -padx 3 -pady 4
@@ -1119,19 +1106,16 @@ test frame-12.1 {FrameWorldChanged procedure} -setup {
deleteWindows
} -result {5 6 30 28}
test frame-12.2 {FrameWorldChanged procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
# Test all -labelanchor positions
set font {helvetica 12}
labelframe .f -highlightthickness 1 -bd 3 -padx 1 -pady 2 -font $font \
-text "Mupp"
- set fh [expr {[font metrics $font -linespace] + 2 - 3}]
- set fw [expr {[font measure $font "Mupp"] + 2 - 3}]
- if {$fw < 0} {set fw 0}
- if {$fh < 0} {set fh 0}
+ set fh [expr {max([font metrics $font -linespace] + 2 - 3, 0)}]
+ set fw [expr {max([font measure $font "Mupp"] + 2 - 3, 0)}]
place .f -x 0 -y 0 -width 100 -height 100
pack [frame .f.f] -fill both -expand 1
-
set result {}
foreach lp {nw n ne en e es se s sw ws w wn} {
.f configure -labelanchor $lp
@@ -1146,27 +1130,37 @@ test frame-12.2 {FrameWorldChanged procedure} -setup {
w* {incr expx $fw ; incr expw -$fw}
e* {incr expw -$fw}
}
- lappend result [expr {\
- [winfo x .f.f] == $expx && [winfo y .f.f] == $expy &&\
- [winfo width .f.f] == $expw && [winfo height .f.f] == $exph}]
+ lappend result [expr {
+ [winfo x .f.f] == $expx && [winfo y .f.f] == $expy &&
+ [winfo width .f.f] == $expw && [winfo height .f.f] == $exph
+ }]
}
return $result
} -cleanup {
deleteWindows
} -result {1 1 1 1 1 1 1 1 1 1 1 1}
test frame-12.3 {FrameWorldChanged procedure} -setup {
- deleteWindows
+ deleteWindows
+ update idletasks
} -body {
# Check reaction on font change
font create myfont -family courier -size 10
labelframe .f -font myfont -text Mupp
place .f -x 0 -y 0 -width 40 -height 40
pack [frame .f.f] -fill both -expand 1
- update
+ if {[tk windowingsystem] eq "aqua"} {
+ update idletasks
+ } else {
+ update
+ }
set h1 [font metrics myfont -linespace]
set y1 [winfo y .f.f]
font configure myfont -size 20
- update
+ if {[tk windowingsystem] eq "aqua"} {
+ update idletasks
+ } else {
+ update
+ }
set h2 [font metrics myfont -linespace]
set y2 [winfo y .f.f]
expr {($h2 - $h1) - ($y2 - $y1)}
@@ -1175,9 +1169,8 @@ test frame-12.3 {FrameWorldChanged procedure} -setup {
font delete myfont
} -result {0}
-
test frame-13.1 {labelframe configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
labelframe .f -class NewFrame
.f configure -class
@@ -1189,32 +1182,32 @@ test frame-13.2 {labelframe configuration options} -setup {
} -body {
labelframe .f -class NewFrame
.f configure -class Different
-} -cleanup {
+} -returnCodes error -cleanup {
deleteWindows
-} -returnCodes error -result {can't modify -class option after widget is created}
+} -result {can't modify -class option after widget is created}
test frame-13.3 {labelframe configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
labelframe .f -colormap new
} -cleanup {
deleteWindows
} -result {.f}
test frame-13.4 {labelframe configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
labelframe .f -visual default
} -cleanup {
deleteWindows
} -result {.f}
test frame-13.5 {labelframe configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
labelframe .f -screen bogus
} -cleanup {
deleteWindows
} -returnCodes error -result {unknown option "-screen"}
test frame-13.6 {labelframe configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
labelframe .f -container true
} -cleanup {
@@ -1229,21 +1222,20 @@ test frame-13.7 {labelframe configuration options} -setup {
deleteWindows
} -result {-container container Container 0 1}
test frame-13.8 {labelframe configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
labelframe .f -container bogus
} -cleanup {
deleteWindows
} -returnCodes error -result {expected boolean value but got "bogus"}
test frame-13.9 {labelframe configuration options} -setup {
- deleteWindows
+ deleteWindows
} -body {
labelframe .f
.f configure -container 1
-} -cleanup {
+} -returnCodes error -cleanup {
deleteWindows
-} -returnCodes error -result {can't modify -container option after widget is created}
-
+} -result {can't modify -container option after widget is created}
destroy .f
labelframe .f
test frame-13.10 {labelframe configuration options} -body {
@@ -1251,9 +1243,9 @@ test frame-13.10 {labelframe configuration options} -body {
lindex [.f configure -background] 4
} -cleanup {
.f configure -background [lindex [.f configure -background] 3]
-} -result {#ff0000}
+} -result "#ff0000"
test frame-13.11 {labelframe configuration options} -body {
- .f configure -background non-existent
+ .f configure -background non-existent
} -returnCodes error -result {unknown color name "non-existent"}
test frame-13.12 {labelframe configuration options} -body {
.f configure -bd 4
@@ -1262,16 +1254,16 @@ test frame-13.12 {labelframe configuration options} -body {
.f configure -bd [lindex [.f configure -bd] 3]
} -result {4}
test frame-13.13 {labelframe configuration options} -body {
- .f configure -bd badValue
+ .f configure -bd badValue
} -returnCodes error -result {bad screen distance "badValue"}
test frame-13.14 {labelframe configuration options} -body {
.f configure -bg #00ff00
lindex [.f configure -bg] 4
} -cleanup {
.f configure -bg [lindex [.f configure -bg] 3]
-} -result {#00ff00}
+} -result "#00ff00"
test frame-13.15 {labelframe configuration options} -body {
- .f configure -bg non-existent
+ .f configure -bg non-existent
} -returnCodes error -result {unknown color name "non-existent"}
test frame-13.16 {labelframe configuration options} -body {
.f configure -borderwidth 1.3
@@ -1280,7 +1272,7 @@ test frame-13.16 {labelframe configuration options} -body {
.f configure -borderwidth [lindex [.f configure -borderwidth] 3]
} -result {1}
test frame-13.17 {labelframe configuration options} -body {
- .f configure -borderwidth badValue
+ .f configure -borderwidth badValue
} -returnCodes error -result {bad screen distance "badValue"}
test frame-13.18 {labelframe configuration options} -body {
.f configure -cursor arrow
@@ -1289,16 +1281,16 @@ test frame-13.18 {labelframe configuration options} -body {
.f configure -cursor [lindex [.f configure -cursor] 3]
} -result {arrow}
test frame-13.19 {labelframe configuration options} -body {
- .f configure -cursor badValue
+ .f configure -cursor badValue
} -returnCodes error -result {bad cursor spec "badValue"}
test frame-13.20 {labelframe configuration options} -body {
.f configure -fg #0000ff
lindex [.f configure -fg] 4
} -cleanup {
.f configure -fg [lindex [.f configure -fg] 3]
-} -result {#0000ff}
+} -result "#0000ff"
test frame-13.21 {labelframe configuration options} -body {
- .f configure -fg non-existent
+ .f configure -fg non-existent
} -returnCodes error -result {unknown color name "non-existent"}
test frame-13.22 {labelframe configuration options} -body {
.f configure -font {courier 8}
@@ -1311,9 +1303,9 @@ test frame-13.23 {labelframe configuration options} -body {
lindex [.f configure -foreground] 4
} -cleanup {
.f configure -foreground [lindex [.f configure -foreground] 3]
-} -result {#ff0000}
+} -result "#ff0000"
test frame-13.24 {labelframe configuration options} -body {
- .f configure -foreground non-existent
+ .f configure -foreground non-existent
} -returnCodes error -result {unknown color name "non-existent"}
test frame-13.25 {labelframe configuration options} -body {
.f configure -height 100
@@ -1322,25 +1314,25 @@ test frame-13.25 {labelframe configuration options} -body {
.f configure -height [lindex [.f configure -height] 3]
} -result {100}
test frame-13.26 {labelframe configuration options} -body {
- .f configure -height not_a_number
+ .f configure -height not_a_number
} -returnCodes error -result {bad screen distance "not_a_number"}
test frame-13.27 {labelframe configuration options} -body {
.f configure -highlightbackground #112233
lindex [.f configure -highlightbackground] 4
} -cleanup {
.f configure -highlightbackground [lindex [.f configure -highlightbackground] 3]
-} -result {#112233}
+} -result "#112233"
test frame-13.28 {labelframe configuration options} -body {
- .f configure -highlightbackground ugly
+ .f configure -highlightbackground ugly
} -returnCodes error -result {unknown color name "ugly"}
test frame-13.29 {labelframe configuration options} -body {
.f configure -highlightcolor #123456
lindex [.f configure -highlightcolor] 4
} -cleanup {
.f configure -highlightcolor [lindex [.f configure -highlightcolor] 3]
-} -result {#123456}
+} -result "#123456"
test frame-13.30 {labelframe configuration options} -body {
- .f configure -highlightcolor non-existent
+ .f configure -highlightcolor non-existent
} -returnCodes error -result {unknown color name "non-existent"}
test frame-13.31 {labelframe configuration options} -body {
.f configure -highlightthickness 6
@@ -1349,7 +1341,7 @@ test frame-13.31 {labelframe configuration options} -body {
.f configure -highlightthickness [lindex [.f configure -highlightthickness] 3]
} -result {6}
test frame-13.32 {labelframe configuration options} -body {
- .f configure -highlightthickness badValue
+ .f configure -highlightthickness badValue
} -returnCodes error -result {bad screen distance "badValue"}
test frame-13.33 {labelframe configuration options} -body {
.f configure -labelanchor se
@@ -1357,9 +1349,9 @@ test frame-13.33 {labelframe configuration options} -body {
} -cleanup {
.f configure -labelanchor [lindex [.f configure -labelanchor] 3]
} -result {se}
-test frame-13.34 {labelframe configuration options} -body {
- .f configure -labelanchor badValue
-} -returnCodes error -result {bad labelanchor "badValue": must be e, en, es, n, ne, nw, s, se, sw, w, wn, or ws}
+test frame-13.34 {labelframe configuration options} -returnCodes error -body {
+ .f configure -labelanchor badValue
+} -result {bad labelanchor "badValue": must be e, en, es, n, ne, nw, s, se, sw, w, wn, or ws}
test frame-13.35 {labelframe configuration options} -body {
.f configure -padx 3
lindex [.f configure -padx] 4
@@ -1367,7 +1359,7 @@ test frame-13.35 {labelframe configuration options} -body {
.f configure -padx [lindex [.f configure -padx] 3]
} -result {3}
test frame-13.36 {labelframe configuration options} -body {
- .f configure -padx badValue
+ .f configure -padx badValue
} -returnCodes error -result {bad screen distance "badValue"}
test frame-13.37 {labelframe configuration options} -body {
.f configure -pady 4
@@ -1376,7 +1368,7 @@ test frame-13.37 {labelframe configuration options} -body {
.f configure -pady [lindex [.f configure -pady] 3]
} -result {4}
test frame-13.38 {labelframe configuration options} -body {
- .f configure -pady badValue
+ .f configure -pady badValue
} -returnCodes error -result {bad screen distance "badValue"}
test frame-13.39 {labelframe configuration options} -body {
.f configure -relief ridge
@@ -1384,9 +1376,9 @@ test frame-13.39 {labelframe configuration options} -body {
} -cleanup {
.f configure -relief [lindex [.f configure -relief] 3]
} -result {ridge}
-test frame-13.40 {labelframe configuration options} -body {
- .f configure -relief badValue
-} -returnCodes error -result {bad relief "badValue": must be flat, groove, raised, ridge, solid, or sunken}
+test frame-13.40 {labelframe configuration options} -returnCodes error -body {
+ .f configure -relief badValue
+} -result {bad relief "badValue": must be flat, groove, raised, ridge, solid, or sunken}
test frame-13.41 {labelframe configuration options} -body {
.f configure -takefocus {any string}
lindex [.f configure -takefocus] 4
@@ -1406,13 +1398,12 @@ test frame-13.43 {labelframe configuration options} -body {
.f configure -width [lindex [.f configure -width] 3]
} -result {32}
test frame-13.44 {labelframe configuration options} -body {
- .f configure -width badValue
+ .f configure -width badValue
} -returnCodes error -result {bad screen distance "badValue"}
destroy .f
-
test frame-14.1 {labelframe labelwidget option} -setup {
- deleteWindows
+ deleteWindows
} -body {
# Test that label is moved in stacking order
label .l -text Mupp -font {helvetica 8}
@@ -1427,7 +1418,7 @@ test frame-14.1 {labelframe labelwidget option} -setup {
deleteWindows
} -result {{.f .l} 54 52}
test frame-14.2 {labelframe labelwidget option} -setup {
- deleteWindows
+ deleteWindows
} -body {
# Test the labelframe's reaction if the label is destroyed
label .l -text Aratherlonglabel
@@ -1446,7 +1437,7 @@ test frame-14.2 {labelframe labelwidget option} -setup {
deleteWindows
} -result {.l 12 {} 4}
test frame-14.3 {labelframe labelwidget option} -setup {
- deleteWindows
+ deleteWindows
} -body {
# Test the labelframe's reaction if the label is stolen
label .l -text Aratherlonglabel
@@ -1465,7 +1456,7 @@ test frame-14.3 {labelframe labelwidget option} -setup {
deleteWindows
} -result {.l 12 {} 4}
test frame-14.4 {labelframe labelwidget option} -setup {
- deleteWindows
+ deleteWindows
} -body {
# Test the label's reaction if the labelframe is destroyed
label .l -text Mupp
@@ -1479,7 +1470,7 @@ test frame-14.4 {labelframe labelwidget option} -setup {
deleteWindows
} -result {labelframe {}}
test frame-14.5 {labelframe labelwidget option} -setup {
- deleteWindows
+ deleteWindows
} -body {
# Test that the labelframe reacts on changes in label
label .l -text Aratherlonglabel
@@ -1502,12 +1493,12 @@ test frame-14.5 {labelframe labelwidget option} -setup {
deleteWindows
} -result {12 12 1 12 1}
test frame-14.6 {labelframe labelwidget option} -setup {
- deleteWindows
+ deleteWindows
} -body {
- # Destroying a labelframe with a child label caused a crash
- # when not handling mapping of the label correctly.
- # This test does not test anything directly, it's just ment
- # to catch if the same mistake is made again.
+ # Destroying a labelframe with a child label caused a crash when not
+ # handling mapping of the label correctly.
+ # This test does not test anything directly, it's just ment to catch if
+ # the same mistake is made again.
labelframe .f
pack .f
label .f.l -text Mupp
@@ -1516,14 +1507,298 @@ test frame-14.6 {labelframe labelwidget option} -setup {
} -cleanup {
deleteWindows
} -result {}
-deleteWindows
-rename eatColors {}
-rename colorsFree {}
+test frame-15.1 {TIP 262: frame background images} -setup {
+ deleteWindows
+ image create photo gorp -width 10 -height 10
+ gorp put black -to 2 2 7 7
+} -body {
+ frame .f -width 100 -height 100
+ pack .f
+ list [image inuse gorp] [.f configure -backgroundimage gorp;update] \
+ [image inuse gorp] [winfo width .f] [winfo height .f]
+} -cleanup {
+ image delete gorp
+ deleteWindows
+} -result {0 {} 1 100 100}
+test frame-15.2 {TIP 262: frame background images} -setup {
+ deleteWindows
+ catch {rename gorp ""}
+} -body {
+ frame .f -width 100 -height 100
+ pack .f
+ update
+ .f configure -backgroundimage gorp
+} -returnCodes error -cleanup {
+ deleteWindows
+} -result {image "gorp" doesn't exist}
+test frame-15.3 {TIP 262: frame background images} -setup {
+ deleteWindows
+ image create photo gorp -width 10 -height 10
+ gorp put black -to 2 2 7 7
+} -body {
+ frame .f -width 100 -height 100 -backgroundimage gorp
+ pack .f
+ .f configure -tile yes
+ update
+ list [.f cget -bgimg] [.f cget -tile]
+} -cleanup {
+ image delete gorp
+ deleteWindows
+} -result {gorp 1}
+test frame-15.4 {TIP 262: frame background images} -setup {
+ deleteWindows
+ image create photo gorp -width 10 -height 10
+ gorp put black -to 2 2 7 7
+} -body {
+ frame .f -width 100 -height 100 -backgroundimage gorp
+ pack .f
+ .f configure -tile yes
+ update
+ gorp put red -to 15 15 20 20
+ update
+ list [.f cget -bgimg] [.f cget -tile]
+} -cleanup {
+ image delete gorp
+ deleteWindows
+} -result {gorp 1}
+test frame-15.5 {TIP 262: frame background images} -setup {
+ deleteWindows
+ image create photo gorp -width 10 -height 10
+ gorp put black -to 2 2 7 7
+ set result {}
+} -body {
+ frame .f -width 100 -height 100 -backgroundimage gorp
+ pack .f
+ .f configure -tile yes
+ update
+ image delete gorp
+ update
+ set result [list [.f cget -bgimg] [.f cget -tile]]
+ image create photo gorp -width 250 -height 250
+ update
+ lappend result [.f cget -backgroundimage]
+} -cleanup {
+ catch {image delete gorp}
+ deleteWindows
+} -result {gorp 1 gorp}
+test frame-15.6 {TIP 262: frame background images} -setup {
+ deleteWindows
+ set result {}
+ . configure -width 200 -height 200
+} -constraints testImageType -body {
+ image create test gorp -variable result
+ pack [frame .f -width 100 -height 100 -bgimg gorp]
+ update idletasks; update
+ return [uniq $result]
+} -cleanup {
+ deleteWindows
+ catch {image delete gorp}
+} -result {{gorp get} {gorp display 0 0 30 15}}
+test frame-15.6a {TIP 262: frame background images (offsets)} -setup {
+ deleteWindows
+ set result {}
+ . configure -width 200 -height 200
+} -constraints testImageType -body {
+ image create test gorp -variable result
+ pack [frame .f -width 10 -height 10 -bgimg gorp]
+ update idletasks; update
+ # On MacOS must wait for the test image display procedure to run.
+ set timer [after 300 {lappend result "timedout"}]
+ while {"timedout" ni $result &&
+ "gorp display 10 2 10 10" ni $result} {
+ vwait result
+ }
+ after cancel $timer
+ update idletasks; update
+ return [uniq $result]
+} -cleanup {
+ deleteWindows
+ catch {image delete gorp}
+} -result {{gorp get} {gorp display 10 2 10 10}}
+test frame-15.7 {TIP 262: frame background images} -setup {
+ deleteWindows
+ set result {}
+ . configure -width 200 -height 200
+} -constraints testImageType -body {
+ image create test gorp -variable result
+ pack [frame .f -width 50 -height 25 -bgimg gorp -tile 1]
+ update idletasks; update
+ # On MacOS must wait for the test image display procedure to run.
+ set timer [after 300 {lappend result "timedout"}]
+ while {"timedout" ni $result &&
+ "gorp display 0 0 20 10" ni $result} {
+ vwait result
+ }
+ after cancel $timer
+ if {[lindex $result end] eq "timedout"} {
+ return [lreplace $result end end]
+ }
+ return [uniq $result]
+} -cleanup {
+ deleteWindows
+ catch {image delete gorp}
+} -result {{gorp get} {gorp display 0 0 30 15} {gorp display 0 0 30 10} {gorp display 0 0 20 15} {gorp display 0 0 20 10}}
+test frame-15.7a {TIP 262: frame background images (offsets)} -setup {
+ deleteWindows
+ set result {}
+ . configure -width 200 -height 200
+} -constraints testImageType -body {
+ image create test gorp -variable result
+ pack [frame .f -width 50 -height 25 -bgimg gorp -tile 1 -highlightthick 1]
+ update idletasks; update
+ # On MacOS must wait for the test image display procedure to run.
+ set timer [after 300 {lappend result "timedout"}]
+ while {"timedout" ni $result &&
+ "gorp display 0 0 18 8" ni $result} {
+ vwait result
+ }
+ after cancel $timer
+ return [uniq $result]
+} -cleanup {
+ deleteWindows
+ catch {image delete gorp}
+} -result {{gorp get} {gorp display 0 0 30 15} {gorp display 0 0 30 8} {gorp display 0 0 18 15} {gorp display 0 0 18 8}}
+test frame-15.7b {TIP 262: frame background images (offsets)} -setup {
+ deleteWindows
+ set result {}
+ . configure -width 200 -height 200
+} -constraints testImageType -body {
+ image create test gorp -variable result
+ pack [frame .f -width 50 -height 25 -bgimg gorp -tile 1 -bd 2]
+ update idletasks; update
+ return [uniq $result]
+} -cleanup {
+ deleteWindows
+ catch {image delete gorp}
+} -result {{gorp get} {gorp display 0 0 30 15} {gorp display 0 0 30 6} {gorp display 0 0 16 15} {gorp display 0 0 16 6}}
+test frame-15.7c {TIP 262: frame background images (offsets)} -setup {
+ deleteWindows
+ set result {}
+ . configure -width 200 -height 200
+} -constraints testImageType -body {
+ image create test gorp -variable result
+ pack [frame .f -width 50 -height 25 -bgimg gorp -tile 1 -bd 2 -highlightthick 1]
+ update idletasks; update
+ return [uniq $result]
+} -cleanup {
+ deleteWindows
+ catch {image delete gorp}
+} -result {{gorp get} {gorp display 0 0 30 15} {gorp display 0 0 30 4} {gorp display 0 0 14 15} {gorp display 0 0 14 4}}
+test frame-15.8 {TIP 262: toplevel background images} -setup {
+ deleteWindows
+ image create photo gorp -width 10 -height 10
+ gorp put black -to 2 2 7 7
+} -body {
+ toplevel .t -width 100 -height 100
+ update
+ # Used to verify that setting a background image doesn't change the widget size
+ set w [winfo width .t]
+ set h [winfo height .t]
+ list [image inuse gorp] [.t configure -backgroundimage gorp;update] \
+ [image inuse gorp] \
+ [expr {$w-[winfo width .t]}] [expr {$h-[winfo height .t]}]
+} -cleanup {
+ image delete gorp
+ deleteWindows
+} -result {0 {} 1 0 0}
+test frame-15.9 {TIP 262: toplevel background images} -setup {
+ deleteWindows
+ catch {rename gorp ""}
+} -body {
+ toplevel .t -width 100 -height 100
+ update
+ .t configure -backgroundimage gorp
+} -returnCodes error -cleanup {
+ deleteWindows
+} -result {image "gorp" doesn't exist}
+test frame-15.10 {TIP 262: toplevel background images} -setup {
+ deleteWindows
+ image create photo gorp -width 10 -height 10
+ gorp put black -to 2 2 7 7
+} -body {
+ toplevel .t -width 100 -height 100 -backgroundimage gorp -tile yes
+ update
+ list [.t cget -bgimg] [.t cget -tile]
+} -cleanup {
+ image delete gorp
+ deleteWindows
+} -result {gorp 1}
+test frame-15.11 {TIP 262: toplevel background images} -setup {
+ deleteWindows
+ image create photo gorp -width 10 -height 10
+ gorp put black -to 2 2 7 7
+} -body {
+ toplevel .t -width 100 -height 100 -backgroundimage gorp -tile yes
+ update
+ gorp put red -to 15 15 20 20
+ update
+ list [.t cget -bgimg] [.t cget -tile]
+} -cleanup {
+ image delete gorp
+ deleteWindows
+} -result {gorp 1}
+test frame-15.12 {TIP 262: toplevel background images} -setup {
+ deleteWindows
+ image create photo gorp -width 10 -height 10
+ gorp put black -to 2 2 7 7
+ set result {}
+} -body {
+ toplevel .t -width 100 -height 100 -backgroundimage gorp -tile yes
+ update
+ image delete gorp
+ update
+ set result [list [.t cget -bgimg] [.t cget -tile]]
+ image create photo gorp -width 250 -height 250
+ update
+ lappend result [.t cget -backgroundimage]
+} -cleanup {
+ catch {image delete gorp}
+ deleteWindows
+} -result {gorp 1 gorp}
+test frame-15.13 {TIP 262: toplevel background images} -setup {
+ deleteWindows
+ set result {}
+} -constraints testImageType -body {
+ image create test gorp -variable result
+ toplevel .t -width 100 -height 100 -bgimg gorp
+ wm overrideredirect .t 1; # Reduce trouble from window managers
+ update idletasks; update
+ return [uniq $result]
+} -cleanup {
+ deleteWindows
+ catch {image delete gorp}
+} -result {{gorp get} {gorp display 0 0 30 15}}
+test frame-15.14 {TIP 262: toplevel background images} -setup {
+ deleteWindows
+ set result {}
+} -constraints testImageType -body {
+ image create test gorp -variable result
+ toplevel .t -width 50 -height 25 -bgimg gorp -tile 1
+ wm overrideredirect .t 1; # Reduce trouble from window managers
+ update idletasks; update
+ # On MacOS must wait for the test image display procedure to run.
+ set timer [after 300 {lappend result "timedout"}]
+ while {"timedout" ni $result &&
+ "gorp display 0 0 20 10" ni $result} {
+ vwait result
+ }
+ after cancel $timer
+ return [uniq $result]
+} -cleanup {
+ deleteWindows
+ catch {image delete gorp}
+} -result {{gorp get} {gorp display 0 0 30 15} {gorp display 0 0 30 10} {gorp display 0 0 20 15} {gorp display 0 0 20 10}}
+
# cleanup
+deleteWindows
+apply {cmds {foreach cmd $cmds {rename $cmd {}}}} {
+ eatColors colorsFree uniq optnames
+}
+
cleanupTests
return
-
-
-
+# Local Variables:
+# mode: tcl
+# End:
diff --git a/tests/grab.test b/tests/grab.test
index 33399cb..653d756 100644
--- a/tests/grab.test
+++ b/tests/grab.test
@@ -12,10 +12,14 @@ eval tcltest::configure $argv
tcltest::loadTestedCommands
namespace import -force tcltest::test
-# There's currently no way to test the actual grab effect, per se,
-# in an automated test. Therefore, this test suite only covers the
-# interface to the grab command (ie, error messages, etc.)
+# The macOS test module includes the pressbutton command to simulate a
+# mouse button press event by injecting events into the NSApplication
+# event queue. On other platforms there is currently no way to test
+# the actual grab effect, per se, in an automated test. Therefore,
+# this test suite only covers the interface to the grab command (ie,
+# error messages, etc.) on platforms other than macOS.
+testConstraint pressbutton [llength [info commands pressbutton]]
test grab-1.1 {Tk_GrabObjCmd} -body {
grab
@@ -182,6 +186,32 @@ test grab-5.2 {Tk_GrabObjCmd, grab set} -body {
grab release .
} -result {. global}
+test grab-6.1 {local grab on child window} -constraints {
+ pressbutton
+} -body {
+ wm geometry . 100x200+200+100
+ set result {}
+ frame .f -background red -padx 10 -pady 10 -height 100 -width 80
+ bind . <Button-1> {lappend result "outside"}
+ bind .f <Button-1> {lappend result "inside"}
+ pack .f
+ update idletasks
+ pressbutton 250 150
+ update
+ lappend result ":"
+ pressbutton 250 250
+ update
+ lappend result ":"
+ grab set .f
+ pressbutton 250 150
+ update
+ lappend result ":"
+ pressbutton 250 250
+ update
+ return $result
+} -cleanup {
+ grab release .f
+} -result {inside outside : outside : inside outside :}
cleanupTests
return
diff --git a/tests/grid.test b/tests/grid.test
index 63bfe2a..53f8be5 100644
--- a/tests/grid.test
+++ b/tests/grid.test
@@ -80,6 +80,7 @@ test grid-1.9 {basic argument checking} -body {
grid_reset 1.9
} -returnCodes ok -result {}
+
test grid-2.1 {bbox} -body {
grid bbox .
} -result {0 0 0 0}
@@ -192,6 +193,30 @@ test grid-3.9 {configure: basic argument checking} -body {
} -cleanup {
grid_reset 3.9
} -returnCodes error -result {invalid window shortcut, "y" should be '-', 'x', or '^'}
+test grid-3.10 {ConfigureSlave procedure, bad -in option} -body {
+ frame .f
+ grid .f -in .f
+} -cleanup {
+ grid_reset 3.10
+} -returnCodes error -result {window can't be managed in itself}
+test grid-3.11 {prevent management loops} -body {
+ frame .f1
+ frame .f2
+ grid .f1 -in .f2
+ grid .f2 -in .f1
+} -cleanup {
+ grid_reset 3.11
+} -returnCodes error -result {can't put .f2 inside .f1, would cause management loop}
+test grid-3.12 {prevent management loops} -body {
+ frame .f1
+ frame .f2
+ frame .f3
+ grid .f1 -in .f2
+ grid .f2 -in .f3
+ grid .f3 -in .f1
+} -cleanup {
+ grid_reset 3.12
+} -returnCodes error -result {can't put .f3 inside .f1, would cause management loop}
test grid-4.1 {forget: basic argument checking} -body {
grid forget foo
diff --git a/tests/image.test b/tests/image.test
index 8121ffd..da65a66 100644
--- a/tests/image.test
+++ b/tests/image.test
@@ -47,7 +47,7 @@ test image-1.6 {Tk_ImageCmd procedure, "create" option} -constraints {
scan [image create test] image%d first
image create test myimage
scan [image create test -variable x] image%d second
- expr $second-$first
+ expr {$second-$first}
} -cleanup {
imageCleanup
} -result {1}
@@ -62,8 +62,18 @@ test image-1.7 {Tk_ImageCmd procedure, "create" option} -constraints {
.c create image 100 150 -image myimage
update
set x {}
+ set timer [after 500 {lappend x "timed out"}]
image create test myimage -variable x
+ update idletasks
update
+ # On MacOS we need to wait for the test image display procedure to run.
+ while {"timed out" ni $x && [lindex $x end 1] ne "display"} {
+ vwait x
+ }
+ after cancel timer
+ if {[lindex $x end] eq "timed out"} {
+ return [lreplace $x end end]
+ }
return $x
} -cleanup {
imageCleanup
@@ -80,8 +90,10 @@ test image-1.8 {Tk_ImageCmd procedure, "create" option} -constraints {
image delete myimage
update
set x {}
+ set timer [after 500 {lappend x "timed out"}]
image create test myimage -variable x
- update
+ vwait x
+ after cancel $timer
return $x
} -cleanup {
.c delete all
@@ -345,7 +357,12 @@ test image-8.1 {Tk_ImageCmd procedure, "inuse" option} -constraints {
catch {destroy .b}
} -result [list 0 1]
-
+if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} {
+ # Aqua >= 10.14 will redraw the entire image in drawRect.
+ set result_9_1 {{foo display 0 0 30 15}}
+} else {
+ set result_9_1 {{foo display 5 6 7 8}}
+}
test image-9.1 {Tk_ImageChanged procedure} -constraints testImageType -setup {
.c delete all
imageCleanup
@@ -355,13 +372,26 @@ test image-9.1 {Tk_ImageChanged procedure} -constraints testImageType -setup {
.c create image 50 50 -image foo
update
set x {}
+ set timer [after 500 {lappend x "timed out"}]
foo changed 5 6 7 8 30 15
+ update idletasks
update
+ # On MacOS we need to wait for the test image display procedure to run.
+ while {"timed out" ni $x && [lindex $x end 1] ne "display"} {
+ vwait x
+ }
+ after cancel $timer
return $x
} -cleanup {
.c delete all
imageCleanup
-} -result {{foo display 5 6 7 8}}
+} -result $result_9_1
+if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} {
+ # Aqua >= 10.14 will redraw the entire image.
+ set result_9_2 {{foo display 0 0 30 15} {foo display 0 0 30 15}}
+} else {
+ set result_9_2 {{foo display 5 6 25 9} {foo display 0 0 12 14}}
+}
test image-9.2 {Tk_ImageChanged procedure} -constraints testImageType -setup {
.c delete all
imageCleanup
@@ -373,13 +403,15 @@ test image-9.2 {Tk_ImageChanged procedure} -constraints testImageType -setup {
update
set x {}
foo changed 5 6 7 8 30 15
- update
+ set timer [after 500 {lappend x "timed out"}]
+ image create test myimage -variable x
+ vwait x
+ after cancel $timer
return $x
} -cleanup {
.c delete all
imageCleanup
-} -result {{foo display 5 6 25 9} {foo display 0 0 12 14}}
-
+} -result $result_9_2
test image-10.1 {Tk_GetImage procedure} -setup {
imageCleanup
@@ -413,8 +445,10 @@ test image-11.1 {Tk_FreeImage procedure} -constraints testImageType -setup {
update
set x {}
.c delete i1
+ set timer [after 500 {lappend x "timed out"}]
pack .c
- update
+ vwait x
+ after cancel $timer
list [imageNames] $x
} -cleanup {
.c delete all
diff --git a/tests/imgListFormat.test b/tests/imgListFormat.test
index b2c401c..331b572 100644
--- a/tests/imgListFormat.test
+++ b/tests/imgListFormat.test
@@ -139,7 +139,7 @@ test imgListFormat-3.4 {StringMatchDef: base64 data is not parsed as valid \
} -format default
} -cleanup {
imageCleanup
-} -returnCodes error -result {couldn't recognize image data}
+} -returnCodes error -result {invalid color name "iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCA"}
test imgListFormat-3.5 {StringMatchDef: valid data} -setup {
image create photo photo1
} -body {
diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test
index 8ab555f..df4cfcb 100644
--- a/tests/imgPhoto.test
+++ b/tests/imgPhoto.test
@@ -542,14 +542,14 @@ test imgPhoto-4.27 {ImgPhotoCmd procedure: put option} -setup {
photo1 put {{white} {white white}}
} -returnCodes error -cleanup {
image delete photo1
-} -result {couldn't recognize image data}
+} -result {invalid row # 1: all rows must have the same number of elements}
test imgPhoto-4.28 {ImgPhotoCmd procedure: put option} -setup {
image create photo photo1
} -body {
photo1 put {{blahgle}}
} -cleanup {
image delete photo1
-} -returnCodes error -result {couldn't recognize image data}
+} -returnCodes error -result {invalid color name "blahgle"}
test imgPhoto-4.29 {ImgPhotoCmd procedure: put option} -setup {
image create photo photo1
} -body {
@@ -1149,7 +1149,7 @@ test imgPhoto-4.95 {ImgPhotoCmd put: default fmt, invalid data} -setup {
#"
} -cleanup {
imageCleanup
-} -returnCodes error -result {couldn't recognize image data}
+} -returnCodes error -result {unmatched open quote in list}
test imgPhoto-4.96 {ImgPhotoCmd put: "default" handler is selected} -setup {
image create photo photo1
image create photo photo2
@@ -1932,14 +1932,14 @@ test imgPhoto-19.6 {MatchStringFormat: invalid data for default} -setup {
photo1 put bogus
} -cleanup {
imageCleanup
-} -returnCodes error -result {couldn't recognize image data}
+} -returnCodes error -result {invalid color name "bogus"}
test imgPhoto-19.7 {MatchStringFormat: invalid data for default} -setup {
image create photo photo1
} -body {
photo1 put bogus -format dEFault
} -cleanup {
imageCleanup
-} -returnCodes error -result {couldn't recognize image data}
+} -returnCodes error -result {invalid color name "bogus"}
test imgPhoto-19.8 {MatchStirngFormat: invalid data for gif} -setup {
image create photo photo1
} -body {
diff --git a/tests/imgSVGnano.test b/tests/imgSVGnano.test
new file mode 100644
index 0000000..ff7046a
--- /dev/null
+++ b/tests/imgSVGnano.test
@@ -0,0 +1,220 @@
+# This file is a Tcl script to test out the code in tkImgSVGnano.c, which reads
+# and write SVG-format image files for photo widgets. The files is organized
+# in the standard fashion for Tcl tests.
+#
+# Copyright (c) 2018 Rene Zaumseil
+# All rights reserved.
+
+package require tcltest 2.2
+namespace import ::tcltest::*
+eval tcltest::configure $argv
+tcltest::loadTestedCommands
+imageInit
+
+namespace eval svgnano {
+ variable data
+ set data(plus) {<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
+<path fill="none" stroke="#000000" d="M0 0 h16 v16 h-16 z"/>
+<path fill="none" stroke="#000000" d="M8 4 v 8 M4 8 h 8"/>
+<circle fill="yellow" stroke="red" cx="10" cy="80" r="10" />
+<ellipse fill="none" stroke="blue" stroke-width="3" cx="60" cy="60" rx="10" ry="20" />
+<line x1="10" y1="90" x2="50" y2="99"/>
+<rect fill="none" stroke="green" x="20" y="20" width="60" height="50" rx="3" ry="3"/>
+<polyline fill="red" stroke="purple" points="80,10 90,20 85,40"/>
+<polygon fill ="yellow" points="80,80 70,85 90,90"/>
+</svg>}
+ set data(bad) {<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0:w
+">
+</svg>}
+
+ tcltest::makeFile $data(plus) plus.svg
+ set data(plusFilePath) [file join [tcltest::configure -tmpdir] plus.svg]
+
+ tcltest::makeFile $data(bad) bad.svg
+ set data(badFilePath) [file join [tcltest::configure -tmpdir] bad.svg]
+
+test imgSVGnano-1.1 {reading simple image} -setup {
+ catch {rename foo ""}
+} -body {
+ image create photo foo -data $data(plus)
+ list [image width foo] [image height foo]
+} -cleanup {
+ rename foo ""
+} -result {100 100}
+
+test imgSVGnano-1.2 {simple image with options} -setup {
+ catch {rename foo ""}
+} -body {
+ image create photo foo -data $data(plus) -format {svg -dpi 100 -scale 3}
+ list [image width foo] [image height foo]
+} -cleanup {
+ rename foo ""
+} -result {300 300}
+
+# test on crash found by Koen Danckaert
+test imgSVGnano-1.3 {reformat image options} -setup {
+ catch {rename foo ""}
+} -body {
+ image create photo foo -data $data(plus)
+ catch {foo configure -format {svg -scale}}
+ list {}
+} -cleanup {
+ rename foo ""
+} -result {{}}
+
+test imgSVGnano-1.4 {image options} -setup {
+ catch {rename foo ""}
+} -body {
+ image create photo foo -data $data(plus)
+ foo configure -format {svg -scale 2}
+ foo configure -format {svg -dpi 600}
+ list [image width foo] [image height foo]
+} -cleanup {
+ rename foo ""
+} -result {100 100}
+test imgSVGnano-1.5 {reading simple image from file} -setup {
+ catch {rename foo ""}
+} -body {
+ image create photo foo -file $data(plusFilePath)
+ list [image width foo] [image height foo]
+} -cleanup {
+ rename foo ""
+} -result {100 100}
+
+test imgSVGnano-1.6 {simple image with options} -setup {
+ catch {rename foo ""}
+} -body {
+ image create photo foo -file $data(plusFilePath) -format {svg -dpi 100 -scale 3}
+ list [image width foo] [image height foo]
+} -cleanup {
+ rename foo ""
+} -result {300 300}
+test imgSVGnano-1.7 {Very small scale gives 1x1 image} -body {
+ image create photo foo -format "svg -scale 0.000001"\
+ -data $data(plus)
+ list [image width foo] [image height foo]
+} -cleanup {
+ rename foo ""
+} -result {1 1}
+test imgSVGnano-1.8 {Very small scale gives 1x1 image from file} -body {
+ image create photo foo -format "svg -scale 0.000001"\
+ -file $data(plusFilePath)
+ list [image width foo] [image height foo]
+} -cleanup {
+ rename foo ""
+} -result {1 1}
+
+test imgSVGnano-2.1 {reading a bad image} -body {
+ image create photo foo -format svg -data $data(bad)
+} -returnCodes error -result {couldn't recognize image data}
+test imgSVGnano-2.2 {using bad option} -body {
+ image create photo foo -data $data(plus) -format {svg -scale 0}
+} -returnCodes error -result {-scale value must be positive}
+test imgSVGnano-2.3 {using bad option} -body {
+ image create photo foo -data $data(plus)
+ foo configure -format {svg 1.0}
+} -cleanup {
+ rename foo ""
+} -returnCodes error -result {bad option "1.0": must be -dpi, -scale, -scaletoheight, or -scaletowidth}
+test imgSVGnano-2.4 {reading a bad image from file} -body {
+ image create photo foo -format svg -file $data(badFilePath)
+} -returnCodes error -match glob\
+ -result {couldn't recognize data in image file "*/bad.svg"}
+
+# -scaletoheight and -scaletowidth options
+test imgSVGnano-3.1 {multiple scale options} -body {
+ image create photo foo -format "svg -scale 1 -scaletowidth 20"\
+ -data $data(bad)
+} -returnCodes error -result {only one of -scale, -scaletoheight, -scaletowidth may be given}
+
+test imgSVGnano-3.2 {no number parameter to -scaletowidth} -body {
+ image create photo foo -format "svg -scaletowidth invalid"\
+ -data $data(plus)
+} -returnCodes error -result {expected integer but got "invalid"}
+
+test imgSVGnano-3.3 {no number parameter to -scaletoheight} -body {
+ image create photo foo -format "svg -scaletoheight invalid"\
+ -data $data(plus)
+} -returnCodes error -result {expected integer but got "invalid"}
+
+test imgSVGnano-3.4 {zero parameter to -scaletowidth} -body {
+ image create photo foo -format "svg -scaletowidth 0"\
+ -data $data(plus)
+} -returnCodes error -result {-scaletowidth value must be positive}
+
+test imgSVGnano-3.5 {zero parameter to -scaletoheight} -body {
+ image create photo foo -format "svg -scaletoheight 0"\
+ -data $data(plus)
+} -returnCodes error -result {-scaletoheight value must be positive}
+
+test imgSVGnano-3.6 {no number parameter to -scaletoheight} -body {
+ image create photo foo -format "svg -scaletoheight invalid"\
+ -data $data(plus)
+} -returnCodes error -result {expected integer but got "invalid"}
+
+test imgSVGnano-3.7 {Option -scaletowidth} -body {
+ image create photo foo -format "svg -scaletowidth 20"\
+ -data $data(plus)
+ image width foo
+} -cleanup {
+ rename foo ""
+} -result {20}
+
+test imgSVGnano-3.8 {Option -scaletoheight} -body {
+ image create photo foo -format "svg -scaletoheight 20"\
+ -data $data(plus)
+ image height foo
+} -cleanup {
+ rename foo ""
+} -result {20}
+
+test imgSVGnano-3.10 {change from -scaletoheight to -scale} -body {
+ set res {}
+ image create photo foo -format "svg -scaletoheight 16"\
+ -data $data(plus)
+ lappend res [image width foo] [image height foo]
+ foo configure -format "svg -scale 2"
+ lappend res [image width foo] [image height foo]
+} -cleanup {
+ rename foo ""
+ unset res
+} -result {16 16 200 200}
+
+# svg file access
+test imgSVGnano-4.1 {reread file on configure -scale} -setup {
+ catch {rename foo ""}
+ set res {}
+} -body {
+ image create photo foo -file $data(plusFilePath)
+ lappend res [image width foo] [image height foo]
+ foo configure -format "svg -scale 2"
+ lappend res [image width foo] [image height foo]
+} -cleanup {
+ rename foo ""
+ unset res
+} -result {100 100 200 200}
+
+
+test imgSVGnano-4.2 {error on file not accessible on reread due to configure} -setup {
+ catch {rename foo ""}
+ tcltest::makeFile $data(plus) tmpplus.svg
+ image create photo foo -file [file join [tcltest::configure -tmpdir] tmpplus.svg]
+ tcltest::removeFile tmpplus.svg
+} -body {
+ foo configure -format "svg -scale 2"
+} -cleanup {
+ rename foo ""
+ tcltest::removeFile tmpplus.svg
+} -returnCodes error -match glob -result {couldn't open "*/tmpplus.svg": no such file or directory}
+
+};# end of namespace svgnano
+
+namespace delete svgnano
+imageFinish
+cleanupTests
+return
+
+# Local Variables:
+# mode: tcl
+# fill-column: 78
+# End:
diff --git a/tests/listbox.test b/tests/listbox.test
index 92029de..98ec96c 100644
--- a/tests/listbox.test
+++ b/tests/listbox.test
@@ -724,7 +724,7 @@ test listbox-3.62 {ListboxWidgetCmd procedure, "index" option} -body {
} -result 18
test listbox-3.63 {ListboxWidgetCmd procedure, "index" option} -body {
.l index 34
-} -result 34
+} -result 18
test listbox-3.64 {ListboxWidgetCmd procedure, "insert" option} -body {
.l insert
} -returnCodes error -result {wrong # args: should be ".l insert index ?element ...?"}
@@ -2112,7 +2112,7 @@ test listbox-10.17 {GetListboxIndex procedure} -setup {
.l index 20
} -cleanup {
destroy .l
-} -result {20}
+} -result {12}
test listbox-10.18 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
@@ -2132,7 +2132,7 @@ test listbox-10.19 {GetListboxIndex procedure} -setup {
.l index -2
} -cleanup {
destroy .l
-} -result -2
+} -result -1
test listbox-10.20 {GetListboxIndex procedure} -setup {
destroy .l
} -body {
@@ -2143,7 +2143,7 @@ test listbox-10.20 {GetListboxIndex procedure} -setup {
.l index 1
} -cleanup {
destroy .l
-} -result 1
+} -result 0
test listbox-11.1 {ChangeListboxView procedure, boundary conditions for index} -setup {
@@ -2209,6 +2209,7 @@ test listbox-11.5 {ChangeListboxView procedure} -setup {
} -body {
listbox .l -height 5 -yscrollcommand "record y"
pack .l
+ update
.l insert 0 a b c d e f g h i j
.l yview 3
update
@@ -2662,10 +2663,11 @@ test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} -setup
destroy .l
} -body {
catch {unset x}
- set log {}
listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x
+ set log {}
pack .l
- update
+ set timeout [after 500 {set log timeout}]
+ vwait log
lappend x "0000000000"
update
lappend x "00000000000000000000"
@@ -2673,15 +2675,17 @@ test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} -setup
set log
} -cleanup {
destroy .l
+ after cancel $timeout
} -result [list {x 0 1} {x 0 1} {x 0 0.5}]
test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} -setup {
destroy .l
} -body {
catch {unset x}
- set log {}
listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x
+ set log {}
pack .l
- update
+ set timeout [after 500 {set log timeout}]
+ vwait log
lappend x "0000000000"
update
lappend x "00000000000000000000"
@@ -2691,6 +2695,7 @@ test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} -setu
set log
} -cleanup {
destroy .l
+ after cancel timeout
} -result [list {x 0 1} {x 0 1} {x 0 0.5} {x 0 1}]
test listbox-21.11 {ListboxListVarProc, bad list} -setup {
destroy .l
@@ -2755,15 +2760,19 @@ test listbox-21.15 {ListboxListVarProc, update vertical scrollbar} -setup {
destroy .l
} -body {
catch {unset x}
+ listbox .l -font $fixed -height 3 -yscrollcommand "record y" -listvar x
+ update
set log {}
- listbox .l -listvar x -yscrollcommand "record y" -font fixed -height 3
pack .l
+ set timeout [after 500 {set log timeout}]
+ vwait log
update
lappend x a b c d e f
- update
+ vwait log
set log
} -cleanup {
destroy .l
+ after cancel $timeout
} -result [list {y 0 1} {y 0 0.5}]
test listbox-21.16 {ListboxListVarProc, update vertical scrollbar} -setup {
destroy .l
@@ -2771,7 +2780,6 @@ test listbox-21.16 {ListboxListVarProc, update vertical scrollbar} -setup {
catch {unset x}
listbox .l -listvar x -height 3
pack .l
- update
set x [list 0 1 2 3 4 5]
.l yview scroll 3 units
update
@@ -2792,17 +2800,19 @@ test listbox-21.16 {ListboxListVarProc, update vertical scrollbar} -setup {
test listbox-22.1 {UpdateHScrollbar} -setup {
destroy .l
} -body {
- set log {}
listbox .l -font $fixed -width 10 -xscrollcommand "record x"
+ set log {}
pack .l
- update
+ set timeout [after 500 {set log timeout}]
+ vwait log
.l insert end "0000000000"
update
.l insert end "00000000000000000000"
- update
+ vwait log
set log
} -cleanup {
destroy .l
+ after cancel $timeout
} -result [list {x 0 1} {x 0 1} {x 0 0.5}]
@@ -3146,7 +3156,7 @@ test listbox-31.1 {<<ListboxSelect>> event} -setup {
bind .l <<ListboxSelect>> {lappend res [%W curselection]}
.l insert end a b c
focus -force .l
- event generate .l <1> -x 5 -y 5 ; # <<ListboxSelect>> fires
+ event generate .l <Button-1> -x 5 -y 5 ; # <<ListboxSelect>> fires
.l configure -state disabled
focus -force .l
event generate .l <Control-Home> ; # <<ListboxSelect>> does NOT fire
@@ -3169,7 +3179,7 @@ test listbox-31.2 {<<ListboxSelect>> event on lost selection} -setup {
bind .l <<ListboxSelect>> {lappend res [list [selection own] [%W curselection]]}
.l insert end a b c
focus -force .l
- event generate .l <1> -x 5 -y 5 ; # <<ListboxSelect>> fires
+ event generate .l <Button-1> -x 5 -y 5 ; # <<ListboxSelect>> fires
selection clear ; # <<ListboxSelect>> fires again
update
set res
@@ -3177,6 +3187,33 @@ test listbox-31.2 {<<ListboxSelect>> event on lost selection} -setup {
destroy .l
} -result {{.l 0} {{} {}}}
+test listbox-32.1 {Bug [5d991b822e]} {
+ # Want this not to segfault, or write to variable with empty name
+ set var INIT
+ listbox .b -listvariable var
+ trace add variable var unset {apply {args {
+ .b configure -listvariable {}
+ }}}
+ pack .b
+ bind .b <Configure> {unset var}
+ update
+ destroy .b
+ info exists {}
+} 0
+test listbox-32.2 {Bug [5d991b822e]} {
+ # Want this not to leak traces
+ set var INIT
+ listbox .b -listvariable var
+ trace add variable var unset {apply {args {
+ .b configure -listvariable new
+ }}}
+ pack .b
+ bind .b <Configure> {unset -nocomplain var}
+ update
+ destroy .b
+ unset new
+} {}
+
resetGridInfo
deleteWindows
option clear
diff --git a/tests/menu.test b/tests/menu.test
index 87d8a9e..5d4884c 100644
--- a/tests/menu.test
+++ b/tests/menu.test
@@ -29,7 +29,7 @@ test menu-1.4 {Tk_MenuCmd procedure} -body {
destroy .m1
menu .m1
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.m1}
test menu-1.5 {Tk_MenuCmd - creating menubar} -setup {
destroy .m1
@@ -38,19 +38,19 @@ test menu-1.5 {Tk_MenuCmd - creating menubar} -setup {
.m1 add cascade -label Test -menu ""
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-1.6 {Tk_MenuCmd procedure menu ref no cascade} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t2 -menu .m1
wm geometry .t2 +0+0
menu .m1
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.m1}
test menu-1.7 {Tk_MenuCmd procedure one clone cascade} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t2 -menu .m1
wm geometry .t2 +0+0
@@ -58,10 +58,10 @@ test menu-1.7 {Tk_MenuCmd procedure one clone cascade} -setup {
.m1 add cascade -menu .m2
menu .m2
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.m2}
test menu-1.8 {Tk_MenuCmd procedure two clone cascades} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add cascade -menu .m2
@@ -71,10 +71,10 @@ test menu-1.8 {Tk_MenuCmd procedure two clone cascades} -setup {
wm geometry .t3 +0+0
menu .m2
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.m2}
test menu-1.9 {Tk_MenuCmd procedure two clone cascades different order} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t2 -menu .m1
wm geometry .t2 +0+0
@@ -84,10 +84,10 @@ test menu-1.9 {Tk_MenuCmd procedure two clone cascades different order} -setup {
wm geometry .t3 +0+0
list [menu .m2]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.m2}
test menu-1.10 {Tk_MenuCmd procedure two clone cascades menus last} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t2 -menu .m1
wm geometry .t2 +0+0
@@ -97,10 +97,10 @@ test menu-1.10 {Tk_MenuCmd procedure two clone cascades menus last} -setup {
.m1 add cascade -menu .m2
list [menu .m2]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.m2}
test menu-1.11 {Tk_MenuCmd procedure three clones cascades} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t2 -menu .m1
wm geometry .t2 +0+0
@@ -112,19 +112,19 @@ test menu-1.11 {Tk_MenuCmd procedure three clones cascades} -setup {
.m1 add cascade -menu .m2
list [menu .m2]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.m2}
test menu-1.12 {Tk_MenuCmd procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t2 -menu .m1
wm geometry .t2 +0+0
list [menu .m1]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.m1}
test menu-1.13 {Tk_MenuCmd procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t2 -menu .m1
wm geometry .t2 +0+0
@@ -132,10 +132,10 @@ test menu-1.13 {Tk_MenuCmd procedure} -setup {
wm geometry .t3 +0+0
list [menu .m1]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.m1}
test menu-1.14 {Tk_MenuCmd procedure} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .t2 -menu .m1
wm geometry .t2 +0+0
@@ -145,7 +145,7 @@ test menu-1.14 {Tk_MenuCmd procedure} -setup {
wm geometry .t4 +0+0
list [menu .m1]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.m1}
# Used for 2.1 - 2.30 tests
@@ -1821,7 +1821,7 @@ test menu-3.67 {MenuWidgetCmd procedure, bad option} -setup {
destroy .m1
} -returnCodes error -result {bad option "foo": must be activate, add, cget, clone, configure, delete, entrycget, entryconfigure, index, insert, invoke, post, postcascade, type, unpost, xposition, or yposition}
test menu-3.68 {MenuWidgetCmd procedure, fix for bug#508988} -setup {
- deleteWindows
+ deleteWindows
} -body {
set t .t
set m1 .t.m1
@@ -1839,7 +1839,7 @@ test menu-3.68 {MenuWidgetCmd procedure, fix for bug#508988} -setup {
$t configure -menu ""
list [winfo exists $c1] [winfo exists $c2]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {1 1}
test menu-3.69 {MenuWidgetCmd procedure, "xposition" option} -setup {
destroy .m1
@@ -1877,7 +1877,7 @@ test menu-4.2 {TkInvokeMenu: tearoff} -setup {
menu .m1
catch {.m1 invoke 0}
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {0}
test menu-4.3 {TkInvokeMenu: checkbutton -on} -setup {
destroy .m1
@@ -2034,7 +2034,7 @@ test menu-5.5 {DestroyMenuInstance - cascades of cloned menus} -setup {
list [destroy .m2] [.m1 entrycget 1 -menu] [. configure -menu ""] [destroy .m1]
} -returnCodes ok -result {{} .m2 {} {}}
test menu-5.6 {DestroyMenuInstance - cascades of cloned menus} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add cascade -menu .m2
@@ -2130,7 +2130,7 @@ test menu-6.4 {TkDestroyMenu - reentrancy - clones} -setup {
.m1 clone .m1.m3
destroy .m1
} -cleanup {
- deleteWindows
+ deleteWindows
} -returnCodes ok
test menu-6.5 {TkDestroyMenu} -setup {
destroy .m1 .m2
@@ -2271,7 +2271,7 @@ test menu-7.4 {UnhookCascadeEntry} -setup {
list [destroy .m1] [destroy .m2]
} -returnCodes ok -result {{} {}}
test menu-7.5 {UnhookCascadeEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
menu .m2
@@ -2282,7 +2282,7 @@ test menu-7.5 {UnhookCascadeEntry} -setup {
list [destroy .m1] [destroy .m2 .m3]
} -returnCodes ok -result {{} {}}
test menu-7.6 {UnhookCascadeEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
menu .m2
@@ -2293,7 +2293,7 @@ test menu-7.6 {UnhookCascadeEntry} -setup {
list [destroy .m2] [destroy .m1 .m3]
} -returnCodes ok -result {{} {}}
test menu-7.7 {UnhookCascadeEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
menu .m2
@@ -2304,7 +2304,7 @@ test menu-7.7 {UnhookCascadeEntry} -setup {
list [destroy .m3] [destroy .m1 .m2]
} -returnCodes ok -result {{} {}}
test menu-7.8 {UnhookCascadeEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
menu .m2
@@ -2375,7 +2375,7 @@ test menu-8.6 {DestroyMenuEntry} -setup {
list [.m1 delete 1] [.m1 entrycget 1 -label] [destroy .m1]
} -result {{} two {}}
test menu-8.7 {DestroyMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "one"
@@ -2392,7 +2392,7 @@ test menu-9.1 {ConfigureMenu} -setup {
menu .m1
list [.m1 configure -postcommand "beep"] [.m1 cget -postcommand]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} beep}
test menu-9.2 {ConfigureMenu} -setup {
destroy .m1
@@ -2401,7 +2401,7 @@ test menu-9.2 {ConfigureMenu} -setup {
.m1 add command -label "test"
list [.m1 configure -tearoff 0] [.m1 entrycget 1 -label]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} test}
test menu-9.3 {ConfigureMenu} -setup {
destroy .m1
@@ -2409,7 +2409,7 @@ test menu-9.3 {ConfigureMenu} -setup {
menu .m1
list [.m1 configure -postcommand "beep"] [.m1 cget -postcommand]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} beep}
test menu-9.4 {ConfigureMenu} -setup {
destroy .m1
@@ -2418,7 +2418,7 @@ test menu-9.4 {ConfigureMenu} -setup {
.m1 add command -label "test"
.m1 configure -fg red
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-9.5 {ConfigureMenu} -setup {
destroy .m1
@@ -2428,7 +2428,7 @@ test menu-9.5 {ConfigureMenu} -setup {
.m1 add command -label "two"
.m1 configure -fg red
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-9.6 {ConfigureMenu} -setup {
destroy .m1
@@ -2439,25 +2439,25 @@ test menu-9.6 {ConfigureMenu} -setup {
.m1 add command -label "three"
.m1 configure -fg red
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-9.7 {ConfigureMenu} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 clone .m2 tearoff
list [.m1 configure -fg red] [.m2 cget -fg]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} red}
test menu-9.8 {ConfigureMenu} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 clone .m2 tearoff
list [.m2 configure -fg red] [.m1 cget -fg]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} red}
test menu-9.9 {ConfigureMenu} -setup {
destroy .m1
@@ -2465,7 +2465,7 @@ test menu-9.9 {ConfigureMenu} -setup {
menu .m1
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
@@ -2478,7 +2478,7 @@ test menu-10.1 {PostProcessEntry: array variable} -setup {
.m1 add checkbutton -variable foo(1) -onvalue on -offvalue off -label "Nonsense"
set foo(1)
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {on}
test menu-10.2 {PostProcessEntry: array variable} -setup {
destroy .m1
@@ -2488,7 +2488,7 @@ test menu-10.2 {PostProcessEntry: array variable} -setup {
.m1 add checkbutton -variable foo(1) -onvalue on -offvalue off -label "Nonsense"
set foo(1)
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {off}
@@ -2500,7 +2500,7 @@ test menu-11.1 {ConfigureMenuEntry} -setup {
.m1 add checkbutton -variable foo -onvalue on -offvalue off -label "Nonsense"
list [.m1 entryconfigure 1 -variable bar] [.m1 entrycget 1 -variable]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} bar}
test menu-11.2 {ConfigureMenuEntry} -setup {
destroy .m1
@@ -2509,7 +2509,7 @@ test menu-11.2 {ConfigureMenuEntry} -setup {
.m1 add command -label "test"
list [.m1 entryconfigure 1 -label ""] [.m1 entrycget 1 -label]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-11.3 {ConfigureMenuEntry} -setup {
destroy .m1
@@ -2518,83 +2518,83 @@ test menu-11.3 {ConfigureMenuEntry} -setup {
.m1 add command
list [.m1 entryconfigure 1 -label "test"] [.m1 entrycget 1 -label]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} test}
test menu-11.4 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command
list [.m1 entryconfigure 1 -accel "S"] [.m1 entrycget 1 -accel]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} S}
test menu-11.5 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command
list [.m1 entryconfigure 1 -label "test"] [.m1 entrycget 1 -label]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} test}
test menu-11.6 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command
.m1 entryconfigure 1 -label "test"
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-11.7 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m2
menu .m1
.m1 add cascade
.m1 entryconfigure 1 -label "test" -menu .m2
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-11.8 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add cascade
.m1 entryconfigure 1 -label "test" -menu .m2
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-11.9 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add cascade -menu .m3
.m1 entryconfigure 1 -label "test" -menu .m2
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-11.10 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add cascade
.m1 entryconfigure 1 -label "test" -menu .m2
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-11.11 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add cascade -menu .m2
.m1 entryconfigure 1 -label "test" -menu .m2
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-11.12 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
menu .m2
@@ -2607,10 +2607,10 @@ test menu-11.12 {ConfigureMenuEntry} -setup {
.m5 add cascade
.m5 entryconfigure 1 -label "test" -menu .m1
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-11.13 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
menu .m2
@@ -2621,32 +2621,32 @@ test menu-11.13 {ConfigureMenuEntry} -setup {
.m4 add cascade -menu .m1
.m3 entryconfigure 1 -label "test" -menu .m1
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-11.14 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add checkbutton
list [.m1 entryconfigure 1 -variable "test"] [.m1 entrycget 1 -variable]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} test}
test menu-11.15 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
list [.m1 add checkbutton -label "test"] [.m1 entrycget 1 -variable]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} test}
test menu-11.16 {ConfigureMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add radiobutton -label "test"
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-11.17 {ConfigureMenuEntry} -setup {
deleteWindows
@@ -2852,35 +2852,35 @@ test menu-13.8 {TkGetMenuIndex} -setup {
.m1 entrycget -1 -label
} -returnCodes error -result {bad menu entry index "-1"}
test menu-13.9 {TkGetMenuIndex} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
.m1 add command -label "test2"
.m1 entrycget 999 -label
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {test2}
test menu-13.10 {TkGetMenuIndex} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 insert 999 command -label "test"
.m1 entrycget 1 -label
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {test}
test menu-13.11 {TkGetMenuIndex} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "1test"
.m1 entrycget 1test -label
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {1test}
test menu-13.12 {TkGetMenuIndex} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
@@ -2888,176 +2888,176 @@ test menu-13.12 {TkGetMenuIndex} -setup {
.m1 add command -label "test3"
.m1 entrycget test2 -command
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {beep}
test menu-14.1 {MenuCmdDeletedProc} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
destroy .m1
} -cleanup {
- deleteWindows
+ deleteWindows
} -returnCodes ok
test menu-14.2 {MenuCmdDeletedProc} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 clone .m2
destroy .m1
} -cleanup {
- deleteWindows
+ deleteWindows
} -returnCodes ok
test menu-15.1 {MenuNewEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-15.2 {MenuNewEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
.m1 add command -label "test3"
.m1 insert 2 command -label "test2"
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-15.3 {MenuNewEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
.m1 add command -label "test2"
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-15.4 {MenuNewEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-16.1 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 insert foo command -label "test"
} -returnCodes error -result {bad menu entry index "foo"}
test menu-16.2 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
.m1 insert test command -label "foo"
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-16.3 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 insert -1 command -label "test"
} -returnCodes error -result {bad menu entry index "-1"}
test menu-16.4 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1 -tearoff 1
.m1 add command -label "test"
.m1 insert 0 command -label "test2"
.m1 entrycget 1 -label
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {test2}
test menu-16.5 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add cascade
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-16.6 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add checkbutton
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-16.7 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-16.8 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add radiobutton
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-16.9 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add separator
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-16.10 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add blork
} -returnCodes error -result {bad menu entry type "blork": must be cascade, checkbutton, command, radiobutton, or separator}
test menu-16.11 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-16.12 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 clone .m2
.m2 clone .m3
list [.m2 add command -label "test"] [.m1 entrycget 1 -label] [.m3 entrycget 1 -label]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} test test}
test menu-16.13 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 clone .m2
.m2 clone .m3
list [.m3 add command -label "test"] [.m1 entrycget 1 -label] [.m2 entrycget 1 -label]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} test test}
test menu-16.14 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -blork
} -returnCodes error -result {unknown option "-blork"}
test menu-16.15 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "File"
@@ -3065,20 +3065,20 @@ test menu-16.15 {MenuAddOrInsert} -setup {
. configure -menu .container
list [.container add cascade -label "File" -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-16.16 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
menu .m2
set tearoff [tk::TearOffMenu .m2]
list [.m2 add cascade -menu .m1] [$tearoff unpost]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-16.17 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
menu .container
@@ -3086,10 +3086,10 @@ test menu-16.17 {MenuAddOrInsert} -setup {
set tearoff [tk::TearOffMenu .container]
list [.container add cascade -label "File" -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-16.18 {MenuAddOrInsert} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
menu .container
@@ -3097,10 +3097,10 @@ test menu-16.18 {MenuAddOrInsert} -setup {
. configure -menu .container
list [.container add cascade -label "File" -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-16.19 {MenuAddOrInsert - Insert a cascade deep into the tree} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .menubar
menu .menubar.test -tearoff 0
@@ -3113,12 +3113,12 @@ test menu-16.19 {MenuAddOrInsert - Insert a cascade deep into the tree} -setup {
[info commands .\#menubar.\#menubar\#test.\#menubar\#test\#cascade] \
[. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {0 .#menubar.#menubar#test.#menubar#test#cascade {}}
test menu-17.1 {MenuVarProc} -setup {
- deleteWindows
+ deleteWindows
} -body {
catch {unset foo}
menu .m1
@@ -3126,21 +3126,21 @@ test menu-17.1 {MenuVarProc} -setup {
list [.m1 add checkbutton -variable foo -onvalue hello -offvalue goodbye] \
[unset foo]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
# menu-17.2 - Don't know how to generate the flags in the if
test menu-17.2 {MenuVarProc} -setup {
- deleteWindows
+ deleteWindows
} -body {
catch {unset foo}
menu .m1
list [.m1 add checkbutton -variable foo -onvalue hello -offvalue goodbye] \
[set foo ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-17.3 {MenuVarProc} -setup {
- deleteWindows
+ deleteWindows
} -body {
catch {unset foo}
menu .m1
@@ -3148,50 +3148,78 @@ test menu-17.3 {MenuVarProc} -setup {
list [.m1 add checkbutton -variable foo -onvalue hello -offvalue goodbye] \
[set foo "hello"] [unset foo]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} hello {}}
test menu-17.4 {MenuVarProc} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
set foo "goodbye"
list [.m1 add checkbutton -variable foo -onvalue hello -offvalue goodbye] \
[set foo "hello"] [unset foo]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} hello {}}
test menu-17.5 {MenuVarProc} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
set foo "hello"
list [.m1 add checkbutton -variable foo -onvalue hello -offvalue goodbye] \
[set foo "goodbye"] [unset foo]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} goodbye {}}
+test menu-17.6 {MenuVarProc [5d991b822e]} -setup {
+ deleteWindows
+} -body {
+ # Want this not to crash
+ menu .b
+ set var INIT
+ .b add checkbutton -variable var
+ trace add variable var unset {apply {args {
+ .b entryconfigure 1 -variable {}
+ }}}
+ unset var
+} -cleanup {
+ deleteWindows
+} -result {}
+test menu-17.7 {MenuVarProc [5d991b822e]} -setup {
+ deleteWindows
+} -body {
+ # Want this not to duplicate traces
+ menu .b
+ set var INIT
+ .b add checkbutton -variable var
+ trace add variable var unset {apply {args {
+ .b entryconfigure 1 -variable new
+ }}}
+ unset var
+} -cleanup {
+ deleteWindows
+} -result {}
test menu-18.1 {TkActivateMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
.m1 activate 1
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-18.2 {TkActivateMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
.m1 activate 0
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-18.3 {TkActivateMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
@@ -3199,10 +3227,10 @@ test menu-18.3 {TkActivateMenuEntry} -setup {
.m1 activate 1
.m1 activate 2
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-18.4 {TkActivateMenuEntry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
@@ -3210,112 +3238,112 @@ test menu-18.4 {TkActivateMenuEntry} -setup {
.m1 activate 1
.m1 activate 1
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-19.1 {TkPostCommand} -constraints nonUnixUserInteraction -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1 -postcommand "set menu_test menu-19.1"
.m1 add command -label "menu-19.1 - hit Escape"
list [.m1 post 40 40] [.m1 unpost] [set menu_test]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {menu-19.1 {} menu-19.1}
test menu-19.2 {TkPostCommand} -constraints nonUnixUserInteraction -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "menu-19.2 - hit Escape"
list [.m1 post 40 40] [.m1 unpost]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-20.1 {CloneMenu} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 clone .m2]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-20.2 {CloneMenu} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 clone .m2 normal
- deleteWindows
+ deleteWindows
} -result {}
test menu-20.3 {CloneMenu} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 clone .m2 tearoff
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-20.4 {CloneMenu} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 clone .m2 menubar
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-20.5 {CloneMenu} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 clone .m2 foo
} -returnCodes error -result {bad menu type "foo": must be normal, tearoff, or menubar}
test menu-20.6 {CloneMenu - hooking up bookeeping ptrs} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 clone .m2
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-20.7 {CloneMenu - hooking up bookeeping ptrs - multiple children} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 clone .m2
.m1 clone .m3
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-20.8 {CloneMenu - cascade entries} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add cascade -menu .m2
.m1 clone .foo
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-20.9 {CloneMenu - cascades entries} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add cascade -menu .m2
menu .m2
.m1 clone .foo
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-20.10 {CloneMenu - tearoff fields} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1 -tearoff 1
list [.m1 clone .m2 normal] [.m2 cget -tearoff]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} 1}
test menu-20.11 {CloneMenu} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
menu .m2
@@ -3323,43 +3351,43 @@ test menu-20.11 {CloneMenu} -setup {
} -returnCodes error -result {window name "m2" already exists in parent}
test menu-21.1 {MenuDoYPosition} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 yposition glorp
} -returnCodes error -result {bad menu entry index "glorp"}
test menu-21.2 {MenuDoYPosition} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "Test"
.m1 yposition 1
} -cleanup {
- deleteWindows
+ deleteWindows
} -returnCodes ok -match glob -result {*}
test menu-22.1 {GetIndexFromCoords} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
.m1 configure -tearoff 0
.m1 index @5
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {0}
test menu-22.2 {GetIndexFromCoords} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label "test"
.m1 configure -tearoff 0
.m1 index @5,5
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {0}
test menu-22.3 {GetIndexFromCoords: mapped window, y only} -setup {
- deleteWindows
+ deleteWindows
} -constraints {x11} -body {
menu .m1
.m1 add command -label "test"
@@ -3368,10 +3396,10 @@ test menu-22.3 {GetIndexFromCoords: mapped window, y only} -setup {
tkwait visibility .m1
.m1 index @5
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {0}
test menu-22.4 {GetIndexFromCoords: mapped window x,y} -setup {
- deleteWindows
+ deleteWindows
} -constraints {x11} -body {
menu .m1
.m1 add command -label "test"
@@ -3382,10 +3410,10 @@ test menu-22.4 {GetIndexFromCoords: mapped window x,y} -setup {
set x [expr {[winfo width .m1] - [.m1 cget -borderwidth] - 1}]
.m1 index @$x,5
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {0}
test menu-22.5 {GetIndexFromCoords: mapped wide window} -setup {
- deleteWindows
+ deleteWindows
} -constraints {x11} -body {
menu .m1
.m1 add command -label "test"
@@ -3397,20 +3425,20 @@ test menu-22.5 {GetIndexFromCoords: mapped wide window} -setup {
set x [expr {[winfo width .m1] - [.m1 cget -borderwidth] - 1}]
.m1 index @$x,5
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {0}
test menu-23.1 {RecursivelyDeleteMenu} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
. configure -menu .m1
. configure -menu ""
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-23.2 {RecursivelyDeleteMenu} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m2
.m2 add command -label "test2"
@@ -3419,28 +3447,28 @@ test menu-23.2 {RecursivelyDeleteMenu} -setup {
. configure -menu .m1
. configure -menu ""
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-24.1 {TkNewMenuName} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-24.2 {TkNewMenuName} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
menu .m1\#0
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-24.3 {TkNewMenuName} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .#m
rename .#m hideme
@@ -3450,33 +3478,33 @@ test menu-24.3 {TkNewMenuName} -setup {
test menu-25.1 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.2 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.3 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
destroy .m1
menu .m1
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.4 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
@@ -3484,10 +3512,10 @@ test menu-25.4 {TkSetWindowMenuBar} -setup {
menu .m2
list [. configure -menu .m2] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.5 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
@@ -3496,10 +3524,10 @@ test menu-25.5 {TkSetWindowMenuBar} -setup {
menu .m3
list [. configure -menu .m3] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.6 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
@@ -3508,10 +3536,10 @@ test menu-25.6 {TkSetWindowMenuBar} -setup {
menu .m3
list [. configure -menu .m3] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.7 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
@@ -3521,10 +3549,10 @@ test menu-25.7 {TkSetWindowMenuBar} -setup {
.t2 configure -menu .m1
list [.t2 configure -menu .m2] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.8 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
@@ -3535,10 +3563,10 @@ test menu-25.8 {TkSetWindowMenuBar} -setup {
.t2 configure -menu .m1
list [. configure -menu .m2] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.9 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
@@ -3550,10 +3578,10 @@ test menu-25.9 {TkSetWindowMenuBar} -setup {
wm geometry .t3 +0+0
list [.t3 configure -menu .m2] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.10 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
@@ -3565,10 +3593,10 @@ test menu-25.10 {TkSetWindowMenuBar} -setup {
wm geometry .t3 +0+0
list [.t2 configure -menu .m2] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.11 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
@@ -3580,57 +3608,57 @@ test menu-25.11 {TkSetWindowMenuBar} -setup {
wm geometry .t3 +0+0
list [. configure -menu .m2] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.12 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.13 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.14 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.15 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-25.16 {TkSetWindowMenuBar} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
. configure -menu .m1
list [toplevel .t2 -menu m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.t2 {}}
test menu-26.1 {DestroyMenuHashTable} -setup {
catch {interp delete testinterp}
- deleteWindows
+ deleteWindows
} -body {
interp create testinterp
load {} Tk testinterp
@@ -3641,48 +3669,48 @@ test menu-26.1 {DestroyMenuHashTable} -setup {
test menu-27.1 {GetMenuHashTable} -setup {
catch {interp delete testinterp}
- deleteWindows
+ deleteWindows
} -body {
interp create testinterp
load {} Tk testinterp
list [catch {interp eval testinterp {menu .m1}} msg] $msg [interp delete testinterp]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {0 .m1 {}}
test menu-28.1 {TkCreateMenuReferences - not there before} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.m1}
test menu-28.2 {TkCreateMenuReferences - there already} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add cascade -menu .m2
menu .m2
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.m2}
test menu-29.1 {TkFindMenuReferences - not there} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
.m1 add cascade -menu .m2
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-30.1 {TkFindMenuReferences - there already} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
@@ -3690,38 +3718,38 @@ test menu-30.1 {TkFindMenuReferences - there already} -setup {
.m1 add cascade -menu .m2
list [. configure -menu .m1] [. configure -menu ""]
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {{} {}}
test menu-31.1 {TkFreeMenuReferences - menuPtr} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
destroy .m1
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-31.2 {TkFreeMenuReferences - cascadePtr} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu ""
menu .m1
.m1 add cascade -menu .m2
.m1 entryconfigure 1 -menu .m3
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-31.3 {TkFreeMenuReferences - topLevelListPtr} -setup {
- deleteWindows
+ deleteWindows
} -body {
. configure -menu .m1
. configure -menu ""
} -cleanup {
- deleteWindows
+ deleteWindows
} -returnCodes ok -result {}
test menu-31.4 {TkFreeMenuReferences - not empty} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add cascade -menu .m3
@@ -3729,22 +3757,22 @@ test menu-31.4 {TkFreeMenuReferences - not empty} -setup {
.m2 add cascade -menu .m3
.m2 entryconfigure 1 -menu ".foo"
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-32.1 {DeleteMenuCloneEntries} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label foo
.m1 clone .m2
.m1 delete 1
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-32.2 {DeleteMenuCloneEntries} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
@@ -3755,10 +3783,10 @@ test menu-32.2 {DeleteMenuCloneEntries} -setup {
.m1 clone .m2
.m1 delete 2 3
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-32.3 {DeleteMenuCloneEntries} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1 -tearoff 0
.m1 add command -label one
@@ -3769,10 +3797,10 @@ test menu-32.3 {DeleteMenuCloneEntries} -setup {
.m2 configure -tearoff 1
.m1 delete 1 2
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-32.4 {DeleteMenuCloneEntries} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label one
@@ -3783,10 +3811,10 @@ test menu-32.4 {DeleteMenuCloneEntries} -setup {
.m2 configure -tearoff 0
.m1 delete 2 3
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-32.5 {DeleteMenuCloneEntries} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label one
@@ -3795,29 +3823,29 @@ test menu-32.5 {DeleteMenuCloneEntries} -setup {
.m1 activate one
.m1 delete one
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-32.6 {DeleteMenuCloneEntries - reentrancy - crashes tk8.0} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1
.m1 add command -label test \
-command ".m1 delete test ; .m1 add command -label test -command \".m1 delete test\"; .m1 delete test"
.m1 invoke test
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-32.7 {DeleteMenuCloneEntries - one entry} -setup {
- deleteWindows
+ deleteWindows
} -body {
menu .m1 -tearoff 0
.m1 add command -label Hello
.m1 delete Hello
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-32.8 {Ensure all menu clone commands are deleted} -setup {
- deleteWindows
+ deleteWindows
} -body {
# SF bug #465324
menu .menubar
@@ -3831,11 +3859,11 @@ test menu-32.8 {Ensure all menu clone commands are deleted} -setup {
info commands .#menubar*test*
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-32.9 {Ensure deleting of clones doesn't corrupt menu refs} -setup {
set res {}
- deleteWindows
+ deleteWindows
} -body {
menu .menubar
. configure -menu .menubar
@@ -3853,12 +3881,12 @@ test menu-32.9 {Ensure deleting of clones doesn't corrupt menu refs} -setup {
lappend res [.#menubar.#menubar#test entrycget 1 -menu]
return $res
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {.menubar.cascade .#menubar.#menubar#test.#menubar#cascade .menubar.cascade .#menubar.#menubar#test.#menubar#cascade}
test menu-33.1 {menu vs command hiding} -setup {
- deleteWindows
+ deleteWindows
} -body {
set l [interp hidden]
menu .m
@@ -3876,7 +3904,7 @@ test menu-33.1 {menu vs command hiding} -setup {
test menu-34.1 {menus on multiple screens - crashes tk8.3.1, Bug 5454} -constraints {
altDisplay
} -setup {
- deleteWindows
+ deleteWindows
} -body {
toplevel .one
menu .one.m
@@ -3896,7 +3924,7 @@ test menu-35.1 {menu -underline string overruns Bug 1599877} -setup {
update
tk::TraverseToMenu . "e"
} -cleanup {
- deleteWindows
+ deleteWindows
} -result {}
test menu-37.1 {menubar menues cannot be posted - bug 2160206} -setup {
@@ -3921,14 +3949,14 @@ test menu-38.1 {Can't dismiss ttk::menubutton menu until mouse has hovered over
pack .top.mb
update
# simulate mouse click on the menubutton, which posts its menu
- event generate .top.mb <ButtonPress-1> -warp 1
+ event generate .top.mb <Button-1> -warp 1
update
after 50
event generate .top.mb <ButtonRelease-1>
update
# simulate mouse click on the menu again, i.e. without
# entering/leaving the posted menu
- event generate .top.mb <ButtonPress-1>
+ event generate .top.mb <Button-1>
update
after 50
event generate .top.mb <ButtonRelease-1>
diff --git a/tests/menuDraw.test b/tests/menuDraw.test
index ec9dae5..9382974 100644
--- a/tests/menuDraw.test
+++ b/tests/menuDraw.test
@@ -20,7 +20,7 @@ test menuDraw-1.1 {TkMenuInitializeDrawingFields} -setup {
} -result {.m1}
-test menuDraw-2.1 {TkIntializeMenuEntryDrawingFields} -setup {
+test menuDraw-2.1 {TkInitializeMenuEntryDrawingFields} -setup {
deleteWindows
} -body {
menu .m1
diff --git a/tests/menubut.test b/tests/menubut.test
index a9d0656..d245fd0 100644
--- a/tests/menubut.test
+++ b/tests/menubut.test
@@ -751,6 +751,35 @@ test menubutton-8.1 {menubutton vs hidden commands} -body {
expr {$res1 eq $res2}
} -result 1
+test menubutton-9.1 {Bug [5d991b822e]} {
+ # Want this not to segfault, or write to variable with empty name
+ unset -nocomplain {}
+ set var INIT
+ menubutton .b -textvariable var
+ trace add variable var unset {apply {args {
+ .b configure -textvariable {}
+ }}}
+ pack .b
+ bind .b <Configure> {unset var}
+ update
+ destroy .b
+ info exists {}
+} 0
+test menubutton-9.2 {Bug [5d991b822e]} {
+ # Want this not to leak traces
+ set var INIT
+ menubutton .b -textvariable var
+ trace add variable var unset {apply {args {
+ .b configure -textvariable new
+ }}}
+ pack .b
+ bind .b <Configure> {unset -nocomplain var}
+ update
+ destroy .b
+ unset new
+} {}
+
+
deleteWindows
diff --git a/tests/message.test b/tests/message.test
index e25bbee..2ca6921 100644
--- a/tests/message.test
+++ b/tests/message.test
@@ -470,5 +470,33 @@ test message-3.7 {MessageWidgetObjCmd procedure, "configure"} -setup {
destroy .m
} -result {4}
+test message-4.1 {Bug [5d991b822e]} {
+ # Want this not to segfault, or write to variable with empty name
+ unset -nocomplain {}
+ set var INIT
+ message .b -textvariable var
+ trace add variable var unset {apply {args {
+ .b configure -textvariable {}
+ }}}
+ pack .b
+ bind .b <Configure> {unset var}
+ update
+ destroy .b
+ info exists {}
+} 0
+test message-4.2 {Bug [5d991b822e]} {
+ # Want this not to leak traces
+ set var INIT
+ message .b -textvariable var
+ trace add variable var unset {apply {args {
+ .b configure -textvariable new
+ }}}
+ pack .b
+ bind .b <Configure> {unset -nocomplain var}
+ update
+ destroy .b
+ unset new
+} {}
+
cleanupTests
return
diff --git a/tests/msgbox.test b/tests/msgbox.test
index 4a6de57..8fd0dae 100644
--- a/tests/msgbox.test
+++ b/tests/msgbox.test
@@ -94,7 +94,7 @@ proc ChooseMsgByKey {parent btn} {
proc PressButton {btn} {
event generate $btn <Enter>
- event generate $btn <ButtonPress-1> -x 5 -y 5
+ event generate $btn <Button-1> -x 5 -y 5
event generate $btn <ButtonRelease-1> -x 5 -y 5
}
@@ -113,7 +113,7 @@ proc SendEventToMsg {parent btn type} {
event generate $w <Enter>
focus $w
event generate $w.$btn <Enter>
- event generate $w <KeyPress> -keysym Return
+ event generate $w <Key> -keysym Return
}
}
#
diff --git a/tests/pack.test b/tests/pack.test
index 9d5964c..4a41516 100644
--- a/tests/pack.test
+++ b/tests/pack.test
@@ -965,6 +965,27 @@ test pack-10.4 {bad -in window does not change master} -setup {
winfo manager .pack.a
pack .pack.a -in .pack.a
} -returnCodes error -result {can't pack .pack.a inside itself}
+test pack-10.5 {prevent management loops} -body {
+ frame .f1
+ frame .f2
+ pack .f1 -in .f2
+ pack .f2 -in .f1
+} -cleanup {
+ destroy .f1
+ destroy .f2
+} -returnCodes error -result {can't put .f2 inside .f1, would cause management loop}
+test pack-10.6 {prevent management loops} -body {
+ frame .f1
+ frame .f2
+ frame .f3
+ pack .f1 -in .f2
+ pack .f2 -in .f3
+ pack .f3 -in .f1
+} -cleanup {
+ destroy .f1
+ destroy .f2
+ destroy .f3
+} -returnCodes error -result {can't put .f3 inside .f1, would cause management loop}
test pack-11.1 {info option} -setup {
pack forget .pack.a .pack.b .pack.c .pack.d
diff --git a/tests/pkgconfig.test b/tests/pkgconfig.test
new file mode 100644
index 0000000..e080b91
--- /dev/null
+++ b/tests/pkgconfig.test
@@ -0,0 +1,66 @@
+# -*- tcl -*-
+# Commands covered: pkgconfig
+#
+# This file contains a collection of tests for one or more of the Tk
+# built-in commands. Sourcing this file into Tk runs the tests and
+# generates output for errors. No output means no errors were found.
+#
+# Copyright (c) 1991-1993 The Regents of the University of California.
+# Copyright (c) 1994-1996 Sun Microsystems, Inc.
+# Copyright (c) 1998-1999 by Scriptics Corporation.
+# Copyright (c) 2017 Stuart Cassoff <stwo@users.sourceforge.net>
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+
+package require tcltest 2.2
+namespace import ::tcltest::*
+eval tcltest::configure $argv
+tcltest::loadTestedCommands
+
+test pkgconfig-1.1 {query keys} nonwin {
+ lsort [::tk::pkgconfig list]
+} [list \
+ 64bit bindir,install bindir,runtime debug demodir,install demodir,runtime \
+ docdir,install docdir,runtime fontsystem includedir,install includedir,runtime \
+ libdir,install libdir,runtime mem_debug optimized profiled \
+ scriptdir,install scriptdir,runtime threaded \
+]
+test pkgconfig-1.2 {query keys multiple times} {
+ string compare [::tk::pkgconfig list] [::tk::pkgconfig list]
+} 0
+test pkgconfig-1.3 {query value multiple times} {
+ string compare \
+ [::tk::pkgconfig get 64bit] \
+ [::tk::pkgconfig get 64bit]
+} 0
+
+
+test pkgconfig-2.0 {error: missing subcommand} {
+ catch {::tk::pkgconfig} msg
+ set msg
+} {wrong # args: should be "::tk::pkgconfig subcommand ?arg?"}
+test pkgconfig-2.1 {error: illegal subcommand} {
+ catch {::tk::pkgconfig foo} msg
+ set msg
+} {bad subcommand "foo": must be get or list}
+test pkgconfig-2.2 {error: list with arguments} {
+ catch {::tk::pkgconfig list foo} msg
+ set msg
+} {wrong # args: should be "::tk::pkgconfig list"}
+test pkgconfig-2.3 {error: get without arguments} {
+ catch {::tk::pkgconfig get} msg
+ set msg
+} {wrong # args: should be "::tk::pkgconfig get key"}
+test pkgconfig-2.4 {error: query unknown key} {
+ catch {::tk::pkgconfig get foo} msg
+ set msg
+} {key not known}
+test pkgconfig-2.5 {error: query with to many arguments} {
+ catch {::tk::pkgconfig get foo bar} msg
+ set msg
+} {wrong # args: should be "::tk::pkgconfig subcommand ?arg?"}
+
+# cleanup
+cleanupTests
+return
diff --git a/tests/place.test b/tests/place.test
index 6a00192..e04ee0a 100644
--- a/tests/place.test
+++ b/tests/place.test
@@ -118,7 +118,26 @@ test place-4.4 {ConfigureSlave procedure, bad -in option} -setup {
} -body {
place .t.f2 -in .
} -returnCodes error -result {can't place .t.f2 relative to .}
-
+test place-4.5 {ConfigureSlave procedure, bad -in option} -setup {
+} -body {
+ frame .t.f1
+ place .t.f1 -in .t.f1
+} -returnCodes error -result {can't place .t.f1 relative to itself}
+test place-4.6 {prevent management loops} -setup {
+ place forget .t.f1
+} -body {
+ place .t.f1 -in .t.f2
+ place .t.f2 -in .t.f1
+} -returnCodes error -result {can't put .t.f2 inside .t.f1, would cause management loop}
+test place-4.7 {prevent management loops} -setup {
+ place forget .t.f1
+ place forget .t.f2
+} -body {
+ frame .t.f3
+ place .t.f1 -in .t.f2
+ place .t.f2 -in .t.f3
+ place .t.f3 -in .t.f1
+} -returnCodes error -result {can't put .t.f3 inside .t.f1, would cause management loop}
test place-5.1 {ConfigureSlave procedure, -relwidth option} -body {
place .t.f2 -relwidth abcd
diff --git a/tests/safe.test b/tests/safe.test
index d4e5f2e..4f0ce15 100644
--- a/tests/safe.test
+++ b/tests/safe.test
@@ -46,7 +46,7 @@ lappend hidden_cmds {*}[apply {{} {
foreach cmd {
atime attributes copy delete dirname executable exists extension
isdirectory isfile link lstat mkdir mtime nativename normalize owned
- readable readlink rename rootname size stat tail tempfile type
+ readable readlink rename rootname size stat tail tempdir tempfile type
volumes writable
} {lappend result tcl:file:$cmd}
if {[package vsatisfies [package provide Tcl] 8.7-]} {
diff --git a/tests/scale.test b/tests/scale.test
index e9dbc65..955092b 100644
--- a/tests/scale.test
+++ b/tests/scale.test
@@ -1364,7 +1364,7 @@ test scale-18.2 {Scale button 1 events [Bug 787065]} -setup {
pack .s
tkwait visibility .s
list [catch {
- event generate .s <1> -x 0 -y 0
+ event generate .s <Button-1> -x 0 -y 0
event generate .s <ButtonRelease-1> -x 0 -y 0
update
set ::error
@@ -1385,7 +1385,7 @@ test scale-18.3 {Scale button 2 events [Bug 787065]} -setup {
pack .s
tkwait visibility .s
list [catch {
- event generate .s <2> -x 0 -y 0
+ event generate .s <Button-2> -x 0 -y 0
event generate .s <ButtonRelease-2> -x 0 -y 0
update
set ::error
@@ -1411,16 +1411,16 @@ test scale-19 {Bug [3529885fff] - Click in through goes in wrong direction} \
} \
-body {
foreach {x y} [.s1 coord 50] {}
- event generate .s1 <1> -x $x -y $y
+ event generate .s1 <Button-1> -x $x -y $y
event generate .s1 <ButtonRelease-1> -x $x -y $y
foreach {x y} [.s2 coord 50] {}
- event generate .s2 <1> -x $x -y $y
+ event generate .s2 <Button-1> -x $x -y $y
event generate .s2 <ButtonRelease-1> -x $x -y $y
foreach {x y} [.s3 coord 50] {}
- event generate .s3 <1> -x $x -y $y
+ event generate .s3 <Button-1> -x $x -y $y
event generate .s3 <ButtonRelease-1> -x $x -y $y
foreach {x y} [.s4 coord 50] {}
- event generate .s4 <1> -x $x -y $y
+ event generate .s4 <Button-1> -x $x -y $y
event generate .s4 <ButtonRelease-1> -x $x -y $y
update
list $x1 $x2 $x3 $x4
@@ -1478,10 +1478,12 @@ test scale-20.4 {Bug [2262543fff] - Scale widget unexpectedly fires command call
scale .s -from 1 -to 50 -command {set commandedVar}
.s set 10
pack .s
- update ; # -command callback shall fire
+ set timeout [after 500 {set $commandedVar "timeout"}]
+ vwait commandedVar ; # -command callback shall fire
set res [list [.s get] $commandedVar]
} -cleanup {
destroy .s
+ after cancel $timeout
} -result {10 10}
test scale-20.5 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 5} -setup {
catch {destroy .s}
@@ -1506,10 +1508,12 @@ test scale-20.6 {Bug [2262543fff] - Scale widget unexpectedly fires command call
pack .s
.s configure -command {set commandedVar}
.s set 10
- update ; # -command callback shall fire
+ set timeout [after 500 {set $commandedVar "timeout"}]
+ vwait commandedVar ; # -command callback shall fire
set res [list [.s get] $commandedVar]
} -cleanup {
destroy .s
+ after cancel $timeout
} -result {10 10}
test scale-20.7 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 7} -setup {
catch {destroy .s}
@@ -1519,10 +1523,12 @@ test scale-20.7 {Bug [2262543fff] - Scale widget unexpectedly fires command call
scale .s -from 1 -to 50 -command {set commandedVar}
pack .s
.s set 10
- update ; # -command callback shall fire
+ set timeout [after 500 {set $commandedVar "timeout"}]
+ vwait commandedVar ; # -command callback shall fire
set res [list [.s get] $commandedVar]
} -cleanup {
destroy .s
+ after cancel $timeout
} -result {10 10}
test scale-20.8 {Bug [2262543fff] - Scale widget unexpectedly fires command callback, case 8} -setup {
catch {destroy .s}
@@ -1533,10 +1539,12 @@ test scale-20.8 {Bug [2262543fff] - Scale widget unexpectedly fires command call
scale .s -from 1 -to 50 -variable scaleVar -command {set commandedVar}
pack .s
.s set 10
- update ; # -command callback shall fire
+ set timeout [after 500 {set $commandedVar "timeout"}]
+ vwait commandedVar ; # -command callback shall fire
set res [list [.s get] $commandedVar]
} -cleanup {
destroy .s
+ after cancel $timeout
} -result {10 10}
test scale-21.1 {Bug [55b95f578a] - Associating variable with bignum value with scale crashes it} -setup {
@@ -1559,6 +1567,32 @@ test scale-21.2 {Bug [55b95f578a] again - Bignum value for -from/-to with scale
destroy .s
} -result {}
+test scale-22.1 {Bug [5d991b822e]} {
+ # Want this not to crash
+ set var INIT
+ scale .b -variable var
+ trace add variable var unset {apply {args {
+ .b configure -variable {}
+ }}}
+ pack .b
+ bind .b <Configure> {unset var}
+ update
+ destroy .b
+} {}
+test scale-22.2 {Bug [5d991b822e]} {
+ # Want this not to leak traces
+ set var INIT
+ scale .b -variable var
+ trace add variable var unset {apply {args {
+ .b configure -variable new
+ }}}
+ pack .b
+ bind .b <Configure> {unset -nocomplain var}
+ update
+ destroy .b
+ unset new
+} {}
+
option clear
# cleanup
diff --git a/tests/scrollbar.test b/tests/scrollbar.test
index cde99a0..e02e3a8 100644
--- a/tests/scrollbar.test
+++ b/tests/scrollbar.test
@@ -20,34 +20,34 @@ proc getTroughSize {w} {
if {[testConstraint testmetrics]} {
# Only Windows has [testmetrics]
if [string match v* [$w cget -orient]] {
- return [expr [winfo height $w] - 2*[testmetrics cyvscroll $w]]
+ return [expr {[winfo height $w] - 2*[testmetrics cyvscroll $w]}]
} else {
- return [expr [winfo width $w] - 2*[testmetrics cxhscroll $w]]
+ return [expr {[winfo width $w] - 2*[testmetrics cxhscroll $w]}]
}
} else {
if {[tk windowingsystem] eq "x11"} {
# Calculations here assume that the arrow area is a square.
if [string match v* [$w cget -orient]] {
- return [expr [winfo height $w] \
+ return [expr {[winfo height $w] \
- ([winfo width $w] \
- [$w cget -highlightthickness] \
- - [$w cget -bd] + 1)*2]
+ - [$w cget -bd] + 1)*2}]
} else {
- return [expr [winfo width $w] \
+ return [expr {[winfo width $w] \
- ([winfo height $w] \
- [$w cget -highlightthickness] \
- - [$w cget -bd] + 1)*2]
+ - [$w cget -bd] + 1)*2}]
}
} else {
# macOS aqua
if [string match v* [$w cget -orient]] {
- return [expr [winfo height $w] \
+ return [expr {[winfo height $w] \
- ([$w cget -highlightthickness] \
- +[$w cget -bd])*2]
+ +[$w cget -bd])*2}]
} else {
- return [expr [winfo width $w] \
+ return [expr {[winfo width $w] \
- ([$w cget -highlightthickness] \
- +[$w cget -bd])*2]
+ +[$w cget -bd])*2}]
}
}
}
@@ -58,8 +58,8 @@ proc getTroughSize {w} {
# as you fix bugs and add features.
foreach {width height} [wm minsize .] {
- set height [expr ($height < 200) ? 200 : $height]
- set width [expr ($width < 1) ? 1 : $width]
+ set height [expr {($height < 200) ? 200 : $height}]
+ set width [expr {($width < 1) ? 1 : $width}]
}
frame .f -height $height -width $width
@@ -233,10 +233,10 @@ test scrollbar-3.25 {ScrollbarWidgetCmd procedure, "delta" option} {
} {0}
test scrollbar-3.26 {ScrollbarWidgetCmd procedure, "delta" option} {
format {%.6g} [.s delta 0 20]
-} [format %.6g [expr 20.0/([getTroughSize .s]-1)]]
+} [format %.6g [expr {20.0/([getTroughSize .s]-1)}]]
test scrollbar-3.27 {ScrollbarWidgetCmd procedure, "delta" option} {
format {%.6g} [.s delta 0 -20]
-} [format %.6g [expr -20.0/([getTroughSize .s]-1)]]
+} [format %.6g [expr {-20.0/([getTroughSize .s]-1)}]]
test scrollbar-3.28 {ScrollbarWidgetCmd procedure, "delta" option} {
toplevel .t -width 250 -height 100
wm geom .t +0+0
@@ -244,7 +244,7 @@ test scrollbar-3.28 {ScrollbarWidgetCmd procedure, "delta" option} {
place .t.s -width 201
update
set result [list [format {%.6g} [.t.s delta 0 20]] \
- [format {%.6g} [.t.s delta [expr [getTroughSize .t.s] - 1] 0]]]
+ [format {%.6g} [.t.s delta [expr {[getTroughSize .t.s] - 1}] 0]]]
destroy .t
set result
} {0 1}
@@ -268,22 +268,22 @@ test scrollbar-3.34 {ScrollbarWidgetCmd procedure, "fraction" option} {
} {1}
test scrollbar-3.35 {ScrollbarWidgetCmd procedure, "fraction" option} {
format {%.6g} [.s fraction 4 21]
-} [format %.6g [expr (21.0 - ([winfo height .s] - [getTroughSize .s])/2.0) \
- /([getTroughSize .s] - 1)]]
+} [format %.6g [expr {(21.0 - ([winfo height .s] - [getTroughSize .s])/2.0) \
+ /([getTroughSize .s] - 1)}]]
test scrollbar-3.36 {ScrollbarWidgetCmd procedure, "fraction" option} x11 {
format {%.6g} [.s fraction 4 179]
} {1}
test scrollbar-3.37 {ScrollbarWidgetCmd procedure, "fraction" option} {testmetrics} {
- format {%.6g} [.s fraction 4 [expr 200 - [testmetrics cyvscroll .s]]]
+ format {%.6g} [.s fraction 4 [expr {200 - [testmetrics cyvscroll .s]}]]
} {1}
test scrollbar-3.38 {ScrollbarWidgetCmd procedure, "fraction" option} x11 {
format {%.6g} [.s fraction 4 178]
} {0.993711}
test scrollbar-3.39 {ScrollbarWidgetCmd procedure, "fraction" option} {testmetrics win} {
- expr \
- [format {%.6g} [.s fraction 4 [expr 200 - [testmetrics cyvscroll .s] - 2]]] \
- == [format %g [expr (200.0 - [testmetrics cyvscroll .s]*2 - 2) \
- / ($height - 1 - [testmetrics cyvscroll .s]*2)]]
+ expr {
+ [format {%.6g} [.s fraction 4 [expr {200 - [testmetrics cyvscroll .s] - 2}]]]
+ == [format %g [expr {(200.0 - [testmetrics cyvscroll .s]*2 - 2)
+ / ($height - 1 - [testmetrics cyvscroll .s]*2)}]]}
} 1
toplevel .t -width 250 -height 100
@@ -297,13 +297,13 @@ test scrollbar-3.41 {ScrollbarWidgetCmd procedure, "fraction" option} {
} {0.5}
if {[testConstraint testmetrics]} {
# Only Windows has [testmetrics]
- place configure .t.s -width [expr 2*[testmetrics cxhscroll .t.s]+1]
+ place configure .t.s -width [expr {2*[testmetrics cxhscroll .t.s]+1}]
} else {
if {[tk windowingsystem] eq "x11"} {
- place configure .t.s -width [expr [winfo height .t.s] - 2*([.t.s cget -highlightthickness] + [.t.s cget -bd] + 1)]
+ place configure .t.s -width [expr {[winfo height .t.s] - 2*([.t.s cget -highlightthickness] + [.t.s cget -bd] + 1)}]
} else {
# macOS aqua
- place configure .t.s -width [expr 2*([.t.s cget -highlightthickness] + [.t.s cget -bd])]
+ place configure .t.s -width [expr {2*([.t.s cget -highlightthickness] + [.t.s cget -bd])}]
}
}
update
@@ -473,16 +473,16 @@ test scrollbar-6.6 {ScrollbarPosition procedure} unix {
.s identify 19 100
} {}
test scrollbar-6.7 {ScrollbarPosition procedure} {
- .s identify [expr [winfo width .s] / 2] -1
+ .s identify [expr {[winfo width .s] / 2}] -1
} {}
test scrollbar-6.8 {ScrollbarPosition procedure} {
- .s identify [expr [winfo width .s] / 2] [expr [winfo height .s]]
+ .s identify [expr {[winfo width .s] / 2}] [winfo height .s]
} {}
test scrollbar-6.9 {ScrollbarPosition procedure} {
- .s identify -1 [expr [winfo height .s] / 2]
+ .s identify -1 [expr {[winfo height .s] / 2}]
} {}
test scrollbar-6.10 {ScrollbarPosition procedure} {
- .s identify [winfo width .s] [expr [winfo height .s] / 2]
+ .s identify [winfo width .s] [expr {[winfo height .s] / 2}]
} {}
test scrollbar-6.11.1 {ScrollbarPosition procedure} x11 {
.s identify 8 4
@@ -499,10 +499,10 @@ test scrollbar-6.12.2 {ScrollbarPosition procedure} aqua {
.s identify 8 19
} {trough1}
test scrollbar-6.14 {ScrollbarPosition procedure} win {
- .s identify [expr [winfo width .s] / 2] 0
+ .s identify [expr {[winfo width .s] / 2}] 0
} {arrow1}
test scrollbar-6.15 {ScrollbarPosition procedure} {testmetrics win} {
- .s identify [expr [winfo width .s] / 2] [expr [testmetrics cyvscroll .s] - 1]
+ .s identify [expr {[winfo width .s] / 2}] [expr {[testmetrics cyvscroll .s] - 1}]
} {arrow1}
test scrollbar-6.16 {ScrollbarPosition procedure} unix {
.s identify 8 20
@@ -513,11 +513,11 @@ test scrollbar-6.17 {ScrollbarPosition procedure} {unix nonPortable} {
.s identify 8 51
} {trough1}
test scrollbar-6.18 {ScrollbarPosition procedure} {testmetrics win} {
- .s identify [expr [winfo width .s] / 2] [testmetrics cyvscroll .s]
+ .s identify [expr {[winfo width .s] / 2}] [testmetrics cyvscroll .s]
} {trough1}
test scrollbar-6.19 {ScrollbarPosition procedure} {testmetrics win} {
- .s identify [expr [winfo width .s] / 2] [expr int(.2 / [.s delta 0 1]) \
- + [testmetrics cyvscroll .s] - 1]
+ .s identify [expr {[winfo width .s] / 2}] [expr {int(.2 / [.s delta 0 1])
+ + [testmetrics cyvscroll .s] - 1}]
} {trough1}
test scrollbar-6.20 {ScrollbarPosition procedure} unix {
.s identify 8 52
@@ -528,12 +528,12 @@ test scrollbar-6.21 {ScrollbarPosition procedure} {unix nonPortable} {
.s identify 8 83
} {slider}
test scrollbar-6.22 {ScrollbarPosition procedure} {testmetrics win} {
- .s identify [expr [winfo width .s] / 2] \
- [expr int(.2 / [.s delta 0 1] + 0.5) + [testmetrics cyvscroll .s]]
+ .s identify [expr {[winfo width .s] / 2}] \
+ [expr {int(.2 / [.s delta 0 1] + 0.5) + [testmetrics cyvscroll .s]}]
} {slider}
test scrollbar-6.23 {ScrollbarPosition procedure} {testmetrics win} {
- .s identify [expr [winfo width .s] / 2] [expr int(.4 / [.s delta 0 1]) \
- + [testmetrics cyvscroll .s] - 1]
+ .s identify [expr {[winfo width .s] / 2}] [expr {int(.4 / [.s delta 0 1])
+ + [testmetrics cyvscroll .s] - 1}]
} {slider}
test scrollbar-6.24 {ScrollbarPosition procedure} unix {
.s identify 8 84
@@ -542,12 +542,12 @@ test scrollbar-6.25 {ScrollbarPosition procedure} unix {
.s identify 8 179
} {trough2}
test scrollbar-6.27 {ScrollbarPosition procedure} {testmetrics win} {
- .s identify [expr [winfo width .s] / 2] [expr int(.4 / [.s delta 0 1]) \
- + [testmetrics cyvscroll .s]]
+ .s identify [expr {[winfo width .s] / 2}] [expr {int(.4 / [.s delta 0 1])
+ + [testmetrics cyvscroll .s]}]
} {trough2}
test scrollbar-6.28 {ScrollbarPosition procedure} {testmetrics win} {
- .s identify [expr [winfo width .s] / 2] [expr [winfo height .s] \
- - [testmetrics cyvscroll .s] - 1]
+ .s identify [expr {[winfo width .s] / 2}] [expr {[winfo height .s]
+ - [testmetrics cyvscroll .s] - 1}]
} {trough2}
test scrollbar-6.29.1 {ScrollbarPosition procedure} x11 {
.s identify 8 180
@@ -564,11 +564,11 @@ test scrollbar-6.30.2 {ScrollbarPosition procedure} aqua {
.s identify 8 195
} {trough2}
test scrollbar-6.32 {ScrollbarPosition procedure} {testmetrics win} {
- .s identify [expr [winfo width .s] / 2] [expr [winfo height .s] \
- - [testmetrics cyvscroll .s]]
+ .s identify [expr {[winfo width .s] / 2}] [expr {[winfo height .s]
+ - [testmetrics cyvscroll .s]}]
} {arrow2}
test scrollbar-6.33 {ScrollbarPosition procedure} win {
- .s identify [expr [winfo width .s] / 2] [expr [winfo height .s] - 1]
+ .s identify [expr {[winfo width .s] / 2}] [expr {[winfo height .s] - 1}]
} {arrow2}
test scrollbar-6.34 {ScrollbarPosition procedure} unix {
.s identify 4 100
@@ -580,7 +580,7 @@ test scrollbar-6.37 {ScrollbarPosition procedure} win {
.s identify 0 100
} {trough2}
test scrollbar-6.38 {ScrollbarPosition procedure} win {
- .s identify [expr [winfo width .s] - 1] 100
+ .s identify [expr {[winfo width .s] - 1}] 100
} {trough2}
catch {destroy .t}
@@ -599,7 +599,7 @@ test scrollbar-6.39.2 {ScrollbarPosition procedure} aqua {
.t.s identify 4 8
} {trough1}
test scrollbar-6.40 {ScrollbarPosition procedure} win {
- .t.s identify 0 [expr [winfo height .t.s] / 2]
+ .t.s identify 0 [expr {[winfo height .t.s] / 2}]
} {arrow1}
test scrollbar-6.41.1 {ScrollbarPosition procedure} x11 {
.t.s identify 82 8
@@ -609,14 +609,14 @@ test scrollbar-6.41.2 {ScrollbarPosition procedure} aqua {
.t.s identify 82 8
} {trough2}
test scrollbar-6.43 {ScrollbarPosition procedure} {testmetrics win} {
- .t.s identify [expr int(.4 / [.t.s delta 1 0]) + [testmetrics cxhscroll .t.s] \
- - 1] [expr [winfo height .t.s] / 2]
+ .t.s identify [expr {int(.4 / [.t.s delta 1 0]) + [testmetrics cxhscroll .t.s]
+ - 1}] [expr {[winfo height .t.s] / 2}]
} {slider}
test scrollbar-6.44 {ScrollbarPosition procedure} unix {
.t.s identify 100 18
} {trough2}
test scrollbar-6.46 {ScrollbarPosition procedure} win {
- .t.s identify 100 [expr [winfo height .t.s] - 1]
+ .t.s identify 100 [expr {[winfo height .t.s] - 1}]
} {trough2}
test scrollbar-7.1 {EventuallyRedraw} {
@@ -645,7 +645,7 @@ test scrollbar-8.1 {TkScrollbarEventProc: recursive deletion} notAqua {
.t.f.s set 0 .5
update
set result [winfo exists .t.f.s]
- event generate .t.f.s <ButtonPress> -button 1 -x [expr [winfo width .t.f.s] / 2] -y 5
+ event generate .t.f.s <Button> -button 1 -x [expr {[winfo width .t.f.s] / 2}] -y 5
event generate .t <ButtonRelease> -button 1
update
lappend result [winfo exists .t.f.s] [winfo exists .t.f]
@@ -666,7 +666,7 @@ test scrollbar-8.2 {TkScrollbarEventProc: recursive deletion} notAqua {
.t.f.s set 0 .5
update
set result [winfo exists .t.f.s]
- event generate .t.f.s <ButtonPress> -button 1 -x [expr [winfo width .t.f.s] / 2] -y 5
+ event generate .t.f.s <Button> -button 1 -x [expr {[winfo width .t.f.s] / 2}] -y 5
event generate .t.f <ButtonRelease> -button 1
update
lappend result [winfo exists .t.f.s] [winfo exists .t.f]
@@ -714,7 +714,7 @@ test scrollbar-10.1.2 {<MouseWheel> event on scrollbar} -constraints {aqua} -set
destroy .t .s
} -result {5.0}
-test scrollbar-10.2.1 {<MouseWheel> event on scrollbar} -constraints {notAqua} -setup {
+test scrollbar-10.2.1 {<Shift-MouseWheel> event on horizontal scrollbar} -constraints {notAqua} -setup {
destroy .t .s
} -body {
pack [text .t -xscrollcommand {.s set} -wrap none] -side top
@@ -728,7 +728,7 @@ test scrollbar-10.2.1 {<MouseWheel> event on scrollbar} -constraints {notAqua} -
} -cleanup {
destroy .t .s
} -result {1.4}
-test scrollbar-10.2.2 {<MouseWheel> event on scrollbar} -constraints {aqua} -setup {
+test scrollbar-10.2.2 {<Shift-MouseWheel> event on horizontal scrollbar} -constraints {aqua} -setup {
destroy .t .s
} -body {
pack [text .t -xscrollcommand {.s set} -wrap none] -side top
@@ -742,6 +742,34 @@ test scrollbar-10.2.2 {<MouseWheel> event on scrollbar} -constraints {aqua} -set
} -cleanup {
destroy .t .s
} -result {1.4}
+test scrollbar-10.2.3 {<MouseWheel> event on horizontal scrollbar} -constraints {notAqua} -setup {
+ destroy .t .s
+} -body {
+ pack [text .t -xscrollcommand {.s set} -wrap none] -side top
+ for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "}
+ pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top
+ update
+ focus -force .s
+ event generate .s <MouseWheel> -delta -120
+ after 200 {set eventprocessed 1} ; vwait eventprocessed
+ .t index @0,0
+} -cleanup {
+ destroy .t .s
+} -result {1.4}
+test scrollbar-10.2.4 {<MouseWheel> event on horizontal scrollbar} -constraints {aqua} -setup {
+ destroy .t .s
+} -body {
+ pack [text .t -xscrollcommand {.s set} -wrap none] -side top
+ for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "}
+ pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top
+ update
+ focus -force .s
+ event generate .s <MouseWheel> -delta -4
+ after 200 {set eventprocessed 1} ; vwait eventprocessed
+ .t index @0,0
+} -cleanup {
+ destroy .t .s
+} -result {1.4}
test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destruction} -body {
proc destroy_scrollbar {} {
@@ -751,11 +779,11 @@ test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destructi
}
toplevel .top
scrollbar .top.s
- bind .top.s <2> {destroy_scrollbar}
+ bind .top.s <Button-2> {destroy_scrollbar}
pack .top.s
focus -force .top.s
update
- event generate .top.s <2>
+ event generate .top.s <Button-2>
update ; # shall not trigger error invalid command name ".top.s"
} -cleanup {
destroy .top.s .top
@@ -770,11 +798,11 @@ test scrollbar-11.2 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destructi
wm minsize .top 50 400
update
scrollbar .top.s
- bind .top.s <2> {after idle destroy_scrollbar}
+ bind .top.s <Button-2> {after idle destroy_scrollbar}
pack .top.s -expand true -fill y
focus -force .top.s
update
- event generate .top.s <2> -x 2 -y [expr {[winfo height .top.s] / 2}]
+ event generate .top.s <Button-2> -x 2 -y [expr {[winfo height .top.s] / 2}]
update ; # shall not trigger error invalid command name ".top.s"
} -cleanup {
destroy .top.s .top
diff --git a/tests/select.test b/tests/select.test
index 568749f..9146397 100644
--- a/tests/select.test
+++ b/tests/select.test
@@ -36,7 +36,7 @@ proc handler {type offset count} {
if {$numBytes <= 0} {
return ""
}
- string range $selValue $offset [expr $numBytes+$offset]
+ string range $selValue $offset [expr {$numBytes+$offset}]
}
proc errIncrHandler {type offset count} {
@@ -55,7 +55,7 @@ proc errIncrHandler {type offset count} {
if {$numBytes <= 0} {
return ""
}
- string range $selValue $offset [expr $numBytes+$offset]
+ string range $selValue $offset [expr {$numBytes+$offset}]
}
proc errHandler args {
@@ -70,7 +70,7 @@ proc badHandler {path type offset count} {
if {$numBytes <= 0} {
return ""
}
- string range $selValue $offset [expr $numBytes+$offset]
+ string range $selValue $offset [expr {$numBytes+$offset}]
}
proc reallyBadHandler {path type offset count} {
global selValue selInfo pass
@@ -86,7 +86,7 @@ proc reallyBadHandler {path type offset count} {
if {$numBytes <= 0} {
return ""
}
- string range $selValue $offset [expr $numBytes+$offset]
+ string range $selValue $offset [expr {$numBytes+$offset}]
}
# Eliminate any existing selection on the screen. This is needed in case
@@ -1147,7 +1147,7 @@ test select-13.1 {SelectionSize procedure, handler deleted} -constraints {
if {$numBytes <= 0} {
return ""
}
- string range $selValue $offset [expr $numBytes+$offset]
+ string range $selValue $offset [expr {$numBytes+$offset}]
}
set selValue $longValue
set selInfo ""
diff --git a/tests/spinbox.test b/tests/spinbox.test
index 28ebe68..2d03cf1 100644
--- a/tests/spinbox.test
+++ b/tests/spinbox.test
@@ -1773,7 +1773,7 @@ test spinbox-3.71 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
.e xview scroll 24
} -cleanup {
destroy .e
-} -returnCodes error -result {wrong # args: should be ".e xview scroll number units|pages"}
+} -returnCodes error -result {wrong # args: should be ".e xview scroll number pages|units"}
test spinbox-3.72 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
pack .e
@@ -1850,7 +1850,7 @@ test spinbox-3.77 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
.e xview scroll 23 foobars
} -cleanup {
destroy .e
-} -returnCodes error -result {bad argument "foobars": must be units or pages}
+} -returnCodes error -result {bad argument "foobars": must be pages or units}
test spinbox-3.78 {SpinboxWidgetCmd procedure, "xview" widget command} -setup {
spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2
pack .e
@@ -2013,11 +2013,13 @@ test spinbox-5.7 {ConfigureSpinbox procedure} -setup {
} -body {
.e configure -font {Courier -12} -width 4 -xscrollcommand scroll
.e insert end "01234567890"
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
.e configure -width 5
format {%.6f %.6f} {*}$scrollInfo
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {0.000000 0.363636}
test spinbox-5.8 {ConfigureSpinbox procedure} -constraints {
@@ -2218,10 +2220,12 @@ test spinbox-7.1 {InsertChars procedure} -setup {
.e configure -textvariable contents -xscrollcommand scroll
.e insert 0 abcde
.e insert 2 XXX
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {abXXXcde abXXXcde {0.000000 1.000000}}
test spinbox-7.2 {InsertChars procedure} -setup {
@@ -2233,10 +2237,12 @@ test spinbox-7.2 {InsertChars procedure} -setup {
.e configure -textvariable contents -xscrollcommand scroll
.e insert 0 abcde
.e insert 500 XXX
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {abcdeXXX abcdeXXX {0.000000 1.000000}}
test spinbox-7.3 {InsertChars procedure} -setup {
spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
@@ -2365,10 +2371,12 @@ test spinbox-8.1 {DeleteChars procedure} -setup {
.e configure -textvariable contents -xscrollcommand scroll
.e insert 0 abcde
.e delete 2 4
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {abe abe {0.000000 1.000000}}
test spinbox-8.2 {DeleteChars procedure} -setup {
unset -nocomplain contents
@@ -2379,10 +2387,12 @@ test spinbox-8.2 {DeleteChars procedure} -setup {
.e configure -textvariable contents -xscrollcommand scroll
.e insert 0 abcde
.e delete -2 2
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {cde cde {0.000000 1.000000}}
test spinbox-8.3 {DeleteChars procedure} -setup {
unset -nocomplain contents
@@ -2393,10 +2403,12 @@ test spinbox-8.3 {DeleteChars procedure} -setup {
.e configure -textvariable contents -xscrollcommand scroll
.e insert 0 abcde
.e delete 3 1000
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo]
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {abc abc {0.000000 1.000000}}
test spinbox-8.4 {DeleteChars procedure} -setup {
spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2
@@ -3193,30 +3205,36 @@ test spinbox-17.1 {SpinboxUpdateScrollbar procedure} -body {
pack .e
.e delete 0 end
.e insert 0 123
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
format {%.6f %.6f} {*}$scrollInfo
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {0.000000 1.000000}
test spinbox-17.2 {SpinboxUpdateScrollbar procedure} -body {
spinbox .e -width 10 -xscrollcommand scroll -font {Courier -12}
pack .e
.e insert 0 0123456789abcdef
.e xview 3
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
format {%.6f %.6f} {*}$scrollInfo
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {0.187500 0.812500}
test spinbox-17.3 {SpinboxUpdateScrollbar procedure} -body {
spinbox .e -width 10 -xscrollcommand scroll -font {Courier -12}
pack .e
.e insert 0 abcdefghijklmnopqrs
.e xview 6
- update
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
format {%.6f %.6f} {*}$scrollInfo
} -cleanup {
destroy .e
+ after cancel $timeout
} -result {0.315789 0.842105}
test spinbox-17.4 {SpinboxUpdateScrollbar procedure} -setup {
proc bgerror msg {
@@ -3226,7 +3244,7 @@ test spinbox-17.4 {SpinboxUpdateScrollbar procedure} -setup {
} -body {
spinbox .e -width 5 -xscrollcommand thisisnotacommand
pack .e
- update
+ vwait x
list $x $errorInfo
} -cleanup {
destroy .e
diff --git a/tests/text.test b/tests/text.test
index 3314fc9..7770084 100644
--- a/tests/text.test
+++ b/tests/text.test
@@ -2698,7 +2698,7 @@ test text-9.2.45 {TextWidgetCmd procedure, "count" option} -setup {
set res {}
} -body {
for {set i 1} {$i < 5} {incr i} {
- .t insert end "Line $i+++Line $i---Line $i///Line $i - This is Line [format %c [expr 64+$i]]\n"
+ .t insert end "Line $i+++Line $i---Line $i///Line $i - This is Line [format %c [expr {64+$i}]]\n"
}
.t tag configure hidden -elide true
.t tag add hidden 2.15 3.10
@@ -2720,7 +2720,7 @@ test text-9.2.46 {TextWidgetCmd procedure, "count" option} -setup {
for {set i 1} {$i < 5} {incr i} {
# 0 1 2 3 4
# 012345 678901234 567890123 456789012 34567890123456789
- .mytop.t insert end "Line $i+++Line $i---Line $i///Line $i - This is Line [format %c [expr 64+$i]]\n"
+ .mytop.t insert end "Line $i+++Line $i---Line $i///Line $i - This is Line [format %c [expr {64+$i}]]\n"
}
.mytop.t tag configure hidden -elide true
.mytop.t tag add hidden 2.30 3.10
@@ -6145,9 +6145,9 @@ test text-23.4 {TkTextGetTabs procedure} -setup {
.t insert end "1\t2\t3\t4\t55.5"
.t configure -tabs {100 right 200 left 300 center 400 numeric}
update idletasks
- list [expr [lindex [.t bbox 1.2] 0] + [lindex [.t bbox 1.2] 2]] \
+ list [expr {[lindex [.t bbox 1.2] 0] + [lindex [.t bbox 1.2] 2]}] \
[lindex [.t bbox 1.4] 0] \
- [expr [lindex [.t bbox 1.6] 0] + [lindex [.t bbox 1.6] 2]/2] \
+ [expr {[lindex [.t bbox 1.6] 0] + [lindex [.t bbox 1.6] 2]/2}] \
[lindex [.t bbox 1.10] 0]
} -cleanup {
destroy .t
@@ -6159,9 +6159,9 @@ test text-23.5 {TkTextGetTabs procedure} -setup {
.t insert end "1\t2\t3\t4\t55.5"
.t configure -tabs {105 r 205 l 305 c 405 n}
update idletasks
- list [expr [lindex [.t bbox 1.2] 0] + [lindex [.t bbox 1.2] 2]] \
+ list [expr {[lindex [.t bbox 1.2] 0] + [lindex [.t bbox 1.2] 2]}] \
[lindex [.t bbox 1.4] 0] \
- [expr [lindex [.t bbox 1.6] 0] + [lindex [.t bbox 1.6] 2]/2] \
+ [expr {[lindex [.t bbox 1.6] 0] + [lindex [.t bbox 1.6] 2]/2}] \
[lindex [.t bbox 1.10] 0]
} -cleanup {
destroy .t
@@ -6705,7 +6705,8 @@ test text-27.15d {<<Selection>> virtual event on <Delete> with cursor inside sel
update
set ::retval no_<<Selection>>_event_fired
.t mark set insert 1.15
- focus .t
+ update idletasks
+ focus -force .t
event generate .t <Delete>
update
set ::retval
@@ -6822,14 +6823,14 @@ test text-27.18 {patch 1469210 - inserting after undo} -setup {
} -cleanup {
destroy .t
} -result 1
-test text-27.19 {patch 1669632 (i) - undo after <Control-1>} -setup {
+test text-27.19 {patch 1669632 (i) - undo after <Control-Button-1>} -setup {
destroy .t
} -body {
text .t -undo 1
.t insert end foo\nbar
.t edit reset
.t insert 2.2 WORLD
- event generate .t <Control-1> -x 1 -y 1
+ event generate .t <Control-Button-1> -x 1 -y 1
.t insert insert HELLO
.t edit undo
.t get 2.2 2.7
@@ -6862,7 +6863,7 @@ test text-27.21 {patch 1669632 (vii) - <<Undo>> shall not remove separators} -se
.t insert end "This is an example text"
.t edit reset
.t insert 1.5 "WORLD "
- event generate .t <Control-1> -x 1 -y 1
+ event generate .t <Control-Button-1> -x 1 -y 1
.t insert insert HELLO
event generate .t <<Undo>>
.t insert insert E
@@ -7817,8 +7818,8 @@ test text-36.1 "bug #1777362: event handling with hyphenated windows" -setup {
pack [set w [text .t-1]]
} -body {
tkwait visibility $w
- event generate $w <1>
- event generate $w <1>
+ event generate $w <Button-1>
+ event generate $w <Button-1>
update
set ::my_error
} -cleanup {
@@ -7835,8 +7836,8 @@ test text-36.2 "bug #1777362: event handling with hyphenated windows" -setup {
pack [set w [text .t+1]]
} -body {
tkwait visibility $w
- event generate $w <1>
- event generate $w <1>
+ event generate $w <Button-1>
+ event generate $w <Button-1>
update
set ::my_error
} -cleanup {
@@ -7853,8 +7854,8 @@ test text-36.3 "bug #1777362: event handling with hyphenated windows" -setup {
pack [set w [text .t*1]]
} -body {
tkwait visibility $w
- event generate $w <1>
- event generate $w <1>
+ event generate $w <Button-1>
+ event generate $w <Button-1>
update
set ::my_error
} -cleanup {
diff --git a/tests/textBTree.test b/tests/textBTree.test
index ebd6c50..fd97afa 100644
--- a/tests/textBTree.test
+++ b/tests/textBTree.test
@@ -422,8 +422,8 @@ test btree-6.5 {very large deletes, with tags} -setup {
setup
.t insert 1.1 $bigText2
for {set i 0} {$i < 100} {incr i} {
- set j [expr $i+2]
- set k [expr 1+2*$i]
+ set j [expr {$i+2}]
+ set k [expr {1+2*$i}]
.t tag add x $j.1 $j.3
.t tag add y $k.1 $k.6
}
@@ -439,13 +439,13 @@ test btree-6.6 {very large deletes, with tags} -setup {
setup
.t insert 1.1 $bigText2
for {set i 0} {$i < 100} {incr i} {
- set j [expr $i+2]
- set k [expr 1+2*$i]
+ set j [expr {$i+2}]
+ set k [expr {1+2*$i}]
.t tag add x $j.1 $j.3
.t tag add y $k.1 $k.6
}
for {set i 199} {$i >= 2} {incr i -1} {
- .t delete $i.0 [expr $i+1].0
+ .t delete $i.0 [expr {$i+1}].0
}
list [.t tag ranges x] [.t tag ranges y]
} -result {{3.0 3.1 3.4 3.12 4.2 4.6} {1.1 1.6 3.4 3.5}}
diff --git a/tests/textDisp.test b/tests/textDisp.test
index b74fc4a..f2d7047 100644
--- a/tests/textDisp.test
+++ b/tests/textDisp.test
@@ -11,6 +11,18 @@ eval tcltest::configure $argv
tcltest::loadTestedCommands
namespace import -force tcltest::test
+# Platform specific procedure for updating the text widget.
+
+if {[tk windowingsystem] == "aqua"} {
+ proc updateText {} {
+ update idletasks
+ }
+} else {
+ proc updateText {} {
+ update
+ }
+}
+
# The procedure below is used as the scrolling command for the text;
# it just saves the scrolling information in a variable "scrollInfo".
@@ -41,7 +53,15 @@ catch {destroy .f .t}
frame .f -width 100 -height 20
pack .f -side left
-set fixedFont {"Courier New" -12}
+# On macOS the font "Courier New" has different metrics than "Courier",
+# and this causes tests 20.1 - 20.5 to fail. So we use "Courier" as the
+# fixed font for testing on Aqua.
+
+if {[tk windowingsystem] eq "aqua"} {
+ set fixedFont {Courier -12}
+} else {
+ set fixedFont {"Courier New" -12}
+}
# 15 on XP, 13 on Solaris 8
set fixedHeight [font metrics $fixedFont -linespace]
# 7 on all platforms
@@ -77,7 +97,7 @@ wm withdraw .
wm minsize . 1 1
wm positionfrom . user
wm deiconify .
-update
+updateText
# Some window managers (like olwm under SunOS 4.1.3) misbehave in a way
# that tends to march windows off the top and left of the screen. If
@@ -158,7 +178,7 @@ test textDisp-0.3 {double tag elide transition} {
.txt tag configure SYSTEM -elide 0
.txt tag configure TRAFFIC -elide 1
.txt insert end "\n" {TRAFFIC SYSTEM}
- update
+ updateText
destroy .txt
} {}
@@ -171,7 +191,7 @@ test textDisp-0.4 {double tag elide transition} {
.txt tag configure TRAFFIC -elide 1
.txt insert end "\n" {SYSTEM TRAFFIC}
# Crash was here.
- update
+ updateText
destroy .txt
} {}
@@ -185,7 +205,7 @@ test textDisp-0.5 {double tag elide transition} {
.txt insert end "\n" {SYSTEM TRAFFIC}
.txt insert end "\n" WELCOME
# Crash was here.
- update
+ updateText
destroy .txt
} {}
@@ -216,7 +236,7 @@ test textDisp-1.2 {GetStyle procedure, wrapmode} {textfonts} {
.t tag configure x -wrap word
.t tag configure y -wrap none
.t tag raise y
- update
+ updateText
set result [list [.t bbox 2.20]]
.t tag add x 2.0 2.1
lappend result [.t bbox 2.20]
@@ -230,7 +250,7 @@ test textDisp-2.1 {LayoutDLine, basics} {
.t delete 1.0 end
.t insert 1.0 "This is some sample text for testing."
list [.t bbox 1.19] [.t bbox 1.20]
-} [list [list [expr 5 + $fixedWidth * 19] 5 $fixedWidth $fixedHeight] [list 5 [expr 5 + $fixedHeight] $fixedWidth $fixedHeight]]
+} [list [list [expr {5 + $fixedWidth * 19}] 5 $fixedWidth $fixedHeight] [list 5 [expr {5 + $fixedHeight}] $fixedWidth $fixedHeight]]
test textDisp-2.2 {LayoutDLine, basics} {textfonts} {
.t configure -wrap char
.t delete 1.0 end
@@ -274,8 +294,8 @@ foreach m [.t mark names] {
}
scan [wm geom .] %dx%d width height
test textDisp-2.8 {LayoutDLine, extra chunk at end of dline} {textfonts} {
- wm geom . [expr $width+1]x$height
- update
+ wm geom . [expr {$width+1}]x$height
+ updateText
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "This isxx some sample text for testing."
@@ -283,7 +303,7 @@ test textDisp-2.8 {LayoutDLine, extra chunk at end of dline} {textfonts} {
list [.t bbox 1.19] [.t bbox 1.20]
} [list [list 138 5 8 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
wm geom . {}
-update
+updateText
test textDisp-2.9 {LayoutDLine, marks and tags} {textfonts} {
.t configure -wrap word
.t delete 1.0 end
@@ -414,22 +434,22 @@ test textDisp-2.22 {LayoutDLine, spacing options} {textfonts} {
.t insert end "to wrap around a couple of times"
.t insert end "\nLine 3\nLine 4"
set i [.t dlineinfo 1.0]
- set b1 [expr [lindex $i 1] + [lindex $i 4]]
+ set b1 [expr {[lindex $i 1] + [lindex $i 4]}]
set i [.t dlineinfo 2.0]
- set b2 [expr [lindex $i 1] + [lindex $i 4]]
+ set b2 [expr {[lindex $i 1] + [lindex $i 4]}]
set i [.t dlineinfo 2.end]
- set b3 [expr [lindex $i 1] + [lindex $i 4]]
+ set b3 [expr {[lindex $i 1] + [lindex $i 4]}]
set i [.t dlineinfo 3.0]
- set b4 [expr [lindex $i 1] + [lindex $i 4]]
+ set b4 [expr {[lindex $i 1] + [lindex $i 4]}]
.t configure -spacing1 2 -spacing2 1 -spacing3 3
set i [.t dlineinfo 1.0]
- set b1 [expr [lindex $i 1] + [lindex $i 4] - $b1]
+ set b1 [expr {[lindex $i 1] + [lindex $i 4] - $b1}]
set i [.t dlineinfo 2.0]
- set b2 [expr [lindex $i 1] + [lindex $i 4] - $b2]
+ set b2 [expr {[lindex $i 1] + [lindex $i 4] - $b2}]
set i [.t dlineinfo 2.end]
- set b3 [expr [lindex $i 1] + [lindex $i 4] - $b3]
+ set b3 [expr {[lindex $i 1] + [lindex $i 4] - $b3}]
set i [.t dlineinfo 3.0]
- set b4 [expr [lindex $i 1] + [lindex $i 4] - $b4]
+ set b4 [expr {[lindex $i 1] + [lindex $i 4] - $b4}]
list $b1 $b2 $b3 $b4
} [list 2 7 10 15]
.t configure -spacing1 0 -spacing2 0 -spacing3 0
@@ -441,13 +461,13 @@ test textDisp-2.23 {LayoutDLine, spacing options} {textfonts} {
.t insert end "to wrap around a couple of times"
.t insert end "\nLine 3\nLine 4"
set i [.t dlineinfo 1.0]
- set b1 [expr [lindex $i 1] + [lindex $i 4]]
+ set b1 [expr {[lindex $i 1] + [lindex $i 4]}]
set i [.t dlineinfo 2.0]
- set b2 [expr [lindex $i 1] + [lindex $i 4]]
+ set b2 [expr {[lindex $i 1] + [lindex $i 4]}]
set i [.t dlineinfo 2.end]
- set b3 [expr [lindex $i 1] + [lindex $i 4]]
+ set b3 [expr {[lindex $i 1] + [lindex $i 4]}]
set i [.t dlineinfo 3.0]
- set b4 [expr [lindex $i 1] + [lindex $i 4]]
+ set b4 [expr {[lindex $i 1] + [lindex $i 4]}]
.t configure -spacing1 4 -spacing2 4 -spacing3 4
.t tag configure x -spacing1 1 -spacing2 2 -spacing3 3
.t tag add x 1.0 end
@@ -455,13 +475,13 @@ test textDisp-2.23 {LayoutDLine, spacing options} {textfonts} {
.t tag add y 2.19 end
.t tag raise y
set i [.t dlineinfo 1.0]
- set b1 [expr [lindex $i 1] + [lindex $i 4] - $b1]
+ set b1 [expr {[lindex $i 1] + [lindex $i 4] - $b1}]
set i [.t dlineinfo 2.0]
- set b2 [expr [lindex $i 1] + [lindex $i 4] - $b2]
+ set b2 [expr {[lindex $i 1] + [lindex $i 4] - $b2}]
set i [.t dlineinfo 2.end]
- set b3 [expr [lindex $i 1] + [lindex $i 4] - $b3]
+ set b3 [expr {[lindex $i 1] + [lindex $i 4] - $b3}]
set i [.t dlineinfo 3.0]
- set b4 [expr [lindex $i 1] + [lindex $i 4] - $b4]
+ set b4 [expr {[lindex $i 1] + [lindex $i 4] - $b4}]
list $b1 $b2 $b3 $b4
} [list 1 5 13 16]
.t configure -spacing1 0 -spacing2 0 -spacing3 0
@@ -535,33 +555,33 @@ test textDisp-3.1 {different character sizes} {textfonts} {
test textDisp-4.1 {UpdateDisplayInfo, basic} {textfonts} {
.t delete 1.0 end
.t insert end "Line 1\nLine 2\nLine 3\n"
- update
+ updateText
.t delete 2.0 2.end
- update
+ updateText
set res $tk_textRelayout
.t insert 2.0 "New Line 2"
- update
+ updateText
lappend res [.t bbox 1.0] [.t bbox 2.0] [.t bbox 3.0] $tk_textRelayout
} [list 2.0 [list 5 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] 2.0]
test textDisp-4.2 {UpdateDisplayInfo, re-use tail of text line} {textfonts} {
.t delete 1.0 end
.t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
- update
+ updateText
.t mark set x 2.21
.t delete 2.2
- update
+ updateText
set res $tk_textRelayout
.t insert 2.0 X
- update
+ updateText
lappend res [.t bbox 2.0] [.t bbox x] [.t bbox 3.0] $tk_textRelayout
} [list 2.0 2.20 [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 12 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight] {2.0 2.20}]
test textDisp-4.3 {UpdateDisplayInfo, tail of text line shifts} {textfonts} {
.t delete 1.0 end
.t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
- update
+ updateText
.t mark set x 2.21
.t delete 2.2
- update
+ updateText
list [.t bbox 2.0] [.t bbox x] [.t bbox 3.0] $tk_textRelayout
} [list [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight] {2.0 2.20}]
.t mark unset x
@@ -569,7 +589,7 @@ test textDisp-4.4 {UpdateDisplayInfo, wrap-mode "none"} {textfonts} {
.t configure -wrap none
.t delete 1.0 end
.t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
- update
+ updateText
list [.t bbox 2.0] [.t bbox 2.25] [.t bbox 3.0] $tk_textRelayout
} [list [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] {} [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] {1.0 2.0 3.0}]
test textDisp-4.5 {UpdateDisplayInfo, tiny window} {textfonts} {
@@ -577,11 +597,11 @@ test textDisp-4.5 {UpdateDisplayInfo, tiny window} {textfonts} {
wm overrideredirect . 1
}
wm geom . 103x$height
- update
+ updateText
.t configure -wrap none
.t delete 1.0 end
.t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
- update
+ updateText
list [.t bbox 2.0] [.t bbox 2.1] [.t bbox 3.0] $tk_textRelayout
} [list [list 5 [expr {$fixedDiff + 18}] 1 $fixedHeight] {} [list 5 [expr {2*$fixedDiff + 31}] 1 $fixedHeight] {1.0 2.0 3.0}]
if {$tcl_platform(platform) == "windows"} {
@@ -601,20 +621,20 @@ test textDisp-4.6 {UpdateDisplayInfo, tiny window} {
frame .f2 -width 20 -height 100
pack .f2 -before .f
wm geom . 103x103
- update
+ updateText
.t configure -wrap none -borderwidth 2
.t delete 1.0 end
.t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
- update
+ updateText
set x [list [.t bbox 1.0] [.t bbox 2.0] $tk_textRelayout]
wm overrideredirect . 0
- update
+ updateText
set x
} [list [list 5 5 1 1] {} 1.0]
catch {destroy .f2}
.t configure -borderwidth 0 -wrap char
wm geom . {}
-update
+updateText
set bw [.t cget -borderwidth]
set px [.t cget -padx]
set py [.t cget -pady]
@@ -633,28 +653,28 @@ test textDisp-4.7 {UpdateDisplayInfo, filling in extra vertical space} {
.t delete 1.0 end
.t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
.t yview 1.0
- update
+ updateText
.t yview 16.0
- update
+ updateText
set x [list [.t index @0,0] $tk_textRelayout $tk_textRedraw]
wm overrideredirect . 0
- update
+ updateText
set x
} {8.0 {16.0 17.0 15.0 14.0 13.0 12.0 11.0 10.0 9.0 8.0} {8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0}}
test textDisp-4.8 {UpdateDisplayInfo, filling in extra vertical space} {
.t delete 1.0 end
.t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
.t yview 16.0
- update
+ updateText
.t delete 5.0 14.0
- update
+ updateText
set x [list [.t index @0,0] $tk_textRelayout $tk_textRedraw]
} {1.0 {5.0 4.0 3.0 2.0 1.0} {1.0 2.0 3.0 4.0 5.0 eof}}
test textDisp-4.9 {UpdateDisplayInfo, filling in extra vertical space} {textfonts} {
.t delete 1.0 end
.t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
.t yview 16.0
- update
+ updateText
.t delete 15.0 end
list [.t bbox 7.0] [.t bbox 12.0]
} [list [list [expr {$hlth + $px + $bw}] [expr {$hlth + $py + $bw + 2 * $fixedHeight}] $fixedWidth $fixedHeight] [list [expr {$hlth + $px + $bw}] [expr {$hlth + $py + $bw + 7 * $fixedHeight}] $fixedWidth $fixedHeight]]
@@ -662,18 +682,18 @@ test textDisp-4.10 {UpdateDisplayInfo, filling in extra vertical space} {
.t delete 1.0 end
.t insert end "1\n2\n3\n4\n5\nLine 6 is such a long line that it wraps around.\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
.t yview end
- update
+ updateText
.t delete 13.0 end
- update
+ updateText
list [.t index @0,0] $tk_textRelayout $tk_textRedraw
} {5.0 {12.0 7.0 6.40 6.20 6.0 5.0} {5.0 6.0 6.20 6.40 7.0 12.0}}
test textDisp-4.11 {UpdateDisplayInfo, filling in extra vertical space} {
.t delete 1.0 end
.t insert end "1\n2\n3\n4\n5\nLine 6 is such a long line that it wraps around, not once but really quite a few times.\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
.t yview end
- update
+ updateText
.t delete 14.0 end
- update
+ updateText
list [.t index @0,0] $tk_textRelayout $tk_textRedraw
} {6.40 {13.0 7.0 6.80 6.60 6.40} {6.40 6.60 6.80 7.0 13.0}}
test textDisp-4.12 {UpdateDisplayInfo, filling in extra vertical space} {
@@ -682,11 +702,11 @@ test textDisp-4.12 {UpdateDisplayInfo, filling in extra vertical space} {
button .b -text "Test" -bd 2 -highlightthickness 2
.t window create 3.end -window .b
.t yview moveto 1
- update
+ updateText
.t yview moveto 0
- update
+ updateText
.t yview moveto 1
- update
+ updateText
winfo ismapped .b
} {0}
.t configure -wrap word
@@ -699,33 +719,33 @@ test textDisp-4.12 {UpdateDisplayInfo, filling in extra vertical space} {
test textDisp-4.13 {UpdateDisplayInfo, special handling for top/bottom lines} {
.t tag add x 1.0 end
.t yview 1.0
- update
+ updateText
.t yview scroll 3 units
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{11.0 12.0 13.0} {4.0 10.0 11.0 12.0 13.0}}
test textDisp-4.14 {UpdateDisplayInfo, special handling for top/bottom lines} {
.t tag remove x 1.0 end
.t yview 1.0
- update
+ updateText
.t yview scroll 3 units
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{11.0 12.0 13.0} {11.0 12.0 13.0}}
test textDisp-4.15 {UpdateDisplayInfo, special handling for top/bottom lines} {
.t tag add x 1.0 end
.t yview 4.0
- update
+ updateText
.t yview scroll -2 units
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 3.0} {2.0 3.0 4.0 11.0}}
test textDisp-4.16 {UpdateDisplayInfo, special handling for top/bottom lines} {
.t tag remove x 1.0 end
.t yview 4.0
- update
+ updateText
.t yview scroll -2 units
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 3.0} {2.0 3.0}}
test textDisp-4.17 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
@@ -733,9 +753,9 @@ test textDisp-4.17 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
.t delete 1.0 end
.t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
.t insert end "\nLine 3\nLine 4"
- update
+ updateText
.t xview scroll 3 units
- update
+ updateText
list $tk_textRelayout $tk_textRedraw [.t bbox 2.0] [.t bbox 2.5] \
[.t bbox 2.23]
} [list {} {1.0 2.0 3.0 4.0} {} [list 17 [expr {$fixedDiff + 16}] 7 $fixedHeight] {}]
@@ -744,9 +764,9 @@ test textDisp-4.18 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
.t delete 1.0 end
.t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
.t insert end "\nLine 3\nLine 4"
- update
+ updateText
.t xview scroll 100 units
- update
+ updateText
list $tk_textRelayout $tk_textRedraw [.t bbox 2.25]
} [list {} {1.0 2.0 3.0 4.0} [list 10 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
test textDisp-4.19 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
@@ -754,10 +774,10 @@ test textDisp-4.19 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
.t delete 1.0 end
.t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
.t insert end "\nLine 3\nLine 4"
- update
+ updateText
.t xview moveto 0
.t xview scroll -10 units
- update
+ updateText
list $tk_textRelayout $tk_textRedraw [.t bbox 2.5]
} [list {} {1.0 2.0 3.0 4.0} [list 38 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
test textDisp-4.20 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
@@ -767,9 +787,9 @@ test textDisp-4.20 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
.t insert end "\nLine 3\nLine 4"
.t xview moveto 0.0
.t xview scroll 100 units
- update
+ updateText
.t delete 2.30 2.44
- update
+ updateText
list $tk_textRelayout $tk_textRedraw [.t bbox 2.25]
} [list 2.0 {1.0 2.0 3.0 4.0} [list 108 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
test textDisp-4.21 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
@@ -778,9 +798,9 @@ test textDisp-4.21 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
.t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
.t insert end "\nLine 3\nLine 4"
.t xview moveto .9
- update
+ updateText
.t xview moveto .6
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{} {}}
test textDisp-4.22 {UpdateDisplayInfo, no horizontal scrolling except for -wrap none} {textfonts} {
@@ -789,7 +809,7 @@ test textDisp-4.22 {UpdateDisplayInfo, no horizontal scrolling except for -wrap
.t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
.t insert end "\nLine 3\nLine 4"
.t xview scroll 25 units
- update
+ updateText
.t configure -wrap word
list [.t bbox 2.0] [.t bbox 2.16]
} [list [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 10 [expr {2*$fixedDiff + 29}] 7 $fixedHeight]]
@@ -799,7 +819,7 @@ test textDisp-4.23 {UpdateDisplayInfo, no horizontal scrolling except for -wrap
.t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
.t insert end "\nLine 3\nLine 4"
.t xview scroll 25 units
- update
+ updateText
.t configure -wrap char
list [.t bbox 2.0] [.t bbox 2.16]
} [list [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 115 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
@@ -817,7 +837,7 @@ test textDisp-5.1 {DisplayDLine, handling of spacing} {textfonts} {
.t window create 1.7 -window .t.f2 -align center
.t window create 2.1 -window .t.f3 -align bottom
.t window create 2.10 -window .t.f4 -align baseline
- update
+ updateText
list [winfo geometry .t.f1] [winfo geometry .t.f2] \
[winfo geometry .t.f3] [winfo geometry .t.f4]
} [list 10x4+24+11 10x4+55+[expr {$fixedDiff/2 + 15}] 10x4+10+[expr {2*$fixedDiff + 43}] 10x4+76+[expr {2*$fixedDiff + 40}]]
@@ -832,7 +852,7 @@ test textDisp-5.2 {DisplayDLine, line resizes during display} {
frame .t.f -width 20 -height 20 -bd 2 -relief raised
bind .t.f <Configure> {.t.f configure -width 30 -height 30}
.t window create insert -window .t.f
- update
+ updateText
list [winfo width .t.f] [winfo height .t.f]
} [list 30 30]
@@ -843,9 +863,9 @@ test textDisp-6.1 {scrolling in DisplayText, scroll up} {
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t delete 2.0 3.0
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 10.0} {2.0 10.0}}
test textDisp-6.2 {scrolling in DisplayText, scroll down} {
@@ -854,9 +874,9 @@ test textDisp-6.2 {scrolling in DisplayText, scroll down} {
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t insert 2.0 "New Line 2\n"
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 3.0} {2.0 3.0}}
test textDisp-6.3 {scrolling in DisplayText, multiple scrolls} {
@@ -866,10 +886,10 @@ test textDisp-6.3 {scrolling in DisplayText, multiple scrolls} {
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t insert 2.end "is so long that it wraps"
.t insert 4.end "is so long that it wraps"
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 2.20 4.0 4.20} {2.0 2.20 4.0 4.20}}
test textDisp-6.4 {scrolling in DisplayText, scrolls interfere} {
@@ -879,10 +899,10 @@ test textDisp-6.4 {scrolling in DisplayText, scrolls interfere} {
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t insert 2.end "is so long that it wraps around, not once but three times"
.t insert 4.end "is so long that it wraps"
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 2.20 2.40 2.60 4.0 4.20} {2.0 2.20 2.40 2.60 4.0 4.20 6.0}}
test textDisp-6.5 {scrolling in DisplayText, scroll source obscured} {nonPortable} {
@@ -894,9 +914,9 @@ test textDisp-6.5 {scrolling in DisplayText, scroll source obscured} {nonPortabl
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t delete 1.6 1.end
- update
+ updateText
destroy .f2
list $tk_textRelayout $tk_textRedraw
} {{1.0 9.0 10.0} {1.0 4.0 5.0 9.0 10.0}}
@@ -911,41 +931,44 @@ test textDisp-6.6 {scrolling in DisplayText, Expose events after scroll} {unix n
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t delete 1.6 1.end
destroy .f2
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{1.0 9.0 10.0} {borders 1.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0}}
.t configure -bd 0
test textDisp-6.7 {DisplayText, vertical scrollbar updates} {
.t configure -wrap char
.t delete 1.0 end
- update ; .t count -update -ypixels 1.0 end ; update
+ updateText
+ .t count -update -ypixels 1.0 end
+ updateText
set scrollInfo
} {0.0 1.0}
test textDisp-6.8 {DisplayText, vertical scrollbar updates} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "Line 1"
- update
+ updateText
set scrollInfo "unchanged"
foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
.t insert end "\nLine $i"
}
- update ; .t count -update -ypixels 1.0 end ; update
+ updateText
+ .t count -update -ypixels 1.0 end ; update
set scrollInfo
} [list 0.0 [expr {10.0/13}]]
.t configure -yscrollcommand {} -xscrollcommand scroll
test textDisp-6.9 {DisplayText, horizontal scrollbar updates} {
.t configure -wrap none
.t delete 1.0 end
- update
+ updateText
set scrollInfo unchanged
.t insert end xxxxxxxxx\n
.t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
.t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
- update
+ updateText
set scrollInfo
} [list 0.0 [expr {4.0/11}]]
test textDisp-6.10 {DisplayText, redisplay embedded windows after scroll.} {aqua} {
@@ -964,9 +987,9 @@ test textDisp-6.10 {DisplayText, redisplay embedded windows after scroll.} {aqua
.t insert end "\nLine 8\n"
.t window create end -create {
button %W.button_three -text "Button 3"}
- update
+ updateText
.t delete 2.0 3.0
- update
+ updateText
list $tk_textEmbWinDisplay
} {{4.0 6.0}}
@@ -984,61 +1007,61 @@ foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
test textDisp-7.1 {TkTextRedrawRegion} {nonPortable} {
frame .f2 -bg #ff0000
place .f2 -in .t -relx 0.2 -relwidth 0.6 -rely 0.22 -relheight 0.55
- update
+ updateText
destroy .f2
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{} {1.40 2.0 3.0 4.0 5.0 6.0}}
test textDisp-7.2 {TkTextRedrawRegion} {nonPortable} {
frame .f2 -bg #ff0000
place .f2 -in .t -relx 0 -relwidth 0.5 -rely 0 -relheight 0.5
- update
+ updateText
destroy .f2
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{} {borders 1.0 1.20 1.40 2.0 3.0}}
test textDisp-7.3 {TkTextRedrawRegion} {nonPortable} {
frame .f2 -bg #ff0000
place .f2 -in .t -relx 0.5 -relwidth 0.5 -rely 0.5 -relheight 0.5
- update
+ updateText
destroy .f2
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{} {borders 4.0 5.0 6.0 7.0 8.0}}
test textDisp-7.4 {TkTextRedrawRegion} {nonPortable} {
frame .f2 -bg #ff0000
place .f2 -in .t -relx 0.4 -relwidth 0.2 -rely 0 -relheight 0.2 \
-bordermode ignore
- update
+ updateText
destroy .f2
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{} {borders 1.0 1.20}}
test textDisp-7.5 {TkTextRedrawRegion} {nonPortable} {
frame .f2 -bg #ff0000
place .f2 -in .t -relx 0.4 -relwidth 0.2 -rely 1.0 -relheight 0.2 \
-anchor s -bordermode ignore
- update
+ updateText
destroy .f2
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{} {borders 7.0 8.0}}
test textDisp-7.6 {TkTextRedrawRegion} {nonPortable} {
frame .f2 -bg #ff0000
place .f2 -in .t -relx 0 -relwidth 0.2 -rely 0.55 -relheight 0.2 \
-anchor w -bordermode ignore
- update
+ updateText
destroy .f2
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{} {borders 3.0 4.0 5.0}}
test textDisp-7.7 {TkTextRedrawRegion} {nonPortable} {
frame .f2 -bg #ff0000
place .f2 -in .t -relx 1.0 -relwidth 0.2 -rely 0.55 -relheight 0.2 \
-anchor e -bordermode ignore
- update
+ updateText
destroy .f2
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{} {borders 3.0 4.0 5.0}}
test textDisp-7.8 {TkTextRedrawRegion} {nonPortable} {
@@ -1047,9 +1070,9 @@ test textDisp-7.8 {TkTextRedrawRegion} {nonPortable} {
frame .f2 -bg #ff0000
place .f2 -in .t -relx 0.0 -relwidth 0.4 -rely 0.35 -relheight 0.4 \
-anchor nw -bordermode ignore
- update
+ updateText
destroy .f2
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{} {borders 4.0 5.0 6.0 7.0 eof}}
.t configure -bd 0
@@ -1061,9 +1084,9 @@ test textDisp-8.1 {TkTextChanged: redisplay whole lines} {textfonts} {
foreach i {3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t delete 2.36 2.38
- update
+ updateText
list $tk_textRelayout $tk_textRedraw [.t bbox 2.32]
} [list {2.0 2.18 2.38} {2.0 2.18 2.38} [list 101 [expr {2*$fixedDiff + 29}] 7 $fixedHeight]]
.t configure -wrap char
@@ -1073,9 +1096,9 @@ test textDisp-8.2 {TkTextChanged, redisplay whole lines} {
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t insert 1.2 xx
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{1.0 1.20 1.40} {1.0 1.20 1.40}}
test textDisp-8.3 {TkTextChanged} {
@@ -1084,9 +1107,9 @@ test textDisp-8.3 {TkTextChanged} {
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t insert 2.0 xx
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {2.0 2.0}
test textDisp-8.4 {TkTextChanged} {
@@ -1095,9 +1118,9 @@ test textDisp-8.4 {TkTextChanged} {
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t delete 1.5
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{1.0 1.20 1.40} {1.0 1.20 1.40}}
test textDisp-8.5 {TkTextChanged} {
@@ -1106,9 +1129,9 @@ test textDisp-8.5 {TkTextChanged} {
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t delete 1.40 1.44
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{1.0 1.20 1.40} {1.0 1.20 1.40}}
test textDisp-8.6 {TkTextChanged} {
@@ -1117,9 +1140,9 @@ test textDisp-8.6 {TkTextChanged} {
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t delete 1.41 1.44
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{1.0 1.20 1.40} {1.0 1.20 1.40}}
test textDisp-8.7 {TkTextChanged} {
@@ -1128,9 +1151,9 @@ test textDisp-8.7 {TkTextChanged} {
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t delete 1.2 1.end
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{1.0 9.0 10.0} {1.0 9.0 10.0}}
test textDisp-8.8 {TkTextChanged} {
@@ -1139,9 +1162,9 @@ test textDisp-8.8 {TkTextChanged} {
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t delete 2.2
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {2.0 2.0}
test textDisp-8.9 {TkTextChanged} {
@@ -1150,9 +1173,9 @@ test textDisp-8.9 {TkTextChanged} {
foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
.t insert end "\nLine $i"
}
- update
+ updateText
.t delete 2.0 3.0
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 8.0} {2.0 8.0}}
test textDisp-8.10 {TkTextChanged} {
@@ -1160,21 +1183,23 @@ test textDisp-8.10 {TkTextChanged} {
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
.t tag add big 2.19
- update
+ updateText
.t delete 2.19
- update
+ updateText
set tk_textRedraw
} {2.0 2.20 eof}
test textDisp-8.11 {TkTextChanged, scrollbar notification when changes are off-screen} {
.t delete 1.0 end
.t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n"
.t configure -yscrollcommand scroll
- update
+ updateText
set scrollInfo ""
.t insert end "a\nb\nc\n"
# We need to wait for our asychronous callbacks to update the
# scrollbar
- update ; .t count -update -ypixels 1.0 end ; update
+ updateText
+ .t count -update -ypixels 1.0 end
+ updateText
.t configure -yscrollcommand ""
set scrollInfo
} {0.0 0.625}
@@ -1187,27 +1212,27 @@ test textDisp-8.12 {TkTextChanged, moving the insert cursor redraws only past an
.t tag add hidden 5.0 8.0
.t tag configure hidden -elide true
.t mark set insert 9.0
- update
+ updateText
.t mark set insert 8.0 ; # up one line
- update
+ updateText
set res [list $tk_textRedraw]
.t mark set insert 12.2 ; # in the visible text
- update
+ updateText
lappend res $tk_textRedraw
.t mark set insert 6.5 ; # in the hidden text
- update
+ updateText
lappend res $tk_textRedraw
.t mark set insert 3.5 ; # in the visible text again
- update
+ updateText
lappend res $tk_textRedraw
.t mark set insert 3.8 ; # within the same line
- update
+ updateText
lappend res $tk_textRedraw
} {{8.0 9.0} {8.0 12.0} {8.0 12.0} {3.0 8.0} {3.0 4.0}}
test textDisp-8.13 {TkTextChanged, used to crash, see [06c1433906]} {
.t delete 1.0 end
.t insert 1.0 \nLine2\nLine3\n
- update
+ updateText
.t insert 3.0 ""
.t delete 1.0 2.0
update idletasks
@@ -1217,62 +1242,62 @@ test textDisp-9.1 {TkTextRedrawTag} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
- update
+ updateText
.t tag add big 2.2 2.4
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 2.18} {2.0 2.18}}
test textDisp-9.2 {TkTextRedrawTag} {textfonts} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
- update
+ updateText
.t tag add big 1.2 2.4
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{1.0 2.0 2.17} {1.0 2.0 2.17}}
test textDisp-9.3 {TkTextRedrawTag} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
- update
+ updateText
.t tag add big 2.2 2.4
- update
+ updateText
.t tag remove big 1.0 end
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 2.20} {2.0 2.20 eof}}
test textDisp-9.4 {TkTextRedrawTag} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
- update
+ updateText
.t tag add big 2.2 2.20
- update
+ updateText
.t tag remove big 1.0 end
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 2.20} {2.0 2.20 eof}}
test textDisp-9.5 {TkTextRedrawTag} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
- update
+ updateText
.t tag add big 2.2 2.end
- update
+ updateText
.t tag remove big 1.0 end
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 2.20} {2.0 2.20 eof}}
test textDisp-9.6 {TkTextRedrawTag} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap"
- update
+ updateText
.t tag add big 2.2 3.5
- update
+ updateText
.t tag remove big 1.0 end
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 2.20 3.0 3.20} {2.0 2.20 3.0 3.20 eof}}
test textDisp-9.7 {TkTextRedrawTag} {
@@ -1280,9 +1305,9 @@ test textDisp-9.7 {TkTextRedrawTag} {
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
.t tag add big 2.19
- update
+ updateText
.t tag remove big 2.19
- update
+ updateText
set tk_textRedraw
} {2.0 2.20 eof}
test textDisp-9.8 {TkTextRedrawTag} {textfonts} {
@@ -1290,9 +1315,9 @@ test textDisp-9.8 {TkTextRedrawTag} {textfonts} {
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
.t tag add big 1.0 2.0
- update
+ updateText
.t tag add big 2.0 2.5
- update
+ updateText
set tk_textRedraw
} {2.0 2.17}
test textDisp-9.9 {TkTextRedrawTag} {textfonts} {
@@ -1300,9 +1325,9 @@ test textDisp-9.9 {TkTextRedrawTag} {textfonts} {
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
.t tag add big 1.0 2.0
- update
+ updateText
.t tag add big 1.5 2.5
- update
+ updateText
set tk_textRedraw
} {2.0 2.17}
test textDisp-9.10 {TkTextRedrawTag} {
@@ -1310,10 +1335,10 @@ test textDisp-9.10 {TkTextRedrawTag} {
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
.t tag add big 1.0 2.0
- update
+ updateText
set tk_textRedraw {none}
.t tag add big 1.3 1.5
- update
+ updateText
set tk_textRedraw
} {none}
test textDisp-9.11 {TkTextRedrawTag} {
@@ -1321,9 +1346,9 @@ test textDisp-9.11 {TkTextRedrawTag} {
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
.t tag add big 1.0 2.0
- update
+ updateText
.t tag add big 1.0 2.0
- update
+ updateText
set tk_textRedraw
} {}
test textDisp-9.12 {TkTextRedrawTag} {
@@ -1334,24 +1359,24 @@ test textDisp-9.12 {TkTextRedrawTag} {
}
.t tag configure hidden -elide true
.t tag add hidden 2.6 3.6
- update
+ updateText
.t tag add hidden 3.11 4.6
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {2.0 {2.0 eof}}
test textDisp-9.13 {TkTextRedrawTag} {
.t configure -wrap none
.t delete 1.0 end
for {set i 1} {$i < 10} {incr i} {
- .t insert end "Line $i - This is Line [format %c [expr 64+$i]]\n"
+ .t insert end "Line $i - This is Line [format %c [expr {64+$i}]]\n"
}
.t tag add hidden 2.8 2.17
.t tag add hidden 6.8 7.17
.t tag configure hidden -background red
.t tag configure hidden -elide true
- update
+ updateText
.t tag configure hidden -elide false
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{2.0 6.0 7.0} {2.0 6.0 7.0}}
test textDisp-9.14 {TkTextRedrawTag} {
@@ -1361,7 +1386,7 @@ test textDisp-9.14 {TkTextRedrawTag} {
}
.tnocrash tag configure mytag1 -relief raised
.tnocrash tag configure mytag2 -relief solid
- update
+ updateText
proc doit {} {
.tnocrash tag add mytag1 4.0 5.0
.tnocrash tag add mytag2 4.0 5.0
@@ -1383,9 +1408,9 @@ test textDisp-10.1 {TkTextRelayoutWindow} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
- update
+ updateText
.t configure -bg black
- update
+ updateText
list $tk_textRelayout $tk_textRedraw
} {{1.0 2.0 2.20 3.0 3.20 4.0} {borders 1.0 2.0 2.20 3.0 3.20 4.0 eof}}
.t configure -bg [lindex [.t configure -bg] 3]
@@ -1399,7 +1424,7 @@ test textDisp-10.2 {TkTextRelayoutWindow} {
.top.t see insert
tkwait visibility .top.t
place .top.t -width 150 -height 100
- update
+ updateText
.top.t index @0,0
} {1.0}
catch {destroy .top}
@@ -1409,96 +1434,96 @@ catch {destroy .top}
for {set i 2} {$i <= 200} {incr i} {
.t insert end "\nLine $i"
}
-update
+updateText
test textDisp-11.1 {TkTextSetYView} {
.t yview 30.0
- update
+ updateText
.t index @0,0
} {30.0}
test textDisp-11.2 {TkTextSetYView} {
.t yview 30.0
- update
+ updateText
.t yview 32.0
- update
+ updateText
list [.t index @0,0] $tk_textRedraw
} {32.0 {40.0 41.0}}
test textDisp-11.3 {TkTextSetYView} {
.t yview 30.0
- update
+ updateText
.t yview 28.0
- update
+ updateText
list [.t index @0,0] $tk_textRedraw
} {28.0 {28.0 29.0}}
test textDisp-11.4 {TkTextSetYView} {
.t yview 30.0
- update
+ updateText
.t yview 31.4
- update
+ updateText
list [.t index @0,0] $tk_textRedraw
} {31.0 40.0}
test textDisp-11.5 {TkTextSetYView} {
.t yview 30.0
- update
+ updateText
set tk_textRedraw {}
.t yview -pickplace 31.0
- update
+ updateText
list [.t index @0,0] $tk_textRedraw
} {30.0 {}}
test textDisp-11.6 {TkTextSetYView} {
.t yview 30.0
- update
+ updateText
set tk_textRedraw {}
.t yview -pickplace 28.0
- update
+ updateText
list [.t index @0,0] $tk_textRedraw
} {28.0 {28.0 29.0}}
test textDisp-11.7 {TkTextSetYView} {
.t yview 30.0
- update ; update
+ updateText
set tk_textRedraw {}
.t yview -pickplace 26.0
- update
+ updateText
list [.t index @0,0] $tk_textRedraw
} {21.0 {21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0}}
test textDisp-11.8 {TkTextSetYView} {
.t yview 30.0
- update
+ updateText
set tk_textRedraw {}
.t yview -pickplace 41.0
- update
+ updateText
list [.t index @0,0] $tk_textRedraw
} {32.0 {40.0 41.0}}
test textDisp-11.9 {TkTextSetYView} {
.t yview 30.0
- update
+ updateText
set tk_textRedraw {}
.t yview -pickplace 43.0
- update
+ updateText
list [.t index @0,0] $tk_textRedraw
} {38.0 {40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0}}
test textDisp-11.10 {TkTextSetYView} {
.t yview 30.0
- update
+ updateText
set tk_textRedraw {}
.t yview 10000.0
- update
+ updateText
list [.t index @0,0] $tk_textRedraw
} {191.0 {191.0 192.0 193.0 194.0 195.0 196.0 197.0 198.0 199.0 200.0}}
test textDisp-11.11 {TkTextSetYView} {
.t yview 195.0
- update
+ updateText
set tk_textRedraw {}
.t yview 197.0
- update
+ updateText
list [.t index @0,0] $tk_textRedraw
} {191.0 {191.0 192.0 193.0 194.0 195.0 196.0}}
test textDisp-11.12 {TkTextSetYView, wrapped line is off-screen} {
.t insert 10.0 "Long line with enough text to wrap\n"
.t yview 1.0
- update
+ updateText
set tk_textRedraw {}
.t see 10.30
- update
+ updateText
list [.t index @0,0] $tk_textRedraw
} {2.0 10.20}
.t delete 10.0 11.0
@@ -1512,15 +1537,15 @@ test textDisp-11.13 {TkTestSetYView, partially visible last line} {
for {set i 2} {$i <= 100} {incr i} {
.top.t insert end "\nLine $i"
}
- update
+ updateText
scan [wm geometry .top] "%dx%d" w2 h2
- wm geometry .top ${w2}x[expr $h2-2]
- update
+ wm geometry .top ${w2}x[expr {$h2-2}]
+ updateText
.top.t yview 1.0
- update
+ updateText
set tk_textRedraw {}
.top.t see 5.0
- update
+ updateText
# Note, with smooth scrolling, the results of this test
# have changed, and the old '2.0 {5.0 6.0}' is quite wrong.
list [.top.t index @0,0] $tk_textRedraw
@@ -1534,29 +1559,29 @@ pack .top.t
for {set i 2} {$i <= 20} {incr i} {
.top.t insert end "\nLine $i"
}
-update
+updateText
test textDisp-11.14 {TkTextSetYView, only a few lines visible} {
.top.t yview 5.0
- update
+ updateText
.top.t see 10.0
.top.t index @0,0
} {8.0}
test textDisp-11.15 {TkTextSetYView, only a few lines visible} {
.top.t yview 5.0
- update
+ updateText
.top.t see 11.0
.top.t index @0,0
# The index 9.0 should be just visible by a couple of pixels
} {9.0}
test textDisp-11.16 {TkTextSetYView, only a few lines visible} {
.top.t yview 8.0
- update
+ updateText
.top.t see 5.0
.top.t index @0,0
} {5.0}
test textDisp-11.17 {TkTextSetYView, only a few lines visible} {
.top.t yview 8.0
- update
+ updateText
.top.t see 4.0
.top.t index @0,0
# The index 2.0 should be just visible by a couple of pixels
@@ -1571,7 +1596,7 @@ test textDisp-11.18 {TkTextSetYView, see in elided lines} {
.top.t tag add hidden 4.10 "4.10 lineend"
.top.t tag add hidden 5.15 10.3
.top.t tag configure hidden -elide true
- update
+ updateText
.top.t see "8.0 lineend"
# The index "8.0 lineend" is on screen despite elided -> no scroll
.top.t index @0,0
@@ -1591,19 +1616,19 @@ test textDisp-11.19 {TkTextSetYView, see in elided lines} {
# Indices 21.0, 17.0 and 15.0 are all on the same display line
# therefore index @0,0 shall be the same for all of them
.top.t see end
- update
+ updateText
.top.t see 21.0
- update
+ updateText
set ind1 [.top.t index @0,0]
.top.t see end
- update
+ updateText
.top.t see 17.0
- update
+ updateText
set ind2 [.top.t index @0,0]
.top.t see end
- update
+ updateText
.top.t see 15.0
- update
+ updateText
set ind3 [.top.t index @0,0]
list [expr {$ind1 == $ind2}] [expr {$ind1 == $ind3}]
} {1 1}
@@ -1626,7 +1651,7 @@ test textDisp-11.21 {TkTextSetYView, window height smaller than the line height}
}
set lineheight [font metrics [.top.t cget -font] -linespace]
wm geometry .top 200x[expr {$lineheight / 2}]
- update
+ updateText
.top.t see 1.0
.top.t index @0,[expr {$lineheight - 2}]
} {1.0}
@@ -1636,38 +1661,38 @@ test textDisp-11.21 {TkTextSetYView, window height smaller than the line height}
.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
test textDisp-12.1 {MeasureUp} {
.t yview 100.0
- update
+ updateText
.t yview -pickplace 52.0
- update
+ updateText
.t index @0,0
} {49.0}
test textDisp-12.2 {MeasureUp} {
.t yview 100.0
- update
+ updateText
.t yview -pickplace 53.0
- update
+ updateText
.t index @0,0
} {50.0}
test textDisp-12.3 {MeasureUp} {
.t yview 100.0
- update
+ updateText
.t yview -pickplace 50.10
- update
+ updateText
.t index @0,0
} {45.0}
.t configure -wrap none
test textDisp-12.4 {MeasureUp} {
.t yview 100.0
- update
+ updateText
.t yview -pickplace 53.0
- update
+ updateText
.t index @0,0
} {48.0}
test textDisp-12.5 {MeasureUp} {
.t yview 100.0
- update
+ updateText
.t yview -pickplace 50.10
- update
+ updateText
.t index @0,0
} {45.0}
@@ -1690,7 +1715,7 @@ test textDisp-13.3 {TkTextSeeCmd procedure} {
test textDisp-13.4 {TkTextSeeCmd procedure} {
.t xview moveto 0
.t yview moveto 0
- update
+ updateText
.t see 4.2
.t index @0,0
} {1.0}
@@ -1698,7 +1723,7 @@ test textDisp-13.5 {TkTextSeeCmd procedure} {
.t configure -wrap char
.t xview moveto 0
.t yview moveto 0
- update
+ updateText
.t see 12.1
.t index @0,0
} {3.0}
@@ -1706,7 +1731,7 @@ test textDisp-13.6 {TkTextSeeCmd procedure} {
.t configure -wrap char
.t xview moveto 0
.t yview moveto 0
- update
+ updateText
.t see 30.50
set x [.t index @0,0]
.t configure -wrap none
@@ -1717,7 +1742,7 @@ test textDisp-13.7 {TkTextSeeCmd procedure} {textfonts} {
.t yview moveto 0
.t tag add sel 30.20
.t tag add sel 30.40
- update
+ updateText
.t see 30.50
.t yview 25.0
.t see 30.50
@@ -1734,7 +1759,7 @@ test textDisp-13.8 {TkTextSeeCmd procedure} {textfonts} {
.t yview moveto 0
.t tag add sel 30.20
.t tag add sel 30.50
- update
+ updateText
.t see 30.50
set x [list [.t bbox 30.50]]
.t see 30.60
@@ -1745,12 +1770,12 @@ test textDisp-13.8 {TkTextSeeCmd procedure} {textfonts} {
lappend x [.t bbox 30.90]
} [list [list 73 [expr {9*$fixedDiff/2 + 64}] 7 $fixedHeight] [list 136 [expr {9*$fixedDiff/2 + 64}] 7 $fixedHeight] [list 136 [expr {9*$fixedDiff/2 + 64}] 7 $fixedHeight] [list 73 [expr {9*$fixedDiff/2 + 64}] 7 $fixedHeight]]
test textDisp-13.9 {TkTextSeeCmd procedure} {textfonts} {
- wm geom . [expr $width-2]x$height
+ wm geom . [expr {$width-2}]x$height
.t xview moveto 0
.t yview moveto 0
.t tag add sel 30.20
.t tag add sel 30.50
- update
+ updateText
.t see 30.50
set x [list [.t bbox 30.50]]
.t see 30.60
@@ -1782,13 +1807,13 @@ test textDisp-13.11 {TkTextSeeCmd procedure} {} {
}
wm geometry .top2 300x200+0+0
- update
+ updateText
.top2.t2 see "1.0 lineend"
- update
+ updateText
set ref [.top2.t2 index @0,0]
.top2.t2 insert "1.0 lineend" ç
.top2.t2 see "1.0 lineend"
- update
+ updateText
set new [.top2.t2 index @0,0]
set res [.top2.t2 compare $ref == $new]
destroy .top2
@@ -1799,7 +1824,7 @@ wm geom . {}
.t configure -wrap none
test textDisp-14.1 {TkTextXviewCmd procedure} {
.t delete 1.0 end
- update
+ updateText
.t insert end xxxxxxxxx\n
.t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
.t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
@@ -1809,7 +1834,7 @@ test textDisp-14.1 {TkTextXviewCmd procedure} {
.t configure -wrap char
test textDisp-14.2 {TkTextXviewCmd procedure} {
.t delete 1.0 end
- update
+ updateText
.t insert end xxxxxxxxx\n
.t insert end "xxxxx\n"
.t insert end "xxxx"
@@ -1818,7 +1843,7 @@ test textDisp-14.2 {TkTextXviewCmd procedure} {
.t configure -wrap none
test textDisp-14.3 {TkTextXviewCmd procedure} {
.t delete 1.0 end
- update
+ updateText
.t insert end xxxxxxxxx\n
.t insert end "xxxxx\n"
.t insert end "xxxx"
@@ -1859,10 +1884,10 @@ test textDisp-14.9 {TkTextXviewCmd procedure} {
} [list [expr {9.0/14}] 1.0]
test textDisp-14.10 {TkTextXviewCmd procedure} {
list [catch {.t xview scroll a} msg] $msg
-} {1 {wrong # args: should be ".t xview scroll number units|pages|pixels"}}
+} {1 {wrong # args: should be ".t xview scroll number pages|pixels|units"}}
test textDisp-14.11 {TkTextXviewCmd procedure} {
list [catch {.t xview scroll a b c} msg] $msg
-} {1 {wrong # args: should be ".t xview scroll number units|pages|pixels"}}
+} {1 {wrong # args: should be ".t xview scroll number pages|pixels|units"}}
test textDisp-14.12 {TkTextXviewCmd procedure} {
list [catch {.t xview scroll gorp units} msg] $msg
} {1 {expected integer but got "gorp"}}
@@ -1896,7 +1921,7 @@ test textDisp-14.14 {TkTextXviewCmd procedure} {
} {2.21 2.20 2.99 2.84}
test textDisp-14.15 {TkTextXviewCmd procedure} {
list [catch {.t xview scroll 14 globs} msg] $msg
-} {1 {bad argument "globs": must be units, pages, or pixels}}
+} {1 {bad argument "globs": must be pages, pixels, or units}}
test textDisp-14.16 {TkTextXviewCmd procedure} {
list [catch {.t xview flounder} msg] $msg
} {1 {bad option "flounder": must be moveto or scroll}}
@@ -1911,43 +1936,43 @@ for {set i 1} {$i < 99} {incr i} {
.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
test textDisp-15.1 {ScrollByLines procedure, scrolling backwards} {
.t yview 45.0
- update
+ updateText
.t yview scroll -3 units
.t index @0,0
} {42.0}
test textDisp-15.2 {ScrollByLines procedure, scrolling backwards} {
.t yview 51.0
- update
+ updateText
.t yview scroll -2 units
.t index @0,0
} {50.20}
test textDisp-15.3 {ScrollByLines procedure, scrolling backwards} {
.t yview 51.0
- update
+ updateText
.t yview scroll -4 units
.t index @0,0
} {49.0}
test textDisp-15.4 {ScrollByLines procedure, scrolling backwards} {
.t yview 50.20
- update
+ updateText
.t yview scroll -2 units
.t index @0,0
} {49.0}
test textDisp-15.5 {ScrollByLines procedure, scrolling backwards} {
.t yview 50.40
- update
+ updateText
.t yview scroll -2 units
.t index @0,0
} {50.0}
test textDisp-15.6 {ScrollByLines procedure, scrolling backwards} {
.t yview 3.2
- update
+ updateText
.t yview scroll -5 units
.t index @0,0
} {1.0}
test textDisp-15.7 {ScrollByLines procedure, scrolling forwards} {
.t yview 48.0
- update
+ updateText
.t yview scroll 4 units
.t index @0,0
} {50.40}
@@ -1973,7 +1998,7 @@ test textDisp-15.8 {Scrolling near end of window} {
for {set i 1} {$i < $textheight} {incr i} {
.tf.f.t insert end "\nLine $i"
}
- update ; after 1000 ; update
+ updateText
set refind [.tf.f.t index @0,[winfo height .tf.f.t]]
# Should scroll and should not crash!
.tf.f.t yview scroll 1 unit
@@ -1993,7 +2018,8 @@ for {set i 2} {$i <= 200} {incr i} {
.t tag add big 100.0 105.0
.t insert 151.end { has a lot of extra text, so that it wraps around on the screen several times over.}
.t insert 153.end { also has enoug extra text to wrap.}
-update ; .t count -update -ypixels 1.0 end
+updateText
+.t count -update -ypixels 1.0 end
test textDisp-16.1 {TkTextYviewCmd procedure} {
.t yview 21.0
set x [.t yview]
@@ -2014,7 +2040,7 @@ test textDisp-16.5 {TkTextYviewCmd procedure} {
} {1 {bad option "-bogus": must be moveto or scroll}}
test textDisp-16.6 {TkTextYviewCmd procedure, integer position} {
.t yview 100.0
- update
+ updateText
.t yview 98
.t index @0,0
} {99.0}
@@ -2069,7 +2095,7 @@ test textDisp-16.18 {TkTextYviewCmd procedure, "moveto" roundoff} {textfonts} {
text .top1.t -height 3 -width 4 -wrap none -setgrid 1 -padx 6 \
-spacing3 6
pack .top1.t
- update
+ updateText
.top1.t insert end "1\n2\n3\n4\n5\n6"
.top1.t yview moveto 0.3333
set result [.top1.t yview]
@@ -2078,65 +2104,65 @@ test textDisp-16.18 {TkTextYviewCmd procedure, "moveto" roundoff} {textfonts} {
} [list [expr {1.0/3}] [expr {5.0/6}]]
test textDisp-16.19 {TkTextYviewCmd procedure, "scroll" option} {
list [catch {.t yview scroll a} msg] $msg
-} {1 {wrong # args: should be ".t yview scroll number units|pages|pixels"}}
+} {1 {wrong # args: should be ".t yview scroll number pages|pixels|units"}}
test textDisp-16.20 {TkTextYviewCmd procedure, "scroll" option} {
list [catch {.t yview scroll a b c} msg] $msg
-} {1 {wrong # args: should be ".t yview scroll number units|pages|pixels"}}
+} {1 {wrong # args: should be ".t yview scroll number pages|pixels|units"}}
test textDisp-16.21 {TkTextYviewCmd procedure, "scroll" option} {
list [catch {.t yview scroll badInt bogus} msg] $msg
-} {1 {bad argument "bogus": must be units, pages, or pixels}}
+} {1 {bad argument "bogus": must be pages, pixels, or units}}
test textDisp-16.21.2 {TkTextYviewCmd procedure, "scroll" option} {
list [catch {.t yview scroll badInt units} msg] $msg
} {1 {expected integer but got "badInt"}}
test textDisp-16.22 {TkTextYviewCmd procedure, "scroll" option, back pages} {
.t yview 50.0
- update
+ updateText
.t yview scroll -1 pages
.t index @0,0
} {42.0}
test textDisp-16.22.1 {TkTextYviewCmd procedure, "scroll" option, back pages} {
list [catch {.t yview scroll -3 p} res] $res
-} {1 {ambiguous argument "p": must be units, pages, or pixels}}
+} {1 {ambiguous argument "p": must be pages, pixels, or units}}
test textDisp-16.23 {TkTextYviewCmd procedure, "scroll" option, back pages} {
.t yview 50.0
- update
+ updateText
.t yview scroll -3 pa
.t index @0,0
} {26.0}
test textDisp-16.24 {TkTextYviewCmd procedure, "scroll" option, back pages} {
.t yview 5.0
- update
+ updateText
.t yview scroll -3 pa
.t index @0,0
} {1.0}
test textDisp-16.25 {TkTextYviewCmd procedure, "scroll" option, back pages} {
.t configure -height 1
- update
+ updateText
.t yview 50.0
- update
+ updateText
.t yview scroll -1 pages
set x [.t index @0,0]
.t configure -height 10
- update
+ updateText
set x
} {49.0}
test textDisp-16.26 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
.t yview 50.0
- update
+ updateText
.t yview scroll 1 pages
.t index @0,0
} {58.0}
test textDisp-16.27 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
.t yview 50.0
- update
+ updateText
.t yview scroll 2 pages
.t index @0,0
} {66.0}
test textDisp-16.28 {TkTextYviewCmd procedure, "scroll" option, forward pages} {textfonts} {
.t yview 98.0
- update
+ updateText
.t yview scroll 1 page
- set res [expr int([.t index @0,0])]
+ set res [expr {int([.t index @0,0])}]
if {$fixedDiff > 1} {
incr res -1
}
@@ -2144,30 +2170,30 @@ test textDisp-16.28 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
} {102}
test textDisp-16.29 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
.t configure -height 1
- update
+ updateText
.t yview 50.0
- update
+ updateText
.t yview scroll 1 pages
set x [.t index @0,0]
.t configure -height 10
- update
+ updateText
set x
} {51.0}
test textDisp-16.30 {TkTextYviewCmd procedure, "scroll units" option} {
.t yview 45.0
- update
+ updateText
.t yview scroll -3 units
.t index @0,0
} {42.0}
test textDisp-16.31 {TkTextYviewCmd procedure, "scroll units" option} {
.t yview 149.0
- update
+ updateText
.t yview scroll 4 units
.t index @0,0
} {151.40}
test textDisp-16.32 {TkTextYviewCmd procedure} {
list [catch {.t yview scroll 12 bogoids} msg] $msg
-} {1 {bad argument "bogoids": must be units, pages, or pixels}}
+} {1 {bad argument "bogoids": must be pages, pixels, or units}}
test textDisp-16.33 {TkTextYviewCmd procedure} {
list [catch {.t yview bad_arg 1 2} msg] $msg
} {1 {bad option "bad_arg": must be moveto or scroll}}
@@ -2266,7 +2292,7 @@ test textDisp-16.42 {TkTextYviewCmd procedure with indices in elided lines} {
.t tag configure hidden -elide true
.t yview 35.0
.t yview scroll [expr {- 15 * $fixedHeight}] pixels
- update
+ updateText
.t index @0,0
} {5.0}
test textDisp-16.43 {TkTextYviewCmd procedure with indices in elided lines} {
@@ -2280,7 +2306,7 @@ test textDisp-16.43 {TkTextYviewCmd procedure with indices in elided lines} {
.t tag configure hidden -elide true
.t yview 35.0
.t yview scroll -15 units
- update
+ updateText
.t index @0,0
} {5.0}
test textDisp-16.44 {TkTextYviewCmd procedure, scroll down, with elided lines} {
@@ -2291,9 +2317,9 @@ test textDisp-16.44 {TkTextYviewCmd procedure, scroll down, with elided lines} {
.t insert end "$x 1111\n$x 2222\n$x 3333\n$x 4444\n$x 5555\n$x 6666" hidden
}
.t tag configure hidden -elide true ; # 5 hidden lines
- update
- .t see [expr {5 + [winfo height .t] / $fixedHeight} + 1].0
- update
+ updateText
+ .t see [expr {5 + [winfo height .t] / $fixedHeight + 1}].0
+ updateText
.t index @0,0
} {2.0}
@@ -2369,7 +2395,7 @@ test textDisp-18.1 {GetXView procedure} {
.t insert end xxxxxxxxx\n
.t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
.t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
- update
+ updateText
set scrollInfo
} [list 0.0 [expr {4.0/11}]]
test textDisp-18.2 {GetXView procedure} {
@@ -2378,13 +2404,13 @@ test textDisp-18.2 {GetXView procedure} {
.t insert end xxxxxxxxx\n
.t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
.t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
- update
+ updateText
set scrollInfo
} {0.0 1.0}
test textDisp-18.3 {GetXView procedure} {
.t configure -wrap none
.t delete 1.0 end
- update
+ updateText
set scrollInfo
} {0.0 1.0}
test textDisp-18.4 {GetXView procedure} {
@@ -2393,7 +2419,7 @@ test textDisp-18.4 {GetXView procedure} {
.t insert end xxxxxxxxx\n
.t insert end xxxxxx\n
.t insert end xxxxxxxxxxxxxxxxx
- update
+ updateText
set scrollInfo
} {0.0 1.0}
test textDisp-18.5 {GetXView procedure} {
@@ -2403,7 +2429,7 @@ test textDisp-18.5 {GetXView procedure} {
.t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
.t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
.t xview scroll 31 units
- update
+ updateText
set scrollInfo
} [list [expr {31.0/55}] [expr {51.0/55}]]
test textDisp-18.6 {GetXView procedure} {
@@ -2414,27 +2440,27 @@ test textDisp-18.6 {GetXView procedure} {
.t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
.t xview moveto 0
.t xview scroll 31 units
- update
+ updateText
set x {}
lappend x $scrollInfo
.t configure -wrap char
- update
+ updateText
lappend x $scrollInfo
.t configure -wrap word
- update
+ updateText
lappend x $scrollInfo
.t configure -wrap none
- update
+ updateText
lappend x $scrollInfo
} [list [list [expr {31.0/56}] [expr {51.0/56}]] {0.0 1.0} {0.0 1.0} [list 0.0 [expr {5.0/14}]]]
test textDisp-18.7 {GetXView procedure} {
.t configure -wrap none
.t delete 1.0 end
- update
+ updateText
set scrollInfo unchanged
.t insert end xxxxxx\n
.t insert end xxx
- update
+ updateText
set scrollInfo
} {unchanged}
test textDisp-18.8 {GetXView procedure} {
@@ -2448,10 +2474,10 @@ test textDisp-18.8 {GetXView procedure} {
.t configure -wrap none
.t delete 1.0 end
.t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
- update
+ updateText
.t delete 1.0 end
.t configure -xscrollcommand scrollError
- update
+ updateText
set x
} {{scrolling error} {scrolling error
while executing
@@ -2468,37 +2494,37 @@ catch {rename bogus {}}
test textDisp-19.1 {GetYView procedure} {
.t configure -wrap char
.t delete 1.0 end
- update
+ updateText
set scrollInfo
} {0.0 1.0}
test textDisp-19.2 {GetYView procedure} {
.t configure -wrap char
.t delete 1.0 end
- update
+ updateText
set scrollInfo "unchanged"
.t insert 1.0 "Line1\nLine2"
- update
+ updateText
set scrollInfo
} {unchanged}
test textDisp-19.3 {GetYView procedure} {
.t configure -wrap char
.t delete 1.0 end
- update; after 10 ; update
+ updateText
set scrollInfo "unchanged"
.t insert 1.0 "Line 1\nLine 2 is so long that it wraps around\nLine 3"
- update
+ updateText
set scrollInfo
} {unchanged}
test textDisp-19.4 {GetYView procedure} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "Line 1"
- update
+ updateText
set scrollInfo "unchanged"
foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
.t insert end "\nLine $i"
}
- update
+ updateText
set scrollInfo
} [list 0.0 [expr {70.0/91}]]
test textDisp-19.5 {GetYView procedure} {
@@ -2509,7 +2535,7 @@ test textDisp-19.5 {GetYView procedure} {
.t insert end "\nLine $i"
}
.t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
- update ; after 100
+ updateText
set x $scrollInfo
} {0.0 0.625}
test textDisp-19.6 {GetYView procedure} {
@@ -2521,7 +2547,7 @@ test textDisp-19.6 {GetYView procedure} {
}
.t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
.t yview 4.0
- update
+ updateText
set x $scrollInfo
} {0.375 1.0}
test textDisp-19.7 {GetYView procedure} {
@@ -2533,7 +2559,7 @@ test textDisp-19.7 {GetYView procedure} {
}
.t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
.t yview 2.26
- update; after 1; update
+ updateText
set x $scrollInfo
} {0.125 0.75}
test textDisp-19.8 {GetYView procedure} {
@@ -2545,7 +2571,7 @@ test textDisp-19.8 {GetYView procedure} {
}
.t insert 10.end " is really quite long; in fact it's so long that it wraps three times"
.t yview 2.0
- update
+ updateText
.t count -update -ypixels 1.0 end
set x $scrollInfo
} {0.0625 0.6875}
@@ -2557,7 +2583,7 @@ test textDisp-19.9 {GetYView procedure} {
.t insert end "\nLine $i"
}
.t yview 3.0
- update
+ updateText
set scrollInfo
} [list [expr {4.0/30}] 0.8]
test textDisp-19.10 {GetYView procedure} {
@@ -2568,7 +2594,7 @@ test textDisp-19.10 {GetYView procedure} {
.t insert end "\nLine $i"
}
.t yview 11.0
- update
+ updateText
set scrollInfo
} [list [expr {1.0/3}] 1.0]
test textDisp-19.10.1 {Widget manipulation causes height miscount} {
@@ -2579,7 +2605,7 @@ test textDisp-19.10.1 {Widget manipulation causes height miscount} {
.t insert end "\nLine $i"
}
.t yview 11.0
- update
+ updateText
.t configure -wrap word
.t delete 1.0 end
.t insert 1.0 "Line 1"
@@ -2589,7 +2615,7 @@ test textDisp-19.10.1 {Widget manipulation causes height miscount} {
.t insert end "\nThis last line wraps around four "
.t insert end "times with a little bit left on the last line."
.t yview insert
- update
+ updateText
.t count -update -ypixels 1.0 end
set scrollInfo
} {0.5 1.0}
@@ -2603,7 +2629,7 @@ test textDisp-19.11 {GetYView procedure} {
.t insert end "\nThis last line wraps around four "
.t insert end "times with a little bit left on the last line."
.t yview insert
- update
+ updateText
.t count -update -ypixels 1.0 end
set scrollInfo
} {0.5 1.0}
@@ -2741,10 +2767,10 @@ test textDisp-19.12 {GetYView procedure, partially visible last line} {
pack .top.t -expand yes -fill both
.top.t insert end "Line 1\nLine 2\nLine 3\nLine 4\nLine 5"
# Need to wait for asychronous calculations to complete.
- update ; after 10
+ updateText
scan [wm geom .top] %dx%d twidth theight
- wm geom .top ${twidth}x[expr $theight - 3]
- update
+ wm geom .top ${twidth}x[expr {$theight - 3}]
+ updateText
.top.t yview
} [list 0.0 [expr {(5.0 * $fixedHeight - 3.0)/ (5.0 * $fixedHeight)}]]
test textDisp-19.13 {GetYView procedure, partially visible last line} {textfonts} {
@@ -2755,10 +2781,10 @@ test textDisp-19.13 {GetYView procedure, partially visible last line} {textfonts
pack .top.t -expand yes -fill both
.top.t insert end "Line 1\nLine 2\nLine 3\nLine 4 has enough text to wrap around at least once"
# Need to wait for asychronous calculations to complete.
- update ; after 10
+ updateText
scan [wm geom .top] %dx%d twidth theight
- wm geom .top ${twidth}x[expr $theight - 3]
- update
+ wm geom .top ${twidth}x[expr {$theight - 3}]
+ updateText
.top.t yview
} [list 0.0 [expr {(5.0 * $fixedHeight - 3.0)/ (5.0 * $fixedHeight)}]]
catch {destroy .top}
@@ -2772,13 +2798,14 @@ test textDisp-19.14 {GetYView procedure} {
.t insert end "\nThis last line wraps around four "
.t insert end "times with a little bit left on the last line."
# Need to update so everything is calculated.
- update ; .t count -update -ypixels 1.0 end
- update ; after 10 ; update
+ updateText
+ .t count -update -ypixels 1.0 end
+ updateText
set scrollInfo "unchanged"
.t mark set insert 3.0
.t tag configure x -background red
.t tag add x 1.0 5.0
- update
+ updateText
.t tag delete x
set scrollInfo
} {unchanged}
@@ -2791,14 +2818,14 @@ test textDisp-19.15 {GetYView procedure} {
}
.t insert end "\nThis last line wraps around four "
.t insert end "times with a bit little left on the last line."
- update
+ updateText
.t configure -yscrollcommand scrollError
proc bgerror args {
global x errorInfo errorCode
set x [list $args $errorInfo $errorCode]
}
.t delete 1.0 end
- update
+ updateText
rename bgerror {}
.t configure -yscrollcommand scroll
set x
@@ -2820,7 +2847,9 @@ test textDisp-19.16 {count -ypixels} {
.t insert end "\nThis last line wraps around four "
.t insert end "times with a little bit left on the last line."
# Need to update so everything is calculated.
- update ; .t count -update -ypixels 1.0 end ; update
+ updateText
+ .t count -update -ypixels 1.0 end
+ updateText
set res {}
lappend res \
[.t count -ypixels 1.0 end] \
@@ -2871,7 +2900,7 @@ test textDisp-19.18 {count -ypixels with indices in elided lines} {
update
lappend res [.t count -ypixels 5.0 25.0]
.t yview scroll [expr {- 15 * $fixedHeight}] pixels
- update
+ updateText
lappend res [.t count -ypixels 5.0 25.0]
} [list [expr {5 * $fixedHeight}] [expr {5 * $fixedHeight}]]
test textDisp-19.19 {count -ypixels with indices in elided lines} {
@@ -2884,7 +2913,7 @@ test textDisp-19.19 {count -ypixels with indices in elided lines} {
.t tag add hidden 5.27 11.0
.t tag configure hidden -elide true
.t yview 5.0
- update
+ updateText
set res [list [.t count -ypixels 5.0 11.0] [.t count -ypixels 5.0 11.20]]
} [list [expr {1 * $fixedHeight}] [expr {2 * $fixedHeight}]]
.t delete 1.0 end
@@ -2976,7 +3005,7 @@ for {set i 2} {$i <= 200} {incr i} {
.t configure -wrap word
.t delete 50.0 51.0
.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
-update
+updateText
.t tag add x 50.1
test textDisp-22.1 {TkTextCharBbox} {textfonts} {
.t config -wrap word
@@ -2992,39 +3021,39 @@ test textDisp-22.2 {TkTextCharBbox} {textfonts} {
test textDisp-22.3 {TkTextCharBbox, cut-off lines} {textfonts} {
.t config -wrap char
.t yview 10.0
- wm geom . ${width}x[expr $height-1]
- update
+ wm geom . ${width}x[expr {$height-1}]
+ updateText
list [.t bbox 19.1] [.t bbox 20.1]
} [list [list 10 [expr {3+9*$fixedHeight}] 7 $fixedHeight] [list 10 [expr {3+10*$fixedHeight}] 7 3]]
test textDisp-22.4 {TkTextCharBbox, cut-off lines} {textfonts} {
.t config -wrap char
.t yview 10.0
- wm geom . ${width}x[expr $height+1]
- update
+ wm geom . ${width}x[expr {$height+1}]
+ updateText
list [.t bbox 19.1] [.t bbox 20.1]
} [list [list 10 [expr {3+9*$fixedHeight}] 7 $fixedHeight] [list 10 [expr {3+10*$fixedHeight}] 7 5]]
test textDisp-22.5 {TkTextCharBbox, cut-off char} {textfonts} {
.t config -wrap none
.t yview 10.0
- wm geom . [expr $width-95]x$height
- update
+ wm geom . [expr {$width-95}]x$height
+ updateText
.t bbox 15.6
} [list 45 [expr {3+5*$fixedHeight}] 7 $fixedHeight]
test textDisp-22.6 {TkTextCharBbox, line visible but not char} {textfonts} {
.t config -wrap char
.t yview 10.0
.t tag add big 20.2 20.5
- wm geom . ${width}x[expr $height+3]
- update
+ wm geom . ${width}x[expr {$height+3}]
+ updateText
list [.t bbox 19.1] [.t bbox 20.1] [.t bbox 20.2]
} [list [list 10 [expr {3+9*$fixedHeight}] 7 $fixedHeight] {} [list 17 [expr {3+10*$fixedHeight}] 14 7]]
wm geom . {}
-update
+updateText
test textDisp-22.7 {TkTextCharBbox, different character sizes} {textfonts} {
.t config -wrap char
.t yview 10.0
.t tag add big 12.2 12.5
- update
+ updateText
list [.t bbox 12.1] [.t bbox 12.2]
} [list [list 10 [expr {3 + 2*$fixedHeight + $ascentDiff}] 7 $fixedHeight] [list 17 [expr {3+ 2*$fixedHeight}] 14 27]]
.t tag remove big 1.0 end
@@ -3051,7 +3080,7 @@ test textDisp-22.9 {TkTextCharBbox, handling of spacing} {textfonts} {
.t window create 1.7 -window .t.f2 -align center
.t window create 2.1 -window .t.f3 -align bottom
.t window create 2.10 -window .t.f4 -align baseline
- update
+ updateText
list [.t bbox .t.f1] [.t bbox .t.f2] [.t bbox .t.f3] [.t bbox .t.f4] \
[.t bbox 1.1] [.t bbox 2.9]
} [list [list 24 11 10 4] [list 55 [expr {$fixedDiff/2 + 15}] 10 4] [list 10 [expr {2*$fixedDiff + 43}] 10 4] [list 76 [expr {2*$fixedDiff + 40}] 10 4] [list 10 11 7 $fixedHeight] [list 69 [expr {$fixedDiff + 34}] 7 $fixedHeight]]
@@ -3060,12 +3089,12 @@ test textDisp-22.10 {TkTextCharBbox, handling of elided lines} {textfonts} {
.t configure -wrap char
.t delete 1.0 end
for {set i 1} {$i < 10} {incr i} {
- .t insert end "Line $i - Line [format %c [expr 64+$i]]\n"
+ .t insert end "Line $i - Line [format %c [expr {64+$i}]]\n"
}
.t tag add hidden 2.8 2.13
.t tag add hidden 6.8 7.13
.t tag configure hidden -elide true
- update
+ updateText
list \
[expr {[lindex [.t bbox 2.9] 0] - [lindex [.t bbox 2.8] 0]}] \
[expr {[lindex [.t bbox 2.10] 0] - [lindex [.t bbox 2.8] 0]}] \
@@ -3083,11 +3112,11 @@ test textDisp-22.11 {TkTextCharBbox, handling of wrapped elided lines} {textfont
.t configure -wrap char
.t delete 1.0 end
for {set i 1} {$i < 10} {incr i} {
- .t insert end "Line $i - Line _$i - Lines .$i - Line [format %c [expr 64+$i]]\n"
+ .t insert end "Line $i - Line _$i - Lines .$i - Line [format %c [expr {64+$i}]]\n"
}
.t tag add hidden 1.30 2.5
.t tag configure hidden -elide true
- update
+ updateText
list \
[expr {[lindex [.t bbox 1.30] 0] - [lindex [.t bbox 2.4] 0]}] \
[expr {[lindex [.t bbox 1.30] 0] - [lindex [.t bbox 2.5] 0]}]
@@ -3101,7 +3130,7 @@ for {set i 2} {$i <= 200} {incr i} {
.t configure -wrap word
.t delete 50.0 51.0
.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
-update
+updateText
test textDisp-23.1 {TkTextDLineInfo} {textfonts} {
.t config -wrap word
.t yview 48.0
@@ -3110,33 +3139,33 @@ test textDisp-23.1 {TkTextDLineInfo} {textfonts} {
} [list {} [list 3 3 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {4*$fixedDiff + 55}] 91 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
test textDisp-23.2 {TkTextDLineInfo} {textfonts} {
.t config -bd 4 -wrap word
- update
+ updateText
.t yview 48.0
.t dlineinfo 50.40
} [list 7 [expr {4*$fixedDiff + 59}] 91 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]
.t config -bd 0
test textDisp-23.3 {TkTextDLineInfo} {textfonts} {
.t config -wrap none
- update
+ updateText
.t yview 48.0
list [.t dlineinfo 50.40] [.t dlineinfo 57.3]
} [list [list 3 [expr {2*$fixedDiff + 29}] 371 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {9*$fixedDiff + 120}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
test textDisp-23.4 {TkTextDLineInfo, cut-off lines} {textfonts} {
.t config -wrap char
.t yview 10.0
- wm geom . ${width}x[expr $height-1]
- update
+ wm geom . ${width}x[expr {$height-1}]
+ updateText
list [.t dlineinfo 19.0] [.t dlineinfo 20.0]
} [list [list 3 [expr {9*$fixedDiff + 120}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {10*$fixedDiff + 133}] 49 3 [expr {$fixedDiff + 10}]]]
test textDisp-23.5 {TkTextDLineInfo, cut-off lines} {textfonts} {
.t config -wrap char
.t yview 10.0
- wm geom . ${width}x[expr $height+1]
- update
+ wm geom . ${width}x[expr {$height+1}]
+ updateText
list [.t dlineinfo 19.0] [.t dlineinfo 20.0]
} [list [list 3 [expr {9*$fixedDiff + 120}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {10*$fixedDiff + 133}] 49 5 [expr {$fixedDiff + 10}]]]
wm geom . {}
-update
+updateText
test textDisp-23.6 {TkTextDLineInfo, horizontal scrolling} {textfonts} {
.t config -wrap none
.t delete 1.0 end
@@ -3144,7 +3173,7 @@ test textDisp-23.6 {TkTextDLineInfo, horizontal scrolling} {textfonts} {
.t insert end "Second line is a very long one that doesn't all fit.\n"
.t insert end "Third"
.t xview scroll 6 units
- update
+ updateText
list [.t dlineinfo 1.0] [.t dlineinfo 2.0] [.t dlineinfo 3.0]
} [list [list -39 3 70 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list -39 [expr {$fixedDiff + 16}] 364 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list -39 [expr {2*$fixedDiff + 29}] 35 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
.t xview moveto 0
@@ -3172,16 +3201,16 @@ test textDisp-24.2 {TkTextCharLayoutProc} {textfonts} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
- wm geom . [expr $width+1]x$height
- update
+ wm geom . [expr {$width+1}]x$height
+ updateText
list [.t bbox 1.19] [.t bbox 1.20]
} [list [list 136 3 12 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
test textDisp-24.3 {TkTextCharLayoutProc} {textfonts} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
- wm geom . [expr $width-1]x$height
- update
+ wm geom . [expr {$width-1}]x$height
+ updateText
list [.t bbox 1.19] [.t bbox 1.20]
} [list [list 136 3 10 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
test textDisp-24.4 {TkTextCharLayoutProc, newline not visible} {textfonts} {
@@ -3189,7 +3218,7 @@ test textDisp-24.4 {TkTextCharLayoutProc, newline not visible} {textfonts} {
.t delete 1.0 end
.t insert 1.0 01234567890123456789\n012345678901234567890
wm geom . {}
- update
+ updateText
list [.t bbox 1.19] [.t bbox 1.20] [.t bbox 2.20]
} [list [list 136 3 7 $fixedHeight] [list 143 3 0 $fixedHeight] [list 3 [expr {2*$fixedDiff + 29}] 7 $fixedHeight]]
test textDisp-24.5 {TkTextCharLayoutProc, char doesn't fit, newline not visible} {unix textfonts} {
@@ -3197,7 +3226,7 @@ test textDisp-24.5 {TkTextCharLayoutProc, char doesn't fit, newline not visible}
.t delete 1.0 end
.t insert 1.0 0\n1\n
wm geom . 110x$height
- update
+ updateText
list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 2.0]
} [list [list 3 3 4 $fixedHeight] [list 7 3 0 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 4 $fixedHeight]]
test textDisp-24.6 {TkTextCharLayoutProc, line ends with space} {textfonts} {
@@ -3205,47 +3234,47 @@ test textDisp-24.6 {TkTextCharLayoutProc, line ends with space} {textfonts} {
.t delete 1.0 end
.t insert 1.0 "a b c d e f g h i j k l m n o p"
wm geom . {}
- update
+ updateText
list [.t bbox 1.19] [.t bbox 1.20]
} [list [list 136 3 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
test textDisp-24.7 {TkTextCharLayoutProc, line ends with space} {textfonts} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "a b c d e f g h i j k l m n o p"
- wm geom . [expr $width+1]x$height
- update
+ wm geom . [expr {$width+1}]x$height
+ updateText
list [.t bbox 1.19] [.t bbox 1.20]
} [list [list 136 3 12 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
test textDisp-24.8 {TkTextCharLayoutProc, line ends with space} {textfonts} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "a b c d e f g h i j k l m n o p"
- wm geom . [expr $width-1]x$height
- update
+ wm geom . [expr {$width-1}]x$height
+ updateText
list [.t bbox 1.19] [.t bbox 1.20]
} [list [list 136 3 10 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
test textDisp-24.9 {TkTextCharLayoutProc, line ends with space} {textfonts} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "a b c d e f g h i j k l m n o p"
- wm geom . [expr $width-6]x$height
- update
+ wm geom . [expr {$width-6}]x$height
+ updateText
list [.t bbox 1.19] [.t bbox 1.20]
} [list [list 136 3 5 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
test textDisp-24.10 {TkTextCharLayoutProc, line ends with space} {textfonts} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "a b c d e f g h i j k l m n o p"
- wm geom . [expr $width-7]x$height
- update
+ wm geom . [expr {$width-7}]x$height
+ updateText
list [.t bbox 1.19] [.t bbox 1.20]
} [list [list 136 3 4 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
test textDisp-24.11 {TkTextCharLayoutProc, line ends with space that doesn't quite fit} {textfonts} {
.t configure -wrap char
.t delete 1.0 end
.t insert 1.0 "01234567890123456789 \nabcdefg"
- wm geom . [expr $width-2]x$height
- update
+ wm geom . [expr {$width-2}]x$height
+ updateText
set result {}
lappend result [.t bbox 1.21] [.t bbox 2.0]
.t mark set insert 1.21
@@ -3264,23 +3293,23 @@ test textDisp-24.13 {TkTextCharLayoutProc, -wrap none} {textfonts} {
.t delete 1.0 end
.t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
wm geom . {}
- update
+ updateText
list [.t bbox 1.19] [.t bbox 1.20]
} [list [list 136 3 7 $fixedHeight] {}]
test textDisp-24.14 {TkTextCharLayoutProc, -wrap none} {textfonts} {
.t configure -wrap none
.t delete 1.0 end
.t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
- wm geom . [expr $width+1]x$height
- update
+ wm geom . [expr {$width+1}]x$height
+ updateText
list [.t bbox 1.19] [.t bbox 1.20]
} [list [list 136 3 7 $fixedHeight] [list 143 3 5 $fixedHeight]]
test textDisp-24.15 {TkTextCharLayoutProc, -wrap none} {textfonts} {
.t configure -wrap none
.t delete 1.0 end
.t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
- wm geom . [expr $width-1]x$height
- update
+ wm geom . [expr {$width-1}]x$height
+ updateText
list [.t bbox 1.19] [.t bbox 1.20]
} [list [list 136 3 7 $fixedHeight] [list 143 3 3 $fixedHeight]]
test textDisp-24.16 {TkTextCharLayoutProc, no chars fit} {textfonts} {
@@ -3291,7 +3320,7 @@ test textDisp-24.16 {TkTextCharLayoutProc, no chars fit} {textfonts} {
.t delete 1.0 end
.t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
wm geom . 103x$height
- update
+ updateText
list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 1.2]
} [list [list 3 3 1 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 1 $fixedHeight] [list 3 [expr {2*$fixedDiff + 29}] 1 $fixedHeight]]
if {$tcl_platform(platform) == "windows"} {
@@ -3302,7 +3331,7 @@ test textDisp-24.17 {TkTextCharLayoutProc, -wrap word} {textfonts} {
.t delete 1.0 end
.t insert 1.0 "This is a line that wraps around"
wm geom . {}
- update
+ updateText
list [.t bbox 1.19] [.t bbox 1.20]
} [list [list 136 3 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
test textDisp-24.18 {TkTextCharLayoutProc, -wrap word} {textfonts} {
@@ -3310,7 +3339,7 @@ test textDisp-24.18 {TkTextCharLayoutProc, -wrap word} {textfonts} {
.t delete 1.0 end
.t insert 1.0 "xxThis is a line that wraps around"
wm geom . {}
- update
+ updateText
list [.t bbox 1.15] [.t bbox 1.16] [.t bbox 1.17]
} [list [list 108 3 7 $fixedHeight] [list 115 3 28 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
test textDisp-24.19 {TkTextCharLayoutProc, -wrap word} {textfonts} {
@@ -3318,7 +3347,7 @@ test textDisp-24.19 {TkTextCharLayoutProc, -wrap word} {textfonts} {
.t delete 1.0 end
.t insert 1.0 "xxThis is a line that wraps around"
wm geom . {}
- update
+ updateText
list [.t bbox 1.14] [.t bbox 1.15] [.t bbox 1.16]
} [list [list 101 3 7 $fixedHeight] [list 108 3 7 $fixedHeight] [list 115 3 28 $fixedHeight]]
test textDisp-24.20 {TkTextCharLayoutProc, vertical offset} {textfonts} {
@@ -3336,7 +3365,7 @@ test textDisp-24.20 {TkTextCharLayoutProc, vertical offset} {textfonts} {
set result
} [list [list 10 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 42 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 10 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 42 [expr {$fixedDiff + 19}] [expr {$fixedDiff + 16}]] [list 10 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 42 [expr {$fixedDiff + 15}] [expr {$fixedDiff + 10}]]]
.t configure -width 30
-update
+updateText
test textDisp-24.21 {TkTextCharLayoutProc, word breaks} {textfonts} {
.t configure -wrap word
.t delete 1.0 end
@@ -3366,7 +3395,7 @@ test textDisp-24.23 {TkTextCharLayoutProc, word breaks} {textfonts} {
} [list 3 [expr {2*$fixedDiff + 29}] 30 20]
catch {destroy .t.f}
.t configure -width 20
-update
+updateText
test textDisp-24.24 {TkTextCharLayoutProc, justification and tabs} {textfonts} {
.t delete 1.0 end
.t tag configure x -justify center
@@ -3379,7 +3408,7 @@ test textDisp-24.25 {TkTextCharLayoutProc, justification and tabs} -constraints
pack .tt
} -body {
.tt insert end \t9\n\t99\n\t999
- update
+ updateText
list [.tt bbox 1.1] [.tt bbox 2.2] [.tt bbox 3.3]
} -cleanup {
destroy .tt
@@ -3387,7 +3416,7 @@ test textDisp-24.25 {TkTextCharLayoutProc, justification and tabs} -constraints
.t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \
-tabs 100
-update
+updateText
test textDisp-25.1 {CharBboxProc procedure, check tab width} {textfonts} {
.t delete 1.0 end
.t insert 1.0 abc\td\tfgh
@@ -3396,7 +3425,7 @@ test textDisp-25.1 {CharBboxProc procedure, check tab width} {textfonts} {
.t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \
-tabs {}
-update
+updateText
test textDisp-26.1 {AdjustForTab procedure, no tabs} {textfonts} {
.t delete 1.0 end
.t insert 1.0 a\tbcdefghij\tc\td
@@ -3428,9 +3457,9 @@ test textDisp-26.3 {AdjustForTab procedure, not enough tabs specified} {
.t tag configure x -tabs {40 70 right}
.t tag add x 1.0 end
list [lindex [.t bbox 1.2] 0] \
- [expr [lindex [.t bbox 1.4] 0] + [lindex [.t bbox 1.4] 2]] \
- [expr [lindex [.t bbox 1.6] 0] + [lindex [.t bbox 1.6] 2]] \
- [expr [lindex [.t bbox 1.8] 0] + [lindex [.t bbox 1.8] 2]]
+ [expr {[lindex [.t bbox 1.4] 0] + [lindex [.t bbox 1.4] 2]}] \
+ [expr {[lindex [.t bbox 1.6] 0] + [lindex [.t bbox 1.6] 2]}] \
+ [expr {[lindex [.t bbox 1.8] 0] + [lindex [.t bbox 1.8] 2]}]
} [list 40 70 100 130]
test textDisp-26.4 {AdjustForTab procedure, different alignments} {
.t delete 1.0 end
@@ -3519,7 +3548,7 @@ test textDisp-26.12 {AdjustForTab procedure, adjusting chunks} {
.t tag add y 1.9
button .b -text "="
.t window create 1.3 -window .b
- update
+ updateText
lindex [.t bbox 1.5] 0
} {120}
test textDisp-26.13 {AdjustForTab procedure, not enough space} {textfonts} {
@@ -3566,7 +3595,7 @@ test textDisp-26.14.2 {AdjustForTab procedure, not enough space} {textfonts} {
.t configure -width 20 -bd 2 -highlightthickness 2 -relief sunken -tabs {} \
-wrap char
-update
+updateText
test textDisp-27.1 {SizeOfTab procedure, old-style tabs} {textfonts} {
.t delete 1.0 end
.t insert 1.0 a\tbcdefghij\tc\td
@@ -3635,7 +3664,7 @@ test textDisp-27.7 {SizeOfTab procedure, center alignment, wrap -none (potential
# Tk_GetPixelsFromObj uses the standard 'int(0.5 + float)' rounding,
# so must we.
set tab [expr {4 + int(0.5 + $tab + $cm)}]
- update
+ updateText
set res [.t bbox 2.23]
lset res 0 [expr {[lindex $res 0] - $tab}]
set res
@@ -3656,7 +3685,7 @@ test textDisp-27.7.1 {SizeOfTab procedure, center alignment, wrap -none (potenti
# Tk_GetPixelsFromObj uses the standard 'int(0.5 + float)' rounding,
# so must we.
set tab [expr {4 + int(0.5 + $tab + $cm)}]
- update
+ updateText
set res [.t bbox 2.23]
.t configure -tabstyle tabular
lset res 0 [expr {[lindex $res 0] - $tab}]
@@ -3671,17 +3700,17 @@ test textDisp-27.7.2 {SizeOfTab procedure, fractional tab interpolation problem}
}
.t configure -tabs $interpolatetab -wrap none -width 150
.t insert 1.0 [string repeat "a\t" 20]
- update
+ updateText
set res [.t bbox 1.20]
# Now, Tk's interpolated tabs should be the same as
# non-interpolated.
.t configure -tabs $precisetab
- update
+ updateText
expr {[lindex $res 0] - [lindex [.t bbox 1.20] 0]}
} {0}
.t configure -wrap char -tabs {} -width 20
-update
+updateText
test textDisp-27.8 {SizeOfTab procedure, right alignment} {textfonts} {
.t delete 1.0 end
.t insert 1.0 a\t\txyzzyabc
@@ -3725,11 +3754,11 @@ test textDisp-28.1 {"yview" option with bizarre scroll command} {
.t2.t insert end "1\n2\n3\n4\n5\n6\n7\n8\n"
pack .t2.t
wm geometry .t2 +0+0
- update
+ updateText
.t2.t configure -yscrollcommand bizarre_scroll
.t2.t yview 100.0
set result [.t2.t index @0,0]
- update
+ updateText
lappend result [.t2.t index @0,0]
} {6.0 1.0}
@@ -3745,7 +3774,7 @@ test textDisp-29.1 {miscellaneous: lines wrap but are still too long} {textfonts
.t2.t insert end 123
frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
.t2.t window create 1.1 -window .t2.t.f
- update
+ updateText
list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
} [list [list 0.0 [expr {20.0*$fixedWidth/300}]] 300x50+[expr {$twbw + $twht + 1}]+[expr {$twbw + $twht + $fixedHeight + 1}] [list [expr {$twbw + $twht + $fixedWidth + 1}] [expr {$twbw + $twht + $fixedHeight + 50 + 1}] $fixedWidth $fixedHeight]]
test textDisp-29.2 {miscellaneous: lines wrap but are still too long} {textfonts} {
@@ -3760,9 +3789,9 @@ test textDisp-29.2 {miscellaneous: lines wrap but are still too long} {textfonts
.t2.t insert end 123
frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
.t2.t window create 1.1 -window .t2.t.f
- update
+ updateText
.t2.t xview scroll 1 unit
- update
+ updateText
list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
} [list [list [expr {1.0*$fixedWidth/300}] [expr {21.0*$fixedWidth/300}]] 300x50+[expr {$twbw + $twht + 1 - $fixedWidth}]+[expr {$twbw + $twht + $fixedHeight + 1}] [list [expr {$twbw + $twht + $fixedWidth + 1 - $fixedWidth}] [expr {$twbw + $twht + $fixedHeight + 50 + 1}] $fixedWidth $fixedHeight]]
test textDisp-29.2.1 {miscellaneous: lines wrap but are still too long} {textfonts} {
@@ -3776,9 +3805,9 @@ test textDisp-29.2.1 {miscellaneous: lines wrap but are still too long} {textfon
pack .t2.s -side bottom -fill x
.t2.t insert end 1\n
.t2.t insert end [string repeat "abc" 30]
- update
+ updateText
.t2.t xview scroll 5 unit
- update
+ updateText
.t2.t xview
} [list [expr {5.0/90}] [expr {25.0/90}]]
test textDisp-29.2.2 {miscellaneous: lines wrap but are still too long} {textfonts} {
@@ -3793,9 +3822,9 @@ test textDisp-29.2.2 {miscellaneous: lines wrap but are still too long} {textfon
.t2.t insert end 123
frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
.t2.t window create 1.1 -window .t2.t.f
- update
+ updateText
.t2.t xview scroll 2 unit
- update
+ updateText
list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
} [list [list [expr {2.0*$fixedWidth/300}] [expr {22.0*$fixedWidth/300}]] 300x50+[expr {$twbw + $twht + 1 - 2*$fixedWidth}]+[expr {$twbw + $twht + $fixedHeight + 1}] {}]
test textDisp-29.2.3 {miscellaneous: lines wrap but are still too long} {textfonts} {
@@ -3810,9 +3839,9 @@ test textDisp-29.2.3 {miscellaneous: lines wrap but are still too long} {textfon
.t2.t insert end 123
frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
.t2.t window create 1.1 -window .t2.t.f
- update
+ updateText
.t2.t xview scroll 7 pixels
- update
+ updateText
list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
} [list [list [expr {7.0/300}] [expr {(20.0*$fixedWidth + 7)/300}]] 300x50+[expr {$twbw + $twht + 1 - 7}]+[expr {$twbw + $twht + $fixedHeight + 1}] [list [expr {$twbw + $twht + $fixedWidth + 1 - 7}] [expr {$twbw + $twht + $fixedHeight + 50 + 1}] $fixedWidth $fixedHeight]]
test textDisp-29.2.4 {miscellaneous: lines wrap but are still too long} {textfonts} {
@@ -3827,9 +3856,9 @@ test textDisp-29.2.4 {miscellaneous: lines wrap but are still too long} {textfon
.t2.t insert end 123
frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
.t2.t window create 1.1 -window .t2.t.f
- update
+ updateText
.t2.t xview scroll 17 pixels
- update
+ updateText
list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
} [list [list [expr {17.0/300}] [expr {(20.0*$fixedWidth + 17)/300}]] 300x50+[expr {$twbw + $twht + 1 - 17}]+[expr {$twbw + $twht + $fixedHeight + 1}] {}]
test textDisp-29.2.5 {miscellaneous: can show last character} {
@@ -3846,7 +3875,7 @@ test textDisp-29.2.5 {miscellaneous: can show last character} {
grid columnconfigure .t2 0 -weight 1
grid rowconfigure .t2 0 -weight 1
grid rowconfigure .t2 1 -weight 0
- update ; update
+ updateText
set xv [.t2.t xview]
set xd [expr {[lindex $xv 1] - [lindex $xv 0]}]
.t2.t xview moveto [expr {1.0-$xd}]
@@ -3872,9 +3901,9 @@ test textDisp-29.3 {miscellaneous: lines wrap but are still too long} {textfonts
.t2.t insert end 123
frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
.t2.t window create 1.1 -window .t2.t.f
- update
+ updateText
.t2.t xview scroll 200 units
- update
+ updateText
list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
} [list [list [expr {16.0/30}] 1.0] 300x50+-155+[expr {$fixedDiff + 18}] {}]
test textDisp-30.1 {elidden text joining multiple logical lines} {
@@ -3894,7 +3923,7 @@ test textDisp-30.2 {elidden text joining multiple logical lines} {
catch {destroy .t2}
.t configure -height 1
-update
+updateText
test textDisp-31.1 {line embedded window height update} {
set res {}
@@ -3912,7 +3941,7 @@ test textDisp-31.1 {line embedded window height update} {
test textDisp-31.2 {line update index shifting} {
set res {}
.t.f configure -height 100
- update
+ updateText
lappend res [.t count -update -ypixels 1.0 end]
.t.f configure -height 10
.t insert 1.0 "abc\n"
@@ -3934,7 +3963,7 @@ test textDisp-31.3 {line update index shifting} {
# have been performed.
set res {}
.t.f configure -height 100
- update
+ updateText
lappend res [.t count -update -ypixels 1.0 end]
.t.f configure -height 10
.t insert 1.0 "abc\n"
@@ -3955,7 +3984,7 @@ test textDisp-31.4 {line embedded image height update} {
image create photo textest -height 100 -width 10
.t delete 3.0
.t image create 3.0 -image textest
- update
+ updateText
lappend res [.t count -update -ypixels 1.0 end]
textest configure -height 10
lappend res [.t count -ypixels 1.0 end]
@@ -3966,7 +3995,7 @@ test textDisp-31.4 {line embedded image height update} {
test textDisp-31.5 {line update index shifting} {
set res {}
textest configure -height 100
- update ; after 1000 ; update
+ updateText
lappend res [.t count -update -ypixels 1.0 end]
textest configure -height 10
.t insert 1.0 "abc\n"
@@ -3988,7 +4017,6 @@ test textDisp-31.6 {line update index shifting} {
# have been performed.
set res {}
textest configure -height 100
- update ; after 1000 ; update
lappend res [.t count -update -ypixels 1.0 end]
textest configure -height 10
.t insert 1.0 "abc\n"
@@ -4031,19 +4059,19 @@ test textDisp-32.0 {everything elided} {
.tt insert 0.0 HELLO
.tt tag configure HIDE -elide 1
.tt tag add HIDE 0.0 end
- update ; update ; update ; update
+ updateText
destroy .tt
} {}
test textDisp-32.1 {everything elided} {
# Must not crash
pack [text .tt]
- update
+ updateText
.tt insert 0.0 HELLO
- update
+ updateText
.tt tag configure HIDE -elide 1
- update
+ updateText
.tt tag add HIDE 0.0 end
- update ; update ; update ; update
+ updateText
destroy .tt
} {}
test textDisp-32.2 {elide and tags} {
@@ -4054,10 +4082,11 @@ test textDisp-32.2 {elide and tags} {
{testtag1 testtag3} \
{[this bit here uses tags 2 and 3]} \
{testtag2 testtag3}
- update
+ updateText
# indent left margin of tag 1 by 20 pixels
# text should be indented
- .tt tag configure testtag1 -lmargin1 20 ; update
+ .tt tag configure testtag1 -lmargin1 20
+ updateText
#1
set res {}
lappend res [list [.tt index "1.0 + 0 displaychars"] \
@@ -4065,7 +4094,8 @@ test textDisp-32.2 {elide and tags} {
[lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
# hide tag 1, remaining text should not be indented, since
# the indented tag and character is hidden.
- .tt tag configure testtag1 -elide 1 ; update
+ .tt tag configure testtag1 -elide 1
+ updateText
#2
lappend res [list [.tt index "1.0 + 0 displaychars"] \
[lindex [.tt bbox 1.0] 0] \
@@ -4075,7 +4105,8 @@ test textDisp-32.2 {elide and tags} {
.tt tag configure testtag1 -elide 0
# indent left margin of tag 2 by 20 pixels
# text should not be indented, since tag1 has lmargin1 of 0.
- .tt tag configure testtag2 -lmargin1 20 ; update
+ .tt tag configure testtag2 -lmargin1 20
+ updateText
#3
lappend res [list [.tt index "1.0 + 0 displaychars"] \
[lindex [.tt bbox 1.0] 0] \
@@ -4083,7 +4114,8 @@ test textDisp-32.2 {elide and tags} {
# hide tag 1, remaining text should now be indented, but
# the bbox of 1.0 should have zero width and zero indent,
# since it is elided at that position.
- .tt tag configure testtag1 -elide 1 ; update
+ .tt tag configure testtag1 -elide 1
+ updateText
#4
lappend res [list [.tt index "1.0 + 0 displaychars"] \
[lindex [.tt bbox 1.0] 0] \
@@ -4095,7 +4127,8 @@ test textDisp-32.2 {elide and tags} {
# text should be indented, since this tag takes
# precedence over testtag1, and is applied to the
# start of the text.
- .tt tag configure testtag3 -lmargin1 20 ; update
+ .tt tag configure testtag3 -lmargin1 20
+ updateText
#5
lappend res [list [.tt index "1.0 + 0 displaychars"] \
[lindex [.tt bbox 1.0] 0] \
@@ -4103,7 +4136,8 @@ test textDisp-32.2 {elide and tags} {
# hide tag 1, remaining text should still be indented,
# since it still has testtag3 on it. Again the
# bbox of 1.0 should have 0.
- .tt tag configure testtag1 -elide 1 ; update
+ .tt tag configure testtag1 -elide 1
+ updateText
#6
lappend res [list [.tt index "1.0 + 0 displaychars"] \
[lindex [.tt bbox 1.0] 0] \
@@ -4141,7 +4175,7 @@ test textDisp-32.3 "NULL undisplayProc problems: #1791052" -setup {
.tt insert end ":)" emoticon
.tt image create end -image $img
pack .tt
- update; update; update
+ updateText
} -cleanup {
image delete $img
destroy .tt
@@ -4150,7 +4184,7 @@ test textDisp-32.3 "NULL undisplayProc problems: #1791052" -setup {
test textDisp-33.0 {one line longer than fits in the widget} {
pack [text .tt -wrap char]
.tt insert 1.0 [string repeat "more wrap + " 300]
- update ; update ; update
+ updateText
.tt see 1.0
lindex [.tt yview] 0
} {0.0}
@@ -4158,7 +4192,7 @@ test textDisp-33.1 {one line longer than fits in the widget} {
destroy .tt
pack [text .tt -wrap char]
.tt insert 1.0 [string repeat "more wrap + " 300]
- update ; update ; update
+ updateText
.tt yview "1.0 +1 displaylines"
if {[lindex [.tt yview] 0] > 0.1} {
set result "window should be scrolled to the top"
@@ -4182,7 +4216,9 @@ test textDisp-33.3 {one line longer than fits in the widget} {
.tt debug 1
set tk_textHeightCalc ""
.tt insert 1.0 [string repeat "more wrap + " 300]
- update ; .tt count -update -ypixels 1.0 end ; update
+ updateText
+ .tt count -update -ypixels 1.0 end
+ updateText
# Each line should have been recalculated just once
.tt debug 0
expr {[llength $tk_textHeightCalc] == [.tt count -displaylines 1.0 end]}
@@ -4193,7 +4229,7 @@ test textDisp-33.4 {one line longer than fits in the widget} {
.tt debug 1
set tk_textHeightCalc ""
.tt insert 1.0 [string repeat "more wrap + " 300]
- update ; update ; update
+ updateText
set idx [.tt index "1.0 + 1 displaylines"]
.tt yview $idx
if {[lindex [.tt yview] 0] > 0.1} {
@@ -4215,7 +4251,7 @@ test textDisp-33.5 {bold or italic fonts} win {
.tt tag configure bi -font bi
.tt tag configure no -font no
.tt insert end abcd no efgh bi ijkl\n no
- update
+ updateText
set bb {}
for {set i 0} {$i < 12} {incr i 4} {
lappend bb [lindex [.tt bbox 1.$i] 0]
@@ -4242,7 +4278,7 @@ test textDisp-34.1 {Line heights recalculation problem: bug 2677890} -setup {
.t1 debug 1
set ge [winfo geometry .]
scan $ge "%dx%d+%d+%d" width height left top
- update
+ updateText
.t1 sync
set negative 0
bind .t1 <<WidgetViewSync>> { if {%d < 0} {set negative 1} }
@@ -4252,7 +4288,7 @@ test textDisp-34.1 {Line heights recalculation problem: bug 2677890} -setup {
# Thus we use this way to check for regression regarding bug 2677890,
# i.e. to check that the fix for this bug really is still in.
wm geometry . "[expr {$width * 2}]x$height+$left+$top"
- update
+ updateText
.t1 sync
set negative
} -cleanup {
diff --git a/tests/textIndex.test b/tests/textIndex.test
index 3f26af5..310db6a 100644
--- a/tests/textIndex.test
+++ b/tests/textIndex.test
@@ -803,6 +803,14 @@ test textIndex-19.12 {Display lines} {
.t index "2.40 -1displaylines"
} {2.20}
+test textIndex-19.12.1 {Display lines} {
+ .t index "2.50 - 100 displaylines"
+} {1.0}
+
+test textIndex-19.12.2 {Display lines} {
+ .t compare [.t index "2.50 + 100 displaylines"] == "end - 1 c"
+} {1}
+
test textIndex-19.13 {Display lines} {
destroy {*}[pack slaves .]
text .txt -height 1 -wrap word -yscroll ".sbar set" -width 400
diff --git a/tests/textTag.test b/tests/textTag.test
index 8b247b9..04a4b30 100644
--- a/tests/textTag.test
+++ b/tests/textTag.test
@@ -1213,14 +1213,14 @@ test textTag-14.4 {SortTags} -setup {
set curFont [.t cget -font]
set curWrap [.t cget -wrap]
set c [.t bbox 2.1]
-set x1 [expr [lindex $c 0] + [lindex $c 2]/2]
-set y1 [expr [lindex $c 1] + [lindex $c 3]/2]
+set x1 [expr {[lindex $c 0] + [lindex $c 2]/2}]
+set y1 [expr {[lindex $c 1] + [lindex $c 3]/2}]
set c [.t bbox 3.2]
-set x2 [expr [lindex $c 0] + [lindex $c 2]/2]
-set y2 [expr [lindex $c 1] + [lindex $c 3]/2]
+set x2 [expr {[lindex $c 0] + [lindex $c 2]/2}]
+set y2 [expr {[lindex $c 1] + [lindex $c 3]/2}]
set c [.t bbox 4.3]
-set x3 [expr [lindex $c 0] + [lindex $c 2]/2]
-set y3 [expr [lindex $c 1] + [lindex $c 3]/2]
+set x3 [expr {[lindex $c 0] + [lindex $c 2]/2}]
+set y3 [expr {[lindex $c 1] + [lindex $c 3]/2}]
.t configure -font $textWidgetFont -wrap none
update
set c [.t bbox 2.1]
@@ -1233,7 +1233,8 @@ set y5 [expr [lindex $c 1] + [lindex $c 3]/2]
test textTag-15.1 {TkTextBindProc} -setup {
.t tag delete x y
- event generate {} <Motion> -warp 1 -x -1 -y -1; update
+ wm geometry . +200+200 ; update
+ event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
} -body {
bind .t <ButtonRelease> {lappend x up}
.t tag bind x <ButtonRelease> {lappend x x-up}
@@ -1258,14 +1259,15 @@ test textTag-15.1 {TkTextBindProc} -setup {
test textTag-15.2 {TkTextBindProc} -setup {
.t tag delete x y
- event generate {} <Motion> -warp 1 -x -1 -y -1; update
+ wm geometry . +200+200 ; update
+ event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
} -body {
.t tag bind x <Enter> {lappend x x-enter}
- .t tag bind x <ButtonPress> {lappend x x-down}
+ .t tag bind x <Button> {lappend x x-down}
.t tag bind x <ButtonRelease> {lappend x x-up}
.t tag bind x <Leave> {lappend x x-leave}
.t tag bind y <Enter> {lappend x y-enter}
- .t tag bind y <ButtonPress> {lappend x y-down}
+ .t tag bind y <Button> {lappend x y-down}
.t tag bind y <ButtonRelease> {lappend x y-up}
.t tag bind y <Leave> {lappend x y-leave}
event gen .t <Motion> -x 0 -y 0
@@ -1286,15 +1288,16 @@ test textTag-15.2 {TkTextBindProc} -setup {
test textTag-15.3 {TkTextBindProc} -setup {
.t tag delete x y
- event generate {} <Motion> -warp 1 -x -1 -y -1; update
+ wm geometry . +200+200 ; update
+ event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
} -body {
.t tag bind x <Enter> {lappend x x-enter}
- .t tag bind x <Any-ButtonPress-1> {lappend x x-down}
- .t tag bind x <Any-ButtonRelease-1> {lappend x x-up}
+ .t tag bind x <Button-1> {lappend x x-down}
+ .t tag bind x <ButtonRelease-1> {lappend x x-up}
.t tag bind x <Leave> {lappend x x-leave}
.t tag bind y <Enter> {lappend x y-enter}
- .t tag bind y <Any-ButtonPress-1> {lappend x y-down}
- .t tag bind y <Any-ButtonRelease-1> {lappend x y-up}
+ .t tag bind y <Button-1> {lappend x y-down}
+ .t tag bind y <ButtonRelease-1> {lappend x y-up}
.t tag bind y <Leave> {lappend x y-leave}
event gen .t <Motion> -x 0 -y 0
set x {}
@@ -1319,7 +1322,8 @@ test textTag-15.3 {TkTextBindProc} -setup {
test textTag-16.1 {TkTextPickCurrent procedure} -setup {
.t tag delete {*}[.t tag names]
- event generate {} <Motion> -warp 1 -x -1 -y -1; update
+ wm geometry . +200+200 ; update
+ event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
} -body {
event gen .t <ButtonRelease-1> -state 0x100 -x $x1 -y $y1
set x [.t index current]
@@ -1341,7 +1345,8 @@ test textTag-16.2 {TkTextPickCurrent procedure} -constraints {
haveFontSizes
} -setup {
.t tag delete {*}[.t tag names]
- event generate {} <Motion> -warp 1 -x -1 -y -1; update
+ wm geometry . +200+200 ; update
+ event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
.t configure -font $textWidgetFont -wrap none
} -body {
.t tag configure big -font $bigFont
@@ -1360,7 +1365,8 @@ test textTag-16.3 {TkTextPickCurrent procedure} -setup {
foreach i {a b c d} {
.t tag remove $i 1.0 end
}
- event generate {} <Motion> -warp 1 -x -1 -y -1; update
+ wm geometry . +200+200 ; update
+ event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
} -body {
foreach i {a b c d} {
.t tag bind $i <Enter> "lappend x enter-$i"
@@ -1387,7 +1393,8 @@ test textTag-16.4 {TkTextPickCurrent procedure} -setup {
foreach i {a b c d} {
.t tag remove $i 1.0 end
}
- event generate {} <Motion> -warp 1 -x -1 -y -1; update
+ wm geometry . +200+200 ; update
+ event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
} -body {
foreach i {a b c d} {
.t tag bind $i <Enter> "lappend x enter-$i"
@@ -1415,7 +1422,8 @@ test textTag-16.5 {TkTextPickCurrent procedure} -constraints {
foreach i {big a b c d} {
.t tag remove $i 1.0 end
}
- event generate {} <Motion> -warp 1 -x -1 -y -1; update
+ wm geometry . +200+200 ; update
+ event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
.t configure -font $textWidgetFont -wrap none
} -body {
.t tag configure big -font $bigFont
@@ -1435,7 +1443,8 @@ test textTag-16.6 {TkTextPickCurrent procedure} -constraints {
foreach i {big a b c d} {
.t tag remove $i 1.0 end
}
- event generate {} <Motion> -warp 1 -x -1 -y -1; update
+ wm geometry . +200+200 ; update
+ event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
.t configure -font $textWidgetFont -wrap none
} -body {
.t tag configure big -font $bigFont
@@ -1456,7 +1465,8 @@ test textTag-16.7 {TkTextPickCurrent procedure} -constraints {
foreach i {big a b c d} {
.t tag remove $i 1.0 end
}
- event generate {} <Motion> -warp 1 -x -1 -y -1; update
+ wm geometry . +200+200 ; update
+ event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
.t configure -font $textWidgetFont -wrap none
} -body {
.t tag configure big -font $bigFont
@@ -1488,7 +1498,8 @@ test textTag-17.1 {insert procedure inserts tags} -setup {
test textTag-18.1 {TkTextPickCurrent tag bindings} -setup {
destroy .t
- event generate {} <Motion> -warp 1 -x -1 -y -1; update
+ wm geometry . +200+200 ; update
+ event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50
} -body {
text .t -width 30 -height 4 -relief sunken -borderwidth 10 \
-highlightthickness 10 -pady 2
diff --git a/tests/textWind.test b/tests/textWind.test
index e189663..7e2d315 100644
--- a/tests/textWind.test
+++ b/tests/textWind.test
@@ -39,6 +39,11 @@ wm minsize . 1 1
wm positionfrom . user
wm deiconify .
+# This update is needed on MacOS to make sure that the window is mapped
+# when the tests begin.
+
+update
+
set bw [.t cget -borderwidth]
set px [.t cget -padx]
set py [.t cget -pady]
@@ -955,7 +960,7 @@ test textWind-11.1 {EmbWinDisplayProc procedure, geometry transforms} -setup {
place .t -x 30 -y 50
frame .f -width 30 -height 20 -bg $color
.t window create 1.12 -window .f
- update
+ update ; after 100 ; update
winfo geom .f
} -cleanup {
destroy .f
@@ -975,7 +980,7 @@ test textWind-11.2 {EmbWinDisplayProc procedure, geometry transforms} -setup {
place .t -x 30 -y 50
frame .t.f -width 30 -height 20 -bg $color
.t window create 1.12 -window .t.f
- update
+ update ; after 100 ; update
winfo geom .t.f
} -cleanup {
destroy .t.f
diff --git a/tests/ttk/checkbutton.test b/tests/ttk/checkbutton.test
index 15d365f..5e929de 100644
--- a/tests/ttk/checkbutton.test
+++ b/tests/ttk/checkbutton.test
@@ -56,7 +56,7 @@ test checkbutton-1.7 "Button destroyed by click" -body {
pack .top.mb
focus -force .top.mb
update
- event generate .top.mb <1>
+ event generate .top.mb <Button-1>
event generate .top.mb <ButtonRelease-1>
update ; # shall not trigger error invalid command name ".top.b"
} -result {}
diff --git a/tests/ttk/combobox.test b/tests/ttk/combobox.test
index 3868953..c14db9b 100644
--- a/tests/ttk/combobox.test
+++ b/tests/ttk/combobox.test
@@ -43,6 +43,17 @@ test combobox-2.4 "current -- value not in list" -body {
.cb current
} -result -1
+test combobox-2.5 "current -- set to end index" -body {
+ .cb configure -values [list a b c d e thelastone]
+ .cb current end
+ .cb get
+} -result thelastone
+
+test combobox-2.6 "current -- set to unknown index" -body {
+ .cb configure -values [list a b c d e]
+ .cb current notanindex
+} -returnCodes error -result {Incorrect index notanindex}
+
test combobox-2.end "Cleanup" -body { destroy .cb }
test combobox-3 "Read postoffset value dynamically from current style" -body {
diff --git a/tests/ttk/entry.test b/tests/ttk/entry.test
index d303446..26edca9 100644
--- a/tests/ttk/entry.test
+++ b/tests/ttk/entry.test
@@ -74,12 +74,29 @@ test entry-2.1 "Create entry before scrollbar" -body {
-expand false -fill x
} -cleanup {destroy .te .tsb}
+test entry-2.1.1 "Create entry before scrollbar - scrollbar catches up" -body {
+ pack [ttk::entry .te -xscrollcommand [list .tsb set]] \
+ -expand true -fill both
+ .te insert end [string repeat "abc" 50]
+ catch {update} ; # error triggers because the -xscrollcommand callback
+ # errors out: invalid command name ".tsb"
+ pack [ttk::scrollbar .tsb -orient horizontal -command [list .te xview]] \
+ -expand false -fill x
+ update ; # no error
+ lappend res [expr [lindex [.tsb get] 1] < 1] ; # scrollbar did update
+} -result {1} -cleanup {destroy .te .tsb}
+
test entry-2.2 "Initial scroll position" -body {
ttk::entry .e -font fixed -width 5 -xscrollcommand scroll
.e insert end "0123456789"
- pack .e; update
+ pack .e;
+ set timeout [after 500 {set $scrollInfo "timeout"}]
+ vwait scrollInfo
set scrollInfo
-} -result {0.0 0.5} -cleanup { destroy .e }
+} -cleanup {
+ destroy .e
+ after cancel $timeout
+} -result {0.0 0.5}
# NOTE: result can vary depending on font.
# Bounding box / scrolling tests.
@@ -103,10 +120,37 @@ test entry-3.1 "bbox widget command" -body {
test entry-3.2 "xview" -body {
.e delete 0 end;
.e insert end [string repeat "0" 40]
- update idletasks
set result [.e xview]
} -result {0.0 0.5}
+test entry-3.3 "xview" -body {
+ .e delete 0 end;
+ .e insert end abcdefghijklmnopqrstuvwxyz
+ .e xview end
+ set result [.e index @0]
+} -result {7}
+
+test entry-3.4 "xview" -body {
+ .e delete 0 end;
+ .e insert end abcdefghijklmnopqrstuvwxyz
+ .e xview moveto 1.0
+ set result [.e index @0]
+} -result {7}
+
+test entry-3.5 "xview" -body {
+ .e delete 0 end;
+ .e insert end abcdefghijklmnopqrstuvwxyz
+ .e xview scroll 5 units
+ set result [.e index @0]
+} -result {5}
+
+test entry-3.6 "xview" -body {
+ .e delete 0 end;
+ .e insert end [string repeat abcdefghijklmnopqrstuvwxyz 5]
+ .e xview scroll 2 pages
+ set result [.e index @0]
+} -result {40}
+
test entry-3.last "Series 3 cleanup" -body {
destroy .e
}
@@ -298,4 +342,16 @@ test entry-10.2 {configuration option: "-placeholderforeground"} -setup {
destroy .e
} -result {red}
+test entry-11.1 {Bug [2830360fff] - Don't loose invalid at focus events} -setup {
+ pack [ttk::entry .e]
+ update
+} -body {
+ .e state invalid
+ set res [.e state]
+ event generate .e <FocusOut>
+ lappend res [.e state]
+} -result {invalid invalid} -cleanup {
+ destroy .e
+}
+
tcltest::cleanupTests
diff --git a/tests/ttk/notebook.test b/tests/ttk/notebook.test
index 3a2a6ff..ac63088 100644
--- a/tests/ttk/notebook.test
+++ b/tests/ttk/notebook.test
@@ -69,7 +69,7 @@ test notebook-2.5 "tab - get all options" -body {
.nb tab .nb.foo
} -result [list \
-padding 0 -sticky nsew \
- -state normal -text "Changed Foo" -image "" -compound none -underline -1]
+ -state normal -text "Changed Foo" -image "" -compound {} -underline -1]
test notebook-4.1 "Test .nb index end" -body {
.nb index end
diff --git a/tests/ttk/scrollbar.test b/tests/ttk/scrollbar.test
index c7cab13..443687a 100644
--- a/tests/ttk/scrollbar.test
+++ b/tests/ttk/scrollbar.test
@@ -4,16 +4,26 @@ loadTestedCommands
testConstraint coreScrollbar [expr {[tk windowingsystem] eq "aqua"}]
-test scrollbar-swapout-1 "Use core scrollbars on OSX..." -constraints {
- coreScrollbar
+# Before 2019 the code in library/ttk/scrollbar.tcl would replace the
+# constructor of ttk::scrollbar with the constructor of tk::scrollbar
+# unless the -class or -style options were specified..
+# Now there is an implementation of ttk::scrollbar for macOS. The
+# tests are left in place, though, except that scrollbar-swapout-1
+# test was changed to expect the class to be TScrollbar instead of
+# Scrollbar.
+
+test scrollbar-swapout-1 "Don't use core scrollbars on OSX..." \
+ -constraints {
+ coreScrollbar
} -body {
ttk::scrollbar .sb -command "yadda"
list [winfo class .sb] [.sb cget -command]
-} -result [list Scrollbar yadda] -cleanup {
+} -result [list TScrollbar yadda] -cleanup {
destroy .sb
}
-test scrollbar-swapout-2 "... unless -style is specified ..." -constraints {
+test scrollbar-swapout-2 "... regardless of whether -style ..." \
+-constraints {
coreScrollbar
} -body {
ttk::style layout Vertical.Custom.TScrollbar \
@@ -24,7 +34,7 @@ test scrollbar-swapout-2 "... unless -style is specified ..." -constraints {
destroy .sb
}
-test scrollbar-swapout-3 "... or -class." -constraints {
+test scrollbar-swapout-3 "... or -class is specified." -constraints {
coreScrollbar
} -body {
ttk::scrollbar .sb -command "yadda" -class Custom.TScrollbar
@@ -44,16 +54,108 @@ test scrollbar-1.1 "Set method" -body {
test scrollbar-1.2 "Set orientation" -body {
.tsb configure -orient vertical
- set w [winfo reqwidth .tsb] ; set h [winfo reqheight .tsb]
+ pack .tsb -side right -anchor e -expand 1 -fill y
+ wm geometry . 200x200
+ update
+ set w [winfo width .tsb] ; set h [winfo height .tsb]
expr {$h > $w}
} -result 1
test scrollbar-1.3 "Change orientation" -body {
.tsb configure -orient horizontal
- set w [winfo reqwidth .tsb] ; set h [winfo reqheight .tsb]
+ pack .tsb -side bottom -anchor s -expand 1 -fill x
+ wm geometry . 200x200
+ update
+ set w [winfo width .tsb] ; set h [winfo height .tsb]
expr {$h < $w}
} -result 1
+test scrollbar-10.1.1 {<MouseWheel> event on scrollbar} -constraints {notAqua} -setup {
+ destroy .t .s
+} -body {
+ pack [text .t -yscrollcommand {.s set}] -side left
+ for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"}
+ pack [ttk::scrollbar .s -command {.t yview}] -fill y -expand 1 -side left
+ update
+ focus -force .s
+ event generate .s <MouseWheel> -delta -120
+ after 200 {set eventprocessed 1} ; vwait eventprocessed
+ .t index @0,0
+} -cleanup {
+ destroy .t .s
+} -result {5.0}
+test scrollbar-10.1.2 {<MouseWheel> event on scrollbar} -constraints {aqua} -setup {
+ destroy .t .s
+} -body {
+ pack [text .t -yscrollcommand {.s set}] -side left
+ for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"}
+ pack [ttk::scrollbar .s -command {.t yview}] -fill y -expand 1 -side left
+ update
+ focus -force .s
+ event generate .s <MouseWheel> -delta -4
+ after 200 {set eventprocessed 1} ; vwait eventprocessed
+ .t index @0,0
+} -cleanup {
+ destroy .t .s
+} -result {5.0}
+
+test scrollbar-10.2.1 {<Shift-MouseWheel> event on horizontal scrollbar} -constraints {notAqua} -setup {
+ destroy .t .s
+} -body {
+ pack [text .t -xscrollcommand {.s set} -wrap none] -side top
+ for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "}
+ pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top
+ update
+ focus -force .s
+ event generate .s <Shift-MouseWheel> -delta -120
+ after 200 {set eventprocessed 1} ; vwait eventprocessed
+ .t index @0,0
+} -cleanup {
+ destroy .t .s
+} -result {1.4}
+test scrollbar-10.2.2 {<Shift-MouseWheel> event on horizontal scrollbar} -constraints {aqua} -setup {
+ destroy .t .s
+} -body {
+ pack [text .t -xscrollcommand {.s set} -wrap none] -side top
+ for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "}
+ pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top
+ update
+ focus -force .s
+ event generate .s <Shift-MouseWheel> -delta -4
+ after 200 {set eventprocessed 1} ; vwait eventprocessed
+ .t index @0,0
+} -cleanup {
+ destroy .t .s
+} -result {1.4}
+test scrollbar-10.2.3 {<MouseWheel> event on horizontal scrollbar} -constraints {notAqua} -setup {
+ destroy .t .s
+} -body {
+ pack [text .t -xscrollcommand {.s set} -wrap none] -side top
+ for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "}
+ pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top
+ update
+ focus -force .s
+ event generate .s <MouseWheel> -delta -120
+ after 200 {set eventprocessed 1} ; vwait eventprocessed
+ .t index @0,0
+} -cleanup {
+ destroy .t .s
+} -result {1.4}
+test scrollbar-10.2.4 {<MouseWheel> event on horizontal scrollbar} -constraints {aqua} -setup {
+ destroy .t .s
+} -body {
+ pack [text .t -xscrollcommand {.s set} -wrap none] -side top
+ for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "}
+ pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top
+ update
+ focus -force .s
+ event generate .s <MouseWheel> -delta -4
+ after 200 {set eventprocessed 1} ; vwait eventprocessed
+ .t index @0,0
+} -cleanup {
+ destroy .t .s
+} -result {1.4}
+
#
# Scale tests:
#
diff --git a/tests/ttk/treetags.test b/tests/ttk/treetags.test
index f91673f..fd3a0c5 100644
--- a/tests/ttk/treetags.test
+++ b/tests/ttk/treetags.test
@@ -11,12 +11,11 @@ proc assert {expr {message ""}} {
error "PANIC: $message ($expr failed)"
}
}
-proc in {e l} { expr {[lsearch -exact $l $e] >= 0} }
proc itemConstraints {tv item} {
# $tag in [$tv item $item -tags] <==> [$tv tag has $tag $item]
foreach tag [$tv item $item -tags] {
- assert {[in $item [$tv tag has $tag]]}
+ assert {$item in [$tv tag has $tag]}
}
foreach child [$tv children $item] {
itemConstraints $tv $child
@@ -28,7 +27,7 @@ proc treeConstraints {tv} {
#
foreach tag [$tv tag names] {
foreach item [$tv tag has $tag] {
- assert {[in $tag [$tv item $item -tags]]}
+ assert {$tag in [$tv item $item -tags]}
}
}
@@ -114,6 +113,12 @@ test treetags-1.10 "tag names - tag configured" -body {
lsort [$tv tag names]
} -result [list tag1 tag2 tag3 tag4 tag5]
+test treetags-1.11 "tag delete" -body {
+ $tv tag delete tag5
+ $tv tag delete tag4
+ lsort [$tv tag names]
+} -result [list tag1 tag2 tag3]
+
test treetags-1.end "cleanup" -body {
$tv item item1 -tags tag1
$tv item item2 -tags tag2
@@ -123,28 +128,28 @@ test treetags-1.end "cleanup" -body {
} -result [list [list item1] [list item2] [list]]
test treetags-2.0 "tag bind" -body {
- $tv tag bind tag1 <KeyPress> {set ::KEY %A}
- $tv tag bind tag1 <KeyPress>
+ $tv tag bind tag1 <Key> {set ::KEY %A}
+ $tv tag bind tag1 <Key>
} -cleanup {
treeConstraints $tv
} -result {set ::KEY %A}
test treetags-2.1 "Events delivered to tags" -body {
- focus -force $tv ; update ;# needed so [event generate] delivers KeyPress
+ focus -force $tv ; update ;# needed so [event generate] delivers Key
$tv focus item1
- event generate $tv <KeyPress-a>
+ event generate $tv <a>
set ::KEY
} -cleanup {
treeConstraints $tv
} -result a
test treetags-2.2 "Events delivered to correct tags" -body {
- $tv tag bind tag2 <KeyPress> [list set ::KEY2 %A]
+ $tv tag bind tag2 <Key> [list set ::KEY2 %A]
$tv focus item1
- event generate $tv <KeyPress-b>
+ event generate $tv <b>
$tv focus item2
- event generate $tv <KeyPress-c>
+ event generate $tv <c>
list $::KEY $::KEY2
} -cleanup {
diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test
index aa7e64a..43dd249 100644
--- a/tests/ttk/treeview.test
+++ b/tests/ttk/treeview.test
@@ -459,6 +459,31 @@ test treeview-8.5 "Selection - bad operation" -body {
.tv selection badop foo
} -returnCodes 1 -match glob -result {bad selection operation "badop": must be *}
+test treeview-8.6 "Selection - <<TreeviewSelect>> on selection add" -body {
+ .tv selection set {}
+ bind .tv <<TreeviewSelect>> {set res 1}
+ set res 0
+ .tv selection add newnode.n1
+ update
+ set res
+} -result {1}
+
+test treeview-8.7 "<<TreeviewSelect>> on selected item deletion" -body {
+ .tv selection set {}
+ .tv insert "" end -id selectedDoomed -text DeadItem
+ .tv insert "" end -id doomed -text AlsoDead
+ .tv selection add selectedDoomed
+ update
+ bind .tv <<TreeviewSelect>> {lappend res 1}
+ set res 0
+ .tv delete doomed
+ update
+ set res [expr {$res == 0}]
+ .tv delete selectedDoomed
+ update
+ set res
+} -result {1 1}
+
### NEED: more tests for see/yview/scrolling
proc scrollcallback {args} {
@@ -471,6 +496,72 @@ test treeview-9.0 "scroll callback - empty tree" -body {
set ::scrolldata
} -result [list 0.0 1.0]
+test treeview-9.1 "scrolling" -setup {
+ pack [ttk::treeview .tree -show tree] -fill y
+ for {set i 1} {$i < 100} {incr i} {
+ .tree insert {} end -text $i
+ }
+} -body {
+ .tree yview scroll 5 units
+ .tree identify item 2 2
+} -cleanup {
+ destroy .tree
+} -result {I006}
+
+test treeview-9.2 {scrolling on see command - bug [14188104c3]} -setup {
+ toplevel .top
+ ttk::treeview .top.tree -show {} -height 10 -columns {label} \
+ -yscrollcommand [list .top.vs set]
+ ttk::scrollbar .top.vs -command {.top.tree yview}
+ grid .top.tree -row 0 -column 0 -sticky ns
+ grid .top.vs -row 0 -column 1 -sticky ns
+ update
+ proc setrows {n} {
+ .top.tree delete [.top.tree children {}]
+ for {set i 1} {$i <= $n} {incr i} {
+ .top.tree insert {} end -id row$i \
+ -values [list [format "Row %2.2d" $i]]
+ }
+ .top.tree see row1
+ update idletasks
+ }
+} -body {
+ setrows 10
+ set res [.top.vs get]
+ setrows 20
+ lappend res [expr [lindex [.top.vs get] 1] < 1]
+} -cleanup {
+ destroy .top
+} -result {0.0 1.0 1}
+
+test treeview-9.3 {scrolling on see command, requested item is closed} -setup {
+ toplevel .top
+ ttk::treeview .top.tree -show tree -height 10 -columns {label} \
+ -yscrollcommand [list .top.vs set]
+ ttk::scrollbar .top.vs -command {.top.tree yview}
+ grid .top.tree -row 0 -column 0 -sticky ns
+ grid .top.vs -row 0 -column 1 -sticky ns
+
+ .top.tree insert {} end -id a -text a
+ .top.tree insert a end -id b -text b
+ .top.tree insert b end -id c -text c
+ .top.tree insert c end -id d -text d
+ .top.tree insert d end -id e -text e
+ for {set i 6} {$i <= 15} {incr i} {
+ .top.tree insert {} end -id row$i \
+ -values [list [format "Row %2.2d" $i]]
+ }
+ update
+} -body {
+ set before [lindex [.top.vs get] 1]
+ .top.tree see e
+ update idletasks
+ set after [lindex [.top.vs get] 1]
+ expr $after < $before
+} -cleanup {
+ destroy .top
+} -result {1}
+
### identify tests:
#
proc identify* {tv comps args} {
@@ -608,9 +699,9 @@ test treeview-10.1 "Root node properly initialized (#1541739)" -setup {
test treeview-3006842 "Null bindings" -setup {
ttk::treeview .tv -show tree
} -body {
- .tv tag bind empty <ButtonPress-1> {}
+ .tv tag bind empty <Button-1> {}
.tv insert {} end -text "Click me" -tags empty
- event generate .tv <ButtonPress-1> -x 10 -y 10
+ event generate .tv <Button-1> -x 10 -y 10
.tv tag bind empty
} -result {} -cleanup {
destroy .tv
@@ -636,4 +727,111 @@ test treeview-3085489-2 "tag remove, no -tags" -setup {
destroy .tv
} -result [list]
+test treeview-368fa4561e "indicators cannot be clicked on leafs" -setup {
+ pack [ttk::treeview .tv]
+ .tv insert {} end -id foo -text "<-- (1) Click the blank space to my left"
+ update
+} -body {
+ foreach {x y w h} [.tv bbox foo #0] {}
+ set res [.tv item foo -open]
+ # using $h even for x computation is intentional here in order to simulate
+ # a mouse click on the (invisible since we're on a leaf) indicator
+ event generate .tv <Button-1> \
+ -x [expr {$x + $h / 2}] \
+ -y [expr {$y + $h / 2}]
+ lappend res [.tv item foo -open]
+ .tv insert foo end -text "sub"
+ lappend res [.tv item foo -open]
+} -cleanup {
+ destroy .tv
+} -result {0 0 0}
+
+test treeview-ce470f20fd-1 "dragging further than the right edge of the treeview is allowed" -setup {
+ pack [ttk::treeview .tv]
+ .tv heading #0 -text "Drag my right edge -->"
+ update
+} -body {
+ set res [.tv column #0 -width]
+ .tv drag #0 400
+ lappend res [expr {[.tv column #0 -width] > $res}]
+} -cleanup {
+ destroy .tv
+} -result {200 1}
+
+proc nostretch {tv} {
+ foreach col [$tv cget -columns] {
+ $tv column $col -stretch 0
+ }
+ $tv column #0 -stretch 0
+ update idletasks ; # redisplay $tv
+}
+
+test treeview-ce470f20fd-2 "changing -stretch resizes columns" -setup {
+ pack [ttk::treeview .tv -columns {bar colA colB colC foo}]
+ foreach col [.tv cget -columns] {
+ .tv heading $col -text $col
+ }
+ nostretch .tv
+ .tv column colA -width 50 ; .tv column colB -width 50 ; # slack created
+ update idletasks ; # redisplay treeview
+} -body {
+ # when no column is stretchable and one of them becomes stretchable
+ # the stretchable column takes the slack and the widget is redisplayed
+ # automatically at idle time
+ set res [.tv column colA -width]
+ .tv column colA -stretch 1
+ update idletasks ; # no slack anymore, widget redisplayed
+ lappend res [expr {[.tv column colA -width] > $res}]
+} -cleanup {
+ destroy .tv
+} -result {50 1}
+
+test treeview-ce470f20fd-3 "changing -stretch resizes columns" -setup {
+ pack [ttk::treeview .tv -columns {bar colA colB colC foo}]
+ foreach col [.tv cget -columns] {
+ .tv heading $col -text $col
+ }
+ .tv configure -displaycolumns {colB colA colC}
+ nostretch .tv
+ .tv column colA -width 50 ; .tv column colB -width 50 ; # slack created
+ update idletasks ; # redisplay treeview
+} -body {
+ # only some columns are displayed (and in a different order than declared
+ # in -columns), a displayed column becomes stretchable --> the stretchable
+ # column expands
+ set res [.tv column colA -width]
+ .tv column colA -stretch 1
+ update idletasks ; # no slack anymore, widget redisplayed
+ lappend res [expr {[.tv column colA -width] > $res}]
+} -cleanup {
+ destroy .tv
+} -result {50 1}
+
+test treeview-ce470f20fd-4 "changing -stretch resizes columns" -setup {
+ pack [ttk::treeview .tv -columns {bar colA colB colC foo}]
+ foreach col [.tv cget -columns] {
+ .tv heading $col -text $col
+ }
+ .tv configure -displaycolumns {colB colA colC}
+ nostretch .tv
+ .tv column colA -width 50 ; .tv column bar -width 60 ; # slack created
+ update idletasks ; # redisplay treeview
+} -body {
+ # only some columns are displayed (and in a different order than declared
+ # in -columns), a non-displayed column becomes stretchable --> nothing
+ # happens
+ set origTreeWidth [winfo width .tv]
+ set res [list [.tv column bar -width] [.tv column colA -width]]
+ .tv column bar -stretch 1
+ update idletasks ; # no change, widget redisplayed
+ lappend res [.tv column bar -width] [.tv column colA -width]
+ # this column becomes visible --> widget resizes
+ .tv configure -displaycolumns {bar colC colA colB}
+ update idletasks ; # no slack anymore because the widget resizes (shrinks)
+ lappend res [.tv column bar -width] [.tv column colA -width] \
+ [expr {[winfo width .tv] < $origTreeWidth}]
+} -cleanup {
+ destroy .tv
+} -result {60 50 60 50 60 50 1}
+
tcltest::cleanupTests
diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test
index 6760b80..53da18a 100644
--- a/tests/ttk/ttk.test
+++ b/tests/ttk/ttk.test
@@ -206,9 +206,10 @@ test ttk-2.8 "bug 3223850: button state disabled during click" -setup {
destroy .b
set ttk28 {}
pack [ttk::button .b -command {set ::ttk28 failed}]
+ update
} -body {
- bind .b <ButtonPress-1> {after 0 {.b configure -state disabled}}
- after 1 {event generate .b <ButtonPress-1>}
+ bind .b <Button-1> {after 0 {.b configure -state disabled}}
+ after 1 {event generate .b <Button-1>}
after 20 {event generate .b <ButtonRelease-1>}
set aid [after 100 {set ::ttk28 [.b instate {disabled !pressed}]}]
vwait ::ttk28
@@ -269,7 +270,7 @@ test ttk-3.4 "SF#2009213" -body {
test ttk-4.0 "Setup" -body {
catch { destroy .t }
pack [ttk::label .t -text "Button 1"]
- testConstraint fontOption [expr ![catch { set prevFont [.t cget -font] }]]
+ testConstraint fontOption [expr {![catch { set prevFont [.t cget -font] }]}]
ok
}
@@ -506,6 +507,19 @@ test ttk-12.2 "-cursor option" -body {
.b cget -cursor
} -result arrow
+test ttk-12.2.1 "-cursor option, widget doesn't overwrite it" -setup {
+ ttk::treeview .tr
+ pack .tr
+ update
+} -body {
+ .tr configure -cursor X_cursor
+ event generate .tr <Motion>
+ update
+ .tr cget -cursor
+} -cleanup {
+ destroy .tr
+} -result {X_cursor}
+
test ttk-12.3 "-borderwidth frame option" -body {
destroy .t
toplevel .t
diff --git a/tests/unixButton.test b/tests/unixButton.test
index 9d54707..f0dcde5 100644
--- a/tests/unixButton.test
+++ b/tests/unixButton.test
@@ -200,7 +200,7 @@ test unixbutton-1.9 {TkpComputeButtonGeometry procedure} -constraints {
list [winfo reqwidth .b2] [winfo reqheight .b2]
} -cleanup {
deleteWindows
-} -result [list [expr {17 + $defaultBorder}] [expr {27 + $defaultBorder}]]
+} -result [list [expr {17 + $defaultBorder}] [expr {27 + $defaultBorder}]]
test unixbutton-1.10 {TkpComputeButtonGeometry procedure} -constraints {
unix
} -setup {
diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test
index 99f7265..c0a5bac 100644
--- a/tests/unixEmbed.test
+++ b/tests/unixEmbed.test
@@ -85,6 +85,8 @@ proc colorsFree {w {red 31} {green 245} {blue 192}} {
&& ([lindex $vals 2]/256 == $blue)
}
+testConstraint pressbutton [llength [info commands pressbutton]]
+
test unixEmbed-1.1 {TkpUseWindow procedure, bad window identifier} -constraints {
unix
} -setup {
@@ -341,7 +343,7 @@ test unixEmbed-2.4 {EmbeddedEventProc procedure} -constraints {
test unixEmbed-3.1 {ContainerEventProc procedure, detect creation} -constraints {
- unix testembed notPortable
+ unix testembed nonPortable
} -body {
frame .f1 -container 1 -width 200 -height 50
pack .f1
@@ -968,23 +970,25 @@ test unixEmbed-7.1 {TkpRedirectKeyEvent procedure, forward keystroke} -constrain
toplevel .t1 -use $w1
}
focus -force .
- bind . <KeyPress> {lappend x {key %A %E}}
+ bind . <Key> {lappend x {key %A %E}}
set x {}
set y [dobg {
update
- bind .t1 <KeyPress> {lappend y {key %A}}
+ bind .t1 <Key> {lappend y {key %A}}
set y {}
- event generate .t1 <KeyPress> -keysym a
+ event generate .t1 <Keys> -keysym a
set y
}]
update
list $x $y
} -cleanup {
deleteWindows
- bind . <KeyPress> {}
+ bind . <Key> {}
} -result {{{key a 1}} {}}
+# TkpRedirectKeyEvent is not implemented in win or aqua. If someone
+# implements it they should change the constraints for this test.
test unixEmbed-7.1a {TkpRedirectKeyEvent procedure, forward keystroke} -constraints {
- unix
+ unix notAqua
} -setup {
deleteWindows
catch {interp delete slave}
@@ -1000,13 +1004,13 @@ test unixEmbed-7.1a {TkpRedirectKeyEvent procedure, forward keystroke} -constrai
toplevel .t1 -use [w1]
}
focus -force .
- bind . <KeyPress> {lappend x {key %A %E}}
+ bind . <Key> {lappend x {key %A %E}}
set x {}
set y [slave eval {
update
- bind .t1 <KeyPress> {lappend y {key %A}}
+ bind .t1 <Key> {lappend y {key %A}}
set y {}
- event generate .t1 <KeyPress> -keysym a
+ event generate .t1 <Key> -keysym a
set y
}]
update
@@ -1014,7 +1018,7 @@ test unixEmbed-7.1a {TkpRedirectKeyEvent procedure, forward keystroke} -constrai
} -cleanup {
interp delete slave
deleteWindows
- bind . <KeyPress> {}
+ bind . <Key> {}
} -result {{{key a 1}} {}}
test unixEmbed-7.2 {TkpRedirectKeyEvent procedure, don't forward keystroke width} -constraints {
unix notAqua
@@ -1031,20 +1035,20 @@ test unixEmbed-7.2 {TkpRedirectKeyEvent procedure, don't forward keystroke width
update
focus -force .f1
update
- bind . <KeyPress> {lappend x {key %A}}
+ bind . <Key> {lappend x {key %A}}
set x {}
set y [dobg {
update
- bind .t1 <KeyPress> {lappend y {key %A}}
+ bind .t1 <Key> {lappend y {key %A}}
set y {}
- event generate .t1 <KeyPress> -keysym b
+ event generate .t1 <Key> -keysym b
set y
}]
update
list $x $y
} -cleanup {
deleteWindows
- bind . <KeyPress> {}
+ bind . <Key> {}
} -result {{} {{key b}}}
test unixEmbed-7.2a {TkpRedirectKeyEvent procedure, don't forward keystroke width} -constraints {
unix
@@ -1064,13 +1068,13 @@ test unixEmbed-7.2a {TkpRedirectKeyEvent procedure, don't forward keystroke widt
update
focus -force .f1
update
- bind . <KeyPress> {lappend x {key %A}}
+ bind . <Key> {lappend x {key %A}}
set x {}
set y [slave eval {
update
- bind .t1 <KeyPress> {lappend y {key %A}}
+ bind .t1 <Key> {lappend y {key %A}}
set y {}
- event generate .t1 <KeyPress> -keysym b
+ event generate .t1 <Key> -keysym b
set y
}]
update
@@ -1078,7 +1082,7 @@ test unixEmbed-7.2a {TkpRedirectKeyEvent procedure, don't forward keystroke widt
} -cleanup {
interp delete slave
deleteWindows
- bind . <KeyPress> {}
+ bind . <Key> {}
} -result {{} {{key b}}}
test unixEmbed-8.1 {TkpClaimFocus procedure} -constraints {
@@ -1234,6 +1238,7 @@ test unixEmbed-10.1 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -con
deleteWindows
} -body {
frame .f1 -container 1 -width 200 -height 50
+ update
pack .f1
update
toplevel .t1 -use [winfo id .f1] -width 150 -height 80
@@ -1260,6 +1265,56 @@ test unixEmbed-10.2 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -con
deleteWindows
} -result {70x300+0+0}
+test unixEmbed-11.1 {focus -force works for embedded toplevels} -constraints {
+ unix
+} -setup {
+ deleteWindows
+} -body {
+ toplevel .t
+ pack [frame .t.f -container 1 -width 200 -height 200] -fill both
+ update idletasks
+ toplevel .embed -use [winfo id .t.f] -bg green
+ update idletasks
+ focus -force .t
+ focus -force .embed
+ focus
+} -cleanup {
+ deleteWindows
+} -result .embed
+test unixEmbed-11.2 {mouse coordinates in embedded toplevels} -constraints {
+ unix pressbutton
+} -setup {
+ deleteWindows
+} -body {
+ toplevel .main
+ set result {}
+ pack [button .main.b -text "Main Button" \
+ -command {lappend result ".main.b"}] -padx 30 -pady 30
+ pack [frame .main.f -container 1 -width 200 -height 200] -fill both
+ update idletasks
+ toplevel .embed -use [winfo id .main.f] -bg green
+ pack [button .embed.b -text "Emb Button" \
+ -command {lappend result ".embed.b"}] -padx 30 -pady 30
+ wm geometry .main 200x400+100+100
+ update idletasks
+ focus -force .main
+ set x [expr {[winfo x .main ] + [winfo x .main.b] + 40}]
+ set y [expr {[winfo y .main ] + [winfo y .main.b] + 38}]
+ lappend result [winfo containing $x $y]
+ after 200
+ pressbutton $x $y
+ update
+ set y [expr {$y + 80}]
+ lappend result [winfo containing $x $y]
+ after 200
+ pressbutton $x $y
+ update
+ set result
+} -cleanup {
+ deleteWindows
+} -result {.main.b .main.b .embed.b .embed.b}
+
+
# cleanup
deleteWindows
cleanupbg
diff --git a/tests/util.test b/tests/util.test
index c1ec6a5..d457b50 100644
--- a/tests/util.test
+++ b/tests/util.test
@@ -28,10 +28,10 @@ test util-1.3 {Tk_GetScrollInfo procedure} -body {
} -result {0.5 0.75}
test util-1.4 {Tk_GetScrollInfo procedure} -body {
.l yview scroll a
-} -returnCodes error -result {wrong # args: should be ".l yview scroll number units|pages"}
+} -returnCodes error -result {wrong # args: should be ".l yview scroll number pages|units"}
test util-1.5 {Tk_GetScrollInfo procedure} -body {
.l yview scroll a b c
-} -returnCodes error -result {wrong # args: should be ".l yview scroll number units|pages"}
+} -returnCodes error -result {wrong # args: should be ".l yview scroll number pages|units"}
test util-1.6 {Tk_GetScrollInfo procedure} -body {
.l yview scroll xyz units
} -returnCodes error -result {expected integer but got "xyz"}
@@ -57,7 +57,7 @@ test util-1.10 {Tk_GetScrollInfo procedure} -body {
} -result {13}
test util-1.11 {Tk_GetScrollInfo procedure} -body {
.l yview scroll 3 zips
-} -returnCodes error -result {bad argument "zips": must be units or pages}
+} -returnCodes error -result {bad argument "zips": must be pages or units}
test util-1.12 {Tk_GetScrollInfo procedure} -body {
.l yview dropdead 3 times
} -returnCodes error -result {unknown option "dropdead": must be moveto or scroll}
diff --git a/tests/visual.test b/tests/visual.test
index 2f5c34a..13d6fd2 100644
--- a/tests/visual.test
+++ b/tests/visual.test
@@ -29,9 +29,9 @@ proc eatColors {w} {
pack $w.c
for {set y 0} {$y < 8} {incr y} {
for {set x 0} {$x < 40} {incr x} {
- set color [format #%02x%02x%02x [expr $x*6] [expr $y*30] 0]
- $w.c create rectangle [expr 10*$x] [expr 20*$y] \
- [expr 10*$x + 10] [expr 20*$y + 20] -outline {} \
+ set color [format #%02x%02x%02x [expr {$x*6}] [expr {$y*30}] 0]
+ $w.c create rectangle [expr {10*$x}] [expr {20*$y}] \
+ [expr {10*$x + 10}] [expr {20*$y + 20}] -outline {} \
-fill $color
}
}
@@ -50,8 +50,8 @@ proc eatColors {w} {
proc colorsFree {w {red 31} {green 245} {blue 192}} {
set vals [winfo rgb $w [format #%02x%02x%02x $red $green $blue]]
- expr ([lindex $vals 0]/256 == $red) && ([lindex $vals 1]/256 == $green) \
- && ([lindex $vals 2]/256 == $blue)
+ expr {([lindex $vals 0]/256 == $red) && ([lindex $vals 1]/256 == $green)
+ && ([lindex $vals 2]/256 == $blue)}
}
# If more than one visual type is available for the screen, pick one
diff --git a/tests/visual_bb.test b/tests/visual_bb.test
index 030a369..eda67e4 100644
--- a/tests/visual_bb.test
+++ b/tests/visual_bb.test
@@ -94,7 +94,7 @@ test 1.1 {running visual tests} -constraints userInteraction -body {
# Set up for keyboard-based menu traversal
- bind . <Any-FocusIn> {
+ bind . <FocusIn> {
if {("%d" == "NotifyVirtual") && ("%m" == "NotifyNormal")} {
focus .menu
}
@@ -104,7 +104,7 @@ test 1.1 {running visual tests} -constraints userInteraction -body {
# Set up a class binding to allow objects to be deleted from a canvas
# by clicking with mouse button 1:
- bind Canvas <1> {%W delete [%W find closest %x %y]}
+ bind Canvas <Button-1> {%W delete [%W find closest %x %y]}
concat ""
} -result {}
diff --git a/tests/winDialog.test b/tests/winDialog.test
index c53b6d7..e70ae3f 100755
--- a/tests/winDialog.test
+++ b/tests/winDialog.test
@@ -256,7 +256,7 @@ test winDialog-5.5 {GetFileName: Tcl_GetIndexFromObj() == TCL_OK} -constraints {
Click cancel
}]
# Note this also tests fix for
- # http://core.tcl.tk/tk/tktview/4a0451f5291b3c9168cc560747dae9264e1d2ef6
+ # https://core.tcl-lang.org/tk/tktview/4a0451f5291b3c9168cc560747dae9264e1d2ef6
# $x is expected to be empty
append x $y
} -result {0}
@@ -376,8 +376,8 @@ test winDialog-5.7.5 {GetFileName: extension {} } -constraints {
test winDialog-5.7.6 {GetFileName: All/extension } -constraints {
nt testwinevent
} -body {
- # In 8.6.4 this combination resulted in bar.ext.ext which is bad
- start {set x [tk_getSaveFile -filetypes {{All *}} -defaultextension {ext} -title Save]}
+ # In 8.6.4 this combination resulted in bar.aaa.aaa which is bad
+ start {set x [tk_getSaveFile -filetypes {{All *}} -defaultextension {aaa} -title Save]}
set msg {}
then {
if {[catch {SetText [vista? 0x47C 0x3e9] bar} msg]} {
@@ -389,37 +389,37 @@ test winDialog-5.7.6 {GetFileName: All/extension } -constraints {
set x "[file tail $x]$msg"
} -cleanup {
unset msg
-} -result bar.ext
+} -result bar.aaa
test winDialog-5.7.7 {tk_getOpenFile: -defaultextension} -constraints {
nt testwinevent
} -body {
unset -nocomplain x
- tcltest::makeFile "" "5 7 7.ext" [initialdir]
+ tcltest::makeFile "" "5 7 7.aaa" [initialdir]
start {set x [tk_getOpenFile \
- -defaultextension ext \
+ -defaultextension aaa \
-initialdir [file nativename [initialdir]] \
-initialfile "5 7 7" -title Foo]}
then {
Click ok
}
return $x
-} -result [file join [initialdir] "5 7 7.ext"]
+} -result [file join [initialdir] "5 7 7.aaa"]
test winDialog-5.7.8 {tk_getOpenFile: -defaultextension} -constraints {
nt testwinevent
} -body {
unset -nocomplain x
- tcltest::makeFile "" "5 7 8.ext" [initialdir]
+ tcltest::makeFile "" "5 7 8.aaa" [initialdir]
start {set x [tk_getOpenFile \
- -defaultextension ext \
+ -defaultextension aaa \
-initialdir [file nativename [initialdir]] \
- -initialfile "5 7 8.ext" -title Foo]}
+ -initialfile "5 7 8.aaa" -title Foo]}
then {
Click ok
}
return $x
-} -result [file join [initialdir] "5 7 8.ext"]
+} -result [file join [initialdir] "5 7 8.aaa"]
test winDialog-5.8 {GetFileName: extension doesn't begin with .} -constraints {
nt testwinevent
diff --git a/tests/winFont.test b/tests/winFont.test
index 662eb10..23c09c9 100644
--- a/tests/winFont.test
+++ b/tests/winFont.test
@@ -180,7 +180,7 @@ test winfont-5.3 {Tk_MeasureChars procedure: all chars did fit} -constraints {
set ax [winfo reqwidth .t.l]
set ay [winfo reqheight .t.l]
- .t.l config -wrap [expr $ax*10] -text "00000000"
+ .t.l config -wrap [expr {$ax*10}] -text "00000000"
list [expr {[winfo reqwidth .t.l] eq 8*$ax}] \
[expr {[winfo reqheight .t.l] eq $ay}]
} -cleanup {
@@ -199,7 +199,7 @@ test winfont-5.4 {Tk_MeasureChars procedure: not all chars fit} -constraints {
set ax [winfo reqwidth .t.l]
set ay [winfo reqheight .t.l]
- .t.l config -wrap [expr $ax*6] -text "00000000"
+ .t.l config -wrap [expr {$ax*6}] -text "00000000"
list [expr {[winfo reqwidth .t.l] eq 6*$ax}] \
[expr {[winfo reqheight .t.l] eq 2*$ay}]
} -cleanup {
@@ -218,7 +218,7 @@ test winfont-5.5 {Tk_MeasureChars procedure: include last partial char} -constra
.t.c dchars $t 0 end
.t.c insert $t 0 "0000"
- .t.c index $t @[expr int($cx*2.5)],1
+ .t.c index $t @[expr {int($cx*2.5)}],1
} -cleanup {
destroy .t.c
} -result {2}
@@ -254,7 +254,7 @@ test winfont-5.7 {Tk_MeasureChars procedure: whole words} -constraints {
set ax [winfo reqwidth .t.l]
set ay [winfo reqheight .t.l]
- .t.l config -wrap [expr $ax*8] -text "000000 0000"
+ .t.l config -wrap [expr {$ax*8}] -text "000000 0000"
list [expr {[winfo reqwidth .t.l] eq 6*$ax}] \
[expr {[winfo reqheight .t.l] eq 2*$ay}]
} -cleanup {
@@ -273,7 +273,7 @@ test winfont-5.8 {Tk_MeasureChars procedure: already saw space in line} -constra
set ax [winfo reqwidth .t.l]
set ay [winfo reqheight .t.l]
- .t.l config -wrap [expr $ax*12] -text "000000 0000000"
+ .t.l config -wrap [expr {$ax*12}] -text "000000 0000000"
list [expr {[winfo reqwidth .t.l] eq 7*$ax}] \
[expr {[winfo reqheight .t.l] eq 2*$ay}]
} -cleanup {
@@ -292,7 +292,7 @@ test winfont-5.9 {Tk_MeasureChars procedure: internal spaces significant} -const
set ax [winfo reqwidth .t.l]
set ay [winfo reqheight .t.l]
- .t.l config -wrap [expr $ax*12] -text "000 00 00000"
+ .t.l config -wrap [expr {$ax*12}] -text "000 00 00000"
list [expr {[winfo reqwidth .t.l] eq 7*$ax}] \
[expr {[winfo reqheight .t.l] eq 2*$ay}]
} -cleanup {
@@ -311,7 +311,7 @@ test winfont-5.10 {Tk_MeasureChars procedure: make first part of word fit} -cons
set ax [winfo reqwidth .t.l]
set ay [winfo reqheight .t.l]
- .t.l config -wrap [expr $ax*12] -text "0000000000000000"
+ .t.l config -wrap [expr {$ax*12}] -text "0000000000000000"
list [expr {[winfo reqwidth .t.l] eq 12*$ax}] \
[expr {[winfo reqheight .t.l] eq 2*$ay}]
} -cleanup {
@@ -334,7 +334,7 @@ test winfont-5.11 {Tk_MeasureChars procedure: check for kerning} -constraints {
.t.l config -text "XaYoYaKaWx"
set x [lindex [getsize] 0]
.t.l config -font $font
- expr $x < ($width*10)
+ expr {$x < ($width*10)}
} -cleanup {
destroy .t.l
} -result {1}
diff --git a/tests/winSend.test b/tests/winSend.test
index 0f3baf8..31c800e 100644
--- a/tests/winSend.test
+++ b/tests/winSend.test
@@ -118,8 +118,8 @@ test winSend-2.3 {Tk_SendObjCmd - sending to ourselves in a different interprete
} {0 b {}}
test winSend-2.4 {Tk_SendObjCmd - sending to ourselves in a different interp with errors} winSend {
newApp testApp
- list [catch {send testApp {expr 2 / 0}} msg] $msg $errorCode $errorInfo [interp delete testApp]
-} "1 {divide by zero} {ARITH DIVZERO {divide by zero}} {divide by zero\n while executing\n\"expr 2 / 0\"\n invoked from within\n\"send testApp {expr 2 / 0}\"} {}"
+ list [catch {send testApp {expr {2 / 0}}} msg] $msg $errorCode $errorInfo [interp delete testApp]
+} "1 {divide by zero} {ARITH DIVZERO {divide by zero}} {divide by zero\n while executing\n\"expr {2 / 0}\"\n invoked from within\n\"send testApp {expr {2 / 0}}\"} {}"
test winSend-2.5 {Tk_SendObjCmd - sending to another app async} winSend {
set newInterps [winfo interps]
foreach interp $newInterps {
@@ -145,8 +145,8 @@ test winSend-2.7 {Tk_SendObjCmd - sending to another app - error} winSend {
break
}
}
- list [catch {send $interp {expr 2 / 0}} msg] $msg $errorCode $errorInfo
-} "1 {divide by zero} {ARITH DIVZERO {divide by zero}} {divide by zero\n while executing\n\"expr 2 / 0\"\n invoked from within\n\"send \$interp {expr 2 / 0}\"}"
+ list [catch {send $interp {expr {2 / 0}}} msg] $msg $errorCode $errorInfo
+} "1 {divide by zero} {ARITH DIVZERO {divide by zero}} {divide by zero\n while executing\n\"expr {2 / 0}\"\n invoked from within\n\"send \$interp {expr {2 / 0}}\"}"
test winSend-3.1 {TkGetInterpNames} winSend {
set origLength [llength $currentInterps]
@@ -170,7 +170,7 @@ test winSend-5.1 {ExecuteRemoteObject - no error} winSend {
break
}
}
- list [send $interp {send [tk appname] {expr 2 / 1}}]
+ list [send $interp {send [tk appname] {expr {2 / 1}}}]
} {2}
test winSend-5.2 {ExecuteRemoteObject - error} winSend {
set newInterps [winfo interps]
@@ -179,7 +179,7 @@ test winSend-5.2 {ExecuteRemoteObject - error} winSend {
break
}
}
- list [catch {send $interp {send [tk appname] {expr 2 / 0}}} msg] $msg
+ list [catch {send $interp {send [tk appname] {expr {2 / 0}}}} msg] $msg
} {1 {divide by zero}}
test winSend-6.1 {SendDDEServer - XTYP_CONNECT} winSend {
@@ -246,7 +246,7 @@ test winSend-6.6 {SendDDEServer - XTYP_REQUEST return results} winSend {
break
}
}
- set command "send [tk appname] {expr $foo + 1}"
+ set command "send [tk appname] {expr {$foo + 1}}"
list [catch "send \{$interp\} \{$command\}" msg] $msg
} {0 4}
test winSend-6.7 {SendDDEServer - XTYP_EXECUTE} winSend {
@@ -256,7 +256,7 @@ test winSend-6.7 {SendDDEServer - XTYP_EXECUTE} winSend {
break
}
}
- set command "send [tk appname] {expr 4 / 2}"
+ set command "send [tk appname] {expr {4 / 2}}"
list [catch "send \{$interp\} \{$command\}" msg] $msg
} {0 2}
test winSend-6.8 {SendDDEServer - XTYP_WILDCONNECT} winSend {
@@ -386,7 +386,7 @@ test winSend-10.17 {Tk_DDEObjCmd - valid variable} winSend {
} {0 winSend-10.17}
test winSend-10.18 {Tk_DDEObjCmd - services} winSend {
set currentService [list Tk [tk appname]]
- list [catch {dde services Tk {}} msg] [expr [lsearch $msg $currentService] >= 0]
+ list [catch {dde services Tk {}} msg] [expr {[lsearch $msg $currentService] >= 0}]
} {0 1}
# Get rid of the other app and all of its interps
diff --git a/tests/winWm.test b/tests/winWm.test
index d251eb8..0064c5a 100644
--- a/tests/winWm.test
+++ b/tests/winWm.test
@@ -448,7 +448,7 @@ test winWm-9.0 "Bug #2799589 - delayed activation of destroyed window" -constrai
if {![winfo ismapped $w]} { update }
event generate $w <Enter>
focus -force $w
- event generate $w <ButtonPress-1> -x 5 -y 5
+ event generate $w <Button-1> -x 5 -y 5
event generate $w <ButtonRelease-1> -x 5 -y 5
}
proc winwm90proc3 {} {
@@ -492,7 +492,7 @@ test winWm-9.1 "delayed activation of grabbed destroyed window" -constraints win
if {![winfo ismapped $w]} { update }
event generate $w <Enter>
focus -force $w
- event generate $w <ButtonPress-1> -x 5 -y 5
+ event generate $w <Button-1> -x 5 -y 5
event generate $w <ButtonRelease-1> -x 5 -y 5
}
proc winwm91proc3 {} {
diff --git a/tests/winfo.test b/tests/winfo.test
index 14c2838..49a92a6 100644
--- a/tests/winfo.test
+++ b/tests/winfo.test
@@ -27,9 +27,9 @@ proc eatColors {w {options ""}} {
pack $w.c
for {set y 0} {$y < 8} {incr y} {
for {set x 0} {$x < 40} {incr x} {
- set color [format #%02x%02x%02x [expr $x*6] [expr $y*30] 0]
- $w.c create rectangle [expr 10*$x] [expr 20*$y] \
- [expr 10*$x + 10] [expr 20*$y + 20] -outline {} \
+ set color [format #%02x%02x%02x [expr {$x*6}] [expr {$y*30}] 0]
+ $w.c create rectangle [expr {10*$x}] [expr {20*$y}] \
+ [expr {10*$x + 10}] [expr {20*$y + 20}] -outline {} \
-fill $color
}
}
@@ -156,7 +156,7 @@ test winfo-4.6 {"winfo containing" command} -constraints {
wm geom .t +0+0
update
- winfo containing [expr [winfo rootx .t.f]-1] [expr [winfo rooty .t.f]-1]
+ winfo containing [expr {[winfo rootx .t.f]-1}] [expr {[winfo rooty .t.f]-1}]
} -cleanup {
destroy .t
} -result .t
@@ -169,8 +169,8 @@ test winfo-4.7 {"winfo containing" command} -setup {
wm geom .t +0+0
update
- set x [winfo containing -display .t.f [expr [winfo rootx .t]+600] \
- [expr [winfo rooty .t.f]+450]]
+ set x [winfo containing -display .t.f [expr {[winfo rootx .t]+600}] \
+ [expr {[winfo rooty .t.f]+450}]]
expr {($x == ".") || ($x == "")}
} -cleanup {
destroy .t
@@ -364,7 +364,7 @@ test winfo-11.5 {"winfo visualid" command} -body {
} -result {3}
test winfo-11.6 {"winfo visualid" command} -body {
set x [lindex [lindex [winfo visualsa . includeids] 0] 2]
- expr $x + 2 - $x
+ expr {$x + 2 - $x}
} -result {2}
@@ -394,6 +394,13 @@ test winfo-13.1 {root coordinates of embedded toplevel} -setup {
deleteWindows
} -result {rootx 1 rooty 1}
+# Windows does not destroy the container when an embedded window is
+# destroyed. Unix and macOS do destroy it. See ticket [67384bce7d].
+if {[tk windowingsystem] == "win32"} {
+ set result_13_2 {embedded 0 container 1}
+} else {
+ set result_13_2 {embedded 0 container 0}
+}
test winfo-13.2 {destroying embedded toplevel} -setup {
deleteWindows
} -body {
@@ -409,7 +416,7 @@ test winfo-13.2 {destroying embedded toplevel} -setup {
list embedded [winfo exists .emb.b] container [winfo exists .con]
} -cleanup {
deleteWindows
-} -result {embedded 0 container 1}
+} -result $result_13_2
test winfo-13.3 {destroying container window} -setup {
deleteWindows
diff --git a/tests/wm.test b/tests/wm.test
index df8d325..2978c1b 100644
--- a/tests/wm.test
+++ b/tests/wm.test
@@ -873,6 +873,12 @@ test wm-iconphoto-1.4 {usage} -returnCodes error -body {
# we currently have no return info
wm iconphoto . -default
} -result {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"}
+test wm-iconphoto-1.5.1 {usage} -constraints aquaOrWin32 -returnCodes error -body {
+ wm iconphoto . -default [image create photo -file {}]
+} -match {glob} -result {failed to create an iconphoto with image *}
+test wm-iconphoto-1.5.2 {usage} -constraints x11 -body {
+ wm iconphoto . -default [image create photo -file {}]
+} -result {}
# All other iconphoto tests are platform specific
@@ -1553,8 +1559,8 @@ test wm-stackorder-5.3 {An overrideredirect window\
destroy .t
} -result 1
-test wm-stackorder-6.1 {An embedded toplevel does not\
- appear in the stacking order on unix or win} -constraints notAqua -body {
+test wm-stackorder-6.1 {An embedded toplevel does not appear in the \
+ stacking order} -body {
toplevel .real -container 1
toplevel .embd -bg blue -use [winfo id .real]
update
@@ -1562,16 +1568,6 @@ test wm-stackorder-6.1 {An embedded toplevel does not\
} -cleanup {
deleteWindows
} -result {. .real}
-test wm-stackorder-6.1.1 {An embedded toplevel does\
- appear in the stacking order on macOS} -constraints aqua -body {
- toplevel .real -container 1
- toplevel .embd -bg blue -use [winfo id .real]
- update
- wm stackorder .
-} -cleanup {
- deleteWindows
-} -result {. .embd}
-
stdWindow
diff --git a/unix/Makefile.in b/unix/Makefile.in
index 86a8a61..271cb07 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -35,6 +35,7 @@ bindir = @bindir@
libdir = @libdir@
includedir = @includedir@
datarootdir = @datarootdir@
+runstatedir = @runstatedir@
mandir = @mandir@
# The following definition can be set to non-null for special systems
@@ -95,16 +96,17 @@ HTML_INSTALL_DIR = $(INSTALL_ROOT)$(HTML_DIR)
CONFIG_INSTALL_DIR = $(INSTALL_ROOT)$(libdir)
# Directory in which to install the demo files:
-DEMO_INSTALL_DIR = $(INSTALL_ROOT)$(TK_LIBRARY)/demos
+DEMO_INSTALL_DIR = $(INSTALL_ROOT)@DEMO_DIR@
# The directory containing the Tcl sources and headers appropriate
# for this version of Tk ("srcdir" will be replaced or has already
# been replaced by the configure script):
-TCL_GENERIC_DIR = @TCL_SRC_DIR@/generic
+TCLDIR = @TCL_SRC_DIR@
+TCL_GENERIC_DIR = $(TCLDIR)/generic
# The directory containing the platform specific Tcl sources and headers
# appropriate for this version of Tk:
-TCL_PLATFORM_DIR = @TCL_SRC_DIR@/unix
+TCL_PLATFORM_DIR = $(TCLDIR)/unix
# The directory containing the Tcl library archive file appropriate
# for this version of Tk:
@@ -310,7 +312,7 @@ GENERIC_DIR = $(TOP_DIR)/generic
TTK_DIR = $(GENERIC_DIR)/ttk
UNIX_DIR = $(TOP_DIR)/unix
BMAP_DIR = $(TOP_DIR)/bitmaps
-TOOL_DIR = @TCL_SRC_DIR@/tools
+TOOL_DIR = $(TCLDIR)/tools
TEST_DIR = $(TOP_DIR)/tests
MAC_OSX_DIR = $(TOP_DIR)/macosx
XLIB_DIR = $(TOP_DIR)/xlib
@@ -327,9 +329,9 @@ MAN_FLAGS = @MAN_FLAGS@
CC = @CC@
-CC_SWITCHES_NO_STUBS = ${CFLAGS} ${CFLAGS_WARNING} ${SHLIB_CFLAGS} \
--I${UNIX_DIR} -I${GENERIC_DIR} -I${BMAP_DIR} -I${TCL_GENERIC_DIR} \
--I${TCL_PLATFORM_DIR} ${@TK_WINDOWINGSYSTEM@_INCLUDES} ${AC_FLAGS} \
+CC_SWITCHES_NO_STUBS = -I${UNIX_DIR} -I${GENERIC_DIR} -I${BMAP_DIR} \
+${@TK_WINDOWINGSYSTEM@_INCLUDES} ${CFLAGS} ${CFLAGS_WARNING} \
+${SHLIB_CFLAGS} -I${TCL_GENERIC_DIR} -I${TCL_PLATFORM_DIR} ${AC_FLAGS} \
${PROTO_FLAGS} ${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} ${KEYSYM_FLAGS} \
${NO_DEPRECATED_FLAGS} @EXTRA_CC_SWITCHES@
@@ -337,10 +339,10 @@ CC_SWITCHES = $(CC_SWITCHES_NO_STUBS) @TCL_STUB_FLAGS@
APP_CC_SWITCHES = $(CC_SWITCHES_NO_STUBS) @EXTRA_APP_CC_SWITCHES@
-DEPEND_SWITCHES = ${CFLAGS} -I${UNIX_DIR} -I${GENERIC_DIR} -I${BMAP_DIR} \
--I${TCL_GENERIC_DIR} -I${TCL_PLATFORM_DIR} ${@TK_WINDOWINGSYSTEM@_INCLUDES} \
-${AC_FLAGS} ${PROTO_FLAGS} ${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} \
-${KEYSYM_FLAGS} @EXTRA_CC_SWITCHES@
+DEPEND_SWITCHES = -I${UNIX_DIR} -I${GENERIC_DIR} -I${BMAP_DIR} \
+${@TK_WINDOWINGSYSTEM@_INCLUDES} ${CFLAGS} -I${TCL_GENERIC_DIR} \
+-I${TCL_PLATFORM_DIR} ${AC_FLAGS} ${PROTO_FLAGS} ${SECURITY_FLAGS} \
+${MEM_DEBUG_FLAGS} ${KEYSYM_FLAGS} @EXTRA_CC_SWITCHES@
WISH_OBJS = tkAppInit.o
@@ -356,7 +358,7 @@ CANV_OBJS = tkCanvas.o tkCanvArc.o tkCanvBmap.o tkCanvImg.o \
tkCanvUtil.o tkCanvWind.o tkRectOval.o tkTrig.o
IMAGE_OBJS = tkImage.o tkImgBmap.o tkImgGIF.o tkImgPNG.o tkImgPPM.o \
- tkImgPhoto.o tkImgPhInstance.o tkImgListFormat.o
+ tkImgPhoto.o tkImgPhInstance.o tkImgListFormat.o tkImgSVGnano.o
TEXT_OBJS = tkText.o tkTextBTree.o tkTextDisp.o tkTextImage.o tkTextIndex.o \
tkTextMark.o tkTextTag.o tkTextWind.o
@@ -369,8 +371,9 @@ GENERIC_OBJS = tk3d.o tkArgv.o tkAtom.o tkBind.o tkBitmap.o tkBusy.o \
tkClipboard.o \
tkCmds.o tkColor.o tkConfig.o tkConsole.o tkCursor.o tkError.o \
tkEvent.o tkFocus.o tkFont.o tkGet.o tkGC.o tkGeometry.o tkGrab.o \
- tkGrid.o tkMain.o tkObj.o tkOldConfig.o tkOption.o tkPack.o tkPlace.o \
- tkSelect.o tkStyle.o tkUndo.o tkUtil.o tkVisual.o tkWindow.o
+ tkGrid.o tkMain.o tkObj.o tkOldConfig.o tkOption.o tkPack.o \
+ tkPkgConfig.o tkPlace.o tkSelect.o tkStyle.o tkUndo.o tkUtil.o \
+ tkVisual.o tkWindow.o
TTK_OBJS = \
ttkBlink.o ttkButton.o ttkCache.o ttkClamTheme.o ttkClassicTheme.o \
@@ -395,10 +398,11 @@ AQUA_OBJS = tkMacOSXBitmap.o tkMacOSXButton.o tkMacOSXClipboard.o \
tkMacOSXColor.o tkMacOSXConfig.o tkMacOSXCursor.o tkMacOSXDebug.o \
tkMacOSXDialog.o tkMacOSXDraw.o tkMacOSXEmbed.o tkMacOSXEntry.o \
tkMacOSXEvent.o tkMacOSXFont.o tkMacOSXHLEvents.o tkMacOSXImage.o \
- tkMacOSXInit.o tkMacOSXKeyboard.o tkMacOSXKeyEvent.o tkMacOSXMenu.o \
+ tkMacOSXInit.o tkMacOSXKeyboard.o tkMacOSXKeyEvent.o \
+ tkMacOSXMenu.o \
tkMacOSXMenubutton.o tkMacOSXMenus.o tkMacOSXMouseEvent.o \
tkMacOSXNotify.o tkMacOSXRegion.o tkMacOSXScrlbr.o tkMacOSXSend.o \
- tkMacOSXSubwindows.o tkMacOSXWindowEvent.o \
+ tkMacOSXServices.o tkMacOSXSubwindows.o tkMacOSXWindowEvent.o \
tkMacOSXWm.o tkMacOSXXStubs.o \
tkFileFilter.o tkMacWinMenu.o tkPointer.o tkUnix3d.o tkUnixScale.o \
xcolors.o xdraw.o xgc.o ximage.o xutil.o \
@@ -431,6 +435,7 @@ GENERIC_SRCS = \
$(GENERIC_DIR)/tkGrid.c $(GENERIC_DIR)/tkConsole.c \
$(GENERIC_DIR)/tkMain.c $(GENERIC_DIR)/tkOption.c \
$(GENERIC_DIR)/tkPack.c $(GENERIC_DIR)/tkPlace.c \
+ $(GENERIC_DIR)/tkPkgConfig.c \
$(GENERIC_DIR)/tkSelect.c $(GENERIC_DIR)/tkStyle.c \
$(GENERIC_DIR)/tkUndo.c $(GENERIC_DIR)/tkUtil.c \
$(GENERIC_DIR)/tkVisual.c $(GENERIC_DIR)/tkWindow.c \
@@ -449,6 +454,7 @@ GENERIC_SRCS = \
$(GENERIC_DIR)/tkTrig.c $(GENERIC_DIR)/tkImage.c \
$(GENERIC_DIR)/tkImgBmap.c $(GENERIC_DIR)/tkImgGIF.c \
$(GENERIC_DIR)/tkImgPNG.c $(GENERIC_DIR)/tkImgPPM.c \
+ $(GENERIC_DIR)/tkImgSVGnano.c $(GENERIC_DIR)/tkImgSVGnano.c \
$(GENERIC_DIR)/tkImgPhoto.c $(GENERIC_DIR)/tkImgPhInstance.c \
$(GENERIC_DIR)/tkImgListFormat.c $(GENERIC_DIR)/tkText.c \
$(GENERIC_DIR)/tkTextBTree.c $(GENERIC_DIR)/tkTextDisp.c \
@@ -521,10 +527,12 @@ AQUA_SRCS = \
$(MAC_OSX_DIR)/tkMacOSXFont.c $(MAC_OSX_DIR)/tkMacOSXHLEvents.c \
$(MAC_OSX_DIR)/tkMacOSXImage.c \
$(MAC_OSX_DIR)/tkMacOSXInit.c $(MAC_OSX_DIR)/tkMacOSXKeyboard.c \
- $(MAC_OSX_DIR)/tkMacOSXKeyEvent.c $(MAC_OSX_DIR)/tkMacOSXMenu.c \
+ $(MAC_OSX_DIR)/tkMacOSXKeyEvent.c \
+ $(MAC_OSX_DIR)/tkMacOSXMenu.c \
$(MAC_OSX_DIR)/tkMacOSXMenubutton.c $(MAC_OSX_DIR)/tkMacOSXMenus.c \
$(MAC_OSX_DIR)/tkMacOSXMouseEvent.c $(MAC_OSX_DIR)/tkMacOSXNotify.c \
$(MAC_OSX_DIR)/tkMacOSXRegion.c $(MAC_OSX_DIR)/tkMacOSXScrlbr.c \
+ $(MAC_OSX_DIR)/tkMacOSXServices.c \
$(MAC_OSX_DIR)/tkMacOSXSend.c $(MAC_OSX_DIR)/tkMacOSXSubwindows.c \
$(MAC_OSX_DIR)/tkMacOSXTest.c $(MAC_OSX_DIR)/tkMacOSXWindowEvent.c \
$(MAC_OSX_DIR)/tkMacOSXWm.c $(MAC_OSX_DIR)/tkMacOSXXStubs.c \
@@ -566,20 +574,15 @@ DEMOPROGS = browse hello ixset rmt rolodex square tcolor timer widget
SHELL_ENV = \
@LD_LIBRARY_PATH_VAR@="`pwd`:${TCL_BIN_DIR}:$${@LD_LIBRARY_PATH_VAR@}"; \
export @LD_LIBRARY_PATH_VAR@; \
- TCL_LIBRARY=@TCL_SRC_DIR@/library; export TCL_LIBRARY; \
+ TCL_LIBRARY=$(TCLDIR)/library; export TCL_LIBRARY; \
TK_LIBRARY=@TK_SRC_DIR@/library; export TK_LIBRARY;
-all: binaries libraries doc
+all: binaries libraries
binaries: ${LIB_FILE} ${WISH_EXE}
libraries:
-$(TOP_DIR)/doc/man.macros:
- $(INSTALL_DATA) @TCL_SRC_DIR@/doc/man.macros $(TOP_DIR)/doc/man.macros
-
-doc: $(TOP_DIR)/doc/man.macros
-
# The following target is configured by autoconf to generate either
# a shared library or non-shared library for Tk.
${LIB_FILE}: ${STUB_LIB_FILE} @LIB_RSRC_FILE@ ${OBJS}
@@ -682,7 +685,7 @@ demo:
# This target can be used to run wish inside either gdb or insight
gdb: ${WISH_EXE}
@echo "set env @LD_LIBRARY_PATH_VAR@=\"`pwd`:${TCL_BIN_DIR}:$${@LD_LIBRARY_PATH_VAR@}\"" > gdb.run
- @echo "set env TCL_LIBRARY=@TCL_SRC_DIR@/library" >> gdb.run
+ @echo "set env TCL_LIBRARY=$(TCLDIR)/library" >> gdb.run
@echo "set env TK_LIBRARY=@TK_SRC_DIR@/library" >> gdb.run
gdb ./${WISH_EXE} --command=gdb.run
rm gdb.run
@@ -1010,6 +1013,32 @@ tkOption.o: $(GENERIC_DIR)/tkOption.c
tkPack.o: $(GENERIC_DIR)/tkPack.c
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkPack.c
+# TIP #59, embedding of configuration information into the binary library.
+#
+# Part of Tk's configuration information are the paths where it was installed
+# and where it will look for its libraries (which can be different). We derive
+# this information from the variables which can be overridden by the user. As
+# every path can be configured separately we do not remember one general
+# prefix/exec_prefix but all the different paths individually.
+
+tkPkgConfig.o: $(GENERIC_DIR)/tkPkgConfig.c
+ $(CC) -c $(CC_SWITCHES) \
+ -DCFG_INSTALL_LIBDIR="\"$(LIB_INSTALL_DIR)\"" \
+ -DCFG_INSTALL_BINDIR="\"$(BIN_INSTALL_DIR)\"" \
+ -DCFG_INSTALL_SCRDIR="\"$(SCRIPT_INSTALL_DIR)\"" \
+ -DCFG_INSTALL_INCDIR="\"$(INCLUDE_INSTALL_DIR)\"" \
+ -DCFG_INSTALL_DOCDIR="\"$(MAN_INSTALL_DIR)\"" \
+ -DCFG_INSTALL_DEMODIR="\"$(DEMO_INSTALL_DIR)\"" \
+ \
+ -DCFG_RUNTIME_LIBDIR="\"$(libdir)\"" \
+ -DCFG_RUNTIME_BINDIR="\"$(bindir)\"" \
+ -DCFG_RUNTIME_SCRDIR="\"$(TK_LIBRARY)\"" \
+ -DCFG_RUNTIME_INCDIR="\"$(includedir)\"" \
+ -DCFG_RUNTIME_DOCDIR="\"$(mandir)\"" \
+ -DCFG_RUNTIME_DEMODIR="\"$(DEMO_INSTALL_DIR)\"" \
+ \
+ $(GENERIC_DIR)/tkPkgConfig.c
+
tkPlace.o: $(GENERIC_DIR)/tkPlace.c
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkPlace.c
@@ -1118,6 +1147,9 @@ tkImgPNG.o: $(GENERIC_DIR)/tkImgPNG.c
tkImgPPM.o: $(GENERIC_DIR)/tkImgPPM.c
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkImgPPM.c
+tkImgSVGnano.o: $(GENERIC_DIR)/tkImgSVGnano.c
+ $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkImgSVGnano.c
+
tkImgPhoto.o: $(GENERIC_DIR)/tkImgPhoto.c $(GENERIC_DIR)/tkImgPhoto.h
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkImgPhoto.c
@@ -1316,6 +1348,9 @@ tkMacOSXScrlbr.o: $(MAC_OSX_DIR)/tkMacOSXScrlbr.c
tkMacOSXSend.o: $(MAC_OSX_DIR)/tkMacOSXSend.c
$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXSend.c
+tkMacOSXServices.o: $(MAC_OSX_DIR)/tkMacOSXServices.c
+ $(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXServices.c
+
tkMacOSXSubwindows.o: $(MAC_OSX_DIR)/tkMacOSXSubwindows.c
$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tkMacOSXSubwindows.c
@@ -1534,7 +1569,6 @@ DISTROOT = /tmp/dist
DISTNAME = tk${VERSION}${PATCH_LEVEL}
ZIPNAME = tk${MAJOR_VERSION}${MINOR_VERSION}${PATCH_LEVEL}-src.zip
DISTDIR = $(DISTROOT)/$(DISTNAME)
-TCLDIR = @TCL_SRC_DIR@
DIST_INSTALL_DATA = CPPROG='cp -p' $(INSTALL) -m 644
DIST_INSTALL_SCRIPT = CPPROG='cp -p' $(INSTALL) -m 755
@@ -1546,14 +1580,14 @@ $(MAC_OSX_DIR)/configure: $(MAC_OSX_DIR)/configure.ac $(UNIX_DIR)/configure
$(UNIX_DIR)/tkConfig.h.in: $(MAC_OSX_DIR)/configure
cd $(MAC_OSX_DIR); autoheader; touch $@
-dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(MAC_OSX_DIR)/configure genstubs
+dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(MAC_OSX_DIR)/configure $(TOP_DIR)/doc/man.macros genstubs
rm -rf $(DISTDIR)
$(INSTALL_DATA_DIR) $(DISTDIR)/unix
$(DIST_INSTALL_DATA) $(UNIX_DIR)/*.c $(UNIX_DIR)/*.h $(DISTDIR)/unix
$(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(UNIX_DIR)/Makefile.in $(DISTDIR)/unix
$(DIST_INSTALL_DATA) $(UNIX_DIR)/configure.ac $(UNIX_DIR)/tk.spec \
$(UNIX_DIR)/aclocal.m4 $(UNIX_DIR)/tcl.m4 \
- $(UNIX_DIR)/tkConfig.sh.in $(TCLDIR)/unix/install-sh \
+ $(UNIX_DIR)/tkConfig.sh.in $(UNIX_DIR)/install-sh \
$(UNIX_DIR)/README $(UNIX_DIR)/installManPage \
$(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(DISTDIR)/unix
$(DIST_INSTALL_SCRIPT) $(UNIX_DIR)/configure $(DISTDIR)/unix
@@ -1569,7 +1603,7 @@ dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(MAC
$(DIST_INSTALL_DATA) $(GENERIC_DIR)/*.decls $(DISTDIR)/generic
$(DIST_INSTALL_DATA) $(GENERIC_DIR)/README $(DISTDIR)/generic
$(DIST_INSTALL_DATA) $(TOP_DIR)/changes $(TOP_DIR)/ChangeLog \
- $(TOP_DIR)/ChangeLog.2??? $(TOP_DIR)/README \
+ $(TOP_DIR)/ChangeLog.2??? $(TOP_DIR)/README.md \
$(TOP_DIR)/license.terms $(DISTDIR)
rm -f $(DISTDIR)/generic/blt*.[ch]
$(INSTALL_DATA_DIR) $(DISTDIR)/generic/ttk
@@ -1607,9 +1641,8 @@ dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(MAC
$(MAC_OSX_DIR)/Tk.xcodeproj/default.pbxuser \
$(DISTDIR)/macosx/Tk.xcodeproj
$(INSTALL_DATA_DIR) $(DISTDIR)/compat
- $(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(TCLDIR)/compat/unistd.h \
- $(TCLDIR)/compat/stdlib.h \
- $(DISTDIR)/compat
+ $(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(TOP_DIR)/compat/stdint.h \
+ $(TOP_DIR)/compat/stdbool.h $(DISTDIR)/compat
$(INSTALL_DATA_DIR) $(DISTDIR)/xlib
$(DIST_INSTALL_DATA) $(XLIB_DIR)/*.[ch] $(DISTDIR)/xlib
$(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(DISTDIR)/xlib
@@ -1655,7 +1688,7 @@ dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(MAC
done;)
$(INSTALL_DATA_DIR) $(DISTDIR)/doc
$(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(TOP_DIR)/doc/*.[13n] \
- $(TCLDIR)/doc/man.macros $(DISTDIR)/doc
+ $(TOP_DIR)/doc/man.macros $(DISTDIR)/doc
$(INSTALL_DATA_DIR) $(DISTDIR)/tests
$(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(TEST_DIR)/*.{test,tcl} \
$(TEST_DIR)/README $(TEST_DIR)/*.{gif,png,ppm,xbm} \
diff --git a/unix/README b/unix/README
index ea5c8fe..d4be49d 100644
--- a/unix/README
+++ b/unix/README
@@ -6,11 +6,11 @@ versions of Tk. This directory also contains source files for Tk that are
specific to UNIX.
The information in this file is maintained at:
- http://www.tcl.tk/doc/howto/compile.html
+ https://www.tcl-lang.org//doc/howto/compile.html
For information on platforms where Tcl/Tk is known to compile, along with any
porting notes for getting it to work on those platforms, see:
- http://www.tcl.tk/software/tcltk/platforms.html
+ https://www.tcl-lang.org//software/tcltk/platforms.html
The rest of this file contains instructions on how to do this. The release
should compile and run either "out of the box" or with trivial changes on any
diff --git a/unix/configure b/unix/configure
index cf5ce30..dceb0a1 100755
--- a/unix/configure
+++ b/unix/configure
@@ -661,6 +661,8 @@ TK_PATCH_LEVEL
TK_MINOR_VERSION
TK_MAJOR_VERSION
TK_VERSION
+TK_DEMO_DIR
+DEMO_DIR
UNIX_FONT_OBJS
XFT_LIBS
XFT_CFLAGS
@@ -692,13 +694,13 @@ PLAT_OBJS
DL_OBJS
DL_LIBS
TCL_LIBS
+EGREP
+GREP
+CPP
LIBOBJS
AR
RANLIB
SHARED_BUILD
-EGREP
-GREP
-CPP
OBJEXT
EXEEXT
ac_ct_CC
@@ -765,6 +767,7 @@ with_tcl
enable_man_symlinks
enable_man_compression
enable_man_suffix
+with_encoding
enable_shared
enable_64bit
enable_64bit_vis
@@ -1427,6 +1430,8 @@ Optional Packages:
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-tcl directory containing tcl configuration
(tclConfig.sh)
+ --with-encoding encoding for configuration values (default:
+ iso8859-1)
--with-x use the X Window System
Some influential environment variables:
@@ -1558,6 +1563,52 @@ fi
} # ac_fn_c_try_compile
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ test -x conftest$ac_exeext
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+ # interfere with the next link command; also delete a directory that is
+ # left behind by Apple's compiler. We do this before executing the actions.
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
# ac_fn_c_try_cpp LINENO
# ----------------------
# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
@@ -1755,52 +1806,6 @@ $as_echo "$ac_res" >&6; }
} # ac_fn_c_check_header_compile
-# ac_fn_c_try_link LINENO
-# -----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_link ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- rm -f conftest.$ac_objext conftest$ac_exeext
- if { { ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link") 2>conftest.err
- ac_status=$?
- if test -s conftest.err; then
- grep -v '^ *+' conftest.err >conftest.er1
- cat conftest.er1 >&5
- mv -f conftest.er1 conftest.err
- fi
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } && {
- test -z "$ac_c_werror_flag" ||
- test ! -s conftest.err
- } && test -s conftest$ac_exeext && {
- test "$cross_compiling" = yes ||
- test -x conftest$ac_exeext
- }; then :
- ac_retval=0
-else
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_retval=1
-fi
- # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
- # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
- # interfere with the next link command; also delete a directory that is
- # left behind by Apple's compiler. We do this before executing the actions.
- rm -rf conftest.dSYM conftest_ipa8_conftest.oo
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
- as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_link
-
# ac_fn_c_check_func LINENO FUNC VAR
# ----------------------------------
# Tests whether FUNC exists, setting the cache variable VAR accordingly
@@ -2280,7 +2285,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
TK_VERSION=8.7
TK_MAJOR_VERSION=8
TK_MINOR_VERSION=7
-TK_PATCH_LEVEL="a2"
+TK_PATCH_LEVEL="a4"
VERSION=${TK_VERSION}
LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv"
@@ -2355,7 +2360,6 @@ $as_echo "$as_me: WARNING: --with-tcl argument should refer to directory contain
for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
`ls -d /Library/Frameworks 2>/dev/null` \
`ls -d /Network/Library/Frameworks 2>/dev/null` \
- `ls -d /System/Library/Frameworks 2>/dev/null` \
; do
if test -f "$i/Tcl.framework/tclConfig.sh" ; then
ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`"
@@ -2372,6 +2376,7 @@ $as_echo "$as_me: WARNING: --with-tcl argument should refer to directory contain
`ls -d /usr/local/lib 2>/dev/null` \
`ls -d /usr/contrib/lib 2>/dev/null` \
`ls -d /usr/pkg/lib 2>/dev/null` \
+ `ls -d /usr/lib/tcl8.7 2>/dev/null` \
`ls -d /usr/lib 2>/dev/null` \
`ls -d /usr/lib64 2>/dev/null` \
`ls -d /usr/local/lib/tcl8.7 2>/dev/null` \
@@ -2425,10 +2430,6 @@ $as_echo "loading" >&6; }
$as_echo "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
fi
- # eval is required to do the TCL_DBGX substitution
- eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
- eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
-
# If the TCL_BIN_DIR is the build directory (not the install directory),
# then set the common variable name to the value of the build variables.
# For example, the variable TCL_LIB_SPEC will be set to the value
@@ -2462,12 +2463,6 @@ $as_echo "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
esac
fi
- # eval is required to do the TCL_DBGX substitution
- eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
- eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
- eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
- eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
-
@@ -3457,11 +3452,201 @@ _ACEOF
esac
+#------------------------------------------------------------------------
+# If we're using GCC, see if the compiler understands -pipe. If so, use it.
+# It makes compiling go faster. (This is only a performance feature.)
+#------------------------------------------------------------------------
+
+if test -z "$no_pipe" && test -n "$GCC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler understands -pipe" >&5
+$as_echo_n "checking if the compiler understands -pipe... " >&6; }
+if ${tcl_cv_cc_pipe+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -pipe"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ tcl_cv_cc_pipe=yes
+else
+ tcl_cv_cc_pipe=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS=$hold_cflags
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_pipe" >&5
+$as_echo "$tcl_cv_cc_pipe" >&6; }
+ if test $tcl_cv_cc_pipe = yes; then
+ CFLAGS="$CFLAGS -pipe"
+ fi
+fi
+
+#------------------------------------------------------------------------
+# Embedded configuration information, encoding to use for the values, TIP #59
+#------------------------------------------------------------------------
+
+
+
+# Check whether --with-encoding was given.
+if test "${with_encoding+set}" = set; then :
+ withval=$with_encoding; with_tcencoding=${withval}
+fi
+
+
+ if test x"${with_tcencoding}" != x ; then
+
+cat >>confdefs.h <<_ACEOF
+#define TCL_CFGVAL_ENCODING "${with_tcencoding}"
+_ACEOF
+
+ else
+
+$as_echo "#define TCL_CFGVAL_ENCODING \"iso8859-1\"" >>confdefs.h
+
+ fi
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to build libraries" >&5
+$as_echo_n "checking how to build libraries... " >&6; }
+ # Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+ enableval=$enable_shared; tcl_ok=$enableval
+else
+ tcl_ok=yes
+fi
+
+
+ if test "${enable_shared+set}" = set; then
+ enableval="$enable_shared"
+ tcl_ok=$enableval
+ else
+ tcl_ok=yes
+ fi
+
+ if test "$tcl_ok" = "yes" ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: shared" >&5
+$as_echo "shared" >&6; }
+ SHARED_BUILD=1
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: static" >&5
+$as_echo "static" >&6; }
+ SHARED_BUILD=0
+
+$as_echo "#define STATIC_BUILD 1" >>confdefs.h
+
+ fi
+
+
+
#--------------------------------------------------------------------
-# Supply a substitute for stdlib.h if it doesn't define strtol,
-# strtoul, or strtod (which it doesn't in some versions of SunOS).
+# The statements below define a collection of compile flags. This
+# macro depends on the value of SHARED_BUILD, and should be called
+# after SC_ENABLE_SHARED checks the configure switches.
#--------------------------------------------------------------------
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+ ac_ct_RANLIB=$RANLIB
+ # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_RANLIB"; then
+ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_RANLIB="ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_RANLIB" = x; then
+ RANLIB=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ RANLIB=$ac_ct_RANLIB
+ fi
+else
+ RANLIB="$ac_cv_prog_RANLIB"
+fi
+
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3859,229 +4044,6 @@ fi
done
-ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
-if test "x$ac_cv_header_stdlib_h" = xyes; then :
- tk_ok=1
-else
- tk_ok=0
-fi
-
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "strtol" >/dev/null 2>&1; then :
-
-else
- tk_ok=0
-fi
-rm -f conftest*
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "strtoul" >/dev/null 2>&1; then :
-
-else
- tk_ok=0
-fi
-rm -f conftest*
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "strtod" >/dev/null 2>&1; then :
-
-else
- tk_ok=0
-fi
-rm -f conftest*
-
-if test $tk_ok = 0; then
-
-$as_echo "#define NO_STDLIB_H 1" >>confdefs.h
-
-fi
-
-#------------------------------------------------------------------------
-# If we're using GCC, see if the compiler understands -pipe. If so, use it.
-# It makes compiling go faster. (This is only a performance feature.)
-#------------------------------------------------------------------------
-
-if test -z "$no_pipe" && test -n "$GCC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler understands -pipe" >&5
-$as_echo_n "checking if the compiler understands -pipe... " >&6; }
-if ${tcl_cv_cc_pipe+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -pipe"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- tcl_cv_cc_pipe=yes
-else
- tcl_cv_cc_pipe=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- CFLAGS=$hold_cflags
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_pipe" >&5
-$as_echo "$tcl_cv_cc_pipe" >&6; }
- if test $tcl_cv_cc_pipe = yes; then
- CFLAGS="$CFLAGS -pipe"
- fi
-fi
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to build libraries" >&5
-$as_echo_n "checking how to build libraries... " >&6; }
- # Check whether --enable-shared was given.
-if test "${enable_shared+set}" = set; then :
- enableval=$enable_shared; tcl_ok=$enableval
-else
- tcl_ok=yes
-fi
-
-
- if test "${enable_shared+set}" = set; then
- enableval="$enable_shared"
- tcl_ok=$enableval
- else
- tcl_ok=yes
- fi
-
- if test "$tcl_ok" = "yes" ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: shared" >&5
-$as_echo "shared" >&6; }
- SHARED_BUILD=1
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: static" >&5
-$as_echo "static" >&6; }
- SHARED_BUILD=0
-
-$as_echo "#define STATIC_BUILD 1" >>confdefs.h
-
- fi
-
-
-
-#--------------------------------------------------------------------
-# The statements below define a collection of compile flags. This
-# macro depends on the value of SHARED_BUILD, and should be called
-# after SC_ENABLE_SHARED checks the configure switches.
-#--------------------------------------------------------------------
-
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_RANLIB+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
-$as_echo "$RANLIB" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
- ac_ct_RANLIB=$RANLIB
- # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test -n "$ac_ct_RANLIB"; then
- ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_RANLIB="ranlib"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
-$as_echo "$ac_ct_RANLIB" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
- if test "x$ac_ct_RANLIB" = x; then
- RANLIB=":"
- else
- case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
- RANLIB=$ac_ct_RANLIB
- fi
-else
- RANLIB="$ac_cv_prog_RANLIB"
-fi
-
# Step 0.a: Enable 64 bit support?
@@ -4197,6 +4159,9 @@ $as_echo "$as_me: WARNING: can't find uname command" >&2;}
if test "`uname -s`" = "AIX" ; then
tcl_cv_sys_version=AIX-`uname -v`.`uname -r`
fi
+ if test "`uname -s`" = "NetBSD" -a -f /etc/debian_version ; then
+ tcl_cv_sys_version=NetBSD-Debian
+ fi
fi
fi
@@ -4274,7 +4239,15 @@ fi
if test "$GCC" = yes; then :
CFLAGS_OPTIMIZE=-O2
- CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement -Wpointer-arith"
+ CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wpointer-arith"
+ case "${CC}" in
+ *++)
+ ;;
+ *)
+ CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -Wdeclaration-after-statement"
+ ;;
+ esac
+
else
@@ -4551,7 +4524,7 @@ fi
CC_SEARCH_FLAGS=""
LD_SEARCH_FLAGS=""
TCL_NEEDS_EXP_FILE=1
- TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.dll.a'
+ TCL_EXPORT_FILE_SUFFIX='${VERSION}.dll.a'
SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$@.a"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Cygwin version of gcc" >&5
$as_echo_n "checking for Cygwin version of gcc... " >&6; }
@@ -4754,7 +4727,7 @@ fi
SHLIB_LD='${CC} -shared'
if test $doRpath = yes; then :
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
fi
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
;;
@@ -4844,7 +4817,7 @@ esac
if test $doRpath = yes; then :
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
fi
;;
@@ -4862,7 +4835,7 @@ esac
if test $doRpath = yes; then :
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
fi
if test "$GCC" = yes; then :
@@ -4899,7 +4872,7 @@ esac
if test $doRpath = yes; then :
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
fi
@@ -4939,7 +4912,7 @@ fi
LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
if test $doRpath = yes; then :
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
fi
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
if test "`uname -m`" = "alpha"; then :
@@ -4987,7 +4960,7 @@ fi
fi
# The combo of gcc + glibc has a bug related to inlining of
- # functions like strtod(). The -fno-builtin flag should address
+ # functions like strtol()/strtoul(). The -fno-builtin flag should address
# this problem but it does not work. The -fno-inline flag is kind
# of overkill but it works. Disable inlining only when one of the
# files in compat/*.c is being linked in.
@@ -5006,8 +4979,8 @@ fi
LD_FLAGS="-Wl,--export-dynamic"
if test $doRpath = yes; then :
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
- LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
+ LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
fi
;;
OpenBSD-*)
@@ -5026,7 +4999,7 @@ fi
DL_LIBS=""
if test $doRpath = yes; then :
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
fi
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
@@ -5050,7 +5023,7 @@ fi
LDFLAGS="$LDFLAGS -export-dynamic"
if test $doRpath = yes; then :
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
fi
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
# The -pthread needs to go in the CFLAGS, not LIBS
@@ -5066,11 +5039,10 @@ fi
SHLIB_SUFFIX=".so"
DL_OBJS="tclLoadDl.o"
DL_LIBS=""
- LDFLAGS=""
if test $doRpath = yes; then :
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
- LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
+ LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
fi
# The -pthread needs to go in the LDFLAGS, not LIBS
LIBS=`echo $LIBS | sed s/-pthread//`
@@ -5229,12 +5201,6 @@ fi
SHLIB_SUFFIX=".dylib"
DL_OBJS="tclLoadDyld.o"
DL_LIBS=""
- # Don't use -prebind when building for Mac OS X 10.4 or later only:
- if test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int($2)}'`" -lt 4 -a \
- "`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int($2)}'`" -lt 4; then :
-
- LDFLAGS="$LDFLAGS -prebind"
-fi
LDFLAGS="$LDFLAGS -headerpad_max_install_names"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if ld accepts -search_paths_first flag" >&5
$as_echo_n "checking if ld accepts -search_paths_first flag... " >&6; }
@@ -5276,6 +5242,7 @@ fi
$as_echo "#define MODULE_SCOPE __private_extern__" >>confdefs.h
+ tcl_cv_cc_visibility_hidden=yes
fi
CC_SEARCH_FLAGS=""
@@ -5427,7 +5394,7 @@ fi
DL_LIBS=""
if test $doRpath = yes; then :
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'
fi
if test "$GCC" = yes; then :
@@ -5470,13 +5437,13 @@ fi
# below.
if test "$GCC" = yes; then :
- SHLIB_CFLAGS="-fPIC -melf"
- LDFLAGS="$LDFLAGS -melf -Wl,-Bexport"
+ SHLIB_CFLAGS="-fPIC -melf"
+ LDFLAGS="$LDFLAGS -melf -Wl,-Bexport"
else
- SHLIB_CFLAGS="-Kpic -belf"
- LDFLAGS="$LDFLAGS -belf -Wl,-Bexport"
+ SHLIB_CFLAGS="-Kpic -belf"
+ LDFLAGS="$LDFLAGS -belf -Wl,-Bexport"
fi
SHLIB_LD="ld -G"
@@ -5827,7 +5794,7 @@ fi
if test "${SHARED_BUILD}" = 1 -a "${SHLIB_SUFFIX}" != ""; then :
LIB_SUFFIX=${SHARED_LIB_SUFFIX}
- MAKE_LIB='${SHLIB_LD} -o $@ ${OBJS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
+ MAKE_LIB='${SHLIB_LD} -o $@ ${OBJS} ${LDFLAGS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
if test "${SHLIB_SUFFIX}" = ".dll"; then :
INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(BIN_INSTALL_DIR)/$(LIB_FILE)";if test -f $(LIB_FILE).a; then $(INSTALL_DATA) $(LIB_FILE).a "$(LIB_INSTALL_DIR)"; fi;'
@@ -5916,6 +5883,15 @@ $as_echo "#define HAVE_CAST_TO_UNION 1" >>confdefs.h
fi
+ ac_fn_c_check_header_mongrel "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdbool_h" = xyes; then :
+
+$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
+
+fi
+
+
+
# FIXME: This subst was left in only because the TCL_DL_LIBS
# entry in tclConfig.sh uses it. It is not clear why someone
# would use TCL_DL_LIBS instead of TCL_LIBS.
@@ -5968,7 +5944,6 @@ else
fi
# FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
- DBGX=""
if test "$tcl_ok" = "no"; then
CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
@@ -7684,8 +7659,8 @@ $as_echo "$enable_xft" >&6; }
XFT_LIBS=`xft-config --libs 2>/dev/null` || found_xft="no"
if test "$found_xft" = "no" ; then
found_xft=yes
- XFT_CFLAGS=`pkg-config --cflags xft 2>/dev/null` || found_xft="no"
- XFT_LIBS=`pkg-config --libs xft 2>/dev/null` || found_xft="no"
+ XFT_CFLAGS=`pkg-config --cflags xft fontconfig 2>/dev/null` || found_xft="no"
+ XFT_LIBS=`pkg-config --libs xft fontconfig 2>/dev/null` || found_xft="no"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $found_xft" >&5
$as_echo "$found_xft" >&6; }
@@ -7841,130 +7816,6 @@ $as_echo "#define HAVE_XFT 1" >>confdefs.h
fi
#--------------------------------------------------------------------
-# Check for XkbKeycodeToKeysym.
-#--------------------------------------------------------------------
-
-if test $tk_aqua = no; then
- tk_oldCFlags=$CFLAGS
- tk_oldLibs=$LIBS
- CFLAGS="$CFLAGS $XINCLUDES"
- LIBS="$LIBS $XLIBSW"
- ac_fn_c_check_header_compile "$LINENO" "X11/XKBlib.h" "ac_cv_header_X11_XKBlib_h" "#include <X11/Xlib.h>
-"
-if test "x$ac_cv_header_X11_XKBlib_h" = xyes; then :
-
- xkblib_header_found=yes
-
-else
-
- xkblib_header_found=no
-
-fi
-
-
- if test $xkblib_header_found = "yes" ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XkbKeycodeToKeysym in -lX11" >&5
-$as_echo_n "checking for XkbKeycodeToKeysym in -lX11... " >&6; }
-if ${ac_cv_lib_X11_XkbKeycodeToKeysym+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lX11 $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XkbKeycodeToKeysym ();
-int
-main ()
-{
-return XkbKeycodeToKeysym ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_X11_XkbKeycodeToKeysym=yes
-else
- ac_cv_lib_X11_XkbKeycodeToKeysym=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_X11_XkbKeycodeToKeysym" >&5
-$as_echo "$ac_cv_lib_X11_XkbKeycodeToKeysym" >&6; }
-if test "x$ac_cv_lib_X11_XkbKeycodeToKeysym" = xyes; then :
-
- xkbkeycodetokeysym_found=yes
-
-else
-
- xkbkeycodetokeysym_found=no
-
-fi
-
- else
- xkbkeycodetokeysym_found=no
- fi
- if test $xkbkeycodetokeysym_found = "yes" ; then
-
-$as_echo "#define HAVE_XKBKEYCODETOKEYSYM 1" >>confdefs.h
-
- fi
- CFLAGS=$tk_oldCFlags
- LIBS=$tk_oldLibs
-fi
-
-#--------------------------------------------------------------------
-# Check whether XKeycodeToKeysym is deprecated in X11 headers.
-#--------------------------------------------------------------------
-
-if test $tk_aqua = no && test "$GCC" = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether XKeycodeToKeysym is deprecated" >&5
-$as_echo_n "checking whether XKeycodeToKeysym is deprecated... " >&6; }
- tk_oldCFlags=$CFLAGS
- CFLAGS="$CFLAGS -Werror"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
- #include <X11/Xlib.h>
-
-int
-main ()
-{
-
- XKeycodeToKeysym(0,0,0);
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-else
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-$as_echo "#define XKEYCODETOKEYSYM_IS_DEPRECATED 1" >>confdefs.h
-
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- CFLAGS=$tk_oldCFlags
-fi
-
-#--------------------------------------------------------------------
# XXX Do this last.
# It might modify XLIBSW which could affect other tests.
#
@@ -8175,7 +8026,7 @@ if test "${SHARED_BUILD}" = "1" -a "${SHLIB_SUFFIX}" != ""; then
TCL_STUB_FLAGS="-DUSE_TCL_STUBS"
fi
-TK_LIBRARY='$(prefix)/lib/tk$(VERSION)'
+test -z "$TK_LIBRARY" && TK_LIBRARY='$(prefix)/lib/tk$(VERSION)'
PRIVATE_INCLUDE_DIR='$(includedir)'
HTML_DIR='$(DISTDIR)/html'
TK_PKG_DIR='tk$(VERSION)'
@@ -8327,6 +8178,18 @@ TK_STUB_LIB_PATH="${TK_STUB_LIB_DIR}/${TK_STUB_LIB_FILE}"
eval "TK_INCLUDE_SPEC=\"-I${includedir}\""
#------------------------------------------------------------------------
+# Demo dir
+#------------------------------------------------------------------------
+
+if test x"${DEMO_DIR}" = x; then :
+ DEMO_DIR='$(TK_LIBRARY)/demos'
+fi
+eval "TK_DEMO_DIR=\"`echo ${DEMO_DIR} | tr '()' '{}'`\""
+eval "TK_DEMO_DIR=\"`echo ${TK_DEMO_DIR} | tr '()' '{}'`\""
+
+
+
+#------------------------------------------------------------------------
# tkConfig.sh refers to this by a different name
#------------------------------------------------------------------------
diff --git a/unix/configure.ac b/unix/configure.ac
index 5f5213d..b765f13 100644
--- a/unix/configure.ac
+++ b/unix/configure.ac
@@ -25,7 +25,7 @@ m4_ifdef([SC_USE_CONFIG_HEADERS], [
TK_VERSION=8.7
TK_MAJOR_VERSION=8
TK_MINOR_VERSION=7
-TK_PATCH_LEVEL="a2"
+TK_PATCH_LEVEL="a4"
VERSION=${TK_VERSION}
LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv"
@@ -83,19 +83,6 @@ fi
AC_PROG_CC
AC_C_INLINE
-#--------------------------------------------------------------------
-# Supply a substitute for stdlib.h if it doesn't define strtol,
-# strtoul, or strtod (which it doesn't in some versions of SunOS).
-#--------------------------------------------------------------------
-
-AC_CHECK_HEADER(stdlib.h, tk_ok=1, tk_ok=0)
-AC_EGREP_HEADER(strtol, stdlib.h, , tk_ok=0)
-AC_EGREP_HEADER(strtoul, stdlib.h, , tk_ok=0)
-AC_EGREP_HEADER(strtod, stdlib.h, , tk_ok=0)
-if test $tk_ok = 0; then
- AC_DEFINE(NO_STDLIB_H, 1, [Do we have <stdlib.h>?])
-fi
-
#------------------------------------------------------------------------
# If we're using GCC, see if the compiler understands -pipe. If so, use it.
# It makes compiling go faster. (This is only a performance feature.)
@@ -112,6 +99,12 @@ if test -z "$no_pipe" && test -n "$GCC"; then
fi
fi
+#------------------------------------------------------------------------
+# Embedded configuration information, encoding to use for the values, TIP #59
+#------------------------------------------------------------------------
+
+SC_TCL_CFG_ENCODING
+
SC_ENABLE_SHARED
#--------------------------------------------------------------------
@@ -463,8 +456,8 @@ if test $tk_aqua = no; then
XFT_LIBS=`xft-config --libs 2>/dev/null` || found_xft="no"
if test "$found_xft" = "no" ; then
found_xft=yes
- XFT_CFLAGS=`pkg-config --cflags xft 2>/dev/null` || found_xft="no"
- XFT_LIBS=`pkg-config --libs xft 2>/dev/null` || found_xft="no"
+ XFT_CFLAGS=`pkg-config --cflags xft fontconfig 2>/dev/null` || found_xft="no"
+ XFT_LIBS=`pkg-config --libs xft fontconfig 2>/dev/null` || found_xft="no"
fi
AC_MSG_RESULT([$found_xft])
dnl make sure that compiling against Xft header file doesn't bomb
@@ -527,57 +520,6 @@ if test $tk_aqua = no; then
fi
#--------------------------------------------------------------------
-# Check for XkbKeycodeToKeysym.
-#--------------------------------------------------------------------
-
-if test $tk_aqua = no; then
- tk_oldCFlags=$CFLAGS
- tk_oldLibs=$LIBS
- CFLAGS="$CFLAGS $XINCLUDES"
- LIBS="$LIBS $XLIBSW"
- AC_CHECK_HEADER(X11/XKBlib.h, [
- xkblib_header_found=yes
- ], [
- xkblib_header_found=no
- ], [#include <X11/Xlib.h>])
- if test $xkblib_header_found = "yes" ; then
- AC_CHECK_LIB(X11, XkbKeycodeToKeysym, [
- xkbkeycodetokeysym_found=yes
- ], [
- xkbkeycodetokeysym_found=no
- ])
- else
- xkbkeycodetokeysym_found=no
- fi
- if test $xkbkeycodetokeysym_found = "yes" ; then
- AC_DEFINE(HAVE_XKBKEYCODETOKEYSYM, 1, [Do we have XkbKeycodeToKeysym?])
- fi
- CFLAGS=$tk_oldCFlags
- LIBS=$tk_oldLibs
-fi
-
-#--------------------------------------------------------------------
-# Check whether XKeycodeToKeysym is deprecated in X11 headers.
-#--------------------------------------------------------------------
-
-if test $tk_aqua = no && test "$GCC" = yes; then
- AC_MSG_CHECKING([whether XKeycodeToKeysym is deprecated])
- tk_oldCFlags=$CFLAGS
- CFLAGS="$CFLAGS -Werror"
- AC_TRY_LINK([
- #include <X11/Xlib.h>
- ], [
- XKeycodeToKeysym(0,0,0);
- ], [
- AC_MSG_RESULT([no])
- ], [
- AC_MSG_RESULT([yes])
- AC_DEFINE(XKEYCODETOKEYSYM_IS_DEPRECATED, 1, [Is XKeycodeToKeysym deprecated?])
- ])
- CFLAGS=$tk_oldCFlags
-fi
-
-#--------------------------------------------------------------------
# XXX Do this last.
# It might modify XLIBSW which could affect other tests.
#
@@ -656,7 +598,7 @@ if test "${SHARED_BUILD}" = "1" -a "${SHLIB_SUFFIX}" != ""; then
TCL_STUB_FLAGS="-DUSE_TCL_STUBS"
fi
-TK_LIBRARY='$(prefix)/lib/tk$(VERSION)'
+test -z "$TK_LIBRARY" && TK_LIBRARY='$(prefix)/lib/tk$(VERSION)'
PRIVATE_INCLUDE_DIR='$(includedir)'
HTML_DIR='$(DISTDIR)/html'
TK_PKG_DIR='tk$(VERSION)'
@@ -773,6 +715,16 @@ TK_STUB_LIB_PATH="${TK_STUB_LIB_DIR}/${TK_STUB_LIB_FILE}"
eval "TK_INCLUDE_SPEC=\"-I${includedir}\""
#------------------------------------------------------------------------
+# Demo dir
+#------------------------------------------------------------------------
+
+AS_IF([test x"${DEMO_DIR}" = x], [DEMO_DIR='$(TK_LIBRARY)/demos'])
+eval "TK_DEMO_DIR=\"`echo ${DEMO_DIR} | tr '()' '{}'`\""
+eval "TK_DEMO_DIR=\"`echo ${TK_DEMO_DIR} | tr '()' '{}'`\""
+AC_SUBST(DEMO_DIR)
+AC_SUBST(TK_DEMO_DIR)
+
+#------------------------------------------------------------------------
# tkConfig.sh refers to this by a different name
#------------------------------------------------------------------------
diff --git a/unix/installManPage b/unix/installManPage
index 4d615bf..935bbcd 100755
--- a/unix/installManPage
+++ b/unix/installManPage
@@ -92,12 +92,20 @@ case $ManPage in
exit 2 ;;
esac
+Name=`basename $ManPage .$Section`
SrcDir=`dirname $ManPage`
########################################################################
### Process Page to Create Target Pages
###
+Specials="FindPhoto FontId MeasureChar"
+for n in $Specials; do
+ if [ "$Name" = "$n" ] ; then
+ Names="$n $Names"
+ fi
+done
+
First=""
for Target in $Names; do
Target=$Target.$Section$Suffix
@@ -106,7 +114,7 @@ for Target in $Names; do
First=$Target
sed -e "/man\.macros/r $SrcDir/man.macros" -e "/man\.macros/d" \
$ManPage > $Dir/$First
- chmod 444 $Dir/$First
+ chmod 644 $Dir/$First
$Gzip $Dir/$First
else
ln $SymOrLoc$First$Gz $Dir/$Target$Gz
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 2f114d7..0a2920b 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -77,7 +77,6 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [
for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
`ls -d /Library/Frameworks 2>/dev/null` \
`ls -d /Network/Library/Frameworks 2>/dev/null` \
- `ls -d /System/Library/Frameworks 2>/dev/null` \
; do
if test -f "$i/Tcl.framework/tclConfig.sh" ; then
ac_cv_c_tclconfig="`(cd $i/Tcl.framework; pwd)`"
@@ -94,6 +93,7 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [
`ls -d /usr/local/lib 2>/dev/null` \
`ls -d /usr/contrib/lib 2>/dev/null` \
`ls -d /usr/pkg/lib 2>/dev/null` \
+ `ls -d /usr/lib/tcl8.7 2>/dev/null` \
`ls -d /usr/lib 2>/dev/null` \
`ls -d /usr/lib64 2>/dev/null` \
`ls -d /usr/local/lib/tcl8.7 2>/dev/null` \
@@ -210,7 +210,6 @@ AC_DEFUN([SC_PATH_TKCONFIG], [
for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
`ls -d /Library/Frameworks 2>/dev/null` \
`ls -d /Network/Library/Frameworks 2>/dev/null` \
- `ls -d /System/Library/Frameworks 2>/dev/null` \
; do
if test -f "$i/Tk.framework/tkConfig.sh" ; then
ac_cv_c_tkconfig="`(cd $i/Tk.framework; pwd)`"
@@ -227,6 +226,7 @@ AC_DEFUN([SC_PATH_TKCONFIG], [
`ls -d /usr/local/lib 2>/dev/null` \
`ls -d /usr/contrib/lib 2>/dev/null` \
`ls -d /usr/pkg/lib 2>/dev/null` \
+ `ls -d /usr/lib/tk8.7 2>/dev/null` \
`ls -d /usr/lib 2>/dev/null` \
`ls -d /usr/lib64 2>/dev/null` \
`ls -d /usr/local/lib/tk8.7 2>/dev/null` \
@@ -293,10 +293,6 @@ AC_DEFUN([SC_LOAD_TCLCONFIG], [
AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
fi
- # eval is required to do the TCL_DBGX substitution
- eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
- eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
-
# If the TCL_BIN_DIR is the build directory (not the install directory),
# then set the common variable name to the value of the build variables.
# For example, the variable TCL_LIB_SPEC will be set to the value
@@ -330,12 +326,6 @@ AC_DEFUN([SC_LOAD_TCLCONFIG], [
esac
fi
- # eval is required to do the TCL_DBGX substitution
- eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
- eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
- eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
- eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
-
AC_SUBST(TCL_VERSION)
AC_SUBST(TCL_PATCH_LEVEL)
AC_SUBST(TCL_BIN_DIR)
@@ -376,10 +366,6 @@ AC_DEFUN([SC_LOAD_TKCONFIG], [
AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
fi
- # eval is required to do the TK_DBGX substitution
- eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
- eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
-
# If the TK_BIN_DIR is the build directory (not the install directory),
# then set the common variable name to the value of the build variables.
# For example, the variable TK_LIB_SPEC will be set to the value
@@ -413,12 +399,6 @@ AC_DEFUN([SC_LOAD_TKCONFIG], [
esac
fi
- # eval is required to do the TK_DBGX substitution
- eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
- eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
- eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
- eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
-
AC_SUBST(TK_VERSION)
AC_SUBST(TK_BIN_DIR)
AC_SUBST(TK_SRC_DIR)
@@ -624,8 +604,6 @@ AC_DEFUN([SC_ENABLE_FRAMEWORK], [
# Sets to $(CFLAGS_OPTIMIZE) if false
# LDFLAGS_DEFAULT Sets to $(LDFLAGS_DEBUG) if true
# Sets to $(LDFLAGS_OPTIMIZE) if false
-# DBGX Formerly used as debug library extension;
-# always blank now.
#------------------------------------------------------------------------
AC_DEFUN([SC_ENABLE_SYMBOLS], [
@@ -635,7 +613,6 @@ AC_DEFUN([SC_ENABLE_SYMBOLS], [
[build with debugging symbols (default: off)]),
[tcl_ok=$enableval], [tcl_ok=no])
# FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
- DBGX=""
if test "$tcl_ok" = "no"; then
CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)'
@@ -814,6 +791,9 @@ AC_DEFUN([SC_CONFIG_SYSTEM], [
if test "`uname -s`" = "AIX" ; then
tcl_cv_sys_version=AIX-`uname -v`.`uname -r`
fi
+ if test "`uname -s`" = "NetBSD" -a -f /etc/debian_version ; then
+ tcl_cv_sys_version=NetBSD-Debian
+ fi
fi
fi
])
@@ -986,7 +966,15 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
CFLAGS_DEBUG=-g
AS_IF([test "$GCC" = yes], [
CFLAGS_OPTIMIZE=-O2
- CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement -Wpointer-arith"
+ CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wpointer-arith"
+ case "${CC}" in
+ *++)
+ ;;
+ *)
+ CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -Wdeclaration-after-statement"
+ ;;
+ esac
+
], [
CFLAGS_OPTIMIZE=-O
CFLAGS_WARNING=""
@@ -1106,7 +1094,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
CC_SEARCH_FLAGS=""
LD_SEARCH_FLAGS=""
TCL_NEEDS_EXP_FILE=1
- TCL_EXPORT_FILE_SUFFIX='${VERSION}\$\{DBGX\}.dll.a'
+ TCL_EXPORT_FILE_SUFFIX='${VERSION}.dll.a'
SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$[@].a"
AC_CACHE_CHECK(for Cygwin version of gcc,
ac_cv_cygwin,
@@ -1192,7 +1180,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
do64bit_ok=yes
SHLIB_LD='${CC} -shared'
AS_IF([test $doRpath = yes], [
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
;;
*)
@@ -1227,7 +1215,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
DL_LIBS=""
AC_LIBOBJ(mkstemp)
AS_IF([test $doRpath = yes], [
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
;;
IRIX-6.*)
@@ -1238,7 +1226,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
DL_LIBS=""
AC_LIBOBJ(mkstemp)
AS_IF([test $doRpath = yes], [
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
AS_IF([test "$GCC" = yes], [
CFLAGS="$CFLAGS -mabi=n32"
@@ -1264,7 +1252,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
DL_LIBS=""
AC_LIBOBJ(mkstemp)
AS_IF([test $doRpath = yes], [
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
# Check to enable 64-bit flags for compiler/linker
@@ -1295,7 +1283,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
DL_LIBS="-ldl"
LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
AS_IF([test $doRpath = yes], [
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
AS_IF([test "`uname -m`" = "alpha"], [CFLAGS="$CFLAGS -mieee"])
AS_IF([test $do64bit = yes], [
@@ -1311,7 +1299,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
])
# The combo of gcc + glibc has a bug related to inlining of
- # functions like strtod(). The -fno-builtin flag should address
+ # functions like strtol()/strtoul(). The -fno-builtin flag should address
# this problem but it does not work. The -fno-inline flag is kind
# of overkill but it works. Disable inlining only when one of the
# files in compat/*.c is being linked in.
@@ -1327,8 +1315,8 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
DL_LIBS="-mshared -ldl"
LD_FLAGS="-Wl,--export-dynamic"
AS_IF([test $doRpath = yes], [
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
- LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
+ LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
;;
OpenBSD-*)
arch=`arch -s`
@@ -1345,7 +1333,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
DL_OBJS="tclLoadDl.o"
DL_LIBS=""
AS_IF([test $doRpath = yes], [
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
LDFLAGS="-Wl,-export-dynamic"
@@ -1367,7 +1355,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
DL_LIBS=""
LDFLAGS="$LDFLAGS -export-dynamic"
AS_IF([test $doRpath = yes], [
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
# The -pthread needs to go in the CFLAGS, not LIBS
LIBS=`echo $LIBS | sed s/-pthread//`
@@ -1382,10 +1370,9 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
SHLIB_SUFFIX=".so"
DL_OBJS="tclLoadDl.o"
DL_LIBS=""
- LDFLAGS=""
AS_IF([test $doRpath = yes], [
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
- LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
+ LD_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
# The -pthread needs to go in the LDFLAGS, not LIBS
LIBS=`echo $LIBS | sed s/-pthread//`
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
@@ -1459,10 +1446,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
SHLIB_SUFFIX=".dylib"
DL_OBJS="tclLoadDyld.o"
DL_LIBS=""
- # Don't use -prebind when building for Mac OS X 10.4 or later only:
- AS_IF([test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F '10\\.' '{print int([$]2)}'`" -lt 4 -a \
- "`echo "${CPPFLAGS}" | awk -F '-mmacosx-version-min=10\\.' '{print int([$]2)}'`" -lt 4], [
- LDFLAGS="$LDFLAGS -prebind"])
LDFLAGS="$LDFLAGS -headerpad_max_install_names"
AC_CACHE_CHECK([if ld accepts -search_paths_first flag],
tcl_cv_ld_search_paths_first, [
@@ -1477,6 +1460,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
AS_IF([test "$tcl_cv_cc_visibility_hidden" != yes], [
AC_DEFINE(MODULE_SCOPE, [__private_extern__],
[Compiler support for module scope symbols])
+ tcl_cv_cc_visibility_hidden=yes
])
CC_SEARCH_FLAGS=""
LD_SEARCH_FLAGS=""
@@ -1556,7 +1540,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
DL_OBJS="tclLoadDl.o"
DL_LIBS=""
AS_IF([test $doRpath = yes], [
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+ CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
LD_SEARCH_FLAGS='-rpath ${LIB_RUNTIME_DIR}'])
AS_IF([test "$GCC" = yes], [CFLAGS="$CFLAGS -mieee"], [
CFLAGS="$CFLAGS -DHAVE_TZSET -std1 -ieee"])
@@ -1589,11 +1573,11 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
# this test works, since "uname -s" was non-standard in 3.2.4 and
# below.
AS_IF([test "$GCC" = yes], [
- SHLIB_CFLAGS="-fPIC -melf"
- LDFLAGS="$LDFLAGS -melf -Wl,-Bexport"
+ SHLIB_CFLAGS="-fPIC -melf"
+ LDFLAGS="$LDFLAGS -melf -Wl,-Bexport"
], [
- SHLIB_CFLAGS="-Kpic -belf"
- LDFLAGS="$LDFLAGS -belf -Wl,-Bexport"
+ SHLIB_CFLAGS="-Kpic -belf"
+ LDFLAGS="$LDFLAGS -belf -Wl,-Bexport"
])
SHLIB_LD="ld -G"
SHLIB_LD_LIBS=""
@@ -1822,7 +1806,7 @@ dnl # preprocessing tests use only CPPFLAGS.
AS_IF([test "${SHARED_BUILD}" = 1 -a "${SHLIB_SUFFIX}" != ""], [
LIB_SUFFIX=${SHARED_LIB_SUFFIX}
- MAKE_LIB='${SHLIB_LD} -o [$]@ ${OBJS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
+ MAKE_LIB='${SHLIB_LD} -o [$]@ ${OBJS} ${LDFLAGS} ${SHLIB_LD_LIBS} ${TCL_SHLIB_LD_EXTRAS} ${TK_SHLIB_LD_EXTRAS} ${LD_SEARCH_FLAGS}'
AS_IF([test "${SHLIB_SUFFIX}" = ".dll"], [
INSTALL_LIB='$(INSTALL_LIBRARY) $(LIB_FILE) "$(BIN_INSTALL_DIR)/$(LIB_FILE)";if test -f $(LIB_FILE).a; then $(INSTALL_DATA) $(LIB_FILE).a "$(LIB_INSTALL_DIR)"; fi;'
DLL_INSTALL_DIR="\$(BIN_INSTALL_DIR)"
@@ -1874,6 +1858,8 @@ dnl # preprocessing tests use only CPPFLAGS.
[Defined when compiler supports casting to union type.])
fi
+ AC_CHECK_HEADER(stdbool.h, [AC_DEFINE(HAVE_STDBOOL_H, 1, [Do we have <stdbool.h>?])],)
+
# FIXME: This subst was left in only because the TCL_DL_LIBS
# entry in tclConfig.sh uses it. It is not clear why someone
# would use TCL_DL_LIBS instead of TCL_LIBS.
@@ -1917,8 +1903,8 @@ dnl # preprocessing tests use only CPPFLAGS.
#
# Supply substitutes for missing POSIX header files. Special
# notes:
-# - stdlib.h doesn't define strtol, strtoul, or
-# strtod insome versions of SunOS
+# - stdlib.h doesn't define strtol or strtoul in some
+# versions of SunOS
# - some versions of string.h don't declare procedures such
# as strstr
#
@@ -1934,7 +1920,6 @@ dnl # preprocessing tests use only CPPFLAGS.
# NO_SYS_WAIT_H
# NO_DLFCN_H
# HAVE_SYS_PARAM_H
-#
# HAVE_STRING_H ?
#
#--------------------------------------------------------------------
@@ -1969,7 +1954,6 @@ closedir(d);
AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
- AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
if test $tcl_ok = 0; then
AC_DEFINE(NO_STDLIB_H, 1, [Do we have <stdlib.h>?])
fi
@@ -2523,7 +2507,20 @@ AC_DEFUN([SC_TCL_CHECK_BROKEN_FUNC],[
#
#--------------------------------------------------------------------
-AC_DEFUN([SC_TCL_GETHOSTBYADDR_R], [AC_CHECK_FUNC(gethostbyaddr_r, [
+AC_DEFUN([SC_TCL_GETHOSTBYADDR_R], [
+ # Avoids picking hidden internal symbol from libc
+ SC_TCL_GETHOSTBYADDR_R_DECL
+
+ if test "$tcl_cv_api_gethostbyaddr_r" = yes; then
+ SC_TCL_GETHOSTBYADDR_R_TYPE
+ fi
+])
+
+AC_DEFUN([SC_TCL_GETHOSTBYADDR_R_DECL], [AC_CHECK_DECLS(gethostbyaddr_r, [
+ tcl_cv_api_gethostbyaddr_r=yes],[tcl_cv_api_gethostbyaddr_r=no],[#include <netdb.h>])
+])
+
+AC_DEFUN([SC_TCL_GETHOSTBYADDR_R_TYPE], [AC_CHECK_FUNC(gethostbyaddr_r, [
AC_CACHE_CHECK([for gethostbyaddr_r with 7 args], tcl_cv_api_gethostbyaddr_r_7, [
AC_TRY_COMPILE([
#include <netdb.h>
@@ -2584,14 +2581,27 @@ AC_DEFUN([SC_TCL_GETHOSTBYADDR_R], [AC_CHECK_FUNC(gethostbyaddr_r, [
# Results:
#
# Might define the following vars:
-# HAVE_GETHOSTBYADDR_R
-# HAVE_GETHOSTBYADDR_R_3
-# HAVE_GETHOSTBYADDR_R_5
-# HAVE_GETHOSTBYADDR_R_6
+# HAVE_GETHOSTBYNAME_R
+# HAVE_GETHOSTBYNAME_R_3
+# HAVE_GETHOSTBYNAME_R_5
+# HAVE_GETHOSTBYNAME_R_6
#
#--------------------------------------------------------------------
-AC_DEFUN([SC_TCL_GETHOSTBYNAME_R], [AC_CHECK_FUNC(gethostbyname_r, [
+AC_DEFUN([SC_TCL_GETHOSTBYNAME_R], [
+ # Avoids picking hidden internal symbol from libc
+ SC_TCL_GETHOSTBYNAME_R_DECL
+
+ if test "$tcl_cv_api_gethostbyname_r" = yes; then
+ SC_TCL_GETHOSTBYNAME_R_TYPE
+ fi
+])
+
+AC_DEFUN([SC_TCL_GETHOSTBYNAME_R_DECL], [AC_CHECK_DECLS(gethostbyname_r, [
+ tcl_cv_api_gethostbyname_r=yes],[tcl_cv_api_gethostbyname_r=no],[#include <netdb.h>])
+])
+
+AC_DEFUN([SC_TCL_GETHOSTBYNAME_R_TYPE], [AC_CHECK_FUNC(gethostbyname_r, [
AC_CACHE_CHECK([for gethostbyname_r with 6 args], tcl_cv_api_gethostbyname_r_6, [
AC_TRY_COMPILE([
#include <netdb.h>
@@ -3014,7 +3024,7 @@ AC_DEFUN([SC_ZIPFS_SUPPORT], [
ZIP_PROG="$ac_cv_path_zip"
AC_MSG_RESULT([$ZIP_PROG])
ZIP_PROG_OPTIONS="-rq"
- ZIP_PROG_VFSSEARCH="."
+ ZIP_PROG_VFSSEARCH="*"
AC_MSG_RESULT([Found INFO Zip in environment])
# Use standard arguments for zip
else
@@ -3022,7 +3032,7 @@ AC_DEFUN([SC_ZIPFS_SUPPORT], [
# We can use the locally distributed minizip instead
ZIP_PROG="./minizip${EXEEXT_FOR_BUILD}"
ZIP_PROG_OPTIONS="-o -r"
- ZIP_PROG_VFSSEARCH="."
+ ZIP_PROG_VFSSEARCH="*"
ZIP_INSTALL_OBJS="minizip${EXEEXT_FOR_BUILD}"
AC_MSG_RESULT([No zip found on PATH. Building minizip])
fi
diff --git a/unix/tk.pc.in b/unix/tk.pc.in
index 68f2130..940184e 100644
--- a/unix/tk.pc.in
+++ b/unix/tk.pc.in
@@ -4,10 +4,11 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
+demodir=@TK_DEMO_DIR@
Name: The Tk Toolkit
Description: Tk is a cross-platform graphical user interface toolkit, the standard GUI not only for Tcl, but for many other dynamic languages as well.
-URL: http://www.tcl.tk/
+URL: https://www.tcl-lang.org/
Version: @TK_VERSION@@TK_PATCH_LEVEL@
Requires: tcl >= 8.6
Libs: -L${libdir} @TK_LIB_FLAG@ @TK_STUB_LIB_FLAG@
diff --git a/unix/tk.spec b/unix/tk.spec
index 590c2c0..be98664 100644
--- a/unix/tk.spec
+++ b/unix/tk.spec
@@ -4,12 +4,12 @@
Name: tk
Summary: Tk graphical toolkit for the Tcl scripting language.
-Version: 8.7a2
+Version: 8.7a4
Release: 2
License: BSD
Group: Development/Languages
Source: http://prdownloads.sourceforge.net/tcl/tk%{version}-src.tar.gz
-URL: http://www.tcl.tk/
+URL: https://www.tcl-lang.org/
Buildroot: /var/tmp/%{name}%{version}
Buildrequires: XFree86-devel tcl >= 8.6.0
Requires: tcl >= 8.6.0
diff --git a/unix/tkAppInit.c b/unix/tkAppInit.c
index 91dcba7..9e6c112 100644
--- a/unix/tkAppInit.c
+++ b/unix/tkAppInit.c
@@ -17,7 +17,13 @@
#include "tk.h"
#ifdef TK_TEST
+#ifdef __cplusplus
+extern "C" {
+#endif
extern Tcl_PackageInitProc Tktest_Init;
+#ifdef __cplusplus
+}
+#endif
#endif /* TK_TEST */
/*
diff --git a/unix/tkConfig.h.in b/unix/tkConfig.h.in
index d598ca3..6753fb5 100644
--- a/unix/tkConfig.h.in
+++ b/unix/tkConfig.h.in
@@ -91,9 +91,6 @@
/* Have we turned on XFT (antialiased fonts)? */
#undef HAVE_XFT
-/* Do we have XkbKeycodeToKeysym? */
-#undef HAVE_XKBKEYCODETOKEYSYM
-
/* Is XScreenSaver available? */
#undef HAVE_XSS
@@ -136,6 +133,12 @@
/* Is this a static build? */
#undef STATIC_BUILD
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* What encoding should be used for embedded configuration info? */
+#undef TCL_CFGVAL_ENCODING
+
/* Is this a 64-bit build? */
#undef TCL_CFG_DO64BIT
@@ -176,9 +179,6 @@
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
-/* Is XKeycodeToKeysym deprecated? */
-#undef XKEYCODETOKEYSYM_IS_DEPRECATED
-
/* Are Darwin SUSv3 extensions available? */
#undef _DARWIN_C_SOURCE
diff --git a/unix/tkConfig.sh.in b/unix/tkConfig.sh.in
index bb85ad0..e08861b 100644
--- a/unix/tkConfig.sh.in
+++ b/unix/tkConfig.sh.in
@@ -95,3 +95,6 @@ TK_BUILD_STUB_LIB_PATH='@TK_BUILD_STUB_LIB_PATH@'
# Path to the Tk stub library in the install directory.
TK_STUB_LIB_PATH='@TK_STUB_LIB_PATH@'
+
+# Top-level directory in which Tk's demo files are installed.
+TK_DEMO_DIR='@TK_DEMO_DIR@'
diff --git a/unix/tkUnix.c b/unix/tkUnix.c
index c6fff82..df70cb0 100644
--- a/unix/tkUnix.c
+++ b/unix/tkUnix.c
@@ -108,6 +108,11 @@ Tk_UpdatePointer(
int x, int y, /* Pointer location in root coords. */
int state) /* Modifier state mask. */
{
+ (void)tkwin;
+ (void)x;
+ (void)y;
+ (void)state;
+
/*
* This function intentionally left blank
*/
diff --git a/unix/tkUnix3d.c b/unix/tkUnix3d.c
index 2969de1..dfa08fb 100644
--- a/unix/tkUnix3d.c
+++ b/unix/tkUnix3d.c
@@ -46,7 +46,7 @@ typedef struct {
TkBorder *
TkpGetBorder(void)
{
- UnixBorder *borderPtr = ckalloc(sizeof(UnixBorder));
+ UnixBorder *borderPtr = (UnixBorder *)ckalloc(sizeof(UnixBorder));
borderPtr->solidGC = NULL;
return (TkBorder *) borderPtr;
@@ -443,7 +443,7 @@ TkpGetShadows(
}
if (borderPtr->shadow == None) {
- borderPtr->shadow = Tk_GetBitmap((Tcl_Interp *) NULL, tkwin,
+ borderPtr->shadow = Tk_GetBitmap(NULL, tkwin,
Tk_GetUid("gray50"));
if (borderPtr->shadow == None) {
Tcl_Panic("TkpGetShadows couldn't allocate bitmap for border");
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c
index 975fca8..8d13db7 100644
--- a/unix/tkUnixButton.c
+++ b/unix/tkUnixButton.c
@@ -173,7 +173,7 @@ TkpDrawCheckIndicator(
* Sanity check.
*/
- if (tkwin == NULL || display == None || d == None || bgBorder == NULL
+ if (tkwin == NULL || display == NULL || d == None || bgBorder == NULL
|| indicatorColor == NULL) {
return;
}
@@ -328,9 +328,9 @@ TkButton *
TkpCreateButton(
Tk_Window tkwin)
{
- UnixButton *butPtr = ckalloc(sizeof(UnixButton));
+ (void)tkwin;
- return (TkButton *) butPtr;
+ return (TkButton *)ckalloc(sizeof(UnixButton));
}
/*
@@ -396,7 +396,7 @@ void
TkpDisplayButton(
ClientData clientData) /* Information about widget. */
{
- register TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
GC gc;
Tk_3DBorder border;
Pixmap pixmap;
@@ -860,7 +860,7 @@ TkpDisplayButton(
void
TkpComputeButtonGeometry(
- register TkButton *butPtr) /* Button whose geometry may have changed. */
+ TkButton *butPtr) /* Button whose geometry may have changed. */
{
int width, height, avgWidth, txtWidth, txtHeight;
int haveImage = 0, haveText = 0;
diff --git a/unix/tkUnixColor.c b/unix/tkUnixColor.c
index 43500ad..a909fb3 100644
--- a/unix/tkUnixColor.c
+++ b/unix/tkUnixColor.c
@@ -85,7 +85,7 @@ TkpFreeColor(
*/
visual = tkColPtr->visual;
- if ((visual->class != StaticGray) && (visual->class != StaticColor)
+ if ((visual->c_class != StaticGray) && (visual->c_class != StaticColor)
&& (tkColPtr->color.pixel != BlackPixelOfScreen(screen))
&& (tkColPtr->color.pixel != WhitePixelOfScreen(screen))) {
Tk_ErrorHandler handler;
@@ -136,17 +136,17 @@ TkpGetColor(
if (*name != '#') {
XColor screen;
- if (((*name - 'A') & 0xdf) < sizeof(tkWebColors)/sizeof(tkWebColors[0])) {
- if (!((name[0] - 'G') & 0xdf) && !((name[1] - 'R') & 0xdf)
- && !((name[2] - 'A') & 0xdb) && !((name[3] - 'Y') & 0xdf)
+ if (((*name - 'A') & 0xDF) < sizeof(tkWebColors)/sizeof(tkWebColors[0])) {
+ if (!((name[0] - 'G') & 0xDF) && !((name[1] - 'R') & 0xDF)
+ && !((name[2] - 'A') & 0xDB) && !((name[3] - 'Y') & 0xDF)
&& !name[4]) {
name = "#808080808080";
goto gotWebColor;
} else {
- const char *p = tkWebColors[((*name - 'A') & 0x1f)];
+ const char *p = tkWebColors[((*name - 'A') & 0x1F)];
if (p) {
const char *q = name;
- while (!((*p - *(++q)) & 0xdf)) {
+ while (!((*p - *(++q)) & 0xDF)) {
if (!*p++) {
name = p;
goto gotWebColor;
@@ -157,7 +157,7 @@ TkpGetColor(
}
if (strlen(name) > 99) {
/* Don't bother to parse this. [Bug 2809525]*/
- return (TkColor *) NULL;
+ return NULL;
} else if (XAllocNamedColor(display, colormap, name, &screen, &color) != 0) {
DeleteStressedCmap(display, colormap);
} else {
@@ -185,7 +185,7 @@ TkpGetColor(
}
}
- tkColPtr = ckalloc(sizeof(TkColor));
+ tkColPtr = (TkColor *)ckalloc(sizeof(TkColor));
tkColPtr->color = color;
return tkColPtr;
@@ -220,7 +220,7 @@ TkpGetColorByValue(
{
Display *display = Tk_Display(tkwin);
Colormap colormap = Tk_Colormap(tkwin);
- TkColor *tkColPtr = ckalloc(sizeof(TkColor));
+ TkColor *tkColPtr = (TkColor *)ckalloc(sizeof(TkColor));
tkColPtr->color.red = colorPtr->red;
tkColPtr->color.green = colorPtr->green;
@@ -269,7 +269,7 @@ FindClosestColor(
XColor *colorPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
Colormap colormap = Tk_Colormap(tkwin);
- XVisualInfo template, *visInfoPtr;
+ XVisualInfo templ, *visInfoPtr;
/*
* Find the TkStressedCmap structure for this colormap, or create a new
@@ -278,19 +278,19 @@ FindClosestColor(
for (stressPtr = dispPtr->stressPtr; ; stressPtr = stressPtr->nextPtr) {
if (stressPtr == NULL) {
- stressPtr = ckalloc(sizeof(TkStressedCmap));
+ stressPtr = (TkStressedCmap *)ckalloc(sizeof(TkStressedCmap));
stressPtr->colormap = colormap;
- template.visualid = XVisualIDFromVisual(Tk_Visual(tkwin));
+ templ.visualid = XVisualIDFromVisual(Tk_Visual(tkwin));
visInfoPtr = XGetVisualInfo(Tk_Display(tkwin),
- VisualIDMask, &template, &numFound);
+ VisualIDMask, &templ, &numFound);
if (numFound < 1) {
Tcl_Panic("FindClosestColor couldn't lookup visual");
}
stressPtr->numColors = visInfoPtr->colormap_size;
XFree((char *) visInfoPtr);
- stressPtr->colorPtr =
+ stressPtr->colorPtr = (XColor *)
ckalloc(stressPtr->numColors * sizeof(XColor));
for (i = 0; i < stressPtr->numColors; i++) {
stressPtr->colorPtr[i].pixel = (unsigned long) i;
diff --git a/unix/tkUnixConfig.c b/unix/tkUnixConfig.c
index 3584494..acd8bb5 100644
--- a/unix/tkUnixConfig.c
+++ b/unix/tkUnixConfig.c
@@ -38,6 +38,10 @@ TkpGetSystemDefault(
const char *dbName, /* The option database name. */
const char *className) /* The name of the option class. */
{
+ (void)tkwin;
+ (void)dbName;
+ (void)className;
+
return NULL;
}
diff --git a/unix/tkUnixCursor.c b/unix/tkUnixCursor.c
index 8afb92d..bcd7cc3 100644
--- a/unix/tkUnixCursor.c
+++ b/unix/tkUnixCursor.c
@@ -245,7 +245,7 @@ TkGetCursorByName(
if ((argv[0][0] != '@') && !inTkTable) {
XColor fg, bg;
unsigned int maskIndex;
- register const struct CursorName *namePtr;
+ const struct CursorName *namePtr;
TkDisplay *dispPtr;
/*
@@ -338,7 +338,7 @@ TkGetCursorByName(
}
if (cursor != None) {
- cursorPtr = ckalloc(sizeof(TkUnixCursor));
+ cursorPtr = (TkUnixCursor *)ckalloc(sizeof(TkUnixCursor));
cursorPtr->info.cursor = (Tk_Cursor) cursor;
cursorPtr->display = display;
}
@@ -608,7 +608,7 @@ TkCreateCursorFromData(
Tk_FreePixmap(display, maskPixmap);
if (cursor != None) {
- cursorPtr = ckalloc(sizeof(TkUnixCursor));
+ cursorPtr = (TkUnixCursor *)ckalloc(sizeof(TkUnixCursor));
cursorPtr->info.cursor = (Tk_Cursor) cursor;
cursorPtr->display = display;
}
diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h
index bc7cd93..fa1f120 100644
--- a/unix/tkUnixDefault.h
+++ b/unix/tkUnixDefault.h
@@ -31,8 +31,7 @@
#define ACTIVE_BG "#ececec"
#define SELECT_BG "#c3c3c3"
#define TROUGH "#b3b3b3"
-#define CHECK_INDICATOR WHITE
-#define MENU_INDICATOR BLACK
+#define INDICATOR WHITE
#define DISABLED "#a3a3a3"
/*
@@ -79,7 +78,7 @@
#define DEF_LABCHKRAD_RELIEF "flat"
#define DEF_BUTTON_REPEAT_DELAY "0"
#define DEF_BUTTON_REPEAT_INTERVAL "0"
-#define DEF_BUTTON_SELECT_COLOR CHECK_INDICATOR
+#define DEF_BUTTON_SELECT_COLOR INDICATOR
#define DEF_BUTTON_SELECT_MONO BLACK
#define DEF_BUTTON_SELECT_IMAGE NULL
#define DEF_BUTTON_STATE "normal"
@@ -176,7 +175,9 @@
*/
#define DEF_FRAME_BG_COLOR NORMAL_BG
+#define DEF_FRAME_BG_IMAGE NULL
#define DEF_FRAME_BG_MONO WHITE
+#define DEF_FRAME_BG_TILE "0"
#define DEF_FRAME_BORDER_WIDTH "0"
#define DEF_FRAME_CLASS "Frame"
#define DEF_FRAME_COLORMAP ""
@@ -287,7 +288,7 @@
#define DEF_MENU_FG BLACK
#define DEF_MENU_POST_COMMAND ""
#define DEF_MENU_RELIEF "raised"
-#define DEF_MENU_SELECT_COLOR MENU_INDICATOR
+#define DEF_MENU_SELECT_COLOR BLACK
#define DEF_MENU_SELECT_MONO BLACK
#define DEF_MENU_TAKE_FOCUS "0"
#define DEF_MENU_TEAROFF "0"
@@ -518,6 +519,14 @@
#define DEF_CANVTEXT_FONT "TkDefaultFont"
/*
+ * Defaults for canvas items
+ * (arcs, bitmaps, lines, polygons, rectangles, and ovals):
+ */
+
+#define DEF_CANVBMAP_FG BLACK
+#define DEF_CANVITEM_OUTLINE BLACK
+
+/*
* Defaults for toplevels (most of the defaults for frames also apply
* to toplevels):
*/
diff --git a/unix/tkUnixDialog.c b/unix/tkUnixDialog.c
index afe443f..2f1f079 100644
--- a/unix/tkUnixDialog.c
+++ b/unix/tkUnixDialog.c
@@ -46,7 +46,7 @@ EvalObjv(
cmdObj = Tcl_NewStringObj(cmdName, -1);
Tcl_IncrRefCount(cmdObj);
- objs = ckalloc(sizeof(Tcl_Obj *) * (objc+1));
+ objs = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc+1));
objs[0] = cmdObj;
memcpy(objs+1, objv, sizeof(Tcl_Obj *) * (unsigned)objc);
diff --git a/unix/tkUnixDraw.c b/unix/tkUnixDraw.c
index acc0565..fec05ee 100644
--- a/unix/tkUnixDraw.c
+++ b/unix/tkUnixDraw.c
@@ -24,7 +24,7 @@ typedef struct ScrollInfo {
int done; /* Flag is 0 until filtering is done. */
Display *display; /* Display to filter. */
Window window; /* Window to filter. */
- TkRegion region; /* Region into which damage is accumulated. */
+ Region region; /* Region into which damage is accumulated. */
int dx, dy; /* Amount by which window was shifted. */
} ScrollInfo;
@@ -61,7 +61,7 @@ TkScrollWindow(
int x, int y, int width, int height,
/* Position rectangle to be scrolled. */
int dx, int dy, /* Distance rectangle should be moved. */
- TkRegion damageRgn) /* Region to accumulate damage in. */
+ Region damageRgn) /* Region to accumulate damage in. */
{
Tk_RestrictProc *prevProc;
ClientData prevArg;
@@ -90,7 +90,7 @@ TkScrollWindow(
}
Tk_RestrictEvents(prevProc, prevArg, &prevArg);
- if (XEmptyRegion((Region) damageRgn)) {
+ if (XEmptyRegion(damageRgn)) {
return 0;
} else {
return 1;
@@ -141,8 +141,8 @@ ScrollRestrictProc(
rect.y = eventPtr->xgraphicsexpose.y;
rect.width = eventPtr->xgraphicsexpose.width;
rect.height = eventPtr->xgraphicsexpose.height;
- XUnionRectWithRegion(&rect, (Region) info->region,
- (Region) info->region);
+ XUnionRectWithRegion(&rect, info->region,
+ info->region);
if (eventPtr->xgraphicsexpose.count == 0) {
info->done = 1;
@@ -160,12 +160,12 @@ ScrollRestrictProc(
rect.y = eventPtr->xexpose.y;
rect.width = eventPtr->xexpose.width;
rect.height = eventPtr->xexpose.height;
- XUnionRectWithRegion(&rect, (Region) info->region,
- (Region) info->region);
+ XUnionRectWithRegion(&rect, info->region,
+ info->region);
rect.x += info->dx;
rect.y += info->dy;
- XUnionRectWithRegion(&rect, (Region) info->region,
- (Region) info->region);
+ XUnionRectWithRegion(&rect, info->region,
+ info->region);
} else {
return TK_DEFER_EVENT;
}
@@ -202,13 +202,15 @@ TkpDrawHighlightBorder(
int highlightWidth,
Drawable drawable)
{
+ (void)bgGC;
+
TkDrawInsetFocusHighlight(tkwin, fgGC, highlightWidth, drawable, 0);
}
/*
*----------------------------------------------------------------------
*
- * TkpDrawFrame --
+ * TkpDrawFrameEx --
*
* This function draws the rectangular frame area.
*
@@ -222,14 +224,15 @@ TkpDrawHighlightBorder(
*/
void
-TkpDrawFrame(
+TkpDrawFrameEx(
Tk_Window tkwin,
+ Drawable drawable,
Tk_3DBorder border,
int highlightWidth,
int borderWidth,
int relief)
{
- Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, highlightWidth,
+ Tk_Fill3DRectangle(tkwin, drawable, border, highlightWidth,
highlightWidth, Tk_Width(tkwin) - 2*highlightWidth,
Tk_Height(tkwin) - 2*highlightWidth, borderWidth, relief);
}
diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c
index 2ac3013..d4654a8 100644
--- a/unix/tkUnixEmbed.c
+++ b/unix/tkUnixEmbed.c
@@ -42,7 +42,7 @@ typedef struct Container {
* process. */
} Container;
-typedef struct ThreadSpecificData {
+typedef struct {
Container *firstContainerPtr;
/* First in list of all containers managed by
* this process. */
@@ -106,7 +106,7 @@ TkpUseWindow(
Tk_ErrorHandler handler;
Container *containerPtr;
XWindowAttributes parentAtts;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->window != None) {
@@ -178,7 +178,7 @@ TkpUseWindow(
}
}
if (containerPtr == NULL) {
- containerPtr = ckalloc(sizeof(Container));
+ containerPtr = (Container *)ckalloc(sizeof(Container));
containerPtr->parent = parent;
containerPtr->parentRoot = parentAtts.root;
containerPtr->parentPtr = NULL;
@@ -216,7 +216,7 @@ TkpMakeWindow(
* the window is to be created. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->flags & TK_EMBEDDED) {
@@ -272,7 +272,7 @@ TkpMakeContainer(
{
TkWindow *winPtr = (TkWindow *) tkwin;
Container *containerPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -281,7 +281,7 @@ TkpMakeContainer(
*/
Tk_MakeWindowExist(tkwin);
- containerPtr = ckalloc(sizeof(Container));
+ containerPtr = (Container *)ckalloc(sizeof(Container));
containerPtr->parent = Tk_WindowId(tkwin);
containerPtr->parentRoot = RootWindowOfScreen(Tk_Screen(tkwin));
containerPtr->parentPtr = winPtr;
@@ -332,7 +332,8 @@ EmbedErrorProc(
XErrorEvent *errEventPtr) /* Points to information about error (not
* used). */
{
- int *iPtr = clientData;
+ int *iPtr = (int *)clientData;
+ (void)errEventPtr;
*iPtr = 1;
return 0;
@@ -362,7 +363,7 @@ EmbeddedEventProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- TkWindow *winPtr = clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
if (eventPtr->type == DestroyNotify) {
EmbedWindowDeleted(winPtr);
@@ -394,10 +395,10 @@ ContainerEventProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- TkWindow *winPtr = clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
Container *containerPtr;
Tk_ErrorHandler errHandler;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -499,7 +500,7 @@ EmbedStructureProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- Container *containerPtr = clientData;
+ Container *containerPtr = (Container *)clientData;
Tk_ErrorHandler errHandler;
if (eventPtr->type == ConfigureNotify) {
@@ -507,7 +508,7 @@ EmbedStructureProc(
* Send a ConfigureNotify to the embedded application.
*/
- if (containerPtr->embeddedPtr != None) {
+ if (containerPtr->embeddedPtr != NULL) {
TkDoConfigureNotify(containerPtr->embeddedPtr);
}
if (containerPtr->wrapper != None) {
@@ -554,7 +555,7 @@ EmbedFocusProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- Container *containerPtr = clientData;
+ Container *containerPtr = (Container *)clientData;
Tk_ErrorHandler errHandler;
Display *display;
@@ -712,7 +713,7 @@ TkpGetOtherWindow(
* window. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (containerPtr = tsdPtr->firstContainerPtr;
@@ -758,7 +759,7 @@ TkpRedirectKeyEvent(
{
Container *containerPtr;
Window saved;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -830,7 +831,7 @@ TkpClaimFocus(
{
XEvent event;
Container *containerPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!(topLevelPtr->flags & TK_EMBEDDED)) {
@@ -872,7 +873,7 @@ TkpClaimFocus(
int
TkpTestembedCmd(
- ClientData clientData, /* Main window for application. */
+ ClientData dummy, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -882,8 +883,9 @@ TkpTestembedCmd(
Tcl_DString dString;
char buffer[50];
Tcl_Interp *embeddedInterp = NULL, *parentInterp = NULL;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
if ((objc > 1) && (strcmp(Tcl_GetString(objv[1]), "all") == 0)) {
all = 1;
@@ -967,7 +969,7 @@ EmbedWindowDeleted(
* deleted. */
{
Container *containerPtr, *prevPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -1025,7 +1027,7 @@ TkUnixContainerId(
TkWindow *winPtr) /* Tk's structure for an embedded window. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (containerPtr = tsdPtr->firstContainerPtr;
@@ -1178,6 +1180,7 @@ TkpCreateBusy(
{
Window root, parent, *dummy;
unsigned int count;
+ (void)busy;
if (winPtr->flags & TK_REPARENTED) {
/*
diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c
index a3867a4..d31b5c1 100644
--- a/unix/tkUnixEvent.c
+++ b/unix/tkUnixEvent.c
@@ -12,18 +12,17 @@
#include "tkUnixInt.h"
#include <signal.h>
-#ifdef HAVE_XKBKEYCODETOKEYSYM
-# include <X11/XKBlib.h>
-#else
-# define XkbOpenDisplay(D,V,E,M,m,R) ((V),(E),(M),(m),(R),(NULL))
-#endif
+#undef register /* Keyword "register" is used in XKBlib.h, so don't try tricky things here */
+#define XkbOpenDisplay XkbOpenDisplay_ /* Move out of the way, conflicting definitions */
+#include <X11/XKBlib.h>
+#undef XkbOpenDisplay
/*
* The following static indicates whether this module has been initialized in
* the current thread.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
int initialized;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -92,10 +91,11 @@ TkCreateXEventSource(void)
static void
DisplayExitHandler(
- ClientData clientData) /* Not used. */
+ ClientData dummy) /* Not used. */
{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
Tcl_DeleteEventSource(DisplaySetupProc, DisplayCheckProc, NULL);
tsdPtr->initialized = 0;
@@ -129,9 +129,8 @@ TkpOpenDisplay(
int major = 1;
int minor = 0;
int reason = 0;
- unsigned int use_xkb = 0;
/* Disabled, until we have a better test. See [Bug 3613668] */
-#if 0 && defined(XKEYCODETOKEYSYM_IS_DEPRECATED)
+#if 0
static int xinited = 0;
static Tcl_Mutex xinitMutex = NULL;
@@ -154,31 +153,19 @@ TkpOpenDisplay(
/*
** Bug [3607830]: Before using Xkb, it must be initialized and confirmed
- ** that the serve supports it. The XkbOpenDisplay call
+ ** that the server supports it. The XkbOpenDisplay call
** will perform this check and return NULL if the extension
** is not supported.
- **
- ** Work around un-const-ified Xkb headers using (char *) cast.
*/
- display = XkbOpenDisplay((char *)displayNameStr, &event, &error, &major,
+ display = XkbOpenDisplay(displayNameStr, &event, &error, &major,
&minor, &reason);
if (display == NULL) {
- /*fprintf(stderr,"event=%d error=%d major=%d minor=%d reason=%d\nDisabling xkb\n",
- event, error, major, minor, reason);*/
- display = XOpenDisplay(displayNameStr);
- } else {
- use_xkb = TK_DISPLAY_USE_XKB;
- /*fprintf(stderr, "Using xkb %d.%d\n", major, minor);*/
- }
-
- if (display == NULL) {
return NULL;
}
- dispPtr = ckalloc(sizeof(TkDisplay));
+ dispPtr = (TkDisplay *)ckalloc(sizeof(TkDisplay));
memset(dispPtr, 0, sizeof(TkDisplay));
dispPtr->display = display;
- dispPtr->flags |= use_xkb;
#ifdef TK_USE_INPUT_METHODS
OpenIM(dispPtr);
XRegisterIMInstantiateCallback(dispPtr->display, NULL, NULL, NULL,
@@ -186,6 +173,31 @@ TkpOpenDisplay(
#endif
Tcl_CreateFileHandler(ConnectionNumber(display), TCL_READABLE,
DisplayFileProc, dispPtr);
+
+ /*
+ * Observed weird WidthMMOfScreen() in X on Wayland on a
+ * Fedora 30/i386 running in a VM. Fallback to 75 dpi,
+ * otherwise many other strange things may happen later.
+ * See: [https://core.tcl-lang.org/tk/tktview?name=a01b6f7227]
+ */
+ if (WidthMMOfScreen(DefaultScreenOfDisplay(display)) <= 0) {
+ int mm;
+
+ mm = WidthOfScreen(DefaultScreenOfDisplay(display)) * (25.4 / 75.0);
+ WidthMMOfScreen(DefaultScreenOfDisplay(display)) = mm;
+ }
+ if (HeightMMOfScreen(DefaultScreenOfDisplay(display)) <= 0) {
+ int mm;
+
+ mm = HeightOfScreen(DefaultScreenOfDisplay(display)) * (25.4 / 75.0);
+ HeightMMOfScreen(DefaultScreenOfDisplay(display)) = mm;
+ }
+
+ /*
+ * Key map info must be available immediately, because of "send event".
+ */
+ TkpInitKeymapInfo(dispPtr);
+
return dispPtr;
}
@@ -286,11 +298,12 @@ TkClipCleanup(
static void
DisplaySetupProc(
- ClientData clientData, /* Not used. */
+ ClientData dummy, /* Not used. */
int flags)
{
TkDisplay *dispPtr;
static Tcl_Time blockTime = { 0, 0 };
+ (void)dummy;
if (!(flags & TCL_WINDOW_EVENTS)) {
return;
@@ -335,9 +348,6 @@ TransferXEventsToTcl(
int type;
XEvent x;
TkKeyEvent k;
-#ifdef GenericEvent
- xGenericEvent xge;
-#endif
} event;
Window w;
TkDisplay *dispPtr = NULL;
@@ -355,12 +365,9 @@ TransferXEventsToTcl(
while (QLength(display) > 0) {
XNextEvent(display, &event.x);
-#ifdef GenericEvent
- if (event.type == GenericEvent) {
- Tcl_Panic("Wild GenericEvent; panic! (extension=%d,evtype=%d)",
- event.xge.extension, event.xge.evtype);
+ if (event.type > MappingNotify) {
+ continue;
}
-#endif
w = None;
if (event.type == KeyPress || event.type == KeyRelease) {
for (dispPtr = TkGetDisplayList(); ; dispPtr = dispPtr->nextPtr) {
@@ -424,10 +431,11 @@ TransferXEventsToTcl(
static void
DisplayCheckProc(
- ClientData clientData, /* Not used. */
+ ClientData dummy, /* Not used. */
int flags)
{
TkDisplay *dispPtr;
+ (void)dummy;
if (!(flags & TCL_WINDOW_EVENTS)) {
return;
@@ -462,9 +470,10 @@ DisplayFileProc(
ClientData clientData, /* The display pointer. */
int flags) /* Should be TCL_READABLE. */
{
- TkDisplay *dispPtr = clientData;
+ TkDisplay *dispPtr = (TkDisplay *)clientData;
Display *display = dispPtr->display;
int numFound;
+ (void)flags;
XFlush(display);
numFound = XEventsQueued(display, QueuedAfterReading);
@@ -489,9 +498,9 @@ DisplayFileProc(
* nice (?!) message.
*/
- void (*oldHandler)();
+ void (*oldHandler)(int);
- oldHandler = (void (*)()) signal(SIGPIPE, SIG_IGN);
+ oldHandler = (void (*)(int)) signal(SIGPIPE, SIG_IGN);
XNoOp(display);
XFlush(display);
(void) signal(SIGPIPE, oldHandler);
@@ -675,6 +684,8 @@ InstantiateIMCallback(
XPointer call_data)
{
TkDisplay *dispPtr;
+ (void)display;
+ (void)call_data;
dispPtr = (TkDisplay *) client_data;
OpenIM(dispPtr);
@@ -689,6 +700,8 @@ DestroyIMCallback(
XPointer call_data)
{
TkDisplay *dispPtr;
+ (void)im;
+ (void)call_data;
dispPtr = (TkDisplay *) client_data;
dispPtr->inputMethod = NULL;
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index 168e8c9..1b7b50d 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -12,8 +12,6 @@
#include "tkUnixInt.h"
#include "tkFont.h"
-#include <netinet/in.h> /* for htons() prototype */
-#include <arpa/inet.h> /* inet_ntoa() */
/*
* The preferred font encodings.
@@ -35,10 +33,11 @@ static const char encodingList[][10] = {
* family": the foundry, face name, and charset.
*/
-#define FONTMAP_SHIFT 12
+#define FONTMAP_SHIFT 10
-#define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT))
#define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT)
+#define FONTMAP_NUMCHARS 0x40000
+#define FONTMAP_PAGES (FONTMAP_NUMCHARS / FONTMAP_BITSPERPAGE)
typedef struct FontFamily {
struct FontFamily *nextPtr; /* Next in list of all known font families. */
@@ -63,7 +62,7 @@ typedef struct FontFamily {
/* Two-level sparse table used to determine
* quickly if the specified character exists.
* As characters are encountered, more pages
- * in this table are dynamically alloced. The
+ * in this table are dynamically allocated. The
* contents of each page is a bitmask
* consisting of FONTMAP_BITSPERPAGE bits,
* representing whether this font can be used
@@ -153,7 +152,7 @@ typedef struct FontAttributes {
TkXLFDAttributes xa;
} FontAttributes;
-typedef struct ThreadSpecificData {
+typedef struct {
FontFamily *fontFamilyList; /* The list of font families that are
* currently loaded. As screen fonts are
* loaded, this list grows to hold information
@@ -186,14 +185,7 @@ static const EncodingAlias encodingAliases[] = {
{"tis620", "tis620*"},
{"ksc5601", "ksc5601*"},
{"dingbats", "*dingbats"},
-#ifdef WORDS_BIGENDIAN
- {"unicode", "iso10646-1"},
-#else
- /*
- * ucs-2be is needed if native order isn't BE.
- */
{"ucs-2be", "iso10646-1"},
-#endif
{NULL, NULL}
};
@@ -201,7 +193,7 @@ static const EncodingAlias encodingAliases[] = {
* Functions used only in this file.
*/
-static void FontPkgCleanup(ClientData clientData);
+static void FontPkgCleanup(void *clientData);
static FontFamily * AllocFontFamily(Display *display,
XFontStruct *fontStructPtr, int base);
static SubFont * CanUseFallback(UnixFont *fontPtr,
@@ -211,7 +203,7 @@ static SubFont * CanUseFallbackWithAliases(UnixFont *fontPtr,
const char *fallbackName, int ch,
Tcl_DString *nameTriedPtr,
SubFont **fixSubFontPtrPtr);
-static int ControlUtfProc(ClientData clientData, const char *src,
+static int ControlUtfProc(void *clientData, const char *src,
int srcLen, int flags, Tcl_EncodingState*statePtr,
char *dst, int dstLen, int *srcReadPtr,
int *dstWrotePtr, int *dstCharsPtr);
@@ -246,16 +238,14 @@ static unsigned RankAttributes(FontAttributes *wantPtr,
static void ReleaseFont(UnixFont *fontPtr);
static void ReleaseSubFont(Display *display, SubFont *subFontPtr);
static int SeenName(const char *name, Tcl_DString *dsPtr);
-#ifndef WORDS_BIGENDIAN
-static int Ucs2beToUtfProc(ClientData clientData, const char*src,
+static int Ucs2beToUtfProc(void *clientData, const char*src,
int srcLen, int flags, Tcl_EncodingState*statePtr,
char *dst, int dstLen, int *srcReadPtr,
int *dstWrotePtr, int *dstCharsPtr);
-static int UtfToUcs2beProc(ClientData clientData, const char*src,
+static int UtfToUcs2beProc(void *clientData, const char*src,
int srcLen, int flags, Tcl_EncodingState*statePtr,
char *dst, int dstLen, int *srcReadPtr,
int *dstWrotePtr, int *dstCharsPtr);
-#endif
/*
*-------------------------------------------------------------------------
@@ -277,9 +267,9 @@ static int UtfToUcs2beProc(ClientData clientData, const char*src,
static void
FontPkgCleanup(
- ClientData clientData)
+ TCL_UNUSED(void *))
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->controlFamily.encoding != NULL) {
@@ -316,22 +306,17 @@ FontPkgCleanup(
void
TkpFontPkgInit(
- TkMainInfo *mainPtr) /* The application being created. */
+ TCL_UNUSED(TkMainInfo *)) /* The application being created. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- Tcl_EncodingType type;
SubFont dummy;
int i;
+ Tcl_Encoding ucs2;
if (tsdPtr->controlFamily.encoding == NULL) {
- type.encodingName = "X11ControlChars";
- type.toUtfProc = ControlUtfProc;
- type.fromUtfProc = ControlUtfProc;
- type.freeProc = NULL;
- type.clientData = NULL;
- type.nullSize = 0;
+ Tcl_EncodingType type = {"X11ControlChars", ControlUtfProc, ControlUtfProc, NULL, NULL, 0};
tsdPtr->controlFamily.refCount = 2;
tsdPtr->controlFamily.encoding = Tcl_CreateEncoding(&type);
tsdPtr->controlFamily.isTwoByteFont = 0;
@@ -343,20 +328,18 @@ TkpFontPkgInit(
FontMapInsert(&dummy, i + 0x80);
}
-#ifndef WORDS_BIGENDIAN
/*
* UCS-2BE is unicode (UCS-2) in big-endian format. Define this if
- * native order isn't BE. It is used in iso10646 fonts.
+ * if it doesn't exist yet. It is used in iso10646 fonts.
*/
- type.encodingName = "ucs-2be";
- type.toUtfProc = Ucs2beToUtfProc;
- type.fromUtfProc = UtfToUcs2beProc;
- type.freeProc = NULL;
- type.clientData = NULL;
- type.nullSize = 2;
- Tcl_CreateEncoding(&type);
-#endif
+ ucs2 = Tcl_GetEncoding(NULL, "ucs-2be");
+ if (ucs2 == NULL) {
+ Tcl_EncodingType ucs2type = {"ucs-2be", Ucs2beToUtfProc, UtfToUcs2beProc, NULL, NULL, 2};
+ Tcl_CreateEncoding(&ucs2type);
+ } else {
+ Tcl_FreeEncoding(ucs2);
+ }
Tcl_CreateThreadExitHandler(FontPkgCleanup, NULL);
}
}
@@ -379,11 +362,11 @@ TkpFontPkgInit(
static int
ControlUtfProc(
- ClientData clientData, /* Not used. */
+ TCL_UNUSED(void *), /* Not used. */
const char *src, /* Source string in UTF-8. */
int srcLen, /* Source string length in bytes. */
- int flags, /* Conversion control flags. */
- Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
+ TCL_UNUSED(int), /* Conversion control flags. */
+ TCL_UNUSED(Tcl_EncodingState *),/* Place for conversion routine to store state
* information used during a piecewise
* conversion. Contents of statePtr are
* initialized and/or reset by conversion
@@ -407,7 +390,7 @@ ControlUtfProc(
const char *srcStart, *srcEnd;
char *dstStart, *dstEnd;
int ch, result;
- static const char hexChars[] = "0123456789abcdef";
+ static const char hexChars[] = "0123456789ABCDEF";
static const char mapChars[] = {
0, 0, 0, 0, 0, 0, 0,
'a', 'b', 't', 'n', 'v', 'f', 'r'
@@ -428,28 +411,28 @@ ControlUtfProc(
}
src += TkUtfToUniChar(src, &ch);
dst[0] = '\\';
- if (((size_t) ch < sizeof(mapChars)) && (mapChars[ch] != 0)) {
+ if (((size_t)ch < sizeof(mapChars)) && (mapChars[ch] != 0)) {
dst[1] = mapChars[ch];
dst += 2;
- } else if (ch < 256) {
+ } else if ((size_t)ch < 256) {
dst[1] = 'x';
- dst[2] = hexChars[(ch >> 4) & 0xf];
- dst[3] = hexChars[ch & 0xf];
+ dst[2] = hexChars[(ch >> 4) & 0xF];
+ dst[3] = hexChars[ch & 0xF];
dst += 4;
- } else if (ch < 0x10000) {
+ } else if ((size_t)ch < 0x10000) {
dst[1] = 'u';
- dst[2] = hexChars[(ch >> 12) & 0xf];
- dst[3] = hexChars[(ch >> 8) & 0xf];
- dst[4] = hexChars[(ch >> 4) & 0xf];
- dst[5] = hexChars[ch & 0xf];
+ dst[2] = hexChars[(ch >> 12) & 0xF];
+ dst[3] = hexChars[(ch >> 8) & 0xF];
+ dst[4] = hexChars[(ch >> 4) & 0xF];
+ dst[5] = hexChars[ch & 0xF];
dst += 6;
} else {
/* TODO we can do better here */
dst[1] = 'u';
- dst[2] = 'f';
- dst[3] = 'f';
- dst[4] = 'f';
- dst[5] = 'd';
+ dst[2] = 'F';
+ dst[3] = 'F';
+ dst[4] = 'F';
+ dst[5] = 'D';
dst += 6;
}
}
@@ -459,14 +442,12 @@ ControlUtfProc(
return result;
}
-#ifndef WORDS_BIGENDIAN
/*
*-------------------------------------------------------------------------
*
* Ucs2beToUtfProc --
*
* Convert from UCS-2BE (big-endian 16-bit Unicode) to UTF-8.
- * This is only defined on LE machines.
*
* Results:
* Returns TCL_OK if conversion was successful.
@@ -479,11 +460,11 @@ ControlUtfProc(
static int
Ucs2beToUtfProc(
- ClientData clientData, /* Not used. */
+ TCL_UNUSED(void *), /* Not used. */
const char *src, /* Source string in Unicode. */
int srcLen, /* Source string length in bytes. */
int flags, /* Conversion control flags. */
- Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
+ TCL_UNUSED(Tcl_EncodingState *),/* Place for conversion routine to store state
* information used during a piecewise
* conversion. Contents of statePtr are
* initialized and/or reset by conversion
@@ -505,9 +486,13 @@ Ucs2beToUtfProc(
* output buffer. */
{
const char *srcStart, *srcEnd;
- char *dstEnd, *dstStart;
- int result, numChars;
+ const char *dstEnd, *dstStart;
+ int result, numChars, charLimit = INT_MAX;
+ unsigned short ch;
+ if (flags & TCL_ENCODING_CHAR_LIMIT) {
+ charLimit = *dstCharsPtr;
+ }
result = TCL_OK;
/* check alignment with ucs-2 (2 == sizeof(UCS-2)) */
@@ -515,6 +500,11 @@ Ucs2beToUtfProc(
result = TCL_CONVERT_MULTIBYTE;
srcLen--;
}
+ /* If last code point is a high surrogate, we cannot handle that yet */
+ if ((srcLen >= 2) && ((src[srcLen - 2] & 0xFC) == 0xD8)) {
+ result = TCL_CONVERT_MULTIBYTE;
+ srcLen -= 2;
+ }
srcStart = src;
srcEnd = src + srcLen;
@@ -522,19 +512,24 @@ Ucs2beToUtfProc(
dstStart = dst;
dstEnd = dst + dstLen - 4;
- for (numChars = 0; src < srcEnd; numChars++) {
+ for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
if (dst > dstEnd) {
result = TCL_CONVERT_NOSPACE;
break;
}
+ ch = (src[0] & 0xFF) << 8 | (src[1] & 0xFF);
+ src += 2 /* sizeof(UTF-16) */;
+
/*
- * Need to swap byte-order on little-endian machines (x86) for
- * UCS-2BE. We know this is an LE->BE swap.
+ * Special case for 1-byte utf chars for speed. Make sure we work with
+ * unsigned short-size data.
*/
-
- dst += Tcl_UniCharToUtf(htons(*((short *)src)), dst);
- src += 2 /* sizeof(UCS-2) */;
+ if (ch && ch < 0x80) {
+ *dst++ = (ch & 0xFF);
+ } else {
+ dst += Tcl_UniCharToUtf(ch, dst);
+ }
}
*srcReadPtr = src - srcStart;
@@ -561,12 +556,12 @@ Ucs2beToUtfProc(
static int
UtfToUcs2beProc(
- ClientData clientData, /* TableEncodingData that specifies
+ TCL_UNUSED(void *), /* TableEncodingData that specifies
* encoding. */
const char *src, /* Source string in UTF-8. */
int srcLen, /* Source string length in bytes. */
int flags, /* Conversion control flags. */
- Tcl_EncodingState *statePtr,/* Place for conversion routine to store state
+ TCL_UNUSED(Tcl_EncodingState *),/* Place for conversion routine to store state
* information used during a piecewise
* conversion. Contents of statePtr are
* initialized and/or reset by conversion
@@ -589,13 +584,13 @@ UtfToUcs2beProc(
{
const char *srcStart, *srcEnd, *srcClose, *dstStart, *dstEnd;
int result, numChars;
- Tcl_UniChar ch;
+ int ch;
srcStart = src;
srcEnd = src + srcLen;
srcClose = srcEnd;
if (!(flags & TCL_ENCODING_END)) {
- srcClose -= 4;
+ srcClose -= 6;
}
dstStart = dst;
@@ -608,31 +603,30 @@ UtfToUcs2beProc(
* If there is more string to follow, this will ensure that the
* last UTF-8 character in the source buffer hasn't been cut off.
*/
-
result = TCL_CONVERT_MULTIBYTE;
break;
}
if (dst > dstEnd) {
result = TCL_CONVERT_NOSPACE;
break;
- }
- src += Tcl_UtfToUniChar(src, &ch);
+ }
+ src += TkUtfToUniChar(src, &ch);
+ if (ch > 0xFFFF) {
+ ch = 0xFFFD;
+ }
/*
* Ensure big-endianness (store big bits first).
- * XXX: This hard-codes the assumed size of Tcl_UniChar as 2. Make
- * sure to work in char* for Tcl_UtfToUniChar alignment. [Bug 1122671]
*/
- *dst++ = (ch >> 8);
- *dst++ = (ch & 0xFF);
+ *dst++ = (char)((ch >> 8) & 0xFF);
+ *dst++ = (char)(ch & 0xFF);
}
*srcReadPtr = src - srcStart;
*dstWrotePtr = dst - dstStart;
*dstCharsPtr = numChars;
return result;
}
-#endif /* WORDS_BIGENDIAN */
/*
*---------------------------------------------------------------------------
@@ -726,7 +720,7 @@ TkpGetNativeFont(
}
fontStructPtr = CreateClosestFont(tkwin, &fa.fa, &fa.xa);
}
- fontPtr = ckalloc(sizeof(UnixFont));
+ fontPtr = (UnixFont *)ckalloc(sizeof(UnixFont));
InitFont(tkwin, fontStructPtr, fontPtr);
return (TkFont *) fontPtr;
@@ -782,7 +776,7 @@ TkpGetFontFromAttributes(
fontPtr = (UnixFont *) tkFontPtr;
if (fontPtr == NULL) {
- fontPtr = ckalloc(sizeof(UnixFont));
+ fontPtr = (UnixFont *)ckalloc(sizeof(UnixFont));
} else {
ReleaseFont(fontPtr);
}
@@ -845,7 +839,7 @@ TkpGetFontFamilies(
Tcl_Interp *interp, /* Interp to hold result. */
Tk_Window tkwin) /* For display to query. */
{
- int i, new, numNames;
+ int i, isNew, numNames;
char *family, **nameList;
Tcl_HashTable familyTable;
Tcl_HashEntry *hPtr;
@@ -874,14 +868,14 @@ TkpGetFontFamilies(
continue; /* See comment above. */
}
*familyEnd = '\0';
- Tcl_CreateHashEntry(&familyTable, family, &new);
+ Tcl_CreateHashEntry(&familyTable, family, &isNew);
}
XFreeFontNames(nameList);
hPtr = Tcl_FirstHashEntry(&familyTable, &search);
resultPtr = Tcl_NewObj();
while (hPtr != NULL) {
- strPtr = Tcl_NewStringObj(Tcl_GetHashKey(&familyTable, hPtr), -1);
+ strPtr = Tcl_NewStringObj((const char *)Tcl_GetHashKey(&familyTable, hPtr), -1);
Tcl_ListObjAppendElement(NULL, resultPtr, strPtr);
hPtr = Tcl_NextHashEntry(&search);
}
@@ -1209,7 +1203,7 @@ TkpMeasureCharsInContext(
Tk_Font tkfont, /* Font in which characters will be drawn. */
const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. */
- int numBytes, /* Maximum number of bytes to consider from
+ TCL_UNUSED(int), /* Maximum number of bytes to consider from
* source string in all. */
int rangeStart, /* Index of first byte to measure. */
int rangeLength, /* Length of range to measure in bytes. */
@@ -1231,7 +1225,6 @@ TkpMeasureCharsInContext(
int *lengthPtr) /* Filled with x-location just after the
* terminating character. */
{
- (void) numBytes; /*unused*/
return Tk_MeasureChars(tkfont, source + rangeStart, rangeLength,
maxLength, flags, lengthPtr);
}
@@ -1403,7 +1396,7 @@ TkpDrawCharsInContext(
* is passed to this function. If they are not
* stripped out, they will be displayed as
* regular printing characters. */
- int numBytes, /* Number of bytes in string. */
+ TCL_UNUSED(int), /* Number of bytes in string. */
int rangeStart, /* Index of first byte to draw. */
int rangeLength, /* Length of range to draw in bytes. */
int x, int y) /* Coordinates at which to place origin of the
@@ -1412,8 +1405,6 @@ TkpDrawCharsInContext(
{
int widthUntilStart;
- (void) numBytes; /*unused*/
-
Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart);
Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart,
rangeLength, x+widthUntilStart, y);
@@ -1581,7 +1572,7 @@ InitFont(
UnixFont *fontPtr) /* Filled with information constructed from
* the above arguments. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
unsigned long value;
int minHi, maxHi, minLo, maxLo, fixed, width, limit, i, n;
@@ -1828,13 +1819,13 @@ AllocFontFamily(
Display *display, /* Display in which font will be used. */
XFontStruct *fontStructPtr, /* Screen font whose FontFamily is to be
* returned. */
- int base) /* Non-zero if this font family is to be used
+ TCL_UNUSED(int)) /* Non-zero if this font family is to be used
* in the base font of a font object. */
{
FontFamily *familyPtr;
FontAttributes fa;
Tcl_Encoding encoding;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
GetFontAttributes(display, fontStructPtr, &fa);
@@ -1853,7 +1844,7 @@ AllocFontFamily(
}
}
- familyPtr = ckalloc(sizeof(FontFamily));
+ familyPtr = (FontFamily *)ckalloc(sizeof(FontFamily));
memset(familyPtr, 0, sizeof(FontFamily));
familyPtr->nextPtr = tsdPtr->fontFamilyList;
tsdPtr->fontFamilyList = familyPtr;
@@ -1910,7 +1901,7 @@ FreeFontFamily(
FontFamily *familyPtr) /* The FontFamily to delete. */
{
FontFamily **familyPtrPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
int i;
@@ -1985,11 +1976,11 @@ FindSubFontForChar(
SubFont *subFontPtr;
Tcl_DString ds;
- if (FontMapLookup(&fontPtr->subFontArray[0], ch)) {
- return &fontPtr->subFontArray[0];
+ if (ch < 0 || ch >= FONTMAP_NUMCHARS) {
+ ch = 0xFFFD;
}
- for (i = 1; i < fontPtr->numSubFonts; i++) {
+ for (i = 0; i < fontPtr->numSubFonts; i++) {
if (FontMapLookup(&fontPtr->subFontArray[i], ch)) {
return &fontPtr->subFontArray[i];
}
@@ -2139,6 +2130,9 @@ FontMapLookup(
{
int row, bitOffset;
+ if (ch < 0 || ch >= FONTMAP_NUMCHARS) {
+ return 0;
+ }
row = ch >> FONTMAP_SHIFT;
if (subFontPtr->fontMap[row] == NULL) {
FontMapLoadPage(subFontPtr, row);
@@ -2179,12 +2173,14 @@ FontMapInsert(
{
int row, bitOffset;
- row = ch >> FONTMAP_SHIFT;
- if (subFontPtr->fontMap[row] == NULL) {
- FontMapLoadPage(subFontPtr, row);
+ if (ch >= 0 && ch < FONTMAP_NUMCHARS) {
+ row = ch >> FONTMAP_SHIFT;
+ if (subFontPtr->fontMap[row] == NULL) {
+ FontMapLoadPage(subFontPtr, row);
+ }
+ bitOffset = ch & (FONTMAP_BITSPERPAGE - 1);
+ subFontPtr->fontMap[row][bitOffset >> 3] |= 1 << (bitOffset & 7);
}
- bitOffset = ch & (FONTMAP_BITSPERPAGE - 1);
- subFontPtr->fontMap[row][bitOffset >> 3] |= 1 << (bitOffset & 7);
}
/*
@@ -2218,10 +2214,10 @@ FontMapLoadPage(
Tcl_Encoding encoding;
XFontStruct *fontStructPtr;
XCharStruct *widths;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- subFontPtr->fontMap[row] = ckalloc(FONTMAP_BITSPERPAGE / 8);
+ subFontPtr->fontMap[row] = (char *)ckalloc(FONTMAP_BITSPERPAGE / 8);
memset(subFontPtr->fontMap[row], 0, FONTMAP_BITSPERPAGE / 8);
if (subFontPtr->familyPtr == &tsdPtr->controlFamily) {
@@ -2459,7 +2455,7 @@ CanUseFallback(
numEncodings = 0;
Tcl_DStringInit(&dsEncodings);
- charset = NULL; /* lint, since numNames must be > 0 to get here. */
+ charset = NULL; /* numNames must be > 0 to get here. */
retry:
bestIdx[0] = -1;
@@ -2553,7 +2549,7 @@ CanUseFallback(
* make a copy.
*/
- nameList = ckalloc(numNames * sizeof(char *));
+ nameList = (char **)ckalloc(numNames * sizeof(char *));
memcpy(nameList, nameListOrig, numNames * sizeof(char *));
}
nameList[nameIdx] = NULL;
@@ -2598,11 +2594,11 @@ CanUseFallback(
if (fontPtr->numSubFonts >= SUBFONT_SPACE) {
SubFont *newPtr;
- newPtr = ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
+ newPtr = (SubFont *)ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
memcpy(newPtr, fontPtr->subFontArray,
fontPtr->numSubFonts * sizeof(SubFont));
if (fixSubFontPtrPtr != NULL) {
- register SubFont *fixSubFontPtr = *fixSubFontPtrPtr;
+ SubFont *fixSubFontPtr = *fixSubFontPtrPtr;
if (fixSubFontPtr != &fontPtr->controlSubFont) {
*fixSubFontPtrPtr =
@@ -3017,7 +3013,7 @@ GetEncodingAlias(
const EncodingAlias *aliasPtr;
for (aliasPtr = encodingAliases; aliasPtr->aliasPattern != NULL; ) {
- if (Tcl_StringMatch(name, aliasPtr->aliasPattern)) {
+ if (Tcl_StringCaseMatch(name, aliasPtr->aliasPattern, 0)) {
return aliasPtr->realName;
}
aliasPtr++;
@@ -3067,29 +3063,31 @@ GetImageOfText(
Pixmap bitmap;
GC bitmapGC;
XGCValues values;
- XImage *image;
+ XImage *image = NULL;
(void) Tk_MeasureChars(tkfont, source, numBytes, -1, 0, &width);
height = fontPtr->fm.ascent + fontPtr->fm.descent;
- bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
- values.graphics_exposures = False;
- values.foreground = BlackPixel(display, DefaultScreen(display));
- bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
- &values);
- XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
-
- values.font = Tk_FontId(tkfont);
- values.foreground = WhitePixel(display, DefaultScreen(display));
- values.background = BlackPixel(display, DefaultScreen(display));
- XChangeGC(display, bitmapGC, GCFont|GCForeground|GCBackground, &values);
- Tk_DrawChars(display, bitmap, bitmapGC, tkfont, source, numBytes, 0,
- fontPtr->fm.ascent);
- XFreeGC(display, bitmapGC);
-
- image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
- ZPixmap);
- Tk_FreePixmap(display, bitmap);
+ if ((width > 0) && (height > 0)) {
+ bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
+ values.graphics_exposures = False;
+ values.foreground = BlackPixel(display, DefaultScreen(display));
+ bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
+ &values);
+ XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
+
+ values.font = Tk_FontId(tkfont);
+ values.foreground = WhitePixel(display, DefaultScreen(display));
+ values.background = BlackPixel(display, DefaultScreen(display));
+ XChangeGC(display, bitmapGC, GCFont|GCForeground|GCBackground, &values);
+ Tk_DrawChars(display, bitmap, bitmapGC, tkfont, source, numBytes, 0,
+ fontPtr->fm.ascent);
+ XFreeGC(display, bitmapGC);
+
+ image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
+ ZPixmap);
+ Tk_FreePixmap(display, bitmap);
+ }
*realWidthPtr = width;
*realHeightPtr = height;
@@ -3104,21 +3102,23 @@ InitDestImage(
int height,
Pixmap *bitmapPtr)
{
- Pixmap bitmap;
- XImage *image;
+ Pixmap bitmap = None;
+ XImage *image = NULL;
GC bitmapGC;
XGCValues values;
- bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
- values.graphics_exposures = False;
- values.foreground = BlackPixel(display, DefaultScreen(display));
- bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
- &values);
- XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
- XFreeGC(display, bitmapGC);
+ if ((width > 0) && (height > 0)) {
+ bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
+ values.graphics_exposures = False;
+ values.foreground = BlackPixel(display, DefaultScreen(display));
+ bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
+ &values);
+ XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
+ XFreeGC(display, bitmapGC);
- image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
- ZPixmap);
+ image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
+ ZPixmap);
+ }
*bitmapPtr = bitmap;
return image;
}
diff --git a/unix/tkUnixInit.c b/unix/tkUnixInit.c
index b0aa2fa..cffe605 100644
--- a/unix/tkUnixInit.c
+++ b/unix/tkUnixInit.c
@@ -14,7 +14,7 @@
#ifdef HAVE_COREFOUNDATION
static int GetLibraryPath(Tcl_Interp *interp);
#else
-#define GetLibraryPath(dummy) (void)0
+#define GetLibraryPath(dummy) (void)dummy
#endif /* HAVE_COREFOUNDATION */
/*
@@ -132,11 +132,11 @@ TkpDisplayWarning(
*----------------------------------------------------------------------
*/
+#ifdef TK_FRAMEWORK
static int
GetLibraryPath(
Tcl_Interp *interp)
{
-#ifdef TK_FRAMEWORK
int foundInFramework = TCL_ERROR;
char tkLibPath[PATH_MAX + 1];
@@ -147,10 +147,15 @@ GetLibraryPath(
Tcl_SetVar2(interp, "tk_library", NULL, tkLibPath, TCL_GLOBAL_ONLY);
}
return foundInFramework;
+}
#else
+static int
+GetLibraryPath(
+ TCL_UNUSED(Tcl_Interp *))
+{
return TCL_ERROR;
-#endif
}
+#endif
#endif /* HAVE_COREFOUNDATION */
/*
diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c
index baba11e..1a5cb7d 100644
--- a/unix/tkUnixKey.c
+++ b/unix/tkUnixKey.c
@@ -12,20 +12,10 @@
#include "tkInt.h"
-/*
-** Bug [3607830]: Before using Xkb, it must be initialized. TkpOpenDisplay
-** does this and sets the USE_XKB flag if xkb is supported.
-** (should this be function ptr?)
-*/
-#ifdef HAVE_XKBKEYCODETOKEYSYM
-# include <X11/XKBlib.h>
-#else
-# define XkbKeycodeToKeysym(D,K,G,L) XKeycodeToKeysym(D,K,L)
-#endif
-#define TkKeycodeToKeysym(D,K,G,L) \
- ((D)->flags & TK_DISPLAY_USE_XKB) ? \
- XkbKeycodeToKeysym((D)->display,K,G,L) : \
- XKeycodeToKeysym((D)->display,K,L)
+#undef register /* Keyword "register" is used in XKBlib.h, so don't try tricky things here */
+#define XkbOpenDisplay XkbOpenDisplay_ /* Move out of the way, conflicting definitions */
+#include <X11/XKBlib.h>
+#undef XkbOpenDisplay
/*
* Prototypes for local functions defined in this file:
@@ -110,7 +100,7 @@ TkpGetString(
XEvent *eventPtr, /* X keyboard event. */
Tcl_DString *dsPtr) /* Initialized, empty string to hold result. */
{
- size_t len;
+ TkSizeT len;
Tcl_DString buf;
TkKeyEvent *kePtr = (TkKeyEvent *) eventPtr;
@@ -138,8 +128,7 @@ TkpGetString(
#ifdef TK_USE_INPUT_METHODS
if ((winPtr->dispPtr->flags & TK_DISPLAY_USE_IM)
- && (winPtr->inputContext != NULL)
- && (eventPtr->type == KeyPress)) {
+ && (winPtr->inputContext != NULL)) {
Status status;
#if X_HAVE_UTF8_STRING
@@ -194,8 +183,7 @@ TkpGetString(
{
/*
* Fall back to convert a keyboard event to a UTF-8 string using
- * XLookupString. This is used when input methods are turned off and
- * for KeyRelease events.
+ * XLookupString. This is used when input methods are turned off.
*
* Note: XLookupString() normally returns a single ISO Latin 1 or
* ASCII control character.
@@ -208,7 +196,7 @@ TkpGetString(
Tcl_DStringValue(&buf)[len] = '\0';
if (len == 1) {
- len = Tcl_UniCharToUtf((unsigned char) Tcl_DStringValue(&buf)[0],
+ len = TkUniCharToUtf((unsigned char) Tcl_DStringValue(&buf)[0],
Tcl_DStringValue(dsPtr));
Tcl_DStringSetLength(dsPtr, len);
} else {
@@ -229,7 +217,7 @@ TkpGetString(
*/
done:
- kePtr->charValuePtr = ckalloc(len + 1);
+ kePtr->charValuePtr = (char *)ckalloc(len + 1);
kePtr->charValueLen = len;
memcpy(kePtr->charValuePtr, Tcl_DStringValue(dsPtr), len + 1);
return Tcl_DStringValue(dsPtr);
@@ -237,7 +225,7 @@ done:
/*
* When mapping from a keysym to a keycode, need information about the
- * modifier state to be used so that when they call TkKeycodeToKeysym taking
+ * modifier state to be used so that when they call XbkKeycodeToKeysym taking
* into account the xkey.state, they will get back the original keysym.
*/
@@ -279,9 +267,9 @@ TkpSetKeycodeAndState(
mincode = 0;
maxcode = -1;
XDisplayKeycodes(dispPtr->display, &mincode, &maxcode);
- if (keycode < mincode) {
+ if (keycode < (KeyCode)mincode) {
keycode = mincode;
- } else if (keycode > maxcode) {
+ } else if (keycode > (KeyCode)maxcode) {
keycode = maxcode;
}
@@ -363,7 +351,7 @@ TkpGetKeySym(
&& (eventPtr->xkey.state & LockMask))) {
index += 1;
}
- sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode, 0,
+ sym = XkbKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, 0,
index);
/*
@@ -378,7 +366,7 @@ TkpGetKeySym(
|| ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis))
|| ((sym >= XK_Ooblique) && (sym <= XK_Thorn)))) {
index &= ~1;
- sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode,
+ sym = XkbKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode,
0, index);
}
}
@@ -389,7 +377,7 @@ TkpGetKeySym(
*/
if ((index & 1) && (sym == NoSymbol)) {
- sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode,
+ sym = XkbKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode,
0, index & ~1);
}
return sym;
@@ -439,7 +427,7 @@ TkpInitKeymapInfo(
if (*codePtr == 0) {
continue;
}
- keysym = TkKeycodeToKeysym(dispPtr, *codePtr, 0, 0);
+ keysym = XkbKeycodeToKeysym(dispPtr->display, *codePtr, 0, 0);
if (keysym == XK_Shift_Lock) {
dispPtr->lockUsage = LU_SHIFT;
break;
@@ -465,7 +453,8 @@ TkpInitKeymapInfo(
if (*codePtr == 0) {
continue;
}
- keysym = TkKeycodeToKeysym(dispPtr, *codePtr, 0, 0);
+ keysym = XkbKeycodeToKeysym(dispPtr->display, *codePtr, 0, 0);
+
if (keysym == XK_Mode_switch) {
dispPtr->modeModMask |= ShiftMask << (i/modMapPtr->max_keypermod);
}
@@ -486,7 +475,7 @@ TkpInitKeymapInfo(
}
dispPtr->numModKeyCodes = 0;
arraySize = KEYCODE_ARRAY_SIZE;
- dispPtr->modKeyCodes = ckalloc(KEYCODE_ARRAY_SIZE * sizeof(KeyCode));
+ dispPtr->modKeyCodes = (KeyCode *)ckalloc(KEYCODE_ARRAY_SIZE * sizeof(KeyCode));
for (i = 0, codePtr = modMapPtr->modifiermap; i < max; i++, codePtr++) {
if (*codePtr == 0) {
continue;
@@ -513,7 +502,7 @@ TkpInitKeymapInfo(
*/
arraySize *= 2;
- newCodes = ckalloc(arraySize * sizeof(KeyCode));
+ newCodes = (KeyCode *)ckalloc(arraySize * sizeof(KeyCode));
memcpy(newCodes, dispPtr->modKeyCodes,
dispPtr->numModKeyCodes * sizeof(KeyCode));
ckfree(dispPtr->modKeyCodes);
diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c
index d62cd50..7c7ed26 100644
--- a/unix/tkUnixMenu.c
+++ b/unix/tkUnixMenu.c
@@ -147,6 +147,8 @@ void
TkpDestroyMenu(
TkMenu *menuPtr)
{
+ (void)menuPtr;
+
/*
* Nothing to do.
*/
@@ -173,6 +175,8 @@ void
TkpDestroyMenuEntry(
TkMenuEntry *mEntryPtr)
{
+ (void)mEntryPtr;
+
/*
* Nothing to do.
*/
@@ -199,7 +203,7 @@ TkpDestroyMenuEntry(
int
TkpConfigureMenuEntry(
- register TkMenuEntry *mePtr)/* Information about menu entry; may or may
+ TkMenuEntry *mePtr)/* Information about menu entry; may or may
* not already have values for some fields. */
{
/*
@@ -241,6 +245,8 @@ int
TkpMenuNewEntry(
TkMenuEntry *mePtr)
{
+ (void)mePtr;
+
return TCL_OK;
}
@@ -296,6 +302,10 @@ TkpSetMainMenubar(
Tk_Window tkwin,
const char *menuName)
{
+ (void)interp;
+ (void)tkwin;
+ (void)menuName;
+
/*
* Nothing to do.
*/
@@ -329,6 +339,8 @@ GetMenuIndicatorGeometry(
int *heightPtr) /* The resulting height */
{
int borderWidth;
+ (void)tkfont;
+ (void)fmPtr;
if ((mePtr->type == CHECK_BUTTON_ENTRY)
|| (mePtr->type == RADIO_BUTTON_ENTRY)) {
@@ -560,6 +572,10 @@ DrawMenuEntryIndicator(
int width, /* Width of menu entry */
int height) /* Height of menu entry */
{
+ (void)tkfont;
+ (void)fmPtr;
+ (void)width;
+
/*
* Draw check-button indicator.
*/
@@ -632,6 +648,10 @@ DrawMenuSeparator(
{
XPoint points[2];
Tk_3DBorder border;
+ (void)mePtr;
+ (void)gc;
+ (void)tkfont;
+ (void)fmPtr;
if (menuPtr->menuType == MENUBAR) {
return;
@@ -789,7 +809,7 @@ DrawMenuEntryLabel(
imageHeight, d, leftEdge + imageXOffset,
(int) (y + (mePtr->height-imageHeight)/2 + imageYOffset));
}
- } else if (mePtr->bitmapPtr != None) {
+ } else if (mePtr->bitmapPtr != NULL) {
Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr);
XCopyPlane(menuPtr->display, bitmap, d, gc, 0, 0,
@@ -817,7 +837,7 @@ DrawMenuEntryLabel(
XFillRectangle(menuPtr->display, d, menuPtr->disabledGC, x, y,
(unsigned) width, (unsigned) height);
} else if ((mePtr->image != NULL)
- && (menuPtr->disabledImageGC != None)) {
+ && (menuPtr->disabledImageGC != NULL)) {
XFillRectangle(menuPtr->display, d, menuPtr->disabledImageGC,
leftEdge + imageXOffset,
(int) (y + (mePtr->height - imageHeight)/2 + imageYOffset),
@@ -853,21 +873,19 @@ DrawMenuUnderline(
int x, int y,
int width, int height)
{
+ (void)width;
+
if ((mePtr->underline >= 0) && (mePtr->labelPtr != NULL)) {
int len;
- /*
- * Do the unicode call just to prevent overruns.
- */
-
- Tcl_GetUnicodeFromObj(mePtr->labelPtr, &len);
+ len = Tcl_GetCharLength(mePtr->labelPtr);
if (mePtr->underline < len) {
- int activeBorderWidth, leftEdge;
+ int activeBorderWidth, leftEdge, ch;
const char *label, *start, *end;
label = Tcl_GetString(mePtr->labelPtr);
start = Tcl_UtfAtIndex(label, mePtr->underline);
- end = Tcl_UtfNext(start);
+ end = start + TkUtfToUniChar(start, &ch);
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin,
menuPtr->activeBorderWidthPtr, &activeBorderWidth);
@@ -934,15 +952,16 @@ TkpPostMenu(
int
TkpPostTearoffMenu(
- Tcl_Interp *interp, /* The interpreter of the menu */
+ Tcl_Interp *dummy, /* The interpreter of the menu */
TkMenu *menuPtr, /* The menu we are posting */
int x, int y, int index) /* The root X,Y coordinates where the
* specified entry will be posted */
{
int vRootX, vRootY, vRootWidth, vRootHeight;
int result;
+ (void)dummy;
- if (index >= menuPtr->numEntries) {
+ if (index >= (int)menuPtr->numEntries) {
index = menuPtr->numEntries - 1;
}
if (index >= 0) {
@@ -1031,6 +1050,10 @@ GetMenuSeparatorGeometry(
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
+ (void)menuPtr;
+ (void)mePtr;
+ (void)tkfont;
+
*widthPtr = 0;
*heightPtr = fmPtr->linespace;
}
@@ -1060,6 +1083,8 @@ GetTearoffEntryGeometry(
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
+ (void)mePtr;
+
if (menuPtr->menuType != MASTER_MENU) {
*heightPtr = 0;
*widthPtr = 0;
@@ -1114,7 +1139,7 @@ TkpComputeMenubarGeometry(
maxWindowWidth = Tk_Width(menuPtr->tkwin);
if (maxWindowWidth == 1) {
- maxWindowWidth = 0x7ffffff;
+ maxWindowWidth = 0x7FFFFFF;
}
currentRowHeight = 0;
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr,
@@ -1134,7 +1159,7 @@ TkpComputeMenubarGeometry(
menuFont = Tk_GetFontFromObj(menuPtr->tkwin, menuPtr->fontPtr);
Tk_GetFontMetrics(menuFont, &menuMetrics);
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuPtr->numEntries; i++) {
mePtr = menuPtr->entries[i];
mePtr->entryFlags &= ~ENTRY_LAST_COLUMN;
if (mePtr->fontPtr != NULL) {
@@ -1211,7 +1236,7 @@ TkpComputeMenubarGeometry(
maxWidth = x + menuPtr->entries[lastEntry]->width + borderWidth;
}
x = borderWidth;
- for (j = lastRowBreak; j < menuPtr->numEntries; j++) {
+ for (j = lastRowBreak; j < (int)menuPtr->numEntries; j++) {
if (j == helpMenuIndex) {
continue;
}
@@ -1283,6 +1308,10 @@ DrawTearoffEntry(
XPoint points[2];
int segmentWidth, maxX;
Tk_3DBorder border;
+ (void)mePtr;
+ (void)gc;
+ (void)tkfont;
+ (void)fmPtr;
if (menuPtr->menuType != MASTER_MENU) {
return;
@@ -1331,6 +1360,9 @@ TkpInitializeMenuBindings(
Tk_BindingTable bindingTable)
/* The table to add to. */
{
+ (void)interp;
+ (void)bindingTable;
+
/*
* Nothing to do.
*/
@@ -1379,7 +1411,7 @@ SetHelpMenu(
&& (cascadeEntryPtr->menuPtr->masterMenuPtr->tkwin != NULL)
&& (menuPtr->masterMenuPtr->tkwin != NULL)) {
TkMenu *masterMenuPtr = cascadeEntryPtr->menuPtr->masterMenuPtr;
- char *helpMenuName = ckalloc(strlen(Tk_PathName(
+ char *helpMenuName = (char *)ckalloc(strlen(Tk_PathName(
masterMenuPtr->tkwin)) + strlen(".help") + 1);
strcpy(helpMenuName, Tk_PathName(masterMenuPtr->tkwin));
@@ -1713,7 +1745,7 @@ TkpComputeStandardMenuGeometry(
Tk_GetFontMetrics(menuFont, &menuMetrics);
accelSpace = Tk_TextWidth(menuFont, "M", 1);
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuPtr->numEntries; i++) {
mePtr = menuPtr->entries[i];
if (mePtr->fontPtr == NULL) {
tkfont = menuFont;
@@ -1808,7 +1840,7 @@ TkpComputeStandardMenuGeometry(
if (accelWidth != 0) {
labelWidth += accelSpace;
}
- for (j = lastColumnBreak; j < menuPtr->numEntries; j++) {
+ for (j = lastColumnBreak; j < (int)menuPtr->numEntries; j++) {
menuPtr->entries[j]->indicatorSpace = indicatorSpace;
menuPtr->entries[j]->labelWidth = labelWidth;
menuPtr->entries[j]->width = indicatorSpace + labelWidth
@@ -1855,9 +1887,12 @@ TkpComputeStandardMenuGeometry(
void
TkpMenuNotifyToplevelCreate(
- Tcl_Interp *interp, /* The interp the menu lives in. */
+ Tcl_Interp *dummy, /* The interp the menu lives in. */
const char *menuName) /* The name of the menu to reconfigure. */
{
+ (void)dummy;
+ (void)menuName;
+
/*
* Nothing to do.
*/
diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c
index c49f15b..407dc30 100644
--- a/unix/tkUnixMenubu.c
+++ b/unix/tkUnixMenubu.c
@@ -34,7 +34,9 @@ TkMenuButton *
TkpCreateMenuButton(
Tk_Window tkwin)
{
- return ckalloc(sizeof(TkMenuButton));
+ (void)tkwin;
+
+ return (TkMenuButton *)ckalloc(sizeof(TkMenuButton));
}
/*
@@ -58,14 +60,14 @@ void
TkpDisplayMenuButton(
ClientData clientData) /* Information about widget. */
{
- register TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
GC gc;
Tk_3DBorder border;
Pixmap pixmap;
int x = 0; /* Initialization needed only to stop compiler
* warning. */
int y = 0;
- register Tk_Window tkwin = mbPtr->tkwin;
+ Tk_Window tkwin = mbPtr->tkwin;
int fullWidth, fullHeight;
int textXOffset, textYOffset;
int imageWidth, imageHeight;
@@ -321,6 +323,7 @@ void
TkpDestroyMenuButton(
TkMenuButton *mbPtr)
{
+ (void)mbPtr;
}
/*
diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h
index dbd5e09..347c9d8 100644
--- a/unix/tkUnixPort.h
+++ b/unix/tkUnixPort.h
@@ -18,17 +18,15 @@
#define __UNIX__ 1
#include <stdio.h>
-#include <ctype.h>
+#include <pwd.h>
+#include <assert.h>
+#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
+#include <ctype.h>
#include <math.h>
-#include <pwd.h>
-#ifdef NO_STDLIB_H
-# include "../compat/stdlib.h"
-#else
-# include <stdlib.h>
-#endif
#include <string.h>
+#include <limits.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/file.h>
#ifdef HAVE_SYS_SELECT_H
@@ -43,18 +41,17 @@
# include <time.h>
#else
# if HAVE_SYS_TIME_H
-# include <sys/time.h>
+# include <sys/time.h>
# else
-# include <time.h>
+# include <time.h>
# endif
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
-#ifndef NO_UNISTD_H
-# include <unistd.h>
-#else
-# include "../compat/unistd.h"
+#include <unistd.h>
+#if defined(__GNUC__) && !defined(__cplusplus)
+# pragma GCC diagnostic ignored "-Wc++-compat"
#endif
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
@@ -109,32 +106,19 @@
# define NBBY 8
#endif
-#ifdef __CYGWIN__
-# include "tkIntXlibDecls.h"
-# define UINT unsigned int
-# define HWND void *
-# define HDC void *
-# define HINSTANCE void *
-# define COLORREF void *
-# define HMENU void *
-# define TkWinDCState void
-# define HPALETTE void *
-# define WNDPROC void *
-# define WPARAM void *
-# define LPARAM void *
-# define LRESULT void *
-
-#else /* !__CYGWIN__ */
- /*
- * The TkPutImage macro strips off the color table information, which isn't
- * needed for X.
- */
-
-# define TkPutImage(colors, ncolors, display, pixels, gc, image, srcx, srcy, destx, desty, width, height) \
- XPutImage(display, pixels, gc, image, srcx, srcy, destx, \
- desty, width, height);
-
-#endif /* !__CYGWIN__ */
+#include "tkIntXlibDecls.h"
+#define UINT unsigned int
+#define HWND void *
+#define HDC void *
+#define HINSTANCE void *
+#define COLORREF void *
+#define HMENU void *
+#define TkWinDCState void
+#define HPALETTE void *
+#define WNDPROC void *
+#define WPARAM void *
+#define LPARAM void *
+#define LRESULT void *
/*
* Supply macros for seek offsets, if they're not already provided by
diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c
index 9c15369..c154f96 100644
--- a/unix/tkUnixRFont.c
+++ b/unix/tkUnixRFont.c
@@ -50,31 +50,44 @@ typedef struct {
* the information isn't retrievable from the GC.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
Region clipRegion; /* The clipping region, or None. */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
/*
- * Package initialization:
- * Nothing to do here except register the fact that we're using Xft in
- * the TIP 59 configuration database.
+ *-------------------------------------------------------------------------
+ *
+ * TkpFontPkgInit --
+ *
+ * This procedure is called when an application is created. It
+ * initializes all the structures that are used by the
+ * platform-dependant code on a per application basis.
+ * Note that this is called before TkpInit() !
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *-------------------------------------------------------------------------
*/
-#ifndef TCL_CFGVAL_ENCODING
-#define TCL_CFGVAL_ENCODING "ascii"
-#endif
+
+static int utf8ToUcs4(const char *source, FcChar32 *c, int numBytes)
+{
+ if (numBytes >= 6) {
+ return TkUtfToUniChar(source, (int *)c);
+ }
+ return FcUtf8ToUcs4((const FcChar8 *)source, c, numBytes);
+}
void
TkpFontPkgInit(
TkMainInfo *mainPtr) /* The application being created. */
{
- static const Tcl_Config cfg[] = {
- { "fontsystem", "xft" },
- { 0,0 }
- };
-
- Tcl_RegisterConfig(mainPtr->interp, "tk", cfg, TCL_CFGVAL_ENCODING);
+ (void)mainPtr;
}
static XftFont *
@@ -247,6 +260,23 @@ GetTkFontMetrics(
*---------------------------------------------------------------------------
*/
+static void
+FinishedWithFont(
+ UnixFtFont *fontPtr);
+
+static int
+InitFontErrorProc(
+ ClientData clientData,
+ TCL_UNUSED(XErrorEvent *))
+{
+ int *errorFlagPtr = (int *)clientData;
+
+ if (errorFlagPtr != NULL) {
+ *errorFlagPtr = 1;
+ }
+ return 0;
+}
+
static UnixFtFont *
InitFont(
Tk_Window tkwin,
@@ -257,10 +287,11 @@ InitFont(
FcCharSet *charset;
FcResult result;
XftFont *ftFont;
- int i, iWidth;
+ int i, iWidth, errorFlag;
+ Tk_ErrorHandler handler;
if (!fontPtr) {
- fontPtr = ckalloc(sizeof(UnixFtFont));
+ fontPtr = (UnixFtFont *)ckalloc(sizeof(UnixFtFont));
}
FcConfigSubstitute(0, pattern, FcMatchPattern);
@@ -271,14 +302,14 @@ InitFont(
*/
set = FcFontSort(0, pattern, FcTrue, NULL, &result);
- if (!set) {
+ if (!set || set->nfont == 0) {
ckfree(fontPtr);
return NULL;
}
fontPtr->fontset = set;
fontPtr->pattern = pattern;
- fontPtr->faces = ckalloc(set->nfont * sizeof(UnixFtFace));
+ fontPtr->faces = (UnixFtFace *)ckalloc(set->nfont * sizeof(UnixFtFace));
fontPtr->nfaces = set->nfont;
/*
@@ -308,10 +339,25 @@ InitFont(
* Fill in platform-specific fields of TkFont.
*/
+ errorFlag = 0;
+ handler = Tk_CreateErrorHandler(Tk_Display(tkwin),
+ -1, -1, -1, InitFontErrorProc, (ClientData) &errorFlag);
ftFont = GetFont(fontPtr, 0, 0.0);
+ if ((ftFont == NULL) || errorFlag) {
+ Tk_DeleteErrorHandler(handler);
+ FinishedWithFont(fontPtr);
+ ckfree(fontPtr);
+ return NULL;
+ }
fontPtr->font.fid = XLoadFont(Tk_Display(tkwin), "fixed");
GetTkFontAttributes(ftFont, &fontPtr->font.fa);
GetTkFontMetrics(ftFont, &fontPtr->font.fm);
+ Tk_DeleteErrorHandler(handler);
+ if (errorFlag) {
+ FinishedWithFont(fontPtr);
+ ckfree(fontPtr);
+ return NULL;
+ }
/*
* Fontconfig can't report any information about the position or thickness
@@ -336,7 +382,16 @@ InitFont(
TkFont *fPtr = &fontPtr->font;
fPtr->underlinePos = fPtr->fm.descent / 2;
+ handler = Tk_CreateErrorHandler(Tk_Display(tkwin),
+ -1, -1, -1, InitFontErrorProc, (ClientData) &errorFlag);
+ errorFlag = 0;
Tk_MeasureChars((Tk_Font) fPtr, "I", 1, -1, 0, &iWidth);
+ Tk_DeleteErrorHandler(handler);
+ if (errorFlag) {
+ FinishedWithFont(fontPtr);
+ ckfree(fontPtr);
+ return NULL;
+ }
fPtr->underlineHeight = iWidth / 3;
if (fPtr->underlineHeight == 0) {
fPtr->underlineHeight = 1;
@@ -627,6 +682,7 @@ TkpGetFontAttrsForChar(
/* UCS-4 character to map */
XftFont *ftFont = GetFont(fontPtr, ucs4, 0.0);
/* Actual font used to render the character */
+ (void)tkwin;
GetTkFontAttributes(ftFont, faPtr);
faPtr->underline = fontPtr->font.fa.underline;
@@ -661,12 +717,15 @@ Tk_MeasureChars(
FcChar32 c;
XGlyphInfo extents;
int clen, curX, newX, curByte, newByte, sawNonSpace;
- int termByte = 0, termX = 0;
+ int termByte = 0, termX = 0, errorFlag = 0;
+ Tk_ErrorHandler handler;
#if DEBUG_FONTSEL
char string[256];
int len = 0;
#endif /* DEBUG_FONTSEL */
+ handler = Tk_CreateErrorHandler(fontPtr->display,
+ -1, -1, -1, InitFontErrorProc, &errorFlag);
curX = 0;
curByte = 0;
sawNonSpace = 0;
@@ -702,7 +761,12 @@ Tk_MeasureChars(
#endif /* DEBUG_FONTSEL */
ftFont = GetFont(fontPtr, c, 0.0);
- XftTextExtents32(fontPtr->display, ftFont, &c, 1, &extents);
+ if (!errorFlag) {
+ XftTextExtents32(fontPtr->display, ftFont, &c, 1, &extents);
+ } else {
+ extents.xOff = 0;
+ errorFlag = 0;
+ }
newX = curX + extents.xOff;
newByte = curByte + clen;
@@ -731,6 +795,7 @@ Tk_MeasureChars(
curX = newX;
curByte = newByte;
}
+ Tk_DeleteErrorHandler(handler);
#if DEBUG_FONTSEL
string[len] = '\0';
printf("MeasureChars %s length %d bytes %d\n", string, curX, curByte);
@@ -824,7 +889,7 @@ LookUpColor(Display *display, /* Display to lookup colors on */
fontPtr->colors[last].color.color.red = xcolor.red;
fontPtr->colors[last].color.color.green = xcolor.green;
fontPtr->colors[last].color.color.blue = xcolor.blue;
- fontPtr->colors[last].color.color.alpha = 0xffff;
+ fontPtr->colors[last].color.color.alpha = 0xFFFF;
fontPtr->colors[last].color.pixel = pixel;
/*
@@ -886,7 +951,7 @@ Tk_DrawChars(
}
XGetGCValues(display, gc, GCForeground, &values);
xftcolor = LookUpColor(display, fontPtr, values.foreground);
- if (tsdPtr->clipRegion != None) {
+ if (tsdPtr->clipRegion != NULL) {
XftDrawSetClip(fontPtr->ftDraw, tsdPtr->clipRegion);
}
nspec = 0;
@@ -894,7 +959,7 @@ Tk_DrawChars(
XftFont *ftFont;
FcChar32 c;
- clen = FcUtf8ToUcs4((FcChar8 *) source, &c, numBytes);
+ clen = utf8ToUcs4(source, &c, numBytes);
if (clen <= 0) {
/*
* This should not happen, but it can.
@@ -936,7 +1001,7 @@ Tk_DrawChars(
}
doUnderlineStrikeout:
- if (tsdPtr->clipRegion != None) {
+ if (tsdPtr->clipRegion != NULL) {
XftDrawSetClip(fontPtr->ftDraw, NULL);
}
if (fontPtr->font.fa.underline != 0) {
@@ -1028,13 +1093,13 @@ TkDrawAngledChars(
nglyph = 0;
currentFtFont = NULL;
- originX = originY = 0; /* lint */
+ originX = originY = 0;
while (numBytes > 0) {
XftFont *ftFont;
FcChar32 c;
- clen = FcUtf8ToUcs4((FcChar8 *) source, &c, numBytes);
+ clen = utf8ToUcs4(source, &c, numBytes);
if (clen <= 0) {
/*
* This should not happen, but it can.
@@ -1130,7 +1195,7 @@ TkDrawAngledChars(
}
XGetGCValues(display, gc, GCForeground, &values);
xftcolor = LookUpColor(display, fontPtr, values.foreground);
- if (tsdPtr->clipRegion != None) {
+ if (tsdPtr->clipRegion != NULL) {
XftDrawSetClip(fontPtr->ftDraw, tsdPtr->clipRegion);
}
nspec = 0;
@@ -1138,7 +1203,7 @@ TkDrawAngledChars(
XftFont *ftFont, *ft0Font;
FcChar32 c;
- clen = FcUtf8ToUcs4((FcChar8 *) source, &c, numBytes);
+ clen = utf8ToUcs4(source, &c, numBytes);
if (clen <= 0) {
/*
* This should not happen, but it can.
@@ -1182,7 +1247,7 @@ TkDrawAngledChars(
#endif /* XFT_HAS_FIXED_ROTATED_PLACEMENT */
doUnderlineStrikeout:
- if (tsdPtr->clipRegion != None) {
+ if (tsdPtr->clipRegion != NULL) {
XftDrawSetClip(fontPtr->ftDraw, NULL);
}
if (fontPtr->font.fa.underline || fontPtr->font.fa.overstrike) {
@@ -1243,12 +1308,12 @@ TkDrawAngledChars(
void
TkUnixSetXftClipRegion(
- TkRegion clipRegion) /* The clipping region to install. */
+ Region clipRegion) /* The clipping region to install. */
{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- tsdPtr->clipRegion = (Region) clipRegion;
+ tsdPtr->clipRegion = clipRegion;
}
/*
diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c
index 8427cfe..b090c4f 100644
--- a/unix/tkUnixScale.c
+++ b/unix/tkUnixScale.c
@@ -24,11 +24,13 @@
static void DisplayHorizontalScale(TkScale *scalePtr,
Drawable drawable, XRectangle *drawnAreaPtr);
static void DisplayHorizontalValue(TkScale *scalePtr,
- Drawable drawable, double value, int top);
+ Drawable drawable, double value, int top,
+ const char *format);
static void DisplayVerticalScale(TkScale *scalePtr,
Drawable drawable, XRectangle *drawnAreaPtr);
static void DisplayVerticalValue(TkScale *scalePtr,
- Drawable drawable, double value, int rightEdge);
+ Drawable drawable, double value, int rightEdge,
+ const char *format);
/*
*----------------------------------------------------------------------
@@ -50,7 +52,9 @@ TkScale *
TkpCreateScale(
Tk_Window tkwin)
{
- return ckalloc(sizeof(TkScale));
+ (void)tkwin;
+
+ return (TkScale *)ckalloc(sizeof(TkScale));
}
/*
@@ -165,7 +169,7 @@ DisplayVerticalScale(
}
}
DisplayVerticalValue(scalePtr, drawable, tickValue,
- scalePtr->vertTickRightX);
+ scalePtr->vertTickRightX, scalePtr->tickFormat);
}
}
}
@@ -176,7 +180,7 @@ DisplayVerticalScale(
if (scalePtr->showValue) {
DisplayVerticalValue(scalePtr, drawable, scalePtr->value,
- scalePtr->vertValueRightX);
+ scalePtr->vertValueRightX, scalePtr->valueFormat);
}
/*
@@ -228,8 +232,8 @@ DisplayVerticalScale(
Tk_GetFontMetrics(scalePtr->tkfont, &fm);
Tk_DrawChars(scalePtr->display, drawable, scalePtr->textGC,
scalePtr->tkfont, scalePtr->label,
- scalePtr->labelLength, scalePtr->vertLabelX,
- scalePtr->inset + (3*fm.ascent)/2);
+ scalePtr->labelLength, scalePtr->vertLabelX,
+ scalePtr->inset + (3 * fm.ascent) / 2);
}
}
@@ -254,25 +258,26 @@ DisplayVerticalScale(
static void
DisplayVerticalValue(
- register TkScale *scalePtr, /* Information about widget in which to
+ TkScale *scalePtr, /* Information about widget in which to
* display value. */
Drawable drawable, /* Pixmap or window in which to draw the
* value. */
double value, /* Y-coordinate of number to display,
* specified in application coords, not in
* pixels (we'll compute pixels). */
- int rightEdge) /* X-coordinate of right edge of text,
+ int rightEdge, /* X-coordinate of right edge of text,
* specified in pixels. */
+ const char *format) /* Format string to use for the value */
{
- register Tk_Window tkwin = scalePtr->tkwin;
+ Tk_Window tkwin = scalePtr->tkwin;
int y, width, length;
char valueString[TCL_DOUBLE_SPACE];
Tk_FontMetrics fm;
Tk_GetFontMetrics(scalePtr->tkfont, &fm);
y = TkScaleValueToPixel(scalePtr, value) + fm.ascent/2;
- if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->format, value) < 0) {
- valueString[TCL_DOUBLE_SPACE - 1] = '\0';
+ if (snprintf(valueString, TCL_DOUBLE_SPACE, format, value) < 0) {
+ valueString[TCL_DOUBLE_SPACE - 1] = '\0';
}
length = (int) strlen(valueString);
width = Tk_TextWidth(scalePtr->tkfont, valueString, length);
@@ -282,10 +287,10 @@ DisplayVerticalValue(
* the window.
*/
- if ((y - fm.ascent) < (scalePtr->inset + SPACING)) {
+ if (y - fm.ascent < scalePtr->inset + SPACING) {
y = scalePtr->inset + SPACING + fm.ascent;
}
- if ((y + fm.descent) > (Tk_Height(tkwin) - scalePtr->inset - SPACING)) {
+ if (y + fm.descent > Tk_Height(tkwin) - scalePtr->inset - SPACING) {
y = Tk_Height(tkwin) - scalePtr->inset - SPACING - fm.descent;
}
Tk_DrawChars(scalePtr->display, drawable, scalePtr->textGC,
@@ -322,9 +327,9 @@ DisplayHorizontalScale(
* to reflect the part of the window that was
* redrawn. */
{
- register Tk_Window tkwin = scalePtr->tkwin;
+ Tk_Window tkwin = scalePtr->tkwin;
int x, y, width, height, shadowWidth;
- double tickValue, tickInterval = scalePtr->tickInterval;
+ double tickInterval = scalePtr->tickInterval;
Tk_3DBorder sliderBorder;
/*
@@ -348,7 +353,7 @@ DisplayHorizontalScale(
if (tickInterval != 0) {
char valueString[TCL_DOUBLE_SPACE];
- double ticks, maxTicks;
+ double ticks, maxTicks, tickValue;
/*
* Ensure that we will only draw enough of the tick values such
@@ -358,17 +363,17 @@ DisplayHorizontalScale(
ticks = fabs((scalePtr->toValue - scalePtr->fromValue)
/ tickInterval);
- if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->format,
- scalePtr->fromValue) < 0) {
- valueString[TCL_DOUBLE_SPACE - 1] = '\0';
- }
+ if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->tickFormat,
+ scalePtr->fromValue) < 0) {
+ valueString[TCL_DOUBLE_SPACE - 1] = '\0';
+ }
maxTicks = (double) Tk_Width(tkwin)
/ (double) Tk_TextWidth(scalePtr->tkfont, valueString, -1);
if (ticks > maxTicks) {
- tickInterval *= (ticks / maxTicks);
+ tickInterval *= ticks / maxTicks;
}
- for (tickValue = scalePtr->fromValue; ;
- tickValue += tickInterval) {
+ tickValue = scalePtr->fromValue;
+ while (1) {
/*
* The TkRoundValueToResolution call gets rid of accumulated
* round-off errors, if any.
@@ -385,7 +390,8 @@ DisplayHorizontalScale(
}
}
DisplayHorizontalValue(scalePtr, drawable, tickValue,
- scalePtr->horizTickY);
+ scalePtr->horizTickY, scalePtr->tickFormat);
+ tickValue += tickInterval;
}
}
}
@@ -396,7 +402,7 @@ DisplayHorizontalScale(
if (scalePtr->showValue) {
DisplayHorizontalValue(scalePtr, drawable, scalePtr->value,
- scalePtr->horizValueY);
+ scalePtr->horizValueY, scalePtr->valueFormat);
}
/*
@@ -449,8 +455,8 @@ DisplayHorizontalScale(
Tk_GetFontMetrics(scalePtr->tkfont, &fm);
Tk_DrawChars(scalePtr->display, drawable, scalePtr->textGC,
scalePtr->tkfont, scalePtr->label,
- scalePtr->labelLength, scalePtr->inset + fm.ascent/2,
- scalePtr->horizLabelY + fm.ascent);
+ scalePtr->labelLength, scalePtr->inset + fm.ascent/2,
+ scalePtr->horizLabelY + fm.ascent);
}
}
@@ -475,17 +481,18 @@ DisplayHorizontalScale(
static void
DisplayHorizontalValue(
- register TkScale *scalePtr, /* Information about widget in which to
+ TkScale *scalePtr, /* Information about widget in which to
* display value. */
Drawable drawable, /* Pixmap or window in which to draw the
* value. */
double value, /* X-coordinate of number to display,
* specified in application coords, not in
* pixels (we'll compute pixels). */
- int top) /* Y-coordinate of top edge of text, specified
+ int top, /* Y-coordinate of top edge of text, specified
* in pixels. */
+ const char *format) /* Format string to use for the value */
{
- register Tk_Window tkwin = scalePtr->tkwin;
+ Tk_Window tkwin = scalePtr->tkwin;
int x, y, length, width;
char valueString[TCL_DOUBLE_SPACE];
Tk_FontMetrics fm;
@@ -493,8 +500,8 @@ DisplayHorizontalValue(
x = TkScaleValueToPixel(scalePtr, value);
Tk_GetFontMetrics(scalePtr->tkfont, &fm);
y = top + fm.ascent;
- if (snprintf(valueString, TCL_DOUBLE_SPACE, scalePtr->format, value) < 0) {
- valueString[TCL_DOUBLE_SPACE - 1] = '\0';
+ if (snprintf(valueString, TCL_DOUBLE_SPACE, format, value) < 0) {
+ valueString[TCL_DOUBLE_SPACE - 1] = '\0';
}
length = (int) strlen(valueString);
width = Tk_TextWidth(scalePtr->tkfont, valueString, length);
@@ -504,8 +511,8 @@ DisplayHorizontalValue(
* the window.
*/
- x -= (width)/2;
- if (x < (scalePtr->inset + SPACING)) {
+ x -= width / 2;
+ if (x < scalePtr->inset + SPACING) {
x = scalePtr->inset + SPACING;
}
@@ -541,7 +548,7 @@ void
TkpDisplayScale(
ClientData clientData) /* Widget record for scale. */
{
- TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
Tk_Window tkwin = scalePtr->tkwin;
Tcl_Interp *interp = scalePtr->interp;
Pixmap pixmap;
@@ -562,10 +569,10 @@ TkpDisplayScale(
Tcl_Preserve(scalePtr);
if ((scalePtr->flags & INVOKE_COMMAND) && (scalePtr->command != NULL)) {
Tcl_Preserve(interp);
- if (snprintf(string, TCL_DOUBLE_SPACE, scalePtr->format,
- scalePtr->value) < 0) {
- string[TCL_DOUBLE_SPACE - 1] = '\0';
- }
+ if (snprintf(string, TCL_DOUBLE_SPACE, scalePtr->valueFormat,
+ scalePtr->value) < 0) {
+ string[TCL_DOUBLE_SPACE - 1] = '\0';
+ }
Tcl_DStringInit(&buf);
Tcl_DStringAppend(&buf, scalePtr->command, -1);
Tcl_DStringAppend(&buf, " ", -1);
@@ -634,7 +641,7 @@ TkpDisplayScale(
gc = Tk_GCForColor(scalePtr->highlightColorPtr, pixmap);
} else {
gc = Tk_GCForColor(
- Tk_3DBorderColor(scalePtr->highlightBorder), pixmap);
+ Tk_3DBorderColor(scalePtr->highlightBorder), pixmap);
}
Tk_DrawFocusHighlight(tkwin, gc, scalePtr->highlightWidth, pixmap);
}
@@ -696,7 +703,7 @@ TkpScaleElement(
if (y < sliderFirst) {
return TROUGH1;
}
- if (y < (sliderFirst+scalePtr->sliderLength)) {
+ if (y < sliderFirst + scalePtr->sliderLength) {
return SLIDER;
}
return TROUGH2;
@@ -716,7 +723,7 @@ TkpScaleElement(
if (x < sliderFirst) {
return TROUGH1;
}
- if (x < (sliderFirst+scalePtr->sliderLength)) {
+ if (x < sliderFirst + scalePtr->sliderLength) {
return SLIDER;
}
return TROUGH2;
diff --git a/unix/tkUnixScrlbr.c b/unix/tkUnixScrlbr.c
index d3e4436..69843db 100644
--- a/unix/tkUnixScrlbr.c
+++ b/unix/tkUnixScrlbr.c
@@ -63,7 +63,7 @@ TkScrollbar *
TkpCreateScrollbar(
Tk_Window tkwin)
{
- UnixScrollbar *scrollPtr = ckalloc(sizeof(UnixScrollbar));
+ UnixScrollbar *scrollPtr = (UnixScrollbar *)ckalloc(sizeof(UnixScrollbar));
scrollPtr->troughGC = NULL;
scrollPtr->copyGC = NULL;
@@ -97,8 +97,8 @@ void
TkpDisplayScrollbar(
ClientData clientData) /* Information about window. */
{
- register TkScrollbar *scrollPtr = clientData;
- register Tk_Window tkwin = scrollPtr->tkwin;
+ TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
+ Tk_Window tkwin = scrollPtr->tkwin;
XPoint points[7];
Tk_3DBorder border;
int relief, width, elementBorderWidth;
@@ -277,7 +277,7 @@ TkpDisplayScrollbar(
extern void
TkpComputeScrollbarGeometry(
- register TkScrollbar *scrollPtr)
+ TkScrollbar *scrollPtr)
/* Scrollbar whose geometry may have
* changed. */
{
@@ -394,22 +394,22 @@ TkpDestroyScrollbar(
void
TkpConfigureScrollbar(
- register TkScrollbar *scrollPtr)
+ TkScrollbar *scrollPtr)
/* Information about widget; may or may not
* already have values for some fields. */
{
XGCValues gcValues;
- GC new;
+ GC newGC;
UnixScrollbar *unixScrollPtr = (UnixScrollbar *) scrollPtr;
Tk_SetBackgroundFromBorder(scrollPtr->tkwin, scrollPtr->bgBorder);
gcValues.foreground = scrollPtr->troughColorPtr->pixel;
- new = Tk_GetGC(scrollPtr->tkwin, GCForeground, &gcValues);
+ newGC = Tk_GetGC(scrollPtr->tkwin, GCForeground, &gcValues);
if (unixScrollPtr->troughGC != NULL) {
Tk_FreeGC(scrollPtr->display, unixScrollPtr->troughGC);
}
- unixScrollPtr->troughGC = new;
+ unixScrollPtr->troughGC = newGC;
if (unixScrollPtr->copyGC == NULL) {
gcValues.graphics_exposures = False;
unixScrollPtr->copyGC = Tk_GetGC(scrollPtr->tkwin,
@@ -437,12 +437,12 @@ TkpConfigureScrollbar(
int
TkpScrollbarPosition(
- register TkScrollbar *scrollPtr,
+ TkScrollbar *scrollPtr,
/* Scrollbar widget record. */
int x, int y) /* Coordinates within scrollPtr's window. */
{
int length, width, tmp;
- register const int inset = scrollPtr->inset;
+ const int inset = scrollPtr->inset;
if (scrollPtr->vertical) {
length = Tk_Height(scrollPtr->tkwin);
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c
index 6155f54..58c3abc 100644
--- a/unix/tkUnixSelect.c
+++ b/unix/tkUnixSelect.c
@@ -21,7 +21,7 @@ typedef struct ConvertInfo {
* offset of the next chunk of data to
* transfer. */
Tcl_EncodingState state; /* The encoding state needed across chunks. */
- char buffer[4]; /* A buffer to hold part of a UTF character
+ char buffer[4]; /* A buffer to hold part of a UTF character
* that is split across chunks.*/
} ConvertInfo;
@@ -68,7 +68,7 @@ typedef struct IncrInfo {
* currently pending. */
} IncrInfo;
-typedef struct ThreadSpecificData {
+typedef struct {
IncrInfo *pendingIncrs; /* List of all incr structures currently
* active. */
} ThreadSpecificData;
@@ -240,17 +240,17 @@ TkSelGetSelection(
void
TkSelPropProc(
- register XEvent *eventPtr) /* X PropertyChange event. */
+ XEvent *eventPtr) /* X PropertyChange event. */
{
- register IncrInfo *incrPtr;
- register TkSelHandler *selPtr;
+ IncrInfo *incrPtr;
+ TkSelHandler *selPtr;
int length, numItems;
unsigned long i;
Atom target, formatType;
long buffer[TK_SEL_WORDS_AT_ONCE];
TkDisplay *dispPtr = TkGetDisplay(eventPtr->xany.display);
Tk_ErrorHandler errorHandler;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -356,7 +356,7 @@ TkSelPropProc(
((char *) buffer)[numItems] = 0;
errorHandler = Tk_CreateErrorHandler(eventPtr->xproperty.display,
- -1, -1, -1, (int (*)()) NULL, NULL);
+ -1, -1, -1, NULL, NULL);
/*
* Encode the data using the proper format for each type.
@@ -446,10 +446,10 @@ TkSelPropProc(
* Preserve any left-over bytes.
*/
- if (srcLen > 4) {
+ if (srcLen > 3) {
Tcl_Panic("selection conversion left too many bytes unconverted");
}
- memcpy(incrPtr->converts[i].buffer, src, (size_t) srcLen+1);
+ memcpy(incrPtr->converts[i].buffer, src, srcLen + 1);
Tcl_DStringFree(&ds);
} else {
/*
@@ -519,10 +519,10 @@ TkSelPropProc(
void
TkSelEventProc(
Tk_Window tkwin, /* Window for which event was targeted. */
- register XEvent *eventPtr) /* X event: either SelectionClear,
+ XEvent *eventPtr) /* X event: either SelectionClear,
* SelectionRequest, or SelectionNotify. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
TkDisplay *dispPtr = winPtr->dispPtr;
Tcl_Interp *interp;
@@ -540,7 +540,7 @@ TkSelEventProc(
*/
if (eventPtr->type == SelectionNotify) {
- register TkSelRetrievalInfo *retrPtr;
+ TkSelRetrievalInfo *retrPtr;
char *propInfo, **propInfoPtr = &propInfo;
Atom type;
int format, result;
@@ -649,7 +649,7 @@ TkSelEventProc(
}
if (propInfo[numItems] != '\0') {
- propData = ckalloc(numItems + 1);
+ propData = (char *)ckalloc(numItems + 1);
strcpy(propData, propInfo);
propData[numItems] = '\0';
}
@@ -742,7 +742,7 @@ static void
SelTimeoutProc(
ClientData clientData) /* Information about retrieval in progress. */
{
- register TkSelRetrievalInfo *retrPtr = clientData;
+ TkSelRetrievalInfo *retrPtr = (TkSelRetrievalInfo *)clientData;
/*
* Make sure that the retrieval is still in progress. Then see how long
@@ -796,7 +796,7 @@ ConvertSelection(
* request; may not be selection's current
* owner, be we set it to the current
* owner. */
- register XSelectionRequestEvent *eventPtr)
+ XSelectionRequestEvent *eventPtr)
/* Event describing request. */
{
union {
@@ -813,11 +813,11 @@ ConvertSelection(
Tk_ErrorHandler errorHandler;
TkSelectionInfo *infoPtr;
TkSelInProgress ip;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- errorHandler = Tk_CreateErrorHandler(eventPtr->display, -1, -1,-1,
- (int (*)()) NULL, NULL);
+ errorHandler = Tk_CreateErrorHandler(eventPtr->display, -1, -1,
+ -1, NULL, NULL);
/*
* Initialize the reply event.
@@ -893,12 +893,12 @@ ConvertSelection(
* below).
*/
- incr.converts = ckalloc(incr.numConversions * sizeof(ConvertInfo));
+ incr.converts = (ConvertInfo *)ckalloc(incr.numConversions * sizeof(ConvertInfo));
incr.numIncrs = 0;
for (i = 0; i < incr.numConversions; i++) {
Atom target, property, type;
long buffer[TK_SEL_WORDS_AT_ONCE];
- register TkSelHandler *selPtr;
+ TkSelHandler *selPtr;
int numItems, format;
char *propPtr;
@@ -919,7 +919,7 @@ ConvertSelection(
/*
* Nobody seems to know about this kind of request. If it's of a
* sort that we can handle without any help, do it. Otherwise mark
- * the request as an errror.
+ * the request as an error.
*/
numItems = TkSelDefaultSelection(infoPtr, target, (char *) buffer,
@@ -1064,7 +1064,7 @@ ConvertSelection(
}
Tcl_DeleteTimerHandler(incr.timeout);
errorHandler = Tk_CreateErrorHandler(winPtr->display,
- -1, -1, -1, (int (*)()) NULL, NULL);
+ -1, -1, -1, NULL, NULL);
XSelectInput(reply.xsel.display, reply.xsel.requestor, 0L);
Tk_DeleteErrorHandler(errorHandler);
if (tsdPtr->pendingIncrs == &incr) {
@@ -1124,9 +1124,9 @@ ConvertSelection(
static void
SelRcvIncrProc(
ClientData clientData, /* Information about retrieval. */
- register XEvent *eventPtr) /* X PropertyChange event. */
+ XEvent *eventPtr) /* X PropertyChange event. */
{
- register TkSelRetrievalInfo *retrPtr = clientData;
+ TkSelRetrievalInfo *retrPtr = (TkSelRetrievalInfo *)clientData;
char *propInfo, **propInfoPtr = &propInfo;
Atom type;
int format, result;
@@ -1374,7 +1374,7 @@ IncrTimeoutProc(
* retrieval for which we are selection
* owner. */
{
- register IncrInfo *incrPtr = clientData;
+ IncrInfo *incrPtr = (IncrInfo *)clientData;
incrPtr->idleTime++;
if (incrPtr->idleTime >= 5) {
@@ -1435,7 +1435,7 @@ SelCvtToX(
if (Tcl_SplitList(NULL, string, &numFields, &field) != TCL_OK) {
return NULL;
}
- propPtr = ckalloc(numFields * sizeof(long));
+ propPtr = (long *)ckalloc(numFields * sizeof(long));
/*
* Convert the fields one-by-one.
@@ -1487,7 +1487,7 @@ SelCvtToX(
static void
SelCvtFromX32(
- register long *propPtr, /* Property value from X. */
+ long *propPtr, /* Property value from X. */
int numValues, /* Number of 32-bit values in property. */
Atom type, /* Type of property Should not be XA_STRING
* (if so, don't bother calling this function
@@ -1520,7 +1520,7 @@ SelCvtFromX32(
static void
SelCvtFromX8(
- register char *propPtr, /* Property value from X. */
+ char *propPtr, /* Property value from X. */
int numValues, /* Number of 8-bit values in property. */
Atom type, /* Type of property Should not be XA_STRING
* (if so, don't bother calling this function
@@ -1528,6 +1528,9 @@ SelCvtFromX8(
Tk_Window tkwin, /* Window to use for atom conversion. */
Tcl_DString *dsPtr) /* Where to store the converted string. */
{
+ (void)type;
+ (void)tkwin;
+
/*
* Convert each long in the property to a string value, which is a
* hexadecimal string. We build the list in a Tcl_DString because this is
diff --git a/unix/tkUnixSend.c b/unix/tkUnixSend.c
index 0b4f05d..6cf711c 100644
--- a/unix/tkUnixSend.c
+++ b/unix/tkUnixSend.c
@@ -97,7 +97,7 @@ typedef struct PendingCommand {
* NULL means end of list. */
} PendingCommand;
-typedef struct ThreadSpecificData {
+typedef struct {
PendingCommand *pendingCommands;
/* List of all commands currently being waited
* for. */
@@ -269,7 +269,7 @@ RegOpen(
handler = Tk_CreateErrorHandler(dispPtr->display, -1, -1, -1, NULL, NULL);
- regPtr = ckalloc(sizeof(NameRegistry));
+ regPtr = (NameRegistry *)ckalloc(sizeof(NameRegistry));
regPtr->dispPtr = dispPtr;
regPtr->locked = 0;
regPtr->modified = 0;
@@ -479,7 +479,7 @@ RegAddName(
sprintf(id, "%x ", (unsigned) commWindow);
idLength = strlen(id);
newBytes = idLength + strlen(name) + 1;
- newProp = ckalloc(regPtr->propLength + newBytes);
+ newProp = (char *)ckalloc(regPtr->propLength + newBytes);
strcpy(newProp, id);
strcpy(newProp+idLength, name);
if (regPtr->property != NULL) {
@@ -808,7 +808,7 @@ Tk_SetAppName(
const char *actualName;
Tcl_DString dString;
int offset, i;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
interp = winPtr->mainPtr->interp;
@@ -830,7 +830,7 @@ Tk_SetAppName(
* the "send" command to the interpreter.
*/
- riPtr = ckalloc(sizeof(RegisteredInterp));
+ riPtr = (RegisteredInterp *)ckalloc(sizeof(RegisteredInterp));
riPtr->interp = interp;
riPtr->dispPtr = winPtr->dispPtr;
riPtr->nextPtr = tsdPtr->interpListPtr;
@@ -914,7 +914,7 @@ Tk_SetAppName(
RegAddName(regPtr, actualName, Tk_WindowId(dispPtr->commTkwin));
RegClose(regPtr);
- riPtr->name = ckalloc(strlen(actualName) + 1);
+ riPtr->name = (char *)ckalloc(strlen(actualName) + 1);
strcpy(riPtr->name, actualName);
if (actualName != name) {
Tcl_DStringFree(&dString);
@@ -943,7 +943,7 @@ Tk_SetAppName(
int
Tk_SendObjCmd(
- ClientData clientData, /* Information about sender (only dispPtr
+ ClientData dummy, /* Information about sender (only dispPtr
* field is used). */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
@@ -958,7 +958,7 @@ Tk_SendObjCmd(
TkWindow *winPtr;
Window commWindow;
PendingCommand pending;
- register RegisteredInterp *riPtr;
+ RegisteredInterp *riPtr;
const char *destName;
int result, index, async, i, firstArg;
Tk_RestrictProc *prevProc;
@@ -967,10 +967,11 @@ Tk_SendObjCmd(
Tcl_Time timeout;
NameRegistry *regPtr;
Tcl_DString request;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_Interp *localInterp; /* Used when the interpreter to send the
* command to is within the same process. */
+ (void)dummy;
/*
* Process options, if any.
@@ -1175,7 +1176,7 @@ Tk_SendObjCmd(
msg = "target application died";
}
pending.code = TCL_ERROR;
- pending.result = ckalloc(strlen(msg) + 1);
+ pending.result = (char *)ckalloc(strlen(msg) + 1);
strcpy(pending.result, msg);
pending.gotResponse = 1;
} else {
@@ -1356,12 +1357,13 @@ TkSendCleanup(
static int
SendInit(
- Tcl_Interp *interp, /* Interpreter to use for error reporting (no
+ Tcl_Interp *dummy, /* Interpreter to use for error reporting (no
* errors are ever returned, but the
* interpreter is needed anyway). */
TkDisplay *dispPtr) /* Display to initialize. */
{
XSetWindowAttributes atts;
+ (void)dummy;
/*
* Create the window used for communication, and set up an event handler
@@ -1419,14 +1421,14 @@ SendEventProc(
ClientData clientData, /* Display information. */
XEvent *eventPtr) /* Information about event. */
{
- TkDisplay *dispPtr = clientData;
+ TkDisplay *dispPtr = (TkDisplay *)clientData;
char *propInfo, **propInfoPtr = &propInfo;
const char *p;
int result, actualFormat;
unsigned long numItems, bytesAfter;
Atom actualType;
Tcl_Interp *remoteInterp; /* Interp in which to execute the command. */
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if ((eventPtr->xproperty.atom != dispPtr->commProperty)
@@ -1698,16 +1700,16 @@ SendEventProc(
}
pcPtr->code = code;
if (resultString != NULL) {
- pcPtr->result = ckalloc(strlen(resultString) + 1);
+ pcPtr->result = (char *)ckalloc(strlen(resultString) + 1);
strcpy(pcPtr->result, resultString);
}
if (code == TCL_ERROR) {
if (errorInfo != NULL) {
- pcPtr->errorInfo = ckalloc(strlen(errorInfo) + 1);
+ pcPtr->errorInfo = (char *)ckalloc(strlen(errorInfo) + 1);
strcpy(pcPtr->errorInfo, errorInfo);
}
if (errorCode != NULL) {
- pcPtr->errorCode = ckalloc(strlen(errorCode) + 1);
+ pcPtr->errorCode = (char *)ckalloc(strlen(errorCode) + 1);
strcpy(pcPtr->errorCode, errorCode);
}
}
@@ -1774,16 +1776,16 @@ AppendPropCarefully(
* operation above.
*/
- /* ARGSUSED */
static int
AppendErrorProc(
ClientData clientData, /* Command to mark complete, or NULL. */
XErrorEvent *errorPtr) /* Information about error. */
{
- PendingCommand *pendingPtr = clientData;
- register PendingCommand *pcPtr;
- ThreadSpecificData *tsdPtr =
+ PendingCommand *pendingPtr = (PendingCommand *)clientData;
+ PendingCommand *pcPtr;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)errorPtr;
if (pendingPtr == NULL) {
return 0;
@@ -1796,7 +1798,7 @@ AppendErrorProc(
for (pcPtr = tsdPtr->pendingCommands; pcPtr != NULL;
pcPtr = pcPtr->nextPtr) {
if ((pcPtr == pendingPtr) && (pcPtr->result == NULL)) {
- pcPtr->result = ckalloc(strlen(pcPtr->target) + 50);
+ pcPtr->result = (char *)ckalloc(strlen(pcPtr->target) + 50);
sprintf(pcPtr->result, "no application named \"%s\"",
pcPtr->target);
pcPtr->code = TCL_ERROR;
@@ -1829,10 +1831,10 @@ DeleteProc(
ClientData clientData) /* Info about registration, passed as
* ClientData. */
{
- RegisteredInterp *riPtr = clientData;
- register RegisteredInterp *riPtr2;
+ RegisteredInterp *riPtr = (RegisteredInterp *)clientData;
+ RegisteredInterp *riPtr2;
NameRegistry *regPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
regPtr = RegOpen(riPtr->interp, riPtr->dispPtr, 1);
@@ -1874,13 +1876,13 @@ DeleteProc(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static Tk_RestrictAction
SendRestrictProc(
- ClientData clientData, /* Not used. */
- register XEvent *eventPtr) /* Event that just arrived. */
+ ClientData dummy, /* Not used. */
+ XEvent *eventPtr) /* Event that just arrived. */
{
TkDisplay *dispPtr;
+ (void)dummy;
if (eventPtr->type != PropertyNotify) {
return TK_DEFER_EVENT;
@@ -1921,7 +1923,7 @@ UpdateCommWindow(
{
Tcl_DString names;
RegisteredInterp *riPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_DStringInit(&names);
@@ -1954,7 +1956,6 @@ UpdateCommWindow(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
TkpTestsendCmd(
ClientData clientData, /* Main window for application. */
@@ -1968,7 +1969,7 @@ TkpTestsendCmd(
static const char *const testsendOptions[] = {
"bogus", "prop", "serial", NULL
};
- TkWindow *winPtr = clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
Tk_ErrorHandler handler;
int index;
@@ -2052,7 +2053,7 @@ TkpTestsendCmd(
Tcl_DStringFree(&tmp);
}
} else if (index == TESTSEND_SERIAL) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(localData.sendSerial+1));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(localData.sendSerial+1));
}
return TCL_OK;
}
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index f548bcd..155a988 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.c
@@ -36,7 +36,7 @@ typedef struct ProtocolHandler {
} ProtocolHandler;
#define HANDLER_SIZE(cmdLength) \
- (Tk_Offset(ProtocolHandler, command) + 1 + cmdLength)
+ (offsetof(ProtocolHandler, command) + 1 + cmdLength)
/*
* Data for [wm attributes] command:
@@ -564,10 +564,10 @@ void
TkWmNewWindow(
TkWindow *winPtr) /* Newly-created top-level window. */
{
- register WmInfo *wmPtr;
+ WmInfo *wmPtr;
TkDisplay *dispPtr = winPtr->dispPtr;
- wmPtr = ckalloc(sizeof(WmInfo));
+ wmPtr = (WmInfo *)ckalloc(sizeof(WmInfo));
memset(wmPtr, 0, sizeof(WmInfo));
wmPtr->winPtr = winPtr;
wmPtr->reparent = None;
@@ -659,7 +659,7 @@ TkWmMapWindow(
TkWindow *winPtr) /* Top-level window that's about to be
* mapped. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
XTextProperty textProp;
if (wmPtr->flags & WM_NEVER_MAPPED) {
@@ -827,7 +827,7 @@ void
TkWmDeadWindow(
TkWindow *winPtr) /* Top-level window that's being deleted. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
WmInfo *wmPtr2;
if (wmPtr == NULL) {
@@ -836,7 +836,7 @@ TkWmDeadWindow(
if ((WmInfo *) winPtr->dispPtr->firstWmPtr == wmPtr) {
winPtr->dispPtr->firstWmPtr = wmPtr->nextPtr;
} else {
- register WmInfo *prevPtr;
+ WmInfo *prevPtr;
for (prevPtr = (WmInfo *) winPtr->dispPtr->firstWmPtr; ;
prevPtr = prevPtr->nextPtr) {
@@ -980,18 +980,18 @@ TkWmSetClass(
if (winPtr->classUid != NULL) {
XClassHint *classPtr;
- Tcl_DString name, class;
+ Tcl_DString name, ds;
Tcl_UtfToExternalDString(NULL, winPtr->nameUid, -1, &name);
- Tcl_UtfToExternalDString(NULL, winPtr->classUid, -1, &class);
+ Tcl_UtfToExternalDString(NULL, winPtr->classUid, -1, &ds);
classPtr = XAllocClassHint();
classPtr->res_name = Tcl_DStringValue(&name);
- classPtr->res_class = Tcl_DStringValue(&class);
+ classPtr->res_class = Tcl_DStringValue(&ds);
XSetClassHint(winPtr->display, winPtr->wmInfoPtr->wrapperPtr->window,
classPtr);
XFree((char *) classPtr);
Tcl_DStringFree(&name);
- Tcl_DStringFree(&class);
+ Tcl_DStringFree(&ds);
}
}
@@ -1005,7 +1005,6 @@ TkWmSetClass(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
Tk_WmObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
@@ -1013,7 +1012,7 @@ Tk_WmObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
static const char *const optionStrings[] = {
"aspect", "attributes", "client", "colormapwindows",
"command", "deiconify", "focusmodel", "forget",
@@ -1055,8 +1054,8 @@ Tk_WmObjCmd(
return TCL_ERROR;
}
if (objc == 2) {
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
- dispPtr->flags & TK_DISPLAY_WM_TRACING));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
+ (dispPtr->flags & TK_DISPLAY_WM_TRACING) != 0));
return TCL_OK;
}
if (Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing) != TCL_OK) {
@@ -1188,8 +1187,9 @@ WmAspectCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int numer1, denom1, numer2, denom2;
+ (void)tkwin;
if ((objc != 3) && (objc != 7)) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -1200,10 +1200,10 @@ WmAspectCmd(
if (wmPtr->sizeHintsFlags & PAspect) {
Tcl_Obj *results[4];
- results[0] = Tcl_NewIntObj(wmPtr->minAspect.x);
- results[1] = Tcl_NewIntObj(wmPtr->minAspect.y);
- results[2] = Tcl_NewIntObj(wmPtr->maxAspect.x);
- results[3] = Tcl_NewIntObj(wmPtr->maxAspect.y);
+ results[0] = Tcl_NewWideIntObj(wmPtr->minAspect.x);
+ results[1] = Tcl_NewWideIntObj(wmPtr->minAspect.y);
+ results[2] = Tcl_NewWideIntObj(wmPtr->maxAspect.x);
+ results[3] = Tcl_NewWideIntObj(wmPtr->maxAspect.y);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
@@ -1315,7 +1315,7 @@ WmSetAttribute(
SetNetWmState(winPtr, "_NET_WM_STATE_FULLSCREEN",
wmPtr->reqState.fullscreen);
break;
- case _WMATT_LAST_ATTRIBUTE: /* NOTREACHED */
+ case _WMATT_LAST_ATTRIBUTE:
return TCL_ERROR;
}
return TCL_OK;
@@ -1345,17 +1345,16 @@ WmGetAttribute(
case WMATT_ALPHA:
return Tcl_NewDoubleObj(wmPtr->attributes.alpha);
case WMATT_TOPMOST:
- return Tcl_NewBooleanObj(wmPtr->attributes.topmost);
+ return Tcl_NewWideIntObj(wmPtr->attributes.topmost != 0);
case WMATT_ZOOMED:
- return Tcl_NewBooleanObj(wmPtr->attributes.zoomed);
+ return Tcl_NewWideIntObj(wmPtr->attributes.zoomed != 0);
case WMATT_FULLSCREEN:
- return Tcl_NewBooleanObj(wmPtr->attributes.fullscreen);
+ return Tcl_NewWideIntObj(wmPtr->attributes.fullscreen != 0);
case WMATT_TYPE:
return GetNetWmType(winPtr);
- case _WMATT_LAST_ATTRIBUTE: /*NOTREACHED*/
+ case _WMATT_LAST_ATTRIBUTE:
break;
}
- /*NOTREACHED*/
return NULL;
}
@@ -1392,6 +1391,7 @@ WmAttributesCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
int attribute = 0;
+ (void)tkwin;
if (objc == 3) { /* wm attributes $win */
Tcl_Obj *result = Tcl_NewListObj(0,0);
@@ -1400,7 +1400,7 @@ WmAttributesCmd(
Tcl_ListObjAppendElement(interp, result,
Tcl_NewStringObj(WmAttributeNames[attribute], -1));
Tcl_ListObjAppendElement(interp, result,
- WmGetAttribute(winPtr, attribute));
+ WmGetAttribute(winPtr, (WmAttribute)attribute));
}
Tcl_SetObjResult(interp, result);
return TCL_OK;
@@ -1409,7 +1409,7 @@ WmAttributesCmd(
sizeof(char *), "attribute", 0, &attribute) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, WmGetAttribute(winPtr, attribute));
+ Tcl_SetObjResult(interp, WmGetAttribute(winPtr, (WmAttribute)attribute));
return TCL_OK;
} else if ((objc - 3) % 2 == 0) { /* wm attributes $win -att value... */
int i;
@@ -1419,7 +1419,7 @@ WmAttributesCmd(
sizeof(char *), "attribute", 0, &attribute) != TCL_OK) {
return TCL_ERROR;
}
- if (WmSetAttribute(winPtr,interp,attribute,objv[i+1]) != TCL_OK) {
+ if (WmSetAttribute(winPtr,interp,(WmAttribute)attribute,objv[i+1]) != TCL_OK) {
return TCL_ERROR;
}
}
@@ -1455,8 +1455,9 @@ WmClientCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?name?");
@@ -1485,7 +1486,7 @@ WmClientCmd(
if (wmPtr->clientMachine != NULL) {
ckfree(wmPtr->clientMachine);
}
- wmPtr->clientMachine = ckalloc(objv[3]->length + 1);
+ wmPtr->clientMachine = (char *)ckalloc(objv[3]->length + 1);
strcpy(wmPtr->clientMachine, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XTextProperty textProp;
@@ -1540,7 +1541,7 @@ WmColormapwindowsCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Window *cmapList;
TkWindow *winPtr2;
int count, i, windowObjc, gotToplevel;
@@ -1583,7 +1584,7 @@ WmColormapwindowsCmd(
!= TCL_OK) {
return TCL_ERROR;
}
- cmapList = ckalloc((windowObjc+1) * sizeof(Window));
+ cmapList = (Window *)ckalloc((windowObjc+1) * sizeof(Window));
gotToplevel = 0;
for (i = 0; i < windowObjc; i++) {
Tk_Window mapWin;
@@ -1641,10 +1642,11 @@ WmCommandCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
int cmdArgc;
const char **cmdArgv;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?value?");
@@ -1710,7 +1712,8 @@ WmDeiconifyCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)tkwin;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -1760,12 +1763,13 @@ WmFocusmodelCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"active", "passive", NULL };
enum options {
OPT_ACTIVE, OPT_PASSIVE };
int index;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?");
@@ -1815,7 +1819,11 @@ WmForgetCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Tk_Window frameWin = (Tk_Window) winPtr;
+ Tk_Window frameWin = (Tk_Window) winPtr;
+ (void)tkwin;
+ (void)interp;
+ (void)objc;
+ (void)objv;
if (Tk_IsTopLevel(frameWin)) {
TkFocusJoin(winPtr);
@@ -1868,8 +1876,10 @@ WmFrameCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Window window;
+ char buf[TCL_INTEGER_SPACE];
+ (void)tkwin;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -1879,7 +1889,8 @@ WmFrameCmd(
if (window == None) {
window = Tk_WindowId((Tk_Window) winPtr);
}
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%x", (unsigned) window));
+ sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)window);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1));
return TCL_OK;
}
@@ -1908,10 +1919,11 @@ WmGeometryCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
char xSign, ySign;
int width, height;
const char *argv3;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?");
@@ -1968,8 +1980,9 @@ WmGridCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int reqWidth, reqHeight, widthInc, heightInc;
+ (void)tkwin;
if ((objc != 3) && (objc != 7)) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -1980,10 +1993,10 @@ WmGridCmd(
if (wmPtr->sizeHintsFlags & PBaseSize) {
Tcl_Obj *results[4];
- results[0] = Tcl_NewIntObj(wmPtr->reqGridWidth);
- results[1] = Tcl_NewIntObj(wmPtr->reqGridHeight);
- results[2] = Tcl_NewIntObj(wmPtr->widthInc);
- results[3] = Tcl_NewIntObj(wmPtr->heightInc);
+ results[0] = Tcl_NewWideIntObj(wmPtr->reqGridWidth);
+ results[1] = Tcl_NewWideIntObj(wmPtr->reqGridHeight);
+ results[2] = Tcl_NewWideIntObj(wmPtr->widthInc);
+ results[3] = Tcl_NewWideIntObj(wmPtr->heightInc);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
@@ -2067,7 +2080,7 @@ WmGroupCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window tkwin2;
WmInfo *wmPtr2;
const char *argv3;
@@ -2110,7 +2123,7 @@ WmGroupCmd(
}
wmPtr->hints.window_group = Tk_WindowId(wmPtr2->wrapperPtr);
wmPtr->hints.flags |= WindowGroupHint;
- wmPtr->leaderName = ckalloc(objv[3]->length + 1);
+ wmPtr->leaderName = (char *)ckalloc(objv[3]->length + 1);
strcpy(wmPtr->leaderName, argv3);
}
UpdateHints(winPtr);
@@ -2142,9 +2155,10 @@ WmIconbitmapCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Pixmap pixmap;
const char *argv3;
+ (void)tkwin;
if ((objc < 3) || (objc > 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?");
@@ -2202,7 +2216,8 @@ WmIconifyCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)tkwin;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -2271,7 +2286,7 @@ WmIconmaskCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Pixmap pixmap;
const char *argv3;
@@ -2330,8 +2345,9 @@ WmIconnameCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
+ (void)tkwin;
if (objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?");
@@ -2347,7 +2363,7 @@ WmIconnameCmd(
ckfree(wmPtr->iconName);
}
argv3 = Tcl_GetString(objv[3]);
- wmPtr->iconName = ckalloc(objv[3]->length + 1);
+ wmPtr->iconName = (char *)ckalloc(objv[3]->length + 1);
strcpy(wmPtr->iconName, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
UpdateTitle(winPtr);
@@ -2381,11 +2397,12 @@ WmIconphotoCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_PhotoHandle photo;
Tk_PhotoImageBlock block;
int i, size = 0, width, height, index = 0, x, y, isDefault = 0;
unsigned long *iconPropertyData;
+ (void)tkwin;
if (objc < 4) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -2432,7 +2449,7 @@ WmIconphotoCmd(
* defines CARD32 arrays to use. [Bug 2902814]
*/
- iconPropertyData = attemptckalloc(sizeof(unsigned long) * size);
+ iconPropertyData = (unsigned long *)attemptckalloc(sizeof(unsigned long) * size);
if (iconPropertyData == NULL) {
return TCL_ERROR;
}
@@ -2441,7 +2458,11 @@ WmIconphotoCmd(
for (i = 3 + isDefault; i < objc; i++) {
photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i]));
if (photo == NULL) {
- Tcl_Free((char *) iconPropertyData);
+ ckfree((char *) iconPropertyData);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "failed to create an iconphoto with image \"%s\"",
+ Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "IMAGE", NULL);
return TCL_ERROR;
}
Tk_PhotoGetSize(photo, &width, &height);
@@ -2470,9 +2491,9 @@ WmIconphotoCmd(
iconPropertyData[index++] = (unsigned long) height;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
- register unsigned char *pixelPtr =
+ unsigned char *pixelPtr =
block.pixelPtr + x*block.pixelSize + y*block.pitch;
- register unsigned long R, G, B, A;
+ unsigned long R, G, B, A;
R = pixelPtr[block.offset[0]];
G = pixelPtr[block.offset[1]];
@@ -2527,8 +2548,9 @@ WmIconpositionCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y;
+ (void)tkwin;
if ((objc != 3) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?");
@@ -2538,8 +2560,8 @@ WmIconpositionCmd(
if (wmPtr->hints.flags & IconPositionHint) {
Tcl_Obj *results[2];
- results[0] = Tcl_NewIntObj(wmPtr->hints.icon_x);
- results[1] = Tcl_NewIntObj(wmPtr->hints.icon_y);
+ results[0] = Tcl_NewWideIntObj(wmPtr->hints.icon_x);
+ results[1] = Tcl_NewWideIntObj(wmPtr->hints.icon_y);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
}
return TCL_OK;
@@ -2584,7 +2606,7 @@ WmIconwindowCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window tkwin2;
WmInfo *wmPtr2;
XSetWindowAttributes atts;
@@ -2704,8 +2726,11 @@ WmManageCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Tk_Window frameWin = (Tk_Window) winPtr;
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ Tk_Window frameWin = (Tk_Window) winPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)tkwin;
+ (void)objc;
+ (void)objv;
if (!Tk_IsTopLevel(frameWin)) {
if (!Tk_IsManageable(frameWin)) {
@@ -2766,8 +2791,9 @@ WmMaxsizeCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
+ (void)tkwin;
if ((objc != 3) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
@@ -2777,8 +2803,8 @@ WmMaxsizeCmd(
Tcl_Obj *results[2];
GetMaxSize(wmPtr, &width, &height);
- results[0] = Tcl_NewIntObj(width);
- results[1] = Tcl_NewIntObj(height);
+ results[0] = Tcl_NewWideIntObj(width);
+ results[1] = Tcl_NewWideIntObj(height);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
@@ -2825,8 +2851,9 @@ WmMinsizeCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
+ (void)tkwin;
if ((objc != 3) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
@@ -2835,8 +2862,8 @@ WmMinsizeCmd(
if (objc == 3) {
Tcl_Obj *results[2];
- results[0] = Tcl_NewIntObj(wmPtr->minWidth);
- results[1] = Tcl_NewIntObj(wmPtr->minHeight);
+ results[0] = Tcl_NewWideIntObj(wmPtr->minWidth);
+ results[1] = Tcl_NewWideIntObj(wmPtr->minHeight);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
@@ -2878,6 +2905,7 @@ WmOverrideredirectCmd(
{
int boolean, curValue;
XSetWindowAttributes atts;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?");
@@ -2885,7 +2913,7 @@ WmOverrideredirectCmd(
}
curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect;
if (objc == 3) {
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(curValue));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(curValue != 0));
return TCL_OK;
}
if (Tcl_GetBooleanFromObj(interp, objv[3], &boolean) != TCL_OK) {
@@ -2934,12 +2962,13 @@ WmPositionfromCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"program", "user", NULL };
enum options {
OPT_PROGRAM, OPT_USER };
int index;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?");
@@ -3001,11 +3030,12 @@ WmProtocolCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- register ProtocolHandler *protPtr, *prevPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ ProtocolHandler *protPtr, *prevPtr;
Atom protocol;
const char *cmd;
- size_t cmdLength;
+ TkSizeT cmdLength;
+ (void)tkwin;
if ((objc < 3) || (objc > 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?");
@@ -3073,7 +3103,7 @@ WmProtocolCmd(
}
cmd = TkGetStringFromObj(objv[4], &cmdLength);
if (cmdLength > 0) {
- protPtr = ckalloc(HANDLER_SIZE(cmdLength));
+ protPtr = (ProtocolHandler *)ckalloc(HANDLER_SIZE(cmdLength));
protPtr->protocol = protocol;
protPtr->nextPtr = wmPtr->protPtr;
wmPtr->protPtr = protPtr;
@@ -3111,8 +3141,9 @@ WmResizableCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
+ (void)tkwin;
if ((objc != 3) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
@@ -3121,8 +3152,8 @@ WmResizableCmd(
if (objc == 3) {
Tcl_Obj *results[2];
- results[0] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_WIDTH_NOT_RESIZABLE));
- results[1] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_HEIGHT_NOT_RESIZABLE));
+ results[0] = Tcl_NewWideIntObj(!(wmPtr->flags&WM_WIDTH_NOT_RESIZABLE));
+ results[1] = Tcl_NewWideIntObj(!(wmPtr->flags&WM_HEIGHT_NOT_RESIZABLE));
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
@@ -3170,12 +3201,13 @@ WmSizefromCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"program", "user", NULL };
enum options {
OPT_PROGRAM, OPT_USER };
int index;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?");
@@ -3263,6 +3295,8 @@ WmStackorderCmd(
ckfree(windows);
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
+ } else {
+ return TCL_ERROR;
}
} else {
Tk_Window relWin;
@@ -3329,7 +3363,7 @@ WmStackorderCmd(
} else { /* OPT_ISBELOW */
result = index1 < index2;
}
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(result));
return TCL_OK;
}
return TCL_OK;
@@ -3360,12 +3394,13 @@ WmStateCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"normal", "iconic", "withdrawn", NULL };
enum options {
OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN };
int index;
+ (void)tkwin;
if ((objc < 3) || (objc > 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?state?");
@@ -3466,8 +3501,9 @@ WmTitleCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
+ (void)tkwin;
if (objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?");
@@ -3484,7 +3520,7 @@ WmTitleCmd(
ckfree(wmPtr->title);
}
argv3 = Tcl_GetString(objv[3]);
- wmPtr->title = ckalloc(objv[3]->length + 1);
+ wmPtr->title = (char *)ckalloc(objv[3]->length + 1);
strcpy(wmPtr->title, argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
@@ -3519,7 +3555,7 @@ WmTransientCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
TkWindow *masterPtr = wmPtr->masterPtr, *w;
WmInfo *wmPtr2;
@@ -3668,7 +3704,8 @@ WmWithdrawCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)tkwin;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -3717,7 +3754,7 @@ WmWaitMapProc(
ClientData clientData, /* Pointer to window. */
XEvent *eventPtr) /* Information about event. */
{
- TkWindow *winPtr = clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
TkWindow *masterPtr = winPtr->wmInfoPtr->masterPtr;
if (masterPtr == NULL) {
@@ -3768,7 +3805,7 @@ Tk_SetGrid(
* of one grid unit. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- register WmInfo *wmPtr;
+ WmInfo *wmPtr;
/*
* Ensure widthInc and heightInc are greater than 0
@@ -3873,7 +3910,7 @@ Tk_UnsetGrid(
* controlling gridding. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- register WmInfo *wmPtr;
+ WmInfo *wmPtr;
/*
* Find the top-level window for tkwin, plus the window manager
@@ -4406,7 +4443,7 @@ WrapperEventProc(
ClientData clientData, /* Information about toplevel window. */
XEvent *eventPtr) /* Event that just happened. */
{
- WmInfo *wmPtr = clientData;
+ WmInfo *wmPtr = (WmInfo *)clientData;
XEvent mapEvent;
TkDisplay *dispPtr = wmPtr->winPtr->dispPtr;
@@ -4486,7 +4523,6 @@ WrapperEventProc(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static void
TopLevelReqProc(
ClientData dummy, /* Not used. */
@@ -4494,6 +4530,7 @@ TopLevelReqProc(
{
TkWindow *winPtr = (TkWindow *) tkwin;
WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)dummy;
if (wmPtr == NULL) {
return;
@@ -4556,8 +4593,8 @@ static void
UpdateGeometryInfo(
ClientData clientData) /* Pointer to the window's record. */
{
- register TkWindow *winPtr = clientData;
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ TkWindow *winPtr = (TkWindow *)clientData;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y, width, height, min, max;
unsigned long serial;
@@ -4818,7 +4855,7 @@ UpdateSizeHints(
int newWidth,
int newHeight)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
XSizeHints *hintsPtr;
int maxWidth, maxHeight;
@@ -5295,7 +5332,7 @@ WaitRestrictProc(
ClientData clientData, /* Pointer to WaitRestrictInfo structure. */
XEvent *eventPtr) /* Event that is about to be handled. */
{
- WaitRestrictInfo *infoPtr = clientData;
+ WaitRestrictInfo *infoPtr = (WaitRestrictInfo *)clientData;
if (eventPtr->type == ReparentNotify) {
return TK_PROCESS_EVENT;
@@ -5451,12 +5488,12 @@ SetNetWmType(
}
if (objc > 0) {
- atoms = ckalloc(sizeof(Atom) * objc);
+ atoms = (Atom *)ckalloc(sizeof(Atom) * objc);
}
for (n = 0; n < objc; ++n) {
Tcl_DString ds, dsName;
- size_t len;
+ TkSizeT len;
char *name = TkGetStringFromObj(objv[n], &len);
Tcl_UtfToUpper(name);
@@ -5564,10 +5601,10 @@ ParseGeometry(
TkWindow *winPtr) /* Pointer to top-level window whose geometry
* is to be changed. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y, width, height, flags;
char *end;
- register const char *p = string;
+ const char *p = string;
/*
* The leading "=" is optional.
@@ -5700,7 +5737,7 @@ Tk_GetRootCoords(
int *yPtr) /* Where to store y-displacement of (0,0). */
{
int x, y;
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
/*
* Search back through this window's parents all the way to a top-level
@@ -6167,7 +6204,7 @@ Tk_MoveToplevelWindow(
int x, int y) /* New location for window (within parent). */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (!(winPtr->flags & TK_TOP_LEVEL)) {
Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window");
@@ -6215,9 +6252,9 @@ Tk_MoveToplevelWindow(
static void
UpdateWmProtocols(
- register WmInfo *wmPtr) /* Information about top-level window. */
+ WmInfo *wmPtr) /* Information about top-level window. */
{
- register ProtocolHandler *protPtr;
+ ProtocolHandler *protPtr;
Atom deleteWindowAtom, pingAtom;
int count;
Atom *arrayPtr, *atomPtr;
@@ -6234,7 +6271,7 @@ UpdateWmProtocols(
protPtr = protPtr->nextPtr, count++) {
/* Empty loop body; we're just counting the handlers. */
}
- arrayPtr = ckalloc(count * sizeof(Atom));
+ arrayPtr = (Atom *)ckalloc(count * sizeof(Atom));
deleteWindowAtom = Tk_InternAtom((Tk_Window) wmPtr->winPtr,
"WM_DELETE_WINDOW");
pingAtom = Tk_InternAtom((Tk_Window) wmPtr->winPtr, "_NET_WM_PING");
@@ -6276,7 +6313,7 @@ TkWmProtocolEventProc(
XEvent *eventPtr) /* X event. */
{
WmInfo *wmPtr;
- register ProtocolHandler *protPtr;
+ ProtocolHandler *protPtr;
Atom protocol;
int result;
const char *protocolName;
@@ -6425,7 +6462,10 @@ TkWmStackorderToplevel(
Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS);
TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table);
- window_ptr = windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *));
+ window_ptr = windows = (TkWindow **)ckalloc((table.numEntries+1) * sizeof(TkWindow *));
+ if (windows == NULL) {
+ return NULL;
+ }
/*
* Special cases: If zero or one toplevels were mapped there is no need to
@@ -6438,7 +6478,7 @@ TkWmStackorderToplevel(
goto done;
case 1:
hPtr = Tcl_FirstHashEntry(&table, &search);
- windows[0] = Tcl_GetHashValue(hPtr);
+ windows[0] = (TkWindow *)Tcl_GetHashValue(hPtr);
windows[1] = NULL;
goto done;
}
@@ -6456,7 +6496,7 @@ TkWmStackorderToplevel(
for (i = 0; i < numChildren; i++) {
hPtr = Tcl_FindHashEntry(&table, children[i]);
if (hPtr != NULL) {
- childWinPtr = Tcl_GetHashValue(hPtr);
+ childWinPtr = (TkWindow *)Tcl_GetHashValue(hPtr);
*window_ptr++ = childWinPtr;
}
}
@@ -6629,7 +6669,7 @@ TkWmAddToColormapWindows(
* add the toplevel itself as the last element of the list.
*/
- newPtr = ckalloc((count+2) * sizeof(Window));
+ newPtr = (Window *)ckalloc((count+2) * sizeof(Window));
for (i = 0; i < count; i++) {
newPtr[i] = oldPtr[i];
}
@@ -6864,7 +6904,7 @@ GetMaxSize(
static void
TkSetTransientFor(Tk_Window tkwin, Tk_Window parent)
{
- if (parent == None) {
+ if (parent == NULL) {
parent = Tk_Parent(tkwin);
while (!Tk_IsTopLevel(parent))
parent = Tk_Parent(parent);
@@ -6982,7 +7022,7 @@ CreateWrapper(
TkWindow *winPtr, *wrapperPtr;
Window parent;
Tcl_HashEntry *hPtr;
- int new;
+ int isNew;
winPtr = wmPtr->winPtr;
if (winPtr->window == None) {
@@ -7026,7 +7066,7 @@ CreateWrapper(
InputOutput, wrapperPtr->visual,
wrapperPtr->dirtyAtts|CWOverrideRedirect, &wrapperPtr->atts);
hPtr = Tcl_CreateHashEntry(&wrapperPtr->dispPtr->winTable,
- (char *) wrapperPtr->window, &new);
+ (char *) wrapperPtr->window, &isNew);
Tcl_SetHashValue(hPtr, wrapperPtr);
wrapperPtr->mainPtr = winPtr->mainPtr;
wrapperPtr->mainPtr->refCount++;
@@ -7245,7 +7285,7 @@ MenubarReqProc(
* for tkwin's toplevel. */
Tk_Window tkwin) /* Handle for menubar window. */
{
- WmInfo *wmPtr = clientData;
+ WmInfo *wmPtr = (WmInfo *)clientData;
wmPtr->menuHeight = Tk_ReqHeight(tkwin);
if (wmPtr->menuHeight <= 0) {
@@ -7280,7 +7320,7 @@ TkWindow *
TkpGetWrapperWindow(
TkWindow *winPtr) /* A toplevel window pointer. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if ((winPtr == NULL) || (wmPtr == NULL)) {
return NULL;
@@ -7310,7 +7350,7 @@ static void
UpdateCommand(
TkWindow *winPtr)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Tcl_DString cmds, ds;
int i, *offsets;
char **cmdArgv;
@@ -7327,8 +7367,8 @@ UpdateCommand(
* entire DString is done.
*/
- cmdArgv = ckalloc(sizeof(char *) * wmPtr->cmdArgc);
- offsets = ckalloc(sizeof(int) * wmPtr->cmdArgc);
+ cmdArgv = (char **)ckalloc(sizeof(char *) * wmPtr->cmdArgc);
+ offsets = (int *)ckalloc(sizeof(int) * wmPtr->cmdArgc);
Tcl_DStringInit(&cmds);
for (i = 0; i < wmPtr->cmdArgc; i++) {
Tcl_UtfToExternalDString(NULL, wmPtr->cmdArgv[i], -1, &ds);
diff --git a/win/Makefile.in b/win/Makefile.in
index f035219..82baeb2 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -1,26 +1,24 @@
-# This file is a Makefile for Tk. If it has the name "Makefile.in"
-# then it is a template for a Makefile; to generate the actual Makefile,
-# run "./configure", which is a configuration script generated by the
-# "autoconf" program (constructs like "@foo@" will get replaced in the
-# actual Makefile.
+#
+# This file is a Makefile for Tk. If it has the name "Makefile.in" then it
+# is a template for a Makefile; to generate the actual Makefile, run
+# "./configure", which is a configuration script generated by the "autoconf"
+# program (constructs like "@foo@" will get replaced in the actual Makefile.
TCLVERSION = @TCL_VERSION@
TCLPATCHL = @TCL_PATCH_LEVEL@
VERSION = @TK_VERSION@
PATCH_LEVEL = @TK_PATCH_LEVEL@
-#----------------------------------------------------------------
-# Things you can change to personalize the Makefile for your own
-# site (you can make these changes in either Makefile.in or
-# Makefile, but changes to Makefile will get lost if you re-run
-# the configuration script).
-#----------------------------------------------------------------
+#--------------------------------------------------------------------------
+# Things you can change to personalize the Makefile for your own site (you can
+# make these changes in either Makefile.in or Makefile, but changes to
+# Makefile will get lost if you re-run the configuration script).
+#--------------------------------------------------------------------------
-# Default top-level directories in which to install architecture-
-# specific files (exec_prefix) and machine-independent files such
-# as scripts (prefix). The values specified here may be overridden
-# at configure-time with the --exec-prefix and --prefix options
-# to the "configure" script.
+# Default top-level directories in which to install architecture-specific
+# files (exec_prefix) and machine-independent files such as scripts (prefix).
+# The values specified here may be overridden at configure-time with the
+# --exec-prefix and --prefix options to the "configure" script.
prefix = @prefix@
exec_prefix = @exec_prefix@
@@ -28,19 +26,19 @@ bindir = @bindir@
libdir = @libdir@
includedir = @includedir@
datarootdir = @datarootdir@
+runstatedir = @runstatedir@
mandir = @mandir@
-# The following definition can be set to non-null for special systems
-# like AFS with replication. It allows the pathnames used for installation
-# to be different than those used for actually reference files at
-# run-time. INSTALL_ROOT is prepended to $prefix and $exec_prefix
-# when installing files.
-INSTALL_ROOT =
+# The following definition can be set to non-null for special systems like AFS
+# with replication. It allows the pathnames used for installation to be
+# different than those used for actually reference files at run-time.
+# INSTALL_ROOT is prepended to $prefix and $exec_prefix when installing files.
+INSTALL_ROOT =
-# Directory from which applications will reference the library of Tk
-# scripts (note: you can set the TK_LIBRARY environment variable at
-# run-time to override this value):
-TK_LIBRARY = $(prefix)/lib/tk$(VERSION)
+# Directory from which applications will reference the library of Tk scripts
+# (note: you can set the TK_LIBRARY environment variable at run-time to
+# override this value):
+TK_LIBRARY = $(prefix)/lib/tk$(VERSION)
# Path to use at runtime to refer to LIB_INSTALL_DIR:
LIB_RUNTIME_DIR = $(libdir)
@@ -60,22 +58,21 @@ INCLUDE_INSTALL_DIR = $(INSTALL_ROOT)$(includedir)
# Directory in which to (optionally) install the private tk headers:
PRIVATE_INCLUDE_INSTALL_DIR = $(INSTALL_ROOT)$(includedir)
-# Top-level directory for manual entries:
+# Top-level directory in which to install manual entries:
MAN_INSTALL_DIR = $(INSTALL_ROOT)$(mandir)
# Directory in which to install manual entry for wish:
-MAN1_INSTALL_DIR = $(MAN_INSTALL_DIR)/man1
+MAN1_INSTALL_DIR = $(MAN_INSTALL_DIR)/man1
# Directory in which to install manual entries for Tk's C library
# procedures:
-MAN3_INSTALL_DIR = $(MAN_INSTALL_DIR)/man3
+MAN3_INSTALL_DIR = $(MAN_INSTALL_DIR)/man3
-# Directory in which to install manual entries for the built-in
-# Tk commands:
-MANN_INSTALL_DIR = $(MAN_INSTALL_DIR)/mann
+# Directory in which to install manual entries for the built-in Tk commands:
+MANN_INSTALL_DIR = $(MAN_INSTALL_DIR)/mann
# Libraries built with optimization switches have this additional extension
-TK_DBGX = @TK_DBGX@
+TK_DBGX = @TK_DBGX@
# Directory in which to install the pkgIndex.tcl file for loadable Tk
PKG_INSTALL_DIR = $(LIB_INSTALL_DIR)/tk$(VERSION)$(TK_DBGX)
@@ -101,6 +98,17 @@ TCL_PLATFORM_DIR = @TCL_SRC_DIR@/win
TCL_TOOL_DIR = @TCL_SRC_DIR@/tools
+SRC_DIR = @srcdir@
+ROOT_DIR = @srcdir@/..
+TOP_DIR = $(shell cd @srcdir@/..; pwd -W 2>/dev/null || pwd -P)
+WIN_DIR = $(TOP_DIR)/win
+UNIX_DIR = $(TOP_DIR)/unix
+GENERIC_DIR = $(TOP_DIR)/generic
+TTK_DIR = $(GENERIC_DIR)/ttk
+BITMAP_DIR = $(TOP_DIR)/bitmaps
+XLIB_DIR = $(TOP_DIR)/xlib
+RC_DIR = $(WIN_DIR)/rc
+
# Converts a POSIX path to a Windows native path.
CYGPATH = @CYGPATH@
@@ -108,25 +116,15 @@ CYGPATH = @CYGPATH@
TCL_LIB_FILE = "$(shell $(CYGPATH) '@TCL_BIN_DIR@/@TCL_LIB_FILE@')"
TCL_STUB_LIB_FILE = "$(shell $(CYGPATH) '@TCL_BIN_DIR@/@TCL_STUB_LIB_FILE@')"
-SRC_DIR = @srcdir@
-ROOT_DIR = $(SRC_DIR)/..
-WIN_DIR = $(SRC_DIR)
-UNIX_DIR = $(SRC_DIR)/../unix
-GENERIC_DIR = $(SRC_DIR)/../generic
-TTK_DIR = $(GENERIC_DIR)/ttk
-BITMAP_DIR = $(ROOT_DIR)/bitmaps
-XLIB_DIR = $(ROOT_DIR)/xlib
-RC_DIR = $(WIN_DIR)/rc
-
-ROOT_DIR_NATIVE = $(shell $(CYGPATH) '$(ROOT_DIR)' | sed 's!\\!/!g')
-WIN_DIR_NATIVE = $(shell $(CYGPATH) '$(WIN_DIR)' | sed 's!\\!/!g')
-GENERIC_DIR_NATIVE = $(shell $(CYGPATH) '$(GENERIC_DIR)' | sed 's!\\!/!g')
-BITMAP_DIR_NATIVE = $(ROOT_DIR_NATIVE)/bitmaps
-XLIB_DIR_NATIVE = $(ROOT_DIR_NATIVE)/xlib
-RC_DIR_NATIVE = $(WIN_DIR_NATIVE)/rc
-TCL_GENERIC_NATIVE = $(shell $(CYGPATH) '$(TCL_GENERIC_DIR)' | sed 's!\\!/!g')
-TCL_PLATFORM_NATIVE = $(shell $(CYGPATH) '$(TCL_PLATFORM_DIR)' | sed 's!\\!/!g')
-TCL_SRC_DIR_NATIVE = $(shell $(CYGPATH) '$(TCL_SRC_DIR)' | sed 's!\\!/!g')
+ROOT_DIR_NATIVE = $(shell $(CYGPATH) '$(ROOT_DIR)')
+WIN_DIR_NATIVE = $(shell $(CYGPATH) '$(WIN_DIR)')
+GENERIC_DIR_NATIVE = $(shell $(CYGPATH) '$(GENERIC_DIR)')
+BITMAP_DIR_NATIVE = $(shell $(CYGPATH) '$(ROOT_DIR)/bitmaps')
+XLIB_DIR_NATIVE = $(shell $(CYGPATH) '$(ROOT_DIR)/xlib')
+RC_DIR_NATIVE = $(shell $(CYGPATH) '$(ROOT_DIR)/rc')
+TCL_GENERIC_NATIVE = $(shell $(CYGPATH) '$(TCL_GENERIC_DIR)')
+TCL_PLATFORM_NATIVE = $(shell $(CYGPATH) '$(TCL_PLATFORM_DIR)')
+TCL_SRC_DIR_NATIVE = $(shell $(CYGPATH) '$(TCL_SRC_DIR)')
DLLSUFFIX = @DLLSUFFIX@
LIBSUFFIX = @LIBSUFFIX@
@@ -152,7 +150,7 @@ MAN2TCL = man2tcl$(EXEEXT)
# makefile to look into these paths when resolving .c to .obj
# dependencies.
-VPATH = $(GENERIC_DIR):$(TTK_DIR):$(WIN_DIR):$(UNIX_DIR):$(XLIB_DIR):$(RC_DIR)
+VPATH = $(GENERIC_DIR):$(TTK_DIR):$(WIN_DIR):$(XLIB_DIR):$(RC_DIR)
# warning flags
CFLAGS_WARNING = @CFLAGS_WARNING@
@@ -170,7 +168,7 @@ LDFLAGS_OPTIMIZE = @LDFLAGS_OPTIMIZE@
#CFLAGS = $(CFLAGS_DEBUG)
#CFLAGS = $(CFLAGS_OPTIMIZE)
#CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE)
-CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -DUNICODE -D_UNICODE -D_ATL_XP_TARGETING
+CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -D_ATL_XP_TARGETING
# Special compiler flags to use when building man2tcl on Windows.
MAN2TCLFLAGS = @MAN2TCLFLAGS@
@@ -322,6 +320,7 @@ TK_OBJS = \
tkImgGIF.$(OBJEXT) \
tkImgPNG.$(OBJEXT) \
tkImgPPM.$(OBJEXT) \
+ tkImgSVGnano.$(OBJEXT) \
tkImgPhoto.$(OBJEXT) \
tkImgPhInstance.$(OBJEXT) \
tkImgUtil.$(OBJEXT) \
@@ -338,6 +337,7 @@ TK_OBJS = \
tkOldConfig.$(OBJEXT) \
tkOption.$(OBJEXT) \
tkPack.$(OBJEXT) \
+ tkPkgConfig.$(OBJEXT) \
tkPlace.$(OBJEXT) \
tkPointer.$(OBJEXT) \
tkRectOval.$(OBJEXT) \
@@ -506,10 +506,10 @@ install-binaries: binaries
done
install-libraries: libraries
- @for i in $(INSTALL_ROOT)$(prefix)/lib \
- $(INCLUDE_INSTALL_DIR) $(INCLUDE_INSTALL_DIR)/X11 \
- $(SCRIPT_INSTALL_DIR) $(SCRIPT_INSTALL_DIR)/images \
- $(SCRIPT_INSTALL_DIR)/msgs $(SCRIPT_INSTALL_DIR)/ttk; \
+ @for i in "$$($(CYGPATH) $(prefix)/lib)" \
+ "$(INCLUDE_INSTALL_DIR)" "$(INCLUDE_INSTALL_DIR)/X11" \
+ "$(SCRIPT_INSTALL_DIR)" "$(SCRIPT_INSTALL_DIR)/images" \
+ "$(SCRIPT_INSTALL_DIR)/msgs" "$(SCRIPT_INSTALL_DIR)/ttk"; \
do \
if [ ! -d $$i ] ; then \
echo "Making directory $$i"; \
@@ -519,8 +519,8 @@ install-libraries: libraries
fi; \
done;
@echo "Installing header files to $(INCLUDE_INSTALL_DIR)/";
- @for i in $(GENERIC_DIR)/tk.h $(GENERIC_DIR)/tkPlatDecls.h \
- $(GENERIC_DIR)/tkIntXlibDecls.h $(GENERIC_DIR)/tkDecls.h ; \
+ @for i in "$(GENERIC_DIR)/tk.h" "$(GENERIC_DIR)/tkPlatDecls.h" \
+ "$(GENERIC_DIR)/tkIntXlibDecls.h" "$(GENERIC_DIR)/tkDecls.h" ; \
do \
$(INSTALL_DATA) $$i $(INCLUDE_INSTALL_DIR); \
done;
@@ -606,9 +606,9 @@ install-private-headers: libraries
fi; \
done;
@echo "Installing private header files to $(PRIVATE_INCLUDE_INSTALL_DIR)/";
- @for i in $(GENERIC_DIR)/tkInt.h $(GENERIC_DIR)/tkIntDecls.h \
- $(GENERIC_DIR)/tkIntPlatDecls.h $(GENERIC_DIR)/tkPort.h \
- $(WIN_DIR)/tkWinPort.h $(WIN_DIR)/tkWinInt.h $(WIN_DIR)/tkWin.h; \
+ @for i in "$(GENERIC_DIR)/tkInt.h" "$(GENERIC_DIR)/tkIntDecls.h" \
+ "$(GENERIC_DIR)/tkIntPlatDecls.h" "$(GENERIC_DIR)/tkPort.h" \
+ "$(WIN_DIR)/tkWinPort.h" "$(WIN_DIR)/tkWinInt.h" "$(WIN_DIR)/tkWin.h"; \
do \
$(INSTALL_DATA) $$i $(PRIVATE_INCLUDE_INSTALL_DIR); \
done;
@@ -634,7 +634,7 @@ ${TEST_DLL_FILE}: ${TKTEST_OBJS} ${TK_STUB_LIB_FILE}
$(TCL_SRC_DIR)/win/cat.c:
cat32.${OBJEXT}: $(TCL_SRC_DIR)/win/cat.c
- $(CC) -c $(CC_SWITCHES) "$(TCL_SRC_DIR)/win/cat.c" $(CC_OBJNAME)
+ $(CC) -c $(CC_SWITCHES) -DUNICODE -D_UNICODE "$(TCL_SRC_DIR)/win/cat.c" $(CC_OBJNAME)
$(CAT32): cat32.${OBJEXT}
$(CC) $(CFLAGS) cat32.$(OBJEXT) $(CC_EXENAME) $(LIBS) $(LDFLAGS_CONSOLE)
@@ -660,10 +660,10 @@ ${TK_LIB_FILE}: ${TK_OBJS}
# Special case object file targets
winMain.$(OBJEXT): winMain.c
- $(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
+ $(CC) -c $(CC_SWITCHES) -DUNICODE=1 -D_UNICODE=1 @DEPARG@ $(CC_OBJNAME)
testMain.$(OBJEXT): winMain.c
- $(CC) -c $(CC_SWITCHES) @DEPARG@ -DTK_TEST $(CC_OBJNAME)
+ $(CC) -c $(CC_SWITCHES) -DTK_TEST -DUNICODE=1 -D_UNICODE=1 @DEPARG@ $(CC_OBJNAME)
tkTest.$(OBJEXT): tkTest.c
$(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
@@ -678,11 +678,18 @@ tkSquare.$(OBJEXT): tkSquare.c
$(CC) -c $(CC_SWITCHES) @DEPARG@ $(CC_OBJNAME)
tkMain2.$(OBJEXT): tkMain.c
- $(CC) -c $(CC_SWITCHES) -DBUILD_tk -DTK_ASCII_MAIN @DEPARG@ $(CC_OBJNAME)
+ $(CC) -c $(CC_SWITCHES) -DBUILD_tk -DUNICODE=1 -D_UNICODE=1 @DEPARG@ $(CC_OBJNAME)
+
+tkUnixMenubu.$(OBJEXT): ${UNIX_DIR}/tkUnixMenubu.c
+ $(CC) -c $(CC_SWITCHES) -DBUILD_tk -DBUILD_ttk @DEPARG@ $(CC_OBJNAME)
+
+tkUnixScale.$(OBJEXT): ${UNIX_DIR}/tkUnixScale.c
+ $(CC) -c $(CC_SWITCHES) -DBUILD_tk -DBUILD_ttk @DEPARG@ $(CC_OBJNAME)
# Extra dependency info
tkConsole.$(OBJEXT): configure Makefile
tkMain.$(OBJEXT): configure Makefile
+tkMain2.$(OBJEXT): configure Makefile
tkWindow.$(OBJEXT): configure Makefile
# Add the object extension to the implicit rules. By default .obj is not
diff --git a/win/README b/win/README
index 7f1818e..e371a2c 100644
--- a/win/README
+++ b/win/README
@@ -18,4 +18,4 @@ locate the necessary Tcl files. Otherwise you may need to
edit makefile.vc and adjust the path to Tcl accordingly.
Information about compiling for windows is maintained at:
- http://www.tcl.tk/doc/howto/compile.html
+ https://www.tcl-lang.org/doc/howto/compile.html
diff --git a/win/configure b/win/configure
index fd50504..0b4ea50 100755
--- a/win/configure
+++ b/win/configure
@@ -1604,83 +1604,6 @@ fi
} # ac_fn_c_try_run
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- as_decl_name=`echo $2|sed 's/ *(.*//'`
- as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
- (void) $as_decl_use;
-#else
- (void) $as_decl_name;
-#endif
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- eval "$3=yes"
-else
- eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
-
-# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists and can be compiled using the include files in
-# INCLUDES, setting the cache variable VAR accordingly.
-ac_fn_c_check_header_compile ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- eval "$3=yes"
-else
- eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_header_compile
-
# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
@@ -1767,6 +1690,37 @@ fi
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
@@ -2129,7 +2083,7 @@ SHELL=/bin/sh
TK_VERSION=8.7
TK_MAJOR_VERSION=8
TK_MINOR_VERSION=7
-TK_PATCH_LEVEL="a2"
+TK_PATCH_LEVEL="a4"
VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
#------------------------------------------------------------------------
@@ -4072,14 +4026,14 @@ $as_echo "$ac_cv_cross" >&6; }
if test "$ac_cv_cross" = "yes"; then
case "$do64bit" in
amd64|x64|yes)
- CC="x86_64-w64-mingw32-gcc"
+ CC="x86_64-w64-mingw32-${CC}"
LD="x86_64-w64-mingw32-ld"
AR="x86_64-w64-mingw32-ar"
RANLIB="x86_64-w64-mingw32-ranlib"
RC="x86_64-w64-mingw32-windres"
;;
*)
- CC="i686-w64-mingw32-gcc"
+ CC="i686-w64-mingw32-${CC}"
LD="i686-w64-mingw32-ld"
AR="i686-w64-mingw32-ar"
RANLIB="i686-w64-mingw32-ranlib"
@@ -4313,10 +4267,19 @@ $as_echo "using shared flags" >&6; }
CFLAGS_DEBUG=-g
CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
- CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement"
+ CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wpointer-arith"
LDFLAGS_DEBUG=
LDFLAGS_OPTIMIZE=
+ case "${CC}" in
+ *++)
+ CFLAGS_WARNING="${CFLAGS_WARNING} -Wno-format"
+ ;;
+ *)
+ CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -Wdeclaration-after-statement"
+ ;;
+ esac
+
# Specify the CC output file names based on the target name
CC_OBJNAME="-o \$@"
CC_EXENAME="-o \$@"
@@ -4411,29 +4374,15 @@ $as_echo "using shared flags" >&6; }
LIBSUFFIX="\${DBGX}.lib"
LIBFLAGSUFFIX="\${DBGX}"
- # This is a 2-stage check to make sure we have the 64-bit SDK
- # We have to know where the SDK is installed.
- # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs
if test "$do64bit" != "no" ; then
- if test "x${MSSDK}x" = "xx" ; then
- MSSDK="C:/Progra~1/Microsoft Platform SDK"
- fi
- MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'`
- PATH64=""
case "$do64bit" in
amd64|x64|yes)
MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
- PATH64="${MSSDK}/Bin/Win64/x86/AMD64"
;;
ia64)
MACHINE="IA64"
- PATH64="${MSSDK}/Bin/Win64"
;;
esac
- if test ! -d "${PATH64}" ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not find 64-bit $MACHINE SDK" >&5
-$as_echo "$as_me: WARNING: Could not find 64-bit $MACHINE SDK" >&2;}
- fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Using 64-bit $MACHINE mode" >&5
$as_echo " Using 64-bit $MACHINE mode" >&6; }
fi
@@ -4449,26 +4398,12 @@ $as_echo " Using 64-bit $MACHINE mode" >&6; }
esac
if test "$do64bit" != "no" ; then
- # The space-based-path will work for the Makefile, but will
- # not work if AC_TRY_COMPILE is called. TEA has the
- # TEA_PATH_NOSPACE to avoid this issue.
- # Check if _WIN64 is already recognized, and if so we don't
- # need to modify CC.
- ac_fn_c_check_decl "$LINENO" "_WIN64" "ac_cv_have_decl__WIN64" "$ac_includes_default"
-if test "x$ac_cv_have_decl__WIN64" = xyes; then :
-
-else
- CC="\"${PATH64}/cl.exe\" -I\"${MSSDK}/Include\" \
- -I\"${MSSDK}/Include/crt\" \
- -I\"${MSSDK}/Include/crt/sys\""
-fi
-
- RC="\"${MSSDK}/bin/rc.exe\""
+ RC="rc"
CFLAGS_DEBUG="-nologo -Zi -Od ${runtime}d"
# Do not use -O2 for Win64 - this has proved buggy in code gen.
CFLAGS_OPTIMIZE="-nologo -O1 ${runtime}"
- lflags="${lflags} -nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\""
- LINKBIN="\"${PATH64}/link.exe\""
+ lflags="${lflags} -nologo -MACHINE:${MACHINE}"
+ LINKBIN="link"
# Avoid 'unresolved external symbol __security_cookie' errors.
# c.f. http://support.microsoft.com/?id=894573
LIBS="$LIBS bufferoverflowU.lib"
@@ -4664,6 +4599,15 @@ $as_echo "#define HAVE_WINNT_IGNORE_VOID 1" >>confdefs.h
fi
+ ac_fn_c_check_header_mongrel "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdbool_h" = xyes; then :
+
+$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
+
+fi
+
+
+
# See if the compiler supports casting to a union type.
# This is used to stop gcc from printing a compiler
# warning when initializing a union member.
diff --git a/win/configure.ac b/win/configure.ac
index a000115..ca9263f 100644
--- a/win/configure.ac
+++ b/win/configure.ac
@@ -14,7 +14,7 @@ SHELL=/bin/sh
TK_VERSION=8.7
TK_MAJOR_VERSION=8
TK_MINOR_VERSION=7
-TK_PATCH_LEVEL="a2"
+TK_PATCH_LEVEL="a4"
VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
#------------------------------------------------------------------------
diff --git a/win/makefile.vc b/win/makefile.vc
index a216b2f..b2d3996 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -17,7 +17,7 @@
# General usage:
# nmake [-nologo] -f makefile.vc [TARGET|MACRODEF [TARGET|MACRODEF] [...]]
#
-# For MACRODEF, see TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md)
+# For MACRODEF, see TIP 477 (https://core.tcl-lang.org/tips/doc/trunk/tip/477.md)
# or examine Sections 6-8 in rules.vc. This makefile has the following
# values for the OPTS macro in addition to the ones described there.
# noxp = If you do not have the uxtheme.h header then you
@@ -84,6 +84,8 @@ DEFAULT_BUILD_TARGET = release
# We have a custom resource file
RCFILE = tk.rc
+USE_WIDECHAR_API = 0
+
# The rules.vc file does much of the hard work in terms of defining
# the build configuration, macros, output directories etc.
!include "rules-ext.vc"
@@ -219,6 +221,7 @@ TKOBJS = \
$(TMP_DIR)\tkImgGIF.obj \
$(TMP_DIR)\tkImgPNG.obj \
$(TMP_DIR)\tkImgPPM.obj \
+ $(TMP_DIR)\tkImgSVGnano.obj \
$(TMP_DIR)\tkImgPhoto.obj \
$(TMP_DIR)\tkImgPhInstance.obj \
$(TMP_DIR)\tkImgUtil.obj \
@@ -235,6 +238,7 @@ TKOBJS = \
$(TMP_DIR)\tkOldConfig.obj \
$(TMP_DIR)\tkOption.obj \
$(TMP_DIR)\tkPack.obj \
+ $(TMP_DIR)\tkPkgConfig.obj \
$(TMP_DIR)\tkPlace.obj \
$(TMP_DIR)\tkPointer.obj \
$(TMP_DIR)\tkRectOval.obj \
@@ -310,21 +314,21 @@ BITMAPDIR = $(ROOT)\bitmaps
# defined in rules.vc
PRJ_INCLUDES = -I"$(BITMAPDIR)" -I"$(XLIBDIR)"
-CONFIG_DEFS =-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 \
- -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 \
- -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 \
- -DSUPPORT_CONFIG_EMBEDDED \
+CONFIG_DEFS =/DSTDC_HEADERS=1 /DHAVE_SYS_TYPES_H=1 /DHAVE_SYS_STAT_H=1 \
+ /DHAVE_STRING_H=1 /DHAVE_MEMORY_H=1 \
+ /DHAVE_STRINGS_H=1 \
+ /DSUPPORT_CONFIG_EMBEDDED \
!if $(HAVE_UXTHEME_H)
- -DHAVE_UXTHEME_H=1 \
+ /DHAVE_UXTHEME_H=1 \
!endif
!if $(TTK_SQUARE_WIDGET)
- -DTTK_SQUARE_WIDGET=1 \
+ /DTTK_SQUARE_WIDGET=1 \
!endif
!if $(TK_NO_DEPRECATED)
- -DTK_NO_DEPRECATED=1
+ /DTK_NO_DEPRECATED=1
!endif
-PRJ_DEFINES = -DBUILD_ttk $(CONFIG_DEFS) -Dinline=__inline -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE
+PRJ_DEFINES = /DBUILD_ttk $(CONFIG_DEFS) /Dinline=__inline /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE
# Additional Link libraries needed beyond those in rules.vc
PRJ_LIBS = netapi32.lib gdi32.lib user32.lib userenv.lib
@@ -347,6 +351,9 @@ all: release $(CAT32)
core: setup $(TKSTUBLIB) $(TKLIB)
cwish: $(WISHC)
install: install-binaries install-libraries install-docs
+!if $(SYMBOLS)
+install: install-pdbs
+!endif
tktest: setup $(TKTEST) $(CAT32)
setup: default-setup
@@ -461,8 +468,8 @@ $(TKTEST): $(TKTESTOBJS) $(TKSTUBLIB) $(TKIMPLIB)
$(CAT32): $(_TCLDIR)\win\cat.c
- $(cc32) $(cflags) $(crt) -D_CRT_NONSTDC_NO_DEPRECATE -DCONSOLE -Fo$(TMP_DIR)\ $?
- $(CONEXECMD) -DCONSOLE -stack:16384 $(TMP_DIR)\cat.obj
+ $(cc32) $(cflags) $(crt) /D_CRT_NONSTDC_NO_DEPRECATE /DCONSOLE /DUNICODE /D_UNICODE -Fo$(TMP_DIR)\ $?
+ $(CONEXECMD) /DCONSOLE -stack:16384 $(TMP_DIR)\cat.obj
$(_VC_MANIFEST_EMBED_EXE)
#---------------------------------------------------------------------
@@ -527,13 +534,18 @@ install-docs:
!endif
# "emacs font-lock highlighting fix
+install-pdbs:
+ @echo Installing debug symbols
+ @$(CPY) "$(OUT_DIR)\*.pdb" "$(BIN_INSTALL_DIR)\"
+# "emacs font-lock highlighting fix
+
#---------------------------------------------------------------------
# Special case object file targets
#---------------------------------------------------------------------
-$(TMP_DIR)\testMain.obj: $(WINDIR)\winMain.c
- $(cc32) $(appcflags_nostubs) -DTK_TEST \
- -DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
+$(TMP_DIR)\testMain.obj: $(WIN_DIR)\winMain.c
+ $(cc32) $(appcflags_nostubs) /DTK_TEST /DUNICODE /D_UNICODE \
+ /DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
-Fo$@ $?
$(TMP_DIR)\tkTest.obj: $(GENERICDIR)\tkTest.c
@@ -542,19 +554,19 @@ $(TMP_DIR)\tkTest.obj: $(GENERICDIR)\tkTest.c
$(TMP_DIR)\tkOldTest.obj: $(GENERICDIR)\tkOldTest.c
$(cc32) $(appcflags_nostubs) -Fo$@ $?
-$(TMP_DIR)\tkWinTest.obj: $(WINDIR)\tkWinTest.c
+$(TMP_DIR)\tkWinTest.obj: $(WIN_DIR)\tkWinTest.c
$(cc32) $(appcflags_nostubs) -Fo$@ $?
$(TMP_DIR)\tkSquare.obj: $(GENERICDIR)\tkSquare.c
$(cc32) $(appcflags_nostubs) -Fo$@ $?
-$(TMP_DIR)\winMain.obj: $(WINDIR)\winMain.c
- $(cc32) $(appcflags_nostubs) \
- -DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
+$(TMP_DIR)\winMain.obj: $(WIN_DIR)\winMain.c
+ $(cc32) $(appcflags_nostubs) /DUNICODE /D_UNICODE \
+ /DTCL_USE_STATIC_PACKAGES=$(TCL_USE_STATIC_PACKAGES) \
-Fo$@ $?
$(TMP_DIR)\tkMain2.obj: $(GENERICDIR)\tkMain.c
- $(cc32) $(pkgcflags) -DTK_ASCII_MAIN -Fo$@ $?
+ $(cc32) $(pkgcflags) /DUNICODE /D_UNICODE -Fo$@ $?
# The following objects are part of the stub library and should not
# be built as DLL objects but none of the symbols should be exported
@@ -563,8 +575,10 @@ $(TMP_DIR)\tkMain2.obj: $(GENERICDIR)\tkMain.c
$(TMP_DIR)\tkStubLib.obj : $(GENERICDIR)\tkStubLib.c
$(cc32) $(stubscflags) -Fo$@ $?
+$(TMP_DIR)\ttkStubLib.obj : $(TTKDIR)\ttkStubLib.c
+ $(cc32) $(stubscflags) -Fo$@ $?
-$(TMP_DIR)\wish.exe.manifest: $(WINDIR)\wish.exe.manifest.in
+$(TMP_DIR)\wish.exe.manifest: $(WIN_DIR)\wish.exe.manifest.in
@nmakehlp -s << $** >$@
@MACHINE@ $(MACHINE:IX86=X86)
@TK_WIN_VERSION@ $(DOTVERSION).0.0
@@ -584,8 +598,8 @@ depend:
!else
set TCL_LIBRARY=$(TCL_LIBRARY)
$(TCLSH) $(TCLTOOLSDIR:\=/)/mkdepend.tcl -vc32 -out:"$(OUT_DIR)\depend.mk" \
- -passthru:"-DBUILD_tk $(TK_INCLUDES)" $(GENERICDIR),$$(GENERICDIR) \
- $(WINDIR),$$(WINDIR) $(TTKDIR),$$(TTKDIR) $(XLIBDIR),$$(XLIBDIR) \
+ -passthru:"/DBUILD_tk $(TK_INCLUDES)" $(GENERICDIR),$$(GENERICDIR) \
+ $(WIN_DIR),$$(WIN_DIR) $(TTKDIR),$$(TTKDIR) $(XLIBDIR),$$(XLIBDIR) \
$(BITMAPDIR),$$(BITMAPDIR) @<<
$(TKOBJS)
<<
diff --git a/win/rules.vc b/win/rules.vc
index fbcb235..490f9c3 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -6,7 +6,7 @@
# compiler switches, defining common targets and macros. The Tcl makefile
# directly includes this. Extensions include it via "rules-ext.vc".
#
-# See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for
+# See TIP 477 (https://core.tcl-lang.org/tips/doc/trunk/tip/477.md) for
# detailed documentation.
#
# See the file "license.terms" for information on usage and redistribution
@@ -24,7 +24,7 @@ _RULES_VC = 1
# For modifications that are not backward-compatible, you *must* change
# the major version.
RULES_VERSION_MAJOR = 1
-RULES_VERSION_MINOR = 3
+RULES_VERSION_MINOR = 6
# The PROJECT macro must be defined by parent makefile.
!if "$(PROJECT)" == ""
@@ -162,7 +162,7 @@ MKDIR = mkdir
# COMPATDIR - source directory that holds compatibility sources
# DOCDIR - source directory containing documentation files
# GENERICDIR - platform-independent source directory
-# WINDIR - Windows-specific source directory
+# WIN_DIR - Windows-specific source directory
# TESTDIR - directory containing test files
# TOOLSDIR - directory containing build tools
# _TCLDIR - root of the Tcl installation OR the Tcl sources. Not set
@@ -215,17 +215,15 @@ DEMODIR = $(LIBDIR)\demos
DEMODIR = $(ROOT)\demos
!endif
!endif # ifndef DEMODIR
-# Do NOT enclose WINDIR in a !ifndef because Windows always defines
-# WINDIR env var to point to c:\windows!
-# TBD - This is a potentially dangerous conflict, rename WINDIR to
-# something else
-WINDIR = $(ROOT)\win
+# Do NOT use WINDIR because it is Windows internal environment
+# variable to point to c:\windows!
+WIN_DIR = $(ROOT)\win
!ifndef RCDIR
-!if exist("$(WINDIR)\rc")
-RCDIR = $(WINDIR)\rc
+!if exist("$(WIN_DIR)\rc")
+RCDIR = $(WIN_DIR)\rc
!else
-RCDIR = $(WINDIR)
+RCDIR = $(WIN_DIR)
!endif
!endif
RCDIR = $(RCDIR:/=\)
@@ -304,7 +302,7 @@ TCLDIR = $(_INSTALLDIR)\..
_TCLDIR = $(_INSTALLDIR)\..
_TCL_H = $(_TCLDIR)\include\tcl.h
-!else # exist(...) && ! $(NEED_TCL_SOURCE)
+!else # exist(...) && !$(NEED_TCL_SOURCE)
!if [echo _TCLDIR = \> nmakehlp.out] \
|| [nmakehlp -L generic\tcl.h >> nmakehlp.out]
@@ -315,7 +313,7 @@ TCLINSTALL = 0
TCLDIR = $(_TCLDIR)
_TCL_H = $(_TCLDIR)\generic\tcl.h
-!endif # exist(...) && ! $(NEED_TCL_SOURCE)
+!endif # exist(...) && !$(NEED_TCL_SOURCE)
!endif # TCLDIR
@@ -475,6 +473,21 @@ MACHINE = AMD64
MACHINE=$(ARCH)
!endif
+#---------------------------------------------------------------
+# The PLATFORM_IDENTIFY macro matches the values returned by
+# the Tcl platform::identify command
+!if "$(MACHINE)" == "AMD64"
+PLATFORM_IDENTIFY = win32-x86_64
+!else
+PLATFORM_IDENTIFY = win32-ix86
+!endif
+
+# The MULTIPLATFORM macro controls whether binary extensions are installed
+# in platform-specific directories. Intended to be set/used by extensions.
+!ifndef MULTIPLATFORM_INSTALL
+MULTIPLATFORM_INSTALL = 0
+!endif
+
#------------------------------------------------------------
# Figure out the *host* architecture by reading the registry
@@ -524,7 +537,7 @@ NMAKEHLPC = nmakehlp.c
!if exist("$(_TCLDIR)\lib\nmake\nmakehlp.c")
NMAKEHLPC = $(_TCLDIR)\lib\nmake\nmakehlp.c
!endif
-!else # ! $(TCLINSTALL)
+!else # !$(TCLINSTALL)
!if exist("$(_TCLDIR)\win\nmakehlp.c")
NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c
!endif
@@ -671,6 +684,10 @@ LINKERFLAGS = $(LINKERFLAGS) -ltcg
# USE_STUBS - 1 -> compile to use stubs interfaces, 0 -> direct linking
# CONFIG_CHECK - 1 -> check current build configuration against Tcl
# configuration (ignored for Tcl itself)
+# _USE_64BIT_TIME_T - forces a build using 64-bit time_t for 32-bit build
+# (CRT library should support this, not needed for Tcl 9.x)
+# TCL_UTF_MAX=4 - forces a build allowing 4-byte UTF-8 sequences internally.
+# (Not needed for Tcl 9.x)
# Further, LINKERFLAGS are modified based on above.
# Default values for all the above
@@ -730,6 +747,29 @@ TCL_USE_STATIC_PACKAGES = 1
TCL_USE_STATIC_PACKAGES = 0
!endif
+!if [nmakehlp -f $(OPTS) "nothreads"]
+!message *** Compile explicitly for non-threaded tcl
+TCL_THREADS = 0
+USE_THREAD_ALLOC= 0
+!else
+TCL_THREADS = 1
+USE_THREAD_ALLOC= 1
+!endif
+
+!if "$(TCL_MAJOR_VERSION)" == "8"
+!if [nmakehlp -f $(OPTS) "time64bit"]
+!message *** Force 64-bit time_t
+_USE_64BIT_TIME_T = 1
+!endif
+
+!if [nmakehlp -f $(OPTS) "utfmax"]
+!message *** Force allowing 4-byte UTF-8 sequences internally
+TCL_UTF_MAX = 4
+!endif
+!endif
+
+# Yes, it's weird that the "symbols" option controls DEBUG and
+# the "pdbs" option controls SYMBOLS. That's historical.
!if [nmakehlp -f $(OPTS) "symbols"]
!message *** Doing symbols
DEBUG = 1
@@ -765,6 +805,12 @@ PGO = 0
!message *** Warning: ignoring option "loimpact" - deprecated on modern Windows.
!endif
+# TBD - should get rid of this option
+!if [nmakehlp -f $(OPTS) "thrdalloc"]
+!message *** Doing thrdalloc
+USE_THREAD_ALLOC = 1
+!endif
+
!if [nmakehlp -f $(OPTS) "tclalloc"]
USE_THREAD_ALLOC = 0
!endif
@@ -948,6 +994,19 @@ VERSION = $(DOTVERSION:.=)
!endif # $(DOING_TCL) ... etc.
+# Windows RC files have 3 version components. Ensure this irrespective
+# of how many components the package has specified. Basically, ensure
+# minimum 4 components by appending 4 0's and then pick out the first 4.
+# Also take care of the fact that DOTVERSION may have "a" or "b" instead
+# of "." separating the version components.
+DOTSEPARATED=$(DOTVERSION:a=.)
+DOTSEPARATED=$(DOTSEPARATED:b=.)
+!if [echo RCCOMMAVERSION = \> versions.vc] \
+ || [for /f "tokens=1,2,3,4,5* delims=." %a in ("$(DOTSEPARATED).0.0.0.0") do echo %a,%b,%c,%d >> versions.vc]
+!error *** Could not generate RCCOMMAVERSION ***
+!endif
+!include versions.vc
+
################################################################
# 10. Construct output directory and file paths
# Figure-out how to name our intermediate and output directories.
@@ -1054,9 +1113,9 @@ TCLLIB = $(OUT_DIR)\$(TCLLIBNAME)
TCLSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
TCLSTUBLIB = $(OUT_DIR)\$(TCLSTUBLIBNAME)
-TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)"
+TCL_INCLUDES = -I"$(WIN_DIR)" -I"$(GENERICDIR)"
-!else # ! $(DOING_TCL)
+!else # !$(DOING_TCL)
!if $(TCLINSTALL) # Building against an installed Tcl
@@ -1129,7 +1188,7 @@ WISH = $(OUT_DIR)\$(WISHNAME)
TKSTUBLIB = $(OUT_DIR)\$(TKSTUBLIBNAME)
TKIMPLIB = $(OUT_DIR)\$(TKIMPLIBNAME)
TKLIB = $(OUT_DIR)\$(TKLIBNAME)
-TK_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)"
+TK_INCLUDES = -I"$(WIN_DIR)" -I"$(GENERICDIR)"
!else # effectively NEED_TK
@@ -1162,8 +1221,8 @@ tklibs = "$(TKSTUBLIB)" "$(TKIMPLIB)"
!endif # $(DOING_TK) || $(NEED_TK)
# Various output paths
-PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX:t=).lib
-PRJLIBNAME = $(PROJECT)$(VERSION)$(SUFX:t=).$(EXT)
+PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
+PRJLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
PRJLIB = $(OUT_DIR)\$(PRJLIBNAME)
PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
@@ -1196,6 +1255,7 @@ BIN_INSTALL_DIR = $(_INSTALLDIR)\bin
DOC_INSTALL_DIR = $(_INSTALLDIR)\doc
!if $(DOING_TCL)
SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
+MODULE_INSTALL_DIR = $(_INSTALLDIR)\lib\tcl$(TCL_MAJOR_VERSION)
!else # DOING_TK
SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
!endif
@@ -1205,8 +1265,13 @@ INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\include
!else # extension other than Tk
PRJ_INSTALL_DIR = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
+!if $(MULTIPLATFORM_INSTALL)
+LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR)\$(PLATFORM_IDENTIFY)
+BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR)\$(PLATFORM_IDENTIFY)
+!else
LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR)
BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR)
+!endif
DOC_INSTALL_DIR = $(PRJ_INSTALL_DIR)
SCRIPT_INSTALL_DIR = $(PRJ_INSTALL_DIR)
DEMO_INSTALL_DIR = $(PRJ_INSTALL_DIR)\demos
@@ -1235,82 +1300,87 @@ INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\..\include
# baselibs - minimum Windows libraries required. Parent makefile can
# define PRJ_LIBS before including rules.rc if additional libs are needed
-OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS
+OPTDEFINES = /DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) /DSTDC_HEADERS
+!if $(VCVERSION) >= 1600
+OPTDEFINES = $(OPTDEFINES) /DHAVE_STDINT_H=1
+!else
+OPTDEFINES = $(OPTDEFINES) /DMP_NO_STDINT=1
+!endif
+!if $(VCVERSION) >= 1800
+OPTDEFINES = $(OPTDEFINES) /DHAVE_INTTYPES_H=1 /DHAVE_STDBOOL_H=1
+!endif
!if $(TCL_MEM_DEBUG)
-OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG
+OPTDEFINES = $(OPTDEFINES) /DTCL_MEM_DEBUG
!endif
!if $(TCL_COMPILE_DEBUG)
-OPTDEFINES = $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS
+OPTDEFINES = $(OPTDEFINES) /DTCL_COMPILE_DEBUG /DTCL_COMPILE_STATS
!endif
-!if $(TCL_THREADS) && $(TCL_VERSION) < 86
-OPTDEFINES = $(OPTDEFINES) -DTCL_THREADS=1
-!if $(USE_THREAD_ALLOC)
-OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1
+!if $(TCL_THREADS) && $(TCL_VERSION) < 87
+OPTDEFINES = $(OPTDEFINES) /DTCL_THREADS=1
+!if $(USE_THREAD_ALLOC) && $(TCL_VERSION) < 87
+OPTDEFINES = $(OPTDEFINES) /DUSE_THREAD_ALLOC=1
!endif
!endif
!if $(STATIC_BUILD)
-OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD
+OPTDEFINES = $(OPTDEFINES) /DSTATIC_BUILD
+!elseif $(TCL_VERSION) > 86
+OPTDEFINES = $(OPTDEFINES) /DTCL_WITH_EXTERNAL_TOMMATH
+!if "$(MACHINE)" == "AMD64"
+OPTDEFINES = $(OPTDEFINES) /DMP_64BIT
+!endif
!endif
!if $(TCL_NO_DEPRECATED)
-OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED
+OPTDEFINES = $(OPTDEFINES) /DTCL_NO_DEPRECATED
!endif
!if $(USE_STUBS)
# Note we do not define USE_TCL_STUBS even when building tk since some
# test targets in tk do not use stubs
-!if ! $(DOING_TCL)
-USE_STUBS_DEFS = -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS
+!if !$(DOING_TCL)
+USE_STUBS_DEFS = /DUSE_TCL_STUBS /DUSE_TCLOO_STUBS
!if $(NEED_TK)
-USE_STUBS_DEFS = $(USE_STUBS_DEFS) -DUSE_TK_STUBS
+USE_STUBS_DEFS = $(USE_STUBS_DEFS) /DUSE_TK_STUBS
!endif
!endif
!endif # USE_STUBS
!if !$(DEBUG)
-OPTDEFINES = $(OPTDEFINES) -DNDEBUG
+OPTDEFINES = $(OPTDEFINES) /DNDEBUG
!if $(OPTIMIZING)
-OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED
+OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_OPTIMIZED
!endif
!endif
!if $(PROFILE)
-OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED
+OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_PROFILED
!endif
!if "$(MACHINE)" == "AMD64"
-OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT
+OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_DO64BIT
!endif
!if $(VCVERSION) < 1300
-OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64
+OPTDEFINES = $(OPTDEFINES) /DNO_STRTOI64=1
!endif
-# _ATL_XP_TARGETING - Newer SDK's need this to build for XP
-COMPILERFLAGS = /D_ATL_XP_TARGETING
-
-# Following is primarily for the benefit of extensions. Tcl 8.5 builds
-# Tcl without /DUNICODE, while 8.6 builds with it defined. When building
-# an extension, it is advisable (but not mandated) to use the same Windows
-# API as the Tcl build. This is accordingly defaulted below. A particular
-# extension can override this by pre-definining USE_WIDECHAR_API.
-!ifndef USE_WIDECHAR_API
-!if $(TCL_VERSION) > 85
-USE_WIDECHAR_API = 1
-!else
-USE_WIDECHAR_API = 0
+!if "$(TCL_MAJOR_VERSION)" == "8"
+!if "$(_USE_64BIT_TIME_T)" == "1"
+OPTDEFINES = $(OPTDEFINES) /D_USE_64BIT_TIME_T=1
!endif
+!if "$(TCL_UTF_MAX)" == "4"
+OPTDEFINES = $(OPTDEFINES) /DTCL_UTF_MAX=4
!endif
-!if $(USE_WIDECHAR_API)
-COMPILERFLAGS = $(COMPILERFLAGS) /DUNICODE /D_UNICODE
+# _ATL_XP_TARGETING - Newer SDK's need this to build for XP
+COMPILERFLAGS = /D_ATL_XP_TARGETING
!endif
# Like the TEA system only set this non empty for non-Tk extensions
# Note: some extensions use PACKAGE_NAME and others use PACKAGE_TCLNAME
# so we pass both
!if !$(DOING_TCL) && !$(DOING_TK)
-PKGNAMEFLAGS = -DPACKAGE_NAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
- -DPACKAGE_TCLNAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
- -DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
- -DMODULE_SCOPE=extern
+PKGNAMEFLAGS = /DPACKAGE_NAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
+ /DPACKAGE_TCLNAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
+ /DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
+ /DMODULE_SCOPE=extern
!endif
# crt picks the C run time based on selected OPTS
@@ -1357,7 +1427,7 @@ cwarn = $(cwarn) -wd4311 -wd4312
### Common compiler options that are architecture specific
!if "$(MACHINE)" == "ARM"
-carch = -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
+carch = /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
!else
carch =
!endif
@@ -1369,7 +1439,7 @@ cwarn = $(cwarn) -WX
INCLUDES = $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES)
!if !$(DOING_TCL) && !$(DOING_TK)
-INCLUDES = $(INCLUDES) -I"$(GENERICDIR)" -I"$(WINDIR)" -I"$(COMPATDIR)"
+INCLUDES = $(INCLUDES) -I"$(GENERICDIR)" -I"$(WIN_DIR)" -I"$(COMPATDIR)"
!endif
# These flags are defined roughly in the order of the pre-reform
@@ -1385,13 +1455,13 @@ cflags = -nologo -c $(COMPILERFLAGS) $(carch) $(cwarn) -Fp$(TMP_DIR)^\ $(cdebug)
# BUILD_$(PROJECT) macro which should be defined only for the shared
# library *implementation* and not for its caller interface
-appcflags = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES) $(USE_STUBS_DEFS)
appcflags_nostubs = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES)
-pkgcflags = $(appcflags) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
-pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
+appcflags = $(appcflags_nostubs) $(USE_STUBS_DEFS)
+pkgcflags = $(appcflags) $(PKGNAMEFLAGS) /DBUILD_$(PROJECT)
+pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) /DBUILD_$(PROJECT)
# stubscflags contains $(cflags) plus flags used for building a stubs
-# library for the package. Note: -DSTATIC_BUILD is defined in
+# library for the package. Note: /DSTATIC_BUILD is defined in
# $(OPTDEFINES) only if the OPTS configuration indicates a static
# library. However the stubs library is ALWAYS static hence included
# here irrespective of the OPTS setting.
@@ -1401,7 +1471,7 @@ pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
# so we do not remove it from cflags. -GL may prevent extensions
# compiled with one VC version to fail to link against stubs library
# compiled with another VC version. Check for this and fix accordingly.
-stubscflags = $(cflags) $(PKGNAMEFLAGS) $(PRJ_DEFINES) $(OPTDEFINES) -Zl -DSTATIC_BUILD $(INCLUDES)
+stubscflags = $(cflags) $(PKGNAMEFLAGS) $(PRJ_DEFINES) $(OPTDEFINES) -Zl /DSTATIC_BUILD $(INCLUDES) $(USE_STUBS_DEFS)
# Link flags
@@ -1426,6 +1496,18 @@ lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug)
lflags = $(lflags) -nodefaultlib:libucrt.lib
!endif
+# Old linkers (Visual C++ 6 in particular) will link for fast loading
+# on Win98. Since we do not support Win98 any more, we specify nowin98
+# as recommended for NT and later. However, this is only required by
+# IX86 on older compilers and only needed if we are not doing a static build.
+
+!if "$(MACHINE)" == "IX86" && !$(STATIC_BUILD)
+!if [nmakehlp -l -opt:nowin98 $(LINKER_TESTFLAGS)]
+# Align sections for PE size savings.
+lflags = $(lflags) -opt:nowin98
+!endif
+!endif
+
dlllflags = $(lflags) -dll
conlflags = $(lflags) -subsystem:console
guilflags = $(lflags) -subsystem:windows
@@ -1466,13 +1548,13 @@ CONEXECMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs)
GUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs)
RESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \
$(TCL_INCLUDES) \
- -DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
- -DCOMMAVERSION=$(DOTVERSION:.=,),0 \
- -DDOTVERSION=\"$(DOTVERSION)\" \
- -DVERSION=\"$(VERSION)\" \
- -DSUFX=\"$(SUFX:t=)\" \
- -DPROJECT=\"$(PROJECT)\" \
- -DPRJLIBNAME=\"$(PRJLIBNAME)\"
+ /DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
+ /DCOMMAVERSION=$(RCCOMMAVERSION) \
+ /DDOTVERSION=\"$(DOTVERSION)\" \
+ /DVERSION=\"$(VERSION)\" \
+ /DSUFX=\"$(SUFX)\" \
+ /DPROJECT=\"$(PROJECT)\" \
+ /DPRJLIBNAME=\"$(PRJLIBNAME)\"
!ifndef DEFAULT_BUILD_TARGET
DEFAULT_BUILD_TARGET = $(PROJECT)
@@ -1480,9 +1562,15 @@ DEFAULT_BUILD_TARGET = $(PROJECT)
default-target: $(DEFAULT_BUILD_TARGET)
+!if $(MULTIPLATFORM_INSTALL)
+default-pkgindex:
+ @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
+ [list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl
+!else
default-pkgindex:
@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
[list load [file join $$dir $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl
+!endif
default-pkgindex-tea:
@if exist $(ROOT)\pkgIndex.tcl.in nmakehlp -s << $(ROOT)\pkgIndex.tcl.in > $(OUT_DIR)\pkgIndex.tcl
@@ -1492,15 +1580,26 @@ default-pkgindex-tea:
@PKG_LIB_FILE@ $(PRJLIBNAME)
<<
-
default-install: default-install-binaries default-install-libraries
+!if $(SYMBOLS)
+default-install: default-install-pdbs
+!endif
+# Again to deal with historical brokenness, there is some confusion
+# in terminlogy. For extensions, the "install-binaries" was used to
+# locate target directory for *binary shared libraries* and thus
+# the appropriate macro is LIB_INSTALL_DIR since BIN_INSTALL_DIR is
+# for executables (exes). On the other hand the "install-libraries"
+# target is for *scripts* and should have been called "install-scripts".
default-install-binaries: $(PRJLIB)
- @echo Installing binaries to '$(SCRIPT_INSTALL_DIR)'
- @if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
- @$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
+ @echo Installing binaries to '$(LIB_INSTALL_DIR)'
+ @if not exist "$(LIB_INSTALL_DIR)" mkdir "$(LIB_INSTALL_DIR)"
+ @$(CPY) $(PRJLIB) "$(LIB_INSTALL_DIR)" >NUL
+
+# Alias for default-install-scripts
+default-install-libraries: default-install-scripts
-default-install-libraries: $(OUT_DIR)\pkgIndex.tcl
+default-install-scripts: $(OUT_DIR)\pkgIndex.tcl
@echo Installing libraries to '$(SCRIPT_INSTALL_DIR)'
@if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)"
@echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
@@ -1511,6 +1610,11 @@ default-install-stubs:
@if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
@$(CPY) $(PRJSTUBLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
+default-install-pdbs:
+ @echo Installing PDBs to '$(LIB_INSTALL_DIR)'
+ @if not exist "$(LIB_INSTALL_DIR)" mkdir "$(LIB_INSTALL_DIR)"
+ @$(CPY) "$(OUT_DIR)\*.pdb" "$(LIB_INSTALL_DIR)\"
+
default-install-docs-html:
@echo Installing documentation files to '$(DOC_INSTALL_DIR)'
@if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)"
@@ -1529,20 +1633,20 @@ default-install-demos:
default-clean:
@echo Cleaning $(TMP_DIR)\* ...
@if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
- @echo Cleaning $(WINDIR)\nmakehlp.obj, nmakehlp.exe ...
- @if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj
- @if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
- @if exist $(WINDIR)\nmakehlp.out del $(WINDIR)\nmakehlp.out
- @echo Cleaning $(WINDIR)\nmhlp-out.txt ...
- @if exist $(WINDIR)\nmhlp-out.txt del $(WINDIR)\nmhlp-out.txt
- @echo Cleaning $(WINDIR)\_junk.pch ...
- @if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch
- @echo Cleaning $(WINDIR)\vercl.x, vercl.i ...
- @if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x
- @if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i
- @echo Cleaning $(WINDIR)\versions.vc, version.vc ...
- @if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc
- @if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc
+ @echo Cleaning $(WIN_DIR)\nmakehlp.obj, nmakehlp.exe ...
+ @if exist $(WIN_DIR)\nmakehlp.obj del $(WIN_DIR)\nmakehlp.obj
+ @if exist $(WIN_DIR)\nmakehlp.exe del $(WIN_DIR)\nmakehlp.exe
+ @if exist $(WIN_DIR)\nmakehlp.out del $(WIN_DIR)\nmakehlp.out
+ @echo Cleaning $(WIN_DIR)\nmhlp-out.txt ...
+ @if exist $(WIN_DIR)\nmhlp-out.txt del $(WIN_DIR)\nmhlp-out.txt
+ @echo Cleaning $(WIN_DIR)\_junk.pch ...
+ @if exist $(WIN_DIR)\_junk.pch del $(WIN_DIR)\_junk.pch
+ @echo Cleaning $(WIN_DIR)\vercl.x, vercl.i ...
+ @if exist $(WIN_DIR)\vercl.x del $(WIN_DIR)\vercl.x
+ @if exist $(WIN_DIR)\vercl.i del $(WIN_DIR)\vercl.i
+ @echo Cleaning $(WIN_DIR)\versions.vc, version.vc ...
+ @if exist $(WIN_DIR)\versions.vc del $(WIN_DIR)\versions.vc
+ @if exist $(WIN_DIR)\version.vc del $(WIN_DIR)\version.vc
default-hose: default-clean
@echo Hosing $(OUT_DIR)\* ...
@@ -1634,7 +1738,7 @@ DISABLE_IMPLICIT_RULES = 0
$<
<<
-{$(WINDIR)}.c{$(TMP_DIR)}.obj::
+{$(WIN_DIR)}.c{$(TMP_DIR)}.obj::
$(CCPKGCMD) @<<
$<
<<
@@ -1652,7 +1756,7 @@ $<
{$(RCDIR)}.rc{$(TMP_DIR)}.res:
$(RESCMD) $<
-{$(WINDIR)}.rc{$(TMP_DIR)}.res:
+{$(WIN_DIR)}.rc{$(TMP_DIR)}.res:
$(RESCMD) $<
{$(TMP_DIR)}.rc{$(TMP_DIR)}.res:
@@ -1668,13 +1772,13 @@ $<
# When building an extension, certain configuration options should
# match the ones used when Tcl was built. Here we check and
# warn on a mismatch.
-!if ! $(DOING_TCL)
+!if !$(DOING_TCL)
!if $(TCLINSTALL) # Building against an installed Tcl
!if exist("$(_TCLDIR)\lib\nmake\tcl.nmake")
TCLNMAKECONFIG = "$(_TCLDIR)\lib\nmake\tcl.nmake"
!endif
-!else # ! $(TCLINSTALL) - building against Tcl source
+!else # !$(TCLINSTALL) - building against Tcl source
!if exist("$(OUT_DIR)\tcl.nmake")
TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake"
!endif
@@ -1687,6 +1791,9 @@ TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake"
!if defined(CORE_MACHINE) && "$(CORE_MACHINE)" != "$(MACHINE)"
!error ERROR: Build target ($(MACHINE)) does not match the Tcl library architecture ($(CORE_MACHINE)).
!endif
+!if $(TCL_VERSION) < 87 && defined(CORE_USE_THREAD_ALLOC) && $(CORE_USE_THREAD_ALLOC) != $(USE_THREAD_ALLOC)
+!message WARNING: Value of USE_THREAD_ALLOC ($(USE_THREAD_ALLOC)) does not match its Tcl core value ($(CORE_USE_THREAD_ALLOC)).
+!endif
!if defined(CORE_DEBUG) && $(CORE_DEBUG) != $(DEBUG)
!message WARNING: Value of DEBUG ($(DEBUG)) does not match its Tcl library configuration ($(DEBUG)).
!endif
@@ -1694,7 +1801,7 @@ TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake"
!endif # TCLNMAKECONFIG
-!endif # ! $(DOING_TCL)
+!endif # !$(DOING_TCL)
#----------------------------------------------------------
diff --git a/win/stubs.c b/win/stubs.c
index c3e853e..faeac08 100644
--- a/win/stubs.c
+++ b/win/stubs.c
@@ -8,6 +8,8 @@ int
_XInitImageFuncPtrs(
XImage *image)
{
+ (void)image;
+
return Success;
}
@@ -21,6 +23,9 @@ XSetWMClientMachine(
Window w,
XTextProperty *text_prop)
{
+ (void)display;
+ (void)w;
+ (void)text_prop;
}
Status
@@ -29,7 +34,11 @@ XStringListToTextProperty(
int count,
XTextProperty *text_prop_return)
{
- return (Status) 0;
+ (void)list;
+ (void)count;
+ (void)text_prop_return;
+
+ return Success;
}
/*
@@ -47,54 +56,36 @@ XChangeProperty(
_Xconst unsigned char *data,
int nelements)
{
- return Success;
-}
+ (void)display;
+ (void)w;
+ (void)property;
+ (void)type;
+ (void)format;
+ (void)mode;
+ (void)data;
+ (void)nelements;
-Cursor
-XCreateGlyphCursor(
- Display *display,
- Font source_font,
- Font mask_font,
- unsigned int source_char,
- unsigned int mask_char,
- XColor _Xconst *foreground_color,
- XColor _Xconst *background_color)
-{
- return 1;
+ return Success;
}
XIC
XCreateIC(XIM xim, ...)
{
+ (void)xim;
return NULL;
}
-Cursor
-XCreatePixmapCursor(
- Display *display,
- Pixmap source,
- Pixmap mask,
- XColor *foreground_color,
- XColor *background_color,
- unsigned int x,
- unsigned int y)
-{
- return (Cursor) NULL;
-}
-
int
XDeleteProperty(
Display *display,
Window w,
Atom property)
{
- return Success;
-}
+ (void)display;
+ (void)w;
+ (void)property;
-void
-XDestroyIC(
- XIC ic)
-{
+ return Success;
}
Bool
@@ -102,6 +93,9 @@ XFilterEvent(
XEvent *event,
Window window)
{
+ (void)event;
+ (void)window;
+
return 0;
}
@@ -110,6 +104,9 @@ XForceScreenSaver(
Display *display,
int mode)
{
+ (void)display;
+ (void)mode;
+
return Success;
}
@@ -118,6 +115,9 @@ XFreeCursor(
Display *display,
Cursor cursor)
{
+ (void)display;
+ (void)cursor;
+
return Success;
}
@@ -125,6 +125,8 @@ GContext
XGContextFromGC(
GC gc)
{
+ (void)gc;
+
return (GContext) NULL;
}
@@ -133,6 +135,9 @@ XGetAtomName(
Display *display,
Atom atom)
{
+ (void)display;
+ (void)atom;
+
return NULL;
}
@@ -142,6 +147,10 @@ XGetWindowAttributes(
Window w,
XWindowAttributes *window_attributes_return)
{
+ (void)display;
+ (void)w;
+ (void)window_attributes_return;
+
return Success;
}
@@ -152,7 +161,12 @@ XGetWMColormapWindows(
Window **windows_return,
int *count_return)
{
- return (Status) 0;
+ (void)display;
+ (void)w;
+ (void)windows_return;
+ (void)count_return;
+
+ return Success;
}
int
@@ -161,6 +175,10 @@ XIconifyWindow(
Window w,
int screen_number)
{
+ (void)display;
+ (void)w;
+ (void)screen_number;
+
return Success;
}
@@ -170,6 +188,10 @@ XListHosts(
int *nhosts_return,
Bool *state_return)
{
+ (void)display;
+ (void)nhosts_return;
+ (void)state_return;
+
return NULL;
}
@@ -181,6 +203,12 @@ XLookupColor(
XColor *exact_def_return,
XColor *screen_def_return)
{
+ (void)display;
+ (void)colormap;
+ (void)color_name;
+ (void)exact_def_return;
+ (void)screen_def_return;
+
return Success;
}
@@ -189,6 +217,9 @@ XNextEvent(
Display *display,
XEvent *event_return)
{
+ (void)display;
+ (void)event_return;
+
return Success;
}
@@ -197,6 +228,9 @@ XPutBackEvent(
Display *display,
XEvent *event)
{
+ (void)display;
+ (void)event;
+
return Success;
}
@@ -207,6 +241,11 @@ XQueryColors(
XColor *defs_in_out,
int ncolors)
{
+ (void)display;
+ (void)colormap;
+ (void)defs_in_out;
+ (void)ncolors;
+
return Success;
}
@@ -219,6 +258,13 @@ XQueryTree(
Window **children_return,
unsigned int *nchildren_return)
{
+ (void)display;
+ (void)w;
+ (void)root_return;
+ (void)parent_return;
+ (void)children_return;
+ (void)nchildren_return;
+
return Success;
}
@@ -226,6 +272,8 @@ int
XRefreshKeyboardMapping(
XMappingEvent *event_map)
{
+ (void)event_map;
+
return Success;
}
@@ -234,6 +282,9 @@ XRootWindow(
Display *display,
int screen_number)
{
+ (void)display;
+ (void)screen_number;
+
return (Window) NULL;
}
@@ -243,6 +294,10 @@ XSelectInput(
Window w,
long event_mask)
{
+ (void)display;
+ (void)w;
+ (void)event_mask;
+
return Success;
}
@@ -254,6 +309,12 @@ XSendEvent(
long event_mask,
XEvent *event_send)
{
+ (void)display;
+ (void)w;
+ (void)propagate;
+ (void)event_mask;
+ (void)event_send;
+
return Success;
}
@@ -264,6 +325,11 @@ XSetCommand(
char **argv,
int argc)
{
+ (void)display;
+ (void)w;
+ (void)argv;
+ (void)argc;
+
return Success;
}
@@ -271,6 +337,8 @@ XErrorHandler
XSetErrorHandler(
XErrorHandler handler)
{
+ (void)handler;
+
return NULL;
}
@@ -280,6 +348,10 @@ XSetIconName(
Window w,
_Xconst char *icon_name)
{
+ (void)display;
+ (void)w;
+ (void)icon_name;
+
return Success;
}
@@ -289,6 +361,10 @@ XSetWindowBackground(
Window w,
unsigned long background_pixel)
{
+ (void)display;
+ (void)w;
+ (void)background_pixel;
+
return Success;
}
@@ -298,6 +374,10 @@ XSetWindowBackgroundPixmap(
Window w,
Pixmap background_pixmap)
{
+ (void)display;
+ (void)w;
+ (void)background_pixmap;
+
return Success;
}
@@ -307,6 +387,10 @@ XSetWindowBorder(
Window w,
unsigned long border_pixel)
{
+ (void)display;
+ (void)w;
+ (void)border_pixel;
+
return Success;
}
@@ -316,6 +400,10 @@ XSetWindowBorderPixmap(
Window w,
Pixmap border_pixmap)
{
+ (void)display;
+ (void)w;
+ (void)border_pixmap;
+
return Success;
}
@@ -325,6 +413,10 @@ XSetWindowBorderWidth(
Window w,
unsigned int width)
{
+ (void)display;
+ (void)w;
+ (void)width;
+
return Success;
}
@@ -334,6 +426,10 @@ XSetWindowColormap(
Window w,
Colormap colormap)
{
+ (void)display;
+ (void)w;
+ (void)colormap;
+
return Success;
}
@@ -348,6 +444,15 @@ XTranslateCoordinates(
int *dest_y_return,
Window *child_return)
{
+ (void)display;
+ (void)src_w;
+ (void)dest_w;
+ (void)src_x;
+ (void)src_y;
+ (void)dest_x_return;
+ (void)dest_y_return;
+ (void)child_return;
+
return 0;
}
@@ -358,6 +463,11 @@ XWindowEvent(
long event_mask,
XEvent *event_return)
{
+ (void)display;
+ (void)w;
+ (void)event_mask;
+ (void)event_return;
+
return Success;
}
@@ -367,6 +477,10 @@ XWithdrawWindow(
Window w,
int screen_number)
{
+ (void)display;
+ (void)w;
+ (void)screen_number;
+
return Success;
}
@@ -379,6 +493,13 @@ XmbLookupString(
KeySym *keysym_return,
Status *status_return)
{
+ (void)ic;
+ (void)event;
+ (void)buffer_return;
+ (void)bytes_buffer;
+ (void)keysym_return;
+ (void)status_return;
+
return Success;
}
@@ -389,7 +510,7 @@ XGetWindowProperty(
Atom property,
long long_offset,
long long_length,
- Bool delete,
+ Bool del,
Atom req_type,
Atom *actual_type_return,
int *actual_format_return,
@@ -397,6 +518,14 @@ XGetWindowProperty(
unsigned long *bytes_after_return,
unsigned char **prop_return)
{
+ (void)display;
+ (void)w;
+ (void)property;
+ (void)long_offset;
+ (void)long_length;
+ (void)del;
+ (void)req_type;
+
*actual_type_return = None;
*actual_format_return = 0;
*nitems_return = 0;
@@ -413,6 +542,8 @@ int
XFlush(
Display *display)
{
+ (void)display;
+
return 0;
}
@@ -420,6 +551,8 @@ int
XGrabServer(
Display *display)
{
+ (void)display;
+
return 0;
}
@@ -427,6 +560,8 @@ int
XUngrabServer(
Display *display)
{
+ (void)display;
+
return 0;
}
@@ -444,25 +579,29 @@ int
XNoOp(
Display *display)
{
- display->request++;
+ display->request++;
return 0;
}
XAfterFunction
XSynchronize(
Display *display,
- Bool bool)
+ Bool onoff)
{
- display->request++;
+ (void)onoff;
+
+ display->request++;
return NULL;
}
int
XSync(
Display *display,
- Bool bool)
+ Bool discard)
{
- display->request++;
+ (void)discard;
+
+ display->request++;
return 0;
}
@@ -472,3 +611,16 @@ XVisualIDFromVisual(
{
return visual->visualid;
}
+
+int
+XOffsetRegion(
+ Region rgn,
+ int dx,
+ int dy)
+{
+ (void)rgn;
+ (void)dx;
+ (void)dy;
+
+ return 0;
+}
diff --git a/win/targets.vc b/win/targets.vc
index 7f1d388..6bfebc7 100644
--- a/win/targets.vc
+++ b/win/targets.vc
@@ -4,7 +4,7 @@
# Part of the nmake based build system for Tcl and its extensions.
# This file defines some standard targets for the convenience of extensions
# and can be optionally included by the extension makefile.
-# See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for docs.
+# See TIP 477 (https://core.tcl-lang.org/tips/doc/trunk/tip/477.md) for docs.
$(PROJECT): setup pkgindex $(PRJLIB)
diff --git a/win/tcl.m4 b/win/tcl.m4
index a58dc2f..ca04f84 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -541,14 +541,14 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
if test "$ac_cv_cross" = "yes"; then
case "$do64bit" in
amd64|x64|yes)
- CC="x86_64-w64-mingw32-gcc"
+ CC="x86_64-w64-mingw32-${CC}"
LD="x86_64-w64-mingw32-ld"
AR="x86_64-w64-mingw32-ar"
RANLIB="x86_64-w64-mingw32-ranlib"
RC="x86_64-w64-mingw32-windres"
;;
*)
- CC="i686-w64-mingw32-gcc"
+ CC="i686-w64-mingw32-${CC}"
LD="i686-w64-mingw32-ld"
AR="i686-w64-mingw32-ar"
RANLIB="i686-w64-mingw32-ranlib"
@@ -685,10 +685,19 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
CFLAGS_DEBUG=-g
CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
- CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement"
+ CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wpointer-arith"
LDFLAGS_DEBUG=
LDFLAGS_OPTIMIZE=
+ case "${CC}" in
+ *++)
+ CFLAGS_WARNING="${CFLAGS_WARNING} -Wno-format"
+ ;;
+ *)
+ CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -Wdeclaration-after-statement"
+ ;;
+ esac
+
# Specify the CC output file names based on the target name
CC_OBJNAME="-o \[$]@"
CC_EXENAME="-o \[$]@"
@@ -764,28 +773,15 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
LIBSUFFIX="\${DBGX}.lib"
LIBFLAGSUFFIX="\${DBGX}"
- # This is a 2-stage check to make sure we have the 64-bit SDK
- # We have to know where the SDK is installed.
- # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs
if test "$do64bit" != "no" ; then
- if test "x${MSSDK}x" = "xx" ; then
- MSSDK="C:/Progra~1/Microsoft Platform SDK"
- fi
- MSSDK=`echo "$MSSDK" | sed -e 's!\\\!/!g'`
- PATH64=""
case "$do64bit" in
amd64|x64|yes)
MACHINE="AMD64" ; # assume AMD64 as default 64-bit build
- PATH64="${MSSDK}/Bin/Win64/x86/AMD64"
;;
ia64)
MACHINE="IA64"
- PATH64="${MSSDK}/Bin/Win64"
;;
esac
- if test ! -d "${PATH64}" ; then
- AC_MSG_WARN([Could not find 64-bit $MACHINE SDK])
- fi
AC_MSG_RESULT([ Using 64-bit $MACHINE mode])
fi
@@ -800,21 +796,12 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
esac
if test "$do64bit" != "no" ; then
- # The space-based-path will work for the Makefile, but will
- # not work if AC_TRY_COMPILE is called. TEA has the
- # TEA_PATH_NOSPACE to avoid this issue.
- # Check if _WIN64 is already recognized, and if so we don't
- # need to modify CC.
- AC_CHECK_DECL([_WIN64], [],
- [CC="\"${PATH64}/cl.exe\" -I\"${MSSDK}/Include\" \
- -I\"${MSSDK}/Include/crt\" \
- -I\"${MSSDK}/Include/crt/sys\""])
- RC="\"${MSSDK}/bin/rc.exe\""
+ RC="rc"
CFLAGS_DEBUG="-nologo -Zi -Od ${runtime}d"
# Do not use -O2 for Win64 - this has proved buggy in code gen.
CFLAGS_OPTIMIZE="-nologo -O1 ${runtime}"
- lflags="${lflags} -nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\""
- LINKBIN="\"${PATH64}/link.exe\""
+ lflags="${lflags} -nologo -MACHINE:${MACHINE}"
+ LINKBIN="link"
# Avoid 'unresolved external symbol __security_cookie' errors.
# c.f. http://support.microsoft.com/?id=894573
LIBS="$LIBS bufferoverflowU.lib"
@@ -948,6 +935,8 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
[Defined when cygwin/mingw ignores VOID define in winnt.h])
fi
+ AC_CHECK_HEADER(stdbool.h, [AC_DEFINE(HAVE_STDBOOL_H, 1, [Do we have <stdbool.h>?])],)
+
# See if the compiler supports casting to a union type.
# This is used to stop gcc from printing a compiler
# warning when initializing a union member.
@@ -1270,7 +1259,7 @@ AC_DEFUN([SC_ZIPFS_SUPPORT], [
ZIP_PROG="$ac_cv_path_zip"
AC_MSG_RESULT([$ZIP_PROG])
ZIP_PROG_OPTIONS="-rq"
- ZIP_PROG_VFSSEARCH="."
+ ZIP_PROG_VFSSEARCH="*"
AC_MSG_RESULT([Found INFO Zip in environment])
# Use standard arguments for zip
else
@@ -1278,7 +1267,7 @@ AC_DEFUN([SC_ZIPFS_SUPPORT], [
# We can use the locally distributed minizip instead
ZIP_PROG="./minizip${EXEEXT_FOR_BUILD}"
ZIP_PROG_OPTIONS="-o -r"
- ZIP_PROG_VFSSEARCH="."
+ ZIP_PROG_VFSSEARCH="*"
ZIP_INSTALL_OBJS="minizip${EXEEXT_FOR_BUILD}"
AC_MSG_RESULT([No zip found on PATH building minizip])
fi
diff --git a/win/tkWin32Dll.c b/win/tkWin32Dll.c
index 3c3d83a..49ffd83 100644
--- a/win/tkWin32Dll.c
+++ b/win/tkWin32Dll.c
@@ -104,6 +104,7 @@ DllMain(
#ifdef HAVE_NO_SEH
TCLEXCEPTION_REGISTRATION registration;
#endif
+ (void)reserved;
/*
* If we are attaching to the DLL from a new process, tell Tk about the
@@ -150,7 +151,7 @@ DllMain(
* Call TkFinalize
*/
- "movq $0x0, 0x0(%%esp)" "\n\t"
+ "movq $0x0, 0x0(%%rsp)" "\n\t"
"call TkFinalize" "\n\t"
/*
diff --git a/win/tkWin3d.c b/win/tkWin3d.c
index 9f7ca22..3684400 100644
--- a/win/tkWin3d.c
+++ b/win/tkWin3d.c
@@ -43,7 +43,7 @@ typedef struct {
TkBorder *
TkpGetBorder(void)
{
- WinBorder *borderPtr = ckalloc(sizeof(WinBorder));
+ WinBorder *borderPtr = (WinBorder *)ckalloc(sizeof(WinBorder));
borderPtr->light2ColorPtr = NULL;
borderPtr->dark2ColorPtr = NULL;
diff --git a/win/tkWinButton.c b/win/tkWinButton.c
index f4039cf..adcaa04 100644
--- a/win/tkWinButton.c
+++ b/win/tkWinButton.c
@@ -63,7 +63,7 @@ enum {
* widget classes.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
BITMAPINFOHEADER *boxesPtr; /* Information about the bitmap. */
DWORD *boxesPalette; /* Pointer to color palette. */
LPSTR boxesBits; /* Pointer to bitmap data. */
@@ -131,9 +131,9 @@ InitBoxes(void)
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- hrsrc = FindResource(module, TEXT("buttons"), RT_BITMAP);
+ hrsrc = FindResourceW(module, L"buttons", (LPWSTR) RT_BITMAP);
if (hrsrc == NULL) {
- Tcl_Panic("FindResource() failed for buttons bitmap resource, "
+ Tcl_Panic("FindResourceW() failed for buttons bitmap resource, "
"resources in tk_base.rc must be linked into Tk dll or static executable");
} else {
hblk = LoadResource(module, hrsrc);
@@ -149,7 +149,7 @@ InitBoxes(void)
size = tsdPtr->boxesPtr->biSize
+ (sizeof(RGBQUAD) << tsdPtr->boxesPtr->biBitCount)
+ tsdPtr->boxesPtr->biSizeImage;
- newBitmap = ckalloc(size);
+ newBitmap = (LPBITMAPINFOHEADER)ckalloc(size);
memcpy(newBitmap, tsdPtr->boxesPtr, size);
tsdPtr->boxesPtr = newBitmap;
tsdPtr->boxWidth = tsdPtr->boxesPtr->biWidth / 4;
@@ -182,7 +182,7 @@ InitBoxes(void)
*/
void
-TkpButtonSetDefaults()
+TkpButtonSetDefaults(void)
{
int width = GetSystemMetrics(SM_CXEDGE);
if (width > 0) {
@@ -211,8 +211,9 @@ TkpCreateButton(
Tk_Window tkwin)
{
WinButton *butPtr;
+ (void)tkwin;
- butPtr = ckalloc(sizeof(WinButton));
+ butPtr = (WinButton *)ckalloc(sizeof(WinButton));
butPtr->hwnd = NULL;
return (TkButton *) butPtr;
}
@@ -242,23 +243,23 @@ CreateProc(
{
Window window;
HWND parent;
- const TCHAR *class;
+ LPCWSTR windowClass;
WinButton *butPtr = (WinButton *)instanceData;
parent = Tk_GetHWND(parentWin);
if (butPtr->info.type == TYPE_LABEL) {
- class = TEXT("STATIC");
+ windowClass = L"STATIC";
butPtr->style = SS_OWNERDRAW | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
} else {
- class = TEXT("BUTTON");
+ windowClass = L"BUTTON";
butPtr->style = BS_OWNERDRAW | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
}
- butPtr->hwnd = CreateWindow(class, NULL, butPtr->style,
+ butPtr->hwnd = CreateWindowW(windowClass, NULL, butPtr->style,
Tk_X(tkwin), Tk_Y(tkwin), Tk_Width(tkwin), Tk_Height(tkwin),
parent, NULL, Tk_GetHINSTANCE(), NULL);
SetWindowPos(butPtr->hwnd, HWND_TOP, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
- butPtr->oldProc = (WNDPROC)SetWindowLongPtr(butPtr->hwnd, GWLP_WNDPROC,
+ butPtr->oldProc = (WNDPROC)SetWindowLongPtrW(butPtr->hwnd, GWLP_WNDPROC,
(LONG_PTR) ButtonProc);
window = Tk_AttachHWND(tkwin, butPtr->hwnd);
@@ -289,7 +290,7 @@ TkpDestroyButton(
HWND hwnd = winButPtr->hwnd;
if (hwnd) {
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) winButPtr->oldProc);
+ SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR) winButPtr->oldProc);
}
}
@@ -316,14 +317,14 @@ TkpDisplayButton(
{
TkWinDCState state;
HDC dc;
- register TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
GC gc;
Tk_3DBorder border;
Pixmap pixmap;
int x = 0; /* Initialization only needed to stop compiler
* warning. */
int y, relief;
- register Tk_Window tkwin = butPtr->tkwin;
+ Tk_Window tkwin = butPtr->tkwin;
int width = 0, height = 0, haveImage = 0, haveText = 0, drawRing = 0;
RECT rect;
int defaultWidth; /* Width of default ring. */
@@ -405,7 +406,10 @@ TkpDisplayButton(
* Compute width of default ring and offset for pushed buttons.
*/
- if (butPtr->type == TYPE_BUTTON) {
+ if (butPtr->type == TYPE_LABEL) {
+ defaultWidth = butPtr->highlightWidth;
+ offset = 0;
+ } else if (butPtr->type == TYPE_BUTTON) {
defaultWidth = ((butPtr->defaultState == DEFAULT_ACTIVE)
? butPtr->highlightWidth : 0);
offset = 1;
@@ -759,17 +763,24 @@ TkpDisplayButton(
butPtr->borderWidth, relief);
}
if (defaultWidth != 0) {
+ int highlightColor;
+
dc = TkWinGetDrawableDC(butPtr->display, pixmap, &state);
+ if (butPtr->type == TYPE_LABEL) {
+ highlightColor = (int) Tk_3DBorderColor(butPtr->highlightBorder)->pixel;
+ } else {
+ highlightColor = (int) butPtr->highlightColorPtr->pixel;
+ }
TkWinFillRect(dc, 0, 0, Tk_Width(tkwin), defaultWidth,
- (int) butPtr->highlightColorPtr->pixel);
+ highlightColor);
TkWinFillRect(dc, 0, 0, defaultWidth, Tk_Height(tkwin),
- (int) butPtr->highlightColorPtr->pixel);
+ highlightColor);
TkWinFillRect(dc, 0, Tk_Height(tkwin) - defaultWidth,
Tk_Width(tkwin), defaultWidth,
- (int) butPtr->highlightColorPtr->pixel);
+ highlightColor);
TkWinFillRect(dc, Tk_Width(tkwin) - defaultWidth, 0,
defaultWidth, Tk_Height(tkwin),
- (int) butPtr->highlightColorPtr->pixel);
+ highlightColor);
TkWinReleaseDrawableDC(pixmap, dc, &state);
}
@@ -808,7 +819,7 @@ TkpDisplayButton(
void
TkpComputeButtonGeometry(
- register TkButton *butPtr) /* Button whose geometry may have changed. */
+ TkButton *butPtr) /* Button whose geometry may have changed. */
{
int txtWidth, txtHeight; /* Width and height of text */
int imgWidth, imgHeight; /* Width and height of image */
@@ -1290,13 +1301,13 @@ ButtonProc(
return 0;
}
}
-
+ /* FALLTHRU */
default:
- if (Tk_TranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
+ if (TkTranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
return result;
}
}
- return DefWindowProc(hwnd, message, wParam, lParam);
+ return DefWindowProcW(hwnd, message, wParam, lParam);
}
/*
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c
index 877eed4..2b009af 100644
--- a/win/tkWinClipboard.c
+++ b/win/tkWinClipboard.c
@@ -78,10 +78,9 @@ TkSelGetSelection(
CloseClipboard();
goto error;
}
- data = GlobalLock(handle);
+ data = (char *)GlobalLock(handle);
Tcl_DStringInit(&ds);
- Tcl_UniCharToUtfDString((Tcl_UniChar *)data,
- Tcl_UniCharLen((Tcl_UniChar *)data), &ds);
+ Tcl_WCharToUtfDString((WCHAR *)data, wcslen((WCHAR *)data), &ds);
GlobalUnlock(handle);
} else if (IsClipboardFormatAvailable(CF_TEXT)) {
/*
@@ -102,7 +101,7 @@ TkSelGetSelection(
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds, "cp######", -1);
- data = GlobalLock(handle);
+ data = (char *)GlobalLock(handle);
/*
* Even though the documentation claims that GetLocaleInfo expects
@@ -132,7 +131,7 @@ TkSelGetSelection(
CloseClipboard();
goto error;
}
- data = GlobalLock(handle);
+ data = (char *)GlobalLock(handle);
Tcl_ExternalToUtfDString(encoding, data, -1, &ds);
GlobalUnlock(handle);
if (encoding) {
@@ -151,15 +150,16 @@ TkSelGetSelection(
if (drop->fWide) {
WCHAR *fname = (WCHAR *) ((char *) drop + drop->pFiles);
Tcl_DString dsTmp;
- int count = 0, len;
+ int count = 0;
+ size_t len;
while (*fname != 0) {
if (count) {
Tcl_DStringAppend(&ds, "\n", 1);
}
- len = Tcl_UniCharLen((Tcl_UniChar *) fname);
+ len = wcslen(fname);
Tcl_DStringInit(&dsTmp);
- Tcl_UniCharToUtfDString((Tcl_UniChar *) fname, len, &dsTmp);
+ Tcl_WCharToUtfDString(fname, len, &dsTmp);
Tcl_DStringAppend(&ds, Tcl_DStringValue(&dsTmp),
Tcl_DStringLength(&dsTmp));
Tcl_DStringFree(&dsTmp);
@@ -234,6 +234,8 @@ XSetSelectionOwner(
{
HWND hwnd = owner ? TkWinGetHWND(owner) : NULL;
Tk_Window tkwin;
+ (void)display;
+ (void)time;
/*
* This is a gross hack because the Tk_InternAtom interface is broken. It
@@ -283,6 +285,7 @@ TkWinClipboardRender(
char *buffer, *p, *rawText, *endPtr;
int length;
Tcl_DString ds;
+ (void)format;
for (targetPtr = dispPtr->clipTargetPtr; targetPtr != NULL;
targetPtr = targetPtr->nextPtr) {
@@ -314,7 +317,7 @@ TkWinClipboardRender(
* Copy the data and change EOL characters.
*/
- buffer = rawText = ckalloc(length + 1);
+ buffer = rawText = (char *)ckalloc(length + 1);
if (targetPtr != NULL) {
for (cbPtr = targetPtr->firstBufferPtr; cbPtr != NULL;
cbPtr = cbPtr->nextPtr) {
@@ -329,14 +332,8 @@ TkWinClipboardRender(
}
*buffer = '\0';
- /*
- * Depending on the platform, turn the data into Unicode or the system
- * encoding before placing it on the clipboard.
- */
-
-#ifdef UNICODE
Tcl_DStringInit(&ds);
- Tcl_WinUtfToTChar(rawText, -1, &ds);
+ Tcl_UtfToWCharDString(rawText, -1, &ds);
ckfree(rawText);
handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
(unsigned) Tcl_DStringLength(&ds) + 2);
@@ -344,28 +341,12 @@ TkWinClipboardRender(
Tcl_DStringFree(&ds);
return;
}
- buffer = GlobalLock(handle);
+ buffer = (char *)GlobalLock(handle);
memcpy(buffer, Tcl_DStringValue(&ds),
(unsigned) Tcl_DStringLength(&ds) + 2);
GlobalUnlock(handle);
Tcl_DStringFree(&ds);
SetClipboardData(CF_UNICODETEXT, handle);
-#else
- Tcl_UtfToExternalDString(NULL, rawText, -1, &ds);
- ckfree(rawText);
- handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
- (unsigned) Tcl_DStringLength(&ds) + 1);
- if (!handle) {
- Tcl_DStringFree(&ds);
- return;
- }
- buffer = GlobalLock(handle);
- memcpy(buffer, Tcl_DStringValue(&ds),
- (unsigned) Tcl_DStringLength(&ds) + 1);
- GlobalUnlock(handle);
- Tcl_DStringFree(&ds);
- SetClipboardData(CF_TEXT, handle);
-#endif
}
/*
@@ -391,6 +372,8 @@ TkSelUpdateClipboard(
TkClipboardTarget *targetPtr)
{
HWND hwnd = TkWinGetHWND(winPtr->window);
+ (void)targetPtr;
+
UpdateClipboard(hwnd);
}
@@ -443,7 +426,7 @@ UpdateClipboard(
void
TkSelEventProc(
Tk_Window tkwin, /* Window for which event was targeted. */
- register XEvent *eventPtr) /* X event: either SelectionClear,
+ XEvent *eventPtr) /* X event: either SelectionClear,
* SelectionRequest, or SelectionNotify. */
{
if (eventPtr->type == SelectionClear) {
@@ -470,8 +453,9 @@ TkSelEventProc(
void
TkSelPropProc(
- register XEvent *eventPtr) /* X PropertyChange event. */
+ XEvent *eventPtr) /* X PropertyChange event. */
{
+ (void)eventPtr;
}
/*
diff --git a/win/tkWinColor.c b/win/tkWinColor.c
index 5540d9a..78e3b6c 100644
--- a/win/tkWinColor.c
+++ b/win/tkWinColor.c
@@ -173,7 +173,7 @@ TkpGetColor(
&& FindSystemColor(name+6, &color, &index))
|| TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), name,
&color)) {
- winColPtr = ckalloc(sizeof(WinColor));
+ winColPtr = (WinColor *)ckalloc(sizeof(WinColor));
winColPtr->info.color = color;
winColPtr->index = index;
@@ -211,7 +211,7 @@ TkpGetColorByValue(
XColor *colorPtr) /* Red, green, and blue fields indicate
* desired color. */
{
- WinColor *tkColPtr = ckalloc(sizeof(WinColor));
+ WinColor *tkColPtr = (WinColor *)ckalloc(sizeof(WinColor));
tkColPtr->info.color.red = colorPtr->red;
tkColPtr->info.color.green = colorPtr->green;
@@ -274,7 +274,7 @@ int
TkWinIndexOfColor(
XColor *colorPtr)
{
- register WinColor *winColPtr = (WinColor *) colorPtr;
+ WinColor *winColPtr = (WinColor *) colorPtr;
if (winColPtr->info.magic == COLOR_MAGIC) {
return winColPtr->index;
}
@@ -307,6 +307,7 @@ XAllocColor(
TkWinColormap *cmap = (TkWinColormap *) colormap;
PALETTEENTRY entry, closeEntry;
HDC dc = GetDC(NULL);
+ (void)display;
entry.peRed = (color->red) >> 8;
entry.peGreen = (color->green) >> 8;
@@ -316,7 +317,7 @@ XAllocColor(
if (GetDeviceCaps(dc, RASTERCAPS) & RC_PALETTE) {
unsigned long sizePalette = GetDeviceCaps(dc, SIZEPALETTE);
UINT newPixel, closePixel;
- int new;
+ int isNew;
size_t refCount;
Tcl_HashEntry *entryPtr;
UINT index;
@@ -347,7 +348,7 @@ XAllocColor(
color->blue = closeEntry.peBlue * 257;
entry = closeEntry;
if (index >= cmap->size) {
- OutputDebugStringA("XAllocColor: Colormap is bigger than we thought");
+ OutputDebugStringW(L"XAllocColor: Colormap is bigger than we thought");
}
} else {
cmap->size++;
@@ -358,8 +359,8 @@ XAllocColor(
color->pixel = PALETTERGB(entry.peRed, entry.peGreen, entry.peBlue);
entryPtr = Tcl_CreateHashEntry(&cmap->refCounts,
- INT2PTR(color->pixel), &new);
- if (new) {
+ INT2PTR(color->pixel), &isNew);
+ if (isNew) {
refCount = 1;
} else {
refCount = (size_t)Tcl_GetHashValue(entryPtr) + 1;
@@ -414,6 +415,8 @@ XFreeColors(
PALETTEENTRY entry, *entries;
Tcl_HashEntry *entryPtr;
HDC dc = GetDC(NULL);
+ (void)display;
+ (void)planes;
/*
* We don't have to do anything for non-palette devices.
@@ -436,7 +439,7 @@ XFreeColors(
GetPaletteEntries(cmap->palette, index, 1, &entry);
if (cref == RGB(entry.peRed, entry.peGreen, entry.peBlue)) {
count = cmap->size - index;
- entries = ckalloc(sizeof(PALETTEENTRY) * count);
+ entries = (PALETTEENTRY *)ckalloc(sizeof(PALETTEENTRY) * count);
GetPaletteEntries(cmap->palette, index+1, count, entries);
SetPaletteEntries(cmap->palette, index, count, entries);
ckfree(entries);
@@ -482,9 +485,13 @@ XCreateColormap(
PALETTEENTRY *entryPtr;
TkWinColormap *cmap;
Tcl_HashEntry *hashPtr;
- int new;
+ int isNew;
UINT i;
HPALETTE sysPal;
+ (void)display;
+ (void)w;
+ (void)visual;
+ (void)alloc;
/*
* Allocate a starting palette with all of the reserved colors.
@@ -496,7 +503,7 @@ XCreateColormap(
logPalettePtr->palNumEntries = GetPaletteEntries(sysPal, 0, 256,
logPalettePtr->palPalEntry);
- cmap = ckalloc(sizeof(TkWinColormap));
+ cmap = (TkWinColormap *)ckalloc(sizeof(TkWinColormap));
cmap->size = logPalettePtr->palNumEntries;
cmap->stale = 0;
cmap->palette = CreatePalette(logPalettePtr);
@@ -509,7 +516,7 @@ XCreateColormap(
for (i = 0; i < logPalettePtr->palNumEntries; i++) {
entryPtr = logPalettePtr->palPalEntry + i;
hashPtr = Tcl_CreateHashEntry(&cmap->refCounts, INT2PTR(PALETTERGB(
- entryPtr->peRed, entryPtr->peGreen, entryPtr->peBlue)), &new);
+ entryPtr->peRed, entryPtr->peGreen, entryPtr->peBlue)), &isNew);
Tcl_SetHashValue(hashPtr, INT2PTR(1));
}
@@ -539,6 +546,7 @@ XFreeColormap(
Colormap colormap)
{
TkWinColormap *cmap = (TkWinColormap *) colormap;
+ (void)display;
if (!DeleteObject(cmap->palette)) {
Tcl_Panic("Unable to free colormap, palette is still selected");
diff --git a/win/tkWinCursor.c b/win/tkWinCursor.c
index 622ba4d..63f3add 100644
--- a/win/tkWinCursor.c
+++ b/win/tkWinCursor.c
@@ -71,7 +71,7 @@ static struct CursorName {
* The default cursor is used whenever no other cursor has been specified.
*/
-#define TK_DEFAULT_CURSOR IDC_ARROW
+#define TK_DEFAULT_CURSOR (LPCWSTR)IDC_ARROW
/*
*----------------------------------------------------------------------
@@ -100,6 +100,7 @@ TkGetCursorByName(
TkWinCursor *cursorPtr;
int argc;
const char **argv = NULL;
+ (void)tkwin;
/*
* All cursor names are valid lists of one element (for
@@ -113,7 +114,7 @@ TkGetCursorByName(
goto badCursorSpec;
}
- cursorPtr = ckalloc(sizeof(TkWinCursor));
+ cursorPtr = (TkWinCursor *)ckalloc(sizeof(TkWinCursor));
cursorPtr->info.cursor = (Tk_Cursor) cursorPtr;
cursorPtr->winCursor = NULL;
cursorPtr->system = 0;
@@ -145,7 +146,7 @@ TkGetCursorByName(
for (namePtr = cursorNames; namePtr->name != NULL; namePtr++) {
if (strcmp(namePtr->name, argv[0]) == 0) {
- cursorPtr->winCursor = LoadCursor(NULL, namePtr->id);
+ cursorPtr->winCursor = LoadCursorW(NULL, (LPCWSTR) namePtr->id);
break;
}
}
@@ -201,6 +202,16 @@ TkCreateCursorFromData(
XColor fgColor, /* Foreground color for cursor. */
XColor bgColor) /* Background color for cursor. */
{
+ (void)tkwin;
+ (void)source;
+ (void)mask;
+ (void)width;
+ (void)height;
+ (void)xHot;
+ (void)yHot;
+ (void)fgColor;
+ (void)bgColor;
+
return NULL;
}
@@ -225,6 +236,8 @@ void
TkpFreeCursor(
TkCursor *cursorPtr)
{
+ (void)cursorPtr;
+
/* TkWinCursor *winCursorPtr = (TkWinCursor *) cursorPtr; */
}
@@ -253,7 +266,7 @@ TkpSetCursor(
TkWinCursor *winCursor = (TkWinCursor *) cursor;
if (winCursor == NULL || winCursor->winCursor == NULL) {
- hcursor = LoadCursor(NULL, TK_DEFAULT_CURSOR);
+ hcursor = LoadCursorW(NULL, TK_DEFAULT_CURSOR);
} else {
hcursor = winCursor->winCursor;
}
diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h
index 194ee1f..33756f8 100644
--- a/win/tkWinDefault.h
+++ b/win/tkWinDefault.h
@@ -180,7 +180,9 @@
*/
#define DEF_FRAME_BG_COLOR NORMAL_BG
+#define DEF_FRAME_BG_IMAGE NULL
#define DEF_FRAME_BG_MONO WHITE
+#define DEF_FRAME_BG_TILE "0"
#define DEF_FRAME_BORDER_WIDTH "0"
#define DEF_FRAME_CLASS "Frame"
#define DEF_FRAME_COLORMAP ""
@@ -521,6 +523,14 @@
#define DEF_CANVTEXT_FONT "TkDefaultFont"
/*
+ * Defaults for canvas items
+ * (arcs, bitmaps, lines, polygons, rectangles, and ovals):
+ */
+
+#define DEF_CANVBMAP_FG NORMAL_FG
+#define DEF_CANVITEM_OUTLINE NORMAL_FG
+
+/*
* Defaults for toplevels (most of the defaults for frames also apply
* to toplevels):
*/
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index 11b556a..9f53396 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -40,15 +40,11 @@
#define BIF_NEWDIALOGSTYLE 0x0040
#endif
-#ifndef BFFM_VALIDATEFAILED
-#ifdef UNICODE
-#define BFFM_VALIDATEFAILED 4
-#else
-#define BFFM_VALIDATEFAILED 3
-#endif
-#endif /* BFFM_VALIDATEFAILED */
+#ifndef BFFM_VALIDATEFAILEDW
+#define BFFM_VALIDATEFAILEDW 4
+#endif /* BFFM_VALIDATEFAILEDW */
-typedef struct ThreadSpecificData {
+typedef struct {
int debugFlag; /* Flags whether we should output debugging
* information while displaying a builtin
* dialog. */
@@ -120,11 +116,11 @@ static const struct {int type; int btnIds[3];} allowedTypes[] = {
*/
#define TkWinGetHInstance(from) \
- ((HINSTANCE) GetWindowLongPtr((from), GWLP_HINSTANCE))
+ ((HINSTANCE) GetWindowLongPtrW((from), GWLP_HINSTANCE))
#define TkWinGetUserData(from) \
- GetWindowLongPtr((from), GWLP_USERDATA)
+ GetWindowLongPtrW((from), GWLP_USERDATA)
#define TkWinSetUserData(to,what) \
- SetWindowLongPtr((to), GWLP_USERDATA, (LPARAM)(what))
+ SetWindowLongPtrW((to), GWLP_USERDATA, (LPARAM)(what))
/*
* The value of TK_MULTI_MAX_PATH dictates how many files can be retrieved
@@ -143,8 +139,8 @@ static const struct {int type; int btnIds[3];} allowedTypes[] = {
*/
typedef struct {
- TCHAR initDir[MAX_PATH]; /* Initial folder to use */
- TCHAR retDir[MAX_PATH]; /* Returned folder to use */
+ WCHAR initDir[MAX_PATH]; /* Initial folder to use */
+ WCHAR retDir[MAX_PATH]; /* Returned folder to use */
Tcl_Interp *interp;
int mustExist; /* True if file must exist to return from
* callback */
@@ -161,7 +157,7 @@ typedef struct OFNData {
int dynFileBufferSize; /* Dynamic filename buffer size, stored to
* avoid shrinking and expanding the buffer
* when selection changes */
- TCHAR *dynFileBuffer; /* Dynamic filename buffer */
+ WCHAR *dynFileBuffer; /* Dynamic filename buffer */
} OFNData;
/*
@@ -180,12 +176,9 @@ typedef struct OFNOpts {
int confirmOverwrite; /* Confirm before overwriting */
int mustExist; /* Used only for */
int forceXPStyle; /* XXX - Force XP style even on newer systems */
- TCHAR file[TK_MULTI_MAX_PATH]; /* File name
+ WCHAR file[TK_MULTI_MAX_PATH]; /* File name
XXX - fixed size because it was so
historically. Why not malloc'ed ?
- XXX - also, TCHAR should really be WCHAR
- because TkWinGetUnicodeEncoding is always
- UCS2.
*/
} OFNOpts;
@@ -430,7 +423,7 @@ typedef struct IFileSaveDialogVtbl {
ULONG ( STDMETHODCALLTYPE *Release )( IFileSaveDialog *);
HRESULT ( STDMETHODCALLTYPE *Show )(
IFileSaveDialog *, HWND);
- HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog * this,
+ HRESULT ( STDMETHODCALLTYPE *SetFileTypes )( IFileSaveDialog *,
UINT, const TCLCOMDLG_FILTERSPEC *);
HRESULT ( STDMETHODCALLTYPE *SetFileTypeIndex )(
IFileSaveDialog *, UINT);
@@ -596,8 +589,7 @@ static UINT APIENTRY OFNHookProc(HWND hdlg, UINT uMsg, WPARAM wParam,
LPARAM lParam);
static LRESULT CALLBACK MsgBoxCBTProc(int nCode, WPARAM wParam, LPARAM lParam);
static void SetTkDialog(ClientData clientData);
-static const char *ConvertExternalFilename(TCHAR *filename,
- Tcl_DString *dsPtr);
+static const char *ConvertExternalFilename(LPCWSTR, Tcl_DString *);
static void LoadShellProcs(void);
@@ -637,20 +629,21 @@ struct ShellProcPointers {
* ShellProcs is populated.
*-------------------------------------------------------------------------
*/
-static void LoadShellProcs()
+static void LoadShellProcs(void)
{
static HMODULE shell32_handle = NULL;
- if (shell32_handle != NULL)
- return; /* We have already been through here. */
+ if (shell32_handle != NULL) {
+ return; /* We have already been through here. */
+ }
- shell32_handle = GetModuleHandle(TEXT("shell32.dll"));
- if (shell32_handle == NULL) /* Should never happen but check anyways. */
- return;
+ shell32_handle = GetModuleHandleW(L"shell32.dll");
+ if (shell32_handle == NULL) { /* Should never happen but check anyways. */
+ return;
+ }
- ShellProcs.SHCreateItemFromParsingName =
- (SHCreateItemFromParsingNameProc*) GetProcAddress(shell32_handle,
- "SHCreateItemFromParsingName");
+ ShellProcs.SHCreateItemFromParsingName = (SHCreateItemFromParsingNameProc*)
+ (void *)GetProcAddress(shell32_handle, "SHCreateItemFromParsingName");
}
@@ -699,7 +692,7 @@ EatSpuriousMessageBugFix(void)
DWORD nTime = GetTickCount() + 250;
while (GetTickCount() < nTime) {
- PeekMessage(&msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE);
+ PeekMessageW(&msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE);
}
}
@@ -726,7 +719,7 @@ void
TkWinDialogDebug(
int debug)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
tsdPtr->debugFlag = debug;
@@ -758,10 +751,10 @@ Tk_ChooseColorObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData, parent;
+ Tk_Window tkwin = (Tk_Window)clientData, parent;
HWND hWnd;
int i, oldMode, winCode, result;
- CHOOSECOLOR chooseColor;
+ CHOOSECOLORW chooseColor;
static int inited = 0;
static COLORREF dwCustColors[16];
static long oldColor; /* the color selected last time */
@@ -796,8 +789,8 @@ Tk_ChooseColorObjCmd(
chooseColor.lpCustColors = dwCustColors;
chooseColor.Flags = CC_RGBINIT | CC_FULLOPEN | CC_ENABLEHOOK;
chooseColor.lCustData = (LPARAM) NULL;
- chooseColor.lpfnHook = (LPOFNHOOKPROC) ColorDlgHookProc;
- chooseColor.lpTemplateName = (LPTSTR) interp;
+ chooseColor.lpfnHook = (LPOFNHOOKPROC)(void *)ColorDlgHookProc;
+ chooseColor.lpTemplateName = (LPWSTR) interp;
for (i = 1; i < objc; i += 2) {
int index;
@@ -849,7 +842,7 @@ Tk_ChooseColorObjCmd(
chooseColor.hwndOwner = hWnd;
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
- winCode = ChooseColor(&chooseColor);
+ winCode = ChooseColorW(&chooseColor);
(void) Tcl_SetServiceMode(oldMode);
/*
@@ -912,10 +905,11 @@ ColorDlgHookProc(
WPARAM wParam, /* First message parameter. */
LPARAM lParam) /* Second message parameter. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
const char *title;
CHOOSECOLOR *ccPtr;
+ (void)wParam;
if (WM_INITDIALOG == uMsg) {
@@ -929,7 +923,8 @@ ColorDlgHookProc(
if ((title != NULL) && (title[0] != '\0')) {
Tcl_DString ds;
- SetWindowText(hDlg, Tcl_WinUtfToTChar(title,-1,&ds));
+ Tcl_DStringInit(&ds);
+ SetWindowTextW(hDlg, Tcl_UtfToWCharDString(title, -1, &ds));
Tcl_DStringFree(&ds);
}
if (tsdPtr->debugFlag) {
@@ -1092,7 +1087,7 @@ ParseOFNOptions(
ZeroMemory(optsPtr, sizeof(*optsPtr));
// optsPtr->forceXPStyle = 1;
- optsPtr->tkwin = clientData;
+ optsPtr->tkwin = (Tk_Window)clientData;
optsPtr->confirmOverwrite = 1; /* By default we ask for confirmation */
Tcl_DStringInit(&optsPtr->utfDirString);
optsPtr->file[0] = 0;
@@ -1153,7 +1148,7 @@ ParseOFNOptions(
Tcl_DStringFree(&ds);
break;
case FILE_PARENT:
- optsPtr->tkwin = Tk_NameToWindow(interp, string, clientData);
+ optsPtr->tkwin = Tk_NameToWindow(interp, string, (Tk_Window)clientData);
if (optsPtr->tkwin == NULL)
goto error_return;
break;
@@ -1208,11 +1203,11 @@ error_return: /* interp should already hold error */
* If new dialogs are available, COM is also initialized.
*----------------------------------------------------------------------
*/
-static int VistaFileDialogsAvailable()
+static int VistaFileDialogsAvailable(void)
{
HRESULT hr;
IFileDialog *fdlgPtr = NULL;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->newFileDialogsState == FDLG_STATE_INIT) {
@@ -1274,7 +1269,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
IShellItem *dirIf = NULL;
LPWSTR wstr;
Tcl_Obj *resultObj = NULL;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
int oldMode;
@@ -1378,8 +1373,9 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
const char *src;
src = Tcl_GetString(optsPtr->extObj);
- wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->extObj->length, &ds);
- if (wstr[0] == L'.')
+ Tcl_DStringInit(&ds);
+ wstr = Tcl_UtfToWCharDString(src, optsPtr->extObj->length, &ds);
+ if (wstr[0] == '.')
++wstr;
hr = fdlgIf->lpVtbl->SetDefaultExtension(fdlgIf, wstr);
Tcl_DStringFree(&ds);
@@ -1392,7 +1388,8 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
const char *src;
src = Tcl_GetString(optsPtr->titleObj);
- wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->titleObj->length, &ds);
+ Tcl_DStringInit(&ds);
+ wstr = Tcl_UtfToWCharDString(src, optsPtr->titleObj->length, &ds);
hr = fdlgIf->lpVtbl->SetTitle(fdlgIf, wstr);
Tcl_DStringFree(&ds);
if (FAILED(hr))
@@ -1412,9 +1409,9 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
normPath = Tcl_FSGetNormalizedPath(interp, iniDirPath);
/* XXX - Note on failures do not raise error, simply ignore ini dir */
if (normPath) {
- const WCHAR *nativePath;
+ LPCWSTR nativePath;
Tcl_IncrRefCount(normPath);
- nativePath = Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/
+ nativePath = (LPCWSTR)Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/
if (nativePath) {
hr = ShellProcs.SHCreateItemFromParsingName(
nativePath, NULL,
@@ -1445,7 +1442,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
/*
* Clear interp result since it might have been set during the modal loop.
- * http://core.tcl.tk/tk/tktview/4a0451f5291b3c9168cc560747dae9264e1d2ef6
+ * https://core.tcl-lang.org/tk/tktview/4a0451f5291b3c9168cc560747dae9264e1d2ef6
*/
Tcl_ResetResult(interp);
@@ -1518,7 +1515,8 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
Tcl_DString ftds;
Tcl_Obj *ftobj;
- Tcl_WinTCharToUtf(filterPtr[ftix-1].pszName, -1, &ftds);
+ Tcl_DStringInit(&ftds);
+ Tcl_WCharToUtfDString(filterPtr[ftix-1].pszName, wcslen(filterPtr[ftix-1].pszName), &ftds);
ftobj = Tcl_NewStringObj(Tcl_DStringValue(&ftds),
Tcl_DStringLength(&ftds));
Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL,
@@ -1572,7 +1570,7 @@ vamoose: /* (hr != 0) => error */
*/
static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper)
{
- OPENFILENAME ofn;
+ OPENFILENAMEW ofn;
OFNData ofnData;
int cdlgerr;
int filterIndex = 0, result = TCL_ERROR, winCode, oldMode;
@@ -1580,7 +1578,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
Tcl_DString utfFilterString, ds;
Tcl_DString extString, filterString, dirString, titleString;
const char *str;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
ZeroMemory(&ofnData, sizeof(OFNData));
@@ -1605,7 +1603,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
ofn.nMaxFile = TK_MULTI_MAX_PATH;
ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR
| OFN_EXPLORER| OFN_ENABLEHOOK| OFN_ENABLESIZING;
- ofn.lpfnHook = (LPOFNHOOKPROC) OFNHookProc;
+ ofn.lpfnHook = (LPOFNHOOKPROC)(void *)OFNHookProc;
ofn.lCustData = (LPARAM) &ofnData;
if (oper != OFN_FILE_SAVE) {
@@ -1625,24 +1623,26 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
*/
ofnData.dynFileBufferSize = 512;
- ofnData.dynFileBuffer = ckalloc(512 * sizeof(TCHAR));
+ ofnData.dynFileBuffer = (WCHAR *)ckalloc(512 * sizeof(WCHAR));
}
if (optsPtr->extObj != NULL) {
- str = Tcl_GetString(optsPtr->extObj);
- if (str[0] == '.')
- ++str;
- Tcl_WinUtfToTChar(str, -1, &extString);
- ofn.lpstrDefExt = (TCHAR *) Tcl_DStringValue(&extString);
+ str = Tcl_GetString(optsPtr->extObj);
+ if (str[0] == '.') {
+ ++str;
+ }
+ Tcl_DStringInit(&extString);
+ ofn.lpstrDefExt = Tcl_UtfToWCharDString(str, -1, &extString);
}
- Tcl_WinUtfToTChar(Tcl_DStringValue(&utfFilterString),
+ Tcl_DStringInit(&filterString);
+ ofn.lpstrFilter = Tcl_UtfToWCharDString(Tcl_DStringValue(&utfFilterString),
Tcl_DStringLength(&utfFilterString), &filterString);
- ofn.lpstrFilter = (TCHAR *) Tcl_DStringValue(&filterString);
ofn.nFilterIndex = filterIndex;
if (Tcl_DStringValue(&optsPtr->utfDirString)[0] != '\0') {
- Tcl_WinUtfToTChar(Tcl_DStringValue(&optsPtr->utfDirString),
+ Tcl_DStringInit(&dirString);
+ Tcl_UtfToWCharDString(Tcl_DStringValue(&optsPtr->utfDirString),
Tcl_DStringLength(&optsPtr->utfDirString), &dirString);
} else {
/*
@@ -1658,16 +1658,17 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
Tcl_DStringValue(&optsPtr->utfDirString), &cwd) == NULL)) {
Tcl_ResetResult(interp);
} else {
- Tcl_WinUtfToTChar(Tcl_DStringValue(&cwd),
+ Tcl_DStringInit(&dirString);
+ Tcl_UtfToWCharDString(Tcl_DStringValue(&cwd),
Tcl_DStringLength(&cwd), &dirString);
}
Tcl_DStringFree(&cwd);
}
- ofn.lpstrInitialDir = (TCHAR *) Tcl_DStringValue(&dirString);
+ ofn.lpstrInitialDir = (WCHAR *) Tcl_DStringValue(&dirString);
if (optsPtr->titleObj != NULL) {
- Tcl_WinUtfToTChar(Tcl_GetString(optsPtr->titleObj), -1, &titleString);
- ofn.lpstrTitle = (TCHAR *) Tcl_DStringValue(&titleString);
+ Tcl_DStringInit(&titleString);
+ ofn.lpstrTitle = Tcl_UtfToWCharDString(Tcl_GetString(optsPtr->titleObj), -1, &titleString);
}
/*
@@ -1676,9 +1677,9 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
if (oper != OFN_FILE_SAVE) {
- winCode = GetOpenFileName(&ofn);
+ winCode = GetOpenFileNameW(&ofn);
} else {
- winCode = GetSaveFileName(&ofn);
+ winCode = GetSaveFileNameW(&ofn);
}
Tcl_SetServiceMode(oldMode);
EatSpuriousMessageBugFix();
@@ -1714,7 +1715,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
/*
* We now allow FNERR_BUFFERTOOSMALL when multiselection is enabled. The
* filename buffer has been dynamically allocated by the OFN dialog
- * procedure to accomodate all selected files.
+ * procedure to accommodate all selected files.
*/
if ((winCode != 0)
@@ -1732,7 +1733,7 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper
* first element is the directory path.
*/
- TCHAR *files = ofnData.dynFileBuffer;
+ WCHAR *files = ofnData.dynFileBuffer;
Tcl_Obj *returnList = Tcl_NewObj();
int count = 0;
@@ -1920,10 +1921,11 @@ OFNHookProc(
WPARAM wParam, /* Message parameter */
LPARAM lParam) /* Message parameter */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
OPENFILENAME *ofnPtr;
OFNData *ofnData;
+ (void)wParam;
if (uMsg == WM_INITDIALOG) {
TkWinSetUserData(hdlg, lParam);
@@ -1944,7 +1946,7 @@ OFNHookProc(
if (notifyPtr->hdr.code == CDN_FILEOK ||
notifyPtr->hdr.code == CDN_SELCHANGE) {
int dirsize, selsize;
- TCHAR *buffer;
+ WCHAR *buffer;
int buffersize;
/*
@@ -1957,8 +1959,8 @@ OFNHookProc(
buffer = ofnData->dynFileBuffer;
hdlg = GetParent(hdlg);
- selsize = (int) SendMessage(hdlg, CDM_GETSPEC, 0, 0);
- dirsize = (int) SendMessage(hdlg, CDM_GETFOLDERPATH, 0, 0);
+ selsize = (int) SendMessageW(hdlg, CDM_GETSPEC, 0, 0);
+ dirsize = (int) SendMessageW(hdlg, CDM_GETFOLDERPATH, 0, 0);
buffersize = (selsize + dirsize + 1);
/*
@@ -1968,15 +1970,15 @@ OFNHookProc(
if ((selsize > 1) && (dirsize > 0)) {
if (ofnData->dynFileBufferSize < buffersize) {
- buffer = ckrealloc(buffer, buffersize * sizeof(TCHAR));
+ buffer = (WCHAR *)ckrealloc(buffer, buffersize * sizeof(WCHAR));
ofnData->dynFileBufferSize = buffersize;
ofnData->dynFileBuffer = buffer;
}
- SendMessage(hdlg, CDM_GETFOLDERPATH, dirsize, (LPARAM) buffer);
+ SendMessageW(hdlg, CDM_GETFOLDERPATH, dirsize, (LPARAM) buffer);
buffer += dirsize;
- SendMessage(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer);
+ SendMessageW(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer);
/*
* If there are multiple files, delete the quotes and change
@@ -1985,7 +1987,7 @@ OFNHookProc(
if (buffer[0] == '"') {
BOOL findquote = TRUE;
- TCHAR *tmp = buffer;
+ WCHAR *tmp = buffer;
while (*buffer != '\0') {
if (findquote) {
@@ -2014,8 +2016,8 @@ OFNHookProc(
if (TCL_PATH_ABSOLUTE ==
Tcl_GetPathType(Tcl_DStringValue(&tmpfile))) {
/* re-get the full path to the start of the buffer */
- buffer = (TCHAR *) ofnData->dynFileBuffer;
- SendMessage(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer);
+ buffer = ofnData->dynFileBuffer;
+ SendMessageW(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer);
} else {
*(buffer-1) = '\\';
}
@@ -2100,7 +2102,7 @@ MakeFilter(
*/
const char *defaultFilter = "All Files (*.*)";
- p = filterStr = ckalloc(30);
+ p = filterStr = (char *)ckalloc(30);
strcpy(p, defaultFilter);
p+= strlen(defaultFilter);
@@ -2114,13 +2116,12 @@ MakeFilter(
*p = '\0';
} else {
- size_t len;
+ TkSizeT len;
if (valuePtr == NULL) {
len = 0;
} else {
- (void) Tcl_GetString(valuePtr);
- len = valuePtr->length;
+ (void) TkGetStringFromObj(valuePtr, &len);
}
/*
@@ -2137,7 +2138,7 @@ MakeFilter(
* twice the size of the string to format the filter
*/
- filterStr = ckalloc(len * 3);
+ filterStr = (char *)ckalloc(len * 3);
for (filterPtr = flist.filters, p = filterStr; filterPtr;
filterPtr = filterPtr->next) {
@@ -2290,59 +2291,63 @@ static int MakeFilterVista(
Tcl_DStringInit(&ds);
Tcl_DStringInit(&patterns);
- dlgFilterPtr = ckalloc(flist.numFilters * sizeof(*dlgFilterPtr));
+ dlgFilterPtr = (TCLCOMDLG_FILTERSPEC *)ckalloc(flist.numFilters * sizeof(*dlgFilterPtr));
for (i = 0, filterPtr = flist.filters;
filterPtr;
filterPtr = filterPtr->next, ++i) {
- const char *sep;
- FileFilterClause *clausePtr;
- int nbytes;
+ const char *sep;
+ FileFilterClause *clausePtr;
+ int nbytes;
- /* Check if this entry should be shown as the default */
- if (initial && strcmp(initial, filterPtr->name) == 0)
+ /* Check if this entry should be shown as the default */
+ if (initial && strcmp(initial, filterPtr->name) == 0)
initialIndex = i+1; /* Windows filter indices are 1-based */
- /* First stash away the text description of the pattern */
- Tcl_WinUtfToTChar(filterPtr->name, -1, &ds);
- nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
- nbytes += sizeof(WCHAR); /* Terminating \0 */
- dlgFilterPtr[i].pszName = ckalloc(nbytes);
- memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes);
- Tcl_DStringFree(&ds);
+ /* First stash away the text description of the pattern */
+ Tcl_DStringInit(&ds);
+ Tcl_UtfToWCharDString(filterPtr->name, -1, &ds);
+ nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
+ nbytes += sizeof(WCHAR); /* Terminating \0 */
+ dlgFilterPtr[i].pszName = (LPCWSTR)ckalloc(nbytes);
+ memmove((void *) dlgFilterPtr[i].pszName, Tcl_DStringValue(&ds), nbytes);
+ Tcl_DStringFree(&ds);
- /*
- * Loop through and join patterns with a ";" Each "clause"
- * corresponds to a single textual description (called typename)
- * in the tk_getOpenFile docs. Each such typename may occur
- * multiple times and all these form a single filter entry
- * with one clause per occurence. Further each clause may specify
- * multiple patterns. Hence the nested loop here.
- */
- sep = "";
- for (clausePtr=filterPtr->clauses ; clausePtr;
- clausePtr=clausePtr->next) {
- GlobPattern *globPtr;
- for (globPtr = clausePtr->patterns; globPtr;
- globPtr = globPtr->next) {
- Tcl_DStringAppend(&patterns, sep, -1);
- Tcl_DStringAppend(&patterns, globPtr->pattern, -1);
- sep = ";";
- }
- }
+ /*
+ * Loop through and join patterns with a ";" Each "clause"
+ * corresponds to a single textual description (called typename)
+ * in the tk_getOpenFile docs. Each such typename may occur
+ * multiple times and all these form a single filter entry
+ * with one clause per occurence. Further each clause may specify
+ * multiple patterns. Hence the nested loop here.
+ */
+ sep = "";
+ for (clausePtr=filterPtr->clauses ; clausePtr;
+ clausePtr=clausePtr->next) {
+ GlobPattern *globPtr;
+ for (globPtr = clausePtr->patterns; globPtr;
+ globPtr = globPtr->next) {
+ Tcl_DStringAppend(&patterns, sep, -1);
+ Tcl_DStringAppend(&patterns, globPtr->pattern, -1);
+ sep = ";";
+ }
+ }
- /* Again we need a Unicode form of the string */
- Tcl_WinUtfToTChar(Tcl_DStringValue(&patterns), -1, &ds);
- nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
- nbytes += sizeof(WCHAR); /* Terminating \0 */
- dlgFilterPtr[i].pszSpec = ckalloc(nbytes);
- memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes);
- Tcl_DStringFree(&ds);
- Tcl_DStringFree(&patterns);
+ /* Again we need a Unicode form of the string */
+ Tcl_DStringInit(&ds);
+ Tcl_UtfToWCharDString(Tcl_DStringValue(&patterns), -1, &ds);
+ nbytes = Tcl_DStringLength(&ds); /* # bytes, not Unicode chars */
+ nbytes += sizeof(WCHAR); /* Terminating \0 */
+ dlgFilterPtr[i].pszSpec = (LPCWSTR)ckalloc(nbytes);
+ memmove((void *)dlgFilterPtr[i].pszSpec, Tcl_DStringValue(&ds), nbytes);
+ Tcl_DStringFree(&ds);
+ Tcl_DStringSetLength(&patterns, 0);
}
+ Tcl_DStringFree(&patterns);
- if (initialIndex == 0)
- initialIndex = 1; /* If no default, show first entry */
+ if (initialIndex == 0) {
+ initialIndex = 1; /* If no default, show first entry */
+ }
*initialIndexPtr = initialIndex;
*dlgFilterPtrPtr = dlgFilterPtr;
*countPtr = flist.numFilters;
@@ -2429,14 +2434,14 @@ Tk_ChooseDirectoryObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- TCHAR path[MAX_PATH];
+ WCHAR path[MAX_PATH];
int oldMode, result;
LPCITEMIDLIST pidl; /* Returned by browser */
- BROWSEINFO bInfo; /* Used by browser */
+ BROWSEINFOW bInfo; /* Used by browser */
ChooseDir cdCBData; /* Structure to pass back and forth */
LPMALLOC pMalloc; /* Used by shell */
HWND hWnd;
- TCHAR saveDir[MAX_PATH];
+ WCHAR saveDir[MAX_PATH];
Tcl_DString titleString; /* Title */
Tcl_DString tempString; /* temporary */
Tcl_Obj *objPtr;
@@ -2464,16 +2469,17 @@ Tk_ChooseDirectoryObjCmd(
utfDir = Tcl_DStringValue(&ofnOpts.utfDirString);
if (utfDir[0] != '\0') {
- const TCHAR *uniStr;
+ LPCWSTR uniStr;
- Tcl_WinUtfToTChar(Tcl_DStringValue(&ofnOpts.utfDirString), -1,
+ Tcl_DStringInit(&tempString);
+ Tcl_UtfToWCharDString(Tcl_DStringValue(&ofnOpts.utfDirString), -1,
&tempString);
- uniStr = (TCHAR *) Tcl_DStringValue(&tempString);
+ uniStr = (WCHAR *) Tcl_DStringValue(&tempString);
/* Convert possible relative path to full path to keep dialog happy. */
- GetFullPathName(uniStr, MAX_PATH, saveDir, NULL);
- _tcsncpy(cdCBData.initDir, saveDir, MAX_PATH);
+ GetFullPathNameW(uniStr, MAX_PATH, saveDir, NULL);
+ wcsncpy(cdCBData.initDir, saveDir, MAX_PATH);
}
/* XXX - rest of this (original) code has no error checks at all. */
@@ -2492,16 +2498,16 @@ Tk_ChooseDirectoryObjCmd(
bInfo.hwndOwner = hWnd;
bInfo.pszDisplayName = path;
bInfo.pidlRoot = NULL;
- if (_tcslen(cdCBData.initDir) == 0) {
- GetCurrentDirectory(MAX_PATH, cdCBData.initDir);
+ if (wcslen(cdCBData.initDir) == 0) {
+ GetCurrentDirectoryW(MAX_PATH, cdCBData.initDir);
}
bInfo.lParam = (LPARAM) &cdCBData;
if (ofnOpts.titleObj != NULL) {
- Tcl_WinUtfToTChar(Tcl_GetString(ofnOpts.titleObj), -1, &titleString);
- bInfo.lpszTitle = (LPTSTR) Tcl_DStringValue(&titleString);
+ Tcl_DStringInit(&titleString);
+ bInfo.lpszTitle = Tcl_UtfToWCharDString(Tcl_GetString(ofnOpts.titleObj), -1, &titleString);
} else {
- bInfo.lpszTitle = TEXT("Please choose a directory, then select OK.");
+ bInfo.lpszTitle = L"Please choose a directory, then select OK.";
}
/*
@@ -2534,13 +2540,13 @@ Tk_ChooseDirectoryObjCmd(
*/
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
- GetCurrentDirectory(MAX_PATH, saveDir);
+ GetCurrentDirectoryW(MAX_PATH, saveDir);
if (SHGetMalloc(&pMalloc) == NOERROR) {
/*
* XXX - MSDN says CoInitialize must have been called before
* SHBrowseForFolder can be used but don't see that called anywhere.
*/
- pidl = SHBrowseForFolder(&bInfo);
+ pidl = SHBrowseForFolderW(&bInfo);
/*
* This is a fix for Windows 2000, which seems to modify the folder
@@ -2555,18 +2561,18 @@ Tk_ChooseDirectoryObjCmd(
*/
if (pidl != NULL) {
- if (!SHGetPathFromIDList(pidl, path)) {
+ if (!SHGetPathFromIDListW(pidl, path)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"error: not a file system folder", -1));
Tcl_SetErrorCode(interp, "TK", "DIRDIALOG", "PSEUDO", NULL);
}
pMalloc->lpVtbl->Free(pMalloc, (void *) pidl);
- } else if (_tcslen(cdCBData.retDir) > 0) {
- _tcscpy(path, cdCBData.retDir);
+ } else if (wcslen(cdCBData.retDir) > 0) {
+ wcscpy(path, cdCBData.retDir);
}
pMalloc->lpVtbl->Release(pMalloc);
}
- SetCurrentDirectory(saveDir);
+ SetCurrentDirectoryW(saveDir);
Tcl_SetServiceMode(oldMode);
/*
@@ -2618,12 +2624,12 @@ ChooseDirectoryValidateProc(
LPARAM lParam,
LPARAM lpData)
{
- TCHAR selDir[MAX_PATH];
+ WCHAR selDir[MAX_PATH];
ChooseDir *chooseDirSharedData = (ChooseDir *) lpData;
Tcl_DString tempString;
Tcl_DString initDirString;
- TCHAR string[MAX_PATH];
- ThreadSpecificData *tsdPtr =
+ WCHAR string[MAX_PATH];
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->debugFlag) {
@@ -2632,7 +2638,7 @@ ChooseDirectoryValidateProc(
}
chooseDirSharedData->retDir[0] = '\0';
switch (message) {
- case BFFM_VALIDATEFAILED:
+ case BFFM_VALIDATEFAILEDW:
/*
* First save and check to see if it is a valid path name, if so then
* make that path the one shown in the window. Otherwise, it failed
@@ -2642,7 +2648,8 @@ ChooseDirectoryValidateProc(
* like ~ are converted correctly.
*/
- Tcl_WinTCharToUtf((TCHAR *) lParam, -1, &initDirString);
+ Tcl_DStringInit(&initDirString);
+ Tcl_WCharToUtfDString((WCHAR *) lParam, wcslen((WCHAR *) lParam), &initDirString);
if (Tcl_TranslateFileName(chooseDirSharedData->interp,
Tcl_DStringValue(&initDirString), &tempString) == NULL) {
/*
@@ -2653,14 +2660,13 @@ ChooseDirectoryValidateProc(
chooseDirSharedData->retDir[0] = '\0';
return 1;
}
- Tcl_DStringFree(&initDirString);
- Tcl_WinUtfToTChar(Tcl_DStringValue(&tempString), -1, &initDirString);
- Tcl_DStringFree(&tempString);
- _tcsncpy(string, (TCHAR *) Tcl_DStringValue(&initDirString),
+ Tcl_DStringSetLength(&initDirString, 0);
+ wcsncpy(string, Tcl_UtfToWCharDString(Tcl_DStringValue(&tempString), -1, &initDirString),
MAX_PATH);
Tcl_DStringFree(&initDirString);
+ Tcl_DStringFree(&tempString);
- if (SetCurrentDirectory(string) == 0) {
+ if (SetCurrentDirectoryW(string) == 0) {
/*
* Get the full path name to the user entry, at this point it does
@@ -2668,17 +2674,17 @@ ChooseDirectoryValidateProc(
* it.
*/
- GetFullPathName(string, MAX_PATH,
+ GetFullPathNameW(string, MAX_PATH,
chooseDirSharedData->retDir, NULL);
if (chooseDirSharedData->mustExist) {
/*
* User HAS to select a valid directory.
*/
- wsprintf(selDir, TEXT("Directory '%s' does not exist,\n")
- TEXT("please select or enter an existing directory."),
+ wsprintfW(selDir, L"Directory '%s' does not exist,\n"
+ L"please select or enter an existing directory.",
chooseDirSharedData->retDir);
- MessageBox(NULL, selDir, NULL, MB_ICONEXCLAMATION|MB_OK);
+ MessageBoxW(NULL, selDir, NULL, MB_ICONEXCLAMATION|MB_OK);
chooseDirSharedData->retDir[0] = '\0';
return 1;
}
@@ -2688,7 +2694,7 @@ ChooseDirectoryValidateProc(
* directory in utfRetDir.
*/
- GetCurrentDirectory(MAX_PATH, chooseDirSharedData->retDir);
+ GetCurrentDirectoryW(MAX_PATH, chooseDirSharedData->retDir);
return 0;
}
return 0;
@@ -2703,30 +2709,30 @@ ChooseDirectoryValidateProc(
* Not called when user changes edit box directly.
*/
- if (SHGetPathFromIDList((LPITEMIDLIST) lParam, selDir)) {
- SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM) selDir);
+ if (SHGetPathFromIDListW((LPITEMIDLIST) lParam, selDir)) {
+ SendMessageW(hwnd, BFFM_SETSTATUSTEXTW, 0, (LPARAM) selDir);
// enable the OK button
- SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
+ SendMessageW(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
} else {
// disable the OK button
- SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 0);
+ SendMessageW(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 0);
}
UpdateWindow(hwnd);
return 1;
case BFFM_INITIALIZED: {
/*
- * Directory browser intializing - tell it where to start from, user
+ * Directory browser initializing - tell it where to start from, user
* specified parameter.
*/
- TCHAR *initDir = chooseDirSharedData->initDir;
+ WCHAR *initDir = chooseDirSharedData->initDir;
- SetCurrentDirectory(initDir);
+ SetCurrentDirectoryW(initDir);
if (*initDir == '\\') {
/*
- * BFFM_SETSELECTION only understands UNC paths as pidls, so
+ * BFFM_SETSELECTIONW only understands UNC paths as pidls, so
* convert path to pidl using IShellFolder interface.
*/
@@ -2739,10 +2745,10 @@ ChooseDirectoryValidateProc(
ULONG ulCount, ulAttr;
if (SUCCEEDED(psfFolder->lpVtbl->ParseDisplayName(
- psfFolder, hwnd, NULL, (TCHAR *)
- initDir, &ulCount,&pidlMain,&ulAttr))
+ psfFolder, hwnd, NULL, initDir,
+ &ulCount,&pidlMain,&ulAttr))
&& (pidlMain != NULL)) {
- SendMessage(hwnd, BFFM_SETSELECTION, FALSE,
+ SendMessageW(hwnd, BFFM_SETSELECTIONW, FALSE,
(LPARAM) pidlMain);
pMalloc->lpVtbl->Free(pMalloc, pidlMain);
}
@@ -2751,9 +2757,9 @@ ChooseDirectoryValidateProc(
pMalloc->lpVtbl->Release(pMalloc);
}
} else {
- SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM) initDir);
+ SendMessageW(hwnd, BFFM_SETSELECTIONW, TRUE, (LPARAM) initDir);
}
- SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
+ SendMessageW(hwnd, BFFM_ENABLEOK, 0, (LPARAM) 1);
break;
}
@@ -2786,7 +2792,7 @@ Tk_MessageBoxObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData, parent;
+ Tk_Window tkwin = (Tk_Window)clientData, parent;
HWND hWnd;
Tcl_Obj *messageObj, *titleObj, *detailObj, *tmpObj;
int defaultBtn, icon, type;
@@ -2800,10 +2806,10 @@ Tk_MessageBoxObjCmd(
MSG_DEFAULT, MSG_DETAIL, MSG_ICON, MSG_MESSAGE,
MSG_PARENT, MSG_TITLE, MSG_TYPE
};
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_DString titleBuf, tmpBuf;
- const WCHAR *titlePtr, *tmpPtr;
+ LPCWSTR titlePtr, tmpPtr;
const char *src;
defaultBtn = -1;
@@ -2911,13 +2917,10 @@ Tk_MessageBoxObjCmd(
flags |= icon | type | MB_TASKMODAL | MB_SETFOREGROUND;
- tmpObj = messageObj ? Tcl_DuplicateObj(messageObj)
- : Tcl_NewUnicodeObj(NULL, 0);
+ tmpObj = messageObj ? Tcl_DuplicateObj(messageObj) : Tcl_NewObj();
Tcl_IncrRefCount(tmpObj);
if (detailObj) {
- const Tcl_UniChar twoNL[] = { '\n', '\n' };
-
- Tcl_AppendUnicodeToObj(tmpObj, twoNL, 2);
+ Tcl_AppendStringsToObj(tmpObj, "\n\n", NULL);
Tcl_AppendObjToObj(tmpObj, detailObj);
}
@@ -2934,18 +2937,20 @@ Tk_MessageBoxObjCmd(
tsdPtr->hSmallIcon = TkWinGetIcon(parent, ICON_SMALL);
tsdPtr->hBigIcon = TkWinGetIcon(parent, ICON_BIG);
- tsdPtr->hMsgBoxHook = SetWindowsHookEx(WH_CBT, MsgBoxCBTProc, NULL,
+ tsdPtr->hMsgBoxHook = SetWindowsHookExW(WH_CBT, MsgBoxCBTProc, NULL,
GetCurrentThreadId());
src = Tcl_GetString(tmpObj);
- tmpPtr = Tcl_WinUtfToTChar(src, tmpObj->length, &tmpBuf);
+ Tcl_DStringInit(&tmpBuf);
+ tmpPtr = Tcl_UtfToWCharDString(src, tmpObj->length, &tmpBuf);
if (titleObj != NULL) {
src = Tcl_GetString(titleObj);
- titlePtr = Tcl_WinUtfToTChar(src, titleObj->length, &titleBuf);
+ Tcl_DStringInit(&titleBuf);
+ titlePtr = Tcl_UtfToWCharDString(src, titleObj->length, &titleBuf);
} else {
titlePtr = L"";
Tcl_DStringInit(&titleBuf);
}
- winCode = MessageBox(hWnd, tmpPtr, titlePtr, flags);
+ winCode = MessageBoxW(hWnd, tmpPtr, titlePtr, flags);
Tcl_DStringFree(&titleBuf);
Tcl_DStringFree(&tmpBuf);
UnhookWindowsHookEx(tsdPtr->hMsgBoxHook);
@@ -2971,7 +2976,7 @@ MsgBoxCBTProc(
WPARAM wParam,
LPARAM lParam)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (nCode == HCBT_CREATEWND) {
@@ -2988,9 +2993,9 @@ MsgBoxCBTProc(
if (WC_DIALOG == lpcbtcreate->lpcs->lpszClass) {
HWND hwnd = (HWND) wParam;
- SendMessage(hwnd, WM_SETICON, ICON_SMALL,
+ SendMessageW(hwnd, WM_SETICON, ICON_SMALL,
(LPARAM) tsdPtr->hSmallIcon);
- SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM) tsdPtr->hBigIcon);
+ SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM) tsdPtr->hBigIcon);
}
}
@@ -3018,11 +3023,11 @@ static void
SetTkDialog(
ClientData clientData)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
char buf[32];
- sprintf(buf, "0x%p", clientData);
+ sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)clientData);
Tcl_SetVar2(tsdPtr->debugInterp, "tk_dialog", NULL, buf, TCL_GLOBAL_ONLY);
}
@@ -3032,12 +3037,13 @@ SetTkDialog(
static const char *
ConvertExternalFilename(
- TCHAR *filename,
+ LPCWSTR filename,
Tcl_DString *dsPtr)
{
char *p;
- Tcl_WinTCharToUtf(filename, -1, dsPtr);
+ Tcl_DStringInit(dsPtr);
+ Tcl_WCharToUtfDString(filename, wcslen(filename), dsPtr);
for (p = Tcl_DStringValue(dsPtr); *p != '\0'; p++) {
/*
* Change the pathname to the Tcl "normalized" pathname, where back
@@ -3067,19 +3073,20 @@ ConvertExternalFilename(
static Tcl_Obj *
GetFontObj(
HDC hdc,
- LOGFONT *plf)
+ LOGFONTW *plf)
{
Tcl_DString ds;
Tcl_Obj *resObj;
int pt = 0;
resObj = Tcl_NewListObj(0, NULL);
- Tcl_WinTCharToUtf(plf->lfFaceName, -1, &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(plf->lfFaceName, wcslen(plf->lfFaceName), &ds);
Tcl_ListObjAppendElement(NULL, resObj,
Tcl_NewStringObj(Tcl_DStringValue(&ds), -1));
Tcl_DStringFree(&ds);
pt = -MulDiv(plf->lfHeight, 72, GetDeviceCaps(hdc, LOGPIXELSY));
- Tcl_ListObjAppendElement(NULL, resObj, Tcl_NewIntObj(pt));
+ Tcl_ListObjAppendElement(NULL, resObj, Tcl_NewWideIntObj(pt));
if (plf->lfWeight >= 700) {
Tcl_ListObjAppendElement(NULL, resObj, Tcl_NewStringObj("bold", -1));
}
@@ -3103,13 +3110,13 @@ ApplyLogfont(
Tcl_Interp *interp,
Tcl_Obj *cmdObj,
HDC hdc,
- LOGFONT *logfontPtr)
+ LOGFONTW *logfontPtr)
{
int objc;
Tcl_Obj **objv, **tmpv;
Tcl_ListObjGetElements(NULL, cmdObj, &objc, &objv);
- tmpv = ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
+ tmpv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc + 2));
memcpy(tmpv, objv, sizeof(Tcl_Obj *) * objc);
tmpv[objc] = GetFontObj(hdc, logfontPtr);
TkBackgroundEvalObjv(interp, objc+1, tmpv, TCL_EVAL_GLOBAL);
@@ -3147,7 +3154,7 @@ HookProc(
CHOOSEFONT *pcf = (CHOOSEFONT *) lParam;
HWND hwndCtrl;
static HookData *phd = NULL;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (WM_INITDIALOG == msg && lParam != 0) {
@@ -3160,9 +3167,10 @@ HookProc(
if (phd->titleObj != NULL) {
Tcl_DString title;
- Tcl_WinUtfToTChar(Tcl_GetString(phd->titleObj), -1, &title);
+ Tcl_DStringInit(&title);
+ Tcl_UtfToWCharDString(Tcl_GetString(phd->titleObj), -1, &title);
if (Tcl_DStringLength(&title) > 0) {
- SetWindowText(hwndDlg, (LPCTSTR) Tcl_DStringValue(&title));
+ SetWindowTextW(hwndDlg, (LPCWSTR) Tcl_DStringValue(&title));
}
Tcl_DStringFree(&title);
}
@@ -3195,10 +3203,10 @@ HookProc(
*/
if (WM_COMMAND == msg && LOWORD(wParam) == 1026) {
- LOGFONT lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0}};
+ LOGFONTW lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0}};
HDC hdc = GetDC(hwndDlg);
- SendMessage(hwndDlg, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM) &lf);
+ SendMessageW(hwndDlg, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM) &lf);
if (phd && phd->cmdObj) {
ApplyLogfont(phd->interp, phd->cmdObj, hdc, &lf);
}
@@ -3257,7 +3265,7 @@ FontchooserCget(
}
break;
case FontchooserVisible:
- resObj = Tcl_NewBooleanObj(hdPtr->hwnd && IsWindow(hdPtr->hwnd));
+ resObj = Tcl_NewWideIntObj((hdPtr->hwnd != NULL) && IsWindow(hdPtr->hwnd));
break;
default:
resObj = Tcl_NewStringObj("", 0);
@@ -3289,14 +3297,14 @@ FontchooserConfigureCmd(
int objc,
Tcl_Obj *const objv[])
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
HookData *hdPtr = NULL;
int i, r = TCL_OK;
static const char *const optionStrings[] = {
"-parent", "-title", "-font", "-command", "-visible", NULL
};
- hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
+ hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
/*
* With no arguments we return all the options in a dict.
@@ -3433,14 +3441,16 @@ FontchooserShowCmd(
Tcl_Obj *const objv[])
{
Tcl_DString ds;
- Tk_Window tkwin = clientData, parent;
- CHOOSEFONT cf;
- LOGFONT lf;
+ Tk_Window tkwin = (Tk_Window)clientData, parent;
+ CHOOSEFONTW cf;
+ LOGFONTW lf;
HDC hdc;
HookData *hdPtr;
int r = TCL_OK, oldMode = 0;
+ (void)objc;
+ (void)objv;
- hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
+ hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
parent = tkwin;
if (hdPtr->parentObj) {
@@ -3477,8 +3487,8 @@ FontchooserShowCmd(
}
fontPtr = (TkFont *) f;
cf.Flags |= CF_INITTOLOGFONTSTRUCT;
- Tcl_WinUtfToTChar(fontPtr->fa.family, -1, &ds);
- _tcsncpy(lf.lfFaceName, (TCHAR *)Tcl_DStringValue(&ds),
+ Tcl_DStringInit(&ds);
+ wcsncpy(lf.lfFaceName, Tcl_UtfToWCharDString(fontPtr->fa.family, -1, &ds),
LF_FACESIZE-1);
Tcl_DStringFree(&ds);
lf.lfFaceName[LF_FACESIZE-1] = 0;
@@ -3510,7 +3520,7 @@ FontchooserShowCmd(
if (TCL_OK == r) {
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
- if (ChooseFont(&cf)) {
+ if (ChooseFontW(&cf)) {
if (hdPtr->cmdObj) {
ApplyLogfont(hdPtr->interp, hdPtr->cmdObj, hdc, &lf);
}
@@ -3541,12 +3551,15 @@ FontchooserShowCmd(
static int
FontchooserHideCmd(
- ClientData clientData, /* Main window */
+ ClientData dummy, /* Main window */
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
- HookData *hdPtr = Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
+ HookData *hdPtr = (HookData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL);
+ (void)dummy;
+ (void)objc;
+ (void)objv;
if (hdPtr->hwnd && IsWindow(hdPtr->hwnd)) {
EndDialog(hdPtr->hwnd, 0);
@@ -3566,9 +3579,10 @@ FontchooserHideCmd(
*/
static void
-DeleteHookData(ClientData clientData, Tcl_Interp *interp)
+DeleteHookData(ClientData clientData, Tcl_Interp *dummy)
{
- HookData *hdPtr = clientData;
+ HookData *hdPtr = (HookData *)clientData;
+ (void)dummy;
if (hdPtr->parentObj) {
Tcl_DecrRefCount(hdPtr->parentObj);
@@ -3605,9 +3619,10 @@ const TkEnsemble tkFontchooserEnsemble[] = {
};
int
-TkInitFontchooser(Tcl_Interp *interp, ClientData clientData)
+TkInitFontchooser(Tcl_Interp *interp, ClientData dummy)
{
- HookData *hdPtr = ckalloc(sizeof(HookData));
+ HookData *hdPtr = (HookData *)ckalloc(sizeof(HookData));
+ (void)dummy;
memset(hdPtr, 0, sizeof(HookData));
Tcl_SetAssocData(interp, "::tk::fontchooser", DeleteHookData, hdPtr);
diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c
index 7a6e7bc..41e9672 100644
--- a/win/tkWinDraw.c
+++ b/win/tkWinDraw.c
@@ -103,7 +103,7 @@ const int tkpWinBltModes[] = {
typedef BOOL (CALLBACK *WinDrawFunc)(HDC dc, const POINT *points, int npoints);
-typedef struct ThreadSpecificData {
+typedef struct {
POINT *winPoints; /* Array of points that is reused. */
int nWinPoints; /* Current size of point array. */
} ThreadSpecificData;
@@ -244,7 +244,7 @@ ConvertPoints(
if (tsdPtr->winPoints != NULL) {
ckfree(tsdPtr->winPoints);
}
- tsdPtr->winPoints = ckalloc(sizeof(POINT) * npoints);
+ tsdPtr->winPoints = (POINT *)ckalloc(sizeof(POINT) * npoints);
if (tsdPtr->winPoints == NULL) {
tsdPtr->nWinPoints = -1;
return NULL;
@@ -412,7 +412,7 @@ XCopyPlane(
*/
fgBrush = CreateSolidBrush(gc->foreground);
- oldBrush = SelectObject(destDC, fgBrush);
+ oldBrush = (HBRUSH)SelectObject(destDC, fgBrush);
SetBkColor(destDC, RGB(255,255,255));
SetTextColor(destDC, RGB(0,0,0));
BitBlt(destDC, dest_x, dest_y, (int) width, (int) height, srcDC,
@@ -450,7 +450,7 @@ XCopyPlane(
BitBlt(memDC, 0, 0, (int) width, (int) height, maskDC,
dest_x - gc->clip_x_origin, dest_y - gc->clip_y_origin,
SRCAND);
- oldBrush = SelectObject(destDC, fgBrush);
+ oldBrush = (HBRUSH)SelectObject(destDC, fgBrush);
BitBlt(destDC, dest_x, dest_y, (int) width, (int) height, memDC,
0, 0, MASKPAT);
@@ -519,7 +519,6 @@ TkPutImage(
BITMAPINFO *infoPtr;
HBITMAP bitmap;
char *data;
- Visual *visual;
display->request++;
@@ -554,10 +553,10 @@ TkPutImage(
usePalette = (image->bits_per_pixel < 16);
if (usePalette) {
- infoPtr = ckalloc(sizeof(BITMAPINFOHEADER)
+ infoPtr = (BITMAPINFO *)ckalloc(sizeof(BITMAPINFOHEADER)
+ sizeof(RGBQUAD)*ncolors);
} else {
- infoPtr = ckalloc(sizeof(BITMAPINFOHEADER) + sizeof(DWORD)*4);
+ infoPtr = (BITMAPINFO *)ckalloc(sizeof(BITMAPINFOHEADER));
}
infoPtr->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@@ -565,13 +564,13 @@ TkPutImage(
infoPtr->bmiHeader.biHeight = -image->height; /* Top-down order */
infoPtr->bmiHeader.biPlanes = 1;
infoPtr->bmiHeader.biBitCount = image->bits_per_pixel;
+ infoPtr->bmiHeader.biCompression = BI_RGB;
infoPtr->bmiHeader.biSizeImage = 0;
infoPtr->bmiHeader.biXPelsPerMeter = 0;
infoPtr->bmiHeader.biYPelsPerMeter = 0;
infoPtr->bmiHeader.biClrImportant = 0;
if (usePalette) {
- infoPtr->bmiHeader.biCompression = BI_RGB;
infoPtr->bmiHeader.biClrUsed = ncolors;
for (i = 0; i < ncolors; i++) {
infoPtr->bmiColors[i].rgbBlue = GetBValue(colors[i]);
@@ -580,13 +579,7 @@ TkPutImage(
infoPtr->bmiColors[i].rgbReserved = 0;
}
} else {
- infoPtr->bmiHeader.biCompression = BI_BITFIELDS;
- /* Modelled on XGetVisualInfo() in xutil.c.
- * We want to get the rgb masks for the default visual for the given display. */
- visual = DefaultVisual(display,0);
- *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))) = visual->blue_mask;
- *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))+1) = visual->green_mask;
- *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))+2) = visual->red_mask;
+ infoPtr->bmiHeader.biClrUsed = 0;
}
bitmap = CreateDIBitmap(dc, &infoPtr->bmiHeader, CBM_INIT,
image->data, infoPtr, DIB_RGB_COLORS);
@@ -598,7 +591,7 @@ TkPutImage(
TkWinReleaseDrawableDC(d, dc, &state);
return BadValue;
}
- bitmap = SelectObject(dcMem, bitmap);
+ bitmap = (HBITMAP)SelectObject(dcMem, bitmap);
BitBlt(dc, dest_x, dest_y, (int) width, (int) height, dcMem, src_x, src_y,
SRCCOPY);
DeleteObject(SelectObject(dcMem, bitmap));
@@ -607,6 +600,7 @@ TkPutImage(
return Success;
}
+#undef XPutImage
int
XPutImage(
Display *display,
@@ -678,7 +672,7 @@ XFillRectangles(
stipple = CreatePatternBrush(twdPtr->bitmap.handle);
SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL);
- oldBrush = SelectObject(dc, stipple);
+ oldBrush = (HBRUSH)SelectObject(dc, stipple);
dcMem = CreateCompatibleDC(dc);
/*
@@ -690,7 +684,7 @@ XFillRectangles(
while (nrectangles-- > 0) {
bitmap = CreateCompatibleBitmap(dc, rectangles[0].width,
rectangles[0].height);
- oldBitmap = SelectObject(dcMem, bitmap);
+ oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
rect.left = 0;
rect.top = 0;
rect.right = rectangles[0].width;
@@ -725,8 +719,8 @@ XFillRectangles(
}
} else {
HPEN newPen = CreatePen(PS_NULL, 0, gc->foreground);
- HPEN oldPen = SelectObject(dc, newPen);
- oldBrush = SelectObject(dc, brush);
+ HPEN oldPen = (HPEN)SelectObject(dc, newPen);
+ oldBrush = (HBRUSH)SelectObject(dc, brush);
while (nrectangles-- > 0) {
Rectangle(dc, rectangles[0].x, rectangles[0].y,
@@ -855,7 +849,7 @@ RenderObject(
*/
SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL);
- oldBrush = SelectObject(dc, CreatePatternBrush(twdPtr->bitmap.handle));
+ oldBrush = (HBRUSH)SelectObject(dc, CreatePatternBrush(twdPtr->bitmap.handle));
/*
* Create temporary drawing surface containing a copy of the
@@ -863,9 +857,9 @@ RenderObject(
*/
dcMem = CreateCompatibleDC(dc);
- oldBitmap = SelectObject(dcMem, CreateCompatibleBitmap(dc, width,
+ oldBitmap = (HBITMAP)SelectObject(dcMem, CreateCompatibleBitmap(dc, width,
height));
- oldPen = SelectObject(dcMem, pen);
+ oldPen = (HPEN)SelectObject(dcMem, pen);
BitBlt(dcMem, 0, 0, width, height, dc, rect.left, rect.top, SRCCOPY);
/*
@@ -885,7 +879,7 @@ RenderObject(
SetPolyFillMode(dcMem, (gc->fill_rule == EvenOddRule) ? ALTERNATE
: WINDING);
- oldMemBrush = SelectObject(dcMem, CreateSolidBrush(gc->foreground));
+ oldMemBrush = (HBRUSH)SelectObject(dcMem, CreateSolidBrush(gc->foreground));
MakeAndStrokePath(dcMem, winPoints, npoints, func);
BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYFG);
@@ -908,8 +902,8 @@ RenderObject(
DeleteObject(SelectObject(dcMem, oldBitmap));
DeleteDC(dcMem);
} else {
- oldPen = SelectObject(dc, pen);
- oldBrush = SelectObject(dc, CreateSolidBrush(gc->foreground));
+ oldPen = (HPEN)SelectObject(dc, pen);
+ oldBrush = (HBRUSH)SelectObject(dc, CreateSolidBrush(gc->foreground));
SetROP2(dc, tkpWinRopModes[gc->function]);
SetPolyFillMode(dc, (gc->fill_rule == EvenOddRule) ? ALTERNATE
@@ -993,6 +987,7 @@ XFillPolygon(
HPEN pen;
TkWinDCState state;
HDC dc;
+ (void)shape;
if (d == None) {
return BadDrawable;
@@ -1000,7 +995,7 @@ XFillPolygon(
dc = TkWinGetDrawableDC(display, d, &state);
- pen = GetStockObject(NULL_PEN);
+ pen = (HPEN)GetStockObject(NULL_PEN);
RenderObject(dc, gc, points, npoints, mode, pen, Polygon);
TkWinReleaseDrawableDC(d, dc, &state);
@@ -1044,8 +1039,8 @@ XDrawRectangle(
pen = SetUpGraphicsPort(gc);
SetBkMode(dc, TRANSPARENT);
- oldPen = SelectObject(dc, pen);
- oldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH));
+ oldPen = (HPEN)SelectObject(dc, pen);
+ oldBrush = (HBRUSH)SelectObject(dc, GetStockObject(NULL_BRUSH));
SetROP2(dc, tkpWinRopModes[gc->function]);
Rectangle(dc, x, y, (int) x+width+1, (int) y+height+1);
@@ -1270,7 +1265,7 @@ DrawOrFillArc(
*/
pen = SetUpGraphicsPort(gc);
- oldPen = SelectObject(dc, pen);
+ oldPen = (HPEN)SelectObject(dc, pen);
if (!fill) {
/*
* Note that this call will leave a gap of one pixel at the end of the
@@ -1283,7 +1278,7 @@ DrawOrFillArc(
xend, yend);
} else {
brush = CreateSolidBrush(gc->foreground);
- oldBrush = SelectObject(dc, brush);
+ oldBrush = (HBRUSH)SelectObject(dc, brush);
if (gc->arc_mode == ArcChord) {
Chord(dc, x, y, (int) (x+width+1), (int) (y+height+1),
xstart, ystart, xend, yend);
@@ -1409,10 +1404,11 @@ TkScrollWindow(
int x, int y, int width, int height,
/* Position rectangle to be scrolled. */
int dx, int dy, /* Distance rectangle should be moved. */
- TkRegion damageRgn) /* Region to accumulate damage in. */
+ Region damageRgn) /* Region to accumulate damage in. */
{
HWND hwnd = TkWinGetHWND(Tk_WindowId(tkwin));
RECT scrollRect;
+ (void)gc;
scrollRect.left = x;
scrollRect.top = y;
@@ -1455,7 +1451,7 @@ TkWinFillRect(
rect.bottom = y + height;
oldColor = SetBkColor(dc, (COLORREF)pixel);
SetBkMode(dc, OPAQUE);
- ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
+ ExtTextOutW(dc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
SetBkColor(dc, oldColor);
}
@@ -1489,13 +1485,15 @@ TkpDrawHighlightBorder(
int highlightWidth,
Drawable drawable)
{
+ (void)bgGC;
+
TkDrawInsetFocusHighlight(tkwin, fgGC, highlightWidth, drawable, 0);
}
/*
*----------------------------------------------------------------------
*
- * TkpDrawFrame --
+ * TkpDrawFrameEx --
*
* This function draws the rectangular frame area.
*
@@ -1509,14 +1507,15 @@ TkpDrawHighlightBorder(
*/
void
-TkpDrawFrame(
+TkpDrawFrameEx(
Tk_Window tkwin,
+ Drawable drawable,
Tk_3DBorder border,
int highlightWidth,
int borderWidth,
int relief)
{
- Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), border, highlightWidth,
+ Tk_Fill3DRectangle(tkwin, drawable, border, highlightWidth,
highlightWidth, Tk_Width(tkwin) - 2 * highlightWidth,
Tk_Height(tkwin) - 2 * highlightWidth, borderWidth, relief);
}
diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c
index c45f088..ce77414 100644
--- a/win/tkWinEmbed.c
+++ b/win/tkWinEmbed.c
@@ -34,7 +34,7 @@ typedef struct Container {
* process. */
} Container;
-typedef struct ThreadSpecificData {
+typedef struct {
Container *firstContainerPtr;
/* First in list of all containers managed by
* this process. */
@@ -69,7 +69,7 @@ void
TkWinCleanupContainerList(void)
{
Container *nextPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (; tsdPtr->firstContainerPtr != NULL;
@@ -96,14 +96,18 @@ TkWinCleanupContainerList(void)
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
TkpTestembedCmd(
- ClientData clientData,
+ ClientData dummy,
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
+ (void)dummy;
+ (void)interp;
+ (void)objc;
+ (void)objv;
+
return TCL_OK;
}
@@ -160,7 +164,7 @@ void Tk_MapEmbeddedWindow(
{
if(!(winPtr->flags & TK_ALREADY_DEAD)) {
HWND hwnd = (HWND)winPtr->privatePtr;
- int state = SendMessage(hwnd, TK_STATE, -1, -1) - 1;
+ int state = SendMessageW(hwnd, TK_STATE, -1, -1) - 1;
if (state < 0 || state > 3) {
state = NormalState;
@@ -283,9 +287,9 @@ TkpUseWindow(
return TCL_ERROR;
}
- id = SendMessage(hwnd, TK_INFO, TK_CONTAINER_VERIFY, 0);
+ id = SendMessageW(hwnd, TK_INFO, TK_CONTAINER_VERIFY, 0);
if (id == PTR2INT(hwnd)) {
- if (!SendMessage(hwnd, TK_INFO, TK_CONTAINER_ISAVAILABLE, 0)) {
+ if (!SendMessageW(hwnd, TK_INFO, TK_CONTAINER_ISAVAILABLE, 0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"The container is already in use", -1));
Tcl_SetErrorCode(interp, "TK", "EMBED", "IN_USE", NULL);
@@ -303,10 +307,10 @@ TkpUseWindow(
* order to avoid bug 1096074 in future.
*/
- TCHAR msg[256];
+ WCHAR msg[256];
- wsprintf(msg, TEXT("Unable to get information of window \"%.40hs\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching."), string);
- if (IDCANCEL == MessageBox(hwnd, msg, TEXT("Tk Warning"),
+ wsprintfW(msg, L"Unable to get information of window \"%.40hs\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string);
+ if (IDCANCEL == MessageBoxW(hwnd, msg, L"Tk Warning",
MB_OKCANCEL | MB_ICONWARNING)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"Operation has been canceled", -1));
@@ -371,7 +375,7 @@ TkpMakeContainer(
*/
Tk_MakeWindowExist(tkwin);
- containerPtr = ckalloc(sizeof(Container));
+ containerPtr = (Container *)ckalloc(sizeof(Container));
containerPtr->parentPtr = winPtr;
containerPtr->parentHWnd = Tk_GetHWND(Tk_WindowId(tkwin));
containerPtr->embeddedHWnd = NULL;
@@ -1018,7 +1022,7 @@ TkpClaimFocus(
* it. */
{
HWND hwnd = GetParent(Tk_GetHWND(topLevelPtr->window));
- SendMessage(hwnd, TK_CLAIMFOCUS, (WPARAM) force, 0);
+ SendMessageW(hwnd, TK_CLAIMFOCUS, (WPARAM) force, 0);
}
/*
@@ -1050,6 +1054,8 @@ TkpRedirectKeyEvent(
XEvent *eventPtr) /* X event to redirect (should be KeyPress or
* KeyRelease). */
{
+ (void)winPtr;
+ (void)eventPtr;
/* not implemented */
}
@@ -1096,7 +1102,7 @@ EmbedWindowDeleted(
break;
}
if (containerPtr->parentPtr == winPtr) {
- SendMessage(containerPtr->embeddedHWnd, WM_CLOSE, 0, 0);
+ SendMessageW(containerPtr->embeddedHWnd, WM_CLOSE, 0, 0);
containerPtr->parentPtr = NULL;
containerPtr->embeddedPtr = NULL;
break;
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 4ffa32b..75578de 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -1,7 +1,7 @@
/*
* tkWinFont.c --
*
- * Contains the Windows implementation of the platform-independant font
+ * Contains the Windows implementation of the platform-independent font
* package interface.
*
* Copyright (c) 1994 Software Research Associates, Inc.
@@ -26,10 +26,11 @@
* Under Windows, a "font family" is uniquely identified by its face name.
*/
-#define FONTMAP_SHIFT 12
+#define FONTMAP_SHIFT 10
-#define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT))
#define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT)
+#define FONTMAP_NUMCHARS 0x40000
+#define FONTMAP_PAGES (FONTMAP_NUMCHARS / FONTMAP_BITSPERPAGE)
typedef struct FontFamily {
struct FontFamily *nextPtr; /* Next in list of all known font families. */
@@ -50,11 +51,11 @@ typedef struct FontFamily {
int isSymbolFont; /* Non-zero if this is a symbol font. */
int isWideFont; /* 1 if this is a double-byte font, 0
* otherwise. */
- BOOL (WINAPI *textOutProc)(HDC hdc, int x, int y, TCHAR *str, int len);
+ BOOL (WINAPI *textOutProc)(HDC hdc, int x, int y, WCHAR *str, int len);
/* The procedure to use to draw text after it
* has been converted from UTF-8 to the
* encoding of this font. */
- BOOL (WINAPI *getTextExtentPoint32Proc)(HDC, TCHAR *, int, LPSIZE);
+ BOOL (WINAPI *getTextExtentPoint32Proc)(HDC, WCHAR *, int, LPSIZE);
/* The procedure to use to measure text after
* it has been converted from UTF-8 to the
* encoding of this font. */
@@ -168,7 +169,7 @@ static const TkStateMap systemMap[] = {
{-1, NULL}
};
-typedef struct ThreadSpecificData {
+typedef struct {
FontFamily *fontFamilyList; /* The list of font families that are
* currently loaded. As screen fonts are
* loaded, this list grows to hold information
@@ -179,12 +180,6 @@ typedef struct ThreadSpecificData {
static Tcl_ThreadDataKey dataKey;
/*
- * Information cached about the system at startup time.
- */
-
-static Tcl_Encoding systemEncoding;
-
-/*
* Procedures used only in this file.
*/
@@ -213,15 +208,15 @@ static inline void InitSubFont(HDC hdc, HFONT hFont, int base,
SubFont *subFontPtr);
static int CreateNamedSystemLogFont(Tcl_Interp *interp,
Tk_Window tkwin, const char* name,
- LOGFONT* logFontPtr);
+ LOGFONTW* logFontPtr);
static int CreateNamedSystemFont(Tcl_Interp *interp,
Tk_Window tkwin, const char* name, HFONT hFont);
static int LoadFontRanges(HDC hdc, HFONT hFont,
USHORT **startCount, USHORT **endCount,
int *symbolPtr);
static void MultiFontTextOut(HDC hdc, WinFont *fontPtr,
- const char *source, int numBytes, int x, int y,
- double angle);
+ const char *source, int numBytes,
+ double x, double y, double angle);
static void ReleaseFont(WinFont *fontPtr);
static inline void ReleaseSubFont(SubFont *subFontPtr);
static int SeenName(const char *name, Tcl_DString *dsPtr);
@@ -229,13 +224,13 @@ static inline HFONT SelectFont(HDC hdc, WinFont *fontPtr,
SubFont *subFontPtr, double angle);
static inline void SwapLong(PULONG p);
static inline void SwapShort(USHORT *p);
-static int CALLBACK WinFontCanUseProc(ENUMLOGFONT *lfPtr,
+static int CALLBACK WinFontCanUseProc(ENUMLOGFONTW *lfPtr,
NEWTEXTMETRIC *tmPtr, int fontType,
LPARAM lParam);
-static int CALLBACK WinFontExistProc(ENUMLOGFONT *lfPtr,
+static int CALLBACK WinFontExistProc(ENUMLOGFONTW *lfPtr,
NEWTEXTMETRIC *tmPtr, int fontType,
LPARAM lParam);
-static int CALLBACK WinFontFamilyEnumProc(ENUMLOGFONT *lfPtr,
+static int CALLBACK WinFontFamilyEnumProc(ENUMLOGFONTW *lfPtr,
NEWTEXTMETRIC *tmPtr, int fontType,
LPARAM lParam);
@@ -262,7 +257,6 @@ void
TkpFontPkgInit(
TkMainInfo *mainPtr) /* The application being created. */
{
- systemEncoding = TkWinGetUnicodeEncoding();
TkWinSetupSystemFonts(mainPtr);
}
@@ -306,8 +300,8 @@ TkpGetNativeFont(
}
tkwin = (Tk_Window) ((TkWindow *) tkwin)->mainPtr->winPtr;
- fontPtr = ckalloc(sizeof(WinFont));
- InitFont(tkwin, GetStockObject(object), 0, fontPtr);
+ fontPtr = (WinFont *)ckalloc(sizeof(WinFont));
+ InitFont(tkwin, (HFONT)GetStockObject(object), 0, fontPtr);
return (TkFont *) fontPtr;
}
@@ -331,12 +325,12 @@ CreateNamedSystemLogFont(
Tcl_Interp *interp,
Tk_Window tkwin,
const char* name,
- LOGFONT* logFontPtr)
+ LOGFONTW* logFontPtr)
{
HFONT hFont;
int r;
- hFont = CreateFontIndirect(logFontPtr);
+ hFont = CreateFontIndirectW(logFontPtr);
r = CreateNamedSystemFont(interp, tkwin, name, hFont);
DeleteObject((HGDIOBJ)hFont);
return r;
@@ -392,8 +386,8 @@ TkWinSetupSystemFonts(
Tcl_Interp *interp;
Tk_Window tkwin;
const TkStateMap *mapPtr;
- NONCLIENTMETRICS ncMetrics;
- ICONMETRICS iconMetrics;
+ NONCLIENTMETRICSW ncMetrics;
+ ICONMETRICSW iconMetrics;
HFONT hFont;
interp = (Tcl_Interp *) mainPtr->interp;
@@ -413,7 +407,7 @@ TkWinSetupSystemFonts(
ZeroMemory(&ncMetrics, sizeof(ncMetrics));
ncMetrics.cbSize = sizeof(ncMetrics);
- if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
+ if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS,
sizeof(ncMetrics), &ncMetrics, 0)) {
CreateNamedSystemLogFont(interp, tkwin, "TkDefaultFont",
&ncMetrics.lfMessageFont);
@@ -432,7 +426,7 @@ TkWinSetupSystemFonts(
}
iconMetrics.cbSize = sizeof(iconMetrics);
- if (SystemParametersInfo(SPI_GETICONMETRICS, sizeof(iconMetrics),
+ if (SystemParametersInfoW(SPI_GETICONMETRICS, sizeof(iconMetrics),
&iconMetrics, 0)) {
CreateNamedSystemLogFont(interp, tkwin, "TkIconFont",
&iconMetrics.lfFont);
@@ -444,9 +438,9 @@ TkWinSetupSystemFonts(
*/
{
- LOGFONT lfFixed = {
+ LOGFONTW lfFixed = {
0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
- 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, TEXT("")
+ 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L""
};
long pointSize, dpi;
HDC hdc = GetDC(NULL);
@@ -564,7 +558,7 @@ TkpGetFontFromAttributes(
hFont = GetScreenFont(faPtr, faceName,
(int)(TkFontGetPixels(tkwin, faPtr->size) + 0.5), 0.0);
if (tkFontPtr == NULL) {
- fontPtr = ckalloc(sizeof(WinFont));
+ fontPtr = (WinFont *)ckalloc(sizeof(WinFont));
} else {
fontPtr = (WinFont *) tkFontPtr;
ReleaseFont(fontPtr);
@@ -651,7 +645,7 @@ TkpGetFontFamilies(
* because it only exists under NT.
*/
- EnumFontFamilies(hdc, NULL, (FONTENUMPROC) WinFontFamilyEnumProc,
+ EnumFontFamiliesW(hdc, NULL, (FONTENUMPROCW) WinFontFamilyEnumProc,
(LPARAM) resultObj);
ReleaseDC(hwnd, hdc);
Tcl_SetObjResult(interp, resultObj);
@@ -659,16 +653,17 @@ TkpGetFontFamilies(
static int CALLBACK
WinFontFamilyEnumProc(
- ENUMLOGFONT *lfPtr, /* Logical-font data. */
- NEWTEXTMETRIC *tmPtr, /* Physical-font data (not used). */
- int fontType, /* Type of font (not used). */
+ ENUMLOGFONTW *lfPtr, /* Logical-font data. */
+ TCL_UNUSED(NEWTEXTMETRIC *), /* Physical-font data (not used). */
+ TCL_UNUSED(int), /* Type of font (not used). */
LPARAM lParam) /* Result object to hold result. */
{
- char *faceName = (char *) lfPtr->elfLogFont.lfFaceName;
+ WCHAR *faceName = lfPtr->elfLogFont.lfFaceName;
Tcl_Obj *resultObj = (Tcl_Obj *) lParam;
Tcl_DString faceString;
- Tcl_ExternalToUtfDString(systemEncoding, faceName, -1, &faceString);
+ Tcl_DStringInit(&faceString);
+ Tcl_WCharToUtfDString(faceName, wcslen(faceName), &faceString);
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
Tcl_DStringValue(&faceString), Tcl_DStringLength(&faceString)));
Tcl_DStringFree(&faceString);
@@ -751,14 +746,14 @@ TkpGetFontAttrsForChar(
* character */
FontFamily *familyPtr = thisSubFontPtr->familyPtr;
HFONT oldfont; /* Saved font from the device context */
- TEXTMETRIC tm; /* Font metrics of the selected subfont */
+ TEXTMETRICW tm; /* Font metrics of the selected subfont */
/*
* Get the font attributes.
*/
- oldfont = SelectObject(hdc, thisSubFontPtr->hFont0);
- GetTextMetrics(hdc, &tm);
+ oldfont = (HFONT)SelectObject(hdc, thisSubFontPtr->hFont0);
+ GetTextMetricsW(hdc, &tm);
SelectObject(hdc, oldfont);
ReleaseDC(fontPtr->hwnd, hdc);
faPtr->family = familyPtr->faceName;
@@ -835,7 +830,7 @@ Tk_MeasureChars(
hdc = GetDC(fontPtr->hwnd);
lastSubFontPtr = &fontPtr->subFontArray[0];
- oldFont = SelectObject(hdc, lastSubFontPtr->hFont0);
+ oldFont = (HFONT)SelectObject(hdc, lastSubFontPtr->hFont0);
/*
* A three step process:
@@ -858,7 +853,7 @@ Tk_MeasureChars(
(int) (p - start), &runString);
size.cx = 0;
familyPtr->getTextExtentPoint32Proc(hdc,
- (TCHAR *)Tcl_DStringValue(&runString),
+ (WCHAR *)Tcl_DStringValue(&runString),
Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
&size);
Tcl_DStringFree(&runString);
@@ -885,7 +880,7 @@ Tk_MeasureChars(
Tcl_UtfToExternalDString(familyPtr->encoding, start,
(int) (p - start), &runString);
size.cx = 0;
- familyPtr->getTextExtentPoint32Proc(hdc, (TCHAR *) Tcl_DStringValue(&runString),
+ familyPtr->getTextExtentPoint32Proc(hdc, (WCHAR *) Tcl_DStringValue(&runString),
Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
&size);
Tcl_DStringFree(&runString);
@@ -919,7 +914,7 @@ Tk_MeasureChars(
Tcl_DStringAppend(&runString,buf,dstWrote);
size.cx = 0;
familyPtr->getTextExtentPoint32Proc(hdc,
- (TCHAR *) Tcl_DStringValue(&runString),
+ (WCHAR *) Tcl_DStringValue(&runString),
Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
&size);
if ((curX+size.cx) > maxLength) {
@@ -1021,7 +1016,7 @@ TkpMeasureCharsInContext(
Tk_Font tkfont, /* Font in which characters will be drawn. */
const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. */
- int numBytes, /* Maximum number of bytes to consider from
+ TCL_UNUSED(int), /* Maximum number of bytes to consider from
* source string in all. */
int rangeStart, /* Index of first byte to measure. */
int rangeLength, /* Length of range to measure in bytes. */
@@ -1043,7 +1038,6 @@ TkpMeasureCharsInContext(
int *lengthPtr) /* Filled with x-location just after the
* terminating character. */
{
- (void) numBytes; /*unused*/
return Tk_MeasureChars(tkfont, source + rangeStart, rangeLength,
maxLength, flags, lengthPtr);
}
@@ -1069,7 +1063,7 @@ Tk_DrawChars(
Display *display, /* Display on which to draw. */
Drawable drawable, /* Window or pixmap in which to draw. */
GC gc, /* Graphics context for drawing characters. */
- Tk_Font tkfont, /* Font in which characters will be drawn;
+ TCL_UNUSED(Tk_Font), /* Font in which characters will be drawn;
* must be the same as font used in GC. */
const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. All Tk meta-characters
@@ -1109,7 +1103,7 @@ Tk_DrawChars(
HBRUSH oldBrush, stipple;
HBITMAP oldBitmap, bitmap;
HDC dcMem;
- TEXTMETRIC tm;
+ TEXTMETRICW tm;
SIZE size;
if (twdPtr->type != TWD_BITMAP) {
@@ -1124,7 +1118,7 @@ Tk_DrawChars(
stipple = CreatePatternBrush(twdPtr->bitmap.handle);
SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL);
- oldBrush = SelectObject(dc, stipple);
+ oldBrush = (HBRUSH)SelectObject(dc, stipple);
SetTextAlign(dcMem, TA_LEFT | TA_BASELINE);
SetTextColor(dcMem, gc->foreground);
@@ -1136,10 +1130,10 @@ Tk_DrawChars(
*/
GetTextExtentPointA(dcMem, source, numBytes, &size);
- GetTextMetrics(dcMem, &tm);
+ GetTextMetricsW(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
- oldBitmap = SelectObject(dcMem, bitmap);
+ oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
/*
* The following code is tricky because fonts are rendered in multiple
@@ -1175,7 +1169,7 @@ Tk_DrawChars(
} else {
HBITMAP oldBitmap, bitmap;
HDC dcMem;
- TEXTMETRIC tm;
+ TEXTMETRICW tm;
SIZE size;
dcMem = CreateCompatibleDC(dc);
@@ -1190,10 +1184,10 @@ Tk_DrawChars(
*/
GetTextExtentPointA(dcMem, source, numBytes, &size);
- GetTextMetrics(dcMem, &tm);
+ GetTextMetricsW(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
- oldBitmap = SelectObject(dcMem, bitmap);
+ oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
MultiFontTextOut(dcMem, fontPtr, source, numBytes, 0, tm.tmAscent,
0.0);
@@ -1216,7 +1210,7 @@ TkDrawAngledChars(
Display *display, /* Display on which to draw. */
Drawable drawable, /* Window or pixmap in which to draw. */
GC gc, /* Graphics context for drawing characters. */
- Tk_Font tkfont, /* Font in which characters will be drawn;
+ TCL_UNUSED(Tk_Font), /* Font in which characters will be drawn;
* must be the same as font used in GC. */
const char *source, /* UTF-8 string to be displayed. Need not be
* '\0' terminated. All Tk meta-characters
@@ -1257,7 +1251,7 @@ TkDrawAngledChars(
HBRUSH oldBrush, stipple;
HBITMAP oldBitmap, bitmap;
HDC dcMem;
- TEXTMETRIC tm;
+ TEXTMETRICW tm;
SIZE size;
if (twdPtr->type != TWD_BITMAP) {
@@ -1272,7 +1266,7 @@ TkDrawAngledChars(
stipple = CreatePatternBrush(twdPtr->bitmap.handle);
SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL);
- oldBrush = SelectObject(dc, stipple);
+ oldBrush = (HBRUSH)SelectObject(dc, stipple);
SetTextAlign(dcMem, TA_LEFT | TA_BASELINE);
SetTextColor(dcMem, gc->foreground);
@@ -1284,10 +1278,10 @@ TkDrawAngledChars(
*/
GetTextExtentPointA(dcMem, source, numBytes, &size);
- GetTextMetrics(dcMem, &tm);
+ GetTextMetricsW(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
- oldBitmap = SelectObject(dcMem, bitmap);
+ oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
/*
* The following code is tricky because fonts are rendered in multiple
@@ -1298,11 +1292,11 @@ TkDrawAngledChars(
*/
PatBlt(dcMem, 0, 0, size.cx, size.cy, BLACKNESS);
- MultiFontTextOut(dc, fontPtr, source, numBytes, (int)x, (int)y, angle);
+ MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
BitBlt(dc, (int)x, (int)y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, 0xEA02E9);
PatBlt(dcMem, 0, 0, size.cx, size.cy, WHITENESS);
- MultiFontTextOut(dc, fontPtr, source, numBytes, (int)x, (int)y, angle);
+ MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
BitBlt(dc, (int)x, (int)y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, 0x8A0E06);
@@ -1319,11 +1313,11 @@ TkDrawAngledChars(
SetTextAlign(dc, TA_LEFT | TA_BASELINE);
SetTextColor(dc, gc->foreground);
SetBkMode(dc, TRANSPARENT);
- MultiFontTextOut(dc, fontPtr, source, numBytes, (int)x, (int)y, angle);
+ MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
} else {
HBITMAP oldBitmap, bitmap;
HDC dcMem;
- TEXTMETRIC tm;
+ TEXTMETRICW tm;
SIZE size;
dcMem = CreateCompatibleDC(dc);
@@ -1338,10 +1332,10 @@ TkDrawAngledChars(
*/
GetTextExtentPointA(dcMem, source, numBytes, &size);
- GetTextMetrics(dcMem, &tm);
+ GetTextMetricsW(dcMem, &tm);
size.cx -= tm.tmOverhang;
bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy);
- oldBitmap = SelectObject(dcMem, bitmap);
+ oldBitmap = (HBITMAP)SelectObject(dcMem, bitmap);
MultiFontTextOut(dcMem, fontPtr, source, numBytes, 0, tm.tmAscent,
angle);
@@ -1391,7 +1385,7 @@ TkpDrawCharsInContext(
* is passed to this function. If they are not
* stripped out, they will be displayed as
* regular printing characters. */
- int numBytes, /* Number of bytes in string. */
+ TCL_UNUSED(int), /* Number of bytes in string. */
int rangeStart, /* Index of first byte to draw. */
int rangeLength, /* Length of range to draw in bytes. */
int x, int y) /* Coordinates at which to place origin of the
@@ -1400,8 +1394,6 @@ TkpDrawCharsInContext(
{
int widthUntilStart;
- (void) numBytes; /*unused*/
-
Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart);
Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart,
rangeLength, x+widthUntilStart, y);
@@ -1434,7 +1426,7 @@ MultiFontTextOut(
* following string. */
const char *source, /* Potentially multilingual UTF-8 string. */
int numBytes, /* Length of string in bytes. */
- int x, int y, /* Coordinates at which to place origin of
+ double x, double y, /* Coordinates at which to place origin of
* string when drawing. */
double angle)
{
@@ -1445,11 +1437,12 @@ MultiFontTextOut(
Tcl_DString runString;
const char *p, *end, *next;
SubFont *lastSubFontPtr, *thisSubFontPtr;
- TEXTMETRIC tm;
+ TEXTMETRICW tm;
+ double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0);
lastSubFontPtr = &fontPtr->subFontArray[0];
oldFont = SelectFont(hdc, fontPtr, lastSubFontPtr, angle);
- GetTextMetrics(hdc, &tm);
+ GetTextMetricsW(hdc, &tm);
end = source + numBytes;
for (p = source; p < end; ) {
@@ -1469,19 +1462,20 @@ MultiFontTextOut(
Tcl_UtfToExternalDString(familyPtr->encoding, source,
(int) (p - source), &runString);
familyPtr->textOutProc(hdc, x-(tm.tmOverhang/2), y,
- (TCHAR *)Tcl_DStringValue(&runString),
+ (WCHAR *)Tcl_DStringValue(&runString),
Tcl_DStringLength(&runString)>>familyPtr->isWideFont);
familyPtr->getTextExtentPoint32Proc(hdc,
- (TCHAR *)Tcl_DStringValue(&runString),
+ (WCHAR *)Tcl_DStringValue(&runString),
Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
&size);
- x += size.cx;
+ x += cosA*size.cx;
+ y -= sinA*size.cx;
Tcl_DStringFree(&runString);
}
lastSubFontPtr = thisSubFontPtr;
source = p;
SelectFont(hdc, fontPtr, lastSubFontPtr, angle);
- GetTextMetrics(hdc, &tm);
+ GetTextMetricsW(hdc, &tm);
}
p = next;
}
@@ -1490,7 +1484,7 @@ MultiFontTextOut(
Tcl_UtfToExternalDString(familyPtr->encoding, source,
(int) (p - source), &runString);
familyPtr->textOutProc(hdc, x-(tm.tmOverhang/2), y,
- (TCHAR *)Tcl_DStringValue(&runString),
+ (WCHAR *)Tcl_DStringValue(&runString),
Tcl_DStringLength(&runString) >> familyPtr->isWideFont);
Tcl_DStringFree(&runString);
}
@@ -1505,9 +1499,9 @@ SelectFont(
double angle)
{
if (angle == 0.0) {
- return SelectObject(hdc, subFontPtr->hFont0);
+ return (HFONT)SelectObject(hdc, subFontPtr->hFont0);
} else if (angle == subFontPtr->angle) {
- return SelectObject(hdc, subFontPtr->hFontAngled);
+ return (HFONT)SelectObject(hdc, subFontPtr->hFontAngled);
} else {
if (subFontPtr->hFontAngled) {
DeleteObject(subFontPtr->hFontAngled);
@@ -1515,10 +1509,10 @@ SelectFont(
subFontPtr->hFontAngled = GetScreenFont(&fontPtr->font.fa,
subFontPtr->familyPtr->faceName, fontPtr->pixelSize, angle);
if (subFontPtr->hFontAngled == NULL) {
- return SelectObject(hdc, subFontPtr->hFont0);
+ return (HFONT)SelectObject(hdc, subFontPtr->hFont0);
}
subFontPtr->angle = angle;
- return SelectObject(hdc, subFontPtr->hFontAngled);
+ return (HFONT)SelectObject(hdc, subFontPtr->hFontAngled);
}
}
@@ -1551,7 +1545,7 @@ InitFont(
HFONT hFont, /* Windows token for font. */
int overstrike, /* The overstrike attribute of logfont used to
* allocate this font. For some reason, the
- * TEXTMETRICs may contain incorrect info in
+ * TEXTMETRICWs may contain incorrect info in
* the tmStruckOut field. */
WinFont *fontPtr) /* Filled with information constructed from
* the above arguments. */
@@ -1559,38 +1553,24 @@ InitFont(
HDC hdc;
HWND hwnd;
HFONT oldFont;
- TEXTMETRIC tm;
+ TEXTMETRICW tm;
Window window;
TkFontMetrics *fmPtr;
Tcl_Encoding encoding;
Tcl_DString faceString;
TkFontAttributes *faPtr;
- TCHAR buf[LF_FACESIZE];
+ WCHAR buf[LF_FACESIZE];
window = Tk_WindowId(tkwin);
hwnd = (window == None) ? NULL : TkWinGetHWND(window);
hdc = GetDC(hwnd);
- oldFont = SelectObject(hdc, hFont);
+ oldFont = (HFONT)SelectObject(hdc, hFont);
- GetTextMetrics(hdc, &tm);
+ GetTextMetricsW(hdc, &tm);
- /*
- * On any version NT, there may fonts with international names. Use the
- * NT-only Unicode version of GetTextFace to get the font's name. If we
- * used the ANSI version on a non-internationalized version of NT, we
- * would get a font name with '?' replacing all the international
- * characters.
- *
- * On a non-internationalized verson of 95, fonts with international names
- * are not allowed, so the ANSI version of GetTextFace will work. On an
- * internationalized version of 95, there may be fonts with international
- * names; the ANSI version will work, fetching the name in the
- * international system code page. Can't use the Unicode version of
- * GetTextFace because it only exists under NT.
- */
-
- GetTextFace(hdc, LF_FACESIZE, buf);
- Tcl_ExternalToUtfDString(systemEncoding, (char *) buf, -1, &faceString);
+ GetTextFaceW(hdc, LF_FACESIZE, buf);
+ Tcl_DStringInit(&faceString);
+ Tcl_WCharToUtfDString(buf, wcslen(buf), &faceString);
fontPtr->font.fid = (Font) fontPtr;
fontPtr->hwnd = hwnd;
@@ -1619,7 +1599,7 @@ InitFont(
encoding = fontPtr->subFontArray[0].familyPtr->encoding;
if (encoding == TkWinGetUnicodeEncoding()) {
- GetCharWidth(hdc, 0, BASE_CHARS - 1, fontPtr->widths);
+ GetCharWidthW(hdc, 0, BASE_CHARS - 1, fontPtr->widths);
} else {
GetCharWidthA(hdc, 0, BASE_CHARS - 1, fontPtr->widths);
}
@@ -1754,23 +1734,24 @@ AllocFontFamily(
HDC hdc, /* HDC in which font can be selected. */
HFONT hFont, /* Screen font whose FontFamily is to be
* returned. */
- int base) /* Non-zero if this font family is to be used
+ TCL_UNUSED(int)) /* Non-zero if this font family is to be used
* in the base font of a font object. */
{
Tk_Uid faceName;
FontFamily *familyPtr;
Tcl_DString faceString;
Tcl_Encoding encoding;
- TCHAR buf[LF_FACESIZE];
- ThreadSpecificData *tsdPtr =
+ WCHAR buf[LF_FACESIZE];
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- hFont = SelectObject(hdc, hFont);
- GetTextFace(hdc, LF_FACESIZE, buf);
- Tcl_ExternalToUtfDString(systemEncoding, (char *) buf, -1, &faceString);
+ hFont = (HFONT)SelectObject(hdc, hFont);
+ GetTextFaceW(hdc, LF_FACESIZE, buf);
+ Tcl_DStringInit(&faceString);
+ Tcl_WCharToUtfDString(buf, wcslen(buf), &faceString);
faceName = Tk_GetUid(Tcl_DStringValue(&faceString));
Tcl_DStringFree(&faceString);
- hFont = SelectObject(hdc, hFont);
+ hFont = (HFONT)SelectObject(hdc, hFont);
familyPtr = tsdPtr->fontFamilyList;
for ( ; familyPtr != NULL; familyPtr = familyPtr->nextPtr) {
@@ -1780,7 +1761,7 @@ AllocFontFamily(
}
}
- familyPtr = ckalloc(sizeof(FontFamily));
+ familyPtr = (FontFamily *)ckalloc(sizeof(FontFamily));
memset(familyPtr, 0, sizeof(FontFamily));
familyPtr->nextPtr = tsdPtr->fontFamilyList;
tsdPtr->fontFamilyList = familyPtr;
@@ -1823,17 +1804,17 @@ AllocFontFamily(
}
if (encoding == NULL) {
- encoding = Tcl_GetEncoding(NULL, "unicode");
+ encoding = TkWinGetUnicodeEncoding();
familyPtr->textOutProc =
- (BOOL (WINAPI *)(HDC, int, int, TCHAR *, int)) TextOutW;
+ (BOOL (WINAPI *)(HDC, int, int, WCHAR *, int)) TextOutW;
familyPtr->getTextExtentPoint32Proc =
- (BOOL (WINAPI *)(HDC, TCHAR *, int, LPSIZE)) GetTextExtentPoint32W;
+ (BOOL (WINAPI *)(HDC, WCHAR *, int, LPSIZE)) GetTextExtentPoint32W;
familyPtr->isWideFont = 1;
} else {
familyPtr->textOutProc =
- (BOOL (WINAPI *)(HDC, int, int, TCHAR *, int)) TextOutA;
+ (BOOL (WINAPI *)(HDC, int, int, WCHAR *, int)) TextOutA;
familyPtr->getTextExtentPoint32Proc =
- (BOOL (WINAPI *)(HDC, TCHAR *, int, LPSIZE)) GetTextExtentPoint32A;
+ (BOOL (WINAPI *)(HDC, WCHAR *, int, LPSIZE)) GetTextExtentPoint32A;
familyPtr->isWideFont = 0;
}
@@ -1866,7 +1847,7 @@ FreeFontFamily(
{
int i;
FontFamily **familyPtrPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (familyPtr == NULL) {
@@ -1943,7 +1924,7 @@ FindSubFontForChar(
SubFont *subFontPtr;
Tcl_DString ds;
- if (ch < BASE_CHARS) {
+ if ((ch < BASE_CHARS) || (ch >= FONTMAP_NUMCHARS)) {
return &fontPtr->subFontArray[0];
}
@@ -2028,7 +2009,7 @@ FindSubFontForChar(
canUse.ch = ch;
canUse.subFontPtr = NULL;
canUse.subFontPtrPtr = subFontPtrPtr;
- EnumFontFamilies(hdc, NULL, (FONTENUMPROC) WinFontCanUseProc,
+ EnumFontFamiliesW(hdc, NULL, (FONTENUMPROCW) WinFontCanUseProc,
(LPARAM) &canUse);
subFontPtr = canUse.subFontPtr;
@@ -2050,9 +2031,9 @@ FindSubFontForChar(
static int CALLBACK
WinFontCanUseProc(
- ENUMLOGFONT *lfPtr, /* Logical-font data. */
- NEWTEXTMETRIC *tmPtr, /* Physical-font data (not used). */
- int fontType, /* Type of font (not used). */
+ ENUMLOGFONTW *lfPtr, /* Logical-font data. */
+ TCL_UNUSED(NEWTEXTMETRIC *), /* Physical-font data (not used). */
+ TCL_UNUSED(int), /* Type of font (not used). */
LPARAM lParam) /* Result object to hold result. */
{
int ch;
@@ -2071,7 +2052,8 @@ WinFontCanUseProc(
nameTriedPtr = canUsePtr->nameTriedPtr;
fallbackName = (char *) lfPtr->elfLogFont.lfFaceName;
- Tcl_ExternalToUtfDString(systemEncoding, fallbackName, -1, &faceString);
+ Tcl_DStringInit(&faceString);
+ Tcl_WCharToUtfDString((WCHAR *)fallbackName, wcslen((WCHAR *)fallbackName), &faceString);
fallbackName = Tcl_DStringValue(&faceString);
if (SeenName(fallbackName, nameTriedPtr) == 0) {
@@ -2115,6 +2097,10 @@ FontMapLookup(
{
int row, bitOffset;
+ if (ch < 0 || ch >= FONTMAP_NUMCHARS) {
+ return 0;
+ }
+
row = ch >> FONTMAP_SHIFT;
if (subFontPtr->fontMap[row] == NULL) {
FontMapLoadPage(subFontPtr, row);
@@ -2155,12 +2141,14 @@ FontMapInsert(
{
int row, bitOffset;
- row = ch >> FONTMAP_SHIFT;
- if (subFontPtr->fontMap[row] == NULL) {
- FontMapLoadPage(subFontPtr, row);
+ if (ch >= 0 && ch < FONTMAP_NUMCHARS) {
+ row = ch >> FONTMAP_SHIFT;
+ if (subFontPtr->fontMap[row] == NULL) {
+ FontMapLoadPage(subFontPtr, row);
+ }
+ bitOffset = ch & (FONTMAP_BITSPERPAGE - 1);
+ subFontPtr->fontMap[row][bitOffset >> 3] |= 1 << (bitOffset & 7);
}
- bitOffset = ch & (FONTMAP_BITSPERPAGE - 1);
- subFontPtr->fontMap[row][bitOffset >> 3] |= 1 << (bitOffset & 7);
}
/*
@@ -2177,7 +2165,7 @@ FontMapInsert(
* None.
*
* Side effects:
- * Mempry allocated.
+ * Memory allocated.
*
*-------------------------------------------------------------------------
*/
@@ -2191,11 +2179,11 @@ FontMapLoadPage(
{
FontFamily *familyPtr;
Tcl_Encoding encoding;
- char src[XMaxTransChars], buf[16];
- USHORT *startCount, *endCount;
int i, j, bitOffset, end, segCount;
+ USHORT *startCount, *endCount;
+ char buf[16], src[6];
- subFontPtr->fontMap[row] = ckalloc(FONTMAP_BITSPERPAGE / 8);
+ subFontPtr->fontMap[row] = (char *)ckalloc(FONTMAP_BITSPERPAGE / 8);
memset(subFontPtr->fontMap[row], 0, FONTMAP_BITSPERPAGE / 8);
familyPtr = subFontPtr->familyPtr;
@@ -2244,7 +2232,7 @@ FontMapLoadPage(
end = (row + 1) << FONTMAP_SHIFT;
for (i = row << FONTMAP_SHIFT; i < end; i++) {
if (Tcl_UtfToExternal(NULL, encoding, src,
- Tcl_UniCharToUtf(i, src), TCL_ENCODING_STOPONERROR, NULL,
+ TkUniCharToUtf(i, src), TCL_ENCODING_STOPONERROR, NULL,
buf, sizeof(buf), NULL, NULL, NULL) != TCL_OK) {
continue;
}
@@ -2426,7 +2414,7 @@ CanUseFallback(
if (fontPtr->numSubFonts >= SUBFONT_SPACE) {
SubFont *newPtr;
- newPtr = ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
+ newPtr = (SubFont *)ckalloc(sizeof(SubFont) * (fontPtr->numSubFonts + 1));
memcpy(newPtr, fontPtr->subFontArray,
fontPtr->numSubFonts * sizeof(SubFont));
if (fontPtr->subFontArray != fontPtr->staticSubFonts) {
@@ -2474,9 +2462,8 @@ GetScreenFont(
double angle) /* What is the desired orientation of the
* font. */
{
- Tcl_DString ds;
HFONT hFont;
- LOGFONT lf;
+ LOGFONTW lf;
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -pixelSize;
@@ -2493,11 +2480,9 @@ GetScreenFont(
lf.lfQuality = DEFAULT_QUALITY;
lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- Tcl_UtfToExternalDString(systemEncoding, faceName, -1, &ds);
- _tcsncpy(lf.lfFaceName, (TCHAR *)Tcl_DStringValue(&ds), LF_FACESIZE-1);
- Tcl_DStringFree(&ds);
+ MultiByteToWideChar(CP_UTF8, 0, faceName, -1, lf.lfFaceName, LF_FACESIZE);
lf.lfFaceName[LF_FACESIZE-1] = 0;
- hFont = CreateFontIndirect(&lf);
+ hFont = CreateFontIndirectW(&lf);
return hFont;
}
@@ -2528,7 +2513,8 @@ FamilyExists(
int result;
Tcl_DString faceString;
- Tcl_UtfToExternalDString(systemEncoding, faceName, -1, &faceString);
+ Tcl_DStringInit(&faceString);
+ Tcl_UtfToWCharDString(faceName, -1, &faceString);
/*
* If the family exists, WinFontExistProc() will be called and
@@ -2537,8 +2523,8 @@ FamilyExists(
* non-zero value.
*/
- result = EnumFontFamilies(hdc, (TCHAR*) Tcl_DStringValue(&faceString),
- (FONTENUMPROC) WinFontExistProc, 0);
+ result = EnumFontFamiliesW(hdc, (WCHAR *)Tcl_DStringValue(&faceString),
+ (FONTENUMPROCW) WinFontExistProc, 0);
Tcl_DStringFree(&faceString);
return (result == 0);
}
@@ -2567,10 +2553,10 @@ FamilyOrAliasExists(
static int CALLBACK
WinFontExistProc(
- ENUMLOGFONT *lfPtr, /* Logical-font data. */
- NEWTEXTMETRIC *tmPtr, /* Physical-font data (not used). */
- int fontType, /* Type of font (not used). */
- LPARAM lParam) /* EnumFontData to hold result. */
+ TCL_UNUSED(ENUMLOGFONTW *), /* Logical-font data. */
+ TCL_UNUSED(NEWTEXTMETRIC *), /* Physical-font data (not used). */
+ TCL_UNUSED(int), /* Type of font (not used). */
+ TCL_UNUSED(LPARAM)) /* EnumFontData to hold result. */
{
return 0;
}
@@ -2725,7 +2711,7 @@ LoadFontRanges(
endCount = NULL;
*symbolPtr = 0;
- hFont = SelectObject(hdc, hFont);
+ hFont = (HFONT)SelectObject(hdc, hFont);
i = 0;
s = (char *) &i;
@@ -2780,8 +2766,8 @@ LoadFontRanges(
segCount = subTable.segment.segCountX2 / 2;
cbData = segCount * sizeof(USHORT);
- startCount = ckalloc(cbData);
- endCount = ckalloc(cbData);
+ startCount = (USHORT *)ckalloc(cbData);
+ endCount = (USHORT *)ckalloc(cbData);
offset = encTable.offset + sizeof(subTable.segment);
GetFontData(hdc, cmapKey, (DWORD) offset, endCount, cbData);
@@ -2824,8 +2810,8 @@ LoadFontRanges(
segCount = 1;
cbData = segCount * sizeof(USHORT);
- startCount = ckalloc(cbData);
- endCount = ckalloc(cbData);
+ startCount = (USHORT *)ckalloc(cbData);
+ endCount = (USHORT *)ckalloc(cbData);
startCount[0] = 0x0000;
endCount[0] = 0x00ff;
}
diff --git a/win/tkWinImage.c b/win/tkWinImage.c
index 0a8ef73..8cfcc55 100644
--- a/win/tkWinImage.c
+++ b/win/tkWinImage.c
@@ -126,6 +126,7 @@ PutPixel(
*/
destPtr[3] = 0;
+ /* FALLTHRU */
case 24:
/*
* Pixel is triplet: 0xBBGGRR.
@@ -211,7 +212,10 @@ XCreateImage(
int bitmap_pad,
int bytes_per_line)
{
- XImage* imagePtr = ckalloc(sizeof(XImage));
+ XImage* imagePtr = (XImage*)ckalloc(sizeof(XImage));
+ (void)display;
+ (void)visual;
+
imagePtr->width = width;
imagePtr->height = height;
imagePtr->xoffset = offset;
@@ -299,6 +303,7 @@ XGetImageZPixmap(
unsigned char *data;
TkWinDCState state;
BOOL ret;
+ (void)plane_mask;
if (format != ZPixmap) {
TkpDisplayWarning("Only ZPixmap types are implemented",
@@ -314,7 +319,7 @@ XGetImageZPixmap(
hbmp = CreateCompatibleBitmap(hdc, (int) width, (int) height);
hdcMem = CreateCompatibleDC(hdc);
- hbmpPrev = SelectObject(hdcMem, hbmp);
+ hbmpPrev = (HBITMAP)SelectObject(hdcMem, hbmp);
hPal = state.palette;
if (hPal) {
hPalPrev1 = SelectPalette(hdcMem, hPal, FALSE);
@@ -349,7 +354,7 @@ XGetImageZPixmap(
if (depth <= 8) {
size += sizeof(unsigned short) << depth;
}
- bmInfo = ckalloc(size);
+ bmInfo = (BITMAPINFO *)ckalloc(size);
bmInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo->bmiHeader.biWidth = width;
@@ -367,7 +372,7 @@ XGetImageZPixmap(
unsigned char *p, *pend;
GetDIBits(hdcMem, hbmp, 0, height, NULL, bmInfo, DIB_PAL_COLORS);
- data = ckalloc(bmInfo->bmiHeader.biSizeImage);
+ data = (unsigned char *)ckalloc(bmInfo->bmiHeader.biSizeImage);
if (!data) {
/* printf("Failed to allocate data area for XImage.\n"); */
ret_image = NULL;
@@ -403,7 +408,7 @@ XGetImageZPixmap(
unsigned char *p;
GetDIBits(hdcMem, hbmp, 0, height, NULL, bmInfo, DIB_PAL_COLORS);
- data = ckalloc(bmInfo->bmiHeader.biSizeImage);
+ data = (unsigned char *)ckalloc(bmInfo->bmiHeader.biSizeImage);
if (!data) {
/* printf("Failed to allocate data area for XImage.\n"); */
ret_image = NULL;
@@ -434,7 +439,7 @@ XGetImageZPixmap(
}
} else if (depth == 16) {
GetDIBits(hdcMem, hbmp, 0, height, NULL, bmInfo, DIB_RGB_COLORS);
- data = ckalloc(bmInfo->bmiHeader.biSizeImage);
+ data = (unsigned char *)ckalloc(bmInfo->bmiHeader.biSizeImage);
if (!data) {
/* printf("Failed to allocate data area for XImage.\n"); */
ret_image = NULL;
@@ -460,7 +465,7 @@ XGetImageZPixmap(
}
} else {
GetDIBits(hdcMem, hbmp, 0, height, NULL, bmInfo, DIB_RGB_COLORS);
- data = ckalloc(width * height * 4);
+ data = (unsigned char *)ckalloc(width * height * 4);
if (!data) {
/* printf("Failed to allocate data area for XImage.\n"); */
ret_image = NULL;
@@ -483,7 +488,7 @@ XGetImageZPixmap(
unsigned int byte_width, h, w;
byte_width = ((width * 3 + 3) & ~(unsigned)3);
- smallBitBase = ckalloc(byte_width * height);
+ smallBitBase = (unsigned char *)ckalloc(byte_width * height);
if (!smallBitBase) {
ckfree(ret_image->data);
ckfree(ret_image);
@@ -613,7 +618,7 @@ XGetImage(
imagePtr = XCreateImage(display, NULL, 32, format, 0, NULL,
width, height, 32, 0);
size = imagePtr->bytes_per_line * imagePtr->height;
- imagePtr->data = ckalloc(size);
+ imagePtr->data = (char *)ckalloc(size);
ZeroMemory(imagePtr->data, size);
for (yy = 0; yy < height; yy++) {
@@ -660,7 +665,7 @@ XGetImage(
imagePtr = XCreateImage(display, NULL, 1, XYBitmap, 0, NULL,
width, height, 32, 0);
- imagePtr->data = ckalloc(imagePtr->bytes_per_line * imagePtr->height);
+ imagePtr->data = (char *)ckalloc(imagePtr->bytes_per_line * imagePtr->height);
dc = GetDC(NULL);
diff --git a/win/tkWinInit.c b/win/tkWinInit.c
index 4c18399..854d62f 100644
--- a/win/tkWinInit.c
+++ b/win/tkWinInit.c
@@ -35,6 +35,7 @@ int
TkpInit(
Tcl_Interp *interp)
{
+ (void)interp;
/*
* This is necessary for static initialization, and is ok otherwise
* because TkWinXInit flips a static bit to do its work just once.
@@ -137,21 +138,21 @@ TkpDisplayWarning(
len = MultiByteToWideChar(CP_UTF8, 0, title, -1, titleString, TK_MAX_WARN_LEN);
msgString = &titleString[len + 1];
- titleString[TK_MAX_WARN_LEN - 1] = L'\0';
+ titleString[TK_MAX_WARN_LEN - 1] = '\0';
MultiByteToWideChar(CP_UTF8, 0, msg, -1, msgString, (TK_MAX_WARN_LEN - 1) - len);
/*
* Truncate MessageBox string if it is too long to not overflow the screen
* and cause possible oversized window error.
*/
- if (titleString[TK_MAX_WARN_LEN - 1] != L'\0') {
+ if (titleString[TK_MAX_WARN_LEN - 1] != '\0') {
memcpy(titleString + (TK_MAX_WARN_LEN - 5), L" ...", 5 * sizeof(WCHAR));
}
if (IsDebuggerPresent()) {
- titleString[len - 1] = L':';
- titleString[len] = L' ';
+ titleString[len - 1] = ':';
+ titleString[len] = ' ';
OutputDebugStringW(titleString);
} else {
- titleString[len - 1] = L'\0';
+ titleString[len - 1] = '\0';
MessageBoxW(NULL, msgString, titleString,
MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL
| MB_SETFOREGROUND | MB_TOPMOST);
@@ -178,33 +179,28 @@ Tcl_Obj*
TkWin32ErrorObj(
HRESULT hrError)
{
- LPTSTR lpBuffer = NULL, p = NULL;
- TCHAR sBuffer[30];
+ LPWSTR lpBuffer = NULL, p = NULL;
+ WCHAR sBuffer[30];
Tcl_Obj* errPtr = NULL;
-#ifdef _UNICODE
Tcl_DString ds;
-#endif
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
+ FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS, NULL, (DWORD)hrError,
- LANG_NEUTRAL, (LPTSTR)&lpBuffer, 0, NULL);
+ LANG_NEUTRAL, (LPWSTR)&lpBuffer, 0, NULL);
if (lpBuffer == NULL) {
lpBuffer = sBuffer;
- wsprintf(sBuffer, TEXT("Error Code: %08lX"), hrError);
+ wsprintfW(sBuffer, L"Error Code: %08lX", hrError);
}
- if ((p = _tcsrchr(lpBuffer, TEXT('\r'))) != NULL) {
- *p = TEXT('\0');
+ if ((p = wcsrchr(lpBuffer, '\r')) != NULL) {
+ *p = '\0';
}
-#ifdef _UNICODE
- Tcl_WinTCharToUtf(lpBuffer, (int)wcslen(lpBuffer) * sizeof (WCHAR), &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(lpBuffer, wcslen(lpBuffer), &ds);
errPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
-#else
- errPtr = Tcl_NewStringObj(lpBuffer, (int)strlen(lpBuffer));
-#endif /* _UNICODE */
if (lpBuffer != sBuffer) {
LocalFree((HLOCAL)lpBuffer);
@@ -212,7 +208,6 @@ TkWin32ErrorObj(
return errPtr;
}
-
/*
* Local Variables:
diff --git a/win/tkWinInt.h b/win/tkWinInt.h
index 0e2c844..7e3119e 100644
--- a/win/tkWinInt.h
+++ b/win/tkWinInt.h
@@ -117,8 +117,8 @@ typedef struct {
* The following macros define the class names for Tk Window types.
*/
-#define TK_WIN_TOPLEVEL_CLASS_NAME TEXT("TkTopLevel")
-#define TK_WIN_CHILD_CLASS_NAME TEXT("TkChild")
+#define TK_WIN_TOPLEVEL_CLASS_NAME L"TkTopLevel"
+#define TK_WIN_CHILD_CLASS_NAME L"TkChild"
/*
* The following variable is a translation table between X gc functions and
@@ -185,6 +185,7 @@ MODULE_SCOPE void TkWinSetupSystemFonts(TkMainInfo *mainPtr);
#define TK_THEME_WIN_CLASSIC 1
#define TK_THEME_WIN_XP 2
+#define TK_THEME_WIN_VISTA 3
/*
* The following is implemented in tkWinWm and used by tkWinEmbed.c
@@ -200,6 +201,16 @@ MODULE_SCOPE long TkpWinToplevelOverrideRedirect(TkWindow *winPtr,
MODULE_SCOPE void TkpWinToplevelDetachWindow(TkWindow *winPtr);
MODULE_SCOPE int TkpWmGetState(TkWindow *winPtr);
+MODULE_SCOPE int TkTranslateWinEvent(HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam, LRESULT *result);
+MODULE_SCOPE void TkWinPointerEvent(HWND hwnd, int x, int y);
+
+/*
+ * The following is implemented in tkWinPointer.c and also used in tkWinWindow.c
+ */
+
+MODULE_SCOPE void TkSetCursorPos(int x, int y);
+
/*
* Common routines used in Windows implementation
*/
@@ -213,17 +224,8 @@ MODULE_SCOPE Tcl_Obj * TkWin32ErrorObj(HRESULT hrError);
*/
#ifndef GetClassLongPtr
-# define GetClassLongPtrA GetClassLongA
# define GetClassLongPtrW GetClassLongW
-# define SetClassLongPtrA SetClassLongA
# define SetClassLongPtrW SetClassLongW
-# ifdef UNICODE
-# define GetClassLongPtr GetClassLongPtrW
-# define SetClassLongPtr SetClassLongPtrW
-# else
-# define GetClassLongPtr GetClassLongPtrA
-# define SetClassLongPtr SetClassLongPtrA
-# endif /* !UNICODE */
#endif /* !GetClassLongPtr */
#ifndef GCLP_HICON
# define GCLP_HICON GCL_HICON
@@ -233,17 +235,8 @@ MODULE_SCOPE Tcl_Obj * TkWin32ErrorObj(HRESULT hrError);
#endif /* !GCLP_HICONSM */
#ifndef GetWindowLongPtr
-# define GetWindowLongPtrA GetWindowLongA
# define GetWindowLongPtrW GetWindowLongW
-# define SetWindowLongPtrA SetWindowLongA
# define SetWindowLongPtrW SetWindowLongW
-# ifdef UNICODE
-# define GetWindowLongPtr GetWindowLongPtrW
-# define SetWindowLongPtr SetWindowLongPtrW
-# else
-# define GetWindowLongPtr GetWindowLongPtrW
-# define SetWindowLongPtr SetWindowLongPtrW
-# endif /* !UNICODE */
#endif /* !GetWindowLongPtr */
#ifndef GWLP_WNDPROC
#define GWLP_WNDPROC GWL_WNDPROC
diff --git a/win/tkWinKey.c b/win/tkWinKey.c
index 357a804..2c20b64 100644
--- a/win/tkWinKey.c
+++ b/win/tkWinKey.c
@@ -11,6 +11,7 @@
*/
#include "tkWinInt.h"
+#include "X11/XF86keysym.h"
/*
* The keymap table holds mappings of Windows keycodes to X keysyms. If
@@ -21,46 +22,47 @@
* like a worthwhile improvement to use the table.
*/
-#define MAX_KEYCODE 179 /* VK_MEDIA_PLAY_PAUSE is the last entry in our table below */
+#define MAX_KEYCODE 183 /* VK_LAUNCH_APP2 is the last entry in our table below */
/* cf. https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx */
static const KeySym keymap[] = {
- NoSymbol, NoSymbol, NoSymbol, XK_Cancel, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, XK_BackSpace, XK_Tab,
- NoSymbol, NoSymbol, XK_Clear, XK_Return, NoSymbol,
- NoSymbol, XK_Shift_L, XK_Control_L, XK_Alt_L, XK_Pause,
- XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, XK_Escape, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, XK_space, XK_Prior, XK_Next,
- XK_End, XK_Home, XK_Left, XK_Up, XK_Right,
- XK_Down, XK_Select, XK_Print, XK_Execute, NoSymbol,
- XK_Insert, XK_Delete, XK_Help, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, XK_Win_L, XK_Win_R, XK_App, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, XK_F1, XK_F2, XK_F3,
- XK_F4, XK_F5, XK_F6, XK_F7, XK_F8,
- XK_F9, XK_F10, XK_F11, XK_F12, XK_F13,
- XK_F14, XK_F15, XK_F16, XK_F17, XK_F18,
- XK_F19, XK_F20, XK_F21, XK_F22, XK_F23,
- XK_F24, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, XK_Num_Lock,
- XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Cancel, NoSymbol, /*0 0x0*/
+ NoSymbol, NoSymbol, NoSymbol, XK_BackSpace, XK_Tab, /*5 0x5*/
+ NoSymbol, NoSymbol, XK_Clear, XK_Return, NoSymbol, /*10 0xA*/
+ NoSymbol, XK_Shift_L, XK_Control_L, XK_Alt_L, XK_Pause, /*15 0xE*/
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*20 0x14*/
+ NoSymbol, NoSymbol, XK_Escape, NoSymbol, NoSymbol, /*25 0x19*/
+ NoSymbol, NoSymbol, XK_space, XK_Prior, XK_Next, /*30 0x1E*/
+ XK_End, XK_Home, XK_Left, XK_Up, XK_Right, /*35 0x23*/
+ XK_Down, XK_Select, XK_Print, XK_Execute, NoSymbol, /*40 0x28*/
+ XK_Insert, XK_Delete, XK_Help, NoSymbol, NoSymbol, /*45 0x2D*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*50 0x32*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*55 0x37*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*60 0x3C*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*65 0x41*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*70 0x46*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*75 0x4B*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*80 0x50*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*85 0x55*/
+ NoSymbol, XK_Win_L, XK_Win_R, XK_App, NoSymbol, /*90 0x5A*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*95 0x5F*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*100 0x64*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*105 0x69*/
+ NoSymbol, NoSymbol, XK_F1, XK_F2, XK_F3, /*110 0x6E*/
+ XK_F4, XK_F5, XK_F6, XK_F7, XK_F8, /*115 0x73*/
+ XK_F9, XK_F10, XK_F11, XK_F12, XK_F13, /*120 0x78*/
+ XK_F14, XK_F15, XK_F16, XK_F17, XK_F18, /*125 0x7D*/
+ XK_F19, XK_F20, XK_F21, XK_F22, XK_F23, /*130 0x82*/
+ XK_F24, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*135 0x87*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, XK_Num_Lock, /*140 0x8C*/
+ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*145 0x91*/
NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*150 0x96*/
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*155 0x9b*/
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*160 0xa0*/
- NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*165 0xa5*/
- NoSymbol, NoSymbol, NoSymbol, XK_XF86AudioMute, XK_XF86AudioLowerVolume, /*170 0xaa*/
- XK_XF86AudioRaiseVolume, XK_XF86AudioNext, XK_XF86AudioPrev, XK_XF86AudioStop, XK_XF86AudioPlay /*175 0xaf*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*155 0x9B*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*160 0xA0*/
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*165 0xA5*/
+ NoSymbol, NoSymbol, NoSymbol, XF86XK_AudioMute, XF86XK_AudioLowerVolume, /*170 0xAA*/
+ XF86XK_AudioRaiseVolume, XF86XK_AudioNext, XF86XK_AudioPrev, XF86XK_AudioStop, XF86XK_AudioPlay, /*175 0xAF*/
+ XF86XK_Mail, XF86XK_AudioMedia, XF86XK_Launch0, XF86XK_Launch1 /*180 0xB4*/
};
/*
@@ -95,14 +97,16 @@ TkpGetString(
* result. */
{
XKeyEvent *keyEv = &eventPtr->xkey;
- char buf[6];
int len;
+ char buf[6];
+ (void)winPtr;
Tcl_DStringInit(dsPtr);
if (keyEv->send_event == -1) {
- if (keyEv->nbytes > 0) {
+ TkKeyEvent *ev = (TkKeyEvent *)keyEv;
+ if (ev->nbytes > 0) {
Tcl_ExternalToUtfDString(TkWinGetKeyInputEncoding(),
- keyEv->trans_chars, keyEv->nbytes, dsPtr);
+ ev->trans_chars, ev->nbytes, dsPtr);
}
} else if (keyEv->send_event == -3) {
@@ -122,7 +126,7 @@ TkpGetString(
if (((keysym != NoSymbol) && (keysym > 0) && (keysym < 256))
|| (keysym == XK_Return) || (keysym == XK_Tab)) {
- len = Tcl_UniCharToUtf((Tcl_UniChar) (keysym & 255), buf);
+ len = TkUniCharToUtf(keysym & 255, buf);
Tcl_DStringAppend(dsPtr, buf, len);
}
}
@@ -153,6 +157,24 @@ XKeycodeToKeysym(
int index)
{
int state = 0;
+ (void)display;
+
+ if (index & 0x01) {
+ state |= ShiftMask;
+ }
+ return KeycodeToKeysym(keycode, state, 0);
+}
+
+KeySym
+XkbKeycodeToKeysym(
+ Display *display,
+ unsigned int keycode,
+ int group,
+ int index)
+{
+ int state = 0;
+ (void)display;
+ (void)group;
if (index & 0x01) {
state |= ShiftMask;
@@ -186,8 +208,8 @@ KeycodeToKeysym(
{
BYTE keys[256];
int result, deadkey, shift;
- TCHAR buf[4];
- unsigned int scancode = MapVirtualKey(keycode, 0);
+ WCHAR buf[4];
+ unsigned int scancode = MapVirtualKeyW(keycode, 0);
/*
* Do not run keycodes of lock keys through ToUnicode(). One of ToUnicode()'s
@@ -201,10 +223,10 @@ KeycodeToKeysym(
}
/*
- * Use MapVirtualKey() to detect some dead keys.
+ * Use MapVirtualKeyW() to detect some dead keys.
*/
- if (MapVirtualKey(keycode, 2) > 0x7fffUL) {
+ if (MapVirtualKeyW(keycode, 2) > 0x7fffUL) {
return XK_Multi_key;
}
@@ -261,10 +283,10 @@ KeycodeToKeysym(
* Get information about the old char
*/
- deadkey = VkKeyScan(buf[0]);
+ deadkey = VkKeyScanW(buf[0]);
shift = deadkey >> 8;
deadkey &= 255;
- scancode = MapVirtualKey(deadkey, 0);
+ scancode = MapVirtualKeyW(deadkey, 0);
/*
* Set up a keyboard with proper modifier keys
@@ -502,7 +524,7 @@ TkpInitKeymapInfo(
}
dispPtr->numModKeyCodes = 0;
arraySize = KEYCODE_ARRAY_SIZE;
- dispPtr->modKeyCodes = ckalloc(KEYCODE_ARRAY_SIZE * sizeof(KeyCode));
+ dispPtr->modKeyCodes = (KeyCode *)ckalloc(KEYCODE_ARRAY_SIZE * sizeof(KeyCode));
for (i = 0, codePtr = modMapPtr->modifiermap; i < max; i++, codePtr++) {
if (*codePtr == 0) {
continue;
@@ -518,18 +540,18 @@ TkpInitKeymapInfo(
}
}
if (dispPtr->numModKeyCodes >= arraySize) {
- KeyCode *new;
+ KeyCode *newKey;
/*
* Ran out of space in the array; grow it.
*/
arraySize *= 2;
- new = ckalloc(arraySize * sizeof(KeyCode));
- memcpy(new, dispPtr->modKeyCodes,
+ newKey = (KeyCode *)ckalloc(arraySize * sizeof(KeyCode));
+ memcpy(newKey, dispPtr->modKeyCodes,
dispPtr->numModKeyCodes * sizeof(KeyCode));
ckfree(dispPtr->modKeyCodes);
- dispPtr->modKeyCodes = new;
+ dispPtr->modKeyCodes = newKey;
}
dispPtr->modKeyCodes[dispPtr->numModKeyCodes] = *codePtr;
dispPtr->numModKeyCodes++;
@@ -540,7 +562,7 @@ TkpInitKeymapInfo(
/*
* When mapping from a keysym to a keycode, need information about the
- * modifier state that should be used so that when they call XKeycodeToKeysym
+ * modifier state that should be used so that when they call XkbKeycodeToKeysym
* taking into account the xkey.state, they will get back the original keysym.
*/
@@ -553,6 +575,7 @@ TkpSetKeycodeAndState(
int i;
SHORT result;
int shift;
+ (void)tkwin;
eventPtr->xkey.keycode = 0;
if (keySym == NoSymbol) {
@@ -572,7 +595,7 @@ TkpSetKeycodeAndState(
}
}
if (keySym >= 0x20) {
- result = VkKeyScan((TCHAR) keySym);
+ result = VkKeyScanW((WCHAR) keySym);
if (result != -1) {
shift = result >> 8;
if (shift & 1)
@@ -609,6 +632,7 @@ XKeysymToKeycode(
{
int i;
SHORT result;
+ (void)display;
/*
* We check our private map first for a virtual keycode, as VkKeyScan will
@@ -625,7 +649,7 @@ XKeysymToKeycode(
}
}
if (keysym >= 0x20) {
- result = VkKeyScan((TCHAR) keysym);
+ result = VkKeyScanW((WCHAR) keysym);
if (result != -1) {
return (KeyCode) (result & 0xff);
}
@@ -654,10 +678,11 @@ XModifierKeymap *
XGetModifierMapping(
Display *display)
{
- XModifierKeymap *map = ckalloc(sizeof(XModifierKeymap));
+ XModifierKeymap *map = (XModifierKeymap *)ckalloc(sizeof(XModifierKeymap));
+ (void)display;
map->max_keypermod = 1;
- map->modifiermap = ckalloc(sizeof(KeyCode) * 8);
+ map->modifiermap = (KeyCode *)ckalloc(sizeof(KeyCode) * 8);
map->modifiermap[ShiftMapIndex] = VK_SHIFT;
map->modifiermap[LockMapIndex] = VK_CAPITAL;
map->modifiermap[ControlMapIndex] = VK_CONTROL;
@@ -715,6 +740,8 @@ KeySym
XStringToKeysym(
_Xconst char *string)
{
+ (void)string;
+
return NoSymbol;
}
@@ -738,6 +765,8 @@ char *
XKeysymToString(
KeySym keysym)
{
+ (void)keysym;
+
return NULL;
}
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index 1896474..0b6efcf 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.c
@@ -19,8 +19,8 @@
* The class of the window for popup menus.
*/
-#define MENU_CLASS_NAME TEXT("MenuWindowClass")
-#define EMBEDDED_MENU_CLASS_NAME TEXT("EmbeddedMenuWindowClass")
+#define MENU_CLASS_NAME L"MenuWindowClass"
+#define EMBEDDED_MENU_CLASS_NAME L"EmbeddedMenuWindowClass"
/*
* Used to align a windows bitmap inside a rectangle
@@ -85,7 +85,7 @@ static int indicatorDimensions[2];
static BOOL showMenuAccelerators;
-typedef struct ThreadSpecificData {
+typedef struct {
int inPostMenu; /* We cannot be re-entrant like X Windows. */
WORD lastCommandID; /* The last command ID we allocated. */
HWND menuHWND; /* A window to service popup-menu messages
@@ -233,13 +233,13 @@ GetNewID(
TkMenuEntry *mePtr, /* The menu we are working with. */
WORD *menuIDPtr) /* The resulting id. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
WORD curID = tsdPtr->lastCommandID;
while (1) {
Tcl_HashEntry *commandEntryPtr;
- int new;
+ int isNew;
/*
* Try the next ID number, taking care to wrap rather than stray
@@ -255,8 +255,8 @@ GetNewID(
}
commandEntryPtr = Tcl_CreateHashEntry(&tsdPtr->commandTable,
- INT2PTR(curID), &new);
- if (new) {
+ INT2PTR(curID), &isNew);
+ if (isNew) {
Tcl_SetHashValue(commandEntryPtr, mePtr);
*menuIDPtr = curID;
tsdPtr->lastCommandID = curID;
@@ -285,7 +285,7 @@ static void
FreeID(
WORD commandID)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -328,7 +328,7 @@ TkpNewMenu(
HMENU winMenuHdl;
Tcl_HashEntry *hashEntryPtr;
int newEntry;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
winMenuHdl = CreatePopupMenu();
@@ -374,7 +374,7 @@ TkpDestroyMenu(
{
HMENU winMenuHdl = (HMENU) menuPtr->platformData;
const char *searchName;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (menuPtr->menuFlags & MENU_RECONFIGURE_PENDING) {
@@ -388,7 +388,7 @@ TkpDestroyMenu(
if (menuPtr->menuFlags & MENU_SYSTEM_MENU) {
TkMenuEntry *searchEntryPtr;
Tcl_HashTable *tablePtr = TkGetMenuHashTable(menuPtr->interp);
- char *menuName = Tcl_GetHashKey(tablePtr,
+ char *menuName = (char *)Tcl_GetHashKey(tablePtr,
menuPtr->menuRefPtr->hashEntryPtr);
/*
@@ -492,16 +492,16 @@ GetEntryText(
char *itemText;
if (mePtr->type == TEAROFF_ENTRY) {
- itemText = ckalloc(sizeof("(Tear-off)"));
+ itemText = (char *)ckalloc(sizeof("(Tear-off)"));
strcpy(itemText, "(Tear-off)");
} else if (mePtr->imagePtr != NULL) {
- itemText = ckalloc(sizeof("(Image)"));
+ itemText = (char *)ckalloc(sizeof("(Image)"));
strcpy(itemText, "(Image)");
} else if (mePtr->bitmapPtr != NULL) {
- itemText = ckalloc(sizeof("(Pixmap)"));
+ itemText = (char *)ckalloc(sizeof("(Pixmap)"));
strcpy(itemText, "(Pixmap)");
} else if (mePtr->labelPtr == NULL || mePtr->labelLength == 0) {
- itemText = ckalloc(sizeof("( )"));
+ itemText = (char *)ckalloc(sizeof("( )"));
strcpy(itemText, "( )");
} else {
int i;
@@ -511,6 +511,7 @@ GetEntryText(
: Tcl_GetString(mePtr->accelPtr);
const char *p, *next;
Tcl_DString itemString;
+ int ch;
/*
* We have to construct the string with an ampersand preceeding the
@@ -527,7 +528,7 @@ GetEntryText(
if (*p == '&') {
Tcl_DStringAppend(&itemString, "&", 1);
}
- next = Tcl_UtfNext(p);
+ next = p + TkUtfToUniChar(p, &ch);
Tcl_DStringAppend(&itemString, p, (int) (next - p));
}
if (mePtr->accelLength > 0) {
@@ -536,12 +537,12 @@ GetEntryText(
if (*p == '&') {
Tcl_DStringAppend(&itemString, "&", 1);
}
- next = Tcl_UtfNext(p);
+ next = p + TkUtfToUniChar(p, &ch);
Tcl_DStringAppend(&itemString, p, (int) (next - p));
}
}
- itemText = ckalloc(Tcl_DStringLength(&itemString) + 1);
+ itemText = (char *)ckalloc(Tcl_DStringLength(&itemString) + 1);
strcpy(itemText, Tcl_DStringValue(&itemString));
Tcl_DStringFree(&itemString);
}
@@ -569,11 +570,11 @@ static void
ReconfigureWindowsMenu(
ClientData clientData) /* The menu we are rebuilding */
{
- TkMenu *menuPtr = clientData;
+ TkMenu *menuPtr = (TkMenu *)clientData;
TkMenuEntry *mePtr;
HMENU winMenuHdl = (HMENU) menuPtr->platformData;
char *itemText = NULL;
- const TCHAR *lpNewItem;
+ LPCWSTR lpNewItem;
UINT flags;
UINT itemID;
int i, count, systemMenu = 0, base;
@@ -609,11 +610,12 @@ ReconfigureWindowsMenu(
itemText = GetEntryText(menuPtr, mePtr);
if ((menuPtr->menuType == MENUBAR)
|| (menuPtr->menuFlags & MENU_SYSTEM_MENU)) {
- Tcl_WinUtfToTChar(itemText, -1, &translatedText);
- lpNewItem = (const TCHAR *) Tcl_DStringValue(&translatedText);
+ Tcl_DStringInit(&translatedText);
+ Tcl_UtfToWCharDString(itemText, -1, &translatedText);
+ lpNewItem = (LPCWSTR) Tcl_DStringValue(&translatedText);
flags |= MF_STRING;
} else {
- lpNewItem = (LPCTSTR) mePtr;
+ lpNewItem = (LPCWSTR) mePtr;
flags |= MF_OWNERDRAW;
}
@@ -716,7 +718,7 @@ ReconfigureWindowsMenu(
}
}
if (!systemMenu) {
- InsertMenu(winMenuHdl, 0xFFFFFFFF, flags, itemID, lpNewItem);
+ InsertMenuW(winMenuHdl, 0xFFFFFFFF, flags, itemID, lpNewItem);
}
Tcl_DStringFree(&translatedText);
if (itemText != NULL) {
@@ -728,7 +730,7 @@ ReconfigureWindowsMenu(
if ((menuPtr->menuType == MENUBAR)
&& (menuPtr->parentTopLevelPtr != NULL)) {
- HANDLE bar = TkWinGetWrapperWindow(menuPtr->parentTopLevelPtr);
+ HWND bar = TkWinGetWrapperWindow(menuPtr->parentTopLevelPtr);
if (bar) {
DrawMenuBar(bar);
@@ -759,7 +761,7 @@ ReconfigureWindowsMenu(
int
TkpPostMenu(
- Tcl_Interp *interp,
+ Tcl_Interp *dummy,
TkMenu *menuPtr,
int x, int y, int index)
{
@@ -769,8 +771,9 @@ TkpPostMenu(
POINT point;
Tk_Window parentWindow = Tk_Parent(menuPtr->tkwin);
int oldServiceMode = Tcl_GetServiceMode();
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
tsdPtr->inPostMenu++;
CallPendingReconfigureImmediately(menuPtr);
@@ -781,7 +784,7 @@ TkpPostMenu(
return result;
}
- if (index >= menuPtr->numEntries) {
+ if (index >= (int)menuPtr->numEntries) {
index = menuPtr->numEntries - 1;
}
if (index >= 0) {
@@ -839,7 +842,7 @@ TkpPostMenu(
Tcl_SetServiceMode(oldServiceMode);
GetCursorPos(&point);
- Tk_PointerEvent(NULL, point.x, point.y);
+ TkWinPointerEvent(NULL, point.x, point.y);
if (tsdPtr->inPostMenu) {
tsdPtr->inPostMenu = 0;
@@ -869,15 +872,16 @@ TkpPostMenu(
int
TkpPostTearoffMenu(
- Tcl_Interp *interp, /* The interpreter of the menu */
+ Tcl_Interp *dummy, /* The interpreter of the menu */
TkMenu *menuPtr, /* The menu we are posting */
int x, int y, int index) /* The root X,Y coordinates where we are
* posting */
{
int vRootX, vRootY, vRootWidth, vRootHeight;
int result;
+ (void)dummy;
- if (index >= menuPtr->numEntries) {
+ if (index >= (int)menuPtr->numEntries) {
index = menuPtr->numEntries - 1;
}
if (index >= 0) {
@@ -1003,7 +1007,7 @@ TkWinMenuProc(
LRESULT lResult;
if (!TkWinHandleMenuEvent(&hwnd, &message, &wParam, &lParam, &lResult)) {
- lResult = DefWindowProc(hwnd, message, wParam, lParam);
+ lResult = DefWindowProcW(hwnd, message, wParam, lParam);
}
return lResult;
}
@@ -1064,7 +1068,7 @@ TkWinEmbeddedMenuProc(
{
static int nIdles = 0;
LRESULT lResult = 1;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
switch(message) {
@@ -1100,9 +1104,9 @@ TkWinEmbeddedMenuProc(
if (lResult || (GetCapture() != hwnd)) {
break;
}
-
+ /* FALLTHRU */
default:
- lResult = DefWindowProc(hwnd, message, wParam, lParam);
+ lResult = DefWindowProcW(hwnd, message, wParam, lParam);
break;
}
return lResult;
@@ -1140,15 +1144,16 @@ TkWinHandleMenuEvent(
int returnResult = 0;
TkMenu *menuPtr;
TkMenuEntry *mePtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)phwnd;
switch (*pMessage) {
case WM_UNINITMENUPOPUP:
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
*pwParam);
if (hashEntryPtr != NULL) {
- menuPtr = Tcl_GetHashValue(hashEntryPtr);
+ menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr);
if ((menuPtr->menuRefPtr != NULL)
&& (menuPtr->menuRefPtr->parentEntryPtr != NULL)) {
TkPostSubmenu(menuPtr->interp,
@@ -1163,7 +1168,7 @@ TkWinHandleMenuEvent(
*pwParam);
if (hashEntryPtr != NULL) {
tsdPtr->oldServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
- menuPtr = Tcl_GetHashValue(hashEntryPtr);
+ menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr);
tsdPtr->modalMenuPtr = menuPtr;
CallPendingReconfigureImmediately(menuPtr);
RecursivelyClearActiveMenu(menuPtr);
@@ -1199,7 +1204,7 @@ TkWinHandleMenuEvent(
if (hashEntryPtr == NULL) {
break;
}
- mePtr = Tcl_GetHashValue(hashEntryPtr);
+ mePtr = (TkMenuEntry *)Tcl_GetHashValue(hashEntryPtr);
if (mePtr != NULL) {
TkMenuReferences *menuRefPtr;
TkMenuEntry *parentEntryPtr;
@@ -1247,27 +1252,34 @@ TkWinHandleMenuEvent(
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
*plParam);
if (hashEntryPtr != NULL) {
- int i, len, underline;
+ TkSizeT i, len, underline;
Tcl_Obj *labelPtr;
- Tcl_UniChar *wlabel, menuChar;
+ WCHAR *wlabel;
+ int menuChar;
+ Tcl_DString ds;
*plResult = 0;
- menuPtr = Tcl_GetHashValue(hashEntryPtr);
+ menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr);
/*
* Assume we have something directly convertable to Tcl_UniChar.
* True at least for wide systems.
*/
- menuChar = Tcl_UniCharToUpper((Tcl_UniChar) LOWORD(*pwParam));
+ menuChar = Tcl_UniCharToUpper(LOWORD(*pwParam));
+ Tcl_DStringInit(&ds);
for (i = 0; i < menuPtr->numEntries; i++) {
underline = menuPtr->entries[i]->underline;
labelPtr = menuPtr->entries[i]->labelPtr;
- if ((underline >= 0) && (labelPtr != NULL)) {
+ if ((underline != TCL_INDEX_NONE) && (labelPtr != NULL)) {
/*
* Ensure we don't exceed the label length, then check
*/
- wlabel = Tcl_GetUnicodeFromObj(labelPtr, &len);
- if ((underline < len) && (menuChar ==
+ const char *src = TkGetStringFromObj(labelPtr, &len);
+
+ Tcl_DStringFree(&ds);
+ Tcl_DStringInit(&ds);
+ wlabel = Tcl_UtfToWCharDString(src, len, &ds);
+ if ((underline + 1 < len + 1) && (menuChar ==
Tcl_UniCharToUpper(wlabel[underline]))) {
*plResult = (2 << 16) | i;
returnResult = 1;
@@ -1275,6 +1287,7 @@ TkWinHandleMenuEvent(
}
}
}
+ Tcl_DStringFree(&ds);
}
break;
}
@@ -1318,7 +1331,7 @@ TkWinHandleMenuEvent(
}
mePtr = (TkMenuEntry *) itemPtr->itemData;
menuPtr = mePtr->menuPtr;
- twdPtr = ckalloc(sizeof(TkWinDrawable));
+ twdPtr = (TkWinDrawable *)ckalloc(sizeof(TkWinDrawable));
twdPtr->type = TWD_WINDC;
twdPtr->winDC.hdc = itemPtr->hDC;
@@ -1384,7 +1397,7 @@ TkWinHandleMenuEvent(
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
*plParam);
if (hashEntryPtr != NULL) {
- menuPtr = Tcl_GetHashValue(hashEntryPtr);
+ menuPtr = (TkMenu *)Tcl_GetHashValue(hashEntryPtr);
}
}
@@ -1403,13 +1416,13 @@ TkWinHandleMenuEvent(
}
mePtr = NULL;
if (flags != 0xFFFF) {
- if ((flags&MF_POPUP) && (entryIndex<menuPtr->numEntries)) {
+ if ((flags&MF_POPUP) && (entryIndex < (int)menuPtr->numEntries)) {
mePtr = menuPtr->entries[entryIndex];
} else {
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->commandTable,
INT2PTR(entryIndex));
if (hashEntryPtr != NULL) {
- mePtr = Tcl_GetHashValue(hashEntryPtr);
+ mePtr = (TkMenuEntry *)Tcl_GetHashValue(hashEntryPtr);
}
}
}
@@ -1417,7 +1430,7 @@ TkWinHandleMenuEvent(
if ((mePtr == NULL) || (mePtr->state == ENTRY_DISABLED)) {
TkActivateMenuEntry(menuPtr, -1);
} else {
- if (mePtr->index >= menuPtr->numEntries) {
+ if (mePtr->index >= (int)menuPtr->numEntries) {
Tcl_Panic("Trying to activate an entry which doesn't exist");
}
TkActivateMenuEntry(menuPtr, mePtr->index);
@@ -1454,7 +1467,7 @@ void
RecursivelyClearActiveMenu(
TkMenu *menuPtr) /* The menu to reset. */
{
- int i;
+ TkSizeT i;
TkMenuEntry *mePtr;
TkActivateMenuEntry(menuPtr, -1);
@@ -1498,7 +1511,7 @@ TkpSetWindowMenuBar(
TkMenu *menuPtr) /* The menu we are inserting */
{
HMENU winMenuHdl;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (menuPtr != NULL) {
@@ -1546,6 +1559,10 @@ TkpSetMainMenubar(
const char *menuName) /* The name of the menu to put in front. If
* NULL, use the default menu bar. */
{
+ (void)interp;
+ (void)tkwin;
+ (void)menuName;
+
/*
* Nothing to do.
*/
@@ -1576,6 +1593,10 @@ GetMenuIndicatorGeometry(
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
+ (void)menuPtr;
+ (void)tkfont;
+ (void)fmPtr;
+
*heightPtr = indicatorDimensions[0];
if (mePtr->hideMargin) {
*widthPtr = 0;
@@ -1624,7 +1645,13 @@ GetMenuAccelGeometry(
{
*heightPtr = fmPtr->linespace;
if (mePtr->type == CASCADE_ENTRY) {
- *widthPtr = 0;
+ /*
+ * Cascade entries have no accelerator but do show an arrow. Set
+ * this field width to the width of the OBM_MNARROW system bitmap
+ * used to display the arrow. I couldn't find how to query the
+ * system for this value, therefore I resort to hardcoding.
+ */
+ *widthPtr = CASCADE_ARROW_WIDTH;
} else if ((menuPtr->menuType != MENUBAR) && (mePtr->accelPtr != NULL)) {
const char *accel = Tcl_GetString(mePtr->accelPtr);
@@ -1659,6 +1686,9 @@ GetTearoffEntryGeometry(
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
+ (void)mePtr;
+ (void)tkfont;
+
if (menuPtr->menuType != MASTER_MENU) {
*heightPtr = 0;
} else {
@@ -1692,6 +1722,10 @@ GetMenuSeparatorGeometry(
int *widthPtr, /* The resulting width */
int *heightPtr) /* The resulting height */
{
+ (void)menuPtr;
+ (void)mePtr;
+ (void)tkfont;
+
*widthPtr = 0;
*heightPtr = fmPtr->linespace - (2 * fmPtr->descent);
}
@@ -1739,7 +1773,7 @@ DrawWindowsSystemBitmap(
SetTextColor(hdc, gc->foreground);
scratchDC = CreateCompatibleDC(hdc);
- bitmap = LoadBitmap(NULL, MAKEINTRESOURCE(bitmapID));
+ bitmap = LoadBitmapW(NULL, (LPCWSTR)MAKEINTRESOURCE(bitmapID));
SelectObject(scratchDC, bitmap);
SetMapMode(scratchDC, GetMapMode(hdc));
@@ -1805,6 +1839,11 @@ DrawMenuEntryIndicator(
int width,
int height)
{
+ (void)tkfont;
+ (void)fmPtr;
+ (void)width;
+ (void)height;
+
if ((mePtr->type == CHECK_BUTTON_ENTRY)
|| (mePtr->type == RADIO_BUTTON_ENTRY)) {
if (mePtr->indicatorOn && (mePtr->entryFlags & ENTRY_SELECTED)) {
@@ -1885,6 +1924,9 @@ DrawMenuEntryAccelerator(
int baseline;
int leftEdge = x + mePtr->indicatorSpace + mePtr->labelWidth;
const char *accel;
+ (void)activeBorder;
+ (void)width;
+ (void)height;
if (menuPtr->menuType == MENUBAR) {
return;
@@ -1902,7 +1944,7 @@ DrawMenuEntryAccelerator(
* Draw disabled 3D text highlight only with the Win95/98 look.
*/
- if (TkWinGetPlatformTheme() == TK_THEME_WIN_CLASSIC) {
+ if (TkWinGetPlatformTheme() != TK_THEME_WIN_XP) {
if ((mePtr->state == ENTRY_DISABLED)
&& (menuPtr->disabledFgPtr != NULL) && (accel != NULL)) {
COLORREF oldFgColor = gc->foreground;
@@ -1928,8 +1970,9 @@ DrawMenuEntryAccelerator(
* DrawMenuEntryArrow --
*
* This function draws the arrow bitmap on the right side of a menu
- * entry. This function is only used when drawing the arrow for a
- * disabled cascade menu.
+ * entry. This function is only used when drawing the arrow for:
+ * - a disabled cascade item
+ * - a cascade item in any state in a torn-off menu
*
* Results:
* None.
@@ -1958,11 +2001,23 @@ DrawMenuEntryArrow(
COLORREF oldFgColor;
COLORREF oldBgColor;
RECT rect;
+ (void)gc;
+ (void)activeBorder;
if (!drawArrow || (mePtr->type != CASCADE_ENTRY)) {
return;
}
+ /*
+ * Don't draw the arrow if a submenu is not attached to this
+ * cascade entry.
+ */
+
+ if ((mePtr->childMenuRefPtr == NULL)
+ || (mePtr->childMenuRefPtr->menuPtr == NULL)) {
+ return;
+ }
+
oldFgColor = gc->foreground;
oldBgColor = gc->background;
@@ -2028,6 +2083,10 @@ DrawMenuSeparator(
{
XPoint points[2];
Tk_3DBorder border;
+ (void)mePtr;
+ (void)gc;
+ (void)tkfont;
+ (void)fmPtr;
points[0].x = x;
points[0].y = y + height / 2;
@@ -2067,17 +2126,20 @@ DrawMenuUnderline(
int width, /* Width of entry */
int height) /* Height of entry */
{
+ (void)fmPtr;
+ (void)width;
+
if ((mePtr->underline >= 0) && (mePtr->labelPtr != NULL)) {
int len;
- /* do the unicode call just to prevent overruns */
- Tcl_GetUnicodeFromObj(mePtr->labelPtr, &len);
+ len = Tcl_GetCharLength(mePtr->labelPtr);
if (mePtr->underline < len) {
const char *label, *start, *end;
+ int ch;
label = Tcl_GetString(mePtr->labelPtr);
start = Tcl_UtfAtIndex(label, mePtr->underline);
- end = Tcl_UtfNext(start);
+ end = start + TkUtfToUniChar(start, &ch);
Tk_UnderlineChars(menuPtr->display, d,
gc, tkfont, label, x + mePtr->indicatorSpace,
y + (height + fmPtr->ascent - fmPtr->descent) / 2,
@@ -2093,7 +2155,7 @@ DrawMenuUnderline(
*
* This function is invoked when keys related to pulling down menus is
* pressed. The corresponding Windows events are generated and passed to
- * DefWindowProc if appropriate. This cmd is registered as tk::WinMenuKey
+ * DefWindowProcW if appropriate. This cmd is registered as tk::WinMenuKey
* in the interp.
*
* Results:
@@ -2107,7 +2169,7 @@ DrawMenuUnderline(
static int
TkWinMenuKeyObjCmd(
- ClientData clientData, /* Unused. */
+ ClientData dummy, /* Unused. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -2119,6 +2181,7 @@ TkWinMenuKeyObjCmd(
TkWindow *winPtr;
KeySym keySym;
int i;
+ (void)dummy;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "window keySym");
@@ -2148,65 +2211,64 @@ TkWinMenuKeyObjCmd(
if (eventPtr->type == KeyPress) {
switch (keySym) {
case XK_Alt_L:
- scanCode = MapVirtualKey(VK_LMENU, 0);
- CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
+ scanCode = MapVirtualKeyW(VK_LMENU, 0);
+ CallWindowProcW(DefWindowProcW, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYDOWN, VK_MENU,
(int) (scanCode << 16) | (1 << 29));
break;
case XK_Alt_R:
- scanCode = MapVirtualKey(VK_RMENU, 0);
- CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
+ scanCode = MapVirtualKeyW(VK_RMENU, 0);
+ CallWindowProcW(DefWindowProcW, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYDOWN, VK_MENU,
(int) (scanCode << 16) | (1 << 29) | (1 << 24));
break;
case XK_F10:
- scanCode = MapVirtualKey(VK_F10, 0);
- CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
+ scanCode = MapVirtualKeyW(VK_F10, 0);
+ CallWindowProcW(DefWindowProcW, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYDOWN, VK_F10, (int) (scanCode << 16));
break;
default:
virtualKey = XKeysymToKeycode(winPtr->display, keySym);
- scanCode = MapVirtualKey(virtualKey, 0);
+ scanCode = MapVirtualKeyW(virtualKey, 0);
if (0 != scanCode) {
- XKeyEvent xkey = eventPtr->xkey;
- CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
+ TkKeyEvent xkey;
+ memcpy(&xkey, eventPtr, sizeof(xkey));
+ CallWindowProcW(DefWindowProcW, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYDOWN, virtualKey,
(int) ((scanCode << 16) | (1 << 29)));
- if (xkey.nbytes > 0) {
- for (i = 0; i < xkey.nbytes; i++) {
- CallWindowProc(DefWindowProc,
- Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSCHAR,
- xkey.trans_chars[i],
- (int) ((scanCode << 16) | (1 << 29)));
- }
+ for (i = 0; i < xkey.nbytes; i++) {
+ CallWindowProcW(DefWindowProcW,
+ Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSCHAR,
+ xkey.trans_chars[i],
+ (int) ((scanCode << 16) | (1 << 29)));
}
}
}
} else if (eventPtr->type == KeyRelease) {
switch (keySym) {
case XK_Alt_L:
- scanCode = MapVirtualKey(VK_LMENU, 0);
- CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
+ scanCode = MapVirtualKeyW(VK_LMENU, 0);
+ CallWindowProcW(DefWindowProcW, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYUP, VK_MENU, (int) (scanCode << 16)
| (1 << 29) | (1 << 30) | (1 << 31));
break;
case XK_Alt_R:
- scanCode = MapVirtualKey(VK_RMENU, 0);
- CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
+ scanCode = MapVirtualKeyW(VK_RMENU, 0);
+ CallWindowProcW(DefWindowProcW, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYUP, VK_MENU, (int) (scanCode << 16) | (1 << 24)
| (1 << 29) | (1 << 30) | (1 << 31));
break;
case XK_F10:
- scanCode = MapVirtualKey(VK_F10, 0);
- CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
+ scanCode = MapVirtualKeyW(VK_F10, 0);
+ CallWindowProcW(DefWindowProcW, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYUP, VK_F10,
(int) (scanCode << 16) | (1 << 30) | (1 << 31));
break;
default:
virtualKey = XKeysymToKeycode(winPtr->display, keySym);
- scanCode = MapVirtualKey(virtualKey, 0);
+ scanCode = MapVirtualKeyW(virtualKey, 0);
if (0 != scanCode) {
- CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)),
+ CallWindowProcW(DefWindowProcW, Tk_GetHWND(Tk_WindowId(tkwin)),
WM_SYSKEYUP, virtualKey, (int) ((scanCode << 16)
| (1 << 29) | (1 << 30) | (1 << 31)));
}
@@ -2434,7 +2496,7 @@ DrawMenuEntryLabel(
int baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2;
const char *label = Tcl_GetString(mePtr->labelPtr);
- if (TkWinGetPlatformTheme() == TK_THEME_WIN_CLASSIC) {
+ if (TkWinGetPlatformTheme() != TK_THEME_WIN_XP) {
/*
* Win 95/98 systems draw disabled menu text with a 3D
* highlight, unless the menu item is highlighted,
@@ -2466,7 +2528,7 @@ DrawMenuEntryLabel(
XFillRectangle(menuPtr->display, d, menuPtr->disabledGC, x, y,
(unsigned) width, (unsigned) height);
} else if ((mePtr->image != NULL)
- && (menuPtr->disabledImageGC != NULL)) {
+ && menuPtr->disabledImageGC) {
XFillRectangle(menuPtr->display, d, menuPtr->disabledImageGC,
leftEdge + imageXOffset,
(int) (y + (mePtr->height - imageHeight)/2 + imageYOffset),
@@ -2530,6 +2592,10 @@ DrawTearoffEntry(
XPoint points[2];
int segmentWidth, maxX;
Tk_3DBorder border;
+ (void)mePtr;
+ (void)gc;
+ (void)tkfont;
+ (void)fmPtr;
if (menuPtr->menuType != MASTER_MENU) {
return;
@@ -2573,7 +2639,7 @@ DrawTearoffEntry(
int
TkpConfigureMenuEntry(
- register TkMenuEntry *mePtr)/* Information about menu entry; may or may
+ TkMenuEntry *mePtr)/* Information about menu entry; may or may
* not already have values for some fields. */
{
ScheduleMenuReconfigure(mePtr->menuPtr);
@@ -2637,7 +2703,7 @@ TkpDrawMenuEntry(
menuDc = TkWinGetDrawableDC(menuPtr->display, menuDrawable, &dcState);
memDc = CreateCompatibleDC(menuDc);
- oldBitmap = SelectObject(memDc,
+ oldBitmap = (HBITMAP)SelectObject(memDc,
CreateCompatibleBitmap(menuDc, width, height) );
memWinDraw.type = TWD_WINDC;
@@ -2978,7 +3044,7 @@ TkpComputeStandardMenuGeometry(
Tk_GetPixelsFromObj(menuPtr->interp, menuPtr->tkwin,
menuPtr->activeBorderWidthPtr, &activeBorderWidth);
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuPtr->numEntries; i++) {
if (menuPtr->entries[i]->fontPtr == NULL) {
tkfont = menuFont;
fmPtr = &menuMetrics;
@@ -3062,7 +3128,7 @@ TkpComputeStandardMenuGeometry(
if (accelWidth != 0) {
labelWidth += accelSpace;
}
- for (j = lastColumnBreak; j < menuPtr->numEntries; j++) {
+ for (j = lastColumnBreak; j < (int)menuPtr->numEntries; j++) {
menuPtr->entries[j]->indicatorSpace = indicatorSpace;
menuPtr->entries[j]->labelWidth = labelWidth;
menuPtr->entries[j]->width = indicatorSpace + labelWidth
@@ -3110,27 +3176,28 @@ static void
MenuSelectEvent(
TkMenu *menuPtr) /* the menu we have selected. */
{
- XVirtualEvent event;
+ union {XEvent general; XVirtualEvent virt;} event;
union {DWORD msgpos; POINTS point;} root;
- event.type = VirtualEvent;
- event.serial = menuPtr->display->request;
- event.send_event = 0;
- event.display = menuPtr->display;
+ memset(&event, 0, sizeof(event));
+ event.virt.type = VirtualEvent;
+ event.virt.serial = menuPtr->display->request;
+ event.virt.send_event = 0;
+ event.virt.display = menuPtr->display;
Tk_MakeWindowExist(menuPtr->tkwin);
- event.event = Tk_WindowId(menuPtr->tkwin);
- event.root = XRootWindow(menuPtr->display, 0);
- event.subwindow = None;
- event.time = TkpGetMS();
+ event.virt.event = Tk_WindowId(menuPtr->tkwin);
+ event.virt.root = XRootWindow(menuPtr->display, 0);
+ event.virt.subwindow = None;
+ event.virt.time = TkpGetMS();
root.msgpos = GetMessagePos();
- event.x_root = root.point.x;
- event.y_root = root.point.y;
- event.state = TkWinGetModifierState();
- event.same_screen = 1;
- event.name = Tk_GetUid("MenuSelect");
- event.user_data = NULL;
- Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
+ event.virt.x_root = root.point.x;
+ event.virt.y_root = root.point.y;
+ event.virt.state = TkWinGetModifierState();
+ event.virt.same_screen = 1;
+ event.virt.name = Tk_GetUid("MenuSelect");
+ event.virt.user_data = NULL;
+ Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
}
/*
@@ -3195,8 +3262,9 @@ HWND
Tk_GetMenuHWND(
Tk_Window tkwin)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)tkwin;
TkMenuInit();
return tsdPtr->embeddedMenuHWND;
@@ -3220,10 +3288,12 @@ Tk_GetMenuHWND(
static void
MenuExitHandler(
- ClientData clientData) /* Not used */
+ ClientData dummy) /* Not used */
{
- UnregisterClass(MENU_CLASS_NAME, Tk_GetHINSTANCE());
- UnregisterClass(EMBEDDED_MENU_CLASS_NAME, Tk_GetHINSTANCE());
+ (void)dummy;
+
+ UnregisterClassW(MENU_CLASS_NAME, Tk_GetHINSTANCE());
+ UnregisterClassW(EMBEDDED_MENU_CLASS_NAME, Tk_GetHINSTANCE());
}
/*
@@ -3245,10 +3315,11 @@ MenuExitHandler(
static void
MenuThreadExitHandler(
- ClientData clientData) /* Not used */
+ ClientData dummy) /* Not used */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
DestroyWindow(tsdPtr->menuHWND);
DestroyWindow(tsdPtr->embeddedMenuHWND);
@@ -3285,10 +3356,12 @@ TkWinGetMenuSystemDefault(
const char *className) /* The name of the option class. */
{
Tcl_Obj *valuePtr = NULL;
+ (void)tkwin;
+ (void)className;
if ((strcmp(dbName, "activeBorderWidth") == 0) ||
(strcmp(dbName, "borderWidth") == 0)) {
- valuePtr = Tcl_NewIntObj(defaultBorderWidth);
+ valuePtr = Tcl_NewWideIntObj(defaultBorderWidth);
} else if (strcmp(dbName, "font") == 0) {
valuePtr = Tcl_NewStringObj(Tcl_DStringValue(&menuFontDString), -1);
}
@@ -3323,12 +3396,11 @@ SetDefaults(
HDC scratchDC;
int bold = 0;
int italic = 0;
- TEXTMETRIC tm;
+ TEXTMETRICW tm;
int pointSize;
HFONT menuFont;
/* See: [Bug #3239768] tk8.4.19 (and later) WIN32 menu font support */
- NONCLIENTMETRICS metrics;
- OSVERSIONINFOW os;
+ NONCLIENTMETRICSW metrics;
/*
* Set all of the default options. The loop will terminate when we run out
@@ -3340,7 +3412,7 @@ SetDefaults(
defaultBorderWidth = GetSystemMetrics(SM_CYBORDER);
}
- scratchDC = CreateDCA("DISPLAY", NULL, NULL, NULL);
+ scratchDC = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
if (!firstTime) {
Tcl_DStringFree(&menuFontDString);
}
@@ -3348,17 +3420,15 @@ SetDefaults(
metrics.cbSize = sizeof(metrics);
- os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
- GetVersionExW(&os);
- if (os.dwMajorVersion < 6) {
+ if (TkWinGetPlatformTheme() != TK_THEME_WIN_VISTA) {
metrics.cbSize -= sizeof(int);
}
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize,
+ SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, metrics.cbSize,
&metrics, 0);
- menuFont = CreateFontIndirect(&metrics.lfMenuFont);
+ menuFont = CreateFontIndirectW(&metrics.lfMenuFont);
SelectObject(scratchDC, menuFont);
- GetTextMetrics(scratchDC, &tm);
+ GetTextMetricsW(scratchDC, &tm);
GetTextFaceA(scratchDC, LF_FACESIZE, faceName);
pointSize = MulDiv(tm.tmHeight - tm.tmInternalLeading,
72, GetDeviceCaps(scratchDC, LOGPIXELSY));
@@ -3415,7 +3485,7 @@ SetDefaults(
*/
showMenuAccelerators = TRUE;
- SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &showMenuAccelerators, 0);
+ SystemParametersInfoW(SPI_GETKEYBOARDCUES, 0, &showMenuAccelerators, 0);
}
/*
@@ -3437,7 +3507,7 @@ SetDefaults(
void
TkpMenuInit(void)
{
- WNDCLASS wndClass;
+ WNDCLASSW wndClass;
wndClass.style = CS_OWNDC;
wndClass.lpfnWndProc = TkWinMenuProc;
@@ -3449,13 +3519,13 @@ TkpMenuInit(void)
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = MENU_CLASS_NAME;
- if (!RegisterClass(&wndClass)) {
+ if (!RegisterClassW(&wndClass)) {
Tcl_Panic("Failed to register menu window class");
}
wndClass.lpfnWndProc = TkWinEmbeddedMenuProc;
wndClass.lpszClassName = EMBEDDED_MENU_CLASS_NAME;
- if (!RegisterClass(&wndClass)) {
+ if (!RegisterClassW(&wndClass)) {
Tcl_Panic("Failed to register embedded menu window class");
}
@@ -3483,10 +3553,10 @@ TkpMenuInit(void)
void
TkpMenuThreadInit(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- tsdPtr->menuHWND = CreateWindow(MENU_CLASS_NAME, TEXT("MenuWindow"), WS_POPUP,
+ tsdPtr->menuHWND = CreateWindowW(MENU_CLASS_NAME, L"MenuWindow", WS_POPUP,
0, 0, 10, 10, NULL, NULL, Tk_GetHINSTANCE(), NULL);
if (!tsdPtr->menuHWND) {
@@ -3494,7 +3564,7 @@ TkpMenuThreadInit(void)
}
tsdPtr->embeddedMenuHWND =
- CreateWindow(EMBEDDED_MENU_CLASS_NAME, TEXT("EmbeddedMenuWindow"),
+ CreateWindowW(EMBEDDED_MENU_CLASS_NAME, L"EmbeddedMenuWindow",
WS_POPUP, 0, 0, 10, 10, NULL, NULL, Tk_GetHINSTANCE(), NULL);
if (!tsdPtr->embeddedMenuHWND) {
diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c
index aa1ebde..d189245 100644
--- a/win/tkWinPixmap.c
+++ b/win/tkWinPixmap.c
@@ -42,7 +42,7 @@ Tk_GetPixmap(
display->request++;
- newTwdPtr = ckalloc(sizeof(TkWinDrawable));
+ newTwdPtr = (TkWinDrawable *)ckalloc(sizeof(TkWinDrawable));
newTwdPtr->type = TWD_BITMAP;
newTwdPtr->bitmap.depth = depth;
twdPtr = (TkWinDrawable *) d;
@@ -100,13 +100,13 @@ Tk_GetPixmap(
LPVOID lpMsgBuf;
repeatError = 1;
- if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)&lpMsgBuf, 0, NULL)) {
- MessageBox(NULL, (LPTSTR) lpMsgBuf,
- TEXT("Tk_GetPixmap: Error from CreateDIBSection"),
+ (LPWSTR)&lpMsgBuf, 0, NULL)) {
+ MessageBoxW(NULL, (LPWSTR) lpMsgBuf,
+ L"Tk_GetPixmap: Error from CreateDIBSection",
MB_OK | MB_ICONINFORMATION);
LocalFree(lpMsgBuf);
}
@@ -208,6 +208,12 @@ XGetGeometry(
unsigned int *depth_return)
{
TkWinDrawable *twdPtr = (TkWinDrawable *)d;
+ (void)display;
+ (void)root_return;
+ (void)x_return;
+ (void)y_return;
+ (void)border_width_return;
+ (void)depth_return;
if (twdPtr->type == TWD_BITMAP) {
HDC dc;
diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c
index 6f1f840..222d938 100644
--- a/win/tkWinPointer.c
+++ b/win/tkWinPointer.c
@@ -81,13 +81,19 @@ TkWinGetModifierState(void)
if (GetKeyState(VK_RBUTTON) & 0x8000) {
state |= Button3Mask;
}
+ if (GetKeyState(VK_XBUTTON1) & 0x8000) {
+ state |= Button4Mask;
+ }
+ if (GetKeyState(VK_XBUTTON2) & 0x8000) {
+ state |= Button5Mask;
+ }
return state;
}
/*
*----------------------------------------------------------------------
*
- * Tk_PointerEvent --
+ * TkWinPointerEvent --
*
* This procedure is called for each pointer-related event. It converts
* the position to root coords and updates the global pointer state
@@ -103,7 +109,7 @@ TkWinGetModifierState(void)
*/
void
-Tk_PointerEvent(
+TkWinPointerEvent(
HWND hwnd, /* Window for coords, or NULL for the root
* window. */
int x, int y) /* Coords relative to hwnd, or screen if hwnd
@@ -173,6 +179,12 @@ XGrabKeyboard(
int keyboard_mode,
Time time)
{
+ (void)display;
+ (void)owner_events;
+ (void)pointer_mode;
+ (void)keyboard_mode;
+ (void)time;
+
keyboardWinPtr = TkWinGetWinPtr(grab_window);
return GrabSuccess;
}
@@ -198,6 +210,9 @@ XUngrabKeyboard(
Display *display,
Time time)
{
+ (void)display;
+ (void)time;
+
keyboardWinPtr = NULL;
return Success;
}
@@ -220,9 +235,10 @@ XUngrabKeyboard(
void
MouseTimerProc(
- ClientData clientData)
+ ClientData dummy)
{
POINT pos;
+ (void)dummy;
mouseTimerSet = 0;
@@ -232,7 +248,7 @@ MouseTimerProc(
*/
GetCursorPos(&pos);
- Tk_PointerEvent(NULL, pos.x, pos.y);
+ TkWinPointerEvent(NULL, pos.x, pos.y);
}
/*
@@ -284,6 +300,7 @@ TkGetPointerCoords(
int *xPtr, int *yPtr) /* Store pointer coordinates here. */
{
POINT point;
+ (void)tkwin;
GetCursorPos(&point);
*xPtr = point.x;
@@ -321,6 +338,12 @@ XQueryPointer(
int *win_y_return,
unsigned int *mask_return)
{
+ (void)w;
+ (void)root_return;
+ (void)child_return;
+ (void)win_x_return;
+ (void)win_y_return;
+
display->request++;
TkGetPointerCoords(NULL, root_x_return, root_y_return);
*mask_return = TkWinGetModifierState();
@@ -330,10 +353,10 @@ XQueryPointer(
/*
*----------------------------------------------------------------------
*
- * XWarpPointer --
+ * XWarpPointer, TkpWarpPointer --
*
- * Move pointer to new location. This is not a complete implementation of
- * this function.
+ * Move pointer to new location. Note that implementation of XWarpPointer
+ * is incomplete.
*
* Results:
* None.
@@ -344,6 +367,44 @@ XQueryPointer(
*----------------------------------------------------------------------
*/
+/*
+ * TkSetCursorPos is a helper function replacing SetCursorPos since this
+ * latter Windows function appears to have been broken by Microsoft
+ * since Win10 Falls Creator Update - See ticket [69b48f427e] along with
+ * several other Internet reports about this breakage.
+ */
+
+void TkSetCursorPos(
+ int x,
+ int y)
+{
+ INPUT input;
+ int xscreen = (int)(GetSystemMetrics(SM_CXSCREEN) - 1);
+ int yscreen = (int)(GetSystemMetrics(SM_CYSCREEN) - 1);
+
+ input.type = INPUT_MOUSE;
+ input.mi.dx = (x * 65535 + xscreen/2) / xscreen;
+ input.mi.dy = (y * 65535 + yscreen/2) / yscreen;
+
+ /*
+ * Horrible workaround here. There is a bug on Win 10: when warping to
+ * pixel (x = 0, y = 0) the SendInput() below just does not move the
+ * mouse pointer. However, as soon as dx or dy is non zero it moves as
+ * expected. Given the scaling factor of 65535 (see above),
+ * (dx = 1 , dy = 0) still means pixel (x = 0, y = 0).
+ * See ticket [69b48f427e].
+ */
+ if (input.mi.dx == 0 && input.mi.dy == 0) {
+ input.mi.dx = 1;
+ }
+
+ input.mi.mouseData = 0;
+ input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
+ input.mi.time = 0;
+ input.mi.dwExtraInfo = 0;
+ SendInput(1, &input, sizeof(input));
+}
+
int
XWarpPointer(
Display *display,
@@ -357,9 +418,15 @@ XWarpPointer(
int dest_y)
{
RECT r;
+ (void)display;
+ (void)src_w;
+ (void)src_x;
+ (void)src_y;
+ (void)src_width;
+ (void)src_height;
GetWindowRect(Tk_GetHWND(dest_w), &r);
- SetCursorPos(r.left+dest_x, r.top+dest_y);
+ TkSetCursorPos(r.left+dest_x, r.top+dest_y);
return Success;
}
@@ -371,9 +438,9 @@ TkpWarpPointer(
RECT r;
GetWindowRect(Tk_GetHWND(Tk_WindowId(dispPtr->warpWindow)), &r);
- SetCursorPos(r.left + dispPtr->warpX, r.top + dispPtr->warpY);
+ TkSetCursorPos(r.left + dispPtr->warpX, r.top + dispPtr->warpY);
} else {
- SetCursorPos(dispPtr->warpX, dispPtr->warpY);
+ TkSetCursorPos(dispPtr->warpX, dispPtr->warpY);
}
}
@@ -401,7 +468,7 @@ XGetInputFocus(
{
Tk_Window tkwin = Tk_HWNDToWindow(GetFocus());
- *focus_return = tkwin ? Tk_WindowId(tkwin) : None;
+ *focus_return = tkwin ? Tk_WindowId(tkwin) : 0;
*revert_to_return = RevertToParent;
display->request++;
return Success;
@@ -431,6 +498,9 @@ XSetInputFocus(
int revert_to,
Time time)
{
+ (void)revert_to;
+ (void)time;
+
display->request++;
if (focus != None) {
SetFocus(Tk_GetHWND(focus));
@@ -538,6 +608,29 @@ TkpSetCapture(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * TkpGetCapture --
+ *
+ * This function requests which window is capturing the mouse.
+ *
+ * Results:
+ * The return value is a pointer to the capture window, if there is
+ * one, otherwise it is NULL.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+Tk_Window
+TkpGetCapture(void)
+{
+ return Tk_HWNDToWindow(GetCapture());
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/win/tkWinPort.h b/win/tkWinPort.h
index 254f44e..11ecf21 100644
--- a/win/tkWinPort.h
+++ b/win/tkWinPort.h
@@ -25,6 +25,7 @@
#include <wchar.h>
#include <io.h>
#include <stdlib.h>
+#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <malloc.h>
@@ -64,6 +65,9 @@
typedef _TCHAR TCHAR;
#endif
+#if defined(__GNUC__) && !defined(__cplusplus)
+# pragma GCC diagnostic ignored "-Wc++-compat"
+#endif
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <X11/keysym.h>
diff --git a/win/tkWinRegion.c b/win/tkWinRegion.c
index d097047..1eff839 100644
--- a/win/tkWinRegion.c
+++ b/win/tkWinRegion.c
@@ -11,13 +11,6 @@
#include "tkWinInt.h"
-#undef TkCreateRegion
-#undef TkDestroyRegion
-#undef TkClipBox
-#undef TkIntersectRegion
-#undef TkUnionRectWithRegion
-#undef TkRectInRegion
-#undef TkSubtractRegion
/*
*----------------------------------------------------------------------
@@ -59,11 +52,12 @@ TkCreateRegion(void)
*----------------------------------------------------------------------
*/
-void
+int
TkDestroyRegion(
TkRegion r)
{
DeleteObject((HRGN) r);
+ return Success;
}
/*
@@ -82,7 +76,7 @@ TkDestroyRegion(
*----------------------------------------------------------------------
*/
-void
+int
TkClipBox(
TkRegion r,
XRectangle* rect_return)
@@ -94,6 +88,7 @@ TkClipBox(
rect_return->y = (short) rect.top;
rect_return->width = (short) (rect.right - rect.left);
rect_return->height = (short) (rect.bottom - rect.top);
+ return Success;
}
/*
@@ -112,13 +107,14 @@ TkClipBox(
*----------------------------------------------------------------------
*/
-void
+int
TkIntersectRegion(
TkRegion sra,
TkRegion srb,
TkRegion dr_return)
{
CombineRgn((HRGN) dr_return, (HRGN) sra, (HRGN) srb, RGN_AND);
+ return Success;
}
/*
@@ -137,7 +133,7 @@ TkIntersectRegion(
*----------------------------------------------------------------------
*/
-void
+int
TkUnionRectWithRegion(
XRectangle *rectangle,
TkRegion src_region,
@@ -149,6 +145,7 @@ TkUnionRectWithRegion(
CombineRgn((HRGN) dest_region_return, (HRGN) src_region,
(HRGN) rectRgn, RGN_OR);
DeleteObject(rectRgn);
+ return Success;
}
/*
@@ -270,13 +267,14 @@ TkRectInRegion(
*----------------------------------------------------------------------
*/
-void
+int
TkSubtractRegion(
TkRegion sra,
TkRegion srb,
TkRegion dr_return)
{
CombineRgn((HRGN) dr_return, (HRGN) sra, (HRGN) srb, RGN_DIFF);
+ return Success;
}
/*
diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c
index 43a33ee..d00b324 100644
--- a/win/tkWinScrlbr.c
+++ b/win/tkWinScrlbr.c
@@ -82,7 +82,7 @@ const Tk_ClassProcs tkpScrollbarProcs = {
static void
WinScrollbarEventProc(ClientData clientData, XEvent *eventPtr)
{
- WinScrollbar *scrollPtr = clientData;
+ WinScrollbar *scrollPtr = (WinScrollbar *)clientData;
if (eventPtr->type == ButtonPress) {
ModalLoop(scrollPtr, eventPtr);
@@ -121,7 +121,7 @@ TkpCreateScrollbar(
Tcl_MutexUnlock(&winScrlbrMutex);
}
- scrollPtr = ckalloc(sizeof(WinScrollbar));
+ scrollPtr = (WinScrollbar *)ckalloc(sizeof(WinScrollbar));
scrollPtr->winFlags = 0;
scrollPtr->hwnd = NULL;
@@ -223,7 +223,7 @@ CreateProc(
| SBS_HORZ;
}
- scrollPtr->hwnd = CreateWindow(TEXT("SCROLLBAR"), NULL, style,
+ scrollPtr->hwnd = CreateWindowW(L"SCROLLBAR", NULL, style,
Tk_X(tkwin), Tk_Y(tkwin), Tk_Width(tkwin), Tk_Height(tkwin),
parent, NULL, Tk_GetHINSTANCE(), NULL);
@@ -245,7 +245,7 @@ CreateProc(
}
scrollPtr->lastVertical = scrollPtr->info.vertical;
- scrollPtr->oldProc = (WNDPROC)SetWindowLongPtr(scrollPtr->hwnd,
+ scrollPtr->oldProc = (WNDPROC)SetWindowLongPtrW(scrollPtr->hwnd,
GWLP_WNDPROC, (LONG_PTR) ScrollbarProc);
window = Tk_AttachHWND(tkwin, scrollPtr->hwnd);
@@ -275,7 +275,7 @@ void
TkpDisplayScrollbar(
ClientData clientData) /* Information about window. */
{
- WinScrollbar *scrollPtr = clientData;
+ WinScrollbar *scrollPtr = (WinScrollbar *)clientData;
Tk_Window tkwin = scrollPtr->info.tkwin;
scrollPtr->info.flags &= ~REDRAW_PENDING;
@@ -291,7 +291,7 @@ TkpDisplayScrollbar(
if (scrollPtr->lastVertical != scrollPtr->info.vertical) {
HWND hwnd = Tk_GetHWND(Tk_WindowId(tkwin));
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) scrollPtr->oldProc);
+ SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR) scrollPtr->oldProc);
DestroyWindow(hwnd);
CreateProc(tkwin, Tk_WindowId(Tk_Parent(tkwin)),
@@ -325,7 +325,7 @@ TkpDestroyScrollbar(
HWND hwnd = winScrollPtr->hwnd;
if (hwnd) {
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (INT_PTR) winScrollPtr->oldProc);
+ SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (INT_PTR) winScrollPtr->oldProc);
if (winScrollPtr->winFlags & IN_MODAL_LOOP) {
((TkWindow *)scrollPtr->tkwin)->flags |= TK_DONT_DESTROY_WINDOW;
SetParent(hwnd, NULL);
@@ -383,7 +383,7 @@ UpdateScrollbarMetrics(void)
void
TkpComputeScrollbarGeometry(
- register TkScrollbar *scrollPtr)
+ TkScrollbar *scrollPtr)
/* Scrollbar whose geometry may have
* changed. */
{
@@ -497,7 +497,7 @@ ScrollbarProc(
int code;
GetCursorPos(&point);
- Tk_TranslateWinEvent(NULL, WM_MOUSEMOVE, 0,
+ TkTranslateWinEvent(NULL, WM_MOUSEMOVE, 0,
MAKELPARAM(point.x, point.y), &result);
if (command == SB_ENDSCROLL) {
@@ -564,11 +564,11 @@ ScrollbarProc(
}
default:
- if (Tk_TranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
+ if (TkTranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
return result;
}
}
- return CallWindowProc(scrollPtr->oldProc, hwnd, message, wParam, lParam);
+ return CallWindowProcW(scrollPtr->oldProc, hwnd, message, wParam, lParam);
}
/*
@@ -591,10 +591,11 @@ ScrollbarProc(
void
TkpConfigureScrollbar(
- register TkScrollbar *scrollPtr)
+ TkScrollbar *scrollPtr)
/* Information about widget; may or may not
* already have values for some fields. */
{
+ (void)scrollPtr;
}
/*
@@ -650,7 +651,7 @@ ModalLoop(
int
TkpScrollbarPosition(
- register TkScrollbar *scrollPtr,
+ TkScrollbar *scrollPtr,
/* Scrollbar widget record. */
int x, int y) /* Coordinates within scrollPtr's window. */
{
diff --git a/win/tkWinSend.c b/win/tkWinSend.c
index fca8561..d1d6777 100644
--- a/win/tkWinSend.c
+++ b/win/tkWinSend.c
@@ -121,6 +121,8 @@ Tk_SetAppName(
* be globally unique. */
{
#ifndef TK_SEND_ENABLED_ON_WINDOWS
+ (void)tkwin;
+
/*
* Temporarily disabled for bug #858822
*/
@@ -150,7 +152,7 @@ Tk_SetAppName(
return "";
}
tsdPtr->initialized = 1;
- TRACE("Initialized COM library for interp 0x%08X\n", (long)interp);
+ TRACE("Initialized COM library for interp 0x%" TCL_Z_MODIFIER "x\n", (size_t)interp);
}
/*
@@ -163,7 +165,7 @@ Tk_SetAppName(
if (riPtr == NULL) {
LPUNKNOWN *objPtr;
- riPtr = ckalloc(sizeof(RegisteredInterp));
+ riPtr = (RegisteredInterp *)ckalloc(sizeof(RegisteredInterp));
memset(riPtr, 0, sizeof(RegisteredInterp));
riPtr->interp = interp;
@@ -213,6 +215,8 @@ TkGetInterpNames(
* lookup. */
{
#ifndef TK_SEND_ENABLED_ON_WINDOWS
+ (void)interp;
+ (void)tkwin;
/*
* Temporarily disabled for bug #858822
*/
@@ -254,7 +258,8 @@ TkGetInterpNames(
if (*p) {
Tcl_DString ds;
- Tcl_WinTCharToUtf(p + 1, -1, &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(p + 1, wcslen(p + 1), &ds);
result = Tcl_ListObjAppendElement(interp,
objList,
Tcl_NewStringObj(Tcl_DStringValue(&ds),
@@ -619,7 +624,8 @@ BuildMoniker(
LPMONIKER pmkItem = NULL;
Tcl_DString dString;
- Tcl_WinUtfToTChar(name, -1, &dString);
+ Tcl_DStringInit(&dString);
+ Tcl_UtfToWCharDString(name, -1, &dString);
hr = CreateFileMoniker((LPOLESTR)Tcl_DStringValue(&dString), &pmkItem);
Tcl_DStringFree(&dString);
if (SUCCEEDED(hr)) {
@@ -733,7 +739,7 @@ Send(
* object. */
Tcl_Interp *interp, /* The local interpreter. */
int async, /* Flag for the calling style. */
- ClientData clientData, /* The RegisteredInterp structure for this
+ ClientData dummy, /* The RegisteredInterp structure for this
* interp. */
int objc, /* Number of arguments to be sent. */
Tcl_Obj *const objv[]) /* The arguments to be sent. */
@@ -747,6 +753,7 @@ Send(
DISPID dispid;
Tcl_DString ds;
const char *src;
+ (void)dummy;
cmd = Tcl_ConcatObj(objc, objv);
@@ -761,8 +768,8 @@ Send(
vCmd.vt = VT_BSTR;
src = Tcl_GetString(cmd);
- Tcl_WinUtfToTChar(src, cmd->length, &ds);
- vCmd.bstrVal = SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
+ Tcl_DStringInit(&ds);
+ vCmd.bstrVal = SysAllocString(Tcl_UtfToWCharDString(src, cmd->length, &ds));
Tcl_DStringFree(&ds);
dp.cArgs = 1;
@@ -784,8 +791,8 @@ Send(
ehr = VariantChangeType(&vResult, &vResult, 0, VT_BSTR);
if (SUCCEEDED(ehr)) {
- Tcl_WinTCharToUtf(vResult.bstrVal, (int) SysStringLen(vResult.bstrVal) *
- sizeof (WCHAR), &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(vResult.bstrVal, SysStringLen(vResult.bstrVal), &ds);
Tcl_DStringResult(interp, &ds);
}
@@ -797,8 +804,9 @@ Send(
if (hr == DISP_E_EXCEPTION && ei.bstrSource != NULL) {
Tcl_Obj *opError, *opErrorCode, *opErrorInfo;
- Tcl_WinTCharToUtf(ei.bstrSource, (int) SysStringLen(ei.bstrSource) *
- sizeof (WCHAR), &ds);
+
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(ei.bstrSource, SysStringLen(ei.bstrSource), &ds);
opError = Tcl_NewStringObj(Tcl_DStringValue(&ds),
Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
@@ -869,14 +877,14 @@ TkWinSend_SetExcepInfo(
/* TODO: Handle failure to append */
src = Tcl_GetString(opError);
- Tcl_WinUtfToTChar(src, opError->length, &ds);
+ Tcl_DStringInit(&ds);
pExcepInfo->bstrDescription =
- SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
+ SysAllocString(Tcl_UtfToWCharDString(src, opError->length, &ds));
Tcl_DStringFree(&ds);
src = Tcl_GetString(opErrorCode);
- Tcl_WinUtfToTChar(src, opErrorCode->length, &ds);
+ Tcl_DStringInit(&ds);
pExcepInfo->bstrSource =
- SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
+ SysAllocString(Tcl_UtfToWCharDString(src, opErrorCode->length, &ds));
Tcl_DStringFree(&ds);
Tcl_DecrRefCount(opErrorCode);
pExcepInfo->scode = E_FAIL;
@@ -923,7 +931,7 @@ TkWinSend_QueueCommand(
TRACE("SendQueueCommand()\n");
- evPtr = ckalloc(sizeof(SendEvent));
+ evPtr = (SendEvent *)ckalloc(sizeof(SendEvent));
evPtr->header.proc = SendEventProc;
evPtr->header.nextPtr = NULL;
evPtr->interp = interp;
@@ -965,6 +973,7 @@ SendEventProc(
int flags)
{
SendEvent *evPtr = (SendEvent *)eventPtr;
+ (void)flags;
TRACE("SendEventProc\n");
diff --git a/win/tkWinSendCom.c b/win/tkWinSendCom.c
index 9e5b7a0..536c6c1 100644
--- a/win/tkWinSendCom.c
+++ b/win/tkWinSendCom.c
@@ -166,17 +166,17 @@ WinSendCom_QueryInterface(
void **ppvObject)
{
HRESULT hr = E_NOINTERFACE;
- TkWinSendCom *this = (TkWinSendCom *) This;
+ TkWinSendCom *sendCom = (TkWinSendCom *) This;
*ppvObject = NULL;
if (memcmp(riid, &IID_IUnknown, sizeof(IID)) == 0
|| memcmp(riid, &IID_IDispatch, sizeof(IID)) == 0) {
- *ppvObject = (void **) this;
- this->lpVtbl->AddRef(This);
+ *ppvObject = (void **) sendCom;
+ sendCom->lpVtbl->AddRef(This);
hr = S_OK;
} else if (memcmp(riid, &IID_ISupportErrorInfo, sizeof(IID)) == 0) {
- *ppvObject = (void **) (this + 1);
- this->lpVtbl2->AddRef((ISupportErrorInfo *) (this + 1));
+ *ppvObject = (void **) (sendCom + 1);
+ sendCom->lpVtbl2->AddRef((ISupportErrorInfo *) (sendCom + 1));
hr = S_OK;
}
return hr;
@@ -186,9 +186,9 @@ static STDMETHODIMP_(ULONG)
WinSendCom_AddRef(
IDispatch *This)
{
- TkWinSendCom *this = (TkWinSendCom*)This;
+ TkWinSendCom *sendCom = (TkWinSendCom*)This;
- return InterlockedIncrement(&this->refcount);
+ return InterlockedIncrement(&sendCom->refcount);
}
static STDMETHODIMP_(ULONG)
@@ -196,9 +196,9 @@ WinSendCom_Release(
IDispatch *This)
{
long r = 0;
- TkWinSendCom *this = (TkWinSendCom*)This;
+ TkWinSendCom *sendCom = (TkWinSendCom*)This;
- if ((r = InterlockedDecrement(&this->refcount)) == 0) {
+ if ((r = InterlockedDecrement(&sendCom->refcount)) == 0) {
TkWinSendCom_Destroy(This);
}
return r;
@@ -210,6 +210,7 @@ WinSendCom_GetTypeInfoCount(
UINT *pctinfo)
{
HRESULT hr = E_POINTER;
+ (void)This;
if (pctinfo != NULL) {
*pctinfo = 0;
@@ -226,6 +227,9 @@ WinSendCom_GetTypeInfo(
ITypeInfo **ppTI)
{
HRESULT hr = E_POINTER;
+ (void)This;
+ (void)iTInfo;
+ (void)lcid;
if (ppTI) {
*ppTI = NULL;
@@ -244,6 +248,10 @@ WinSendCom_GetIDsOfNames(
DISPID *rgDispId)
{
HRESULT hr = E_POINTER;
+ (void)This;
+ (void)riid;
+ (void)cNames;
+ (void)lcid;
if (rgDispId) {
hr = DISP_E_UNKNOWNNAME;
@@ -269,7 +277,9 @@ WinSendCom_Invoke(
UINT *puArgErr)
{
HRESULT hr = DISP_E_MEMBERNOTFOUND;
- TkWinSendCom *this = (TkWinSendCom*)This;
+ TkWinSendCom *sendCom = (TkWinSendCom*)This;
+ (void)riid;
+ (void)lcid;
switch (dispidMember) {
case TKWINSENDCOM_DISPID_SEND:
@@ -277,7 +287,7 @@ WinSendCom_Invoke(
if (pDispParams->cArgs != 1) {
hr = DISP_E_BADPARAMCOUNT;
} else {
- hr = Send(this, pDispParams->rgvarg[0], pvarResult,
+ hr = Send(sendCom, pDispParams->rgvarg[0], pvarResult,
pExcepInfo, puArgErr);
}
}
@@ -288,7 +298,7 @@ WinSendCom_Invoke(
if (pDispParams->cArgs != 1) {
hr = DISP_E_BADPARAMCOUNT;
} else {
- hr = Async(this, pDispParams->rgvarg[0], pExcepInfo, puArgErr);
+ hr = Async(sendCom, pDispParams->rgvarg[0], pExcepInfo, puArgErr);
}
}
break;
@@ -313,27 +323,27 @@ ISupportErrorInfo_QueryInterface(
REFIID riid,
void **ppvObject)
{
- TkWinSendCom *this = (TkWinSendCom *)(This - 1);
+ TkWinSendCom *sendCom = (TkWinSendCom *)(This - 1);
- return this->lpVtbl->QueryInterface((IDispatch *) this, riid, ppvObject);
+ return sendCom->lpVtbl->QueryInterface((IDispatch *) sendCom, riid, ppvObject);
}
static STDMETHODIMP_(ULONG)
ISupportErrorInfo_AddRef(
ISupportErrorInfo *This)
{
- TkWinSendCom *this = (TkWinSendCom *)(This - 1);
+ TkWinSendCom *sendCom = (TkWinSendCom *)(This - 1);
- return InterlockedIncrement(&this->refcount);
+ return InterlockedIncrement(&sendCom->refcount);
}
static STDMETHODIMP_(ULONG)
ISupportErrorInfo_Release(
ISupportErrorInfo *This)
{
- TkWinSendCom *this = (TkWinSendCom *)(This - 1);
+ TkWinSendCom *sendCom = (TkWinSendCom *)(This - 1);
- return this->lpVtbl->Release((IDispatch *) this);
+ return sendCom->lpVtbl->Release((IDispatch *) sendCom);
}
static STDMETHODIMP
@@ -341,7 +351,10 @@ ISupportErrorInfo_InterfaceSupportsErrorInfo(
ISupportErrorInfo *This,
REFIID riid)
{
- /*TkWinSendCom *this = (TkWinSendCom*)(This - 1);*/
+ (void)This;
+ (void)riid;
+
+ /*TkWinSendCom *sendCom = (TkWinSendCom*)(This - 1);*/
return S_OK; /* or S_FALSE */
}
@@ -371,6 +384,7 @@ Async(
HRESULT hr = S_OK;
VARIANT vCmd;
Tcl_DString ds;
+ (void)puArgErr;
VariantInit(&vCmd);
@@ -385,8 +399,8 @@ Async(
if (SUCCEEDED(hr) && obj->interp) {
Tcl_Obj *scriptPtr;
- Tcl_WinTCharToUtf(vCmd.bstrVal, (int) SysStringLen(vCmd.bstrVal) *
- sizeof (WCHAR), &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(vCmd.bstrVal, SysStringLen(vCmd.bstrVal), &ds);
scriptPtr =
Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
@@ -427,9 +441,10 @@ Send(
HRESULT hr = S_OK;
int result = TCL_OK;
VARIANT v;
- register Tcl_Interp *interp = obj->interp;
+ Tcl_Interp *interp = obj->interp;
Tcl_Obj *scriptPtr;
Tcl_DString ds;
+ (void)puArgErr;
if (interp == NULL) {
return S_OK;
@@ -440,8 +455,8 @@ Send(
return hr;
}
- Tcl_WinTCharToUtf(v.bstrVal, (int) SysStringLen(v.bstrVal) *
- sizeof (WCHAR), &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(v.bstrVal, SysStringLen(v.bstrVal), &ds);
scriptPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
Tcl_Preserve(interp);
@@ -457,8 +472,8 @@ Send(
pvResult->vt = VT_BSTR;
obj = Tcl_GetObjResult(interp);
src = Tcl_GetString(obj);
- Tcl_WinUtfToTChar(src, obj->length, &ds);
- pvResult->bstrVal = SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
+ Tcl_DStringInit(&ds);
+ pvResult->bstrVal = SysAllocString(Tcl_UtfToWCharDString(src, obj->length, &ds));
Tcl_DStringFree(&ds);
}
if (result == TCL_ERROR) {
diff --git a/win/tkWinTest.c b/win/tkWinTest.c
index 70465d6..c419be8 100644
--- a/win/tkWinTest.c
+++ b/win/tkWinTest.c
@@ -147,7 +147,7 @@ AppendSystemError(
if (Tcl_IsShared(resultPtr)) {
resultPtr = Tcl_DuplicateObj(resultPtr);
}
- length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
+ length = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS
| FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *) wMsgPtrPtr,
@@ -175,12 +175,10 @@ AppendSystemError(
}
msg = msgBuf;
} else {
- Tcl_Encoding encoding;
char *msgPtr;
- encoding = Tcl_GetEncoding(NULL, "unicode");
- Tcl_ExternalToUtfDString(encoding, (char *) wMsgPtr, -1, &ds);
- Tcl_FreeEncoding(encoding);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(wMsgPtr, wcslen(wMsgPtr), &ds);
LocalFree(wMsgPtr);
msgPtr = Tcl_DStringValue(&ds);
@@ -233,6 +231,8 @@ SetSelectionResult(
Tcl_Interp *interp,
const char *selection)
{
+ (void)dummy;
+
Tcl_AppendResult(interp, selection, NULL);
return TCL_OK;
}
@@ -244,7 +244,7 @@ TestclipboardObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
@@ -273,7 +273,7 @@ TestclipboardObjCmd(
static int
TestwineventObjCmd(
- ClientData clientData, /* Main window for application. */
+ ClientData dummy, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -290,12 +290,23 @@ TestwineventObjCmd(
static const TkStateMap messageMap[] = {
{WM_LBUTTONDOWN, "WM_LBUTTONDOWN"},
{WM_LBUTTONUP, "WM_LBUTTONUP"},
+ {WM_LBUTTONDBLCLK, "WM_LBUTTONDBLCLK"},
+ {WM_MBUTTONDOWN, "WM_MBUTTONDOWN"},
+ {WM_MBUTTONUP, "WM_MBUTTONUP"},
+ {WM_MBUTTONDBLCLK, "WM_MBUTTONDBLCLK"},
+ {WM_RBUTTONDOWN, "WM_RBUTTONDOWN"},
+ {WM_RBUTTONUP, "WM_RBUTTONUP"},
+ {WM_RBUTTONDBLCLK, "WM_RBUTTONDBLCLK"},
+ {WM_XBUTTONDOWN, "WM_XBUTTONDOWN"},
+ {WM_XBUTTONUP, "WM_XBUTTONUP"},
+ {WM_XBUTTONDBLCLK, "WM_XBUTTONDBLCLK"},
{WM_CHAR, "WM_CHAR"},
{WM_GETTEXT, "WM_GETTEXT"},
{WM_SETTEXT, "WM_SETTEXT"},
{WM_COMMAND, "WM_COMMAND"},
{-1, NULL}
};
+ (void)dummy;
if ((objc == 3) && (strcmp(Tcl_GetString(objv[1]), "debug") == 0)) {
int b;
@@ -311,7 +322,7 @@ TestwineventObjCmd(
return TCL_ERROR;
}
- hwnd = INT2PTR(strtol(Tcl_GetString(objv[1]), &rest, 0));
+ hwnd = (HWND)INT2PTR(strtol(Tcl_GetString(objv[1]), &rest, 0));
if (rest == Tcl_GetString(objv[1])) {
hwnd = FindWindowA(NULL, Tcl_GetString(objv[1]));
if (hwnd == NULL) {
@@ -378,20 +389,21 @@ TestwineventObjCmd(
case WM_SETTEXT: {
Tcl_DString ds;
- control = TestFindControl(hwnd, id);
- if (control == NULL) {
- Tcl_SetObjResult(interp,
- Tcl_ObjPrintf("Could not find control with id %d", id));
- return TCL_ERROR;
- }
+ control = TestFindControl(hwnd, id);
+ if (control == NULL) {
+ Tcl_SetObjResult(interp,
+ Tcl_ObjPrintf("Could not find control with id %d", id));
+ return TCL_ERROR;
+ }
+ Tcl_DStringInit(&ds);
Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[4]), -1, &ds);
- result = SendMessageA(control, WM_SETTEXT, 0,
- (LPARAM) Tcl_DStringValue(&ds));
+ result = SendMessageA(control, WM_SETTEXT, 0,
+ (LPARAM) Tcl_DStringValue(&ds));
Tcl_DStringFree(&ds);
if (result == 0) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to send text to dialog: ", -1));
- AppendSystemError(interp, GetLastError());
- return TCL_ERROR;
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to send text to dialog: ", -1));
+ AppendSystemError(interp, GetLastError());
+ return TCL_ERROR;
}
break;
}
@@ -430,16 +442,17 @@ TestwineventObjCmd(
static int
TestfindwindowObjCmd(
- ClientData clientData, /* Main window for application. */
+ ClientData dummy, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
- const TCHAR *title = NULL, *class = NULL;
+ LPCWSTR title = NULL, windowClass = NULL;
Tcl_DString titleString, classString;
HWND hwnd = NULL;
int r = TCL_OK;
DWORD myPid;
+ (void)dummy;
Tcl_DStringInit(&classString);
Tcl_DStringInit(&titleString);
@@ -449,21 +462,20 @@ TestfindwindowObjCmd(
return TCL_ERROR;
}
- title = Tcl_WinUtfToTChar(Tcl_GetString(objv[1]), -1, &titleString);
+ Tcl_DStringInit(&titleString);
+ title = Tcl_UtfToWCharDString(Tcl_GetString(objv[1]), -1, &titleString);
if (objc == 3) {
- class = Tcl_WinUtfToTChar(Tcl_GetString(objv[2]), -1, &classString);
+ Tcl_DStringInit(&classString);
+ windowClass = Tcl_UtfToWCharDString(Tcl_GetString(objv[2]), -1, &classString);
}
if (title[0] == 0)
title = NULL;
-#if 0
- hwnd = FindWindow(class, title);
-#else
/* We want find a window the belongs to us and not some other process */
hwnd = NULL;
myPid = GetCurrentProcessId();
while (1) {
DWORD pid, tid;
- hwnd = FindWindowEx(NULL, hwnd, class, title);
+ hwnd = FindWindowExW(NULL, hwnd, windowClass, title);
if (hwnd == NULL)
break;
tid = GetWindowThreadProcessId(hwnd, &pid);
@@ -476,8 +488,6 @@ TestfindwindowObjCmd(
break; /* Found it */
}
-#endif
-
if (hwnd == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to find window: ", -1));
AppendSystemError(interp, GetLastError());
@@ -505,7 +515,7 @@ EnumChildrenProc(
static int
TestgetwindowinfoObjCmd(
- ClientData clientData,
+ ClientData dummy,
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
@@ -513,9 +523,10 @@ TestgetwindowinfoObjCmd(
Tcl_WideInt hwnd;
Tcl_Obj *dictObj = NULL, *classObj = NULL, *textObj = NULL;
Tcl_Obj *childrenObj = NULL;
- TCHAR buf[512];
+ WCHAR buf[512];
int cch, cchBuf = 256;
Tcl_DString ds;
+ (void)dummy;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "hwnd");
@@ -525,14 +536,14 @@ TestgetwindowinfoObjCmd(
if (Tcl_GetWideIntFromObj(interp, objv[1], &hwnd) != TCL_OK)
return TCL_ERROR;
- cch = GetClassName((HWND)(size_t)hwnd, buf, cchBuf);
+ cch = GetClassNameW((HWND)INT2PTR(hwnd), buf, cchBuf);
if (cch == 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to get class name: ", -1));
AppendSystemError(interp, GetLastError());
return TCL_ERROR;
} else {
- Tcl_DString ds;
- Tcl_WinTCharToUtf(buf, -1, &ds);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(buf, wcslen(buf), &ds);
classObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
}
@@ -542,8 +553,9 @@ TestgetwindowinfoObjCmd(
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("id", 2),
Tcl_NewWideIntObj(GetWindowLongPtr((HWND)(size_t)hwnd, GWL_ID)));
- cch = GetWindowText((HWND)(size_t)hwnd, (LPTSTR)buf, cchBuf);
- Tcl_WinTCharToUtf(buf, cch * sizeof (WCHAR), &ds);
+ cch = GetWindowTextW((HWND)INT2PTR(hwnd), buf, cchBuf);
+ Tcl_DStringInit(&ds);
+ Tcl_WCharToUtfDString(buf, cch, &ds);
textObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
@@ -561,11 +573,13 @@ TestgetwindowinfoObjCmd(
static int
TestwinlocaleObjCmd(
- ClientData clientData, /* Main window for application. */
+ ClientData dummy, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
+ (void)dummy;
+
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c
index fc72dac..f868a06 100644
--- a/win/tkWinWindow.c
+++ b/win/tkWinWindow.c
@@ -13,7 +13,7 @@
#include "tkWinInt.h"
#include "tkBusy.h"
-typedef struct ThreadSpecificData {
+typedef struct {
int initialized; /* 0 means table below needs initializing. */
Tcl_HashTable windowTable; /* The windowTable maps from HWND to Tk_Window
* handles. */
@@ -49,7 +49,7 @@ Tk_AttachHWND(
Tk_Window tkwin,
HWND hwnd)
{
- int new;
+ int isNew;
Tcl_HashEntry *entryPtr;
TkWinDrawable *twdPtr = (TkWinDrawable *) Tk_WindowId(tkwin);
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@@ -66,7 +66,7 @@ Tk_AttachHWND(
*/
if (twdPtr == NULL) {
- twdPtr = ckalloc(sizeof(TkWinDrawable));
+ twdPtr = (TkWinDrawable *)ckalloc(sizeof(TkWinDrawable));
twdPtr->type = TWD_WINDOW;
twdPtr->window.winPtr = (TkWindow *) tkwin;
} else if (twdPtr->window.handle != NULL) {
@@ -80,7 +80,7 @@ Tk_AttachHWND(
*/
twdPtr->window.handle = hwnd;
- entryPtr = Tcl_CreateHashEntry(&tsdPtr->windowTable, (char *)hwnd, &new);
+ entryPtr = Tcl_CreateHashEntry(&tsdPtr->windowTable, (char *)hwnd, &isNew);
Tcl_SetHashValue(entryPtr, tkwin);
return (Window)twdPtr;
@@ -170,16 +170,7 @@ TkpPrintWindowId(
{
HWND hwnd = (window) ? Tk_GetHWND(window) : 0;
- /*
- * Use pointer representation, because Win64 is P64 (*not* LP64). Windows
- * doesn't print the 0x for %p, so we do it.
- * Bug 2026405: cygwin does output 0x for %p so test and recover.
- */
-
- sprintf(buf, "0x%p", hwnd);
- if (buf[2] == '0' && buf[3] == 'x') {
- sprintf(buf, "%p", hwnd);
- }
+ sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)hwnd);
}
/*
@@ -277,7 +268,7 @@ TkpMakeWindow(
* order.
*/
- hwnd = CreateWindowEx(WS_EX_NOPARENTNOTIFY, TK_WIN_CHILD_CLASS_NAME, NULL,
+ hwnd = CreateWindowExW(WS_EX_NOPARENTNOTIFY, TK_WIN_CHILD_CLASS_NAME, NULL,
(DWORD) style, Tk_X(winPtr), Tk_Y(winPtr), Tk_Width(winPtr),
Tk_Height(winPtr), parentWin, NULL, Tk_GetHINSTANCE(), NULL);
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
@@ -765,33 +756,6 @@ XChangeWindowAttributes(
/*
*----------------------------------------------------------------------
*
- * XReparentWindow --
- *
- * TODO: currently placeholder to satisfy Xlib stubs.
- *
- * Results:
- * None.
- *
- * Side effects:
- * TODO.
- *
- *----------------------------------------------------------------------
- */
-
-int
-XReparentWindow(
- Display *display,
- Window w,
- Window parent,
- int x,
- int y)
-{
- return BadWindow;
-}
-
-/*
- *----------------------------------------------------------------------
- *
* TkWinSetWindowPos --
*
* Adjust the stacking order of a window relative to a second window (or
@@ -882,7 +846,7 @@ TkpShowBusyWindow(
*/
GetCursorPos(&point);
- SetCursorPos(point.x, point.y);
+ TkSetCursorPos(point.x, point.y);
}
/*
@@ -924,7 +888,7 @@ TkpHideBusyWindow(
*/
GetCursorPos(&point);
- SetCursorPos(point.x, point.y);
+ TkSetCursorPos(point.x, point.y);
}
/*
@@ -953,7 +917,7 @@ TkpMakeTransparentWindowExist(
int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
DWORD exStyle = WS_EX_TRANSPARENT | WS_EX_TOPMOST;
- hWnd = CreateWindowEx(exStyle, TK_WIN_CHILD_CLASS_NAME, NULL, style,
+ hWnd = CreateWindowExW(exStyle, TK_WIN_CHILD_CLASS_NAME, NULL, style,
Tk_X(tkwin), Tk_Y(tkwin), Tk_Width(tkwin), Tk_Height(tkwin),
hParent, NULL, Tk_GetHINSTANCE(), NULL);
winPtr->window = Tk_AttachHWND(tkwin, hWnd);
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 4d8a952..2f00672 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -66,7 +66,7 @@ typedef struct ProtocolHandler {
} ProtocolHandler;
#define HANDLER_SIZE(cmdLength) \
- (Tk_Offset(ProtocolHandler, command) + 1 + cmdLength)
+ (offsetof(ProtocolHandler, command) + 1 + cmdLength)
/*
* Helper type passed via lParam to TkWmStackorderToplevelEnumProc
@@ -367,7 +367,7 @@ static const Tk_GeomMgr wmMgrType = {
NULL, /* lostSlaveProc */
};
-typedef struct ThreadSpecificData {
+typedef struct {
HPALETTE systemPalette; /* System palette; refers to the currently
* installed foreground logical palette. */
TkWindow *createWindow; /* Window that is being constructed. This
@@ -856,7 +856,7 @@ static int
InitWindowClass(
WinIconPtr titlebaricon)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
@@ -867,26 +867,21 @@ InitWindowClass(
if (!initialized) {
Tcl_MutexLock(&winWmMutex);
if (!initialized) {
- WNDCLASS class;
+ WNDCLASSW windowClass;
initialized = 1;
- /*
- * The only difference between WNDCLASSW and WNDCLASSA are in
- * pointers, so we can use the generic structure WNDCLASS.
- */
-
- ZeroMemory(&class, sizeof(WNDCLASS));
+ ZeroMemory(&windowClass, sizeof(WNDCLASSW));
- class.style = CS_HREDRAW | CS_VREDRAW;
- class.hInstance = Tk_GetHINSTANCE();
- class.lpszClassName = TK_WIN_TOPLEVEL_CLASS_NAME;
- class.lpfnWndProc = WmProc;
+ windowClass.style = CS_HREDRAW | CS_VREDRAW;
+ windowClass.hInstance = Tk_GetHINSTANCE();
+ windowClass.lpszClassName = TK_WIN_TOPLEVEL_CLASS_NAME;
+ windowClass.lpfnWndProc = WmProc;
if (titlebaricon == NULL) {
- class.hIcon = LoadIcon(Tk_GetHINSTANCE(), TEXT("tk"));
+ windowClass.hIcon = LoadIconW(Tk_GetHINSTANCE(), L"tk");
} else {
- class.hIcon = GetIcon(titlebaricon, ICON_BIG);
- if (class.hIcon == NULL) {
+ windowClass.hIcon = GetIcon(titlebaricon, ICON_BIG);
+ if (windowClass.hIcon == NULL) {
return TCL_ERROR;
}
@@ -897,9 +892,9 @@ InitWindowClass(
tsdPtr->iconPtr = titlebaricon;
}
- class.hCursor = LoadCursor(NULL, IDC_ARROW);
+ windowClass.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
- if (!RegisterClass(&class)) {
+ if (!RegisterClassW(&windowClass)) {
Tcl_Panic("Unable to register TkTopLevel class");
}
}
@@ -1018,15 +1013,15 @@ WinSetIcon(
/*
* Don't check return result of SetClassLong() or
- * SetClassLongPtr() since they return the previously set value
+ * SetClassLongPtrW() since they return the previously set value
* which is zero on the initial call or in an error case. The MSDN
* documentation does not indicate that the result needs to be
* checked.
*/
- SetClassLongPtr(hwnd, GCLP_HICONSM,
+ SetClassLongPtrW(hwnd, GCLP_HICONSM,
(LPARAM) GetIcon(titlebaricon, ICON_SMALL));
- SetClassLongPtr(hwnd, GCLP_HICON,
+ SetClassLongPtrW(hwnd, GCLP_HICON,
(LPARAM) GetIcon(titlebaricon, ICON_BIG));
tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -1071,9 +1066,9 @@ WinSetIcon(
return TCL_ERROR;
}
}
- SendMessage(hwnd, WM_SETICON, ICON_SMALL,
+ SendMessageW(hwnd, WM_SETICON, ICON_SMALL,
(LPARAM) GetIcon(titlebaricon, ICON_SMALL));
- SendMessage(hwnd, WM_SETICON, ICON_BIG,
+ SendMessageW(hwnd, WM_SETICON, ICON_BIG,
(LPARAM) GetIcon(titlebaricon, ICON_BIG));
/*
@@ -1122,7 +1117,7 @@ TkWinGetIcon(
{
WmInfo *wmPtr;
HICON icon;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->iconPtr != NULL) {
@@ -1162,10 +1157,10 @@ TkWinGetIcon(
* the window class.
*/
- icon = (HICON) SendMessage(wmPtr->wrapper, WM_GETICON, iconsize,
+ icon = (HICON) SendMessageW(wmPtr->wrapper, WM_GETICON, iconsize,
(LPARAM) NULL);
if (icon == (HICON) NULL) {
- icon = (HICON) GetClassLongPtr(wmPtr->wrapper,
+ icon = (HICON) GetClassLongPtrW(wmPtr->wrapper,
(iconsize == ICON_BIG) ? GCLP_HICON : GCLP_HICONSM);
}
return icon;
@@ -1237,7 +1232,7 @@ ReadIconFromFile(
*/
if (lpIR == NULL) {
- SHFILEINFO sfiSM;
+ SHFILEINFOW sfiSM;
Tcl_DString ds, ds2;
DWORD *res;
const char *file;
@@ -1246,17 +1241,17 @@ ReadIconFromFile(
if (file == NULL) {
return NULL;
}
- Tcl_WinUtfToTChar(file, -1, &ds2);
- Tcl_DStringFree(&ds);
- res = (DWORD *)SHGetFileInfo((TCHAR *)Tcl_DStringValue(&ds2), 0, &sfiSM,
+ Tcl_DStringInit(&ds2);
+ res = (DWORD *)SHGetFileInfoW(Tcl_UtfToWCharDString(file, -1, &ds2), 0, &sfiSM,
sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_ICON);
+ Tcl_DStringFree(&ds);
if (res != 0) {
- SHFILEINFO sfi;
+ SHFILEINFOW sfi;
unsigned size;
Tcl_ResetResult(interp);
- res = (DWORD *)SHGetFileInfo((TCHAR *)Tcl_DStringValue(&ds2), 0, &sfi,
+ res = (DWORD *)SHGetFileInfoW((WCHAR *)Tcl_DStringValue(&ds2), 0, &sfi,
sizeof(SHFILEINFO), SHGFI_ICON);
/*
@@ -1265,7 +1260,7 @@ ReadIconFromFile(
size = sizeof(BlockOfIconImages)
+ ((res != 0) ? sizeof(ICONIMAGE) : 0);
- lpIR = ckalloc(size);
+ lpIR = (BlockOfIconImagesPtr)ckalloc(size);
if (lpIR == NULL) {
if (res != 0) {
DestroyIcon(sfi.hIcon);
@@ -1296,7 +1291,7 @@ ReadIconFromFile(
Tcl_DStringFree(&ds2);
}
if (lpIR != NULL) {
- titlebaricon = ckalloc(sizeof(WinIconInstance));
+ titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance));
titlebaricon->iconBlock = lpIR;
titlebaricon->refCount = 1;
}
@@ -1372,7 +1367,7 @@ GetIconFromPixmap(
return NULL;
}
- lpIR = ckalloc(sizeof(BlockOfIconImages));
+ lpIR = (BlockOfIconImagesPtr)ckalloc(sizeof(BlockOfIconImages));
if (lpIR == NULL) {
DestroyIcon(hIcon);
return NULL;
@@ -1393,7 +1388,7 @@ GetIconFromPixmap(
lpIR->IconImages[0].lpXOR = 0;
lpIR->IconImages[0].lpAND = 0;
- titlebaricon = ckalloc(sizeof(WinIconInstance));
+ titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance));
titlebaricon->iconBlock = lpIR;
titlebaricon->refCount = 1;
return titlebaricon;
@@ -1598,7 +1593,7 @@ ReadIconOrCursorFromFile(
* Allocate memory for the resource structure
*/
- lpIR = ckalloc(sizeof(BlockOfIconImages));
+ lpIR = (BlockOfIconImagesPtr)ckalloc(sizeof(BlockOfIconImages));
/*
* Read in the header
@@ -1616,14 +1611,14 @@ ReadIconOrCursorFromFile(
* Adjust the size of the struct to account for the images.
*/
- lpIR = ckrealloc(lpIR, sizeof(BlockOfIconImages)
+ lpIR = (BlockOfIconImagesPtr)ckrealloc(lpIR, sizeof(BlockOfIconImages)
+ (lpIR->nNumImages - 1) * sizeof(ICONIMAGE));
/*
* Allocate enough memory for the icon directory entries.
*/
- lpIDE = ckalloc(lpIR->nNumImages * sizeof(ICONDIRENTRY));
+ lpIDE = (LPICONDIRENTRY)ckalloc(lpIR->nNumImages * sizeof(ICONDIRENTRY));
/*
* Read in the icon directory entries.
@@ -1658,7 +1653,7 @@ ReadIconOrCursorFromFile(
* Allocate memory for the resource.
*/
- lpIR->IconImages[i].lpBits = ckalloc(lpIDE[i].dwBytesInRes);
+ lpIR->IconImages[i].lpBits = (LPBYTE)ckalloc(lpIDE[i].dwBytesInRes);
lpIR->IconImages[i].dwNumBytes = lpIDE[i].dwBytesInRes;
/*
@@ -1737,7 +1732,7 @@ static TkWindow *
GetTopLevel(
HWND hwnd)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -1749,7 +1744,7 @@ GetTopLevel(
if (tsdPtr->createWindow) {
return tsdPtr->createWindow;
}
- return (TkWindow *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ return (TkWindow *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
}
/*
@@ -1774,7 +1769,7 @@ SetLimits(
HWND hwnd,
MINMAXINFO *info)
{
- register WmInfo *wmPtr;
+ WmInfo *wmPtr;
int maxWidth, maxHeight;
int minWidth, minHeight;
int base;
@@ -1879,14 +1874,14 @@ TkWinWmCleanup(
}
initialized = 0;
- tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ tsdPtr = (ThreadSpecificData *)Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
return;
}
tsdPtr->initialized = 0;
- UnregisterClass(TK_WIN_TOPLEVEL_CLASS_NAME, hInstance);
+ UnregisterClassW(TK_WIN_TOPLEVEL_CLASS_NAME, hInstance);
}
/*
@@ -1910,7 +1905,7 @@ void
TkWmNewWindow(
TkWindow *winPtr) /* Newly-created top-level window. */
{
- register WmInfo *wmPtr = ckalloc(sizeof(WmInfo));
+ WmInfo *wmPtr = (WmInfo *)ckalloc(sizeof(WmInfo));
/*
* Initialize full structure, then set what isn't NULL
@@ -1995,7 +1990,7 @@ static void
UpdateWrapper(
TkWindow *winPtr) /* Top-level window to redecorate. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
HWND parentHWND, oldWrapper = wmPtr->wrapper;
HWND child, nextHWND, focusHWND;
int x, y, width, height, state;
@@ -2004,7 +1999,7 @@ UpdateWrapper(
HICON hBigIcon = NULL;
Tcl_DString titleString;
int *childStateInfo = NULL;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->window == None) {
@@ -2126,16 +2121,17 @@ UpdateWrapper(
*/
tsdPtr->createWindow = winPtr;
- Tcl_WinUtfToTChar(((wmPtr->title != NULL) ?
+ Tcl_DStringInit(&titleString);
+ Tcl_UtfToWCharDString(((wmPtr->title != NULL) ?
wmPtr->title : winPtr->nameUid), -1, &titleString);
- wmPtr->wrapper = CreateWindowEx(wmPtr->exStyle,
+ wmPtr->wrapper = CreateWindowExW(wmPtr->exStyle,
TK_WIN_TOPLEVEL_CLASS_NAME,
- (LPCTSTR) Tcl_DStringValue(&titleString),
+ (LPCWSTR) Tcl_DStringValue(&titleString),
wmPtr->style, x, y, width, height,
parentHWND, NULL, Tk_GetHINSTANCE(), NULL);
Tcl_DStringFree(&titleString);
- SetWindowLongPtr(wmPtr->wrapper, GWLP_USERDATA, (LONG_PTR) winPtr);
+ SetWindowLongPtrW(wmPtr->wrapper, GWLP_USERDATA, (LONG_PTR) winPtr);
tsdPtr->createWindow = NULL;
if (wmPtr->exStyleConfig & WS_EX_LAYERED) {
@@ -2186,24 +2182,24 @@ UpdateWrapper(
* doesn't try to set the focus to the child window.
*/
- SetWindowLongPtr(child, GWL_STYLE,
+ SetWindowLongPtrW(child, GWL_STYLE,
WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
if (winPtr->flags & TK_EMBEDDED) {
- SetWindowLongPtr(child, GWLP_WNDPROC, (LONG_PTR) TopLevelProc);
+ SetWindowLongPtrW(child, GWLP_WNDPROC, (LONG_PTR) TopLevelProc);
}
SetParent(child, wmPtr->wrapper);
if (oldWrapper) {
hSmallIcon = (HICON)
- SendMessage(oldWrapper, WM_GETICON, ICON_SMALL, (LPARAM)NULL);
+ SendMessageW(oldWrapper, WM_GETICON, ICON_SMALL, (LPARAM)NULL);
hBigIcon = (HICON)
- SendMessage(oldWrapper, WM_GETICON, ICON_BIG, (LPARAM) NULL);
+ SendMessageW(oldWrapper, WM_GETICON, ICON_BIG, (LPARAM) NULL);
}
if (oldWrapper && (oldWrapper != wmPtr->wrapper)
&& (oldWrapper != GetDesktopWindow())) {
- SetWindowLongPtr(oldWrapper, GWLP_USERDATA, (LONG_PTR) 0);
+ SetWindowLongPtrW(oldWrapper, GWLP_USERDATA, (LONG_PTR) 0);
if (wmPtr->numTransients > 0) {
/*
@@ -2213,7 +2209,7 @@ UpdateWrapper(
WmInfo *wmPtr2;
- childStateInfo = ckalloc(wmPtr->numTransients * sizeof(int));
+ childStateInfo = (int *)ckalloc(wmPtr->numTransients * sizeof(int));
state = 0;
for (wmPtr2 = winPtr->dispPtr->firstWmPtr; wmPtr2 != NULL;
wmPtr2 = wmPtr2->nextPtr) {
@@ -2236,11 +2232,11 @@ UpdateWrapper(
wmPtr->flags &= ~WM_NEVER_MAPPED;
if (winPtr->flags & TK_EMBEDDED &&
- SendMessage(wmPtr->wrapper, TK_ATTACHWINDOW, (WPARAM) child, 0)) {
- SendMessage(wmPtr->wrapper, TK_GEOMETRYREQ,
+ SendMessageW(wmPtr->wrapper, TK_ATTACHWINDOW, (WPARAM) child, 0)) {
+ SendMessageW(wmPtr->wrapper, TK_GEOMETRYREQ,
Tk_ReqWidth((Tk_Window) winPtr),
Tk_ReqHeight((Tk_Window) winPtr));
- SendMessage(wmPtr->wrapper, TK_SETMENU, (WPARAM) wmPtr->hMenu,
+ SendMessageW(wmPtr->wrapper, TK_SETMENU, (WPARAM) wmPtr->hMenu,
(LPARAM) Tk_GetMenuHWND((Tk_Window) winPtr));
}
@@ -2260,11 +2256,11 @@ UpdateWrapper(
wmPtr->hints.initial_state = state;
if (hSmallIcon != NULL) {
- SendMessage(wmPtr->wrapper, WM_SETICON, ICON_SMALL,
+ SendMessageW(wmPtr->wrapper, WM_SETICON, ICON_SMALL,
(LPARAM) hSmallIcon);
}
if (hBigIcon != NULL) {
- SendMessage(wmPtr->wrapper, WM_SETICON, ICON_BIG, (LPARAM) hBigIcon);
+ SendMessageW(wmPtr->wrapper, WM_SETICON, ICON_BIG, (LPARAM) hBigIcon);
}
/*
@@ -2276,7 +2272,7 @@ UpdateWrapper(
*/
if (winPtr->flags & TK_EMBEDDED) {
- if (state+1 != SendMessage(wmPtr->wrapper, TK_STATE, state, 0)) {
+ if (state+1 != SendMessageW(wmPtr->wrapper, TK_STATE, state, 0)) {
TkpWmSetState(winPtr, NormalState);
wmPtr->hints.initial_state = NormalState;
}
@@ -2359,8 +2355,8 @@ TkWmMapWindow(
TkWindow *winPtr) /* Top-level window that's about to be
* mapped. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- ThreadSpecificData *tsdPtr =
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
@@ -2585,7 +2581,7 @@ void
TkWmDeadWindow(
TkWindow *winPtr) /* Top-level window that's being deleted. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
WmInfo *wmPtr2;
if (wmPtr == NULL) {
@@ -2599,7 +2595,7 @@ TkWmDeadWindow(
if (winPtr->dispPtr->firstWmPtr == wmPtr) {
winPtr->dispPtr->firstWmPtr = wmPtr->nextPtr;
} else {
- register WmInfo *prevPtr;
+ WmInfo *prevPtr;
for (prevPtr = winPtr->dispPtr->firstWmPtr; ;
prevPtr = prevPtr->nextPtr) {
@@ -2706,7 +2702,7 @@ TkWmDeadWindow(
}
} else {
if (wmPtr->wrapper != NULL) {
- SendMessage(wmPtr->wrapper, TK_DETACHWINDOW, 0, 0);
+ SendMessageW(wmPtr->wrapper, TK_DETACHWINDOW, 0, 0);
}
}
if (wmPtr->iconPtr != NULL) {
@@ -2746,6 +2742,8 @@ void
TkWmSetClass(
TkWindow *winPtr) /* Newly-created top-level window. */
{
+ (void)winPtr;
+
/* Do nothing */
return;
}
@@ -2767,7 +2765,6 @@ TkWmSetClass(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
Tk_WmObjCmd(
ClientData clientData, /* Main window associated with interpreter. */
@@ -2775,7 +2772,7 @@ Tk_WmObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
static const char *const optionStrings[] = {
"aspect", "attributes", "client", "colormapwindows",
"command", "deiconify", "focusmodel", "forget", "frame",
@@ -2801,7 +2798,7 @@ Tk_WmObjCmd(
WMOPT_WITHDRAW
};
int index;
- size_t length;
+ TkSizeT length;
const char *argv1;
TkWindow *winPtr, **winPtrPtr = &winPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -2812,8 +2809,7 @@ Tk_WmObjCmd(
return TCL_ERROR;
}
- argv1 = Tcl_GetString(objv[1]);
- length = objv[1]->length;
+ argv1 = TkGetStringFromObj(objv[1], &length);
if ((argv1[0] == 't') && !strncmp(argv1, "tracing", length)
&& (length >= 3)) {
int wmTracing;
@@ -2823,8 +2819,8 @@ Tk_WmObjCmd(
return TCL_ERROR;
}
if (objc == 2) {
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
- dispPtr->flags & TK_DISPLAY_WM_TRACING));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
+ (dispPtr->flags & TK_DISPLAY_WM_TRACING) != 0));
return TCL_OK;
}
if (Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing) != TCL_OK) {
@@ -2956,8 +2952,9 @@ WmAspectCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int numer1, denom1, numer2, denom2;
+ (void)tkwin;
if ((objc != 3) && (objc != 7)) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -2968,10 +2965,10 @@ WmAspectCmd(
if (wmPtr->sizeHintsFlags & PAspect) {
Tcl_Obj *results[4];
- results[0] = Tcl_NewIntObj(wmPtr->minAspect.x);
- results[1] = Tcl_NewIntObj(wmPtr->minAspect.y);
- results[2] = Tcl_NewIntObj(wmPtr->maxAspect.x);
- results[3] = Tcl_NewIntObj(wmPtr->maxAspect.y);
+ results[0] = Tcl_NewWideIntObj(wmPtr->minAspect.x);
+ results[1] = Tcl_NewWideIntObj(wmPtr->minAspect.y);
+ results[2] = Tcl_NewWideIntObj(wmPtr->maxAspect.x);
+ results[3] = Tcl_NewWideIntObj(wmPtr->maxAspect.y);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
@@ -3026,11 +3023,11 @@ WmAttributesCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
LONG style, exStyle, styleBit, *stylePtr = NULL;
const char *string;
int i, boolean;
- size_t length;
+ TkSizeT length;
int config_fullscreen = 0, updatewrapper = 0;
int fullscreen_attr_changed = 0, fullscreen_attr = 0;
@@ -3060,25 +3057,24 @@ WmAttributesCmd(
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj("-disabled", -1));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewBooleanObj((style & WS_DISABLED)));
+ Tcl_NewWideIntObj((style & WS_DISABLED) != 0));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj("-fullscreen", -1));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewBooleanObj((wmPtr->flags & WM_FULLSCREEN)));
+ Tcl_NewWideIntObj((wmPtr->flags & WM_FULLSCREEN) != 0));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj("-toolwindow", -1));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewBooleanObj((exStyle & WS_EX_TOOLWINDOW)));
+ Tcl_NewWideIntObj((exStyle & WS_EX_TOOLWINDOW) != 0));
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_NewStringObj("-topmost", -1));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewBooleanObj((exStyle & WS_EX_TOPMOST)));
+ Tcl_NewWideIntObj((exStyle & WS_EX_TOPMOST) != 0));
Tcl_SetObjResult(interp, objPtr);
return TCL_OK;
}
for (i = 3; i < objc; i += 2) {
- string = Tcl_GetString(objv[i]);
- length = objv[i]->length;
+ string = TkGetStringFromObj(objv[i], &length);
if ((length < 2) || (string[0] != '-')) {
goto configArgs;
}
@@ -3146,9 +3142,8 @@ WmAttributesCmd(
}
wmPtr->alpha = dval;
} else { /* -transparentcolor */
- const char *crefstr = Tcl_GetString(objv[i+1]);
+ const char *crefstr = TkGetStringFromObj(objv[i+1], &length);
- length = objv[i+1]->length;
if (length == 0) {
/* reset to no transparent color */
if (wmPtr->crefObj) {
@@ -3193,7 +3188,7 @@ WmAttributesCmd(
*/
if (!(wmPtr->exStyleConfig & WS_EX_LAYERED)) {
- SetWindowLongPtr(wmPtr->wrapper, GWL_EXSTYLE,
+ SetWindowLongPtrW(wmPtr->wrapper, GWL_EXSTYLE,
*stylePtr);
}
SetLayeredWindowAttributes((HWND) wmPtr->wrapper,
@@ -3210,8 +3205,8 @@ WmAttributesCmd(
}
if (config_fullscreen) {
if (objc == 4) {
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
- wmPtr->flags & WM_FULLSCREEN));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
+ (wmPtr->flags & WM_FULLSCREEN) != 0));
} else {
fullscreen_attr_changed = 1;
fullscreen_attr = boolean;
@@ -3219,7 +3214,7 @@ WmAttributesCmd(
config_fullscreen = 0;
} else if (objc == 4) {
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(*stylePtr & styleBit));
+ Tcl_NewWideIntObj((*stylePtr & styleBit) != 0));
} else if (boolean) {
*stylePtr |= styleBit;
} else {
@@ -3324,9 +3319,10 @@ WmClientCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
- size_t length;
+ TkSizeT length;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?name?");
@@ -3339,8 +3335,7 @@ WmClientCmd(
}
return TCL_OK;
}
- argv3 = Tcl_GetString(objv[3]);
- length = objv[3]->length;
+ argv3 = TkGetStringFromObj(objv[3], &length);
if (argv3[0] == 0) {
if (wmPtr->clientMachine != NULL) {
ckfree(wmPtr->clientMachine);
@@ -3355,7 +3350,7 @@ WmClientCmd(
if (wmPtr->clientMachine != NULL) {
ckfree(wmPtr->clientMachine);
}
- wmPtr->clientMachine = ckalloc(length + 1);
+ wmPtr->clientMachine = (char *)ckalloc(length + 1);
memcpy(wmPtr->clientMachine, argv3, length + 1);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XTextProperty textProp;
@@ -3395,7 +3390,7 @@ WmColormapwindowsCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
TkWindow **cmapList, *winPtr2, **winPtr2Ptr = &winPtr2;
int i, windowObjc, gotToplevel;
Tcl_Obj **windowObjv, *resultObj;
@@ -3422,7 +3417,7 @@ WmColormapwindowsCmd(
!= TCL_OK) {
return TCL_ERROR;
}
- cmapList = ckalloc((windowObjc + 1) * sizeof(TkWindow*));
+ cmapList = (TkWindow**)ckalloc((windowObjc + 1) * sizeof(TkWindow*));
gotToplevel = 0;
for (i = 0; i < windowObjc; i++) {
if (TkGetWindowFromObj(interp, tkwin, windowObjv[i],
@@ -3489,10 +3484,11 @@ WmCommandCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
int cmdArgc;
const char **cmdArgv;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?value?");
@@ -3558,7 +3554,8 @@ WmDeiconifyCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)tkwin;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -3572,7 +3569,7 @@ WmDeiconifyCmd(
return TCL_ERROR;
}
if (winPtr->flags & TK_EMBEDDED) {
- if (!SendMessage(wmPtr->wrapper, TK_DEICONIFY, 0, 0)) {
+ if (!SendMessageW(wmPtr->wrapper, TK_DEICONIFY, 0, 0)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't deiconify %s: the container does not support the request",
winPtr->pathName));
@@ -3610,7 +3607,7 @@ WmFocusmodelCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"active", "passive", NULL
};
@@ -3618,6 +3615,7 @@ WmFocusmodelCmd(
OPT_ACTIVE, OPT_PASSIVE
};
int index;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?active|passive?");
@@ -3662,11 +3660,15 @@ static int
WmForgetCmd(
Tk_Window tkwin, /* Main window of the application. */
TkWindow *winPtr, /* Toplevel or Frame to work with */
- Tcl_Interp *interp, /* Current interpreter. */
+ Tcl_Interp *dummy, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Tk_Window frameWin = (Tk_Window) winPtr;
+ Tk_Window frameWin = (Tk_Window) winPtr;
+ (void)tkwin;
+ (void)dummy;
+ (void)objc;
+ (void)objv;
if (Tk_IsTopLevel(frameWin)) {
Tk_UnmapWindow(frameWin);
@@ -3714,8 +3716,10 @@ WmFrameCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
HWND hwnd;
+ char buf[TCL_INTEGER_SPACE];
+ (void)tkwin;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -3728,7 +3732,8 @@ WmFrameCmd(
if (hwnd == NULL) {
hwnd = Tk_GetHWND(Tk_WindowId((Tk_Window) winPtr));
}
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%" TCL_Z_MODIFIER "x", (size_t)PTR2INT(hwnd)));
+ sprintf(buf, "0x%" TCL_Z_MODIFIER "x", (size_t)hwnd);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1));
return TCL_OK;
}
@@ -3757,10 +3762,11 @@ WmGeometryCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
char xSign, ySign;
int width, height;
const char *argv3;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?");
@@ -3780,7 +3786,7 @@ WmGeometryCmd(
height = winPtr->changes.height;
}
if (winPtr->flags & TK_EMBEDDED) {
- int result = SendMessage(wmPtr->wrapper, TK_MOVEWINDOW, -1, -1);
+ int result = SendMessageW(wmPtr->wrapper, TK_MOVEWINDOW, -1, -1);
wmPtr->x = result >> 16;
wmPtr->y = result & 0x0000ffff;
@@ -3825,8 +3831,9 @@ WmGridCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int reqWidth, reqHeight, widthInc, heightInc;
+ (void)tkwin;
if ((objc != 3) && (objc != 7)) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -3837,10 +3844,10 @@ WmGridCmd(
if (wmPtr->sizeHintsFlags & PBaseSize) {
Tcl_Obj *results[4];
- results[0] = Tcl_NewIntObj(wmPtr->reqGridWidth);
- results[1] = Tcl_NewIntObj(wmPtr->reqGridHeight);
- results[2] = Tcl_NewIntObj(wmPtr->widthInc);
- results[3] = Tcl_NewIntObj(wmPtr->heightInc);
+ results[0] = Tcl_NewWideIntObj(wmPtr->reqGridWidth);
+ results[1] = Tcl_NewWideIntObj(wmPtr->reqGridHeight);
+ results[2] = Tcl_NewWideIntObj(wmPtr->widthInc);
+ results[3] = Tcl_NewWideIntObj(wmPtr->heightInc);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
@@ -3923,10 +3930,10 @@ WmGroupCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window tkwin2;
const char *argv3;
- size_t length;
+ TkSizeT length;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?");
@@ -3938,8 +3945,7 @@ WmGroupCmd(
}
return TCL_OK;
}
- argv3 = Tcl_GetString(objv[3]);
- length = objv[3]->length;
+ argv3 = TkGetStringFromObj(objv[3], &length);
if (*argv3 == '\0') {
wmPtr->hints.flags &= ~WindowGroupHint;
if (wmPtr->leaderName != NULL) {
@@ -3956,7 +3962,7 @@ WmGroupCmd(
}
wmPtr->hints.window_group = Tk_WindowId(tkwin2);
wmPtr->hints.flags |= WindowGroupHint;
- wmPtr->leaderName = ckalloc(length + 1);
+ wmPtr->leaderName = (char *)ckalloc(length + 1);
memcpy(wmPtr->leaderName, argv3, length + 1);
}
return TCL_OK;
@@ -3987,9 +3993,10 @@ WmIconbitmapCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
TkWindow *useWinPtr = winPtr; /* window to apply to (NULL if -default) */
const char *string;
+ (void)tkwin;
if ((objc < 3) || (objc > 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?-default? ?image?");
@@ -4123,13 +4130,15 @@ WmIconifyCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)tkwin;
+
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
return TCL_ERROR;
}
if (winPtr->flags & TK_EMBEDDED) {
- if (!SendMessage(wmPtr->wrapper, TK_ICONIFY, 0, 0)) {
+ if (!SendMessageW(wmPtr->wrapper, TK_ICONIFY, 0, 0)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't iconify %s: the container does not support the request",
winPtr->pathName));
@@ -4188,7 +4197,7 @@ WmIconmaskCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Pixmap pixmap;
const char *argv3;
@@ -4246,9 +4255,10 @@ WmIconnameCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
- size_t length;
+ TkSizeT length;
+ (void)tkwin;
if (objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?newName?");
@@ -4262,9 +4272,8 @@ WmIconnameCmd(
if (wmPtr->iconName != NULL) {
ckfree(wmPtr->iconName);
}
- argv3 = Tcl_GetString(objv[3]);
- length = objv[3]->length;
- wmPtr->iconName = ckalloc(length + 1);
+ argv3 = TkGetStringFromObj(objv[3], &length);
+ wmPtr->iconName = (char *)ckalloc(length + 1);
memcpy(wmPtr->iconName, argv3, length + 1);
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);
@@ -4310,6 +4319,7 @@ WmIconphotoCmd(
unsigned size;
BITMAPINFO bmInfo;
ICONINFO iconInfo;
+ (void)tkwin;
if (objc < 4) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -4347,7 +4357,7 @@ WmIconphotoCmd(
*/
size = sizeof(BlockOfIconImages) + (sizeof(ICONIMAGE) * (objc-startObj-1));
- lpIR = attemptckalloc(size);
+ lpIR = (BlockOfIconImagesPtr)attemptckalloc(size);
if (lpIR == NULL) {
return TCL_ERROR;
}
@@ -4371,7 +4381,7 @@ WmIconphotoCmd(
iconInfo.fIcon = TRUE;
/*
- * Create device-independant color bitmap.
+ * Create device-independent color bitmap.
*/
ZeroMemory(&bmInfo, sizeof bmInfo);
@@ -4387,9 +4397,9 @@ WmIconphotoCmd(
if (!iconInfo.hbmColor) {
ckfree(lpIR);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "failed to create color bitmap for \"%s\"",
+ "failed to create an iconphoto with image \"%s\"",
Tcl_GetString(objv[i])));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "BITMAP", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "IMAGE", NULL);
return TCL_ERROR;
}
@@ -4452,7 +4462,7 @@ WmIconphotoCmd(
lpIR->IconImages[i-startObj].hIcon = hIcon;
}
- titlebaricon = ckalloc(sizeof(WinIconInstance));
+ titlebaricon = (WinIconPtr)ckalloc(sizeof(WinIconInstance));
titlebaricon->iconBlock = lpIR;
titlebaricon->refCount = 1;
if (WinSetIcon(interp, titlebaricon, (Tk_Window) useWinPtr) != TCL_OK) {
@@ -4491,8 +4501,9 @@ WmIconpositionCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y;
+ (void)tkwin;
if ((objc != 3) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?");
@@ -4502,8 +4513,8 @@ WmIconpositionCmd(
if (wmPtr->hints.flags & IconPositionHint) {
Tcl_Obj *results[2];
- results[0] = Tcl_NewIntObj(wmPtr->hints.icon_x);
- results[1] = Tcl_NewIntObj(wmPtr->hints.icon_y);
+ results[0] = Tcl_NewWideIntObj(wmPtr->hints.icon_x);
+ results[1] = Tcl_NewWideIntObj(wmPtr->hints.icon_y);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
}
return TCL_OK;
@@ -4547,7 +4558,7 @@ WmIconwindowCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window tkwin2;
WmInfo *wmPtr2;
XSetWindowAttributes atts;
@@ -4657,8 +4668,11 @@ WmManageCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Tk_Window frameWin = (Tk_Window) winPtr;
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ Tk_Window frameWin = (Tk_Window) winPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)tkwin;
+ (void)objc;
+ (void)objv;
if (!Tk_IsTopLevel(frameWin)) {
if (!Tk_IsManageable(frameWin)) {
@@ -4711,8 +4725,9 @@ WmMaxsizeCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
+ (void)tkwin;
if ((objc != 3) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
@@ -4722,8 +4737,8 @@ WmMaxsizeCmd(
Tcl_Obj *results[2];
GetMaxSize(wmPtr, &width, &height);
- results[0] = Tcl_NewIntObj(width);
- results[1] = Tcl_NewIntObj(height);
+ results[0] = Tcl_NewWideIntObj(width);
+ results[1] = Tcl_NewWideIntObj(height);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
@@ -4762,8 +4777,9 @@ WmMinsizeCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
+ (void)tkwin;
if ((objc != 3) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
@@ -4773,8 +4789,8 @@ WmMinsizeCmd(
Tcl_Obj *results[2];
GetMinSize(wmPtr, &width, &height);
- results[0] = Tcl_NewIntObj(width);
- results[1] = Tcl_NewIntObj(height);
+ results[0] = Tcl_NewWideIntObj(width);
+ results[1] = Tcl_NewWideIntObj(height);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
@@ -4813,16 +4829,17 @@ WmOverrideredirectCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int boolean, curValue;
XSetWindowAttributes atts;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?");
return TCL_ERROR;
}
if (winPtr->flags & TK_EMBEDDED) {
- curValue = SendMessage(wmPtr->wrapper, TK_OVERRIDEREDIRECT, -1, -1)-1;
+ curValue = SendMessageW(wmPtr->wrapper, TK_OVERRIDEREDIRECT, -1, -1)-1;
if (curValue < 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"Container does not support overrideredirect", -1));
@@ -4833,7 +4850,7 @@ WmOverrideredirectCmd(
curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect;
}
if (objc == 3) {
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(curValue));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(curValue != 0));
return TCL_OK;
}
if (Tcl_GetBooleanFromObj(interp, objv[3], &boolean) != TCL_OK) {
@@ -4841,7 +4858,7 @@ WmOverrideredirectCmd(
}
if (curValue != boolean) {
if (winPtr->flags & TK_EMBEDDED) {
- SendMessage(wmPtr->wrapper, TK_OVERRIDEREDIRECT, boolean, 0);
+ SendMessageW(wmPtr->wrapper, TK_OVERRIDEREDIRECT, boolean, 0);
} else {
/*
* Only do this if we are really changing value, because it causes
@@ -4885,7 +4902,7 @@ WmPositionfromCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"program", "user", NULL
};
@@ -4893,6 +4910,7 @@ WmPositionfromCmd(
OPT_PROGRAM, OPT_USER
};
int index;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?");
@@ -4953,12 +4971,13 @@ WmProtocolCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
- register ProtocolHandler *protPtr, *prevPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ ProtocolHandler *protPtr, *prevPtr;
Atom protocol;
const char *cmd;
- size_t cmdLength;
+ TkSizeT cmdLength;
Tcl_Obj *resultObj;
+ (void)tkwin;
if ((objc < 3) || (objc > 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?");
@@ -5012,10 +5031,9 @@ WmProtocolCmd(
break;
}
}
- cmd = Tcl_GetString(objv[4]);
- cmdLength = objv[4]->length;
+ cmd = TkGetStringFromObj(objv[4], &cmdLength);
if (cmdLength > 0) {
- protPtr = ckalloc(HANDLER_SIZE(cmdLength));
+ protPtr = (ProtocolHandler *)ckalloc(HANDLER_SIZE(cmdLength));
protPtr->protocol = protocol;
protPtr->nextPtr = wmPtr->protPtr;
wmPtr->protPtr = protPtr;
@@ -5050,8 +5068,9 @@ WmResizableCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
+ (void)tkwin;
if ((objc != 3) && (objc != 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
@@ -5060,8 +5079,8 @@ WmResizableCmd(
if (objc == 3) {
Tcl_Obj *results[2];
- results[0] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_WIDTH_NOT_RESIZABLE));
- results[1] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_HEIGHT_NOT_RESIZABLE));
+ results[0] = Tcl_NewWideIntObj(!(wmPtr->flags&WM_WIDTH_NOT_RESIZABLE));
+ results[1] = Tcl_NewWideIntObj(!(wmPtr->flags&WM_HEIGHT_NOT_RESIZABLE));
Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
@@ -5112,7 +5131,7 @@ WmSizefromCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"program", "user", NULL
};
@@ -5120,6 +5139,7 @@ WmSizefromCmd(
OPT_PROGRAM, OPT_USER
};
int index;
+ (void)tkwin;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?");
@@ -5198,18 +5218,18 @@ WmStackorderCmd(
if (objc == 3) {
windows = TkWmStackorderToplevel(winPtr);
- if (windows == NULL) {
- Tcl_Panic("TkWmStackorderToplevel failed");
- }
-
- resultObj = Tcl_NewObj();
- for (windowPtr = windows; *windowPtr ; windowPtr++) {
- Tcl_ListObjAppendElement(NULL, resultObj,
- TkNewWindowObj((Tk_Window) *windowPtr));
+ if (windows != NULL) {
+ resultObj = Tcl_NewObj();
+ for (windowPtr = windows; *windowPtr ; windowPtr++) {
+ Tcl_ListObjAppendElement(NULL, resultObj,
+ TkNewWindowObj((Tk_Window) *windowPtr));
+ }
+ Tcl_SetObjResult(interp, resultObj);
+ ckfree(windows);
+ return TCL_OK;
+ } else {
+ return TCL_ERROR;
}
- Tcl_SetObjResult(interp, resultObj);
- ckfree(windows);
- return TCL_OK;
} else {
TkWindow *winPtr2, **winPtr2Ptr = &winPtr2;
int index1 = -1, index2 = -1, result;
@@ -5279,7 +5299,7 @@ WmStackorderCmd(
} else { /* OPT_ISBELOW */
result = index1 < index2;
}
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(result));
return TCL_OK;
}
}
@@ -5309,7 +5329,7 @@ WmStateCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
static const char *const optionStrings[] = {
"normal", "iconic", "withdrawn", "zoomed", NULL
};
@@ -5317,6 +5337,7 @@ WmStateCmd(
OPT_NORMAL, OPT_ICONIC, OPT_WITHDRAWN, OPT_ZOOMED
};
int index;
+ (void)tkwin;
if ((objc < 3) || (objc > 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?state?");
@@ -5355,7 +5376,7 @@ WmStateCmd(
Tcl_Panic("unexpected index");
}
- if (state+1 != SendMessage(wmPtr->wrapper, TK_STATE, state, 0)) {
+ if (state+1 != SendMessageW(wmPtr->wrapper, TK_STATE, state, 0)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't change state of %s: the container does not support the request",
winPtr->pathName));
@@ -5408,7 +5429,7 @@ WmStateCmd(
int state;
if (winPtr->flags & TK_EMBEDDED) {
- state = SendMessage(wmPtr->wrapper, TK_STATE, -1, -1) - 1;
+ state = SendMessageW(wmPtr->wrapper, TK_STATE, -1, -1) - 1;
} else {
state = wmPtr->hints.initial_state;
}
@@ -5449,10 +5470,11 @@ WmTitleCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
const char *argv3;
- size_t length;
+ TkSizeT length;
HWND wrapper;
+ (void)tkwin;
if (objc > 4) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?");
@@ -5460,18 +5482,19 @@ WmTitleCmd(
}
if (winPtr->flags & TK_EMBEDDED) {
- wrapper = (HWND) SendMessage(wmPtr->wrapper, TK_GETFRAMEWID, 0, 0);
+ wrapper = (HWND) SendMessageW(wmPtr->wrapper, TK_GETFRAMEWID, 0, 0);
} else {
wrapper = wmPtr->wrapper;
}
if (objc == 3) {
if (wrapper) {
- TCHAR buf[256];
+ WCHAR buf[256];
Tcl_DString titleString;
int size = 256;
- GetWindowText(wrapper, buf, size);
- Tcl_WinTCharToUtf(buf, -1, &titleString);
+ GetWindowTextW(wrapper, buf, size);
+ Tcl_DStringInit(&titleString);
+ Tcl_WCharToUtfDString(buf, wcslen(buf), &titleString);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
Tcl_DStringValue(&titleString),
Tcl_DStringLength(&titleString)));
@@ -5484,16 +5507,16 @@ WmTitleCmd(
if (wmPtr->title != NULL) {
ckfree(wmPtr->title);
}
- argv3 = Tcl_GetString(objv[3]);
- length = objv[3]->length;
- wmPtr->title = ckalloc(length + 1);
+ argv3 = TkGetStringFromObj(objv[3], &length);
+ wmPtr->title = (char *)ckalloc(length + 1);
memcpy(wmPtr->title, argv3, length + 1);
if (!(wmPtr->flags & WM_NEVER_MAPPED) && wmPtr->wrapper != NULL) {
Tcl_DString titleString;
- Tcl_WinUtfToTChar(wmPtr->title, -1, &titleString);
- SetWindowText(wrapper, (LPCTSTR) Tcl_DStringValue(&titleString));
+ Tcl_DStringInit(&titleString);
+ Tcl_UtfToWCharDString(wmPtr->title, -1, &titleString);
+ SetWindowTextW(wrapper, (LPCWSTR) Tcl_DStringValue(&titleString));
Tcl_DStringFree(&titleString);
}
}
@@ -5525,7 +5548,7 @@ WmTransientCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
TkWindow *masterPtr = wmPtr->masterPtr, **masterPtrPtr = &masterPtr, *w;
WmInfo *wmPtr2;
@@ -5653,7 +5676,8 @@ WmWithdrawCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ (void)tkwin;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -5668,7 +5692,7 @@ WmWithdrawCmd(
}
if (winPtr->flags & TK_EMBEDDED) {
- if (SendMessage(wmPtr->wrapper, TK_WITHDRAW, 0, 0) < 0) {
+ if (SendMessageW(wmPtr->wrapper, TK_WITHDRAW, 0, 0) < 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't withdraw %s: the container does not support the request",
Tcl_GetString(objv[2])));
@@ -5698,13 +5722,12 @@ WmUpdateGeom(
}
}
- /*ARGSUSED*/
static void
WmWaitVisibilityOrMapProc(
ClientData clientData, /* Pointer to window. */
XEvent *eventPtr) /* Information about event. */
{
- TkWindow *winPtr = clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
TkWindow *masterPtr = winPtr->wmInfoPtr->masterPtr;
if (masterPtr == NULL)
@@ -5765,7 +5788,7 @@ Tk_SetGrid(
* of one grid unit. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- register WmInfo *wmPtr;
+ WmInfo *wmPtr;
/*
* Ensure widthInc and heightInc are greater than 0
@@ -5862,7 +5885,7 @@ Tk_UnsetGrid(
* controlling gridding. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- register WmInfo *wmPtr;
+ WmInfo *wmPtr;
/*
* Find the top-level window for tkwin, plus the window manager
@@ -5921,7 +5944,7 @@ TopLevelEventProc(
ClientData clientData, /* Window for which event occurred. */
XEvent *eventPtr) /* Event that just happened. */
{
- register TkWindow *winPtr = clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
if (eventPtr->type == DestroyNotify) {
Tk_ErrorHandler handler;
@@ -5961,7 +5984,6 @@ TopLevelEventProc(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static void
TopLevelReqProc(
ClientData dummy, /* Not used. */
@@ -5969,11 +5991,12 @@ TopLevelReqProc(
{
TkWindow *winPtr = (TkWindow *) tkwin;
WmInfo *wmPtr;
+ (void)dummy;
wmPtr = winPtr->wmInfoPtr;
if (wmPtr) {
if ((winPtr->flags & TK_EMBEDDED) && (wmPtr->wrapper != NULL)) {
- SendMessage(wmPtr->wrapper, TK_GEOMETRYREQ, Tk_ReqWidth(tkwin),
+ SendMessageW(wmPtr->wrapper, TK_GEOMETRYREQ, Tk_ReqWidth(tkwin),
Tk_ReqHeight(tkwin));
}
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
@@ -6012,8 +6035,8 @@ UpdateGeometryInfo(
int width, height; /* Size of client area. */
int min, max;
RECT rect;
- register TkWindow *winPtr = clientData;
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ TkWindow *winPtr = (TkWindow *)clientData;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
wmPtr->flags &= ~WM_UPDATE_PENDING;
@@ -6185,8 +6208,8 @@ UpdateGeometryInfo(
* be ignored.
*/
- SendMessage(wmPtr->wrapper, TK_MOVEWINDOW, x, y);
- SendMessage(wmPtr->wrapper, TK_GEOMETRYREQ, width, height);
+ SendMessageW(wmPtr->wrapper, TK_MOVEWINDOW, x, y);
+ SendMessageW(wmPtr->wrapper, TK_GEOMETRYREQ, width, height);
} else {
int reqHeight, reqWidth;
RECT windowRect;
@@ -6293,10 +6316,10 @@ ParseGeometry(
TkWindow *winPtr) /* Pointer to top-level window whose geometry
* is to be changed. */
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y, width, height, flags;
char *end;
- register const char *p = string;
+ const char *p = string;
/*
* The leading "=" is optional.
@@ -6425,7 +6448,7 @@ Tk_GetRootCoords(
int *xPtr, /* Where to store x-displacement of (0,0). */
int *yPtr) /* Where to store y-displacement of (0,0). */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
/*
* If the window is mapped, let Windows figure out the translation.
@@ -6522,6 +6545,8 @@ Tk_GetVRootGeometry(
int *widthPtr, int *heightPtr)
/* Store dimensions of virtual root here. */
{
+ (void)tkwin;
+
*xPtr = GetSystemMetrics(SM_XVIRTUALSCREEN);
*yPtr = GetSystemMetrics(SM_YVIRTUALSCREEN);
*widthPtr = GetSystemMetrics(SM_CXVIRTUALSCREEN);
@@ -6554,7 +6579,7 @@ Tk_MoveToplevelWindow(
int x, int y) /* New location for window (within parent). */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (!(winPtr->flags & TK_TOP_LEVEL)) {
Tcl_Panic("Tk_MoveToplevelWindow called with non-toplevel window");
@@ -6605,7 +6630,7 @@ TkWmProtocolEventProc(
XEvent *eventPtr) /* X event. */
{
WmInfo *wmPtr;
- register ProtocolHandler *protPtr;
+ ProtocolHandler *protPtr;
Atom protocol;
int result;
Tcl_Interp *interp;
@@ -6683,7 +6708,7 @@ TkWmStackorderToplevelEnumProc(
hPtr = Tcl_FindHashEntry(pair->table, hwnd);
if (hPtr != NULL) {
- childWinPtr = Tcl_GetHashValue(hPtr);
+ childWinPtr = (TkWindow *)Tcl_GetHashValue(hPtr);
/*
* Double check that same HWND does not get passed twice.
@@ -6783,7 +6808,7 @@ TkWmStackorderToplevel(
Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS);
TkWmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table);
- windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *));
+ windows = (TkWindow **)ckalloc((table.numEntries+1) * sizeof(TkWindow *));
/*
* Special cases: If zero or one toplevels were mapped there is no need to
@@ -6796,7 +6821,7 @@ TkWmStackorderToplevel(
goto done;
case 1:
hPtr = Tcl_FirstHashEntry(&table, &search);
- windows[0] = Tcl_GetHashValue(hPtr);
+ windows[0] = (TkWindow *)Tcl_GetHashValue(hPtr);
windows[1] = NULL;
goto done;
}
@@ -6815,8 +6840,6 @@ TkWmStackorderToplevel(
(LPARAM) &pair) == 0) {
ckfree(windows);
windows = NULL;
- } else if (pair.windowPtr != (windows-1)) {
- Tcl_Panic("num matched toplevel windows does not equal num children");
}
done:
@@ -6881,7 +6904,7 @@ TkWmRestackToplevel(
}
if (winPtr->flags & TK_EMBEDDED) {
- SendMessage(winPtr->wmInfoPtr->wrapper, TK_RAISEWINDOW,
+ SendMessageW(winPtr->wmInfoPtr->wrapper, TK_RAISEWINDOW,
(WPARAM) insertAfter, aboveBelow);
} else {
TkWinSetWindowPos(hwnd, insertAfter, aboveBelow);
@@ -6961,7 +6984,7 @@ TkWmAddToColormapWindows(
* Automatically add the toplevel itself as the last element of the list.
*/
- newPtr = ckalloc((count+2) * sizeof(TkWindow *));
+ newPtr = (TkWindow **)ckalloc((count+2) * sizeof(TkWindow *));
if (count > 0) {
memcpy(newPtr, oldPtr, count * sizeof(TkWindow*));
}
@@ -7107,7 +7130,7 @@ TkWinSetMenu(
wmPtr->flags |= WM_UPDATE_PENDING|WM_MOVE_PENDING;
}
} else {
- SendMessage(wmPtr->wrapper, TK_SETMENU, (WPARAM) hMenu,
+ SendMessageW(wmPtr->wrapper, TK_SETMENU, (WPARAM) hMenu,
(LPARAM) Tk_GetMenuHWND(tkwin));
}
}
@@ -7421,7 +7444,7 @@ InstallColormaps(
SelectPalette(dc, oldPalette, TRUE);
RealizePalette(dc);
ReleaseDC(hwnd, dc);
- SendMessage(hwnd, WM_PALETTECHANGED, (WPARAM) hwnd, (LPARAM) NULL);
+ SendMessageW(hwnd, WM_PALETTECHANGED, (WPARAM) hwnd, (LPARAM) NULL);
return TRUE;
}
} else {
@@ -7817,7 +7840,7 @@ TopLevelProc(
winPtr->changes.height = pos->cy;
}
if (!(pos->flags & SWP_NOMOVE)) {
- long result = SendMessage(winPtr->wmInfoPtr->wrapper,
+ long result = SendMessageW(winPtr->wmInfoPtr->wrapper,
TK_MOVEWINDOW, -1, -1);
winPtr->wmInfoPtr->x = winPtr->changes.x = result >> 16;
winPtr->wmInfoPtr->y = winPtr->changes.y = result & 0xffff;
@@ -8008,7 +8031,7 @@ WmProc(
* 2272]
*/
- result = DefWindowProc(hwnd, message, wParam, lParam);
+ result = DefWindowProcW(hwnd, message, wParam, lParam);
goto done;
}
@@ -8085,7 +8108,7 @@ WmProc(
HWND hMenuHWnd = Tk_GetEmbeddedMenuHWND((Tk_Window) winPtr);
if (hMenuHWnd) {
- if (SendMessage(hMenuHWnd, message, wParam, lParam)) {
+ if (SendMessageW(hMenuHWnd, message, wParam, lParam)) {
goto done;
}
} else if (TkWinHandleMenuEvent(&hwnd, &message, &wParam, &lParam,
@@ -8102,12 +8125,12 @@ WmProc(
if (message == WM_SETFOCUS) {
SetFocus(child);
result = 0;
- } else if (!Tk_TranslateWinEvent(child, message, wParam, lParam,
+ } else if (!TkTranslateWinEvent(child, message, wParam, lParam,
&result)) {
- result = DefWindowProc(hwnd, message, wParam, lParam);
+ result = DefWindowProcW(hwnd, message, wParam, lParam);
}
} else {
- result = DefWindowProc(hwnd, message, wParam, lParam);
+ result = DefWindowProcW(hwnd, message, wParam, lParam);
}
done:
@@ -8257,7 +8280,7 @@ TkpGetWrapperWindow(
static void
GenerateActivateEvent(TkWindow * winPtr, const int *flagPtr)
{
- ActivateEvent *eventPtr = ckalloc(sizeof(ActivateEvent));
+ ActivateEvent *eventPtr = (ActivateEvent *)ckalloc(sizeof(ActivateEvent));
eventPtr->ev.proc = ActivateWindow;
eventPtr->winPtr = winPtr;
@@ -8360,7 +8383,7 @@ void
TkWinSetForegroundWindow(
TkWindow *winPtr)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (wmPtr->wrapper != NULL) {
SetForegroundWindow(wmPtr->wrapper);
@@ -8390,7 +8413,7 @@ void
TkpWinToplevelWithDraw(
TkWindow *winPtr)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
wmPtr->flags |= WM_WITHDRAWN;
TkpWmSetState(winPtr, WithdrawnState);
@@ -8441,7 +8464,7 @@ void
TkpWinToplevelDeiconify(
TkWindow *winPtr)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
wmPtr->flags &= ~WM_WITHDRAWN;
@@ -8509,7 +8532,7 @@ long
TkpWinToplevelIsControlledByWm(
TkWindow *winPtr)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (!wmPtr) {
return 0;
@@ -8539,7 +8562,7 @@ TkpWinToplevelMove(
TkWindow *winPtr,
int x, int y)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (wmPtr && x >= 0 && y >= 0 && !TkpWinToplevelIsControlledByWm(winPtr)) {
Tk_MoveToplevelWindow((Tk_Window) winPtr, x, y);
@@ -8571,7 +8594,7 @@ TkpWinToplevelOverrideRedirect(
int reqValue)
{
int curValue;
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect;
if (reqValue < 0) {
@@ -8618,13 +8641,13 @@ void
TkpWinToplevelDetachWindow(
TkWindow *winPtr)
{
- register WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
if (winPtr->flags & TK_EMBEDDED) {
- int state = SendMessage(wmPtr->wrapper, TK_STATE, -1, -1) - 1;
+ int state = SendMessageW(wmPtr->wrapper, TK_STATE, -1, -1) - 1;
- SendMessage(wmPtr->wrapper, TK_SETMENU, 0, 0);
- SendMessage(wmPtr->wrapper, TK_DETACHWINDOW, 0, 0);
+ SendMessageW(wmPtr->wrapper, TK_SETMENU, 0, 0);
+ SendMessageW(wmPtr->wrapper, TK_DETACHWINDOW, 0, 0);
winPtr->flags &= ~TK_EMBEDDED;
winPtr->privatePtr = NULL;
wmPtr->wrapper = NULL;
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 34633a6..661ad29 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -26,6 +26,15 @@
#include <zmouse.h>
/*
+ * WM_MOUSEHWHEEL is normally defined by Winuser.h for Vista/2008 or later,
+ * but is also usable on 2000/XP if IntelliPoint drivers are installed.
+ */
+
+#ifndef WM_MOUSEHWHEEL
+#define WM_MOUSEHWHEEL 0x020E
+#endif
+
+/*
* imm.h is needed by HandleIMEComposition
*/
@@ -50,7 +59,7 @@
static const char winScreenName[] = ":0"; /* Default name of windows display. */
static HINSTANCE tkInstance = NULL; /* Application instance handle. */
static int childClassInitialized; /* Registered child class? */
-static WNDCLASS childClass; /* Window class for child windows. */
+static WNDCLASSW childClass; /* Window class for child windows. */
static int tkWinTheme = 0; /* See TkWinGetPlatformTheme */
static Tcl_Encoding keyInputEncoding = NULL;
/* The current character encoding for
@@ -66,13 +75,15 @@ static Tcl_Encoding unicodeEncoding = NULL;
* specific date for threads.
*/
-typedef struct ThreadSpecificData {
+typedef struct {
TkDisplay *winDisplay; /* TkDisplay structure that represents Windows
* screen. */
int updatingClipboard; /* If 1, we are updating the clipboard. */
int surrogateBuffer; /* Buffer for first of surrogate pair. */
- DWORD wheelTickPrev; /* For high resolution wheels. */
- short wheelAcc; /* For high resolution wheels. */
+ DWORD vWheelTickPrev; /* For high resolution wheels (vertical). */
+ DWORD hWheelTickPrev; /* For high resolution wheels (horizontal). */
+ short vWheelAcc; /* For high resolution wheels (vertical). */
+ short hWheelAcc; /* For high resolution wheels (horizontal). */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -83,7 +94,7 @@ static Tcl_ThreadDataKey dataKey;
static void GenerateXEvent(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam);
static unsigned int GetState(UINT message, WPARAM wParam, LPARAM lParam);
-static void GetTranslatedKey(XKeyEvent *xkey, UINT type);
+static void GetTranslatedKey(TkKeyEvent *xkey, UINT type);
static void UpdateInputLanguage(int charset);
static int HandleIMEComposition(HWND hwnd, LPARAM lParam);
@@ -114,11 +125,12 @@ TkGetServerInfo(
{
static char buffer[32]; /* Empty string means not initialized yet. */
OSVERSIONINFOW os;
+ (void)tkwin;
if (!buffer[0]) {
- HANDLE handle = GetModuleHandle(TEXT("NTDLL"));
- int(__stdcall *getversion)(void *) =
- (int(__stdcall *)(void *))GetProcAddress(handle, "RtlGetVersion");
+ HMODULE handle = GetModuleHandleW(L"NTDLL");
+ int(__stdcall *getversion)(void *) = (int(__stdcall *)(void *))
+ (void *)GetProcAddress(handle, "RtlGetVersion");
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
if (!getversion || getversion(&os)) {
GetVersionExW(&os);
@@ -157,7 +169,7 @@ HINSTANCE
Tk_GetHINSTANCE(void)
{
if (tkInstance == NULL) {
- tkInstance = GetModuleHandle(NULL);
+ tkInstance = GetModuleHandleW(NULL);
}
return tkInstance;
}
@@ -237,7 +249,7 @@ TkWinXInit(
childClass.hIcon = NULL;
childClass.hCursor = NULL;
- if (!RegisterClass(&childClass)) {
+ if (!RegisterClassW(&childClass)) {
Tcl_Panic("Unable to register TkChild class");
}
@@ -245,10 +257,10 @@ TkWinXInit(
* Initialize input language info
*/
- if (GetLocaleInfo(LANGIDFROMLCID(PTR2INT(GetKeyboardLayout(0))),
+ if (GetLocaleInfoW(LANGIDFROMLCID(PTR2INT(GetKeyboardLayout(0))),
LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
- (LPTSTR) &lpCP, sizeof(lpCP)/sizeof(TCHAR))
- && TranslateCharsetInfo(INT2PTR(lpCP), &lpCs, TCI_SRCCODEPAGE)) {
+ (LPWSTR) &lpCP, sizeof(lpCP)/sizeof(WCHAR))
+ && TranslateCharsetInfo((DWORD *)INT2PTR(lpCP), &lpCs, TCI_SRCCODEPAGE)) {
UpdateInputLanguage((int) lpCs.ciCharset);
}
@@ -279,7 +291,7 @@ void
TkWinXCleanup(
ClientData clientData)
{
- HINSTANCE hInstance = clientData;
+ HINSTANCE hInstance = (HINSTANCE)clientData;
/*
* Clean up our own class.
@@ -287,7 +299,7 @@ TkWinXCleanup(
if (childClassInitialized) {
childClassInitialized = 0;
- UnregisterClass(TK_WIN_CHILD_CLASS_NAME, hInstance);
+ UnregisterClassW(TK_WIN_CHILD_CLASS_NAME, hInstance);
}
if (unicodeEncoding != NULL) {
@@ -314,6 +326,7 @@ TkWinXCleanup(
* The return value is one of:
* TK_THEME_WIN_CLASSIC 95/98/NT or XP in classic mode
* TK_THEME_WIN_XP XP not in classic mode
+ * TK_THEME_WIN_VISTA Vista or higher
*
*----------------------------------------------------------------------
*/
@@ -327,25 +340,28 @@ TkWinGetPlatformTheme(void)
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
GetVersionExW(&os);
+ if (os.dwPlatformId != VER_PLATFORM_WIN32_NT) {
+ Tcl_Panic("Windows NT is the only supported platform");
+ }
+
/*
- * Set tkWinTheme to be TK_THEME_WIN_XP or TK_THEME_WIN_CLASSIC. The
+ * Set tkWinTheme to be TK_THEME_WIN_(CLASSIC|XP|VISTA). The
* TK_THEME_WIN_CLASSIC could be set even when running under XP if the
* windows classic theme was selected.
*/
-
- if ((os.dwMajorVersion == 5 && os.dwMinorVersion == 1)) {
+ if ((os.dwMajorVersion == 5) && (os.dwMinorVersion == 1)) {
HKEY hKey;
- LPCTSTR szSubKey = TEXT("Control Panel\\Appearance");
- LPCTSTR szCurrent = TEXT("Current");
+ LPCWSTR szSubKey = L"Control Panel\\Appearance";
+ LPCWSTR szCurrent = L"Current";
DWORD dwSize = 200;
char pBuffer[200];
memset(pBuffer, 0, dwSize);
- if (RegOpenKeyEx(HKEY_CURRENT_USER, szSubKey, 0L,
+ if (RegOpenKeyExW(HKEY_CURRENT_USER, szSubKey, 0L,
KEY_READ, &hKey) != ERROR_SUCCESS) {
tkWinTheme = TK_THEME_WIN_XP;
} else {
- RegQueryValueEx(hKey, szCurrent, NULL, NULL, (LPBYTE) pBuffer, &dwSize);
+ RegQueryValueExW(hKey, szCurrent, NULL, NULL, (LPBYTE) pBuffer, &dwSize);
RegCloseKey(hKey);
if (strcmp(pBuffer, "Windows Standard") == 0) {
tkWinTheme = TK_THEME_WIN_CLASSIC;
@@ -353,6 +369,8 @@ TkWinGetPlatformTheme(void)
tkWinTheme = TK_THEME_WIN_XP;
}
}
+ } else if (os.dwMajorVersion > 5) {
+ tkWinTheme = TK_THEME_WIN_VISTA;
} else {
tkWinTheme = TK_THEME_WIN_CLASSIC;
}
@@ -379,9 +397,11 @@ TkWinGetPlatformTheme(void)
const char *
TkGetDefaultScreenName(
- Tcl_Interp *interp, /* Not used. */
+ Tcl_Interp *dummy, /* Not used. */
const char *screenName) /* If NULL, use default string. */
{
+ (void)dummy;
+
if ((screenName == NULL) || (screenName[0] == '\0')) {
screenName = winScreenName;
}
@@ -434,44 +454,44 @@ TkWinDisplayChanged(
* the HWND and we'll just get blank spots copied onto the screen.
*/
- screen->ext_data = INT2PTR(GetDeviceCaps(dc, PLANES));
+ screen->ext_data = (XExtData *)INT2PTR(GetDeviceCaps(dc, PLANES));
screen->root_depth = GetDeviceCaps(dc, BITSPIXEL) * PTR2INT(screen->ext_data);
if (screen->root_visual != NULL) {
ckfree(screen->root_visual);
}
- screen->root_visual = ckalloc(sizeof(Visual));
+ screen->root_visual = (Visual *)ckalloc(sizeof(Visual));
screen->root_visual->visualid = 0;
if (GetDeviceCaps(dc, RASTERCAPS) & RC_PALETTE) {
screen->root_visual->map_entries = GetDeviceCaps(dc, SIZEPALETTE);
- screen->root_visual->class = PseudoColor;
+ screen->root_visual->c_class = PseudoColor;
screen->root_visual->red_mask = 0x0;
screen->root_visual->green_mask = 0x0;
screen->root_visual->blue_mask = 0x0;
} else if (screen->root_depth == 4) {
- screen->root_visual->class = StaticColor;
+ screen->root_visual->c_class = StaticColor;
screen->root_visual->map_entries = 16;
} else if (screen->root_depth == 8) {
- screen->root_visual->class = StaticColor;
+ screen->root_visual->c_class = StaticColor;
screen->root_visual->map_entries = 256;
} else if (screen->root_depth == 12) {
- screen->root_visual->class = TrueColor;
+ screen->root_visual->c_class = TrueColor;
screen->root_visual->map_entries = 32;
- screen->root_visual->red_mask = 0xf00000;
+ screen->root_visual->red_mask = 0xf0;
screen->root_visual->green_mask = 0xf000;
- screen->root_visual->blue_mask = 0xf0;
+ screen->root_visual->blue_mask = 0xf00000;
} else if (screen->root_depth == 16) {
- screen->root_visual->class = TrueColor;
+ screen->root_visual->c_class = TrueColor;
screen->root_visual->map_entries = 64;
- screen->root_visual->red_mask = 0xf80000;
+ screen->root_visual->red_mask = 0xf8;
screen->root_visual->green_mask = 0xfc00;
- screen->root_visual->blue_mask = 0xf8;
+ screen->root_visual->blue_mask = 0xf80000;
} else if (screen->root_depth >= 24) {
- screen->root_visual->class = TrueColor;
+ screen->root_visual->c_class = TrueColor;
screen->root_visual->map_entries = 256;
- screen->root_visual->red_mask = 0xff0000;
+ screen->root_visual->red_mask = 0xff;
screen->root_visual->green_mask = 0xff00;
- screen->root_visual->blue_mask = 0xff;
+ screen->root_visual->blue_mask = 0xff0000;
}
screen->root_visual->bits_per_rgb = screen->root_depth;
ReleaseDC(NULL, dc);
@@ -486,7 +506,7 @@ TkWinDisplayChanged(
/*
*----------------------------------------------------------------------
*
- * TkpOpenDisplay --
+ * TkpOpenDisplay/XkbOpenDisplay --
*
* Create the Display structure and fill it with device specific
* information.
@@ -504,11 +524,10 @@ TkDisplay *
TkpOpenDisplay(
const char *display_name)
{
- Screen *screen;
- TkWinDrawable *twdPtr;
Display *display;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ DWORD initialWheelTick;
if (tsdPtr->winDisplay != NULL) {
if (!strcmp(tsdPtr->winDisplay->display->display_name, display_name)) {
@@ -518,33 +537,47 @@ TkpOpenDisplay(
}
}
- display = ckalloc(sizeof(Display));
- ZeroMemory(display, sizeof(Display));
-
- display->display_name = ckalloc(strlen(display_name) + 1);
- strcpy(display->display_name, display_name);
+ display = XkbOpenDisplay((char *)display_name, NULL, NULL, NULL, NULL, NULL);
+ TkWinDisplayChanged(display);
- display->cursor_font = 1;
- display->nscreens = 1;
- display->request = 1;
- display->qlen = 0;
+ tsdPtr->winDisplay =(TkDisplay *) ckalloc(sizeof(TkDisplay));
+ ZeroMemory(tsdPtr->winDisplay, sizeof(TkDisplay));
+ tsdPtr->winDisplay->display = display;
+ tsdPtr->updatingClipboard = FALSE;
+ initialWheelTick = GetTickCount();
+ tsdPtr->vWheelTickPrev = initialWheelTick;
+ tsdPtr->hWheelTickPrev = initialWheelTick;
+ tsdPtr->vWheelAcc = 0;
+ tsdPtr->hWheelAcc = 0;
- screen = ckalloc(sizeof(Screen));
- ZeroMemory(screen, sizeof(Screen));
- screen->display = display;
+ /*
+ * Key map info must be available immediately, because of "send event".
+ */
+ TkpInitKeymapInfo(tsdPtr->winDisplay);
/*
- * Set up the root window.
+ * Key map info must be available immediately, because of "send event".
*/
+ TkpInitKeymapInfo(tsdPtr->winDisplay);
- twdPtr = ckalloc(sizeof(TkWinDrawable));
- if (twdPtr == NULL) {
- return NULL;
- }
- twdPtr->type = TWD_WINDOW;
- twdPtr->window.winPtr = NULL;
- twdPtr->window.handle = NULL;
- screen->root = (Window)twdPtr;
+ return tsdPtr->winDisplay;
+}
+
+Display *
+XkbOpenDisplay(
+ const char *name,
+ int *ev_rtrn,
+ int *err_rtrn,
+ int *major_rtrn,
+ int *minor_rtrn,
+ int *reason)
+{
+ Display *display = (Display *)ckalloc(sizeof(Display));
+ Screen *screen = (Screen *)ckalloc(sizeof(Screen));
+ TkWinDrawable *twdPtr = (TkWinDrawable *)ckalloc(sizeof(TkWinDrawable));
+
+ ZeroMemory(screen, sizeof(Screen));
+ ZeroMemory(display, sizeof(Display));
/*
* Note that these pixel values are not palette relative.
@@ -558,16 +591,27 @@ TkpOpenDisplay(
display->nscreens = 1;
display->default_screen = 0;
- TkWinDisplayChanged(display);
+ twdPtr->type = TWD_WINDOW;
+ twdPtr->window.winPtr = NULL;
+ twdPtr->window.handle = NULL;
+ screen->root = (Window)twdPtr;
+ screen->display = display;
- tsdPtr->winDisplay = ckalloc(sizeof(TkDisplay));
- ZeroMemory(tsdPtr->winDisplay, sizeof(TkDisplay));
- tsdPtr->winDisplay->display = display;
- tsdPtr->updatingClipboard = FALSE;
- tsdPtr->wheelTickPrev = GetTickCount();
- tsdPtr->wheelAcc = 0;
+ display->display_name = (char *)ckalloc(strlen(name) + 1);
+ strcpy(display->display_name, name);
- return tsdPtr->winDisplay;
+ display->cursor_font = 1;
+ display->nscreens = 1;
+ display->request = 1;
+ display->qlen = 0;
+
+ if (ev_rtrn) *ev_rtrn = 0;
+ if (err_rtrn) *err_rtrn = 0;
+ if (major_rtrn) *major_rtrn = 0;
+ if (minor_rtrn) *minor_rtrn = 0;
+ if (reason) *reason = 0;
+
+ return display;
}
/*
@@ -676,6 +720,9 @@ XBell(
Display *display,
int percent)
{
+ (void)display;
+ (void)percent;
+
MessageBeep(MB_OK);
return Success;
}
@@ -714,7 +761,7 @@ TkWinChildProc(
case WM_IME_COMPOSITION:
result = 0;
if (HandleIMEComposition(hwnd, lParam) == 0) {
- result = DefWindowProc(hwnd, message, wParam, lParam);
+ result = DefWindowProcW(hwnd, message, wParam, lParam);
}
break;
@@ -734,7 +781,7 @@ TkWinChildProc(
case WM_PAINT:
GenerateXEvent(hwnd, message, wParam, lParam);
- result = DefWindowProc(hwnd, message, wParam, lParam);
+ result = DefWindowProcW(hwnd, message, wParam, lParam);
break;
case TK_CLAIMFOCUS:
@@ -761,7 +808,7 @@ TkWinChildProc(
result = 1;
} else {
/* If the event was translated, we must return 0 */
- if (Tk_TranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
+ if (TkTranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
result = 0;
} else {
result = 1;
@@ -770,8 +817,8 @@ TkWinChildProc(
break;
default:
- if (!Tk_TranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
- result = DefWindowProc(hwnd, message, wParam, lParam);
+ if (!TkTranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
+ result = DefWindowProcW(hwnd, message, wParam, lParam);
}
break;
}
@@ -787,7 +834,7 @@ TkWinChildProc(
/*
*----------------------------------------------------------------------
*
- * Tk_TranslateWinEvent --
+ * TkTranslateWinEvent --
*
* This function is called by widget window functions to handle the
* translation from Win32 events to Tk events.
@@ -802,7 +849,7 @@ TkWinChildProc(
*/
int
-Tk_TranslateWinEvent(
+TkTranslateWinEvent(
HWND hwnd,
UINT message,
WPARAM wParam,
@@ -852,7 +899,7 @@ Tk_TranslateWinEvent(
? ((NMHDR*)lParam)->hwndFrom : (HWND) lParam;
if (target && target != hwnd) {
- *resultPtr = SendMessage(target, message, wParam, lParam);
+ *resultPtr = SendMessageW(target, message, wParam, lParam);
return 1;
}
break;
@@ -864,11 +911,14 @@ Tk_TranslateWinEvent(
case WM_MBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONDBLCLK:
+ case WM_XBUTTONDOWN:
+ case WM_XBUTTONDBLCLK:
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
+ case WM_XBUTTONUP:
case WM_MOUSEMOVE:
- Tk_PointerEvent(hwnd, (short) LOWORD(lParam), (short) HIWORD(lParam));
+ TkWinPointerEvent(hwnd, (short) LOWORD(lParam), (short) HIWORD(lParam));
return 1;
case WM_SYSKEYDOWN:
@@ -891,6 +941,7 @@ Tk_TranslateWinEvent(
case WM_SYSKEYUP:
case WM_KEYUP:
case WM_MOUSEWHEEL:
+ case WM_MOUSEHWHEEL:
GenerateXEvent(hwnd, message, wParam, lParam);
return 1;
case WM_MENUCHAR:
@@ -930,12 +981,12 @@ GenerateXEvent(
WPARAM wParam,
LPARAM lParam)
{
- XEvent event;
+ union {XEvent x; TkKeyEvent key;} event;
TkWindow *winPtr;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- if (message == WM_MOUSEWHEEL) {
+ if ((message == WM_MOUSEWHEEL) || (message == WM_MOUSEHWHEEL)) {
union {LPARAM lParam; POINTS point;} root;
POINT pos;
root.lParam = lParam;
@@ -956,33 +1007,33 @@ GenerateXEvent(
return;
}
- memset(&event, 0, sizeof(XEvent));
- event.xany.serial = winPtr->display->request++;
- event.xany.send_event = False;
- event.xany.display = winPtr->display;
- event.xany.window = winPtr->window;
+ memset(&event.x, 0, sizeof(XEvent));
+ event.x.xany.serial = winPtr->display->request++;
+ event.x.xany.send_event = False;
+ event.x.xany.display = winPtr->display;
+ event.x.xany.window = winPtr->window;
switch (message) {
case WM_PAINT: {
PAINTSTRUCT ps;
- event.type = Expose;
+ event.x.type = Expose;
BeginPaint(hwnd, &ps);
- event.xexpose.x = ps.rcPaint.left;
- event.xexpose.y = ps.rcPaint.top;
- event.xexpose.width = ps.rcPaint.right - ps.rcPaint.left;
- event.xexpose.height = ps.rcPaint.bottom - ps.rcPaint.top;
+ event.x.xexpose.x = ps.rcPaint.left;
+ event.x.xexpose.y = ps.rcPaint.top;
+ event.x.xexpose.width = ps.rcPaint.right - ps.rcPaint.left;
+ event.x.xexpose.height = ps.rcPaint.bottom - ps.rcPaint.top;
EndPaint(hwnd, &ps);
- event.xexpose.count = 0;
+ event.x.xexpose.count = 0;
break;
}
case WM_CLOSE:
- event.type = ClientMessage;
- event.xclient.message_type =
+ event.x.type = ClientMessage;
+ event.x.xclient.message_type =
Tk_InternAtom((Tk_Window) winPtr, "WM_PROTOCOLS");
- event.xclient.format = 32;
- event.xclient.data.l[0] =
+ event.x.xclient.format = 32;
+ event.x.xclient.data.l[0] =
Tk_InternAtom((Tk_Window) winPtr, "WM_DELETE_WINDOW");
break;
@@ -1018,10 +1069,10 @@ GenerateXEvent(
return;
}
- event.xany.window = winPtr->window;
- event.type = (message == WM_SETFOCUS) ? FocusIn : FocusOut;
- event.xfocus.mode = NotifyNormal;
- event.xfocus.detail = NotifyNonlinear;
+ event.x.xany.window = winPtr->window;
+ event.x.type = (message == WM_SETFOCUS) ? FocusIn : FocusOut;
+ event.x.xfocus.mode = NotifyNormal;
+ event.x.xfocus.detail = NotifyNonlinear;
/*
* Destroy the caret if we own it. If we are moving to another Tk
@@ -1043,13 +1094,14 @@ GenerateXEvent(
return;
}
- event.type = SelectionClear;
- event.xselectionclear.selection =
+ event.x.type = SelectionClear;
+ event.x.xselectionclear.selection =
Tk_InternAtom((Tk_Window)winPtr, "CLIPBOARD");
- event.xselectionclear.time = TkpGetMS();
+ event.x.xselectionclear.time = TkpGetMS();
break;
case WM_MOUSEWHEEL:
+ case WM_MOUSEHWHEEL:
case WM_CHAR:
case WM_UNICHAR:
case WM_SYSKEYDOWN:
@@ -1074,15 +1126,15 @@ GenerateXEvent(
* Set up the common event fields.
*/
- event.xbutton.root = RootWindow(winPtr->display, winPtr->screenNum);
- event.xbutton.subwindow = None;
- event.xbutton.x = clientPoint.x;
- event.xbutton.y = clientPoint.y;
- event.xbutton.x_root = root.point.x;
- event.xbutton.y_root = root.point.y;
- event.xbutton.state = state;
- event.xbutton.time = time;
- event.xbutton.same_screen = True;
+ event.x.xbutton.root = RootWindow(winPtr->display, winPtr->screenNum);
+ event.x.xbutton.subwindow = None;
+ event.x.xbutton.x = clientPoint.x;
+ event.x.xbutton.y = clientPoint.y;
+ event.x.xbutton.x_root = root.point.x;
+ event.x.xbutton.y_root = root.point.y;
+ event.x.xbutton.state = state;
+ event.x.xbutton.time = time;
+ event.x.xbutton.same_screen = True;
/*
* Now set up event specific fields.
@@ -1091,18 +1143,50 @@ GenerateXEvent(
switch (message) {
case WM_MOUSEWHEEL: {
/*
- * Support for high resolution wheels.
+ * Support for high resolution wheels (vertical).
+ */
+
+ DWORD wheelTick = GetTickCount();
+
+ if (wheelTick - tsdPtr->vWheelTickPrev < 1500) {
+ tsdPtr->vWheelAcc += (short) HIWORD(wParam);
+ } else {
+ tsdPtr->vWheelAcc = (short) HIWORD(wParam);
+ }
+ tsdPtr->vWheelTickPrev = wheelTick;
+ if (abs(tsdPtr->vWheelAcc) < WHEEL_DELTA) {
+ return;
+ }
+
+ /*
+ * We have invented a new X event type to handle this event. It
+ * still uses the KeyPress struct. However, the keycode field has
+ * been overloaded to hold the zDelta of the wheel. Set nbytes to
+ * 0 to prevent conversion of the keycode to a keysym in
+ * TkpGetString. [Bug 1118340].
+ */
+
+ event.x.type = MouseWheelEvent;
+ event.x.xany.send_event = -1;
+ event.key.nbytes = 0;
+ event.x.xkey.keycode = tsdPtr->vWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
+ tsdPtr->vWheelAcc = tsdPtr->vWheelAcc % WHEEL_DELTA;
+ break;
+ }
+ case WM_MOUSEHWHEEL: {
+ /*
+ * Support for high resolution wheels (horizontal).
*/
DWORD wheelTick = GetTickCount();
- if (wheelTick - tsdPtr->wheelTickPrev < 1500) {
- tsdPtr->wheelAcc += (short) HIWORD(wParam);
+ if (wheelTick - tsdPtr->hWheelTickPrev < 1500) {
+ tsdPtr->hWheelAcc -= (short) HIWORD(wParam);
} else {
- tsdPtr->wheelAcc = (short) HIWORD(wParam);
+ tsdPtr->hWheelAcc = -((short) HIWORD(wParam));
}
- tsdPtr->wheelTickPrev = wheelTick;
- if (abs(tsdPtr->wheelAcc) < WHEEL_DELTA) {
+ tsdPtr->hWheelTickPrev = wheelTick;
+ if (abs(tsdPtr->hWheelAcc) < WHEEL_DELTA) {
return;
}
@@ -1114,11 +1198,12 @@ GenerateXEvent(
* TkpGetString. [Bug 1118340].
*/
- event.type = MouseWheelEvent;
- event.xany.send_event = -1;
- event.xkey.nbytes = 0;
- event.xkey.keycode = tsdPtr->wheelAcc / WHEEL_DELTA * WHEEL_DELTA;
- tsdPtr->wheelAcc = tsdPtr->wheelAcc % WHEEL_DELTA;
+ event.x.type = MouseWheelEvent;
+ event.x.xany.send_event = -1;
+ event.key.nbytes = 0;
+ event.x.xkey.state |= ShiftMask;
+ event.x.xkey.keycode = tsdPtr->hWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
+ tsdPtr->hWheelAcc = tsdPtr->hWheelAcc % WHEEL_DELTA;
break;
}
case WM_SYSKEYDOWN:
@@ -1131,10 +1216,10 @@ GenerateXEvent(
* MBCS characters that came from the TranslateMessage call.
*/
- event.type = KeyPress;
- event.xany.send_event = -1;
- event.xkey.keycode = wParam;
- GetTranslatedKey(&event.xkey, (message == WM_KEYDOWN) ? WM_CHAR :
+ event.x.type = KeyPress;
+ event.x.xany.send_event = -1;
+ event.x.xkey.keycode = wParam;
+ GetTranslatedKey(&event.key, (message == WM_KEYDOWN) ? WM_CHAR :
WM_SYSCHAR);
break;
@@ -1146,9 +1231,9 @@ GenerateXEvent(
* WM_CHAR messages which will follow.
*/
- event.type = KeyRelease;
- event.xkey.keycode = wParam;
- event.xkey.nbytes = 0;
+ event.x.type = KeyRelease;
+ event.x.xkey.keycode = wParam;
+ event.key.nbytes = 0;
break;
case WM_CHAR:
@@ -1182,9 +1267,9 @@ GenerateXEvent(
* character.
*/
- event.type = KeyPress;
- event.xany.send_event = -1;
- event.xkey.keycode = 0;
+ event.x.type = KeyPress;
+ event.x.xany.send_event = -1;
+ event.x.xkey.keycode = 0;
if ((int)wParam & 0xff00) {
int ch1 = wParam & 0xffff;
@@ -1197,36 +1282,36 @@ GenerateXEvent(
(ch1 & 0x3ff) | 0x10000;
tsdPtr->surrogateBuffer = 0;
}
- event.xany.send_event = -3;
- event.xkey.nbytes = 0;
- event.xkey.keycode = ch1;
+ event.x.xany.send_event = -3;
+ event.key.nbytes = 0;
+ event.x.xkey.keycode = ch1;
} else {
- event.xkey.nbytes = 1;
- event.xkey.trans_chars[0] = (char) wParam;
+ event.key.nbytes = 1;
+ event.key.trans_chars[0] = (char) wParam;
if (IsDBCSLeadByte((BYTE) wParam)) {
MSG msg;
- if ((PeekMessage(&msg, NULL, WM_CHAR, WM_CHAR,
+ if ((PeekMessageW(&msg, NULL, WM_CHAR, WM_CHAR,
PM_NOREMOVE) != 0)
&& (msg.message == WM_CHAR)) {
- GetMessage(&msg, NULL, WM_CHAR, WM_CHAR);
- event.xkey.nbytes = 2;
- event.xkey.trans_chars[1] = (char) msg.wParam;
+ GetMessageW(&msg, NULL, WM_CHAR, WM_CHAR);
+ event.key.nbytes = 2;
+ event.key.trans_chars[1] = (char) msg.wParam;
}
}
}
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- event.type = KeyRelease;
+ Tk_QueueWindowEvent(&event.x, TCL_QUEUE_TAIL);
+ event.x.type = KeyRelease;
break;
case WM_UNICHAR: {
- event.type = KeyPress;
- event.xany.send_event = -3;
- event.xkey.keycode = wParam;
- event.xkey.nbytes = 0;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- event.type = KeyRelease;
+ event.x.type = KeyPress;
+ event.x.xany.send_event = -3;
+ event.x.xkey.keycode = wParam;
+ event.key.nbytes = 0;
+ Tk_QueueWindowEvent(&event.x, TCL_QUEUE_TAIL);
+ event.x.type = KeyRelease;
break;
}
@@ -1247,7 +1332,7 @@ GenerateXEvent(
* Post the translated event to the main Tk event queue.
*/
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
+ Tk_QueueWindowEvent(&event.x, TCL_QUEUE_TAIL);
}
/*
@@ -1349,7 +1434,7 @@ GetState(
static void
GetTranslatedKey(
- XKeyEvent *xkey,
+ TkKeyEvent *xkey,
UINT type)
{
MSG msg;
@@ -1372,10 +1457,9 @@ GetTranslatedKey(
*/
if ((msg.message == WM_CHAR) && (msg.lParam & 0x20000000)) {
- xkey->state = 0;
+ xkey->keyEvent.state = 0;
}
- xkey->trans_chars[xkey->nbytes] = (char) msg.wParam;
- xkey->nbytes++;
+ xkey->trans_chars[xkey->nbytes++] = (char) msg.wParam;
if (((unsigned short) msg.wParam) > ((unsigned short) 0xff)) {
/*
@@ -1423,7 +1507,7 @@ UpdateInputLanguage(
if (keyInputCharset == charset) {
return;
}
- if (TranslateCharsetInfo(INT2PTR(charset), &charsetInfo,
+ if (TranslateCharsetInfo((DWORD*)INT2PTR(charset), &charsetInfo,
TCI_SRCCHARSET) == 0) {
/*
* Some mysterious failure.
@@ -1432,7 +1516,11 @@ UpdateInputLanguage(
return;
}
- wsprintfA(codepage, "cp%d", charsetInfo.ciACP);
+ if (charsetInfo.ciACP == CP_UTF8) {
+ strcpy(codepage, "utf-8");
+ } else {
+ sprintf(codepage, "cp%d", charsetInfo.ciACP);
+ }
if ((encoding = Tcl_GetEncoding(NULL, codepage)) == NULL) {
/*
@@ -1493,7 +1581,10 @@ Tcl_Encoding
TkWinGetUnicodeEncoding(void)
{
if (unicodeEncoding == NULL) {
- unicodeEncoding = Tcl_GetEncoding(NULL, "unicode");
+ unicodeEncoding = Tcl_GetEncoding(NULL, "utf-16");
+ if (unicodeEncoding == NULL) {
+ unicodeEncoding = Tcl_GetEncoding(NULL, "unicode");
+ }
}
return unicodeEncoding;
}
@@ -1509,7 +1600,7 @@ TkWinGetUnicodeEncoding(void)
*
* When an Input Method Editor (IME) is ready to send input characters to
* an application, it sends a WM_IME_COMPOSITION message with the
- * GCS_RESULTSTR. However, The DefWindowProc() on English Windows 2000
+ * GCS_RESULTSTR. However, The DefWindowProcW() on English Windows 2000
* arbitrarily converts all non-Latin-1 characters in the composition to
* "?".
*
@@ -1548,7 +1639,7 @@ HandleIMEComposition(
return 0;
}
- n = ImmGetCompositionString(hIMC, GCS_RESULTSTR, NULL, 0);
+ n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
if (n > 0) {
WCHAR *buff = (WCHAR *) ckalloc(n);
@@ -1556,7 +1647,7 @@ HandleIMEComposition(
XEvent event;
int i;
- n = ImmGetCompositionString(hIMC, GCS_RESULTSTR, buff, (unsigned) n) / 2;
+ n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, (unsigned) n) / 2;
/*
* Set up the fields pertinent to key event.
@@ -1617,7 +1708,7 @@ HandleIMEComposition(
* TkWinResendEvent --
*
* This function converts an X event into a Windows event and invokes the
- * specified windo function.
+ * specified window function.
*
* Results:
* A standard Windows result.
@@ -1655,6 +1746,14 @@ TkWinResendEvent(
msg = WM_RBUTTONDOWN;
wparam = MK_RBUTTON;
break;
+ case Button4:
+ msg = WM_XBUTTONDOWN;
+ wparam = MAKEWPARAM(MK_XBUTTON1, XBUTTON1);
+ break;
+ case Button5:
+ msg = WM_XBUTTONDOWN;
+ wparam = MAKEWPARAM(MK_XBUTTON2, XBUTTON2);
+ break;
default:
return 0;
}
@@ -1668,6 +1767,12 @@ TkWinResendEvent(
if (eventPtr->xbutton.state & Button3Mask) {
wparam |= MK_RBUTTON;
}
+ if (eventPtr->xbutton.state & Button4Mask) {
+ wparam |= MK_XBUTTON1;
+ }
+ if (eventPtr->xbutton.state & Button5Mask) {
+ wparam |= MK_XBUTTON2;
+ }
if (eventPtr->xbutton.state & ShiftMask) {
wparam |= MK_SHIFT;
}
@@ -1676,7 +1781,7 @@ TkWinResendEvent(
}
lparam = MAKELPARAM((short) eventPtr->xbutton.x,
(short) eventPtr->xbutton.y);
- return CallWindowProc(wndproc, hwnd, msg, wparam, lparam);
+ return CallWindowProcW(wndproc, hwnd, msg, wparam, lparam);
}
/*
@@ -1851,6 +1956,7 @@ Tk_GetUserInactiveTime(
Display *dpy) /* Ignored on Windows */
{
LASTINPUTINFO li;
+ (void)dpy;
li.cbSize = sizeof(li);
if (!GetLastInputInfo(&li)) {
@@ -1886,6 +1992,7 @@ Tk_ResetUserInactiveTime(
Display *dpy)
{
INPUT inp;
+ (void)dpy;
inp.type = INPUT_MOUSE;
inp.mi.dx = 0;
diff --git a/win/ttkWinMonitor.c b/win/ttkWinMonitor.c
index 5d9cf0a..1d31c1c 100644
--- a/win/ttkWinMonitor.c
+++ b/win/ttkWinMonitor.c
@@ -22,7 +22,7 @@ typedef struct {
int index;
} SystemColorEntry;
-static SystemColorEntry sysColors[] = {
+static const SystemColorEntry sysColors[] = {
{ "System3dDarkShadow", COLOR_3DDKSHADOW },
{ "System3dLight", COLOR_3DLIGHT },
{ "SystemActiveBorder", COLOR_ACTIVEBORDER },
@@ -55,7 +55,7 @@ static SystemColorEntry sysColors[] = {
static void RegisterSystemColors(Tcl_Interp *interp)
{
Ttk_ResourceCache cache = Ttk_GetResourceCache(interp);
- SystemColorEntry *sysColor;
+ const SystemColorEntry *sysColor;
for (sysColor = sysColors; sysColor->name; ++sysColor) {
DWORD pixel = GetSysColor(sysColor->index);
@@ -70,29 +70,29 @@ static void RegisterSystemColors(Tcl_Interp *interp)
static HWND
CreateThemeMonitorWindow(HINSTANCE hinst, Tcl_Interp *interp)
{
- WNDCLASSEX wc;
+ WNDCLASSEXW wc;
HWND hwnd = NULL;
- TCHAR title[32] = TEXT("TtkMonitorWindow");
- TCHAR name[32] = TEXT("TtkMonitorClass");
+ WCHAR title[32] = L"TtkMonitorWindow";
+ WCHAR name[32] = L"TtkMonitorClass";
- wc.cbSize = sizeof(WNDCLASSEX);
+ wc.cbSize = sizeof(WNDCLASSEXW);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hinst;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hIcon = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
+ wc.hIconSm = LoadIconW(NULL, (LPCWSTR)IDI_APPLICATION);
+ wc.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszMenuName = name;
wc.lpszClassName = name;
- if (RegisterClassEx(&wc)) {
- hwnd = CreateWindow( name, title, WS_OVERLAPPEDWINDOW,
+ if (RegisterClassExW(&wc)) {
+ hwnd = CreateWindowW( name, title, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hinst, NULL );
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) interp);
+ SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) interp);
ShowWindow(hwnd, SW_HIDE);
UpdateWindow(hwnd);
}
@@ -109,7 +109,7 @@ DestroyThemeMonitorWindow(void *clientData)
static LRESULT WINAPI
WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
- Tcl_Interp *interp = (Tcl_Interp *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ Tcl_Interp *interp = (Tcl_Interp *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
Ttk_Theme theme;
switch (msg) {
@@ -137,7 +137,7 @@ WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
}
break;
}
- return DefWindowProc(hwnd, msg, wp, lp);
+ return DefWindowProcW(hwnd, msg, wp, lp);
}
/*
diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c
index 63e9704..7c3e45c 100644
--- a/win/ttkWinTheme.c
+++ b/win/ttkWinTheme.c
@@ -54,7 +54,7 @@ static unsigned int ReliefToEdge(int relief)
* +++ State tables for FrameControlElements.
*/
-static Ttk_StateTable checkbutton_statemap[] = { /* see also SF#1865898 */
+static const Ttk_StateTable checkbutton_statemap[] = { /* see also SF#1865898 */
{ DFCS_BUTTON3STATE|DFCS_CHECKED|DFCS_INACTIVE,
TTK_STATE_ALTERNATE|TTK_STATE_DISABLED, 0 },
{ DFCS_BUTTON3STATE|DFCS_CHECKED|DFCS_PUSHED,
@@ -75,14 +75,14 @@ static Ttk_StateTable checkbutton_statemap[] = { /* see also SF#1865898 */
{ 0, 0, 0 },
};
-static Ttk_StateTable pushbutton_statemap[] = {
+static const Ttk_StateTable pushbutton_statemap[] = {
{ DFCS_INACTIVE, TTK_STATE_DISABLED, 0 },
{ DFCS_PUSHED, TTK_STATE_PRESSED, 0 },
{ DFCS_HOT, TTK_STATE_ACTIVE, 0 },
{ 0, 0, 0 }
};
-static Ttk_StateTable arrow_statemap[] = {
+static const Ttk_StateTable arrow_statemap[] = {
{ DFCS_INACTIVE, TTK_STATE_DISABLED, 0 },
{ DFCS_PUSHED | DFCS_FLAT, TTK_STATE_PRESSED, 0 },
{ 0, 0, 0 }
@@ -96,20 +96,20 @@ typedef struct {
const char *name; /* element name */
int classId; /* class id for DrawFrameControl */
int partId; /* part id for DrawFrameControl */
- int cxId; /* system metric ids for width/height... */
- int cyId; /* ... or size if FIXEDSIZE bit set */
- Ttk_StateTable *stateMap; /* map Tk states to Win32 flags */
+ unsigned cxId; /* system metric ids for width/height... */
+ unsigned cyId; /* ... or size if FIXEDSIZE bit set */
+ const Ttk_StateTable *stateMap; /* map Tk states to Win32 flags */
Ttk_Padding margins; /* additional placement padding */
} FrameControlElementData;
-#define _FIXEDSIZE 0x80000000L
-#define _HALFMETRIC 0x40000000L
+#define _FIXEDSIZE 0x80000000UL
+#define _HALFMETRIC 0x40000000UL
#define FIXEDSIZE(id) (id|_FIXEDSIZE)
#define HALFMETRIC(id) (id|_HALFMETRIC)
#define GETMETRIC(m) \
- ((m) & _FIXEDSIZE ? (int)((m) & ~_FIXEDSIZE) : GetSystemMetrics((m)&0x0fffffff))
+ ((m) & _FIXEDSIZE ? (int)((m) & ~_FIXEDSIZE) : GetSystemMetrics((m)&0xFFFFFFF))
-static FrameControlElementData FrameControlElements[] = {
+static const FrameControlElementData FrameControlElements[] = {
{ "Checkbutton.indicator",
DFC_BUTTON, DFCS_BUTTONCHECK, FIXEDSIZE(13), FIXEDSIZE(13),
checkbutton_statemap, {0,0,4,0} },
@@ -147,9 +147,13 @@ static void FrameControlElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- FrameControlElementData *p = clientData;
+ FrameControlElementData *p = (FrameControlElementData *)clientData;
int cx = GETMETRIC(p->cxId);
int cy = GETMETRIC(p->cyId);
+ (void)elementRecord;
+ (void)tkwin;
+ (void)paddingPtr;
+
if (p->cxId & _HALFMETRIC) cx /= 2;
if (p->cyId & _HALFMETRIC) cy /= 2;
*widthPtr = cx + Ttk_PaddingWidth(p->margins);
@@ -160,10 +164,11 @@ static void FrameControlElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- FrameControlElementData *elementData = clientData;
+ FrameControlElementData *elementData = (FrameControlElementData *)clientData;
RECT rc = BoxToRect(Ttk_PadBox(b, elementData->margins));
TkWinDCState dcState;
HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
+ (void)elementRecord;
DrawFrameControl(hdc, &rc,
elementData->classId,
@@ -171,7 +176,7 @@ static void FrameControlElementDraw(
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
-static Ttk_ElementSpec FrameControlElementSpec = {
+static const Ttk_ElementSpec FrameControlElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
@@ -187,28 +192,36 @@ typedef struct {
Tcl_Obj *reliefObj;
} BorderElement;
-static Ttk_ElementOptionSpec BorderElementOptions[] = {
- { "-relief",TK_OPTION_RELIEF,Tk_Offset(BorderElement,reliefObj), "flat" },
- {NULL, 0, 0, NULL}
+static const Ttk_ElementOptionSpec BorderElementOptions[] = {
+ { "-relief",TK_OPTION_RELIEF, offsetof(BorderElement,reliefObj), "flat" },
+ {NULL, TK_OPTION_BOOLEAN, 0, NULL}
};
static void BorderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+
paddingPtr->left = paddingPtr->right = GetSystemMetrics(SM_CXEDGE);
paddingPtr->top = paddingPtr->bottom = GetSystemMetrics(SM_CYEDGE);
}
static void BorderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- BorderElement *border = elementRecord;
+ BorderElement *border = (BorderElement *)elementRecord;
RECT rc = BoxToRect(b);
int relief = TK_RELIEF_FLAT;
TkWinDCState dcState;
HDC hdc;
+ (void)dummy;
+ (void)state;
Tk_GetReliefFromObj(NULL, border->reliefObj, &relief);
@@ -220,7 +233,7 @@ static void BorderElementDraw(
}
}
-static Ttk_ElementSpec BorderElementSpec = {
+static const Ttk_ElementSpec BorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BorderElement),
BorderElementOptions,
@@ -237,29 +250,37 @@ typedef struct {
Tcl_Obj *backgroundObj;
} FieldElement;
-static Ttk_ElementOptionSpec FieldElementOptions[] = {
+static const Ttk_ElementOptionSpec FieldElementOptions[] = {
{ "-fieldbackground", TK_OPTION_BORDER,
- Tk_Offset(FieldElement,backgroundObj), "white" },
- { NULL, 0, 0, NULL }
+ offsetof(FieldElement,backgroundObj), "white" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void FieldElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+
paddingPtr->left = paddingPtr->right = GetSystemMetrics(SM_CXEDGE);
paddingPtr->top = paddingPtr->bottom = GetSystemMetrics(SM_CYEDGE);
}
static void FieldElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- FieldElement *field = elementRecord;
+ FieldElement *field = (FieldElement *)elementRecord;
Tk_3DBorder bg = Tk_Get3DBorderFromObj(tkwin, field->backgroundObj);
RECT rc = BoxToRect(b);
TkWinDCState dcState;
HDC hdc;
+ (void)dummy;
+ (void)state;
Tk_Fill3DRectangle(
tkwin, d, bg, b.x, b.y, b.width, b.height, 0, TK_RELIEF_FLAT);
@@ -269,7 +290,7 @@ static void FieldElementDraw(
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
-static Ttk_ElementSpec FieldElementSpec = {
+static const Ttk_ElementSpec FieldElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FieldElement),
FieldElementOptions,
@@ -288,24 +309,28 @@ typedef struct {
Tcl_Obj *defaultStateObj;
} ButtonBorderElement;
-static Ttk_ElementOptionSpec ButtonBorderElementOptions[] = {
+static const Ttk_ElementOptionSpec ButtonBorderElementOptions[] = {
{ "-relief",TK_OPTION_RELIEF,
- Tk_Offset(ButtonBorderElement,reliefObj), "flat" },
+ offsetof(ButtonBorderElement,reliefObj), "flat" },
{ "-highlightcolor",TK_OPTION_COLOR,
- Tk_Offset(ButtonBorderElement,highlightColorObj), "black" },
+ offsetof(ButtonBorderElement,highlightColorObj), "black" },
{ "-default", TK_OPTION_ANY,
- Tk_Offset(ButtonBorderElement,defaultStateObj), "disabled" },
- {NULL, 0, 0, NULL}
+ offsetof(ButtonBorderElement,defaultStateObj), "disabled" },
+ {NULL, TK_OPTION_BOOLEAN, 0, NULL}
};
static void ButtonBorderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ButtonBorderElement *bd = elementRecord;
+ ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord;
int relief = TK_RELIEF_RAISED;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
short int cx, cy;
+ (void)dummy;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
Tk_GetReliefFromObj(NULL, bd->reliefObj, &relief);
Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState);
@@ -327,15 +352,16 @@ static void ButtonBorderElementSize(
}
static void ButtonBorderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ButtonBorderElement *bd = elementRecord;
+ ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord;
int relief = TK_RELIEF_FLAT;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
TkWinDCState dcState;
HDC hdc;
RECT rc;
+ (void)dummy;
Tk_GetReliefFromObj(NULL, bd->reliefObj, &relief);
Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState);
@@ -367,7 +393,7 @@ static void ButtonBorderElementDraw(
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
-static Ttk_ElementSpec ButtonBorderElementSpec = {
+static const Ttk_ElementSpec ButtonBorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ButtonBorderElement),
ButtonBorderElementOptions,
@@ -381,16 +407,25 @@ static Ttk_ElementSpec ButtonBorderElementSpec = {
*/
static void FocusElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+
*paddingPtr = Ttk_UniformPadding(1);
}
static void FocusElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
+ (void)dummy;
+ (void)elementRecord;
+
if (state & TTK_STATE_FOCUS) {
RECT rc = BoxToRect(b);
TkWinDCState dcState;
@@ -400,7 +435,7 @@ static void FocusElementDraw(
}
}
-static Ttk_ElementSpec FocusElementSpec = {
+static const Ttk_ElementSpec FocusElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
@@ -416,18 +451,20 @@ typedef struct {
Tcl_Obj *fillColorObj;
} FillFocusElement;
-static Ttk_ElementOptionSpec FillFocusElementOptions[] = {
+static const Ttk_ElementOptionSpec FillFocusElementOptions[] = {
{ "-focusfill", TK_OPTION_COLOR,
- Tk_Offset(FillFocusElement,fillColorObj), "white" },
- {NULL, 0, 0, NULL}
+ offsetof(FillFocusElement,fillColorObj), "white" },
+ {NULL, TK_OPTION_BOOLEAN, 0, NULL}
};
/* @@@ FIX THIS */
static void FillFocusElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- FillFocusElement *focus = elementRecord;
+ FillFocusElement *focus = (FillFocusElement *)elementRecord;
+ (void)dummy;
+
if (state & TTK_STATE_FOCUS) {
RECT rc = BoxToRect(b);
TkWinDCState dcState;
@@ -455,7 +492,7 @@ static void ComboboxFocusElementDraw(
}
}
-static Ttk_ElementSpec ComboboxFocusElementSpec = {
+static const Ttk_ElementSpec ComboboxFocusElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FillFocusElement),
FillFocusElementOptions,
@@ -482,7 +519,7 @@ static const WORD Pattern[] = {
static void TroughClientDataDeleteProc(void *clientData)
{
- TroughClientData *cd = clientData;
+ TroughClientData *cd = (TroughClientData *)clientData;
DeleteObject(cd->PatternBrush);
DeleteObject(cd->PatternBitmap);
ckfree(clientData);
@@ -490,7 +527,7 @@ static void TroughClientDataDeleteProc(void *clientData)
static TroughClientData *TroughClientDataInit(Tcl_Interp *interp)
{
- TroughClientData *cd = ckalloc(sizeof(*cd));
+ TroughClientData *cd = (TroughClientData *)ckalloc(sizeof(*cd));
cd->PatternBitmap = CreateBitmap(8, 8, 1, 1, Pattern);
cd->PatternBrush = CreatePatternBrush(cd->PatternBitmap);
Ttk_RegisterCleanup(interp, cd, TroughClientDataDeleteProc);
@@ -501,13 +538,15 @@ static void TroughElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- TroughClientData *cd = clientData;
+ TroughClientData *cd = (TroughClientData *)clientData;
TkWinDCState dcState;
HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
HBRUSH hbr;
COLORREF bk, oldbk, oldtxt;
+ (void)elementRecord;
+ (void)state;
- hbr = SelectObject(hdc, GetSysColorBrush(COLOR_SCROLLBAR));
+ hbr = (HBRUSH)SelectObject(hdc, GetSysColorBrush(COLOR_SCROLLBAR));
bk = GetSysColor(COLOR_3DHIGHLIGHT);
oldtxt = SetTextColor(hdc, GetSysColor(COLOR_3DFACE));
oldbk = SetBkColor(hdc, bk);
@@ -525,7 +564,7 @@ static void TroughElementDraw(
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
-static Ttk_ElementSpec TroughElementSpec = {
+static const Ttk_ElementSpec TroughElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
@@ -541,19 +580,22 @@ typedef struct {
Tcl_Obj *orientObj;
} ThumbElement;
-static Ttk_ElementOptionSpec ThumbElementOptions[] = {
- { "-orient", TK_OPTION_ANY,Tk_Offset(ThumbElement,orientObj),"horizontal"},
- { NULL, 0, 0, NULL }
+static const Ttk_ElementOptionSpec ThumbElementOptions[] = {
+ { "-orient", TK_OPTION_ANY, offsetof(ThumbElement,orientObj),"horizontal"},
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void ThumbElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ThumbElement *thumbPtr = elementRecord;
- int orient;
+ ThumbElement *thumbPtr = (ThumbElement *)elementRecord;
+ Ttk_Orient orient;
+ (void)dummy;
+ (void)tkwin;
+ (void)paddingPtr;
- Ttk_GetOrientFromObj(NULL, thumbPtr->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, thumbPtr->orientObj, &orient);
if (orient == TTK_ORIENT_HORIZONTAL) {
*widthPtr = GetSystemMetrics(SM_CXHTHUMB);
*heightPtr = GetSystemMetrics(SM_CYHSCROLL);
@@ -564,12 +606,14 @@ static void ThumbElementSize(
}
static void ThumbElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
RECT rc = BoxToRect(b);
TkWinDCState dcState;
HDC hdc;
+ (void)dummy;
+ (void)elementRecord;
/* Windows doesn't show a thumb when the scrollbar is disabled */
if (state & TTK_STATE_DISABLED)
@@ -580,7 +624,7 @@ static void ThumbElementDraw(
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
-static Ttk_ElementSpec ThumbElementSpec = {
+static const Ttk_ElementSpec ThumbElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ThumbElement),
ThumbElementOptions,
@@ -597,20 +641,23 @@ typedef struct {
Tcl_Obj *orientObj; /* orientation of the slider widget */
} SliderElement;
-static Ttk_ElementOptionSpec SliderElementOptions[] = {
- { "-orient", TK_OPTION_ANY, Tk_Offset(SliderElement,orientObj),
+static const Ttk_ElementOptionSpec SliderElementOptions[] = {
+ { "-orient", TK_OPTION_ANY, offsetof(SliderElement,orientObj),
"horizontal" },
- { NULL, 0, 0, NULL }
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void SliderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- SliderElement *slider = elementRecord;
- int orient;
+ SliderElement *slider = (SliderElement *)elementRecord;
+ Ttk_Orient orient;
+ (void)dummy;
+ (void)tkwin;
+ (void)paddingPtr;
- Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
if (orient == TTK_ORIENT_HORIZONTAL) {
*widthPtr = (GetSystemMetrics(SM_CXHTHUMB) / 2) | 1;
*heightPtr = GetSystemMetrics(SM_CYHSCROLL);
@@ -621,19 +668,22 @@ static void SliderElementSize(
}
static void SliderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
RECT rc = BoxToRect(b);
TkWinDCState dcState;
HDC hdc;
+ (void)dummy;
+ (void)elementRecord;
+ (void)state;
hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | BF_MIDDLE);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
-static Ttk_ElementSpec SliderElementSpec = {
+static const Ttk_ElementSpec SliderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SliderElement),
SliderElementOptions,
@@ -646,25 +696,35 @@ static Ttk_ElementSpec SliderElementSpec = {
*/
static void ClientElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+
paddingPtr->left = paddingPtr->right = GetSystemMetrics(SM_CXEDGE);
paddingPtr->top = paddingPtr->bottom = GetSystemMetrics(SM_CYEDGE);
}
static void ClientElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
RECT rc = BoxToRect(b);
TkWinDCState dcState;
HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
+ (void)dummy;
+ (void)elementRecord;
+ (void)state;
+
DrawEdge(hdc, &rc, EDGE_RAISED, BF_RECT | BF_SOFT);
TkWinReleaseDrawableDC(d, hdc, &dcState);
}
-static Ttk_ElementSpec ClientElementSpec = {
+static const Ttk_ElementSpec ClientElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
@@ -698,7 +758,8 @@ MODULE_SCOPE
int TtkWinTheme_Init(Tcl_Interp *interp, HWND hwnd)
{
Ttk_Theme themePtr, parentPtr;
- FrameControlElementData *fce = FrameControlElements;
+ const FrameControlElementData *fce = FrameControlElements;
+ (void)hwnd;
parentPtr = Ttk_GetTheme(interp, "alt");
themePtr = Ttk_CreateTheme(interp, "winnative", parentPtr);
@@ -722,7 +783,7 @@ int TtkWinTheme_Init(Tcl_Interp *interp, HWND hwnd)
for (fce = FrameControlElements; fce->name != 0; ++fce) {
Ttk_RegisterElementSpec(themePtr, fce->name,
- &FrameControlElementSpec, fce);
+ &FrameControlElementSpec, (void *)fce);
}
Ttk_RegisterLayouts(themePtr, LayoutTable);
diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c
index 4f822a7..fec0450 100644
--- a/win/ttkWinXPTheme.c
+++ b/win/ttkWinXPTheme.c
@@ -95,16 +95,16 @@ LoadXPThemeProcs(HINSTANCE *phlib)
* if we are running at least on Windows XP.
*/
HINSTANCE handle;
- *phlib = handle = LoadLibrary(TEXT("uxtheme.dll"));
+ *phlib = handle = LoadLibraryW(L"uxtheme.dll");
if (handle != 0)
{
/*
* We have successfully loaded the library. Proceed in storing the
* addresses of the functions we want to use.
*/
- XPThemeProcs *procs = ckalloc(sizeof(XPThemeProcs));
+ XPThemeProcs *procs = (XPThemeProcs *)ckalloc(sizeof(XPThemeProcs));
#define LOADPROC(name) \
- (0 != (procs->name = (name ## Proc *)GetProcAddress(handle, #name) ))
+ (0 != (procs->name = (name ## Proc *)(void *)GetProcAddress(handle, #name) ))
if ( LOADPROC(OpenThemeData)
&& LOADPROC(CloseThemeData)
@@ -134,7 +134,7 @@ LoadXPThemeProcs(HINSTANCE *phlib)
static void
XPThemeDeleteProc(void *clientData)
{
- XPThemeData *themeData = clientData;
+ XPThemeData *themeData = (XPThemeData *)clientData;
FreeLibrary(themeData->hlibrary);
ckfree(clientData);
}
@@ -142,9 +142,11 @@ XPThemeDeleteProc(void *clientData)
static int
XPThemeEnabled(Ttk_Theme theme, void *clientData)
{
- XPThemeData *themeData = clientData;
+ XPThemeData *themeData = (XPThemeData *)clientData;
int active = themeData->procs->IsThemeActive();
int themed = themeData->procs->IsAppThemed();
+ (void)theme;
+
return (active && themed);
}
@@ -166,12 +168,12 @@ BoxToRect(Ttk_Box b)
/*
* Map Tk state bitmaps to XP style enumerated values.
*/
-static Ttk_StateTable null_statemap[] = { {0,0,0} };
+static const Ttk_StateTable null_statemap[] = { {0,0,0} };
/*
* Pushbuttons (Tk: "Button")
*/
-static Ttk_StateTable pushbutton_statemap[] =
+static const Ttk_StateTable pushbutton_statemap[] =
{
{ PBS_DISABLED, TTK_STATE_DISABLED, 0 },
{ PBS_PRESSED, TTK_STATE_PRESSED, 0 },
@@ -183,7 +185,7 @@ static Ttk_StateTable pushbutton_statemap[] =
/*
* Checkboxes (Tk: "Checkbutton")
*/
-static Ttk_StateTable checkbox_statemap[] =
+static const Ttk_StateTable checkbox_statemap[] =
{
{CBS_MIXEDDISABLED, TTK_STATE_ALTERNATE|TTK_STATE_DISABLED, 0},
{CBS_MIXEDPRESSED, TTK_STATE_ALTERNATE|TTK_STATE_PRESSED, 0},
@@ -202,7 +204,7 @@ static Ttk_StateTable checkbox_statemap[] =
/*
* Radiobuttons:
*/
-static Ttk_StateTable radiobutton_statemap[] =
+static const Ttk_StateTable radiobutton_statemap[] =
{
{RBS_UNCHECKEDDISABLED, TTK_STATE_ALTERNATE|TTK_STATE_DISABLED, 0},
{RBS_UNCHECKEDNORMAL, TTK_STATE_ALTERNATE, 0},
@@ -219,7 +221,7 @@ static Ttk_StateTable radiobutton_statemap[] =
/*
* Groupboxes (tk: "frame")
*/
-static Ttk_StateTable groupbox_statemap[] =
+static const Ttk_StateTable groupbox_statemap[] =
{
{GBS_DISABLED, TTK_STATE_DISABLED, 0},
{GBS_NORMAL, 0,0 }
@@ -228,7 +230,7 @@ static Ttk_StateTable groupbox_statemap[] =
/*
* Edit fields (tk: "entry")
*/
-static Ttk_StateTable edittext_statemap[] =
+static const Ttk_StateTable edittext_statemap[] =
{
{ ETS_DISABLED, TTK_STATE_DISABLED, 0 },
{ ETS_READONLY, TTK_STATE_READONLY, 0 },
@@ -243,7 +245,7 @@ static Ttk_StateTable edittext_statemap[] =
* Same as edittext_statemap, but doesn't use ETS_READONLY
* (fixes: #1032409)
*/
-static Ttk_StateTable combotext_statemap[] =
+static const Ttk_StateTable combotext_statemap[] =
{
{ ETS_DISABLED, TTK_STATE_DISABLED, 0 },
{ ETS_FOCUSED, TTK_STATE_FOCUS, 0 },
@@ -254,7 +256,7 @@ static Ttk_StateTable combotext_statemap[] =
/*
* Combobox button: (CBP_DROPDOWNBUTTON)
*/
-static Ttk_StateTable combobox_statemap[] = {
+static const Ttk_StateTable combobox_statemap[] = {
{ CBXS_DISABLED, TTK_STATE_DISABLED, 0 },
{ CBXS_PRESSED, TTK_STATE_PRESSED, 0 },
{ CBXS_HOT, TTK_STATE_ACTIVE, 0 },
@@ -265,7 +267,7 @@ static Ttk_StateTable combobox_statemap[] = {
/*
* Toolbar buttons (TP_BUTTON):
*/
-static Ttk_StateTable toolbutton_statemap[] = {
+static const Ttk_StateTable toolbutton_statemap[] = {
{ TS_DISABLED, TTK_STATE_DISABLED, 0 },
{ TS_PRESSED, TTK_STATE_PRESSED, 0 },
{ TS_HOTCHECKED, TTK_STATE_SELECTED|TTK_STATE_ACTIVE, 0 },
@@ -277,7 +279,7 @@ static Ttk_StateTable toolbutton_statemap[] = {
/*
* Scrollbars (Tk: "Scrollbar.thumb")
*/
-static Ttk_StateTable scrollbar_statemap[] =
+static const Ttk_StateTable scrollbar_statemap[] =
{
{ SCRBS_DISABLED, TTK_STATE_DISABLED, 0 },
{ SCRBS_PRESSED, TTK_STATE_PRESSED, 0 },
@@ -285,7 +287,7 @@ static Ttk_StateTable scrollbar_statemap[] =
{ SCRBS_NORMAL, 0, 0 }
};
-static Ttk_StateTable uparrow_statemap[] =
+static const Ttk_StateTable uparrow_statemap[] =
{
{ ABS_UPDISABLED, TTK_STATE_DISABLED, 0 },
{ ABS_UPPRESSED, TTK_STATE_PRESSED, 0 },
@@ -293,7 +295,7 @@ static Ttk_StateTable uparrow_statemap[] =
{ ABS_UPNORMAL, 0, 0 }
};
-static Ttk_StateTable downarrow_statemap[] =
+static const Ttk_StateTable downarrow_statemap[] =
{
{ ABS_DOWNDISABLED, TTK_STATE_DISABLED, 0 },
{ ABS_DOWNPRESSED, TTK_STATE_PRESSED, 0 },
@@ -301,7 +303,7 @@ static Ttk_StateTable downarrow_statemap[] =
{ ABS_DOWNNORMAL, 0, 0 }
};
-static Ttk_StateTable leftarrow_statemap[] =
+static const Ttk_StateTable leftarrow_statemap[] =
{
{ ABS_LEFTDISABLED, TTK_STATE_DISABLED, 0 },
{ ABS_LEFTPRESSED, TTK_STATE_PRESSED, 0 },
@@ -309,7 +311,7 @@ static Ttk_StateTable leftarrow_statemap[] =
{ ABS_LEFTNORMAL, 0, 0 }
};
-static Ttk_StateTable rightarrow_statemap[] =
+static const Ttk_StateTable rightarrow_statemap[] =
{
{ ABS_RIGHTDISABLED,TTK_STATE_DISABLED, 0 },
{ ABS_RIGHTPRESSED, TTK_STATE_PRESSED, 0 },
@@ -317,7 +319,7 @@ static Ttk_StateTable rightarrow_statemap[] =
{ ABS_RIGHTNORMAL, 0, 0 }
};
-static Ttk_StateTable spinbutton_statemap[] =
+static const Ttk_StateTable spinbutton_statemap[] =
{
{ DNS_DISABLED, TTK_STATE_DISABLED, 0 },
{ DNS_PRESSED, TTK_STATE_PRESSED, 0 },
@@ -328,7 +330,7 @@ static Ttk_StateTable spinbutton_statemap[] =
/*
* Trackbar thumb: (Tk: "scale slider")
*/
-static Ttk_StateTable scale_statemap[] =
+static const Ttk_StateTable scale_statemap[] =
{
{ TUS_DISABLED, TTK_STATE_DISABLED, 0 },
{ TUS_PRESSED, TTK_STATE_PRESSED, 0 },
@@ -337,7 +339,7 @@ static Ttk_StateTable scale_statemap[] =
{ TUS_NORMAL, 0, 0 }
};
-static Ttk_StateTable tabitem_statemap[] =
+static const Ttk_StateTable tabitem_statemap[] =
{
{ TIS_DISABLED, TTK_STATE_DISABLED, 0 },
{ TIS_SELECTED, TTK_STATE_SELECTED, 0 },
@@ -372,18 +374,18 @@ static Ttk_StateTable tabitem_statemap[] =
typedef struct /* XP element specifications */
{
const char *elementName; /* Tk theme engine element name */
- Ttk_ElementSpec *elementSpec;
+ const Ttk_ElementSpec *elementSpec;
/* Element spec (usually GenericElementSpec) */
LPCWSTR className; /* Windows window class name */
int partId; /* BP_PUSHBUTTON, BP_CHECKBUTTON, etc. */
- Ttk_StateTable *statemap; /* Map Tk states to XP states */
+ const Ttk_StateTable *statemap; /* Map Tk states to XP states */
Ttk_Padding padding; /* See NOTE-GetThemeMargins */
- int flags;
-# define IGNORE_THEMESIZE 0x80000000 /* See NOTE-GetThemePartSize */
-# define PAD_MARGINS 0x40000000 /* See NOTE-GetThemeMargins */
-# define HEAP_ELEMENT 0x20000000 /* ElementInfo is on heap */
-# define HALF_HEIGHT 0x10000000 /* Used by GenericSizedElements */
-# define HALF_WIDTH 0x08000000 /* Used by GenericSizedElements */
+ unsigned flags;
+# define IGNORE_THEMESIZE 0x80000000U /* See NOTE-GetThemePartSize */
+# define PAD_MARGINS 0x40000000U /* See NOTE-GetThemeMargins */
+# define HEAP_ELEMENT 0x20000000U /* ElementInfo is on heap */
+# define HALF_HEIGHT 0x10000000U /* Used by GenericSizedElements */
+# define HALF_WIDTH 0x08000000U /* Used by GenericSizedElements */
} ElementInfo;
typedef struct
@@ -391,7 +393,7 @@ typedef struct
/*
* Static data, initialized when element is registered:
*/
- ElementInfo *info;
+ const ElementInfo *info;
XPThemeProcs *procs; /* Pointer to theme procedure table */
/*
@@ -407,9 +409,9 @@ typedef struct
} ElementData;
static ElementData *
-NewElementData(XPThemeProcs *procs, ElementInfo *info)
+NewElementData(XPThemeProcs *procs, const ElementInfo *info)
{
- ElementData *elementData = ckalloc(sizeof(ElementData));
+ ElementData *elementData = (ElementData *)ckalloc(sizeof(ElementData));
elementData->procs = procs;
elementData->info = info;
@@ -425,12 +427,12 @@ NewElementData(XPThemeProcs *procs, ElementInfo *info)
*/
static void DestroyElementData(void *clientData)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
if (elementData->info->flags & HEAP_ELEMENT) {
- ckfree(elementData->info->statemap);
+ ckfree((char *)elementData->info->statemap);
ckfree((char *)elementData->info->className);
ckfree((char *)elementData->info->elementName);
- ckfree(elementData->info);
+ ckfree((char *)elementData->info);
}
ckfree(clientData);
}
@@ -451,7 +453,7 @@ InitElementData(ElementData *elementData, Tk_Window tkwin, Drawable d)
{
Window win = Tk_WindowId(tkwin);
- if (win != None) {
+ if (win) {
elementData->hwnd = Tk_GetHWND(win);
} else {
elementData->hwnd = elementData->procs->stubWindow;
@@ -493,9 +495,10 @@ static void GenericElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
HRESULT result;
SIZE size;
+ (void)elementRecord;
if (!InitElementData(elementData, tkwin, 0))
return;
@@ -529,8 +532,9 @@ static void GenericElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
RECT rc;
+ (void)elementRecord;
if (!InitElementData(elementData, tkwin, d)) {
return;
@@ -552,7 +556,7 @@ static void GenericElementDraw(
FreeElementData(elementData);
}
-static Ttk_ElementSpec GenericElementSpec =
+static const Ttk_ElementSpec GenericElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -574,7 +578,7 @@ GenericSizedElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
if (!InitElementData(elementData, tkwin, 0))
return;
@@ -592,7 +596,7 @@ GenericSizedElementSize(
*widthPtr /= 2;
}
-static Ttk_ElementSpec GenericSizedElementSpec = {
+static const Ttk_ElementSpec GenericSizedElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
@@ -610,7 +614,7 @@ SpinboxArrowElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
if (!InitElementData(elementData, tkwin, 0))
return;
@@ -622,7 +626,7 @@ SpinboxArrowElementSize(
*heightPtr /= 2;
}
-static Ttk_ElementSpec SpinboxArrowElementSpec = {
+static const Ttk_ElementSpec SpinboxArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(NullElement),
TtkNullElementOptions,
@@ -639,9 +643,10 @@ static void ThumbElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
unsigned stateId = Ttk_StateTableLookup(elementData->info->statemap, state);
RECT rc = BoxToRect(b);
+ (void)elementRecord;
/*
* Don't draw the thumb if we are disabled.
@@ -659,7 +664,7 @@ static void ThumbElementDraw(
FreeElementData(elementData);
}
-static Ttk_ElementSpec ThumbElementSpec =
+static const Ttk_ElementSpec ThumbElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -678,7 +683,7 @@ static void PbarElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
int nBars = 3;
GenericElementSize(clientData, elementRecord, tkwin,
@@ -691,7 +696,7 @@ static void PbarElementSize(
}
}
-static Ttk_ElementSpec PbarElementSpec =
+static const Ttk_ElementSpec PbarElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -718,9 +723,10 @@ static void TabElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ElementData *elementData = clientData;
+ ElementData *elementData = (ElementData *)clientData;
int partId = elementData->info->partId;
RECT rc = BoxToRect(b);
+ (void)elementRecord;
if (!InitElementData(elementData, tkwin, d))
return;
@@ -732,7 +738,7 @@ static void TabElementDraw(
FreeElementData(elementData);
}
-static Ttk_ElementSpec TabElementSpec =
+static const Ttk_ElementSpec TabElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -750,14 +756,14 @@ static Ttk_ElementSpec TabElementSpec =
#define TTK_STATE_OPEN TTK_STATE_USER1
#define TTK_STATE_LEAF TTK_STATE_USER2
-static Ttk_StateTable header_statemap[] =
+static const Ttk_StateTable header_statemap[] =
{
{ HIS_PRESSED, TTK_STATE_PRESSED, 0 },
{ HIS_HOT, TTK_STATE_ACTIVE, 0 },
{ HIS_NORMAL, 0,0 },
};
-static Ttk_StateTable treeview_statemap[] =
+static const Ttk_StateTable treeview_statemap[] =
{
{ TREIS_DISABLED, TTK_STATE_DISABLED, 0 },
{ TREIS_SELECTED, TTK_STATE_SELECTED, 0},
@@ -765,7 +771,7 @@ static Ttk_StateTable treeview_statemap[] =
{ TREIS_NORMAL, 0,0 },
};
-static Ttk_StateTable tvpglyph_statemap[] =
+static const Ttk_StateTable tvpglyph_statemap[] =
{
{ GLPS_OPENED, TTK_STATE_OPEN, 0 },
{ GLPS_CLOSED, 0,0 },
@@ -780,7 +786,7 @@ static void TreeIndicatorElementDraw(
}
}
-static Ttk_ElementSpec TreeIndicatorElementSpec =
+static const Ttk_ElementSpec TreeIndicatorElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -808,12 +814,12 @@ typedef struct
Tcl_Obj *fontObj;
} TextElement;
-static Ttk_ElementOptionSpec TextElementOptions[] =
+static const Ttk_ElementOptionSpec TextElementOptions[] =
{
{ "-text", TK_OPTION_STRING,
- Tk_Offset(TextElement,textObj), "" },
+ offsetof(TextElement,textObj), "" },
{ "-font", TK_OPTION_FONT,
- Tk_Offset(TextElement,fontObj), DEFAULT_FONT },
+ offsetof(TextElement,fontObj), DEFAULT_FONT },
{ NULL }
};
@@ -825,16 +831,21 @@ static void TextElementSize(
ElementData *elementData = clientData;
RECT rc = {0, 0};
HRESULT hr = S_OK;
+ const char *src;
+ TkSizeT len;
+ Tcl_DString ds;
if (!InitElementData(elementData, tkwin, 0))
return;
+ src = TkGetStringFromObj(element->textObj, &len);
+ Tcl_DStringInit(&ds);
hr = elementData->procs->GetThemeTextExtent(
elementData->hTheme,
elementData->hDC,
elementData->info->partId,
Ttk_StateTableLookup(elementData->info->statemap, 0),
- Tcl_GetUnicode(element->textObj),
+ Tcl_UtfToWCharDString(src, len, &ds),
-1,
DT_LEFT,// | DT_BOTTOM | DT_NOPREFIX,
NULL,
@@ -847,6 +858,7 @@ static void TextElementSize(
if (*widthPtr < 80) *widthPtr = 80;
if (*heightPtr < 20) *heightPtr = 20;
+ Tcl_DStringFree(&ds);
FreeElementData(elementData);
}
@@ -858,24 +870,31 @@ static void TextElementDraw(
ElementData *elementData = clientData;
RECT rc = BoxToRect(b);
HRESULT hr = S_OK;
+ const char *src;
+ TkSizeT len;
+ Tcl_DString ds;
if (!InitElementData(elementData, tkwin, d))
return;
+ src = TkGetStringFromObj(element->textObj, &len);
+ Tcl_DStringInit(&ds);
hr = elementData->procs->DrawThemeText(
elementData->hTheme,
elementData->hDC,
elementData->info->partId,
Ttk_StateTableLookup(elementData->info->statemap, state),
- Tcl_GetUnicode(element->textObj),
+ Tcl_UtfToWCharDString(src, len, &ds),
-1,
DT_LEFT,// | DT_BOTTOM | DT_NOPREFIX,
(state & TTK_STATE_DISABLED) ? DTT_GRAYED : 0,
&rc);
+
+ Tcl_DStringFree(&ds);
FreeElementData(elementData);
}
-static Ttk_ElementSpec TextElementSpec =
+static const Ttk_ElementSpec TextElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(TextElement),
@@ -941,7 +960,7 @@ TTK_END_LAYOUT_TABLE
/* name spec className partId statemap padding flags */
-static ElementInfo ElementInfoTable[] = {
+static const ElementInfo ElementInfoTable[] = {
{ "Checkbutton.indicator", &GenericElementSpec, L"BUTTON",
BP_CHECKBOX, checkbox_statemap, PAD(0, 0, 4, 0), PAD_MARGINS },
{ "Radiobutton.indicator", &GenericElementSpec, L"BUTTON",
@@ -1012,7 +1031,7 @@ static ElementInfo ElementInfoTable[] = {
{ "Menubutton.dropdown", &GenericElementSpec, L"TOOLBAR",
TP_SPLITBUTTONDROPDOWN,toolbutton_statemap, NOPAD,0 },
{ "Treeview.field", &GenericElementSpec, L"TREEVIEW",
- TVP_TREEITEM, treeview_statemap, PAD(1, 1, 1, 1), 0 },
+ TVP_TREEITEM, treeview_statemap, PAD(1, 1, 1, 1), IGNORE_THEMESIZE },
{ "Treeitem.indicator", &TreeIndicatorElementSpec, L"TREEVIEW",
TVP_GLYPH, tvpglyph_statemap, PAD(1,1,6,0), PAD_MARGINS },
{ "Treeheading.border", &GenericElementSpec, L"HEADER",
@@ -1041,11 +1060,11 @@ static ElementInfo ElementInfoTable[] = {
static int
GetSysFlagFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr)
{
- static const char *names[] = {
+ static const char *const names[] = {
"SM_CXBORDER", "SM_CYBORDER", "SM_CXVSCROLL", "SM_CYVSCROLL",
"SM_CXHSCROLL", "SM_CYHSCROLL", "SM_CXMENUCHECK", "SM_CYMENUCHECK",
"SM_CXMENUSIZE", "SM_CYMENUSIZE", "SM_CXSIZE", "SM_CYSIZE", "SM_CXSMSIZE",
- "SM_CYSMSIZE"
+ "SM_CYSMSIZE", NULL
};
int flags[] = {
SM_CXBORDER, SM_CYBORDER, SM_CXVSCROLL, SM_CYVSCROLL,
@@ -1095,18 +1114,19 @@ Ttk_CreateVsapiElement(
int objc,
Tcl_Obj *const objv[])
{
- XPThemeData *themeData = clientData;
+ XPThemeData *themeData = (XPThemeData *)clientData;
ElementInfo *elementPtr = NULL;
ClientData elementData;
- Tcl_UniChar *className;
+ LPCWSTR className;
int partId = 0;
Ttk_StateTable *stateTable;
Ttk_Padding pad = {0, 0, 0, 0};
int flags = 0;
- int length = 0;
+ TkSizeT length = 0;
char *name;
LPWSTR wname;
- Ttk_ElementSpec *elementSpec = &GenericElementSpec;
+ const Ttk_ElementSpec *elementSpec = &GenericElementSpec;
+ Tcl_DString classBuf;
static const char *const optionStrings[] =
{ "-padding","-width","-height","-margins", "-syssize",
@@ -1124,7 +1144,9 @@ Ttk_CreateVsapiElement(
if (Tcl_GetIntFromObj(interp, objv[1], &partId) != TCL_OK) {
return TCL_ERROR;
}
- className = Tcl_GetUnicodeFromObj(objv[0], &length);
+ name = TkGetStringFromObj(objv[0], &length);
+ Tcl_DStringInit(&classBuf);
+ className = Tcl_UtfToWCharDString(name, length, &classBuf);
/* flags or padding */
if (objc > 3) {
@@ -1136,54 +1158,54 @@ Ttk_CreateVsapiElement(
"Missing value for \"%s\".",
Tcl_GetString(objv[i])));
Tcl_SetErrorCode(interp, "TTK", "VSAPI", "MISSING", NULL);
- return TCL_ERROR;
+ goto retErr;
}
if (Tcl_GetIndexFromObjStruct(interp, objv[i], optionStrings,
sizeof(char *), "option", 0, &option) != TCL_OK)
- return TCL_ERROR;
+ goto retErr;
switch (option) {
case O_PADDING:
if (Ttk_GetBorderFromObj(interp, objv[i+1], &pad) != TCL_OK) {
- return TCL_ERROR;
+ goto retErr;
}
break;
case O_MARGINS:
if (Ttk_GetBorderFromObj(interp, objv[i+1], &pad) != TCL_OK) {
- return TCL_ERROR;
+ goto retErr;
}
flags |= PAD_MARGINS;
break;
case O_WIDTH:
if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
- return TCL_ERROR;
+ goto retErr;
}
pad.left = pad.right = tmp;
flags |= IGNORE_THEMESIZE;
break;
case O_HEIGHT:
if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
- return TCL_ERROR;
+ goto retErr;
}
pad.top = pad.bottom = tmp;
flags |= IGNORE_THEMESIZE;
break;
case O_SYSSIZE:
if (GetSysFlagFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
- return TCL_ERROR;
+ goto retErr;
}
elementSpec = &GenericSizedElementSpec;
flags |= (tmp & 0xFFFF);
break;
case O_HALFHEIGHT:
if (Tcl_GetBooleanFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
- return TCL_ERROR;
+ goto retErr;
}
if (tmp)
flags |= HALF_HEIGHT;
break;
case O_HALFWIDTH:
if (Tcl_GetBooleanFromObj(interp, objv[i+1], &tmp) != TCL_OK) {
- return TCL_ERROR;
+ goto retErr;
}
if (tmp)
flags |= HALF_WIDTH;
@@ -1197,9 +1219,9 @@ Ttk_CreateVsapiElement(
Tcl_Obj **specs;
int n,j,count, status = TCL_OK;
if (Tcl_ListObjGetElements(interp, objv[2], &count, &specs) != TCL_OK)
- return TCL_ERROR;
+ goto retErr;
/* we over-allocate to ensure there is a terminating entry */
- stateTable = ckalloc(sizeof(Ttk_StateTable) * (count + 1));
+ stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable) * (count + 1));
memset(stateTable, 0, sizeof(Ttk_StateTable) * (count + 1));
for (n = 0, j = 0; status == TCL_OK && n < count; n += 2, ++j) {
Ttk_StateSpec spec = {0,0};
@@ -1213,14 +1235,15 @@ Ttk_CreateVsapiElement(
}
if (status != TCL_OK) {
ckfree(stateTable);
+ Tcl_DStringFree(&classBuf);
return status;
}
} else {
- stateTable = ckalloc(sizeof(Ttk_StateTable));
+ stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable));
memset(stateTable, 0, sizeof(Ttk_StateTable));
}
- elementPtr = ckalloc(sizeof(ElementInfo));
+ elementPtr = (ElementInfo *)ckalloc(sizeof(ElementInfo));
elementPtr->elementSpec = elementSpec;
elementPtr->partId = partId;
elementPtr->statemap = stateTable;
@@ -1228,12 +1251,12 @@ Ttk_CreateVsapiElement(
elementPtr->flags = HEAP_ELEMENT | flags;
/* set the element name to an allocated copy */
- name = ckalloc(strlen(elementName) + 1);
+ name = (char *)ckalloc(strlen(elementName) + 1);
strcpy(name, elementName);
elementPtr->elementName = name;
/* set the class name to an allocated copy */
- wname = ckalloc(sizeof(WCHAR) * (length + 1));
+ wname = (LPWSTR)ckalloc(Tcl_DStringLength(&classBuf) + sizeof(WCHAR));
wcscpy(wname, className);
elementPtr->className = wname;
@@ -1243,7 +1266,12 @@ Ttk_CreateVsapiElement(
Ttk_RegisterCleanup(interp, elementData, DestroyElementData);
Tcl_SetObjResult(interp, Tcl_NewStringObj(elementName, -1));
+ Tcl_DStringFree(&classBuf);
return TCL_OK;
+
+retErr:
+ Tcl_DStringFree(&classBuf);
+ return TCL_ERROR;
}
/*----------------------------------------------------------------------
@@ -1256,11 +1284,7 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd)
XPThemeProcs *procs;
HINSTANCE hlibrary;
Ttk_Theme themePtr, parentPtr, vistaPtr;
- ElementInfo *infoPtr;
- OSVERSIONINFOW os;
-
- os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
- GetVersionExW(&os);
+ const ElementInfo *infoPtr;
procs = LoadXPThemeProcs(&hlibrary);
if (!procs)
@@ -1280,7 +1304,7 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd)
* Set theme data and cleanup proc
*/
- themeData = ckalloc(sizeof(XPThemeData));
+ themeData = (XPThemeData *)ckalloc(sizeof(XPThemeData));
themeData->procs = procs;
themeData->hlibrary = hlibrary;
@@ -1293,7 +1317,7 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd)
* enable function. The theme itself is defined in script.
*/
- if (os.dwPlatformId == VER_PLATFORM_WIN32_NT && os.dwMajorVersion > 5) {
+ if (TkWinGetPlatformTheme() == TK_THEME_WIN_VISTA) {
vistaPtr = Ttk_CreateTheme(interp, "vista", themePtr);
if (vistaPtr) {
Ttk_SetThemeEnabledProc(vistaPtr, XPThemeEnabled, themeData);
diff --git a/win/winMain.c b/win/winMain.c
index f1d671f..c3ec364 100644
--- a/win/winMain.c
+++ b/win/winMain.c
@@ -25,7 +25,13 @@ int _CRT_glob = 0;
#endif /* __GNUC__ */
#ifdef TK_TEST
+#ifdef __cplusplus
+extern "C" {
+#endif
extern Tcl_PackageInitProc Tktest_Init;
+#ifdef __cplusplus
+}
+#endif
#endif /* TK_TEST */
#if defined(STATIC_BUILD) && TCL_USE_STATIC_PACKAGES
@@ -106,6 +112,10 @@ _tWinMain(
TCHAR **argv;
int argc;
TCHAR *p;
+ (void)hInstance;
+ (void)hPrevInstance;
+ (void)lpszCmdLine;
+ (void)nCmdShow;
/*
* Create the console channels and install them as the standard channels.
@@ -367,7 +377,7 @@ setargv(
#undef Tcl_Alloc
#undef Tcl_DbCkalloc
- argSpace = ckalloc(size * sizeof(char *)
+ argSpace = (TCHAR *)ckalloc(size * sizeof(char *)
+ (_tcslen(cmdLine) * sizeof(TCHAR)) + sizeof(TCHAR));
argv = (TCHAR **) argSpace;
argSpace += size * (sizeof(char *)/sizeof(TCHAR));
diff --git a/xlib/X11/DECkeysym.h b/xlib/X11/DECkeysym.h
new file mode 100644
index 0000000..d9e23c4
--- /dev/null
+++ b/xlib/X11/DECkeysym.h
@@ -0,0 +1,65 @@
+/***********************************************************
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * DEC private keysyms
+ * (29th bit set)
+ */
+
+/* two-key compose sequence initiators, chosen to map to Latin1 characters */
+
+#define DXK_ring_accent 0x1000FEB0
+#define DXK_circumflex_accent 0x1000FE5E
+#define DXK_cedilla_accent 0x1000FE2C
+#define DXK_acute_accent 0x1000FE27
+#define DXK_grave_accent 0x1000FE60
+#define DXK_tilde 0x1000FE7E
+#define DXK_diaeresis 0x1000FE22
+
+/* special keysym for LK2** "Remove" key on editing keypad */
+
+#define DXK_Remove 0x1000FF00 /* Remove */
diff --git a/xlib/X11/HPkeysym.h b/xlib/X11/HPkeysym.h
new file mode 100644
index 0000000..4a0655a
--- /dev/null
+++ b/xlib/X11/HPkeysym.h
@@ -0,0 +1,164 @@
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Hewlett Packard
+or Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD
+TO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. Hewlett-Packard shall not be liable for errors
+contained herein or direct, indirect, special, incidental or
+consequential damages in connection with the furnishing,
+performance, or use of this material.
+
+*/
+
+#ifndef _HPKEYSYM_H
+
+#define _HPKEYSYM_H
+
+#define hpXK_ClearLine 0x1000FF6F
+#define hpXK_InsertLine 0x1000FF70
+#define hpXK_DeleteLine 0x1000FF71
+#define hpXK_InsertChar 0x1000FF72
+#define hpXK_DeleteChar 0x1000FF73
+#define hpXK_BackTab 0x1000FF74
+#define hpXK_KP_BackTab 0x1000FF75
+#define hpXK_Modelock1 0x1000FF48
+#define hpXK_Modelock2 0x1000FF49
+#define hpXK_Reset 0x1000FF6C
+#define hpXK_System 0x1000FF6D
+#define hpXK_User 0x1000FF6E
+#define hpXK_mute_acute 0x100000A8
+#define hpXK_mute_grave 0x100000A9
+#define hpXK_mute_asciicircum 0x100000AA
+#define hpXK_mute_diaeresis 0x100000AB
+#define hpXK_mute_asciitilde 0x100000AC
+#define hpXK_lira 0x100000AF
+#define hpXK_guilder 0x100000BE
+#define hpXK_Ydiaeresis 0x100000EE
+#define hpXK_IO 0x100000EE
+#define hpXK_longminus 0x100000F6
+#define hpXK_block 0x100000FC
+
+
+#ifndef _OSF_Keysyms
+#define _OSF_Keysyms
+
+#define osfXK_Copy 0x1004FF02
+#define osfXK_Cut 0x1004FF03
+#define osfXK_Paste 0x1004FF04
+#define osfXK_BackTab 0x1004FF07
+#define osfXK_BackSpace 0x1004FF08
+#define osfXK_Clear 0x1004FF0B
+#define osfXK_Escape 0x1004FF1B
+#define osfXK_AddMode 0x1004FF31
+#define osfXK_PrimaryPaste 0x1004FF32
+#define osfXK_QuickPaste 0x1004FF33
+#define osfXK_PageLeft 0x1004FF40
+#define osfXK_PageUp 0x1004FF41
+#define osfXK_PageDown 0x1004FF42
+#define osfXK_PageRight 0x1004FF43
+#define osfXK_Activate 0x1004FF44
+#define osfXK_MenuBar 0x1004FF45
+#define osfXK_Left 0x1004FF51
+#define osfXK_Up 0x1004FF52
+#define osfXK_Right 0x1004FF53
+#define osfXK_Down 0x1004FF54
+#define osfXK_EndLine 0x1004FF57
+#define osfXK_BeginLine 0x1004FF58
+#define osfXK_EndData 0x1004FF59
+#define osfXK_BeginData 0x1004FF5A
+#define osfXK_PrevMenu 0x1004FF5B
+#define osfXK_NextMenu 0x1004FF5C
+#define osfXK_PrevField 0x1004FF5D
+#define osfXK_NextField 0x1004FF5E
+#define osfXK_Select 0x1004FF60
+#define osfXK_Insert 0x1004FF63
+#define osfXK_Undo 0x1004FF65
+#define osfXK_Menu 0x1004FF67
+#define osfXK_Cancel 0x1004FF69
+#define osfXK_Help 0x1004FF6A
+#define osfXK_SelectAll 0x1004FF71
+#define osfXK_DeselectAll 0x1004FF72
+#define osfXK_Reselect 0x1004FF73
+#define osfXK_Extend 0x1004FF74
+#define osfXK_Restore 0x1004FF78
+#define osfXK_Delete 0x1004FFFF
+
+#endif /* _OSF_Keysyms */
+
+
+/**************************************************************
+ * The use of the following macros is deprecated.
+ * They are listed below only for backwards compatibility.
+ */
+#define XK_Reset 0x1000FF6C
+#define XK_System 0x1000FF6D
+#define XK_User 0x1000FF6E
+#define XK_ClearLine 0x1000FF6F
+#define XK_InsertLine 0x1000FF70
+#define XK_DeleteLine 0x1000FF71
+#define XK_InsertChar 0x1000FF72
+#define XK_DeleteChar 0x1000FF73
+#define XK_BackTab 0x1000FF74
+#define XK_KP_BackTab 0x1000FF75
+#define XK_Ext16bit_L 0x1000FF76
+#define XK_Ext16bit_R 0x1000FF77
+#define XK_mute_acute 0x100000a8
+#define XK_mute_grave 0x100000a9
+#define XK_mute_asciicircum 0x100000aa
+#define XK_mute_diaeresis 0x100000ab
+#define XK_mute_asciitilde 0x100000ac
+#define XK_lira 0x100000af
+#define XK_guilder 0x100000be
+#ifndef XK_Ydiaeresis
+#define XK_Ydiaeresis 0x100000ee
+#endif
+#define XK_IO 0x100000ee
+#define XK_longminus 0x100000f6
+#define XK_block 0x100000fc
+
+#endif /* _HPKEYSYM_H */
diff --git a/xlib/X11/Sunkeysym.h b/xlib/X11/Sunkeysym.h
new file mode 100644
index 0000000..78d1286
--- /dev/null
+++ b/xlib/X11/Sunkeysym.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 1991, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+/************************************************************
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+***********************************************************/
+
+/*
+ * Floating Accent
+ */
+
+#define SunXK_FA_Grave 0x1005FF00
+#define SunXK_FA_Circum 0x1005FF01
+#define SunXK_FA_Tilde 0x1005FF02
+#define SunXK_FA_Acute 0x1005FF03
+#define SunXK_FA_Diaeresis 0x1005FF04
+#define SunXK_FA_Cedilla 0x1005FF05
+
+/*
+ * Miscellaneous Functions
+ */
+
+#define SunXK_F36 0x1005FF10 /* Labeled F11 */
+#define SunXK_F37 0x1005FF11 /* Labeled F12 */
+
+#define SunXK_Sys_Req 0x1005FF60
+#define SunXK_Print_Screen 0x0000FF61 /* Same as XK_Print */
+
+/*
+ * International & Multi-Key Character Composition
+ */
+
+#define SunXK_Compose 0x0000FF20 /* Same as XK_Multi_key */
+#define SunXK_AltGraph 0x0000FF7E /* Same as XK_Mode_switch */
+
+/*
+ * Cursor Control
+ */
+
+#define SunXK_PageUp 0x0000FF55 /* Same as XK_Prior */
+#define SunXK_PageDown 0x0000FF56 /* Same as XK_Next */
+
+/*
+ * Open Look Functions
+ */
+
+#define SunXK_Undo 0x0000FF65 /* Same as XK_Undo */
+#define SunXK_Again 0x0000FF66 /* Same as XK_Redo */
+#define SunXK_Find 0x0000FF68 /* Same as XK_Find */
+#define SunXK_Stop 0x0000FF69 /* Same as XK_Cancel */
+#define SunXK_Props 0x1005FF70
+#define SunXK_Front 0x1005FF71
+#define SunXK_Copy 0x1005FF72
+#define SunXK_Open 0x1005FF73
+#define SunXK_Paste 0x1005FF74
+#define SunXK_Cut 0x1005FF75
+
+#define SunXK_PowerSwitch 0x1005FF76
+#define SunXK_AudioLowerVolume 0x1005FF77
+#define SunXK_AudioMute 0x1005FF78
+#define SunXK_AudioRaiseVolume 0x1005FF79
+#define SunXK_VideoDegauss 0x1005FF7A
+#define SunXK_VideoLowerBrightness 0x1005FF7B
+#define SunXK_VideoRaiseBrightness 0x1005FF7C
+#define SunXK_PowerSwitchShift 0x1005FF7D
diff --git a/xlib/X11/X.h b/xlib/X11/X.h
index 2a9cd52..0e2d152 100644
--- a/xlib/X11/X.h
+++ b/xlib/X11/X.h
@@ -1,15 +1,34 @@
-/*
- * $XConsortium: X.h,v 1.66 88/09/06 15:55:56 jim Exp $
- */
-
/* Definitions for the X window system likely to be used by applications */
#ifndef X_H
#define X_H
/***********************************************************
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
-and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
@@ -17,7 +36,7 @@ Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
-supporting documentation, and that the names of Digital or MIT not be
+supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
@@ -30,25 +49,24 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
+
#define X_PROTOCOL 11 /* current protocol version */
#define X_PROTOCOL_REVISION 0 /* current minor version */
-#if defined(MAC_OSX_TK)
-# define Cursor XCursor
-# define Region XRegion
-#endif
-
/* Resources */
#ifdef _WIN64
-typedef __int64 XID;
+typedef unsigned __int64 XID;
#else
typedef unsigned long XID;
#endif
typedef XID Window;
typedef XID Drawable;
+#ifndef _XTYPEDEF_FONT
+# define _XTYPEDEF_FONT
typedef XID Font;
+#endif
typedef XID Pixmap;
typedef XID Cursor;
typedef XID Colormap;
@@ -63,7 +81,7 @@ typedef unsigned long VisualID;
typedef unsigned long Time;
-typedef unsigned long KeyCode; /* In order to use IME, the Macintosh needs
+typedef unsigned int KeyCode; /* In order to use IME, the Macintosh needs
* to pack 3 bytes into the keyCode field in
* the XEvent. In the real X.h, a KeyCode is
* defined as a short, which wouldn't be big
@@ -171,7 +189,8 @@ are reserved in the protocol for errors and replies. */
#define ColormapNotify 32
#define ClientMessage 33
#define MappingNotify 34
-#define LASTEvent 35 /* must be bigger than any event # */
+#define GenericEvent 35
+#define LASTEvent 36 /* must be bigger than any event # */
/* Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer,
@@ -257,9 +276,13 @@ enum _Bug9e31fd9449 { None = 0, ControlMask = (1<<2) };
/* protocol families */
-#define FamilyInternet 0
+#define FamilyInternet 0 /* IPv4 */
#define FamilyDECnet 1
#define FamilyChaos 2
+#define FamilyInternet6 6 /* IPv6 */
+
+/* authentication families not tied to a specific protocol */
+#define FamilyServerInterpreted 5
/* Property notification */
@@ -672,9 +695,4 @@ enum _Bug9e31fd9449 { None = 0, ControlMask = (1<<2) };
#define LSBFirst 0
#define MSBFirst 1
-#if defined(MAC_OSX_TK)
-# undef Cursor
-# undef Region
-#endif
-
#endif /* X_H */
diff --git a/xlib/X11/XF86keysym.h b/xlib/X11/XF86keysym.h
new file mode 100755
index 0000000..dd287e2
--- /dev/null
+++ b/xlib/X11/XF86keysym.h
@@ -0,0 +1,230 @@
+/*
+ * XFree86 vendor specific keysyms.
+ *
+ * The XFree86 keysym range is 0x10080001 - 0x1008FFFF.
+ *
+ * X.Org will not be adding to the XF86 set of keysyms, though they have
+ * been adopted and are considered a "standard" part of X keysym definitions.
+ * XFree86 never properly commented these keysyms, so we have done our
+ * best to explain the semantic meaning of these keys.
+ *
+ * XFree86 has removed their mail archives of the period, that might have
+ * shed more light on some of these definitions. Until/unless we resurrect
+ * these archives, these are from memory and usage.
+ */
+
+/*
+ * ModeLock
+ *
+ * This one is old, and not really used any more since XKB offers this
+ * functionality.
+ */
+
+#define XF86XK_ModeLock 0x1008FF01 /* Mode Switch Lock */
+
+/* Backlight controls. */
+#define XF86XK_MonBrightnessUp 0x1008FF02 /* Monitor/panel brightness */
+#define XF86XK_MonBrightnessDown 0x1008FF03 /* Monitor/panel brightness */
+#define XF86XK_KbdLightOnOff 0x1008FF04 /* Keyboards may be lit */
+#define XF86XK_KbdBrightnessUp 0x1008FF05 /* Keyboards may be lit */
+#define XF86XK_KbdBrightnessDown 0x1008FF06 /* Keyboards may be lit */
+#define XF86XK_MonBrightnessCycle 0x1008FF07 /* Monitor/panel brightness */
+
+/*
+ * Keys found on some "Internet" keyboards.
+ */
+#define XF86XK_Standby 0x1008FF10 /* System into standby mode */
+#define XF86XK_AudioLowerVolume 0x1008FF11 /* Volume control down */
+#define XF86XK_AudioMute 0x1008FF12 /* Mute sound from the system */
+#define XF86XK_AudioRaiseVolume 0x1008FF13 /* Volume control up */
+#define XF86XK_AudioPlay 0x1008FF14 /* Start playing of audio > */
+#define XF86XK_AudioStop 0x1008FF15 /* Stop playing audio */
+#define XF86XK_AudioPrev 0x1008FF16 /* Previous track */
+#define XF86XK_AudioNext 0x1008FF17 /* Next track */
+#define XF86XK_HomePage 0x1008FF18 /* Display user's home page */
+#define XF86XK_Mail 0x1008FF19 /* Invoke user's mail program */
+#define XF86XK_Start 0x1008FF1A /* Start application */
+#define XF86XK_Search 0x1008FF1B /* Search */
+#define XF86XK_AudioRecord 0x1008FF1C /* Record audio application */
+
+/* These are sometimes found on PDA's (e.g. Palm, PocketPC or elsewhere) */
+#define XF86XK_Calculator 0x1008FF1D /* Invoke calculator program */
+#define XF86XK_Memo 0x1008FF1E /* Invoke Memo taking program */
+#define XF86XK_ToDoList 0x1008FF1F /* Invoke To Do List program */
+#define XF86XK_Calendar 0x1008FF20 /* Invoke Calendar program */
+#define XF86XK_PowerDown 0x1008FF21 /* Deep sleep the system */
+#define XF86XK_ContrastAdjust 0x1008FF22 /* Adjust screen contrast */
+#define XF86XK_RockerUp 0x1008FF23 /* Rocker switches exist up */
+#define XF86XK_RockerDown 0x1008FF24 /* and down */
+#define XF86XK_RockerEnter 0x1008FF25 /* and let you press them */
+
+/* Some more "Internet" keyboard symbols */
+#define XF86XK_Back 0x1008FF26 /* Like back on a browser */
+#define XF86XK_Forward 0x1008FF27 /* Like forward on a browser */
+#define XF86XK_Stop 0x1008FF28 /* Stop current operation */
+#define XF86XK_Refresh 0x1008FF29 /* Refresh the page */
+#define XF86XK_PowerOff 0x1008FF2A /* Power off system entirely */
+#define XF86XK_WakeUp 0x1008FF2B /* Wake up system from sleep */
+#define XF86XK_Eject 0x1008FF2C /* Eject device (e.g. DVD) */
+#define XF86XK_ScreenSaver 0x1008FF2D /* Invoke screensaver */
+#define XF86XK_WWW 0x1008FF2E /* Invoke web browser */
+#define XF86XK_Sleep 0x1008FF2F /* Put system to sleep */
+#define XF86XK_Favorites 0x1008FF30 /* Show favorite locations */
+#define XF86XK_AudioPause 0x1008FF31 /* Pause audio playing */
+#define XF86XK_AudioMedia 0x1008FF32 /* Launch media collection app */
+#define XF86XK_MyComputer 0x1008FF33 /* Display "My Computer" window */
+#define XF86XK_VendorHome 0x1008FF34 /* Display vendor home web site */
+#define XF86XK_LightBulb 0x1008FF35 /* Light bulb keys exist */
+#define XF86XK_Shop 0x1008FF36 /* Display shopping web site */
+#define XF86XK_History 0x1008FF37 /* Show history of web surfing */
+#define XF86XK_OpenURL 0x1008FF38 /* Open selected URL */
+#define XF86XK_AddFavorite 0x1008FF39 /* Add URL to favorites list */
+#define XF86XK_HotLinks 0x1008FF3A /* Show "hot" links */
+#define XF86XK_BrightnessAdjust 0x1008FF3B /* Invoke brightness adj. UI */
+#define XF86XK_Finance 0x1008FF3C /* Display financial site */
+#define XF86XK_Community 0x1008FF3D /* Display user's community */
+#define XF86XK_AudioRewind 0x1008FF3E /* "rewind" audio track */
+#define XF86XK_BackForward 0x1008FF3F /* ??? */
+#define XF86XK_Launch0 0x1008FF40 /* Launch Application */
+#define XF86XK_Launch1 0x1008FF41 /* Launch Application */
+#define XF86XK_Launch2 0x1008FF42 /* Launch Application */
+#define XF86XK_Launch3 0x1008FF43 /* Launch Application */
+#define XF86XK_Launch4 0x1008FF44 /* Launch Application */
+#define XF86XK_Launch5 0x1008FF45 /* Launch Application */
+#define XF86XK_Launch6 0x1008FF46 /* Launch Application */
+#define XF86XK_Launch7 0x1008FF47 /* Launch Application */
+#define XF86XK_Launch8 0x1008FF48 /* Launch Application */
+#define XF86XK_Launch9 0x1008FF49 /* Launch Application */
+#define XF86XK_LaunchA 0x1008FF4A /* Launch Application */
+#define XF86XK_LaunchB 0x1008FF4B /* Launch Application */
+#define XF86XK_LaunchC 0x1008FF4C /* Launch Application */
+#define XF86XK_LaunchD 0x1008FF4D /* Launch Application */
+#define XF86XK_LaunchE 0x1008FF4E /* Launch Application */
+#define XF86XK_LaunchF 0x1008FF4F /* Launch Application */
+
+#define XF86XK_ApplicationLeft 0x1008FF50 /* switch to application, left */
+#define XF86XK_ApplicationRight 0x1008FF51 /* switch to application, right*/
+#define XF86XK_Book 0x1008FF52 /* Launch bookreader */
+#define XF86XK_CD 0x1008FF53 /* Launch CD/DVD player */
+#define XF86XK_Calculater 0x1008FF54 /* Launch Calculater */
+#define XF86XK_Clear 0x1008FF55 /* Clear window, screen */
+#define XF86XK_Close 0x1008FF56 /* Close window */
+#define XF86XK_Copy 0x1008FF57 /* Copy selection */
+#define XF86XK_Cut 0x1008FF58 /* Cut selection */
+#define XF86XK_Display 0x1008FF59 /* Output switch key */
+#define XF86XK_DOS 0x1008FF5A /* Launch DOS (emulation) */
+#define XF86XK_Documents 0x1008FF5B /* Open documents window */
+#define XF86XK_Excel 0x1008FF5C /* Launch spread sheet */
+#define XF86XK_Explorer 0x1008FF5D /* Launch file explorer */
+#define XF86XK_Game 0x1008FF5E /* Launch game */
+#define XF86XK_Go 0x1008FF5F /* Go to URL */
+#define XF86XK_iTouch 0x1008FF60 /* Logitech iTouch- don't use */
+#define XF86XK_LogOff 0x1008FF61 /* Log off system */
+#define XF86XK_Market 0x1008FF62 /* ?? */
+#define XF86XK_Meeting 0x1008FF63 /* enter meeting in calendar */
+#define XF86XK_MenuKB 0x1008FF65 /* distinguish keyboard from PB */
+#define XF86XK_MenuPB 0x1008FF66 /* distinguish PB from keyboard */
+#define XF86XK_MySites 0x1008FF67 /* Favourites */
+#define XF86XK_New 0x1008FF68 /* New (folder, document... */
+#define XF86XK_News 0x1008FF69 /* News */
+#define XF86XK_OfficeHome 0x1008FF6A /* Office home (old Staroffice)*/
+#define XF86XK_Open 0x1008FF6B /* Open */
+#define XF86XK_Option 0x1008FF6C /* ?? */
+#define XF86XK_Paste 0x1008FF6D /* Paste */
+#define XF86XK_Phone 0x1008FF6E /* Launch phone; dial number */
+#define XF86XK_Q 0x1008FF70 /* Compaq's Q - don't use */
+#define XF86XK_Reply 0x1008FF72 /* Reply e.g., mail */
+#define XF86XK_Reload 0x1008FF73 /* Reload web page, file, etc. */
+#define XF86XK_RotateWindows 0x1008FF74 /* Rotate windows e.g. xrandr */
+#define XF86XK_RotationPB 0x1008FF75 /* don't use */
+#define XF86XK_RotationKB 0x1008FF76 /* don't use */
+#define XF86XK_Save 0x1008FF77 /* Save (file, document, state */
+#define XF86XK_ScrollUp 0x1008FF78 /* Scroll window/contents up */
+#define XF86XK_ScrollDown 0x1008FF79 /* Scrool window/contentd down */
+#define XF86XK_ScrollClick 0x1008FF7A /* Use XKB mousekeys instead */
+#define XF86XK_Send 0x1008FF7B /* Send mail, file, object */
+#define XF86XK_Spell 0x1008FF7C /* Spell checker */
+#define XF86XK_SplitScreen 0x1008FF7D /* Split window or screen */
+#define XF86XK_Support 0x1008FF7E /* Get support (??) */
+#define XF86XK_TaskPane 0x1008FF7F /* Show tasks */
+#define XF86XK_Terminal 0x1008FF80 /* Launch terminal emulator */
+#define XF86XK_Tools 0x1008FF81 /* toolbox of desktop/app. */
+#define XF86XK_Travel 0x1008FF82 /* ?? */
+#define XF86XK_UserPB 0x1008FF84 /* ?? */
+#define XF86XK_User1KB 0x1008FF85 /* ?? */
+#define XF86XK_User2KB 0x1008FF86 /* ?? */
+#define XF86XK_Video 0x1008FF87 /* Launch video player */
+#define XF86XK_WheelButton 0x1008FF88 /* button from a mouse wheel */
+#define XF86XK_Word 0x1008FF89 /* Launch word processor */
+#define XF86XK_Xfer 0x1008FF8A
+#define XF86XK_ZoomIn 0x1008FF8B /* zoom in view, map, etc. */
+#define XF86XK_ZoomOut 0x1008FF8C /* zoom out view, map, etc. */
+
+#define XF86XK_Away 0x1008FF8D /* mark yourself as away */
+#define XF86XK_Messenger 0x1008FF8E /* as in instant messaging */
+#define XF86XK_WebCam 0x1008FF8F /* Launch web camera app. */
+#define XF86XK_MailForward 0x1008FF90 /* Forward in mail */
+#define XF86XK_Pictures 0x1008FF91 /* Show pictures */
+#define XF86XK_Music 0x1008FF92 /* Launch music application */
+
+#define XF86XK_Battery 0x1008FF93 /* Display battery information */
+#define XF86XK_Bluetooth 0x1008FF94 /* Enable/disable Bluetooth */
+#define XF86XK_WLAN 0x1008FF95 /* Enable/disable WLAN */
+#define XF86XK_UWB 0x1008FF96 /* Enable/disable UWB */
+
+#define XF86XK_AudioForward 0x1008FF97 /* fast-forward audio track */
+#define XF86XK_AudioRepeat 0x1008FF98 /* toggle repeat mode */
+#define XF86XK_AudioRandomPlay 0x1008FF99 /* toggle shuffle mode */
+#define XF86XK_Subtitle 0x1008FF9A /* cycle through subtitle */
+#define XF86XK_AudioCycleTrack 0x1008FF9B /* cycle through audio tracks */
+#define XF86XK_CycleAngle 0x1008FF9C /* cycle through angles */
+#define XF86XK_FrameBack 0x1008FF9D /* video: go one frame back */
+#define XF86XK_FrameForward 0x1008FF9E /* video: go one frame forward */
+#define XF86XK_Time 0x1008FF9F /* display, or shows an entry for time seeking */
+#define XF86XK_Select 0x1008FFA0 /* Select button on joypads and remotes */
+#define XF86XK_View 0x1008FFA1 /* Show a view options/properties */
+#define XF86XK_TopMenu 0x1008FFA2 /* Go to a top-level menu in a video */
+
+#define XF86XK_Red 0x1008FFA3 /* Red button */
+#define XF86XK_Green 0x1008FFA4 /* Green button */
+#define XF86XK_Yellow 0x1008FFA5 /* Yellow button */
+#define XF86XK_Blue 0x1008FFA6 /* Blue button */
+
+#define XF86XK_Suspend 0x1008FFA7 /* Sleep to RAM */
+#define XF86XK_Hibernate 0x1008FFA8 /* Sleep to disk */
+#define XF86XK_TouchpadToggle 0x1008FFA9 /* Toggle between touchpad/trackstick */
+#define XF86XK_TouchpadOn 0x1008FFB0 /* The touchpad got switched on */
+#define XF86XK_TouchpadOff 0x1008FFB1 /* The touchpad got switched off */
+
+#define XF86XK_AudioMicMute 0x1008FFB2 /* Mute the Mic from the system */
+
+#define XF86XK_Keyboard 0x1008FFB3 /* User defined keyboard related action */
+
+#define XF86XK_WWAN 0x1008FFB4 /* Toggle WWAN (LTE, UMTS, etc.) radio */
+#define XF86XK_RFKill 0x1008FFB5 /* Toggle radios on/off */
+
+#define XF86XK_AudioPreset 0x1008FFB6 /* Select equalizer preset, e.g. theatre-mode */
+
+#define XF86XK_RotationLockToggle 0x1008FFB7 /* Toggle screen rotation lock on/off */
+
+/* Keys for special action keys (hot keys) */
+/* Virtual terminals on some operating systems */
+#define XF86XK_Switch_VT_1 0x1008FE01
+#define XF86XK_Switch_VT_2 0x1008FE02
+#define XF86XK_Switch_VT_3 0x1008FE03
+#define XF86XK_Switch_VT_4 0x1008FE04
+#define XF86XK_Switch_VT_5 0x1008FE05
+#define XF86XK_Switch_VT_6 0x1008FE06
+#define XF86XK_Switch_VT_7 0x1008FE07
+#define XF86XK_Switch_VT_8 0x1008FE08
+#define XF86XK_Switch_VT_9 0x1008FE09
+#define XF86XK_Switch_VT_10 0x1008FE0A
+#define XF86XK_Switch_VT_11 0x1008FE0B
+#define XF86XK_Switch_VT_12 0x1008FE0C
+
+#define XF86XK_Ungrab 0x1008FE20 /* force ungrab */
+#define XF86XK_ClearGrab 0x1008FE21 /* kill application with grab */
+#define XF86XK_Next_VMode 0x1008FE22 /* next video mode available */
+#define XF86XK_Prev_VMode 0x1008FE23 /* prev. video mode available */
+#define XF86XK_LogWindowTree 0x1008FE24 /* print window tree to log */
+#define XF86XK_LogGrabInfo 0x1008FE25 /* print all active grabs to log */
diff --git a/xlib/X11/Xfuncproto.h b/xlib/X11/Xfuncproto.h
index 6d63002..89bc96f 100644
--- a/xlib/X11/Xfuncproto.h
+++ b/xlib/X11/Xfuncproto.h
@@ -1,16 +1,26 @@
-/* $XConsortium: Xfuncproto.h,v 1.7 91/05/13 20:49:21 rws Exp $ */
/*
- * Copyright 1989, 1991 by the Massachusetts Institute of Technology
*
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of M.I.T. not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission. M.I.T. makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
+Copyright 1989, 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
*
*/
@@ -24,7 +34,7 @@
#endif /* NeedFunctionPrototypes */
#ifndef NeedVarargsPrototypes
-#define NeedVarargsPrototypes 0
+#define NeedVarargsPrototypes 1
#endif /* NeedVarargsPrototypes */
#if NeedFunctionPrototypes
@@ -37,6 +47,15 @@
#define _Xconst const
#endif /* _Xconst */
+/* Function prototype configuration (see configure for more info) */
+#if !defined(NARROWPROTO) && \
+ (defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__))
+#define NARROWPROTO
+#endif
+#ifndef FUNCPROTO
+#define FUNCPROTO 15
+#endif
+
#ifndef NeedWidePrototypes
#ifdef NARROWPROTO
#define NeedWidePrototypes 0
@@ -47,14 +66,156 @@
#endif /* NeedFunctionPrototypes */
-#ifdef __cplusplus
-#define _XFUNCPROTOBEGIN extern "C" {
-#define _XFUNCPROTOEND }
-#endif
-
#ifndef _XFUNCPROTOBEGIN
+#if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */
+#define _XFUNCPROTOBEGIN extern "C" { /* do not leave open across includes */
+#define _XFUNCPROTOEND }
+#else
#define _XFUNCPROTOBEGIN
#define _XFUNCPROTOEND
+#endif
#endif /* _XFUNCPROTOBEGIN */
+/* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute */
+#ifndef __has_attribute
+# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
+#endif
+#ifndef __has_feature
+# define __has_feature(x) 0 /* Compatibility with non-clang compilers. */
+#endif
+#ifndef __has_extension
+# define __has_extension(x) 0 /* Compatibility with non-clang compilers. */
+#endif
+
+/* Added in X11R6.9, so available in any version of modular xproto */
+#if __has_attribute(__sentinel__) || (defined(__GNUC__) && (__GNUC__ >= 4))
+# define _X_SENTINEL(x) __attribute__ ((__sentinel__(x)))
+#else
+# define _X_SENTINEL(x)
+#endif /* GNUC >= 4 */
+
+/* Added in X11R6.9, so available in any version of modular xproto */
+#if (__has_attribute(visibility) || (defined(__GNUC__) && (__GNUC__ >= 4))) \
+ && !defined(__CYGWIN__) && !defined(__MINGW32__)
+# define _X_EXPORT __attribute__((visibility("default")))
+# define _X_HIDDEN __attribute__((visibility("hidden")))
+# define _X_INTERNAL __attribute__((visibility("internal")))
+#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+# define _X_EXPORT __global
+# define _X_HIDDEN __hidden
+# define _X_INTERNAL __hidden
+#else /* not gcc >= 4 and not Sun Studio >= 8 */
+# define _X_EXPORT
+# define _X_HIDDEN
+# define _X_INTERNAL
+#endif /* GNUC >= 4 */
+
+/* Branch prediction hints for individual conditionals */
+/* requires xproto >= 7.0.9 */
+#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
+# define _X_LIKELY(x) __builtin_expect(!!(x), 1)
+# define _X_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#else /* not gcc >= 3.3 */
+# define _X_LIKELY(x) (x)
+# define _X_UNLIKELY(x) (x)
+#endif
+
+/* Bulk branch prediction hints via marking error path functions as "cold" */
+/* requires xproto >= 7.0.25 */
+#if __has_attribute(__cold__) || \
+ (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403)) /* 4.3+ */
+# define _X_COLD __attribute__((__cold__))
+#else
+# define _X_COLD /* nothing */
+#endif
+
+/* Added in X11R6.9, so available in any version of modular xproto */
+#if __has_attribute(deprecated) \
+ || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301)) \
+ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5130))
+# define _X_DEPRECATED __attribute__((deprecated))
+#else /* not gcc >= 3.1 */
+# define _X_DEPRECATED
+#endif
+
+/* requires xproto >= 7.0.30 */
+#if __has_extension(attribute_deprecated_with_message) || \
+ (defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))))
+# define _X_DEPRECATED_MSG(_msg) __attribute__((deprecated(_msg)))
+#else
+# define _X_DEPRECATED_MSG(_msg) _X_DEPRECATED
+#endif
+
+/* requires xproto >= 7.0.17 */
+#if __has_attribute(noreturn) \
+ || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
+ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+# define _X_NORETURN __attribute((noreturn))
+#else
+# define _X_NORETURN
+#endif /* GNUC */
+
+/* Added in X11R6.9, so available in any version of modular xproto */
+#if __has_attribute(__format__) \
+ || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)
+# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
+#else /* not gcc >= 2.3 */
+# define _X_ATTRIBUTE_PRINTF(x,y)
+#endif
+
+/* requires xproto >= 7.0.22 - since this uses either gcc or C99 variable
+ argument macros, must be only used inside #ifdef _X_NONNULL guards, as
+ many legacy X clients are compiled in C89 mode still. */
+#if __has_attribute(nonnull) \
+ && defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */
+#define _X_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
+#elif __has_attribute(nonnull) \
+ || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
+#define _X_NONNULL(args...) __attribute__((nonnull(args)))
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */
+#define _X_NONNULL(...) /* */
+#endif
+
+/* requires xproto >= 7.0.22 */
+#if __has_attribute(__unused__) \
+ || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)
+#define _X_UNUSED __attribute__((__unused__))
+#else
+#define _X_UNUSED /* */
+#endif
+
+/* C99 keyword "inline" or equivalent extensions in pre-C99 compilers */
+/* requires xproto >= 7.0.9
+ (introduced in 7.0.8 but didn't support all compilers until 7.0.9) */
+#if defined(inline) /* assume autoconf set it correctly */ || \
+ (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */ || \
+ (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550))
+# define _X_INLINE inline
+#elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
+# define _X_INLINE __inline__
+#else
+# define _X_INLINE
+#endif
+
+/* C99 keyword "restrict" or equivalent extensions in pre-C99 compilers */
+/* requires xproto >= 7.0.21 */
+#ifndef _X_RESTRICT_KYWD
+# if defined(restrict) /* assume autoconf set it correctly */ || \
+ (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */ \
+ && !defined(__cplusplus)) /* Workaround g++ issue on Solaris */
+# define _X_RESTRICT_KYWD restrict
+# elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
+# define _X_RESTRICT_KYWD __restrict__
+# else
+# define _X_RESTRICT_KYWD
+# endif
+#endif
+
+/* requires xproto >= 7.0.30 */
+#if __has_attribute(no_sanitize_thread)
+# define _X_NOTSAN __attribute__((no_sanitize_thread))
+#else
+# define _X_NOTSAN
+#endif
+
#endif /* _XFUNCPROTO_H_ */
diff --git a/xlib/X11/Xlib.h b/xlib/X11/Xlib.h
index b4b04d7..0ad68d6 100644
--- a/xlib/X11/Xlib.h
+++ b/xlib/X11/Xlib.h
@@ -1,20 +1,28 @@
-/* $XConsortium: Xlib.h,v 11.221 93/07/02 14:13:28 gildea Exp $ */
/*
- * Copyright 1985, 1986, 1987, 1991 by the Massachusetts Institute of Technology
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of M.I.T. not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission. M.I.T. makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * X Window System is a Trademark of MIT.
- *
- */
+
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
/*
@@ -22,27 +30,63 @@
* interface library (Xlib) to the X Window System Protocol (V11).
* Structures and symbols starting with "_" are private to the library.
*/
-#ifndef _XLIB_H_
-#define _XLIB_H_
+#ifndef _X11_XLIB_H_
+#define _X11_XLIB_H_
-#define XlibSpecificationRelease 5
+#define XlibSpecificationRelease 6
-#if !defined(MAC_OSX_TK)
-# include <X11/X.h>
-#endif
-#ifdef MAC_OSX_TK
-# include <X11/X.h>
-# define Cursor XCursor
-# define Region XRegion
+#include <sys/types.h>
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#include <stdint.h>
#endif
+#include <X11/X.h>
+
/* applications should not depend on these two headers being included! */
#include <X11/Xfuncproto.h>
#ifndef X_WCHAR
-#ifdef X_NOT_STDC_ENV
-#define X_WCHAR
+#include <stddef.h>
+#else
+#ifdef __UNIXOS2__
+#include <stdlib.h>
+#else
+/* replace this with #include or typedef appropriate for your system */
+typedef unsigned long wchar_t;
+#endif
+#endif
+
+#ifndef EXTERN
+# define EXTERN extern TCL_STORAGE_CLASS
#endif
+#if defined(STATIC_BUILD) || !defined(_WIN32)
+# ifndef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS
+# endif
+#elif defined(BUILD_tk)
+# undef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS __declspec(dllexport)
+#elif !defined(TCL_STORAGE_CLASS)
+# define TCL_STORAGE_CLASS __declspec(dllimport)
+#endif
+
+EXTERN int
+_Xmblen(
+ char *str,
+ int len
+ );
+
+/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in
+ November 2000. Its presence is indicated through the following macro. */
+#define X_HAVE_UTF8_STRING 1
+
+/* The Xlib structs are full of implicit padding to properly align members.
+ We can't clean that up without breaking ABI, so tell clang not to bother
+ complaining about it. */
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
#endif
typedef char *XPointer;
@@ -121,7 +165,9 @@ typedef int Status;
typedef struct _XExtData {
int number; /* number returned by XRegisterExtension */
struct _XExtData *next; /* next item on list of data for structure */
- int (*free_private)(); /* called to free private storage */
+ int (*free_private)( /* called to free private storage */
+ struct _XExtData *extension
+ );
XPointer private_data; /* data private to this extension. */
} XExtData;
@@ -214,6 +260,9 @@ typedef struct {
* implementation dependent. A Screen should be treated as opaque
* by application code.
*/
+
+struct _XDisplay; /* Forward declare before use for C++ */
+
typedef struct {
XExtData *ext_data; /* hook for extension to hang data */
struct _XDisplay *display;/* back pointer to display structure */
@@ -305,6 +354,16 @@ typedef struct {
} XHostAddress;
/*
+ * Data structure for ServerFamilyInterpreted addresses in host routines
+ */
+typedef struct {
+ int typelength; /* length of type string, in bytes */
+ int valuelength; /* length of value string, in bytes */
+ char *type; /* pointer to where to find the type string */
+ char *value; /* pointer to where to find the address */
+} XServerInterpretedAddress;
+
+/*
* Data structure for "image" data, used by image manipulation routines.
*/
typedef struct _XImage {
@@ -327,20 +386,22 @@ typedef struct _XImage {
int pixelpower; /* n such that pixels are 2^n x 2^n blocks*/
#endif
struct funcs { /* image manipulation routines */
- struct _XImage *(*create_image)();
-#if NeedFunctionPrototypes
+ struct _XImage *(*create_image)(
+ struct _XDisplay* /* display */,
+ Visual* /* visual */,
+ unsigned int /* depth */,
+ int /* format */,
+ int /* offset */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* bitmap_pad */,
+ int /* bytes_per_line */);
int (*destroy_image) (struct _XImage *);
unsigned long (*get_pixel) (struct _XImage *, int, int);
int (*put_pixel) (struct _XImage *, int, int, unsigned long);
struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int);
int (*add_pixel) (struct _XImage *, long);
-#else
- int (*destroy_image)();
- unsigned long (*get_pixel)();
- int (*put_pixel)();
- struct _XImage *(*sub_image)();
- int (*add_pixel)();
-#endif
} f;
} XImage;
@@ -436,46 +497,51 @@ typedef struct {
*/
typedef struct _XDisplay {
XExtData *ext_data; /* hook for extension to hang data */
- struct _XFreeFuncs *free_funcs; /* internal free functions */
+ struct _XPrivate *private1;
int fd; /* Network socket. */
- int conn_checker; /* ugly thing used by _XEventsQueued */
- int proto_major_version;/* maj. version of server's X protocol */
+ int private2;
+ int proto_major_version;/* major version of server's X protocol */
int proto_minor_version;/* minor version of servers X protocol */
char *vendor; /* vendor of the server hardware */
- XID resource_base; /* resource ID base */
- XID resource_mask; /* resource ID mask bits */
- XID resource_id; /* allocator current ID */
- int resource_shift; /* allocator shift to correct bits */
- XID (*resource_alloc)(); /* allocator function */
+ XID private3;
+ XID private4;
+ XID private5;
+ int private6;
+ XID (*resource_alloc)( /* allocator function */
+ struct _XDisplay*
+ );
int byte_order; /* screen byte order, LSBFirst, MSBFirst */
int bitmap_unit; /* padding and data requirements */
int bitmap_pad; /* padding requirements on bitmaps */
int bitmap_bit_order; /* LeastSignificant or MostSignificant */
int nformats; /* number of pixmap formats in list */
ScreenFormat *pixmap_format; /* pixmap format list */
- int vnumber; /* Xlib's X protocol version number. */
+ int private8;
int release; /* release of the server */
- struct _XSQEvent *head, *tail; /* Input event queue. */
+ struct _XPrivate *private9, *private10;
int qlen; /* Length of input event queue */
+ unsigned long last_request_read; /* seq number of last event read */
unsigned long request; /* sequence number of last request. */
- char *last_req; /* beginning of last request, or dummy */
- char *buffer; /* Output buffer starting address. */
- char *bufptr; /* Output buffer index pointer. */
- char *bufmax; /* Output buffer maximum+1 address. */
+ XPointer private11;
+ XPointer private12;
+ XPointer private13;
+ XPointer private14;
unsigned max_request_size; /* maximum number 32 bit words in request*/
struct _XrmHashBucketRec *db;
- int (*synchandler)(); /* Synchronization handler */
+ int (*private15)(
+ struct _XDisplay*
+ );
char *display_name; /* "host:display" string used on this connect*/
int default_screen; /* default screen for operations */
int nscreens; /* number of screens on this server*/
Screen *screens; /* pointer to list of screens */
unsigned long motion_buffer; /* size of motion buffer */
- unsigned long flags; /* internal connection flags */
+ unsigned long private16;
int min_keycode; /* minimum defined keycode */
int max_keycode; /* maximum defined keycode */
- KeySym *keysyms; /* This server's keysyms */
- XModifierKeymap *modifiermap; /* This server's modifier keymap */
- int keysyms_per_keycode;/* number of rows */
+ XPointer private17;
+ XPointer private18;
+ int private19;
char *xdefaults; /* contents of defaults from server */
char *scratch_buffer; /* place to hang scratch buffer */
unsigned long scratch_length; /* length of scratch buffer */
@@ -489,8 +555,8 @@ typedef struct _XDisplay {
* list to find the right procedure for each event might be
* expensive if many extensions are being used.
*/
- Bool (*event_vec[128])(); /* vector for wire to event */
- Status (*wire_vec[128])(); /* vector for event to wire */
+ Bool (*event_vec[128])(void); /* vector for wire to event */
+ Status (*wire_vec[128])(void); /* vector for event to wire */
KeySym lock_meaning; /* for XLookupString */
struct _XLockInfo *lock; /* multi-thread state, display lock */
struct _XInternalAsync *async_handlers; /* for internal async */
@@ -502,7 +568,7 @@ typedef struct _XDisplay {
struct _XDisplayAtoms *atoms; /* for XInternAtom */
unsigned int mode_switch; /* keyboard group modifiers */
struct _XContextDB *context_db; /* context database */
- Bool (**error_vec)(); /* vector for wire to error */
+ Bool (**error_vec)(void); /* vector for wire to error */
/*
* Xcms information
*/
@@ -515,7 +581,7 @@ typedef struct _XDisplay {
struct _XIMFilter *im_filters;
struct _XSQEvent *qfree; /* unallocated event queue elements */
unsigned long next_event_serial_num; /* inserted into next queue elt */
- int (*savedsynchandler)(); /* user synchandler when Xlib usurps */
+ int (*savedsynchandler)(void); /* user synchandler when Xlib usurps */
} Display;
#if NeedFunctionPrototypes /* prototypes require event type definitions */
@@ -523,7 +589,7 @@ typedef struct _XDisplay {
#endif
#ifndef _XEVENT_
-#define XMaxTransChars 4
+#define XMaxTransChars 7
/*
* Definitions of specific events.
@@ -542,9 +608,6 @@ typedef struct {
unsigned int state; /* key or button mask */
unsigned int keycode; /* detail */
Bool same_screen; /* same screen flag */
- char trans_chars[XMaxTransChars];
- /* translated characters */
- int nbytes;
} XKeyEvent;
typedef XKeyEvent XKeyPressedEvent;
typedef XKeyEvent XKeyReleasedEvent;
@@ -614,7 +677,8 @@ typedef struct {
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
Window window; /* window of event */
- int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
+ int mode; /* NotifyNormal, NotifyWhileGrabbed,
+ NotifyGrab, NotifyUngrab */
int detail;
/*
* NotifyAncestor, NotifyVirtual, NotifyInferior,
@@ -915,6 +979,33 @@ typedef struct {
Window window; /* window on which event was requested in event mask */
} XAnyEvent;
+
+/***************************************************************
+ *
+ * GenericEvent. This event is the standard event for all newer extensions.
+ */
+
+typedef struct
+ {
+ int type; /* of event. Always GenericEvent */
+ unsigned long serial; /* # of last request processed */
+ Bool send_event; /* true if from SendEvent request */
+ Display *display; /* Display the event was read from */
+ int extension; /* major opcode of extension that caused the event */
+ int evtype; /* actual event type. */
+ } XGenericEvent;
+
+typedef struct {
+ int type; /* of event. Always GenericEvent */
+ unsigned long serial; /* # of last request processed */
+ Bool send_event; /* true if from SendEvent request */
+ Display *display; /* Display the event was read from */
+ int extension; /* major opcode of extension that caused the event */
+ int evtype; /* actual event type. */
+ unsigned int cookie;
+ void *data;
+} XGenericEventCookie;
+
/*
* this union is defined so Xlib can always use the same sized
* event structure internally, to avoid memory fragmentation.
@@ -952,7 +1043,9 @@ typedef union _XEvent {
XMappingEvent xmapping;
XErrorEvent xerror;
XKeymapEvent xkeymap;
- long pad[24];
+ XGenericEvent xgeneric;
+ XGenericEventCookie xcookie;
+ XID pad[24];
} XEvent;
#endif
@@ -1033,7 +1126,12 @@ typedef struct {
XRectangle max_logical_extent;
} XFontSetExtents;
-typedef struct _XFontSet *XFontSet;
+/* unused:
+typedef void (*XOMProc)();
+ */
+
+typedef struct _XOM *XOM;
+typedef struct _XOC *XOC, *XFontSet;
typedef struct {
char *chars;
@@ -1042,11 +1140,69 @@ typedef struct {
XFontSet font_set;
} XmbTextItem;
-typedef void (*XIMProc)();
+typedef struct {
+ wchar_t *chars;
+ int nchars;
+ int delta;
+ XFontSet font_set;
+} XwcTextItem;
+
+#define XNRequiredCharSet "requiredCharSet"
+#define XNQueryOrientation "queryOrientation"
+#define XNBaseFontName "baseFontName"
+#define XNOMAutomatic "omAutomatic"
+#define XNMissingCharSet "missingCharSet"
+#define XNDefaultString "defaultString"
+#define XNOrientation "orientation"
+#define XNDirectionalDependentDrawing "directionalDependentDrawing"
+#define XNContextualDrawing "contextualDrawing"
+#define XNFontInfo "fontInfo"
+
+typedef struct {
+ int charset_count;
+ char **charset_list;
+} XOMCharSetList;
+
+typedef enum {
+ XOMOrientation_LTR_TTB,
+ XOMOrientation_RTL_TTB,
+ XOMOrientation_TTB_LTR,
+ XOMOrientation_TTB_RTL,
+ XOMOrientation_Context
+} XOrientation;
+
+typedef struct {
+ int num_orientation;
+ XOrientation *orientation; /* Input Text description */
+} XOMOrientation;
+
+typedef struct {
+ int num_font;
+ XFontStruct **font_struct_list;
+ char **font_name_list;
+} XOMFontInfo;
typedef struct _XIM *XIM;
typedef struct _XIC *XIC;
+typedef void (*XIMProc)(
+ XIM,
+ XPointer,
+ XPointer
+);
+
+typedef Bool (*XICProc)(
+ XIC,
+ XPointer,
+ XPointer
+);
+
+typedef void (*XIDProc)(
+ Display*,
+ XPointer,
+ XPointer
+);
+
typedef unsigned long XIMStyle;
typedef struct {
@@ -1065,17 +1221,20 @@ typedef struct {
#define XIMStatusNone 0x0800L
#define XNVaNestedList "XNVaNestedList"
+#define XNQueryInputStyle "queryInputStyle"
#define XNClientWindow "clientWindow"
#define XNInputStyle "inputStyle"
#define XNFocusWindow "focusWindow"
#define XNResourceName "resourceName"
#define XNResourceClass "resourceClass"
#define XNGeometryCallback "geometryCallback"
+#define XNDestroyCallback "destroyCallback"
#define XNFilterEvents "filterEvents"
#define XNPreeditStartCallback "preeditStartCallback"
#define XNPreeditDoneCallback "preeditDoneCallback"
#define XNPreeditDrawCallback "preeditDrawCallback"
#define XNPreeditCaretCallback "preeditCaretCallback"
+#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback"
#define XNPreeditAttributes "preeditAttributes"
#define XNStatusStartCallback "statusStartCallback"
#define XNStatusDoneCallback "statusDoneCallback"
@@ -1093,31 +1252,47 @@ typedef struct {
#define XNLineSpace "lineSpace"
#define XNCursor "cursor"
+#define XNQueryIMValuesList "queryIMValuesList"
+#define XNQueryICValuesList "queryICValuesList"
+#define XNVisiblePosition "visiblePosition"
+#define XNR6PreeditCallback "r6PreeditCallback"
+#define XNStringConversionCallback "stringConversionCallback"
+#define XNStringConversion "stringConversion"
+#define XNResetState "resetState"
+#define XNHotKey "hotKey"
+#define XNHotKeyState "hotKeyState"
+#define XNPreeditState "preeditState"
+#define XNSeparatorofNestedList "separatorofNestedList"
+
#define XBufferOverflow -1
#define XLookupNone 1
#define XLookupChars 2
#define XLookupKeySym 3
#define XLookupBoth 4
-#if NeedFunctionPrototypes
typedef void *XVaNestedList;
-#else
-typedef XPointer XVaNestedList;
-#endif
typedef struct {
XPointer client_data;
XIMProc callback;
} XIMCallback;
+typedef struct {
+ XPointer client_data;
+ XICProc callback;
+} XICCallback;
+
typedef unsigned long XIMFeedback;
-#define XIMReverse 1
-#define XIMUnderline (1<<1)
-#define XIMHighlight (1<<2)
-#define XIMPrimary (1<<5)
-#define XIMSecondary (1<<6)
-#define XIMTertiary (1<<7)
+#define XIMReverse 1L
+#define XIMUnderline (1L<<1)
+#define XIMHighlight (1L<<2)
+#define XIMPrimary (1L<<5)
+#define XIMSecondary (1L<<6)
+#define XIMTertiary (1L<<7)
+#define XIMVisibleToForward (1L<<8)
+#define XIMVisibleToBackword (1L<<9)
+#define XIMVisibleToCenter (1L<<10)
typedef struct _XIMText {
unsigned short length;
@@ -1125,15 +1300,57 @@ typedef struct _XIMText {
Bool encoding_is_wchar;
union {
char *multi_byte;
+ wchar_t *wide_char;
} string;
} XIMText;
-typedef struct _XIMPreeditDrawCallbackStruct {
- int caret; /* Cursor offset within pre-edit string */
- int chg_first; /* Starting change position */
- int chg_length; /* Length of the change in character count */
- XIMText *text;
-} XIMPreeditDrawCallbackStruct;
+typedef unsigned long XIMPreeditState;
+
+#define XIMPreeditUnKnown 0L
+#define XIMPreeditEnable 1L
+#define XIMPreeditDisable (1L<<1)
+
+typedef struct _XIMPreeditStateNotifyCallbackStruct {
+ XIMPreeditState state;
+} XIMPreeditStateNotifyCallbackStruct;
+
+typedef unsigned long XIMResetState;
+
+#define XIMInitialState 1L
+#define XIMPreserveState (1L<<1)
+
+typedef unsigned long XIMStringConversionFeedback;
+
+#define XIMStringConversionLeftEdge (0x00000001)
+#define XIMStringConversionRightEdge (0x00000002)
+#define XIMStringConversionTopEdge (0x00000004)
+#define XIMStringConversionBottomEdge (0x00000008)
+#define XIMStringConversionConcealed (0x00000010)
+#define XIMStringConversionWrapped (0x00000020)
+
+typedef struct _XIMStringConversionText {
+ unsigned short length;
+ XIMStringConversionFeedback *feedback;
+ Bool encoding_is_wchar;
+ union {
+ char *mbs;
+ wchar_t *wcs;
+ } string;
+} XIMStringConversionText;
+
+typedef unsigned short XIMStringConversionPosition;
+
+typedef unsigned short XIMStringConversionType;
+
+#define XIMStringConversionBuffer (0x0001)
+#define XIMStringConversionLine (0x0002)
+#define XIMStringConversionWord (0x0003)
+#define XIMStringConversionChar (0x0004)
+
+typedef unsigned short XIMStringConversionOperation;
+
+#define XIMStringConversionSubstitution (0x0001)
+#define XIMStringConversionRetrieval (0x0002)
typedef enum {
XIMForwardChar, XIMBackwardChar,
@@ -1145,6 +1362,21 @@ typedef enum {
XIMDontChange
} XIMCaretDirection;
+typedef struct _XIMStringConversionCallbackStruct {
+ XIMStringConversionPosition position;
+ XIMCaretDirection direction;
+ XIMStringConversionOperation operation;
+ unsigned short factor;
+ XIMStringConversionText *text;
+} XIMStringConversionCallbackStruct;
+
+typedef struct _XIMPreeditDrawCallbackStruct {
+ int caret; /* Cursor offset within pre-edit string */
+ int chg_first; /* Starting change position */
+ int chg_length; /* Length of the change in character count */
+ XIMText *text;
+} XIMPreeditDrawCallbackStruct;
+
typedef enum {
XIMIsInvisible, /* Disable caret feedback */
XIMIsPrimary, /* UI defined caret feedback */
@@ -1170,24 +1402,2655 @@ typedef struct _XIMStatusDrawCallbackStruct {
} data;
} XIMStatusDrawCallbackStruct;
+typedef struct _XIMHotKeyTrigger {
+ KeySym keysym;
+ int modifier;
+ int modifier_mask;
+} XIMHotKeyTrigger;
+
+typedef struct _XIMHotKeyTriggers {
+ int num_hot_key;
+ XIMHotKeyTrigger *key;
+} XIMHotKeyTriggers;
+
+typedef unsigned long XIMHotKeyState;
+
+#define XIMHotKeyStateON (0x0001L)
+#define XIMHotKeyStateOFF (0x0002L)
+
+typedef struct {
+ unsigned short count_values;
+ char **supported_values;
+} XIMValuesList;
+
+_XFUNCPROTOBEGIN
+
+#if defined(WIN32) && !defined(_XLIBINT_)
+#define _Xdebug *_Xdebug_p
+#endif
+
+EXTERN int _Xdebug;
+
+EXTERN XFontStruct *XLoadQueryFont(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+
+EXTERN XFontStruct *XQueryFont(
+ Display* /* display */,
+ XID /* font_ID */
+);
+
+
+EXTERN XTimeCoord *XGetMotionEvents(
+ Display* /* display */,
+ Window /* w */,
+ Time /* start */,
+ Time /* stop */,
+ int* /* nevents_return */
+);
+
+EXTERN XModifierKeymap *XDeleteModifiermapEntry(
+ XModifierKeymap* /* modmap */,
+#if NeedWidePrototypes
+ unsigned int /* keycode_entry */,
+#else
+ KeyCode /* keycode_entry */,
+#endif
+ int /* modifier */
+);
+
+EXTERN XModifierKeymap *XGetModifierMapping(
+ Display* /* display */
+);
+
+EXTERN XModifierKeymap *XInsertModifiermapEntry(
+ XModifierKeymap* /* modmap */,
+#if NeedWidePrototypes
+ unsigned int /* keycode_entry */,
+#else
+ KeyCode /* keycode_entry */,
+#endif
+ int /* modifier */
+);
+
+EXTERN XModifierKeymap *XNewModifiermap(
+ int /* max_keys_per_mod */
+);
+
+EXTERN XImage *XCreateImage(
+ Display* /* display */,
+ Visual* /* visual */,
+ unsigned int /* depth */,
+ int /* format */,
+ int /* offset */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* bitmap_pad */,
+ int /* bytes_per_line */
+);
+EXTERN Status XInitImage(
+ XImage* /* image */
+);
+EXTERN XImage *XGetImage(
+ Display* /* display */,
+ Drawable /* d */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* plane_mask */,
+ int /* format */
+);
+EXTERN XImage *XGetSubImage(
+ Display* /* display */,
+ Drawable /* d */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* plane_mask */,
+ int /* format */,
+ XImage* /* dest_image */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+/*
+ * X function declarations.
+ */
+EXTERN Display *XOpenDisplay(
+ _Xconst char* /* display_name */
+);
+
+EXTERN void XrmInitialize(
+ void
+);
+
+EXTERN char *XFetchBytes(
+ Display* /* display */,
+ int* /* nbytes_return */
+);
+EXTERN char *XFetchBuffer(
+ Display* /* display */,
+ int* /* nbytes_return */,
+ int /* buffer */
+);
+EXTERN char *XGetAtomName(
+ Display* /* display */,
+ Atom /* atom */
+);
+EXTERN Status XGetAtomNames(
+ Display* /* dpy */,
+ Atom* /* atoms */,
+ int /* count */,
+ char** /* names_return */
+);
+EXTERN char *XGetDefault(
+ Display* /* display */,
+ _Xconst char* /* program */,
+ _Xconst char* /* option */
+);
+EXTERN char *XDisplayName(
+ _Xconst char* /* string */
+);
+EXTERN char *XKeysymToString(
+ KeySym /* keysym */
+);
+
+EXTERN int (*XSynchronize(
+ Display* /* display */,
+ Bool /* onoff */
+))(
+ Display* /* display */
+);
+EXTERN int (*XSetAfterFunction(
+ Display* /* display */,
+ int (*) (
+ Display* /* display */
+ ) /* procedure */
+))(
+ Display* /* display */
+);
+EXTERN Atom XInternAtom(
+ Display* /* display */,
+ _Xconst char* /* atom_name */,
+ Bool /* only_if_exists */
+);
+EXTERN Status XInternAtoms(
+ Display* /* dpy */,
+ char** /* names */,
+ int /* count */,
+ Bool /* onlyIfExists */,
+ Atom* /* atoms_return */
+);
+EXTERN Colormap XCopyColormapAndFree(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+EXTERN Colormap XCreateColormap(
+ Display* /* display */,
+ Window /* w */,
+ Visual* /* visual */,
+ int /* alloc */
+);
+EXTERN Cursor XCreatePixmapCursor(
+ Display* /* display */,
+ Pixmap /* source */,
+ Pixmap /* mask */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */,
+ unsigned int /* x */,
+ unsigned int /* y */
+);
+EXTERN Cursor XCreateGlyphCursor(
+ Display* /* display */,
+ Font /* source_font */,
+ Font /* mask_font */,
+ unsigned int /* source_char */,
+ unsigned int /* mask_char */,
+ XColor _Xconst * /* foreground_color */,
+ XColor _Xconst * /* background_color */
+);
+EXTERN Cursor XCreateFontCursor(
+ Display* /* display */,
+ unsigned int /* shape */
+);
+EXTERN Font XLoadFont(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+EXTERN GC XCreateGC(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values */
+);
+EXTERN GContext XGContextFromGC(
+ GC /* gc */
+);
+EXTERN void XFlushGC(
+ Display* /* display */,
+ GC /* gc */
+);
+EXTERN Pixmap XCreatePixmap(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* depth */
+);
+EXTERN Pixmap XCreateBitmapFromData(
+ Display* /* display */,
+ Drawable /* d */,
+ _Xconst char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+EXTERN Pixmap XCreatePixmapFromBitmapData(
+ Display* /* display */,
+ Drawable /* d */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* fg */,
+ unsigned long /* bg */,
+ unsigned int /* depth */
+);
+EXTERN Window XCreateSimpleWindow(
+ Display* /* display */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* border_width */,
+ unsigned long /* border */,
+ unsigned long /* background */
+);
+EXTERN Window XGetSelectionOwner(
+ Display* /* display */,
+ Atom /* selection */
+);
+EXTERN Window XCreateWindow(
+ Display* /* display */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* border_width */,
+ int /* depth */,
+ unsigned int /* class */,
+ Visual* /* visual */,
+ unsigned long /* valuemask */,
+ XSetWindowAttributes* /* attributes */
+);
+EXTERN Colormap *XListInstalledColormaps(
+ Display* /* display */,
+ Window /* w */,
+ int* /* num_return */
+);
+EXTERN char **XListFonts(
+ Display* /* display */,
+ _Xconst char* /* pattern */,
+ int /* maxnames */,
+ int* /* actual_count_return */
+);
+EXTERN char **XListFontsWithInfo(
+ Display* /* display */,
+ _Xconst char* /* pattern */,
+ int /* maxnames */,
+ int* /* count_return */,
+ XFontStruct** /* info_return */
+);
+EXTERN char **XGetFontPath(
+ Display* /* display */,
+ int* /* npaths_return */
+);
+EXTERN char **XListExtensions(
+ Display* /* display */,
+ int* /* nextensions_return */
+);
+EXTERN Atom *XListProperties(
+ Display* /* display */,
+ Window /* w */,
+ int* /* num_prop_return */
+);
+EXTERN XHostAddress *XListHosts(
+ Display* /* display */,
+ int* /* nhosts_return */,
+ Bool* /* state_return */
+);
+EXTERN _X_DEPRECATED KeySym XKeycodeToKeysym(
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* keycode */,
+#else
+ KeyCode /* keycode */,
+#endif
+ int /* index */
+);
+EXTERN KeySym XLookupKeysym(
+ XKeyEvent* /* key_event */,
+ int /* index */
+);
+EXTERN KeySym *XGetKeyboardMapping(
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* first_keycode */,
+#else
+ KeyCode /* first_keycode */,
+#endif
+ int /* keycode_count */,
+ int* /* keysyms_per_keycode_return */
+);
+EXTERN KeySym XStringToKeysym(
+ _Xconst char* /* string */
+);
+EXTERN long XMaxRequestSize(
+ Display* /* display */
+);
+EXTERN long XExtendedMaxRequestSize(
+ Display* /* display */
+);
+EXTERN char *XResourceManagerString(
+ Display* /* display */
+);
+EXTERN char *XScreenResourceString(
+ Screen* /* screen */
+);
+EXTERN unsigned long XDisplayMotionBufferSize(
+ Display* /* display */
+);
+EXTERN VisualID XVisualIDFromVisual(
+ Visual* /* visual */
+);
+
+/* multithread routines */
+
+EXTERN Status XInitThreads(
+ void
+);
+
+EXTERN void XLockDisplay(
+ Display* /* display */
+);
+
+EXTERN void XUnlockDisplay(
+ Display* /* display */
+);
+
+/* routines for dealing with extensions */
+
+EXTERN XExtCodes *XInitExtension(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+
+EXTERN XExtCodes *XAddExtension(
+ Display* /* display */
+);
+EXTERN XExtData *XFindOnExtensionList(
+ XExtData** /* structure */,
+ int /* number */
+);
+EXTERN XExtData **XEHeadOfExtensionList(
+ XEDataObject /* object */
+);
+
+/* these are routines for which there are also macros */
+EXTERN Window XRootWindow(
+ Display* /* display */,
+ int /* screen_number */
+);
+EXTERN Window XDefaultRootWindow(
+ Display* /* display */
+);
+EXTERN Window XRootWindowOfScreen(
+ Screen* /* screen */
+);
+EXTERN Visual *XDefaultVisual(
+ Display* /* display */,
+ int /* screen_number */
+);
+EXTERN Visual *XDefaultVisualOfScreen(
+ Screen* /* screen */
+);
+EXTERN GC XDefaultGC(
+ Display* /* display */,
+ int /* screen_number */
+);
+EXTERN GC XDefaultGCOfScreen(
+ Screen* /* screen */
+);
+EXTERN unsigned long XBlackPixel(
+ Display* /* display */,
+ int /* screen_number */
+);
+EXTERN unsigned long XWhitePixel(
+ Display* /* display */,
+ int /* screen_number */
+);
+EXTERN unsigned long XAllPlanes(
+ void
+);
+EXTERN unsigned long XBlackPixelOfScreen(
+ Screen* /* screen */
+);
+EXTERN unsigned long XWhitePixelOfScreen(
+ Screen* /* screen */
+);
+EXTERN unsigned long XNextRequest(
+ Display* /* display */
+);
+EXTERN unsigned long XLastKnownRequestProcessed(
+ Display* /* display */
+);
+EXTERN char *XServerVendor(
+ Display* /* display */
+);
+EXTERN char *XDisplayString(
+ Display* /* display */
+);
+EXTERN Colormap XDefaultColormap(
+ Display* /* display */,
+ int /* screen_number */
+);
+EXTERN Colormap XDefaultColormapOfScreen(
+ Screen* /* screen */
+);
+EXTERN Display *XDisplayOfScreen(
+ Screen* /* screen */
+);
+EXTERN Screen *XScreenOfDisplay(
+ Display* /* display */,
+ int /* screen_number */
+);
+EXTERN Screen *XDefaultScreenOfDisplay(
+ Display* /* display */
+);
+EXTERN long XEventMaskOfScreen(
+ Screen* /* screen */
+);
+
+EXTERN int XScreenNumberOfScreen(
+ Screen* /* screen */
+);
+
typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */
-#if NeedFunctionPrototypes
Display* /* display */,
XErrorEvent* /* error_event */
-#endif
);
-_XFUNCPROTOBEGIN
+EXTERN XErrorHandler XSetErrorHandler (
+ XErrorHandler /* handler */
+);
+typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */
+ Display* /* display */
+);
-#include "tkIntXlibDecls.h"
+EXTERN XIOErrorHandler XSetIOErrorHandler (
+ XIOErrorHandler /* handler */
+);
-_XFUNCPROTOEND
-#if defined(MAC_OSX_TK)
-# undef Cursor
-# undef Region
+EXTERN XPixmapFormatValues *XListPixmapFormats(
+ Display* /* display */,
+ int* /* count_return */
+);
+EXTERN int *XListDepths(
+ Display* /* display */,
+ int /* screen_number */,
+ int* /* count_return */
+);
+
+/* ICCCM routines for things that don't require special include files; */
+/* other declarations are given in Xutil.h */
+EXTERN Status XReconfigureWMWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */,
+ unsigned int /* mask */,
+ XWindowChanges* /* changes */
+);
+
+EXTERN Status XGetWMProtocols(
+ Display* /* display */,
+ Window /* w */,
+ Atom** /* protocols_return */,
+ int* /* count_return */
+);
+EXTERN Status XSetWMProtocols(
+ Display* /* display */,
+ Window /* w */,
+ Atom* /* protocols */,
+ int /* count */
+);
+EXTERN Status XIconifyWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */
+);
+EXTERN Status XWithdrawWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */
+);
+EXTERN Status XGetCommand(
+ Display* /* display */,
+ Window /* w */,
+ char*** /* argv_return */,
+ int* /* argc_return */
+);
+EXTERN Status XGetWMColormapWindows(
+ Display* /* display */,
+ Window /* w */,
+ Window** /* windows_return */,
+ int* /* count_return */
+);
+EXTERN Status XSetWMColormapWindows(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* colormap_windows */,
+ int /* count */
+);
+EXTERN void XFreeStringList(
+ char** /* list */
+);
+EXTERN int XSetTransientForHint(
+ Display* /* display */,
+ Window /* w */,
+ Window /* prop_window */
+);
+
+/* The following are given in alphabetical order */
+
+EXTERN int XActivateScreenSaver(
+ Display* /* display */
+);
+
+EXTERN int XAddHost(
+ Display* /* display */,
+ XHostAddress* /* host */
+);
+
+EXTERN int XAddHosts(
+ Display* /* display */,
+ XHostAddress* /* hosts */,
+ int /* num_hosts */
+);
+
+EXTERN int XAddToExtensionList(
+ struct _XExtData** /* structure */,
+ XExtData* /* ext_data */
+);
+
+EXTERN int XAddToSaveSet(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN Status XAllocColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* screen_in_out */
+);
+
+EXTERN Status XAllocColorCells(
+ Display* /* display */,
+ Colormap /* colormap */,
+ Bool /* contig */,
+ unsigned long* /* plane_masks_return */,
+ unsigned int /* nplanes */,
+ unsigned long* /* pixels_return */,
+ unsigned int /* npixels */
+);
+
+EXTERN Status XAllocColorPlanes(
+ Display* /* display */,
+ Colormap /* colormap */,
+ Bool /* contig */,
+ unsigned long* /* pixels_return */,
+ int /* ncolors */,
+ int /* nreds */,
+ int /* ngreens */,
+ int /* nblues */,
+ unsigned long* /* rmask_return */,
+ unsigned long* /* gmask_return */,
+ unsigned long* /* bmask_return */
+);
+
+EXTERN Status XAllocNamedColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_name */,
+ XColor* /* screen_def_return */,
+ XColor* /* exact_def_return */
+);
+
+EXTERN int XAllowEvents(
+ Display* /* display */,
+ int /* event_mode */,
+ Time /* time */
+);
+
+EXTERN int XAutoRepeatOff(
+ Display* /* display */
+);
+
+EXTERN int XAutoRepeatOn(
+ Display* /* display */
+);
+
+EXTERN int XBell(
+ Display* /* display */,
+ int /* percent */
+);
+
+EXTERN int XBitmapBitOrder(
+ Display* /* display */
+);
+
+EXTERN int XBitmapPad(
+ Display* /* display */
+);
+
+EXTERN int XBitmapUnit(
+ Display* /* display */
+);
+
+EXTERN int XCellsOfScreen(
+ Screen* /* screen */
+);
+
+EXTERN int XChangeActivePointerGrab(
+ Display* /* display */,
+ unsigned int /* event_mask */,
+ Cursor /* cursor */,
+ Time /* time */
+);
+
+EXTERN int XChangeGC(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values */
+);
+
+EXTERN int XChangeKeyboardControl(
+ Display* /* display */,
+ unsigned long /* value_mask */,
+ XKeyboardControl* /* values */
+);
+
+EXTERN int XChangeKeyboardMapping(
+ Display* /* display */,
+ int /* first_keycode */,
+ int /* keysyms_per_keycode */,
+ KeySym* /* keysyms */,
+ int /* num_codes */
+);
+
+EXTERN int XChangePointerControl(
+ Display* /* display */,
+ Bool /* do_accel */,
+ Bool /* do_threshold */,
+ int /* accel_numerator */,
+ int /* accel_denominator */,
+ int /* threshold */
+);
+
+EXTERN int XChangeProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */,
+ Atom /* type */,
+ int /* format */,
+ int /* mode */,
+ _Xconst unsigned char* /* data */,
+ int /* nelements */
+);
+
+EXTERN int XChangeSaveSet(
+ Display* /* display */,
+ Window /* w */,
+ int /* change_mode */
+);
+
+EXTERN int XChangeWindowAttributes(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* valuemask */,
+ XSetWindowAttributes* /* attributes */
+);
+
+EXTERN Bool XCheckIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+EXTERN Bool XCheckMaskEvent(
+ Display* /* display */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+EXTERN Bool XCheckTypedEvent(
+ Display* /* display */,
+ int /* event_type */,
+ XEvent* /* event_return */
+);
+
+EXTERN Bool XCheckTypedWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ int /* event_type */,
+ XEvent* /* event_return */
+);
+
+EXTERN Bool XCheckWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+EXTERN int XCirculateSubwindows(
+ Display* /* display */,
+ Window /* w */,
+ int /* direction */
+);
+
+EXTERN int XCirculateSubwindowsDown(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XCirculateSubwindowsUp(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XClearArea(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ Bool /* exposures */
+);
+
+EXTERN int XClearWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XCloseDisplay(
+ Display* /* display */
+);
+
+EXTERN int XConfigureWindow(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* value_mask */,
+ XWindowChanges* /* values */
+);
+
+EXTERN int XConnectionNumber(
+ Display* /* display */
+);
+
+EXTERN int XConvertSelection(
+ Display* /* display */,
+ Atom /* selection */,
+ Atom /* target */,
+ Atom /* property */,
+ Window /* requestor */,
+ Time /* time */
+);
+
+EXTERN int XCopyArea(
+ Display* /* display */,
+ Drawable /* src */,
+ Drawable /* dest */,
+ GC /* gc */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+EXTERN int XCopyGC(
+ Display* /* display */,
+ GC /* src */,
+ unsigned long /* valuemask */,
+ GC /* dest */
+);
+
+EXTERN int XCopyPlane(
+ Display* /* display */,
+ Drawable /* src */,
+ Drawable /* dest */,
+ GC /* gc */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* dest_x */,
+ int /* dest_y */,
+ unsigned long /* plane */
+);
+
+EXTERN int XDefaultDepth(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+EXTERN int XDefaultDepthOfScreen(
+ Screen* /* screen */
+);
+
+EXTERN int XDefaultScreen(
+ Display* /* display */
+);
+
+EXTERN int XDefineCursor(
+ Display* /* display */,
+ Window /* w */,
+ Cursor /* cursor */
+);
+
+EXTERN int XDeleteProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */
+);
+
+EXTERN int XDestroyWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XDestroySubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XDoesBackingStore(
+ Screen* /* screen */
+);
+
+EXTERN Bool XDoesSaveUnders(
+ Screen* /* screen */
+);
+
+EXTERN int XDisableAccessControl(
+ Display* /* display */
+);
+
+
+EXTERN int XDisplayCells(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+EXTERN int XDisplayHeight(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+EXTERN int XDisplayHeightMM(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+EXTERN int XDisplayKeycodes(
+ Display* /* display */,
+ int* /* min_keycodes_return */,
+ int* /* max_keycodes_return */
+);
+
+EXTERN int XDisplayPlanes(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+EXTERN int XDisplayWidth(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+EXTERN int XDisplayWidthMM(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+EXTERN int XDrawArc(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* angle1 */,
+ int /* angle2 */
+);
+
+EXTERN int XDrawArcs(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XArc* /* arcs */,
+ int /* narcs */
+);
+
+EXTERN int XDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* string */,
+ int /* length */
+);
+
+EXTERN int XDrawImageString16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst XChar2b* /* string */,
+ int /* length */
+);
+
+EXTERN int XDrawLine(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x1 */,
+ int /* y1 */,
+ int /* x2 */,
+ int /* y2 */
+);
+
+EXTERN int XDrawLines(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* mode */
+);
+
+EXTERN int XDrawPoint(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */
+);
+
+EXTERN int XDrawPoints(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* mode */
+);
+
+EXTERN int XDrawRectangle(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+EXTERN int XDrawRectangles(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XRectangle* /* rectangles */,
+ int /* nrectangles */
+);
+
+EXTERN int XDrawSegments(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XSegment* /* segments */,
+ int /* nsegments */
+);
+
+EXTERN int XDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* string */,
+ int /* length */
+);
+
+EXTERN int XDrawString16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst XChar2b* /* string */,
+ int /* length */
+);
+
+EXTERN int XDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XTextItem* /* items */,
+ int /* nitems */
+);
+
+EXTERN int XDrawText16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XTextItem16* /* items */,
+ int /* nitems */
+);
+
+EXTERN int XEnableAccessControl(
+ Display* /* display */
+);
+
+EXTERN int XEventsQueued(
+ Display* /* display */,
+ int /* mode */
+);
+
+EXTERN Status XFetchName(
+ Display* /* display */,
+ Window /* w */,
+ char** /* window_name_return */
+);
+
+EXTERN int XFillArc(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* angle1 */,
+ int /* angle2 */
+);
+
+EXTERN int XFillArcs(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XArc* /* arcs */,
+ int /* narcs */
+);
+
+EXTERN int XFillPolygon(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* shape */,
+ int /* mode */
+);
+
+EXTERN int XFillRectangle(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+EXTERN int XFillRectangles(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XRectangle* /* rectangles */,
+ int /* nrectangles */
+);
+
+EXTERN int XFlush(
+ Display* /* display */
+);
+
+EXTERN int XForceScreenSaver(
+ Display* /* display */,
+ int /* mode */
+);
+
+EXTERN int XFree(
+ void* /* data */
+);
+
+EXTERN int XFreeColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+EXTERN int XFreeColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ unsigned long* /* pixels */,
+ int /* npixels */,
+ unsigned long /* planes */
+);
+
+EXTERN int XFreeCursor(
+ Display* /* display */,
+ Cursor /* cursor */
+);
+
+EXTERN int XFreeExtensionList(
+ char** /* list */
+);
+
+EXTERN int XFreeFont(
+ Display* /* display */,
+ XFontStruct* /* font_struct */
+);
+
+EXTERN int XFreeFontInfo(
+ char** /* names */,
+ XFontStruct* /* free_info */,
+ int /* actual_count */
+);
+
+EXTERN int XFreeFontNames(
+ char** /* list */
+);
+
+EXTERN int XFreeFontPath(
+ char** /* list */
+);
+
+EXTERN int XFreeGC(
+ Display* /* display */,
+ GC /* gc */
+);
+
+EXTERN int XFreeModifiermap(
+ XModifierKeymap* /* modmap */
+);
+
+EXTERN int XFreePixmap(
+ Display* /* display */,
+ Pixmap /* pixmap */
+);
+
+EXTERN int XGeometry(
+ Display* /* display */,
+ int /* screen */,
+ _Xconst char* /* position */,
+ _Xconst char* /* default_position */,
+ unsigned int /* bwidth */,
+ unsigned int /* fwidth */,
+ unsigned int /* fheight */,
+ int /* xadder */,
+ int /* yadder */,
+ int* /* x_return */,
+ int* /* y_return */,
+ int* /* width_return */,
+ int* /* height_return */
+);
+
+EXTERN int XGetErrorDatabaseText(
+ Display* /* display */,
+ _Xconst char* /* name */,
+ _Xconst char* /* message */,
+ _Xconst char* /* default_string */,
+ char* /* buffer_return */,
+ int /* length */
+);
+
+EXTERN int XGetErrorText(
+ Display* /* display */,
+ int /* code */,
+ char* /* buffer_return */,
+ int /* length */
+);
+
+EXTERN Bool XGetFontProperty(
+ XFontStruct* /* font_struct */,
+ Atom /* atom */,
+ unsigned long* /* value_return */
+);
+
+EXTERN Status XGetGCValues(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values_return */
+);
+
+EXTERN Status XGetGeometry(
+ Display* /* display */,
+ Drawable /* d */,
+ Window* /* root_return */,
+ int* /* x_return */,
+ int* /* y_return */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned int* /* border_width_return */,
+ unsigned int* /* depth_return */
+);
+
+EXTERN Status XGetIconName(
+ Display* /* display */,
+ Window /* w */,
+ char** /* icon_name_return */
+);
+
+EXTERN int XGetInputFocus(
+ Display* /* display */,
+ Window* /* focus_return */,
+ int* /* revert_to_return */
+);
+
+EXTERN int XGetKeyboardControl(
+ Display* /* display */,
+ XKeyboardState* /* values_return */
+);
+
+EXTERN int XGetPointerControl(
+ Display* /* display */,
+ int* /* accel_numerator_return */,
+ int* /* accel_denominator_return */,
+ int* /* threshold_return */
+);
+
+EXTERN int XGetPointerMapping(
+ Display* /* display */,
+ unsigned char* /* map_return */,
+ int /* nmap */
+);
+
+EXTERN int XGetScreenSaver(
+ Display* /* display */,
+ int* /* timeout_return */,
+ int* /* interval_return */,
+ int* /* prefer_blanking_return */,
+ int* /* allow_exposures_return */
+);
+
+EXTERN Status XGetTransientForHint(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* prop_window_return */
+);
+
+EXTERN int XGetWindowProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */,
+ long /* long_offset */,
+ long /* long_length */,
+ Bool /* delete */,
+ Atom /* req_type */,
+ Atom* /* actual_type_return */,
+ int* /* actual_format_return */,
+ unsigned long* /* nitems_return */,
+ unsigned long* /* bytes_after_return */,
+ unsigned char** /* prop_return */
+);
+
+EXTERN Status XGetWindowAttributes(
+ Display* /* display */,
+ Window /* w */,
+ XWindowAttributes* /* window_attributes_return */
+);
+
+EXTERN int XGrabButton(
+ Display* /* display */,
+ unsigned int /* button */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */
+);
+
+EXTERN int XGrabKey(
+ Display* /* display */,
+ int /* keycode */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */
+);
+
+EXTERN int XGrabKeyboard(
+ Display* /* display */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Time /* time */
+);
+
+EXTERN int XGrabPointer(
+ Display* /* display */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */,
+ Time /* time */
+);
+
+EXTERN int XGrabServer(
+ Display* /* display */
+);
+
+EXTERN int XHeightMMOfScreen(
+ Screen* /* screen */
+);
+
+EXTERN int XHeightOfScreen(
+ Screen* /* screen */
+);
+
+EXTERN int XIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+EXTERN int XImageByteOrder(
+ Display* /* display */
+);
+
+EXTERN int XInstallColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+EXTERN KeyCode XKeysymToKeycode(
+ Display* /* display */,
+ KeySym /* keysym */
+);
+
+EXTERN int XKillClient(
+ Display* /* display */,
+ XID /* resource */
+);
+
+EXTERN Status XLookupColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_name */,
+ XColor* /* exact_def_return */,
+ XColor* /* screen_def_return */
+);
+
+EXTERN int XLowerWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XMapRaised(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XMapSubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XMapWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XMaskEvent(
+ Display* /* display */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+EXTERN int XMaxCmapsOfScreen(
+ Screen* /* screen */
+);
+
+EXTERN int XMinCmapsOfScreen(
+ Screen* /* screen */
+);
+
+EXTERN int XMoveResizeWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+EXTERN int XMoveWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */
+);
+
+EXTERN int XNextEvent(
+ Display* /* display */,
+ XEvent* /* event_return */
+);
+
+EXTERN int XNoOp(
+ Display* /* display */
+);
+
+EXTERN Status XParseColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* spec */,
+ XColor* /* exact_def_return */
+);
+
+EXTERN int XParseGeometry(
+ _Xconst char* /* parsestring */,
+ int* /* x_return */,
+ int* /* y_return */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+EXTERN int XPeekEvent(
+ Display* /* display */,
+ XEvent* /* event_return */
+);
+
+EXTERN int XPeekIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+EXTERN int XPending(
+ Display* /* display */
+);
+
+EXTERN int XPlanesOfScreen(
+ Screen* /* screen */
+);
+
+EXTERN int XProtocolRevision(
+ Display* /* display */
+);
+
+EXTERN int XProtocolVersion(
+ Display* /* display */
+);
+
+
+EXTERN int XPutBackEvent(
+ Display* /* display */,
+ XEvent* /* event */
+);
+
+EXTERN int XPutImage(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XImage* /* image */,
+ int /* src_x */,
+ int /* src_y */,
+ int /* dest_x */,
+ int /* dest_y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+EXTERN int XQLength(
+ Display* /* display */
+);
+
+EXTERN Status XQueryBestCursor(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+EXTERN Status XQueryBestSize(
+ Display* /* display */,
+ int /* class */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+EXTERN Status XQueryBestStipple(
+ Display* /* display */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+EXTERN Status XQueryBestTile(
+ Display* /* display */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+EXTERN int XQueryColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* def_in_out */
+);
+
+EXTERN int XQueryColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* defs_in_out */,
+ int /* ncolors */
+);
+
+EXTERN Bool XQueryExtension(
+ Display* /* display */,
+ _Xconst char* /* name */,
+ int* /* major_opcode_return */,
+ int* /* first_event_return */,
+ int* /* first_error_return */
+);
+
+EXTERN int XQueryKeymap(
+ Display* /* display */,
+ char [32] /* keys_return */
+);
+
+EXTERN Bool XQueryPointer(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* root_return */,
+ Window* /* child_return */,
+ int* /* root_x_return */,
+ int* /* root_y_return */,
+ int* /* win_x_return */,
+ int* /* win_y_return */,
+ unsigned int* /* mask_return */
+);
+
+EXTERN int XQueryTextExtents(
+ Display* /* display */,
+ XID /* font_ID */,
+ _Xconst char* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+EXTERN int XQueryTextExtents16(
+ Display* /* display */,
+ XID /* font_ID */,
+ _Xconst XChar2b* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+EXTERN Status XQueryTree(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* root_return */,
+ Window* /* parent_return */,
+ Window** /* children_return */,
+ unsigned int* /* nchildren_return */
+);
+
+EXTERN int XRaiseWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XReadBitmapFile(
+ Display* /* display */,
+ Drawable /* d */,
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ Pixmap* /* bitmap_return */,
+ int* /* x_hot_return */,
+ int* /* y_hot_return */
+);
+
+EXTERN int XReadBitmapFileData(
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned char** /* data_return */,
+ int* /* x_hot_return */,
+ int* /* y_hot_return */
+);
+
+EXTERN int XRebindKeysym(
+ Display* /* display */,
+ KeySym /* keysym */,
+ KeySym* /* list */,
+ int /* mod_count */,
+ _Xconst unsigned char* /* string */,
+ int /* bytes_string */
+);
+
+EXTERN int XRecolorCursor(
+ Display* /* display */,
+ Cursor /* cursor */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */
+);
+
+EXTERN int XRefreshKeyboardMapping(
+ XMappingEvent* /* event_map */
+);
+
+EXTERN int XRemoveFromSaveSet(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XRemoveHost(
+ Display* /* display */,
+ XHostAddress* /* host */
+);
+
+EXTERN int XRemoveHosts(
+ Display* /* display */,
+ XHostAddress* /* hosts */,
+ int /* num_hosts */
+);
+
+EXTERN int XReparentWindow(
+ Display* /* display */,
+ Window /* w */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */
+);
+
+EXTERN int XResetScreenSaver(
+ Display* /* display */
+);
+
+EXTERN int XResizeWindow(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+EXTERN int XRestackWindows(
+ Display* /* display */,
+ Window* /* windows */,
+ int /* nwindows */
+);
+
+EXTERN int XRotateBuffers(
+ Display* /* display */,
+ int /* rotate */
+);
+
+EXTERN int XRotateWindowProperties(
+ Display* /* display */,
+ Window /* w */,
+ Atom* /* properties */,
+ int /* num_prop */,
+ int /* npositions */
+);
+
+EXTERN int XScreenCount(
+ Display* /* display */
+);
+
+EXTERN int XSelectInput(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */
+);
+
+EXTERN Status XSendEvent(
+ Display* /* display */,
+ Window /* w */,
+ Bool /* propagate */,
+ long /* event_mask */,
+ XEvent* /* event_send */
+);
+
+EXTERN int XSetAccessControl(
+ Display* /* display */,
+ int /* mode */
+);
+
+EXTERN int XSetArcMode(
+ Display* /* display */,
+ GC /* gc */,
+ int /* arc_mode */
+);
+
+EXTERN int XSetBackground(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* background */
+);
+
+EXTERN int XSetClipMask(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* pixmap */
+);
+
+EXTERN int XSetClipOrigin(
+ Display* /* display */,
+ GC /* gc */,
+ int /* clip_x_origin */,
+ int /* clip_y_origin */
+);
+
+EXTERN int XSetClipRectangles(
+ Display* /* display */,
+ GC /* gc */,
+ int /* clip_x_origin */,
+ int /* clip_y_origin */,
+ XRectangle* /* rectangles */,
+ int /* n */,
+ int /* ordering */
+);
+
+EXTERN int XSetCloseDownMode(
+ Display* /* display */,
+ int /* close_mode */
+);
+
+EXTERN int XSetCommand(
+ Display* /* display */,
+ Window /* w */,
+ char** /* argv */,
+ int /* argc */
+);
+
+EXTERN int XSetDashes(
+ Display* /* display */,
+ GC /* gc */,
+ int /* dash_offset */,
+ _Xconst char* /* dash_list */,
+ int /* n */
+);
+
+EXTERN int XSetFillRule(
+ Display* /* display */,
+ GC /* gc */,
+ int /* fill_rule */
+);
+
+EXTERN int XSetFillStyle(
+ Display* /* display */,
+ GC /* gc */,
+ int /* fill_style */
+);
+
+EXTERN int XSetFont(
+ Display* /* display */,
+ GC /* gc */,
+ Font /* font */
+);
+
+EXTERN int XSetFontPath(
+ Display* /* display */,
+ char** /* directories */,
+ int /* ndirs */
+);
+
+EXTERN int XSetForeground(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* foreground */
+);
+
+EXTERN int XSetFunction(
+ Display* /* display */,
+ GC /* gc */,
+ int /* function */
+);
+
+EXTERN int XSetGraphicsExposures(
+ Display* /* display */,
+ GC /* gc */,
+ Bool /* graphics_exposures */
+);
+
+EXTERN int XSetIconName(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* icon_name */
+);
+
+EXTERN int XSetInputFocus(
+ Display* /* display */,
+ Window /* focus */,
+ int /* revert_to */,
+ Time /* time */
+);
+
+EXTERN int XSetLineAttributes(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned int /* line_width */,
+ int /* line_style */,
+ int /* cap_style */,
+ int /* join_style */
+);
+
+EXTERN int XSetModifierMapping(
+ Display* /* display */,
+ XModifierKeymap* /* modmap */
+);
+
+EXTERN int XSetPlaneMask(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* plane_mask */
+);
+
+EXTERN int XSetPointerMapping(
+ Display* /* display */,
+ _Xconst unsigned char* /* map */,
+ int /* nmap */
+);
+
+EXTERN int XSetScreenSaver(
+ Display* /* display */,
+ int /* timeout */,
+ int /* interval */,
+ int /* prefer_blanking */,
+ int /* allow_exposures */
+);
+
+EXTERN int XSetSelectionOwner(
+ Display* /* display */,
+ Atom /* selection */,
+ Window /* owner */,
+ Time /* time */
+);
+
+EXTERN int XSetState(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* foreground */,
+ unsigned long /* background */,
+ int /* function */,
+ unsigned long /* plane_mask */
+);
+
+EXTERN int XSetStipple(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* stipple */
+);
+
+EXTERN int XSetSubwindowMode(
+ Display* /* display */,
+ GC /* gc */,
+ int /* subwindow_mode */
+);
+
+EXTERN int XSetTSOrigin(
+ Display* /* display */,
+ GC /* gc */,
+ int /* ts_x_origin */,
+ int /* ts_y_origin */
+);
+
+EXTERN int XSetTile(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* tile */
+);
+
+EXTERN int XSetWindowBackground(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* background_pixel */
+);
+
+EXTERN int XSetWindowBackgroundPixmap(
+ Display* /* display */,
+ Window /* w */,
+ Pixmap /* background_pixmap */
+);
+
+EXTERN int XSetWindowBorder(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* border_pixel */
+);
+
+EXTERN int XSetWindowBorderPixmap(
+ Display* /* display */,
+ Window /* w */,
+ Pixmap /* border_pixmap */
+);
+
+EXTERN int XSetWindowBorderWidth(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* width */
+);
+
+EXTERN int XSetWindowColormap(
+ Display* /* display */,
+ Window /* w */,
+ Colormap /* colormap */
+);
+
+EXTERN int XStoreBuffer(
+ Display* /* display */,
+ _Xconst char* /* bytes */,
+ int /* nbytes */,
+ int /* buffer */
+);
+
+EXTERN int XStoreBytes(
+ Display* /* display */,
+ _Xconst char* /* bytes */,
+ int /* nbytes */
+);
+
+EXTERN int XStoreColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* color */
+);
+
+EXTERN int XStoreColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* color */,
+ int /* ncolors */
+);
+
+EXTERN int XStoreName(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* window_name */
+);
+
+EXTERN int XStoreNamedColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color */,
+ unsigned long /* pixel */,
+ int /* flags */
+);
+
+EXTERN int XSync(
+ Display* /* display */,
+ Bool /* discard */
+);
+
+EXTERN int XTextExtents(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+EXTERN int XTextExtents16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+EXTERN int XTextWidth(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* count */
+);
+
+EXTERN int XTextWidth16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* count */
+);
+
+EXTERN Bool XTranslateCoordinates(
+ Display* /* display */,
+ Window /* src_w */,
+ Window /* dest_w */,
+ int /* src_x */,
+ int /* src_y */,
+ int* /* dest_x_return */,
+ int* /* dest_y_return */,
+ Window* /* child_return */
+);
+
+EXTERN int XUndefineCursor(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XUngrabButton(
+ Display* /* display */,
+ unsigned int /* button */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */
+);
+
+EXTERN int XUngrabKey(
+ Display* /* display */,
+ int /* keycode */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */
+);
+
+EXTERN int XUngrabKeyboard(
+ Display* /* display */,
+ Time /* time */
+);
+
+EXTERN int XUngrabPointer(
+ Display* /* display */,
+ Time /* time */
+);
+
+EXTERN int XUngrabServer(
+ Display* /* display */
+);
+
+EXTERN int XUninstallColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+EXTERN int XUnloadFont(
+ Display* /* display */,
+ Font /* font */
+);
+
+EXTERN int XUnmapSubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XUnmapWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+EXTERN int XVendorRelease(
+ Display* /* display */
+);
+
+EXTERN int XWarpPointer(
+ Display* /* display */,
+ Window /* src_w */,
+ Window /* dest_w */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* src_width */,
+ unsigned int /* src_height */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+EXTERN int XWidthMMOfScreen(
+ Screen* /* screen */
+);
+
+EXTERN int XWidthOfScreen(
+ Screen* /* screen */
+);
+
+EXTERN int XWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+EXTERN int XWriteBitmapFile(
+ Display* /* display */,
+ _Xconst char* /* filename */,
+ Pixmap /* bitmap */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* x_hot */,
+ int /* y_hot */
+);
+
+EXTERN Bool XSupportsLocale (void);
+
+EXTERN char *XSetLocaleModifiers(
+ const char* /* modifier_list */
+);
+
+EXTERN XOM XOpenOM(
+ Display* /* display */,
+ struct _XrmHashBucketRec* /* rdb */,
+ _Xconst char* /* res_name */,
+ _Xconst char* /* res_class */
+);
+
+EXTERN Status XCloseOM(
+ XOM /* om */
+);
+
+EXTERN char *XSetOMValues(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+EXTERN char *XGetOMValues(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+EXTERN Display *XDisplayOfOM(
+ XOM /* om */
+);
+
+EXTERN char *XLocaleOfOM(
+ XOM /* om */
+);
+
+EXTERN XOC XCreateOC(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+EXTERN void XDestroyOC(
+ XOC /* oc */
+);
+
+EXTERN XOM XOMOfOC(
+ XOC /* oc */
+);
+
+EXTERN char *XSetOCValues(
+ XOC /* oc */,
+ ...
+) _X_SENTINEL(0);
+
+EXTERN char *XGetOCValues(
+ XOC /* oc */,
+ ...
+) _X_SENTINEL(0);
+
+EXTERN XFontSet XCreateFontSet(
+ Display* /* display */,
+ _Xconst char* /* base_font_name_list */,
+ char*** /* missing_charset_list */,
+ int* /* missing_charset_count */,
+ char** /* def_string */
+);
+
+EXTERN void XFreeFontSet(
+ Display* /* display */,
+ XFontSet /* font_set */
+);
+
+EXTERN int XFontsOfFontSet(
+ XFontSet /* font_set */,
+ XFontStruct*** /* font_struct_list */,
+ char*** /* font_name_list */
+);
+
+EXTERN char *XBaseFontNameListOfFontSet(
+ XFontSet /* font_set */
+);
+
+EXTERN char *XLocaleOfFontSet(
+ XFontSet /* font_set */
+);
+
+EXTERN Bool XContextDependentDrawing(
+ XFontSet /* font_set */
+);
+
+EXTERN Bool XDirectionalDependentDrawing(
+ XFontSet /* font_set */
+);
+
+EXTERN Bool XContextualDrawing(
+ XFontSet /* font_set */
+);
+
+EXTERN XFontSetExtents *XExtentsOfFontSet(
+ XFontSet /* font_set */
+);
+
+EXTERN int XmbTextEscapement(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+EXTERN int XwcTextEscapement(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+EXTERN int Xutf8TextEscapement(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+EXTERN int XmbTextExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+EXTERN int XwcTextExtents(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+EXTERN int Xutf8TextExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+EXTERN Status XmbTextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+EXTERN Status XwcTextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+EXTERN Status Xutf8TextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+EXTERN void XmbDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XmbTextItem* /* text_items */,
+ int /* nitems */
+);
+
+EXTERN void XwcDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XwcTextItem* /* text_items */,
+ int /* nitems */
+);
+
+EXTERN void Xutf8DrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XmbTextItem* /* text_items */,
+ int /* nitems */
+);
+
+EXTERN void XmbDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+EXTERN void XwcDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+EXTERN void Xutf8DrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+EXTERN void XmbDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+EXTERN void XwcDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+EXTERN void Xutf8DrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+EXTERN XIM XOpenIM(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */
+);
+
+EXTERN Status XCloseIM(
+ XIM /* im */
+);
+
+EXTERN char *XGetIMValues(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+EXTERN char *XSetIMValues(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+EXTERN Display *XDisplayOfIM(
+ XIM /* im */
+);
+
+EXTERN char *XLocaleOfIM(
+ XIM /* im*/
+);
+
+EXTERN XIC XCreateIC(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+EXTERN void XDestroyIC(
+ XIC /* ic */
+);
+
+EXTERN void XSetICFocus(
+ XIC /* ic */
+);
+
+EXTERN void XUnsetICFocus(
+ XIC /* ic */
+);
+
+EXTERN wchar_t *XwcResetIC(
+ XIC /* ic */
+);
+
+EXTERN char *XmbResetIC(
+ XIC /* ic */
+);
+
+EXTERN char *Xutf8ResetIC(
+ XIC /* ic */
+);
+
+EXTERN char *XSetICValues(
+ XIC /* ic */, ...
+) _X_SENTINEL(0);
+
+EXTERN char *XGetICValues(
+ XIC /* ic */, ...
+) _X_SENTINEL(0);
+
+EXTERN XIM XIMOfIC(
+ XIC /* ic */
+);
+
+EXTERN Bool XFilterEvent(
+ XEvent* /* event */,
+ Window /* window */
+);
+
+EXTERN int XmbLookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+EXTERN int XwcLookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ wchar_t* /* buffer_return */,
+ int /* wchars_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+EXTERN int Xutf8LookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+EXTERN XVaNestedList XVaCreateNestedList(
+ int /*unused*/, ...
+) _X_SENTINEL(0);
+
+/* internal connections for IMs */
+
+EXTERN Bool XRegisterIMInstantiateCallback(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIDProc /* callback */,
+ XPointer /* client_data */
+);
+
+EXTERN Bool XUnregisterIMInstantiateCallback(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIDProc /* callback */,
+ XPointer /* client_data */
+);
+
+typedef void (*XConnectionWatchProc)(
+ Display* /* dpy */,
+ XPointer /* client_data */,
+ int /* fd */,
+ Bool /* opening */, /* open or close flag */
+ XPointer* /* watch_data */ /* open sets, close uses */
+);
+
+
+EXTERN Status XInternalConnectionNumbers(
+ Display* /* dpy */,
+ int** /* fd_return */,
+ int* /* count_return */
+);
+
+EXTERN void XProcessInternalConnection(
+ Display* /* dpy */,
+ int /* fd */
+);
+
+EXTERN Status XAddConnectionWatch(
+ Display* /* dpy */,
+ XConnectionWatchProc /* callback */,
+ XPointer /* client_data */
+);
+
+EXTERN void XRemoveConnectionWatch(
+ Display* /* dpy */,
+ XConnectionWatchProc /* callback */,
+ XPointer /* client_data */
+);
+
+EXTERN void XSetAuthorization(
+ char * /* name */,
+ int /* namelen */,
+ char * /* data */,
+ int /* datalen */
+);
+
+EXTERN int _Xmbtowc(
+ wchar_t * /* wstr */,
+ char * /* str */,
+ int /* len */
+);
+
+EXTERN int _Xwctomb(
+ char * /* str */,
+ wchar_t /* wc */
+);
+
+EXTERN Bool XGetEventData(
+ Display* /* dpy */,
+ XGenericEventCookie* /* cookie*/
+);
+
+EXTERN void XFreeEventData(
+ Display* /* dpy */,
+ XGenericEventCookie* /* cookie*/
+);
+
+#include "tkIntXlibDecls.h"
+
+#ifdef __clang__
+#pragma clang diagnostic pop
#endif
-#endif /* _XLIB_H_ */
+_XFUNCPROTOEND
+
+#endif /* _X11_XLIB_H_ */
diff --git a/xlib/X11/Xutil.h b/xlib/X11/Xutil.h
index 38ae9f5..6a22c97 100644
--- a/xlib/X11/Xutil.h
+++ b/xlib/X11/Xutil.h
@@ -1,8 +1,30 @@
-/* $XConsortium: Xutil.h,v 11.73 91/07/30 16:21:37 rws Exp $ */
/***********************************************************
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
-and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
@@ -10,7 +32,7 @@ Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
-supporting documentation, and that the names of Digital or MIT not be
+supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
@@ -24,13 +46,19 @@ SOFTWARE.
******************************************************************/
-#ifndef _XUTIL_H_
-#define _XUTIL_H_
+#ifndef _X11_XUTIL_H_
+#define _X11_XUTIL_H_
/* You must include <X11/Xlib.h> before including this file */
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
-#if defined(MAC_OSX_TK)
-# define Region XRegion
+/* The Xlib structs are full of implicit padding to properly align members.
+ We can't clean that up without breaking ABI, so tell clang not to bother
+ complaining about it. */
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
#endif
/*
@@ -112,6 +140,7 @@ typedef struct {
#define WindowGroupHint (1L << 6)
#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \
IconPositionHint|IconMaskHint|WindowGroupHint)
+#define XUrgencyHint (1L << 8)
/* definitions for initial window state */
#define WithdrawnState 0 /* for windows that are not mapped */
@@ -146,7 +175,9 @@ typedef enum {
XStringStyle, /* STRING */
XCompoundTextStyle, /* COMPOUND_TEXT */
XTextStyle, /* text in owner's encoding (current locale)*/
- XStdICCTextStyle /* STRING, else COMPOUND_TEXT */
+ XStdICCTextStyle, /* STRING, else COMPOUND_TEXT */
+ /* The following is an XFree86 extension, introduced in November 2000 */
+ XUTF8StringStyle /* UTF8_STRING */
} XICCEncodingStyle;
typedef struct {
@@ -160,6 +191,38 @@ typedef struct {
char *res_class;
} XClassHint;
+#ifndef EXTERN
+# define EXTERN extern TCL_STORAGE_CLASS
+#endif
+#if defined(STATIC_BUILD) || !defined(_WIN32)
+# ifndef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS
+# endif
+#elif defined(BUILD_tk)
+# undef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS __declspec(dllexport)
+#elif !defined(TCL_STORAGE_CLASS)
+# define TCL_STORAGE_CLASS __declspec(dllimport)
+#endif
+
+#ifdef XUTIL_DEFINE_FUNCTIONS
+EXTERN int XDestroyImage(
+ XImage *ximage);
+EXTERN unsigned long XGetPixel(
+ XImage *ximage,
+ int x, int y);
+EXTERN int XPutPixel(
+ XImage *ximage,
+ int x, int y,
+ unsigned long pixel);
+EXTERN XImage *XSubImage(
+ XImage *ximage,
+ int x, int y,
+ unsigned int width, unsigned int height);
+EXTERN int XAddPixel(
+ XImage *ximage,
+ long value);
+#else
/*
* These macros are used to give some sugar to the image routines so that
* naive people are more comfortable with them.
@@ -174,6 +237,7 @@ typedef struct {
((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height)))
#define XAddPixel(ximage, value) \
((*((ximage)->f.add_pixel))((ximage), (value)))
+#endif
/*
* Compose sequence status structure, used in calling XLookupString.
@@ -187,24 +251,36 @@ typedef struct _XComposeStatus {
* Keysym macros, used on Keysyms to test for classes of symbols
*/
#define IsKeypadKey(keysym) \
- (((unsigned)(keysym) >= XK_KP_Space) && ((unsigned)(keysym) <= XK_KP_Equal))
+ (((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal))
+
+#define IsPrivateKeypadKey(keysym) \
+ (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))
#define IsCursorKey(keysym) \
- (((unsigned)(keysym) >= XK_Home) && ((unsigned)(keysym) < XK_Select))
+ (((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select))
#define IsPFKey(keysym) \
- (((unsigned)(keysym) >= XK_KP_F1) && ((unsigned)(keysym) <= XK_KP_F4))
+ (((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4))
#define IsFunctionKey(keysym) \
- (((unsigned)(keysym) >= XK_F1) && ((unsigned)(keysym) <= XK_F35))
+ (((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35))
#define IsMiscFunctionKey(keysym) \
- (((unsigned)(keysym) >= XK_Select) && ((unsigned)(keysym) <= XK_Break))
+ (((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break))
+#ifdef XK_XKB_KEYS
+#define IsModifierKey(keysym) \
+ ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
+ || (((KeySym)(keysym) >= XK_ISO_Lock) && \
+ ((KeySym)(keysym) <= XK_ISO_Level5_Lock)) \
+ || ((KeySym)(keysym) == XK_Mode_switch) \
+ || ((KeySym)(keysym) == XK_Num_Lock))
+#else
#define IsModifierKey(keysym) \
- ((((unsigned)(keysym) >= XK_Shift_L) && ((unsigned)(keysym) <= XK_Hyper_R)) \
- || ((unsigned)(keysym) == XK_Mode_switch) \
- || ((unsigned)(keysym) == XK_Num_Lock))
+ ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
+ || ((KeySym)(keysym) == XK_Mode_switch) \
+ || ((KeySym)(keysym) == XK_Num_Lock))
+#endif
/*
* opaque reference to Region data type
*/
@@ -301,313 +377,258 @@ _XFUNCPROTOBEGIN
/* The following declarations are alphabetized. */
-extern XClassHint *XAllocClassHint (
-#if NeedFunctionPrototypes
+EXTERN XClassHint *XAllocClassHint (
void
-#endif
);
-extern XIconSize *XAllocIconSize (
-#if NeedFunctionPrototypes
+EXTERN XIconSize *XAllocIconSize (
void
-#endif
);
-extern XSizeHints *XAllocSizeHints (
-#if NeedFunctionPrototypes
+EXTERN XSizeHints *XAllocSizeHints (
void
-#endif
);
-extern XStandardColormap *XAllocStandardColormap (
-#if NeedFunctionPrototypes
+EXTERN XStandardColormap *XAllocStandardColormap (
void
-#endif
);
-extern XWMHints *XAllocWMHints (
-#if NeedFunctionPrototypes
+EXTERN XWMHints *XAllocWMHints (
void
-#endif
);
-extern void XClipBox(
-#if NeedFunctionPrototypes
+EXTERN int XClipBox(
Region /* r */,
XRectangle* /* rect_return */
-#endif
);
-extern Region XCreateRegion(
-#if NeedFunctionPrototypes
+EXTERN Region XCreateRegion(
void
-#endif
);
-extern char *XDefaultString(
-#if NeedFunctionPrototypes
- void
-#endif
-);
+EXTERN const char *XDefaultString (void);
-extern int XDeleteContext(
-#if NeedFunctionPrototypes
+EXTERN int XDeleteContext(
Display* /* display */,
XID /* rid */,
XContext /* context */
-#endif
);
-extern void XDestroyRegion(
-#if NeedFunctionPrototypes
+EXTERN int XDestroyRegion(
Region /* r */
-#endif
);
-extern Bool XEmptyRegion(
-#if NeedFunctionPrototypes
+EXTERN int XEmptyRegion(
Region /* r */
-#endif
);
-extern Bool XEqualRegion(
-#if NeedFunctionPrototypes
+EXTERN int XEqualRegion(
Region /* r1 */,
Region /* r2 */
-#endif
);
-extern int XFindContext(
-#if NeedFunctionPrototypes
+EXTERN int XFindContext(
Display* /* display */,
XID /* rid */,
XContext /* context */,
XPointer* /* data_return */
-#endif
);
-extern Status XGetClassHint(
-#if NeedFunctionPrototypes
+EXTERN Status XGetClassHint(
Display* /* display */,
Window /* w */,
XClassHint* /* class_hints_return */
-#endif
);
-extern Status XGetIconSizes(
-#if NeedFunctionPrototypes
+EXTERN Status XGetIconSizes(
Display* /* display */,
Window /* w */,
XIconSize** /* size_list_return */,
int* /* count_return */
-#endif
);
-extern Status XGetNormalHints(
-#if NeedFunctionPrototypes
+EXTERN Status XGetNormalHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* hints_return */
-#endif
);
-extern Status XGetRGBColormaps(
-#if NeedFunctionPrototypes
+EXTERN Status XGetRGBColormaps(
Display* /* display */,
Window /* w */,
XStandardColormap** /* stdcmap_return */,
int* /* count_return */,
Atom /* property */
-#endif
);
-extern Status XGetSizeHints(
-#if NeedFunctionPrototypes
+EXTERN Status XGetSizeHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* hints_return */,
Atom /* property */
-#endif
);
-extern Status XGetStandardColormap(
-#if NeedFunctionPrototypes
+EXTERN Status XGetStandardColormap(
Display* /* display */,
Window /* w */,
XStandardColormap* /* colormap_return */,
Atom /* property */
-#endif
);
-extern Status XGetTextProperty(
-#if NeedFunctionPrototypes
+EXTERN Status XGetTextProperty(
Display* /* display */,
Window /* window */,
XTextProperty* /* text_prop_return */,
Atom /* property */
-#endif
);
+EXTERN XVisualInfo *XGetVisualInfo(
+ Display* /* display */,
+ long /* vinfo_mask */,
+ XVisualInfo* /* vinfo_template */,
+ int* /* nitems_return */
+);
-extern Status XGetWMClientMachine(
-#if NeedFunctionPrototypes
+EXTERN Status XGetWMClientMachine(
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop_return */
-#endif
);
-extern XWMHints *XGetWMHints(
-#if NeedFunctionPrototypes
+EXTERN XWMHints *XGetWMHints(
Display* /* display */,
Window /* w */
-#endif
);
-extern Status XGetWMIconName(
-#if NeedFunctionPrototypes
+EXTERN Status XGetWMIconName(
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop_return */
-#endif
);
-extern Status XGetWMName(
-#if NeedFunctionPrototypes
+EXTERN Status XGetWMName(
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop_return */
-#endif
);
-extern Status XGetWMNormalHints(
-#if NeedFunctionPrototypes
+EXTERN Status XGetWMNormalHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* hints_return */,
long* /* supplied_return */
-#endif
);
-extern Status XGetWMSizeHints(
-#if NeedFunctionPrototypes
+EXTERN Status XGetWMSizeHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* hints_return */,
long* /* supplied_return */,
Atom /* property */
-#endif
);
-extern Status XGetZoomHints(
-#if NeedFunctionPrototypes
+EXTERN Status XGetZoomHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* zhints_return */
-#endif
);
-extern void XIntersectRegion(
-#if NeedFunctionPrototypes
+EXTERN int XIntersectRegion(
Region /* sra */,
Region /* srb */,
Region /* dr_return */
-#endif
);
-extern int XLookupString(
-#if NeedFunctionPrototypes
+EXTERN void XConvertCase(
+ KeySym /* sym */,
+ KeySym* /* lower */,
+ KeySym* /* upper */
+);
+
+EXTERN int XLookupString(
XKeyEvent* /* event_struct */,
char* /* buffer_return */,
int /* bytes_buffer */,
KeySym* /* keysym_return */,
XComposeStatus* /* status_in_out */
-#endif
);
-extern Status XMatchVisualInfo(
-#if NeedFunctionPrototypes
+EXTERN Status XMatchVisualInfo(
Display* /* display */,
int /* screen */,
int /* depth */,
int /* class */,
XVisualInfo* /* vinfo_return */
-#endif
);
-extern int XOffsetRegion(
-#if NeedFunctionPrototypes
+EXTERN int XOffsetRegion(
Region /* r */,
int /* dx */,
int /* dy */
-#endif
);
-extern int XRectInRegion(
-#if NeedFunctionPrototypes
+EXTERN Bool XPointInRegion(
+ Region /* r */,
+ int /* x */,
+ int /* y */
+);
+
+EXTERN Region XPolygonRegion(
+ XPoint* /* points */,
+ int /* n */,
+ int /* fill_rule */
+);
+
+EXTERN int XRectInRegion(
Region /* r */,
int /* x */,
int /* y */,
unsigned int /* width */,
unsigned int /* height */
-#endif
);
-extern int XSaveContext(
-#if NeedFunctionPrototypes
+EXTERN int XSaveContext(
Display* /* display */,
XID /* rid */,
XContext /* context */,
_Xconst char* /* data */
-#endif
);
-extern void XSetClassHint(
-#if NeedFunctionPrototypes
+EXTERN int XSetClassHint(
Display* /* display */,
Window /* w */,
XClassHint* /* class_hints */
-#endif
);
-extern void XSetIconSizes(
-#if NeedFunctionPrototypes
+EXTERN int XSetIconSizes(
Display* /* display */,
Window /* w */,
XIconSize* /* size_list */,
int /* count */
-#endif
);
-extern void XSetNormalHints(
-#if NeedFunctionPrototypes
+EXTERN int XSetNormalHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* hints */
-#endif
);
-extern void XSetRGBColormaps(
-#if NeedFunctionPrototypes
+EXTERN void XSetRGBColormaps(
Display* /* display */,
Window /* w */,
XStandardColormap* /* stdcmaps */,
int /* count */,
Atom /* property */
-#endif
);
-extern void XSetSizeHints(
-#if NeedFunctionPrototypes
+EXTERN int XSetSizeHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* hints */,
Atom /* property */
-#endif
);
-extern void XSetStandardProperties(
-#if NeedFunctionPrototypes
+EXTERN int XSetStandardProperties(
Display* /* display */,
Window /* w */,
_Xconst char* /* window_name */,
@@ -616,52 +637,46 @@ extern void XSetStandardProperties(
char** /* argv */,
int /* argc */,
XSizeHints* /* hints */
-#endif
);
-extern void XSetTextProperty(
-#if NeedFunctionPrototypes
+EXTERN void XSetTextProperty(
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop */,
Atom /* property */
-#endif
);
-extern void XSetWMHints(
-#if NeedFunctionPrototypes
+EXTERN void XSetWMClientMachine(
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop */
+);
+
+EXTERN int XSetWMHints(
Display* /* display */,
Window /* w */,
XWMHints* /* wm_hints */
-#endif
);
-extern void XSetWMIconName(
-#if NeedFunctionPrototypes
+EXTERN void XSetWMIconName(
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop */
-#endif
);
-extern void XSetWMName(
-#if NeedFunctionPrototypes
+EXTERN void XSetWMName(
Display* /* display */,
Window /* w */,
XTextProperty* /* text_prop */
-#endif
);
-extern void XSetWMNormalHints(
-#if NeedFunctionPrototypes
+EXTERN void XSetWMNormalHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* hints */
-#endif
);
-extern void XSetWMProperties(
-#if NeedFunctionPrototypes
+EXTERN void XSetWMProperties(
Display* /* display */,
Window /* w */,
XTextProperty* /* window_name */,
@@ -671,11 +686,21 @@ extern void XSetWMProperties(
XSizeHints* /* normal_hints */,
XWMHints* /* wm_hints */,
XClassHint* /* class_hints */
-#endif
);
-extern void XmbSetWMProperties(
-#if NeedFunctionPrototypes
+EXTERN void XmbSetWMProperties(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* window_name */,
+ _Xconst char* /* icon_name */,
+ char** /* argv */,
+ int /* argc */,
+ XSizeHints* /* normal_hints */,
+ XWMHints* /* wm_hints */,
+ XClassHint* /* class_hints */
+);
+
+EXTERN void Xutf8SetWMProperties(
Display* /* display */,
Window /* w */,
_Xconst char* /* window_name */,
@@ -685,104 +710,120 @@ extern void XmbSetWMProperties(
XSizeHints* /* normal_hints */,
XWMHints* /* wm_hints */,
XClassHint* /* class_hints */
-#endif
);
-extern void XSetWMSizeHints(
-#if NeedFunctionPrototypes
+EXTERN void XSetWMSizeHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* hints */,
Atom /* property */
-#endif
);
-extern void XSetRegion(
-#if NeedFunctionPrototypes
+EXTERN int XSetRegion(
Display* /* display */,
GC /* gc */,
Region /* r */
-#endif
);
-extern void XSetStandardColormap(
-#if NeedFunctionPrototypes
+EXTERN void XSetStandardColormap(
Display* /* display */,
Window /* w */,
XStandardColormap* /* colormap */,
Atom /* property */
-#endif
);
-extern void XSetZoomHints(
-#if NeedFunctionPrototypes
+EXTERN int XSetZoomHints(
Display* /* display */,
Window /* w */,
XSizeHints* /* zhints */
-#endif
);
-extern void XShrinkRegion(
-#if NeedFunctionPrototypes
+EXTERN int XShrinkRegion(
Region /* r */,
int /* dx */,
int /* dy */
-#endif
);
-extern void XSubtractRegion(
-#if NeedFunctionPrototypes
+EXTERN Status XStringListToTextProperty(
+ char** /* list */,
+ int /* count */,
+ XTextProperty* /* text_prop_return */
+);
+
+EXTERN int XSubtractRegion(
Region /* sra */,
Region /* srb */,
Region /* dr_return */
-#endif
);
-extern int XmbTextListToTextProperty(
-#if NeedFunctionPrototypes
- Display* /* display */,
- char** /* list */,
- int /* count */,
- XICCEncodingStyle /* style */,
- XTextProperty* /* text_prop_return */
-#endif
+EXTERN int XmbTextListToTextProperty(
+ Display* display,
+ char** list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty* text_prop_return
);
-extern Status XTextPropertyToStringList(
-#if NeedFunctionPrototypes
- XTextProperty* /* text_prop */,
- char*** /* list_return */,
- int* /* count_return */
-#endif
+EXTERN int XwcTextListToTextProperty(
+ Display* display,
+ wchar_t** list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty* text_prop_return
);
-extern int XmbTextPropertyToTextList(
-#if NeedFunctionPrototypes
- Display* /* display */,
+EXTERN int Xutf8TextListToTextProperty(
+ Display* display,
+ char** list,
+ int count,
+ XICCEncodingStyle style,
+ XTextProperty* text_prop_return
+);
+
+EXTERN void XwcFreeStringList(
+ wchar_t** list
+);
+
+EXTERN Status XTextPropertyToStringList(
XTextProperty* /* text_prop */,
char*** /* list_return */,
int* /* count_return */
-#endif
);
-extern void XUnionRectWithRegion(
-#if NeedFunctionPrototypes
+EXTERN int XmbTextPropertyToTextList(
+ Display* display,
+ const XTextProperty* text_prop,
+ char*** list_return,
+ int* count_return
+);
+
+EXTERN int XwcTextPropertyToTextList(
+ Display* display,
+ const XTextProperty* text_prop,
+ wchar_t*** list_return,
+ int* count_return
+);
+
+EXTERN int Xutf8TextPropertyToTextList(
+ Display* display,
+ const XTextProperty* text_prop,
+ char*** list_return,
+ int* count_return
+);
+
+EXTERN int XUnionRectWithRegion(
XRectangle* /* rectangle */,
Region /* src_region */,
Region /* dest_region_return */
-#endif
);
-extern int XUnionRegion(
-#if NeedFunctionPrototypes
+EXTERN int XUnionRegion(
Region /* sra */,
Region /* srb */,
Region /* dr_return */
-#endif
);
-extern int XWMGeometry(
-#if NeedFunctionPrototypes
+EXTERN int XWMGeometry(
Display* /* display */,
int /* screen_number */,
_Xconst char* /* user_geometry */,
@@ -794,21 +835,18 @@ extern int XWMGeometry(
int* /* width_return */,
int* /* height_return */,
int* /* gravity_return */
-#endif
);
-extern void XXorRegion(
-#if NeedFunctionPrototypes
+EXTERN int XXorRegion(
Region /* sra */,
Region /* srb */,
Region /* dr_return */
-#endif
);
-_XFUNCPROTOEND
-
-#if defined(MAC_OSX_TK)
-# undef Region
+#ifdef __clang__
+#pragma clang diagnostic pop
#endif
-#endif /* _XUTIL_H_ */
+_XFUNCPROTOEND
+
+#endif /* _X11_XUTIL_H_ */
diff --git a/xlib/X11/ap_keysym.h b/xlib/X11/ap_keysym.h
new file mode 100644
index 0000000..76cbde2
--- /dev/null
+++ b/xlib/X11/ap_keysym.h
@@ -0,0 +1,51 @@
+/******************************************************************
+Copyright 1987 by Apollo Computer Inc., Chelmsford, Massachusetts.
+Copyright 1989 by Hewlett-Packard Company.
+
+ All Rights Reserved
+
+Permission to use, duplicate, change, and distribute this software and
+its documentation for any purpose and without fee is granted, provided
+that the above copyright notice appear in such copy and that this
+copyright notice appear in all supporting documentation, and that the
+names of Apollo Computer Inc., the Hewlett-Packard Company, or the X
+Consortium not be used in advertising or publicity pertaining to
+distribution of the software without written prior permission.
+
+HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD
+TO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. Hewlett-Packard shall not be liable for errors
+contained herein or direct, indirect, special, incidental or
+consequential damages in connection with the furnishing,
+performance, or use of this material.
+
+This software is not subject to any license of the American
+Telephone and Telegraph Company or of the Regents of the
+University of California.
+******************************************************************/
+
+#define apXK_LineDel 0x1000FF00
+#define apXK_CharDel 0x1000FF01
+#define apXK_Copy 0x1000FF02
+#define apXK_Cut 0x1000FF03
+#define apXK_Paste 0x1000FF04
+#define apXK_Move 0x1000FF05
+#define apXK_Grow 0x1000FF06
+#define apXK_Cmd 0x1000FF07
+#define apXK_Shell 0x1000FF08
+#define apXK_LeftBar 0x1000FF09
+#define apXK_RightBar 0x1000FF0A
+#define apXK_LeftBox 0x1000FF0B
+#define apXK_RightBox 0x1000FF0C
+#define apXK_UpBox 0x1000FF0D
+#define apXK_DownBox 0x1000FF0E
+#define apXK_Pop 0x1000FF0F
+#define apXK_Read 0x1000FF10
+#define apXK_Edit 0x1000FF11
+#define apXK_Save 0x1000FF12
+#define apXK_Exit 0x1000FF13
+#define apXK_Repeat 0x1000FF14
+
+#define apXK_KP_parenleft 0x1000FFA8
+#define apXK_KP_parenright 0x1000FFA9
diff --git a/xlib/X11/cursorfont.h b/xlib/X11/cursorfont.h
index 617274f..c69d508 100644
--- a/xlib/X11/cursorfont.h
+++ b/xlib/X11/cursorfont.h
@@ -1,4 +1,34 @@
-/* $XConsortium: cursorfont.h,v 1.2 88/09/06 16:44:27 jim Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#ifndef _X11_CURSORFONT_H_
+#define _X11_CURSORFONT_H_
+
#define XC_num_glyphs 154
#define XC_X_cursor 0
#define XC_arrow 2
@@ -77,3 +107,5 @@
#define XC_ur_angle 148
#define XC_watch 150
#define XC_xterm 152
+
+#endif /* _X11_CURSORFONT_H_ */
diff --git a/xlib/X11/keysym.h b/xlib/X11/keysym.h
index 550b76d..0ffdde4 100644
--- a/xlib/X11/keysym.h
+++ b/xlib/X11/keysym.h
@@ -1,8 +1,29 @@
-/* $XConsortium: keysym.h,v 1.13 91/03/13 20:09:49 rws Exp $ */
-
/***********************************************************
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
-and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
@@ -10,7 +31,7 @@ Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
-supporting documentation, and that the names of Digital or MIT not be
+supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
@@ -26,10 +47,28 @@ SOFTWARE.
/* default keysyms */
#define XK_MISCELLANY
+#define XK_XKB_KEYS
#define XK_LATIN1
#define XK_LATIN2
#define XK_LATIN3
#define XK_LATIN4
+#define XK_LATIN8
+#define XK_LATIN9
+#define XK_CAUCASUS
#define XK_GREEK
+#define XK_KATAKANA
+#define XK_ARABIC
+#define XK_CYRILLIC
+#define XK_HEBREW
+#define XK_THAI
+#define XK_KOREAN
+#define XK_ARMENIAN
+#define XK_GEORGIAN
+#define XK_VIETNAMESE
+#define XK_CURRENCY
+#define XK_MATHEMATICAL
+#define XK_BRAILLE
+#define XK_SINHALA
#include <X11/keysymdef.h>
+
diff --git a/xlib/X11/keysymdef.h b/xlib/X11/keysymdef.h
index a7c654d..19abff2 100644
--- a/xlib/X11/keysymdef.h
+++ b/xlib/X11/keysymdef.h
@@ -1,8 +1,30 @@
-/* $XConsortium: keysymdef.h,v 1.15 93/04/02 10:57:36 rws Exp $ */
-
/***********************************************************
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
-and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+Copyright 1987, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts
All Rights Reserved
@@ -10,7 +32,7 @@ Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
-supporting documentation, and that the names of Digital or MIT not be
+supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
@@ -24,65 +46,140 @@ SOFTWARE.
******************************************************************/
-#define XK_VoidSymbol 0xFFFFFF /* void symbol */
+/*
+ * The "X11 Window System Protocol" standard defines in Appendix A the
+ * keysym codes. These 29-bit integer values identify characters or
+ * functions associated with each key (e.g., via the visible
+ * engraving) of a keyboard layout. This file assigns mnemonic macro
+ * names for these keysyms.
+ *
+ * This file is also compiled (by src/util/makekeys.c in libX11) into
+ * hash tables that can be accessed with X11 library functions such as
+ * XStringToKeysym() and XKeysymToString().
+ *
+ * Where a keysym corresponds one-to-one to an ISO 10646 / Unicode
+ * character, this is noted in a comment that provides both the U+xxxx
+ * Unicode position, as well as the official Unicode name of the
+ * character.
+ *
+ * Where the correspondence is either not one-to-one or semantically
+ * unclear, the Unicode position and name are enclosed in
+ * parentheses. Such legacy keysyms should be considered deprecated
+ * and are not recommended for use in future keyboard mappings.
+ *
+ * For any future extension of the keysyms with characters already
+ * found in ISO 10646 / Unicode, the following algorithm shall be
+ * used. The new keysym code position will simply be the character's
+ * Unicode number plus 0x01000000. The keysym values in the range
+ * 0x01000100 to 0x0110ffff are reserved to represent Unicode
+ * characters in the range U+0100 to U+10FFFF.
+ *
+ * While most newer Unicode-based X11 clients do already accept
+ * Unicode-mapped keysyms in the range 0x01000100 to 0x0110ffff, it
+ * will remain necessary for clients -- in the interest of
+ * compatibility with existing servers -- to also understand the
+ * existing legacy keysym values in the range 0x0100 to 0x20ff.
+ *
+ * Where several mnemonic names are defined for the same keysym in this
+ * file, all but the first one listed should be considered deprecated.
+ *
+ * Mnemonic names for keysyms are defined in this file with lines
+ * that match one of these Perl regular expressions:
+ *
+ * /^\#define XK_([a-zA-Z_0-9]+)\s+0x([0-9a-f]+)\s*\/\* U+([0-9A-F]{4,6}) (.*) \*\/\s*$/
+ * /^\#define XK_([a-zA-Z_0-9]+)\s+0x([0-9a-f]+)\s*\/\*\(U+([0-9A-F]{4,6}) (.*)\)\*\/\s*$/
+ * /^\#define XK_([a-zA-Z_0-9]+)\s+0x([0-9a-f]+)\s*(\/\*\s*(.*)\s*\*\/)?\s*$/
+ *
+ * Before adding new keysyms, please do consider the following: In
+ * addition to the keysym names defined in this file, the
+ * XStringToKeysym() and XKeysymToString() functions will also handle
+ * any keysym string of the form "U0020" to "U007E" and "U00A0" to
+ * "U10FFFF" for all possible Unicode characters. In other words,
+ * every possible Unicode character has already a keysym string
+ * defined algorithmically, even if it is not listed here. Therefore,
+ * defining an additional keysym macro is only necessary where a
+ * non-hexadecimal mnemonic name is needed, or where the new keysym
+ * does not represent any existing Unicode character.
+ *
+ * When adding new keysyms to this file, do not forget to also update the
+ * following as needed:
+ *
+ * - the mappings in src/KeyBind.c in the libX11 repo
+ * https://gitlab.freedesktop.org/xorg/lib/libx11
+ *
+ * - the protocol specification in specs/keysyms.xml in this repo
+ * https://gitlab.freedesktop.org/xorg/proto/xorgproto
+ *
+ */
+
+#define XK_VoidSymbol 0xffffff /* Void symbol */
#ifdef XK_MISCELLANY
/*
- * TTY Functions, cleverly chosen to map to ascii, for convenience of
+ * TTY function keys, cleverly chosen to map to ASCII, for convenience of
* programming, but could have been arbitrary (at the cost of lookup
- * tables in client code.
+ * tables in client code).
*/
-#define XK_BackSpace 0xFF08 /* back space, back char */
-#define XK_Tab 0xFF09
-#define XK_Linefeed 0xFF0A /* Linefeed, LF */
-#define XK_Clear 0xFF0B
-#define XK_Return 0xFF0D /* Return, enter */
-#define XK_Pause 0xFF13 /* Pause, hold */
-#define XK_Scroll_Lock 0xFF14
-#define XK_Sys_Req 0xFF15
-#define XK_Escape 0xFF1B
-#define XK_Delete 0xFFFF /* Delete, rubout */
+#define XK_BackSpace 0xff08 /* Back space, back char */
+#define XK_Tab 0xff09
+#define XK_Linefeed 0xff0a /* Linefeed, LF */
+#define XK_Clear 0xff0b
+#define XK_Return 0xff0d /* Return, enter */
+#define XK_Pause 0xff13 /* Pause, hold */
+#define XK_Scroll_Lock 0xff14
+#define XK_Sys_Req 0xff15
+#define XK_Escape 0xff1b
+#define XK_Delete 0xffff /* Delete, rubout */
/* International & multi-key character composition */
-#define XK_Multi_key 0xFF20 /* Multi-key character compose */
+#define XK_Multi_key 0xff20 /* Multi-key character compose */
+#define XK_Codeinput 0xff37
+#define XK_SingleCandidate 0xff3c
+#define XK_MultipleCandidate 0xff3d
+#define XK_PreviousCandidate 0xff3e
/* Japanese keyboard support */
-#define XK_Kanji 0xFF21 /* Kanji, Kanji convert */
-#define XK_Muhenkan 0xFF22 /* Cancel Conversion */
-#define XK_Henkan_Mode 0xFF23 /* Start/Stop Conversion */
-#define XK_Henkan 0xFF23 /* Alias for Henkan_Mode */
-#define XK_Romaji 0xFF24 /* to Romaji */
-#define XK_Hiragana 0xFF25 /* to Hiragana */
-#define XK_Katakana 0xFF26 /* to Katakana */
-#define XK_Hiragana_Katakana 0xFF27 /* Hiragana/Katakana toggle */
-#define XK_Zenkaku 0xFF28 /* to Zenkaku */
-#define XK_Hankaku 0xFF29 /* to Hankaku */
-#define XK_Zenkaku_Hankaku 0xFF2A /* Zenkaku/Hankaku toggle */
-#define XK_Touroku 0xFF2B /* Add to Dictionary */
-#define XK_Massyo 0xFF2C /* Delete from Dictionary */
-#define XK_Kana_Lock 0xFF2D /* Kana Lock */
-#define XK_Kana_Shift 0xFF2E /* Kana Shift */
-#define XK_Eisu_Shift 0xFF2F /* Alphanumeric Shift */
-#define XK_Eisu_toggle 0xFF30 /* Alphanumeric toggle */
+#define XK_Kanji 0xff21 /* Kanji, Kanji convert */
+#define XK_Muhenkan 0xff22 /* Cancel Conversion */
+#define XK_Henkan_Mode 0xff23 /* Start/Stop Conversion */
+#define XK_Henkan 0xff23 /* Alias for Henkan_Mode */
+#define XK_Romaji 0xff24 /* to Romaji */
+#define XK_Hiragana 0xff25 /* to Hiragana */
+#define XK_Katakana 0xff26 /* to Katakana */
+#define XK_Hiragana_Katakana 0xff27 /* Hiragana/Katakana toggle */
+#define XK_Zenkaku 0xff28 /* to Zenkaku */
+#define XK_Hankaku 0xff29 /* to Hankaku */
+#define XK_Zenkaku_Hankaku 0xff2a /* Zenkaku/Hankaku toggle */
+#define XK_Touroku 0xff2b /* Add to Dictionary */
+#define XK_Massyo 0xff2c /* Delete from Dictionary */
+#define XK_Kana_Lock 0xff2d /* Kana Lock */
+#define XK_Kana_Shift 0xff2e /* Kana Shift */
+#define XK_Eisu_Shift 0xff2f /* Alphanumeric Shift */
+#define XK_Eisu_toggle 0xff30 /* Alphanumeric toggle */
+#define XK_Kanji_Bangou 0xff37 /* Codeinput */
+#define XK_Zen_Koho 0xff3d /* Multiple/All Candidate(s) */
+#define XK_Mae_Koho 0xff3e /* Previous Candidate */
+
+/* 0xff31 thru 0xff3f are under XK_KOREAN */
/* Cursor control & motion */
-#define XK_Home 0xFF50
-#define XK_Left 0xFF51 /* Move left, left arrow */
-#define XK_Up 0xFF52 /* Move up, up arrow */
-#define XK_Right 0xFF53 /* Move right, right arrow */
-#define XK_Down 0xFF54 /* Move down, down arrow */
-#define XK_Prior 0xFF55 /* Prior, previous */
-#define XK_Page_Up 0xFF55
-#define XK_Next 0xFF56 /* Next */
-#define XK_Page_Down 0xFF56
-#define XK_End 0xFF57 /* EOL */
-#define XK_Begin 0xFF58 /* BOL */
+#define XK_Home 0xff50
+#define XK_Left 0xff51 /* Move left, left arrow */
+#define XK_Up 0xff52 /* Move up, up arrow */
+#define XK_Right 0xff53 /* Move right, right arrow */
+#define XK_Down 0xff54 /* Move down, down arrow */
+#define XK_Prior 0xff55 /* Prior, previous */
+#define XK_Page_Up 0xff55
+#define XK_Next 0xff56 /* Next */
+#define XK_Page_Down 0xff56
+#define XK_End 0xff57 /* EOL */
+#define XK_Begin 0xff58 /* BOL */
/* Special Windows keyboard keys */
@@ -90,630 +187,923 @@ SOFTWARE.
#define XK_Win_R 0xFF5C /* Right-hand Windows */
#define XK_App 0xFF5D /* Menu key */
-/* Misc Functions */
-
-#define XK_Select 0xFF60 /* Select, mark */
-#define XK_Print 0xFF61
-#define XK_Execute 0xFF62 /* Execute, run, do */
-#define XK_Insert 0xFF63 /* Insert, insert here */
-#define XK_Undo 0xFF65 /* Undo, oops */
-#define XK_Redo 0xFF66 /* redo, again */
-#define XK_Menu 0xFF67
-#define XK_Find 0xFF68 /* Find, search */
-#define XK_Cancel 0xFF69 /* Cancel, stop, abort, exit */
-#define XK_Help 0xFF6A /* Help, ? */
-#define XK_Break 0xFF6B
-#define XK_Mode_switch 0xFF7E /* Character set switch */
-#define XK_script_switch 0xFF7E /* Alias for mode_switch */
-#define XK_Num_Lock 0xFF7F
-
-/* Keypad Functions, keypad numbers cleverly chosen to map to ascii */
-
-#define XK_KP_Space 0xFF80 /* space */
-#define XK_KP_Tab 0xFF89
-#define XK_KP_Enter 0xFF8D /* enter */
-#define XK_KP_F1 0xFF91 /* PF1, KP_A, ... */
-#define XK_KP_F2 0xFF92
-#define XK_KP_F3 0xFF93
-#define XK_KP_F4 0xFF94
-#define XK_KP_Home 0xFF95
-#define XK_KP_Left 0xFF96
-#define XK_KP_Up 0xFF97
-#define XK_KP_Right 0xFF98
-#define XK_KP_Down 0xFF99
-#define XK_KP_Prior 0xFF9A
-#define XK_KP_Page_Up 0xFF9A
-#define XK_KP_Next 0xFF9B
-#define XK_KP_Page_Down 0xFF9B
-#define XK_KP_End 0xFF9C
-#define XK_KP_Begin 0xFF9D
-#define XK_KP_Insert 0xFF9E
-#define XK_KP_Delete 0xFF9F
-#define XK_KP_Equal 0xFFBD /* equals */
-#define XK_KP_Multiply 0xFFAA
-#define XK_KP_Add 0xFFAB
-#define XK_KP_Separator 0xFFAC /* separator, often comma */
-#define XK_KP_Subtract 0xFFAD
-#define XK_KP_Decimal 0xFFAE
-#define XK_KP_Divide 0xFFAF
-
-#define XK_KP_0 0xFFB0
-#define XK_KP_1 0xFFB1
-#define XK_KP_2 0xFFB2
-#define XK_KP_3 0xFFB3
-#define XK_KP_4 0xFFB4
-#define XK_KP_5 0xFFB5
-#define XK_KP_6 0xFFB6
-#define XK_KP_7 0xFFB7
-#define XK_KP_8 0xFFB8
-#define XK_KP_9 0xFFB9
+/* Misc functions */
+
+#define XK_Select 0xff60 /* Select, mark */
+#define XK_Print 0xff61
+#define XK_Execute 0xff62 /* Execute, run, do */
+#define XK_Insert 0xff63 /* Insert, insert here */
+#define XK_Undo 0xff65
+#define XK_Redo 0xff66 /* Redo, again */
+#define XK_Menu 0xff67
+#define XK_Find 0xff68 /* Find, search */
+#define XK_Cancel 0xff69 /* Cancel, stop, abort, exit */
+#define XK_Help 0xff6a /* Help */
+#define XK_Break 0xff6b
+#define XK_Mode_switch 0xff7e /* Character set switch */
+#define XK_script_switch 0xff7e /* Alias for mode_switch */
+#define XK_Num_Lock 0xff7f
+
+/* Keypad functions, keypad numbers cleverly chosen to map to ASCII */
+
+#define XK_KP_Space 0xff80 /* Space */
+#define XK_KP_Tab 0xff89
+#define XK_KP_Enter 0xff8d /* Enter */
+#define XK_KP_F1 0xff91 /* PF1, KP_A, ... */
+#define XK_KP_F2 0xff92
+#define XK_KP_F3 0xff93
+#define XK_KP_F4 0xff94
+#define XK_KP_Home 0xff95
+#define XK_KP_Left 0xff96
+#define XK_KP_Up 0xff97
+#define XK_KP_Right 0xff98
+#define XK_KP_Down 0xff99
+#define XK_KP_Prior 0xff9a
+#define XK_KP_Page_Up 0xff9a
+#define XK_KP_Next 0xff9b
+#define XK_KP_Page_Down 0xff9b
+#define XK_KP_End 0xff9c
+#define XK_KP_Begin 0xff9d
+#define XK_KP_Insert 0xff9e
+#define XK_KP_Delete 0xff9f
+#define XK_KP_Equal 0xffbd /* Equals */
+#define XK_KP_Multiply 0xffaa
+#define XK_KP_Add 0xffab
+#define XK_KP_Separator 0xffac /* Separator, often comma */
+#define XK_KP_Subtract 0xffad
+#define XK_KP_Decimal 0xffae
+#define XK_KP_Divide 0xffaf
+
+#define XK_KP_0 0xffb0
+#define XK_KP_1 0xffb1
+#define XK_KP_2 0xffb2
+#define XK_KP_3 0xffb3
+#define XK_KP_4 0xffb4
+#define XK_KP_5 0xffb5
+#define XK_KP_6 0xffb6
+#define XK_KP_7 0xffb7
+#define XK_KP_8 0xffb8
+#define XK_KP_9 0xffb9
/*
- * Auxilliary Functions; note the duplicate definitions for left and right
- * function keys; Sun keyboards and a few other manufactures have such
+ * Auxiliary functions; note the duplicate definitions for left and right
+ * function keys; Sun keyboards and a few other manufacturers have such
* function key groups on the left and/or right sides of the keyboard.
* We've not found a keyboard with more than 35 function keys total.
*/
-#define XK_F1 0xFFBE
-#define XK_F2 0xFFBF
-#define XK_F3 0xFFC0
-#define XK_F4 0xFFC1
-#define XK_F5 0xFFC2
-#define XK_F6 0xFFC3
-#define XK_F7 0xFFC4
-#define XK_F8 0xFFC5
-#define XK_F9 0xFFC6
-#define XK_F10 0xFFC7
-#define XK_F11 0xFFC8
-#define XK_L1 0xFFC8
-#define XK_F12 0xFFC9
-#define XK_L2 0xFFC9
-#define XK_F13 0xFFCA
-#define XK_L3 0xFFCA
-#define XK_F14 0xFFCB
-#define XK_L4 0xFFCB
-#define XK_F15 0xFFCC
-#define XK_L5 0xFFCC
-#define XK_F16 0xFFCD
-#define XK_L6 0xFFCD
-#define XK_F17 0xFFCE
-#define XK_L7 0xFFCE
-#define XK_F18 0xFFCF
-#define XK_L8 0xFFCF
-#define XK_F19 0xFFD0
-#define XK_L9 0xFFD0
-#define XK_F20 0xFFD1
-#define XK_L10 0xFFD1
-#define XK_F21 0xFFD2
-#define XK_R1 0xFFD2
-#define XK_F22 0xFFD3
-#define XK_R2 0xFFD3
-#define XK_F23 0xFFD4
-#define XK_R3 0xFFD4
-#define XK_F24 0xFFD5
-#define XK_R4 0xFFD5
-#define XK_F25 0xFFD6
-#define XK_R5 0xFFD6
-#define XK_F26 0xFFD7
-#define XK_R6 0xFFD7
-#define XK_F27 0xFFD8
-#define XK_R7 0xFFD8
-#define XK_F28 0xFFD9
-#define XK_R8 0xFFD9
-#define XK_F29 0xFFDA
-#define XK_R9 0xFFDA
-#define XK_F30 0xFFDB
-#define XK_R10 0xFFDB
-#define XK_F31 0xFFDC
-#define XK_R11 0xFFDC
-#define XK_F32 0xFFDD
-#define XK_R12 0xFFDD
-#define XK_F33 0xFFDE
-#define XK_R13 0xFFDE
-#define XK_F34 0xFFDF
-#define XK_R14 0xFFDF
-#define XK_F35 0xFFE0
-#define XK_R15 0xFFE0
+#define XK_F1 0xffbe
+#define XK_F2 0xffbf
+#define XK_F3 0xffc0
+#define XK_F4 0xffc1
+#define XK_F5 0xffc2
+#define XK_F6 0xffc3
+#define XK_F7 0xffc4
+#define XK_F8 0xffc5
+#define XK_F9 0xffc6
+#define XK_F10 0xffc7
+#define XK_F11 0xffc8
+#define XK_L1 0xffc8
+#define XK_F12 0xffc9
+#define XK_L2 0xffc9
+#define XK_F13 0xffca
+#define XK_L3 0xffca
+#define XK_F14 0xffcb
+#define XK_L4 0xffcb
+#define XK_F15 0xffcc
+#define XK_L5 0xffcc
+#define XK_F16 0xffcd
+#define XK_L6 0xffcd
+#define XK_F17 0xffce
+#define XK_L7 0xffce
+#define XK_F18 0xffcf
+#define XK_L8 0xffcf
+#define XK_F19 0xffd0
+#define XK_L9 0xffd0
+#define XK_F20 0xffd1
+#define XK_L10 0xffd1
+#define XK_F21 0xffd2
+#define XK_R1 0xffd2
+#define XK_F22 0xffd3
+#define XK_R2 0xffd3
+#define XK_F23 0xffd4
+#define XK_R3 0xffd4
+#define XK_F24 0xffd5
+#define XK_R4 0xffd5
+#define XK_F25 0xffd6
+#define XK_R5 0xffd6
+#define XK_F26 0xffd7
+#define XK_R6 0xffd7
+#define XK_F27 0xffd8
+#define XK_R7 0xffd8
+#define XK_F28 0xffd9
+#define XK_R8 0xffd9
+#define XK_F29 0xffda
+#define XK_R9 0xffda
+#define XK_F30 0xffdb
+#define XK_R10 0xffdb
+#define XK_F31 0xffdc
+#define XK_R11 0xffdc
+#define XK_F32 0xffdd
+#define XK_R12 0xffdd
+#define XK_F33 0xffde
+#define XK_R13 0xffde
+#define XK_F34 0xffdf
+#define XK_R14 0xffdf
+#define XK_F35 0xffe0
+#define XK_R15 0xffe0
/* Modifiers */
-#define XK_Shift_L 0xFFE1 /* Left shift */
-#define XK_Shift_R 0xFFE2 /* Right shift */
-#define XK_Control_L 0xFFE3 /* Left control */
-#define XK_Control_R 0xFFE4 /* Right control */
-#define XK_Caps_Lock 0xFFE5 /* Caps lock */
-#define XK_Shift_Lock 0xFFE6 /* Shift lock */
-
-#define XK_Meta_L 0xFFE7 /* Left meta */
-#define XK_Meta_R 0xFFE8 /* Right meta */
-#define XK_Alt_L 0xFFE9 /* Left alt */
-#define XK_Alt_R 0xFFEA /* Right alt */
-#define XK_Super_L 0xFFEB /* Left super */
-#define XK_Super_R 0xFFEC /* Right super */
-#define XK_Hyper_L 0xFFED /* Left hyper */
-#define XK_Hyper_R 0xFFEE /* Right hyper */
+#define XK_Shift_L 0xffe1 /* Left shift */
+#define XK_Shift_R 0xffe2 /* Right shift */
+#define XK_Control_L 0xffe3 /* Left control */
+#define XK_Control_R 0xffe4 /* Right control */
+#define XK_Caps_Lock 0xffe5 /* Caps lock */
+#define XK_Shift_Lock 0xffe6 /* Shift lock */
+
+#define XK_Meta_L 0xffe7 /* Left meta */
+#define XK_Meta_R 0xffe8 /* Right meta */
+#define XK_Alt_L 0xffe9 /* Left alt */
+#define XK_Alt_R 0xffea /* Right alt */
+#define XK_Super_L 0xffeb /* Left super */
+#define XK_Super_R 0xffec /* Right super */
+#define XK_Hyper_L 0xffed /* Left hyper */
+#define XK_Hyper_R 0xffee /* Right hyper */
#endif /* XK_MISCELLANY */
/*
- * Latin 1
- * Byte 3 = 0
+ * Keyboard (XKB) Extension function and modifier keys
+ * (from Appendix C of "The X Keyboard Extension: Protocol Specification")
+ * Byte 3 = 0xfe
+ */
+
+#ifdef XK_XKB_KEYS
+#define XK_ISO_Lock 0xfe01
+#define XK_ISO_Level2_Latch 0xfe02
+#define XK_ISO_Level3_Shift 0xfe03
+#define XK_ISO_Level3_Latch 0xfe04
+#define XK_ISO_Level3_Lock 0xfe05
+#define XK_ISO_Level5_Shift 0xfe11
+#define XK_ISO_Level5_Latch 0xfe12
+#define XK_ISO_Level5_Lock 0xfe13
+#define XK_ISO_Group_Shift 0xff7e /* Alias for mode_switch */
+#define XK_ISO_Group_Latch 0xfe06
+#define XK_ISO_Group_Lock 0xfe07
+#define XK_ISO_Next_Group 0xfe08
+#define XK_ISO_Next_Group_Lock 0xfe09
+#define XK_ISO_Prev_Group 0xfe0a
+#define XK_ISO_Prev_Group_Lock 0xfe0b
+#define XK_ISO_First_Group 0xfe0c
+#define XK_ISO_First_Group_Lock 0xfe0d
+#define XK_ISO_Last_Group 0xfe0e
+#define XK_ISO_Last_Group_Lock 0xfe0f
+
+#define XK_ISO_Left_Tab 0xfe20
+#define XK_ISO_Move_Line_Up 0xfe21
+#define XK_ISO_Move_Line_Down 0xfe22
+#define XK_ISO_Partial_Line_Up 0xfe23
+#define XK_ISO_Partial_Line_Down 0xfe24
+#define XK_ISO_Partial_Space_Left 0xfe25
+#define XK_ISO_Partial_Space_Right 0xfe26
+#define XK_ISO_Set_Margin_Left 0xfe27
+#define XK_ISO_Set_Margin_Right 0xfe28
+#define XK_ISO_Release_Margin_Left 0xfe29
+#define XK_ISO_Release_Margin_Right 0xfe2a
+#define XK_ISO_Release_Both_Margins 0xfe2b
+#define XK_ISO_Fast_Cursor_Left 0xfe2c
+#define XK_ISO_Fast_Cursor_Right 0xfe2d
+#define XK_ISO_Fast_Cursor_Up 0xfe2e
+#define XK_ISO_Fast_Cursor_Down 0xfe2f
+#define XK_ISO_Continuous_Underline 0xfe30
+#define XK_ISO_Discontinuous_Underline 0xfe31
+#define XK_ISO_Emphasize 0xfe32
+#define XK_ISO_Center_Object 0xfe33
+#define XK_ISO_Enter 0xfe34
+
+#define XK_dead_grave 0xfe50
+#define XK_dead_acute 0xfe51
+#define XK_dead_circumflex 0xfe52
+#define XK_dead_tilde 0xfe53
+#define XK_dead_perispomeni 0xfe53 /* alias for dead_tilde */
+#define XK_dead_macron 0xfe54
+#define XK_dead_breve 0xfe55
+#define XK_dead_abovedot 0xfe56
+#define XK_dead_diaeresis 0xfe57
+#define XK_dead_abovering 0xfe58
+#define XK_dead_doubleacute 0xfe59
+#define XK_dead_caron 0xfe5a
+#define XK_dead_cedilla 0xfe5b
+#define XK_dead_ogonek 0xfe5c
+#define XK_dead_iota 0xfe5d
+#define XK_dead_voiced_sound 0xfe5e
+#define XK_dead_semivoiced_sound 0xfe5f
+#define XK_dead_belowdot 0xfe60
+#define XK_dead_hook 0xfe61
+#define XK_dead_horn 0xfe62
+#define XK_dead_stroke 0xfe63
+#define XK_dead_abovecomma 0xfe64
+#define XK_dead_psili 0xfe64 /* alias for dead_abovecomma */
+#define XK_dead_abovereversedcomma 0xfe65
+#define XK_dead_dasia 0xfe65 /* alias for dead_abovereversedcomma */
+#define XK_dead_doublegrave 0xfe66
+#define XK_dead_belowring 0xfe67
+#define XK_dead_belowmacron 0xfe68
+#define XK_dead_belowcircumflex 0xfe69
+#define XK_dead_belowtilde 0xfe6a
+#define XK_dead_belowbreve 0xfe6b
+#define XK_dead_belowdiaeresis 0xfe6c
+#define XK_dead_invertedbreve 0xfe6d
+#define XK_dead_belowcomma 0xfe6e
+#define XK_dead_currency 0xfe6f
+
+/* extra dead elements for German T3 layout */
+#define XK_dead_lowline 0xfe90
+#define XK_dead_aboveverticalline 0xfe91
+#define XK_dead_belowverticalline 0xfe92
+#define XK_dead_longsolidusoverlay 0xfe93
+
+/* dead vowels for universal syllable entry */
+#define XK_dead_a 0xfe80
+#define XK_dead_A 0xfe81
+#define XK_dead_e 0xfe82
+#define XK_dead_E 0xfe83
+#define XK_dead_i 0xfe84
+#define XK_dead_I 0xfe85
+#define XK_dead_o 0xfe86
+#define XK_dead_O 0xfe87
+#define XK_dead_u 0xfe88
+#define XK_dead_U 0xfe89
+#define XK_dead_small_schwa 0xfe8a
+#define XK_dead_capital_schwa 0xfe8b
+
+#define XK_dead_greek 0xfe8c
+
+#define XK_First_Virtual_Screen 0xfed0
+#define XK_Prev_Virtual_Screen 0xfed1
+#define XK_Next_Virtual_Screen 0xfed2
+#define XK_Last_Virtual_Screen 0xfed4
+#define XK_Terminate_Server 0xfed5
+
+#define XK_AccessX_Enable 0xfe70
+#define XK_AccessX_Feedback_Enable 0xfe71
+#define XK_RepeatKeys_Enable 0xfe72
+#define XK_SlowKeys_Enable 0xfe73
+#define XK_BounceKeys_Enable 0xfe74
+#define XK_StickyKeys_Enable 0xfe75
+#define XK_MouseKeys_Enable 0xfe76
+#define XK_MouseKeys_Accel_Enable 0xfe77
+#define XK_Overlay1_Enable 0xfe78
+#define XK_Overlay2_Enable 0xfe79
+#define XK_AudibleBell_Enable 0xfe7a
+
+#define XK_Pointer_Left 0xfee0
+#define XK_Pointer_Right 0xfee1
+#define XK_Pointer_Up 0xfee2
+#define XK_Pointer_Down 0xfee3
+#define XK_Pointer_UpLeft 0xfee4
+#define XK_Pointer_UpRight 0xfee5
+#define XK_Pointer_DownLeft 0xfee6
+#define XK_Pointer_DownRight 0xfee7
+#define XK_Pointer_Button_Dflt 0xfee8
+#define XK_Pointer_Button1 0xfee9
+#define XK_Pointer_Button2 0xfeea
+#define XK_Pointer_Button3 0xfeeb
+#define XK_Pointer_Button4 0xfeec
+#define XK_Pointer_Button5 0xfeed
+#define XK_Pointer_DblClick_Dflt 0xfeee
+#define XK_Pointer_DblClick1 0xfeef
+#define XK_Pointer_DblClick2 0xfef0
+#define XK_Pointer_DblClick3 0xfef1
+#define XK_Pointer_DblClick4 0xfef2
+#define XK_Pointer_DblClick5 0xfef3
+#define XK_Pointer_Drag_Dflt 0xfef4
+#define XK_Pointer_Drag1 0xfef5
+#define XK_Pointer_Drag2 0xfef6
+#define XK_Pointer_Drag3 0xfef7
+#define XK_Pointer_Drag4 0xfef8
+#define XK_Pointer_Drag5 0xfefd
+
+#define XK_Pointer_EnableKeys 0xfef9
+#define XK_Pointer_Accelerate 0xfefa
+#define XK_Pointer_DfltBtnNext 0xfefb
+#define XK_Pointer_DfltBtnPrev 0xfefc
+
+/* Single-Stroke Multiple-Character N-Graph Keysyms For The X Input Method */
+
+#define XK_ch 0xfea0
+#define XK_Ch 0xfea1
+#define XK_CH 0xfea2
+#define XK_c_h 0xfea3
+#define XK_C_h 0xfea4
+#define XK_C_H 0xfea5
+
+#endif /* XK_XKB_KEYS */
+
+/*
+ * 3270 Terminal Keys
+ * Byte 3 = 0xfd
+ */
+
+#ifdef XK_3270
+#define XK_3270_Duplicate 0xfd01
+#define XK_3270_FieldMark 0xfd02
+#define XK_3270_Right2 0xfd03
+#define XK_3270_Left2 0xfd04
+#define XK_3270_BackTab 0xfd05
+#define XK_3270_EraseEOF 0xfd06
+#define XK_3270_EraseInput 0xfd07
+#define XK_3270_Reset 0xfd08
+#define XK_3270_Quit 0xfd09
+#define XK_3270_PA1 0xfd0a
+#define XK_3270_PA2 0xfd0b
+#define XK_3270_PA3 0xfd0c
+#define XK_3270_Test 0xfd0d
+#define XK_3270_Attn 0xfd0e
+#define XK_3270_CursorBlink 0xfd0f
+#define XK_3270_AltCursor 0xfd10
+#define XK_3270_KeyClick 0xfd11
+#define XK_3270_Jump 0xfd12
+#define XK_3270_Ident 0xfd13
+#define XK_3270_Rule 0xfd14
+#define XK_3270_Copy 0xfd15
+#define XK_3270_Play 0xfd16
+#define XK_3270_Setup 0xfd17
+#define XK_3270_Record 0xfd18
+#define XK_3270_ChangeScreen 0xfd19
+#define XK_3270_DeleteWord 0xfd1a
+#define XK_3270_ExSelect 0xfd1b
+#define XK_3270_CursorSelect 0xfd1c
+#define XK_3270_PrintScreen 0xfd1d
+#define XK_3270_Enter 0xfd1e
+#endif /* XK_3270 */
+
+/*
+ * Latin 1
+ * (ISO/IEC 8859-1 = Unicode U+0020..U+00FF)
+ * Byte 3 = 0
*/
#ifdef XK_LATIN1
-#define XK_space 0x020
-#define XK_exclam 0x021
-#define XK_quotedbl 0x022
-#define XK_numbersign 0x023
-#define XK_dollar 0x024
-#define XK_percent 0x025
-#define XK_ampersand 0x026
-#define XK_apostrophe 0x027
-#define XK_quoteright 0x027 /* deprecated */
-#define XK_parenleft 0x028
-#define XK_parenright 0x029
-#define XK_asterisk 0x02a
-#define XK_plus 0x02b
-#define XK_comma 0x02c
-#define XK_minus 0x02d
-#define XK_period 0x02e
-#define XK_slash 0x02f
-#define XK_0 0x030
-#define XK_1 0x031
-#define XK_2 0x032
-#define XK_3 0x033
-#define XK_4 0x034
-#define XK_5 0x035
-#define XK_6 0x036
-#define XK_7 0x037
-#define XK_8 0x038
-#define XK_9 0x039
-#define XK_colon 0x03a
-#define XK_semicolon 0x03b
-#define XK_less 0x03c
-#define XK_equal 0x03d
-#define XK_greater 0x03e
-#define XK_question 0x03f
-#define XK_at 0x040
-#define XK_A 0x041
-#define XK_B 0x042
-#define XK_C 0x043
-#define XK_D 0x044
-#define XK_E 0x045
-#define XK_F 0x046
-#define XK_G 0x047
-#define XK_H 0x048
-#define XK_I 0x049
-#define XK_J 0x04a
-#define XK_K 0x04b
-#define XK_L 0x04c
-#define XK_M 0x04d
-#define XK_N 0x04e
-#define XK_O 0x04f
-#define XK_P 0x050
-#define XK_Q 0x051
-#define XK_R 0x052
-#define XK_S 0x053
-#define XK_T 0x054
-#define XK_U 0x055
-#define XK_V 0x056
-#define XK_W 0x057
-#define XK_X 0x058
-#define XK_Y 0x059
-#define XK_Z 0x05a
-#define XK_bracketleft 0x05b
-#define XK_backslash 0x05c
-#define XK_bracketright 0x05d
-#define XK_asciicircum 0x05e
-#define XK_underscore 0x05f
-#define XK_grave 0x060
-#define XK_quoteleft 0x060 /* deprecated */
-#define XK_a 0x061
-#define XK_b 0x062
-#define XK_c 0x063
-#define XK_d 0x064
-#define XK_e 0x065
-#define XK_f 0x066
-#define XK_g 0x067
-#define XK_h 0x068
-#define XK_i 0x069
-#define XK_j 0x06a
-#define XK_k 0x06b
-#define XK_l 0x06c
-#define XK_m 0x06d
-#define XK_n 0x06e
-#define XK_o 0x06f
-#define XK_p 0x070
-#define XK_q 0x071
-#define XK_r 0x072
-#define XK_s 0x073
-#define XK_t 0x074
-#define XK_u 0x075
-#define XK_v 0x076
-#define XK_w 0x077
-#define XK_x 0x078
-#define XK_y 0x079
-#define XK_z 0x07a
-#define XK_braceleft 0x07b
-#define XK_bar 0x07c
-#define XK_braceright 0x07d
-#define XK_asciitilde 0x07e
-
-#define XK_nobreakspace 0x0a0
-#define XK_exclamdown 0x0a1
-#define XK_cent 0x0a2
-#define XK_sterling 0x0a3
-#define XK_currency 0x0a4
-#define XK_yen 0x0a5
-#define XK_brokenbar 0x0a6
-#define XK_section 0x0a7
-#define XK_diaeresis 0x0a8
-#define XK_copyright 0x0a9
-#define XK_ordfeminine 0x0aa
-#define XK_guillemotleft 0x0ab /* left angle quotation mark */
-#define XK_notsign 0x0ac
-#define XK_hyphen 0x0ad
-#define XK_registered 0x0ae
-#define XK_macron 0x0af
-#define XK_degree 0x0b0
-#define XK_plusminus 0x0b1
-#define XK_twosuperior 0x0b2
-#define XK_threesuperior 0x0b3
-#define XK_acute 0x0b4
-#define XK_mu 0x0b5
-#define XK_paragraph 0x0b6
-#define XK_periodcentered 0x0b7
-#define XK_cedilla 0x0b8
-#define XK_onesuperior 0x0b9
-#define XK_masculine 0x0ba
-#define XK_guillemotright 0x0bb /* right angle quotation mark */
-#define XK_onequarter 0x0bc
-#define XK_onehalf 0x0bd
-#define XK_threequarters 0x0be
-#define XK_questiondown 0x0bf
-#define XK_Agrave 0x0c0
-#define XK_Aacute 0x0c1
-#define XK_Acircumflex 0x0c2
-#define XK_Atilde 0x0c3
-#define XK_Adiaeresis 0x0c4
-#define XK_Aring 0x0c5
-#define XK_AE 0x0c6
-#define XK_Ccedilla 0x0c7
-#define XK_Egrave 0x0c8
-#define XK_Eacute 0x0c9
-#define XK_Ecircumflex 0x0ca
-#define XK_Ediaeresis 0x0cb
-#define XK_Igrave 0x0cc
-#define XK_Iacute 0x0cd
-#define XK_Icircumflex 0x0ce
-#define XK_Idiaeresis 0x0cf
-#define XK_ETH 0x0d0
-#define XK_Eth 0x0d0 /* deprecated */
-#define XK_Ntilde 0x0d1
-#define XK_Ograve 0x0d2
-#define XK_Oacute 0x0d3
-#define XK_Ocircumflex 0x0d4
-#define XK_Otilde 0x0d5
-#define XK_Odiaeresis 0x0d6
-#define XK_multiply 0x0d7
-#define XK_Ooblique 0x0d8
-#define XK_Ugrave 0x0d9
-#define XK_Uacute 0x0da
-#define XK_Ucircumflex 0x0db
-#define XK_Udiaeresis 0x0dc
-#define XK_Yacute 0x0dd
-#define XK_THORN 0x0de
-#define XK_Thorn 0x0de /* deprecated */
-#define XK_ssharp 0x0df
-#define XK_agrave 0x0e0
-#define XK_aacute 0x0e1
-#define XK_acircumflex 0x0e2
-#define XK_atilde 0x0e3
-#define XK_adiaeresis 0x0e4
-#define XK_aring 0x0e5
-#define XK_ae 0x0e6
-#define XK_ccedilla 0x0e7
-#define XK_egrave 0x0e8
-#define XK_eacute 0x0e9
-#define XK_ecircumflex 0x0ea
-#define XK_ediaeresis 0x0eb
-#define XK_igrave 0x0ec
-#define XK_iacute 0x0ed
-#define XK_icircumflex 0x0ee
-#define XK_idiaeresis 0x0ef
-#define XK_eth 0x0f0
-#define XK_ntilde 0x0f1
-#define XK_ograve 0x0f2
-#define XK_oacute 0x0f3
-#define XK_ocircumflex 0x0f4
-#define XK_otilde 0x0f5
-#define XK_odiaeresis 0x0f6
-#define XK_division 0x0f7
-#define XK_oslash 0x0f8
-#define XK_ugrave 0x0f9
-#define XK_uacute 0x0fa
-#define XK_ucircumflex 0x0fb
-#define XK_udiaeresis 0x0fc
-#define XK_yacute 0x0fd
-#define XK_thorn 0x0fe
-#define XK_ydiaeresis 0x0ff
+#define XK_space 0x0020 /* U+0020 SPACE */
+#define XK_exclam 0x0021 /* U+0021 EXCLAMATION MARK */
+#define XK_quotedbl 0x0022 /* U+0022 QUOTATION MARK */
+#define XK_numbersign 0x0023 /* U+0023 NUMBER SIGN */
+#define XK_dollar 0x0024 /* U+0024 DOLLAR SIGN */
+#define XK_percent 0x0025 /* U+0025 PERCENT SIGN */
+#define XK_ampersand 0x0026 /* U+0026 AMPERSAND */
+#define XK_apostrophe 0x0027 /* U+0027 APOSTROPHE */
+#define XK_quoteright 0x0027 /* deprecated */
+#define XK_parenleft 0x0028 /* U+0028 LEFT PARENTHESIS */
+#define XK_parenright 0x0029 /* U+0029 RIGHT PARENTHESIS */
+#define XK_asterisk 0x002a /* U+002A ASTERISK */
+#define XK_plus 0x002b /* U+002B PLUS SIGN */
+#define XK_comma 0x002c /* U+002C COMMA */
+#define XK_minus 0x002d /* U+002D HYPHEN-MINUS */
+#define XK_period 0x002e /* U+002E FULL STOP */
+#define XK_slash 0x002f /* U+002F SOLIDUS */
+#define XK_0 0x0030 /* U+0030 DIGIT ZERO */
+#define XK_1 0x0031 /* U+0031 DIGIT ONE */
+#define XK_2 0x0032 /* U+0032 DIGIT TWO */
+#define XK_3 0x0033 /* U+0033 DIGIT THREE */
+#define XK_4 0x0034 /* U+0034 DIGIT FOUR */
+#define XK_5 0x0035 /* U+0035 DIGIT FIVE */
+#define XK_6 0x0036 /* U+0036 DIGIT SIX */
+#define XK_7 0x0037 /* U+0037 DIGIT SEVEN */
+#define XK_8 0x0038 /* U+0038 DIGIT EIGHT */
+#define XK_9 0x0039 /* U+0039 DIGIT NINE */
+#define XK_colon 0x003a /* U+003A COLON */
+#define XK_semicolon 0x003b /* U+003B SEMICOLON */
+#define XK_less 0x003c /* U+003C LESS-THAN SIGN */
+#define XK_equal 0x003d /* U+003D EQUALS SIGN */
+#define XK_greater 0x003e /* U+003E GREATER-THAN SIGN */
+#define XK_question 0x003f /* U+003F QUESTION MARK */
+#define XK_at 0x0040 /* U+0040 COMMERCIAL AT */
+#define XK_A 0x0041 /* U+0041 LATIN CAPITAL LETTER A */
+#define XK_B 0x0042 /* U+0042 LATIN CAPITAL LETTER B */
+#define XK_C 0x0043 /* U+0043 LATIN CAPITAL LETTER C */
+#define XK_D 0x0044 /* U+0044 LATIN CAPITAL LETTER D */
+#define XK_E 0x0045 /* U+0045 LATIN CAPITAL LETTER E */
+#define XK_F 0x0046 /* U+0046 LATIN CAPITAL LETTER F */
+#define XK_G 0x0047 /* U+0047 LATIN CAPITAL LETTER G */
+#define XK_H 0x0048 /* U+0048 LATIN CAPITAL LETTER H */
+#define XK_I 0x0049 /* U+0049 LATIN CAPITAL LETTER I */
+#define XK_J 0x004a /* U+004A LATIN CAPITAL LETTER J */
+#define XK_K 0x004b /* U+004B LATIN CAPITAL LETTER K */
+#define XK_L 0x004c /* U+004C LATIN CAPITAL LETTER L */
+#define XK_M 0x004d /* U+004D LATIN CAPITAL LETTER M */
+#define XK_N 0x004e /* U+004E LATIN CAPITAL LETTER N */
+#define XK_O 0x004f /* U+004F LATIN CAPITAL LETTER O */
+#define XK_P 0x0050 /* U+0050 LATIN CAPITAL LETTER P */
+#define XK_Q 0x0051 /* U+0051 LATIN CAPITAL LETTER Q */
+#define XK_R 0x0052 /* U+0052 LATIN CAPITAL LETTER R */
+#define XK_S 0x0053 /* U+0053 LATIN CAPITAL LETTER S */
+#define XK_T 0x0054 /* U+0054 LATIN CAPITAL LETTER T */
+#define XK_U 0x0055 /* U+0055 LATIN CAPITAL LETTER U */
+#define XK_V 0x0056 /* U+0056 LATIN CAPITAL LETTER V */
+#define XK_W 0x0057 /* U+0057 LATIN CAPITAL LETTER W */
+#define XK_X 0x0058 /* U+0058 LATIN CAPITAL LETTER X */
+#define XK_Y 0x0059 /* U+0059 LATIN CAPITAL LETTER Y */
+#define XK_Z 0x005a /* U+005A LATIN CAPITAL LETTER Z */
+#define XK_bracketleft 0x005b /* U+005B LEFT SQUARE BRACKET */
+#define XK_backslash 0x005c /* U+005C REVERSE SOLIDUS */
+#define XK_bracketright 0x005d /* U+005D RIGHT SQUARE BRACKET */
+#define XK_asciicircum 0x005e /* U+005E CIRCUMFLEX ACCENT */
+#define XK_underscore 0x005f /* U+005F LOW LINE */
+#define XK_grave 0x0060 /* U+0060 GRAVE ACCENT */
+#define XK_quoteleft 0x0060 /* deprecated */
+#define XK_a 0x0061 /* U+0061 LATIN SMALL LETTER A */
+#define XK_b 0x0062 /* U+0062 LATIN SMALL LETTER B */
+#define XK_c 0x0063 /* U+0063 LATIN SMALL LETTER C */
+#define XK_d 0x0064 /* U+0064 LATIN SMALL LETTER D */
+#define XK_e 0x0065 /* U+0065 LATIN SMALL LETTER E */
+#define XK_f 0x0066 /* U+0066 LATIN SMALL LETTER F */
+#define XK_g 0x0067 /* U+0067 LATIN SMALL LETTER G */
+#define XK_h 0x0068 /* U+0068 LATIN SMALL LETTER H */
+#define XK_i 0x0069 /* U+0069 LATIN SMALL LETTER I */
+#define XK_j 0x006a /* U+006A LATIN SMALL LETTER J */
+#define XK_k 0x006b /* U+006B LATIN SMALL LETTER K */
+#define XK_l 0x006c /* U+006C LATIN SMALL LETTER L */
+#define XK_m 0x006d /* U+006D LATIN SMALL LETTER M */
+#define XK_n 0x006e /* U+006E LATIN SMALL LETTER N */
+#define XK_o 0x006f /* U+006F LATIN SMALL LETTER O */
+#define XK_p 0x0070 /* U+0070 LATIN SMALL LETTER P */
+#define XK_q 0x0071 /* U+0071 LATIN SMALL LETTER Q */
+#define XK_r 0x0072 /* U+0072 LATIN SMALL LETTER R */
+#define XK_s 0x0073 /* U+0073 LATIN SMALL LETTER S */
+#define XK_t 0x0074 /* U+0074 LATIN SMALL LETTER T */
+#define XK_u 0x0075 /* U+0075 LATIN SMALL LETTER U */
+#define XK_v 0x0076 /* U+0076 LATIN SMALL LETTER V */
+#define XK_w 0x0077 /* U+0077 LATIN SMALL LETTER W */
+#define XK_x 0x0078 /* U+0078 LATIN SMALL LETTER X */
+#define XK_y 0x0079 /* U+0079 LATIN SMALL LETTER Y */
+#define XK_z 0x007a /* U+007A LATIN SMALL LETTER Z */
+#define XK_braceleft 0x007b /* U+007B LEFT CURLY BRACKET */
+#define XK_bar 0x007c /* U+007C VERTICAL LINE */
+#define XK_braceright 0x007d /* U+007D RIGHT CURLY BRACKET */
+#define XK_asciitilde 0x007e /* U+007E TILDE */
+
+#define XK_nobreakspace 0x00a0 /* U+00A0 NO-BREAK SPACE */
+#define XK_exclamdown 0x00a1 /* U+00A1 INVERTED EXCLAMATION MARK */
+#define XK_cent 0x00a2 /* U+00A2 CENT SIGN */
+#define XK_sterling 0x00a3 /* U+00A3 POUND SIGN */
+#define XK_currency 0x00a4 /* U+00A4 CURRENCY SIGN */
+#define XK_yen 0x00a5 /* U+00A5 YEN SIGN */
+#define XK_brokenbar 0x00a6 /* U+00A6 BROKEN BAR */
+#define XK_section 0x00a7 /* U+00A7 SECTION SIGN */
+#define XK_diaeresis 0x00a8 /* U+00A8 DIAERESIS */
+#define XK_copyright 0x00a9 /* U+00A9 COPYRIGHT SIGN */
+#define XK_ordfeminine 0x00aa /* U+00AA FEMININE ORDINAL INDICATOR */
+#define XK_guillemotleft 0x00ab /* U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */
+#define XK_notsign 0x00ac /* U+00AC NOT SIGN */
+#define XK_hyphen 0x00ad /* U+00AD SOFT HYPHEN */
+#define XK_registered 0x00ae /* U+00AE REGISTERED SIGN */
+#define XK_macron 0x00af /* U+00AF MACRON */
+#define XK_degree 0x00b0 /* U+00B0 DEGREE SIGN */
+#define XK_plusminus 0x00b1 /* U+00B1 PLUS-MINUS SIGN */
+#define XK_twosuperior 0x00b2 /* U+00B2 SUPERSCRIPT TWO */
+#define XK_threesuperior 0x00b3 /* U+00B3 SUPERSCRIPT THREE */
+#define XK_acute 0x00b4 /* U+00B4 ACUTE ACCENT */
+#define XK_mu 0x00b5 /* U+00B5 MICRO SIGN */
+#define XK_paragraph 0x00b6 /* U+00B6 PILCROW SIGN */
+#define XK_periodcentered 0x00b7 /* U+00B7 MIDDLE DOT */
+#define XK_cedilla 0x00b8 /* U+00B8 CEDILLA */
+#define XK_onesuperior 0x00b9 /* U+00B9 SUPERSCRIPT ONE */
+#define XK_masculine 0x00ba /* U+00BA MASCULINE ORDINAL INDICATOR */
+#define XK_guillemotright 0x00bb /* U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */
+#define XK_onequarter 0x00bc /* U+00BC VULGAR FRACTION ONE QUARTER */
+#define XK_onehalf 0x00bd /* U+00BD VULGAR FRACTION ONE HALF */
+#define XK_threequarters 0x00be /* U+00BE VULGAR FRACTION THREE QUARTERS */
+#define XK_questiondown 0x00bf /* U+00BF INVERTED QUESTION MARK */
+#define XK_Agrave 0x00c0 /* U+00C0 LATIN CAPITAL LETTER A WITH GRAVE */
+#define XK_Aacute 0x00c1 /* U+00C1 LATIN CAPITAL LETTER A WITH ACUTE */
+#define XK_Acircumflex 0x00c2 /* U+00C2 LATIN CAPITAL LETTER A WITH CIRCUMFLEX */
+#define XK_Atilde 0x00c3 /* U+00C3 LATIN CAPITAL LETTER A WITH TILDE */
+#define XK_Adiaeresis 0x00c4 /* U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS */
+#define XK_Aring 0x00c5 /* U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE */
+#define XK_AE 0x00c6 /* U+00C6 LATIN CAPITAL LETTER AE */
+#define XK_Ccedilla 0x00c7 /* U+00C7 LATIN CAPITAL LETTER C WITH CEDILLA */
+#define XK_Egrave 0x00c8 /* U+00C8 LATIN CAPITAL LETTER E WITH GRAVE */
+#define XK_Eacute 0x00c9 /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */
+#define XK_Ecircumflex 0x00ca /* U+00CA LATIN CAPITAL LETTER E WITH CIRCUMFLEX */
+#define XK_Ediaeresis 0x00cb /* U+00CB LATIN CAPITAL LETTER E WITH DIAERESIS */
+#define XK_Igrave 0x00cc /* U+00CC LATIN CAPITAL LETTER I WITH GRAVE */
+#define XK_Iacute 0x00cd /* U+00CD LATIN CAPITAL LETTER I WITH ACUTE */
+#define XK_Icircumflex 0x00ce /* U+00CE LATIN CAPITAL LETTER I WITH CIRCUMFLEX */
+#define XK_Idiaeresis 0x00cf /* U+00CF LATIN CAPITAL LETTER I WITH DIAERESIS */
+#define XK_ETH 0x00d0 /* U+00D0 LATIN CAPITAL LETTER ETH */
+#define XK_Eth 0x00d0 /* deprecated */
+#define XK_Ntilde 0x00d1 /* U+00D1 LATIN CAPITAL LETTER N WITH TILDE */
+#define XK_Ograve 0x00d2 /* U+00D2 LATIN CAPITAL LETTER O WITH GRAVE */
+#define XK_Oacute 0x00d3 /* U+00D3 LATIN CAPITAL LETTER O WITH ACUTE */
+#define XK_Ocircumflex 0x00d4 /* U+00D4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX */
+#define XK_Otilde 0x00d5 /* U+00D5 LATIN CAPITAL LETTER O WITH TILDE */
+#define XK_Odiaeresis 0x00d6 /* U+00D6 LATIN CAPITAL LETTER O WITH DIAERESIS */
+#define XK_multiply 0x00d7 /* U+00D7 MULTIPLICATION SIGN */
+#define XK_Oslash 0x00d8 /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */
+#define XK_Ooblique 0x00d8 /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */
+#define XK_Ugrave 0x00d9 /* U+00D9 LATIN CAPITAL LETTER U WITH GRAVE */
+#define XK_Uacute 0x00da /* U+00DA LATIN CAPITAL LETTER U WITH ACUTE */
+#define XK_Ucircumflex 0x00db /* U+00DB LATIN CAPITAL LETTER U WITH CIRCUMFLEX */
+#define XK_Udiaeresis 0x00dc /* U+00DC LATIN CAPITAL LETTER U WITH DIAERESIS */
+#define XK_Yacute 0x00dd /* U+00DD LATIN CAPITAL LETTER Y WITH ACUTE */
+#define XK_THORN 0x00de /* U+00DE LATIN CAPITAL LETTER THORN */
+#define XK_Thorn 0x00de /* deprecated */
+#define XK_ssharp 0x00df /* U+00DF LATIN SMALL LETTER SHARP S */
+#define XK_agrave 0x00e0 /* U+00E0 LATIN SMALL LETTER A WITH GRAVE */
+#define XK_aacute 0x00e1 /* U+00E1 LATIN SMALL LETTER A WITH ACUTE */
+#define XK_acircumflex 0x00e2 /* U+00E2 LATIN SMALL LETTER A WITH CIRCUMFLEX */
+#define XK_atilde 0x00e3 /* U+00E3 LATIN SMALL LETTER A WITH TILDE */
+#define XK_adiaeresis 0x00e4 /* U+00E4 LATIN SMALL LETTER A WITH DIAERESIS */
+#define XK_aring 0x00e5 /* U+00E5 LATIN SMALL LETTER A WITH RING ABOVE */
+#define XK_ae 0x00e6 /* U+00E6 LATIN SMALL LETTER AE */
+#define XK_ccedilla 0x00e7 /* U+00E7 LATIN SMALL LETTER C WITH CEDILLA */
+#define XK_egrave 0x00e8 /* U+00E8 LATIN SMALL LETTER E WITH GRAVE */
+#define XK_eacute 0x00e9 /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */
+#define XK_ecircumflex 0x00ea /* U+00EA LATIN SMALL LETTER E WITH CIRCUMFLEX */
+#define XK_ediaeresis 0x00eb /* U+00EB LATIN SMALL LETTER E WITH DIAERESIS */
+#define XK_igrave 0x00ec /* U+00EC LATIN SMALL LETTER I WITH GRAVE */
+#define XK_iacute 0x00ed /* U+00ED LATIN SMALL LETTER I WITH ACUTE */
+#define XK_icircumflex 0x00ee /* U+00EE LATIN SMALL LETTER I WITH CIRCUMFLEX */
+#define XK_idiaeresis 0x00ef /* U+00EF LATIN SMALL LETTER I WITH DIAERESIS */
+#define XK_eth 0x00f0 /* U+00F0 LATIN SMALL LETTER ETH */
+#define XK_ntilde 0x00f1 /* U+00F1 LATIN SMALL LETTER N WITH TILDE */
+#define XK_ograve 0x00f2 /* U+00F2 LATIN SMALL LETTER O WITH GRAVE */
+#define XK_oacute 0x00f3 /* U+00F3 LATIN SMALL LETTER O WITH ACUTE */
+#define XK_ocircumflex 0x00f4 /* U+00F4 LATIN SMALL LETTER O WITH CIRCUMFLEX */
+#define XK_otilde 0x00f5 /* U+00F5 LATIN SMALL LETTER O WITH TILDE */
+#define XK_odiaeresis 0x00f6 /* U+00F6 LATIN SMALL LETTER O WITH DIAERESIS */
+#define XK_division 0x00f7 /* U+00F7 DIVISION SIGN */
+#define XK_oslash 0x00f8 /* U+00F8 LATIN SMALL LETTER O WITH STROKE */
+#define XK_ooblique 0x00f8 /* U+00F8 LATIN SMALL LETTER O WITH STROKE */
+#define XK_ugrave 0x00f9 /* U+00F9 LATIN SMALL LETTER U WITH GRAVE */
+#define XK_uacute 0x00fa /* U+00FA LATIN SMALL LETTER U WITH ACUTE */
+#define XK_ucircumflex 0x00fb /* U+00FB LATIN SMALL LETTER U WITH CIRCUMFLEX */
+#define XK_udiaeresis 0x00fc /* U+00FC LATIN SMALL LETTER U WITH DIAERESIS */
+#define XK_yacute 0x00fd /* U+00FD LATIN SMALL LETTER Y WITH ACUTE */
+#define XK_thorn 0x00fe /* U+00FE LATIN SMALL LETTER THORN */
+#define XK_ydiaeresis 0x00ff /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */
#endif /* XK_LATIN1 */
/*
- * Latin 2
- * Byte 3 = 1
+ * Latin 2
+ * Byte 3 = 1
*/
#ifdef XK_LATIN2
-#define XK_Aogonek 0x1a1
-#define XK_breve 0x1a2
-#define XK_Lstroke 0x1a3
-#define XK_Lcaron 0x1a5
-#define XK_Sacute 0x1a6
-#define XK_Scaron 0x1a9
-#define XK_Scedilla 0x1aa
-#define XK_Tcaron 0x1ab
-#define XK_Zacute 0x1ac
-#define XK_Zcaron 0x1ae
-#define XK_Zabovedot 0x1af
-#define XK_aogonek 0x1b1
-#define XK_ogonek 0x1b2
-#define XK_lstroke 0x1b3
-#define XK_lcaron 0x1b5
-#define XK_sacute 0x1b6
-#define XK_caron 0x1b7
-#define XK_scaron 0x1b9
-#define XK_scedilla 0x1ba
-#define XK_tcaron 0x1bb
-#define XK_zacute 0x1bc
-#define XK_doubleacute 0x1bd
-#define XK_zcaron 0x1be
-#define XK_zabovedot 0x1bf
-#define XK_Racute 0x1c0
-#define XK_Abreve 0x1c3
-#define XK_Lacute 0x1c5
-#define XK_Cacute 0x1c6
-#define XK_Ccaron 0x1c8
-#define XK_Eogonek 0x1ca
-#define XK_Ecaron 0x1cc
-#define XK_Dcaron 0x1cf
-#define XK_Dstroke 0x1d0
-#define XK_Nacute 0x1d1
-#define XK_Ncaron 0x1d2
-#define XK_Odoubleacute 0x1d5
-#define XK_Rcaron 0x1d8
-#define XK_Uring 0x1d9
-#define XK_Udoubleacute 0x1db
-#define XK_Tcedilla 0x1de
-#define XK_racute 0x1e0
-#define XK_abreve 0x1e3
-#define XK_lacute 0x1e5
-#define XK_cacute 0x1e6
-#define XK_ccaron 0x1e8
-#define XK_eogonek 0x1ea
-#define XK_ecaron 0x1ec
-#define XK_dcaron 0x1ef
-#define XK_dstroke 0x1f0
-#define XK_nacute 0x1f1
-#define XK_ncaron 0x1f2
-#define XK_odoubleacute 0x1f5
-#define XK_udoubleacute 0x1fb
-#define XK_rcaron 0x1f8
-#define XK_uring 0x1f9
-#define XK_tcedilla 0x1fe
-#define XK_abovedot 0x1ff
+#define XK_Aogonek 0x01a1 /* U+0104 LATIN CAPITAL LETTER A WITH OGONEK */
+#define XK_breve 0x01a2 /* U+02D8 BREVE */
+#define XK_Lstroke 0x01a3 /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */
+#define XK_Lcaron 0x01a5 /* U+013D LATIN CAPITAL LETTER L WITH CARON */
+#define XK_Sacute 0x01a6 /* U+015A LATIN CAPITAL LETTER S WITH ACUTE */
+#define XK_Scaron 0x01a9 /* U+0160 LATIN CAPITAL LETTER S WITH CARON */
+#define XK_Scedilla 0x01aa /* U+015E LATIN CAPITAL LETTER S WITH CEDILLA */
+#define XK_Tcaron 0x01ab /* U+0164 LATIN CAPITAL LETTER T WITH CARON */
+#define XK_Zacute 0x01ac /* U+0179 LATIN CAPITAL LETTER Z WITH ACUTE */
+#define XK_Zcaron 0x01ae /* U+017D LATIN CAPITAL LETTER Z WITH CARON */
+#define XK_Zabovedot 0x01af /* U+017B LATIN CAPITAL LETTER Z WITH DOT ABOVE */
+#define XK_aogonek 0x01b1 /* U+0105 LATIN SMALL LETTER A WITH OGONEK */
+#define XK_ogonek 0x01b2 /* U+02DB OGONEK */
+#define XK_lstroke 0x01b3 /* U+0142 LATIN SMALL LETTER L WITH STROKE */
+#define XK_lcaron 0x01b5 /* U+013E LATIN SMALL LETTER L WITH CARON */
+#define XK_sacute 0x01b6 /* U+015B LATIN SMALL LETTER S WITH ACUTE */
+#define XK_caron 0x01b7 /* U+02C7 CARON */
+#define XK_scaron 0x01b9 /* U+0161 LATIN SMALL LETTER S WITH CARON */
+#define XK_scedilla 0x01ba /* U+015F LATIN SMALL LETTER S WITH CEDILLA */
+#define XK_tcaron 0x01bb /* U+0165 LATIN SMALL LETTER T WITH CARON */
+#define XK_zacute 0x01bc /* U+017A LATIN SMALL LETTER Z WITH ACUTE */
+#define XK_doubleacute 0x01bd /* U+02DD DOUBLE ACUTE ACCENT */
+#define XK_zcaron 0x01be /* U+017E LATIN SMALL LETTER Z WITH CARON */
+#define XK_zabovedot 0x01bf /* U+017C LATIN SMALL LETTER Z WITH DOT ABOVE */
+#define XK_Racute 0x01c0 /* U+0154 LATIN CAPITAL LETTER R WITH ACUTE */
+#define XK_Abreve 0x01c3 /* U+0102 LATIN CAPITAL LETTER A WITH BREVE */
+#define XK_Lacute 0x01c5 /* U+0139 LATIN CAPITAL LETTER L WITH ACUTE */
+#define XK_Cacute 0x01c6 /* U+0106 LATIN CAPITAL LETTER C WITH ACUTE */
+#define XK_Ccaron 0x01c8 /* U+010C LATIN CAPITAL LETTER C WITH CARON */
+#define XK_Eogonek 0x01ca /* U+0118 LATIN CAPITAL LETTER E WITH OGONEK */
+#define XK_Ecaron 0x01cc /* U+011A LATIN CAPITAL LETTER E WITH CARON */
+#define XK_Dcaron 0x01cf /* U+010E LATIN CAPITAL LETTER D WITH CARON */
+#define XK_Dstroke 0x01d0 /* U+0110 LATIN CAPITAL LETTER D WITH STROKE */
+#define XK_Nacute 0x01d1 /* U+0143 LATIN CAPITAL LETTER N WITH ACUTE */
+#define XK_Ncaron 0x01d2 /* U+0147 LATIN CAPITAL LETTER N WITH CARON */
+#define XK_Odoubleacute 0x01d5 /* U+0150 LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */
+#define XK_Rcaron 0x01d8 /* U+0158 LATIN CAPITAL LETTER R WITH CARON */
+#define XK_Uring 0x01d9 /* U+016E LATIN CAPITAL LETTER U WITH RING ABOVE */
+#define XK_Udoubleacute 0x01db /* U+0170 LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */
+#define XK_Tcedilla 0x01de /* U+0162 LATIN CAPITAL LETTER T WITH CEDILLA */
+#define XK_racute 0x01e0 /* U+0155 LATIN SMALL LETTER R WITH ACUTE */
+#define XK_abreve 0x01e3 /* U+0103 LATIN SMALL LETTER A WITH BREVE */
+#define XK_lacute 0x01e5 /* U+013A LATIN SMALL LETTER L WITH ACUTE */
+#define XK_cacute 0x01e6 /* U+0107 LATIN SMALL LETTER C WITH ACUTE */
+#define XK_ccaron 0x01e8 /* U+010D LATIN SMALL LETTER C WITH CARON */
+#define XK_eogonek 0x01ea /* U+0119 LATIN SMALL LETTER E WITH OGONEK */
+#define XK_ecaron 0x01ec /* U+011B LATIN SMALL LETTER E WITH CARON */
+#define XK_dcaron 0x01ef /* U+010F LATIN SMALL LETTER D WITH CARON */
+#define XK_dstroke 0x01f0 /* U+0111 LATIN SMALL LETTER D WITH STROKE */
+#define XK_nacute 0x01f1 /* U+0144 LATIN SMALL LETTER N WITH ACUTE */
+#define XK_ncaron 0x01f2 /* U+0148 LATIN SMALL LETTER N WITH CARON */
+#define XK_odoubleacute 0x01f5 /* U+0151 LATIN SMALL LETTER O WITH DOUBLE ACUTE */
+#define XK_rcaron 0x01f8 /* U+0159 LATIN SMALL LETTER R WITH CARON */
+#define XK_uring 0x01f9 /* U+016F LATIN SMALL LETTER U WITH RING ABOVE */
+#define XK_udoubleacute 0x01fb /* U+0171 LATIN SMALL LETTER U WITH DOUBLE ACUTE */
+#define XK_tcedilla 0x01fe /* U+0163 LATIN SMALL LETTER T WITH CEDILLA */
+#define XK_abovedot 0x01ff /* U+02D9 DOT ABOVE */
#endif /* XK_LATIN2 */
/*
- * Latin 3
- * Byte 3 = 2
+ * Latin 3
+ * Byte 3 = 2
*/
#ifdef XK_LATIN3
-#define XK_Hstroke 0x2a1
-#define XK_Hcircumflex 0x2a6
-#define XK_Iabovedot 0x2a9
-#define XK_Gbreve 0x2ab
-#define XK_Jcircumflex 0x2ac
-#define XK_hstroke 0x2b1
-#define XK_hcircumflex 0x2b6
-#define XK_idotless 0x2b9
-#define XK_gbreve 0x2bb
-#define XK_jcircumflex 0x2bc
-#define XK_Cabovedot 0x2c5
-#define XK_Ccircumflex 0x2c6
-#define XK_Gabovedot 0x2d5
-#define XK_Gcircumflex 0x2d8
-#define XK_Ubreve 0x2dd
-#define XK_Scircumflex 0x2de
-#define XK_cabovedot 0x2e5
-#define XK_ccircumflex 0x2e6
-#define XK_gabovedot 0x2f5
-#define XK_gcircumflex 0x2f8
-#define XK_ubreve 0x2fd
-#define XK_scircumflex 0x2fe
+#define XK_Hstroke 0x02a1 /* U+0126 LATIN CAPITAL LETTER H WITH STROKE */
+#define XK_Hcircumflex 0x02a6 /* U+0124 LATIN CAPITAL LETTER H WITH CIRCUMFLEX */
+#define XK_Iabovedot 0x02a9 /* U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE */
+#define XK_Gbreve 0x02ab /* U+011E LATIN CAPITAL LETTER G WITH BREVE */
+#define XK_Jcircumflex 0x02ac /* U+0134 LATIN CAPITAL LETTER J WITH CIRCUMFLEX */
+#define XK_hstroke 0x02b1 /* U+0127 LATIN SMALL LETTER H WITH STROKE */
+#define XK_hcircumflex 0x02b6 /* U+0125 LATIN SMALL LETTER H WITH CIRCUMFLEX */
+#define XK_idotless 0x02b9 /* U+0131 LATIN SMALL LETTER DOTLESS I */
+#define XK_gbreve 0x02bb /* U+011F LATIN SMALL LETTER G WITH BREVE */
+#define XK_jcircumflex 0x02bc /* U+0135 LATIN SMALL LETTER J WITH CIRCUMFLEX */
+#define XK_Cabovedot 0x02c5 /* U+010A LATIN CAPITAL LETTER C WITH DOT ABOVE */
+#define XK_Ccircumflex 0x02c6 /* U+0108 LATIN CAPITAL LETTER C WITH CIRCUMFLEX */
+#define XK_Gabovedot 0x02d5 /* U+0120 LATIN CAPITAL LETTER G WITH DOT ABOVE */
+#define XK_Gcircumflex 0x02d8 /* U+011C LATIN CAPITAL LETTER G WITH CIRCUMFLEX */
+#define XK_Ubreve 0x02dd /* U+016C LATIN CAPITAL LETTER U WITH BREVE */
+#define XK_Scircumflex 0x02de /* U+015C LATIN CAPITAL LETTER S WITH CIRCUMFLEX */
+#define XK_cabovedot 0x02e5 /* U+010B LATIN SMALL LETTER C WITH DOT ABOVE */
+#define XK_ccircumflex 0x02e6 /* U+0109 LATIN SMALL LETTER C WITH CIRCUMFLEX */
+#define XK_gabovedot 0x02f5 /* U+0121 LATIN SMALL LETTER G WITH DOT ABOVE */
+#define XK_gcircumflex 0x02f8 /* U+011D LATIN SMALL LETTER G WITH CIRCUMFLEX */
+#define XK_ubreve 0x02fd /* U+016D LATIN SMALL LETTER U WITH BREVE */
+#define XK_scircumflex 0x02fe /* U+015D LATIN SMALL LETTER S WITH CIRCUMFLEX */
#endif /* XK_LATIN3 */
/*
- * Latin 4
- * Byte 3 = 3
+ * Latin 4
+ * Byte 3 = 3
*/
#ifdef XK_LATIN4
-#define XK_kra 0x3a2
-#define XK_kappa 0x3a2 /* deprecated */
-#define XK_Rcedilla 0x3a3
-#define XK_Itilde 0x3a5
-#define XK_Lcedilla 0x3a6
-#define XK_Emacron 0x3aa
-#define XK_Gcedilla 0x3ab
-#define XK_Tslash 0x3ac
-#define XK_rcedilla 0x3b3
-#define XK_itilde 0x3b5
-#define XK_lcedilla 0x3b6
-#define XK_emacron 0x3ba
-#define XK_gcedilla 0x3bb
-#define XK_tslash 0x3bc
-#define XK_ENG 0x3bd
-#define XK_eng 0x3bf
-#define XK_Amacron 0x3c0
-#define XK_Iogonek 0x3c7
-#define XK_Eabovedot 0x3cc
-#define XK_Imacron 0x3cf
-#define XK_Ncedilla 0x3d1
-#define XK_Omacron 0x3d2
-#define XK_Kcedilla 0x3d3
-#define XK_Uogonek 0x3d9
-#define XK_Utilde 0x3dd
-#define XK_Umacron 0x3de
-#define XK_amacron 0x3e0
-#define XK_iogonek 0x3e7
-#define XK_eabovedot 0x3ec
-#define XK_imacron 0x3ef
-#define XK_ncedilla 0x3f1
-#define XK_omacron 0x3f2
-#define XK_kcedilla 0x3f3
-#define XK_uogonek 0x3f9
-#define XK_utilde 0x3fd
-#define XK_umacron 0x3fe
+#define XK_kra 0x03a2 /* U+0138 LATIN SMALL LETTER KRA */
+#define XK_kappa 0x03a2 /* deprecated */
+#define XK_Rcedilla 0x03a3 /* U+0156 LATIN CAPITAL LETTER R WITH CEDILLA */
+#define XK_Itilde 0x03a5 /* U+0128 LATIN CAPITAL LETTER I WITH TILDE */
+#define XK_Lcedilla 0x03a6 /* U+013B LATIN CAPITAL LETTER L WITH CEDILLA */
+#define XK_Emacron 0x03aa /* U+0112 LATIN CAPITAL LETTER E WITH MACRON */
+#define XK_Gcedilla 0x03ab /* U+0122 LATIN CAPITAL LETTER G WITH CEDILLA */
+#define XK_Tslash 0x03ac /* U+0166 LATIN CAPITAL LETTER T WITH STROKE */
+#define XK_rcedilla 0x03b3 /* U+0157 LATIN SMALL LETTER R WITH CEDILLA */
+#define XK_itilde 0x03b5 /* U+0129 LATIN SMALL LETTER I WITH TILDE */
+#define XK_lcedilla 0x03b6 /* U+013C LATIN SMALL LETTER L WITH CEDILLA */
+#define XK_emacron 0x03ba /* U+0113 LATIN SMALL LETTER E WITH MACRON */
+#define XK_gcedilla 0x03bb /* U+0123 LATIN SMALL LETTER G WITH CEDILLA */
+#define XK_tslash 0x03bc /* U+0167 LATIN SMALL LETTER T WITH STROKE */
+#define XK_ENG 0x03bd /* U+014A LATIN CAPITAL LETTER ENG */
+#define XK_eng 0x03bf /* U+014B LATIN SMALL LETTER ENG */
+#define XK_Amacron 0x03c0 /* U+0100 LATIN CAPITAL LETTER A WITH MACRON */
+#define XK_Iogonek 0x03c7 /* U+012E LATIN CAPITAL LETTER I WITH OGONEK */
+#define XK_Eabovedot 0x03cc /* U+0116 LATIN CAPITAL LETTER E WITH DOT ABOVE */
+#define XK_Imacron 0x03cf /* U+012A LATIN CAPITAL LETTER I WITH MACRON */
+#define XK_Ncedilla 0x03d1 /* U+0145 LATIN CAPITAL LETTER N WITH CEDILLA */
+#define XK_Omacron 0x03d2 /* U+014C LATIN CAPITAL LETTER O WITH MACRON */
+#define XK_Kcedilla 0x03d3 /* U+0136 LATIN CAPITAL LETTER K WITH CEDILLA */
+#define XK_Uogonek 0x03d9 /* U+0172 LATIN CAPITAL LETTER U WITH OGONEK */
+#define XK_Utilde 0x03dd /* U+0168 LATIN CAPITAL LETTER U WITH TILDE */
+#define XK_Umacron 0x03de /* U+016A LATIN CAPITAL LETTER U WITH MACRON */
+#define XK_amacron 0x03e0 /* U+0101 LATIN SMALL LETTER A WITH MACRON */
+#define XK_iogonek 0x03e7 /* U+012F LATIN SMALL LETTER I WITH OGONEK */
+#define XK_eabovedot 0x03ec /* U+0117 LATIN SMALL LETTER E WITH DOT ABOVE */
+#define XK_imacron 0x03ef /* U+012B LATIN SMALL LETTER I WITH MACRON */
+#define XK_ncedilla 0x03f1 /* U+0146 LATIN SMALL LETTER N WITH CEDILLA */
+#define XK_omacron 0x03f2 /* U+014D LATIN SMALL LETTER O WITH MACRON */
+#define XK_kcedilla 0x03f3 /* U+0137 LATIN SMALL LETTER K WITH CEDILLA */
+#define XK_uogonek 0x03f9 /* U+0173 LATIN SMALL LETTER U WITH OGONEK */
+#define XK_utilde 0x03fd /* U+0169 LATIN SMALL LETTER U WITH TILDE */
+#define XK_umacron 0x03fe /* U+016B LATIN SMALL LETTER U WITH MACRON */
#endif /* XK_LATIN4 */
/*
+ * Latin 8
+ */
+#ifdef XK_LATIN8
+#define XK_Wcircumflex 0x1000174 /* U+0174 LATIN CAPITAL LETTER W WITH CIRCUMFLEX */
+#define XK_wcircumflex 0x1000175 /* U+0175 LATIN SMALL LETTER W WITH CIRCUMFLEX */
+#define XK_Ycircumflex 0x1000176 /* U+0176 LATIN CAPITAL LETTER Y WITH CIRCUMFLEX */
+#define XK_ycircumflex 0x1000177 /* U+0177 LATIN SMALL LETTER Y WITH CIRCUMFLEX */
+#define XK_Babovedot 0x1001e02 /* U+1E02 LATIN CAPITAL LETTER B WITH DOT ABOVE */
+#define XK_babovedot 0x1001e03 /* U+1E03 LATIN SMALL LETTER B WITH DOT ABOVE */
+#define XK_Dabovedot 0x1001e0a /* U+1E0A LATIN CAPITAL LETTER D WITH DOT ABOVE */
+#define XK_dabovedot 0x1001e0b /* U+1E0B LATIN SMALL LETTER D WITH DOT ABOVE */
+#define XK_Fabovedot 0x1001e1e /* U+1E1E LATIN CAPITAL LETTER F WITH DOT ABOVE */
+#define XK_fabovedot 0x1001e1f /* U+1E1F LATIN SMALL LETTER F WITH DOT ABOVE */
+#define XK_Mabovedot 0x1001e40 /* U+1E40 LATIN CAPITAL LETTER M WITH DOT ABOVE */
+#define XK_mabovedot 0x1001e41 /* U+1E41 LATIN SMALL LETTER M WITH DOT ABOVE */
+#define XK_Pabovedot 0x1001e56 /* U+1E56 LATIN CAPITAL LETTER P WITH DOT ABOVE */
+#define XK_pabovedot 0x1001e57 /* U+1E57 LATIN SMALL LETTER P WITH DOT ABOVE */
+#define XK_Sabovedot 0x1001e60 /* U+1E60 LATIN CAPITAL LETTER S WITH DOT ABOVE */
+#define XK_sabovedot 0x1001e61 /* U+1E61 LATIN SMALL LETTER S WITH DOT ABOVE */
+#define XK_Tabovedot 0x1001e6a /* U+1E6A LATIN CAPITAL LETTER T WITH DOT ABOVE */
+#define XK_tabovedot 0x1001e6b /* U+1E6B LATIN SMALL LETTER T WITH DOT ABOVE */
+#define XK_Wgrave 0x1001e80 /* U+1E80 LATIN CAPITAL LETTER W WITH GRAVE */
+#define XK_wgrave 0x1001e81 /* U+1E81 LATIN SMALL LETTER W WITH GRAVE */
+#define XK_Wacute 0x1001e82 /* U+1E82 LATIN CAPITAL LETTER W WITH ACUTE */
+#define XK_wacute 0x1001e83 /* U+1E83 LATIN SMALL LETTER W WITH ACUTE */
+#define XK_Wdiaeresis 0x1001e84 /* U+1E84 LATIN CAPITAL LETTER W WITH DIAERESIS */
+#define XK_wdiaeresis 0x1001e85 /* U+1E85 LATIN SMALL LETTER W WITH DIAERESIS */
+#define XK_Ygrave 0x1001ef2 /* U+1EF2 LATIN CAPITAL LETTER Y WITH GRAVE */
+#define XK_ygrave 0x1001ef3 /* U+1EF3 LATIN SMALL LETTER Y WITH GRAVE */
+#endif /* XK_LATIN8 */
+
+/*
+ * Latin 9
+ * Byte 3 = 0x13
+ */
+
+#ifdef XK_LATIN9
+#define XK_OE 0x13bc /* U+0152 LATIN CAPITAL LIGATURE OE */
+#define XK_oe 0x13bd /* U+0153 LATIN SMALL LIGATURE OE */
+#define XK_Ydiaeresis 0x13be /* U+0178 LATIN CAPITAL LETTER Y WITH DIAERESIS */
+#endif /* XK_LATIN9 */
+
+/*
* Katakana
* Byte 3 = 4
*/
#ifdef XK_KATAKANA
-#define XK_overline 0x47e
-#define XK_kana_fullstop 0x4a1
-#define XK_kana_openingbracket 0x4a2
-#define XK_kana_closingbracket 0x4a3
-#define XK_kana_comma 0x4a4
-#define XK_kana_conjunctive 0x4a5
-#define XK_kana_middledot 0x4a5 /* deprecated */
-#define XK_kana_WO 0x4a6
-#define XK_kana_a 0x4a7
-#define XK_kana_i 0x4a8
-#define XK_kana_u 0x4a9
-#define XK_kana_e 0x4aa
-#define XK_kana_o 0x4ab
-#define XK_kana_ya 0x4ac
-#define XK_kana_yu 0x4ad
-#define XK_kana_yo 0x4ae
-#define XK_kana_tsu 0x4af
-#define XK_kana_tu 0x4af /* deprecated */
-#define XK_prolongedsound 0x4b0
-#define XK_kana_A 0x4b1
-#define XK_kana_I 0x4b2
-#define XK_kana_U 0x4b3
-#define XK_kana_E 0x4b4
-#define XK_kana_O 0x4b5
-#define XK_kana_KA 0x4b6
-#define XK_kana_KI 0x4b7
-#define XK_kana_KU 0x4b8
-#define XK_kana_KE 0x4b9
-#define XK_kana_KO 0x4ba
-#define XK_kana_SA 0x4bb
-#define XK_kana_SHI 0x4bc
-#define XK_kana_SU 0x4bd
-#define XK_kana_SE 0x4be
-#define XK_kana_SO 0x4bf
-#define XK_kana_TA 0x4c0
-#define XK_kana_CHI 0x4c1
-#define XK_kana_TI 0x4c1 /* deprecated */
-#define XK_kana_TSU 0x4c2
-#define XK_kana_TU 0x4c2 /* deprecated */
-#define XK_kana_TE 0x4c3
-#define XK_kana_TO 0x4c4
-#define XK_kana_NA 0x4c5
-#define XK_kana_NI 0x4c6
-#define XK_kana_NU 0x4c7
-#define XK_kana_NE 0x4c8
-#define XK_kana_NO 0x4c9
-#define XK_kana_HA 0x4ca
-#define XK_kana_HI 0x4cb
-#define XK_kana_FU 0x4cc
-#define XK_kana_HU 0x4cc /* deprecated */
-#define XK_kana_HE 0x4cd
-#define XK_kana_HO 0x4ce
-#define XK_kana_MA 0x4cf
-#define XK_kana_MI 0x4d0
-#define XK_kana_MU 0x4d1
-#define XK_kana_ME 0x4d2
-#define XK_kana_MO 0x4d3
-#define XK_kana_YA 0x4d4
-#define XK_kana_YU 0x4d5
-#define XK_kana_YO 0x4d6
-#define XK_kana_RA 0x4d7
-#define XK_kana_RI 0x4d8
-#define XK_kana_RU 0x4d9
-#define XK_kana_RE 0x4da
-#define XK_kana_RO 0x4db
-#define XK_kana_WA 0x4dc
-#define XK_kana_N 0x4dd
-#define XK_voicedsound 0x4de
-#define XK_semivoicedsound 0x4df
-#define XK_kana_switch 0xFF7E /* Alias for mode_switch */
+#define XK_overline 0x047e /* U+203E OVERLINE */
+#define XK_kana_fullstop 0x04a1 /* U+3002 IDEOGRAPHIC FULL STOP */
+#define XK_kana_openingbracket 0x04a2 /* U+300C LEFT CORNER BRACKET */
+#define XK_kana_closingbracket 0x04a3 /* U+300D RIGHT CORNER BRACKET */
+#define XK_kana_comma 0x04a4 /* U+3001 IDEOGRAPHIC COMMA */
+#define XK_kana_conjunctive 0x04a5 /* U+30FB KATAKANA MIDDLE DOT */
+#define XK_kana_middledot 0x04a5 /* deprecated */
+#define XK_kana_WO 0x04a6 /* U+30F2 KATAKANA LETTER WO */
+#define XK_kana_a 0x04a7 /* U+30A1 KATAKANA LETTER SMALL A */
+#define XK_kana_i 0x04a8 /* U+30A3 KATAKANA LETTER SMALL I */
+#define XK_kana_u 0x04a9 /* U+30A5 KATAKANA LETTER SMALL U */
+#define XK_kana_e 0x04aa /* U+30A7 KATAKANA LETTER SMALL E */
+#define XK_kana_o 0x04ab /* U+30A9 KATAKANA LETTER SMALL O */
+#define XK_kana_ya 0x04ac /* U+30E3 KATAKANA LETTER SMALL YA */
+#define XK_kana_yu 0x04ad /* U+30E5 KATAKANA LETTER SMALL YU */
+#define XK_kana_yo 0x04ae /* U+30E7 KATAKANA LETTER SMALL YO */
+#define XK_kana_tsu 0x04af /* U+30C3 KATAKANA LETTER SMALL TU */
+#define XK_kana_tu 0x04af /* deprecated */
+#define XK_prolongedsound 0x04b0 /* U+30FC KATAKANA-HIRAGANA PROLONGED SOUND MARK */
+#define XK_kana_A 0x04b1 /* U+30A2 KATAKANA LETTER A */
+#define XK_kana_I 0x04b2 /* U+30A4 KATAKANA LETTER I */
+#define XK_kana_U 0x04b3 /* U+30A6 KATAKANA LETTER U */
+#define XK_kana_E 0x04b4 /* U+30A8 KATAKANA LETTER E */
+#define XK_kana_O 0x04b5 /* U+30AA KATAKANA LETTER O */
+#define XK_kana_KA 0x04b6 /* U+30AB KATAKANA LETTER KA */
+#define XK_kana_KI 0x04b7 /* U+30AD KATAKANA LETTER KI */
+#define XK_kana_KU 0x04b8 /* U+30AF KATAKANA LETTER KU */
+#define XK_kana_KE 0x04b9 /* U+30B1 KATAKANA LETTER KE */
+#define XK_kana_KO 0x04ba /* U+30B3 KATAKANA LETTER KO */
+#define XK_kana_SA 0x04bb /* U+30B5 KATAKANA LETTER SA */
+#define XK_kana_SHI 0x04bc /* U+30B7 KATAKANA LETTER SI */
+#define XK_kana_SU 0x04bd /* U+30B9 KATAKANA LETTER SU */
+#define XK_kana_SE 0x04be /* U+30BB KATAKANA LETTER SE */
+#define XK_kana_SO 0x04bf /* U+30BD KATAKANA LETTER SO */
+#define XK_kana_TA 0x04c0 /* U+30BF KATAKANA LETTER TA */
+#define XK_kana_CHI 0x04c1 /* U+30C1 KATAKANA LETTER TI */
+#define XK_kana_TI 0x04c1 /* deprecated */
+#define XK_kana_TSU 0x04c2 /* U+30C4 KATAKANA LETTER TU */
+#define XK_kana_TU 0x04c2 /* deprecated */
+#define XK_kana_TE 0x04c3 /* U+30C6 KATAKANA LETTER TE */
+#define XK_kana_TO 0x04c4 /* U+30C8 KATAKANA LETTER TO */
+#define XK_kana_NA 0x04c5 /* U+30CA KATAKANA LETTER NA */
+#define XK_kana_NI 0x04c6 /* U+30CB KATAKANA LETTER NI */
+#define XK_kana_NU 0x04c7 /* U+30CC KATAKANA LETTER NU */
+#define XK_kana_NE 0x04c8 /* U+30CD KATAKANA LETTER NE */
+#define XK_kana_NO 0x04c9 /* U+30CE KATAKANA LETTER NO */
+#define XK_kana_HA 0x04ca /* U+30CF KATAKANA LETTER HA */
+#define XK_kana_HI 0x04cb /* U+30D2 KATAKANA LETTER HI */
+#define XK_kana_FU 0x04cc /* U+30D5 KATAKANA LETTER HU */
+#define XK_kana_HU 0x04cc /* deprecated */
+#define XK_kana_HE 0x04cd /* U+30D8 KATAKANA LETTER HE */
+#define XK_kana_HO 0x04ce /* U+30DB KATAKANA LETTER HO */
+#define XK_kana_MA 0x04cf /* U+30DE KATAKANA LETTER MA */
+#define XK_kana_MI 0x04d0 /* U+30DF KATAKANA LETTER MI */
+#define XK_kana_MU 0x04d1 /* U+30E0 KATAKANA LETTER MU */
+#define XK_kana_ME 0x04d2 /* U+30E1 KATAKANA LETTER ME */
+#define XK_kana_MO 0x04d3 /* U+30E2 KATAKANA LETTER MO */
+#define XK_kana_YA 0x04d4 /* U+30E4 KATAKANA LETTER YA */
+#define XK_kana_YU 0x04d5 /* U+30E6 KATAKANA LETTER YU */
+#define XK_kana_YO 0x04d6 /* U+30E8 KATAKANA LETTER YO */
+#define XK_kana_RA 0x04d7 /* U+30E9 KATAKANA LETTER RA */
+#define XK_kana_RI 0x04d8 /* U+30EA KATAKANA LETTER RI */
+#define XK_kana_RU 0x04d9 /* U+30EB KATAKANA LETTER RU */
+#define XK_kana_RE 0x04da /* U+30EC KATAKANA LETTER RE */
+#define XK_kana_RO 0x04db /* U+30ED KATAKANA LETTER RO */
+#define XK_kana_WA 0x04dc /* U+30EF KATAKANA LETTER WA */
+#define XK_kana_N 0x04dd /* U+30F3 KATAKANA LETTER N */
+#define XK_voicedsound 0x04de /* U+309B KATAKANA-HIRAGANA VOICED SOUND MARK */
+#define XK_semivoicedsound 0x04df /* U+309C KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK */
+#define XK_kana_switch 0xff7e /* Alias for mode_switch */
#endif /* XK_KATAKANA */
/*
- * Arabic
- * Byte 3 = 5
+ * Arabic
+ * Byte 3 = 5
*/
#ifdef XK_ARABIC
-#define XK_Arabic_comma 0x5ac
-#define XK_Arabic_semicolon 0x5bb
-#define XK_Arabic_question_mark 0x5bf
-#define XK_Arabic_hamza 0x5c1
-#define XK_Arabic_maddaonalef 0x5c2
-#define XK_Arabic_hamzaonalef 0x5c3
-#define XK_Arabic_hamzaonwaw 0x5c4
-#define XK_Arabic_hamzaunderalef 0x5c5
-#define XK_Arabic_hamzaonyeh 0x5c6
-#define XK_Arabic_alef 0x5c7
-#define XK_Arabic_beh 0x5c8
-#define XK_Arabic_tehmarbuta 0x5c9
-#define XK_Arabic_teh 0x5ca
-#define XK_Arabic_theh 0x5cb
-#define XK_Arabic_jeem 0x5cc
-#define XK_Arabic_hah 0x5cd
-#define XK_Arabic_khah 0x5ce
-#define XK_Arabic_dal 0x5cf
-#define XK_Arabic_thal 0x5d0
-#define XK_Arabic_ra 0x5d1
-#define XK_Arabic_zain 0x5d2
-#define XK_Arabic_seen 0x5d3
-#define XK_Arabic_sheen 0x5d4
-#define XK_Arabic_sad 0x5d5
-#define XK_Arabic_dad 0x5d6
-#define XK_Arabic_tah 0x5d7
-#define XK_Arabic_zah 0x5d8
-#define XK_Arabic_ain 0x5d9
-#define XK_Arabic_ghain 0x5da
-#define XK_Arabic_tatweel 0x5e0
-#define XK_Arabic_feh 0x5e1
-#define XK_Arabic_qaf 0x5e2
-#define XK_Arabic_kaf 0x5e3
-#define XK_Arabic_lam 0x5e4
-#define XK_Arabic_meem 0x5e5
-#define XK_Arabic_noon 0x5e6
-#define XK_Arabic_ha 0x5e7
-#define XK_Arabic_heh 0x5e7 /* deprecated */
-#define XK_Arabic_waw 0x5e8
-#define XK_Arabic_alefmaksura 0x5e9
-#define XK_Arabic_yeh 0x5ea
-#define XK_Arabic_fathatan 0x5eb
-#define XK_Arabic_dammatan 0x5ec
-#define XK_Arabic_kasratan 0x5ed
-#define XK_Arabic_fatha 0x5ee
-#define XK_Arabic_damma 0x5ef
-#define XK_Arabic_kasra 0x5f0
-#define XK_Arabic_shadda 0x5f1
-#define XK_Arabic_sukun 0x5f2
-#define XK_Arabic_switch 0xFF7E /* Alias for mode_switch */
+#define XK_Farsi_0 0x10006f0 /* U+06F0 EXTENDED ARABIC-INDIC DIGIT ZERO */
+#define XK_Farsi_1 0x10006f1 /* U+06F1 EXTENDED ARABIC-INDIC DIGIT ONE */
+#define XK_Farsi_2 0x10006f2 /* U+06F2 EXTENDED ARABIC-INDIC DIGIT TWO */
+#define XK_Farsi_3 0x10006f3 /* U+06F3 EXTENDED ARABIC-INDIC DIGIT THREE */
+#define XK_Farsi_4 0x10006f4 /* U+06F4 EXTENDED ARABIC-INDIC DIGIT FOUR */
+#define XK_Farsi_5 0x10006f5 /* U+06F5 EXTENDED ARABIC-INDIC DIGIT FIVE */
+#define XK_Farsi_6 0x10006f6 /* U+06F6 EXTENDED ARABIC-INDIC DIGIT SIX */
+#define XK_Farsi_7 0x10006f7 /* U+06F7 EXTENDED ARABIC-INDIC DIGIT SEVEN */
+#define XK_Farsi_8 0x10006f8 /* U+06F8 EXTENDED ARABIC-INDIC DIGIT EIGHT */
+#define XK_Farsi_9 0x10006f9 /* U+06F9 EXTENDED ARABIC-INDIC DIGIT NINE */
+#define XK_Arabic_percent 0x100066a /* U+066A ARABIC PERCENT SIGN */
+#define XK_Arabic_superscript_alef 0x1000670 /* U+0670 ARABIC LETTER SUPERSCRIPT ALEF */
+#define XK_Arabic_tteh 0x1000679 /* U+0679 ARABIC LETTER TTEH */
+#define XK_Arabic_peh 0x100067e /* U+067E ARABIC LETTER PEH */
+#define XK_Arabic_tcheh 0x1000686 /* U+0686 ARABIC LETTER TCHEH */
+#define XK_Arabic_ddal 0x1000688 /* U+0688 ARABIC LETTER DDAL */
+#define XK_Arabic_rreh 0x1000691 /* U+0691 ARABIC LETTER RREH */
+#define XK_Arabic_comma 0x05ac /* U+060C ARABIC COMMA */
+#define XK_Arabic_fullstop 0x10006d4 /* U+06D4 ARABIC FULL STOP */
+#define XK_Arabic_0 0x1000660 /* U+0660 ARABIC-INDIC DIGIT ZERO */
+#define XK_Arabic_1 0x1000661 /* U+0661 ARABIC-INDIC DIGIT ONE */
+#define XK_Arabic_2 0x1000662 /* U+0662 ARABIC-INDIC DIGIT TWO */
+#define XK_Arabic_3 0x1000663 /* U+0663 ARABIC-INDIC DIGIT THREE */
+#define XK_Arabic_4 0x1000664 /* U+0664 ARABIC-INDIC DIGIT FOUR */
+#define XK_Arabic_5 0x1000665 /* U+0665 ARABIC-INDIC DIGIT FIVE */
+#define XK_Arabic_6 0x1000666 /* U+0666 ARABIC-INDIC DIGIT SIX */
+#define XK_Arabic_7 0x1000667 /* U+0667 ARABIC-INDIC DIGIT SEVEN */
+#define XK_Arabic_8 0x1000668 /* U+0668 ARABIC-INDIC DIGIT EIGHT */
+#define XK_Arabic_9 0x1000669 /* U+0669 ARABIC-INDIC DIGIT NINE */
+#define XK_Arabic_semicolon 0x05bb /* U+061B ARABIC SEMICOLON */
+#define XK_Arabic_question_mark 0x05bf /* U+061F ARABIC QUESTION MARK */
+#define XK_Arabic_hamza 0x05c1 /* U+0621 ARABIC LETTER HAMZA */
+#define XK_Arabic_maddaonalef 0x05c2 /* U+0622 ARABIC LETTER ALEF WITH MADDA ABOVE */
+#define XK_Arabic_hamzaonalef 0x05c3 /* U+0623 ARABIC LETTER ALEF WITH HAMZA ABOVE */
+#define XK_Arabic_hamzaonwaw 0x05c4 /* U+0624 ARABIC LETTER WAW WITH HAMZA ABOVE */
+#define XK_Arabic_hamzaunderalef 0x05c5 /* U+0625 ARABIC LETTER ALEF WITH HAMZA BELOW */
+#define XK_Arabic_hamzaonyeh 0x05c6 /* U+0626 ARABIC LETTER YEH WITH HAMZA ABOVE */
+#define XK_Arabic_alef 0x05c7 /* U+0627 ARABIC LETTER ALEF */
+#define XK_Arabic_beh 0x05c8 /* U+0628 ARABIC LETTER BEH */
+#define XK_Arabic_tehmarbuta 0x05c9 /* U+0629 ARABIC LETTER TEH MARBUTA */
+#define XK_Arabic_teh 0x05ca /* U+062A ARABIC LETTER TEH */
+#define XK_Arabic_theh 0x05cb /* U+062B ARABIC LETTER THEH */
+#define XK_Arabic_jeem 0x05cc /* U+062C ARABIC LETTER JEEM */
+#define XK_Arabic_hah 0x05cd /* U+062D ARABIC LETTER HAH */
+#define XK_Arabic_khah 0x05ce /* U+062E ARABIC LETTER KHAH */
+#define XK_Arabic_dal 0x05cf /* U+062F ARABIC LETTER DAL */
+#define XK_Arabic_thal 0x05d0 /* U+0630 ARABIC LETTER THAL */
+#define XK_Arabic_ra 0x05d1 /* U+0631 ARABIC LETTER REH */
+#define XK_Arabic_zain 0x05d2 /* U+0632 ARABIC LETTER ZAIN */
+#define XK_Arabic_seen 0x05d3 /* U+0633 ARABIC LETTER SEEN */
+#define XK_Arabic_sheen 0x05d4 /* U+0634 ARABIC LETTER SHEEN */
+#define XK_Arabic_sad 0x05d5 /* U+0635 ARABIC LETTER SAD */
+#define XK_Arabic_dad 0x05d6 /* U+0636 ARABIC LETTER DAD */
+#define XK_Arabic_tah 0x05d7 /* U+0637 ARABIC LETTER TAH */
+#define XK_Arabic_zah 0x05d8 /* U+0638 ARABIC LETTER ZAH */
+#define XK_Arabic_ain 0x05d9 /* U+0639 ARABIC LETTER AIN */
+#define XK_Arabic_ghain 0x05da /* U+063A ARABIC LETTER GHAIN */
+#define XK_Arabic_tatweel 0x05e0 /* U+0640 ARABIC TATWEEL */
+#define XK_Arabic_feh 0x05e1 /* U+0641 ARABIC LETTER FEH */
+#define XK_Arabic_qaf 0x05e2 /* U+0642 ARABIC LETTER QAF */
+#define XK_Arabic_kaf 0x05e3 /* U+0643 ARABIC LETTER KAF */
+#define XK_Arabic_lam 0x05e4 /* U+0644 ARABIC LETTER LAM */
+#define XK_Arabic_meem 0x05e5 /* U+0645 ARABIC LETTER MEEM */
+#define XK_Arabic_noon 0x05e6 /* U+0646 ARABIC LETTER NOON */
+#define XK_Arabic_ha 0x05e7 /* U+0647 ARABIC LETTER HEH */
+#define XK_Arabic_heh 0x05e7 /* deprecated */
+#define XK_Arabic_waw 0x05e8 /* U+0648 ARABIC LETTER WAW */
+#define XK_Arabic_alefmaksura 0x05e9 /* U+0649 ARABIC LETTER ALEF MAKSURA */
+#define XK_Arabic_yeh 0x05ea /* U+064A ARABIC LETTER YEH */
+#define XK_Arabic_fathatan 0x05eb /* U+064B ARABIC FATHATAN */
+#define XK_Arabic_dammatan 0x05ec /* U+064C ARABIC DAMMATAN */
+#define XK_Arabic_kasratan 0x05ed /* U+064D ARABIC KASRATAN */
+#define XK_Arabic_fatha 0x05ee /* U+064E ARABIC FATHA */
+#define XK_Arabic_damma 0x05ef /* U+064F ARABIC DAMMA */
+#define XK_Arabic_kasra 0x05f0 /* U+0650 ARABIC KASRA */
+#define XK_Arabic_shadda 0x05f1 /* U+0651 ARABIC SHADDA */
+#define XK_Arabic_sukun 0x05f2 /* U+0652 ARABIC SUKUN */
+#define XK_Arabic_madda_above 0x1000653 /* U+0653 ARABIC MADDAH ABOVE */
+#define XK_Arabic_hamza_above 0x1000654 /* U+0654 ARABIC HAMZA ABOVE */
+#define XK_Arabic_hamza_below 0x1000655 /* U+0655 ARABIC HAMZA BELOW */
+#define XK_Arabic_jeh 0x1000698 /* U+0698 ARABIC LETTER JEH */
+#define XK_Arabic_veh 0x10006a4 /* U+06A4 ARABIC LETTER VEH */
+#define XK_Arabic_keheh 0x10006a9 /* U+06A9 ARABIC LETTER KEHEH */
+#define XK_Arabic_gaf 0x10006af /* U+06AF ARABIC LETTER GAF */
+#define XK_Arabic_noon_ghunna 0x10006ba /* U+06BA ARABIC LETTER NOON GHUNNA */
+#define XK_Arabic_heh_doachashmee 0x10006be /* U+06BE ARABIC LETTER HEH DOACHASHMEE */
+#define XK_Farsi_yeh 0x10006cc /* U+06CC ARABIC LETTER FARSI YEH */
+#define XK_Arabic_farsi_yeh 0x10006cc /* U+06CC ARABIC LETTER FARSI YEH */
+#define XK_Arabic_yeh_baree 0x10006d2 /* U+06D2 ARABIC LETTER YEH BARREE */
+#define XK_Arabic_heh_goal 0x10006c1 /* U+06C1 ARABIC LETTER HEH GOAL */
+#define XK_Arabic_switch 0xff7e /* Alias for mode_switch */
#endif /* XK_ARABIC */
/*
@@ -721,456 +1111,1401 @@ SOFTWARE.
* Byte 3 = 6
*/
#ifdef XK_CYRILLIC
-#define XK_Serbian_dje 0x6a1
-#define XK_Macedonia_gje 0x6a2
-#define XK_Cyrillic_io 0x6a3
-#define XK_Ukrainian_ie 0x6a4
-#define XK_Ukranian_je 0x6a4 /* deprecated */
-#define XK_Macedonia_dse 0x6a5
-#define XK_Ukrainian_i 0x6a6
-#define XK_Ukranian_i 0x6a6 /* deprecated */
-#define XK_Ukrainian_yi 0x6a7
-#define XK_Ukranian_yi 0x6a7 /* deprecated */
-#define XK_Cyrillic_je 0x6a8
-#define XK_Serbian_je 0x6a8 /* deprecated */
-#define XK_Cyrillic_lje 0x6a9
-#define XK_Serbian_lje 0x6a9 /* deprecated */
-#define XK_Cyrillic_nje 0x6aa
-#define XK_Serbian_nje 0x6aa /* deprecated */
-#define XK_Serbian_tshe 0x6ab
-#define XK_Macedonia_kje 0x6ac
-#define XK_Byelorussian_shortu 0x6ae
-#define XK_Cyrillic_dzhe 0x6af
-#define XK_Serbian_dze 0x6af /* deprecated */
-#define XK_numerosign 0x6b0
-#define XK_Serbian_DJE 0x6b1
-#define XK_Macedonia_GJE 0x6b2
-#define XK_Cyrillic_IO 0x6b3
-#define XK_Ukrainian_IE 0x6b4
-#define XK_Ukranian_JE 0x6b4 /* deprecated */
-#define XK_Macedonia_DSE 0x6b5
-#define XK_Ukrainian_I 0x6b6
-#define XK_Ukranian_I 0x6b6 /* deprecated */
-#define XK_Ukrainian_YI 0x6b7
-#define XK_Ukranian_YI 0x6b7 /* deprecated */
-#define XK_Cyrillic_JE 0x6b8
-#define XK_Serbian_JE 0x6b8 /* deprecated */
-#define XK_Cyrillic_LJE 0x6b9
-#define XK_Serbian_LJE 0x6b9 /* deprecated */
-#define XK_Cyrillic_NJE 0x6ba
-#define XK_Serbian_NJE 0x6ba /* deprecated */
-#define XK_Serbian_TSHE 0x6bb
-#define XK_Macedonia_KJE 0x6bc
-#define XK_Byelorussian_SHORTU 0x6be
-#define XK_Cyrillic_DZHE 0x6bf
-#define XK_Serbian_DZE 0x6bf /* deprecated */
-#define XK_Cyrillic_yu 0x6c0
-#define XK_Cyrillic_a 0x6c1
-#define XK_Cyrillic_be 0x6c2
-#define XK_Cyrillic_tse 0x6c3
-#define XK_Cyrillic_de 0x6c4
-#define XK_Cyrillic_ie 0x6c5
-#define XK_Cyrillic_ef 0x6c6
-#define XK_Cyrillic_ghe 0x6c7
-#define XK_Cyrillic_ha 0x6c8
-#define XK_Cyrillic_i 0x6c9
-#define XK_Cyrillic_shorti 0x6ca
-#define XK_Cyrillic_ka 0x6cb
-#define XK_Cyrillic_el 0x6cc
-#define XK_Cyrillic_em 0x6cd
-#define XK_Cyrillic_en 0x6ce
-#define XK_Cyrillic_o 0x6cf
-#define XK_Cyrillic_pe 0x6d0
-#define XK_Cyrillic_ya 0x6d1
-#define XK_Cyrillic_er 0x6d2
-#define XK_Cyrillic_es 0x6d3
-#define XK_Cyrillic_te 0x6d4
-#define XK_Cyrillic_u 0x6d5
-#define XK_Cyrillic_zhe 0x6d6
-#define XK_Cyrillic_ve 0x6d7
-#define XK_Cyrillic_softsign 0x6d8
-#define XK_Cyrillic_yeru 0x6d9
-#define XK_Cyrillic_ze 0x6da
-#define XK_Cyrillic_sha 0x6db
-#define XK_Cyrillic_e 0x6dc
-#define XK_Cyrillic_shcha 0x6dd
-#define XK_Cyrillic_che 0x6de
-#define XK_Cyrillic_hardsign 0x6df
-#define XK_Cyrillic_YU 0x6e0
-#define XK_Cyrillic_A 0x6e1
-#define XK_Cyrillic_BE 0x6e2
-#define XK_Cyrillic_TSE 0x6e3
-#define XK_Cyrillic_DE 0x6e4
-#define XK_Cyrillic_IE 0x6e5
-#define XK_Cyrillic_EF 0x6e6
-#define XK_Cyrillic_GHE 0x6e7
-#define XK_Cyrillic_HA 0x6e8
-#define XK_Cyrillic_I 0x6e9
-#define XK_Cyrillic_SHORTI 0x6ea
-#define XK_Cyrillic_KA 0x6eb
-#define XK_Cyrillic_EL 0x6ec
-#define XK_Cyrillic_EM 0x6ed
-#define XK_Cyrillic_EN 0x6ee
-#define XK_Cyrillic_O 0x6ef
-#define XK_Cyrillic_PE 0x6f0
-#define XK_Cyrillic_YA 0x6f1
-#define XK_Cyrillic_ER 0x6f2
-#define XK_Cyrillic_ES 0x6f3
-#define XK_Cyrillic_TE 0x6f4
-#define XK_Cyrillic_U 0x6f5
-#define XK_Cyrillic_ZHE 0x6f6
-#define XK_Cyrillic_VE 0x6f7
-#define XK_Cyrillic_SOFTSIGN 0x6f8
-#define XK_Cyrillic_YERU 0x6f9
-#define XK_Cyrillic_ZE 0x6fa
-#define XK_Cyrillic_SHA 0x6fb
-#define XK_Cyrillic_E 0x6fc
-#define XK_Cyrillic_SHCHA 0x6fd
-#define XK_Cyrillic_CHE 0x6fe
-#define XK_Cyrillic_HARDSIGN 0x6ff
+#define XK_Cyrillic_GHE_bar 0x1000492 /* U+0492 CYRILLIC CAPITAL LETTER GHE WITH STROKE */
+#define XK_Cyrillic_ghe_bar 0x1000493 /* U+0493 CYRILLIC SMALL LETTER GHE WITH STROKE */
+#define XK_Cyrillic_ZHE_descender 0x1000496 /* U+0496 CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER */
+#define XK_Cyrillic_zhe_descender 0x1000497 /* U+0497 CYRILLIC SMALL LETTER ZHE WITH DESCENDER */
+#define XK_Cyrillic_KA_descender 0x100049a /* U+049A CYRILLIC CAPITAL LETTER KA WITH DESCENDER */
+#define XK_Cyrillic_ka_descender 0x100049b /* U+049B CYRILLIC SMALL LETTER KA WITH DESCENDER */
+#define XK_Cyrillic_KA_vertstroke 0x100049c /* U+049C CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE */
+#define XK_Cyrillic_ka_vertstroke 0x100049d /* U+049D CYRILLIC SMALL LETTER KA WITH VERTICAL STROKE */
+#define XK_Cyrillic_EN_descender 0x10004a2 /* U+04A2 CYRILLIC CAPITAL LETTER EN WITH DESCENDER */
+#define XK_Cyrillic_en_descender 0x10004a3 /* U+04A3 CYRILLIC SMALL LETTER EN WITH DESCENDER */
+#define XK_Cyrillic_U_straight 0x10004ae /* U+04AE CYRILLIC CAPITAL LETTER STRAIGHT U */
+#define XK_Cyrillic_u_straight 0x10004af /* U+04AF CYRILLIC SMALL LETTER STRAIGHT U */
+#define XK_Cyrillic_U_straight_bar 0x10004b0 /* U+04B0 CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE */
+#define XK_Cyrillic_u_straight_bar 0x10004b1 /* U+04B1 CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE */
+#define XK_Cyrillic_HA_descender 0x10004b2 /* U+04B2 CYRILLIC CAPITAL LETTER HA WITH DESCENDER */
+#define XK_Cyrillic_ha_descender 0x10004b3 /* U+04B3 CYRILLIC SMALL LETTER HA WITH DESCENDER */
+#define XK_Cyrillic_CHE_descender 0x10004b6 /* U+04B6 CYRILLIC CAPITAL LETTER CHE WITH DESCENDER */
+#define XK_Cyrillic_che_descender 0x10004b7 /* U+04B7 CYRILLIC SMALL LETTER CHE WITH DESCENDER */
+#define XK_Cyrillic_CHE_vertstroke 0x10004b8 /* U+04B8 CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE */
+#define XK_Cyrillic_che_vertstroke 0x10004b9 /* U+04B9 CYRILLIC SMALL LETTER CHE WITH VERTICAL STROKE */
+#define XK_Cyrillic_SHHA 0x10004ba /* U+04BA CYRILLIC CAPITAL LETTER SHHA */
+#define XK_Cyrillic_shha 0x10004bb /* U+04BB CYRILLIC SMALL LETTER SHHA */
+
+#define XK_Cyrillic_SCHWA 0x10004d8 /* U+04D8 CYRILLIC CAPITAL LETTER SCHWA */
+#define XK_Cyrillic_schwa 0x10004d9 /* U+04D9 CYRILLIC SMALL LETTER SCHWA */
+#define XK_Cyrillic_I_macron 0x10004e2 /* U+04E2 CYRILLIC CAPITAL LETTER I WITH MACRON */
+#define XK_Cyrillic_i_macron 0x10004e3 /* U+04E3 CYRILLIC SMALL LETTER I WITH MACRON */
+#define XK_Cyrillic_O_bar 0x10004e8 /* U+04E8 CYRILLIC CAPITAL LETTER BARRED O */
+#define XK_Cyrillic_o_bar 0x10004e9 /* U+04E9 CYRILLIC SMALL LETTER BARRED O */
+#define XK_Cyrillic_U_macron 0x10004ee /* U+04EE CYRILLIC CAPITAL LETTER U WITH MACRON */
+#define XK_Cyrillic_u_macron 0x10004ef /* U+04EF CYRILLIC SMALL LETTER U WITH MACRON */
+
+#define XK_Serbian_dje 0x06a1 /* U+0452 CYRILLIC SMALL LETTER DJE */
+#define XK_Macedonia_gje 0x06a2 /* U+0453 CYRILLIC SMALL LETTER GJE */
+#define XK_Cyrillic_io 0x06a3 /* U+0451 CYRILLIC SMALL LETTER IO */
+#define XK_Ukrainian_ie 0x06a4 /* U+0454 CYRILLIC SMALL LETTER UKRAINIAN IE */
+#define XK_Ukranian_je 0x06a4 /* deprecated */
+#define XK_Macedonia_dse 0x06a5 /* U+0455 CYRILLIC SMALL LETTER DZE */
+#define XK_Ukrainian_i 0x06a6 /* U+0456 CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I */
+#define XK_Ukranian_i 0x06a6 /* deprecated */
+#define XK_Ukrainian_yi 0x06a7 /* U+0457 CYRILLIC SMALL LETTER YI */
+#define XK_Ukranian_yi 0x06a7 /* deprecated */
+#define XK_Cyrillic_je 0x06a8 /* U+0458 CYRILLIC SMALL LETTER JE */
+#define XK_Serbian_je 0x06a8 /* deprecated */
+#define XK_Cyrillic_lje 0x06a9 /* U+0459 CYRILLIC SMALL LETTER LJE */
+#define XK_Serbian_lje 0x06a9 /* deprecated */
+#define XK_Cyrillic_nje 0x06aa /* U+045A CYRILLIC SMALL LETTER NJE */
+#define XK_Serbian_nje 0x06aa /* deprecated */
+#define XK_Serbian_tshe 0x06ab /* U+045B CYRILLIC SMALL LETTER TSHE */
+#define XK_Macedonia_kje 0x06ac /* U+045C CYRILLIC SMALL LETTER KJE */
+#define XK_Ukrainian_ghe_with_upturn 0x06ad /* U+0491 CYRILLIC SMALL LETTER GHE WITH UPTURN */
+#define XK_Byelorussian_shortu 0x06ae /* U+045E CYRILLIC SMALL LETTER SHORT U */
+#define XK_Cyrillic_dzhe 0x06af /* U+045F CYRILLIC SMALL LETTER DZHE */
+#define XK_Serbian_dze 0x06af /* deprecated */
+#define XK_numerosign 0x06b0 /* U+2116 NUMERO SIGN */
+#define XK_Serbian_DJE 0x06b1 /* U+0402 CYRILLIC CAPITAL LETTER DJE */
+#define XK_Macedonia_GJE 0x06b2 /* U+0403 CYRILLIC CAPITAL LETTER GJE */
+#define XK_Cyrillic_IO 0x06b3 /* U+0401 CYRILLIC CAPITAL LETTER IO */
+#define XK_Ukrainian_IE 0x06b4 /* U+0404 CYRILLIC CAPITAL LETTER UKRAINIAN IE */
+#define XK_Ukranian_JE 0x06b4 /* deprecated */
+#define XK_Macedonia_DSE 0x06b5 /* U+0405 CYRILLIC CAPITAL LETTER DZE */
+#define XK_Ukrainian_I 0x06b6 /* U+0406 CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I */
+#define XK_Ukranian_I 0x06b6 /* deprecated */
+#define XK_Ukrainian_YI 0x06b7 /* U+0407 CYRILLIC CAPITAL LETTER YI */
+#define XK_Ukranian_YI 0x06b7 /* deprecated */
+#define XK_Cyrillic_JE 0x06b8 /* U+0408 CYRILLIC CAPITAL LETTER JE */
+#define XK_Serbian_JE 0x06b8 /* deprecated */
+#define XK_Cyrillic_LJE 0x06b9 /* U+0409 CYRILLIC CAPITAL LETTER LJE */
+#define XK_Serbian_LJE 0x06b9 /* deprecated */
+#define XK_Cyrillic_NJE 0x06ba /* U+040A CYRILLIC CAPITAL LETTER NJE */
+#define XK_Serbian_NJE 0x06ba /* deprecated */
+#define XK_Serbian_TSHE 0x06bb /* U+040B CYRILLIC CAPITAL LETTER TSHE */
+#define XK_Macedonia_KJE 0x06bc /* U+040C CYRILLIC CAPITAL LETTER KJE */
+#define XK_Ukrainian_GHE_WITH_UPTURN 0x06bd /* U+0490 CYRILLIC CAPITAL LETTER GHE WITH UPTURN */
+#define XK_Byelorussian_SHORTU 0x06be /* U+040E CYRILLIC CAPITAL LETTER SHORT U */
+#define XK_Cyrillic_DZHE 0x06bf /* U+040F CYRILLIC CAPITAL LETTER DZHE */
+#define XK_Serbian_DZE 0x06bf /* deprecated */
+#define XK_Cyrillic_yu 0x06c0 /* U+044E CYRILLIC SMALL LETTER YU */
+#define XK_Cyrillic_a 0x06c1 /* U+0430 CYRILLIC SMALL LETTER A */
+#define XK_Cyrillic_be 0x06c2 /* U+0431 CYRILLIC SMALL LETTER BE */
+#define XK_Cyrillic_tse 0x06c3 /* U+0446 CYRILLIC SMALL LETTER TSE */
+#define XK_Cyrillic_de 0x06c4 /* U+0434 CYRILLIC SMALL LETTER DE */
+#define XK_Cyrillic_ie 0x06c5 /* U+0435 CYRILLIC SMALL LETTER IE */
+#define XK_Cyrillic_ef 0x06c6 /* U+0444 CYRILLIC SMALL LETTER EF */
+#define XK_Cyrillic_ghe 0x06c7 /* U+0433 CYRILLIC SMALL LETTER GHE */
+#define XK_Cyrillic_ha 0x06c8 /* U+0445 CYRILLIC SMALL LETTER HA */
+#define XK_Cyrillic_i 0x06c9 /* U+0438 CYRILLIC SMALL LETTER I */
+#define XK_Cyrillic_shorti 0x06ca /* U+0439 CYRILLIC SMALL LETTER SHORT I */
+#define XK_Cyrillic_ka 0x06cb /* U+043A CYRILLIC SMALL LETTER KA */
+#define XK_Cyrillic_el 0x06cc /* U+043B CYRILLIC SMALL LETTER EL */
+#define XK_Cyrillic_em 0x06cd /* U+043C CYRILLIC SMALL LETTER EM */
+#define XK_Cyrillic_en 0x06ce /* U+043D CYRILLIC SMALL LETTER EN */
+#define XK_Cyrillic_o 0x06cf /* U+043E CYRILLIC SMALL LETTER O */
+#define XK_Cyrillic_pe 0x06d0 /* U+043F CYRILLIC SMALL LETTER PE */
+#define XK_Cyrillic_ya 0x06d1 /* U+044F CYRILLIC SMALL LETTER YA */
+#define XK_Cyrillic_er 0x06d2 /* U+0440 CYRILLIC SMALL LETTER ER */
+#define XK_Cyrillic_es 0x06d3 /* U+0441 CYRILLIC SMALL LETTER ES */
+#define XK_Cyrillic_te 0x06d4 /* U+0442 CYRILLIC SMALL LETTER TE */
+#define XK_Cyrillic_u 0x06d5 /* U+0443 CYRILLIC SMALL LETTER U */
+#define XK_Cyrillic_zhe 0x06d6 /* U+0436 CYRILLIC SMALL LETTER ZHE */
+#define XK_Cyrillic_ve 0x06d7 /* U+0432 CYRILLIC SMALL LETTER VE */
+#define XK_Cyrillic_softsign 0x06d8 /* U+044C CYRILLIC SMALL LETTER SOFT SIGN */
+#define XK_Cyrillic_yeru 0x06d9 /* U+044B CYRILLIC SMALL LETTER YERU */
+#define XK_Cyrillic_ze 0x06da /* U+0437 CYRILLIC SMALL LETTER ZE */
+#define XK_Cyrillic_sha 0x06db /* U+0448 CYRILLIC SMALL LETTER SHA */
+#define XK_Cyrillic_e 0x06dc /* U+044D CYRILLIC SMALL LETTER E */
+#define XK_Cyrillic_shcha 0x06dd /* U+0449 CYRILLIC SMALL LETTER SHCHA */
+#define XK_Cyrillic_che 0x06de /* U+0447 CYRILLIC SMALL LETTER CHE */
+#define XK_Cyrillic_hardsign 0x06df /* U+044A CYRILLIC SMALL LETTER HARD SIGN */
+#define XK_Cyrillic_YU 0x06e0 /* U+042E CYRILLIC CAPITAL LETTER YU */
+#define XK_Cyrillic_A 0x06e1 /* U+0410 CYRILLIC CAPITAL LETTER A */
+#define XK_Cyrillic_BE 0x06e2 /* U+0411 CYRILLIC CAPITAL LETTER BE */
+#define XK_Cyrillic_TSE 0x06e3 /* U+0426 CYRILLIC CAPITAL LETTER TSE */
+#define XK_Cyrillic_DE 0x06e4 /* U+0414 CYRILLIC CAPITAL LETTER DE */
+#define XK_Cyrillic_IE 0x06e5 /* U+0415 CYRILLIC CAPITAL LETTER IE */
+#define XK_Cyrillic_EF 0x06e6 /* U+0424 CYRILLIC CAPITAL LETTER EF */
+#define XK_Cyrillic_GHE 0x06e7 /* U+0413 CYRILLIC CAPITAL LETTER GHE */
+#define XK_Cyrillic_HA 0x06e8 /* U+0425 CYRILLIC CAPITAL LETTER HA */
+#define XK_Cyrillic_I 0x06e9 /* U+0418 CYRILLIC CAPITAL LETTER I */
+#define XK_Cyrillic_SHORTI 0x06ea /* U+0419 CYRILLIC CAPITAL LETTER SHORT I */
+#define XK_Cyrillic_KA 0x06eb /* U+041A CYRILLIC CAPITAL LETTER KA */
+#define XK_Cyrillic_EL 0x06ec /* U+041B CYRILLIC CAPITAL LETTER EL */
+#define XK_Cyrillic_EM 0x06ed /* U+041C CYRILLIC CAPITAL LETTER EM */
+#define XK_Cyrillic_EN 0x06ee /* U+041D CYRILLIC CAPITAL LETTER EN */
+#define XK_Cyrillic_O 0x06ef /* U+041E CYRILLIC CAPITAL LETTER O */
+#define XK_Cyrillic_PE 0x06f0 /* U+041F CYRILLIC CAPITAL LETTER PE */
+#define XK_Cyrillic_YA 0x06f1 /* U+042F CYRILLIC CAPITAL LETTER YA */
+#define XK_Cyrillic_ER 0x06f2 /* U+0420 CYRILLIC CAPITAL LETTER ER */
+#define XK_Cyrillic_ES 0x06f3 /* U+0421 CYRILLIC CAPITAL LETTER ES */
+#define XK_Cyrillic_TE 0x06f4 /* U+0422 CYRILLIC CAPITAL LETTER TE */
+#define XK_Cyrillic_U 0x06f5 /* U+0423 CYRILLIC CAPITAL LETTER U */
+#define XK_Cyrillic_ZHE 0x06f6 /* U+0416 CYRILLIC CAPITAL LETTER ZHE */
+#define XK_Cyrillic_VE 0x06f7 /* U+0412 CYRILLIC CAPITAL LETTER VE */
+#define XK_Cyrillic_SOFTSIGN 0x06f8 /* U+042C CYRILLIC CAPITAL LETTER SOFT SIGN */
+#define XK_Cyrillic_YERU 0x06f9 /* U+042B CYRILLIC CAPITAL LETTER YERU */
+#define XK_Cyrillic_ZE 0x06fa /* U+0417 CYRILLIC CAPITAL LETTER ZE */
+#define XK_Cyrillic_SHA 0x06fb /* U+0428 CYRILLIC CAPITAL LETTER SHA */
+#define XK_Cyrillic_E 0x06fc /* U+042D CYRILLIC CAPITAL LETTER E */
+#define XK_Cyrillic_SHCHA 0x06fd /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */
+#define XK_Cyrillic_CHE 0x06fe /* U+0427 CYRILLIC CAPITAL LETTER CHE */
+#define XK_Cyrillic_HARDSIGN 0x06ff /* U+042A CYRILLIC CAPITAL LETTER HARD SIGN */
#endif /* XK_CYRILLIC */
/*
* Greek
+ * (based on an early draft of, and not quite identical to, ISO/IEC 8859-7)
* Byte 3 = 7
*/
#ifdef XK_GREEK
-#define XK_Greek_ALPHAaccent 0x7a1
-#define XK_Greek_EPSILONaccent 0x7a2
-#define XK_Greek_ETAaccent 0x7a3
-#define XK_Greek_IOTAaccent 0x7a4
-#define XK_Greek_IOTAdiaeresis 0x7a5
-#define XK_Greek_OMICRONaccent 0x7a7
-#define XK_Greek_UPSILONaccent 0x7a8
-#define XK_Greek_UPSILONdieresis 0x7a9
-#define XK_Greek_OMEGAaccent 0x7ab
-#define XK_Greek_accentdieresis 0x7ae
-#define XK_Greek_horizbar 0x7af
-#define XK_Greek_alphaaccent 0x7b1
-#define XK_Greek_epsilonaccent 0x7b2
-#define XK_Greek_etaaccent 0x7b3
-#define XK_Greek_iotaaccent 0x7b4
-#define XK_Greek_iotadieresis 0x7b5
-#define XK_Greek_iotaaccentdieresis 0x7b6
-#define XK_Greek_omicronaccent 0x7b7
-#define XK_Greek_upsilonaccent 0x7b8
-#define XK_Greek_upsilondieresis 0x7b9
-#define XK_Greek_upsilonaccentdieresis 0x7ba
-#define XK_Greek_omegaaccent 0x7bb
-#define XK_Greek_ALPHA 0x7c1
-#define XK_Greek_BETA 0x7c2
-#define XK_Greek_GAMMA 0x7c3
-#define XK_Greek_DELTA 0x7c4
-#define XK_Greek_EPSILON 0x7c5
-#define XK_Greek_ZETA 0x7c6
-#define XK_Greek_ETA 0x7c7
-#define XK_Greek_THETA 0x7c8
-#define XK_Greek_IOTA 0x7c9
-#define XK_Greek_KAPPA 0x7ca
-#define XK_Greek_LAMDA 0x7cb
-#define XK_Greek_LAMBDA 0x7cb
-#define XK_Greek_MU 0x7cc
-#define XK_Greek_NU 0x7cd
-#define XK_Greek_XI 0x7ce
-#define XK_Greek_OMICRON 0x7cf
-#define XK_Greek_PI 0x7d0
-#define XK_Greek_RHO 0x7d1
-#define XK_Greek_SIGMA 0x7d2
-#define XK_Greek_TAU 0x7d4
-#define XK_Greek_UPSILON 0x7d5
-#define XK_Greek_PHI 0x7d6
-#define XK_Greek_CHI 0x7d7
-#define XK_Greek_PSI 0x7d8
-#define XK_Greek_OMEGA 0x7d9
-#define XK_Greek_alpha 0x7e1
-#define XK_Greek_beta 0x7e2
-#define XK_Greek_gamma 0x7e3
-#define XK_Greek_delta 0x7e4
-#define XK_Greek_epsilon 0x7e5
-#define XK_Greek_zeta 0x7e6
-#define XK_Greek_eta 0x7e7
-#define XK_Greek_theta 0x7e8
-#define XK_Greek_iota 0x7e9
-#define XK_Greek_kappa 0x7ea
-#define XK_Greek_lamda 0x7eb
-#define XK_Greek_lambda 0x7eb
-#define XK_Greek_mu 0x7ec
-#define XK_Greek_nu 0x7ed
-#define XK_Greek_xi 0x7ee
-#define XK_Greek_omicron 0x7ef
-#define XK_Greek_pi 0x7f0
-#define XK_Greek_rho 0x7f1
-#define XK_Greek_sigma 0x7f2
-#define XK_Greek_finalsmallsigma 0x7f3
-#define XK_Greek_tau 0x7f4
-#define XK_Greek_upsilon 0x7f5
-#define XK_Greek_phi 0x7f6
-#define XK_Greek_chi 0x7f7
-#define XK_Greek_psi 0x7f8
-#define XK_Greek_omega 0x7f9
-#define XK_Greek_switch 0xFF7E /* Alias for mode_switch */
+#define XK_Greek_ALPHAaccent 0x07a1 /* U+0386 GREEK CAPITAL LETTER ALPHA WITH TONOS */
+#define XK_Greek_EPSILONaccent 0x07a2 /* U+0388 GREEK CAPITAL LETTER EPSILON WITH TONOS */
+#define XK_Greek_ETAaccent 0x07a3 /* U+0389 GREEK CAPITAL LETTER ETA WITH TONOS */
+#define XK_Greek_IOTAaccent 0x07a4 /* U+038A GREEK CAPITAL LETTER IOTA WITH TONOS */
+#define XK_Greek_IOTAdieresis 0x07a5 /* U+03AA GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */
+#define XK_Greek_IOTAdiaeresis 0x07a5 /* old typo */
+#define XK_Greek_OMICRONaccent 0x07a7 /* U+038C GREEK CAPITAL LETTER OMICRON WITH TONOS */
+#define XK_Greek_UPSILONaccent 0x07a8 /* U+038E GREEK CAPITAL LETTER UPSILON WITH TONOS */
+#define XK_Greek_UPSILONdieresis 0x07a9 /* U+03AB GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA */
+#define XK_Greek_OMEGAaccent 0x07ab /* U+038F GREEK CAPITAL LETTER OMEGA WITH TONOS */
+#define XK_Greek_accentdieresis 0x07ae /* U+0385 GREEK DIALYTIKA TONOS */
+#define XK_Greek_horizbar 0x07af /* U+2015 HORIZONTAL BAR */
+#define XK_Greek_alphaaccent 0x07b1 /* U+03AC GREEK SMALL LETTER ALPHA WITH TONOS */
+#define XK_Greek_epsilonaccent 0x07b2 /* U+03AD GREEK SMALL LETTER EPSILON WITH TONOS */
+#define XK_Greek_etaaccent 0x07b3 /* U+03AE GREEK SMALL LETTER ETA WITH TONOS */
+#define XK_Greek_iotaaccent 0x07b4 /* U+03AF GREEK SMALL LETTER IOTA WITH TONOS */
+#define XK_Greek_iotadieresis 0x07b5 /* U+03CA GREEK SMALL LETTER IOTA WITH DIALYTIKA */
+#define XK_Greek_iotaaccentdieresis 0x07b6 /* U+0390 GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS */
+#define XK_Greek_omicronaccent 0x07b7 /* U+03CC GREEK SMALL LETTER OMICRON WITH TONOS */
+#define XK_Greek_upsilonaccent 0x07b8 /* U+03CD GREEK SMALL LETTER UPSILON WITH TONOS */
+#define XK_Greek_upsilondieresis 0x07b9 /* U+03CB GREEK SMALL LETTER UPSILON WITH DIALYTIKA */
+#define XK_Greek_upsilonaccentdieresis 0x07ba /* U+03B0 GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS */
+#define XK_Greek_omegaaccent 0x07bb /* U+03CE GREEK SMALL LETTER OMEGA WITH TONOS */
+#define XK_Greek_ALPHA 0x07c1 /* U+0391 GREEK CAPITAL LETTER ALPHA */
+#define XK_Greek_BETA 0x07c2 /* U+0392 GREEK CAPITAL LETTER BETA */
+#define XK_Greek_GAMMA 0x07c3 /* U+0393 GREEK CAPITAL LETTER GAMMA */
+#define XK_Greek_DELTA 0x07c4 /* U+0394 GREEK CAPITAL LETTER DELTA */
+#define XK_Greek_EPSILON 0x07c5 /* U+0395 GREEK CAPITAL LETTER EPSILON */
+#define XK_Greek_ZETA 0x07c6 /* U+0396 GREEK CAPITAL LETTER ZETA */
+#define XK_Greek_ETA 0x07c7 /* U+0397 GREEK CAPITAL LETTER ETA */
+#define XK_Greek_THETA 0x07c8 /* U+0398 GREEK CAPITAL LETTER THETA */
+#define XK_Greek_IOTA 0x07c9 /* U+0399 GREEK CAPITAL LETTER IOTA */
+#define XK_Greek_KAPPA 0x07ca /* U+039A GREEK CAPITAL LETTER KAPPA */
+#define XK_Greek_LAMDA 0x07cb /* U+039B GREEK CAPITAL LETTER LAMDA */
+#define XK_Greek_LAMBDA 0x07cb /* U+039B GREEK CAPITAL LETTER LAMDA */
+#define XK_Greek_MU 0x07cc /* U+039C GREEK CAPITAL LETTER MU */
+#define XK_Greek_NU 0x07cd /* U+039D GREEK CAPITAL LETTER NU */
+#define XK_Greek_XI 0x07ce /* U+039E GREEK CAPITAL LETTER XI */
+#define XK_Greek_OMICRON 0x07cf /* U+039F GREEK CAPITAL LETTER OMICRON */
+#define XK_Greek_PI 0x07d0 /* U+03A0 GREEK CAPITAL LETTER PI */
+#define XK_Greek_RHO 0x07d1 /* U+03A1 GREEK CAPITAL LETTER RHO */
+#define XK_Greek_SIGMA 0x07d2 /* U+03A3 GREEK CAPITAL LETTER SIGMA */
+#define XK_Greek_TAU 0x07d4 /* U+03A4 GREEK CAPITAL LETTER TAU */
+#define XK_Greek_UPSILON 0x07d5 /* U+03A5 GREEK CAPITAL LETTER UPSILON */
+#define XK_Greek_PHI 0x07d6 /* U+03A6 GREEK CAPITAL LETTER PHI */
+#define XK_Greek_CHI 0x07d7 /* U+03A7 GREEK CAPITAL LETTER CHI */
+#define XK_Greek_PSI 0x07d8 /* U+03A8 GREEK CAPITAL LETTER PSI */
+#define XK_Greek_OMEGA 0x07d9 /* U+03A9 GREEK CAPITAL LETTER OMEGA */
+#define XK_Greek_alpha 0x07e1 /* U+03B1 GREEK SMALL LETTER ALPHA */
+#define XK_Greek_beta 0x07e2 /* U+03B2 GREEK SMALL LETTER BETA */
+#define XK_Greek_gamma 0x07e3 /* U+03B3 GREEK SMALL LETTER GAMMA */
+#define XK_Greek_delta 0x07e4 /* U+03B4 GREEK SMALL LETTER DELTA */
+#define XK_Greek_epsilon 0x07e5 /* U+03B5 GREEK SMALL LETTER EPSILON */
+#define XK_Greek_zeta 0x07e6 /* U+03B6 GREEK SMALL LETTER ZETA */
+#define XK_Greek_eta 0x07e7 /* U+03B7 GREEK SMALL LETTER ETA */
+#define XK_Greek_theta 0x07e8 /* U+03B8 GREEK SMALL LETTER THETA */
+#define XK_Greek_iota 0x07e9 /* U+03B9 GREEK SMALL LETTER IOTA */
+#define XK_Greek_kappa 0x07ea /* U+03BA GREEK SMALL LETTER KAPPA */
+#define XK_Greek_lamda 0x07eb /* U+03BB GREEK SMALL LETTER LAMDA */
+#define XK_Greek_lambda 0x07eb /* U+03BB GREEK SMALL LETTER LAMDA */
+#define XK_Greek_mu 0x07ec /* U+03BC GREEK SMALL LETTER MU */
+#define XK_Greek_nu 0x07ed /* U+03BD GREEK SMALL LETTER NU */
+#define XK_Greek_xi 0x07ee /* U+03BE GREEK SMALL LETTER XI */
+#define XK_Greek_omicron 0x07ef /* U+03BF GREEK SMALL LETTER OMICRON */
+#define XK_Greek_pi 0x07f0 /* U+03C0 GREEK SMALL LETTER PI */
+#define XK_Greek_rho 0x07f1 /* U+03C1 GREEK SMALL LETTER RHO */
+#define XK_Greek_sigma 0x07f2 /* U+03C3 GREEK SMALL LETTER SIGMA */
+#define XK_Greek_finalsmallsigma 0x07f3 /* U+03C2 GREEK SMALL LETTER FINAL SIGMA */
+#define XK_Greek_tau 0x07f4 /* U+03C4 GREEK SMALL LETTER TAU */
+#define XK_Greek_upsilon 0x07f5 /* U+03C5 GREEK SMALL LETTER UPSILON */
+#define XK_Greek_phi 0x07f6 /* U+03C6 GREEK SMALL LETTER PHI */
+#define XK_Greek_chi 0x07f7 /* U+03C7 GREEK SMALL LETTER CHI */
+#define XK_Greek_psi 0x07f8 /* U+03C8 GREEK SMALL LETTER PSI */
+#define XK_Greek_omega 0x07f9 /* U+03C9 GREEK SMALL LETTER OMEGA */
+#define XK_Greek_switch 0xff7e /* Alias for mode_switch */
#endif /* XK_GREEK */
/*
* Technical
+ * (from the DEC VT330/VT420 Technical Character Set, http://vt100.net/charsets/technical.html)
* Byte 3 = 8
*/
#ifdef XK_TECHNICAL
-#define XK_leftradical 0x8a1
-#define XK_topleftradical 0x8a2
-#define XK_horizconnector 0x8a3
-#define XK_topintegral 0x8a4
-#define XK_botintegral 0x8a5
-#define XK_vertconnector 0x8a6
-#define XK_topleftsqbracket 0x8a7
-#define XK_botleftsqbracket 0x8a8
-#define XK_toprightsqbracket 0x8a9
-#define XK_botrightsqbracket 0x8aa
-#define XK_topleftparens 0x8ab
-#define XK_botleftparens 0x8ac
-#define XK_toprightparens 0x8ad
-#define XK_botrightparens 0x8ae
-#define XK_leftmiddlecurlybrace 0x8af
-#define XK_rightmiddlecurlybrace 0x8b0
-#define XK_topleftsummation 0x8b1
-#define XK_botleftsummation 0x8b2
-#define XK_topvertsummationconnector 0x8b3
-#define XK_botvertsummationconnector 0x8b4
-#define XK_toprightsummation 0x8b5
-#define XK_botrightsummation 0x8b6
-#define XK_rightmiddlesummation 0x8b7
-#define XK_lessthanequal 0x8bc
-#define XK_notequal 0x8bd
-#define XK_greaterthanequal 0x8be
-#define XK_integral 0x8bf
-#define XK_therefore 0x8c0
-#define XK_variation 0x8c1
-#define XK_infinity 0x8c2
-#define XK_nabla 0x8c5
-#define XK_approximate 0x8c8
-#define XK_similarequal 0x8c9
-#define XK_ifonlyif 0x8cd
-#define XK_implies 0x8ce
-#define XK_identical 0x8cf
-#define XK_radical 0x8d6
-#define XK_includedin 0x8da
-#define XK_includes 0x8db
-#define XK_intersection 0x8dc
-#define XK_union 0x8dd
-#define XK_logicaland 0x8de
-#define XK_logicalor 0x8df
-#define XK_partialderivative 0x8ef
-#define XK_function 0x8f6
-#define XK_leftarrow 0x8fb
-#define XK_uparrow 0x8fc
-#define XK_rightarrow 0x8fd
-#define XK_downarrow 0x8fe
+#define XK_leftradical 0x08a1 /* U+23B7 RADICAL SYMBOL BOTTOM */
+#define XK_topleftradical 0x08a2 /*(U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT)*/
+#define XK_horizconnector 0x08a3 /*(U+2500 BOX DRAWINGS LIGHT HORIZONTAL)*/
+#define XK_topintegral 0x08a4 /* U+2320 TOP HALF INTEGRAL */
+#define XK_botintegral 0x08a5 /* U+2321 BOTTOM HALF INTEGRAL */
+#define XK_vertconnector 0x08a6 /*(U+2502 BOX DRAWINGS LIGHT VERTICAL)*/
+#define XK_topleftsqbracket 0x08a7 /* U+23A1 LEFT SQUARE BRACKET UPPER CORNER */
+#define XK_botleftsqbracket 0x08a8 /* U+23A3 LEFT SQUARE BRACKET LOWER CORNER */
+#define XK_toprightsqbracket 0x08a9 /* U+23A4 RIGHT SQUARE BRACKET UPPER CORNER */
+#define XK_botrightsqbracket 0x08aa /* U+23A6 RIGHT SQUARE BRACKET LOWER CORNER */
+#define XK_topleftparens 0x08ab /* U+239B LEFT PARENTHESIS UPPER HOOK */
+#define XK_botleftparens 0x08ac /* U+239D LEFT PARENTHESIS LOWER HOOK */
+#define XK_toprightparens 0x08ad /* U+239E RIGHT PARENTHESIS UPPER HOOK */
+#define XK_botrightparens 0x08ae /* U+23A0 RIGHT PARENTHESIS LOWER HOOK */
+#define XK_leftmiddlecurlybrace 0x08af /* U+23A8 LEFT CURLY BRACKET MIDDLE PIECE */
+#define XK_rightmiddlecurlybrace 0x08b0 /* U+23AC RIGHT CURLY BRACKET MIDDLE PIECE */
+#define XK_topleftsummation 0x08b1
+#define XK_botleftsummation 0x08b2
+#define XK_topvertsummationconnector 0x08b3
+#define XK_botvertsummationconnector 0x08b4
+#define XK_toprightsummation 0x08b5
+#define XK_botrightsummation 0x08b6
+#define XK_rightmiddlesummation 0x08b7
+#define XK_lessthanequal 0x08bc /* U+2264 LESS-THAN OR EQUAL TO */
+#define XK_notequal 0x08bd /* U+2260 NOT EQUAL TO */
+#define XK_greaterthanequal 0x08be /* U+2265 GREATER-THAN OR EQUAL TO */
+#define XK_integral 0x08bf /* U+222B INTEGRAL */
+#define XK_therefore 0x08c0 /* U+2234 THEREFORE */
+#define XK_variation 0x08c1 /* U+221D PROPORTIONAL TO */
+#define XK_infinity 0x08c2 /* U+221E INFINITY */
+#define XK_nabla 0x08c5 /* U+2207 NABLA */
+#define XK_approximate 0x08c8 /* U+223C TILDE OPERATOR */
+#define XK_similarequal 0x08c9 /* U+2243 ASYMPTOTICALLY EQUAL TO */
+#define XK_ifonlyif 0x08cd /* U+21D4 LEFT RIGHT DOUBLE ARROW */
+#define XK_implies 0x08ce /* U+21D2 RIGHTWARDS DOUBLE ARROW */
+#define XK_identical 0x08cf /* U+2261 IDENTICAL TO */
+#define XK_radical 0x08d6 /* U+221A SQUARE ROOT */
+#define XK_includedin 0x08da /* U+2282 SUBSET OF */
+#define XK_includes 0x08db /* U+2283 SUPERSET OF */
+#define XK_intersection 0x08dc /* U+2229 INTERSECTION */
+#define XK_union 0x08dd /* U+222A UNION */
+#define XK_logicaland 0x08de /* U+2227 LOGICAL AND */
+#define XK_logicalor 0x08df /* U+2228 LOGICAL OR */
+#define XK_partialderivative 0x08ef /* U+2202 PARTIAL DIFFERENTIAL */
+#define XK_function 0x08f6 /* U+0192 LATIN SMALL LETTER F WITH HOOK */
+#define XK_leftarrow 0x08fb /* U+2190 LEFTWARDS ARROW */
+#define XK_uparrow 0x08fc /* U+2191 UPWARDS ARROW */
+#define XK_rightarrow 0x08fd /* U+2192 RIGHTWARDS ARROW */
+#define XK_downarrow 0x08fe /* U+2193 DOWNWARDS ARROW */
#endif /* XK_TECHNICAL */
/*
- * Special
- * Byte 3 = 9
+ * Special
+ * (from the DEC VT100 Special Graphics Character Set)
+ * Byte 3 = 9
*/
#ifdef XK_SPECIAL
-#define XK_blank 0x9df
-#define XK_soliddiamond 0x9e0
-#define XK_checkerboard 0x9e1
-#define XK_ht 0x9e2
-#define XK_ff 0x9e3
-#define XK_cr 0x9e4
-#define XK_lf 0x9e5
-#define XK_nl 0x9e8
-#define XK_vt 0x9e9
-#define XK_lowrightcorner 0x9ea
-#define XK_uprightcorner 0x9eb
-#define XK_upleftcorner 0x9ec
-#define XK_lowleftcorner 0x9ed
-#define XK_crossinglines 0x9ee
-#define XK_horizlinescan1 0x9ef
-#define XK_horizlinescan3 0x9f0
-#define XK_horizlinescan5 0x9f1
-#define XK_horizlinescan7 0x9f2
-#define XK_horizlinescan9 0x9f3
-#define XK_leftt 0x9f4
-#define XK_rightt 0x9f5
-#define XK_bott 0x9f6
-#define XK_topt 0x9f7
-#define XK_vertbar 0x9f8
+#define XK_blank 0x09df
+#define XK_soliddiamond 0x09e0 /* U+25C6 BLACK DIAMOND */
+#define XK_checkerboard 0x09e1 /* U+2592 MEDIUM SHADE */
+#define XK_ht 0x09e2 /* U+2409 SYMBOL FOR HORIZONTAL TABULATION */
+#define XK_ff 0x09e3 /* U+240C SYMBOL FOR FORM FEED */
+#define XK_cr 0x09e4 /* U+240D SYMBOL FOR CARRIAGE RETURN */
+#define XK_lf 0x09e5 /* U+240A SYMBOL FOR LINE FEED */
+#define XK_nl 0x09e8 /* U+2424 SYMBOL FOR NEWLINE */
+#define XK_vt 0x09e9 /* U+240B SYMBOL FOR VERTICAL TABULATION */
+#define XK_lowrightcorner 0x09ea /* U+2518 BOX DRAWINGS LIGHT UP AND LEFT */
+#define XK_uprightcorner 0x09eb /* U+2510 BOX DRAWINGS LIGHT DOWN AND LEFT */
+#define XK_upleftcorner 0x09ec /* U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT */
+#define XK_lowleftcorner 0x09ed /* U+2514 BOX DRAWINGS LIGHT UP AND RIGHT */
+#define XK_crossinglines 0x09ee /* U+253C BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */
+#define XK_horizlinescan1 0x09ef /* U+23BA HORIZONTAL SCAN LINE-1 */
+#define XK_horizlinescan3 0x09f0 /* U+23BB HORIZONTAL SCAN LINE-3 */
+#define XK_horizlinescan5 0x09f1 /* U+2500 BOX DRAWINGS LIGHT HORIZONTAL */
+#define XK_horizlinescan7 0x09f2 /* U+23BC HORIZONTAL SCAN LINE-7 */
+#define XK_horizlinescan9 0x09f3 /* U+23BD HORIZONTAL SCAN LINE-9 */
+#define XK_leftt 0x09f4 /* U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT */
+#define XK_rightt 0x09f5 /* U+2524 BOX DRAWINGS LIGHT VERTICAL AND LEFT */
+#define XK_bott 0x09f6 /* U+2534 BOX DRAWINGS LIGHT UP AND HORIZONTAL */
+#define XK_topt 0x09f7 /* U+252C BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */
+#define XK_vertbar 0x09f8 /* U+2502 BOX DRAWINGS LIGHT VERTICAL */
#endif /* XK_SPECIAL */
/*
- * Publishing
- * Byte 3 = a
+ * Publishing
+ * (these are probably from a long forgotten DEC Publishing
+ * font that once shipped with DECwrite)
+ * Byte 3 = 0x0a
*/
#ifdef XK_PUBLISHING
-#define XK_emspace 0xaa1
-#define XK_enspace 0xaa2
-#define XK_em3space 0xaa3
-#define XK_em4space 0xaa4
-#define XK_digitspace 0xaa5
-#define XK_punctspace 0xaa6
-#define XK_thinspace 0xaa7
-#define XK_hairspace 0xaa8
-#define XK_emdash 0xaa9
-#define XK_endash 0xaaa
-#define XK_signifblank 0xaac
-#define XK_ellipsis 0xaae
-#define XK_doubbaselinedot 0xaaf
-#define XK_onethird 0xab0
-#define XK_twothirds 0xab1
-#define XK_onefifth 0xab2
-#define XK_twofifths 0xab3
-#define XK_threefifths 0xab4
-#define XK_fourfifths 0xab5
-#define XK_onesixth 0xab6
-#define XK_fivesixths 0xab7
-#define XK_careof 0xab8
-#define XK_figdash 0xabb
-#define XK_leftanglebracket 0xabc
-#define XK_decimalpoint 0xabd
-#define XK_rightanglebracket 0xabe
-#define XK_marker 0xabf
-#define XK_oneeighth 0xac3
-#define XK_threeeighths 0xac4
-#define XK_fiveeighths 0xac5
-#define XK_seveneighths 0xac6
-#define XK_trademark 0xac9
-#define XK_signaturemark 0xaca
-#define XK_trademarkincircle 0xacb
-#define XK_leftopentriangle 0xacc
-#define XK_rightopentriangle 0xacd
-#define XK_emopencircle 0xace
-#define XK_emopenrectangle 0xacf
-#define XK_leftsinglequotemark 0xad0
-#define XK_rightsinglequotemark 0xad1
-#define XK_leftdoublequotemark 0xad2
-#define XK_rightdoublequotemark 0xad3
-#define XK_prescription 0xad4
-#define XK_minutes 0xad6
-#define XK_seconds 0xad7
-#define XK_latincross 0xad9
-#define XK_hexagram 0xada
-#define XK_filledrectbullet 0xadb
-#define XK_filledlefttribullet 0xadc
-#define XK_filledrighttribullet 0xadd
-#define XK_emfilledcircle 0xade
-#define XK_emfilledrect 0xadf
-#define XK_enopencircbullet 0xae0
-#define XK_enopensquarebullet 0xae1
-#define XK_openrectbullet 0xae2
-#define XK_opentribulletup 0xae3
-#define XK_opentribulletdown 0xae4
-#define XK_openstar 0xae5
-#define XK_enfilledcircbullet 0xae6
-#define XK_enfilledsqbullet 0xae7
-#define XK_filledtribulletup 0xae8
-#define XK_filledtribulletdown 0xae9
-#define XK_leftpointer 0xaea
-#define XK_rightpointer 0xaeb
-#define XK_club 0xaec
-#define XK_diamond 0xaed
-#define XK_heart 0xaee
-#define XK_maltesecross 0xaf0
-#define XK_dagger 0xaf1
-#define XK_doubledagger 0xaf2
-#define XK_checkmark 0xaf3
-#define XK_ballotcross 0xaf4
-#define XK_musicalsharp 0xaf5
-#define XK_musicalflat 0xaf6
-#define XK_malesymbol 0xaf7
-#define XK_femalesymbol 0xaf8
-#define XK_telephone 0xaf9
-#define XK_telephonerecorder 0xafa
-#define XK_phonographcopyright 0xafb
-#define XK_caret 0xafc
-#define XK_singlelowquotemark 0xafd
-#define XK_doublelowquotemark 0xafe
-#define XK_cursor 0xaff
+#define XK_emspace 0x0aa1 /* U+2003 EM SPACE */
+#define XK_enspace 0x0aa2 /* U+2002 EN SPACE */
+#define XK_em3space 0x0aa3 /* U+2004 THREE-PER-EM SPACE */
+#define XK_em4space 0x0aa4 /* U+2005 FOUR-PER-EM SPACE */
+#define XK_digitspace 0x0aa5 /* U+2007 FIGURE SPACE */
+#define XK_punctspace 0x0aa6 /* U+2008 PUNCTUATION SPACE */
+#define XK_thinspace 0x0aa7 /* U+2009 THIN SPACE */
+#define XK_hairspace 0x0aa8 /* U+200A HAIR SPACE */
+#define XK_emdash 0x0aa9 /* U+2014 EM DASH */
+#define XK_endash 0x0aaa /* U+2013 EN DASH */
+#define XK_signifblank 0x0aac /*(U+2423 OPEN BOX)*/
+#define XK_ellipsis 0x0aae /* U+2026 HORIZONTAL ELLIPSIS */
+#define XK_doubbaselinedot 0x0aaf /* U+2025 TWO DOT LEADER */
+#define XK_onethird 0x0ab0 /* U+2153 VULGAR FRACTION ONE THIRD */
+#define XK_twothirds 0x0ab1 /* U+2154 VULGAR FRACTION TWO THIRDS */
+#define XK_onefifth 0x0ab2 /* U+2155 VULGAR FRACTION ONE FIFTH */
+#define XK_twofifths 0x0ab3 /* U+2156 VULGAR FRACTION TWO FIFTHS */
+#define XK_threefifths 0x0ab4 /* U+2157 VULGAR FRACTION THREE FIFTHS */
+#define XK_fourfifths 0x0ab5 /* U+2158 VULGAR FRACTION FOUR FIFTHS */
+#define XK_onesixth 0x0ab6 /* U+2159 VULGAR FRACTION ONE SIXTH */
+#define XK_fivesixths 0x0ab7 /* U+215A VULGAR FRACTION FIVE SIXTHS */
+#define XK_careof 0x0ab8 /* U+2105 CARE OF */
+#define XK_figdash 0x0abb /* U+2012 FIGURE DASH */
+#define XK_leftanglebracket 0x0abc /*(U+27E8 MATHEMATICAL LEFT ANGLE BRACKET)*/
+#define XK_decimalpoint 0x0abd /*(U+002E FULL STOP)*/
+#define XK_rightanglebracket 0x0abe /*(U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET)*/
+#define XK_marker 0x0abf
+#define XK_oneeighth 0x0ac3 /* U+215B VULGAR FRACTION ONE EIGHTH */
+#define XK_threeeighths 0x0ac4 /* U+215C VULGAR FRACTION THREE EIGHTHS */
+#define XK_fiveeighths 0x0ac5 /* U+215D VULGAR FRACTION FIVE EIGHTHS */
+#define XK_seveneighths 0x0ac6 /* U+215E VULGAR FRACTION SEVEN EIGHTHS */
+#define XK_trademark 0x0ac9 /* U+2122 TRADE MARK SIGN */
+#define XK_signaturemark 0x0aca /*(U+2613 SALTIRE)*/
+#define XK_trademarkincircle 0x0acb
+#define XK_leftopentriangle 0x0acc /*(U+25C1 WHITE LEFT-POINTING TRIANGLE)*/
+#define XK_rightopentriangle 0x0acd /*(U+25B7 WHITE RIGHT-POINTING TRIANGLE)*/
+#define XK_emopencircle 0x0ace /*(U+25CB WHITE CIRCLE)*/
+#define XK_emopenrectangle 0x0acf /*(U+25AF WHITE VERTICAL RECTANGLE)*/
+#define XK_leftsinglequotemark 0x0ad0 /* U+2018 LEFT SINGLE QUOTATION MARK */
+#define XK_rightsinglequotemark 0x0ad1 /* U+2019 RIGHT SINGLE QUOTATION MARK */
+#define XK_leftdoublequotemark 0x0ad2 /* U+201C LEFT DOUBLE QUOTATION MARK */
+#define XK_rightdoublequotemark 0x0ad3 /* U+201D RIGHT DOUBLE QUOTATION MARK */
+#define XK_prescription 0x0ad4 /* U+211E PRESCRIPTION TAKE */
+#define XK_permille 0x0ad5 /* U+2030 PER MILLE SIGN */
+#define XK_minutes 0x0ad6 /* U+2032 PRIME */
+#define XK_seconds 0x0ad7 /* U+2033 DOUBLE PRIME */
+#define XK_latincross 0x0ad9 /* U+271D LATIN CROSS */
+#define XK_hexagram 0x0ada
+#define XK_filledrectbullet 0x0adb /*(U+25AC BLACK RECTANGLE)*/
+#define XK_filledlefttribullet 0x0adc /*(U+25C0 BLACK LEFT-POINTING TRIANGLE)*/
+#define XK_filledrighttribullet 0x0add /*(U+25B6 BLACK RIGHT-POINTING TRIANGLE)*/
+#define XK_emfilledcircle 0x0ade /*(U+25CF BLACK CIRCLE)*/
+#define XK_emfilledrect 0x0adf /*(U+25AE BLACK VERTICAL RECTANGLE)*/
+#define XK_enopencircbullet 0x0ae0 /*(U+25E6 WHITE BULLET)*/
+#define XK_enopensquarebullet 0x0ae1 /*(U+25AB WHITE SMALL SQUARE)*/
+#define XK_openrectbullet 0x0ae2 /*(U+25AD WHITE RECTANGLE)*/
+#define XK_opentribulletup 0x0ae3 /*(U+25B3 WHITE UP-POINTING TRIANGLE)*/
+#define XK_opentribulletdown 0x0ae4 /*(U+25BD WHITE DOWN-POINTING TRIANGLE)*/
+#define XK_openstar 0x0ae5 /*(U+2606 WHITE STAR)*/
+#define XK_enfilledcircbullet 0x0ae6 /*(U+2022 BULLET)*/
+#define XK_enfilledsqbullet 0x0ae7 /*(U+25AA BLACK SMALL SQUARE)*/
+#define XK_filledtribulletup 0x0ae8 /*(U+25B2 BLACK UP-POINTING TRIANGLE)*/
+#define XK_filledtribulletdown 0x0ae9 /*(U+25BC BLACK DOWN-POINTING TRIANGLE)*/
+#define XK_leftpointer 0x0aea /*(U+261C WHITE LEFT POINTING INDEX)*/
+#define XK_rightpointer 0x0aeb /*(U+261E WHITE RIGHT POINTING INDEX)*/
+#define XK_club 0x0aec /* U+2663 BLACK CLUB SUIT */
+#define XK_diamond 0x0aed /* U+2666 BLACK DIAMOND SUIT */
+#define XK_heart 0x0aee /* U+2665 BLACK HEART SUIT */
+#define XK_maltesecross 0x0af0 /* U+2720 MALTESE CROSS */
+#define XK_dagger 0x0af1 /* U+2020 DAGGER */
+#define XK_doubledagger 0x0af2 /* U+2021 DOUBLE DAGGER */
+#define XK_checkmark 0x0af3 /* U+2713 CHECK MARK */
+#define XK_ballotcross 0x0af4 /* U+2717 BALLOT X */
+#define XK_musicalsharp 0x0af5 /* U+266F MUSIC SHARP SIGN */
+#define XK_musicalflat 0x0af6 /* U+266D MUSIC FLAT SIGN */
+#define XK_malesymbol 0x0af7 /* U+2642 MALE SIGN */
+#define XK_femalesymbol 0x0af8 /* U+2640 FEMALE SIGN */
+#define XK_telephone 0x0af9 /* U+260E BLACK TELEPHONE */
+#define XK_telephonerecorder 0x0afa /* U+2315 TELEPHONE RECORDER */
+#define XK_phonographcopyright 0x0afb /* U+2117 SOUND RECORDING COPYRIGHT */
+#define XK_caret 0x0afc /* U+2038 CARET */
+#define XK_singlelowquotemark 0x0afd /* U+201A SINGLE LOW-9 QUOTATION MARK */
+#define XK_doublelowquotemark 0x0afe /* U+201E DOUBLE LOW-9 QUOTATION MARK */
+#define XK_cursor 0x0aff
#endif /* XK_PUBLISHING */
/*
- * APL
- * Byte 3 = b
+ * APL
+ * Byte 3 = 0x0b
*/
#ifdef XK_APL
-#define XK_leftcaret 0xba3
-#define XK_rightcaret 0xba6
-#define XK_downcaret 0xba8
-#define XK_upcaret 0xba9
-#define XK_overbar 0xbc0
-#define XK_downtack 0xbc2
-#define XK_upshoe 0xbc3
-#define XK_downstile 0xbc4
-#define XK_underbar 0xbc6
-#define XK_jot 0xbca
-#define XK_quad 0xbcc
-#define XK_uptack 0xbce
-#define XK_circle 0xbcf
-#define XK_upstile 0xbd3
-#define XK_downshoe 0xbd6
-#define XK_rightshoe 0xbd8
-#define XK_leftshoe 0xbda
-#define XK_lefttack 0xbdc
-#define XK_righttack 0xbfc
+#define XK_leftcaret 0x0ba3 /*(U+003C LESS-THAN SIGN)*/
+#define XK_rightcaret 0x0ba6 /*(U+003E GREATER-THAN SIGN)*/
+#define XK_downcaret 0x0ba8 /*(U+2228 LOGICAL OR)*/
+#define XK_upcaret 0x0ba9 /*(U+2227 LOGICAL AND)*/
+#define XK_overbar 0x0bc0 /*(U+00AF MACRON)*/
+#define XK_downtack 0x0bc2 /* U+22A4 DOWN TACK */
+#define XK_upshoe 0x0bc3 /*(U+2229 INTERSECTION)*/
+#define XK_downstile 0x0bc4 /* U+230A LEFT FLOOR */
+#define XK_underbar 0x0bc6 /*(U+005F LOW LINE)*/
+#define XK_jot 0x0bca /* U+2218 RING OPERATOR */
+#define XK_quad 0x0bcc /* U+2395 APL FUNCTIONAL SYMBOL QUAD */
+#define XK_uptack 0x0bce /* U+22A5 UP TACK */
+#define XK_circle 0x0bcf /* U+25CB WHITE CIRCLE */
+#define XK_upstile 0x0bd3 /* U+2308 LEFT CEILING */
+#define XK_downshoe 0x0bd6 /*(U+222A UNION)*/
+#define XK_rightshoe 0x0bd8 /*(U+2283 SUPERSET OF)*/
+#define XK_leftshoe 0x0bda /*(U+2282 SUBSET OF)*/
+#define XK_lefttack 0x0bdc /* U+22A3 LEFT TACK */
+#define XK_righttack 0x0bfc /* U+22A2 RIGHT TACK */
#endif /* XK_APL */
/*
* Hebrew
- * Byte 3 = c
+ * Byte 3 = 0x0c
*/
#ifdef XK_HEBREW
-#define XK_hebrew_doublelowline 0xcdf
-#define XK_hebrew_aleph 0xce0
-#define XK_hebrew_bet 0xce1
-#define XK_hebrew_beth 0xce1 /* deprecated */
-#define XK_hebrew_gimel 0xce2
-#define XK_hebrew_gimmel 0xce2 /* deprecated */
-#define XK_hebrew_dalet 0xce3
-#define XK_hebrew_daleth 0xce3 /* deprecated */
-#define XK_hebrew_he 0xce4
-#define XK_hebrew_waw 0xce5
-#define XK_hebrew_zain 0xce6
-#define XK_hebrew_zayin 0xce6 /* deprecated */
-#define XK_hebrew_chet 0xce7
-#define XK_hebrew_het 0xce7 /* deprecated */
-#define XK_hebrew_tet 0xce8
-#define XK_hebrew_teth 0xce8 /* deprecated */
-#define XK_hebrew_yod 0xce9
-#define XK_hebrew_finalkaph 0xcea
-#define XK_hebrew_kaph 0xceb
-#define XK_hebrew_lamed 0xcec
-#define XK_hebrew_finalmem 0xced
-#define XK_hebrew_mem 0xcee
-#define XK_hebrew_finalnun 0xcef
-#define XK_hebrew_nun 0xcf0
-#define XK_hebrew_samech 0xcf1
-#define XK_hebrew_samekh 0xcf1 /* deprecated */
-#define XK_hebrew_ayin 0xcf2
-#define XK_hebrew_finalpe 0xcf3
-#define XK_hebrew_pe 0xcf4
-#define XK_hebrew_finalzade 0xcf5
-#define XK_hebrew_finalzadi 0xcf5 /* deprecated */
-#define XK_hebrew_zade 0xcf6
-#define XK_hebrew_zadi 0xcf6 /* deprecated */
-#define XK_hebrew_qoph 0xcf7
-#define XK_hebrew_kuf 0xcf7 /* deprecated */
-#define XK_hebrew_resh 0xcf8
-#define XK_hebrew_shin 0xcf9
-#define XK_hebrew_taw 0xcfa
-#define XK_hebrew_taf 0xcfa /* deprecated */
-#define XK_Hebrew_switch 0xFF7E /* Alias for mode_switch */
+#define XK_hebrew_doublelowline 0x0cdf /* U+2017 DOUBLE LOW LINE */
+#define XK_hebrew_aleph 0x0ce0 /* U+05D0 HEBREW LETTER ALEF */
+#define XK_hebrew_bet 0x0ce1 /* U+05D1 HEBREW LETTER BET */
+#define XK_hebrew_beth 0x0ce1 /* deprecated */
+#define XK_hebrew_gimel 0x0ce2 /* U+05D2 HEBREW LETTER GIMEL */
+#define XK_hebrew_gimmel 0x0ce2 /* deprecated */
+#define XK_hebrew_dalet 0x0ce3 /* U+05D3 HEBREW LETTER DALET */
+#define XK_hebrew_daleth 0x0ce3 /* deprecated */
+#define XK_hebrew_he 0x0ce4 /* U+05D4 HEBREW LETTER HE */
+#define XK_hebrew_waw 0x0ce5 /* U+05D5 HEBREW LETTER VAV */
+#define XK_hebrew_zain 0x0ce6 /* U+05D6 HEBREW LETTER ZAYIN */
+#define XK_hebrew_zayin 0x0ce6 /* deprecated */
+#define XK_hebrew_chet 0x0ce7 /* U+05D7 HEBREW LETTER HET */
+#define XK_hebrew_het 0x0ce7 /* deprecated */
+#define XK_hebrew_tet 0x0ce8 /* U+05D8 HEBREW LETTER TET */
+#define XK_hebrew_teth 0x0ce8 /* deprecated */
+#define XK_hebrew_yod 0x0ce9 /* U+05D9 HEBREW LETTER YOD */
+#define XK_hebrew_finalkaph 0x0cea /* U+05DA HEBREW LETTER FINAL KAF */
+#define XK_hebrew_kaph 0x0ceb /* U+05DB HEBREW LETTER KAF */
+#define XK_hebrew_lamed 0x0cec /* U+05DC HEBREW LETTER LAMED */
+#define XK_hebrew_finalmem 0x0ced /* U+05DD HEBREW LETTER FINAL MEM */
+#define XK_hebrew_mem 0x0cee /* U+05DE HEBREW LETTER MEM */
+#define XK_hebrew_finalnun 0x0cef /* U+05DF HEBREW LETTER FINAL NUN */
+#define XK_hebrew_nun 0x0cf0 /* U+05E0 HEBREW LETTER NUN */
+#define XK_hebrew_samech 0x0cf1 /* U+05E1 HEBREW LETTER SAMEKH */
+#define XK_hebrew_samekh 0x0cf1 /* deprecated */
+#define XK_hebrew_ayin 0x0cf2 /* U+05E2 HEBREW LETTER AYIN */
+#define XK_hebrew_finalpe 0x0cf3 /* U+05E3 HEBREW LETTER FINAL PE */
+#define XK_hebrew_pe 0x0cf4 /* U+05E4 HEBREW LETTER PE */
+#define XK_hebrew_finalzade 0x0cf5 /* U+05E5 HEBREW LETTER FINAL TSADI */
+#define XK_hebrew_finalzadi 0x0cf5 /* deprecated */
+#define XK_hebrew_zade 0x0cf6 /* U+05E6 HEBREW LETTER TSADI */
+#define XK_hebrew_zadi 0x0cf6 /* deprecated */
+#define XK_hebrew_qoph 0x0cf7 /* U+05E7 HEBREW LETTER QOF */
+#define XK_hebrew_kuf 0x0cf7 /* deprecated */
+#define XK_hebrew_resh 0x0cf8 /* U+05E8 HEBREW LETTER RESH */
+#define XK_hebrew_shin 0x0cf9 /* U+05E9 HEBREW LETTER SHIN */
+#define XK_hebrew_taw 0x0cfa /* U+05EA HEBREW LETTER TAV */
+#define XK_hebrew_taf 0x0cfa /* deprecated */
+#define XK_Hebrew_switch 0xff7e /* Alias for mode_switch */
#endif /* XK_HEBREW */
+/*
+ * Thai
+ * Byte 3 = 0x0d
+ */
+
+#ifdef XK_THAI
+#define XK_Thai_kokai 0x0da1 /* U+0E01 THAI CHARACTER KO KAI */
+#define XK_Thai_khokhai 0x0da2 /* U+0E02 THAI CHARACTER KHO KHAI */
+#define XK_Thai_khokhuat 0x0da3 /* U+0E03 THAI CHARACTER KHO KHUAT */
+#define XK_Thai_khokhwai 0x0da4 /* U+0E04 THAI CHARACTER KHO KHWAI */
+#define XK_Thai_khokhon 0x0da5 /* U+0E05 THAI CHARACTER KHO KHON */
+#define XK_Thai_khorakhang 0x0da6 /* U+0E06 THAI CHARACTER KHO RAKHANG */
+#define XK_Thai_ngongu 0x0da7 /* U+0E07 THAI CHARACTER NGO NGU */
+#define XK_Thai_chochan 0x0da8 /* U+0E08 THAI CHARACTER CHO CHAN */
+#define XK_Thai_choching 0x0da9 /* U+0E09 THAI CHARACTER CHO CHING */
+#define XK_Thai_chochang 0x0daa /* U+0E0A THAI CHARACTER CHO CHANG */
+#define XK_Thai_soso 0x0dab /* U+0E0B THAI CHARACTER SO SO */
+#define XK_Thai_chochoe 0x0dac /* U+0E0C THAI CHARACTER CHO CHOE */
+#define XK_Thai_yoying 0x0dad /* U+0E0D THAI CHARACTER YO YING */
+#define XK_Thai_dochada 0x0dae /* U+0E0E THAI CHARACTER DO CHADA */
+#define XK_Thai_topatak 0x0daf /* U+0E0F THAI CHARACTER TO PATAK */
+#define XK_Thai_thothan 0x0db0 /* U+0E10 THAI CHARACTER THO THAN */
+#define XK_Thai_thonangmontho 0x0db1 /* U+0E11 THAI CHARACTER THO NANGMONTHO */
+#define XK_Thai_thophuthao 0x0db2 /* U+0E12 THAI CHARACTER THO PHUTHAO */
+#define XK_Thai_nonen 0x0db3 /* U+0E13 THAI CHARACTER NO NEN */
+#define XK_Thai_dodek 0x0db4 /* U+0E14 THAI CHARACTER DO DEK */
+#define XK_Thai_totao 0x0db5 /* U+0E15 THAI CHARACTER TO TAO */
+#define XK_Thai_thothung 0x0db6 /* U+0E16 THAI CHARACTER THO THUNG */
+#define XK_Thai_thothahan 0x0db7 /* U+0E17 THAI CHARACTER THO THAHAN */
+#define XK_Thai_thothong 0x0db8 /* U+0E18 THAI CHARACTER THO THONG */
+#define XK_Thai_nonu 0x0db9 /* U+0E19 THAI CHARACTER NO NU */
+#define XK_Thai_bobaimai 0x0dba /* U+0E1A THAI CHARACTER BO BAIMAI */
+#define XK_Thai_popla 0x0dbb /* U+0E1B THAI CHARACTER PO PLA */
+#define XK_Thai_phophung 0x0dbc /* U+0E1C THAI CHARACTER PHO PHUNG */
+#define XK_Thai_fofa 0x0dbd /* U+0E1D THAI CHARACTER FO FA */
+#define XK_Thai_phophan 0x0dbe /* U+0E1E THAI CHARACTER PHO PHAN */
+#define XK_Thai_fofan 0x0dbf /* U+0E1F THAI CHARACTER FO FAN */
+#define XK_Thai_phosamphao 0x0dc0 /* U+0E20 THAI CHARACTER PHO SAMPHAO */
+#define XK_Thai_moma 0x0dc1 /* U+0E21 THAI CHARACTER MO MA */
+#define XK_Thai_yoyak 0x0dc2 /* U+0E22 THAI CHARACTER YO YAK */
+#define XK_Thai_rorua 0x0dc3 /* U+0E23 THAI CHARACTER RO RUA */
+#define XK_Thai_ru 0x0dc4 /* U+0E24 THAI CHARACTER RU */
+#define XK_Thai_loling 0x0dc5 /* U+0E25 THAI CHARACTER LO LING */
+#define XK_Thai_lu 0x0dc6 /* U+0E26 THAI CHARACTER LU */
+#define XK_Thai_wowaen 0x0dc7 /* U+0E27 THAI CHARACTER WO WAEN */
+#define XK_Thai_sosala 0x0dc8 /* U+0E28 THAI CHARACTER SO SALA */
+#define XK_Thai_sorusi 0x0dc9 /* U+0E29 THAI CHARACTER SO RUSI */
+#define XK_Thai_sosua 0x0dca /* U+0E2A THAI CHARACTER SO SUA */
+#define XK_Thai_hohip 0x0dcb /* U+0E2B THAI CHARACTER HO HIP */
+#define XK_Thai_lochula 0x0dcc /* U+0E2C THAI CHARACTER LO CHULA */
+#define XK_Thai_oang 0x0dcd /* U+0E2D THAI CHARACTER O ANG */
+#define XK_Thai_honokhuk 0x0dce /* U+0E2E THAI CHARACTER HO NOKHUK */
+#define XK_Thai_paiyannoi 0x0dcf /* U+0E2F THAI CHARACTER PAIYANNOI */
+#define XK_Thai_saraa 0x0dd0 /* U+0E30 THAI CHARACTER SARA A */
+#define XK_Thai_maihanakat 0x0dd1 /* U+0E31 THAI CHARACTER MAI HAN-AKAT */
+#define XK_Thai_saraaa 0x0dd2 /* U+0E32 THAI CHARACTER SARA AA */
+#define XK_Thai_saraam 0x0dd3 /* U+0E33 THAI CHARACTER SARA AM */
+#define XK_Thai_sarai 0x0dd4 /* U+0E34 THAI CHARACTER SARA I */
+#define XK_Thai_saraii 0x0dd5 /* U+0E35 THAI CHARACTER SARA II */
+#define XK_Thai_saraue 0x0dd6 /* U+0E36 THAI CHARACTER SARA UE */
+#define XK_Thai_sarauee 0x0dd7 /* U+0E37 THAI CHARACTER SARA UEE */
+#define XK_Thai_sarau 0x0dd8 /* U+0E38 THAI CHARACTER SARA U */
+#define XK_Thai_sarauu 0x0dd9 /* U+0E39 THAI CHARACTER SARA UU */
+#define XK_Thai_phinthu 0x0dda /* U+0E3A THAI CHARACTER PHINTHU */
+#define XK_Thai_maihanakat_maitho 0x0dde
+#define XK_Thai_baht 0x0ddf /* U+0E3F THAI CURRENCY SYMBOL BAHT */
+#define XK_Thai_sarae 0x0de0 /* U+0E40 THAI CHARACTER SARA E */
+#define XK_Thai_saraae 0x0de1 /* U+0E41 THAI CHARACTER SARA AE */
+#define XK_Thai_sarao 0x0de2 /* U+0E42 THAI CHARACTER SARA O */
+#define XK_Thai_saraaimaimuan 0x0de3 /* U+0E43 THAI CHARACTER SARA AI MAIMUAN */
+#define XK_Thai_saraaimaimalai 0x0de4 /* U+0E44 THAI CHARACTER SARA AI MAIMALAI */
+#define XK_Thai_lakkhangyao 0x0de5 /* U+0E45 THAI CHARACTER LAKKHANGYAO */
+#define XK_Thai_maiyamok 0x0de6 /* U+0E46 THAI CHARACTER MAIYAMOK */
+#define XK_Thai_maitaikhu 0x0de7 /* U+0E47 THAI CHARACTER MAITAIKHU */
+#define XK_Thai_maiek 0x0de8 /* U+0E48 THAI CHARACTER MAI EK */
+#define XK_Thai_maitho 0x0de9 /* U+0E49 THAI CHARACTER MAI THO */
+#define XK_Thai_maitri 0x0dea /* U+0E4A THAI CHARACTER MAI TRI */
+#define XK_Thai_maichattawa 0x0deb /* U+0E4B THAI CHARACTER MAI CHATTAWA */
+#define XK_Thai_thanthakhat 0x0dec /* U+0E4C THAI CHARACTER THANTHAKHAT */
+#define XK_Thai_nikhahit 0x0ded /* U+0E4D THAI CHARACTER NIKHAHIT */
+#define XK_Thai_leksun 0x0df0 /* U+0E50 THAI DIGIT ZERO */
+#define XK_Thai_leknung 0x0df1 /* U+0E51 THAI DIGIT ONE */
+#define XK_Thai_leksong 0x0df2 /* U+0E52 THAI DIGIT TWO */
+#define XK_Thai_leksam 0x0df3 /* U+0E53 THAI DIGIT THREE */
+#define XK_Thai_leksi 0x0df4 /* U+0E54 THAI DIGIT FOUR */
+#define XK_Thai_lekha 0x0df5 /* U+0E55 THAI DIGIT FIVE */
+#define XK_Thai_lekhok 0x0df6 /* U+0E56 THAI DIGIT SIX */
+#define XK_Thai_lekchet 0x0df7 /* U+0E57 THAI DIGIT SEVEN */
+#define XK_Thai_lekpaet 0x0df8 /* U+0E58 THAI DIGIT EIGHT */
+#define XK_Thai_lekkao 0x0df9 /* U+0E59 THAI DIGIT NINE */
+#endif /* XK_THAI */
+
+/*
+ * Korean
+ * Byte 3 = 0x0e
+ */
+
+#ifdef XK_KOREAN
+
+#define XK_Hangul 0xff31 /* Hangul start/stop(toggle) */
+#define XK_Hangul_Start 0xff32 /* Hangul start */
+#define XK_Hangul_End 0xff33 /* Hangul end, English start */
+#define XK_Hangul_Hanja 0xff34 /* Start Hangul->Hanja Conversion */
+#define XK_Hangul_Jamo 0xff35 /* Hangul Jamo mode */
+#define XK_Hangul_Romaja 0xff36 /* Hangul Romaja mode */
+#define XK_Hangul_Codeinput 0xff37 /* Hangul code input mode */
+#define XK_Hangul_Jeonja 0xff38 /* Jeonja mode */
+#define XK_Hangul_Banja 0xff39 /* Banja mode */
+#define XK_Hangul_PreHanja 0xff3a /* Pre Hanja conversion */
+#define XK_Hangul_PostHanja 0xff3b /* Post Hanja conversion */
+#define XK_Hangul_SingleCandidate 0xff3c /* Single candidate */
+#define XK_Hangul_MultipleCandidate 0xff3d /* Multiple candidate */
+#define XK_Hangul_PreviousCandidate 0xff3e /* Previous candidate */
+#define XK_Hangul_Special 0xff3f /* Special symbols */
+#define XK_Hangul_switch 0xff7e /* Alias for mode_switch */
+
+/* Hangul Consonant Characters */
+#define XK_Hangul_Kiyeog 0x0ea1
+#define XK_Hangul_SsangKiyeog 0x0ea2
+#define XK_Hangul_KiyeogSios 0x0ea3
+#define XK_Hangul_Nieun 0x0ea4
+#define XK_Hangul_NieunJieuj 0x0ea5
+#define XK_Hangul_NieunHieuh 0x0ea6
+#define XK_Hangul_Dikeud 0x0ea7
+#define XK_Hangul_SsangDikeud 0x0ea8
+#define XK_Hangul_Rieul 0x0ea9
+#define XK_Hangul_RieulKiyeog 0x0eaa
+#define XK_Hangul_RieulMieum 0x0eab
+#define XK_Hangul_RieulPieub 0x0eac
+#define XK_Hangul_RieulSios 0x0ead
+#define XK_Hangul_RieulTieut 0x0eae
+#define XK_Hangul_RieulPhieuf 0x0eaf
+#define XK_Hangul_RieulHieuh 0x0eb0
+#define XK_Hangul_Mieum 0x0eb1
+#define XK_Hangul_Pieub 0x0eb2
+#define XK_Hangul_SsangPieub 0x0eb3
+#define XK_Hangul_PieubSios 0x0eb4
+#define XK_Hangul_Sios 0x0eb5
+#define XK_Hangul_SsangSios 0x0eb6
+#define XK_Hangul_Ieung 0x0eb7
+#define XK_Hangul_Jieuj 0x0eb8
+#define XK_Hangul_SsangJieuj 0x0eb9
+#define XK_Hangul_Cieuc 0x0eba
+#define XK_Hangul_Khieuq 0x0ebb
+#define XK_Hangul_Tieut 0x0ebc
+#define XK_Hangul_Phieuf 0x0ebd
+#define XK_Hangul_Hieuh 0x0ebe
+
+/* Hangul Vowel Characters */
+#define XK_Hangul_A 0x0ebf
+#define XK_Hangul_AE 0x0ec0
+#define XK_Hangul_YA 0x0ec1
+#define XK_Hangul_YAE 0x0ec2
+#define XK_Hangul_EO 0x0ec3
+#define XK_Hangul_E 0x0ec4
+#define XK_Hangul_YEO 0x0ec5
+#define XK_Hangul_YE 0x0ec6
+#define XK_Hangul_O 0x0ec7
+#define XK_Hangul_WA 0x0ec8
+#define XK_Hangul_WAE 0x0ec9
+#define XK_Hangul_OE 0x0eca
+#define XK_Hangul_YO 0x0ecb
+#define XK_Hangul_U 0x0ecc
+#define XK_Hangul_WEO 0x0ecd
+#define XK_Hangul_WE 0x0ece
+#define XK_Hangul_WI 0x0ecf
+#define XK_Hangul_YU 0x0ed0
+#define XK_Hangul_EU 0x0ed1
+#define XK_Hangul_YI 0x0ed2
+#define XK_Hangul_I 0x0ed3
+
+/* Hangul syllable-final (JongSeong) Characters */
+#define XK_Hangul_J_Kiyeog 0x0ed4
+#define XK_Hangul_J_SsangKiyeog 0x0ed5
+#define XK_Hangul_J_KiyeogSios 0x0ed6
+#define XK_Hangul_J_Nieun 0x0ed7
+#define XK_Hangul_J_NieunJieuj 0x0ed8
+#define XK_Hangul_J_NieunHieuh 0x0ed9
+#define XK_Hangul_J_Dikeud 0x0eda
+#define XK_Hangul_J_Rieul 0x0edb
+#define XK_Hangul_J_RieulKiyeog 0x0edc
+#define XK_Hangul_J_RieulMieum 0x0edd
+#define XK_Hangul_J_RieulPieub 0x0ede
+#define XK_Hangul_J_RieulSios 0x0edf
+#define XK_Hangul_J_RieulTieut 0x0ee0
+#define XK_Hangul_J_RieulPhieuf 0x0ee1
+#define XK_Hangul_J_RieulHieuh 0x0ee2
+#define XK_Hangul_J_Mieum 0x0ee3
+#define XK_Hangul_J_Pieub 0x0ee4
+#define XK_Hangul_J_PieubSios 0x0ee5
+#define XK_Hangul_J_Sios 0x0ee6
+#define XK_Hangul_J_SsangSios 0x0ee7
+#define XK_Hangul_J_Ieung 0x0ee8
+#define XK_Hangul_J_Jieuj 0x0ee9
+#define XK_Hangul_J_Cieuc 0x0eea
+#define XK_Hangul_J_Khieuq 0x0eeb
+#define XK_Hangul_J_Tieut 0x0eec
+#define XK_Hangul_J_Phieuf 0x0eed
+#define XK_Hangul_J_Hieuh 0x0eee
+
+/* Ancient Hangul Consonant Characters */
+#define XK_Hangul_RieulYeorinHieuh 0x0eef
+#define XK_Hangul_SunkyeongeumMieum 0x0ef0
+#define XK_Hangul_SunkyeongeumPieub 0x0ef1
+#define XK_Hangul_PanSios 0x0ef2
+#define XK_Hangul_KkogjiDalrinIeung 0x0ef3
+#define XK_Hangul_SunkyeongeumPhieuf 0x0ef4
+#define XK_Hangul_YeorinHieuh 0x0ef5
+
+/* Ancient Hangul Vowel Characters */
+#define XK_Hangul_AraeA 0x0ef6
+#define XK_Hangul_AraeAE 0x0ef7
+
+/* Ancient Hangul syllable-final (JongSeong) Characters */
+#define XK_Hangul_J_PanSios 0x0ef8
+#define XK_Hangul_J_KkogjiDalrinIeung 0x0ef9
+#define XK_Hangul_J_YeorinHieuh 0x0efa
+
+/* Korean currency symbol */
+#define XK_Korean_Won 0x0eff /*(U+20A9 WON SIGN)*/
+
+#endif /* XK_KOREAN */
+
+/*
+ * Armenian
+ */
+
+#ifdef XK_ARMENIAN
+#define XK_Armenian_ligature_ew 0x1000587 /* U+0587 ARMENIAN SMALL LIGATURE ECH YIWN */
+#define XK_Armenian_full_stop 0x1000589 /* U+0589 ARMENIAN FULL STOP */
+#define XK_Armenian_verjaket 0x1000589 /* U+0589 ARMENIAN FULL STOP */
+#define XK_Armenian_separation_mark 0x100055d /* U+055D ARMENIAN COMMA */
+#define XK_Armenian_but 0x100055d /* U+055D ARMENIAN COMMA */
+#define XK_Armenian_hyphen 0x100058a /* U+058A ARMENIAN HYPHEN */
+#define XK_Armenian_yentamna 0x100058a /* U+058A ARMENIAN HYPHEN */
+#define XK_Armenian_exclam 0x100055c /* U+055C ARMENIAN EXCLAMATION MARK */
+#define XK_Armenian_amanak 0x100055c /* U+055C ARMENIAN EXCLAMATION MARK */
+#define XK_Armenian_accent 0x100055b /* U+055B ARMENIAN EMPHASIS MARK */
+#define XK_Armenian_shesht 0x100055b /* U+055B ARMENIAN EMPHASIS MARK */
+#define XK_Armenian_question 0x100055e /* U+055E ARMENIAN QUESTION MARK */
+#define XK_Armenian_paruyk 0x100055e /* U+055E ARMENIAN QUESTION MARK */
+#define XK_Armenian_AYB 0x1000531 /* U+0531 ARMENIAN CAPITAL LETTER AYB */
+#define XK_Armenian_ayb 0x1000561 /* U+0561 ARMENIAN SMALL LETTER AYB */
+#define XK_Armenian_BEN 0x1000532 /* U+0532 ARMENIAN CAPITAL LETTER BEN */
+#define XK_Armenian_ben 0x1000562 /* U+0562 ARMENIAN SMALL LETTER BEN */
+#define XK_Armenian_GIM 0x1000533 /* U+0533 ARMENIAN CAPITAL LETTER GIM */
+#define XK_Armenian_gim 0x1000563 /* U+0563 ARMENIAN SMALL LETTER GIM */
+#define XK_Armenian_DA 0x1000534 /* U+0534 ARMENIAN CAPITAL LETTER DA */
+#define XK_Armenian_da 0x1000564 /* U+0564 ARMENIAN SMALL LETTER DA */
+#define XK_Armenian_YECH 0x1000535 /* U+0535 ARMENIAN CAPITAL LETTER ECH */
+#define XK_Armenian_yech 0x1000565 /* U+0565 ARMENIAN SMALL LETTER ECH */
+#define XK_Armenian_ZA 0x1000536 /* U+0536 ARMENIAN CAPITAL LETTER ZA */
+#define XK_Armenian_za 0x1000566 /* U+0566 ARMENIAN SMALL LETTER ZA */
+#define XK_Armenian_E 0x1000537 /* U+0537 ARMENIAN CAPITAL LETTER EH */
+#define XK_Armenian_e 0x1000567 /* U+0567 ARMENIAN SMALL LETTER EH */
+#define XK_Armenian_AT 0x1000538 /* U+0538 ARMENIAN CAPITAL LETTER ET */
+#define XK_Armenian_at 0x1000568 /* U+0568 ARMENIAN SMALL LETTER ET */
+#define XK_Armenian_TO 0x1000539 /* U+0539 ARMENIAN CAPITAL LETTER TO */
+#define XK_Armenian_to 0x1000569 /* U+0569 ARMENIAN SMALL LETTER TO */
+#define XK_Armenian_ZHE 0x100053a /* U+053A ARMENIAN CAPITAL LETTER ZHE */
+#define XK_Armenian_zhe 0x100056a /* U+056A ARMENIAN SMALL LETTER ZHE */
+#define XK_Armenian_INI 0x100053b /* U+053B ARMENIAN CAPITAL LETTER INI */
+#define XK_Armenian_ini 0x100056b /* U+056B ARMENIAN SMALL LETTER INI */
+#define XK_Armenian_LYUN 0x100053c /* U+053C ARMENIAN CAPITAL LETTER LIWN */
+#define XK_Armenian_lyun 0x100056c /* U+056C ARMENIAN SMALL LETTER LIWN */
+#define XK_Armenian_KHE 0x100053d /* U+053D ARMENIAN CAPITAL LETTER XEH */
+#define XK_Armenian_khe 0x100056d /* U+056D ARMENIAN SMALL LETTER XEH */
+#define XK_Armenian_TSA 0x100053e /* U+053E ARMENIAN CAPITAL LETTER CA */
+#define XK_Armenian_tsa 0x100056e /* U+056E ARMENIAN SMALL LETTER CA */
+#define XK_Armenian_KEN 0x100053f /* U+053F ARMENIAN CAPITAL LETTER KEN */
+#define XK_Armenian_ken 0x100056f /* U+056F ARMENIAN SMALL LETTER KEN */
+#define XK_Armenian_HO 0x1000540 /* U+0540 ARMENIAN CAPITAL LETTER HO */
+#define XK_Armenian_ho 0x1000570 /* U+0570 ARMENIAN SMALL LETTER HO */
+#define XK_Armenian_DZA 0x1000541 /* U+0541 ARMENIAN CAPITAL LETTER JA */
+#define XK_Armenian_dza 0x1000571 /* U+0571 ARMENIAN SMALL LETTER JA */
+#define XK_Armenian_GHAT 0x1000542 /* U+0542 ARMENIAN CAPITAL LETTER GHAD */
+#define XK_Armenian_ghat 0x1000572 /* U+0572 ARMENIAN SMALL LETTER GHAD */
+#define XK_Armenian_TCHE 0x1000543 /* U+0543 ARMENIAN CAPITAL LETTER CHEH */
+#define XK_Armenian_tche 0x1000573 /* U+0573 ARMENIAN SMALL LETTER CHEH */
+#define XK_Armenian_MEN 0x1000544 /* U+0544 ARMENIAN CAPITAL LETTER MEN */
+#define XK_Armenian_men 0x1000574 /* U+0574 ARMENIAN SMALL LETTER MEN */
+#define XK_Armenian_HI 0x1000545 /* U+0545 ARMENIAN CAPITAL LETTER YI */
+#define XK_Armenian_hi 0x1000575 /* U+0575 ARMENIAN SMALL LETTER YI */
+#define XK_Armenian_NU 0x1000546 /* U+0546 ARMENIAN CAPITAL LETTER NOW */
+#define XK_Armenian_nu 0x1000576 /* U+0576 ARMENIAN SMALL LETTER NOW */
+#define XK_Armenian_SHA 0x1000547 /* U+0547 ARMENIAN CAPITAL LETTER SHA */
+#define XK_Armenian_sha 0x1000577 /* U+0577 ARMENIAN SMALL LETTER SHA */
+#define XK_Armenian_VO 0x1000548 /* U+0548 ARMENIAN CAPITAL LETTER VO */
+#define XK_Armenian_vo 0x1000578 /* U+0578 ARMENIAN SMALL LETTER VO */
+#define XK_Armenian_CHA 0x1000549 /* U+0549 ARMENIAN CAPITAL LETTER CHA */
+#define XK_Armenian_cha 0x1000579 /* U+0579 ARMENIAN SMALL LETTER CHA */
+#define XK_Armenian_PE 0x100054a /* U+054A ARMENIAN CAPITAL LETTER PEH */
+#define XK_Armenian_pe 0x100057a /* U+057A ARMENIAN SMALL LETTER PEH */
+#define XK_Armenian_JE 0x100054b /* U+054B ARMENIAN CAPITAL LETTER JHEH */
+#define XK_Armenian_je 0x100057b /* U+057B ARMENIAN SMALL LETTER JHEH */
+#define XK_Armenian_RA 0x100054c /* U+054C ARMENIAN CAPITAL LETTER RA */
+#define XK_Armenian_ra 0x100057c /* U+057C ARMENIAN SMALL LETTER RA */
+#define XK_Armenian_SE 0x100054d /* U+054D ARMENIAN CAPITAL LETTER SEH */
+#define XK_Armenian_se 0x100057d /* U+057D ARMENIAN SMALL LETTER SEH */
+#define XK_Armenian_VEV 0x100054e /* U+054E ARMENIAN CAPITAL LETTER VEW */
+#define XK_Armenian_vev 0x100057e /* U+057E ARMENIAN SMALL LETTER VEW */
+#define XK_Armenian_TYUN 0x100054f /* U+054F ARMENIAN CAPITAL LETTER TIWN */
+#define XK_Armenian_tyun 0x100057f /* U+057F ARMENIAN SMALL LETTER TIWN */
+#define XK_Armenian_RE 0x1000550 /* U+0550 ARMENIAN CAPITAL LETTER REH */
+#define XK_Armenian_re 0x1000580 /* U+0580 ARMENIAN SMALL LETTER REH */
+#define XK_Armenian_TSO 0x1000551 /* U+0551 ARMENIAN CAPITAL LETTER CO */
+#define XK_Armenian_tso 0x1000581 /* U+0581 ARMENIAN SMALL LETTER CO */
+#define XK_Armenian_VYUN 0x1000552 /* U+0552 ARMENIAN CAPITAL LETTER YIWN */
+#define XK_Armenian_vyun 0x1000582 /* U+0582 ARMENIAN SMALL LETTER YIWN */
+#define XK_Armenian_PYUR 0x1000553 /* U+0553 ARMENIAN CAPITAL LETTER PIWR */
+#define XK_Armenian_pyur 0x1000583 /* U+0583 ARMENIAN SMALL LETTER PIWR */
+#define XK_Armenian_KE 0x1000554 /* U+0554 ARMENIAN CAPITAL LETTER KEH */
+#define XK_Armenian_ke 0x1000584 /* U+0584 ARMENIAN SMALL LETTER KEH */
+#define XK_Armenian_O 0x1000555 /* U+0555 ARMENIAN CAPITAL LETTER OH */
+#define XK_Armenian_o 0x1000585 /* U+0585 ARMENIAN SMALL LETTER OH */
+#define XK_Armenian_FE 0x1000556 /* U+0556 ARMENIAN CAPITAL LETTER FEH */
+#define XK_Armenian_fe 0x1000586 /* U+0586 ARMENIAN SMALL LETTER FEH */
+#define XK_Armenian_apostrophe 0x100055a /* U+055A ARMENIAN APOSTROPHE */
+#endif /* XK_ARMENIAN */
+
+/*
+ * Georgian
+ */
+
+#ifdef XK_GEORGIAN
+#define XK_Georgian_an 0x10010d0 /* U+10D0 GEORGIAN LETTER AN */
+#define XK_Georgian_ban 0x10010d1 /* U+10D1 GEORGIAN LETTER BAN */
+#define XK_Georgian_gan 0x10010d2 /* U+10D2 GEORGIAN LETTER GAN */
+#define XK_Georgian_don 0x10010d3 /* U+10D3 GEORGIAN LETTER DON */
+#define XK_Georgian_en 0x10010d4 /* U+10D4 GEORGIAN LETTER EN */
+#define XK_Georgian_vin 0x10010d5 /* U+10D5 GEORGIAN LETTER VIN */
+#define XK_Georgian_zen 0x10010d6 /* U+10D6 GEORGIAN LETTER ZEN */
+#define XK_Georgian_tan 0x10010d7 /* U+10D7 GEORGIAN LETTER TAN */
+#define XK_Georgian_in 0x10010d8 /* U+10D8 GEORGIAN LETTER IN */
+#define XK_Georgian_kan 0x10010d9 /* U+10D9 GEORGIAN LETTER KAN */
+#define XK_Georgian_las 0x10010da /* U+10DA GEORGIAN LETTER LAS */
+#define XK_Georgian_man 0x10010db /* U+10DB GEORGIAN LETTER MAN */
+#define XK_Georgian_nar 0x10010dc /* U+10DC GEORGIAN LETTER NAR */
+#define XK_Georgian_on 0x10010dd /* U+10DD GEORGIAN LETTER ON */
+#define XK_Georgian_par 0x10010de /* U+10DE GEORGIAN LETTER PAR */
+#define XK_Georgian_zhar 0x10010df /* U+10DF GEORGIAN LETTER ZHAR */
+#define XK_Georgian_rae 0x10010e0 /* U+10E0 GEORGIAN LETTER RAE */
+#define XK_Georgian_san 0x10010e1 /* U+10E1 GEORGIAN LETTER SAN */
+#define XK_Georgian_tar 0x10010e2 /* U+10E2 GEORGIAN LETTER TAR */
+#define XK_Georgian_un 0x10010e3 /* U+10E3 GEORGIAN LETTER UN */
+#define XK_Georgian_phar 0x10010e4 /* U+10E4 GEORGIAN LETTER PHAR */
+#define XK_Georgian_khar 0x10010e5 /* U+10E5 GEORGIAN LETTER KHAR */
+#define XK_Georgian_ghan 0x10010e6 /* U+10E6 GEORGIAN LETTER GHAN */
+#define XK_Georgian_qar 0x10010e7 /* U+10E7 GEORGIAN LETTER QAR */
+#define XK_Georgian_shin 0x10010e8 /* U+10E8 GEORGIAN LETTER SHIN */
+#define XK_Georgian_chin 0x10010e9 /* U+10E9 GEORGIAN LETTER CHIN */
+#define XK_Georgian_can 0x10010ea /* U+10EA GEORGIAN LETTER CAN */
+#define XK_Georgian_jil 0x10010eb /* U+10EB GEORGIAN LETTER JIL */
+#define XK_Georgian_cil 0x10010ec /* U+10EC GEORGIAN LETTER CIL */
+#define XK_Georgian_char 0x10010ed /* U+10ED GEORGIAN LETTER CHAR */
+#define XK_Georgian_xan 0x10010ee /* U+10EE GEORGIAN LETTER XAN */
+#define XK_Georgian_jhan 0x10010ef /* U+10EF GEORGIAN LETTER JHAN */
+#define XK_Georgian_hae 0x10010f0 /* U+10F0 GEORGIAN LETTER HAE */
+#define XK_Georgian_he 0x10010f1 /* U+10F1 GEORGIAN LETTER HE */
+#define XK_Georgian_hie 0x10010f2 /* U+10F2 GEORGIAN LETTER HIE */
+#define XK_Georgian_we 0x10010f3 /* U+10F3 GEORGIAN LETTER WE */
+#define XK_Georgian_har 0x10010f4 /* U+10F4 GEORGIAN LETTER HAR */
+#define XK_Georgian_hoe 0x10010f5 /* U+10F5 GEORGIAN LETTER HOE */
+#define XK_Georgian_fi 0x10010f6 /* U+10F6 GEORGIAN LETTER FI */
+#endif /* XK_GEORGIAN */
+
+/*
+ * Azeri (and other Turkic or Caucasian languages)
+ */
+
+#ifdef XK_CAUCASUS
+/* latin */
+#define XK_Xabovedot 0x1001e8a /* U+1E8A LATIN CAPITAL LETTER X WITH DOT ABOVE */
+#define XK_Ibreve 0x100012c /* U+012C LATIN CAPITAL LETTER I WITH BREVE */
+#define XK_Zstroke 0x10001b5 /* U+01B5 LATIN CAPITAL LETTER Z WITH STROKE */
+#define XK_Gcaron 0x10001e6 /* U+01E6 LATIN CAPITAL LETTER G WITH CARON */
+#define XK_Ocaron 0x10001d1 /* U+01D1 LATIN CAPITAL LETTER O WITH CARON */
+#define XK_Obarred 0x100019f /* U+019F LATIN CAPITAL LETTER O WITH MIDDLE TILDE */
+#define XK_xabovedot 0x1001e8b /* U+1E8B LATIN SMALL LETTER X WITH DOT ABOVE */
+#define XK_ibreve 0x100012d /* U+012D LATIN SMALL LETTER I WITH BREVE */
+#define XK_zstroke 0x10001b6 /* U+01B6 LATIN SMALL LETTER Z WITH STROKE */
+#define XK_gcaron 0x10001e7 /* U+01E7 LATIN SMALL LETTER G WITH CARON */
+#define XK_ocaron 0x10001d2 /* U+01D2 LATIN SMALL LETTER O WITH CARON */
+#define XK_obarred 0x1000275 /* U+0275 LATIN SMALL LETTER BARRED O */
+#define XK_SCHWA 0x100018f /* U+018F LATIN CAPITAL LETTER SCHWA */
+#define XK_schwa 0x1000259 /* U+0259 LATIN SMALL LETTER SCHWA */
+#define XK_EZH 0x10001b7 /* U+01B7 LATIN CAPITAL LETTER EZH */
+#define XK_ezh 0x1000292 /* U+0292 LATIN SMALL LETTER EZH */
+/* those are not really Caucasus */
+/* For Inupiak */
+#define XK_Lbelowdot 0x1001e36 /* U+1E36 LATIN CAPITAL LETTER L WITH DOT BELOW */
+#define XK_lbelowdot 0x1001e37 /* U+1E37 LATIN SMALL LETTER L WITH DOT BELOW */
+#endif /* XK_CAUCASUS */
+
+/*
+ * Vietnamese
+ */
+
+#ifdef XK_VIETNAMESE
+#define XK_Abelowdot 0x1001ea0 /* U+1EA0 LATIN CAPITAL LETTER A WITH DOT BELOW */
+#define XK_abelowdot 0x1001ea1 /* U+1EA1 LATIN SMALL LETTER A WITH DOT BELOW */
+#define XK_Ahook 0x1001ea2 /* U+1EA2 LATIN CAPITAL LETTER A WITH HOOK ABOVE */
+#define XK_ahook 0x1001ea3 /* U+1EA3 LATIN SMALL LETTER A WITH HOOK ABOVE */
+#define XK_Acircumflexacute 0x1001ea4 /* U+1EA4 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE */
+#define XK_acircumflexacute 0x1001ea5 /* U+1EA5 LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE */
+#define XK_Acircumflexgrave 0x1001ea6 /* U+1EA6 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE */
+#define XK_acircumflexgrave 0x1001ea7 /* U+1EA7 LATIN SMALL LETTER A WITH CIRCUMFLEX AND GRAVE */
+#define XK_Acircumflexhook 0x1001ea8 /* U+1EA8 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE */
+#define XK_acircumflexhook 0x1001ea9 /* U+1EA9 LATIN SMALL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE */
+#define XK_Acircumflextilde 0x1001eaa /* U+1EAA LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE */
+#define XK_acircumflextilde 0x1001eab /* U+1EAB LATIN SMALL LETTER A WITH CIRCUMFLEX AND TILDE */
+#define XK_Acircumflexbelowdot 0x1001eac /* U+1EAC LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW */
+#define XK_acircumflexbelowdot 0x1001ead /* U+1EAD LATIN SMALL LETTER A WITH CIRCUMFLEX AND DOT BELOW */
+#define XK_Abreveacute 0x1001eae /* U+1EAE LATIN CAPITAL LETTER A WITH BREVE AND ACUTE */
+#define XK_abreveacute 0x1001eaf /* U+1EAF LATIN SMALL LETTER A WITH BREVE AND ACUTE */
+#define XK_Abrevegrave 0x1001eb0 /* U+1EB0 LATIN CAPITAL LETTER A WITH BREVE AND GRAVE */
+#define XK_abrevegrave 0x1001eb1 /* U+1EB1 LATIN SMALL LETTER A WITH BREVE AND GRAVE */
+#define XK_Abrevehook 0x1001eb2 /* U+1EB2 LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE */
+#define XK_abrevehook 0x1001eb3 /* U+1EB3 LATIN SMALL LETTER A WITH BREVE AND HOOK ABOVE */
+#define XK_Abrevetilde 0x1001eb4 /* U+1EB4 LATIN CAPITAL LETTER A WITH BREVE AND TILDE */
+#define XK_abrevetilde 0x1001eb5 /* U+1EB5 LATIN SMALL LETTER A WITH BREVE AND TILDE */
+#define XK_Abrevebelowdot 0x1001eb6 /* U+1EB6 LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW */
+#define XK_abrevebelowdot 0x1001eb7 /* U+1EB7 LATIN SMALL LETTER A WITH BREVE AND DOT BELOW */
+#define XK_Ebelowdot 0x1001eb8 /* U+1EB8 LATIN CAPITAL LETTER E WITH DOT BELOW */
+#define XK_ebelowdot 0x1001eb9 /* U+1EB9 LATIN SMALL LETTER E WITH DOT BELOW */
+#define XK_Ehook 0x1001eba /* U+1EBA LATIN CAPITAL LETTER E WITH HOOK ABOVE */
+#define XK_ehook 0x1001ebb /* U+1EBB LATIN SMALL LETTER E WITH HOOK ABOVE */
+#define XK_Etilde 0x1001ebc /* U+1EBC LATIN CAPITAL LETTER E WITH TILDE */
+#define XK_etilde 0x1001ebd /* U+1EBD LATIN SMALL LETTER E WITH TILDE */
+#define XK_Ecircumflexacute 0x1001ebe /* U+1EBE LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE */
+#define XK_ecircumflexacute 0x1001ebf /* U+1EBF LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE */
+#define XK_Ecircumflexgrave 0x1001ec0 /* U+1EC0 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE */
+#define XK_ecircumflexgrave 0x1001ec1 /* U+1EC1 LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE */
+#define XK_Ecircumflexhook 0x1001ec2 /* U+1EC2 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE */
+#define XK_ecircumflexhook 0x1001ec3 /* U+1EC3 LATIN SMALL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE */
+#define XK_Ecircumflextilde 0x1001ec4 /* U+1EC4 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE */
+#define XK_ecircumflextilde 0x1001ec5 /* U+1EC5 LATIN SMALL LETTER E WITH CIRCUMFLEX AND TILDE */
+#define XK_Ecircumflexbelowdot 0x1001ec6 /* U+1EC6 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW */
+#define XK_ecircumflexbelowdot 0x1001ec7 /* U+1EC7 LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT BELOW */
+#define XK_Ihook 0x1001ec8 /* U+1EC8 LATIN CAPITAL LETTER I WITH HOOK ABOVE */
+#define XK_ihook 0x1001ec9 /* U+1EC9 LATIN SMALL LETTER I WITH HOOK ABOVE */
+#define XK_Ibelowdot 0x1001eca /* U+1ECA LATIN CAPITAL LETTER I WITH DOT BELOW */
+#define XK_ibelowdot 0x1001ecb /* U+1ECB LATIN SMALL LETTER I WITH DOT BELOW */
+#define XK_Obelowdot 0x1001ecc /* U+1ECC LATIN CAPITAL LETTER O WITH DOT BELOW */
+#define XK_obelowdot 0x1001ecd /* U+1ECD LATIN SMALL LETTER O WITH DOT BELOW */
+#define XK_Ohook 0x1001ece /* U+1ECE LATIN CAPITAL LETTER O WITH HOOK ABOVE */
+#define XK_ohook 0x1001ecf /* U+1ECF LATIN SMALL LETTER O WITH HOOK ABOVE */
+#define XK_Ocircumflexacute 0x1001ed0 /* U+1ED0 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE */
+#define XK_ocircumflexacute 0x1001ed1 /* U+1ED1 LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACUTE */
+#define XK_Ocircumflexgrave 0x1001ed2 /* U+1ED2 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE */
+#define XK_ocircumflexgrave 0x1001ed3 /* U+1ED3 LATIN SMALL LETTER O WITH CIRCUMFLEX AND GRAVE */
+#define XK_Ocircumflexhook 0x1001ed4 /* U+1ED4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE */
+#define XK_ocircumflexhook 0x1001ed5 /* U+1ED5 LATIN SMALL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE */
+#define XK_Ocircumflextilde 0x1001ed6 /* U+1ED6 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE */
+#define XK_ocircumflextilde 0x1001ed7 /* U+1ED7 LATIN SMALL LETTER O WITH CIRCUMFLEX AND TILDE */
+#define XK_Ocircumflexbelowdot 0x1001ed8 /* U+1ED8 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELOW */
+#define XK_ocircumflexbelowdot 0x1001ed9 /* U+1ED9 LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELOW */
+#define XK_Ohornacute 0x1001eda /* U+1EDA LATIN CAPITAL LETTER O WITH HORN AND ACUTE */
+#define XK_ohornacute 0x1001edb /* U+1EDB LATIN SMALL LETTER O WITH HORN AND ACUTE */
+#define XK_Ohorngrave 0x1001edc /* U+1EDC LATIN CAPITAL LETTER O WITH HORN AND GRAVE */
+#define XK_ohorngrave 0x1001edd /* U+1EDD LATIN SMALL LETTER O WITH HORN AND GRAVE */
+#define XK_Ohornhook 0x1001ede /* U+1EDE LATIN CAPITAL LETTER O WITH HORN AND HOOK ABOVE */
+#define XK_ohornhook 0x1001edf /* U+1EDF LATIN SMALL LETTER O WITH HORN AND HOOK ABOVE */
+#define XK_Ohorntilde 0x1001ee0 /* U+1EE0 LATIN CAPITAL LETTER O WITH HORN AND TILDE */
+#define XK_ohorntilde 0x1001ee1 /* U+1EE1 LATIN SMALL LETTER O WITH HORN AND TILDE */
+#define XK_Ohornbelowdot 0x1001ee2 /* U+1EE2 LATIN CAPITAL LETTER O WITH HORN AND DOT BELOW */
+#define XK_ohornbelowdot 0x1001ee3 /* U+1EE3 LATIN SMALL LETTER O WITH HORN AND DOT BELOW */
+#define XK_Ubelowdot 0x1001ee4 /* U+1EE4 LATIN CAPITAL LETTER U WITH DOT BELOW */
+#define XK_ubelowdot 0x1001ee5 /* U+1EE5 LATIN SMALL LETTER U WITH DOT BELOW */
+#define XK_Uhook 0x1001ee6 /* U+1EE6 LATIN CAPITAL LETTER U WITH HOOK ABOVE */
+#define XK_uhook 0x1001ee7 /* U+1EE7 LATIN SMALL LETTER U WITH HOOK ABOVE */
+#define XK_Uhornacute 0x1001ee8 /* U+1EE8 LATIN CAPITAL LETTER U WITH HORN AND ACUTE */
+#define XK_uhornacute 0x1001ee9 /* U+1EE9 LATIN SMALL LETTER U WITH HORN AND ACUTE */
+#define XK_Uhorngrave 0x1001eea /* U+1EEA LATIN CAPITAL LETTER U WITH HORN AND GRAVE */
+#define XK_uhorngrave 0x1001eeb /* U+1EEB LATIN SMALL LETTER U WITH HORN AND GRAVE */
+#define XK_Uhornhook 0x1001eec /* U+1EEC LATIN CAPITAL LETTER U WITH HORN AND HOOK ABOVE */
+#define XK_uhornhook 0x1001eed /* U+1EED LATIN SMALL LETTER U WITH HORN AND HOOK ABOVE */
+#define XK_Uhorntilde 0x1001eee /* U+1EEE LATIN CAPITAL LETTER U WITH HORN AND TILDE */
+#define XK_uhorntilde 0x1001eef /* U+1EEF LATIN SMALL LETTER U WITH HORN AND TILDE */
+#define XK_Uhornbelowdot 0x1001ef0 /* U+1EF0 LATIN CAPITAL LETTER U WITH HORN AND DOT BELOW */
+#define XK_uhornbelowdot 0x1001ef1 /* U+1EF1 LATIN SMALL LETTER U WITH HORN AND DOT BELOW */
+#define XK_Ybelowdot 0x1001ef4 /* U+1EF4 LATIN CAPITAL LETTER Y WITH DOT BELOW */
+#define XK_ybelowdot 0x1001ef5 /* U+1EF5 LATIN SMALL LETTER Y WITH DOT BELOW */
+#define XK_Yhook 0x1001ef6 /* U+1EF6 LATIN CAPITAL LETTER Y WITH HOOK ABOVE */
+#define XK_yhook 0x1001ef7 /* U+1EF7 LATIN SMALL LETTER Y WITH HOOK ABOVE */
+#define XK_Ytilde 0x1001ef8 /* U+1EF8 LATIN CAPITAL LETTER Y WITH TILDE */
+#define XK_ytilde 0x1001ef9 /* U+1EF9 LATIN SMALL LETTER Y WITH TILDE */
+#define XK_Ohorn 0x10001a0 /* U+01A0 LATIN CAPITAL LETTER O WITH HORN */
+#define XK_ohorn 0x10001a1 /* U+01A1 LATIN SMALL LETTER O WITH HORN */
+#define XK_Uhorn 0x10001af /* U+01AF LATIN CAPITAL LETTER U WITH HORN */
+#define XK_uhorn 0x10001b0 /* U+01B0 LATIN SMALL LETTER U WITH HORN */
+
+#endif /* XK_VIETNAMESE */
+
+#ifdef XK_CURRENCY
+#define XK_EcuSign 0x10020a0 /* U+20A0 EURO-CURRENCY SIGN */
+#define XK_ColonSign 0x10020a1 /* U+20A1 COLON SIGN */
+#define XK_CruzeiroSign 0x10020a2 /* U+20A2 CRUZEIRO SIGN */
+#define XK_FFrancSign 0x10020a3 /* U+20A3 FRENCH FRANC SIGN */
+#define XK_LiraSign 0x10020a4 /* U+20A4 LIRA SIGN */
+#define XK_MillSign 0x10020a5 /* U+20A5 MILL SIGN */
+#define XK_NairaSign 0x10020a6 /* U+20A6 NAIRA SIGN */
+#define XK_PesetaSign 0x10020a7 /* U+20A7 PESETA SIGN */
+#define XK_RupeeSign 0x10020a8 /* U+20A8 RUPEE SIGN */
+#define XK_WonSign 0x10020a9 /* U+20A9 WON SIGN */
+#define XK_NewSheqelSign 0x10020aa /* U+20AA NEW SHEQEL SIGN */
+#define XK_DongSign 0x10020ab /* U+20AB DONG SIGN */
+#define XK_EuroSign 0x20ac /* U+20AC EURO SIGN */
+#endif /* XK_CURRENCY */
+
+#ifdef XK_MATHEMATICAL
+/* one, two and three are defined above. */
+#define XK_zerosuperior 0x1002070 /* U+2070 SUPERSCRIPT ZERO */
+#define XK_foursuperior 0x1002074 /* U+2074 SUPERSCRIPT FOUR */
+#define XK_fivesuperior 0x1002075 /* U+2075 SUPERSCRIPT FIVE */
+#define XK_sixsuperior 0x1002076 /* U+2076 SUPERSCRIPT SIX */
+#define XK_sevensuperior 0x1002077 /* U+2077 SUPERSCRIPT SEVEN */
+#define XK_eightsuperior 0x1002078 /* U+2078 SUPERSCRIPT EIGHT */
+#define XK_ninesuperior 0x1002079 /* U+2079 SUPERSCRIPT NINE */
+#define XK_zerosubscript 0x1002080 /* U+2080 SUBSCRIPT ZERO */
+#define XK_onesubscript 0x1002081 /* U+2081 SUBSCRIPT ONE */
+#define XK_twosubscript 0x1002082 /* U+2082 SUBSCRIPT TWO */
+#define XK_threesubscript 0x1002083 /* U+2083 SUBSCRIPT THREE */
+#define XK_foursubscript 0x1002084 /* U+2084 SUBSCRIPT FOUR */
+#define XK_fivesubscript 0x1002085 /* U+2085 SUBSCRIPT FIVE */
+#define XK_sixsubscript 0x1002086 /* U+2086 SUBSCRIPT SIX */
+#define XK_sevensubscript 0x1002087 /* U+2087 SUBSCRIPT SEVEN */
+#define XK_eightsubscript 0x1002088 /* U+2088 SUBSCRIPT EIGHT */
+#define XK_ninesubscript 0x1002089 /* U+2089 SUBSCRIPT NINE */
+#define XK_partdifferential 0x1002202 /* U+2202 PARTIAL DIFFERENTIAL */
+#define XK_emptyset 0x1002205 /* U+2205 NULL SET */
+#define XK_elementof 0x1002208 /* U+2208 ELEMENT OF */
+#define XK_notelementof 0x1002209 /* U+2209 NOT AN ELEMENT OF */
+#define XK_containsas 0x100220B /* U+220B CONTAINS AS MEMBER */
+#define XK_squareroot 0x100221A /* U+221A SQUARE ROOT */
+#define XK_cuberoot 0x100221B /* U+221B CUBE ROOT */
+#define XK_fourthroot 0x100221C /* U+221C FOURTH ROOT */
+#define XK_dintegral 0x100222C /* U+222C DOUBLE INTEGRAL */
+#define XK_tintegral 0x100222D /* U+222D TRIPLE INTEGRAL */
+#define XK_because 0x1002235 /* U+2235 BECAUSE */
+#define XK_approxeq 0x1002248 /* U+2245 ALMOST EQUAL TO */
+#define XK_notapproxeq 0x1002247 /* U+2247 NOT ALMOST EQUAL TO */
+#define XK_notidentical 0x1002262 /* U+2262 NOT IDENTICAL TO */
+#define XK_stricteq 0x1002263 /* U+2263 STRICTLY EQUIVALENT TO */
+#endif /* XK_MATHEMATICAL */
+
+#ifdef XK_BRAILLE
+#define XK_braille_dot_1 0xfff1
+#define XK_braille_dot_2 0xfff2
+#define XK_braille_dot_3 0xfff3
+#define XK_braille_dot_4 0xfff4
+#define XK_braille_dot_5 0xfff5
+#define XK_braille_dot_6 0xfff6
+#define XK_braille_dot_7 0xfff7
+#define XK_braille_dot_8 0xfff8
+#define XK_braille_dot_9 0xfff9
+#define XK_braille_dot_10 0xfffa
+#define XK_braille_blank 0x1002800 /* U+2800 BRAILLE PATTERN BLANK */
+#define XK_braille_dots_1 0x1002801 /* U+2801 BRAILLE PATTERN DOTS-1 */
+#define XK_braille_dots_2 0x1002802 /* U+2802 BRAILLE PATTERN DOTS-2 */
+#define XK_braille_dots_12 0x1002803 /* U+2803 BRAILLE PATTERN DOTS-12 */
+#define XK_braille_dots_3 0x1002804 /* U+2804 BRAILLE PATTERN DOTS-3 */
+#define XK_braille_dots_13 0x1002805 /* U+2805 BRAILLE PATTERN DOTS-13 */
+#define XK_braille_dots_23 0x1002806 /* U+2806 BRAILLE PATTERN DOTS-23 */
+#define XK_braille_dots_123 0x1002807 /* U+2807 BRAILLE PATTERN DOTS-123 */
+#define XK_braille_dots_4 0x1002808 /* U+2808 BRAILLE PATTERN DOTS-4 */
+#define XK_braille_dots_14 0x1002809 /* U+2809 BRAILLE PATTERN DOTS-14 */
+#define XK_braille_dots_24 0x100280a /* U+280a BRAILLE PATTERN DOTS-24 */
+#define XK_braille_dots_124 0x100280b /* U+280b BRAILLE PATTERN DOTS-124 */
+#define XK_braille_dots_34 0x100280c /* U+280c BRAILLE PATTERN DOTS-34 */
+#define XK_braille_dots_134 0x100280d /* U+280d BRAILLE PATTERN DOTS-134 */
+#define XK_braille_dots_234 0x100280e /* U+280e BRAILLE PATTERN DOTS-234 */
+#define XK_braille_dots_1234 0x100280f /* U+280f BRAILLE PATTERN DOTS-1234 */
+#define XK_braille_dots_5 0x1002810 /* U+2810 BRAILLE PATTERN DOTS-5 */
+#define XK_braille_dots_15 0x1002811 /* U+2811 BRAILLE PATTERN DOTS-15 */
+#define XK_braille_dots_25 0x1002812 /* U+2812 BRAILLE PATTERN DOTS-25 */
+#define XK_braille_dots_125 0x1002813 /* U+2813 BRAILLE PATTERN DOTS-125 */
+#define XK_braille_dots_35 0x1002814 /* U+2814 BRAILLE PATTERN DOTS-35 */
+#define XK_braille_dots_135 0x1002815 /* U+2815 BRAILLE PATTERN DOTS-135 */
+#define XK_braille_dots_235 0x1002816 /* U+2816 BRAILLE PATTERN DOTS-235 */
+#define XK_braille_dots_1235 0x1002817 /* U+2817 BRAILLE PATTERN DOTS-1235 */
+#define XK_braille_dots_45 0x1002818 /* U+2818 BRAILLE PATTERN DOTS-45 */
+#define XK_braille_dots_145 0x1002819 /* U+2819 BRAILLE PATTERN DOTS-145 */
+#define XK_braille_dots_245 0x100281a /* U+281a BRAILLE PATTERN DOTS-245 */
+#define XK_braille_dots_1245 0x100281b /* U+281b BRAILLE PATTERN DOTS-1245 */
+#define XK_braille_dots_345 0x100281c /* U+281c BRAILLE PATTERN DOTS-345 */
+#define XK_braille_dots_1345 0x100281d /* U+281d BRAILLE PATTERN DOTS-1345 */
+#define XK_braille_dots_2345 0x100281e /* U+281e BRAILLE PATTERN DOTS-2345 */
+#define XK_braille_dots_12345 0x100281f /* U+281f BRAILLE PATTERN DOTS-12345 */
+#define XK_braille_dots_6 0x1002820 /* U+2820 BRAILLE PATTERN DOTS-6 */
+#define XK_braille_dots_16 0x1002821 /* U+2821 BRAILLE PATTERN DOTS-16 */
+#define XK_braille_dots_26 0x1002822 /* U+2822 BRAILLE PATTERN DOTS-26 */
+#define XK_braille_dots_126 0x1002823 /* U+2823 BRAILLE PATTERN DOTS-126 */
+#define XK_braille_dots_36 0x1002824 /* U+2824 BRAILLE PATTERN DOTS-36 */
+#define XK_braille_dots_136 0x1002825 /* U+2825 BRAILLE PATTERN DOTS-136 */
+#define XK_braille_dots_236 0x1002826 /* U+2826 BRAILLE PATTERN DOTS-236 */
+#define XK_braille_dots_1236 0x1002827 /* U+2827 BRAILLE PATTERN DOTS-1236 */
+#define XK_braille_dots_46 0x1002828 /* U+2828 BRAILLE PATTERN DOTS-46 */
+#define XK_braille_dots_146 0x1002829 /* U+2829 BRAILLE PATTERN DOTS-146 */
+#define XK_braille_dots_246 0x100282a /* U+282a BRAILLE PATTERN DOTS-246 */
+#define XK_braille_dots_1246 0x100282b /* U+282b BRAILLE PATTERN DOTS-1246 */
+#define XK_braille_dots_346 0x100282c /* U+282c BRAILLE PATTERN DOTS-346 */
+#define XK_braille_dots_1346 0x100282d /* U+282d BRAILLE PATTERN DOTS-1346 */
+#define XK_braille_dots_2346 0x100282e /* U+282e BRAILLE PATTERN DOTS-2346 */
+#define XK_braille_dots_12346 0x100282f /* U+282f BRAILLE PATTERN DOTS-12346 */
+#define XK_braille_dots_56 0x1002830 /* U+2830 BRAILLE PATTERN DOTS-56 */
+#define XK_braille_dots_156 0x1002831 /* U+2831 BRAILLE PATTERN DOTS-156 */
+#define XK_braille_dots_256 0x1002832 /* U+2832 BRAILLE PATTERN DOTS-256 */
+#define XK_braille_dots_1256 0x1002833 /* U+2833 BRAILLE PATTERN DOTS-1256 */
+#define XK_braille_dots_356 0x1002834 /* U+2834 BRAILLE PATTERN DOTS-356 */
+#define XK_braille_dots_1356 0x1002835 /* U+2835 BRAILLE PATTERN DOTS-1356 */
+#define XK_braille_dots_2356 0x1002836 /* U+2836 BRAILLE PATTERN DOTS-2356 */
+#define XK_braille_dots_12356 0x1002837 /* U+2837 BRAILLE PATTERN DOTS-12356 */
+#define XK_braille_dots_456 0x1002838 /* U+2838 BRAILLE PATTERN DOTS-456 */
+#define XK_braille_dots_1456 0x1002839 /* U+2839 BRAILLE PATTERN DOTS-1456 */
+#define XK_braille_dots_2456 0x100283a /* U+283a BRAILLE PATTERN DOTS-2456 */
+#define XK_braille_dots_12456 0x100283b /* U+283b BRAILLE PATTERN DOTS-12456 */
+#define XK_braille_dots_3456 0x100283c /* U+283c BRAILLE PATTERN DOTS-3456 */
+#define XK_braille_dots_13456 0x100283d /* U+283d BRAILLE PATTERN DOTS-13456 */
+#define XK_braille_dots_23456 0x100283e /* U+283e BRAILLE PATTERN DOTS-23456 */
+#define XK_braille_dots_123456 0x100283f /* U+283f BRAILLE PATTERN DOTS-123456 */
+#define XK_braille_dots_7 0x1002840 /* U+2840 BRAILLE PATTERN DOTS-7 */
+#define XK_braille_dots_17 0x1002841 /* U+2841 BRAILLE PATTERN DOTS-17 */
+#define XK_braille_dots_27 0x1002842 /* U+2842 BRAILLE PATTERN DOTS-27 */
+#define XK_braille_dots_127 0x1002843 /* U+2843 BRAILLE PATTERN DOTS-127 */
+#define XK_braille_dots_37 0x1002844 /* U+2844 BRAILLE PATTERN DOTS-37 */
+#define XK_braille_dots_137 0x1002845 /* U+2845 BRAILLE PATTERN DOTS-137 */
+#define XK_braille_dots_237 0x1002846 /* U+2846 BRAILLE PATTERN DOTS-237 */
+#define XK_braille_dots_1237 0x1002847 /* U+2847 BRAILLE PATTERN DOTS-1237 */
+#define XK_braille_dots_47 0x1002848 /* U+2848 BRAILLE PATTERN DOTS-47 */
+#define XK_braille_dots_147 0x1002849 /* U+2849 BRAILLE PATTERN DOTS-147 */
+#define XK_braille_dots_247 0x100284a /* U+284a BRAILLE PATTERN DOTS-247 */
+#define XK_braille_dots_1247 0x100284b /* U+284b BRAILLE PATTERN DOTS-1247 */
+#define XK_braille_dots_347 0x100284c /* U+284c BRAILLE PATTERN DOTS-347 */
+#define XK_braille_dots_1347 0x100284d /* U+284d BRAILLE PATTERN DOTS-1347 */
+#define XK_braille_dots_2347 0x100284e /* U+284e BRAILLE PATTERN DOTS-2347 */
+#define XK_braille_dots_12347 0x100284f /* U+284f BRAILLE PATTERN DOTS-12347 */
+#define XK_braille_dots_57 0x1002850 /* U+2850 BRAILLE PATTERN DOTS-57 */
+#define XK_braille_dots_157 0x1002851 /* U+2851 BRAILLE PATTERN DOTS-157 */
+#define XK_braille_dots_257 0x1002852 /* U+2852 BRAILLE PATTERN DOTS-257 */
+#define XK_braille_dots_1257 0x1002853 /* U+2853 BRAILLE PATTERN DOTS-1257 */
+#define XK_braille_dots_357 0x1002854 /* U+2854 BRAILLE PATTERN DOTS-357 */
+#define XK_braille_dots_1357 0x1002855 /* U+2855 BRAILLE PATTERN DOTS-1357 */
+#define XK_braille_dots_2357 0x1002856 /* U+2856 BRAILLE PATTERN DOTS-2357 */
+#define XK_braille_dots_12357 0x1002857 /* U+2857 BRAILLE PATTERN DOTS-12357 */
+#define XK_braille_dots_457 0x1002858 /* U+2858 BRAILLE PATTERN DOTS-457 */
+#define XK_braille_dots_1457 0x1002859 /* U+2859 BRAILLE PATTERN DOTS-1457 */
+#define XK_braille_dots_2457 0x100285a /* U+285a BRAILLE PATTERN DOTS-2457 */
+#define XK_braille_dots_12457 0x100285b /* U+285b BRAILLE PATTERN DOTS-12457 */
+#define XK_braille_dots_3457 0x100285c /* U+285c BRAILLE PATTERN DOTS-3457 */
+#define XK_braille_dots_13457 0x100285d /* U+285d BRAILLE PATTERN DOTS-13457 */
+#define XK_braille_dots_23457 0x100285e /* U+285e BRAILLE PATTERN DOTS-23457 */
+#define XK_braille_dots_123457 0x100285f /* U+285f BRAILLE PATTERN DOTS-123457 */
+#define XK_braille_dots_67 0x1002860 /* U+2860 BRAILLE PATTERN DOTS-67 */
+#define XK_braille_dots_167 0x1002861 /* U+2861 BRAILLE PATTERN DOTS-167 */
+#define XK_braille_dots_267 0x1002862 /* U+2862 BRAILLE PATTERN DOTS-267 */
+#define XK_braille_dots_1267 0x1002863 /* U+2863 BRAILLE PATTERN DOTS-1267 */
+#define XK_braille_dots_367 0x1002864 /* U+2864 BRAILLE PATTERN DOTS-367 */
+#define XK_braille_dots_1367 0x1002865 /* U+2865 BRAILLE PATTERN DOTS-1367 */
+#define XK_braille_dots_2367 0x1002866 /* U+2866 BRAILLE PATTERN DOTS-2367 */
+#define XK_braille_dots_12367 0x1002867 /* U+2867 BRAILLE PATTERN DOTS-12367 */
+#define XK_braille_dots_467 0x1002868 /* U+2868 BRAILLE PATTERN DOTS-467 */
+#define XK_braille_dots_1467 0x1002869 /* U+2869 BRAILLE PATTERN DOTS-1467 */
+#define XK_braille_dots_2467 0x100286a /* U+286a BRAILLE PATTERN DOTS-2467 */
+#define XK_braille_dots_12467 0x100286b /* U+286b BRAILLE PATTERN DOTS-12467 */
+#define XK_braille_dots_3467 0x100286c /* U+286c BRAILLE PATTERN DOTS-3467 */
+#define XK_braille_dots_13467 0x100286d /* U+286d BRAILLE PATTERN DOTS-13467 */
+#define XK_braille_dots_23467 0x100286e /* U+286e BRAILLE PATTERN DOTS-23467 */
+#define XK_braille_dots_123467 0x100286f /* U+286f BRAILLE PATTERN DOTS-123467 */
+#define XK_braille_dots_567 0x1002870 /* U+2870 BRAILLE PATTERN DOTS-567 */
+#define XK_braille_dots_1567 0x1002871 /* U+2871 BRAILLE PATTERN DOTS-1567 */
+#define XK_braille_dots_2567 0x1002872 /* U+2872 BRAILLE PATTERN DOTS-2567 */
+#define XK_braille_dots_12567 0x1002873 /* U+2873 BRAILLE PATTERN DOTS-12567 */
+#define XK_braille_dots_3567 0x1002874 /* U+2874 BRAILLE PATTERN DOTS-3567 */
+#define XK_braille_dots_13567 0x1002875 /* U+2875 BRAILLE PATTERN DOTS-13567 */
+#define XK_braille_dots_23567 0x1002876 /* U+2876 BRAILLE PATTERN DOTS-23567 */
+#define XK_braille_dots_123567 0x1002877 /* U+2877 BRAILLE PATTERN DOTS-123567 */
+#define XK_braille_dots_4567 0x1002878 /* U+2878 BRAILLE PATTERN DOTS-4567 */
+#define XK_braille_dots_14567 0x1002879 /* U+2879 BRAILLE PATTERN DOTS-14567 */
+#define XK_braille_dots_24567 0x100287a /* U+287a BRAILLE PATTERN DOTS-24567 */
+#define XK_braille_dots_124567 0x100287b /* U+287b BRAILLE PATTERN DOTS-124567 */
+#define XK_braille_dots_34567 0x100287c /* U+287c BRAILLE PATTERN DOTS-34567 */
+#define XK_braille_dots_134567 0x100287d /* U+287d BRAILLE PATTERN DOTS-134567 */
+#define XK_braille_dots_234567 0x100287e /* U+287e BRAILLE PATTERN DOTS-234567 */
+#define XK_braille_dots_1234567 0x100287f /* U+287f BRAILLE PATTERN DOTS-1234567 */
+#define XK_braille_dots_8 0x1002880 /* U+2880 BRAILLE PATTERN DOTS-8 */
+#define XK_braille_dots_18 0x1002881 /* U+2881 BRAILLE PATTERN DOTS-18 */
+#define XK_braille_dots_28 0x1002882 /* U+2882 BRAILLE PATTERN DOTS-28 */
+#define XK_braille_dots_128 0x1002883 /* U+2883 BRAILLE PATTERN DOTS-128 */
+#define XK_braille_dots_38 0x1002884 /* U+2884 BRAILLE PATTERN DOTS-38 */
+#define XK_braille_dots_138 0x1002885 /* U+2885 BRAILLE PATTERN DOTS-138 */
+#define XK_braille_dots_238 0x1002886 /* U+2886 BRAILLE PATTERN DOTS-238 */
+#define XK_braille_dots_1238 0x1002887 /* U+2887 BRAILLE PATTERN DOTS-1238 */
+#define XK_braille_dots_48 0x1002888 /* U+2888 BRAILLE PATTERN DOTS-48 */
+#define XK_braille_dots_148 0x1002889 /* U+2889 BRAILLE PATTERN DOTS-148 */
+#define XK_braille_dots_248 0x100288a /* U+288a BRAILLE PATTERN DOTS-248 */
+#define XK_braille_dots_1248 0x100288b /* U+288b BRAILLE PATTERN DOTS-1248 */
+#define XK_braille_dots_348 0x100288c /* U+288c BRAILLE PATTERN DOTS-348 */
+#define XK_braille_dots_1348 0x100288d /* U+288d BRAILLE PATTERN DOTS-1348 */
+#define XK_braille_dots_2348 0x100288e /* U+288e BRAILLE PATTERN DOTS-2348 */
+#define XK_braille_dots_12348 0x100288f /* U+288f BRAILLE PATTERN DOTS-12348 */
+#define XK_braille_dots_58 0x1002890 /* U+2890 BRAILLE PATTERN DOTS-58 */
+#define XK_braille_dots_158 0x1002891 /* U+2891 BRAILLE PATTERN DOTS-158 */
+#define XK_braille_dots_258 0x1002892 /* U+2892 BRAILLE PATTERN DOTS-258 */
+#define XK_braille_dots_1258 0x1002893 /* U+2893 BRAILLE PATTERN DOTS-1258 */
+#define XK_braille_dots_358 0x1002894 /* U+2894 BRAILLE PATTERN DOTS-358 */
+#define XK_braille_dots_1358 0x1002895 /* U+2895 BRAILLE PATTERN DOTS-1358 */
+#define XK_braille_dots_2358 0x1002896 /* U+2896 BRAILLE PATTERN DOTS-2358 */
+#define XK_braille_dots_12358 0x1002897 /* U+2897 BRAILLE PATTERN DOTS-12358 */
+#define XK_braille_dots_458 0x1002898 /* U+2898 BRAILLE PATTERN DOTS-458 */
+#define XK_braille_dots_1458 0x1002899 /* U+2899 BRAILLE PATTERN DOTS-1458 */
+#define XK_braille_dots_2458 0x100289a /* U+289a BRAILLE PATTERN DOTS-2458 */
+#define XK_braille_dots_12458 0x100289b /* U+289b BRAILLE PATTERN DOTS-12458 */
+#define XK_braille_dots_3458 0x100289c /* U+289c BRAILLE PATTERN DOTS-3458 */
+#define XK_braille_dots_13458 0x100289d /* U+289d BRAILLE PATTERN DOTS-13458 */
+#define XK_braille_dots_23458 0x100289e /* U+289e BRAILLE PATTERN DOTS-23458 */
+#define XK_braille_dots_123458 0x100289f /* U+289f BRAILLE PATTERN DOTS-123458 */
+#define XK_braille_dots_68 0x10028a0 /* U+28a0 BRAILLE PATTERN DOTS-68 */
+#define XK_braille_dots_168 0x10028a1 /* U+28a1 BRAILLE PATTERN DOTS-168 */
+#define XK_braille_dots_268 0x10028a2 /* U+28a2 BRAILLE PATTERN DOTS-268 */
+#define XK_braille_dots_1268 0x10028a3 /* U+28a3 BRAILLE PATTERN DOTS-1268 */
+#define XK_braille_dots_368 0x10028a4 /* U+28a4 BRAILLE PATTERN DOTS-368 */
+#define XK_braille_dots_1368 0x10028a5 /* U+28a5 BRAILLE PATTERN DOTS-1368 */
+#define XK_braille_dots_2368 0x10028a6 /* U+28a6 BRAILLE PATTERN DOTS-2368 */
+#define XK_braille_dots_12368 0x10028a7 /* U+28a7 BRAILLE PATTERN DOTS-12368 */
+#define XK_braille_dots_468 0x10028a8 /* U+28a8 BRAILLE PATTERN DOTS-468 */
+#define XK_braille_dots_1468 0x10028a9 /* U+28a9 BRAILLE PATTERN DOTS-1468 */
+#define XK_braille_dots_2468 0x10028aa /* U+28aa BRAILLE PATTERN DOTS-2468 */
+#define XK_braille_dots_12468 0x10028ab /* U+28ab BRAILLE PATTERN DOTS-12468 */
+#define XK_braille_dots_3468 0x10028ac /* U+28ac BRAILLE PATTERN DOTS-3468 */
+#define XK_braille_dots_13468 0x10028ad /* U+28ad BRAILLE PATTERN DOTS-13468 */
+#define XK_braille_dots_23468 0x10028ae /* U+28ae BRAILLE PATTERN DOTS-23468 */
+#define XK_braille_dots_123468 0x10028af /* U+28af BRAILLE PATTERN DOTS-123468 */
+#define XK_braille_dots_568 0x10028b0 /* U+28b0 BRAILLE PATTERN DOTS-568 */
+#define XK_braille_dots_1568 0x10028b1 /* U+28b1 BRAILLE PATTERN DOTS-1568 */
+#define XK_braille_dots_2568 0x10028b2 /* U+28b2 BRAILLE PATTERN DOTS-2568 */
+#define XK_braille_dots_12568 0x10028b3 /* U+28b3 BRAILLE PATTERN DOTS-12568 */
+#define XK_braille_dots_3568 0x10028b4 /* U+28b4 BRAILLE PATTERN DOTS-3568 */
+#define XK_braille_dots_13568 0x10028b5 /* U+28b5 BRAILLE PATTERN DOTS-13568 */
+#define XK_braille_dots_23568 0x10028b6 /* U+28b6 BRAILLE PATTERN DOTS-23568 */
+#define XK_braille_dots_123568 0x10028b7 /* U+28b7 BRAILLE PATTERN DOTS-123568 */
+#define XK_braille_dots_4568 0x10028b8 /* U+28b8 BRAILLE PATTERN DOTS-4568 */
+#define XK_braille_dots_14568 0x10028b9 /* U+28b9 BRAILLE PATTERN DOTS-14568 */
+#define XK_braille_dots_24568 0x10028ba /* U+28ba BRAILLE PATTERN DOTS-24568 */
+#define XK_braille_dots_124568 0x10028bb /* U+28bb BRAILLE PATTERN DOTS-124568 */
+#define XK_braille_dots_34568 0x10028bc /* U+28bc BRAILLE PATTERN DOTS-34568 */
+#define XK_braille_dots_134568 0x10028bd /* U+28bd BRAILLE PATTERN DOTS-134568 */
+#define XK_braille_dots_234568 0x10028be /* U+28be BRAILLE PATTERN DOTS-234568 */
+#define XK_braille_dots_1234568 0x10028bf /* U+28bf BRAILLE PATTERN DOTS-1234568 */
+#define XK_braille_dots_78 0x10028c0 /* U+28c0 BRAILLE PATTERN DOTS-78 */
+#define XK_braille_dots_178 0x10028c1 /* U+28c1 BRAILLE PATTERN DOTS-178 */
+#define XK_braille_dots_278 0x10028c2 /* U+28c2 BRAILLE PATTERN DOTS-278 */
+#define XK_braille_dots_1278 0x10028c3 /* U+28c3 BRAILLE PATTERN DOTS-1278 */
+#define XK_braille_dots_378 0x10028c4 /* U+28c4 BRAILLE PATTERN DOTS-378 */
+#define XK_braille_dots_1378 0x10028c5 /* U+28c5 BRAILLE PATTERN DOTS-1378 */
+#define XK_braille_dots_2378 0x10028c6 /* U+28c6 BRAILLE PATTERN DOTS-2378 */
+#define XK_braille_dots_12378 0x10028c7 /* U+28c7 BRAILLE PATTERN DOTS-12378 */
+#define XK_braille_dots_478 0x10028c8 /* U+28c8 BRAILLE PATTERN DOTS-478 */
+#define XK_braille_dots_1478 0x10028c9 /* U+28c9 BRAILLE PATTERN DOTS-1478 */
+#define XK_braille_dots_2478 0x10028ca /* U+28ca BRAILLE PATTERN DOTS-2478 */
+#define XK_braille_dots_12478 0x10028cb /* U+28cb BRAILLE PATTERN DOTS-12478 */
+#define XK_braille_dots_3478 0x10028cc /* U+28cc BRAILLE PATTERN DOTS-3478 */
+#define XK_braille_dots_13478 0x10028cd /* U+28cd BRAILLE PATTERN DOTS-13478 */
+#define XK_braille_dots_23478 0x10028ce /* U+28ce BRAILLE PATTERN DOTS-23478 */
+#define XK_braille_dots_123478 0x10028cf /* U+28cf BRAILLE PATTERN DOTS-123478 */
+#define XK_braille_dots_578 0x10028d0 /* U+28d0 BRAILLE PATTERN DOTS-578 */
+#define XK_braille_dots_1578 0x10028d1 /* U+28d1 BRAILLE PATTERN DOTS-1578 */
+#define XK_braille_dots_2578 0x10028d2 /* U+28d2 BRAILLE PATTERN DOTS-2578 */
+#define XK_braille_dots_12578 0x10028d3 /* U+28d3 BRAILLE PATTERN DOTS-12578 */
+#define XK_braille_dots_3578 0x10028d4 /* U+28d4 BRAILLE PATTERN DOTS-3578 */
+#define XK_braille_dots_13578 0x10028d5 /* U+28d5 BRAILLE PATTERN DOTS-13578 */
+#define XK_braille_dots_23578 0x10028d6 /* U+28d6 BRAILLE PATTERN DOTS-23578 */
+#define XK_braille_dots_123578 0x10028d7 /* U+28d7 BRAILLE PATTERN DOTS-123578 */
+#define XK_braille_dots_4578 0x10028d8 /* U+28d8 BRAILLE PATTERN DOTS-4578 */
+#define XK_braille_dots_14578 0x10028d9 /* U+28d9 BRAILLE PATTERN DOTS-14578 */
+#define XK_braille_dots_24578 0x10028da /* U+28da BRAILLE PATTERN DOTS-24578 */
+#define XK_braille_dots_124578 0x10028db /* U+28db BRAILLE PATTERN DOTS-124578 */
+#define XK_braille_dots_34578 0x10028dc /* U+28dc BRAILLE PATTERN DOTS-34578 */
+#define XK_braille_dots_134578 0x10028dd /* U+28dd BRAILLE PATTERN DOTS-134578 */
+#define XK_braille_dots_234578 0x10028de /* U+28de BRAILLE PATTERN DOTS-234578 */
+#define XK_braille_dots_1234578 0x10028df /* U+28df BRAILLE PATTERN DOTS-1234578 */
+#define XK_braille_dots_678 0x10028e0 /* U+28e0 BRAILLE PATTERN DOTS-678 */
+#define XK_braille_dots_1678 0x10028e1 /* U+28e1 BRAILLE PATTERN DOTS-1678 */
+#define XK_braille_dots_2678 0x10028e2 /* U+28e2 BRAILLE PATTERN DOTS-2678 */
+#define XK_braille_dots_12678 0x10028e3 /* U+28e3 BRAILLE PATTERN DOTS-12678 */
+#define XK_braille_dots_3678 0x10028e4 /* U+28e4 BRAILLE PATTERN DOTS-3678 */
+#define XK_braille_dots_13678 0x10028e5 /* U+28e5 BRAILLE PATTERN DOTS-13678 */
+#define XK_braille_dots_23678 0x10028e6 /* U+28e6 BRAILLE PATTERN DOTS-23678 */
+#define XK_braille_dots_123678 0x10028e7 /* U+28e7 BRAILLE PATTERN DOTS-123678 */
+#define XK_braille_dots_4678 0x10028e8 /* U+28e8 BRAILLE PATTERN DOTS-4678 */
+#define XK_braille_dots_14678 0x10028e9 /* U+28e9 BRAILLE PATTERN DOTS-14678 */
+#define XK_braille_dots_24678 0x10028ea /* U+28ea BRAILLE PATTERN DOTS-24678 */
+#define XK_braille_dots_124678 0x10028eb /* U+28eb BRAILLE PATTERN DOTS-124678 */
+#define XK_braille_dots_34678 0x10028ec /* U+28ec BRAILLE PATTERN DOTS-34678 */
+#define XK_braille_dots_134678 0x10028ed /* U+28ed BRAILLE PATTERN DOTS-134678 */
+#define XK_braille_dots_234678 0x10028ee /* U+28ee BRAILLE PATTERN DOTS-234678 */
+#define XK_braille_dots_1234678 0x10028ef /* U+28ef BRAILLE PATTERN DOTS-1234678 */
+#define XK_braille_dots_5678 0x10028f0 /* U+28f0 BRAILLE PATTERN DOTS-5678 */
+#define XK_braille_dots_15678 0x10028f1 /* U+28f1 BRAILLE PATTERN DOTS-15678 */
+#define XK_braille_dots_25678 0x10028f2 /* U+28f2 BRAILLE PATTERN DOTS-25678 */
+#define XK_braille_dots_125678 0x10028f3 /* U+28f3 BRAILLE PATTERN DOTS-125678 */
+#define XK_braille_dots_35678 0x10028f4 /* U+28f4 BRAILLE PATTERN DOTS-35678 */
+#define XK_braille_dots_135678 0x10028f5 /* U+28f5 BRAILLE PATTERN DOTS-135678 */
+#define XK_braille_dots_235678 0x10028f6 /* U+28f6 BRAILLE PATTERN DOTS-235678 */
+#define XK_braille_dots_1235678 0x10028f7 /* U+28f7 BRAILLE PATTERN DOTS-1235678 */
+#define XK_braille_dots_45678 0x10028f8 /* U+28f8 BRAILLE PATTERN DOTS-45678 */
+#define XK_braille_dots_145678 0x10028f9 /* U+28f9 BRAILLE PATTERN DOTS-145678 */
+#define XK_braille_dots_245678 0x10028fa /* U+28fa BRAILLE PATTERN DOTS-245678 */
+#define XK_braille_dots_1245678 0x10028fb /* U+28fb BRAILLE PATTERN DOTS-1245678 */
+#define XK_braille_dots_345678 0x10028fc /* U+28fc BRAILLE PATTERN DOTS-345678 */
+#define XK_braille_dots_1345678 0x10028fd /* U+28fd BRAILLE PATTERN DOTS-1345678 */
+#define XK_braille_dots_2345678 0x10028fe /* U+28fe BRAILLE PATTERN DOTS-2345678 */
+#define XK_braille_dots_12345678 0x10028ff /* U+28ff BRAILLE PATTERN DOTS-12345678 */
+#endif /* XK_BRAILLE */
+
+/*
+ * Sinhala (http://unicode.org/charts/PDF/U0D80.pdf)
+ * http://www.nongnu.org/sinhala/doc/transliteration/sinhala-transliteration_6.html
+ */
+
+#ifdef XK_SINHALA
+#define XK_Sinh_ng 0x1000d82 /* U+0D82 SINHALA ANUSVARAYA */
+#define XK_Sinh_h2 0x1000d83 /* U+0D83 SINHALA VISARGAYA */
+#define XK_Sinh_a 0x1000d85 /* U+0D85 SINHALA AYANNA */
+#define XK_Sinh_aa 0x1000d86 /* U+0D86 SINHALA AAYANNA */
+#define XK_Sinh_ae 0x1000d87 /* U+0D87 SINHALA AEYANNA */
+#define XK_Sinh_aee 0x1000d88 /* U+0D88 SINHALA AEEYANNA */
+#define XK_Sinh_i 0x1000d89 /* U+0D89 SINHALA IYANNA */
+#define XK_Sinh_ii 0x1000d8a /* U+0D8A SINHALA IIYANNA */
+#define XK_Sinh_u 0x1000d8b /* U+0D8B SINHALA UYANNA */
+#define XK_Sinh_uu 0x1000d8c /* U+0D8C SINHALA UUYANNA */
+#define XK_Sinh_ri 0x1000d8d /* U+0D8D SINHALA IRUYANNA */
+#define XK_Sinh_rii 0x1000d8e /* U+0D8E SINHALA IRUUYANNA */
+#define XK_Sinh_lu 0x1000d8f /* U+0D8F SINHALA ILUYANNA */
+#define XK_Sinh_luu 0x1000d90 /* U+0D90 SINHALA ILUUYANNA */
+#define XK_Sinh_e 0x1000d91 /* U+0D91 SINHALA EYANNA */
+#define XK_Sinh_ee 0x1000d92 /* U+0D92 SINHALA EEYANNA */
+#define XK_Sinh_ai 0x1000d93 /* U+0D93 SINHALA AIYANNA */
+#define XK_Sinh_o 0x1000d94 /* U+0D94 SINHALA OYANNA */
+#define XK_Sinh_oo 0x1000d95 /* U+0D95 SINHALA OOYANNA */
+#define XK_Sinh_au 0x1000d96 /* U+0D96 SINHALA AUYANNA */
+#define XK_Sinh_ka 0x1000d9a /* U+0D9A SINHALA KAYANNA */
+#define XK_Sinh_kha 0x1000d9b /* U+0D9B SINHALA MAHA. KAYANNA */
+#define XK_Sinh_ga 0x1000d9c /* U+0D9C SINHALA GAYANNA */
+#define XK_Sinh_gha 0x1000d9d /* U+0D9D SINHALA MAHA. GAYANNA */
+#define XK_Sinh_ng2 0x1000d9e /* U+0D9E SINHALA KANTAJA NAASIKYAYA */
+#define XK_Sinh_nga 0x1000d9f /* U+0D9F SINHALA SANYAKA GAYANNA */
+#define XK_Sinh_ca 0x1000da0 /* U+0DA0 SINHALA CAYANNA */
+#define XK_Sinh_cha 0x1000da1 /* U+0DA1 SINHALA MAHA. CAYANNA */
+#define XK_Sinh_ja 0x1000da2 /* U+0DA2 SINHALA JAYANNA */
+#define XK_Sinh_jha 0x1000da3 /* U+0DA3 SINHALA MAHA. JAYANNA */
+#define XK_Sinh_nya 0x1000da4 /* U+0DA4 SINHALA TAALUJA NAASIKYAYA */
+#define XK_Sinh_jnya 0x1000da5 /* U+0DA5 SINHALA TAALUJA SANYOOGA NAASIKYAYA */
+#define XK_Sinh_nja 0x1000da6 /* U+0DA6 SINHALA SANYAKA JAYANNA */
+#define XK_Sinh_tta 0x1000da7 /* U+0DA7 SINHALA TTAYANNA */
+#define XK_Sinh_ttha 0x1000da8 /* U+0DA8 SINHALA MAHA. TTAYANNA */
+#define XK_Sinh_dda 0x1000da9 /* U+0DA9 SINHALA DDAYANNA */
+#define XK_Sinh_ddha 0x1000daa /* U+0DAA SINHALA MAHA. DDAYANNA */
+#define XK_Sinh_nna 0x1000dab /* U+0DAB SINHALA MUURDHAJA NAYANNA */
+#define XK_Sinh_ndda 0x1000dac /* U+0DAC SINHALA SANYAKA DDAYANNA */
+#define XK_Sinh_tha 0x1000dad /* U+0DAD SINHALA TAYANNA */
+#define XK_Sinh_thha 0x1000dae /* U+0DAE SINHALA MAHA. TAYANNA */
+#define XK_Sinh_dha 0x1000daf /* U+0DAF SINHALA DAYANNA */
+#define XK_Sinh_dhha 0x1000db0 /* U+0DB0 SINHALA MAHA. DAYANNA */
+#define XK_Sinh_na 0x1000db1 /* U+0DB1 SINHALA DANTAJA NAYANNA */
+#define XK_Sinh_ndha 0x1000db3 /* U+0DB3 SINHALA SANYAKA DAYANNA */
+#define XK_Sinh_pa 0x1000db4 /* U+0DB4 SINHALA PAYANNA */
+#define XK_Sinh_pha 0x1000db5 /* U+0DB5 SINHALA MAHA. PAYANNA */
+#define XK_Sinh_ba 0x1000db6 /* U+0DB6 SINHALA BAYANNA */
+#define XK_Sinh_bha 0x1000db7 /* U+0DB7 SINHALA MAHA. BAYANNA */
+#define XK_Sinh_ma 0x1000db8 /* U+0DB8 SINHALA MAYANNA */
+#define XK_Sinh_mba 0x1000db9 /* U+0DB9 SINHALA AMBA BAYANNA */
+#define XK_Sinh_ya 0x1000dba /* U+0DBA SINHALA YAYANNA */
+#define XK_Sinh_ra 0x1000dbb /* U+0DBB SINHALA RAYANNA */
+#define XK_Sinh_la 0x1000dbd /* U+0DBD SINHALA DANTAJA LAYANNA */
+#define XK_Sinh_va 0x1000dc0 /* U+0DC0 SINHALA VAYANNA */
+#define XK_Sinh_sha 0x1000dc1 /* U+0DC1 SINHALA TAALUJA SAYANNA */
+#define XK_Sinh_ssha 0x1000dc2 /* U+0DC2 SINHALA MUURDHAJA SAYANNA */
+#define XK_Sinh_sa 0x1000dc3 /* U+0DC3 SINHALA DANTAJA SAYANNA */
+#define XK_Sinh_ha 0x1000dc4 /* U+0DC4 SINHALA HAYANNA */
+#define XK_Sinh_lla 0x1000dc5 /* U+0DC5 SINHALA MUURDHAJA LAYANNA */
+#define XK_Sinh_fa 0x1000dc6 /* U+0DC6 SINHALA FAYANNA */
+#define XK_Sinh_al 0x1000dca /* U+0DCA SINHALA AL-LAKUNA */
+#define XK_Sinh_aa2 0x1000dcf /* U+0DCF SINHALA AELA-PILLA */
+#define XK_Sinh_ae2 0x1000dd0 /* U+0DD0 SINHALA AEDA-PILLA */
+#define XK_Sinh_aee2 0x1000dd1 /* U+0DD1 SINHALA DIGA AEDA-PILLA */
+#define XK_Sinh_i2 0x1000dd2 /* U+0DD2 SINHALA IS-PILLA */
+#define XK_Sinh_ii2 0x1000dd3 /* U+0DD3 SINHALA DIGA IS-PILLA */
+#define XK_Sinh_u2 0x1000dd4 /* U+0DD4 SINHALA PAA-PILLA */
+#define XK_Sinh_uu2 0x1000dd6 /* U+0DD6 SINHALA DIGA PAA-PILLA */
+#define XK_Sinh_ru2 0x1000dd8 /* U+0DD8 SINHALA GAETTA-PILLA */
+#define XK_Sinh_e2 0x1000dd9 /* U+0DD9 SINHALA KOMBUVA */
+#define XK_Sinh_ee2 0x1000dda /* U+0DDA SINHALA DIGA KOMBUVA */
+#define XK_Sinh_ai2 0x1000ddb /* U+0DDB SINHALA KOMBU DEKA */
+#define XK_Sinh_o2 0x1000ddc /* U+0DDC SINHALA KOMBUVA HAA AELA-PILLA*/
+#define XK_Sinh_oo2 0x1000ddd /* U+0DDD SINHALA KOMBUVA HAA DIGA AELA-PILLA*/
+#define XK_Sinh_au2 0x1000dde /* U+0DDE SINHALA KOMBUVA HAA GAYANUKITTA */
+#define XK_Sinh_lu2 0x1000ddf /* U+0DDF SINHALA GAYANUKITTA */
+#define XK_Sinh_ruu2 0x1000df2 /* U+0DF2 SINHALA DIGA GAETTA-PILLA */
+#define XK_Sinh_luu2 0x1000df3 /* U+0DF3 SINHALA DIGA GAYANUKITTA */
+#define XK_Sinh_kunddaliya 0x1000df4 /* U+0DF4 SINHALA KUNDDALIYA */
+#endif /* XK_SINHALA */
+
/* Multimedia keys, defined same as on Linux
* /usr/include/pkg/libxkbcommon/xkbcommon/xkbcommon-keysyms.h
*/
+#ifndef TK_NO_DEPRECATED
#define XK_XF86AudioLowerVolume 0x1008FF11 /* Volume control down */
#define XK_XF86AudioMute 0x1008FF12 /* Mute sound from the system */
#define XK_XF86AudioRaiseVolume 0x1008FF13 /* Volume control up */
@@ -1178,4 +2513,5 @@ SOFTWARE.
#define XK_XF86AudioStop 0x1008FF15 /* Stop playing audio */
#define XK_XF86AudioPrev 0x1008FF16 /* Previous track */
#define XK_XF86AudioNext 0x1008FF17 /* Next track */
+#endif /* !TK_NO_DEPRECATED */
diff --git a/xlib/xcolors.c b/xlib/xcolors.c
index 31db297..73391fb 100644
--- a/xlib/xcolors.c
+++ b/xlib/xcolors.c
@@ -44,18 +44,18 @@ typedef char elem[32];
static const elem xColors[] = {
/* Colors starting with 'a' */
- "liceBlue\0 \360\370\377",
+ "liceBlue\0 \360\370\377\0",
"ntiqueWhite\0 \213\203\170\315\300\260\356\337\314\377\357\333\372\353\327\4",
- "qua\0 \000\377\377",
+ "qua\0 \000\377\377\0",
"quamarine\0 \105\213\164\146\315\252\166\356\306\177\377\324\177\377\324\4",
"zure\0 \203\213\213\301\315\315\340\356\356\360\377\377\360\377\377\4",
/* Colors starting with 'b' */
- "eige\0 \365\365\334",
+ "eige\0 \365\365\334\0",
"isque\0 \213\175\153\315\267\236\356\325\267\377\344\304\377\344\304\4",
- "lack\0 \000\000\000",
- "lanchedAlmond\0 \377\353\315",
+ "lack\0 \000\000\000\0",
+ "lanchedAlmond\0 \377\353\315\0",
"lue\0 \000\000\213\000\000\315\000\000\356\000\000\377\000\000\377\4",
- "lueViolet\0 \212\053\342",
+ "lueViolet\0 \212\053\342\0",
"rown\0 \213\043\043\315\063\063\356\073\073\377\100\100\245\052\052\4",
"urlywood\0 \213\163\125\315\252\175\356\305\221\377\323\233\336\270\207\4",
/* Colors starting with 'c' */
@@ -63,168 +63,168 @@ static const elem xColors[] = {
"hartreuse\0 \105\213\000\146\315\000\166\356\000\177\377\000\177\377\000\4",
"hocolate\0 \213\105\023\315\146\035\356\166\041\377\177\044\322\151\036\4",
"oral\0 \213\076\057\315\133\105\356\152\120\377\162\126\377\177\120\4",
- "ornflowerBlue\0 \144\225\355",
+ "ornflowerBlue\0 \144\225\355\0",
"ornsilk\0 \213\210\170\315\310\261\356\350\315\377\370\334\377\370\334\4",
- "rimson\0 \334\024\074",
+ "rimson\0 \334\024\074\0",
"yan\0 \000\213\213\000\315\315\000\356\356\000\377\377\000\377\377\4",
/* Colors starting with 'd' */
- "arkBlue\0 \000\000\213",
- "arkCyan\0 \000\213\213",
+ "arkBlue\0 \000\000\213\0",
+ "arkCyan\0 \000\213\213\0",
"arkGoldenrod\0 \213\145\010\315\225\014\356\255\016\377\271\017\270\206\013\4",
- "arkGray\0 \251\251\251",
- "arkGreen\0 \000\144\000",
- "arkGrey\0 \251\251\251",
- "arkKhaki\0 \275\267\153",
- "arkMagenta\0 \213\000\213",
+ "arkGray\0 \251\251\251\0",
+ "arkGreen\0 \000\144\000\0",
+ "arkGrey\0 \251\251\251\0",
+ "arkKhaki\0 \275\267\153\0",
+ "arkMagenta\0 \213\000\213\0",
"arkOliveGreen\0 \156\213\075\242\315\132\274\356\150\312\377\160\125\153\057\4",
"arkOrange\0 \213\105\000\315\146\000\356\166\000\377\177\000\377\214\000\4",
"arkOrchid\0 \150\042\213\232\062\315\262\072\356\277\076\377\231\062\314\4",
- "arkRed\0 \213\000\000",
- "arkSalmon\0 \351\226\172",
+ "arkRed\0 \213\000\000\0",
+ "arkSalmon\0 \351\226\172\0",
"arkSeaGreen\0 \151\213\151\233\315\233\264\356\264\301\377\301\217\274\217\4",
- "arkSlateBlue\0 \110\075\213",
+ "arkSlateBlue\0 \110\075\213\0",
"arkSlateGray\0 \122\213\213\171\315\315\215\356\356\227\377\377\057\117\117\4",
- "arkSlateGrey\0 \057\117\117",
- "arkTurquoise\0 \000\316\321",
- "arkViolet\0 \224\000\323",
+ "arkSlateGrey\0 \057\117\117\0",
+ "arkTurquoise\0 \000\316\321\0",
+ "arkViolet\0 \224\000\323\0",
"eepPink\0 \213\012\120\315\020\166\356\022\211\377\024\223\377\024\223\4",
"eepSkyBlue\0 \000\150\213\000\232\315\000\262\356\000\277\377\000\277\377\4",
- "imGray\0 \151\151\151",
- "imGrey\0 \151\151\151",
+ "imGray\0 \151\151\151\0",
+ "imGrey\0 \151\151\151\0",
"odgerBlue\0 \020\116\213\030\164\315\034\206\356\036\220\377\036\220\377\4",
/* Colors starting with 'e' */
- "\377" /* placeholder */,
+ "\377 \0" /* placeholder */,
/* Colors starting with 'f' */
"irebrick\0 \213\032\032\315\046\046\356\054\054\377\060\060\262\042\042\4",
- "loralWhite\0 \377\372\360",
- "orestGreen\0 \042\213\042",
- "uchsia\0 \377\000\377",
+ "loralWhite\0 \377\372\360\0",
+ "orestGreen\0 \042\213\042\0",
+ "uchsia\0 \377\000\377\0",
/* Colors starting with 'g' */
- "ainsboro\0 \334\334\334",
- "hostWhite\0 \370\370\377",
+ "ainsboro\0 \334\334\334\0",
+ "hostWhite\0 \370\370\377\0",
"old\0 \213\165\000\315\255\000\356\311\000\377\327\000\377\327\000\4",
"oldenrod\0 \213\151\024\315\233\035\356\264\042\377\301\045\332\245\040\4",
"ray\0\024\024\024\022\022\022\017\017\017\015\015\015\012\012\012"
"\010\010\010\005\005\005\003\003\003\200\200\200\10",
- "ray0\0 \000\000\000",
+ "ray0\0 \000\000\000\0",
"reen\0 \000\213\000\000\315\000\000\356\000\000\377\000\000\200\000\4",
- "reenYellow\0 \255\377\057",
+ "reenYellow\0 \255\377\057\0",
"rey\0\024\024\024\022\022\022\017\017\017\015\015\015\012\012\012"
"\010\010\010\005\005\005\003\003\003\200\200\200\10",
- "rey0\0 \000\000\000",
+ "rey0\0 \000\000\000\0",
/* Colors starting with 'h' */
"oneydew\0 \203\213\203\301\315\301\340\356\340\360\377\360\360\377\360\4",
"otPink\0 \213\072\142\315\140\220\356\152\247\377\156\264\377\151\264\4",
/* Colors starting with 'i' */
"ndianRed\0 \213\072\072\315\125\125\356\143\143\377\152\152\315\134\134\4",
- "ndigo\0 \113\000\202",
+ "ndigo\0 \113\000\202\0",
"vory\0 \213\213\203\315\315\301\356\356\340\377\377\360\377\377\360\4",
/* Colors starting with 'j' */
- "\377" /* placeholder */,
+ "\377 \0" /* placeholder */,
/* Colors starting with 'k' */
"haki\0 \213\206\116\315\306\163\356\346\205\377\366\217\360\346\214\4",
/* Colors starting with 'l' */
- "avender\0 \346\346\372",
+ "avender\0 \346\346\372\0",
"avenderBlush\0 \213\203\206\315\301\305\356\340\345\377\360\365\377\360\365\4",
- "awnGreen\0 \174\374\000",
+ "awnGreen\0 \174\374\000\0",
"emonChiffon\0 \213\211\160\315\311\245\356\351\277\377\372\315\377\372\315\4",
"ightBlue\0 \150\203\213\232\300\315\262\337\356\277\357\377\255\330\346\4",
- "ightCoral\0 \360\200\200",
+ "ightCoral\0 \360\200\200\0",
"ightCyan\0 \172\213\213\264\315\315\321\356\356\340\377\377\340\377\377\4",
"ightGoldenrod\0 \213\201\114\315\276\160\356\334\202\377\354\213\356\335\202\4",
- "ightGoldenrodYellow\0 \372\372\322",
- "ightGray\0 \323\323\323",
- "ightGreen\0 \220\356\220",
- "ightGrey\0 \323\323\323",
+ "ightGoldenrodYellow\0 \372\372\322\0",
+ "ightGray\0 \323\323\323\0",
+ "ightGreen\0 \220\356\220\0",
+ "ightGrey\0 \323\323\323\0",
"ightPink\0 \213\137\145\315\214\225\356\242\255\377\256\271\377\266\301\4",
"ightSalmon\0 \213\127\102\315\201\142\356\225\162\377\240\172\377\240\172\4",
- "ightSeaGreen\0 \040\262\252",
+ "ightSeaGreen\0 \040\262\252\0",
"ightSkyBlue\0 \140\173\213\215\266\315\244\323\356\260\342\377\207\316\372\4",
- "ightSlateBlue\0 \204\160\377",
- "ightSlateGray\0 \167\210\231",
- "ightSlateGrey\0 \167\210\231",
+ "ightSlateBlue\0 \204\160\377\0",
+ "ightSlateGray\0 \167\210\231\0",
+ "ightSlateGrey\0 \167\210\231\0",
"ightSteelBlue\0 \156\173\213\242\265\315\274\322\356\312\341\377\260\304\336\4",
"ightYellow\0 \213\213\172\315\315\264\356\356\321\377\377\340\377\377\340\4",
- "ime\0 \000\377\000",
- "imeGreen\0 \062\315\062",
- "inen\0 \372\360\346",
+ "ime\0 \000\377\000\0",
+ "imeGreen\0 \062\315\062\0",
+ "inen\0 \372\360\346\0",
/* Colors starting with 'm' */
"agenta\0 \213\000\213\315\000\315\356\000\356\377\000\377\377\000\377\4",
"aroon\0 \213\034\142\315\051\220\356\060\247\377\064\263\200\000\000\4",
- "ediumAquamarine\0 \146\315\252",
- "ediumBlue\0 \000\000\315",
+ "ediumAquamarine\0 \146\315\252\0",
+ "ediumBlue\0 \000\000\315\0",
"ediumOrchid\0 \172\067\213\264\122\315\321\137\356\340\146\377\272\125\323\4",
"ediumPurple\0 \135\107\213\211\150\315\237\171\356\253\202\377\223\160\333\4",
- "ediumSeaGreen\0 \074\263\161",
- "ediumSlateBlue\0 \173\150\356",
- "ediumSpringGreen\0 \000\372\232",
- "ediumTurquoise\0 \110\321\314",
- "ediumVioletRed\0 \307\025\205",
- "idnightBlue\0 \031\031\160",
- "intCream\0 \365\377\372",
+ "ediumSeaGreen\0 \074\263\161\0",
+ "ediumSlateBlue\0 \173\150\356\0",
+ "ediumSpringGreen\0 \000\372\232\0",
+ "ediumTurquoise\0 \110\321\314\0",
+ "ediumVioletRed\0 \307\025\205\0",
+ "idnightBlue\0 \031\031\160\0",
+ "intCream\0 \365\377\372\0",
"istyRose\0 \213\175\173\315\267\265\356\325\322\377\344\341\377\344\341\4",
- "occasin\0 \377\344\265",
+ "occasin\0 \377\344\265\0",
/* Colors starting with 'n' */
"avajoWhite\0 \213\171\136\315\263\213\356\317\241\377\336\255\377\336\255\4",
- "avy\0 \000\000\200",
- "avyBlue\0 \000\000\200",
+ "avy\0 \000\000\200\0",
+ "avyBlue\0 \000\000\200\0",
/* Colors starting with 'o' */
- "ldLace\0 \375\365\346",
- "live\0 \200\200\000",
+ "ldLace\0 \375\365\346\0",
+ "live\0 \200\200\000\0",
"liveDrab\0 \151\213\042\232\315\062\263\356\072\300\377\076\153\216\043\4",
"range\0 \213\132\000\315\205\000\356\232\000\377\245\000\377\245\000\4",
"rangeRed\0 \213\045\000\315\067\000\356\100\000\377\105\000\377\105\000\4",
"rchid\0 \213\107\211\315\151\311\356\172\351\377\203\372\332\160\326\4",
/* Colors starting with 'p' */
- "aleGoldenrod\0 \356\350\252",
+ "aleGoldenrod\0 \356\350\252\0",
"aleGreen\0 \124\213\124\174\315\174\220\356\220\232\377\232\230\373\230\4",
"aleTurquoise\0 \146\213\213\226\315\315\256\356\356\273\377\377\257\356\356\4",
"aleVioletRed\0 \213\107\135\315\150\211\356\171\237\377\202\253\333\160\223\4",
- "apayaWhip\0 \377\357\325",
+ "apayaWhip\0 \377\357\325\0",
"eachPuff\0 \213\167\145\315\257\225\356\313\255\377\332\271\377\332\271\4",
- "eru\0 \315\205\077",
+ "eru\0 \315\205\077\0",
"ink\0 \213\143\154\315\221\236\356\251\270\377\265\305\377\300\313\4",
"lum\0 \213\146\213\315\226\315\356\256\356\377\273\377\335\240\335\4",
- "owderBlue\0 \260\340\346",
+ "owderBlue\0 \260\340\346\0",
"urple\0 \125\032\213\175\046\315\221\054\356\233\060\377\200\000\200\4",
/* Colors starting with 'q' */
- "\377" /* placeholder */,
+ "\377 \0" /* placeholder */,
/* Colors starting with 'r' */
"ed\0 \213\000\000\315\000\000\356\000\000\377\000\000\377\000\000\4",
"osyBrown\0 \213\151\151\315\233\233\356\264\264\377\301\301\274\217\217\4",
"oyalBlue\0 \047\100\213\072\137\315\103\156\356\110\166\377\101\151\341\4",
/* Colors starting with 's' */
- "addleBrown\0 \213\105\023",
+ "addleBrown\0 \213\105\023\0",
"almon\0 \213\114\071\315\160\124\356\202\142\377\214\151\372\200\162\4",
- "andyBrown\0 \364\244\140",
+ "andyBrown\0 \364\244\140\0",
"eaGreen\0 \056\213\127\103\315\200\116\356\224\124\377\237\056\213\127\4",
"eashell\0 \213\206\202\315\305\277\356\345\336\377\365\356\377\365\356\4",
"ienna\0 \213\107\046\315\150\071\356\171\102\377\202\107\240\122\055\4",
- "ilver\0 \300\300\300",
+ "ilver\0 \300\300\300\0",
"kyBlue\0 \112\160\213\154\246\315\176\300\356\207\316\377\207\316\353\4",
"lateBlue\0 \107\074\213\151\131\315\172\147\356\203\157\377\152\132\315\4",
"lateGray\0 \154\173\213\237\266\315\271\323\356\306\342\377\160\200\220\4",
- "lateGrey\0 \160\200\220",
+ "lateGrey\0 \160\200\220\0",
"now\0 \213\211\211\315\311\311\356\351\351\377\372\372\377\372\372\4",
"pringGreen\0 \000\213\105\000\315\146\000\356\166\000\377\177\000\377\177\4",
"teelBlue\0 \066\144\213\117\224\315\134\254\356\143\270\377\106\202\264\4",
/* Colors starting with 't' */
"an\0 \213\132\053\315\205\077\356\232\111\377\245\117\322\264\214\4",
- "eal\0 \000\200\200",
+ "eal\0 \000\200\200\0",
"histle\0 \213\173\213\315\265\315\356\322\356\377\341\377\330\277\330\4",
"omato\0 \213\066\046\315\117\071\356\134\102\377\143\107\377\143\107\4",
"urquoise\0 \000\206\213\000\305\315\000\345\356\000\365\377\100\340\320\4",
/* Colors starting with 'u' */
- "\377" /* placeholder */,
+ "\377 \0" /* placeholder */,
/* Colors starting with 'v' */
- "iolet\0 \356\202\356",
+ "iolet\0 \356\202\356\0",
"ioletRed\0 \213\042\122\315\062\170\356\072\214\377\076\226\320\040\220\4",
/* Colors starting with 'w' */
"heat\0 \213\176\146\315\272\226\356\330\256\377\347\272\365\336\263\4",
- "hite\0 \377\377\377",
- "hiteSmoke\0 \365\365\365",
+ "hite\0 \377\377\377\0",
+ "hiteSmoke\0 \365\365\365\0",
/* Colors starting with 'x' */
- "\377" /* placeholder */,
+ "\377 \0" /* placeholder */,
/* Colors starting with 'y' */
"ellow\0 \213\213\000\315\315\000\356\356\000\377\377\000\377\377\000\4",
"ellowGreen\0 \232\315\062\0"
@@ -341,6 +341,9 @@ XParseColor(
const char *spec,
XColor *colorPtr)
{
+ (void)display;
+ (void)map;
+
if (spec[0] == '#') {
char *p;
Tcl_WideInt value = parseHex64bit(++spec, &p);
diff --git a/xlib/xgc.c b/xlib/xgc.c
index a1308f9..ed12f4b 100644
--- a/xlib/xgc.c
+++ b/xlib/xgc.c
@@ -24,12 +24,9 @@
# include <tkMacOSXInt.h>
# include <X11/Xlib.h>
# include <X11/X.h>
-# define Cursor XCursor
-# define Region XRegion
# define gcCacheSize sizeof(TkpGCCache)
#endif
-#undef TkSetRegion
/*
*----------------------------------------------------------------------
@@ -51,7 +48,7 @@ static TkpClipMask *AllocClipMask(GC gc) {
TkpClipMask *clip_mask = (TkpClipMask*) gc->clip_mask;
if (clip_mask == NULL) {
- clip_mask = ckalloc(sizeof(TkpClipMask));
+ clip_mask = (TkpClipMask *)ckalloc(sizeof(TkpClipMask));
gc->clip_mask = (Pixmap) clip_mask;
#ifdef MAC_OSX_TK
} else if (clip_mask->type == TKP_CLIP_REGION) {
@@ -113,17 +110,18 @@ XCreateGC(
XGCValues *values)
{
GC gp;
+ (void)d;
/*
* In order to have room for a dash list, MAX_DASH_LIST_SIZE extra chars
* are defined, which is invisible from the outside. The list is assumed
- * to end with a 0-char, so this must be set explicitely during
+ * to end with a 0-char, so this must be set explicitly during
* initialization.
*/
#define MAX_DASH_LIST_SIZE 10
- gp = ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize);
+ gp = (GC)ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize);
if (!gp) {
return NULL;
}
@@ -144,11 +142,11 @@ XCreateGC(
InitField(fill_style, GCFillStyle, FillSolid);
InitField(fill_rule, GCFillRule, WindingRule);
InitField(arc_mode, GCArcMode, ArcPieSlice);
- InitField(tile, GCTile, None);
- InitField(stipple, GCStipple, None);
+ InitField(tile, GCTile, 0);
+ InitField(stipple, GCStipple, 0);
InitField(ts_x_origin, GCTileStipXOrigin, 0);
InitField(ts_y_origin, GCTileStipYOrigin, 0);
- InitField(font, GCFont, None);
+ InitField(font, GCFont, 0);
InitField(subwindow_mode, GCSubwindowMode, ClipByChildren);
InitField(graphics_exposures, GCGraphicsExposures, True);
InitField(clip_x_origin, GCClipXOrigin, 0);
@@ -268,6 +266,8 @@ int XFreeGC(
Display *d,
GC gc)
{
+ (void)d;
+
if (gc != NULL) {
FreeClipMask(gc);
TkpFreeGCCache(gc);
@@ -299,6 +299,8 @@ XSetForeground(
GC gc,
unsigned long foreground)
{
+ (void)display;
+
gc->foreground = foreground;
return Success;
}
@@ -309,6 +311,8 @@ XSetBackground(
GC gc,
unsigned long background)
{
+ (void)display;
+
gc->background = background;
return Success;
}
@@ -322,6 +326,7 @@ XSetDashes(
int n)
{
char *p = &(gc->dashes);
+ (void)display;
#ifdef TkWinDeleteBrush
TkWinDeleteBrush(gc->fgBrush);
@@ -344,6 +349,8 @@ XSetFunction(
GC gc,
int function)
{
+ (void)display;
+
gc->function = function;
return Success;
}
@@ -354,6 +361,8 @@ XSetFillRule(
GC gc,
int fill_rule)
{
+ (void)display;
+
gc->fill_rule = fill_rule;
return Success;
}
@@ -364,6 +373,8 @@ XSetFillStyle(
GC gc,
int fill_style)
{
+ (void)display;
+
gc->fill_style = fill_style;
return Success;
}
@@ -374,6 +385,8 @@ XSetTSOrigin(
GC gc,
int x, int y)
{
+ (void)display;
+
gc->ts_x_origin = x;
gc->ts_y_origin = y;
return Success;
@@ -385,6 +398,8 @@ XSetFont(
GC gc,
Font font)
{
+ (void)display;
+
gc->font = font;
return Success;
}
@@ -395,6 +410,8 @@ XSetArcMode(
GC gc,
int arc_mode)
{
+ (void)display;
+
gc->arc_mode = arc_mode;
return Success;
}
@@ -405,6 +422,8 @@ XSetStipple(
GC gc,
Pixmap stipple)
{
+ (void)display;
+
gc->stipple = stipple;
return Success;
}
@@ -418,6 +437,8 @@ XSetLineAttributes(
int cap_style,
int join_style)
{
+ (void)display;
+
gc->line_width = line_width;
gc->line_style = line_style;
gc->cap_style = cap_style;
@@ -432,6 +453,8 @@ XSetClipOrigin(
int clip_x_origin,
int clip_y_origin)
{
+ (void)display;
+
gc->clip_x_origin = clip_x_origin;
gc->clip_y_origin = clip_y_origin;
return Success;
@@ -453,17 +476,19 @@ XSetClipOrigin(
* None.
*
* Side effects:
- * Allocates or dealloates a TkpClipMask.
+ * Allocates or deallocates a TkpClipMask.
*
*----------------------------------------------------------------------
*/
-void
+int
TkSetRegion(
Display *display,
GC gc,
TkRegion r)
{
+ (void)display;
+
if (r == NULL) {
Tcl_Panic("must not pass NULL to TkSetRegion for compatibility with X11; use XSetClipMask instead");
} else {
@@ -475,6 +500,7 @@ TkSetRegion(
TkpRetainRegion(r);
#endif
}
+ return Success;
}
int
@@ -483,6 +509,8 @@ XSetClipMask(
GC gc,
Pixmap pixmap)
{
+ (void)display;
+
if (pixmap == None) {
FreeClipMask(gc);
} else {
@@ -541,6 +569,7 @@ XDrawPoints(
int mode)
{
int res = Success;
+ (void)mode;
while (npoints-- > 0) {
res = XDrawLine(display, d, gc,
@@ -560,17 +589,26 @@ XDrawSegments(
XSegment *segments,
int nsegments)
{
+ (void)display;
+ (void)d;
+ (void)gc;
+ (void)segments;
+ (void)nsegments;
+
return BadDrawable;
}
#endif
-#if 0
char *
XFetchBuffer(
Display *display,
int *nbytes_return,
int buffer)
{
+ (void)display;
+ (void)nbytes_return;
+ (void)buffer;
+
return (char *) 0;
}
@@ -580,7 +618,11 @@ XFetchName(
Window w,
char **window_name_return)
{
- return (Status) 0;
+ (void)display;
+ (void)w;
+ (void)window_name_return;
+
+ return Success;
}
Atom *
@@ -589,32 +631,25 @@ XListProperties(
Window w,
int *num_prop_return)
{
+ (void)display;
+ (void)w;
+ (void)num_prop_return;
+
return (Atom *) 0;
}
-void
+int
XMapRaised(
Display *display,
Window w)
{
-}
+ (void)display;
+ (void)w;
-void
-XPutImage(
- Display *display,
- Drawable d,
- GC gc,
- XImage *image,
- int src_x,
- int src_y,
- int dest_x,
- int dest_y,
- unsigned int width,
- unsigned int height)
-{
+ return Success;
}
-void
+int
XQueryTextExtents(
Display *display,
XID font_ID,
@@ -625,9 +660,19 @@ XQueryTextExtents(
int *font_descent_return,
XCharStruct *overall_return)
{
+ (void)display;
+ (void)font_ID;
+ (void)string;
+ (void)nchars;
+ (void)direction_return;
+ (void)font_ascent_return;
+ (void)font_descent_return;
+ (void)overall_return;
+
+ return Success;
}
-void
+int
XReparentWindow(
Display *display,
Window w,
@@ -635,32 +680,298 @@ XReparentWindow(
int x,
int y)
{
+ (void)display;
+ (void)w;
+ (void)parent;
+ (void)x;
+ (void)y;
+
+ return BadWindow;
}
-void
-XRotateBuffers(
+int
+XUndefineCursor(
Display *display,
- int rotate)
+ Window w)
{
+ (void)display;
+ (void)w;
+
+ return Success;
+}
+
+XVaNestedList
+XVaCreateNestedList(
+ int unused, ...)
+{
+ (void)unused;
+ return NULL;
+}
+
+char *
+XSetICValues(
+ XIC xic, ...)
+{
+ (void)xic;
+ return NULL;
+}
+
+char *
+XGetICValues(
+ XIC xic, ...)
+{
+ (void)xic;
+ return NULL;
}
void
-XStoreBuffer(
+XSetICFocus(
+ XIC xic)
+{
+ (void)xic;
+}
+
+Window
+XCreateWindow(
Display *display,
- _Xconst char *bytes,
- int nbytes,
- int buffer)
+ Window parent,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height,
+ unsigned int border_width,
+ int depth,
+ unsigned int clazz,
+ Visual *visual,
+ unsigned long value_mask,
+ XSetWindowAttributes *attributes)
+{
+ (void)display;
+ (void)parent;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)border_width;
+ (void)depth;
+ (void)clazz;
+ (void)visual;
+ (void)value_mask;
+ (void)attributes;
+
+ return 0;
+}
+
+int
+XPointInRegion(
+ Region rgn,
+ int x,
+ int y)
{
+ (void)rgn;
+ (void)x;
+ (void)y;
+
+ return 0;
}
+int
+XUnionRegion(
+ Region srca,
+ Region srcb,
+ Region dr_return)
+{
+ (void)srca;
+ (void)srcb;
+ (void)dr_return;
+
+ return 0;
+}
+
+Region
+XPolygonRegion(
+ XPoint *pts,
+ int n,
+ int rule)
+{
+ (void)pts;
+ (void)n;
+ (void)rule;
+
+ return 0;
+}
+
void
-XUndefineCursor(
+XDestroyIC(
+ XIC ic)
+{
+ (void)ic;
+}
+
+Cursor
+XCreatePixmapCursor(
Display *display,
- Window w)
+ Pixmap source,
+ Pixmap mask,
+ XColor *foreground_color,
+ XColor *background_color,
+ unsigned int x,
+ unsigned int y)
{
+ (void)display;
+ (void)source;
+ (void)mask;
+ (void)foreground_color;
+ (void)background_color;
+ (void)x;
+ (void)y;
+
+ return (Cursor) NULL;
}
-#endif
-
+
+Cursor
+XCreateGlyphCursor(
+ Display *display,
+ Font source_font,
+ Font mask_font,
+ unsigned int source_char,
+ unsigned int mask_char,
+ XColor _Xconst *foreground_color,
+ XColor _Xconst *background_color)
+{
+ (void)display;
+ (void)source_font;
+ (void)mask_font;
+ (void)source_char;
+ (void)mask_char;
+ (void)foreground_color;
+ (void)background_color;
+
+ return 1;
+}
+
+XFontSet
+XCreateFontSet(
+ Display *display /* display */,
+ _Xconst char *base_font_name_list /* base_font_name_list */,
+ char ***missing_charset_list /* missing_charset_list */,
+ int *missing_charset_count /* missing_charset_count */,
+ char **def_string /* def_string */
+) {
+ (void)display;
+ (void)base_font_name_list;
+ (void)missing_charset_list;
+ (void)missing_charset_count;
+ (void)def_string;
+
+ return (XFontSet)0;
+}
+
+void
+XFreeFontSet(
+ Display *display, /* display */
+ XFontSet fontset /* font_set */
+) {
+ (void)display;
+ (void)fontset;
+}
+
+void
+XFreeStringList(
+ char **list /* list */
+) {
+ (void)list;
+}
+
+Status
+XCloseIM(
+ XIM im /* im */
+) {
+ (void)im;
+
+ return Success;
+}
+
+Bool
+XRegisterIMInstantiateCallback(
+ Display *dpy /* dpy */,
+ struct _XrmHashBucketRec *rdb /* rdb */,
+ char *res_name /* res_name */,
+ char *res_class /* res_class */,
+ XIDProc callback /* callback */,
+ XPointer client_data /* client_data */
+) {
+ (void)dpy;
+ (void)rdb;
+ (void)res_name;
+ (void)res_class;
+ (void)callback;
+ (void)client_data;
+
+ return False;
+}
+
+Bool
+XUnregisterIMInstantiateCallback(
+ Display *dpy /* dpy */,
+ struct _XrmHashBucketRec *rdb /* rdb */,
+ char *res_name /* res_name */,
+ char *res_class /* res_class */,
+ XIDProc callback /* callback */,
+ XPointer client_data /* client_data */
+) {
+ (void)dpy;
+ (void)rdb;
+ (void)res_name;
+ (void)res_class;
+ (void)callback;
+ (void)client_data;
+
+ return False;
+}
+
+char *
+XSetLocaleModifiers(
+ const char *modifier_list /* modifier_list */
+) {
+ (void)modifier_list;
+
+ return NULL;
+}
+
+XIM XOpenIM(
+ Display *dpy /* dpy */,
+ struct _XrmHashBucketRec *rdb /* rdb */,
+ char *res_name /* res_name */,
+ char *res_class /* res_class */
+) {
+ (void)dpy;
+ (void)rdb;
+ (void)res_name;
+ (void)res_class;
+
+ return NULL;
+}
+
+char *
+XGetIMValues(
+ XIM im /* im */, ...
+) {
+ (void)im;
+
+ return NULL;
+}
+
+char *
+XSetIMValues(
+ XIM im /* im */, ...
+) {
+ (void)im;
+
+ return NULL;
+}
+
+
/*
* Local Variables:
* mode: c
diff --git a/xlib/xutil.c b/xlib/xutil.c
index 1e81549..a5f3b99 100644
--- a/xlib/xutil.c
+++ b/xlib/xutil.c
@@ -36,6 +36,8 @@ XInternAtom(
Bool only_if_exists)
{
static Atom atom = XA_LAST_PREDEFINED;
+ (void)atom_name;
+ (void)only_if_exists;
display->request++;
return ++atom;
@@ -64,13 +66,13 @@ XGetVisualInfo(
XVisualInfo *vinfo_template,
int *nitems_return)
{
- XVisualInfo *info = ckalloc(sizeof(XVisualInfo));
+ XVisualInfo *info = (XVisualInfo *)ckalloc(sizeof(XVisualInfo));
info->visual = DefaultVisual(display, 0);
info->visualid = info->visual->visualid;
info->screen = 0;
info->depth = info->visual->bits_per_rgb;
- info->class = info->visual->class;
+ info->c_class = info->visual->c_class;
info->colormap_size = info->visual->map_entries;
info->bits_per_rgb = info->visual->bits_per_rgb;
info->red_mask = info->visual->red_mask;
@@ -84,7 +86,7 @@ XGetVisualInfo(
|| ((vinfo_mask & VisualDepthMask)
&& (vinfo_template->depth != info->depth))
|| ((vinfo_mask & VisualClassMask)
- && (vinfo_template->class != info->class))
+ && (vinfo_template->c_class != info->c_class))
|| ((vinfo_mask & VisualColormapSizeMask)
&& (vinfo_template->colormap_size != info->colormap_size))
|| ((vinfo_mask & VisualBitsPerRGBMask)