From c709ff98b014a66934671dcece6d2b26d5101b1a Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Tue, 24 Sep 2002 20:37:56 +0000 Subject: import tk 8.4.0 --- tk/ChangeLog | 9299 +++++++++++++++++++++++---------- tk/README | 26 +- tk/changes | 386 ++ tk/compat/limits.h | 1 - tk/compat/stdlib.h | 1 - tk/compat/unistd.h | 1 - tk/doc/3DBorder.3 | 3 +- tk/doc/AddOption.3 | 4 +- tk/doc/BindTable.3 | 5 +- tk/doc/CanvPsY.3 | 11 +- tk/doc/CanvTkwin.3 | 3 +- tk/doc/CanvTxtInfo.3 | 1 - tk/doc/Clipboard.3 | 1 - tk/doc/ClrSelect.3 | 1 - tk/doc/ConfigWidg.3 | 16 +- tk/doc/ConfigWind.3 | 1 - tk/doc/CoordToWin.3 | 1 - tk/doc/CrtCmHdlr.3 | 69 + tk/doc/CrtErrHdlr.3 | 1 - tk/doc/CrtGenHdlr.3 | 1 - tk/doc/CrtImgType.3 | 7 +- tk/doc/CrtItemType.3 | 4 +- tk/doc/CrtPhImgFmt.3 | 2 - tk/doc/CrtSelHdlr.3 | 1 - tk/doc/CrtWindow.3 | 20 +- tk/doc/DeleteImg.3 | 3 +- tk/doc/DrawFocHlt.3 | 2 - tk/doc/EventHndlr.3 | 1 - tk/doc/FindPhoto.3 | 39 +- tk/doc/FontId.3 | 5 +- tk/doc/FreeXId.3 | 1 - tk/doc/GeomReq.3 | 39 +- tk/doc/GetAnchor.3 | 5 +- tk/doc/GetBitmap.3 | 7 +- tk/doc/GetCapStyl.3 | 5 +- tk/doc/GetClrmap.3 | 3 +- tk/doc/GetColor.3 | 3 +- tk/doc/GetCursor.3 | 7 +- tk/doc/GetDash.3 | 1 - tk/doc/GetFont.3 | 8 +- tk/doc/GetGC.3 | 1 - tk/doc/GetHWND.3 | 2 +- tk/doc/GetImage.3 | 3 +- tk/doc/GetJoinStl.3 | 5 +- tk/doc/GetJustify.3 | 5 +- tk/doc/GetOption.3 | 5 +- tk/doc/GetPixels.3 | 3 +- tk/doc/GetPixmap.3 | 1 - tk/doc/GetRelief.3 | 5 +- tk/doc/GetRootCrd.3 | 1 - tk/doc/GetScroll.3 | 4 +- tk/doc/GetSelect.3 | 1 - tk/doc/GetUid.3 | 1 - tk/doc/GetVRoot.3 | 1 - tk/doc/GetVisual.3 | 3 +- tk/doc/HWNDToWindow.3 | 2 +- tk/doc/HandleEvent.3 | 1 - tk/doc/IdToWindow.3 | 1 - tk/doc/ImgChanged.3 | 1 - tk/doc/InternAtom.3 | 5 +- tk/doc/MainLoop.3 | 1 - tk/doc/MainWin.3 | 2 - tk/doc/MaintGeom.3 | 4 +- tk/doc/ManageGeom.3 | 1 - tk/doc/MapWindow.3 | 1 - tk/doc/MeasureChar.3 | 1 - tk/doc/MoveToplev.3 | 1 - tk/doc/Name.3 | 3 +- tk/doc/NameOfImg.3 | 3 +- tk/doc/OwnSelect.3 | 1 - tk/doc/ParseArgv.3 | 3 +- tk/doc/QWinEvent.3 | 26 +- tk/doc/Restack.3 | 1 - tk/doc/RestrictEv.3 | 1 - tk/doc/SetAppName.3 | 5 +- tk/doc/SetCaret.3 | 40 + tk/doc/SetClass.3 | 1 - tk/doc/SetClassProcs.3 | 91 + tk/doc/SetGrid.3 | 1 - tk/doc/SetOptions.3 | 166 +- tk/doc/SetVisual.3 | 1 - tk/doc/StrictMotif.3 | 1 - tk/doc/TextLayout.3 | 1 - tk/doc/TkInitStubs.3 | 10 +- tk/doc/Tk_Init.3 | 50 +- tk/doc/Tk_Main.3 | 1 - tk/doc/WindowId.3 | 38 +- tk/doc/bell.n | 12 +- tk/doc/bind.n | 69 +- tk/doc/bindtags.n | 1 - tk/doc/bitmap.n | 1 - tk/doc/button.n | 35 +- tk/doc/canvas.n | 85 +- tk/doc/checkbutton.n | 35 +- tk/doc/chooseColor.n | 1 - tk/doc/chooseDirectory.n | 1 - tk/doc/clipboard.n | 18 +- tk/doc/colors.n | 24 +- tk/doc/console.n | 142 + tk/doc/destroy.n | 1 - tk/doc/dialog.n | 1 - tk/doc/entry.n | 53 +- tk/doc/event.n | 6 +- tk/doc/focus.n | 1 - tk/doc/focusNext.n | 1 - tk/doc/font.n | 3 +- tk/doc/frame.n | 13 +- tk/doc/getOpenFile.n | 14 +- tk/doc/grab.n | 1 - tk/doc/grid.n | 71 +- tk/doc/image.n | 9 +- tk/doc/label.n | 18 +- tk/doc/labelframe.n | 147 + tk/doc/listbox.n | 51 +- tk/doc/loadTk.n | 7 +- tk/doc/lower.n | 1 - tk/doc/man.macros | 2 +- tk/doc/menu.n | 31 +- tk/doc/menubar.n | 1 - tk/doc/menubutton.n | 23 +- tk/doc/message.n | 11 +- tk/doc/messageBox.n | 6 +- tk/doc/option.n | 1 - tk/doc/optionMenu.n | 1 - tk/doc/options.n | 5 +- tk/doc/pack-old.n | 1 - tk/doc/pack.n | 7 +- tk/doc/palette.n | 1 - tk/doc/panedwindow.n | 246 + tk/doc/photo.n | 58 +- tk/doc/place.n | 208 +- tk/doc/popup.n | 1 - tk/doc/radiobutton.n | 36 +- tk/doc/raise.n | 1 - tk/doc/scale.n | 10 +- tk/doc/scrollbar.n | 10 +- tk/doc/selection.n | 7 +- tk/doc/send.n | 1 - tk/doc/spinbox.n | 582 +++ tk/doc/text.n | 192 +- tk/doc/tk.n | 27 +- tk/doc/tkerror.n | 1 - tk/doc/tkvars.n | 15 +- tk/doc/tkwait.n | 1 - tk/doc/toplevel.n | 17 +- tk/doc/winfo.n | 9 +- tk/doc/wish.1 | 1 - tk/doc/wm.n | 63 +- tk/generic/default.h | 5 +- tk/generic/ks_names.h | 2 - tk/generic/prolog.ps | 1 - tk/generic/tk.decls | 587 ++- tk/generic/tk.h | 352 +- tk/generic/tk3d.c | 25 +- tk/generic/tk3d.h | 1 - tk/generic/tkArgv.c | 18 +- tk/generic/tkAtom.c | 7 +- tk/generic/tkBind.c | 236 +- tk/generic/tkBitmap.c | 34 +- tk/generic/tkButton.c | 126 +- tk/generic/tkButton.h | 39 +- tk/generic/tkCanvArc.c | 79 +- tk/generic/tkCanvBmap.c | 66 +- tk/generic/tkCanvImg.c | 5 +- tk/generic/tkCanvLine.c | 106 +- tk/generic/tkCanvPoly.c | 112 +- tk/generic/tkCanvPs.c | 346 +- tk/generic/tkCanvText.c | 83 +- tk/generic/tkCanvUtil.c | 18 +- tk/generic/tkCanvWind.c | 80 +- tk/generic/tkCanvas.c | 168 +- tk/generic/tkCanvas.h | 3 +- tk/generic/tkClipboard.c | 336 +- tk/generic/tkCmds.c | 516 +- tk/generic/tkColor.c | 15 +- tk/generic/tkColor.h | 24 - tk/generic/tkConfig.c | 271 +- tk/generic/tkConsole.c | 52 +- tk/generic/tkCursor.c | 30 +- tk/generic/tkDecls.h | 457 +- tk/generic/tkEntry.c | 2185 +++++++- tk/generic/tkError.c | 1 - tk/generic/tkEvent.c | 428 +- tk/generic/tkFileFilter.c | 25 +- tk/generic/tkFileFilter.h | 1 - tk/generic/tkFocus.c | 52 +- tk/generic/tkFont.c | 199 +- tk/generic/tkFont.h | 6 - tk/generic/tkFrame.c | 1310 ++++- tk/generic/tkGC.c | 58 +- tk/generic/tkGeometry.c | 143 +- tk/generic/tkGet.c | 59 +- tk/generic/tkGrab.c | 274 +- tk/generic/tkGrid.c | 1790 ++++--- tk/generic/tkImage.c | 105 +- tk/generic/tkImgBmap.c | 193 +- tk/generic/tkImgGIF.c | 1280 ++--- tk/generic/tkImgPPM.c | 8 +- tk/generic/tkImgPhoto.c | 1285 +++-- tk/generic/tkImgUtil.c | 1 - tk/generic/tkInitScript.h | 11 +- tk/generic/tkInt.decls | 780 ++- tk/generic/tkInt.h | 246 +- tk/generic/tkIntDecls.h | 492 +- tk/generic/tkIntPlatDecls.h | 783 ++- tk/generic/tkIntXlibDecls.h | 1124 +++- tk/generic/tkListbox.c | 726 ++- tk/generic/tkMacWinMenu.c | 1 - tk/generic/tkMain.c | 37 +- tk/generic/tkMenu.c | 122 +- tk/generic/tkMenu.h | 13 +- tk/generic/tkMenuDraw.c | 28 +- tk/generic/tkMenubutton.c | 75 +- tk/generic/tkMenubutton.h | 11 +- tk/generic/tkMessage.c | 376 +- tk/generic/tkObj.c | 314 +- tk/generic/tkOldConfig.c | 43 +- tk/generic/tkOption.c | 260 +- tk/generic/tkPack.c | 626 ++- tk/generic/tkPanedWindow.c | 2752 ++++++++++ tk/generic/tkPlace.c | 749 +-- tk/generic/tkPlatDecls.h | 94 +- tk/generic/tkPointer.c | 11 +- tk/generic/tkPort.h | 3 +- tk/generic/tkRectOval.c | 79 +- tk/generic/tkScale.c | 47 +- tk/generic/tkScale.h | 2 - tk/generic/tkScrollbar.c | 13 +- tk/generic/tkScrollbar.h | 3 +- tk/generic/tkSelect.c | 674 ++- tk/generic/tkSelect.h | 1 - tk/generic/tkSquare.c | 79 +- tk/generic/tkStubImg.c | 3 +- tk/generic/tkStubInit.c | 386 +- tk/generic/tkStubLib.c | 15 +- tk/generic/tkStyle.c | 1664 ++++++ tk/generic/tkTest.c | 252 +- tk/generic/tkText.c | 940 +++- tk/generic/tkText.h | 92 +- tk/generic/tkTextBTree.c | 5 +- tk/generic/tkTextDisp.c | 63 +- tk/generic/tkTextImage.c | 15 +- tk/generic/tkTextIndex.c | 77 +- tk/generic/tkTextMark.c | 29 +- tk/generic/tkTextTag.c | 58 +- tk/generic/tkTextWind.c | 23 +- tk/generic/tkTrig.c | 1 - tk/generic/tkUndo.c | 400 ++ tk/generic/tkUndo.h | 90 + tk/generic/tkUtil.c | 18 +- tk/generic/tkVisual.c | 7 +- tk/generic/tkWindow.c | 613 ++- tk/library/bgerror.tcl | 332 +- tk/library/button.tcl | 515 +- tk/library/choosedir.tcl | 49 +- tk/library/clrpick.tcl | 326 +- tk/library/comdlg.tcl | 110 +- tk/library/console.tcl | 841 ++- tk/library/demos/README | 1 - tk/library/demos/arrow.tcl | 88 +- tk/library/demos/bind.tcl | 1 - tk/library/demos/bitmap.tcl | 1 - tk/library/demos/browse | 33 +- tk/library/demos/button.tcl | 1 - tk/library/demos/check.tcl | 1 - tk/library/demos/clrpick.tcl | 3 +- tk/library/demos/colors.tcl | 1 - tk/library/demos/cscroll.tcl | 15 +- tk/library/demos/ctext.tcl | 38 +- tk/library/demos/dialog1.tcl | 1 - tk/library/demos/dialog2.tcl | 3 +- tk/library/demos/entry1.tcl | 1 - tk/library/demos/entry2.tcl | 1 - tk/library/demos/entry3.tcl | 187 + tk/library/demos/filebox.tcl | 5 +- tk/library/demos/floor.tcl | 3 +- tk/library/demos/form.tcl | 1 - tk/library/demos/hello | 3 + tk/library/demos/hscale.tcl | 3 +- tk/library/demos/icon.tcl | 1 - tk/library/demos/image1.tcl | 1 - tk/library/demos/image2.tcl | 47 +- tk/library/demos/items.tcl | 3 +- tk/library/demos/ixset | 134 +- tk/library/demos/label.tcl | 1 - tk/library/demos/labelframe.tcl | 80 + tk/library/demos/menu.tcl | 13 +- tk/library/demos/menubu.tcl | 4 +- tk/library/demos/msgbox.tcl | 1 - tk/library/demos/paned1.tcl | 34 + tk/library/demos/paned2.tcl | 76 + tk/library/demos/plot.tcl | 16 +- tk/library/demos/puzzle.tcl | 22 +- tk/library/demos/radio.tcl | 40 +- tk/library/demos/rmt | 32 +- tk/library/demos/rolodex | 77 +- tk/library/demos/ruler.tcl | 17 +- tk/library/demos/sayings.tcl | 1 - tk/library/demos/search.tcl | 1 - tk/library/demos/spin.tcl | 55 + tk/library/demos/square | 1 - tk/library/demos/states.tcl | 1 - tk/library/demos/style.tcl | 1 - tk/library/demos/tcolor | 277 +- tk/library/demos/text.tcl | 17 +- tk/library/demos/timer | 32 +- tk/library/demos/twind.tcl | 20 +- tk/library/demos/vscale.tcl | 3 +- tk/library/demos/widget | 233 +- tk/library/dialog.tcl | 45 +- tk/library/entry.tcl | 289 +- tk/library/focus.tcl | 24 +- tk/library/images/README | 1 - tk/library/listbox.tcl | 158 +- tk/library/menu.tcl | 563 +- tk/library/mkpsenc.tcl | 1367 +++++ tk/library/msgbox.tcl | 159 +- tk/library/msgs/cs.msg | 70 + tk/library/msgs/de.msg | 70 + tk/library/msgs/el.msg | 86 + tk/library/msgs/en.msg | 70 + tk/library/msgs/en_gb.msg | 3 + tk/library/msgs/es.msg | 70 + tk/library/msgs/fr.msg | 70 + tk/library/msgs/it.msg | 70 + tk/library/msgs/nl.msg | 106 + tk/library/msgs/ru.msg | 73 + tk/library/obsolete.tcl | 1 - tk/library/optMenu.tcl | 5 +- tk/library/palette.tcl | 63 +- tk/library/panedwindow.tcl | 181 + tk/library/safetk.tcl | 4 +- tk/library/scale.tcl | 130 +- tk/library/scrlbar.tcl | 206 +- tk/library/spinbox.tcl | 568 ++ tk/library/tclIndex | 448 +- tk/library/tearoff.tcl | 13 +- tk/library/text.tcl | 461 +- tk/library/tk.tcl | 363 +- tk/library/tkfbox.tcl | 998 ++-- tk/library/unsupported.tcl | 297 ++ tk/library/xmfbox.tcl | 486 +- tk/mac/MW_TkBuildLibHeader.h | 7 + tk/mac/MW_TkBuildLibHeader.pch | 36 + tk/mac/MW_TkHeader.h | 50 +- tk/mac/MW_TkHeader.pch | 28 +- tk/mac/MW_TkHeaderCommon.h | 40 + tk/mac/MW_TkOldImgHeader.h | 2 +- tk/mac/MW_TkOldImgStaticHeader.h | 3 + tk/mac/MW_TkStaticHeader.h | 7 + tk/mac/MW_TkStaticHeader.pch | 36 + tk/mac/MW_TkTestHeader.pch | 34 +- tk/mac/README | 16 +- tk/mac/tclets.r | 262 +- tk/mac/tclets.tcl | 89 +- tk/mac/tkMac.h | 29 +- tk/mac/tkMacAppInit.c | 57 +- tk/mac/tkMacAppearanceStubs.c | 2 - tk/mac/tkMacApplication.r | 50 +- tk/mac/tkMacBitmap.c | 3 +- tk/mac/tkMacButton.c | 322 +- tk/mac/tkMacClipboard.c | 1 - tk/mac/tkMacColor.c | 1 - tk/mac/tkMacConfig.c | 5 +- tk/mac/tkMacCursor.c | 11 +- tk/mac/tkMacCursors.r | 1 - tk/mac/tkMacDefault.h | 68 +- tk/mac/tkMacDialog.c | 35 +- tk/mac/tkMacDraw.c | 4 +- tk/mac/tkMacEmbed.c | 5 +- tk/mac/tkMacFont.c | 9 +- tk/mac/tkMacHLEvents.c | 5 +- tk/mac/tkMacInit.c | 117 +- tk/mac/tkMacInt.h | 27 +- tk/mac/tkMacKeyboard.c | 2 - tk/mac/tkMacLibrary.r | 448 +- tk/mac/tkMacMDEF.c | 1 - tk/mac/tkMacMDEF.r | 31 +- tk/mac/tkMacMenu.c | 199 +- tk/mac/tkMacMenu.r | 1 - tk/mac/tkMacMenubutton.c | 169 +- tk/mac/tkMacMenus.c | 12 +- tk/mac/tkMacPort.h | 20 +- tk/mac/tkMacProjects.sea.hqx | 6419 +++++++++++++---------- tk/mac/tkMacRegion.c | 29 + tk/mac/tkMacResource.r | 78 +- tk/mac/tkMacScale.c | 2 - tk/mac/tkMacScrlbr.c | 38 +- tk/mac/tkMacSend.c | 7 +- tk/mac/tkMacSubwindows.c | 11 +- tk/mac/tkMacTclCode.r | 71 + tk/mac/tkMacTest.c | 1 - tk/mac/tkMacWindowMgr.c | 18 +- tk/mac/tkMacWm.c | 3445 ++++++++---- tk/mac/tkMacXCursors.r | 1 - tk/mac/tkMacXStubs.c | 30 +- tk/mac/widget.r | 18 + tk/macosx/Makefile | 86 + tk/macosx/Wish.icns | Bin 0 -> 35960 bytes tk/macosx/Wish.pbproj/jingham.pbxuser | 1502 ++++++ tk/macosx/Wish.pbproj/project.pbxproj | 3619 +++++++++++++ tk/macosx/tclets.r | 172 + tk/macosx/tkAboutDlg.r | 393 ++ tk/macosx/tkMacOSX.h | 34 + tk/macosx/tkMacOSXAppInit.c | 241 + tk/macosx/tkMacOSXApplication.r | 276 + tk/macosx/tkMacOSXBitmap.c | 283 + tk/macosx/tkMacOSXButton.c | 1580 ++++++ tk/macosx/tkMacOSXClipboard.c | 321 ++ tk/macosx/tkMacOSXColor.c | 448 ++ tk/macosx/tkMacOSXConfig.c | 46 + tk/macosx/tkMacOSXCursor.c | 406 ++ tk/macosx/tkMacOSXCursors.r | 130 + tk/macosx/tkMacOSXDebug.c | 439 ++ tk/macosx/tkMacOSXDebug.h | 69 + tk/macosx/tkMacOSXDefault.h | 531 ++ tk/macosx/tkMacOSXDialog.c | 1229 +++++ tk/macosx/tkMacOSXDraw.c | 1714 ++++++ tk/macosx/tkMacOSXEmbed.c | 1193 +++++ tk/macosx/tkMacOSXEvent.c | 276 + tk/macosx/tkMacOSXEvent.h | 86 + tk/macosx/tkMacOSXFont.c | 2191 ++++++++ tk/macosx/tkMacOSXHLEvents.c | 447 ++ tk/macosx/tkMacOSXInit.c | 221 + tk/macosx/tkMacOSXInt.h | 155 + tk/macosx/tkMacOSXKeyEvent.c | 501 ++ tk/macosx/tkMacOSXKeyboard.c | 682 +++ tk/macosx/tkMacOSXLibrary.r | 510 ++ tk/macosx/tkMacOSXMenu.c | 4691 +++++++++++++++++ tk/macosx/tkMacOSXMenu.r | 47 + tk/macosx/tkMacOSXMenubutton.c | 861 +++ tk/macosx/tkMacOSXMenus.c | 325 ++ tk/macosx/tkMacOSXMouseEvent.c | 740 +++ tk/macosx/tkMacOSXNotify.c | 1162 ++++ tk/macosx/tkMacOSXPort.h | 154 + tk/macosx/tkMacOSXRegion.c | 252 + tk/macosx/tkMacOSXResource.r | 502 ++ tk/macosx/tkMacOSXScale.c | 431 ++ tk/macosx/tkMacOSXScrlbr.c | 1076 ++++ tk/macosx/tkMacOSXSend.c | 552 ++ tk/macosx/tkMacOSXSubwindows.c | 1304 +++++ tk/macosx/tkMacOSXTest.c | 82 + tk/macosx/tkMacOSXUtil.c | 330 ++ tk/macosx/tkMacOSXUtil.h | 65 + tk/macosx/tkMacOSXWindowEvent.c | 693 +++ tk/macosx/tkMacOSXWm.c | 5512 +++++++++++++++++++ tk/macosx/tkMacOSXWm.h | 302 ++ tk/macosx/tkMacOSXXCursors.r | 961 ++++ tk/macosx/tkMacOSXXStubs.c | 862 +++ tk/tests/README | 1 - tk/tests/all.tcl | 77 +- tk/tests/bell.test | 31 +- tk/tests/bgerror.test | 9 +- tk/tests/bind.test | 87 +- tk/tests/bitmap.test | 29 +- tk/tests/border.test | 58 +- tk/tests/button.test | 123 +- tk/tests/canvImg.test | 151 +- tk/tests/canvPs.test | 20 +- tk/tests/canvPsImg.tcl | 3 +- tk/tests/canvRect.test | 15 +- tk/tests/canvText.test | 21 +- tk/tests/canvWind.test | 15 +- tk/tests/canvas.test | 112 +- tk/tests/choosedir.test | 12 +- tk/tests/clipboard.test | 80 +- tk/tests/clrpick.test | 28 +- tk/tests/cmds.test | 11 +- tk/tests/color.test | 97 +- tk/tests/config.test | 499 +- tk/tests/constraints.tcl | 181 + tk/tests/cursor.test | 107 +- tk/tests/dialog.test | 64 + tk/tests/embed.test | 51 + tk/tests/entry.test | 147 +- tk/tests/event.test | 617 ++- tk/tests/filebox.test | 430 +- tk/tests/focus.test | 40 +- tk/tests/focusTcl.test | 49 +- tk/tests/font.test | 94 +- tk/tests/frame.test | 326 +- tk/tests/geometry.test | 12 +- tk/tests/get.test | 13 +- tk/tests/grab.test | 185 + tk/tests/grid.test | 336 +- tk/tests/id.test | 26 +- tk/tests/image.test | 133 +- tk/tests/imgBmap.test | 16 +- tk/tests/imgPPM.test | 18 +- tk/tests/imgPhoto.test | 335 +- tk/tests/listbox.test | 120 +- tk/tests/macEmbed.test | 113 +- tk/tests/macFont.test | 150 +- tk/tests/macMenu.test | 569 +- tk/tests/macWinMenu.test | 32 +- tk/tests/macscrollbar.test | 53 +- tk/tests/main.test | 29 +- tk/tests/menu.test | 135 +- tk/tests/menuDraw.test | 97 +- tk/tests/menubut.test | 55 +- tk/tests/message.test | 125 + tk/tests/msgbox.test | 17 +- tk/tests/obj.test | 17 +- tk/tests/oldpack.test | 11 +- tk/tests/option.test | 20 +- tk/tests/pack.test | 156 +- tk/tests/panedwindow.test | 2392 +++++++++ tk/tests/place.test | 184 +- tk/tests/raise.test | 44 +- tk/tests/safe.test | 74 +- tk/tests/scale.test | 22 +- tk/tests/scrollbar.test | 54 +- tk/tests/select.test | 342 +- tk/tests/send.test | 889 ++-- tk/tests/spinbox.test | 1589 ++++++ tk/tests/text.test | 262 +- tk/tests/textBTree.test | 9 +- tk/tests/textDisp.test | 44 +- tk/tests/textImage.test | 24 +- tk/tests/textIndex.test | 13 +- tk/tests/textMark.test | 94 +- tk/tests/textTag.test | 257 +- tk/tests/textWind.test | 14 +- tk/tests/tk.test | 35 +- tk/tests/unixButton.test | 76 +- tk/tests/unixEmbed.test | 209 +- tk/tests/unixFont.test | 131 +- tk/tests/unixMenu.test | 371 +- tk/tests/unixSelect.test | 17 +- tk/tests/unixWm.test | 404 +- tk/tests/util.test | 15 +- tk/tests/visual.test | 26 +- tk/tests/visual_bb.test | 36 +- tk/tests/winButton.test | 76 +- tk/tests/winClipboard.test | 67 +- tk/tests/winDialog.test | 92 +- tk/tests/winFont.test | 21 +- tk/tests/winMenu.test | 133 +- tk/tests/winSend.test | 172 +- tk/tests/winWm.test | 64 +- tk/tests/window.test | 19 +- tk/tests/winfo.test | 62 +- tk/tests/wm.test | 2196 +++++--- tk/tests/xmfbox.test | 60 +- tk/unix/Makefile.in | 353 +- tk/unix/README | 54 +- tk/unix/aclocal.m4 | 1 - tk/unix/configure | 2492 +++++---- tk/unix/configure.in | 301 +- tk/unix/install-sh | 20 +- tk/unix/mkLinks | 1490 ++++-- tk/unix/tcl.m4 | 1280 +++-- tk/unix/tk.spec | 52 + tk/unix/tkAppInit.c | 15 - tk/unix/tkConfig.sh.in | 14 +- tk/unix/tkUnix.c | 5 +- tk/unix/tkUnix3d.c | 13 +- tk/unix/tkUnixButton.c | 360 +- tk/unix/tkUnixColor.c | 1 - tk/unix/tkUnixConfig.c | 5 +- tk/unix/tkUnixCursor.c | 7 +- tk/unix/tkUnixDefault.h | 69 +- tk/unix/tkUnixDialog.c | 13 +- tk/unix/tkUnixDraw.c | 7 +- tk/unix/tkUnixEmbed.c | 17 +- tk/unix/tkUnixEvent.c | 128 +- tk/unix/tkUnixFocus.c | 1 - tk/unix/tkUnixFont.c | 352 +- tk/unix/tkUnixInit.c | 7 +- tk/unix/tkUnixInt.h | 1 - tk/unix/tkUnixKey.c | 68 +- tk/unix/tkUnixMenu.c | 168 +- tk/unix/tkUnixMenubu.c | 267 +- tk/unix/tkUnixPort.h | 21 +- tk/unix/tkUnixScale.c | 6 +- tk/unix/tkUnixScrlbr.c | 11 +- tk/unix/tkUnixSelect.c | 46 +- tk/unix/tkUnixSend.c | 73 +- tk/unix/tkUnixWm.c | 3902 +++++++++----- tk/unix/tkUnixXId.c | 88 +- tk/win/Makefile.in | 196 +- tk/win/README | 8 +- tk/win/aclocal.m4 | 1 - tk/win/buildall.vc.bat | 37 + tk/win/configure | 1258 ++--- tk/win/configure.in | 142 +- tk/win/lamp.bmp | Bin 0 -> 2102 bytes tk/win/makefile.bc | 875 ++-- tk/win/makefile.vc | 1347 +++-- tk/win/mkd.bat | 36 +- tk/win/nmakehlp.c | 297 ++ tk/win/rc/tk.rc | 115 +- tk/win/rc/tk_base.rc | 261 +- tk/win/rc/wish.exe.manifest | 23 + tk/win/rc/wish.rc | 136 +- tk/win/rmd.bat | 48 +- tk/win/rules.vc | 263 + tk/win/stubs.c | 4 +- tk/win/tcl.m4 | 378 +- tk/win/tkConfig.sh.in | 5 - tk/win/tkWin.h | 1 - tk/win/tkWin32Dll.c | 15 - tk/win/tkWinButton.c | 672 ++- tk/win/tkWinClipboard.c | 2 - tk/win/tkWinColor.c | 2 - tk/win/tkWinConfig.c | 5 +- tk/win/tkWinCursor.c | 76 +- tk/win/tkWinDefault.h | 84 +- tk/win/tkWinDialog.c | 1049 +++- tk/win/tkWinDraw.c | 20 +- tk/win/tkWinEmbed.c | 19 +- tk/win/tkWinFont.c | 49 +- tk/win/tkWinImage.c | 3 +- tk/win/tkWinInit.c | 40 +- tk/win/tkWinInt.h | 35 +- tk/win/tkWinKey.c | 37 +- tk/win/tkWinMenu.c | 214 +- tk/win/tkWinPixmap.c | 1 - tk/win/tkWinPort.h | 19 +- tk/win/tkWinRegion.c | 24 + tk/win/tkWinScrlbr.c | 22 +- tk/win/tkWinSend.c | 4 +- tk/win/tkWinTest.c | 120 +- tk/win/tkWinWindow.c | 51 +- tk/win/tkWinWm.c | 5997 +++++++++++++++------ tk/win/tkWinX.c | 513 +- tk/win/winMain.c | 26 +- tk/xlib/X11/X.h | 8 +- tk/xlib/X11/Xlib.h | 13 +- tk/xlib/X11/Xutil.h | 4 +- tk/xlib/xbytes.h | 1 - tk/xlib/xcolors.c | 1510 +++--- tk/xlib/xdraw.c | 1 - tk/xlib/xgc.c | 12 +- tk/xlib/ximage.c | 3 +- tk/xlib/xutil.c | 1 - 636 files changed, 117752 insertions(+), 33235 deletions(-) create mode 100644 tk/doc/CrtCmHdlr.3 create mode 100644 tk/doc/SetCaret.3 create mode 100644 tk/doc/SetClassProcs.3 create mode 100644 tk/doc/console.n create mode 100644 tk/doc/labelframe.n create mode 100644 tk/doc/panedwindow.n create mode 100644 tk/doc/spinbox.n create mode 100644 tk/generic/tkPanedWindow.c create mode 100644 tk/generic/tkStyle.c create mode 100644 tk/generic/tkUndo.c create mode 100644 tk/generic/tkUndo.h create mode 100644 tk/library/demos/entry3.tcl create mode 100644 tk/library/demos/labelframe.tcl create mode 100644 tk/library/demos/paned1.tcl create mode 100644 tk/library/demos/paned2.tcl create mode 100644 tk/library/demos/spin.tcl create mode 100644 tk/library/mkpsenc.tcl create mode 100644 tk/library/msgs/cs.msg create mode 100644 tk/library/msgs/de.msg create mode 100644 tk/library/msgs/el.msg create mode 100644 tk/library/msgs/en.msg create mode 100644 tk/library/msgs/en_gb.msg create mode 100644 tk/library/msgs/es.msg create mode 100644 tk/library/msgs/fr.msg create mode 100644 tk/library/msgs/it.msg create mode 100644 tk/library/msgs/nl.msg create mode 100644 tk/library/msgs/ru.msg create mode 100644 tk/library/panedwindow.tcl create mode 100644 tk/library/spinbox.tcl create mode 100644 tk/library/unsupported.tcl create mode 100644 tk/mac/MW_TkBuildLibHeader.h create mode 100644 tk/mac/MW_TkBuildLibHeader.pch create mode 100644 tk/mac/MW_TkHeaderCommon.h create mode 100644 tk/mac/MW_TkOldImgStaticHeader.h create mode 100644 tk/mac/MW_TkStaticHeader.h create mode 100644 tk/mac/MW_TkStaticHeader.pch create mode 100644 tk/mac/tkMacTclCode.r create mode 100644 tk/mac/widget.r create mode 100644 tk/macosx/Makefile create mode 100644 tk/macosx/Wish.icns create mode 100644 tk/macosx/Wish.pbproj/jingham.pbxuser create mode 100644 tk/macosx/Wish.pbproj/project.pbxproj create mode 100644 tk/macosx/tclets.r create mode 100644 tk/macosx/tkAboutDlg.r create mode 100644 tk/macosx/tkMacOSX.h create mode 100644 tk/macosx/tkMacOSXAppInit.c create mode 100644 tk/macosx/tkMacOSXApplication.r create mode 100644 tk/macosx/tkMacOSXBitmap.c create mode 100644 tk/macosx/tkMacOSXButton.c create mode 100644 tk/macosx/tkMacOSXClipboard.c create mode 100644 tk/macosx/tkMacOSXColor.c create mode 100644 tk/macosx/tkMacOSXConfig.c create mode 100644 tk/macosx/tkMacOSXCursor.c create mode 100644 tk/macosx/tkMacOSXCursors.r create mode 100644 tk/macosx/tkMacOSXDebug.c create mode 100644 tk/macosx/tkMacOSXDebug.h create mode 100644 tk/macosx/tkMacOSXDefault.h create mode 100644 tk/macosx/tkMacOSXDialog.c create mode 100644 tk/macosx/tkMacOSXDraw.c create mode 100644 tk/macosx/tkMacOSXEmbed.c create mode 100644 tk/macosx/tkMacOSXEvent.c create mode 100644 tk/macosx/tkMacOSXEvent.h create mode 100644 tk/macosx/tkMacOSXFont.c create mode 100644 tk/macosx/tkMacOSXHLEvents.c create mode 100644 tk/macosx/tkMacOSXInit.c create mode 100644 tk/macosx/tkMacOSXInt.h create mode 100644 tk/macosx/tkMacOSXKeyEvent.c create mode 100644 tk/macosx/tkMacOSXKeyboard.c create mode 100644 tk/macosx/tkMacOSXLibrary.r create mode 100644 tk/macosx/tkMacOSXMenu.c create mode 100644 tk/macosx/tkMacOSXMenu.r create mode 100644 tk/macosx/tkMacOSXMenubutton.c create mode 100644 tk/macosx/tkMacOSXMenus.c create mode 100644 tk/macosx/tkMacOSXMouseEvent.c create mode 100644 tk/macosx/tkMacOSXNotify.c create mode 100644 tk/macosx/tkMacOSXPort.h create mode 100644 tk/macosx/tkMacOSXRegion.c create mode 100644 tk/macosx/tkMacOSXResource.r create mode 100644 tk/macosx/tkMacOSXScale.c create mode 100644 tk/macosx/tkMacOSXScrlbr.c create mode 100644 tk/macosx/tkMacOSXSend.c create mode 100644 tk/macosx/tkMacOSXSubwindows.c create mode 100644 tk/macosx/tkMacOSXTest.c create mode 100644 tk/macosx/tkMacOSXUtil.c create mode 100644 tk/macosx/tkMacOSXUtil.h create mode 100644 tk/macosx/tkMacOSXWindowEvent.c create mode 100644 tk/macosx/tkMacOSXWm.c create mode 100644 tk/macosx/tkMacOSXWm.h create mode 100644 tk/macosx/tkMacOSXXCursors.r create mode 100644 tk/macosx/tkMacOSXXStubs.c create mode 100644 tk/tests/constraints.tcl create mode 100644 tk/tests/dialog.test create mode 100644 tk/tests/embed.test create mode 100644 tk/tests/grab.test create mode 100644 tk/tests/message.test create mode 100644 tk/tests/panedwindow.test create mode 100644 tk/tests/spinbox.test create mode 100644 tk/unix/tk.spec create mode 100644 tk/win/buildall.vc.bat create mode 100644 tk/win/lamp.bmp create mode 100644 tk/win/nmakehlp.c create mode 100644 tk/win/rc/wish.exe.manifest create mode 100644 tk/win/rules.vc diff --git a/tk/ChangeLog b/tk/ChangeLog index 25d85457335..0ff16040b3b 100644 --- a/tk/ChangeLog +++ b/tk/ChangeLog @@ -1,2211 +1,3230 @@ -2001-08-08 Mo DeJong - - * cygtcl.m4: Update from Tcl. - * unix/configure: Regen. - * win/configure: Regen. - -2001-08-06 Mo DeJong - - * cygtcl.m4: Update from Tcl. - * unix/configure: Regen. - * win/configure: Regen. - -2001-08-06 Mo DeJong - - * unix/Makefile.in: Remove TCL_LIB_FLAG, replace TCL_LIB_SPEC - with TCL_BUILD_LIB_SPEC. - * unix/configure: Regen. - * unix/configure.in: Avoid resetting TCL_LIB_SPEC and - TCL_STUB_LIB_SPEC since they are already set in tclConfig.sh. Subst - TCL_BUILD_STUB_LIB_SPEC and TCL_BUILD_LIB_SPEC into the Makefile. - * win/Makefile.in: Use TCL_LIB_SPEC and TCL_STUB_LIB_SPEC from - tclConfig.sh instead of creating them via a cygpath call. Use - TCL_STUB_LIB_SPEC in place of TCL_STUB_LIB_FILE. - * win/configure: Regen. - * win/configure.in: Fixup TK_STUB_LIB_SPEC, TK_BUILD_STUB_LIB_PATH, - TK_STUB_LIB_PATH, TK_LIB_FLAG, TK_BUILD_LIB_SPEC, TK_LIB_SPEC - and TK_LIB_FULL_PATH variables so they work like the unix version. - -2001-08-01 Mo DeJong - - * cygtcl.m4: Update from Tcl. - * unix/configure: Regen. - * unix/configure.in: Use TCL_TOOL_SHARED_LIB_LONGNAME - and TCL_TOOL_STATIC_LIB_LONGNAME to generate lib names. - * win/configure: Regen. - * win/configure.in: Use TCL_TOOL_SHARED_LIB_LONGNAME - and TCL_TOOL_STATIC_LIB_LONGNAME to generate lib names. - -2001-07-24 Mo DeJong - - * generic/default.h: Include tkWinDefault.h - when built with Cygwin or Mingw. - -2001-07-24 Mo DeJong - - * win/configure: - * win/tcl.m4: Update from Tcl. - -2001-07-12 Mo DeJong - - * unix/Makefile.in: - * unix/configure: Regen. - * unix/configure.in: - * unix/tcl.m4: - * win/Makefile.in: - * win/configure: Regen. - * win/configure.in: - * win/tcl.m4: - Revert ill-conceived EXTRA_CFLAGS changes made on 2001-07-09. - The change ended up causing big problems with the - tclConfig.sh file since it exported EXTRA_CFLAGS and did - not deal with the debug/non-debug case. - -2001-07-11 Mo DeJong - - * unix/configure: Regen. - * unix/tcl.m4: Update from Tcl. - -2001-07-11 Mo DeJong - - * unix/Makefile.in: Add AR and STLIB_LD variables. - * unix/configure: Regen. - * unix/configure.in: Use STLIB_LD when defining MAKE_LIB - and MAKE_STUB_LIB. Subst STLIB_LD, RANLIB, and AR. - * unix/tcl.m4: Update from Tcl. - * win/configure: Regen. - * win/tcl.m4: Update from Tcl. - -2001-07-10 Mo DeJong - - * win/configure: - * win/tcl.m4 (SC_CONFIG_CFLAGS): Use STLIB_LD in MAKE_LIB instead - of AR which can be overridden on the make command line. - -2001-07-09 Mo DeJong - - * win/configure: - * win/tcl.m4 (SC_CONFIG_CFLAGS): Fix quoting of CYGPATH - argument to AC_CHECK_PROG. +2002-09-10 Daniel Steffen + + * unix/Makefile.in: added DYLIB_INSTALL_DIR variable for Darwin + and set it to default value ${LIB_RUNTIME_DIR} + * unix/tcl.m4 (Darwin): use DYLIB_INSTALL_DIR instead of + LIB_RUNTIME_DIR in the -install_name argument to ld. + * unix/configure: regen. + + * macosx/Wish.pbproj/project.pbxproj: + * macosx/Makefile: added support for building Tcl as an embedded + framework, i.e. using an dyld install_name containing + @executable_path/../Frameworks via the new DYLIB_INSTALL_DIR + unix/Makefile variable. + +2002-09-10 Jeff Hobbs -2001-07-09 Mo DeJong + *** 8.4.0 TAGGED FOR RELEASE *** - * unix/Makefile.in: Add EXTRA_CFLAGS_DEBUG and EXTRA_CFLAGS_OPTIMIZE - variables. These two do not actually differ in the unix version - but are there to keep in sync with the Windows version. - * unix/configure: Regen. - * unix/configure.in: Don't subst EXTRA_CFLAGS. Subst EXTRA_CFLAGS_DEFAULT, - EXTRA_CFLAGS_DEBUG, and EXTRA_CFLAGS_OPTIMIZE. - * unix/tcl.m4: Update from Tcl. - * win/Makefile.in: Add EXTRA_CFLAGS_DEBUG and EXTRA_CFLAGS_OPTIMIZE - variables. This is needed so that the proper runtime lib gets linked - into VC++ produced .obj files when CFLAGS is reset on the command line. - * win/configure: Regen. - * win/configure.in: Don't subst EXTRA_CFLAGS. Subst EXTRA_CFLAGS_DEFAULT, - EXTRA_CFLAGS_DEBUG, and EXTRA_CFLAGS_OPTIMIZE. - * win/tcl.m4: Update from Tcl. +2002-09-09 Jeff Hobbs -2001-07-06 Mo DeJong + * macosx/tkMacOSXNotify.c (Tk_MacOSXSetupTkNotifier): corrected + Mac Jaguar event loop issue. - * win/configure: Regen. - * win/tcl.m4: Update from Tcl. + * library/tk.tcl: use command instead of control on Aqua bindings. + Force dialogs to appear below fixed native Mac menubar. + * macosx/tkMacOSXKeyEvent.c: + * macosx/tkMacOSXKeyboard.c: Keypress/release events for pure + modifier keys were not being passed to Tk. + Deadkey presses were inserting null characters into text windows. + Now they do nothing. (Still not ideal, but better than before!) + * macosx/tkMacOSXMenu.c: Allow more than 200 menus to exist - + increased to 2000. + * macosx/tkMacOSXMouseEvent.c: Bad interactions between floating + windows and ordinary ones. Ensure that local<->global coordinate + transformations are wrt to the correct window. + * macosx/tkMacOSXWm.c: Better error msg for 'wm attributes'. + Remove crash in 'wm transient'. + Add 'noActivates' and 'noUpdates' flags to unsupported command. + [Patch #606658] (darley) -2001-07-06 Mo DeJong + * library/xmfbox.tcl (::tk::MotifFDialog_ActivateSEnt): corrected + msgcat code with XPG specifier. [Patch #606719] (miller) - * unix/configure: Regen. - * unix/configure.in: Replace call to SC_ENABLE_GCC with - AC_PROG_CC so that CC passed in from the caller is respected. - * unix/tcl.m4: Update from Tcl. - * win/configure: Regen. - * win/configure.in: Replace call to SC_ENABLE_GCC with - AC_PROG_CC so that CC passed in from the caller is respected. - * win/tcl.m4: Update from Tcl. +2002-09-06 Don Porter -2001-07-06 Mo DeJong + * tests/unixWm.test (unixWm-50.3): Constrained test that hangs + on Windows. - * win/Makefile.in: Subst DEPARG directly instead - of relying on a variable. This will make Cygwin - builds faster since an extra exec will be avoided. - * win/configure: Regen. - * win/configure.in: Subst DEPARG. - * win/tcl.m4: Update from Tcl. +2002-09-05 Daniel Steffen -2001-06-26 Mo DeJong + * macosx/Wish.pbproj/project.pbxproj: added overlooked missing + TK_PATCH_LEVEL version bump to 8.4.0. - * cygtcl.m4: Update from Tcl. - * unix/configure: Regen. - * win/Makefile.in: Remove PATHTYPE variable. - Use : in VPATH instead of VPSEP. - * win/configure: Regen. - * win/configure.in: Don't subst PATHTYPE or VPSEP. - * win/tcl.m4: Update from Tcl. +2002-09-04 Andreas Kupries -2001-06-25 Mo DeJong + * win/Makefile.in (install-libraries): Added code section to + install the message catalogs. Copied same section from + unix/Makefile.in and adapted it to the slightly different + environment. - * win/configure: Regen. - * win/tcl.m4: Update from Tcl. +2002-09-03 Jeff Hobbs -2001-06-22 Mo DeJong + * library/button.tcl: further restrict buttons to not resetting + the "original" relief if it has changed in the interim. This + prevents code that simulated overrelief buttons from not working + in 8.4. [Bug #604270] - * unix/Makefile.in: Set CFLAGS to @CFLAGS@ and @CFLAGS_DEFAULT@. - Set LDFLAGS to @LDFLAGS@ and @LDFLAGS_DEFAULT@. Add LDFLAGS_DEBUG - and LDFLAGS_OPTIMIZE to match the way CFLAGS_DEFAULT works. Use - new LDFLAGS variable in the Makefile instead of @LDFLAGS@. - * unix/configure: Regen. - * unix/configure.in: Don't set CFLAGS to CFLAGS_DEFAULT, instead - subst CFLAGS_DEFAULT into the Makefile. Add AC_SUBST for CFLAGS_DEBUG, - CFLAGS_OPTIMIZE, LDFLAGS_DEFAULT, LDFLAGS_DEBUG, and LDFLAGS_OPTIMIZE. - Remove unused LD_FLAGS subst. - * unix/tcl.m4: Update from Tcl. - * win/Makefile.in: Set CFLAGS to @CFLAGS@ and @CFLAGS_DEFAULT@. - Set LDFLAGS to @LDFLAGS@ and @LDFLAGS_DEFAULT@. - * win/configure: Regen. - * win/configure.in: Don't set CFLAGS or LDFLAGS, instead subst - CFLAGS_DEFAULT and LDFLAGS_DEFAULT into the Makefile. - * win/tcl.m4: Update from Tcl. +2002-09-03 Daniel Steffen -2001-06-22 Mo DeJong + * macosx/Wish.pbproj/project.pbxproj: Bumped version number to + 8.4.0 and updated copyright info. - * configure: - * configure.in: When a windows32 host is detected - configure in the win subdirectory. - * cygtcl.m4: Update from Tcl. - * unix/configure: Regen. - * win/configure: Regen. +2002-09-03 Vince Darley -2001-06-22 Mo DeJong + * macosx/tkMacOSXWm.c: fix to 'wm attributes' error-handling bug. + +2002-09-03 Don Porter - * win/configure: - * win/tcl.m4: Update from Tcl. + * changes: Updated for 8.4.0 release -2001-06-08 Mo DeJong +2002-09-02 Jeff Hobbs - * win/Makefile.in: Set TK_LIBRARY to - $INSTALL/share/tk8.3 instead of - $INSTALL/lib/tk8.3. + * tests/cursor.test: reverted 2002-08-31 change for OS X to use + 'heart' cursor because 'arrow' on windows has a pre-skewed use + count. [Bug #602667] -2001-06-06 Mo DeJong + * tests/button.test: added button-14.1 + * win/tkWinButton.c (TkpComputeButtonGeometry): correct Win button + sizing to be equal for one-line buttons with -height of 0 or 1, as + well as -height 0 buttons with empty text and no image, which + should be the same as single-line text buttons. [Bug #565485] - * win/configure: - * win/configure.in: Handle the --prefix option correctly - it should default to /usr/local like the unix version. + * library/button.tcl (::tk::ButtonLeave): correctly restore state + of button to normal for unix bindings. [Bug #597920] -2001-06-05 Mo DeJong + * doc/tk.n: added tk windowingsystem docs. - * cygtcl.m4: - * unix/configure: Update from Tcl. + * tests/wm.test: + * unix/tkUnixWm.c: remove possible 2-second delay in 'raise'. + [Patch #601518] (english) TIP #107 -2001-06-01 Mo DeJong + * unix/tcl.m4: add support for 64-bit builds on HP-11 with gcc. + * unix/configure.in: make sure to substitute LD_LIBRARY_PATH_VAR. + * unix/configure: regend - * cygtcl.m4: + * README: Bumped version number to 8.4.0 + * generic/tk.h: * unix/configure: + * unix/configure.in: + * unix/tk.spec: * win/configure: - * win/tcl.m4: Update from Tcl. + * win/configure.in: -2001-05-30 Mo DeJong + * generic/tkCmds.c: + * generic/tkWindow.c: made 'tk' available in safe interpreters, + but only the caret and windowingsystem subcommands may be called. + * tests/safe.test (safe-1.2): noted that tk is now available in + safe interps, but not the appname/scaling subcommands. - * unix/configure: Regen. - * unix/tcl.m4: - Update from Tcl version. + * tests/tk.test (tk-1.2): noted new tk windowingsystem subcommand -2001-05-30 Mo DeJong +2002-08-31 Daniel Steffen - * cygtcl.m4: - * unix/configure: Regen. - * unix/tcl.m4: - Update from Tcl versions. + * unix/tcl.m4: update from Tcl -2001-05-26 Mo DeJong + * unix/Makefile.in: import of TK_SHLIB_LD_EXTRAS for Tk library + specific linker settings. Added use of new LD_LIBRARY_PATH_VAR. - * cygtcl.m4: - * unix/aclocal.m4: - * unix/configure: Regen. - * unix/tcl.m4: - * win/aclocal.m4: - * win/configure: Regen. - * win/tcl.m4: - Update from Tcl versions. + * unix/configure: regen -2001-05-09 Mo DeJong +2002-08-31 Daniel Steffen - * unix/Makefile.in: Use TK_STUB_LIB_FILE instead - of STUB_LIB_FILE subst. - * unix/configure: Regen. - * unix/configure.in: Use new path macros. - * unix/tcl.m4: Update from Tcl. - * win/configure: Regen. - * win/configure.in: Use new path macros. - * win/tcl.m4: Update from Tcl. + *** macosx-8-4-branch merged into the mainline [tcl patch #602770] *** -2001-05-08 Ian Roxborough + * generic/tk.decls: + * generic/tkInt.decls: added new "aqua" specific entries to the + stubs tables. Changed all "unix" entries to "x11" to allow us to + distinguish and build both "aqua" on MacOSX and "x11" on MacOSX. - * unix/configure.in: Cygnus local change - to build gdbtk: Set TK_BUILD_INCLUDES to - correct path. - * unix/configure: Regenerated. + * generic/tk.h: added a #ifnded RESOURCE_INCLUDED so that tk.h can + be passed to the resource compiler. -2001-04-09 Mo DeJong + * generic/tkCmds.c (Tk_TkObjCmd): added [tk windowingsystem] + subcommand: returns "x11" when running on X11, "win32" on Windows, + "classic" on MacOS9 and "aqua" on MacOSX Aqua (i.e. Carbon) - * unix/aclocal.m4: Pull in tcl.m4. - * unix/configure: Regen. - * unix/tcl.m4: Add from tcl/unix. - * win/Makefile.in: Append version to tclsh - in the win subdirectory. - * win/configure: Regen. - * win/configure.in: The TK_BUILD_LIB_SPEC and - TK_BUILD_LIB_SPEC variables need to use the - lib file and not the dll file, since it is - not possible to link to a dll with VC++. - Use new TCL_TOOL_PATH macro to correctly - set the XINCLUDES variable. - * win/tcl.m4: Update from tcl/win so we can use - the TCL_TOOL_PATH macro. + * generic/tkFont.c (TkFontGetFirstTextLayout): new private function + returning the first chunk of a Tk_TextLayout, i.e. until the first + font change on the first line (or the whole first line if there is + no such font change). -2001-04-05 Mo DeJong + * generic/tkMain.c: made Tcl_ThreadDataKey static - * win/Makefile.in: Don't depend on - TCLSH_PROG variable from configure. - * win/configure: Regen. - * win/configure.in: Don't call - SC_PROG_TCLSH, it was removed from - Tcl. This macro required that Tcl - be built before Tk could be configured. - * win/tcl.m4: Update from Tcl version. + * library/demos/puzzle.tcl: fixed button metrics for aqua -2000-08-08 Jeff Hobbs + * tests/cursor.test: check for presence of arrow cursor instead of + heart cursor - 8.3.2 RELEASE finalized - - * changes: updated for release notes version of ChangeLog + * xlib/xcolors.c: changed xColors static initialization to more + standard C + + * macosx/Wish.pbproj/jingham.pbxuser (new): + * macosx/Wish.pbproj/project.pbxproj (new): project for Apple's + ProjectBuilder IDE. + + * macosx/Makefile (new): simple makefile for building the project + from the command line via the ProjectBuilder tool 'pbxbuild'. + + * macosx/tkMacOSXAppInit.c (new): macosx specific AppInit looking + for a AppMain.tcl file in its bundled Resources/Scripts folder. If + present, argv[1] is set to that file and the Scripts folder is + added to the auto_path. This allows tk apps to embed scripts within + their bundle directory structure. + + * macosx/tkMacOSXInit.c (new): macosx adapted version of + tkUnixInit.c: we initialize & cache the Carbon native encoding + (e.g. 'macRoman') and try to find the tk script library files + inside Tk packaged as a framework. + + * macosx/tkMacOSXNotify.c (new): new macosx specific merged + Carbon/select-based notifier. + + * macosx/tkMacOSXEvent.c (new): + * macosx/tkMacOSXEvent.h (new): + * macosx/tkMacOSXKeyEvent.c (new): + * macosx/tkMacOSXMouseEvent.c (new): + * macosx/tkMacOSXWindowEvent.c (new): new macosx specific event + handling functionality. + + * macosx/tkMacOSX.h (new): + * macosx/tkMacOSXBitmap.c (new): + * macosx/tkMacOSXButton.c (new): + * macosx/tkMacOSXClipboard.c (new): + * macosx/tkMacOSXColor.c (new): + * macosx/tkMacOSXConfig.c (new): + * macosx/tkMacOSXCursor.c (new): + * macosx/tkMacOSXDefault.h (new): + * macosx/tkMacOSXDialog.c (new): + * macosx/tkMacOSXDraw.c (new): + * macosx/tkMacOSXEmbed.c (new): + * macosx/tkMacOSXFont.c (new): + * macosx/tkMacOSXHLEvents.c (new): + * macosx/tkMacOSXInt.h (new): + * macosx/tkMacOSXKeyboard.c (new): + * macosx/tkMacOSXMenu.c (new): + * macosx/tkMacOSXMenubutton.c (new): + * macosx/tkMacOSXMenus.c (new): + * macosx/tkMacOSXPort.h (new): + * macosx/tkMacOSXRegion.c (new): + * macosx/tkMacOSXScale.c (new): + * macosx/tkMacOSXScrlbr.c (new): + * macosx/tkMacOSXSubwindows.c (new): + * macosx/tkMacOSXTest.c (new): + * macosx/tkMacOSXUtil.c (new): + * macosx/tkMacOSXUtil.h (new): + * macosx/tkMacOSXWm.c (new): + * macosx/tkMacOSXWm.h (new): + * macosx/tkMacOSXXStubs.c (new): macosx ports of classic mac Tk + implementation in tk/mac. + + * macosx/tkMacOSXSend.c (new): only send to local interp + implemented currently. + + * macosx/tkMacOSXDebug.h (new): + * macosx/tkMacOSXDebug.c (new): new macosx specific functions for + debugging MacOS events, regions, etc. + + * macosx/tkAboutDlg.r (new): + * macosx/tkMacOSXApplication.r (new): + * macosx/tkMacOSXCursors.r (new): + * macosx/tkMacOSXLibrary.r (new): + * macosx/tkMacOSXMenu.r (new): + * macosx/tkMacOSXResource.r (new): + * macosx/tkMacOSXXCursors.r (new): + * macosx/tclets.r (new): sources for Rez resource compiler. + + * macosx/Wish.icns (new): Wish application icon. -2000-08-05 Jeff Hobbs + * generic/tk.h: + * generic/default.h: + * generic/tkBind.c: + * generic/tkCmds.c: + * generic/tkGrab.c: + * generic/tkPointer.c: + * generic/tkPort.h: + * generic/tkSelect.c: + * generic/tkStubLib.c: + * generic/tkTest.c: + * generic/tkText.c: + * generic/tkWindow.c: + * unix/tkUnix3d.c: + * xlib/xgc.c: + * xlib/X11/X.h: + * xlib/X11/Xlib.h: + * xlib/X11/Xutil.h: added #includes and #ifdefs for macosx - * win/Makefile.in (cat32.${OBJEXT}): corrected where to find cat.c - given the change in default def'n of TCL_SRC_DIR. + * library/bgerror.tcl: + * library/button.tcl: + * library/console.tcl: + * library/dialog.tcl: + * library/entry.tcl: + * library/listbox.tcl: + * library/menu.tcl: + * library/msgbox.tcl: + * library/scrlbar.tcl: + * library/spinbox.tcl: + * library/text.tcl: + * library/tk.tcl: + * library/demos/menu.tcl: + * library/demos/menubu.tcl: + * library/demos/widget: check [tk windowingsystem] instead of + and/or in addition to $tcl_platform(platform). - * win/tcl.m4: changed references from 8.4 to 8.3 (leftover from a - backported file). + * generic/tkInt.h: + * mac/tkMacBitmap.c: + * mac/tkMacWm.c: added missing CONSTification - * library/safetk.tcl: rationalized the setting of tk_library when - initialized Tk in a safe interpreter. + * generic/tkIntDecls.h: + * generic/tkIntPlatDecls.h: + * generic/tkIntXlibDecls.h: + * generic/tkPlatDecls.h: + * generic/tkStubInit.c: regen -2000-08-04 Jeff Hobbs +2002-08-27 D. Richard Hipp - * BACKPORTED FROM 8.4 (HEAD) BRANCH: + * doc/checkbutton.n: [Bug 582457] Fix the -offrelief option so + * doc/radiobutton.n: that when -offrelief is flat and -relief is + * mac/tkMacButton.c: sunken and -overrelief is raised, buttons + * unix/tkUnixButton.c: work look toolbar buttons under Windows. + * win/tkWinButton.c: See also: TIP #82. - * tests/button.test: - * generic/tkButton.c: Added -activeforeground, -activebackground - for labels, for the -state option. +2002-08-26 Don Porter - * doc/label.n: Added -disabledforeground to list of options [Bug: - 6053]. + * win/Makefile.in: Removed dependence on the (parts of) the + * win/winMain.c: tcltest executable on Windows. It was not + used, and the dependency complicated the Makefile. [Bug 592638]. - * tests/focus.test (focusSetupAlt): removed wm withdraw from proc - as it would cause a hang for tkwait visibility +2002-08-20 Don Porter - * tests/menu.test: - * generic/tk3d.c: - * generic/tkColor.c: - * generic/tkCursor.c: corrected handling of 3DBorder, Cursor and - Color objects on multiple screens. [Bug: 5454] + * README: Bumped version number to 8.4b3 to distinguish + * generic/tk.h: HEAD from the 8.4b2 release. + * unix/configure.in: + * win/configure.in: + * unix/tk.spec: + + * unix/configure: autoconf + * win/configure: - * generic/tkCursor.c: Added initialization for nextPtr field of - TkCursor, patch from Nijtmans/Howlett. + * generic/tk.h: Added compile-time check that the tcl.h header file + #included by Tk 8.4 is one from Tcl 8.4. This is needed to be sure + that new #defines like CONST84 are available. [Bug 597432]. - * canvas.test: added test for 5783. - * generic/tkCanvPoly.c (DisplayPolygon): added checks for the - polygon fillGC not being empty to prevent segfault. [Bug: 5783] +2002-08-16 Jeff Hobbs - * generic/tkImgGIF.c: Applied patch from Jan Nijtmans to fix a - problem with the GIF writing code [Bug: 5823]. - * generic/tkImgGIF.c: Changed defines for GIF87a/GIF89a to be - static char arrays with integer initialization, to address EBCIDIC - vs. ASCII encoding issues and to handle compilers that don't deal - with "\xAB" syntax for specifying hex values in strings. + * unix/Makefile.in (install-binaries): simplified pkgIndex.tcl + file created on installation. + * win/Makefile.in (install-binaries): corrected and simplified + creation of pkgIndex.tcl file on installation. - * generic/tkMenu.c (DeleteMenuCloneEntries): Applied fix from - [Bug: 5275], which corrected a segfault-causing indexing problem - when deleting entries from torn-off menus. +2002-08-14 Vince Darley - * generic/tkPlace.c (Tk_PlaceCmd): reworked place master/slave - table init'n to prevent seg fault when using place on multiple - displays. + * win/tkWinDialog.c: + * win/makefile.vc: broken compilation and link from changes + Hobbs-08-07 fixed. + * win/tkWinTest.c: CONST problem resolved. - * tests/text.test: Added tests for -regexp -nocase searches with - backslash character classes. - * tests/text.test: Added tests for searching when text is elided. - * generic/tkText.c (TextSearchCmd): Text search did not work - properly when -regexp and -nocase were used, in combination with - backslash character classes represented by capital letters (ie, - \W, \M); altered implementation of -regexp -nocase searches to use - new regexp interfaces to fix this problem. [Bug: 5988]. - * generic/tkText.c (TextSearchCmd): Text search was not returning - the correct index when the search covered (but did not search) - elided characters; corrected this by adjusting the match index by - the number of elided characters preceeding the start of the match, - just as is done with embedded windows, etc. [Bug: 5470]. - * generic/tkText.c (TextSearchCmd): Added a test for a NULL - segment pointer when doing backwards searches for "" on an empty - text widget. [Bug: 6007]. +2002-08-13 Jeff Hobbs - * library/focus.tcl: fixed calling of takeFocus proc [Bug: 5372] + * library/button.tcl: change the bindings to use Priv($w,relief) + instead of just Priv(relief). This ensures that neighboring + buttons don't confuse (over)relief settings. - * win/tkWinMenu.c (ReconfigureWindowsMenu): Added MF_GRAYED bit - for disabled menu entries, to ensure that those which are drawn by - the system are shown grayed (such as entries on menubars) [Bug: 4372]. - * win/tkWinMenu.c (ReconfigureWindowsMenu): Added code to add the - MF_SEPARATOR bit for SEPARATOR_ENTRY menu items. This causes - separator entries on the system menu to be drawn correctly [Bug: 5451]. - * win/tkWinMenu.c (GetMenuSeparatorGeometry): Tweaked height - requested for separator bars to be (linespace - (2*descent)) - instead of just (linespace); this makes the separator occupy a - more correct amount of vertical space. [Bug: 5303]. +2002-08-13 Reinhard Max -2000-07-20 Brent Welch + * unix/tkUnixSend.c (Tk_SetAppName): Fixed a compiler warning. - * win/tkConfig.sh.in: - Made corresponding changes to match gcc for windows mods - to the rest of the files. +2002-08-12 Donal K. Fellows -2000-07-28 Mo DeJong + * library/demos/image2.tcl: Tweaked the behaviour of the directory + box on resize, as resizing of the overall window tends to be + common given the sample images. - * win/Makefile.in: - * win/aclocal.m4: - * win/configure.in: - * win/tcl.m4: Back port of gcc for windows - build system from 8.4. +2002-08-08 Mo DeJong -2000-07-26 Jeff Hobbs + * unix/tkUnixWm.c (WmTransientCmd): Apply fix for + wm transient assertion error that was applied + to tkWinWm.c for Tk Bug #592201. - * unix/configure.in (TK_PATCH_LEVEL): updated to 8.3.2 - * unix/tk.spec: - * win/configure.in: - * generic/tk.h: - * README: +2002-08-08 Mo DeJong -2000-07-22 Brent Welch - * win/Makefile.in, win/configure.in, win/rc/tk.rc, win/rc/tk_base.rc - Trying to generalize .rc files so they work with both DLL's and - static shell builds. + * tests/wm.test: Add deleteWindows at start of + new transient tests so they do not fail if the + toplevels already exist. + * unix/tkUnixWm.c: Revert patch for Tk Bug #592201 + which incorrectly removed numTransients member. -2000-07-10 Brent Welch +2002-08-08 Joe English - * win/{Makefile.in,configure.in,tkConfig.sh.in}: - Cleanup of defines in tkConfig.sh + * unix/tkUnixWm.c: + * win/tkWinWm.c: + * tests/wm.test: Fix for Tk Bug #592201 "wm transient fails with two + masters"; fixes panic after a transient window is reassigned to + new master and either master is subsequently destroyed. -2000-05-15 Jeff Hobbs +2002-08-08 Don Porter - * win/tkWinWm.c: changed wm deiconify from using idle - callback to calling restack and focus code immediately. + * tests/unixWm.test: Corrected packaging of unixWm-50.3 so that + [setupbg] and [cleanupbg] always balance, no matter what tests + are skipped. -2000-04-26 Jeff Hobbs +2002-08-08 Reinhard Max - 8.3.1 RELEASE + * unix/Makefile.in: Fixed typos in DISTNAME, and ZIPNAME. - * README: - * mac/README: - * unix/README: - * unix/tk.spec: - * win/README: Updating URLs to reference dev.scriptics.com +2002-08-08 Jeff Hobbs -2000-04-25 Jeff Hobbs + *** 8.4b2 TAGGED FOR RELEASE *** - * unix/Makefile.in: - * win/Makefile.in: makefile cleanup + * generic/tkButton.c (TkButtonWorldChanged): added GCFont handling + to the disabledGc of buttons when compound != none. The drawing + appears to be incorrect across platforms still. [Bug #477740] -2000-04-25 Eric Melski + * generic/tkImgGIF.c (FileReadGIF): fixed -from handling for gifs + [Bug #467524] (obermeier) - * generic/tkMain.c: Fixed function header comment for Tk_MainEx. +2002-08-07 Jeff Hobbs - * unix/mkLinks: - * doc/GetScroll.3: Added information about Tk_GetScrollInfoObj - [Bug: 1866]. + * generic/tkCanvUtil.c (TkSmoothParseProc): recognize the built-in + bezier method by name. [Bug #578654] + * doc/canvas.n: update to note that -smooth really doesn't take + or return just booleans. -2000-04-24 Eric Melski + * win/tkWinMenu.c (TkpSetWindowMenuBar): fixed logic bug in when + to idle call ReconfigureWindowsMenu. - * unix/mkLinks: - * doc/Grab.3: Man page for Tk_Grab and Tk_Ungrab [Bug: 1868, 1889] + * doc/GetBitmap.3: removed doc refs to deprecated + Tk_GetBitmapFromData. [Bug #590379] - * unix/mkLinks: - * doc/MainWin.3: Added entry for Tk_GetNumMainWindows [Bug: 1865]. + * generic/tkPanedWindow.c (Tk_PanedWindowObjCmd): + * library/panedwindow.tcl: changed class from PanedWindow to + Panedwindow to not conflict with existing bwidgets, but also to be + more regular with other names used in the core. - * unix/mkLinks: - * doc/GetHINSTANCE.3: Man page for Tk_GetHINSTANCE [Bug: 1862]. + * tests/panedwindow.test: added -text foobar to some test buttons + to enable correct testing of panedwindow across platforms. + [Bug #582370] -2000-04-24 Jeff Hobbs + * win/tkWinDialog.c: enabled use of the updated native Windows + directory browser (tk_chooseDirectory). This does require + shell32.dll v4.71 or greater. [Patch #468139] - * generic/tkImage.c (Tk_PostscriptImage): added check to create - necessary prolog for photos - * generic/tkCanvPs.c: added Tk_PostscriptPhoto that outputs PS for - photo images - * generic/tkImgPhoto.c: new func ImgPhotoPostscript and added that - in as ps proc in tkPhotoImageType. - * generic/tkStubInit.c: + * win/configure: + * win/tcl.m4: added shell32 to libs for updated native Windows + tk_chooseDirectory dialog. + +2002-08-06 Donal K. Fellows + + * generic/tkPanedWindow.c (RESIZE_PENDING): Separated out flag for + indicating that a resize needs to be issued. + (PanedWindowReqProc): Do the old behaviour when the panedwindow is + not mapped; easiest way of making the test suite pass while still + preserving improved behaviour in the face of children whose size + is not known immediately. + +2002-08-06 Don Porter + + * tests/defs.tcl: removed file. No longer needed now that Tk is + using the tcltest package to do its testing. + +2002-08-05 Don Porter + + * win/tkWinFont.c: Additional changes to fix CONST warnings on + * win/tkWinWM.c: Windows due to latest patch. Tks Vince Darley. + + * doc/3DBorder.3: Applied companion patch for Tcl Patch 585105, + * doc/BindTable.3: updating Tk to use Tcl 8.4's fully CONST-ified + * doc/ConfigWidg.3: interface, and fully CONSTifying Tk at the + * doc/CrtImgType.3: same time. + * doc/CrtWindow.3: + * doc/DeleteImg.3: This patch includes purging Tk of its last + * doc/FindPhoto.3: direct access to interp->result. [Bug 589853] + * doc/GetAnchor.3: + * doc/GetBitmap.3: The substantial changes include copying + * doc/GetCapStyl.3: event sequence strings into Tcl_DStrings + * doc/GetClrmap.3: in tkBind.c, and copying [text] indices into + * doc/GetColor.3: Tcl_DStrings because parsing them involved + * doc/GetCursor.3: overwriting them. If this causes performance + * doc/GetFont.3: trouble, that can be resolved by further + * doc/GetImage.3: converting them to Tcl_Obj's. + * doc/GetJoinStl.3: + * doc/GetJustify.3: The #defines USE_NON_CONST and USE_COMPAT_CONST + * doc/GetOption.3: have the same effect for Tk as they do for Tcl. + * doc/GetRelief.3: (They actually change tcl.h) + * doc/GetScroll.3: + * doc/GetVisual.3: + * doc/InternAtom.3: + * doc/NameOfImg.3: + * doc/SetAppName.3: + * doc/WindowId.3: + * generic/tk.decls: + * generic/tk.h: + * generic/tk3d.c: + * generic/tkAtom.c: + * generic/tkBind.c: + * generic/tkBitmap.c: + * generic/tkButton.c: + * generic/tkCanvArc.c: + * generic/tkCanvBmap.c: + * generic/tkCanvImg.c: + * generic/tkCanvLine.c: + * generic/tkCanvPoly.c: + * generic/tkCanvPs.c: + * generic/tkCanvText.c: + * generic/tkCanvUtil.c: + * generic/tkCanvWind.c: + * generic/tkCanvas.c: + * generic/tkCanvas.h: + * generic/tkClipboard.c: + * generic/tkCmds.c: + * generic/tkColor.c: + * generic/tkConfig.c: + * generic/tkConsole.c: + * generic/tkCursor.c: * generic/tkDecls.h: - * generic/tk.decls: added Tk_PostscriptPhoto + * generic/tkEntry.c: + * generic/tkFont.c: + * generic/tkFrame.c: + * generic/tkGet.c: + * generic/tkGrid.c: + * generic/tkImage.c: + * generic/tkImgBmap.c: + * generic/tkImgPhoto.c: + * generic/tkInt.decls: + * generic/tkInt.h: + * generic/tkIntDecls.h: + * generic/tkIntPlatDecls.h: + * generic/tkListbox.c: + * generic/tkMenu.c: + * generic/tkMenubutton.c: + * generic/tkMessage.c: + * generic/tkOldConfig.c: + * generic/tkOption.c: + * generic/tkRectOval.c: + * generic/tkScale.c: + * generic/tkScrollbar.c: + * generic/tkSelect.c: + * generic/tkStyle.c: + * generic/tkTest.c: + * generic/tkText.c: + * generic/tkText.h: + * generic/tkTextBTree.c: + * generic/tkTextDisp.c: + * generic/tkTextImage.c: + * generic/tkTextIndex.c: + * generic/tkTextMark.c: + * generic/tkTextTag.c: + * generic/tkTextWind.c: + * generic/tkUtil.c: + * generic/tkVisual.c: + * generic/tkWindow.c: + * mac/tkMacConfig.c: + * mac/tkMacCursor.c: + * mac/tkMacEmbed.c: + * mac/tkMacSend.c: + * unix/tkUnixConfig.c: + * unix/tkUnixCursor.c: + * unix/tkUnixEmbed.c: + * unix/tkUnixFont.c: + * unix/tkUnixSelect.c: + * unix/tkUnixSend.c: + * unix/tkUnixWm.c: + * win/tkWinConfig.c: + * win/tkWinCursor.c: + * win/tkWinEmbed.c: + * win/tkWinMenu.c: + * win/tkWinSend.c: - * generic/tkConfig.c (DoObjConfig): removed direct setting of - interp->result. +2002-08-02 Donal K. Fellows - * mac/tkMacWm.c (Tk_WmCmd): initialized gotToplevel in - colormapwindows case (bug found by Reasoning, Inc's automated code - testing). + * generic/tkPanedWindow.c (DestroyPanedWindow): Idle calls need to + be deleted on destruction of the window, or things can *really* go + pear-shaped. -2000-04-24 Eric Melski +2002-07-31 Donal K. Fellows - * unix/mkLinks: - * doc/GetHWND.3: Man page for Tk_GetHWND [Bug: 1863]. + * generic/tkPanedWindow.c (PanedWindowReqProc): Postpone pane + arrangement until idle, as is done in other window managers, to + fix problems with size calculations when the children don't + already know their sizes anyway. - * unix/mkLinks: - * doc/HWNDToWindow.3: Man page for Tk_HWNDToWindow [Bug: 1869]. + * unix/configure: Regen. + * unix/tcl.m4: Update from Tcl. - * unix/mkLinks: - * doc/AddOption.3: Man page for Tk_AddOption [Bug: 1854] +2002-07-29 Mo DeJong -2000-04-22 Jim Ingham + * unix/configure: Regen. + * unix/configure.in: Remove code that was setting + CC_SEARCH_FLAGS and LD_SEARCH_FLAGS to try to + account for cc vs ld linking. Tcl now handles this. + * unix/tcl.m4: Update from Tcl. - * mac/tkMacDialog.c (Tk_MacGetOpenFile): Add empty bodies for the - "-initialfile" and "-defaultextension" options. +2002-07-27 Mo DeJong - * mac/tkMacDialog.c (NavServicesGetFile): Only cons the result up - into a list if multiple is true. + * unix/Makefile.in: Add MAJOR_VERSION, MINOR_VERSION, + PATCH_LEVEL, INSTALL_LIBRARY, STUB_LIB_FILE, and LIB_FILE + to support changes in tcl.m4 related to library builds. + Use MAKE_LIB macro to avoid dealing with RANLIB issues. + Rename TK_CC_SEARCH_FLAGS to CC_SEARCH_FLAGS and + rename TK_LD_SEARCH_FLAGS to LD_SEARCH_FLAGS. + Use new INSTALL_LIB and INSTALL_STUB_LIB substs to + deal with ranlib issues when install libraries. + * unix/configure: Regen. + * unix/configure.in: Remove AC_PROG_RANLIB since + this is done by tcl.m4 now. Define CC_SEARCH_FLAGS + instead of TK_CC_SEARCH_FLAGS and so on. + Use MAKE_LIB and MAKE_STUB_LIB from tcl.m4. + Remove AC_SUBST calls that are no done in tcl.m4. + * unix/tcl.m4: Update from Tcl. + * unix/tkConfig.sh.in: Subst CC_SEARCH_FLAGS and + LD_SEARCH_FLAGS. - * mac/tkMacMenus.c (SourceDialog): Use the "tk_getOpenFile" - instead of hand-coding the dialog with StandardGetFile. This way - we get the Navigation dialogs for free. +2002-07-25 Peter Spjuth - * doc/getOpenFile.n: Document the -multiple and -message flags - which are only implemented on the Mac. Also note that the -title - works on the Mac with Nav Services installed. + * generic/tkInt.h: + * generic/tkWindow.c: + * mac/tkMacWm.c: + * unix/tkUnixWm.c: + * win/tkWinWm.c: + * tests/wm.test: + * tests/winWm.test: + * tests/unixWm.test: Objectifed wm. [Patch #564521] + Note: At this point the Mac file is completely untested + and may not even compile. -2000-04-19 Eric Melski +2002-07-25 Jeff Hobbs - * doc/WinViewable.3: - * unix/mkLinks: Removed docs for Tk_IsViewable. + * tests/spinbox.test: added spinbox-22.[1-3] + * generic/tkEntry.c (ConfigureEntry): made the textvariable value + take precedence over changed -from/-to values, unless it must be + constrained. [Bug #559078] - * win/tkWinDialog.c: Removed calls to Tk_IsViewable. + * library/spinbox.tcl (MouseSelect): when not in the entry, just + return instead of invoking - ButtonUp handles invoking already. + [Bug #499168] - * generic/tkUtil.c: - * generic/tkStubInit.c: - * generic/tkDecls.h: - * generic/tkCmds.c: - * generic/tk.decls: Removed Tk_IsViewable function (it was not - actually needed). + * library/tk.tcl (RestoreFocusGrab): handle the case where the + FocusGrab info is not set. [Bug #553283] -2000-04-19 Jeff Hobbs +2002-07-24 Jeff Hobbs - * win/aclocal.m4: made SC_PROG_TCLSH search specifically for - tclsh*.exe type files to find an executable. + * tests/canvas.test: added canvas-14.[1-6] + * generic/tkCanvas.c (CanvasWidgetCmd): corrected handling of + 'scan' subcommand args. Also removed early return cases to goto + done instead where the canvasPtr would be Tcl_Release'd. This may + solve other problems with unreleased canvasPtr's. [Bug #581560] - * win/Makefile.in: fixed up cleanup, winhelp, cat32 targets + * win/tkWinButton.c (TkpDisplayButton): corrected display of focus + ring around the actual text when the button is a compound button. + [Bug #583691] - * library/console.tcl: made console use systemfixed font on Win + * unix/README: Corrected notes about running user interactive Tk + tests. [Bug #462320] - * generic/tkEntry.c: removed unnecessary ENTRY_VALIDATE #define + * generic/tkText.c (TextEditUndo): set isDirtyIncrement to -1 when + reverting to note proper "dirtiness". [Bug #580362] (callewaert) -2000-04-19 Eric Melski + * generic/tkEntry.c (DisplayEntry): correct cursor position before + calling Tk_SetCaretPos. (yamamoto) - * generic/tkRectOval.c (ConfigureRectOval): Added checks for valid - outline settings before creating of outline GC; this means that it - is really possible now to have an oval or rectangle with no - outline. [Bug: 5029]. +2002-07-23 Mo DeJong -2000-04-19 Jeff Hobbs + * unix/configure: Regen. + * unix/tcl.m4: Update from Tcl. - * library/choosedir.tcl (::tk::dialog::file::chooseDir::Config): - * library/tkfbox.tcl (::tk::dialog::file::Config): removed the - extraneous glob on -initialdir after file isdir already returned 1 - and moved cd trick into this case as the else already uses [pwd]. - [Bug: 5181] +2002-07-22 Mo DeJong - * win/winMain.c: moved extern call out of WinMain func + * library/choosedir.tcl (tk::dialog::file::chooseDir): + * library/clrpick.tcl (tk::dialog::file::chooseDir): + * library/msgbox.tcl (tk::MessageBox): + * library/tkfbox.tcl (tk::dialog::file): + * library/xmfbox.tcl (tk::MotifFDialog): + Revert [Tk patch 568278]. The transient window workaround + is no longer needed since the fix for [Tk bug 570764] + solved the problem for withdrawn transients. - * README: - * generic/tk.h: +2002-07-19 Mo DeJong + + * unix/configure: * unix/configure.in: - * unix/tk.spec: - * win/configure.in: bumped to version 8.3.1 + * win/configure: + * win/configure.in: Add AC_PREREQ(2.13) in an attempt + to make it more clear that the configure scripts + must be generated with autoconf version 2.13. + [Tcl Bug 583573] - * library/msgbox.tcl (tkMessageBox): changed to use grid in some - places, realign icon to anchor nw. +2002-07-19 D. Richard Hipp - * mac/tkMacScale.c: reverted tkMacScale.c to 1.5 equivalent (it - was accidentally bumped forward). + * library/mkpsec.tcl: Fix a bug that was causing postscript generation + to fail under Win2K. -2000-04-18 Eric Melski +2002-07-18 Reinhard Max - * win/tkWinPointer.c: Changed Mod2Mask in TkWinGetModifierState to - ALT_MASK, to fix some event problems [Bugs: 1160, 5088]. + * unix/tkUnixSend.c: Using Tcl_GetTime instead of TclpGetTime. - * win/tkWinX.c: Changed Mod2Mask in GetState to ALT_MASK, to fix - some event problems [Bugs: 1160, 5088]. +2002-07-17 Reinhard Max - * generic/tkInt.h: Moved definition of ALT_MASK and META_MASK here - so that it would be accessible from other modules than tkBind.c. + * library/unsupported.tcl: Extended ExposePrivateVariable, and + ExposePrivateCommand to accept patterns as well. - * generic/tkBind.c: Added code in BindEvent to check for ALT_MASK - and META_MASK in the event state field, as this field may not be - set up with the correct display modifier mask bits if the XEvent - structure was created by [event generate] or by the Windows X - emulation. [Bugs: 1160, 5088]. +2002-07-17 Don Porter -2000-04-18 Scott Redman + * generic/tkFont.c: Corrected reversed logic in assert -> panic + conversion. [Bug 582799] - * win/tk.rc: - * win/wish.rc: - * win/wish.ico: Modified copyright dates in Windows resource - files. Updated the icon for wish.exe. +2002-07-16 Mo DeJong -2000-04-17 Eric Melski + * generic/tkFont.c (TkFontPkgFree): Call panic instead + of assert since assert is not used in the rest of Tk. + [Tk bug 579651] - * win/tkWinDialog.c: Added checks for visibility of parent window - before creating MessageBox and ChooseColor dialogs; this prevents - the application from locking when the parent is withdrawn and the - message box is created. In these cases, the window will be - created without a parent. +2002-07-16 Mo DeJong - * unix/mkLinks: Added WinViewable.3. + * unix/Makefile.in: + * win/Makefile.in: Add a more descriptive warning + in the event `make genstubs` needs to be rerun. - * tests/msgbox.test: Added tests for patch from [Bug: 4997]. +2002-07-16 Vince Darley - * library/msgbox.tcl: - * library/dialog.tcl: Applied patch from [Bug: 4997]; detaches - dialog window from parent if parent is not viewable. + * win/tkWinWm.c: + * doc/wm.n: fix for part of [Bug 581627], and made iconbitmap + code on Windows more flexible about reading in icons [Bug + 220800]. - * library/bgerror.tcl: Removed workaround from [Bug: 4370]; this - is superceeded by patches to dialog.tcl. +2002-07-15 David Gravereaux - * generic/tkCmds.c: Changed WinfoObjCmd to use Tk_IsViewable - function to determine visibility of windows instead of inlining - the code. + * win/makefile.bc (new): re-add of the borland makefile. Submitted + by Helmut Giese . This needs testing, still. - * generic/tkStubInit.c: - * generic/tkDecls.h: - * generic/tk.decls: Added Tk_IsViewable declaration. +2002-07-15 Don Porter -2000-04-17 Eric Melski + * Fixes for [Bug 581627, 581795]. + * generic/tkTest.c: Test commands not supported on non-Unix + platforms should not be defined there in the first place. + * tests/constraints.tcl: Fixed "secureserver" constraint. + * tests/unixWm.test: Some tests needed "unix" constraint. + * win/tkWinWm.c: Typo in error message. - * library/text.tcl: Tweaked double-/triple-click selection; - previously, anchor and insert marks were placed in unexpected - locations following a double or triple click. Now they are placed - logically. Also tweaked the extension of selection via - shift-double-clicks so that it no longer selects the contiguous - whitespace on the side of the selection opposite the - double-click. [RFE: 4253]. +2002-07-14 Don Porter - * doc/menu.n: Added note regarding rendering of - checkbuttons/radiobuttons in menubars on different platforms -- - some systems do not draw indicators for check/radiobuttons in - menubars. + * tests/event.test: Fixes to enable testing of only userInteraction + * tests/visual_bb.test: tests. - * library/menu.tcl: Corrected behavior of - checkbuttons/commands/radiobuttons in menubars [Bug: 630]. + * README: Bumped HEAD to version 8.4b2 in order to + * generic/tk.h: distinguish it from the 8.4b1 release. + * unix/configure*: Also extended LOCALES to cover all message + * unix/tk.spec: catalogs. + * win/configure*: - * tests/grid.test: Added test for [grid propagate . 0] to not toggle. - - * generic/tkGrid.c: Fixed bogus logic in [grid propagate] that - caused [grid propagate . 0] to act as a toggle instead of an - absolute set. [Bug: 2286]. + * tests/focustTcl.test: Conversion bug: Corrected backwards logic. + * tests/imgPhoto.test: Conversion bug: overwrote unix/README. -2000-04-16 Jeff Hobbs + * tests/all.tcl: Completed conversion of Tk test suite + * tests/constraints.tcl: to use tcltest. + * tests/[b-v]*.test: + * unix/Makefile.in: - * win/tkWinColor.c (FindSystemColor): correct calculation of - colors when shifting value. [Bug: 4919] +2002-07-12 Don Porter -2000-04-16 Jim Ingham + * tests/constraints.tcl: Converted more files to tcltest and + * tests/[g-x]*.test: factored out common code. - * mac/tkMacPort.h: protect against strncasecmp already defined - - it is in the Pro5 version of MSL. +2002-07-11 Don Porter - * mac/tkMacWindowMgr.c (GenerateKeyEvent): Check for a null tkWin. - If the hidden window we use for double-buffering controls manages - to percolate to the top (should never happen, but...) this will - keep us from crashing. + * tests/canvPsImg.tcl: Converted several files in the + * tests/constraints.tcl (new file): Tk test suite for testing by + * tests/[r-x]*.test: tcltest 2.1. + * unix/Makefile.in: - * mac/tkMacButton.c (InitSampleControls): Hide the - double-buffering window BEHIND the first "." window you can find. - This will keep it from ever being the front window, and thus a - black hole for events. * mac/tkMacButton.c (ButtonEventProc): - Disable the controls when the window is in the background. This - is required by the MacOS HIG. This doesn't always get called when - it should, it still needs more work. +2002-07-11 Jeff Hobbs - * mac/tkMacDialog.c: Pretty substantial rewrite to include - Navigation Services support for systems which have it. + * win/tkWinDialog.c (Tk_ChooseDirectoryObjCmd): initialize + utfTitle to NULL, add a few more notes about limitations of + possible new Tk_ChooseDirectoryObjCmd function. -2000-04-14 Eric Melski +2002-07-11 Donal K. Fellows - * win/tkWinKey.c: Added check for ASCII delete character in - KeycodeToKeysym, to fix [Bug: 5090]. See comment in code for more - information. + * tests/imgPhoto.test (imgPhoto-15.1): Added test of mem-alloc + failure, but this is non-portable. + * generic/tkImgPhoto.c (ImgPhotoSetSize): Allowed this function to + fail when it can't allocate enough memory. Note that not all the + places that call it can fail nicely without API changes; some + still panic but at least some of the potential failures are now + handled gracefully. - * generic/ks_names.h: Added Scroll_Lock and Sys_Req definitions. + * tests/visual_bb.test (lpr): Stopped this from relying on + external files; direct piping is much more flexible for this + application. - * win/tkWinKey.c: Changed implementation of KeycodeToKeysym, - et. al., to use a keycode table for lookups; this will result in - faster keycode -> keysym translations for non-ASCII keys like - Control, Alt, etc. +2002-07-09 Don Porter -2000-04-14 Jeff Hobbs + * generic/tkTest.c: Removed unused dependence on TclThread_Init() + * tests/defs.tcl: and [testthread]. [Bug 578165, Tcl Bug 531413] - * win/tkWinWm.c (WmProc): added check in WM_MOUSEACTIVATE so we - correctly activate native menus when clicking in when we didn't - have focus [Bug: 2272] +2002-07-08 David Gravereaux - * generic/tkCanvas.c (CanvasEventProc:2451): corrected cast + * unix/Makefile.in: Added missing win/lamp.bmp to the dist + target. - * generic/tkEntry.c (Tk_EntryObjCmd): adjusted finishing error - cases and changed TK_CONFIG_NULL_OK to TK_OPTION_NULL_OK +2002-07-05 Jeff Hobbs - * tests/scale.test: - * generic/tkScale.c: - * generic/tkScale.h: - * unix/tkUnixScale.c: - * mac/tkMacScale.c: moved (PixelToValue|ValueToPixel|SetScaleValue) - to tkScale.c. Caused an associated variable to be immediately set - [Bug: 4833] + *** 8.4b1 TAGGED FOR RELEASE *** - * library/scale.tcl (tkScaleActivate): reduced number of scale - redisplays by checking current value of state before setting it - again. [Bug: 4191] +2002-07-04 Donal K. Fellows - * tests/winDialog.test: tk_chooseDirectory seems to get a noop - from GetOpenFileName in the static build, hanging some tests. - The tests were fixed to timeout (noop cause unknown). + * library/bgerror.tcl (bgerror): Stopped the bgerror dialog from + getting wider than the screen; in theory really long messages + could make it become taller than the screen now, but that's much + less likely to happen. Also trimmed a little bit of internal + space so that the icon-message gap is the same as the icon-frame + and message-frame gaps. - * unix/aclocal.m4 (SC_ENABLE_THREADS): enhanced the detection of - pthread_mutex_init [Bug: 4359] and (SC_CONFIG_CFLAGS) added - --enable-64bit-vis switch for Sparc VIS compilation [Bug: 4995] +2002-07-01 Don Porter -2000-04-13 Eric Melski + * unix/configure: + * unix/tcl.m4: Updated to latest tcl.m4 from Tcl. - * win/tkWinKey.c: Added smarts to check whether the left or right - Control, Shift, or Alt key was pressed. [Bug: 870]. +2002-06-28 Donal K. Fellows - * win/tkWinMenu.c: Corrected code that created separator items on - menus; originally, it requested that the system be responsible for - drawing those items, so it would ignore configuration items like - the widget background. Now, we draw the separators ourselves (as - we do with every other kind of menu item already). [Bug: 1166]. + * library/msgbox.tcl (MessageBox): Force all non-button widgets to + have the same background as the containing toplevel. [Bug #552515] - * win/tkWin3d.c: - * unix/tkUnix3d.c: Applied patch from [RFE: 2501]: adds more - sophisticated smarts to TkpGetShadows, so that the highlight of a - very bright color is actually distinguishable from the color, and - the shadow of a very dark color is similarly distinguishable from - the color. +2002-06-27 Andreas Kupries - * generic/tkCanvas.c: Applied patch from [Bug: 4202]; adds a check - for NULL tkwin in Tk_CanvasEventuallyRedraw. + * win/Makefile.in (install-binaries): Fix of troubled Makefile + quoting introduced by [Patch 521356] causing the installed to + fail. -2000-04-12 Jeff Hobbs +2002-06-25 Don Porter - * test/winClipboard.test: - * win/tkWinInt.h: - * win/tkWinClipboard.c (UpdateClipboard): - * win/tkWinX.c (GenerateXEvent): added updatingClipboard tsd and - TkWinUpdatingClipboard accessor function to allow us to flag - ourselves when we are the ones updating the clipboard. This - corrected inability to create our own clipboard types within a Tk - application. [Bug: 2338 4318] - * win/tkWinTest.c (TestclipboardCmd): improved TestclipboardCmd - with better error handling and obj'ification + * unix/tkUnixFont.c: (Tk_DrawChars) silence compiler warning. -2000-04-11 Eric Melski +2002-06-26 David Gravereaux - * msgcat.n: Added docs for new behavior from patch in [Bug: 4158]. + * generic/tkStyle.c: of the committing cvs client didn't + match the of the file itself. Windows users where getting + \r\r\n. Problem fixed. - * msgcat.test: Added tests for new behavior from patch in [Bug: - 4158]. - - * msgcat.tcl: Applied patch from [Bug: 4158], which enables - msgcat::mc to search the entire namespace ancestry chain for - message translations (ie, first it checks the current namespace, - then the parent, then the parent's parent, etc). Also allows the - specification of additional args for msgcat::mc; if extra args are - given, the [format] command is used to substitute the additional - args in the translated message. +2002-06-26 Anton Kovalenko - * library/bgerror.tcl: Moved check for withdrawn state after check - for tkerror; this was causing problems when tkerror was used. + * generic/tkFont.c (TkTextLayoutToPostscript): fixed potential + buffer overflow which could be intentionally triggered from + within safe interpreter -- malicious applet could modify + tk::psglyphs array. -2000-04-10 Eric Melski +2002-06-26 Anton Kovalenko - * library/bgerror.tcl: Added check for withdrawn state of . and - unsetting of transient bit for .bgerrorDialog if . is not - viewable; this protects against the application hanging on systems - like Windows, where transient windows are withdrawn with their - parents. [Bug: 4370]. + * tests/font.test (font-32.1): updated this test + to expect the new behavior of canvas postscript. - * tests/event.test: Added test for [event generate $widget - ] [Bug: 4611]. +2002-06-25 Don Porter - * tests/choosedir.test: Changed "namespace import ::tcltest" to - "namespace import -force ::tcltest". + * unix/Makefile.in: Expanded install-binaries target to create + * win/Makefile.in: and install a pkgIndex.tcl file to enable + Tk as a loadable package [Patch 521356] - * win/tkWinKey.c: - * unix/tkUnixKey.c: - * mac/tkMacKeyboard.c: Changed InitKeymapInfo to - TkpInitKeymapInfo. [Bug: 4611]. +2002-06-25 Anton Kovalenko - * generic/tkStubInit.c: - * generic/tkIntDecls.h: Re-gen'd from tkInt.decls. + * library/mkpsenc.tcl: (added) utilities to generate + Postscript prolog for current system encoding. + * generic/tkCanvPs.c (TkCanvPostscriptCmd): now + uses mkpsenc.tcl to generate Postscript prolog. + * generic/tkFont.c (TkTextLayoutToPostscript): modified + according to patch #546910. Now outputs system-encoded + characters (for unibyte) or Adobe glyph names (for + multibyte or outside-locale). + * tests/canvText.test (canvText-17.1): updated this test + to expect the new behavior of canvas postscript. - * generic/tkInt.decls: Added TkpInitKeymapInfo to list of function - decls. +2002-06-25 Reinhard Max - * generic/tkBind.c (HandleEventGenerate): Added code to initialize - keymap info if necessary, and to correctly set modifier bits in - XEvent structure create to handle [event generate] calls. - Previously, the alt/meta bits were not set correctly, so [event - generate $widget ] would always fail. [Bug: 4611] + * unix/tcl.m4: New macro SC_CONFIG_MANPAGES. + * unix/configure.in: Added support for symlinks and compression + * unix/Makefile.in: when installing the manpages. [Patch 518052] + Default is still hardlinks and no compression. -2000-04-07 Jeff Hobbs + * unix/mkLinks: generated + * unix/configure: - * generic/tkGrid.c (InitMasterData): fixed uninit'd data in - GridMaster struct [Bug: 4387] + * unix/README: Added documentation for the new features. + + * unix/configure: Replaced ${exec_prefix}/lib + * unix/tcl.m4 (SC_PATH_TCLCONFIG): by ${libdir}. + +2002-06-24 Mo DeJong + + * tests/winWm.test: Verify that both an unmapped + and already mapped toplevel are raised and receive + the focus when deiconified. + * tests/wm.test: Add wm deiconify tests. Check that + a toplevel that has never been mapped is not mapped + by the deiconify command since it should be done + at idle by MapFrame. + * win/tkWinWm.c (Tk_WmCmd): Check the WM_NEVER_MAPPED + flag while processing the wm deiconify command. + The WM_UPDATE_PENDING flag should never be set when + WM_NEVER_MAPPED is set, but double check so that + the implementation is more explicit and matches + the comment just above. + Return without invoking TkWmRestackToplevel or + TkSetFocusWin on a toplevel that has never been + mapped. This fixes a bug where a toplevel is mapped + with the wrong size and is then resized by the + idle call to MapFrame. [Tk bug 233150] + +2002-06-23 Jeff Hobbs + + * win/tkWinWm.c (UpdateGeometryInfo): remove the check for a null + wrapper introduced in r1.41 on 2002-06-15 because it prevented + geometry setting from taking effect if the window was not on the + screen. Another check may go in it's place as IsIconic and + IsZoomed should not be passed NULL. + +2002-06-22 Mo DeJong + + * tests/wm.test: Remove invalid minsize test. Add update + calls to wm transient tests so that idle handlers get + run. This is needed to get the tests to pass under Win32. + * unix/tkUnixWm.c (WmWaitMapProc): Move the special + transient withdrawn check into the if body to + make it easier to set a breakpoint on this test + inside a debugger. No functional changes. + * win/tkWinWm.c (WmWaitVisibilityOrMapProc): Ditto. + +2002-06-22 Jeff Hobbs + + * doc/wm.n: TIP #95 Windows implementation and + * mac/tkMacWm.c (Tk_WmCmd): docs with mac and unix stubs. + * unix/tkUnixWm.c (Tk_WmCmd): + * win/tkWinWm.c (Tk_WmCmd): + * tests/unixWm.test: + * tests/winWm.test: more wm attr tests will be needed. - * library/safetk.tcl (disallowTk): made disallowTk work in the - simple case. + * generic/tkGrid.c (GridReqProc): check that gridPtr is not NULL + (may be when embedded). [Bug #548791] (halliday) - * library/comdlg.tcl (tkFocusGroup_In): fixed key navigation - problems in dialogs under CDE [Bug: 2960] + * generic/tkFont.c (TkFontPkgFree): changed panic on freeing fonts + to an assert, and wrapped panic in #ifdef PURIFY. [Bug #568701] - * tests/winDialog.test: removed knownBug constraint from 5.16 + * library/menu.tcl: corrected menus from being posted offscreen + on Windows. [Bug #464451] (darley) - * win/tkWinFont.c (GetScreenFont): corrected adjustment against - LC_FACESIZE limitation for NT [Bug: 4931] + * library/console.tcl: corrected the defaultPrompt substitution + [Bug #553207] and made Tab a default expansion key (like Escape). - * win/makefile.vc (TKTEST_OBJS): - * win/Makefile.in (TKTEST_OBJS): moved tkWinTest.c from normal - objs to TKTEST_OBJS where it belonged. + * win/tkWinEmbed.c (EmbedWindowDeleted): added a check for a null + containerPtr. The core of this bug is likely elsewhere. [Bug #476176] -2000-04-03 Jeff Hobbs + * doc/text.n: TIP #93 implementation that + * generic/tkText.c (TextWidgetCmd): enhances the text get and + * generic/tkTextIndex.c (TkTextGetIndex): delete methods to accept + * tests/text.test: multiple range pairs. + This handles the delete case in an atomic, fixed-index fashion. - * generic/tkTest.c: fixed incorrect platform inclusion for - TkplatformtestInit (it would never get called). +2002-06-21 Mo DeJong - * unix/Makefile.in (MAN_INSTALL_DIR): patch to accept --mandir - correctly [Bug: 4085] + * tests/wm.test: Add tests to make sure a withdrawn + transient does not get remapped by state changes + in the master. + * unix/tkUnixWm.c (Tk_WmCmd, WmWaitMapProc): + * win/tkWinWm.c (Tk_WmCmd, WmWaitVisibilityOrMapProc): + Add a WM_TRANSIENT_WITHDRAWN flag that gets set by the + withdraw, deiconify, or state wm subcommands. Check + this flag before mapping a transient when processing + a MapNotify event. [Tk bug 570764] - * library/clrpick.tcl (tkColorDialog_Config): error now thrown - when -initialcolor "" specified. [Bug: 4198] +2002-06-21 Donal K. Fellows -2000-03-31 Jeff Hobbs + * unix/tk.spec (version), README, win/configure.in, unix/configure.in: + * generic/tk.h (TK_RELEASE_*, TK_PATCH_LEVEL): Bumped to beta1. - * doc/DrawFocHlt.3: doc name correction +2002-06-21 Jeff Hobbs - * generic/tkEntry.c: set TK_OPTION_NULL_OK bit on -invcmd option - and removed #ifdef ENTRY_VALIDATE expressions + * doc/text.n: TIP #104 implementation which generalizes the + * generic/tkText.c: undo/redo stack to not be tied solely to the + * generic/tkText.h: text widget. The APIs are still private. + * generic/tkUndo.c: This also adds a stack limiting ability and + * generic/tkUndo.h: a -maxundo option to the text widget (in + * library/text.tcl: addition to the options from TIP #26) should + * mac/tkMacDefault.h: users want to limit the undo/redo stack + * tests/text.test: (should not be necessary in most cases). + * unix/Makefile.in: [Patch #554763] (callewart) + * unix/tkUnixDefault.h: + * win/Makefile.in: + * win/makefile.vc: + * win/tkWinDefault.h: + +2002-06-21 Don Porter + + * unix/Makefile.in: Removed unnecessary dependence of tktest + * unix/tkAppInit.c: executable on the tcltest executable on + Unix. If there are similar dependencies on other platforms, they + can probably be removed as well. [Bug 572134]. + +2002-06-20 Jeff Hobbs + + * doc/listbox.n: + * generic/tkListbox.c (DisplayListbox): + * mac/tkMacDefault.h: TIP #94 implementation adding -activestyle + * tests/listbox.test: option to the listbox. This adds the ability + * unix/tkUnixDefault.h: to have listboxes look native on Windows, and + * win/tkWinDefault.h: "nicer" elsewhere using the 'dotbox' style. + +2002-06-20 Peter Spjuth + + * generic/tkGrid.c: Corrected the test for grid propagate change. + [Bug #571433] + +2002-06-19 Jeff Hobbs + + * tests/panedwindow.test: + * generic/tkPanedWindow.c: ensure that sash index is lower bounds + checked. [Bug #548727] + +2002-06-19 Mo DeJong + + * generic/tkClipboard.c (TkClipCleanup): Add code + to set dispPtr->clipWindow to NULL, this was + accidently removed by last commit. Fixes + a crash while running the tests under win32. + +2002-06-19 Mo DeJong + + * generic/tkBind.c (TkBindDeadWindow): + Handle case where Tk_DestroyWindow is invoked + on clipboard and send windows. + * generic/tkClipboard.c (TkClipCleanup): + Invoke Tk_DestroyWindow to cleanup the + dispPtr->clipWindow. Call Tcl_Preserve + and Tcl_Release on the window to avoid an + invalid memory ref on shutdown. + * generic/tkEvent.c (Tk_HandleEvent): + Panic if XCreateIC is invoked twice for + the same window. This should never happen, + the check were just added to make sure it + does not since this could lead to crashes + in XCloseIM. + * generic/tkFocus.c (TkFocusDeadWindow): + Handle case where Tk_DestroyWindow is invoked + on clipboard and send windows. + * generic/tkOption.c (TkOptionDeadWindow): Ditto. + * generic/tkWindow.c (TkCloseDisplay): Move + deletion of dispPtr->winTable after TkpCloseDisplay + call since Tk_DestroyWindow uses it and could + be called by TkpCloseDisplay for clipboard/send windows. + Also invoke ckfree for the dispPtr instead of + doing it in TkpCloseDisplay. + (Tk_DestroyWindow): Check for a null winPtr->mainPtr + before doing certain cleanup tasks so the we can + invoke Tk_DestroyWindow on clipboard and send windows. + We need to do this so that XDestroyIC will get invoked + for the input contexts of each window. + * mac/tkMacXStubs.c (TkpCloseDisplay): Don't free + the displayPtr since this is now done in TkCloseDisplay. + * unix/tkUnixEvent.c (TkpCloseDisplay, OpenIM): Remove + conditional compilation around calls to XCloseIM + since I am confident that the crashes related to + input contexts has been fixed. Don't free + the displayPtr since this is now done in TkCloseDisplay. + * unix/tkUnixSend.c (TkSendCleanup): Invoke the + Tk_DestroyWindow method to cleanup the special + send window. This will call XDestroyIC and thereby + avoid a crash in XCloseIM. The send window needs + to be Tcl_Preserve and Tcl_Release to avoid an + invalid memory ref on shutdown. + * win/tkWinX.c (TkpCloseDisplay): Don't free + the displayPtr since this is now done in TkCloseDisplay. + [Tk patch 570902] + +2002-06-19 Donal K. Fellows + + * generic/tkStyle.c: TIP#48 style engine. + See http://purl.org/tcl/tip/48.html for details. + + * generic/tkConfig.c (GetOptionFromObj): Split to allow for access + to option tables via name as well as via object. + (TkGetOptionSpec): Semi-public interface to GetOption functionality. + (DoObjConfig, Tk_RestoreSavedOptions, FreeResources) + (GetObjectForOption): Basic style support for configure. + + * generic/tkWindow.c (TkCreateMainWindow, Tk_DestroyWindow): Added + calls to set up and tear down the style subsystem. + + * generic/tk.decls, generic/tk.h: Many declarations forming TIP#48 + public interface. + + * generic/tkInt.decls (TkStylePkgInit,TkStylePkgFree): + * generic/tkInt.h (TkGetOptionSpec): Supporting declarations. + + * unix/Makefile.in, win/Makefile.in, win/makefile.vc: Added + tkStyle.c to list of generic source files. + +2002-06-18 Donal K. Fellows + + * tests/defs.tcl (makeFile): Defined the return value of this + procedure to be the filename of the created file, as in the real + tcltest package... + +2002-06-17 Mo DeJong + + * generic/tkImage.c (Tk_ImageObjCmd, DeleteImage): Call + Tcl_Preserve and Tcl_Release for the masterPtr->winPtr + window to avoid accessing memory that had already + been deallocated in DeleteImage. + +2002-06-17 David Gravereaux + + Trims to support the removal of RESOURCE_INCLUDED from rc + scripts from Tcl's accepted FR #565088. + + * generic/tk.h: Changed RESOURCE_INCLUDED to be RC_INVOKED + as the RC tool defines this already by default. + + * win/rc/tk.rc: + * win/rc/wish.rc: removed the #define RESOURCE_INCLUDED lines. + +2002-06-17 Jeff Hobbs + + * unix/Makefile.in (dist): correct installation of + wish.exe.manifest to DISTDIR target directory. + + * generic/tkCmds.c (Tk_TkObjCmd): + * generic/tkInt.h (struct TkCaret): + * mac/tkMacXStubs.c (Tk_SetCaretPos): + * unix/tkUnixKey.c (TkpGetString, Tk_SetCaretPos): + * win/tkWinX.c (Tk_SetCaretPos): + * tests/tk.test: Added 'tk caret' implementation of TIP#96 + * doc/SetCaret.3 (new): which adds a TkCaret structure element to + * doc/tk.n: TkDisplay for maintaining state. + + * unix/tkUnixSend.c (TkSendCleanup): special cleanup of + inputContext to avoid bug in XCloseIM. (dejong) + +2002-06-17 Don Porter + + * library/msgs/en_gb.msg: Added catalog for UK English. + Currently includes only Color -> Colour translation. + +2002-06-17 D. Richard Hipp + + * doc/checkbutton.n: + * doc/radiobutton.n: + * generic/tkButton.c: + * generic/tkButton.h: + * mac/tkMacButton.c: + * tests/button.test: + * unix/tkUnixButton.c: + * win/tkWinButton.c: Implementation of TIP#82 - Added the + -offrelief option to checkbutton and radiobutton. - * library/menu.tcl (tkMenuInvoke): corrected naming of tearoffs - [Bug: 4506] +2002-06-14 Mo DeJong - * library/tkfbox.tcl (tkIconList_Goto): caused browsecmd to be - called in tkIconList_Select. This causes the entry to be set - properly when using the type-in-name-in-listbox bindings. + * generic/tkWindow.c (Tk_DestroyWindow): Set the pathName + component of a window to NULL after its memory has been + deallocated to avoid a possible illegal memory access + as a result of a call to Tk_PathName() on a Tk_Window + structure of a window that has already been destroyed. + [Tk bug 521946] - * win/tkWinDialog.c: added unicode-aware open/save file dialogs +2002-06-14 Mo DeJong - * win/tkWinFont.c (TkpFontPkgInit): move private ref to platformId - to TkWinGetPlatformId + * generic/tkOption.c (Tk_GetOption): Allocate + memory with ckalloc not malloc. This keeps + Tk from erroring out when built with + TCL_MEM_DEBUG. - * win/tkWinMenu.c (SetDefaults): moved private use of versionInfo - to TkWinGetPlatformId and removed all code for - (versionInfo.dwMajorVersion < 4) (== Win32s) +2002-06-14 Jeff Hobbs - * win/tkWinX.c: - * win/tkWin32Dll.c: moved TkWinGetPlatformId to tkWinX.c - * win/tkWinInit.c: added TkWinXInit to TkpInit to ensure that its - called for static Windows shells. [Bug: 3647] + * generic/tkBind.c (HandleEventGenerate): + * generic/tkInt.h: changed warpInProgress boolean from int to a + bit in the flags variable (TK_DISPLAY_IN_WARP) - * win/tkWinInt.h: - * win/tkWinX.c: - * win/tkWinDraw.c (SetUpGraphicsPort): - * win/tkWinScrlbr.c (UpdateScrollbar): removed use of tkpIsWin32s + * generic/tkCmds.c (Tk_TkObjCmd): + * unix/tkUnixKey.c (TkpGetString): + * generic/tkEvent.c (Tk_HandleEvent): + * generic/tkInt.h: changed useInputMethods boolean from int to a + bit in the flags variable (TK_DISPLAY_USE_IM) - * win/tkWinInt.h (TkWinDCState struct): added bkmode value - * win/tkWinDraw.c (TkWinGetDrawableDC, et al): added support for - properly transparent dashed lines on Windows. [Bug: 4617] + * generic/tkInt.h: + * generic/tkCmds.c (Tk_WmObjCmd): + * unix/tkUnixWm.c (Tk_WmCmd): + * win/tkWinWm.c (Tk_WmCmd): changed wmTracing from being an int to + just a bit in the flags variable (TK_DISPLAY_WM_TRACING) + + * generic/tkEvent.c (Tk_HandleEvent): + * unix/tkUnixEvent.c (OpenIM): + * unix/tkUnixKey.c (TkpGetString): + * generic/tkInt.h: added TK_DISPLAY_XIM_SPOT flag bit for TkDisplay + and used this to allow a runtime check to see if over-the-spot XIM + is possible. If not it will try and fallback to the old-style + input context, which handles things like dead keys input. + + * generic/tk.decls: added TIP #84 implementation that adds a + * generic/tkDecls.h: Tk_CollapseMotionEvents API which controls + * generic/tkEvent.c: Tk's collapsing of incoming motion events + * generic/tkInt.h: on its windows. The default remains to do + * generic/tkStubInit.c: collapsing. Added a flags parameter to the + * generic/tkWindow.c: internal display structure to support this + * doc/QWinEvent.3: and be used in the future for other bits. + [Tk patch 564642] + + * unix/mkLinks: updated from current docs + +2002-06-14 Mo DeJong + + * generic/tkEvent.c (TkXErrorHandler): Declare static + function to avoid compiler error with VC++. + * generic/tkBind.c (ExpandPercents): Cast argument to + Tk_GetAtomName in order to avoid compiler warning. + +2002-06-14 Joe English + + * doc/bind.n: + * generic/tk.h: + * generic/tkBind.c: + * generic/tkCanvWind.c: + * generic/tkCmds.c: + * generic/tkEvent.c: + * generic/tkFocus.c: + * generic/tkGrab.c: + * generic/tkGrid.c: + * generic/tkImage.c: + * generic/tkPack.c: + * generic/tkPlace.c: + * generic/tkPointer.c: + * generic/tkTextWind.c: + * generic/tkWindow.c: + * mac/tkMacSubwindows.c: + * mac/tkMacWindowMgr.c + * mac/tkMacWm.c: + * unix/Makefile.in: + * unix/tkUnixEmbed.c: + * unix/tkUnixWm.c: + * win/tkWinScrlbr.c: + * win/tkWinWindow.c: + * win/tkWinWm.c: Implementation of TIP #47 by Neil McKay + "Modifying Tk to Allow Writing X Window managers". + Add CirculateRequest, Create, MapRequest, ResizeRequest, + and ConfigureRequest event types; + Split TK_TOPLEVEL flag into TK_TOPLEVEL, TK_HAS_WRAPPER, + TK_WIN_MANAGED, and TK_TOP_HIERARCHY. [Tk patch 572978] -2000-03-30 Eric Melski +2002-06-14 Andreas Kupries - * generic/tkImgGIF.c: Fixed some ANSI specific bits to avoid - compile problems with non-ANSI compilers (ie, replace const with - CONST, etc). [Bug: 4223]. + * unix/tkAppInit.c: Removed now unneeded and erroneous reference + to 'matherr'. See Tcl ChangeLog entry 2002-05-31 Don Porter. - * unix/configure.in: Applied patch from [Bug: 4237]; ensures that - srcdir is fully qualified. +2002-06-14 David Gravereaux - * unix/Makefile.in: Applied patch from [Bug: 4237]; if tcltest was - not compiled, make test/tktest failed. Now it has a rule to build - tcltest if it has not been built. + * win/rules.vc: The test for compiler optimizations was in error. + Thanks goes to Roy Terry for his + assistance with this. -2000-03-28 Eric Melski +2002-06-14 Donal K. Fellows - * library/tkfbox.tcl: Moved an overlooked tkFDialog* function in - ::tk::dialog::file namespace. + Implement TIP 98 [Tk patch 566765] + + * doc/FindPhoto.3, generic/tk.h, generic/tk.decls: + * generic/tkImgPhoto.c: Changed *_Old to *_NoComposite and + USE_OLD_PHOTO_PUT_BLOCK to USE_COMPOSITELESS_PHOTO_PUT_BLOCK + following a suggestion from Don Porter. - * tests/unixWm.test: Added tests for memory leak conditions in - tkUnixWm.c. + * tests/imgPhoto.test: Added tests of -compositingrule - * tests/canvas.test: Added test for bad configuration options on - empty and non-empty canvas. + * doc/photo.n: Added documentation for "-compositingrule". + * generic/tkImgPhoto.c (ImgPhotoCmd, ParseSubcommandOptions): New + "-compositingrule" option for [$photo copy] subcommand, using + OPT_COMPOSITE flag and compositingRule field in SubcommandOptions + structure. - * generic/tkCanvas.c: Removed bad code in CANV_CONFIGURE block of - CanvasWidgetCmd; this was causing non-empty canvases to improperly - handle bad configuration options [Bug: 4456]. + * doc/FindPhoto.3: Documented the extra argument for the + compositing rule and the action to take if anyone wants to + maintain total backward-compatability. -2000-03-27 Eric Melski + * generic/tk.h (TK_PHOTO_COMPOSITE_*): Defined values for use as + compositing rules. + (USE_OLD_PHOTO_PUT_BLOCK): Added a way for users to select the old + interface to Tk_PhotoPutBlock to provide an easier upgrade path. - * unix/tkUnixWm.c: Applied patch from [Bug: 4405]; fixes memory - leak in Unix wm command. + * generic/tk.decls: Alter Tk_PhotoPut*Block to Tk_PhotoPut*Block_Old + and introduce new slots for the old name of function with an extra + argument at the end for the compositing rule. -2000-03-24 Eric Melski + * generic/tkImgPhoto.c (ImgPhotoCmd): Updated "transparency set" + subcommand to use TkSubtractRegion(). - * tests/filebox.test: - * tests/choosedir.test: Updated tests. + * win/tkWinRegion.c (TkSubtractRegion): + * mac/tkMacRegion.c (TkSubtractRegion): + * generic/tkInt.decls (TkSubtractRegion): + * unix/tkUnixPort.h (TkSubtractRegion): Added function to perform + the set-difference operation on regions; it seems all platforms + can support it, and it makes removing rectangular bits from + regions much easier. - * library/xmfbox.tcl: Updated to stash data array in - ::tk::dialog::file namespace instead of in global namespace. + * generic/tkImgPPM.c (FileReadPPM): Reading a PPM/PGM always uses + the SET compositing rule because it is faster and the format does + not have any transparency information. - * library/tkfbox.tcl: Extended some functions to support creation - of a choosedir dialog, to allow greater code reuse between the two - dialogs. Moved tkFDialog* functions into a namespace - (::tk::dialog::file). Because these are private Tk functions (and - should thus not be used directly by users), this should not impact - anybody (the tk_getOpenFile and tk_getSaveFile commands still - exist at the global scope). + * generic/tkImgGIF.c (FileReadGIF): Reading a GIF always uses the + SET compositing rule because GIF files model transparency as a + single special colour. - * library/tk.tcl: - * library/tclIndex: Updated function names for tkFDialog* - functions and choosedir functions. + * generic/tkImgPhoto.c (Tk_PhotoPutBlock, Tk_PhotoPutZoomedBlock): + Added a compositing rule to allow better control over what happens + to transparent pixels when inserting data into a photo image. - * library/choosedir.tcl: New and improved implementation of - tk_chooseDirectory dialog. Based on tk_getOpenFile dialog. +2002-06-13 Mo DeJong -2000-03-23 Eric Melski + * tests/winfo.test: Add basic tests for winfo ismapped. - * generic/tkWindow.c: - * generic/tkInt.h: Updated Tcl_OptionCmd -> Tcl_OptionObjCmd +2002-06-13 Mo DeJong - * generic/tkOption.c: Tcl_Obj'ectified the "option" command. + * tests/unixWm.test: + * tests/wm.test: Move wm minsize and wm maxsize + usage tests into the cross platform wm tests. + +2002-06-13 Don Porter + + * tests/cursor.test: corrected error after cursor-2.2. + * tests/defs.tcl: Added enhancements to Tk's fake version of + tcltest required by recent cursor.test changes. + +2002-06-13 Donal K. Fellows + + * tests/cursor.test (cursor-2.[34]): Tests added to ensure that + cursor specs really are well-behaved lists. Also some general + clean-up... + * win/tkWinCursor.c (TkGetCursorByName): Undone Jeff's back-off + and fixed things so that they should work now. Cursor specs are + lists first and foremost. + +2002-06-12 Mo DeJong + + * changes: Clearly label wm transient changes as + a POTENTIAL INCOMPATIBILITY. + * doc/wm.n: Remove "some window managers will" text + and explicitly state what behavior a transient + window will display. Also mention that it is an + error to make a window a transient of itself. + +2002-06-12 Mo DeJong + + * library/choosedir.tcl (tk::dialog::file::chooseDir): + * library/clrpick.tcl (tk::dialog::file::chooseDir): + * library/msgbox.tcl (tk::MessageBox): + * library/tkfbox.tcl (tk::dialog::file): + * library/xmfbox.tcl (tk::MotifFDialog): Remove the + transient property on dialogs after they have been + dismissed to insulate them from further state changes + in the master. This keeps a withdrawn dialog from + being mapped when the master is deiconified. [Tk patch 568278] + +2002-06-12 Jeff Hobbs + + * win/tkWinCursor.c (TkGetCursorByName): reverted fix from + 2002-06-06 because it broke the ability to use built-in cursors + like left_ptr. + +2002-06-12 Mo DeJong + + * library/choosedir.tcl (tk::dialog::file::chooseDir): + * library/clrpick.tcl (tk::dialog::color): + * library/dialog.tcl (tk_dialog): + * library/msgbox.tcl (tk::MessageBox): + * library/tkfbox.tcl (tk::dialog::file): + * library/xmfbox.tcl (tk::MotifFDialog_Create): + Only make the dialog window a transient if + the master is visible. This check already + appeared in some of the dialogs. This patch + just copies the check into those that were + lacking. [Tk patch 568253] + +2002-06-12 Mo DeJong + + * changes: Add note about new transient behavior. + * tests/unixWm.test: Check that the WM_TRANSIENT_FOR + property for a transient window is being cleared + when the master is destroyed. + * tests/wm.test: Source defs.tcl instead of using + tcltest to match the rest of Tk's test files. + Add new tests that ensure that a transient's state + mirrors the state of the master. + * unix/tkUnixWm.c (WmInfo, TkWmNewWindow, TkWmMapWindow, + TkWmDeadWindow, Tk_WmCmd, WmWaitMapProc): Add numTransients + member to WmInfo structure. Keep state of master and + transient in sync using a callback that tracks MapNotify + and UnmapNotify events. When the master is mapped, map + the transient. When the master is unmapped or iconified, + withdraw the transient. + * win/tkWinWm.c (TkWmMapWindow, TkpWmSetState, + TkWmDeadWindow, Tk_WmCmd, WmWaitVisibilityOrMapProc): + Keep state of master and transient in sync using a + callback that tracks MapNotify and UnmapNotify events. + Move masterPtr check from TkpWmSetState into TkWmMapWindow + to deal with WM_NEVER_MAPPED transients. Cleanup + numTransients and the callback in TkWmDeadWindow. + Cleanup numTransients and the callback only after + deleting a master in wm transient command to avoid + deleting the callback when an error is raised. + Add support for MapNotify and UnmapNotify events + to the master callback. [Tk patch 561708] + +2002-06-11 Joe English + + * library/menu.tcl: fix for bug report #530212 "Bad Window Path + Name in tkMenuFind" + +2002-06-10 David Gravereaux + + * win/makefile.vc: Fixed a win98 issue where the /exclude option + for xcopy is unsupported. + Reported by Roy Terry . + +2002-06-10 Anton Kovalenko + + * library/tk.tcl: added utility functions to get "-underline" and + "-text" for labels and buttons from translatable string containing + "magic ampersand" [patch #566605] + * library/clrpick.tcl: + * library/msgbox.tcl: + * library/tkfbox.tcl: + * library/xmfbox.tcl: some places where msgcat is used to get + translated label are modified to handle labels with magic ampersand. + * library/msgs/ru.msg: russian translations added + * library/msgs/cs.msg: + * library/msgs/de.msg: + * library/msgs/el.msg: + * library/msgs/es.msg: + * library/msgs/fr.msg: + * library/msgs/it.msg: + * library/msgs/nl.msg: all translation files now have labels with + 'magic ampersand' where appropriate. In el.msg some ampersands are + missing, as I don't know which underline positions seems natural + to "el" users. + +2002-06-09 Mo DeJong + + * library/bgerror.tcl (tk::dialog::error::bgerror): + Don't set the bgerror dialog as a transient of + itself since this operation is ill defined. + +2002-06-06 Donal K. Fellows + + * win/tkWinCursor.c (TkGetCursorByName): Fixed so that the reading + of cursors from a file with a cursor spec was built using [list] + works when the file has a space in instead of requiring fiddling + with backslashes. + +2002-06-06 Anton Kovalenko + + * library/msgbox.tcl (MessageBox): Add -default normal + when creating non-default buttons for message box. + They already get -default normal when they're + unfocused, and dialog window size used to change suddenly + in such cases. + +2002-06-05 Anton Kovalenko + + * unix/tkUnixFont.c (Tk_DrawChars): Don't assume that + one char is always one byte, and that required + subfont for the last character in any string is + the same as for the previous character + [Bug #559435] [Patch #559437] + +2002-05-27 Mo DeJong + + * changes: Document [wm transient .t .t] error. + * tests/wm.test: Check that setting a window + as a transient of itself raises an error. Check + that passing a non-toplevel window to the wm + transient command uses the enclosing toplevel. + * unix/tkUnixWm.c (Tk_WmCmd): Raise an error + if the user tries to make a toplevel a + transient of itself. + * win/tkWinWm.c (Tk_WmCmd): Raise an error + if the user tries to make a toplevel a + transient of itself. Test for other error + before checking for the transient self error. + +2002-05-27 Mo DeJong + + * unix/tkUnixWm.c (WmInfo, TkWmCleanup, TkWmNewWindow, + TkWmMapWindow, TkWmDeadWindow, Tk_WmCmd): Replace + WmInfo's master and masterWindowName members with + a masterPtr member. This implementation is much + simpler and mirrors the Win32 implementation. This + change makes it easy to check the flags of the + master window. No user visible changes. + +2002-05-27 Mo DeJong + + * generic/tkInt.decls: Add unix decl for TkpWmSetState. + * generic/tkIntPlatDecls.h: Regen. + * generic/tkStubInit.c: Regen. + * tests/wm.test: Test state changes between iconic, + normal, and withdrawn both before and after initial + mapping. + * unix/tkUnixWm.c (Tk_WmCmd, TkpWmSetState): Move + state change code into TkpWmSetState to more closely + match the Win32 implementation. No user visible changes. + +2002-05-27 Mo DeJong + + * tests/embed.test: Added cross platform embed tests. + Check that window passed to -use has the -container + option set. + * tests/wm.test: Remove useless catch call. Deiconify + . just in case, stackorder tests will not pass unless + it is in the normal state. Add -container flag to + embedded stackorder test. + * unix/tkUnixEmbed.c (TkpUseWindow): + * win/tkWinEmbed.c (TkpUseWindow): Lookup Tk window + based on the id passed in as the value for -use. + Generate an error if the Tk window did not have + the -container option set. + +2002-05-26 Peter Spjuth + + * generic/tkButton.c (ConfigureButton): When creating + a radiobutton with -value "" it was not drawn properly + if the -variable was created by the radiobutton. + [Bug #548765] + +2002-05-26 Peter Spjuth + + * generic/tkCanvText.c (ComputeTextBbox): Negative + coordinates were rounded badly causing a 1 pixel + displacement. [Bug #556526] + +2002-05-24 Mo DeJong -2000-03-22 Eric Melski + * mac/tkMacWm.c (Tk_WmCmd): + * tests/unixWm.test: Move wm transient checks over + to wm.test so they will be run on all systems. + * tests/wm.test: Add tests to check for error when + an iconwindow is passed to the wm transient command. + * unix/tkUnixWm.c (Tk_WmCmd): + * win/tkWinWm.c (Tk_WmCmd): Raise an error if one + of the windows passed to the wm transient command + is an iconwindow for another toplevel. - * library/listbox.tcl (tkListboxCancel): Added a check for empty - string value for tkPriv(listboxPrev). Without this check, it's - possible to get a stack trace under certain conditions. [Bug: 4373]. +2002-05-23 Mo DeJong -2000-03-15 Sven Delmas + * mac/tkMacWm.c (TkWmStackorderToplevelWrapperMap): + * tests/wm.test: Add embedded Window test case for + the stackorder command. + * unix/tkUnixWm.c (TkWmStackorderToplevelWrapperMap): + * win/tkWinWm.c (TkWmStackorderToplevelWrapperMap): + Ignore embedded windows during wm stackorder command. - * win/tkWinDialog.c: Changed the behavior for the - tk_chooseDirectory dialog under Windows. Instead of trying to - return the currently selected listbox entry (which didn't work in - case the user selected the initial directory anyway), we now - return the value shown in the entry. This seems to be in - accordance with the expected behavior for this dialog. +2002-05-21 Mo DeJong -2000-03-14 Eric Melski + * unix/configure: Regen. + * unix/configure.in: Invoke SC_ENABLE_SHARED before + calling SC_CONFIG_CFLAGS so that the SHARED_BUILD + variable can be checked inside SC_CONFIG_CFLAGS. + * unix/tcl.m4: Update from Tcl. - * tests/choosedir.test: Marked test 3.1 and 3.2 as bad until the - issue with those tests on IRIX can be determined. +2002-05-20 Don Porter -2000-03-10 Eric Melski + * library/tk.tcl: A little namespace cleanup on Daniel Steffen's + latest revisions to avoid defining new global commands. - * library/menu.tcl: Applied patch from [Bug: 4155]; protects - against grabs on non-viewable windows. +2002-05-20 Daniel Steffen -2000-03-08 Eric Melski + * mac/tkMacInit.c: + * mac/tkMacTclCode.r: include msgcat package in resources + as bgerror depends on it. Restores ability of mac static + build to run standalone (except for encoding file issues). - * tests/choosedir.test: Modified test 3.1 (-mustexist works) to be - more careful about cleaning up its potentially troublesome after - events. + * mac/tkMacInit.c: + * library/console.tcl: + * library/tk.tcl: fix tk.tcl not sourcing library files + that define bindings at startup on mac. (independent of + tk library files being in resources or on auto_path) -2000-03-07 Eric Melski +2002-05-08 Don Porter - * tests/button.test: - * generic/tkButton.c: Added -disabledforeground/-state to labels. + * library/bgerror.tcl: + * library/tclIndex: Cleaned up namespace usage of the bgerror + dialog. Completes soft dependence on msgcat. [FR 539309] -2000-03-07 Jeff Hobbs +2002-05-07 David Gravereaux + * win/makefile.vc: Problem with TCLDIR macro not accepting + forward slash path seperators resolved. Added the same logic + to INSTALLDIR, too. [Bug #553208] - * tests/entry.test: - * generic/tkEntry.c (EntrySetValue): malloc the value when - validating because validation could cause the pointer to become - invalid. Also fixed configure to not trigger focus-based - validation. Improved use of Tcl_WrongNumArgs. [Bug: 4320] +2002-04-26 Jeff Hobbs -2000-03-06 Eric Melski + * unix/configure: + * unix/tcl.m4: change HP-11 SHLIB_LD_LIBS from "" to ${LIBS} so + that the .sl knows its dependent libs. + +2002-04-24 Daniel Steffen + + * mac/tkMacTclCode.r: + * mac/tkMacResource.r: added check of + TCLTK_NO_LIBRARY_TEXT_RESOURCES #define to allow disabling the + inclusion of the tk library code in the resource fork of Tk + executables and shared libraries. + Moved tk library code inclusion to separate file like in tcl. + Added 'panedwindow' resource. + +2002-04-22 Jeff Hobbs + + * library/button.tcl (ButtonLeave): corrected the 3 + implementations of ButtonLeave to check for Priv(relief) existing + before trying to use it. [Patch #541849] + + * generic/tkTextDisp.c (DisplayLineBackground): + * unix/tkUnix3d.c (Tk_3DHorizontalBevel): + * unix/tkUnixFont.c (Tk_DrawChars): applied fixes to not overrun + the X window 16-bit size limit. [Patch #541999] (bonfield) + +2002-04-22 Donal K. Fellows + + * generic/tkTextDisp.c (GetXView, GetYView): Comparison with + previous values of scrollbar range are now done in a way that is + sensitive to the bizarreness of floating-point on architectures + where IEEE-FP is not used on the processor. Also increased the + size of the temporary buffer to take account of the fact that + TCL_DOUBLE_SPACE is meant to only imply enough space to take a + printed double and trailing '\0', and no more. [Bug #223739] + (FP_EQUAL_SCALE): New macro to help compare floating-point numbers + for equality in a sane way, used in GetXView and GetYView. + +2002-04-12 Jeff Hobbs + + * generic/tkWindow.c (TkCloseDisplay): Added to centralize where a + display was closed. This handles freeing memory associated with a + display and closing it. + (DeleteWindowsExitProc): actually close displays. This would also + ideally be done in Tk_DestroyWindow when the last window on the + display has been closed, but that still has unresolved order of + cleanup problems. + (Tk_DestroyWindow): added TkFocusFree call. - * library/menu.tcl: Added a check in tkMenuFirstEntry that changes - menu behavior to only auto-post an immediate child cascade if we - are currently on a menubar menu. This prevents massive - auto-cascading in cases where the first entry of the cascade is - itself a cascade, and the first entry of that cascade is a - cascade, and the first entry of that cascade is a cascade - ... [Bug: 676]. + * generic/tkStubInit.c: + * generic/tkIntPlatDecls.h: + * generic/tkIntDecls.h: + * generic/tkInt.decls: added TkFocusFree, TkClipCleanup and + TkGCCleanup generic private procs, and TkWmCleanup, TkSendCleanup + and TkFreeXId unix private procs. - * generic/tkOldConfig.c: Added check for NULL tkwin value in - Tk_ConfigureWidget [Bug: 4079] + * generic/tkInt.h: + * unix/tkUnixXId.c (TkFreeXId): frees XID resources. + Made idCleanupScheduled a Tcl_TimerToken (was int) in TkDisplay + structure to allow us to delete the timer scheduled for it. - * generic/tkWindow.c: Added check for NULL tkwin value in - Tk_NameToWindow [Bug: 4079] + * unix/tkUnixWm.c (TkWmStackorderToplevel): ensure children + structure is freed. + (ConfigureEvent, ComputeReparentGeometry): Add extra wm tracing info + (TkWmRestackToplevel): initialize changes to 0 to prevent UMR. + Use WaitForConfigureNotify on all windows. This part still + requires fixing as it is the root of the 2 second raise delay on + some window managers (those that use extra wrapper windows of + their own). -2000-03-02 Jeff Hobbs + * unix/tkUnixSend.c (TkSendCleanup): free send-related resources - * tests/color.test: - * xlib/xcolors.c (XParseColor FindColor): - * win/tkWinColor.c (XAllocColor): Fixed bit fiddling for colors to - return "correct" values for color mapping. [Bug: 4282] + * unix/tkUnixEvent.c (TkpCloseDisplay): call TkSendCleanup and + TkWmCleanup. - * unix/Makefile.in (SCRIPT_INSTALL_DIR): removed extraneous '/' - * unix/aclocal.m4: corrected TCL_NEEDS_EXP_FILE to be 1 for AIX + * unix/tkUnixSelect.c (SelRcvIncrProc): added missing Tcl_Release + of interp - * win/tkWinInt.h: change extern to EXTERN for TkWinChildProc - declaration with extra #defs. [Bug: 4240] + * generic/tkGet.c (FreeUidThreadExitProc): free thread-specific + resources on thread exit - * library/focus.tcl: fixed tkFocusOK to protect $w in - uplevel with list. [Bug: 4208] + * generic/tkFocus.c (TkFocusFree): frees TkMainInfo data + * generic/tkClipboard.c (TkClipCleanup): frees TkDisplay data + * generic/tkGC.c (TkGCCleanup): frees TkDisplay data - * doc/CrtItemType.3: fixed docs for Tk_CreateItemType to reflect - changes made in 8.3.0 (but old style would still work as well). - [Bug: 4252] + * unix/tkUnixFont.c (FontPkgCleanup): cleanup thread specific font + resources on thread exit. - * tests/config.test: extra test to check object cleanup when - destroying the widget - * generic/tkListbox.c (DestroyListbox): fixed crash in - DestroyListbox due to null tkwin. [Bug: 4207] + * mac/tkMacXStubs.c (TkpOpenDisplay): memset the initial display + structures to 0. - * tests/entry.test: added test suite for entry validation - * doc/entry.n: improved docs discussing caveats and gotchas when - mixing textvar with widget validation - * generic/tkEntry.c (EntryValidateChange): improved handling of - validation with relation to -textvariable. Previously, it would - turn off whenever the textvar was set. Now it will it will turn - off only when the textvar is set and validation returns 0. Added - %V (type of validation occuring) to %-subs to help work with - trickier validation. + * generic/tkOption.c (OptionThreadExitProc): freed tsd option + stacks on thread exit. + (Tk_GetOption): free mem used to get Tk_Uid -2000-03-01 Eric Melski + * generic/tkMenu.c (ConfigureMenu): freed saved options in all + error cases. - * tests/clrpick.test: - * library/clrpick.tcl: Added code to make color chooser dialog - inherit screen setting from parent (bug #2334) + * win/tkWinInt.h: declaration for TkWinGetUnicodeEncoding + * win/tkWinDialog.c (GetFileNameW): use TkWinGetUnicodeEncoding + * win/tkWinInit.c (TkpDisplayWarning): use TkWinGetUnicodeEncoding + * win/tkWinFont.c: use TkWinGetUnicodeEncoding instead of static + unicodeEncoding. -2000-02-25 Jeff Hobbs + * win/tkWinX.c (Tk_SetCaretPos): remove WM_IME_STARTCOMPOSITION + and place the IME position within Tk_SetCaretPos. Cache results in + Tk_SetCaretPos to reduce unnecessary repositioning. Also call + DestroyCaret if we receive WM_KILLFOCUS. + (TkpOpenDisplay): ZeroMemory the initial display structures. + (TkWinGetUnicodeEncoding): Added so that Windows only needs to + cache this value one, and then free it in TkWinXCleanup. + (HandleIMEComposition): add support for Win98 and ATOK13 + IME. (yamamoto) - * win/tkWinWm.c (RaiseWinWhenIdle): Checked for the possibility - that the window could be destroyed (can occur with - wm deiconify .toplevel; destroy .toplevel). + * generic/tkConsole.c (ConsoleCmd): correct return that should + have just set result code. -2000-02-25 Eric Melski + * generic/tkImgPhoto.c: Added PhotoFormatThreadExitProc to clean + up on thread exit. (Tk_PhotoPutBlock) slight code updates - * generic/tkImgGIF.c: Applied "spirit of" the patch in 1605 (the - submitted patch was more complicated than necessary and did not - extend to writing GIF's, only reading), to allow reading/writing - of GIF files on EBCDIC and other non-ASCII based systems. + * generic/tkPanedWindow.c (DestroyPanedWindow, ConfigureSlaves): + fix mem leaks in not freeing slave info -2000-02-14 Eric Melski + * win/configure: + * win/tcl.m4: Enabled COFF as well as CV style debug info with + --enable-symbols to allow Dr. Watson users to see function info. + More info on debugging levels can be obtained at: + http://msdn.microsoft.com/library/en-us/dnvc60/html/gendepdebug.asp - * unix/tk.spec: RPM specification for producing a binary Tk RPM - for Linux. +2002-04-10 Mo DeJong - * unix/Makefile.in: Added rpm target to generate Tk - binary RPM. + * doc/wm.n: + * mac/tkMacWm.c: + * tests/wm.test: + * unix/tkUnixWm.c: + * win/tkWinWm.c: Update wm stackorder usage message + to make it clear that either 1 or 3 arguments are + required. [Bug 540013] + +2002-04-08 Daniel Steffen + + * mac/tkMacProjects.sea.hqx: added tkPanedWindow.c to projects + * mac/tkMacAppInit.c: fixes to MSL stdin/stdout hookup to the + TkConsole when using shared MSL libraries; fix for crashing + bug on exit: writing to stdin/sterr when console has already + been destroyed. (both fixes need support in MSL, see + 'CW Pro6 changes' in tcl/mac/tcltkMacBuildSupport.sea.hqx) + * mac/tkMacDialog.c: fixes to Navigation Services Dialog filter. + * mac/tkMacDraw.c: add panic for overwide TkImages that would + crash Tk on mac otherwise. + +2002-04-05 Jeff Hobbs + + * mac/tkMacXStubs.c: added Tk_SetCaretPos stub (does nothing). + * win/tkWinX.c: added Tk_SetCaretPos code to position IME windows + correctly when WM_IME_STARTCOMPOSITION is received. + * unix/tkUnixKey.c: added Tk_SetCaretPos and code for setting + XIM caret in TkpGetString. -2000-02-10 Jeff Hobbs + * generic/tkStubInit.c: + * generic/tkDecls.h: + * generic/tk.decls: added Tk_SetCaretPos declaration. This command + allows users to indicate the cursor position and is used by XIM + (Unix) or IME (Windows) to place the caret box correctly. It is + also part of correct Accessibility style on Windows to make the + magnifier jump to the focus point. + + * win/tkWinButton.c (TkpDisplayButton): + * generic/tkTextMark.c (TkTextInsertDisplayProc): + * generic/tkCanvText.c (DisplayCanvText): + * generic/tkEntry.c (DisplayEntry): added Tk_SetCaretPos calls + + * generic/tkInt.h: added TK_XIM_SPOT #define (default 1). + Added XFontSet attribute to TkDisplay when TK_XIM_SPOT is true. + * generic/tkEvent.c (Tk_HandleEvent): made sure inputContexts are + not getting created on DestroyNotify events (for dead windows). + Added over-the-spot support if TK_XIM_SPOT is defined (default). + The is the nicer XIM behavior, but uses a bit more memory. + + * unix/tkUnixEvent.c: + * generic/tkWindow.c: moved OpenIM over to tkUnixEvent.c. + Removed setting inputContext to null in Tk_MakeWindowExist as it + was redundant. + + * unix/tkUnixWm.c (CreateWrapper): Removed redundat setting of + inputContext to null. + + * win/Makefile.in: changed gdb and shell targets to properly build + all binaries before running (otherwise an error often occured). + +2002-03-28 David Gravereaux + + * win/.cvsignore (new): + * win/lamp.bmp (new): + * win/makefile.vc: + * win/nmakehlp.c (new): + * win/rules.vc: Brought the makefile up-to-date with Tcl's one. + This now has support for Win9x issues and the winhelp target now + exists. Color scheme can be changed. I'm just imparting a first + suggestion using orange :) I'll have to think about the install + portion of the helpfile as I'll need to do some tricks to insert + tk's contents file into Tcl's using some special winhlp32.exe + switches. [Bug 533862 527941] - 8.3.0 RELEASE + * win/makefile.vc: Tk helpfile is now installing itself into Tcl's + contents file as part of the install target and rebuilding the + contents table as desired. [Bug 527941] - * changes: updated for 8.3.0 release + * doc/console.n: Changed topic from "Tcl Built-In Commands" to + "Tk Built-In Commands" - * generic/tkImgGIF.c (FileReadGIF): added cast for trashBuffer + * win/buildall.vc.bat: Update to match Tcl. - * generic/tkIntXlibDecls.h: - * generic/tkInt.decls: declared some Xlib emulation calls for - the Mac +2002-03-26 Andreas Kupries - * generic/tkFrame.c (TkInstallFrameMenu): added extra panic to - inform user of bad call when framePtr is NULL [Bug: 2530] + * unix/tkUnixFont.c: Added inclusion of . This fixes + a GCC/HPUX problem with missing a "htons". See also + "tclUnixPort.h" for equivalent code. - * generic/tkMenu.c (DestroyMenuInstance): Placed checks around - menu name objects before trying to incr the ref. [Bug: 3402] +2002-03-21 David Gravereaux - * generic/tkTest.c: removed USE_OLD_IMAGE def for Mac + * win/makefile.vc: Changed optimize flag to -0ti instead of -02. + [Bug 528441] - * library/listbox.tcl: - * library/text.tcl: added support for <4> and <5> for mousewheel - style scrolling on Unix for mice that map to these buttons. +2002-03-20 Don Porter - * tests/scrollbar.test: fixed check of testmetrics command to - allow unix tests to run (testmetrics is mac/pc only) + * generic/tkButton.c (ButtonTextVarProc,ButtonVarProc): + * generic/tkCmds.c (WaitVariableProc): + * generic/tkEntry.c (EntryTextVarProc): + * generic/tkListbox.c (ListboxListVarProc): + * generic/tkMenu.c (MenuVarProc): + * generic/tkMenubutton.c (MenuButtonTextVarProc): + * generic/tkMessage.c (MessageTextVarProc): + * generic/tkScale.c (ScaleVarProc): Updates to handle change in + type of part2 argument of Tcl_VarTraceProc typedef. [TIP 27] + [Patch 532644]. - * unix/tkUnixWm.c (Tk_CoordsToWindow): qualified delete of error - handler as the goto label is reached from above and below. +2002-03-19 Jeff Hobbs - * unix/configure.in: - * unix/aclocal.m4: cleaned up macros to coincide with tcl.m4, - added -export-dynamic to LDFLAGS for FreeBSD-3+ [Bug: 2998] + * generic/tkOldConfig.c (Tk_ConfigureValue): prevent leaving + interp->result as NULL. - * unix/README: - * unix/Makefile.in (dist): removed porting.notes and porting.old - from distribution and CVS. The information was very outdated. Now - refer to http://dev.scriptics.com/services/support/platforms.html +2002-03-07 Donal K. Fellows - * xlib/xgc.c: #def'd out XDrawSegments for the Mac, and added - some extra include info for the Mac + * library/text.tcl (TextPasteSelection): Renaming of TextPaste to + prevent confusion with tk_textPaste. Stopped code from inserting + selections twice, which seems to have happened with TIP#26, and + reorganized code to reduce amount of stuff protected by catch + which is tricky to maintain. + (tk_textPaste): Reduce amount of code protected by catch. -2000-02-09 Jim Ingham +2002-03-06 Mo DeJong - * mac/tkMacButton.c: Stop removing the appearance window from the - Window List. It is not clear why Ray did this, and it causes the - Appearance manager to crash at random times. - - * mac/tkMacWM.c: Add support in unsupported1 style for the Appearance - specification of window styles, including floating window support. - * mac/tkMacWindowMgr.c: Operate on the front non-floating window, - unless the mouse is directly over the floating window. Also, - keystrokes go to the front non-floating window. - * mac/tkMacAppInit.c: Initialize floating window support. - * mac/tkMacScrlbr.c: - * mac/tkMacmenu.c: Fixes for floating windows - operate on the - FrontNonFloatingWindow. - * mac/tkMacLibrary.r: Fix typo in File info string. - * mac/tkMacApplication.r: Fix typo in file info string. Add - Finder balloon help for no apparent reason. - - * mac/tkMacSubwindows.c: Change panic in tkMacGetDrawablePort to - Debugger. This is only a temporary fix. The panic is only - triggered when a safeTk interpreter is torn down, and ignoring it - does no harm. I haven't figured out how to avoid it yet, however. - Also use the Appearance MoveWindowStructure call when available. - - New Files: - * MW_TkOldImageHeader.h: Handle #defining USE_OLD_IMAGE for tkImgPPM.c. - * MW_TkTestHeader.h: - * MW_TkTestHeader.pch: - * MW_TkHeader.h: Add separate prefix files for test & release - versions of Tk, so we can just have separate targets w/o having to - edit files. - - * tclets.r: The D&D Tclets icon in rez form so we can have a - target for this. + * win/tkWinX.c: Define _WIN32_IE as 0x0300 + before including commctrl.h so that we can + access the InitCommonControlsEx API when + building Tk with mingw. - The above are curtesy of Daniel Steffen (steffen@math.mq.edu.au) - - * tkMacAppearanceStubs.c: Stubs of the Mac Appearance calls I use - so I can link the static 68K Shell without putting ifdef's all - over the code. - -2000-02-08 Jeff Hobbs +2002-03-06 Donal K. Fellows - * generic/tk.decls: - * generic/tkBind.c: - * generic/tkInt.decls: - * generic/tkIntDecls.h: - * generic/tkStubInit.c: - * mac/tkMacKeyboard.c: - * unix/tkUnixKey.c: - * win/tkWinKey.c: Fix for keyboard handling of "dead" keys and - caps lock from Peter Spjuth. [Bug: 4105 3359 2493] - Split functions into platform specific files: - Static functions GetKeySym(), SetKeycodeAndState() and InitKeymapInfo() - from tkBind.c moved into platform files tkWinKey.c tkUnixKey.c and - tkMacKeyboard.c. GetKeySym() and SetKeycodeAndState() renamed to - Tkp* and made public (as private functions) in tkInt.decls. + * README, generic/tk.h, unix/configure.in, unix/tk.spec: + * win/configure.in: Bumped patchlevel; this might need to change + in the future, but it will help us distinguish between the CVS + version and the most recent released version. - Step 2, fixes in tkWinKey.c - New static function: KeycodeToKeysym(), based on XKeycodeToKeysym() - but with different arguments, and a lot of improvements. - TkpGetString() changed to use KeycodeToKeysym() + other fixes. - TkpGetKeySym() changed to use KeycodeToKeysym() + other fixes. - InitKeymapInfo() changed to use KeycodeToKeysym(). - TkpSetKeycodeAndState() rewritten, mostly by copying code from - XKeysymToKeycode(). - XKeycodeToKeysym() rewritten. Preferably it should be removed. +2002-03-05 Jeff Hobbs - EXPLANATION: The main problem is ToAscii() which has a lot of side - effects, and also that XKeycodeToKeysym() is not provided enough - input to do a proper job. The changes' main goal is to avoid - calling ToAscii() if not necessary, and to provide it with as - correct information as possible when called. Also some attempts - to clean up what ToAscii() did are done. See the code for details. + *** 8.4a4 TAGGED FOR RELEASE *** - BUGS FIXED: Typing shifted (and AltGr) dead keys did not work. - Keyboard lock lamps did not work on Win98. - Events regarding AltGr-keys behaved badly. - Example: On a Swedish keyboard, $ is typed with AltGr-4. - That keyboard event would get the keysym '4' not 'dollar'. - Also, doing [event generete . ] would send keysym '4'. - Translation to ascii in TkpGetString did not handle return and - tab correctly. I.e. [event generate . ] gave wrong %A + * unix/README: updated --* options docs. - * generic/tkDecls.h: - * generic/tk.decls: - * generic/tk.h: moved new public functions created in dash patch - to the stubs interface [Bug: 4062] + * unix/tk.spec: fixed URL refs to use www.tcl.tk or SF. - * generic/tk.h: - * doc/CrtImgType.3: - * doc/CrtPhImgFmt.3: - * generic/tk.h: - * generic/tkImgGIF.c: - * generic/tkImgPhoto.c: - * generic/tkStubImg.c (new file): - * generic/tkTest.c: - * unix/Makefile.in: - * win/Makefile.in: - * win/makefile.vc: improved support for moving from the old style - image C API to the new obj'ified one with new Tk_InitImageArgs - command and stub'ing of image code. See docs for how to make the - transition. [Bug: 4060] +2002-03-04 Jeff Hobbs - * library/tk.tcl: wrapped check for tcl_platform(os) around info - exists because it won't in safe interpreters + * README: + * mac/README: + * unix/README: + * win/README: updated to use www.tcl.tk URL. - * win/tkWinFont.c: corrected symbol font use to only work on 8-bit - characters [Bug: 2406] +2002-03-03 Jeff Hobbs - * unix/aclocal.m4: changed all -fpic to -fPIC + * library/entry.tcl: added catch around Triple-1 binding use of + sel.last - * README: - * unix/configure.in: - * win/configure.in: - * generic/tk.h (TK_RELEASE_SERIAL): Moved to 8.3.0 patchlevel +2002-02-28 Don Porter -2000-02-07 Eric Melski + * library/console.tcl (ConsoleBind): Corrected console <> + binding on Unix platforms. - * library/tkfbox.tcl: Applied patch from bug #4117, - tk_getOpenFile/getSaveFile doesn't do the right thing when user - types a directory name in the entry and a default extension is - specified. +2002-02-26 Jeff Hobbs -2000-02-05 Jeff Hobbs + * unix/configure: Regen. + * unix/tcl.m4: Update from Tcl. - * unix/tkUnixScale.c (TkpDestroyScale): changed ckfree to - Tcl_EventuallyFree to behave with Tcl_Preserve in TkpDisplayScale - (prevents possible segfault). + * generic/tkWindow.c (Tk_MainWindow, Tk_GetNumMainWindows): + protect against being called before Tcl stubs are init'ed. + [Bug #220916] (porter) -2000-02-03 Eric Melski +2002-02-25 Jeff Hobbs - * tests/canvText.test: test for fix for bug #2525. + * generic/tkText.c (ConfigureText): reenable the blinking cursor + on state change where necessary. [Bug #503772] - * generic/tkFont.c (Tk_ComputeTextLayout): Was erroneously setting - the width of newline-only text display chunks to some arbitrary - huge number, instead of 0; this was interfering with things like - the canvas find enclosed feature. (bug #2525). + * tests/listbox.test: + * generic/tkListbox.c: corrected error handling when setting to an + invalid listvar value. [Bug #503613] - * tests/text.test: - * generic/tkText.c (DumpLine/DumpSegment): Changed DumpSegment to - take a TkTextIndex instead of two integer offsets, so that it - could use TkTextPrintIndex to format the offsets into an index, - which makes it UTF smart (bug #2582). + * library/scale.tcl: mirror B2 bindings to B3 on Windows to better + accomodate two button mice. [Patch #493145] -2000-02-01 Eric Melski + * library/panedwindow.tcl: improved proxy sash handling. (boudaillier) - * library/tk.tcl: - * library/tclIndex: - * library/choosedir.tcl: Moved choosedir functions into the - ::tk::dialog::chooseDir namespace instead of a toplevel - ::tkChooseDirectory namespace. Additional cleanup on the - chooseDir dialog. +2002-02-25 Donal K. Fellows -2000-02-01 Jeff Hobbs + * tests/filebox.test: Reorganised and fixed so that tests are + executed fewer times (!) and the automatic extension adding + behaviour of tk_getSaveFile is tested. - * doc/text.n: clarified docs on what happens during a search with - -count when images/windows are embedded +2002-02-23 Mo DeJong - * win/Makefile.in (install-*): reduced verbosity of install + * unix/configure: Regen. + * unix/tcl.m4: Update from Tcl. - * win/tkWinPixmap.c (XGetGeometry): added support for windows in - XGetGeometry [Bug: 4069] +2002-02-22 Jeff Hobbs - * win/tkWinFont.c (GetScreenFont): fixed possible mem overrun with - long font names [Bug: 4108] + * generic/tkPanedWindow.c (PanedWindowWidgetObjCmd): fixed returns + that should have been breaks instead. Corrected .pw configure + handling for insufficient args. [Patch #521436] (boudaillier) - * win/tkWinDialog.c: added EnableWindow calls to dialogs to - correct for possible loss of control in parent Tk toplevel - [Bug: 1212 et al] + * mac/tkMacDefault.h: + * unix/tkUnixDefault.h: + * win/tkWinDefault.h: changed panedwindow default relief to flat, + a more natural outer relief. - * generic/tkRectOval.c (ConfigureRectOval): - * generic/tkCanvLine.c (ConfigureLine): - * generic/tkCanvPoly.c (ConfigurePoly): - * generic/tkCanvArc.c (Configure/DisplayArc): fixed handling for - negative dash values [Bug: 4104] + * library/panedwindow.tcl (ReleaseSash): changed to not pass x and + y args at all (they aren't used). + Added proc comments. Made configuring sash cursor more efficient. + Added Cursor timer that restores the default cursor when pointer + is no longer over the sash. This is necessary because Leave + events won't be seen when moving into a paned child. - * generic/tkScale.c (TkRoundToResolution): fixed incorrect - assumption that (N+1)*delta = N*delta + delta with floating point - math [Bug: 3689, 4099] - (DestroyScale) Fixed check for cancelling TkpDisplayScale (was - REDRAW_ALL, is now REDRAW_PENDING) +2002-02-22 Donal K. Fellows - * tests/listbox.test: corrected test case for listbox itemconfigure + * library/demos/widget: New section "Paned Windows" + * library/demos/paned2.tcl, library/demos/paned1.tcl: New files. - * unix/aclocal.m4: added *BSD ELF recognition for - SHARED_LIB_SUFFIX determination (from Tcl's tcl.m4) + * library/panedwindow.tcl (ReleaseSash): Added missing arguments. + * library/tk.tcl: Bindings for paned window were not being loaded + by default. -2000-01-27 Eric Melski + * unix/tkUnixMenu.c (GetMenuLabelGeometry,DrawMenuEntryLabel): + Stop meaningless GCC warnings. - * generic/tkImgPhoto.c: Removed unneccesary object translation in - MatchStringFormat (bug #4103). +2002-02-21 Jeff Hobbs -2000-01-27 Eric Melski + * doc/panedwindow.n (new): + * generic/tkPanedWindow.c (new): + * generic/tkInt.h: + * generic/tkWindow.c: + * library/panedwindow.tcl (new): + * mac/tkMacDefault.h: + * tests/panedwindow.test (new): + * unix/Makefile.in: + * unix/tkUnixDefault.h: + * win/Makefile.in: + * win/makefile.vc: + * win/tkWinDefault.h: added implementation of TIP #41, panedwindow + widget. [Patch #512503] (melski) - * generic/tkImgGIF.c: Additional code cleanup (now we only have - one decoder! neat!) + * generic/tkOption.c (ReadOptionFile): fixed Tcl_Seek casting to + remove warnings (we expect no option files with be > 2GB). -2000-01-26 Eric Melski + * unix/configure: regenerated + * unix/tcl.m4: updated to sync with Tcl's tcl.m4 + Added --enable-64bit support for AIX-4 using IBM's xlc (-q64 flag). - * doc/getOpenFile.n: - * doc/chooseDirectory.n: Man page/cross links for - tk_chooseDirectory (bug #1786). +2002-02-19 Don Porter - * library/tk.tcl: - * library/tclIndex: Added hooks for tk_chooseDirectory. (bug #1786) + * changes: First draft of updated changes for 8.4a4 release. - * library/choosedir.tcl: tk_chooseDirectory implementation for - Unix/Mac (bug #1786). +2002-02-19 Donal K. Fellows - * generic/tkImgPhoto.c: Added some comments regarding slow - processing of transparent images. + * generic/tkImgPhoto.c (MatchFileFormat): Tcl_Seek takes + Tcl_WideInt offset (three places.) + * generic/tkImgPPM.c (FileReadPPM): Tcl_Seek takes Tcl_WideInt offset. + * generic/tkFrame.c (ConfigureFrame): Stop GCC warning. - * generic/tkImgGIF.c: Improved GIF decoder for ~60% speed - increase. Added some comments on how to further improve the - implementation, time permitting. + * generic/tkImgGIF.c: Made file meet the formatting rules from the + Tcl Engineering Manual better; mostly differences in whitespace. - * doc/photo.n: Added a description of what the -data string can - contain (base64 or binary data). +2002-02-18 Jeff Hobbs - * generic/tkImgPhoto.c: Fixed bug with use of binary data for - "-data" option to "image create" command. + * unix/configure: regen'd + * unix/tcl.m4: + * unix/configure.in: added macros and calls to SC_TCL_EARLY_FLAGS + and SC_TCL_64BIT_FLAGS, part of TIP #72. -2000-01-21 Eric Melski +2002-02-14 Mo DeJong - * library/tkfbox.tcl: Fixed bug relating to incorrect parent - values for error message boxes displayed by the file dialog (bug - #3616). + * library/entry.tcl: + * library/text.tcl: Adjust and bindings + so that no anchor point is set and the insertion cursor is + set to the last character in the selection. [Bug 220943] + * tests/event.test: Add test cases for double click and + drag as well as triple click and drag in the text and + entry widgets. - * tests/text.test: - * generic/tkText.c: Fixed bug relating to regexp searching for - empty lines; previously, the starting line was ignored. (bug #1643). +2002-02-14 Mo DeJong -2000-01-20 Jeff Hobbs + * tests/event.test (_text_ind_to_x_y, _get_selection): Fix + incorrect use of results from bbox invocation so that + y center point for a give index is calculated correctly. + Add new method to return the selection and use it in + test cases. Always lappend to the result list to avoid + case where initial result includes a space. - * library/text.tcl: fixed double-click selection behavior where - there were embedded windows/widgets in the same line. [Bug: 3989] +2002-02-07 Don Porter - * win/tkWinWm.c (TkWmProtocolEventProc): cached atom name as the - window could get destroyed during eval [Bug: 2513] + * generic/tkMain.c: + * mac/tkMacInit.c: + * mac/tkMacKeyboard.c: + * win/tkWinDialog.c: + * win/tkWinTest.c: modified some callers of Tcl routines that + were restored to return (char *) pointing into Tcl_DStrings. - * generic/tkCanvLine.c (LineCoords): fixed segfault when too few - coords were passed to a line with certain options set (it should - always have thrown an error anyway). [Bug: 4042] +2002-02-03 eric melski - * tests/text.test: - * generic/tkText.c: fixed missing " in error case and missing - 'dump' in subcommand listing [Bug: 4036] + * generic/tkImage.c (Tk_ImageObjCmd): Clean up bogus for loop in + [image inuse] subcommand [Bug #485803]. - * generic/tkListbox.c: adjusted use of basic string concatenation - in (non-K&R behavior) [Bug: 4027] - Swapped bg/fg class for -select(bg|fg) for listbox and their - items [Bug: 4039] +2002-02-01 Jeff Hobbs - * unix/mkLinks: - * doc/WindowId.3: added docs for Tk_IsContainer and Tk_IsEmbedded + * generic/tkCmds.c (Tk_TkObjCmd): don't use 'bool' as an arg as it + conflicts with the C99 spec. [Bug #511956] (ingham) - * doc/text.n: clarified mark gravity definition and usage of - ``word'' in binding definitions. [Bug: 2004 2277 1388] +2002-02-01 David Gravereaux - * generic/tkInt.h: moved new TkDisplay useInputMethods structure - element to end to not disturb position of previous elements in - the structure (as compared to Tk <=8.2). + * win/makefile.vc: unset macro located in the tktest target + caused a failure to build. [Bug 511652] -2000-01-20 Eric Melski +2002-01-30 Don Porter - * tests/grid.test: Added a test for the consecutive ^ and multiple - widget case (bug #1386). + * win/stubs.c (XSetCommand): Overlooked CONSTification. - * generic/tkGrid.c: Fixed interpretation of consecutive ^ - characters in grid command. Previously, ^ ^ was interpreted as - meaning that there must be a 2-column widget above to extend, - neglecting the case where there was actually 2 1-column widgets - above. Now, ^ ^ is interpreted as a possible width; the gridder - will consume as many ^'s as there are columns in the widget, and - leave the rest for the extension of other widgets. (bug #1386). +2002-02-01 Donal K. Fellows -2000-01-19 Eric Melski + * doc/photo.n: Documented transparency subcommand. + * tests/imgPhoto.test (imgPhoto-4.40...imgPhoto-4.68): Tests for + the transparency subcommand. + * generic/tkImgPhoto.c (ImgPhotoCmd): Added transparency + subcommand (see TIP #14.) - * library/tk.tcl: Created a virtual event <> for - reverse tab traversals, with one default binding , and - OS specific bindings for Linux, HP-UX, and IRIX. (bug #3163) +2002-01-31 Todd Helfter + * generic/tkMenu.c (ConfigureMenuCloneEntries) + * tests/menu.test (menu3.68) + Correct and test for logic error when cloning menus. [Bug #508988] -2000-01-13 Jeff Hobbs +2002-01-30 Don Porter - * changes: updated changes file to reflect 8.3b2 mods - * README: - * generic/tk.h: - * unix/configure.in: - * win/configure.in: updated to patchlevel 8.3b2 + * generic/tk.decls: The POTENTIAL INCOMPATIBILITY in the changing + interface of Tk_ParseArgv can now be removed by the -DUSE_NON_CONST + compiler flag. + * generic/tkDecls.h: make genstubs - * win/tkWinWm.c: added visibility event handler to make sure - that transient window wrappers would be updated when the master - was initially mapped. +2002-01-29 Andreas Kupries -2000-01-12 Jeff Hobbs + * win/tkWinInit.c (TkpGetAppName): TIP 27 fixup. The code now does + not write into the CONST path returned by "argv0" and + Tcl_SplitPath anymore. - * tests/text.test: changed test to reflect change of -hidden - to -elide in search options. +2002-01-28 Mo DeJong - * win/tkWinScrlbr.c: added check for valid hwnd in ModalLoopProc - to avoid crash when building statically + * unix/configure: Regen. + * unix/configure.in: Don't set TCL_LIB_SPEC and + TCL_STUB_LIB_SPEC variables since this breaks + the AIX build. This was used in the past to + support linking with Tcl from the build dir + or the install dir, but it is no longer needed. - * doc/event.n: - * generic/tkBind.c: prevented core with event -warp on Windows - when window wasn't mapped [Bug: 4004] and added docs stating - the requirement for mapped windows. +2002-01-28 Mo DeJong - * generic/tkCanvas.c: fixed mem leak with TagSearchExprInit - [Bug: 3977] + * unix/Makefile.in: Remove commented out vars. + * unix/configure: Regen. + * unix/configure.in: Don't subst vars that are already + taken care of in SC_LOAD_TCLCONFIG. + * unix/tcl.m4: Update from Tcl. + * win/configure: Regen. + * win/tcl.m4: Update from Tcl. - * generic/tkStubInit.c: - * generic/tkDecls.h: remove non-existent - Tk_(Get|Create)CanvasVisitor prototypes +2001-01-27 Daniel Steffen - * generic/tkText.c: - * generic/tkEntry.c: fixed cursor to not blink when widget was - disabled [Bug: 1807] + * generic/tkFileFilter.c: + * mac/tkMacInit.c: + * mac/tkMacKeyboard.c: + * mac/tkMacMenus.c: TIP 27 CONSTification induced changes + +2002-01-25 Don Porter + + * All changes below are Patch 505159 + + * doc/AddOption.3: + * doc/CanvTkWin.3: + * doc/GetPixels.3: + * doc/Name.3: + * doc/ParseArgv.3: + * generic/tk.decls (Tk_AddOption,Tk_CanvasGetCoord,Tk_GetPixels, + Tk_GetScreenMM,Tk_NameToWindow,Tk_ParseArgv): + * generic/tkArgv.c (Tk_ParseArgv): + * generic/tkCanvLine.c (ParseArrowShape): + * generic/tkCanvUtil.c (Tk_CanvasGetCoord,Tk_CanvasTagsParseProc, + Tk_CanvasTagsPrintProc,Tk_GetDash): + * generic/tkCanvas.c (ConfigureCanvas): + * generic/tkGet.c (Tk_GetPixels,Tk_GetScreenMM): + * generic/tkImgPhoto.c (ImgPhotoCmd): + * generic/tkMain.c (Tk_MainEx): + * generic/tkOldConfig.c (FormatConfigInfo): + * generic/tkOption.c (Tk_AddOption): + * generic/tkText.c (TextWidgetCmd,TkTextGetTabs,DumpSegment): + * generic/tkText.h (TkTextCreateTag): + * generic/tkTextTag.c (TkTextCreateTag): + * generic/tkWindow.c (Tk_NameToWindow,Initialize): + * mac/tkMacCursor.c (FindCursorByName,TkGetCursorByName): + * mac/tkMacWm.c (Tk_WmCmd): + * unix/tkUnixCursor.c (TkGetCursorByName): + * unix/tkUnixSend.c (ValidateName): + * unix/tkUnixWm.c (Tk_WmCmd): + * win/tkWinCursor.c (TkGetCursorByName): + * win/tkWinWm.c (Tk_WmCmd): Updated callers of Tcl_SplitList and + Tcl_Merge. + * generic/tkDecls.h: make genstubs + ***POTENTIAL INCOMPATIBILITY*** + Includes a source incompatibility in the argv argument of Tcl_ParseArgv. + + * generic/tkBind.c (DeleteVirtualEvent): + * generic/tkCanvas.c (ScrollFractions, CanvasWidgetCmd, + CanvasUpdateScrollbars): + * generic/tkTestTag.c (TkTextTagCmd): Updated callers of + Tcl_GetStringResult. Rewrote PrintScrollFractions to + ScrollFractions to stop scribbling directly on interp->result. + + * generic/tkInt.decls (TkGetDefaultScreenName, TkpDisplayWarning, + TkpOpenDisplay): + * generic/tkCanvPs.c (Tk_PostscriptColor, Tk_PostscriptFont): + * generic/tkEntry.c (EntrySetValue, EntryValidateChange, ExpandPercents, + EntryValueChanged, Tk_EntryObjCmd, DestroyEntry, ConfigureEntry, + EntryComputeGeometry, InsertChars, DeleteChars, EntryFetchSelection, + EntryTextVarProc, Tk_SpinBoxObjCmd, SpinboxWidgetObjCmd): + * generic/tkMain.c (Prompt): + * generic/tkMenu.c (MenuVarProc): + * generic/tkMenubutton.c (ConfigureMenuButton, MenuButtonTextVarProc): + * generic/tkMessage.c (ConfigureMessage, MessageTextVarProc): + * generic/tkWindow.c (GetScreen, Initialize): + * mac/tkMacInit.c (TkpInit, TkpDisplayWarning): + * mac/tkMacXStubs.c (TkGetDefaultScreenName, TkpOpenDisplay): + * unix/tkUnix.c (TkGetDefaultScreenName): + * unix/tkUnixEvent.c (TkpOpenDisplay): + * unix/tkUnixInit.c (TkpGetAppName, TkpDisplayWarning): + * unix/tkUnixSend.c (SendEventProc): + * win/tkWinInit.c (TkpGetAppName, TkpDisplayWarning): + * win/tkWinX.c (TkGetDefaultScreenName,TkpOpenDisplay): Updated + callers of Tcl_GetVar, Tcl_GetVar2 + * generic/tkIntDecls.h: make genstubs + + * generic/tkCanvPs.c (TkCanvPostscriptCmd): + * generic/tkImgBmap.c (TkGetBitmapData): + * generic/tkOption.c (ReadOptionFile): + * mac/tkMacInit.c (TkpInit, TkpGetAppName): + * win/tkWinInit.c (TkpGetAppName): Updated callers of + Tcl_SplitPath, Tcl_JoinPath, and Tcl_TranslateFileName. + +2002-01-18 Mo DeJong + + * tests/wm.test: Rewrite stackorder tests that + deal with toplevels that have the overrideredirect + flag set. [Tk bug 492259] + +2002-01-18 Don Porter + + * win/tkWinDialog.c: Overlooked Tcl_GetIndexFromObj callers. + +2001-01-18 Daniel Steffen + + * mac/tkMacDialog.c: + * mac/tkMacSend.c: TIP 27 CONSTification broke the mac + build in a few places. + +2002-01-16 Jeff Hobbs + + * generic/tkListbox.c (ChangeListboxOffset): improved tracking + when scrolling on x axis with entry/text. [Bug #225025] (voskuil) + +2002-01-16 Don Porter + + * generic/tk3d.c (Tk_GetReliefFromObj): + * generic/tkBind.c (Tk_EventObjCmd,HandleEventGenerate): + * generic/tkButton.c (ButtonWidgetObjCmd): + * generic/tkCanvas.c (CanvasWidgetCmd,FindItems): + * generic/tkClipboard.c (Tk_ClipboardObjCmd): + * generic/tkCmds.c (Tk_BellObjCmd, Tk_TkObjCmd, Tk_TkwaitObjCmd, + Tk_UpdateObjCmd, Tk_WinfoObjCmd, Tk_WmObjCmd): + * generic/tkConfig.c (DoObjConfig): + * generic/tkEntry.c (EntryWidgetObjCmd, SpinboxWidgetObjCmd): + * generic/tkFocus.c (Tk_FocusObjCmd): + * generic/tkFont.c (Tk_FocusObjCmd, ConfigAttributesObj): + * generic/tkFrame.c (Tk_FrameObjCmd): + * generic/tkGet.c (Tk_GetAnchorFromObj, Tk_GetJustifyFromObj): + * generic/tkGrab.c (Tk_GrabObjCmd): + * generic/tkGrid.c (Tk_GridObjCmd,GridRowColumnConfigureCommand, + GridSlavesCommand, ConfigureSlaves): + * generic/tkImage.c (Tk_ImageObjCmd): + * generic/tkImgBmap.c (ImgBmapCmd): + * generic/tkImgGIF.c (FileReadGIF): + * generic/tkImgPhoto.c (ImgPhotoCmd): + * generic/tkListbox.c (ListboxWidgetObjCmd, ListboxSelectionSubCmd, + GetListboxIndex): + * generic/tkMenu.c (MenuWidgetObjCmd, MenuAddOrInsert, MenuCmd, + ConfigureMenu, CloneMenu): + * generic/tkMenubutton.c (MenuButtonWidgetObjCmd): + * generic/tkMessage.c (MessageWidgetObjCmd): + * generic/tkOption.c (Tk_OptionObjCmd): + * generic/tkPack.c (Tk_PackObjCmd, ConfigureSlaves): + * generic/tkPlace.c (Tk_PlaceObjCmd): + * generic/tkScale.c (ScaleWidgetObjCmd): + * generic/tkSelect.c (Tk_SelectionObjCmd): + * generic/tkSquare.c (SquareWidgetObjCmd): + * generic/tkTest.c (TestobjconfigObjCmd, TrivialConfigObjCmd, + TestfontObjCmd): Updates to handle change in type of tablePtr + argument of Tcl_GetIndexFromObj(Struct) from (char **) to + (CONST char **). [TIP 27] [Patch 504705] + + * generic/tkCanvText.c (GetSelText): + * generic/tkEntry.c (Entry{FetchSelection,Setvalue},ExpandPercents): + * generic/tkSelect.c (HandleTclCommand): + * generic/tkText.c (TextSearchCmd): + * generic/tkTextIndex.c (TkTextMakeByteIndex, TkTextIndexBackChars): + * mac/tkMacFont.c (Tk_MeasureChars, BreakLine): + * unix/tkUnixMenu.c (DrawMenuUnderline): + * win/tkWinMenu.c (GetEntryText, DrawMenuUnderline): Updated + callers of Tcl_Utf* and Tcl_Regexp* APIs to reflect TIP 27 API + changes (see Tcl Patch 471509). [Patch 471513] + +2002-01-16 Mo DeJong - * generic/tkRectOval.c: added note about change to bloat for - RectOval bounds calculation for WIN32 only + * unix/configure: Regen. + * unix/tcl.m4: Update from Tcl. + * win/configure: Regen. + * win/tcl.m4: Update from Tcl. - * library/dialog.tcl: improved handling of $default arg to allow - for name of given button, as well as bounds checking +2002-01-04 Don Porter - * doc/wm.n: - * tests/winWm.test: - * tests/unixWm.test: - * mac/tkMacWm.c: - * unix/tkUnixWm.c: fixed possible X error being raised [Bug: 3377] - * win/tkWinWm.c: wm deiconify in zoom state [Bug: 2077], - fixed possible flashing of unmapped toplevel in deiconify [Bug: 3338] - and fixed mapping of transient window [Bug: 572] - Also, for all wm's, extended 'wm state' command to allow setting - of the state, and added official support of 'zoomed' state on Win. + * generic/tkMain.c (Tk_MainEx): Updated callers of CONSTified + Tcl interfaces Tcl_EvalFile and TclGetStartupScriptFileName. - * unix/aclocal.m4: strtod bug on Tru64 [Bug: 3378] + * generic/tkConsole.c (ConsoleOutputProc, TkConsolePrint): + * generic/tkInt.h (TkConsolePrint): + * mac/tkMacAppInit.c (TkConsolePrint): Updated Tk's console to + CONSTified channel driver interface. [Tcl Patch 503565, Tk Patch + 503983] - * unix/Makefile.in: added tests to prevent unnecessary chmod +x - in source dirs while installing [Bug: 3367] +2002-01-11 Mo DeJong - * unix/configure.in: properly sub'ed in TK_SHARED_BUILD [Bug: 3385] + Use ${libdir} instead of ${exec_prefix}/lib. [Tcl bug 489370] + + * unix/configure: Regen. + * unix/configure.in: Define and use libdir. + * win/configure: Regen. + * win/configure.in: Define libdir. -2000-01-05 Jeff Hobbs +2002-01-11 Mo DeJong - * doc/text.n: - * generic/tkText.c: - * generic/tkText.h: - * generic/tkTextBTree.c: - * generic/tkTextDisp.c: - * generic/tkTextTag.c: removed the -state option for text tags, - and reoriented it around -elide, as -state disabled was never - implemented, and -state hidden is better as -elide. + * unix/Makefile.in: Burn Tcl and Tk build + directories into tktest executable to avoid crashes + caused by ld loading a previously installed version + of the tcl or tk shared libraries. Remove setting + of LD_LIBRARY_PATH, LIBPATH, and SHLIB_PATH + before running tktest since it should no + longer be required. - * mac/tkMacClipboard.c: fixed i18n problems with clipboard [Bug: 3544] +2002-01-11 Mo DeJong - * library/entry.tcl: - * library/focus.tcl: - * library/listbox.tcl: - * library/scale.tcl: - * library/scrlbar.tcl: - * library/tearoff.tcl: - * library/text.tcl: - * library/tkfbox.tcl: - * library/xmfbox.tcl: fixed unprotected arg parsing through eval/after - [Bug: 3943] + Enable use of Tcl stubs when building Tk as + a shared library. This should fix the build + under AIX. [Bugs 220858, 220955, 220921] - * unix/Makefile.in: added unix/aclocal.m4 to distribution [Bug: 3938] - * unix/aclocal.m4: changed NetBSD SHLIB_CFLAGS from -fpic to -fPIC + * unix/Makefile.in: Add TCL_STUB_LIB_SPEC and + TCL_STUB_LIB_FLAG variables. + * unix/configure: Regen. + * unix/configure.in: Pass TCL_STUB_LIB_SPEC into + Makefile and use it when linking the tk shared library. + Define USE_TCL_STUBS when building shared. Subst + TCL_STUB_LIB_SPEC and TCL_STUB_LIB_FLAG. - * win/tkWinImage.c: added static declaration to function +2002-01-08 D. Richard Hipp -1999-12-22 Jeff Hobbs + * win/tkWinMenu.c: Fix the following bug: If you select an entry + on a cascade menu then the next time the parent menu is posted, the + cascade entry was active. Also, if you traverse to a disabled entry + using keystrokes and press ENTER on the disabled entry, then that + entry appears active the next time the menu is posted. The same + patch fixes both problems. - * changes: updated changes file +2002-01-04 Don Porter - * generic/tkScale.c: - * generic/tkScale.h: - * mac/tkMacScale.c: - * unix/tkUnixScale.c: fixed potential segv from patch in 3897 + * generic/tkBind.c (TkBindFree): + * generic/tkGrid.c (ResolveConstraints,CheckSlotData,DestroyGrid): + * generic/tkSelect.c (Tk_DeleteSelHandler,TkSelDeadWindow): Replaced + Tcl_Free calls with ckfree so that memory debugging is fully supported. - * tests/unixWm.test: nonPOrtable -> nonPortable +2001-12-28 Jeff Hobbs -1999-12-21 Jeff Hobbs + * test/winButton.test: + * win/tkWinButton.c: added updated patch #463234 which returns the + default sizing behavior (not so native), but enables native L&F + with negative sizing (-11 for example). - * generic/tk.h: - * unix/configure.in: - * win/configure.in: - * win/aclocal.m4: - * README: updated for patch level 8.3b1 + * library/text.tcl (tk::TextButton1): made text receive focus even + in disabled state for Windows to show selection and allow + mouse-wheel scrolling. - * unix/tkUnixWm.c: fixed panic in Tk_CoordsToWindow to print error - and continue instead (for Tix) [Bug: 716 et al] + * win/tkWinInit.c (TkpDisplayWarning): added Tcl_DStringFree's - * scale.test: - * generic/tkScale.c: - * generic/tkScale.h: fixed possible core when freeing options - (cursor) associated with scale widget [Bug: 3897] + * win/tkWinInt.h: + * win/tkWinX.c: added TkWinProcs that represent a function table + to switch between unicode and ansi procs on Windows. This is + analogous to the TclWinProcs. Using Tcl_WinUtfToTChar, we can + easily take advantage of using unicode functions where available + without having to switch on the platform id each time. - * doc/MeasureChar.3: fixed docs for Tk_MeasureChars to reflect code - * doc/listbox.n: fixed formatting problem + * win/tkWinWm.c (InitWindowClass): corrected init routines to + allow unicode in window titles on Windows (for Win2K/XP). + (TkWmStackorderToplevel): Corrected casts to enable debug compile - * generic/tk3d.c: added extra calculations to ensure that thin - frames get refreshed too [Bug: 3596] + * win/configure: regen'ed + * win/tcl.m4: added shell32.lib to link libs, as these are + necessary for new directory chooser (when enabled). - * unix/tkUnixMenu.c: - * unix/tkUnixFont.c: - * generic/tkCanvText.c: - * generic/tkEntry.c: - * generic/tkFont.c: - * generic/tkImgPPM.c: removed extranneous vars that were set but - never used. + * win/tkWinDialog.c (Tk_MessageBoxObjCmd): use MessageBoxW for + proper display of unicode errors. + Added patch which uses new OLE based directory chooser. This + still has some issues, so is disabled by default. [Patch #468139] + (ColorDlgHookProc) Corrected ability to use unicode chars in + tk_chooseColor -title. - * mac/tclMacHLEvents.c: fixed applescript for I18N [Bug: 3644] +2001-12-27 Jeff Hobbs - * unix/aclocal.m4: removed -O flag for AIX when using the IBM - compiler (several versions have a bug that crops up in the text - widget). [Bug: 2316] + * win/tkWinInit.c (TkpDisplayWarning): Use MessageBoxW in case the + error displayed has unicode chars. [Bug #485986] - * unix/Makefile.in: removed extra slash in SCRIPT_INSTALL_DIR - [Bug: 3896] +2001-12-27 Daniel Steffen - * library/listbox.tcl: added extra checks for existence of - tkPriv(listboxSelection) before it was used. [Bug: 3892] + * mac/tkMacInit.c: + * mac/tkMacResource.r: synced up tkInit features to unix/win: + use existing tkInit proc if defined. Added spinbox.tcl resource. + Used TclGetEnv() instead of Tcl_GetVar2(interp, env) + * mac/tkMacApplication.r: + * mac/tkMacLibrary.r: minor version resources cleanup -1999-12-16 Jeff Hobbs +2001-12-27 Jeff Hobbs - * doc/GetCursor.3: - * win/tkWinCursor.c: added support for Windows cursors to - TkGetCursorByName (.ani, .cur) using -cursor @ - (Ascher) [Bug: 1350] + * generic/tkButton.c (ButtonTextVarProc): guard against being + called while the *button/label is being deleted. [Bug #490051] - * win/tkWinWm.c: fixed 'wm deiconify' to update position of the - toplevel if event is waiting before mapping. (Mao) [Bug: 3687] - This removes the need for 'update idle' before 'wm deiconify' on - Windows. + * library/entry.tcl: + * library/spinbox.tcl: + * library/text.tcl: added extra checks against bug #220269 and + made spinbox reuse more of the entry procedure code. - * doc/listbox.n: added doc for <> [Bug: 3500] +2001-12-20 Mo DeJong - * doc/getOpenFile.n: removed note that -initialfile didn't work - for tk_getOpenFile - * library/tkfbox.tcl: updated tk_get*File to better match the - Windows file box it emulates, give proper support to -initialfile, - and fixes lack of global tkPriv call. [Bug: 3735 3882] + * unix/configure: Regen. + * unix/tcl.m4: Update from Tcl. - * doc/tk.n: added doc for 'tk useinputmethods ...' - * tests/tk.test: - * unix/tkUnixKey.c: - * generic/tkCmds.c: - * generic/tkEvent.c: - * generic/tkWindow.c: - * generic/tkInt.h: add 'tk useinputmethods ?-display win? ?bool?' - call to provide support for disabling/enabling the use of XIM on - X. This was previously all done at compile time, and always on. - Now it is turned off by default, even when available, and the user - must turn it on to use XIM (per display). +2001-12-19 Mo DeJong - * generic/tkCanvUtil.c: fixed bug in Tk_CanvasPsOutline that freed - mem it shouldn't. + * unix/configure: Regen. + * unix/tcl.m4: Update from Tcl. - * generic/tkFont.c: added "bitstream cyberbit" (popular Windows - CJK font) to list of font fallbacks. (kenny) [Bug: 2407] +2001-12-18 Mo DeJong - * mac/tkMacMenu.c: finished bug 3075 by changing the char values of - what was checked (verified correctness on Mac). + * unix/configure: Regen. + * unix/configure.in: Move EXP file changes over from + Tcl configure script to fix AIX build with gcc. [Bug 220955] -1999-12-13 Jeff Hobbs +2001-12-18 Mo DeJong + + * unix/Makefile.in: + * win/Makefile.in: Use $(MAKE) instead of make + in the tcltest rule. + +2001-12-18 Don Porter + + * tests/event.test (event-click-drag-1.2): Corrected test that + failed on Solaris/CDE due to text scrolling. [Bug 413735] + +2001-12-18 Jeff Hobbs + + * library/spinbox.tcl (ButtonDown): added catch to ignore + possible error in after cancel when Priv(afterId) isn't defined. + + * doc/spinbox.n: corrected spin(up|down) -> button(up|down) + +2001-12-14 Donal K. Fellows + + * doc/getOpenFile.n: Documented change. + * library/tkfbox.tcl (SetFilter): Added code to guess the correct + default extension from whatever value was selected in the + filetypes option menu. Adapted from code by Chris Nelson + submitted in Patch #492220. + +2001-12-12 Jeff Hobbs + + * unix/tkUnixWm.c (TkWmStackorderToplevelWrapperMap): added static + +2001-12-05 Jeff Hobbs - * doc/canvas.n: added docs for items added by dash patch (-*dash*, - -state, -active*, -disabled*, -offset, essentially rewrote the - man patch for completely updated 8.3 canvas widget. - * doc/entry.n: added docs for entry widget validation - * doc/event.n: added docs for -warp - * doc/text.n: doc'ed new -state value 'hidden' - * doc/GetDash.3: (new file) man page explaining Tk_GetDash - * generic/tkStubInit.c: - * generic/tkDecls.h: - * generic/tkIntXlibDecls.h: - * generic/tkInt.decls: added XSetDashes and XWarpPointer - * generic/tk.decls: added Tk_CreateSmoothMethod, and reserved - two spots - * generic/tk.h: added Tk_SmoothMethod struct, - state item to canvas record, #defines for item state, - support for using old char*-based canvas item C creation - procedures with -DUSE_OLD_CANVAS, - Tk_Dash, Tk_TSOffset (-offsets) & Tk_Outline structs and #defs, - decls for dash, outline and postscript routines - * generic/tkBind.c: added support for Quadruple clicks, and added - the -warp option to 'event' with pointer warping routines - * xlib/xgc.c: - * generic/tkRectOval.c: - * generic/tkCanvArc.c: - * generic/tkCanvBmap.c: - * generic/tkCanvImg.c: - * generic/tkCanvLine.c: - * generic/tkCanvPoly.c: - * generic/tkCanvPs.c: - * generic/tkCanvText.c: - * generic/tkCanvUtil.c: - * generic/tkCanvWind.c: - * generic/tkCanvas.c: - * generic/tkCanvas.h: Canvas and items received overhaul to with - the addition of the dash patch (Nijtmans, et al) This includes - objectification of the 'canvas' command, as well as support for - (where appropriate) dashes in items, extended stipple support, - state for all items, and postscript generation of images and - windows. See the new canvas man page for related docs. - * generic/tkEntry.c: added entry widget validation, see entry.n - * generic/tkEvent.c: on simulated events, ButtonPress should - be matched with ButtonRelease to be correct - * generic/tkFont.c: corrected possible null reference - * generic/tkFrame.c: made frame a Tcl_Obj based command - * generic/tkGet.c: added TkGetDoublePixels - * generic/tkImage.c: bug fixes from Img patch and new - Tk_PostscriptImage and Tk_SetTSOrigin functions - * generic/tkImgBmap.c: new ImgBmapPostscript function - * generic/tkImgPhoto.c: new Tk_CreatePhotoOption, Tk_DitherPhoto - * generic/tkInt.h: declarations for some new functions - * generic/tkMessage.c: reworked relief drawing - * generic/tkOldConfig.c: added TK_CONFIG_OBJS so old style - ConfigureWidget calls can pass in Tcl_Obj arrays - * generic/tkScrollbar.c: - * generic/tkScrollbar.h: made -orient use an option table * generic/tkText.c: - * generic/tkText.h: made -wrap and -state use option tables - * generic/tkTextBTree.c: - * generic/tkTextDisp.c: - * generic/tkTextImage.c: - * generic/tkTextMark.c: - * generic/tkTextTag.c: - * generic/tkTextWind.c: added support for -elide and -state hidden - * generic/tkTrig.c: changed TkMakeBezierCurve to support returning - the upper limit of points needed for spline - * generic/tkUtil.c: new option table parsing routines - * generic/tkWindow.c: init'ing of warp stuff, mouseButtonState + * generic/tkText.h: changed TkTextEditType enums to be prefaced + with TK_EDIT_ to prevent name collision. - related bug ids for the fixes: - [Bug: 648 1541 1540 1779 2168 2311 2297 2340 2348 2578 3386] +2001-12-05 Daniel Steffen - * tests/bind.test: - * tests/canvImg.test: - * tests/canvPsArc.tcl: - * tests/canvPsImg.tcl: (new file) - * tests/canvRect.test: - * tests/canvText.test: - * tests/canvas.test: - * tests/defs.tcl: - * tests/entry.test: - * tests/event.test: - * tests/font.test: - * tests/frame.test: - * tests/imgPhoto.test: - * tests/safe.test: - * tests/scale.test: - * tests/scrollbar.test: - * tests/select.test: - * tests/text.test: - * tests/textDisp.test: - * tests/textTag.test: - * tests/unixFont.test: - * tests/unixWm.test: - * tests/visual_bb.test: - * tests/winClipboard.test: tests for the dash patch changes + * mac/tkMacWm.c: mac implementation of wm stackorder + (patch 481148, TIP 74) - * unix/mkLinks: added GetDash.3 into the mkLink step +2001-12-03 Mo DeJong - * mac/tkMacDraw.c: mac still needs pointer warping routine - * mac/tkMacXStubs.c: - * win/tkWinDraw.c: - * win/tkWinPointer.c: added support for pointer warping and - platform specific support for dash patch items + Add TK patch 481148 to implement TIP 74, the + wm stackorder command. -1999-12-12 Jeff Hobbs + * doc/winfo.n: Update documentation for the winfo + children command to indicate that top-level windows + are not returned in stacking order. + * doc/wm.n: Add documentation for wm stackorder. + * generic/tkInt.decls (TkWmStackorderToplevel): + Add decl for new function. + * generic/tkIntDecls.h: Regen. + * generic/tkStubInit.c: Regen. + * tests/unixWm.test: Add stackorder command to test + for wm command usage message. + * tests/wm.test: Add new set of tests for generic + window manager methods. + * unix/tkUnixWm.c (Tk_WmCmd, + TkWmStackorderToplevelWrapperMap, + TkWmStackorderToplevel): Add unix implementation of + new wm stackorder command. + * win/tkWinWm.c (Tk_WmCmd, + TkWmStackorderToplevelEnumProc, + TkWmStackorderToplevelWrapperMap, + TkWmStackorderToplevel): Add windows implementation + of new wm stackorder command. - * generic/tkText.c: fixed bug in TextSearchCmd for multibyte chars - (Darley) [Bug: 3839] +2001-12-03 David Gravereaux - * unix/aclocal.m4: added warning when configuring with - --enable-threads that Tk may have problems + * win/makefile.vc: install target changes by request from + Ryan Casey . -1999-12-09 Jeff Hobbs +2001-11-30 Donal K. Fellows - * generic/tkImgGIF.c: updated casting + * library/demos/widget: Further overhauling; shrank fonts, made + better use of fonts, added an icon, fixed the About box. Prompted + by Bug #487442 from Vincent Wartelle. - * win/makefile.vc: removed 16bit stuff, simplified makefile. +2001-11-29 Donal K. Fellows -1999-12-06 Scott Redman + * library/palette.tcl (tk_setPalette): Added heuristic to guess + from the background whether to use black or white for the + foreground when not told specifically. Suggested by Chris Nelson, + this makes the command fit the documentation better! - * generic/tkMain.c: need to include tclInt.h for new hook - functions that are internal-use-only. +2001-11-27 David Gravereaux -1999-12-06 Jeff Hobbs + * win/makefile.vc: Fixed CAT32 target. cat.c is located in the Tcl + source, not the Tk source. - * library/comdlg.tcl: removed tclVerifyInteger and tclSortNoCase, - they weren't used, and were not actually correct +2001-11-27 D. Richard Hipp - * mac/tkMacFont.c: - * mac/tkMacMenu.c: - * mac/tkMacWindowMgr.c: fixed greyed out menu items, handling of - ... elipsis, font mapping problem, and enabled generated menu - posting [Bug: 3705] + * library/menu.tcl: Do not allow keyboard traversal of torn-off + menus to visit the (invisible) tearoff bar. -1999-12-02 Jeff Hobbs +2001-11-26 D. Richard Hipp - * generic/tkInt.h: - * generic/tkWindow.c: - * generic/tkCmds.c: converted Tk_DestroyCmd, Tk_LowerCmd and - Tk_RaiseCmd to their ObjCmd equivalent. + * win/tkWinMenu.c: disabled menu items show the activebackground + color in their background. This change makes menu behavior + consistent with what native windows does. - * library/msgbox.tcl: added color icons for tk_messageBox on Unix - and Mac when tk_strictMotif isn't set. (Hipp) - * library/tk.tcl: added window bounds checking to ::tk::PlaceWindow +2001-11-24 Mo DeJong - * tests/imgPPM.test: fixed test 2.2 to use -format ppm (since - we know have GIF write capability) + * unix/Makefile.in: Add comments to better describe + TCL_EXE and when it should be available. Add + rule that prints message about running `make genstubs` + when tkStubInit.c is out of date. + * win/Makefile.in: Add TCL_TOOL_DIR and TCL_EXE + variables to better match the Tcl Makefile. Add + genstubs rule so tkSTubInit.c can be regenerated. -1999-12-01 Scott Redman +2001-11-24 Mo DeJong - * generic/tkMain.c : - * unix/tkAppInit.c: - * win/winMain.c: Added added hooks into the main() code for - supporting TclPro and other "big" shells more easily without - requiring a copy of the main() code. + * win/configure: Regen. + * win/configure.in: Don't AC_SUBST CFLAGS_DEBUG, CFLAGS_OPTIMIZE, + or CFLAGS_WARNING since it is now done in SC_CONFIG_CFLAGS. + * win/tcl.m4 (SC_CONFIG_CFLAGS): AC_SUBST DL_LIBS, CFLAGS_DEBUG, + CFLAGS_OPTIMIZE, and CFLAGS_WARNING. -1999-11-29 Jeff Hobbs +2001-11-23 Daniel Steffen - * generic/tkImgGIF.c: added GIF writing that uses miGIF RLE - [Bug: 2039, new patch] + Up-port to 8.4 of mac code changes for 8.3.3 & various new + changes for 8.4, some already backported to 8.3.4 (patch #435660) - * library/entry.tcl: fixed up tkEntrySeeInsert (Nemthi) + * library/tk.tcl: added binding for <> on the mac (TIP26) - * generic/tkListbox.c: fixed 'get' of listbox to return a string - when only one item is requested. + * library/button.tcl: fixed undefined $Priv(repeated) error for button + without -repeatdelay support - * tests/clrpick.test: - * tests/filebox.test: minor whitespace cleanup + * generic/tkConsole.c: + * library/console.tcl: + * mac/tkMacInit.c: + * mac/tkMacResource.r: corrected how mac deals with tcl library + files present both in resources and in $tk_library directory. - * library/tk.tcl: fixed missing $w in ::tk::PlaceWindow + * generic/tkConsole.c: crashing bug fix when printing to console + at program exit after the console has already been closed. + Now setting gStdoutInterp=NULL in ConsoleClose(). -1999-11-24 Jeff Hobbs + * mac/tkMacInit.c: correct use of Tcl_JoinPath in tk_library + initialization - * library/clrpick.tcl: - * library/msgbox.tcl: - * library/tk.tcl: - * library/tkfbox.tcl: - * library/xmfbox.tcl: fixed dialogs to center over -parent, - added utility functions ::tk::PlaceWindow, ::tk::SetFocusGrab, - ::tk::RestoreFocusGrab to tk.tcl to help + * mac/tkMacMenu.c: special MDEF_PROC_OFFSET only needed for + exactly one specific version of the MWERKS 68k compiler . -1999-11-23 Eric Melski + * mac/tkMacShLib.exp: removed file - * tests/listbox.test: Added a test to check that the topIndex is - update when items are removed from the listvar variable. + * unix/Makefile.in: removed reference to .exp files - * generic/tkListbox.c: Added a check the updates the topIndex when - items are removed from the listvar variable. + * mac/MWTkBuildLibHeader.h: + * mac/MW_TkBuildLibHeader.pch: + * mac/MW_TkHeaderCommon.h: + * mac/MW_TkOldImgStaticHeader.h: + * mac/MW_TkStaticHeader.h: + * mac/MW_TkStaticHeader.pch: new precompiled header files - * tests/listbox.test: Added a test to check that the vertical - scrollbar is updated when the listvar changes. + * mac/MW_TkHeader.pch: + * mac/MW_TkOldImgHeader.h: + * mac/MW_TkTestHeader.pch: revised precompiled header handling: now + include a common header file 'MW_TkHeaderCommon.h' from all .pch files, + the .pch files themselves now only setup #defines (e.g. BUILD_tk, + STATIC_BUILD, TCL_DEBUG, TCL_THREADS) like in makefiles on other + platforms. - * generic/tkListbox.c (ListboxListVarProc): added a check that - sets the UPDATE_V_SCROLLBAR flag if the length of the listvar has - changed. + * mac/tkMac.h: + * mac/tkMacPort.h: + * mac/tkMacInt.h: use of BUILD_tk and TCL_STORAGE_CLASS like on other + platforms, standardize #include'd files to what's done on other + platforms, removed use of #pragma export, changed extern to EXTERN + where appropriate to enable DLL export via the TCL_STORAGE_CLASS + mechanism. + + * mac/tkMacAppearanceStubs.c: removed use of #pragma export + + * mac/widget.r: new resource file for 'Widget Demos' + + * mac/tkMacProjects.sea.hqx: updated mac build project files: + build support for CodeWarrior Pro6, UnivIntf 3.4 & shared runtime + libraries (see Tcl ChangeLog for details). + changed weak linking so that CFM68k binaries now work on all OS + versions from the free 7.5.5 onwards, with or without AppearanceMgr + and/or NavigationMgr installed. + added target to automatically build 'Widget Demos' + included XML versions of the projects for CW Pro5 or Pro7 users. + use compat/strtod.c instead of MSL's strtod() -1999-11-23 Jeff Hobbs + * generic/tkInt.decls: + * generic/tkIntDecls.h: + * generic/tkIntPlatDecls.h: + * generic/tkStubInit.c: - * generic/tk.h: - * generic/tkConfig.c: added support for TK_OPTION_DONT_SET_DEFAULT - as equiv for TK_CONFIG_DONT_SET_DEFAULT - * generic/tkListbox.c: added TK_OPTION_DONT_SET_DEFAULT to the - item specs + * mac/tkMacInt.h: MAC_TCL tk stub support was badly broken due to + multiply defined (mac specific) names in tk.decls and tkInt.decls, + removed the duplicates from the internal unsupported interfaces + "interface tkInt" and "interface tkIntPlat"; moved declaration of + TkpIsWindowFloating from tkMacInt.h to tkInt.decls: interface tkIntPlat. + - these changes to the stub tables might require you to recompile your + Tk extensions if they turn out to reference one of the removed routines + in the wrong table (should be unlikely). + + * generic/tkMain.c: MAC_TCL: workaround for broken/non-standard isatty + on MW Pro6, #include instead of defining isatty + + * generic/tkPointer.c: MAC_TCL: #include tkMacInt.h -1999-11-19 Jeff Hobbs + * generic/tkStubLib.c: MAC_TCL: removed obsolete special casing of mac + headers, standardize #include'd files to what's done on other platforms - * generic/tkColor.c: - * generic/tkColor.h: fixed Tk_NameOfColor to work correctly, - with minor change to TkColor struct. + * mac/tclets.r: + * mac/tkMacWindowMgr.c: + * mac/tkMacScrlbr.c: + * mac/tkMacMenu.c: + * mac/tkMacMenus.c: + * mac/tkMacFont.c: + * mac/tkMacDialog.c: + * mac/tkMacButton.c: renamed obsolete apple API names to modern + equivalents; UH3.4 support: added #include ; + fixed munged non-ASCII chars in sources due to bungled latin1<->mac + roman encoding in CVS repository. + + * mac/tkMacDialog.c: added support for -filetypes option (fix for bug + tcl #221636); added update event handling for background windows while + in a NavigationMgr dialog; fixed nasty bug when calling CustomGetFile + (missing addr operator) (fix for bug tk #220911 & tcl #219367); renamed + routines conflicting with standard MoreFiles headers (see Tcl ChangeLog + for details) + + * mac/tkMacApplication.r: + * mac/tkMacLibrary.r: + * mac/tkMacResource.r: fixed obsolete copyrights/dates in version + strings, updated version strings to standard usage, added support for + '(Support Libraries)' subfolder for shared runtime libraries in + unmerged binaries, commented out demo setting of "Tcl Environment + Variables"; reorganized resources among these files to avoid + multiple copies in applications and shared libraries, the script + libraries/Xcursors etc are now no longer duplicated in Wish but are + only included in the resources of Tk.shlb. + + * mac/tkMacMenu.c: + * mac/tkMacMDEF.r: changes to support MW Pro 6 68k (vers 0x2400 only) + compiler producing different offset to start of MDEF; fix to static 68k + presence testing when calling the custom MDEF + + * mac/tkMacWm.c.c: + * mac/tkMacWindowMgr.c: added/fixed AppearanceMgr checks; override + AppearanceMgr version detection on static 68k to ensure static 68k Wish + runs on PPCs with recent AppearanceMgr + + * mac/tkMacButton.c: fixed misplaced/missing variable initialization. + +2001-11-20 Jeff Hobbs + + * generic/tkText.c (TextGetText): reworked to use DString for + improved speed. (callewaert, darley) + (DestroyText): plugged mem leak when not clearing stack (callewaert) + (TextGetText): more efficient string size calculation (darley) + +2001-11-19 Donal K. Fellows + + * library/demos/entry3.tcl: New demo showing off validation and + password entry. + + * library/demos/widget: Some reorganization to make the code + simpler, plus a new entry demo. + +2001-11-17 Jeff Hobbs + + * win/tkWinButton.c (TkpComputeButtonGeometry): corrected the + default size of Windows buttons to conform to the Windows style. + This changes the default size of buttons on Windows. + [Patch #463234] (nelson) + **** POTENTIAL VISUAL INCOMPATABILITY **** + +2001-11-16 Jeff Hobbs - * generic/tkConsole.c: added static declaration to - ConsoleDeleteProc function (proto already had it) + * library/menu.tcl: corrected menu traversal code on Unix to + better handle entering cascades. [Patch #481219] (oleinick) - * win/tkWinInt.h: removed TkFontAttributes typedef (was - redundant with tkFont.h). - * win/tkWinPort.h: put #ifndef __GNUC__ around redefinition - of str[n]casecmp, as cygwin uses the originals. - * win/tkWinX.c: changed GetCurrentTime to GetTickCount (the - former is deprecated). [Bug: 2053] +2001-11-16 David Gravereaux -1999-11-19 Eric Melski + * win/makefile.vc: Install target repaired. - * tests/listbox.test: Added tests for itemcget and itemconfigure. +2001-11-15 Donal K. Fellows - * doc/listbox.n: Added documentation for -listvar option and for - itemconfigure and itemcget commands. + * library/demos/image2.tcl: Many improvements to this + image-viewing demo; now uses labelframes and tk_chooseDirectory - * generic/tkListbox.c: Added support for itemconfigure/itemcget - listbox subcommands (addresses rfe #936) + * library/palette.tcl (::tk::RecolorTree): Made this work better + with CDE, which does some extremely annoying things with the + option database that interact badly with Tk's way of handling + options. -1999-11-17 Eric Melski + * doc/text.n: Overhauled the documentation of undo to make it + easier to understand. + * library/tk.tcl (::tk::EventMotifBindings): Added Emacs-like undo + binding, but not behaviour (we separate undo and redo.) + * library/demos/text.tcl: Show off our undo capability! - * tests/listbox.test: Updated tests for new error messages. +2001-11-12 David Gravereaux - * generic/tkListbox.c: Improved error messages for bad -listvar's. + * win/mkd.bat: + * win/rmd.bat: Removed -kb CVS attribute and added changes + from Llyod Lim for better stability. [Patch #456761] - * tests/listbox.test: Added tests for bad -listvar's. + * win/rules.vc(new): + * win/buildall.vc.bat(new): + * win/makefile.vc: large rewrite following Tcl's makefile.vc as + a guide and Patch #456761. Appears BugFree(tm). - * generic/tkListbox.c: Added handlers for bad -listvar's (ie, bad - lists) +2001-11-12 Jeff Hobbs - * tests/listbox.test: Added tests for ListboxUpdateHScrollbar. + * doc/text.n: + * generic/tkText.c: + * generic/tkText.h: + * generic/tkTextTag.c: + * library/text.tcl: + * library/tk.tcl: + * mac/tkMacDefault.h: + * tests/text.test: + * unix/tkUnixDefault.h: + * win/tkWinDefault.h: added TIP #26 implementation of simple + built-in undo/redo of text editing in the text widget. + [Patch #458879] (callewaert) - * generic/tkListbox.c: Changed some old static buffers to base - size on TCL_DOUBLLE_SPACE instead of (completely) hardcoding the size. +2001-11-12 Donal K. Fellows - * tests/listbox.test: New tests for -listvar functionality, and an - odd extra case that wasn't covered before. + * library/demos/menu.tcl: Show off -compound support in menus. - * generic/tkListbox.c: Tests exposed some bugs, now fixed. + * library/demos/radio.tcl: Added some code to both show off the + extra capabilities of the buttons and also show what can be done + with compound images on the sly. -1999-11-16 Eric Melski +2001-11-10 Mo DeJong - * tests/listbox.test: Fixed tests to comply with new objectified - error messages. No -listvar specific tests yet. + * unix/Makefile.in: + * win/Makefile.in: Add "make gdb" target. This target + can run wish inside either gdb or insight. - * win/tkWinDefault.h: - * unix/tkUnixDefault.h: - * mac/tkMacDefault.h: Added default value for -listvar option. +2001-11-09 Jeff Hobbs - * generic/tkWindow.c: Changed "listbox" mapping from old-school to - new-school objectified command. + * library/clrpick.tcl: changed a few parameters so that the full + 0..255 range could be accessed via the mouse. [Bug #478498] - * generic/tkListbox.c: Objectified listbox; added support for - -listvar option. Converted internal structure to use a Tcl list - object to store the data. + * unix/configure: + * unix/tcl.m4: added -lc to AIX libs, fixed path to ldAix - * generic/tkInt.h: Changed reference to Tk_ListboxCmd to - Tk_ListboxObjCmd. + * win/configure: + * win/tcl.m4: + * win/makefile.vc: add comctl32.lib to build libs. + * win/tkWinX.c (TkWinXInit): added InitCommonControlsEx call. + * win/rc/tk.rc: + * win/rc/wish.rc: + * win/rc/wish.exe.manifest: added resources that specify using v6 + of the MS Common Controls library when available (WinXP+). This + enables use of the themeable widgets (like scrollbars) to be used + in Tk. [Patch #478933] -1999-11-09 Jeff Hobbs +2001-11-09 Mo DeJong - * generic/tkGrid.c: changed Tcl_Alloc to ckalloc + * unix/configure: + * unix/tcl.m4: Update from Tcl. - * generic/tkEntry.c: fixed C expr error in destroy of entry - that could lead to 'malformed bucket chain' error +2001-11-08 Mo DeJong - * win/winMain.c: corrected winMain to not do a DebugBreak when - returning an error message from the top level + * unix/Makefile.in: + Avoid adding libc to the LIBS and WISH_LIBS + variables since it is not needed when linking with CC. + If required when linking with LD it should be done + on a case by case basis in tcl.m4. -1999-10-30 Jeff Hobbs +2001-11-05 Donal K. Fellows - * win/tkWinKey.c: fixed XKeysymToKeycode to handle mapping of - symbolic keysyms (Left, Home, ...) with event generate + * library/demos/dialog2.tcl: Typo-fix. + * library/demos/browse, library/demos/ixset, library/demos/rolodex: + Installation does version number fixup, so we shouldn't. Thanks + to wohnivec@iol.cz for pointing these (thankfully minor) problems + out. - * library/entry.tcl: change tkEntrySeeInsert to avoid the use - of a while loop that could eat CPU tremendously. Behavior of - moving the cursor at the right edge changes slightly (previously - it tried to keep the cursor at the right edge, now it moves the - cursor to a "central right" location - better IMHO). +2001-10-30 Donal K. Fellows -1999-10-28 Jeff Hobbs + * library/demos/widget: Integrated labelframe item into the labels + section and added a spinbox demo to the (retitled) entry section. - * doc/CrtImgType.3: - * doc/CrtPhImgFmt.3: - * doc/FindPhoto.3: - * doc/photo.n: - * generic/tk.h: - * generic/tkCmds.c: - * generic/tkImage.c: - * generic/tkImgBmap.c: - * generic/tkImgGIF.c: - * generic/tkImgPPM.c: - * generic/tkImgPhoto.c: - * generic/tkInt.h: - * generic/tkTest.c: - * generic/tkWindow.c: - * tests/imgPhoto.test: added Img patch (Nijtmans) with docs, - headers #def'd with USE_OLD_IMAGE. Upgrades image stuff to - Tcl_Obj API, adds alpha channel (images are now 32 bpp) + * library/demos/labelframe.tcl: Adjusted so as to show off the + labelframe widget to better effect and have a better description. - * makefile.vc: changed 'c:/program files' to c:/progra~1 + * library/demos/spin.tcl: New demo to show off spinbox capabilities. -1999-10-19 Jeff Hobbs + * library/demos/rolodex: Changes up-ported from core-8-3-1-branch + to make the script use more 8.*-isms, but not menus due to the way + the context help system works. - * library/scrlbar.tcl: changed tkScrollButtonUp to check for - existence of tkPriv(relief) in order to avoid spurious release - events + * library/demos/ixset: Changed to use the labelframe widget and + the grid geometry manager. - * unix/Makefile.in: added ChangeLog to dist archive +2001-10-29 Donal K. Fellows -1999-09-24 Jeff Hobbs + * library/demos/browse: Changes up-ported from core-8-3-1-branch + to make the script much more robust, particularly when neither the + current version of wish or the script are on the path. - * */README: - * win/makefile.vc: - * */configure.in: - * generic/tk.h: - * library/tk.tcl: up'd to 8.3a1 + * library/demos/hello: Added emacs trailing tag-line. - * unix/Makefile.in: changed 'mkdir' to 'mkdir -p' + * library/demos/tcolor: Changes up-ported from core-8-3-1-branch + to make the script compliant with current good practise, as well + as extensive use of the new labelframe widget. - * library/dialog.tcl: changed {Times 18} to {Times 12} for - dialog font. + * library/demos/timer: Changes up-ported from core-8-3-1-branch to + make the script look and work better. -1999-09-16 Jeff Hobbs + * library/demos/rmt: Changes up-ported from core-8-3-1-branch to + use more 8.* features and make the demo script more generally + useful to people. - * generic/tkFont.c: fixed processing of font options and error - returned [Bug: 2075] +2001-10-23 Donal K. Fellows - * win/tkWinWm.c: fixed bug in 'wm deiconify' that raised the - wrong toplevel, and changed it to not set focus on overridden - toplevels + * generic/tkCursor.c (Tk_GetCursorFromData): Fixed uninit nextPtr + field. [adapted from Patch 473875] + (GetCursor): Removed double-assignment to nextPtr field. -1999-09-15 Jeff Hobbs +2001-10-19 Jeff Hobbs - * unix/aclocal.m4: added fix for FreeBSD-[1-2] recognition [Bug: 2070] - and fix to AIX-* to get ldAix right [Bug: 2624], fixed AIX - version check (readjust from 8-21 fix) and several other config - fixes for AIX - * mac/tkMacMenubutton.c: - * unix/tkUnixMenubu.c: fixed permanently stippled menubutton image - * win/tkWinButton.c: fixed possible pointer smash [Bug: 2733] + * library/console.tcl: removed transpose ability until the console + can get a proper rewrite of tag handling. -1999-09-14 Jeff Hobbs +2001-10-18 Jeff Hobbs - * win/tkWinMenu.c: fix for stack overrun in GetTextFace [Bug: 909] + * tests/defs.tcl: removed threaded build warning under X. -1999-09-01 Jeff Hobbs + * library/console.tcl (ConsoleOutput): fixed undefined widget + argument. - * win/tkWinDraw.c: - * unix/tkUnixDraw.c: fixed header style for TkpDrawHighlightBorder - * generic/tkCanvas.c: fixed GC error (bg <> fg) in tkCanvas.c - (from code added to support TkpDrawHighlightBorder) [Bug: 2676] - * unix/aclocal.m4: added -bnoentry to the AIX-* flags - * library/msgbox.tcl: changed the behavior of tk_messageBox on - Unix to be more Windows like in handling of and the - default button - * library/button.tcl: - * library/clrpick.tcl: - * library/comdlg.tcl: - * library/console.tcl: - * library/dialog.tcl: - * library/entry.tcl: - * library/focus.tcl: - * library/listbox.tcl: - * library/menu.tcl: - * library/msgbox.tcl: - * library/palette.tcl: - * library/safetk.tcl: - * library/scale.tcl: - * library/scrlbar.tcl: - * library/tearoff.tcl: - * library/text.tcl: - * library/tk.tcl: - * library/tkfbox.tcl: - * library/xmfbox.tcl: updated commands to use [string] ops - instead of expr equality operators +2001-10-16 Jeff Hobbs -1999-08-21 Jeff Hobbs + * library/xmfbox.tcl: fixed filtering in motif file dialog. + [Patch #469670] (nelson) - * unix/aclocal.m4: Changed AIX-4.[2-9] check to AIX-4.[1-9] - [Bug: 1909] + * generic/tkWindow.c (OpenIM): Added simple XIM patch to enable + basic XIM input on Unix. [Patch #412727] (fabian) -1999-08-20 Jeff Hobbs +2001-10-15 Jeff Hobbs - * generic/tkCursor.c: fixed bug in GetCursorFromObj that caused - panic [Bug: 2562] + * unix/configure: + * unix/configure.in: + * win/configure: + * win/configure.in: + * win/tkConfig.sh.in: reworked to be a little cleaner in + comparison to each other, and to AC_SUBST even empty vars for + win/tkConfig.sh - * TK 8.2.0 RELEASED +2001-10-12 Todd M. Helfter -1999-08-13 Jim Ingham + * ChangeLog: + * doc/menu.n: + * generic/tkMenu.c: + * generic/tkMenu.h: + * generic/tkMenubutton.c: + * generic/tkMenubutton.h: + * mac/tkMacDefault.h: + * mac/tkMacMenu.c: + * mac/tkMacMenubutton.c: + * tests/menu.test: + * unix/tkUnixDefault.h: + * unix/tkUnixMenu.c: + * win/makefile.vc: + * win/tkWinDefault.h: + * win/tkWinMenu.c: + * win/tkWinWm.c: Implementation of TIP #63, the addition of + a -compound option to menu entries allowing text and an image to + be displayed at the same time. - * mac/tkMacMenu.c: Tk_DrawChars ends up setting the menu background - wrong. There is no clean way to stop it, so I use lower level routines - here to draw the text. - * mac/tkMacProjects.sea.hqx: Rearrange the projects so that the build - directory is separate from the sources. Much more convenient! - -1999-08-10 Jeff Hobbs +2001-10-09 Jeff Hobbs - * win/tkWinWm.c: changed "wm deiconify" on Windows to raise and - force the focus on the deiconified window (behavioral change from - 8.1 to comply better with Windows style) [Bug: 1609] - * doc/wm.n: clarified behavior of "wm deiconify". - * generic/tkInt.decls: added TkSetFocusWin - * generic/tkFocus.c: changed static SetFocus to TkSetFocusWin + * library/console.tcl: added more smarts extracted from tkcon to + the default console. - * library/clrpick.tcl: - * library/console.tcl: - * library/tk.tcl: fixed code where abbreviations where used - in calling widget methods (confuses iWidgets) [Bug: 2422] +2001-10-01 Jeff Hobbs -1999-08-09 Jeff Hobbs + * win/tkWinTest.c: better error reporting from testclipboard - * library/button.tcl: cleaned up programming (config -> configure) - and fixed Windows relief bug [Bug: 664] - * library/entry.tcl: changed Entry C/C/P to not use global data - (now uses tkPriv(data)) [Bug: 1475] - * library/listbox.tcl: fixed extended mode script error [Bug: 866] - * doc/options.n: clarified that -troughcolor doesn't work on Windows - * doc/wm.n: fixed wm positionfrom docs [Bug: 2284] + * win/tkWinDialog.c: minor cast changes to support Win64 -1999-08-01 Jeff Hobbs + * win/tkWinWindow.c: made use of standard Tk_GetHWND instead of + older, private TkWinGetHWND. - * mac/tkMacPort.h: wrapped panic in #ifndef panic to avoid - compiler errors when used with stubs-#defines, from Vince Darley. - [Bug: 2389] + * win/configure: regen'ed + * win/tcl.m4: + * win/makefile.vc: updated for Win64 SDK RC1 compilation support + +2001-09-30 Peter Spjuth + + * doc/grid.n: + * generic/tkGrid.c: + * tests/grid.test: Added -uniform option to grid's row/column- + configure. [TIP 37] [Patch 459343] -1999-07-31 Scott Redman +2001-09-26 Peter Spjuth - * xlib/X11/Xlib.h: Remove XFillRectangle since it is now in the - stub tables. + * win/tkWinFont.c (Tk_DrawChars): Added support for clipping text. -1999-07-30 Jeff Hobbs + * doc/frame.n: + * doc/labelframe.n: + * doc/toplevel.n: + * generic/tkFrame.c: + * generic/tkInt.h: + * generic/tkWindow.c: + * library/demos/radio.tcl: + * library/demos/labelframe.tcl: + * library/demos/widget: + * mac/tkMacDefault.h: + * tests/frame.test: + * unix/tkUnixDefault.h: + * win/tkWinDefault.h: Added labelframe widget. Added -padx/y + options to frame and toplevel. - * generic/tkInt.decls: Added stub entry for XFillRectangle [Bug: 2446] + * tests/grid.test: + * tests/pack.test: + * tests/place.test: Used labelframe to test geometry manager changes. + [TIP 18] [Patch 429164] + +2001-09-26 Peter Spjuth -1999-07-30 + * doc/GeomReq.3: + * doc/WindowId.3: + * generic/tk.decls: + * generic/tk.h: + * generic/tkDecls.h: + * generic/tkGeometry.c: + * generic/tkGrid.c (ArrangeGrid): + * generic/tkInt.h: + * generic/tkPack.c (ArrangePacking): + * generic/tkPlace.c (RecomputePlacement): + * generic/tkStubInit.c: + * generic/tkUtil.c (TkComputeAnchor): + * generic/tkWindow.c (TkAllocWindow): + * unix/mkLinks: Geometry manager changes to support TIP#18. + Allows a widget to set different internal border widths on + different sides, and to set a minimum requested size. + POTENTIAL INCOMPATIBILITY. [Patch 429164] + +2001-09-25 Don Porter - * win/makefile.vc: Corrected building threaded tktest.exe on - Windows. Needed to link in .obj files from Tcl, needs to change - later so that code is in Tk and doesn't require a Tcl build. - Also added runtest target. + * generic/tkBind.c: + * generic/tkInt.decls (TkpScanWindowId): + * unix/tkUnixPort.h (Tkp{Print,Scan}WindowId): + * unix/tkUnixXId.c (TkpScanWindowId): + * win/tkWinWindow.c (TkpScanWindowId): Corrected definition of + TkpScanWindowId to handle situation where types Window and int + do not have the same number of bits. CONST-ified too. -1999-07-29 + * generic/tkIntPlatDecls.h: + * generic/tkStubInit.c: make genstubs - * generic/tkConsole.c: Allow tcl to open CON and NUL, even for std - channels. Checking for bad/unusable std channels was moved to Tk - since its only purpose was to check whether to use the Tk Console - Window for the std channels. [Bug: 2393 2392 2209 2458] +2001-09-24 Don Porter - * win/Makefile.in: Corrected building threaded tktest.exe on - Windows. Needed to link in .obj files from Tcl, needs to change - later so that code is in Tk and doesn't require a Tcl build. + * generic/tkMain.c (StdinProc): Update to handle change in + return type of Tcl_DStringAppend() from (char *) to (CONST char *). + [TIP 27] -1999-07-22 +2001-09-23 Peter Spjuth + * generic/tkPack.c (ConfigureSlaves): + * tests/pack.test: + * tests/grid.test: Pack accepted asymmetric values for -ipadx/y. + Only -padx/y supports asymmetry. [Bug #462348] - * Changed version to 8.2b2 +2001-09-21 Jeff Hobbs - * win/tkWinPort.h: Block out include of sys/stat.h in order to - build extensions with MetroWerks compiler for Win32. [Bug: 2385] - - * unix/Makefile.in: Need to make install-sh executable before - calling (with chmod +x). [Bug: 2413] - - * library/menu.tcl: Applied patch from Jeff Hobbs to fix typo. - [Bug: 2425] - -1999-07-21 + * win/tkWinWindow.c (TkpPrintWindowId, TkpScanWindowId): fixed to + work on Win64 with 64bit XIDs. - * unix/Makefile.in: Add Windows configure script to distribution. + * generic/tkWindow.c (Tk_CreateAnonymousWindow): + * generic/tkEntry.c (GetSpinboxElement): fixed unreachable returns. -1999-07-16 + * win/tkWinX.c (TkGetServerInfo): added recognition of Win64. - * unix/Makefile.in: - * win/Makefile.in: Copy the prolog.ps from the generic directory - for install-libraries. + * xlib/X11/X.h: made XID __int64 type for Win64. - * unix/aclocal.m4: Check for Alpha/Linux to set the IEEE flag to - the compiler to be -mieee. Patch from Don Porter. + * unix/tkUnixPort.h: + * mac/tkMacPort.h: add (int*) cast to TkpScanWindowId. + These may need to be changed to Window* (ulong). -1999-07-08 + * generic/tkCmds.c (Tk_WinfoObjCmd): + * generic/tkBind.c (NameToWindow): + correct Window id's to be of type Window - * tests/unixSelect.test: Fixed broken test. + * generic/tkIntDecls.h: + * generic/tkIntPlatDecls.h: + * generic/tkInt.decls (TkpScanWindowId): changed decl to use + Window* instead of int*. - * win/makefile.vc: Added special case target to ensure that - tkStubLib.obj is built with -DSTATIC_BUILD. + * xlib/xcolors.c: + * generic/tkPack.c,tkWindow.c: + * win/tkWinFont.c,tkWinMenu.c: + * unix/tkUnixScale.c: minor cast fixes to prevent 64bit warnings. - * win/tkWinX.c (TkWinChildProc): Changed to pass - WM_WINDOWPOSCHANGED through to DefWindowProc to make OpenGL - sub-windows happy. This allows Windows to generate the WM_SIZE - and WM_MOVE messages. + * tests/scrollbar.test (scrollbar-6.27): marked knownBug because + it is skewed by bad dimensions returned by Windows. -1999-07-08 + * tests/textDisp.test (textDisp-4.12): corrected test to work + properly on Windows. - * unix/configure.in: Fix Tk stub lib file names and flags. + * tests/id.test,macFont.test,macMenu.test,macscrollbar.test: + * tests/send.test,winClipboard.test,winDialog.test,winFont.test: + improved use of test constraints -1999-06-30 + * win/tkWinWm.c (WinSetIcon): fixed SetClassLong for 64bit support. - * generic/tkGrid.c: removed deprecated functions (applied patch - from Jan Nijtmans). [Bug: 2080] +2001-09-20 Jeff Hobbs - * generic/tkImgGIF.c: - * generic/tkImgPPM.c: - * generic/tkImgPhoto.c: Applied patch to allow Img extension to - work with 8.2, from Jan Nijtmans. [Bug: 2068] + * unix/configure: regen'ed + * unix/tcl.m4: added --enable-64bit support for HP-11 with the + 64-bit kernel. - * win/tkWinWm.c: Applied patch from Don Porter to prevent the - windows code from calling the Tcl functions when the stub table - has not been initialized in TkWinWmCleanup. [Bug: 2269] - -1999-06-16 +2001-09-17 Don Porter - * unix/configure.in: - * unix/Makefile.in: - * unix/aclocal.m4: Numerous build changes to make Tk conform to - the proposed TEA spec + * generic/tkGrid.c (ConfigureSlaves): + * generic/tkPack.c (PackAfter): Corrected type definition of + argument passed to Tcl_GetStringFromObj() from size_t to int. + Incorrect type broke [pack] and [grid] on systems where + sizeof(size_t) != sizeof(int). [Bugs 462375, 462342, 462338] - * tkConsole.c: changed some variable types from (int) to (size_t) - to prevent compiler warnings. Cast return value from strlen() - to (int) in one place for the same reason. +2001-09-17 Donal K. Fellows -1999-06-03 + * library/choosedir.tcl (DblClick): + * library/tkfbox.tcl (OkCmd, ListInvoke): Rewrote so as to avoid + the highly confusing string "text" and to be consistent about what + is and what is not a list. [Bug 459895, reported by fandom] - * unix/tkUnixSelect.c: - * tests/unixSelect.test: - * generic/tkSelect.c: Fixed selection code to handle Unicode data - in COMPOUND_TEXT and STRING selections. [Bug: 1791] +2001-09-14 Andreas Kupries -1999-06-02 + * generic/tkImgGIF.c: + * generic/tkImgPPM.c: + * generic/tkImgPhoto.c: + * generic/tkMenu.c: Applied patch [461578], provided by Vincent + Darley. This fixes several memory leaks in the image code. They + happen if there are errors during the initialization of the + channel the image is supposed to be read from. - * generic/tkIntXlibDecls.h: - * xlib/X11/Xlib.h: Added Mac specific defines to help with - compilation. +2001-09-12 Mo DeJong - * generic/tkFont.c: lint + * unix/configure: + * unix/tcl.m4: Update from Tcl. -1999-06-01 +2001-09-12 D. Richard Hipp - * unix/tkUnixSelect.c: Improved I18N selection support. - COMPOUND_TEXT is converted to/from iso2022, and STRING is - converted to/from iso8859-1. There are still a few loose ends to - tie up before this is completely done. + * library/tkfbox.tcl: fixed error that appeared when you would + click on the canvas while viewing an empty directory. - * unix/tkUnixFont.c: Eliminated redundant case folding code. +2001-09-10 Mo DeJong - * generic/tkFont.c: Eliminated use of isupper/tolower in favor of - Unicode variants. + * unix/configure: + * unix/tcl.m4: Update from Tcl. -1999-05-24 +2001-09-09 Mo DeJong - * generic/tkStubLib.c: - * generic/tkStubInit.c: - * generic/tkIntXlibDecls.h: - * generic/tkIntPlatDecls.h: - * generic/tkIntDecls.h: - * generic/tkInt.decls: - * generic/tkConsole.c: Various changes to try to get the Mac - builds working. + * win/Makefile.in: Fix Windows Makefile so that + tcltest will automatically be compiled if the + user tries to build tktest. -1999-05-21 +2001-09-09 Mo DeJong - * win/tkWinClipboard.c: Fixed clipboard code to handle lack of - CF_LOCALE information (e.g. from command.com). + * win/Makefile.in: Use TKTEST variable directly + instead of depending on the tktest alias. -1999-05-20 +2001-09-08 Mo DeJong - * library/console.tcl: Changed copyright string to read 1999 - Scriptics Corp. in wish console about box. - -1999-05-19 + * win/mkd.bat: + * win/rmd.bat: + Apply binary property (cvs admin -kb) to files and convert + to CRLF linefeed format to fix the VC++ build. [Tcl Bug #219409] - * generic/tk.h: Add extern "C" block around entire header file for - C++ compilers to fix linkage issues. Submitted by Don Porter and - Paul Duffin. +2001-08-29 Jeff Hobbs -1999-05-18 + * tests/menu.test: + * tests/send.test: + * tests/select.test: corrected to use testConfig constraints in + the TK_ALT_DISPLAY case + + * tests/unixSend.test: removed test file completely identical to + send.test. Removed platform specific named file in case somebody + gets send working on Win/Mac in the future. + + * tests/config.test: added config-14.1 to test namespace import + evaluation of widgets. + * generic/tkButton.c (ButtonCreate): + * generic/tkFrame.c (CreateFrame): + * generic/tkMenubutton.c (Tk_MenubuttonObjCmd): + * generic/tkPlace.c (Tk_PlaceObjCmd): + * generic/tkScale.c (Tk_ScaleObjCmd): + * generic/tkMessage.c (Tk_MessageObjCmd): + * generic/tkEntry.c (Tk_EntryObjCmd, Tk_SpinboxObjCmd): + * generic/tkSquare.c (SquareObjCmd): redid the handling of + optionTables in widgets to allow them to be imported into other + namespaces. [Bug #456632] + +2001-08-28 Jeff Hobbs + + * win/tkWinDialog.c (ChooseDirectoryHookProc): work-around for MS + bug that caused crashing in tk_chooseDirectory on Win95. + [Bug #224936] (baker) + + * unix/tkUnixWm.c (TkWmRestackToplevel): reworked how + ConfigureNotify requests were handled in relation to the parent to + avoid the problem with potential 'raise' delays on some wms. + [Bug #220260] (baker) wms that were affected should notice the + difference in tests unixWm-51.* not failing that failed before. + +2001-08-26 Don Porter + + * library/text.tcl ( binding): Corrected TIP 44 typo + that broke binding. Thanks to "Michal" for the fix. + [Bug 455468] + +2001-08-23 Jeff Hobbs - * tests/winClipboard.test: - * win/tkWinClipboard.c: Fixed clipboard code so it handles Unicode - data properly on Windows NT and 95. [Bug: 1791] + * unix/configure: + * unix/tcl.m4: added QNX-6 build support. [Bug #219410] (loverso) -1999-05-07 + * doc/CrtPhImgFmt.3: removed bogus note about including tkPhoto.h - * library/menu.tcl: Fixed bug where tk_popup fails when called too - quickly. [Bug: 2009] +2001-08-22 Peter Spjuth -1999-04-30 + * generics/tkGrid.c (ConfigureSlaves): + * tests/grid.test: Fixed a bug where adjacent 'x' and '^' where + not handled properly. [Bug #452040] + +2001-08-22 Jeff Hobbs - * Changed version number to 8.1.1. + * generic/tkPack.c (TkParsePadAmount): added lint init for sepChar. -1999-04-30 + * tests/dialog.test (HitReturn): fixed failing dialog-2.1 test + because it wasn't always getting focus properly. - * Merged changes from 8.1.0 branch: +2001-08-21 Jeff Hobbs - * generic/tkDecls.h: - * generic/tkIntDecls.h: - * generic/tkIntPlatDecls.h: - * generic/tkIntXlibDecls.h: - * generic/tkPlatDecls.h: - * generic/tkStubInit.c: Changed to avoid the need for forward - declarations in stub initializers. Added extern "C" blocks around - stub table pointer declarations so the stubs can be used from C++ - code. [Bug: 1934] + * tests/unixFont.test (unixFont-2.[234]): fixed to be more + sensitive on systems that have more installed fonts. - * generic/tkInt.decls: Added TkClipBox, XDrawSegments, and - XForceScreenSaver to stubs. + * library/dialog.tcl (tk_dialog): changed dialog to show bar on + Windows as well and added some y padding between the buttons and + the bar. [Patch #442835] (harrismh) - * generic/tkStubLib.c: Reordered declarations to avoid - circularities and forward references. +2001-08-20 Peter Spjuth - * generic/tkStubInit.c: Added includes for Mac. + * generic/tkInt.h: + * generic/tkWindow.c: + * generic/tkGrid.c: + * generic/tkPack.c: + * tests/grid.test: + * tests/oldpack.test: + * tests/pack.test: Objectified grid and pack commands. + +2001-08-20 Donal K. Fellows + + * generic/tkObj.c (TkGetWindowFromObj): Rewrote window code to + reuse a previously worked-out set of window information exactly + when the reference window is the same and no window deletions have + occurred since the object was allocated (display has same epoch + counter.) Required changing the internal rep of the window quite + a bit as now need to save three words-worth of information in the + internal rep (this window, reference window, display epoch.) + * generic/tkObj.c (SetWindowFromAny, DupWindowInternalRep, + FreeWindowInternalRep): Code to support new internal rep for + window objects. + * generic/tkInt.h: Added epoch counter to TkDisplay structure + * generic/tkWindow.c (GetScreen, Tk_DestroyWindow): Epoch counter + is incremented every time a window is deleted. + +2001-08-18 Peter Spjuth + + * doc/grid.n: + * tests/grid.test: + * generic/tkGrid.c: Grid configure rejected initial "x" and "^". + [Bug #418664] + +2001-08-17 Donal K. Fellows - * generic/tkMenubutton.c: lint + * generic/tkObj.c (TkGetWindowFromObj): Was failing to reuse + cached window objects, forcing a call to Tcl_GetStringFromObj and + Tk_NameToWindow every time. This fault has been in there for + nearly three years... - * generic/tkEntry.c: Fixed bad option table entry. +2001-08-15 Don Porter - * generic/tkImgBmap.c: - * generic/tkImgPPM.c: - * generic/tkImgPhoto.c: Set the -translation and -encoding options - to binary for image files. (reported by Marco Gazzetta) - -1999-04-23 + * changes: Labelled the TIP 44 changes as "POTENTIAL INCOMPATIBILITY". + Although technically internal changes are not incompatible, they'll + be perceived as such by those who get bitten, and this will help + them find the cause of their trouble. - * generic/tkInt.decls: Added TkClipBox, XDrawSegments, and - XForceScreenSaver to stubs. +2001-08-14 Donal K. Fellows - * generic/tkStubLib.c: Reordered declarations to avoid - circularities and forward references. + * generic/tk{Util,Font,Cursor,Color,Bitmap,3d}.c: Modified + objtype declarations so that they can be picked up in tkObj.c and + the names are now prefixed with "tk" too. + * generic/tkObj.c (TkRegisterObjTypes): + * generic/tkWindow.c (Initialize): + * generic/tkInt.h: Added code to register Tk's object types with + the Tcl runtime. [Tcl Bug 450545] - * generic/tkStubInit.c: Added includes for Mac. +2001-08-12 Mo DeJong - * generic/tkMenubutton.c: lint + * unix/configure: Regen. + * unix/tcl.m4: Update from Tcl. - * generic/tkEntry.c: Fixed bad option table entry. +2001-08-10 Donal K. Fellows -1999-04-22 + * library/demos/image2.tcl (loadDir): Converted non-portable + [glob [file join $dirName *]] to [glob -directory $dirName *] + which is both fully portable and more reliable when directory + names contain glob-significant characters. [Bug 223313] - * generic/tkImgBmap.c: - * generic/tkImgPPM.c: - * generic/tkImgPhoto.c: Set the -translation and -encoding options - to binary for image files. (reported by Marco Gazzetta) +2001-08-08 Don Porter -1999-04-20 + * tests/dialog.test: New file testing [tk_dialog]. - * xlib/X11/Xlib.h: changed definition of Status type to use a - typedef instead of a #define to avoid conflicting with the cygwin - win32 headers [Bug 1804] + * library/dialog.tcl: + * library/tkfbox.tcl: Corrections to problems introduced by + the TIP 44 changes. [Bug 449261] -1999-04-15 + * README: + * generic/tk.h: + * unix/configure: + * unix/configure.in: + * unix/tk.spec: + * win/configure: + * win/configure.in: Bumped up patchlevel to 8.4a4 to distinguish + CVS snapshots from the 8.4a3 release. This does not necessarily + mean there will be an 8.4a4 release. [Bug 448938]. - * Merged 8.1 branch into the main trunk +2001-08-07 Jeff Hobbs -1999-04-09 + * unix/Makefile.in (dist): added {unix,win}/tcl.m4 and + library/msgs/*.msg to dist target. [Bug: #448802] - * generic/tkWindow.c: Fixed deadlock situation when the Initialize() - function returns without releasing the mutex. Found while testing - Bug 1700, during safe.test (tk). +2001-08-06 Jeff Hobbs -1999-04-06 + 8.4a3 RELEASE - * generic/tkMain.c (Tk_MainEx): Changed to reset result before - calling Tcl_EvalFile. The ensures that error messages will be - generated cleanly. + * changes: + * README: updated for 8.4a3 release - * tests/winfo.test: Enabled tests that previously failed. + * unix/configure: regenerated + * unix/tcl.m4: added GNU (HURD) configuration target. (brinkmann) + [Patch: #442974] -1999-04-05 +2001-08-06 Don Porter + * generic/tkConsole.c: + * generic/tkWindow.c: * library/bgerror.tcl: - * library/button.tcl: - * library/clrpick.tcl: + * library/dialog.tcl: + * library/msgbox.tcl: + * library/unsupported.tcl: + * mac/tclets.tcl: + * mac/tkMacHLEvents.c: + * mac/tkMacWm.c: TIP 44 changes specific to the Mac and + Windows platforms that were overlooked before: tkOpenDocument, + tkConsoleExit, tkConsoleOutput, unsupported1 out of namespace :: . + Thanks to Vince Darley for prompting another look. + +2001-08-03 Jeff Hobbs + + * win/winMain.c (WishPanic): fixed CONST changes to go with + CONST-ification in Tcl. + + * win/configure: regenerated + * win/tcl.m4: fixed DLLSUFFIX definition to always be ${DBGX}.dll. + This is necessary for TEA compliant builds that build shared + against a static-built Tk. + * win/Makefile.in ($(WISH)): added $(TK_STUB_LIB_FILE) to build + target, otherwise it wouldn't get generated in a static build. + +2001-08-01 Don Porter + + * doc/console.n: + * doc/menu.n: + * doc/text.n: + * doc/tkvars.n: + * generic/tkBind.c: + * generic/tkMenu.c: + * library/bgerror.tcl: + * library/button.tcl: + * library/choosedir.tcl: + * library/clrpick.tcl: + * library/comdlg.tcl: * library/console.tcl: * library/dialog.tcl: * library/entry.tcl: @@ -2213,1493 +3232,4155 @@ * library/listbox.tcl: * library/menu.tcl: * library/msgbox.tcl: + * library/optMenu.tcl: * library/palette.tcl: * library/scale.tcl: * library/scrlbar.tcl: + * library/spinbox.tcl: + * library/tclIndex: * library/tearoff.tcl: * library/text.tcl: - * library/tk.tcl: Lots of minor performance improvements - contributed by Jeffrey Hobbs. [Bug: 1118] + * library/tk.tcl: + * library/tkfbox.tcl: + * library/unsupported.tcl: + * library/xmfbox.tcl: + * mac/tkMacMenu.c: + * tests/clrpick.test: + * tests/filebox.test: + * tests/macMenu.test: + * tests/menu.test: + * tests/menuDraw.test: + * tests/msgbox.test: + * tests/text.test: + * tests/unixMenu.test: + * tests/winMenu.test: + * tests/xmfbox.test: + * unix/mkLinks: + * unix/tkUnixDialog.c: Merged changes from feature branch + dgp-privates-into-namespace, implementing TIP 44. All + Tk commands and variables matching tk[A-Z]* are now in the + ::tk namespace. See "BRANCH: dgp-privates-into-namespace" + entries below for details. [FR 220936] - * win/tkWinWm.c (Tk_WmCmd): Fixed bad code in tracing - suboption. [Bug: 1519] +2001-07-24 Mo DeJong - * library/tkfbox.tcl: Change to restore button text after an - action to avoid the sticky "Open" button in a save dialog. - [Bug: 1640] + * generic/default.h: Include tkWinDefault.h + when built with Cygwin or Mingw. - * library/entry.tcl: Fixed so selection is returned using the - -show character during cut and paste operations. [Bug: 1687] - -1999-04-5 +2001-07-18 Don Porter - * generic/tkInt.decls: - * generic/tkIntXlibDecls.h: - * generic/tkStubInit.c: - * xlib/xgc.c: - * xlib/X11/Xlib.h: - * xlib/X11/Xutil.h: Added more X functions to the Win & Mac stubs - tables. - -1999-04-05 + BRANCH dgp-privates-into-namespace: + * doc/console.n: Updated names of private console commands. - * unix/configure.in: - * generic/tkCanvPs.c: Added configure test for pw_gecos field in - pwd to support OS/390. [Bug: 1724] +2001-07-16 Don Porter -1999-04-02 + BRANCH dgp-privates-into-namespace: + * library/console.tcl: + * library/unsupported.tcl: Renamed tk::histNum to tk::HistNum + as directed by the Tcl Style Guide. - * tests/text.test: - * generic/tkText.c: Fixed handling of Unicode in text searches. - The -count option was returning byte counts instead of character - counts. [Bug: 1056, 1148, 1666] +2001-07-10 Mo DeJong -1999-04-01 + * unix/Makefile.in: Add AR and STLIB_LD variables. + * unix/configure: + * unix/configure.in: Use STLIB_LD when defining MAKE_LIB + and MAKE_STUB_LIB. Subst STLIB_LD, RANLIB, and AR. + * unix/tcl.m4: Update from Tcl. + * win/configure: Regen. + * win/tcl.m4: Update from Tcl. - * generic/tk.decls: - * generic/tk.h: - * generic/tkStubInit.c: - * generic/tkWindow.c: - * unix/Makefile.in: - * win/makefile.vc: Tk now uses its own stub library to store - pointers to its own stubs table. +2001-07-06 Mo DeJong - * doc/dde.n: (removed) - * doc/send.n: - * generic/tk.decls: - * tests/winSend.test: - * generic/tkPlatDecls.h: - * win/tkWinSend.c: Removed the DDE-based send and dde commands, - they were causing Tk to lock up when any window on the system was - not processing its message queue (more importantly, windows in Tcl - and Tk). The send command needs to be rewritten to prevent the - deadlock situation (soon). The dde command is being pushed into - its own package and will provide almost all of the capabilities - that send did before (using a "dde eval" command), not yet - completed. + * win/configure: Regen. + * win/tcl.m4: Update from Tcl. -1999-03-31 +2001-07-05 Mo DeJong - * win/tkWinSend.c: Modified dde/send code to work properly on - Win95/Win98. String lengths are not returned properly by DDE, so - NULL terminate all strings going in and ignore the string length - coming back out. Do not destroy handles until all necessary work - on those handles (and child handles) is done. + * win/Makefile.in: Subst DEPARG directly instead + of relying on a variable. This will make Cygwin + build faster since an extra exec will be avoided. + * win/configure: Regen. + * win/configure.in: Subst DEPARG. + * win/tcl.m4: Update from Tcl. -1999-03-30 +2001-07-04 Jeff Hobbs - * generic/tkWindow.c (Tk_DestroyWindow): Image handlers are now - finalized before the font subsystem since complex image handlers - may contain references to fonts (e.g. Tix compound images). - [Bug: 1603] + * README: + * mac/README: + * unix/README: + * win/README: updated READMEs with purls -1999-03-29 +2001-07-03 Jeff Hobbs - * doc/MeasureChar.3: - * doc/TextLayout.3: - * generic/tk.decls: - * generic/tkCanvText.c: - * generic/tkEntry.c: - * generic/tkFont.c: - * generic/tkListbox.c: - * generic/tkMessage.c: - * mac/tkMacFont.c: - * unix/tkUnixButton.c: - * unix/tkUnixFont.c: - * unix/tkUnixMenu.c: - * win/tkWinFont.c: - * win/tkWinMenu.c: Standardized text layout and font interfaces - so they are consistent with respect to byte versus character - oriented indices. The layout functions all manipulate character - oriented values while the lower level measurement functions all - operate on byte oriented values. This distinction was not clear - and so the functions were being used improperly in a number of - places. [Bug: 1053, 747, 749, 1646] + * tests/canvas.test: + * generic/tkCanvPoly.c (PolygonToArea): Added patch that respects + the polygon difference of including points in the polygon even + when fill is empty. [Bug #226357] - * generic/tk.decls: Eliminated uses of C++ STL types string and - list from declarations. +2001-07-03 Mo DeJong - * generic/tkFont.c: Changes to named fonts were not being - propagated in some cases. [Bug: 1144] - - * xlib/X11/Xlib.h: - * generic/tkInt.decls: Added XParseColor to xlib stub - tables. [Bug: 1574] + * win/Makefile.in: Remove PATHTYPE variable. + * win/configure: Regen. + * win/configure.in: Don't subst PATHTYPE. + * win/tcl.m4: Update from Tcl. - * doc/GetBitmap.3: - * generic/tkBitmap.c (BitmapInit): Eliminated use of Tk_Uid's in - bitmaps. Added a few CONST declarations. +2001-07-03 Mo DeJong -1999-03-29 + * win/Makefile.in: Don't use VPSEP, instead just use : + in the VPATH. + * win/configure: Regen. + * win/configure.in: Don't subst VPSEP. - * unix/configure.in: - * unix/Makefile.in: - * win/makefile.vc: - * generic/tkDecls.h: - * generic/tkIntDecls.h: - * generic/tkIntPlatDecls.h: - * generic/tkPlatDecls.h: - * generic/tkIntXlibDecls.h: Removed stub functions. Always use the - Tcl stubs when building with --enable-shared. - +2001-07-03 Donal K. Fellows -1999-03-26 + * library/xmfbox.tcl (tkMotifFDialog_ActivateSEnt): Added missing + backslash [Bug #438247] - * generic/tkTextIndex.c: - * tests/testIndex.test: Avoid looking past the beginning of the - array storing data for the text widget (.t index end-2c). Added - test case to check for the bug. [Bug 991] - - * generic/tkConsole.c: Copy static strings into a Tcl_DString - before passing to Tcl_Eval, in case the compiler puts static - strings into read-only memory. +2001-07-02 Jeff Hobbs -1999-03-26 - - * unix/configure.in: - --nameble-shared is now the default and builds Tk as a shared - library; specify --disable-shared to build a static Tk library - and shell. + * generic/tkWindow.c (Tk_DestroyWindow): changed to use + Tcl_EventuallyFree instead of ckfree so that widgets that have + references to a tkwin can use them. -1999-03-26 + * generic/tkCanvArc.c: + * generic/tkCanvBmap.c: + * generic/tkCanvLine.c: + * generic/tkCanvPoly.c: + * generic/tkCanvText.c: + * generic/tkCanvWind.c: + * generic/tkRectOval.c: corrected argument handling in + Create functions that could lead to ABRs or FMRs and + corrected names of argc/argv to objc/objv. - * library/menu.tcl: Fixed bug reported by Bryan Oakley in the - menubutton bindings. There was a false assumption that there was - always a menu attached to the button. [Bug 1116] + * generic/tkImgGIF.c (Mgetc): corrected screwy use of ternary + operator and possible FMR. -1999-03-26 + * generic/tkEntry.c: corrected missing Tcl_Release that caused + font not freed complaints when trying valid cleanup calls. + * generic/tkListbox.c: made use of Tcl_Preserve/Tcl_Release to + prevent FMR errors in Display functions. - * unix/configure.in: Removed --enable-tcl-stub. Linking Tk to Tcl - stubs is causing too many problems when linking executables like wish. - Until the Tk is a fully loadable extension, linking against the Tcl - stubs is not supported in Tk. + * unix/tkUnixScale.c (TkpDisplayScale): corrected FMR when scale + was deleted while calling its command. -1999-03-19 + * library/console.tcl: + * library/entry.tcl: + * library/spinbox.tcl: + * library/text.tcl: + * library/tk.tcl: added private ::tk::GetSelection command to + handle requesting selection. This is to support requesting + UTF8_STRING before generic STRING on Unix. Changed Text, Spinbox, + Entry and Console to use this command. - * generic/tkBitmap.c: - * generic/tkCursor.c: - * generic/tkGC.c: When creating hash tables that key off of XID - handles, make sure to pass TCL_ONE_WORD_KEYS. XIDs are guaranteed - to be 32bit numbers, although on some 64bit systems (including 64bit - Solaris 7) they are packed into a 64bit value where the upper 32bits - are zero. The normal method of sizeof(XID)/sizeof(int) causes the - hash table code to assume that the XID is a pointer to an array of - two ints, which it is not. Tk now supports 64bit Solaris 7. + * tests/select.test: + * generic/tkSelect.c (Tk_CreateSelHandler, Tk_DeleteSelHandler): + on Unix, a UTF8_STRING handler will be created when the user + requests a STRING handler (in addition to the STRING handler). + This provides implicit support for the new UTF8_STRING selection + target. + * unix/tkUnixSelect.c (TkSelEventProc, ConvertSelection): Added + support for UTF8_STRING target. [RFE #418653, Patch #433283] -1999-03-17 + * generic/tkInt.h: added utf8Atom to TkDisplay structure. - * win/makefile.vc: - * generic/tk.h: Changed to use TCL_BETA_RELEASE macro, and fixed - so this works in rc files. - - * win/makefile.vc: - * win/makefile.bc: - * win/README: - * unix/configure.in: - * generic/tk.h: - * README: Updated version to 8.1b3. + * tests/listbox.test: changed 'darkblue' to 'white' in a test + because it isn't a portable color name. -1999-03-14 + * generic/tkEntry.c (DestroyEntry): used Tcl_EventuallyFree + instead of ckfree for entryPtr to prevent FMRs. [Bug #413904] - * unix/configure.in: Added missing stub related definitions. +2001-06-26 Mo DeJong - * unix/Makefile.in: Install tkDecls.h in addition to tk.h. + * unix/Makefile.in: + * win/Makefile.in: Add `make shell` target. This target + will set the proper env vars before invoking wish + from the build directory. - * generic/tkStubLib.c: Added flags to ensure we are using Tcl - stub macros. +2001-06-26 Mo DeJong -1999-03-11 + * win/configure: + * win/configure.in: Revert cross compiling change + accidently added during last checkin. - * generic/tkInt.decls: Added reserved slot for XSetDashes for use - by the dash patch. +2001-06-26 Mo DeJong -1999-03-10 + * unix/configure: Regen. + * unix/configure.in: Fix last checkin by removing + export since that only works in bash. + * win/configure: Regen. + * win/configure.in: Ditto. - * xlib/xdraw.c: - * xlib/X11/Xlib.h: - * mac/tkMac.h: - * mac/tkMacInt.h: - * mac/tkMacPort.h: - * mac/tkMacXStubs.c: - * mac/tkMacAppInit.c: - * mac/tkMacCursor.c: - * win/makefile.vc: - * win/tkWin.h: - * win/tkWinInt.h: - * win/tkWinPort.h: - * win/winMain.c: - * generic/tk.h: - * generic/tkInt.h: - * generic/tk.decls: - * generic/tkInt.decls: - * generic/tkDecls.h: - * generic/tkPlatDecls.h: - * generic/tkIntDecls.h: - * generic/tkIntPlatDecls.h: - * generic/tkIntXlibDecls.h: - * generic/tkStubs.c: - * generic/tkPlatStubs.c: - * generic/tkIntStubs.c: - * generic/tkIntPlatStubs.c: - * generic/tkIntXlibStubs.c: - * generic/tkStubInit.c: - * generic/tkStubLib.c: - * generic/tkBind.c: - * generic/tkCmds.c: - * generic/tkConfig.c: - * generic/tkConsole.c: - * generic/tkCursor.c: - * generic/tkGrab.c: - * generic/tkImgPhoto.c: - * generic/tkMain.c: - * generic/tkMenu.c: - * generic/tkPointer.c: - * generic/tkTextDisp.c: - * generic/tkWindow.c: - * unix/tkUnixInt.h: - * unix/tkUnixPort.h: - * unix/Makefile.in: - * unix/configure.in: - * unix/tkConfig.sh.in: - * unix/tkUnix.c: - * unix/tkUnix3d.c: - * unix/tkUnixDraw.c: - * unix/tkUnixFont.c: - * unix/tkUnixMenubu.c: Stubs implementation for 8.1. Tk_Main() is - replaced with a macro which calls Tk_MainEx(). Tk can link to the Tcl - stubs library, wish links directly to Tcl and Tk. Use - --enable-tcl-stubs to link Tk to the Tcl stubs library (Unix), on - by default on Windows. Exported all public functions through the - stubs mechanism (see the *.decls files) and many of the internal - functions. Most of the changes dealt with shifting around the - function declarations in the header files. Mac code may not - compile, but it shouldn't take much work to fix this. - - * mac/tkMacMenu.c: Added dummy TkpMenuThreadInit for Mac to be - consistent with Unix and Windows versions. - -1999-03-08 +2001-06-26 Mo DeJong - * win/tkWinWm.c: Toplevel class no longer shared between - threads. - - * win/tkWinX.c: Multiple threads no longer share the same - TkDisplay structure. Required because TkDisplay stores much - thread-specific data for a given thread. + * unix/configure: Regen. + * unix/configure.in: Set CFLAGS to "" if the user + did not set CFLAGS in the env. This keeps AC_PROG_CC + from adding "-g -O2" to the CFLAGS by default. + * win/configure: Regen. + * win/configure.in: Ditto. - * win/tkWinSend.c: Moved application instance handle out - out thread-local storage. DDE was failing to initialize - when the instance handles were different between threads. - - * win/makefile.vc: Added THREADDEFINES for building with - threads enabled. - - * generic/tkMenu.c: - * win/tkWinMenu.c: - * unix/tkUnixMenu.c: Added TkpMenuThreadInit for initializing - thread-specific Menu state. +2001-06-22 Mo DeJong -1999-03-01 + * win/configure: Regen. + * win/configure.in: Use RC_DEFINE flag from tcl.m4. + * win/tcl.m4: Update from Tcl. - * win/tkWinWm.c: - * win/tkWinPointer.c: - * win/tkWinInt.h: Fix "focus -force" for Windows. The Win32 API - function SetForegroundWindow() does not work unless the window - handle is a toplevel window (a Windows toplevel). The handle - being passed was a Tk toplevel, which is a child of the Windows - toplevel. +2001-06-22 Mo DeJong -1999-02-26 + * win/configure: Regen. + * win/tcl.m4: Update from Tcl. - * win/cat.c: Remove this file, use the one in the Tcl source directory. +2001-06-22 Mo DeJong - * win/makefile.vc: Remove the wishc.exe from the default targets. Add - a separate console-wish target to build it. The need for a - console-wish will go away soon, so we don't want to encourage its - use. + * win/configure: Regen. + * win/tcl.m4 (SC_CONFIG_CFLAGS): Link to the + imm32 library when building with mingw gcc. + * win/tkWinX.c: Include the imm.h header + to fix compiling with mingw gcc. -1999-02-25 +2001-06-22 Mo DeJong - * win/tkWinWm.c: Properly initialize the tsdPtr->firstWindow field. - - * win/cat.c: Code for cat32.exe, copied from the Tcl sources. Required - in order to run the test suite from the makefile + * win/configure: Regen. + * win/configure.in: Add resource compiler fix from + 8.3.3 to fix compiling with mingw. - * win/winMain.c: Add main() for a console-based wishc.exe, which meant - adding code to disable the call to Tk_ConsoleInit(). - - * generic/tkConsole.c: Check the standard handles before creating the - new standard channels. This allows a windows app that has stdin, - stdout, or stderr to correctly connect to them. - - * generic/tkMain.c: Add a proper check for the interactive mode, since - the standard channels may actually be connected in windows mode or - even in the console-based wish. - - * win/makefile.vc: Add targets for wishc.exe (console-based wish) and - cat32.exe (for testing). Fix the test suite target so it can be run - from the makefile (which can happen since the standard handles have - been fixed). +2001-06-22 Mo DeJong -1999-02-12 + * win/configure: Regen. + * win/tcl.m4: Fix silly typo in last checkin. - * generic/tkMenuButton.h: - * generic/tkMenuButton.c: - * mac/tkMacMenubutton.c: - * mac/tkMacDefault.h - * unix/tkUnixMenubu.c: Eliminated Tk_Uids used by -state option. - * unix/tkUnixDefault.h - * win/tkWinDefault.h - +2001-06-22 Mo DeJong - * generic/tk.h: - * generic/tkScale.h: - * generic/tkScale.c: + * unix/Makefile.in: Set CFLAGS to @CFLAGS@ and @CFLAGS_DEFAULT@. + Set LDFLAGS to @LDFLAGS@ and @LDFLAGS_DEFAULT@. Add LDFLAGS_DEBUG + and LDFLAGS_OPTIMIZE to match the way CFLAGS_DEFAULT works. Use + new LDFLAGS variable in the Makefile instead of @LDFLAGS@. + * unix/configure: Regen. + * unix/configure.in: Don't set CFLAGS to CFLAGS_DEFAULT, instead + subst CFLAGS_DEFAULT into the Makefile. Add AC_SUBST for CFLAGS_DEBUG, + CFLAGS_OPTIMIZE, LDFLAGS_DEFAULT, LDFLAGS_DEBUG, and LDFLAGS_OPTIMIZE. + Remove unused LD_FLAGS subst. + * unix/tcl.m4: Update from Tcl. + * win/Makefile.in: Set CFLAGS to @CFLAGS@ and @CFLAGS_DEFAULT@. + Set LDFLAGS to @LDFLAGS@ and @LDFLAGS_DEFAULT@. + * win/configure: Regen. + * win/configure.in: Don't set CFLAGS or LDFLAGS, instead subst + CFLAGS_DEFAULT and LDFLAGS_DEFAULT into the Makefile. + * win/tcl.m4: Update from Tcl. + +2001-06-22 Mo DeJong + + * win/configure: + * win/tcl.m4: Update From Tcl. + +2001-06-21 eric melski + + * doc/colors.n: Corrected bogus documentation with respect to + several shades of blue, all of which were listed as RGB 0 0 0. + [Bug #432104]. + +2001-06-14 Donal K. Fellows + + * library/demos/floor.tcl, library/demos/filebox.tcl, + * library/demos/clrpick.tcl, library/demos/vscale.tcl, + * library/demos/twind.tcl, library/demos/ruler.tcl, + * library/demos/plot.tcl, library/demos/items.tcl, + * library/demos/hscale.tcl, library/demos/ctext.tcl, + * library/demos/cscroll.tcl, library/demos/arrow.tcl, + * library/xmfbox.tcl, library/msgbox.tcl, + * library/clrpick.tcl, library/bgerror.tcl: Braced expressions. + +2001-06-06 Mo DeJong + + * win/configure: Regen. + * win/configure.in: Handle the --prefix option correctly + it should default to /usr/local like the unix version. + +2001-06-03 Jeff Hobbs + + * doc/selection.n: + * doc/clipboard.n: added SEE ALSOs to cross-reference selection + and clipboard, with extra note for clipboard command in selection + docs. [Patch #422256] + + * unix/tkUnixFont.c: Corrected support for iso10646 (X11 Unicode) + fonts on Unix. This adds a ucs-2be (UCS-2 Big Endian) encoding in + Tk on Unix that is used for those fonts (X11 requires + big-endianness). (welch) [Patch #406411; Bug #220890 #220899] + This differs from the 8.3.3 patch by not adding ucs-2be in the + preferred encodingList (seems works fine without). + Added alias for jisx0201* fonts to jis0201 encoding. [Bug #414033] + +2001-05-30 Jeff Hobbs + + * win/tkWinKey.c (TkpSetKeycodeAndState): removed old debug info + +2001-05-29 Jeff Hobbs + + * win/tkWinX.c: moved the initialization of tkPlatformId from + TkWinXInit to TkWinGetPlatformId because static builds could call + it before it was initialized. [Bug #427278] + +2001-05-28 Peter Spjuth + + * generic/tkFrame.c: * generic/tkWindow.c: - * unix/tkUnixScale.c: - * unix/tkUnixDefault.h: - * unix/tkWinDefault.h: - * mac/tkMacDefault.h: Objectified scale widget. + * tests/frame.test: Upgraded frame to use the newer TK_OPTION + style when processing configuration options. Some cleanup of + bad comments and bad code. [part of patch #420861] - * win/tkWinX.c: Removed Thread-specific data from process - initialization code that was stopping the Tk Dll from - loading. +2001-05-23 Mo DeJong -1999-02-11 + * unix/configure: + * unix/tcl.m4: + * win/configure: + * win/tcl.m4: Sync from Tcl sources. - * README: - * generic/tk.h: - * unix/configure.in: - * win/README: - * win/makefile.bc: - * win/makefile.vc: Updated version to 8.1b2. - - * unix/tkUnixSend.c: Fixed one more Tcl_*ObjVar instance. - -1999-02-04 +2001-05-21 Jeff Hobbs - * Various cleanup related to the Tcl_Eval and Tcl_ObjSetVar - changes in Tcl. - - INTEGRATED PATCHES FROM 8.0.5b2: - - * win/tkWinMenu.c (TkpDestroyMenu): Changed so modalMenuPtr is - cleared when it is being destroyed. + * unix/tcl.m4: sync'ed up wih Tcl tcl.m4. [Bug #419812] - * generic/tkImgPhoto.c: Changed so color tables are freed - immediately instead of being delayed. This ensures that color - tables are properly disposed at process exit. + * doc/TkInitStubs.3: + * generic/tk.h: + * generic/tkStubLib.c: CONST'ified Tk_InitStubs to match CONST + changes to Tcl_PkgRequireEx. - * library/prolog.ps: Changed string that determines font height to - include European character with an umlaut. +2001-05-21 Todd M. Helfter - * generic/tkImgBmap.c (ImgBmapConfigureInstance): If an image - mask changed but ended up with the same XID, the GC failed to be - updated and so the new mask was not used. [Bug: 970] + * doc/menubutton.n: + * generic/tkMenubutton.c: + * generic/tkMenubutton.h: + * mac/tkMacMenubutton.c: + * tests/menubut.test: + * unix/tkUnixMenubu.c: Implementation of TIP #11, the addition of + a -compound option to the menubutton allowing text and an image to + be displayed at the same time. This behavior is identical to the + behavior of the button widget. - * generic/tkFocus.c (SetFocus): Changed so focus window is always - set if -force is specified. This fixes the problem on Windows - where Tk does not activate the window if it already has focus. +2001-05-16 Donal K. Fellows - * generic/tkConsole.c: Fixed so errors in console eval are - reported properly. Eliminated duplicate result messages. [Bug: 973] + * doc/console.n: Added - was erroneously placed in Tcl before... - * win/tkWinWm.c: Changed so windows that aren't resizable don't - have resize handles and the zoom box is disabled. +2001-04-25 Mo DeJong - * win/tkWinInt.h: - * win/tkWinPointer.c: Changed to cancel the mouse timer when a - user initiated move/resize loop begins. + * unix/configure: Regen. + * unix/tcl.m4: Update from Tcl. + * win/configure: Regen. + * win/tcl.m4: Update from Tcl. - * unix/configure.in: TK_LD_SEARCH_FLAGS was set incorrectly if - SHLIB_LD_LIBS='${LIBS}', and shared linking is performed through - the C compiler. Systems affected are Linux, MP-RAS and NEXTSTEP, - but also with gcc on many more systems. [Bug: 908] +2001-04-25 Mo DeJong - * win/makefile.vc: First stab at install target. Fixed quoting so - paths with spaces work. - - * tests/main.test: - * tests/unixWm.test: Better cleanup of temporary files. - - * mac/tkMacAppInit.c: - * generic/tkTest.c: - * generic/tkAppInit.c: - * win/winMain.c: Changed some EXTERN declarations to extern - since they are not defining exported interfaces. This avoids - generating useless declspec() attributes and makes the windows - makefile simpler. + * unix/configure: Regen. + * unix/configure.in: Use $@ in MAKE_LIB and MAKE_STUB_LIB + commands instead of using a delayed subst variable. Replace + instances of STUB_LIB_FILE with TK_STUB_LIB_FILE. - * library/menu.tcl (tkMenuFind): Changed so keyboard shortcuts - will only be found in the current toplevel. Previously, they - might be found in menus attached to other toplevels that might not - even be mapped. [Bug: 924] +2001-04-25 Mo DeJong - * generic/tkCanvLine.c: Changed to treat zero width lines like - they have width 1 for purposes of selection. [Bug: 925] + * unix/Makefile.in: Use TCL_STUB_LIB_FILE instead of STUB_LIB_FILE. + * unix/configure: Regen. + * unix/configure.in: Don't subst STUB_LIB_FILE, use TCL_STUB_LIB_FILE + instead. - * win/tkWinFont.c (Tk_MeasureChars): Added a workaround for a bug - in GetTextExtentExPoint on Win NT 4.0/Japanese. [Bug: 1006] +2001-04-12 Donal K. Fellows - * unix/tkUnixSend.c (Tk_SetAppName): Fixed uninitialized memory - access bug. [Bug: 919] + * generic/tkImage.c (Tk_ImageObjCmd,DeleteImage): Better detection + of deletion when world is falling apart. [Bug #220819] -1999-1-28 +2001-04-04 Jeff Hobbs - * generic/tkGrid.c: Fixed bug in "grid forget" that failed to cancel - pending idle handlers, resulting in a crash in a few odd cases. + * win/tkWinMenu.c (TkWinHandleMenuEvent): corrected reseting of + service mode to only occur when it was set. [Bug #220948] -1999-01-06 +2001-04-03 Jeff Hobbs - * generic/tk.h, generic/tkGet.c, generic/tkConfig.c, - * generic/tkOldConfig.c, generic/tkEntry.c, generic/tkMenubutton.c, - * generic/tkMenubutton.h, generic/tkScale.c, generic/tkScale.h, - * generic/tkTextDisplay.c, generic/tkText.c, unix/tkUnixMenubu.c, - * unix/tkUnixScale.c, mac/tkMacMenu.c, mac/tkMacMenubutton.c, - - Removed global Tk_Uids dealing with "-state" configuration option - and added new TK_CONFIG_STATE configSpec that doesn't use - Tk_Uids. + * tests/winClipboard.test: improved results for understanding when + tests fail. -1998-12-11 === Tk 8.1b1 Release === - -1998-12-11 + * tests/winDialog.test: string totitle'd some results that + expected [pwd] to return a capital drive letter. - * generic/tkMain.c (Tk_Main): Fixed improper command line encoding - handling. + * tests/cursor.test: changed tests to use 'heart' cursor because + 'arrow' on windows has a pre-skewed use count. -1998-12-08 + * win/tkWinDialog.c (GetFileNameA): initialize multi to 0. - * tkMacMenu.c, tkUnixMenu.c, tkWinMenu.c, tkMenuDraw.c, tkMenu.h, - * tkMenu.c: Backed out the previous fix for bug 620 and - eliminated a bunch of code that created unnecessary objects. - Changed back to using internal types instead of objects for many - configuration options. There are many more fixes like this that - could be made, but some require a little restructuring of the - code. In any case the leaks are fixed and there is a lot less - allocation happening. [Bug: 620] - -2000-03-21 Syd Polk +2001-04-02 Jeff Hobbs + + * win/configure: + * win/tcl.m4 (SHLIB_LD): added -incremental:no. [Bug #219381] + + * generic/tkMenu.c (TkInvokeMenu): checked for menu deletion + before calling associated menu entry command. [Bug #220821] - * configure.in: Compare to cygwin, not cygwin32. - * configure: Regenerate. + * doc/image.n: added warning about names chosen for images. -1999-05-24 Syd Polk + * generic/tkImgPhoto.c (ImgPhotoCmd): corrected the src and dest + values for $imageName put when -format and -to are used. + [Bug #232741] - * generic/tkArgv.c: Updated version string. + * tests/listbox.test: added test listbox-27.1, delete during + scrollbar update + * generic/tkListbox.c (DestroyListbox, ListboxEventProc): + corrected listbox to make proper use of Tcl_EventuallyFree and + protect against unusual listbox deletion. -1999-04-22 Syd Polk + * tests/entry.test: added tests entry-20.*, delete during widget + activity + * generic/tkEntry.c (DestroyEntry, EntryEventProc): fixed the + entry widget to survive deletion while processing scrollbar + updates and validation. + + * tests/canvas.test: test of canvas delete during event + * generic/tkCanvas.c (DestroyCanvas, CanvasEventProc): fixed the + canvas to survive deletion during event processing. [Bug #228024] + +2001-04-01 Jeff Hobbs + + * README: + * mac/README: updated patchlevel to 8.4a3 and corrected links and + notes. + + * generic/tk.h: + * unix/configure.in (TK_PATCH_LEVEL): + * unix/configure: + * unix/tk.spec: + * win/configure.in (TK_PATCH_LEVEL): + * win/configure: updated patchlevel to 8.4a3 + +2001-03-30 Jeff Hobbs + + * tests/safe.test: added note about correcting failures in + safe.test. + * library/tk.tcl: moved package require msgcat inside if case to + not be used in safe interps. + + * win/makefile.vc: + * win/configure: + * win/tcl.m4: added imm32.lib to LIBS_GUI for Tk IME support. + * win/tkWinInt.h: + * win/tkWinKey.c: + * win/tkWinX.c: added support for changing IME on the fly in + Windows (2000). (lam) [Patch #402993] + + * tests/bind.test (bind-22.18): + * generic/tkBind.c (NameToWindow): handled the error case where a + valid-looking but invalid identifier could be passed in certain + event generate options causing a crash. [Bug #411307] + + * win/tkWinWm.c (UpdateWrapper): ensured that the passed in winPtr + had an existent window to operate on. [Bug #409172] + + * win/Makefile.in (install-*): improved install-* targets to use + their base build dependency. + + * generic/tkImage.c (Tk_ImageObjCmd, EventuallyDeleteImage): + added casts to allow compiling on Windows with debbuging. + +2001-03-29 Jeff Hobbs + + * library/msgs/de.msg: fixed translations. [Patch #403525] + + * doc/canvas.n: Noted ability to specify coords as a list in the + docs. (techentin) [Patch #403660] + + * tests/canvas.test: added test case to check obj conversion + * generic/tkObj.c (UpdateStringOfMM, SetMMFromAny): better + obj-aware screen distances. (pgbaum, hobbs) [Patch #403327] + + * library/bgerror.tcl (bgerror): allow focus into details window + for Windows C&P to work. [Bug #220929] + + * library/tk.tcl: put a catch around adding to the + <> virtual event as it doesn't seem to work on all HP + systems. [Bug #411669] + + * library/tkfbox.tcl: fixed selecting directories and single files + with spaces using tk_getOpenFile -multiple 1. [Bug #411640] + + * win/tkWinDialog.c (GetFileNameA): added support for -multiple to + ascii-based tk_getOpenFile (Win9*). (haneef) [Patch #403047] + (GetFileNameW): increased number of files that could be returned + by tk_getOpenFile -multiple. [Patch #412042] + +2001-03-29 Mo DeJong + + * library/entry.tcl (tkEntryMouseSelect): + * library/text.tcl (tkTextSelectTo): When + the mouse is dragged with the button down, + move the insertion cursor to the current + mouse position. + * tests/event.test: Add a series of tests + for event generation. Add tests for selection, + check the position of the insertion cursor. + +2001-03-28 Jeff Hobbs + + * unix/configure: + * unix/tcl.m4: corrected IRIX-5.x config to not use -n32. + (english) [Patch 403626] + +2001-03-28 Don Porter + + * tests/focus.test (focus-6.1): + * tests/macEmbed.test (unixEmbed-5.1): + * tests/macMenu.test (macMenu-21.3): + * tests/menu.test (menu-27.1): + * tests/unixEmbed.test (unixEmbed-8.2): + * tests/unixWm.test (unixWm-50.4): Replaced all [load {} tk] + in Tk test suite with [load {} Tk]. [Bug 220940, Patch 411952] + +2001-03-12 Don Porter + + BRANCH dgp-privates-into-namespace: + * doc/menu.n: + * unix/mkLinks: Added documentation for [tk_menuSetFocus]. + +2001-03-12 Don Porter + + BRANCH dgp-privates-into-namespace: + * doc/text.n: + * doc/tkvars.n: + * unix/mkLinks: Added documentation for commands and variables + matching tk_text*. + +2001-03-08 Don Porter + + BRANCH dgp-privates-into-namespace: + * generic/tkTextDisp.c: + * library/unsupported.tcl: + * tests/textDisp.test: Restored the global variables tk_textRedraw + and tk_textRelayout. Since they match tk_*, they should remain + publicly available until at least Tk 9. + +2001-03-01 Don Porter + + BRANCH dgp-privates-into-namespace: + * library/unsupported.tcl: New file for Tk's unsupported + interfaces. Contains [tk::unsupported::ExposePrivateCommand] + and [tk::unsupported::ExposePrivateVariable] that restore the + availability of an old public name of one of Tk's private + commands and variables, respectively, for those applications + and extensions that depend on the old names against advice. + +2001-02-28 Don Porter + + BRANCH dgp-privates-into-namespace: Feature branch to move all + of Tk's private commands and variable into the ::tk namespace + and its children. + + * doc/tkvars.n: Documented private variable tkPriv renamed tk::Priv. + + * generic/tkBind.c: + * generic/tkMenu.c: + * generic/tkTextDisp.c: + * library/bgerror.tcl: + * library/button.tcl: + * library/choosedir.tcl: + * library/clrpick.tcl: + * library/comdlg.tcl: + * library/console.tcl: + * library/dialog.tcl: + * library/entry.tcl: + * library/focus.tcl: + * library/listbox.tcl: + * library/menu.tcl: + * library/msgbox.tcl: + * library/optMenu.tcl: + * library/palette.tcl: + * library/scale.tcl: + * library/scrlbar.tcl: + * library/spinbox.tcl: + * library/tclIndex: + * library/tearoff.tcl: + * library/text.tcl: + * library/tk.tcl: + * library/tkfbox.tcl: + * library/xmfbox.tcl: + * mac/tkMacMenu.c: + * tests/clrpick.test: + * tests/filebox.test: + * tests/macMenu.test: + * tests/menu.test: + * tests/menuDraw.test: + * tests/msgbox.test: + * tests/text.test: + * tests/textDisp.test: + * tests/unixMenu.test: + * tests/winMenu.test: + * tests/xmfbox.test: + * unix/tkUnixDialog.c: All Tk commands matching ::tk[A-Z]* and + all Tk private variables in the global namespace were renamed to + live in the namespace ::tk or one of its children. + +2001-02-13 Eric Melski + + * doc/photo.n: [Bug 132213] Added clarification on interpretation + of ranges for "photoName data -from" subcommand. + +2001-02-12 D. Richard Hipp + + TIP #21: Asymmetric padding in the pack and grid geometry managers. + With this changes, you can now say "-padx {10 20}" to put 10 pixels + of padding on the left and 20 on the right. Similar rules apply + for vertical padding. See the revised documentation for details. + +2001-01-02 Andreas Kupries + + * Everything below belongs together and implements TIP #8 + (SF patch #102833). + + * win/tkWinWm.c (line 56f): Added icon structures. + * win/tkWinWm.c (struct WmInfo, line 242): Added reference to + optional icon for titlebar. + * win/tkWinWm.c (struct ThreadSpecificData, line 335): Added + reference to optional default icon for toplevel windows. + * win/tkWinWm.c (line 387 ... 1169): All the new functions required + to deal with icon specifications, 'InitWm' changed. + * win/tkWinWm.c (TkWmNewWindow, UpdateWrapper, TkWmDeadWindow, Tk_WmCmd): + Added initialization and handling of the new fields. + * doc/wm.n: Documentation updated to explain the newly available + functionality. + +2000-12-13 jeff hobbs + + * generic/tkObj.c (SetMMFromAny): Added ability to recognize + double type object to speed up canvas coord calculations. + [Patch 403327] + +2000-12-12 Donal K. Fellows + + * doc/entry.n: Improved documentation of interplay between the + -state and -textvariable options. + +2000-11-29 Donal K. Fellows + + * tests/image.test (image-1.10): Improved this test, which + previously only worked if the command failed to delete the root + window, and caused *major* trouble otherwise... + * generic/tkImage.c (EventuallyDeleteImage): Created this function + so that images that get deleted during the creation of an image + won't cause a nasty core dump. Properly fixes bug #120819. + +2000-11-28 Donal K. Fellows + + * doc/image.n: + * generic/tkImage.c (Tk_ImageObjCmd): Backed out previous change. + Bug #120819 is back again in force. Left the test in there + though. + +2000-11-23 Donal K. Fellows + + * doc/image.n: + * tests/image.test (image-1.10): + * generic/tkImage.c (Tk_ImageObjCmd): Prohibited image names that + start with "." since they can cause some really obscure + crashes. Fixes Bug #120819. + +2000-11-21 Eric Melski + + Overall change: Implemented TIP 5, which exports + TkClassProcs/TkSetClassProcs as Tk_ClassProcs/Tk_SetClassProcs, + adding a size field to Tk_ClassProcs to allow for future + expansion, and renaming the geometryProc to worldChangedProc, + which is more in keeping with the actual use of the callback. + + * unix/mkLinks: Added link for Tk_SetClassProcs. + + * doc/SetClassProcs.3: Documentation for + Tk_ClassProcs/Tk_SetClassProcs. + + * generic/tkCanvas.c: + * generic/tkEntry.c: + * generic/tkFrame.c: + * generic/tkListbox.c: + * generic/tkMenu.c: + * generic/tkMessage.c: + * generic/tkScale.c: + * generic/tkText.c: Updated to use Tk_ClassProcs/Tk_SetClassProcs + instead of TkClassProcs/TkSetClassProcs. + + * generic/tkMenubutton.c: + * generic/tkScrollbar.c: + * generic/tkButton.c: Updated to use Tk_SetClassProcs instead of + TkSetClassProcs. + + * generic/tkMenubutton.h: + * generic/tkScrollbar.h: + * generic/tkButton.h: + * win/tkWinButton.c: + * win/tkWinScrlbr.c: + * mac/tkMacButton.c: + * mac/tkMacMenubutton.c: + * mac/tkMacScrlbr.c: + * unix/tkUnixButton.c: + * unix/tkUnixMenubu.c: + * unix/tkUnixScrlbr.c: Updated to use Tk_ClassProcs instead of + TkClassProcs. + + * generic/tkDecls.h: + * generic/tkStubInit.c: + * generic/tkIntDecls.h: Regenned from tk.decls, tkInt.decls. + + * generic/tk.h: Added declaration of Tk_ClassProcs, with size + field. Added typedef's for Tk_ClassCreateProc, + Tk_ClassWorldChangedProc, Tk_ClassModalProc. Added definition of + Tk_GetClassProc macro, shorthand for extracting a member of the + Tk_ClassProcs structure. + + * generic/tkInt.h: Removed declaration of TkClassProcs, + TkClassGeometryProc, etc. + + * generic/tkBind.c (Tk_BindEvent): Updated to use Tk_GetClassProc + macro to extract modalProc; added check that the modalProc is non-NULL. + + * generic/tkFont.c (RecomputeWidgets): Updated to use + Tk_GetClassProc macro to extract worldChangedProc; added comment + about the choice of a recursive versus iterative algorithm for + propagating world changed messages. + + * generic/tkWindow.c (Tk_MakeWindowExist): Updated to use + Tk_GetClassProc macro to extract createProc from Tk_ClassProcs. + + * generic/tk.decls: Added declaration for Tk_SetClassProcs. + + * generic/tkInt.decls: Commented out declaration for + TkSetClassProcs, which is made public by this change. The entry + is left in place, but commented, so that future developers will + know not to reuse it's stub number. + +2000-11-21 Donal K. Fellows + + * doc/ConfigWidg.3: Added deprecation note from Bug #120944 - use + Tk_SetOption() instead. + + * generic/tkImgPhoto.c (TkPhotoGetValidRegion): Applied patch to + create this function and add it to tkInt stubs. Should now be + possible to write an extension that accesses the transparency data + in a photo image. Bug #120930 + +2000-11-03 Jeff Hobbs + + 8.4a2 RELEASE + + * generic/tkWindow.c (Initialize): added call to Tcl_SetMainLoop. + This only has effect when tclsh is run (not wish), and then Tk is + loaded in interactively. + +2000-11-02 Jeff Hobbs + + * win/tkWinButton.c: + * win/tkWinDialog.c: + * win/tkWinScrlbr.c: + * win/tkWinWm.c: fixed up code for Win64 support. This mostly + remains in _WIN64 #ifdef's, until updated compilers are standard. + + * win/tcl.m4: + * win/makefile.vc: updated for Win64 compile support + + * unix/configure: + * win/configure: checked in configure scripts so people doing + CVS checkouts aren't required to have autoconf. Changes to + configure.in in the future will require the corresponding + configure script to also be re-autoconf'ed and checked in. + + * doc/event.n: added note that key events require window focus. + +2000-11-01 Jeff Hobbs + + * win/tkWinDialog.c (GetFileNameW, GetFileNameA, + Tk_ChooseDirectoryObjCmd): created + work-around for change in NT5.0/98 that caused no initialdir + setting to open the browser up in the user's documents dir. + + * tests/color.test: marked color-2.6 nonPortable as we can't + reliably assume what 'red' maps to. + +2000-11-01 Eric Melski + + * tests/winDialog.test: Corrected expected results for bad option + tests (5.2, 5.5) to include -multiple option. + + * win/tkWinDialog.c: Added branch for 0 return from + CommDlgExtendedError() switches; this was formerly treated as an + error, but it actually is not, since it just means the user hit + cancel or closed the dialog. (GetFileNameW): Added better smarts + such that -multiple is not considered a valid option for + tk_getSaveFile. + Removed CommDlgExtendedError() checks for color and choosedir + dialogs, and removed all except the explicit invalid filename + checks for the file dialogs. + +2000-10-30 David Gravereaux + + * win/configure.in: + * win/Makefile.in: + * win/makefile.vc: + * win/rc/tk.rc: + * win/rc/tk_base.rc (new): + * win/rc/wish.rc: Added logic to derive filenames better in the + resource scripts based on compile options along with better + support for building a static wish shell with cursor resources. + +2000-10-27 Jeff Hobbs + + * unix/tcl.m4: added support for AIX-5. + + * tests/tk.test: + * doc/tk.n: updated to reflect default on status of useinputmethods. + * library/tk.tcl: tk useinputmethods is set to 1 by default. This + enables Kanji and dead-char input by default. Intro'd in + 1999-12-16 with default off to avoid some problems with older X + servers that would slow down widget creation over time. + + * win/Makefile.in (test, winhelp, tktest): corrected the + TCL_LIBRARY path specification. + +2000-10-18 Eric Melski + + * win/tkWinDraw.c (RenderObject): Applied patch from [Bug: 6368], + which corrects rendering of 1-pixel wide stippled lines on Windows. + + * generic/tkCanvLine.c (DisplayLine): Applied patch from + [Bug: 6368], corrects bugs relating to use of active- and + disabledwidth values for displaying lines (disabledwidth was never + used, and activewidth/disablewidths would only possibly be used + when greater than default width, rather than when simply not equal + to default width). + + * library/tkfbox.tcl (OkCmd): Applied patch from [Bug: 6365], + which adds safety for directory names containing spaces or which + are non-lists. + + * win/tkWinDialog.c (GetFileNameW, GetFileNameA, + Tk_ChooseColorObjCmd, Tk_ChooseDirectoryObjCmd): Added error + checking for the return value from the common dialog functions, so + that the commands will not silently fail if the common dialog + returns an error. [Bug: 6369]. + +2000-10-10 Eric Melski + + * generic/tkConfig.c (Tk_InitOptions): Added + Tcl_IncrRefCount/Tcl_DecrRefCount calls on valuePtr, to prevent + memory leaks when the value object comes from the option + database. [Bug: 6275]. + +2000-10-06 Jeff Hobbs + + * win/Makefile.in (cat32.${OBJEXT}): add win/ subdirectory to + cat32 target to correctly find the source file. + +2000-10-05 Eric Melski + + * generic/tkCmds.c (Tk_WinfoObjCmd): Added check for + TK_ANONYMOUS_WINDOW flag in the [winfo children] subcommand; if + set, the window will not be printed in the list of children. + + * doc/CrtWindow.3: Added entry for Tk_CreateAnonymousWindow. + + * generic/tkWindow.c + (Tk_CreateAnonymousWindow): New API for creating anonymous + windows. These windows are manipulable from C, but not from Tcl, + because they have no pathname associated with them. They are used + initially by widgets that do rubber-band resizing (panedwindow, + multi-column listbox, etc.), and may be useful for other widgets + as well (dropbox, combobox). + (Tk_DestroyWindow): Added check for TK_ANONYMOUS_WINDOW flag when + determining whether to generate a DestroyNotify event. + + * generic/tkStubInit.c: + * generic/tkDecls.h: Regen'd from tk.decls. + + * generic/tk.decls: Added Tk_CreateAnonymousWindow declaration. + + * generic/tk.h: Added TK_ANONYMOUS_WINDOW flag for Tk_Window's. + +2000-10-04 Eric Melski + + * doc/MaintGeom.3: Noted that Tk_MaintainGeometry handles direct + descendants properly. + + * generic/tkGeometry.c (Tk_MaintainGeometry): Added a check for + the case in which the slave window is a direct descendant of the + master window. In this case, we need not set up the additional + infrastructure normally provide by Tk_MaintainGeometry, because we + can rely on the parent/child relationship to handle it for us + implicitly. In this case, Tk_MaintainGeometry just calls directly + to Tk_MoveResizeWindow. This allows geometry managers to simply + always use Tk_MaintainGeometry to maintain geometry for slaves, + and avoid doing the direct descendant check themselves. + (Tk_UnmaintainGeometry): Added a matching check for the direct + descendant case; in this case, Tk_UnmaintainGeometry simply + returns immediately. + +2000-10-01 Eric Melski + + * generic/tkButton.c (ConfigureButton): Added tests for -compound + option, so that when there is a textvariable and an image, and + -compound is not none, the button will display both the + textvariable and the image. + + * doc/SetOptions.3: Added note that restoreProc and freeProc may + be NULL. + + * generic/tkConfig.c (Tk_RestoreSavedOptions): For custom options, + added test that the restoreProc is not NULL, to allow for custom + options that don't care about supporting Tk_RestoreSavedOptions. + +2000-09-29 D. Richard Hipp + + * generic/tkBitmap.c: Changes to prevent a BadMatch error from the + Xserver when the same bitmap is used on two or more screens of the + same display. + + * tests/menu.test: Print a warning if the TK_ALT_DISPLAY environment + variable is not configured so as to test for the bug fix above. + + * library/tk.tcl (::tk::SetGrabFocus): "Catch" the grab in case + another application already holds the grab and the "grab" command + fails. + +2000-09-29 Jeff Hobbs + + * win/Makefile.in: commented use of TESTFLAGS + * unix/Makefile.in: added TESTFLAGS to test and testlang targets to + conform with Windows makefile and TEA style. + +2000-09-29 Eric Melski + + * generic/tkTest.c: Fixed tests to use updated API. + + * doc/SetOptions.3: + * generic/tk.h: + * generic/tkConfig.c: Changed interface for Tk_CustomOptionSetProc + and Tk_CustomOptionGetProc; these now take a pointer to the start + of the widget record, and an integer offset to the slot for the + option value, instead of just a pointer to the slot. This allows + more sophisticated options to do interesting things based on other + data in the widget record. + +2000-09-17 Eric Melski + + * generic/tk.h: Added declaration of Tk_ObjCustomOption structure, + used for TK_OPTION_CUSTOM, and typedef's of the functions + Tk_CustomOptionSetProc, Tk_CustomOptionGetProc, + Tk_CustomOptionRestoreProc, and Tk_CustomOptionFreeProc, used for + TK_OPTION_CUSTOM. + + * doc/SetOptions.3: Added documentation of TK_OPTION_CUSTOM, and + section "CUSTOM OPTION TYPES" explaining how to create and use + custom options. + + * tests/config.test: Added tests for custom option type. + + * generic/tkTest.c: Added test support for TK_OPTION_CUSTOM to + TestobjconfigObjCmd. Added CustomOption* functions to implement a + test custom option. + + * generic/tkConfig.c: Added new option type TK_OPTION_CUSTOM, + which allows the definition of custom option types by creating + parsing, printing, freeing, and restoring procedures for a custom + option. This is needed by the text and canvas widgets if they are + to be fully objectified. + +2000-09-07 Jeff Hobbs + + * doc/Tk_Init.3: + * doc/bell.n: + * doc/loadTk.n: minor doc cleanup + +2000-09-06 Eric Melski + + * doc/HWNDToWindow.3: + * doc/GetHWND.3: Changed synopsis to indicate the tkPlatDecls.h + should be included, not tk.h. + + * generic/tkPlatDecls.h: Removed #include for Windows, + a better solution for now is to update the docs and have extension + authors #include . + + * generic/tk.h: Removed '#include "tkPlatDecls.h"', as the + incorrect inclusion order between windows.h/tkPlatDecls.h causes + build conflicts on Windows. + + * generic/tkPlatDecls.h: Added #include for Windows, + so that HWND, etc., are defined properly. + +2000-09-06 Jeff Hobbs + + * doc/canvas.n: fixed doc bug (ellson). [Bug: 6218] + + * README: + * generic/tk.h: + * unix/configure.in: + * unix/tk.spec: + * win/configure.in: updated to patchlevel 8.4a2 + + * generic/tkMessage.c (MessageWidgetObjCmd): initialized result to + avoid pedantic warning. + + * generic/tkGrab.c (Tk_GrabObjCmd): changed len arg from size_t to + int to fix pedantic warning. + +2000-09-01 Eric Melski + + * win/makefile.vc (install-libraries): + * win/Makefile.in (install-libraries): + * unix/Makefile.in (install-libraries): Added tkPlatDecls.h to + list of header files to install. + + * generic/tk.h: Added #include "tkPlatDecls.h", which declares the + platform specific component of the public Tk stubs API's. + +2000-08-29 Eric Melski + + * win/tkWinMenu.c (DrawWindowsSystemBitmap): Use scratchDC + for determining the source's logical coordinates. Patch from + [Bug: 6134 (Markus Oberhumer)]. + + * win/tkWinMenu.c (SetDefaults): Compute the indicatorDimensions[] + under Windows NT/2000 in the same way as under Windows 95/98. + Patch from [Bug: 6134 (Markus Oberhumer)]. + + * win/tkWinFont.c (GetScreenFont): Added a memset() to + pacify memory checkers. Patch from [Bug: 6134 (Markus Oberhumer)]. + + * library/tkfbox.tcl (::tk::dialog::file::Update): Corrected + handling of multi-pattern filters (eg, "* *.*"), which was broken + by the getOpenFile performance patches applied earlier. + +2000-08-24 Eric Melski + + * doc/toplevel.n: + * doc/spinbox.n: + * doc/scrollbar.n: + * doc/scale.n: + * doc/menubutton.n: + * doc/menu.n: + * doc/listbox.n: + * doc/entry.n: + * doc/frame.n: + * doc/message.n: + * doc/checkbutton.n: + * doc/radiobutton.n: + * doc/button.n: + * doc/label.n: + * doc/canvas.n: + * doc/text.n: Fixed Standard Options section to make best use of + new tab settings in man.macros. + +2000-08-24 Mo DeJong + + * unix/README: Update to account for removal of --enable-gcc. + * unix/configure.in: + * unix/tcl.m4 (SC_ENABLE_GCC): Remove --enable-gcc option. + * win/configure.in: + * win/tcl.m4 (SC_ENABLE_GCC): Remove --enable-gcc option. + Remove quick hack that provided cross compile support for + windows builds. + +2000-08-23 Jeff Hobbs + + * generic/tkButton.c (ButtonTextVarProc): reversed change below, + it was not correct. + +2000-08-22 Jeff Hobbs + + * generic/tkButton.c (ButtonTextVarProc): changed order of + incr/decr of new value object, in case they are equal. + +2000-08-18 Eric Melski + + * generic/tkImgPhoto.c (ImgPhotoGet): Removed redundant call to + DitherInstance; this call was formerly being made from + ImgPhotoGet->ImgPhotoConfigureInstance->DitherInstance, and + ImgPhotoGet->DitherInstance. The second call was removed. + +2000-08-10 Jeff Hobbs + + * doc/SetOptions.3: added missing ')'. + +2000-08-09 Eric Melski + + * doc/SetOptions.3: Updated documentation to reflect support for + TK_OPTION_NULL_OK for TK_OPTION_DOUBLE and TK_OPTION_PIXELS. + + * generic/tkConfig.c: Added for TK_OPTION_NULL_OK support for + TK_OPTION_DOUBLE and TK_OPTION_PIXELS. + + * doc/place.n: Updated, reformatted manual entry. + + * tests/place.test: Added many tests. + + * generic/tkPlace.c (Tk_PlaceObjCmd): Updated to use Tk + widget-option management facilities to manage place options (-x, + -y, etc.), which simplifies the placer code. Added support for + [place configure pathName] and [place configure pathName -option], + similar to the behavior of the configure subcommand supported by + widgets. + +2000-08-08 Eric Melski + + * tests/place.test: Extended test suite to test error returns from + [place]. + + * generic/tkInt.h: Replaced Tk_PlaceCmd prototype with + Tk_PlaceObjCmd prototype. + + * generic/tkWindow.c: Updated [place] command entry to use new + Tcl_Obj interface. + + * generic/tkPlace.c (Tk_PlaceObjCmd): Tcl_Obj'ified [place] command. + +2000-08-07 Eric Melski + + * generic/tkWindow.c: Updated [selection] command entry to use + new Tcl_Obj interface. + + * generic/tkInt.h: Replaced Tk_SelectionCmd prototype with + Tk_SelectionObjCmd prototype. + + * tests/select.test: Updated test suite to recognize standardized + error messages. + + * generic/tkSelect.c (Tk_SelectionObjCmd): Tcl_Obj'ified + [selection] command. + +2000-08-07 Jeff Hobbs + + * doc/cursors.n: changed .SS to more compatible macros. + +2000-08-05 Jeff Hobbs + + * library/safetk.tcl: rationalized the setting of tk_library when + initialized Tk in a safe interpreter. + +2000-08-03 Eric Melski + + * generic/tkWindow.c: Updated "grab" command entry to use + Tcl_Obj'ified command. + + * generic/tkInt.h: Replaced Tk_GrabCmd prototype with + Tk_GrabObjCmd prototype. + + * tests/grab.test: Initial suite of tests for [grab] command. + + * generic/tkGrab.c (Tk_GrabObjCmd): Tcl_Obj'ified [grab] command. + + * generic/tkInt.h: Removed Tk_AfterCmd function prototype; the + function does not exist (since 4.0p3). Cleaned up some line + wrapping. + + * generic/tk.h: Removed "#define Tk_AfterCmd Tcl_AfterCmd"; + nothing in the core uses Tk_AfterCmd, and Tcl_AfterCmd doesn't exist + anymore anyway. + + * generic/tkInt.h: Replace Tk_BindCmd prototype with + Tk_BindObjCmd prototype. + + * generic/tkWindow.c: Updated "bind" command entry to use + Tcl_Obj'ified command. + + * generic/tkCmds.c (Tk_BindObjCmd): Tcl_Obj'ified [bind] command. + + * tests/bind.test: Tweaked expected error messages for [bindtags] + to comply with updated error messages. + + * generic/tkMenu.c (CloneMenu): Replaced calls to Tk_BindtagsCmd + with equivalent calls to Tk_BindtagsObjCmd. + + * generic/tkInt.h: Replace Tk_BindtagsCmd prototype with + Tk_BindtagsObjCmd prototype. + + * generic/tkWindow.c: Updated "bindtags" command entry to use + Tcl_Obj'ified command. + + * generic/tkCmds.c (Tk_BindtagsObjCmd): Tcl_Obj'ified [bindtags] + command. + +2000-08-02 Eric Melski + + * generic/tkCmds.c (Tk_TkwaitObjCmd): Tcl_Obj'ified [tkwait] command. + + * generic/tkWindow.c: Updated "tkwait" command entry to use + Tcl_Obj'ified command. + + * generic/tkInt.h: Replace Tk_TkwaitCmd prototype with + Tk_TkwaitObjCmd prototype. + + * generic/tkGrid.c (Tk_GridCmd): Split [grid] subcommands into + separate functions instead of inlining them all in Tk_GridCmd. + +2000-08-01 Eric Melski + + * generic/tkInt.h: Replaced prototype for Tk_MessageCmd with + prototype for Tk_MessageObjCmd. + + * generic/tkWindow.c: Marked message command as using the new + MessageObjCmd instead of the old MessageCmd. + + * tests/message.test: Added tests for the message widget. + + * generic/tkMessage.c: Obj'ified the message widget. + + * generic/tkInt.h: Removed prototype for Tk_ClipboardCmd, added + prototype for Tk_ClipboardObjCmd. + + * generic/tkWindow.c: Updated function pointers for clipboard + command to use Tcl_Obj version. + + * tests/clipboard.test: Updated tests to expect standard error + messages. + + * generic/tkClipboard.c (Tk_ClipboardObjCmd): Obj'ified + Tk_ClipboardCmd -> Tk_ClipboardObjCmd. + +2000-07-28 Eric Melski + + * unix/tkUnixButton.c (TkpDisplayButton): Added bits to change + the indicator color when radio-/check-buttons are disabled. This + reduces the visual incongruity when a group of these controls are + disabled together. + + * win/tkWinMenu.c (ReconfigureWindowsMenu): Added MF_GRAYED bit + for disabled menu entries, to ensure that those which are drawn by + the system are shown grayed (such as entries on menubars) [Bug: 4372]. + + * doc/label.n: Added -disabledforeground to list of options [Bug: + 6053]. + + * mac/tkMacDefault.h: + * unix/tkUnixDefault.h: Added default values for listbox + disabledforeground and state. + + * win/tkWinDefault.h: Changed default listbox background color to + white and listbox selection borderwidth to 0, in keeping with the + "Microsoft Windows User Experience"; added default values for + listbox disabledforeground and listbox state. + + * doc/listbox.n: Added documentation for -state option. + + * generic/tkListbox.c: Added support for -state to listbox. [RFE: + 6052]. + + * tests/listbox.test: Tests for listbox disabled state. + +2000-07-27 Mo DeJong + + * win/configure.in: TCL_STUB_LIB_FLAG and + TK_STUB_LIB_FLAG should not include ${TCL_DBGX} + in win/tkConfig.sh, fix that. + +2000-07-25 Joe English + * doc: CanvPsY.3, ConfigWidg.3, CrtImgType.3, CrtItemType.3, + FontId.3, GetFont.3, canvas.n, font.n, options.n, text.n: + Documentation fix: Replaced references to XFontStruct * + and Tk_FontStruct with Tk_Font. + +2000-07-24 Eric Melski + + * tests/text.test: Added tests for -regexp -nocase searches with + backslash character classes. + + * generic/tkText.c (TextSearchCmd): Text search did not work + properly when -regexp and -nocase were used, in combination with + backslash character classes represented by capital letters (ie, + \W, \M); altered implementation of -regexp -nocase searches to use + new regexp interfaces to fix this problem. [Bug: 5988]. + +2000-07-21 Eric Melski + + * tests/text.test: Added tests for searching when text is elided. + + * generic/tkText.c (TextSearchCmd): Text search was not returning + the correct index when the search covered (but did not search) + elided characters; corrected this by adjusting the match index by + the number of elided characters preceeding the start of the match, + just as is done with embedded windows, etc. [Bug: 5470]. + +2000-07-21 Mo DeJong + + * win/configure.in: Add TK_STUB_LIB_FLAG and + TK_BUILD_STUB_LIB_SPEC. These are needed to build a stub enabled + extension. + +2000-07-20 Eric Melski + + * unix/tkUnixDraw.c (TkScrollWindow): Replaced a use of a trinary + operator with an if/else, to avoid build problems on some + platforms [Bug: 5819]. + + * win/makefile.vc: Applied patch from Don Porter to enhance nmake + support on NT/Alpha [RFE: 5939]. + +2000-07-19 Eric Melski + + * library/text.tcl: Enhanced binding to behave like normal + bindings when the text widget is disabled (ie, it advances + focus to the next widget). + + * generic/tkText.c (TextSearchCmd): Added a test for a NULL + segment pointer when doing backwards searches for "" on an empty + text widget. [Bug: 6007]. + +2000-07-18 Mo DeJong + + * unix/aclocal.m4: Use tcl.m4. + + * unix/configure.in: Properly quote LOCALES variable. Properly quote + argument to m4 macro. + + * unix/tcl.m4: Add updated file from tcl. + + * win/tcl.m4: Updated file from tcl. + +2000-07-18 Eric Melski + + * library/tkfbox.tcl: Fixed keyboard navigation in the iconlist. + + * unix/configure.in (MAKE_LIB): Corrected definition of MAKE_LIB + for shared builds, with patch from Mike Hopkirk. + +2000-07-18 Mo DeJong + + * win/Makefile.in: Fix TCL_GENERIC_DIR variable + so that it uses the TK_SRC_DIR in the same way + as the unix version. + +2000-07-17 David Gravereaux + + * generic/tkConsole.c: Added comments for a Win2K OS bug with + GetStdHandle(STD_OUTPUT_HANDLE). No change was done to the code + as the resulting behaviour of ShouldUseConsoleChannel() was + correct, anyways. [BUG: 5971] + +2000-07-17 Eric Melski + + * generic/tkStubImg.c (Tk_InitImageArgs): Applied patch from [Bug: + 5990], from Anselm Lingnau, which correctly sets the value of + useNewImage to 0 when the new image system is not to be used, + instead of leaving it at -1, which causes the check to be + performed more times than is really necessary. + + * library/bgerror.tcl: Fixed a typo in one of the bgerror dialog + label. + + * library/msgs/it.msg: Italian message catalog, from Paolo + Brutti. [RFE: 6012]. + +2000-07-07 Eric Melski + + * library/msgs/el.msg: Greek message catalog, from George Petasis. + +2000-07-07 Mo DeJong + + * win/configure.in: Fix subst of TK_SHARED_BUILD + variable in tkConfig.sh.in. Fix definition of + TK_SRC_DIR variable so that it matches the + unix version. + +2000-07-05 Mo DeJong + + * generic/tkFileFilter.c (AddClause): Cast to match function prototype. + * win/stubs.c (_XInitImageFuncPtrs): Add return value for function. + * win/tkWinButton.c (buttonStyles, ButtonBindProc, ComputeStyle): + Remove unused declarations. + * win/tkWinColor.c (GetColorByName, GetColorByValue): Remove unused + function declarations. + * win/tkWinDialog.c (TrySetDirectory): Remove unused function + declaration. + * win/tkWinEmbed.c (TkWinEmbeddedEventProc): Cast to match function + prototype. + * win/tkWinMenu.c (winMenuMutex, MenuExitProc): Remove unused + declaration. + * win/tkWinWindow.c (StackWindow): Remove unused declaration. + * win/tkWinWm.c (ConfigureEvent): Remove unused declaration. + * win/tkWinX.c (winXMutex): Remove unused declaration. + * xlib/ximage.c (XCreateBitmapFromData): Cast to match function + prototype. + +2000-07-05 Eric Melski + + * tests/imgPhoto.test: Added test for GIF writing code [Bug: 5823]. + + * generic/tkImgGIF.c: Applied patch from Jan Nijtmans to fix a + problem with the GIF writing code [Bug: 5823]. + + * generic/tkCursor.c: Added initialization for nextPtr field of + TkCursor, patch from Nijtmans/Howlett. + +2000-07-05 Eric Melski + + * library/msgs/nl.msg: Dutch message catalog for dialogs, from Jan + Nijtmans. + +2000-06-30 Eric Melski + + * doc/keysyms.n: + * doc/colors.n: Added extra .CE/.CS pairs to break up the large + text block, so that the generated Windows help file could + accomodate the manual entry. [Bug: 5862] + + * tests/filebox.test: Adjusted tests to accomodate -multiple. + + * library/xmfbox.tcl: Adjusted arguments list construction such + that -multiple is not presented as an option for tk_getSaveFile. + + * library/tk.tcl: Added test for safe interpreter status before + attempting to load message catalogs (which is impossible in a + standard safe interpreter). This means that SafeTk will not have + localized dialogs, unless a means is found for loading the message + catalog files. + +2000-06-29 Eric Melski + + * library/msgs/de.msg: German message catalog. + + * library/msgs/en.msg: English message catalog. + + * library/msgs/es.msg: Spanish message catalog. + + * library/msgs/fr.msg: French message catalog. + + * unix/Makefile.in: + * unix/configure.in: + * library/tk.tcl: + * library/clrpick.tcl: + * library/choosedir.tcl: + * library/console.tcl: + * library/msgbox.tcl: + * library/tkfbox.tcl: + * library/xmfbox.tcl: + * library/bgerror.tcl: Applied patches from Laurent Duperval to + provide localization of Tk dialogs. [RFE: 2671]. + +2000-06-27 Eric Melski + + * generic/tkMenu.c (DeleteMenuCloneEntries): Applied fix from + [Bug: 5275], which corrected a segfault-causing indexing problem + when deleting entries from torn-off menus. + +2000-06-22 Eric Melski + + * doc/getOpenFile.n: Updated with information about -multiple. + + * library/choosedir.tcl: Tweaked to handle modified tkIconList API's. + + * library/tkfbox.tcl: Preliminary implementation of multiple + selection; based on patch from [RFE: 604]. Some of the tkIconList + functions changed to support this and to make the dialog faster. + + * library/xmfbox.tcl: Added support for multiple selection, from + patch in [RFE: 4999]. + +2000-06-21 Eric Melski + + * library/text.tcl: Corrected behavior of text widget with respect + to this sequence of events: click, shift-click. Previously, the + shift-click just moved the cursor and anchor; now, the shift-click + will select the text between the click and the shift-click, which + is the behavior most users expect. [Bug: 5929]. + +2000-06-19 Eric Melski + + * library/bgerror.tcl: Added auto-truncation for long error + messages (more than 30 characters wide, or more than 4 lines + long), so that the dialog remains a manageable size. [RFE: 5782] + +2000-06-15 Eric Melski + + * win/tkWinDialog.c: Patched to support tk_getOpenFile + -multiple. [RFE: 604]. + +2000-06-13 Eric Melski + + * win/aclocal.m4: + * win/configure.in: + * win/Makefile.in: Applied patch from [RFE: 5844], to provide + support for the mingw compile environment for Windows. + +2000-06-06 Jeff Hobbs + + 8.4a1 RELEASE + +2000-06-03 Jeff Hobbs + + * doc/CrtCmHdlr.3: new doc for ClientMessage handler procs + * generic/tk.h: added typdef for Tk_ClientMessageProc + * generic/tkStubInit.c: + * generic/tkDecls.h: + * generic/tk.decls: Added Tk_CreateClientMessageHandler and + Tk_DeleteClientMessageHandler declarations. + * generic/tkEvent.c (Tk_HandleEvent): Added + Tk_CreateClientMessageHandler and Tk_DeleteClientMessageHandler to + allow adding event handlers that invoke for ClientMessage events. + This is necessary to support unix dnd protocols. + +2000-06-02 Jeff Hobbs + + * canvas.test: added test for 5783. + * generic/tkCanvPoly.c (DisplayPolygon): added checks for the + polygon fillGC not being empty to prevent segfault. [Bug: 5783] + +2000-05-31 Eric Melski + + * library/bgerror.tcl: Improved bgerror based on work by Donal + K. Fellows; no longer dependant 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. + +2000-05-30 Eric Melski + + * generic/tkImgGIF.c: Changed defines for GIF87a/GIF89a to be + static char arrays with integer initialization, to address EBCIDIC + vs. ASCII encoding issues and to handle compilers that don't deal + with "\xAB" syntax for specifying hex values in strings. + +2000-05-28 Jeff Hobbs + + * doc/spinbox.n: (new file) docs for spinbox widget + * generic/tkInt.h: added Tk_SpinboxObjCmd declaration + * generic/tkEntry.c: added 'spinbox' widget - an extension of the + entry widget type. + * generic/tkWindow.c: added 'spinbox' to core Tk commands + * library/spinbox.tcl: (new file) binding and helper procs for spinbox + * library/tk.tcl: added spinbox.tcl to list of files to source + * tests/entry.test: updated changed error messages + * tests/spinbox.test: (new file) test suite for spinbox + + * generic/tkPlace.c (Tk_PlaceCmd): reworked place master/slave + table init'n to prevent seg fault when using place on multiple + displays. + + * generic/tk.h: added comments ot Tk_FakeWin structure + +2000-05-26 Eric Melski + + * generic/tkOption.c (Tk_GetOption): Extended Tk_GetOption to + support a new syntax for option names in option tables. If the + option name has an embedded ".", it indicates that the name field + contains both an option name and an overriding widget class, in + the form "class.option". The lookup for the option value will be + performed as though the widget class is that specified, rather + than the actual widget class. + (SetupStacks): Replaced several lines of array element copying + with a for loop for conciseness. + +2000-05-25 Eric Melski + + * library/button.tcl: Tweaks for -overrelief handling on Windows. + + * doc/radiobutton.n: Added documentation for -overrelief option. + + * doc/checkbutton.n: Added documentation for -overrelief option. + + * doc/label.n: Added documentation for -state option. + + * generic/tkButton.c: Added -overrelief option for checkbuttons, + and radiobuttons. + + * library/button.tcl (tkButtonDown, macintosh version): Added + protection against querying the -repeatdelay option from a widget + that doesn't support it (ie, checkbuttons, radiobuttons, etc). + Other platforms use a different binding script for checkbuttons + and radiobuttons, so they don't have this issue. + (tkCheckRadioEnter, windows version): Added code to handle + -overrelief for check/radiobuttons on windows. + +2000-05-22 Eric Melski + + * generic/tkButton.c: Added -activeforeground, -activebackground + for labels, for the -state option. + + * doc/label.n: Added documentation for -state option, + -activeforeground, -activebackground. + +2000-05-22 Jeff Hobbs + + * win/Makefile.in (install-libraries): corrected to install X + headers [Bug: 5516] + + * doc/bind.n: + * doc/canvas.n: + * doc/entry.n: + * doc/listbox.n: + * doc/photo.n: doc fix-ups [Bug: 5396] + +2000-05-17 Jeff Hobbs + + * doc/bell.n: + * tests/bell.test: + * generic/tkCmds.c (Tk_BellObjCmd): added -nice option to + optionally avoid resetting screen saver [Bug: 4279] + +2000-05-15 Jeff Hobbs + + * win/tkWinWm.c (Tk_WmCmd): changed wm deiconify from using idle + callback to calling restack and focus code immediately. + +2000-05-17 Eric Melski + + Overall change: Added "-readonlybackground" option for entries, + to enable a visual change when state goes to readonly. + + * mac/tkMacDefault.h (DEF_ENTRY_READONLY_BG_COLOR, + DEF_ENTRY_READONLY_BG_COLOR): + * win/tkWinDefault.h (DEF_ENTRY_READONLY_BG_COLOR, + DEF_ENTRY_READONLY_BG_COLOR): + * unix/tkUnixDefault.h (DEF_ENTRY_READONLY_BG_COLOR, + DEF_ENTRY_READONLY_BG_COLOR): Added default values for entry + -readonlybackground option. + + * generic/tkEntry.c: Added -readonlybackground option, cleaned up + excessive use of graphics contexts. + + * tests/entry.test: Added configuration test for + -readonlybackground option. + + * doc/entry.n: Added documentation for -readonlybackground option. + + Overall change: changed implementation of "link" relief for + buttons. Instead of a new relief style (-relief link), there is a + new option, -overrelief, which if set is used when the mouse is + over the button. + + * doc/SetOptions.3: Added information about TK_OPTION_NULL_OK with + TK_OPTION_RELIEF. + + * win/tkWinButton.c: Removed bits about TK_RELIEF_LINK. + + * tests/button.test: Added tests for -overrelief; removed tests + for -relief link. + + * mac/tkMacButton.c: Removed bits about TK_RELIEF_LINK. + + * generic/tkOldConfig.c: Removed bits about TK_RELIEF_LINK. + + * generic/tkConfig.c: Removed bits about TK_RELIEF_LINK; added + support for TK_OPTION_NULL_OK for TK_OPTION_RELIEF. + + * library/button.tcl: Added binding support for -overrelief. + + * generic/tk3d.c (Tk_GetRelief): Added branch for TK_RELIEF_NULL. + + * generic/tkButton.c: Added -overrelief option; removed + Enter/Leave EventProc masks and handlers. + + * generic/tk.h: Added TK_RELIEF_NULL definition, removed + TK_RELIEF_LINK. + + * mac/tkMacDefault.h (DEF_BUTTON_OVER_RELIEF): + * win/tkWinDefault.h (DEF_BUTTON_OVER_RELIEF): + * unix/tkUnixDefault.h (DEF_BUTTON_OVER_RELIEF): Added default + value for the -overrelief option. + +2000-05-16 Eric Melski + + * win/tkWinMenu.c (ReconfigureWindowsMenu): Added code to add the + MF_SEPARATOR bit for SEPARATOR_ENTRY menu items. This causes + separator entries on the system menu to be drawn correctly [Bug: 5451]. + +2000-05-15 Eric Melski + + * doc/image.n: Added documentation for [image inuse] command. + + * tests/image.test: Added tests for [image inuse] command. + + * generic/tkImage.c (Tk_ImageObjCmd): Added [image inuse] command, + which provides a means for programmers to determine if a given + image is in use by any widgets. [RFE: 3327]. + +2000-05-14 Eric Melski + + * doc/clipboard.n: Added documentation for "clipboard get". + + * generic/tkClipboard.c (Tk_ClipboardCmd): Added "clipboard get" + subcommand [RFE: 4628]. + + * tests/clipboard.test: Updated to use "clipboard get" instead of + "selection get -s CLIPBOARD". + + * library/entry.tcl: Adjusted Button-1 binding to set focus to the + entry when it is readonly or normal. + + * doc/entry.n: Added documentation for readonly state, + -disabledforeground, -disabledbackground. + + * tests/entry.test: Added tests for readonly state. + + * generic/tkEntry.c: Added support for "readonly" state, and + redefined "disabled" state. A disabled entry will display its + text in a dimmed color and possibly with a different background, + and will be completely unusable (no selection, no editing). A + readonly entry will look like a normal entry, but it will not be + editable; selection is still allowed. [RFE: 4239]. To support the + new disabled state properly, "-disabledforeground" and + "-disabledbackground" options were added. + *** THIS IS A BACKWARDS INCOMPATIBLE BEHAVIOR CHANGE *** + + * win/tkWinDefault.h: + * mac/tkMacDefault.h: + * unix/tkUnixDefault.h: Added DEF_ENTRY_DISABLED_FG, + DEF_ENTRY_DISABLED_BG_COLOR, DEF_ENTRY_DISABLED_BG_MONO. + +2000-05-12 Eric Melski + + * unix/tkUnixButton.c (TkpDisplayButton, TkpComputeButtonGeometry): + * mac/tkMacButton.c (TkpDisplayButton, TkpComputeButtonGeometry): + * win/tkWinButton.c (TkpDisplayButton, TkpComputeButtonGeometry): + Added code for drawing compound buttons. + + * tests/button.test: Added configuration tests for -repeatdelay, + -repeatinterval, -compound. + + * library/button.tcl: Added support for -repeatedelay, + -repeatinterval options. + + * generic/tkOldConfig.c: Changed handling of link relief so that + proper error messages are used. + + * generic/tkButton.h: Added -compound, -repeatdelay, + -repeatinterval options. + + * generic/tkButton.c: Added event watchers for enter/leave events, + for link relief support. + + * generic/tk3d.c: Changed handling of link relief so that proper + error messages are used. + + * generic/tk.h: Changed values of + TK_OPTION_LINK_OK/TK_CONFIG_LINK_OK for link relief support. + +2000-05-12 Jeff Hobbs + + * win/tkWinFont.c (LoadFontRanges): improved support for all chars + in 0-255 range for bitmap ANSI fonts. May be improved to handle + bitmap non-ANSI fonts in the future. [Bug: 2172] + + * win/tkWinWm.c (RaiseWinWhenIdle): added TK_DONT_DESTROY_WINDOW + to flag check to prevent timing related core dump. [Bug: 5438] + +2000-05-11 Jeff Hobbs + + * win/tkWinTest.c (TestclipboardObjCmd): ensured CloseClipboard + would always get called for each OpenClipboard. + + * tests/focus.test (focusSetupAlt): removed wm withdraw from proc + as it would cause a hang for tkwait visibility + + * tests/menu.test: + * generic/tk3d.c: + * generic/tkColor.c: + * generic/tkCursor.c: corrected handling of 3DBorder, Cursor and + Color objects on multiple screens. [Bug: 5454] + +2000-05-09 Eric Melski + + * doc/button.n: Added documentation for link relief. + + * tests/button.test: Added tests for link relief for buttons. + + * generic/tk.h (TK_CONFIG_LINK_OK): Added definition of + TK_RELIEF_LINK, TK_OPTION_LINK_OK and TK_CONFIG_LINK_OK. [RFE: 4348] + + * generic/tk3d.c: Added support for link relief. [RFE: 4348] + + * mac/tkMacButton.c (TkpDisplayButton): + * unix/tkUnixButton.c (TkpDisplayButton): Added support for link + relief. [RFE: 4348] + + * generic/tkOldConfig.c (Tk_ConfigureWidget): + * generic/tkConfig.c (DoObjConfig): Added understanding of link + relief, which is allowed only for widgets that have + TK_OPTION_LINK_OK or TK_CONFIG_LINK_OK set for the "-relief" + option. [RFE: 4348] + + * generic/tkButton.c: Added TK_OPTION_LINK_OK to "-relief" option + for buttons. [RFE: 4348] + + * win/tkWinWm.c (EX_TRANSIENT_STYLE): Removed WS_EX_TOOLWINDOW + style bit, so that transient windows have full-size titlebars + (like the tk_getOpenFile dialog). + + * win/tkWinMenu.c (GetMenuSeparatorGeometry): Tweaked height + requested for separator bars to be (linespace - (2*descent)) + instead of just (linespace); this makes the separator occupy a + more correct amount of vertical space. [Bug: 5303]. + +2000-05-09 Jeff Hobbs + + * library/focus.tcl: fixed calling of takeFocus proc [Bug: 5372] + +2000-05-02 Jeff Hobbs + + * README: + * generic/tk.h: + * library/tk.tcl: + * mac/README: + * unix/README: + * unix/configure.in: + * unix/tk.spec: + * win/README: + * win/aclocal.m4: + * win/configure.in: + * win/makefile.vc: updated patchlevel to 8.4a1 + + * unix/Makefile.in: added tk.spec to dist target + +2000-04-27 Eric Melski + + * doc/Tk_Init.3: Added Tk_SafeInit information [Bug: 1884]. + + * doc/keysyms.n: Man page enumerating keysyms [RFE: 1645]. + + * doc/colors.n: Man page enumerating valid color names [RFE: 1645]. + + * doc/cursors.n: Man page enumerating valid cursor values [RFE: 1645]. + + * library/msgbox.tcl: Corrected Unix tk_messageBox implementation + to make the first button the default when no default is specified + [Bug: 2218]. + + * doc/messageBox.n: Updated documentation with regards to + selection of default button when none is specified (now it will + use the first button as the default in that case) [Bug: 2218]. + +2000-04-26 Jeff Hobbs + + 8.3.1 RELEASE + + * README: + * mac/README: + * unix/README: + * unix/tk.spec: + * win/README: Updating URLs to reference dev.scriptics.com + +2000-04-25 Jeff Hobbs + + * unix/Makefile.in: + * win/Makefile.in: makefile cleanup + +2000-04-25 Eric Melski + + * generic/tkMain.c: Fixed function header comment for Tk_MainEx. + + * unix/mkLinks: + * doc/GetScroll.3: Added information about Tk_GetScrollInfoObj + [Bug: 1866]. + +2000-04-24 Eric Melski + + * unix/mkLinks: + * doc/Grab.3: Man page for Tk_Grab and Tk_Ungrab [Bug: 1868, 1889] + + * unix/mkLinks: + * doc/MainWin.3: Added entry for Tk_GetNumMainWindows [Bug: 1865]. + + * unix/mkLinks: + * doc/GetHINSTANCE.3: Man page for Tk_GetHINSTANCE [Bug: 1862]. + +2000-04-24 Jeff Hobbs + + * generic/tkImage.c (Tk_PostscriptImage): added check to create + necessary prolog for photos + * generic/tkCanvPs.c: added Tk_PostscriptPhoto that outputs PS for + photo images + * generic/tkImgPhoto.c: new func ImgPhotoPostscript and added that + in as ps proc in tkPhotoImageType. + * generic/tkStubInit.c: + * generic/tkDecls.h: + * generic/tk.decls: added Tk_PostscriptPhoto + + * generic/tkConfig.c (DoObjConfig): removed direct setting of + interp->result. + + * mac/tkMacWm.c (Tk_WmCmd): initialized gotToplevel in + colormapwindows case (bug found by Reasoning, Inc's automated code + testing). + +2000-04-24 Eric Melski + + * unix/mkLinks: + * doc/GetHWND.3: Man page for Tk_GetHWND [Bug: 1863]. + + * unix/mkLinks: + * doc/HWNDToWindow.3: Man page for Tk_HWNDToWindow [Bug: 1869]. + + * unix/mkLinks: + * doc/AddOption.3: Man page for Tk_AddOption [Bug: 1854] + +2000-04-22 Jim Ingham + + * mac/tkMacDialog.c (Tk_MacGetOpenFile): Add empty bodies for the + "-initialfile" and "-defaultextension" options. + + * mac/tkMacDialog.c (NavServicesGetFile): Only cons the result up + into a list if multiple is true. + + * mac/tkMacMenus.c (SourceDialog): Use the "tk_getOpenFile" + instead of hand-coding the dialog with StandardGetFile. This way + we get the Navigation dialogs for free. + + * doc/getOpenFile.n: Document the -multiple and -message flags + which are only implemented on the Mac. Also note that the -title + works on the Mac with Nav Services installed. + +2000-04-19 Eric Melski + + * doc/WinViewable.3: + * unix/mkLinks: Removed docs for Tk_IsViewable. + + * win/tkWinDialog.c: Removed calls to Tk_IsViewable. + + * generic/tkUtil.c: + * generic/tkStubInit.c: + * generic/tkDecls.h: + * generic/tkCmds.c: + * generic/tk.decls: Removed Tk_IsViewable function (it was not + actually needed). + +2000-04-19 Jeff Hobbs + + * win/aclocal.m4: made SC_PROG_TCLSH search specifically for + tclsh*.exe type files to find an executable. + + * win/Makefile.in: fixed up cleanup, winhelp, cat32 targets + + * library/console.tcl: made console use systemfixed font on Win + + * generic/tkEntry.c: removed unnecessary ENTRY_VALIDATE #define + +2000-04-19 Eric Melski + + * generic/tkRectOval.c (ConfigureRectOval): Added checks for valid + outline settings before creating of outline GC; this means that it + is really possible now to have an oval or rectangle with no + outline. [Bug: 5029]. + +2000-04-19 Jeff Hobbs + + * library/choosedir.tcl (::tk::dialog::file::chooseDir::Config): + * library/tkfbox.tcl (::tk::dialog::file::Config): removed the + extraneous glob on -initialdir after file isdir already returned 1 + and moved cd trick into this case as the else already uses [pwd]. + [Bug: 5181] + + * win/winMain.c: moved extern call out of WinMain func + + * README: + * generic/tk.h: + * unix/configure.in: + * unix/tk.spec: + * win/configure.in: bumped to version 8.3.1 + + * library/msgbox.tcl (tkMessageBox): changed to use grid in some + places, realign icon to anchor nw. + + * mac/tkMacScale.c: reverted tkMacScale.c to 1.5 equivalent (it + was accidentally bumped forward). + +2000-04-18 Eric Melski + + * win/tkWinPointer.c: Changed Mod2Mask in TkWinGetModifierState to + ALT_MASK, to fix some event problems [Bugs: 1160, 5088]. + + * win/tkWinX.c: Changed Mod2Mask in GetState to ALT_MASK, to fix + some event problems [Bugs: 1160, 5088]. + + * generic/tkInt.h: Moved definition of ALT_MASK and META_MASK here + so that it would be accessible from other modules than tkBind.c. + + * generic/tkBind.c: Added code in BindEvent to check for ALT_MASK + and META_MASK in the event state field, as this field may not be + set up with the correct display modifier mask bits if the XEvent + structure was created by [event generate] or by the Windows X + emulation. [Bugs: 1160, 5088]. + +2000-04-18 Scott Redman + + * win/tk.rc: + * win/wish.rc: + * win/wish.ico: Modified copyright dates in Windows resource + files. Updated the icon for wish.exe. + +2000-04-17 Eric Melski + + * win/tkWinDialog.c: Added checks for visibility of parent window + before creating MessageBox and ChooseColor dialogs; this prevents + the application from locking when the parent is withdrawn and the + message box is created. In these cases, the window will be + created without a parent. + + * unix/mkLinks: Added WinViewable.3. + + * tests/msgbox.test: Added tests for patch from [Bug: 4997]. + + * library/msgbox.tcl: + * library/dialog.tcl: Applied patch from [Bug: 4997]; detaches + dialog window from parent if parent is not viewable. + + * library/bgerror.tcl: Removed workaround from [Bug: 4370]; this + is superceeded by patches to dialog.tcl. + + * generic/tkCmds.c: Changed WinfoObjCmd to use Tk_IsViewable + function to determine visibility of windows instead of inlining + the code. + + * generic/tkStubInit.c: + * generic/tkDecls.h: + * generic/tk.decls: Added Tk_IsViewable declaration. + +2000-04-17 Eric Melski + + * library/text.tcl: Tweaked double-/triple-click selection; + previously, anchor and insert marks were placed in unexpected + locations following a double or triple click. Now they are placed + logically. Also tweaked the extension of selection via + shift-double-clicks so that it no longer selects the contiguous + whitespace on the side of the selection opposite the + double-click. [RFE: 4253]. + + * doc/menu.n: Added note regarding rendering of + checkbuttons/radiobuttons in menubars on different platforms -- + some systems do not draw indicators for check/radiobuttons in + menubars. + + * library/menu.tcl: Corrected behavior of + checkbuttons/commands/radiobuttons in menubars [Bug: 630]. + + * tests/grid.test: Added test for [grid propagate . 0] to not toggle. + + * generic/tkGrid.c: Fixed bogus logic in [grid propagate] that + caused [grid propagate . 0] to act as a toggle instead of an + absolute set. [Bug: 2286]. + +2000-04-16 Jeff Hobbs + + * win/tkWinColor.c (FindSystemColor): correct calculation of + colors when shifting value. [Bug: 4919] + +2000-04-16 Jim Ingham + + * mac/tkMacPort.h: protect against strncasecmp already defined - + it is in the Pro5 version of MSL. + + * mac/tkMacWindowMgr.c (GenerateKeyEvent): Check for a null tkWin. + If the hidden window we use for double-buffering controls manages + to percolate to the top (should never happen, but...) this will + keep us from crashing. + + * mac/tkMacButton.c (InitSampleControls): Hide the + double-buffering window BEHIND the first "." window you can find. + This will keep it from ever being the front window, and thus a + black hole for events. * mac/tkMacButton.c (ButtonEventProc): + Disable the controls when the window is in the background. This + is required by the MacOS HIG. This doesn't always get called when + it should, it still needs more work. + + * mac/tkMacDialog.c: Pretty substantial rewrite to include + Navigation Services support for systems which have it. + +2000-04-14 Eric Melski + + * win/tkWinKey.c: Added check for ASCII delete character in + KeycodeToKeysym, to fix [Bug: 5090]. See comment in code for more + information. + + * generic/ks_names.h: Added Scroll_Lock and Sys_Req definitions. + + * win/tkWinKey.c: Changed implementation of KeycodeToKeysym, + et. al., to use a keycode table for lookups; this will result in + faster keycode -> keysym translations for non-ASCII keys like + Control, Alt, etc. + +2000-04-14 Jeff Hobbs + + * win/tkWinWm.c (WmProc): added check in WM_MOUSEACTIVATE so we + correctly activate native menus when clicking in when we didn't + have focus [Bug: 2272] + + * generic/tkCanvas.c (CanvasEventProc:2451): corrected cast + + * generic/tkEntry.c (Tk_EntryObjCmd): adjusted finishing error + cases and changed TK_CONFIG_NULL_OK to TK_OPTION_NULL_OK + + * tests/scale.test: + * generic/tkScale.c: + * generic/tkScale.h: + * unix/tkUnixScale.c: + * mac/tkMacScale.c: moved (PixelToValue|ValueToPixel|SetScaleValue) + to tkScale.c. Caused an associated variable to be immediately set + [Bug: 4833] + + * library/scale.tcl (tkScaleActivate): reduced number of scale + redisplays by checking current value of state before setting it + again. [Bug: 4191] + + * tests/winDialog.test: tk_chooseDirectory seems to get a noop + from GetOpenFileName in the static build, hanging some tests. + The tests were fixed to timeout (noop cause unknown). + + * unix/aclocal.m4 (SC_ENABLE_THREADS): enhanced the detection of + pthread_mutex_init [Bug: 4359] and (SC_CONFIG_CFLAGS) added + --enable-64bit-vis switch for Sparc VIS compilation [Bug: 4995] + +2000-04-13 Eric Melski + + * win/tkWinKey.c: Added smarts to check whether the left or right + Control, Shift, or Alt key was pressed. [Bug: 870]. + + * win/tkWinMenu.c: Corrected code that created separator items on + menus; originally, it requested that the system be responsible for + drawing those items, so it would ignore configuration items like + the widget background. Now, we draw the separators ourselves (as + we do with every other kind of menu item already). [Bug: 1166]. + + * win/tkWin3d.c: + * unix/tkUnix3d.c: Applied patch from [RFE: 2501]: adds more + sophisticated smarts to TkpGetShadows, so that the highlight of a + very bright color is actually distinguishable from the color, and + the shadow of a very dark color is similarly distinguishable from + the color. + + * generic/tkCanvas.c: Applied patch from [Bug: 4202]; adds a check + for NULL tkwin in Tk_CanvasEventuallyRedraw. + +2000-04-12 Jeff Hobbs + + * test/winClipboard.test: + * win/tkWinInt.h: + * win/tkWinClipboard.c (UpdateClipboard): + * win/tkWinX.c (GenerateXEvent): added updatingClipboard tsd and + TkWinUpdatingClipboard accessor function to allow us to flag + ourselves when we are the ones updating the clipboard. This + corrected inability to create our own clipboard types within a Tk + application. [Bug: 2338 4318] + * win/tkWinTest.c (TestclipboardCmd): improved TestclipboardCmd + with better error handling and obj'ification + +2000-04-11 Eric Melski + + * msgcat.n: Added docs for new behavior from patch in [Bug: 4158]. + + * msgcat.test: Added tests for new behavior from patch in [Bug: + 4158]. + + * msgcat.tcl: Applied patch from [Bug: 4158], which enables + msgcat::mc to search the entire namespace ancestry chain for + message translations (ie, first it checks the current namespace, + then the parent, then the parent's parent, etc). Also allows the + specification of additional args for msgcat::mc; if extra args are + given, the [format] command is used to substitute the additional + args in the translated message. + + * library/bgerror.tcl: Moved check for withdrawn state after check + for tkerror; this was causing problems when tkerror was used. + +2000-04-10 Eric Melski + + * library/bgerror.tcl: Added check for withdrawn state of . and + unsetting of transient bit for .bgerrorDialog if . is not + viewable; this protects against the application hanging on systems + like Windows, where transient windows are withdrawn with their + parents. [Bug: 4370]. + + * tests/event.test: Added test for [event generate $widget + ] [Bug: 4611]. + + * tests/choosedir.test: Changed "namespace import ::tcltest" to + "namespace import -force ::tcltest". + + * win/tkWinKey.c: + * unix/tkUnixKey.c: + * mac/tkMacKeyboard.c: Changed InitKeymapInfo to + TkpInitKeymapInfo. [Bug: 4611]. + + * generic/tkStubInit.c: + * generic/tkIntDecls.h: Re-gen'd from tkInt.decls. + + * generic/tkInt.decls: Added TkpInitKeymapInfo to list of function + decls. + + * generic/tkBind.c (HandleEventGenerate): Added code to initialize + keymap info if necessary, and to correctly set modifier bits in + XEvent structure create to handle [event generate] calls. + Previously, the alt/meta bits were not set correctly, so [event + generate $widget ] would always fail. [Bug: 4611] + +2000-04-07 Jeff Hobbs + + * generic/tkGrid.c (InitMasterData): fixed uninit'd data in + GridMaster struct [Bug: 4387] + + * library/safetk.tcl (disallowTk): made disallowTk work in the + simple case. + + * library/comdlg.tcl (tkFocusGroup_In): fixed key navigation + problems in dialogs under CDE [Bug: 2960] + + * tests/winDialog.test: removed knownBug constraint from 5.16 + + * win/tkWinFont.c (GetScreenFont): corrected adjustment against + LC_FACESIZE limitation for NT [Bug: 4931] + + * win/makefile.vc (TKTEST_OBJS): + * win/Makefile.in (TKTEST_OBJS): moved tkWinTest.c from normal + objs to TKTEST_OBJS where it belonged. + +2000-04-03 Jeff Hobbs + + * generic/tkTest.c: fixed incorrect platform inclusion for + TkplatformtestInit (it would never get called). + + * unix/Makefile.in (MAN_INSTALL_DIR): patch to accept --mandir + correctly [Bug: 4085] + + * library/clrpick.tcl (tkColorDialog_Config): error now thrown + when -initialcolor "" specified. [Bug: 4198] + +2000-03-31 Jeff Hobbs + + * doc/DrawFocHlt.3: doc name correction + + * generic/tkEntry.c: set TK_OPTION_NULL_OK bit on -invcmd option + and removed #ifdef ENTRY_VALIDATE expressions + + * library/menu.tcl (tkMenuInvoke): corrected naming of tearoffs + [Bug: 4506] + + * library/tkfbox.tcl (tkIconList_Goto): caused browsecmd to be + called in tkIconList_Select. This causes the entry to be set + properly when using the type-in-name-in-listbox bindings. + + * win/tkWinDialog.c: added unicode-aware open/save file dialogs + + * win/tkWinFont.c (TkpFontPkgInit): move private ref to platformId + to TkWinGetPlatformId + + * win/tkWinMenu.c (SetDefaults): moved private use of versionInfo + to TkWinGetPlatformId and removed all code for + (versionInfo.dwMajorVersion < 4) (== Win32s) + + * win/tkWinX.c: + * win/tkWin32Dll.c: moved TkWinGetPlatformId to tkWinX.c + * win/tkWinInit.c: added TkWinXInit to TkpInit to ensure that its + called for static Windows shells. [Bug: 3647] + + * win/tkWinInt.h: + * win/tkWinX.c: + * win/tkWinDraw.c (SetUpGraphicsPort): + * win/tkWinScrlbr.c (UpdateScrollbar): removed use of tkpIsWin32s + + * win/tkWinInt.h (TkWinDCState struct): added bkmode value + * win/tkWinDraw.c (TkWinGetDrawableDC, et al): added support for + properly transparent dashed lines on Windows. [Bug: 4617] + +2000-03-30 Eric Melski + + * generic/tkImgGIF.c: Fixed some ANSI specific bits to avoid + compile problems with non-ANSI compilers (ie, replace const with + CONST, etc). [Bug: 4223]. + + * unix/configure.in: Applied patch from [Bug: 4237]; ensures that + srcdir is fully qualified. + + * unix/Makefile.in: Applied patch from [Bug: 4237]; if tcltest was + not compiled, make test/tktest failed. Now it has a rule to build + tcltest if it has not been built. + +2000-03-28 Eric Melski + + * library/tkfbox.tcl: Moved an overlooked tkFDialog* function in + ::tk::dialog::file namespace. + + * tests/unixWm.test: Added tests for memory leak conditions in + tkUnixWm.c. + + * tests/canvas.test: Added test for bad configuration options on + empty and non-empty canvas. + + * generic/tkCanvas.c: Removed bad code in CANV_CONFIGURE block of + CanvasWidgetCmd; this was causing non-empty canvases to improperly + handle bad configuration options [Bug: 4456]. + +2000-03-27 Eric Melski + + * unix/tkUnixWm.c: Applied patch from [Bug: 4405]; fixes memory + leak in Unix wm command. + +2000-03-24 Eric Melski + + * tests/filebox.test: + * tests/choosedir.test: Updated tests. + + * library/xmfbox.tcl: Updated to stash data array in + ::tk::dialog::file namespace instead of in global namespace. + + * library/tkfbox.tcl: Extended some functions to support creation + of a choosedir dialog, to allow greater code reuse between the two + dialogs. Moved tkFDialog* functions into a namespace + (::tk::dialog::file). Because these are private Tk functions (and + should thus not be used directly by users), this should not impact + anybody (the tk_getOpenFile and tk_getSaveFile commands still + exist at the global scope). + + * library/tk.tcl: + * library/tclIndex: Updated function names for tkFDialog* + functions and choosedir functions. + + * library/choosedir.tcl: New and improved implementation of + tk_chooseDirectory dialog. Based on tk_getOpenFile dialog. + +2000-03-23 Eric Melski + + * generic/tkWindow.c: + * generic/tkInt.h: Updated Tcl_OptionCmd -> Tcl_OptionObjCmd + + * generic/tkOption.c: Tcl_Obj'ectified the "option" command. + +2000-03-22 Eric Melski + + * library/listbox.tcl (tkListboxCancel): Added a check for empty + string value for tkPriv(listboxPrev). Without this check, it's + possible to get a stack trace under certain conditions. [Bug: 4373]. + +2000-03-15 Sven Delmas + + * win/tkWinDialog.c: Changed the behavior for the + tk_chooseDirectory dialog under Windows. Instead of trying to + return the currently selected listbox entry (which didn't work in + case the user selected the initial directory anyway), we now + return the value shown in the entry. This seems to be in + accordance with the expected behavior for this dialog. + +2000-03-14 Eric Melski + + * tests/choosedir.test: Marked test 3.1 and 3.2 as bad until the + issue with those tests on IRIX can be determined. + +2000-03-10 Eric Melski + + * library/menu.tcl: Applied patch from [Bug: 4155]; protects + against grabs on non-viewable windows. + +2000-03-08 Eric Melski + + * tests/choosedir.test: Modified test 3.1 (-mustexist works) to be + more careful about cleaning up its potentially troublesome after + events. + +2000-03-07 Eric Melski + + * tests/button.test: + * generic/tkButton.c: Added -disabledforeground/-state to labels. + +2000-03-07 Jeff Hobbs + + * tests/entry.test: + * generic/tkEntry.c (EntrySetValue): malloc the value when + validating because validation could cause the pointer to become + invalid. Also fixed configure to not trigger focus-based + validation. Improved use of Tcl_WrongNumArgs. [Bug: 4320] + +2000-03-06 Eric Melski + + * library/menu.tcl: Added a check in tkMenuFirstEntry that changes + menu behavior to only auto-post an immediate child cascade if we + are currently on a menubar menu. This prevents massive + auto-cascading in cases where the first entry of the cascade is + itself a cascade, and the first entry of that cascade is a + cascade, and the first entry of that cascade is a cascade + ... [Bug: 676]. + + * generic/tkOldConfig.c: Added check for NULL tkwin value in + Tk_ConfigureWidget [Bug: 4079] + + * generic/tkWindow.c: Added check for NULL tkwin value in + Tk_NameToWindow [Bug: 4079] + +2000-03-02 Jeff Hobbs + + * tests/color.test: + * xlib/xcolors.c (XParseColor FindColor): + * win/tkWinColor.c (XAllocColor): Fixed bit fiddling for colors to + return "correct" values for color mapping. [Bug: 4282] + + * unix/Makefile.in (SCRIPT_INSTALL_DIR): removed extraneous '/' + * unix/aclocal.m4: corrected TCL_NEEDS_EXP_FILE to be 1 for AIX + + * win/tkWinInt.h: change extern to EXTERN for TkWinChildProc + declaration with extra #defs. [Bug: 4240] + + * library/focus.tcl: fixed tkFocusOK to protect $w in + uplevel with list. [Bug: 4208] + + * doc/CrtItemType.3: fixed docs for Tk_CreateItemType to reflect + changes made in 8.3.0 (but old style would still work as well). + [Bug: 4252] + + * tests/config.test: extra test to check object cleanup when + destroying the widget + * generic/tkListbox.c (DestroyListbox): fixed crash in + DestroyListbox due to null tkwin. [Bug: 4207] + + * tests/entry.test: added test suite for entry validation + * doc/entry.n: improved docs discussing caveats and gotchas when + mixing textvar with widget validation + * generic/tkEntry.c (EntryValidateChange): improved handling of + validation with relation to -textvariable. Previously, it would + turn off whenever the textvar was set. Now it will it will turn + off only when the textvar is set and validation returns 0. Added + %V (type of validation occuring) to %-subs to help work with + trickier validation. + +2000-03-01 Eric Melski + + * tests/clrpick.test: + * library/clrpick.tcl: Added code to make color chooser dialog + inherit screen setting from parent (bug #2334) + +2000-02-25 Jeff Hobbs + + * win/tkWinWm.c (RaiseWinWhenIdle): Checked for the possibility + that the window could be destroyed (can occur with + wm deiconify .toplevel; destroy .toplevel). + +2000-02-25 Eric Melski + + * generic/tkImgGIF.c: Applied "spirit of" the patch in 1605 (the + submitted patch was more complicated than necessary and did not + extend to writing GIF's, only reading), to allow reading/writing + of GIF files on EBCDIC and other non-ASCII based systems. + +2000-02-14 Eric Melski + + * unix/tk.spec: RPM specification for producing a binary Tk RPM + for Linux. + + * unix/Makefile.in: Added rpm target to generate Tk + binary RPM. + +2000-02-10 Jeff Hobbs + + 8.3.0 RELEASE + + * changes: updated for 8.3.0 release + + * generic/tkImgGIF.c (FileReadGIF): added cast for trashBuffer + + * generic/tkIntXlibDecls.h: + * generic/tkInt.decls: declared some Xlib emulation calls for + the Mac + + * generic/tkFrame.c (TkInstallFrameMenu): added extra panic to + inform user of bad call when framePtr is NULL [Bug: 2530] + + * generic/tkMenu.c (DestroyMenuInstance): Placed checks around + menu name objects before trying to incr the ref. [Bug: 3402] + + * generic/tkTest.c: removed USE_OLD_IMAGE def for Mac + + * library/listbox.tcl: + * library/text.tcl: added support for <4> and <5> for mousewheel + style scrolling on Unix for mice that map to these buttons. + + * tests/scrollbar.test: fixed check of testmetrics command to + allow unix tests to run (testmetrics is mac/pc only) + + * unix/tkUnixWm.c (Tk_CoordsToWindow): qualified delete of error + handler as the goto label is reached from above and below. + + * unix/configure.in: + * unix/aclocal.m4: cleaned up macros to coincide with tcl.m4, + added -export-dynamic to LDFLAGS for FreeBSD-3+ [Bug: 2998] + + * unix/README: + * unix/Makefile.in (dist): removed porting.notes and porting.old + from distribution and CVS. The information was very outdated. Now + refer to http://dev.scriptics.com/services/support/platforms.html + + * xlib/xgc.c: #def'd out XDrawSegments for the Mac, and added + some extra include info for the Mac + +2000-02-09 Jim Ingham + + * mac/tkMacButton.c: Stop removing the appearance window from the + Window List. It is not clear why Ray did this, and it causes the + Appearance manager to crash at random times. + + * mac/tkMacWM.c: Add support in unsupported1 style for the Appearance + specification of window styles, including floating window support. + * mac/tkMacWindowMgr.c: Operate on the front non-floating window, + unless the mouse is directly over the floating window. Also, + keystrokes go to the front non-floating window. + * mac/tkMacAppInit.c: Initialize floating window support. + * mac/tkMacScrlbr.c: + * mac/tkMacmenu.c: Fixes for floating windows - operate on the + FrontNonFloatingWindow. + * mac/tkMacLibrary.r: Fix typo in File info string. + * mac/tkMacApplication.r: Fix typo in file info string. Add + Finder balloon help for no apparent reason. + + * mac/tkMacSubwindows.c: Change panic in tkMacGetDrawablePort to + Debugger. This is only a temporary fix. The panic is only + triggered when a safeTk interpreter is torn down, and ignoring it + does no harm. I haven't figured out how to avoid it yet, however. + Also use the Appearance MoveWindowStructure call when available. + + New Files: + * MW_TkOldImageHeader.h: Handle #defining USE_OLD_IMAGE for tkImgPPM.c. + * MW_TkTestHeader.h: + * MW_TkTestHeader.pch: + * MW_TkHeader.h: Add separate prefix files for test & release + versions of Tk, so we can just have separate targets w/o having to + edit files. + + * tclets.r: The D&D Tclets icon in rez form so we can have a + target for this. + + The above are curtesy of Daniel Steffen (steffen@math.mq.edu.au) + + * tkMacAppearanceStubs.c: Stubs of the Mac Appearance calls I use + so I can link the static 68K Shell without putting ifdef's all + over the code. + +2000-02-08 Jeff Hobbs + + * generic/tk.decls: + * generic/tkBind.c: + * generic/tkInt.decls: + * generic/tkIntDecls.h: + * generic/tkStubInit.c: + * mac/tkMacKeyboard.c: + * unix/tkUnixKey.c: + * win/tkWinKey.c: Fix for keyboard handling of "dead" keys and + caps lock from Peter Spjuth. [Bug: 4105 3359 2493] + Split functions into platform specific files: + Static functions GetKeySym(), SetKeycodeAndState() and InitKeymapInfo() + from tkBind.c moved into platform files tkWinKey.c tkUnixKey.c and + tkMacKeyboard.c. GetKeySym() and SetKeycodeAndState() renamed to + Tkp* and made public (as private functions) in tkInt.decls. + + Step 2, fixes in tkWinKey.c + New static function: KeycodeToKeysym(), based on XKeycodeToKeysym() + but with different arguments, and a lot of improvements. + TkpGetString() changed to use KeycodeToKeysym() + other fixes. + TkpGetKeySym() changed to use KeycodeToKeysym() + other fixes. + InitKeymapInfo() changed to use KeycodeToKeysym(). + TkpSetKeycodeAndState() rewritten, mostly by copying code from + XKeysymToKeycode(). + XKeycodeToKeysym() rewritten. Preferably it should be removed. + + EXPLANATION: The main problem is ToAscii() which has a lot of side + effects, and also that XKeycodeToKeysym() is not provided enough + input to do a proper job. The changes' main goal is to avoid + calling ToAscii() if not necessary, and to provide it with as + correct information as possible when called. Also some attempts + to clean up what ToAscii() did are done. See the code for details. + + BUGS FIXED: Typing shifted (and AltGr) dead keys did not work. + Keyboard lock lamps did not work on Win98. + Events regarding AltGr-keys behaved badly. + Example: On a Swedish keyboard, $ is typed with AltGr-4. + That keyboard event would get the keysym '4' not 'dollar'. + Also, doing [event generete . ] would send keysym '4'. + Translation to ascii in TkpGetString did not handle return and + tab correctly. I.e. [event generate . ] gave wrong %A + + * generic/tkDecls.h: + * generic/tk.decls: + * generic/tk.h: moved new public functions created in dash patch + to the stubs interface [Bug: 4062] + + * generic/tk.h: + * doc/CrtImgType.3: + * doc/CrtPhImgFmt.3: + * generic/tk.h: + * generic/tkImgGIF.c: + * generic/tkImgPhoto.c: + * generic/tkStubImg.c (new file): + * generic/tkTest.c: + * unix/Makefile.in: + * win/Makefile.in: + * win/makefile.vc: improved support for moving from the old style + image C API to the new obj'ified one with new Tk_InitImageArgs + command and stub'ing of image code. See docs for how to make the + transition. [Bug: 4060] + + * library/tk.tcl: wrapped check for tcl_platform(os) around info + exists because it won't in safe interpreters + + * win/tkWinFont.c: corrected symbol font use to only work on 8-bit + characters [Bug: 2406] + + * unix/aclocal.m4: changed all -fpic to -fPIC + + * README: + * unix/configure.in: + * win/configure.in: + * generic/tk.h (TK_RELEASE_SERIAL): Moved to 8.3.0 patchlevel + +2000-02-07 Eric Melski + + * library/tkfbox.tcl: Applied patch from bug #4117, + tk_getOpenFile/getSaveFile doesn't do the right thing when user + types a directory name in the entry and a default extension is + specified. + +2000-02-05 Jeff Hobbs + + * unix/tkUnixScale.c (TkpDestroyScale): changed ckfree to + Tcl_EventuallyFree to behave with Tcl_Preserve in TkpDisplayScale + (prevents possible segfault). + +2000-02-03 Eric Melski + + * tests/canvText.test: test for fix for bug #2525. + + * generic/tkFont.c (Tk_ComputeTextLayout): Was erroneously setting + the width of newline-only text display chunks to some arbitrary + huge number, instead of 0; this was interfering with things like + the canvas find enclosed feature. (bug #2525). + + * tests/text.test: + * generic/tkText.c (DumpLine/DumpSegment): Changed DumpSegment to + take a TkTextIndex instead of two integer offsets, so that it + could use TkTextPrintIndex to format the offsets into an index, + which makes it UTF smart (bug #2582). + +2000-02-01 Eric Melski + + * library/tk.tcl: + * library/tclIndex: + * library/choosedir.tcl: Moved choosedir functions into the + ::tk::dialog::chooseDir namespace instead of a toplevel + ::tkChooseDirectory namespace. Additional cleanup on the + chooseDir dialog. + +2000-02-01 Jeff Hobbs + + * doc/text.n: clarified docs on what happens during a search with + -count when images/windows are embedded + + * win/Makefile.in (install-*): reduced verbosity of install + + * win/tkWinPixmap.c (XGetGeometry): added support for windows in + XGetGeometry [Bug: 4069] + + * win/tkWinFont.c (GetScreenFont): fixed possible mem overrun with + long font names [Bug: 4108] + + * win/tkWinDialog.c: added EnableWindow calls to dialogs to + correct for possible loss of control in parent Tk toplevel + [Bug: 1212 et al] + + * generic/tkRectOval.c (ConfigureRectOval): + * generic/tkCanvLine.c (ConfigureLine): + * generic/tkCanvPoly.c (ConfigurePoly): + * generic/tkCanvArc.c (Configure/DisplayArc): fixed handling for + negative dash values [Bug: 4104] + + * generic/tkScale.c (TkRoundToResolution): fixed incorrect + assumption that (N+1)*delta = N*delta + delta with floating point + math [Bug: 3689, 4099] + (DestroyScale) Fixed check for cancelling TkpDisplayScale (was + REDRAW_ALL, is now REDRAW_PENDING) + + * tests/listbox.test: corrected test case for listbox itemconfigure + + * unix/aclocal.m4: added *BSD ELF recognition for + SHARED_LIB_SUFFIX determination (from Tcl's tcl.m4) + +2000-01-27 Eric Melski + + * generic/tkImgPhoto.c: Removed unneccesary object translation in + MatchStringFormat (bug #4103). + +2000-01-27 Eric Melski + + * generic/tkImgGIF.c: Additional code cleanup (now we only have + one decoder! neat!) + +2000-01-26 Eric Melski + + * doc/getOpenFile.n: + * doc/chooseDirectory.n: Man page/cross links for + tk_chooseDirectory (bug #1786). + + * library/tk.tcl: + * library/tclIndex: Added hooks for tk_chooseDirectory. (bug #1786) + + * library/choosedir.tcl: tk_chooseDirectory implementation for + Unix/Mac (bug #1786). + + * generic/tkImgPhoto.c: Added some comments regarding slow + processing of transparent images. + + * generic/tkImgGIF.c: Improved GIF decoder for ~60% speed + increase. Added some comments on how to further improve the + implementation, time permitting. + + * doc/photo.n: Added a description of what the -data string can + contain (base64 or binary data). + + * generic/tkImgPhoto.c: Fixed bug with use of binary data for + "-data" option to "image create" command. + +2000-01-21 Eric Melski + + * library/tkfbox.tcl: Fixed bug relating to incorrect parent + values for error message boxes displayed by the file dialog (bug + #3616). + + * tests/text.test: + * generic/tkText.c: Fixed bug relating to regexp searching for + empty lines; previously, the starting line was ignored. (bug #1643). + +2000-01-20 Jeff Hobbs + + * library/text.tcl: fixed double-click selection behavior where + there were embedded windows/widgets in the same line. [Bug: 3989] + + * win/tkWinWm.c (TkWmProtocolEventProc): cached atom name as the + window could get destroyed during eval [Bug: 2513] + + * generic/tkCanvLine.c (LineCoords): fixed segfault when too few + coords were passed to a line with certain options set (it should + always have thrown an error anyway). [Bug: 4042] + + * tests/text.test: + * generic/tkText.c: fixed missing " in error case and missing + 'dump' in subcommand listing [Bug: 4036] + + * generic/tkListbox.c: adjusted use of basic string concatenation + in (non-K&R behavior) [Bug: 4027] + Swapped bg/fg class for -select(bg|fg) for listbox and their + items [Bug: 4039] + + * unix/mkLinks: + * doc/WindowId.3: added docs for Tk_IsContainer and Tk_IsEmbedded + + * doc/text.n: clarified mark gravity definition and usage of + ``word'' in binding definitions. [Bug: 2004 2277 1388] + + * generic/tkInt.h: moved new TkDisplay useInputMethods structure + element to end to not disturb position of previous elements in + the structure (as compared to Tk <=8.2). + +2000-01-20 Eric Melski + + * tests/grid.test: Added a test for the consecutive ^ and multiple + widget case (bug #1386). + + * generic/tkGrid.c: Fixed interpretation of consecutive ^ + characters in grid command. Previously, ^ ^ was interpreted as + meaning that there must be a 2-column widget above to extend, + neglecting the case where there was actually 2 1-column widgets + above. Now, ^ ^ is interpreted as a possible width; the gridder + will consume as many ^'s as there are columns in the widget, and + leave the rest for the extension of other widgets. (bug #1386). + +2000-01-19 Eric Melski + + * library/tk.tcl: Created a virtual event <> for + reverse tab traversals, with one default binding , and + OS specific bindings for Linux, HP-UX, and IRIX. (bug #3163) + +2000-01-13 Jeff Hobbs + + * changes: updated changes file to reflect 8.3b2 mods + * README: + * generic/tk.h: + * unix/configure.in: + * win/configure.in: updated to patchlevel 8.3b2 + + * win/tkWinWm.c: added visibility event handler to make sure + that transient window wrappers would be updated when the master + was initially mapped. + +2000-01-12 Jeff Hobbs + + * tests/text.test: changed test to reflect change of -hidden + to -elide in search options. + + * win/tkWinScrlbr.c: added check for valid hwnd in ModalLoopProc + to avoid crash when building statically + + * doc/event.n: + * generic/tkBind.c: prevented core with event -warp on Windows + when window wasn't mapped [Bug: 4004] and added docs stating + the requirement for mapped windows. + + * generic/tkCanvas.c: fixed mem leak with TagSearchExprInit + [Bug: 3977] + + * generic/tkStubInit.c: + * generic/tkDecls.h: remove non-existent + Tk_(Get|Create)CanvasVisitor prototypes + + * generic/tkText.c: + * generic/tkEntry.c: fixed cursor to not blink when widget was + disabled [Bug: 1807] + + * generic/tkRectOval.c: added note about change to bloat for + RectOval bounds calculation for WIN32 only + + * library/dialog.tcl: improved handling of $default arg to allow + for name of given button, as well as bounds checking + + * doc/wm.n: + * tests/winWm.test: + * tests/unixWm.test: + * mac/tkMacWm.c: + * unix/tkUnixWm.c: fixed possible X error being raised [Bug: 3377] + * win/tkWinWm.c: wm deiconify in zoom state [Bug: 2077], + fixed possible flashing of unmapped toplevel in deiconify [Bug: 3338] + and fixed mapping of transient window [Bug: 572] + Also, for all wm's, extended 'wm state' command to allow setting + of the state, and added official support of 'zoomed' state on Win. + + * unix/aclocal.m4: strtod bug on Tru64 [Bug: 3378] + + * unix/Makefile.in: added tests to prevent unnecessary chmod +x + in source dirs while installing [Bug: 3367] + + * unix/configure.in: properly sub'ed in TK_SHARED_BUILD [Bug: 3385] + +2000-01-05 Jeff Hobbs + + * doc/text.n: + * generic/tkText.c: + * generic/tkText.h: + * generic/tkTextBTree.c: + * generic/tkTextDisp.c: + * generic/tkTextTag.c: removed the -state option for text tags, + and reoriented it around -elide, as -state disabled was never + implemented, and -state hidden is better as -elide. + + * mac/tkMacClipboard.c: fixed i18n problems with clipboard [Bug: 3544] + + * library/entry.tcl: + * library/focus.tcl: + * library/listbox.tcl: + * library/scale.tcl: + * library/scrlbar.tcl: + * library/tearoff.tcl: + * library/text.tcl: + * library/tkfbox.tcl: + * library/xmfbox.tcl: fixed unprotected arg parsing through eval/after + [Bug: 3943] + + * unix/Makefile.in: added unix/aclocal.m4 to distribution [Bug: 3938] + * unix/aclocal.m4: changed NetBSD SHLIB_CFLAGS from -fpic to -fPIC + + * win/tkWinImage.c: added static declaration to function + +1999-12-22 Jeff Hobbs + + * changes: updated changes file + + * generic/tkScale.c: + * generic/tkScale.h: + * mac/tkMacScale.c: + * unix/tkUnixScale.c: fixed potential segv from patch in 3897 + + * tests/unixWm.test: nonPOrtable -> nonPortable + +1999-12-21 Jeff Hobbs + + * generic/tk.h: + * unix/configure.in: + * win/configure.in: + * win/aclocal.m4: + * README: updated for patch level 8.3b1 + + * unix/tkUnixWm.c: fixed panic in Tk_CoordsToWindow to print error + and continue instead (for Tix) [Bug: 716 et al] + + * scale.test: + * generic/tkScale.c: + * generic/tkScale.h: fixed possible core when freeing options + (cursor) associated with scale widget [Bug: 3897] + + * doc/MeasureChar.3: fixed docs for Tk_MeasureChars to reflect code + * doc/listbox.n: fixed formatting problem + + * generic/tk3d.c: added extra calculations to ensure that thin + frames get refreshed too [Bug: 3596] + + * unix/tkUnixMenu.c: + * unix/tkUnixFont.c: + * generic/tkCanvText.c: + * generic/tkEntry.c: + * generic/tkFont.c: + * generic/tkImgPPM.c: removed extranneous vars that were set but + never used. + + * mac/tclMacHLEvents.c: fixed applescript for I18N [Bug: 3644] + + * unix/aclocal.m4: removed -O flag for AIX when using the IBM + compiler (several versions have a bug that crops up in the text + widget). [Bug: 2316] + + * unix/Makefile.in: removed extra slash in SCRIPT_INSTALL_DIR + [Bug: 3896] + + * library/listbox.tcl: added extra checks for existence of + tkPriv(listboxSelection) before it was used. [Bug: 3892] + +1999-12-16 Jeff Hobbs + + * doc/GetCursor.3: + * win/tkWinCursor.c: added support for Windows cursors to + TkGetCursorByName (.ani, .cur) using -cursor @ + (Ascher) [Bug: 1350] + + * win/tkWinWm.c: fixed 'wm deiconify' to update position of the + toplevel if event is waiting before mapping. (Mao) [Bug: 3687] + This removes the need for 'update idle' before 'wm deiconify' on + Windows. + + * doc/listbox.n: added doc for <> [Bug: 3500] + + * doc/getOpenFile.n: removed note that -initialfile didn't work + for tk_getOpenFile + * library/tkfbox.tcl: updated tk_get*File to better match the + Windows file box it emulates, give proper support to -initialfile, + and fixes lack of global tkPriv call. [Bug: 3735 3882] + + * doc/tk.n: added doc for 'tk useinputmethods ...' + * tests/tk.test: + * unix/tkUnixKey.c: + * generic/tkCmds.c: + * generic/tkEvent.c: + * generic/tkWindow.c: + * generic/tkInt.h: add 'tk useinputmethods ?-display win? ?bool?' + call to provide support for disabling/enabling the use of XIM on + X. This was previously all done at compile time, and always on. + Now it is turned off by default, even when available, and the user + must turn it on to use XIM (per display). + + * generic/tkCanvUtil.c: fixed bug in Tk_CanvasPsOutline that freed + mem it shouldn't. + + * generic/tkFont.c: added "bitstream cyberbit" (popular Windows + CJK font) to list of font fallbacks. (kenny) [Bug: 2407] + + * mac/tkMacMenu.c: finished bug 3075 by changing the char values of + what was checked (verified correctness on Mac). + +1999-12-13 Jeff Hobbs + + * doc/canvas.n: added docs for items added by dash patch (-*dash*, + -state, -active*, -disabled*, -offset, essentially rewrote the + man patch for completely updated 8.3 canvas widget. + * doc/entry.n: added docs for entry widget validation + * doc/event.n: added docs for -warp + * doc/text.n: doc'ed new -state value 'hidden' + * doc/GetDash.3: (new file) man page explaining Tk_GetDash + * generic/tkStubInit.c: + * generic/tkDecls.h: + * generic/tkIntXlibDecls.h: + * generic/tkInt.decls: added XSetDashes and XWarpPointer + * generic/tk.decls: added Tk_CreateSmoothMethod, and reserved + two spots + * generic/tk.h: added Tk_SmoothMethod struct, + state item to canvas record, #defines for item state, + support for using old char*-based canvas item C creation + procedures with -DUSE_OLD_CANVAS, + Tk_Dash, Tk_TSOffset (-offsets) & Tk_Outline structs and #defs, + decls for dash, outline and postscript routines + * generic/tkBind.c: added support for Quadruple clicks, and added + the -warp option to 'event' with pointer warping routines + * xlib/xgc.c: + * generic/tkRectOval.c: + * generic/tkCanvArc.c: + * generic/tkCanvBmap.c: + * generic/tkCanvImg.c: + * generic/tkCanvLine.c: + * generic/tkCanvPoly.c: + * generic/tkCanvPs.c: + * generic/tkCanvText.c: + * generic/tkCanvUtil.c: + * generic/tkCanvWind.c: + * generic/tkCanvas.c: + * generic/tkCanvas.h: Canvas and items received overhaul to with + the addition of the dash patch (Nijtmans, et al) This includes + objectification of the 'canvas' command, as well as support for + (where appropriate) dashes in items, extended stipple support, + state for all items, and postscript generation of images and + windows. See the new canvas man page for related docs. + * generic/tkEntry.c: added entry widget validation, see entry.n + * generic/tkEvent.c: on simulated events, ButtonPress should + be matched with ButtonRelease to be correct + * generic/tkFont.c: corrected possible null reference + * generic/tkFrame.c: made frame a Tcl_Obj based command + * generic/tkGet.c: added TkGetDoublePixels + * generic/tkImage.c: bug fixes from Img patch and new + Tk_PostscriptImage and Tk_SetTSOrigin functions + * generic/tkImgBmap.c: new ImgBmapPostscript function + * generic/tkImgPhoto.c: new Tk_CreatePhotoOption, Tk_DitherPhoto + * generic/tkInt.h: declarations for some new functions + * generic/tkMessage.c: reworked relief drawing + * generic/tkOldConfig.c: added TK_CONFIG_OBJS so old style + ConfigureWidget calls can pass in Tcl_Obj arrays + * generic/tkScrollbar.c: + * generic/tkScrollbar.h: made -orient use an option table + * generic/tkText.c: + * generic/tkText.h: made -wrap and -state use option tables + * generic/tkTextBTree.c: + * generic/tkTextDisp.c: + * generic/tkTextImage.c: + * generic/tkTextMark.c: + * generic/tkTextTag.c: + * generic/tkTextWind.c: added support for -elide and -state hidden + * generic/tkTrig.c: changed TkMakeBezierCurve to support returning + the upper limit of points needed for spline + * generic/tkUtil.c: new option table parsing routines + * generic/tkWindow.c: init'ing of warp stuff, mouseButtonState + + related bug ids for the fixes: + [Bug: 648 1541 1540 1779 2168 2311 2297 2340 2348 2578 3386] + + * tests/bind.test: + * tests/canvImg.test: + * tests/canvPsArc.tcl: + * tests/canvPsImg.tcl: (new file) + * tests/canvRect.test: + * tests/canvText.test: + * tests/canvas.test: + * tests/defs.tcl: + * tests/entry.test: + * tests/event.test: + * tests/font.test: + * tests/frame.test: + * tests/imgPhoto.test: + * tests/safe.test: + * tests/scale.test: + * tests/scrollbar.test: + * tests/select.test: + * tests/text.test: + * tests/textDisp.test: + * tests/textTag.test: + * tests/unixFont.test: + * tests/unixWm.test: + * tests/visual_bb.test: + * tests/winClipboard.test: tests for the dash patch changes + + * unix/mkLinks: added GetDash.3 into the mkLink step + + * mac/tkMacDraw.c: mac still needs pointer warping routine + * mac/tkMacXStubs.c: + * win/tkWinDraw.c: + * win/tkWinPointer.c: added support for pointer warping and + platform specific support for dash patch items + +1999-12-12 Jeff Hobbs + + * generic/tkText.c: fixed bug in TextSearchCmd for multibyte chars + (Darley) [Bug: 3839] + + * unix/aclocal.m4: added warning when configuring with + --enable-threads that Tk may have problems + +1999-12-09 Jeff Hobbs + + * generic/tkImgGIF.c: updated casting + + * win/makefile.vc: removed 16bit stuff, simplified makefile. + +1999-12-06 Scott Redman + + * generic/tkMain.c: need to include tclInt.h for new hook + functions that are internal-use-only. + +1999-12-06 Jeff Hobbs + + * library/comdlg.tcl: removed tclVerifyInteger and tclSortNoCase, + they weren't used, and were not actually correct + + * mac/tkMacFont.c: + * mac/tkMacMenu.c: + * mac/tkMacWindowMgr.c: fixed greyed out menu items, handling of + ... elipsis, font mapping problem, and enabled generated menu + posting [Bug: 3705] + +1999-12-02 Jeff Hobbs + + * generic/tkInt.h: + * generic/tkWindow.c: + * generic/tkCmds.c: converted Tk_DestroyCmd, Tk_LowerCmd and + Tk_RaiseCmd to their ObjCmd equivalent. + + * library/msgbox.tcl: added color icons for tk_messageBox on Unix + and Mac when tk_strictMotif isn't set. (Hipp) + * library/tk.tcl: added window bounds checking to ::tk::PlaceWindow + + * tests/imgPPM.test: fixed test 2.2 to use -format ppm (since + we know have GIF write capability) + +1999-12-01 Scott Redman + + * generic/tkMain.c : + * unix/tkAppInit.c: + * win/winMain.c: Added added hooks into the main() code for + supporting TclPro and other "big" shells more easily without + requiring a copy of the main() code. + +1999-11-29 Jeff Hobbs + + * generic/tkImgGIF.c: added GIF writing that uses miGIF RLE + [Bug: 2039, new patch] + + * library/entry.tcl: fixed up tkEntrySeeInsert (Nemthi) + + * generic/tkListbox.c: fixed 'get' of listbox to return a string + when only one item is requested. + + * tests/clrpick.test: + * tests/filebox.test: minor whitespace cleanup - * unix/Makefile.in: Don't install tk.h for install-libraries. + * library/tk.tcl: fixed missing $w in ::tk::PlaceWindow -1999-03-19 Khamis Abuelkomboz - - * library/tkfbox.tcl (tkFDialog_OkCmd): Bug fix for double-click on - a directory when multiple-mode is turned on, double-clicking a - directory didn't switch to that directory. +1999-11-24 Jeff Hobbs -1999-03-19 Khamis Abuelkomboz + * library/clrpick.tcl: + * library/msgbox.tcl: + * library/tk.tcl: + * library/tkfbox.tcl: + * library/xmfbox.tcl: fixed dialogs to center over -parent, + added utility functions ::tk::PlaceWindow, ::tk::SetFocusGrab, + ::tk::RestoreFocusGrab to tk.tcl to help - * win/tkWinDialog.c (GetFileName): set the multi flag to the boolean - value it was given to turn multi-selection on/off. +1999-11-23 Eric Melski - * library/tkfbox.tcl (tkFDialog): mask list of selected files using the - list command only when the string isn't empty to avoid getting "{}" - in the entry box. + * tests/listbox.test: Added a test to check that the topIndex is + update when items are removed from the listvar variable. -1999-03-19 Khamis Abuelkomboz + * generic/tkListbox.c: Added a check the updates the topIndex when + items are removed from the listvar variable. - * library/tkfbox.tcl (tkFDialog): Corrected reference to not valid - variable name. + * tests/listbox.test: Added a test to check that the vertical + scrollbar is updated when the listvar changes. - * win/tkWinDialog.c (GetFileName): set the multi flag to the boolean - value it was given to turn multi-selection on/off. + * generic/tkListbox.c (ListboxListVarProc): added a check that + sets the UPDATE_V_SCROLLBAR flag if the length of the listvar has + changed. -1999-03-18 Syd Polk +1999-11-23 Jeff Hobbs - * library/tkfbox.txl (tkFDialog): Fix a reference to an unknown - variable $text. + * generic/tk.h: + * generic/tkConfig.c: added support for TK_OPTION_DONT_SET_DEFAULT + as equiv for TK_CONFIG_DONT_SET_DEFAULT + * generic/tkListbox.c: added TK_OPTION_DONT_SET_DEFAULT to the + item specs -1999-03-18 Khamis Abuelkomboz +1999-11-19 Jeff Hobbs - * win/tkWinDialog.c (GetFileName): When only one file is selected and - multi selection is enabled, add the file using tcl_AppendElement to the - result to get a list of files (here with only one file). This makes - the functionality consistent to the case when multiple files are - selected. This has produced a bug when only one file is selected that - contains spaces. + * generic/tkColor.c: + * generic/tkColor.h: fixed Tk_NameOfColor to work correctly, + with minor change to TkColor struct. - * library/tkfbox.tcl (tkFDialog): mask a file containing spaces using - the list command when -multipl flag is set to yes. - (tkFDialog_ListBrowse): likewise. + * generic/tkConsole.c: added static declaration to + ConsoleDeleteProc function (proto already had it) -1999-03-03 Syd Polk + * win/tkWinInt.h: removed TkFontAttributes typedef (was + redundant with tkFont.h). + * win/tkWinPort.h: put #ifndef __GNUC__ around redefinition + of str[n]casecmp, as cygwin uses the originals. + * win/tkWinX.c: changed GetCurrentTime to GetTickCount (the + former is deprecated). [Bug: 2053] - * generic/tkText.c (TextSearchCmd): Was incorrectly returning - number of bytes instead of number of characters in search subcommand. +1999-11-19 Eric Melski -1999-03-04 Syd Polk + * tests/listbox.test: Added tests for itemcget and itemconfigure. - * win/tkWinMenu.c: Fixed compile error introduced by merge - of 1999-03-02. + * doc/listbox.n: Added documentation for -listvar option and for + itemconfigure and itemcget commands. -1999-02-28 Ian Roxborough + * generic/tkListbox.c: Added support for itemconfigure/itemcget + listbox subcommands (addresses rfe #936) - * win/tkWin3d(Tk_3DHorizontalBevel,Tk_3DVerticalBevel): - Draw sunken 3D effect the same as Window95/98/NT. - * win/tkWinButton: Decrease this minimum button high - for a better Windowz look and feel. - * win/tkWinDefault.h: Increase default button y padding. +1999-11-17 Eric Melski -1999-02-22 Syd Polk + * tests/listbox.test: Updated tests for new error messages. - * win/configure.in: Fix TK_LIB_FULL_PATH for cygwin build. - * win/configure: Regenerate. + * generic/tkListbox.c: Improved error messages for bad -listvar's. -1999-02-18 Syd Polk + * tests/listbox.test: Added tests for bad -listvar's. - * win/configure.in: Set TK_SRC_DIR and export it. - Set TK_LIB_FULL_PATH and export it. - * win/configure: Regenerate. + * generic/tkListbox.c: Added handlers for bad -listvar's (ie, bad + lists) -1999-02-09 Syd Polk + * tests/listbox.test: Added tests for ListboxUpdateHScrollbar. - * unix/configure.in: Export TK_LIB_FULL_PATH so that dependency - tracking can be done. - Use TCL_LIB_FULL_PATH to track dependencies. - * unix/configure: Regenerate. - * unix/tkConfig.sh.in: Export TK_LIB_FULL_PATH so that dependecy - tracking can be done. - * unix/Makefile.in: Add dependency for TCL_LIB_FULL_PATH. + * generic/tkListbox.c: Changed some old static buffers to base + size on TCL_DOUBLLE_SPACE instead of (completely) hardcoding the size. -1998-12-31 Syd Polk + * tests/listbox.test: New tests for -listvar functionality, and an + odd extra case that wasn't covered before. - * generic/tkFont.c (Tk_UnderlineTextLayout): - Don't draw an underline if underline value is - -1. + * generic/tkListbox.c: Tests exposed some bugs, now fixed. -1998-12-30 Syd Polk +1999-11-16 Eric Melski - * generic/tkFont.c (Tk_UnderlineTextLayout): - Tk_CharBBox needs a byte offset, not a character - offset. + * tests/listbox.test: Fixed tests to comply with new objectified + error messages. No -listvar specific tests yet. -1998-12-17 Syd Polk + * win/tkWinDefault.h: + * unix/tkUnixDefault.h: + * mac/tkMacDefault.h: Added default value for -listvar option. - * win/tkWinMenu.c: (TkWinMenuHandleEvent): WM_MENUCHAR - needs to index characters, not bytes, when handling the - underline character. + * generic/tkWindow.c: Changed "listbox" mapping from old-school to + new-school objectified command. -1998-12-11 Syd Polk + * generic/tkListbox.c: Objectified listbox; added support for + -listvar option. Converted internal structure to use a Tcl list + object to store the data. - * generic/tkMain.c (Tk_Main): All arguments except the filename - on the command-line were not being translated to UTF. + * generic/tkInt.h: Changed reference to Tk_ListboxCmd to + Tk_ListboxObjCmd. -1998-12-10 Ian Roxborough +1999-11-09 Jeff Hobbs - * win/tkWinDialog.c (GetFileName): Increased the buffer size in the - file select dialog so that there is less change of it filling up - if the user selects a lot of files. + * generic/tkGrid.c: changed Tcl_Alloc to ckalloc -1998-12-04 Syd Polk + * generic/tkEntry.c: fixed C expr error in destroy of entry + that could lead to 'malformed bucket chain' error - * win/tkWinClipboard.c: The clipboard was not translating to - and from the Windows character set. + * win/winMain.c: corrected winMain to not do a DebugBreak when + returning an error message from the top level -1998-12-03 Ian Roxborough +1999-10-30 Jeff Hobbs - * win/tkWinInit.c: Merged in changes from WishCon. - * win/tkMain.c: Merged in changes from WishCon. + * win/tkWinKey.c: fixed XKeysymToKeycode to handle mapping of + symbolic keysyms (Left, Home, ...) with event generate -1998-11-18 Syd Polk - * generic/tkMenu.c (ConfigureMenuCloneEntries): The parameter for - the configure command when reconfiguring entries for a clone menu - should have been "-menu", not "menu". + * library/entry.tcl: change tkEntrySeeInsert to avoid the use + of a while loop that could eat CPU tremendously. Behavior of + moving the cursor at the right edge changes slightly (previously + it tried to keep the cursor at the right edge, now it moves the + cursor to a "central right" location - better IMHO). -1998-11-19 Ben Elliston +1999-10-28 Jeff Hobbs - * win/tkWinWm.c: Local grabs did not exclude menus or the caption - bar. `wm frame' would crash if the window had not been mapped yet. - Patch obtained from the Scriptics CVS repository. + * doc/CrtImgType.3: + * doc/CrtPhImgFmt.3: + * doc/FindPhoto.3: + * doc/photo.n: + * generic/tk.h: + * generic/tkCmds.c: + * generic/tkImage.c: + * generic/tkImgBmap.c: + * generic/tkImgGIF.c: + * generic/tkImgPPM.c: + * generic/tkImgPhoto.c: + * generic/tkInt.h: + * generic/tkTest.c: + * generic/tkWindow.c: + * tests/imgPhoto.test: added Img patch (Nijtmans) with docs, + headers #def'd with USE_OLD_IMAGE. Upgrades image stuff to + Tcl_Obj API, adds alpha channel (images are now 32 bpp) - * win/tkWinWindow.c: Reduce message traffic by setting - WS_EX_NOPARENTNOTIFY on TkChild windows. Patch obtained from the - Scriptics CVS repository. + * makefile.vc: changed 'c:/program files' to c:/progra~1 -1998-11-13 Khamis Abuelkomboz +1999-10-19 Jeff Hobbs - * generic/tkMenu.c (MenuWidgetObjCmd): added patch for selection - problem. Disabled menu entries remain disabled. - (DestroyMenuEntry): added patch for memory leak. + * library/scrlbar.tcl: changed tkScrollButtonUp to check for + existence of tkPriv(relief) in order to avoid spurious release + events -1998-11-11 Syd Polk + * unix/Makefile.in: added ChangeLog to dist archive - * win/tkWinMenu.c: Merged from latest tcl8.1 source. +1999-09-24 Jeff Hobbs -1998-11-06 Ian Roxborough + * */README: + * win/makefile.vc: + * */configure.in: + * generic/tk.h: + * library/tk.tcl: up'd to 8.3a1 - * win/tkWinDialog.c (GetFileName): Add support for --multiple to - tk_getOpenFile. + * unix/Makefile.in: changed 'mkdir' to 'mkdir -p' -1998-11-06 Syd Polk + * library/dialog.tcl: changed {Times 18} to {Times 12} for + dialog font. - * win/tkWinMenu.c (GetEntryText): Fixed menubars and system - menu character set problems. - * win/tkWinWm.c: Fixed title bar text character set problems. +1999-09-16 Jeff Hobbs -1998-10-28 Syd Polk + * generic/tkFont.c: fixed processing of font options and error + returned [Bug: 2075] - * win/Makefile.in: Remove prolog.ps from install + * win/tkWinWm.c: fixed bug in 'wm deiconify' that raised the + wrong toplevel, and changed it to not set focus on overridden + toplevels -1998-10-26 Syd Polk +1999-09-15 Jeff Hobbs - * win/Makefile.in: Change tcl directory. - * win/configure.in: XINCLUDES needs be generated correctly. - * win/configure: Regenerated. + * unix/aclocal.m4: added fix for FreeBSD-[1-2] recognition [Bug: 2070] + and fix to AIX-* to get ldAix right [Bug: 2624], fixed AIX + version check (readjust from 8-21 fix) and several other config + fixes for AIX + * mac/tkMacMenubutton.c: + * unix/tkUnixMenubu.c: fixed permanently stippled menubutton image + * win/tkWinButton.c: fixed possible pointer smash [Bug: 2733] -1998-10-23 Ben Elliston +1999-09-14 Jeff Hobbs - * generic/tkFont.c (Tk_UnderlineChars): Count multibyte characters - correctly when underlining. Contributed by Scott Stanton - . + * win/tkWinMenu.c: fix for stack overrun in GetTextFace [Bug: 909] -1998-10-20 Syd Polk +1999-09-01 Jeff Hobbs - * unix/configure.in: Work with tcl8.1 directory name - * unix/configure: Regenerated - -1998-10-04 Syd Polk + * win/tkWinDraw.c: + * unix/tkUnixDraw.c: fixed header style for TkpDrawHighlightBorder + * generic/tkCanvas.c: fixed GC error (bg <> fg) in tkCanvas.c + (from code added to support TkpDrawHighlightBorder) [Bug: 2676] + * unix/aclocal.m4: added -bnoentry to the AIX-* flags + * library/msgbox.tcl: changed the behavior of tk_messageBox on + Unix to be more Windows like in handling of and the + default button + * library/button.tcl: + * library/clrpick.tcl: + * library/comdlg.tcl: + * library/console.tcl: + * library/dialog.tcl: + * library/entry.tcl: + * library/focus.tcl: + * library/listbox.tcl: + * library/menu.tcl: + * library/msgbox.tcl: + * library/palette.tcl: + * library/safetk.tcl: + * library/scale.tcl: + * library/scrlbar.tcl: + * library/tearoff.tcl: + * library/text.tcl: + * library/tk.tcl: + * library/tkfbox.tcl: + * library/xmfbox.tcl: updated commands to use [string] ops + instead of expr equality operators - * win/Makefile.in: Somehow this ended up on the main branch. +1999-08-21 Jeff Hobbs -1998-10-14 Syd Polk + * unix/aclocal.m4: Changed AIX-4.[2-9] check to AIX-4.[1-9] + [Bug: 1909] - * win/Makefile.in configure.in: More work for tk 8.1 build. - * win/configure: Regenerated - * win/tkWinDialog.c: Added dummy -multiple option. irox will re-implement - this soon. +1999-08-20 Jeff Hobbs -1998-09-29 Syd Polk + * generic/tkCursor.c: fixed bug in GetCursorFromObj that caused + panic [Bug: 2562] - * win/configure.in: Generate the correct version number - * win/configure: Regenerated. - * win/Makefile.in: Now compiles for Visual C++. - * win/tkWinFont.c win/TkWinInt.h win/TkWinWm.c: Removed changing - font map when system changes. 8.1 is eventually supposed to support - this and the font package changed dramatically. The changes were - not easy to bring forward, so we will have to do something if - Tk 8.1 does not support this. + * TK 8.2.0 RELEASED -1998-09-29 Syd Polk +1999-08-13 Jim Ingham - * win/configure.in: Merged from devo - * win/configure: Regenerated. + * mac/tkMacMenu.c: Tk_DrawChars ends up setting the menu background + wrong. There is no clean way to stop it, so I use lower level routines + here to draw the text. + * mac/tkMacProjects.sea.hqx: Rearrange the projects so that the build + directory is separate from the sources. Much more convenient! -1998-09-28 Syd Polk +1999-08-10 Jeff Hobbs - * win/Makefile.in: Fixes for OBJEXT; removed hard-coded 80 - references; added new tk files for 8.1. + * win/tkWinWm.c: changed "wm deiconify" on Windows to raise and + force the focus on the deiconified window (behavioral change from + 8.1 to comply better with Windows style) [Bug: 1609] + * doc/wm.n: clarified behavior of "wm deiconify". + * generic/tkInt.decls: added TkSetFocusWin + * generic/tkFocus.c: changed static SetFocus to TkSetFocusWin -Wed Aug 19 17:48:00 PDT 1998 Syd Polk + * library/clrpick.tcl: + * library/console.tcl: + * library/tk.tcl: fixed code where abbreviations where used + in calling widget methods (confuses iWidgets) [Bug: 2422] - * Continued 8.1 integration +1999-08-09 Jeff Hobbs -Mon Jul 6 18:13:02 1998 Martin M. Hunt + * library/button.tcl: cleaned up programming (config -> configure) + and fixed Windows relief bug [Bug: 664] + * library/entry.tcl: changed Entry C/C/P to not use global data + (now uses tkPriv(data)) [Bug: 1475] + * library/listbox.tcl: fixed extended mode script error [Bug: 866] + * doc/options.n: clarified that -troughcolor doesn't work on Windows + * doc/wm.n: fixed wm positionfrom docs [Bug: 2284] - * win/Makefile.in: Remove bad line with just "mv" on it. +1999-08-01 Jeff Hobbs -Mon Jul 6 15:53:35 1998 Ian Roxborough - * win/Makefile.in: Don't set lflags or lcommon if you're not - setting OBJEXT to 'obj', (i.e. for MSVC). + * mac/tkMacPort.h: wrapped panic in #ifndef panic to avoid + compiler errors when used with stubs-#defines, from Vince Darley. + [Bug: 2389] + +1999-07-31 Scott Redman -Sat Jul 4 16:21:25 1998 Ian Roxborough - * win/Makefile.in: Don't make dumpext.exe unless you're using MSVC - and setting OBJEXT = obj. + * xlib/X11/Xlib.h: Remove XFillRectangle since it is now in the + stub tables. -1998-07-03 Ben Elliston +1999-07-30 Jeff Hobbs - Patches from Ian Roxborough . - * win/configure.in: Add AC_OBJEXT macro invocation. + * generic/tkInt.decls: Added stub entry for XFillRectangle [Bug: 2446] - * win/configure: Regenerate. +1999-07-30 - * win/Makefile.in: Don't assume object files end in `.o'. - -Wed Jul 1 00:11:02 1998 Khamis Abuelkomboz + * win/makefile.vc: Corrected building threaded tktest.exe on + Windows. Needed to link in .obj files from Tcl, needs to change + later so that code is in Tk and doesn't require a Tcl build. + Also added runtest target. - * unix/tkUnixDefault.h (DEF_TEXT_TAB_SIZE): new macro to define - the default tab size "8". - - * win/tkWinDefault.h (DEF_TEXT_TAB_SIZE): new macro to define the - default tab size "8". +1999-07-29 - * mac/tkMacDefault.h (DEF_TEXT_TAB_SIZE): new macro to define the - default tab size "8". + * generic/tkConsole.c: Allow tcl to open CON and NUL, even for std + channels. Checking for bad/unusable std channels was moved to Tk + since its only purpose was to check whether to use the Tk Console + Window for the std channels. [Bug: 2393 2392 2209 2458] - * generic/tkTextDisp.c (NextTabStop): Added the text widget pointer - as an argument for this function to read the set tab-width for - the default tabulator behavior. Default is 8. + * win/Makefile.in: Corrected building threaded tktest.exe on + Windows. Needed to link in .obj files from Tcl, needs to change + later so that code is in Tk and doesn't require a Tcl build. - * generic/tkText.c: (configSpecs) Added "-tabsize" to the option - command list of the text widget. It defines the width of the - default tabulator, default 8. +1999-07-22 - * generic/tkText.h: added a new structur member to TkText "tabsize", - it stores the tab width (default 8). "-tabs" doesn't support - normal text tabulator behaviar, so we can't use it in SN. + * Changed version to 8.2b2 -Thu Jun 18 10:27:00 1998 Syd Polk + * win/tkWinPort.h: Block out include of sys/stat.h in order to + build extensions with MetroWerks compiler for Win32. [Bug: 2385] - * Removed all of the files in Tk 8.1a2 not in Tk 8.0p2. They - were added when the import was done. - -Fri Jun 12 11:48:26 1998 Mumit Khan - - * configure.in (*-*-mingw32*): Support. - * win/Makefile.in (DLL_LDLIBS, DLL_LDFLAGS): New variables. - (tkcyg.def): Ignore errors. - (plugin.def): Likewise. - ($(TKDLL),$(TKPLUGINDLL)): Cleanup DLL build flags and use - DLL_LDLIBS and DLL_LDFLAGS. - * win/configure.in (DLL_LDLIBS, DLL_LDFLAGS): Define and substitute. - (TK_PATCH_LEVEL): Bump to p2. - * win/tkWinPort.h (TK_READ_DATA_PENDING): Define for Mingw32. - (timezone,timeval,gettimeofday): Don't define/declare for Mingw32. - * win/tkWinX.c (GetCurrentTime): Define as GetTickCount if - __MINGW32__ as well. - * win/configure: Rebuild. + * unix/Makefile.in: Need to make install-sh executable before + calling (with chmod +x). [Bug: 2413] + + * library/menu.tcl: Applied patch from Jeff Hobbs to fix typo. + [Bug: 2425] + +1999-07-21 -Fri May 29 17:12:29 1998 Ian Lance Taylor + * unix/Makefile.in: Add Windows configure script to distribution. - * win/Makefile.in (X11_INCLUDE_INSTALL_DIR): New variable. - (install-libraries): Install X11 header files in - X11_INCLUDE_INSTALL_DIR. - (install-minimal): Don't create INCLUDE_INSTALL_DIR. - * win/configure.in: Call AC_CANONICAL_HOST. - * win/configure: Rebuild. +1999-07-16 -Wed May 27 17:00:35 1998 Ian Lance Taylor + * unix/Makefile.in: + * win/Makefile.in: Copy the prolog.ps from the generic directory + for install-libraries. - * library/tkfbox.tcl (tkFDialog): Save the old multiple setting, - and recreate the dialog if it changes. + * unix/aclocal.m4: Check for Alpha/Linux to set the IEEE flag to + the compiler to be -mieee. Patch from Don Porter. -Thu Apr 30 18:10:15 1998 Geoffrey Noer +1999-07-08 - * win/Makefile.in: invoke gcc instead of ld when producing - dlls. Pass the linker options down via args to -Wl options. + * tests/unixSelect.test: Fixed broken test. -Sun Apr 26 15:45:18 1998 Khamis Abuelkomboz + * win/makefile.vc: Added special case target to ensure that + tkStubLib.obj is built with -DSTATIC_BUILD. - * generic/tkCanvBmap.c (tkCreateBitmap): renamed from "CreateBitmap" - to avoid conflicts with the already defined MSVC procedure. + * win/tkWinX.c (TkWinChildProc): Changed to pass + WM_WINDOWPOSCHANGED through to DefWindowProc to make OpenGL + sub-windows happy. This allows Windows to generate the WM_SIZE + and WM_MOVE messages. -Thu Apr 23 10:09:29 1998 Tom Tromey +1999-07-08 - * library/tkfbox.tcl (tkFDialog_Config): Use lindex, not join, to - extract list item. - (tkFDialog_Config): Recognize -choosedir option. - (tkFDialog_OkCmd): If -choosedir set, then don't special-case - directories. - (tkFDialog_VerifyFileName): Handle -choosedir. - (tkFDialog_ListBrowse): Likewise. + * unix/configure.in: Fix Tk stub lib file names and flags. -Thu Apr 16 17:30:46 1998 Ian Lance Taylor +1999-06-30 - * win/tkWinButton.c (WinButton): Add pixFlags field. - (TkpCreateButton): Initialize new pixFlags field. - (TkpDestroyButton): Clear pixmap field if we free the pixmap. - (TkpRealDisplayButton): Don't free the pixmap just because we're - unmapping the window. Check pixFlags field to see if we can use - the cached pixmap. Set pixFlag field if we cache the pixmap. - * generic/tkButton.c (TkButtonWorldChanged): Remove Cygnus local - patch; once again check whether the button is mapped before - scheduling a call to TkpDisplayButton. - (ButtonVarProc): Likewise. + * generic/tkGrid.c: removed deprecated functions (applied patch + from Jan Nijtmans). [Bug: 2080] -Thu Apr 16 15:59:55 MEST 1998 Khamis Abuelkomboz - * library/tkfbox.tcl - -One COMMENT: I have never seen so bad tcl/source code as how this - stuped tk/filedialog is implemented!!!!!!!!!!!!! - - (tkIconList_Select): Include the fact that by multi-selection a file - could contain blanks, so that the file is added as a list - element. - (tkFDialog): When the dialog is not new created (withdrawn) don't - center it again - -Define Tracer before calling the dialog and immediatly remove - it after selection. - -tk dialog box doesn't use dynamic array names, so it's - not possible to use more than one dialog box at the same - time. Other dialogs must be deleted! - (tkFDialog_SetPath): Accept the fact that the variable could be bound - on a already deleted widget (trace). - -No tracer here. - (tkFDialog_Config): "glob" command returns a list of items, so we must - join the result, this was bugy when a file has contained blanks. - (tkFDialog_ActivateEnt): We can't trim a list. - (tkFDialog_OkCmd): Join file name only by single selection. - (tkFDialog_ListInvoke): Differ between single and multi selection by - joining files. - -return a list of files by multi-selection and the file itself - by single-selection. - -Tue Apr 14 15:01:10 1998 Ian Lance Taylor - - * generic/tkText.c (TextBlinkProc): Remove test of TkTextCharBbox, - since it is a difference from standard releases, and it will never - change what happens. - -Mon Apr 13 17:55:13 1998 Ian Lance Taylor - - * compat/memmove.c: Remove. - -Thu Apr 9 15:00:47 1998 Martin M. Hunt - - * library/msgbox.tcl (tkMessageBox): When a default button - is supplied, simply set the focus on it, don't bind . - For all buttons, bind for them so the button command - is invoked. - -Tue Apr 7 20:32:40 1998 Ian Lance Taylor - - * tests/msgbox.test: Update unknown option message for -modal - option. - -Fri Mar 27 15:18:30 1998 Jeff Holcomb - - * win/tkWinX.c: Added temporary define for MNC_CLOSE. - -Wed Mar 11 13:48:31 1998 Tom Tromey - - * library/entry.tcl: Only bind when not on Windows. - -Sat Mar 21 21:18:06 1998 Elena Zannoni - - Merged changes from Foundry (list follows in reverse chronological order) - - - Tom Tromey - * win/tkWinWm.c (InitWm): Look for "tk" icon first in - application's resources and then in Tk DLL's. - * generic/tkButton.c (TkButtonWorldChanged): Don't check to see if - button is unmapped before scheduling a redraw. - * win/tkWinWm.c (Tk_WmCmd): In "frame" case, make window exist if - it doesn't already. - * generic/tkButton.c (ButtonVarProc): Don't check to see if button - is unmapped before scheduling a redraw. - * win/tkWinButton.c (TkpRealDisplayButton): Destroy backing pixmap - if window is unmapped. - * win/tkWinWm.c (EX_TRANSIENT_STYLE): Define as 0. - * win/tkWinX.c (Tk_TranslateWinEvent): Handle WM_MENUCHAR. - (GenerateXEvent): Likewise. - * win/tkWinWm.c (UpdateWrapper): Turn off maximize box and sizebox - for non-resizable windows. - * win/tkWinDialog.c (Tk_MessageBoxCmd): Don't pass - MB_SETFOREGROUND for "-modal system". - - - Ian Lance Taylor - * win/Makefile.in ($(TKDLL)): Don't generate relocs for debugging - information. - * win/tkWinFont.c (Tk_MeasureChars): Free the partials array. - * win/tkWinFont.c (Tk_MeasureChars): Rearrange to always use sizes - from partials array, rather than size.cx. - - - Tom Tromey - * win/tkWinMenu.c (TkWinHandleMenuEvent): Don't use height element - of indicatorDimensions when computing width. - * win/tkWinDialog.c: Reverted previous change. It turns out that - with the change, if the user selects too many files, the list will - be truncated in the middle but no error message will be returned. - This makes it impossible to detect failures. - * win/tkWinDialog.c (ParseFileDlgArgs): If -multiple passed, don't - require files to exist. This is a hack to work around a bug in - the common dialog. - (CYG_MAX_PATH): New define. - (_OpenFileData): Use CYG_MAX_PATH. - (GetFileName): Likewise. - * generic/tkTextDisp.c (DisplayDLine): Display cursor for disabled - widgets on Windows. - - - Ian Lance Taylor - * win/tkWinFont.c (WinFont): Remove widths field. - (Tk_MeasureChars): Rewrite to use GetTextExtentExPoint, and not - assume that Windows doesn't do kerning, since in reality it does - do kerning. - (AllocFont): Don't initialize widths field. - - - Tom Tromey - * library/text.tcl (tkTextButton1): Unconditionally set the - focus. - - - Ian Lance Taylor - * win/tkWinDialog.c (Tk_MessageBoxCmd): If -modal system, pass - MB_SETFOREGROUND. May or may not be useless. - * generic/tkFocus.c (SetFocus): If force, then don't just return - even if the desired window is already the focus window. - * win/tkWinPointer.c (TkpChangeFocus): Call XSetInputFocus even if - force. - * win/tkWinWm.c (EX_TRANSIENT_STYLE): Remove WS_EX_TOOLWINDOW. - -Mon Jan 12 15:45:03 1997 Syd Polk - - * library/tkfbox.tcl (tk_getOpenFile): tk_getOpenFile would complain - and behave incorrectly if the -initialdir argument had a space - in it. - -Wed Dec 31 12:27:25 1997 Ian Lance Taylor - - * win/Makefile.in (install-libraries): Install the X11 header - files as well as tk.h. - -Tue Dec 23 16:31:07 1997 Ian Lance Taylor - - * win/Makefile.in ($(TKDLL)): Don't generate relocs for debugging - information. + * generic/tkImgGIF.c: + * generic/tkImgPPM.c: + * generic/tkImgPhoto.c: Applied patch to allow Img extension to + work with 8.2, from Jan Nijtmans. [Bug: 2068] -Mon Nov 17 18:07:12 1997 Ian Lance Taylor + * win/tkWinWm.c: Applied patch from Don Porter to prevent the + windows code from calling the Tcl functions when the stub table + has not been initialized in TkWinWmCleanup. [Bug: 2269] + +1999-06-16 - * win/tkWinButton.c (TkpCreateButton): Initialize pixmap field. - (TkpDestroyButton): Free pixmap field. - (TkpDisplayButton): Entire function moved into - TkpRealDisplayButton. - (TkpRealDisplayButton): New static function, from old - TkpDisplayButton. - (TkpComputeButtonGeometry): Discard any saved pixmap. - (ButtonProc): Call TkpRealDisplayButton, not TkpDisplayButton. - -Fri Nov 14 12:24:04 1997 Ian Lance Taylor - - * win/tkWinMenu.c (TkpDestroyMenu): Remove the menu handle from - winMenuTable. Clear modalMenuPtr if we're destroying it. - (TkWinHandleMenuEvent): Don't treat WM_SYSCOMMAND like - WM_COMMAND. - - * win/tkWinDialog.c (Tk_MessageBoxCmd): If -modal task, and - -parent not used, pass hWnd as NULL to MessageBox. - -Tue Nov 11 20:07:04 1997 Ian Lance Taylor - - * win/tkWinMenu.c (TkWinHandleMenuEvent): If TkPreprocessMenu - returns an error, call Tcl_BackgroundError. - -Fri Nov 7 15:52:23 1997 Ian Lance Taylor - - * win/tkWinDialog.c (Tk_MessageBoxCmd): Accept -modal option. - * library/msgbox.tcl (tkMessageBox): Accept and ignore -modal - option. - -Tue Oct 28 17:51:06 1997 Martin M. Hunt - - * generic/tkText.c: Patch text.txt from the net. Fixes - Win95 selection bug. - - * library/dialog.tcl (tk_dialog): Two fixes from the net for - Windows 95 dialogs. Patch "dialog.txt" from "Robert Embleton" - - -Tue Oct 28 16:36:11 1997 Ian Lance Taylor - - * Makefile.in (install-minimal): New target. - * win/Makefile.in (install-minimal): New target. - -Thu Oct 23 12:59:18 1997 Tom Tromey - - * generic/tkScale.c (ConfigureScale): When setting scale value, - don't cause scale to invoke command. - -Fri Oct 10 19:41:57 1997 Tom Tromey - - * xlib/X11/Xlib.h: On Windows, use a typdef for Status. - - * win/tkWinPort.h: Declare struct timeval. - -Wed Oct 8 18:33:41 1997 Jeffrey A Law (law@cygnus.com) - - * generic/tkText.c: Avoid ANSI-C code. - -Tue Oct 7 10:32:01 1997 Tom Tromey - - * library/button.tcl: Bind to invoke buttons on Windows. - -Thu Oct 2 17:05:14 1997 Ian Lance Taylor - - * generic/tkColor.c (struct TkGCList): Define. - (Tk_GetColor): Initialize gcList element. - (Tk_GetColorByValue): Likewise. - (TkMapOverColors): New function. - (TkRegisterColorGC, TkDeregisterColorGC): New functions. - (TkColorChanged): New function. - * generic/tkColor.h (TkGCList): Define typedef. - (TkColor): Add gcList field. - (TkMapOverColors, TkColorChanged): Declare. - * generic/tkGC.c: Include tkInt.h. - (TkGC): Add foreground and background fields. - (ValueKey): Add foreground and background fields. - (Tk_GetGCColor): Rename from Tk_GetGC. Add foreground and - background parameters. Register the GC with the colors. - (Tk_GetGC): New function which just calls Tk_GetGCColor. - (Tk_FreeGC): Deregister colors. - * generic/tk.h (Tk_GetGCColor): Declare. - * generic/tkInt.h (TkRegisterColorGC): Declare. - (TkDeregisterColorGC): Declare. - * win/tkWinColor.c (ChangeColor): New static function. - (TkWinSysColorChange): New function. - * win/tkWinWm.c (WmProc): Handle WM_SYSCOLORCHANGE. - * win/tkWinInt.h (TkWinSysColorChange): Declare. - * generic/tk3d.c: Change some calls to Tk_GetGC to call - Tk_GetGCColor instead. - * generic/tkButton.c: Likewise. - * generic/tkCanvArc.c: Likewise. - * generic/tkCanvBmap.c: Likewise. - * generic/tkCanvLine.c: Likewise. - * generic/tkCanvPoly.c: Likewise. - * generic/tkCanvText.c: Likewise. - * generic/tkCanvas.c: Likewise. - * generic/tkEntry.c: Likewise. - * generic/tkImgBmap.c: Likewise. - * generic/tkImgPhoto.c: Likewise. - * generic/tkListbox.c: Likewise. - * generic/tkMenuDraw.c: Likewise. - * generic/tkMenuButton.c: Likewise. - * generic/tkMessage.c: Likewise. - * generic/tkRectOval.c: Likewise. - * generic/tkScale.c: Likewise. - * generic/tkTextDisp.c: Likewise. + * unix/configure.in: + * unix/Makefile.in: + * unix/aclocal.m4: Numerous build changes to make Tk conform to + the proposed TEA spec -Tue Sep 30 17:13:16 1997 Ian Lance Taylor + * tkConsole.c: changed some variable types from (int) to (size_t) + to prevent compiler warnings. Cast return value from strlen() + to (int) in one place for the same reason. - * win/tkWinPointer.c (TkWinCancelMouseTimer): New function. - * win/tkWinWm.c (WmProc): Call it in WM_ENTERSIZEMOVE case. +1999-06-03 -Mon Sep 15 16:29:16 PDT 1997 Khamis Abuelkomboz - generic/tkText.[ch] - Added a new functionality for the editor '-synccommand'. When it es - not empty, this command is called, when ever the contents in the - editor is changed (insert, delete). The function is called with the - same parameters how it called for the editor. - This functionality is used in the new GUI for SN to be able to open - more than one editor with the same file (like emacs multiple buffers). + * unix/tkUnixSelect.c: + * tests/unixSelect.test: + * generic/tkSelect.c: Fixed selection code to handle Unicode data + in COMPOUND_TEXT and STRING selections. [Bug: 1791] -Wed Sep 10 12:56:43 1997 Ian Lance Taylor +1999-06-02 - * generic/tkImgPhoto.c (FreeColorTable): Add force parameter. - Change all callers. - (DisposeInstance): Force FreeColorTable to free the color table - immediately, in case we are being called from TkDeleteAllImages - when Tk is exiting. + * generic/tkIntXlibDecls.h: + * xlib/X11/Xlib.h: Added Mac specific defines to help with + compilation. - * win/tkWinMenu.c (TkWinHandleMenuEvent): If TkInvokeMenu returns - an error, call Tcl_BackgroundError. + * generic/tkFont.c: lint - * win/Makefile.in (install-libraries): Don't try to install *.gif - or *.xbm. +1999-06-01 -Mon Sep 8 17:13:49 MET DST 1997 Zsolt Koppany - unix/tkUnixEvent.c - Deleted the second unnecessary call of XOpenDisplay(). + * unix/tkUnixSelect.c: Improved I18N selection support. + COMPOUND_TEXT is converted to/from iso2022, and STRING is + converted to/from iso8859-1. There are still a few loose ends to + tie up before this is completely done. -Thu Sep 4 20:07:23 1997 Ian Lance Taylor + * unix/tkUnixFont.c: Eliminated redundant case folding code. - * win/tkWinFont.c (nonClientMap): New static array. - (TkpGetFontFromAttributes): If the font is in a magic windows-* - family, use SystemParametersInfo to get the attributes. - (TkWinNCMetricsChanged): New function. - (FontChanged): New static function. - * win/tkWinInt.h (TkWinNCMetricsChanged): Declare. - * generic/tkFont.c (TkUpdateFonts): New function. - * generic/tkFont.h (TkUpdateFonts): Declare. - * win/tkWinWm.c (WmProc): Handle WM_SETTINGCHANGE with a wParam - value of SPI_SETNONCLIENTMETRICS. + * generic/tkFont.c: Eliminated use of isupper/tolower in favor of + Unicode variants. -Thu Sep 4 11:34:20 1997 Martin M. Hunt +1999-05-24 - * library/palette.tcl (tkRecolorTree): If color isn't - set don't try to apply it. + * generic/tkStubLib.c: + * generic/tkStubInit.c: + * generic/tkIntXlibDecls.h: + * generic/tkIntPlatDecls.h: + * generic/tkIntDecls.h: + * generic/tkInt.decls: + * generic/tkConsole.c: Various changes to try to get the Mac + builds working. - * library/menu.tcl: Apply patch "menu2.txt" from patches - archive. +1999-05-21 -Fri Aug 29 11:27:17 1997 Tom Tromey + * win/tkWinClipboard.c: Fixed clipboard code to handle lack of + CF_LOCALE information (e.g. from command.com). - * library/menu.tcl (tk_popup): Use Tcl syntax for call to - tk_menuSetFocus. - -Thu Aug 28 15:25:31 MET DST 1997 Zsolt Koppany - * generic/tkImgGIF.c - Memory bug fix. +1999-05-20 -Thu Aug 28 13:36:30 1997 Ian Lance Taylor + * library/console.tcl: Changed copyright string to read 1999 + Scriptics Corp. in wish console about box. + +1999-05-19 - * testsuite/tk.tests/tk-test.exp: Permit capital letters in test - case names. Try better error string handling. + * generic/tk.h: Add extern "C" block around entire header file for + C++ compilers to fix linkage issues. Submitted by Don Porter and + Paul Duffin. - * generic/tkInitScript.h (initScript): Don't call pwd in a safe - interpreter. +1999-05-18 - * library/tkfbox.tcl (tkFDialog_VerifyFileName): Only add file to - selectFile using lappend if -multiple. - * tests/filebox.tcl: Set the expected unknown options based on the - command and mode. + * tests/winClipboard.test: + * win/tkWinClipboard.c: Fixed clipboard code so it handles Unicode + data properly on Windows NT and 95. [Bug: 1791] -Sun Aug 24 21:40:30 1997 Ian Lance Taylor +1999-05-07 - * win/Makefile.in ($(TKDLL)): Set base address to 0x66300000. + * library/menu.tcl: Fixed bug where tk_popup fails when called too + quickly. [Bug: 2009] -Mon Aug 18 18:13:00 1997 Ian Lance Taylor +1999-04-30 - * win/tkWinDialog.c (GetFileName): Handle the case of a single - file when OFN_ALLOWMULTISELECT is set. + * Changed version number to 8.1.1. -Fri Aug 15 19:26:39 1997 Ian Lance Taylor +1999-04-30 - * win/tkWinInit.c (initScript): Don't append share to [info - library] (revert patch of Aug 7). + * Merged changes from 8.1.0 branch: -Thu Aug 14 09:29:45 1997 Tom Tromey + * generic/tkDecls.h: + * generic/tkIntDecls.h: + * generic/tkIntPlatDecls.h: + * generic/tkIntXlibDecls.h: + * generic/tkPlatDecls.h: + * generic/tkStubInit.c: Changed to avoid the need for forward + declarations in stub initializers. Added extern "C" blocks around + stub table pointer declarations so the stubs can be used from C++ + code. [Bug: 1934] - * library/dialog.tcl (tk_dialog): Run update after setting - geometry. From the net. + * generic/tkInt.decls: Added TkClipBox, XDrawSegments, and + XForceScreenSaver to stubs. -Wed Aug 13 12:28:08 1997 Tom Tromey + * generic/tkStubLib.c: Reordered declarations to avoid + circularities and forward references. - * library/tkfbox.tcl (tkFDialog_VerifyFileName): Use fname and not - contents of entry to compute flat, path, and file. + * generic/tkStubInit.c: Added includes for Mac. -Tue Aug 12 18:02:15 1997 Ian Lance Taylor + * generic/tkMenubutton.c: lint - * win/rc/cygnus.ico: Change color to match other Cygnus designs. + * generic/tkEntry.c: Fixed bad option table entry. -Tue Aug 12 17:37:36 MET DST 1997 Zsolt Koppany + * generic/tkImgBmap.c: + * generic/tkImgPPM.c: + * generic/tkImgPhoto.c: Set the -translation and -encoding options + to binary for image files. (reported by Marco Gazzetta) + +1999-04-23 - * unix/tkUnixWm.c - Memory leak bug fixes. + * generic/tkInt.decls: Added TkClipBox, XDrawSegments, and + XForceScreenSaver to stubs. - * generic/tkText.c - TkTextRedrawRegion() should be called only if TkTextCharBbox() - does not return -1, because in that case x,y and h variables - will not be set. + * generic/tkStubLib.c: Reordered declarations to avoid + circularities and forward references. -Mon Aug 11 16:58:08 1997 Ian Lance Taylor + * generic/tkStubInit.c: Added includes for Mac. - * configure.in: Call AC_CANONICAL_HOST. Check host, not target, - for cygwin32. - * configure: Rebuild. + * generic/tkMenubutton.c: lint - * win/rc/cygnus.ico: New file. - * win/rc/tk.rc: Replace tk.ico with cygnus.ico. + * generic/tkEntry.c: Fixed bad option table entry. -Mon Aug 11 11:14:31 1997 Martin M. Hunt +1999-04-22 - * generic/tk.h, generic/tkImage.c, generic/tkImgBmap.c, - generic/tkImgGIF.c, generic/tkImgPhoto.c, generic/tkTest.c, - generic/tkWindow.c, library/tkfbox.tcl, tests/imgPhoto.test, - doc/photo.n: Two patches from Jan.Nijtmans@cmg.nl. Fixes - numerous image problems including GIF transparency. + * generic/tkImgBmap.c: + * generic/tkImgPPM.c: + * generic/tkImgPhoto.c: Set the -translation and -encoding options + to binary for image files. (reported by Marco Gazzetta) -Fri Aug 8 21:14:55 1997 Ian Lance Taylor +1999-04-20 - * win/tkWinPointer.c (TkpChangeFocus): If force is set, call - SetForegroundWindow. + * xlib/X11/Xlib.h: changed definition of Status type to use a + typedef instead of a #define to avoid conflicting with the cygwin + win32 headers [Bug 1804] -Thu Aug 7 12:55:50 1997 Ian Lance Taylor +1999-04-15 - * generic/tkFrame.c (mapFrameWindow): New static variable. - (mapFrameFrame): New static variable. - (MapFrame): Set new variables. - (TkInstallFrameMenu): Use new variables. + * Merged 8.1 branch into the main trunk - * win/tkWinInit.c (initScript): Look under share. +1999-04-09 -Wed Aug 6 23:47:01 1997 Ian Lance Taylor + * generic/tkWindow.c: Fixed deadlock situation when the Initialize() + function returns without releasing the mutex. Found while testing + Bug 1700, during safe.test (tk). - * win/Makefile.in: Update for Tk 8.0. - * win/configure.in: Likewise. - * win/configure: Rebuild. - * win/tkWinInt.h (TkFontAttributes): Don't use typedef if - __GNUC__. - * win/tkWinPort.h (strnicmp, stricmp): Define if __CYGWIN32__. - (strncasecmp, strcasecmp): Don't define if __CYGWIN32__. +1999-04-06 -Tue Aug 5 14:00:53 1997 Tom Tromey + * generic/tkMain.c (Tk_MainEx): Changed to reset result before + calling Tcl_EvalFile. The ensures that error messages will be + generated cleanly. - * tests/all: Preserved local changes. - * tests/defs: Preserved local changes. + * tests/winfo.test: Enabled tests that previously failed. -Fri Jul 25 12:42:54 1997 Stephen Peters +1999-04-05 - * win/tkWinDialog.c (GetFileName, ParseFileDlgArgs): Changes to - let tk_getOpenFile and tk_getSaveFile deal with multi-file - selections on Windows. - * doc/getOpenFile.n: Add documentation for `-multiple' option. + * library/bgerror.tcl: + * library/button.tcl: + * library/clrpick.tcl: + * library/console.tcl: + * library/dialog.tcl: + * library/entry.tcl: + * library/focus.tcl: + * library/listbox.tcl: + * library/menu.tcl: + * library/msgbox.tcl: + * library/palette.tcl: + * library/scale.tcl: + * library/scrlbar.tcl: + * library/tearoff.tcl: + * library/text.tcl: + * library/tk.tcl: Lots of minor performance improvements + contributed by Jeffrey Hobbs. [Bug: 1118] -Thu Jul 24 13:12:02 1997 Stephen Peters + * win/tkWinWm.c (Tk_WmCmd): Fixed bad code in tracing + suboption. [Bug: 1519] - * library/tkfbox.tcl: Changes to let tk_getOpenFile take a - `-multiple yes' argument and handle multi-file selections. + * library/tkfbox.tcl: Change to restore button text after an + action to avoid the sticky "Open" button in a save dialog. + [Bug: 1640] -Tue Jul 22 12:40:50 1997 Ian Lance Taylor + * library/entry.tcl: Fixed so selection is returned using the + -show character during cut and paste operations. [Bug: 1687] + +1999-04-5 - * win/Makefile.in (.c.o): Use CFLAGS. + * generic/tkInt.decls: + * generic/tkIntXlibDecls.h: + * generic/tkStubInit.c: + * xlib/xgc.c: + * xlib/X11/Xlib.h: + * xlib/X11/Xutil.h: Added more X functions to the Win & Mac stubs + tables. + +1999-04-05 -Sat Jul 12 11:28:22 MET DST 1997 Zsolt Koppany + * unix/configure.in: + * generic/tkCanvPs.c: Added configure test for pw_gecos field in + pwd to support OS/390. [Bug: 1724] - * generic/tkImgGIF.c - Patch from tk8.b2 in GetCode(). - * generic/tkImgPhoto.c - Purify UMR bug fix in AllocateColors(). +1999-04-02 -Wed Jul 9 14:43:57 1997 Ian Lance Taylor + * tests/text.test: + * generic/tkText.c: Fixed handling of Unicode in text searches. + The -count option was returning byte counts instead of character + counts. [Bug: 1056, 1148, 1666] - * generic/tkMain.c: Include winuser.h if _WIN32. - (Tk_Main): If _WIN32, call MessageBox on error. +1999-04-01 -Fri Jul 4 13:36:03 1997 Ian Lance Taylor + * generic/tk.decls: + * generic/tk.h: + * generic/tkStubInit.c: + * generic/tkWindow.c: + * unix/Makefile.in: + * win/makefile.vc: Tk now uses its own stub library to store + pointers to its own stubs table. - * win/tkWinImage.c (PutPixel): Correct yet another bug. + * doc/dde.n: (removed) + * doc/send.n: + * generic/tk.decls: + * tests/winSend.test: + * generic/tkPlatDecls.h: + * win/tkWinSend.c: Removed the DDE-based send and dde commands, + they were causing Tk to lock up when any window on the system was + not processing its message queue (more importantly, windows in Tcl + and Tk). The send command needs to be rewritten to prevent the + deadlock situation (soon). The dde command is being pushed into + its own package and will provide almost all of the capabilities + that send did before (using a "dde eval" command), not yet + completed. -Thu Jul 3 16:00:57 1997 Ian Lance Taylor +1999-03-31 - * win/tkWinImage.c (PutPixel): For a depth of 16 bits, convert a - 24 bit truecolor value into a 16 bit truecolor value. Correct - error in storing high byte. For a depth of 1 bit, correct error - in clearing bit. + * win/tkWinSend.c: Modified dde/send code to work properly on + Win95/Win98. String lengths are not returned properly by DDE, so + NULL terminate all strings going in and ignore the string length + coming back out. Do not destroy handles until all necessary work + on those handles (and child handles) is done. -Thu Jun 26 14:02:03 1997 Ian Lance Taylor +1999-03-30 - * win/Makefile.in (WINDRES): New variable. - (install-binaries): Don't install DLL here... - (install-libraries): ...install it here instead. - ($(TKDLL)): Depend upon and link with tkres.o. - ($(WISH)): Depend upon and link with wishres.o. - ($(TKTEST)): Likewise. - (tkres.o, wishres.o): New targets. - * win/tkWinX.c (TkWinGetTkModule): If __CYGWIN32__, use cygtkdll - as the DLL name. - * win/configure.in: Define and substitute WINDRES. - * win/configure: Rebuild. + * generic/tkWindow.c (Tk_DestroyWindow): Image handlers are now + finalized before the font subsystem since complex image handlers + may contain references to fonts (e.g. Tix compound images). + [Bug: 1603] -Tue Jun 24 11:42:06 1997 Tom Tromey +1999-03-29 - * library/palette.tcl (tkRecolorTree): Properly quote color name. - From Jeffrey Hobbs. + * doc/MeasureChar.3: + * doc/TextLayout.3: + * generic/tk.decls: + * generic/tkCanvText.c: + * generic/tkEntry.c: + * generic/tkFont.c: + * generic/tkListbox.c: + * generic/tkMessage.c: + * mac/tkMacFont.c: + * unix/tkUnixButton.c: + * unix/tkUnixFont.c: + * unix/tkUnixMenu.c: + * win/tkWinFont.c: + * win/tkWinMenu.c: Standardized text layout and font interfaces + so they are consistent with respect to byte versus character + oriented indices. The layout functions all manipulate character + oriented values while the lower level measurement functions all + operate on byte oriented values. This distinction was not clear + and so the functions were being used improperly in a number of + places. [Bug: 1053, 747, 749, 1646] -Mon Jun 23 10:15:56 1997 Ian Lance Taylor + * generic/tk.decls: Eliminated uses of C++ STL types string and + list from declarations. - * Makefile.in (install-binaries, install-libraries): New targets. + * generic/tkFont.c: Changes to named fonts were not being + propagated in some cases. [Bug: 1144] + + * xlib/X11/Xlib.h: + * generic/tkInt.decls: Added XParseColor to xlib stub + tables. [Bug: 1574] -Wed Jun 18 12:21:57 1997 Ian Lance Taylor + * doc/GetBitmap.3: + * generic/tkBitmap.c (BitmapInit): Eliminated use of Tk_Uid's in + bitmaps. Added a few CONST declarations. - * win/Makefile.in: Copy install, install-binaries, - install-libraries, and install-demos rules, and associated - variables from unix/Makefile.in, with appropriate adjustments. +1999-03-29 -Thu Jun 12 19:20:57 1997 Ian Lance Taylor + * unix/configure.in: + * unix/Makefile.in: + * win/makefile.vc: + * generic/tkDecls.h: + * generic/tkIntDecls.h: + * generic/tkIntPlatDecls.h: + * generic/tkPlatDecls.h: + * generic/tkIntXlibDecls.h: Removed stub functions. Always use the + Tcl stubs when building with --enable-shared. + - * win/Makefile.in (tkcyg.def): Don't export impure_ptr. +1999-03-26 -Tue Jun 10 19:16:39 1997 Stephen Peters + * generic/tkTextIndex.c: + * tests/testIndex.test: Avoid looking past the beginning of the + array storing data for the text widget (.t index end-2c). Added + test case to check for the bug. [Bug 991] + + * generic/tkConsole.c: Copy static strings into a Tcl_DString + before passing to Tcl_Eval, in case the compiler puts static + strings into read-only memory. - * unix/configure.in: Use a real replacement for memmove, instead - of using memcpy (which doesn't guarantee overlaps will copy - correctly). - * unix/configure: Rebuilt. - * unix/Makefile.in: Use replacement memmove if needed. - * compat/memmove.c: New file for replacing memmove. +1999-03-26 + + * unix/configure.in: + --nameble-shared is now the default and builds Tk as a shared + library; specify --disable-shared to build a static Tk library + and shell. -Mon Jun 9 16:26:13 1997 Ian Lance Taylor +1999-03-26 - * win/configure.in: Set TK_BUILD_INCLUDES. - * win/configure: Rebuild. + * library/menu.tcl: Fixed bug reported by Bryan Oakley in the + menubutton bindings. There was a false assumption that there was + always a menu attached to the button. [Bug 1116] -Fri Jun 6 23:43:34 1997 Ian Lance Taylor +1999-03-26 - Add support for building with cygwin32: - * win/Makefile.in: Rewrite completely based on makefile.vc. - * win/configure.in: Rewrite completely. - * win/configure: Rebuild. - * win/tkWin32Dll.c (_impure_ptr): Define if __CYGWIN32__. - (__imp_reent_data): Declare if __CYGWIN32__. - (DllMain): Initialize _impure_ptr if __CYGWIN32__. - * win/tkWinX.c (GetCurrentTime): Define as GetTickCount if - __CYGWIN32__. + * unix/configure.in: Removed --enable-tcl-stub. Linking Tk to Tcl + stubs is causing too many problems when linking executables like wish. + Until the Tk is a fully loadable extension, linking against the Tcl + stubs is not supported in Tk. -Thu May 22 15:49:40 1997 Ian Lance Taylor +1999-03-19 - * win/configure.in: Use win rather than CONFIGDIR. - * win/configure: Rebuild. + * generic/tkBitmap.c: + * generic/tkCursor.c: + * generic/tkGC.c: When creating hash tables that key off of XID + handles, make sure to pass TCL_ONE_WORD_KEYS. XIDs are guaranteed + to be 32bit numbers, although on some 64bit systems (including 64bit + Solaris 7) they are packed into a 64bit value where the upper 32bits + are zero. The normal method of sizeof(XID)/sizeof(int) causes the + hash table code to assume that the XID is a pointer to an array of + two ints, which it is not. Tk now supports 64bit Solaris 7. -Fri May 9 19:07:17 1997 Zsolt Koppany +1999-03-17 - * generic/tkWindow.c (GetScreen): Init metaModMask, altModMask - (from Purify). + * win/makefile.vc: + * generic/tk.h: Changed to use TCL_BETA_RELEASE macro, and fixed + so this works in rc files. + + * win/makefile.vc: + * win/makefile.bc: + * win/README: + * unix/configure.in: + * generic/tk.h: + * README: Updated version to 8.1b3. -Tue May 13 23:19:20 1997 Zsolt Koppany +1999-03-14 - * generic/tkText.c (ConfigureText): Bug fix from Ousterhout. + * unix/configure.in: Added missing stub related definitions. -Wed Apr 23 14:36:14 1997 Tom Tromey + * unix/Makefile.in: Install tkDecls.h in addition to tk.h. - * library/tkfbox.tcl: Incorporated version from Tk 8.0. + * generic/tkStubLib.c: Added flags to ensure we are using Tcl + stub macros. -Tue Mar 25 23:35:02 1997 Martin M. Hunt +1999-03-11 - * library/palette.tcl: Patch from kcorey@eng.sun.com - (Ken Corey) + * generic/tkInt.decls: Added reserved slot for XSetDashes for use + by the dash patch. -Tue Mar 18 16:01:05 1997 Martin M. Hunt +1999-03-10 - * generic/tkImgGIF.c: Fix GIF transparency. Patch from - nijtmans@nici.kun.nl + * xlib/xdraw.c: + * xlib/X11/Xlib.h: + * mac/tkMac.h: + * mac/tkMacInt.h: + * mac/tkMacPort.h: + * mac/tkMacXStubs.c: + * mac/tkMacAppInit.c: + * mac/tkMacCursor.c: + * win/makefile.vc: + * win/tkWin.h: + * win/tkWinInt.h: + * win/tkWinPort.h: + * win/winMain.c: + * generic/tk.h: + * generic/tkInt.h: + * generic/tk.decls: + * generic/tkInt.decls: + * generic/tkDecls.h: + * generic/tkPlatDecls.h: + * generic/tkIntDecls.h: + * generic/tkIntPlatDecls.h: + * generic/tkIntXlibDecls.h: + * generic/tkStubs.c: + * generic/tkPlatStubs.c: + * generic/tkIntStubs.c: + * generic/tkIntPlatStubs.c: + * generic/tkIntXlibStubs.c: + * generic/tkStubInit.c: + * generic/tkStubLib.c: + * generic/tkBind.c: + * generic/tkCmds.c: + * generic/tkConfig.c: + * generic/tkConsole.c: + * generic/tkCursor.c: + * generic/tkGrab.c: + * generic/tkImgPhoto.c: + * generic/tkMain.c: + * generic/tkMenu.c: + * generic/tkPointer.c: + * generic/tkTextDisp.c: + * generic/tkWindow.c: + * unix/tkUnixInt.h: + * unix/tkUnixPort.h: + * unix/Makefile.in: + * unix/configure.in: + * unix/tkConfig.sh.in: + * unix/tkUnix.c: + * unix/tkUnix3d.c: + * unix/tkUnixDraw.c: + * unix/tkUnixFont.c: + * unix/tkUnixMenubu.c: Stubs implementation for 8.1. Tk_Main() is + replaced with a macro which calls Tk_MainEx(). Tk can link to the Tcl + stubs library, wish links directly to Tcl and Tk. Use + --enable-tcl-stubs to link Tk to the Tcl stubs library (Unix), on + by default on Windows. Exported all public functions through the + stubs mechanism (see the *.decls files) and many of the internal + functions. Most of the changes dealt with shifting around the + function declarations in the header files. Mac code may not + compile, but it shouldn't take much work to fix this. + + * mac/tkMacMenu.c: Added dummy TkpMenuThreadInit for Mac to be + consistent with Unix and Windows versions. + +1999-03-08 -Thu Mar 13 10:42:01 1997 Tom Tromey + * win/tkWinWm.c: Toplevel class no longer shared between + threads. + + * win/tkWinX.c: Multiple threads no longer share the same + TkDisplay structure. Required because TkDisplay stores much + thread-specific data for a given thread. - * win/configure.in: Don't run AC_C_CROSS. - (AC_CONFIG_AUX_DIR): Look in srcdir. + * win/tkWinSend.c: Moved application instance handle out + out thread-local storage. DDE was failing to initialize + when the instance handles were different between threads. + + * win/makefile.vc: Added THREADDEFINES for building with + threads enabled. + + * generic/tkMenu.c: + * win/tkWinMenu.c: + * unix/tkUnixMenu.c: Added TkpMenuThreadInit for initializing + thread-specific Menu state. -Fri Mar 7 13:08:47 1997 Tom Tromey +1999-03-01 - * Updated to Tk 4.2p2. + * win/tkWinWm.c: + * win/tkWinPointer.c: + * win/tkWinInt.h: Fix "focus -force" for Windows. The Win32 API + function SetForegroundWindow() does not work unless the window + handle is a toplevel window (a Windows toplevel). The handle + being passed was a Tk toplevel, which is a child of the Windows + toplevel. -Thu Nov 21 10:07:02 1996 Tom Tromey +1999-02-26 - * generic/tkGrid.c (Tk_GridCmd): Applied fix suggested by Stephen - Uhler. + * win/cat.c: Remove this file, use the one in the Tcl source directory. - * library/menu.tcl: Applied patch from Ousterhout. + * win/makefile.vc: Remove the wishc.exe from the default targets. Add + a separate console-wish target to build it. The need for a + console-wish will go away soon, so we don't want to encourage its + use. -Mon Oct 14 12:17:11 1996 Tom Tromey +1999-02-25 - * Makefile.in (RUNTEST): Use srcdir, not SRC_DIR. - (tk-check): Ditto. - (check): Renamed from tk-check. + * win/tkWinWm.c: Properly initialize the tsdPtr->firstWindow field. + + * win/cat.c: Code for cat32.exe, copied from the Tcl sources. Required + in order to run the test suite from the makefile - * testsuite/config/default.exp (find_x_display): New proc. - (tk_start): Use find_x_display. + * win/winMain.c: Add main() for a console-based wishc.exe, which meant + adding code to disable the call to Tk_ConsoleInit(). + + * generic/tkConsole.c: Check the standard handles before creating the + new standard channels. This allows a windows app that has stdin, + stdout, or stderr to correctly connect to them. + + * generic/tkMain.c: Add a proper check for the interactive mode, since + the standard channels may actually be connected in windows mode or + even in the console-based wish. + + * win/makefile.vc: Add targets for wishc.exe (console-based wish) and + cat32.exe (for testing). Fix the test suite target so it can be run + from the makefile (which can happen since the standard handles have + been fixed). -Mon Aug 19 12:30:51 1996 Tom Tromey +1999-02-12 - * testsuite/config/default.exp, testsuite/tk.tests/tk-test.exp: - New files. + * generic/tkMenuButton.h: + * generic/tkMenuButton.c: + * mac/tkMacMenubutton.c: + * mac/tkMacDefault.h + * unix/tkUnixMenubu.c: Eliminated Tk_Uids used by -state option. + * unix/tkUnixDefault.h + * win/tkWinDefault.h + - * Makefile.in (EXPECT, RUNTESTFLAGS, RUNTEST): New variables. - (tk-check): New target. + * generic/tk.h: + * generic/tkScale.h: + * generic/tkScale.c: + * generic/tkWindow.c: + * unix/tkUnixScale.c: + * unix/tkUnixDefault.h: + * unix/tkWinDefault.h: + * mac/tkMacDefault.h: Objectified scale widget. - * tests/all: Look for tests in srcdir. - * tests/defs: Set srcdir if not already set. + * win/tkWinX.c: Removed Thread-specific data from process + initialization code that was stopping the Tk Dll from + loading. -Thu Aug 15 12:50:47 1996 Tom Tromey +1999-02-11 - * generic/tkArgv.c (defaultTable): Added -version. - (Tk_ParseArgv): Handle -version option. - * generic/tk.h (TK_ARGV_VERSION): New define. + * README: + * generic/tk.h: + * unix/configure.in: + * win/README: + * win/makefile.bc: + * win/makefile.vc: Updated version to 8.1b2. + + * unix/tkUnixSend.c: Fixed one more Tcl_*ObjVar instance. + +1999-02-04 -Mon Aug 5 10:47:09 1996 Tom Tromey + * Various cleanup related to the Tcl_Eval and Tcl_ObjSetVar + changes in Tcl. + + INTEGRATED PATCHES FROM 8.0.5b2: + + * win/tkWinMenu.c (TkpDestroyMenu): Changed so modalMenuPtr is + cleared when it is being destroyed. - * Makefile.in (configure): Don't depend on configure.in. - (config.status): Depend on configure. + * generic/tkImgPhoto.c: Changed so color tables are freed + immediately instead of being delayed. This ensures that color + tables are properly disposed at process exit. -Wed Jun 26 12:51:43 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + * library/prolog.ps: Changed string that determines font height to + include European character with an umlaut. - * configure.in (AC_PREREQ): autoconf 2.5 or higher. - * configure: Rebuilt. + * generic/tkImgBmap.c (ImgBmapConfigureInstance): If an image + mask changed but ended up with the same XID, the GC failed to be + updated and so the new mask was not used. [Bug: 970] -Mon May 6 09:45:20 1996 Tom Tromey + * generic/tkFocus.c (SetFocus): Changed so focus window is always + set if -force is specified. This fixes the problem on Windows + where Tk does not activate the window if it already has focus. - * generic/tkMain.c (Tk_Main): Exit after printing version number. + * generic/tkConsole.c: Fixed so errors in console eval are + reported properly. Eliminated duplicate result messages. [Bug: 973] -Tue Apr 30 13:40:04 1996 Tom Tromey + * win/tkWinWm.c: Changed so windows that aren't resizable don't + have resize handles and the zoom box is disabled. - * generic/tkMain.c (Tk_Main): Removed "-inet-1.0". + * win/tkWinInt.h: + * win/tkWinPointer.c: Changed to cancel the mouse timer when a + user initiated move/resize loop begins. -Mon Apr 29 17:43:15 1996 Tom Tromey + * unix/configure.in: TK_LD_SEARCH_FLAGS was set incorrectly if + SHLIB_LD_LIBS='${LIBS}', and shared linking is performed through + the C compiler. Systems affected are Linux, MP-RAS and NEXTSTEP, + but also with gcc on many more systems. [Bug: 908] - * generic/tkMain.c (argTable): Added -version. - (Tk_Main): Handle -version. + * win/makefile.vc: First stab at install target. Fixed quoting so + paths with spaces work. + + * tests/main.test: + * tests/unixWm.test: Better cleanup of temporary files. + + * mac/tkMacAppInit.c: + * generic/tkTest.c: + * generic/tkAppInit.c: + * win/winMain.c: Changed some EXTERN declarations to extern + since they are not defining exported interfaces. This avoids + generating useless declspec() attributes and makes the windows + makefile simpler. -Thu Mar 7 10:08:57 1996 Tom Tromey + * library/menu.tcl (tkMenuFind): Changed so keyboard shortcuts + will only be found in the current toplevel. Previously, they + might be found in menus attached to other toplevels that might not + even be mapped. [Bug: 924] - * Makefile.in (config.status): Depend on nothing. + * generic/tkCanvLine.c: Changed to treat zero width lines like + they have width 1 for purposes of selection. [Bug: 925] -Wed Mar 6 19:07:38 1996 Tom Tromey + * win/tkWinFont.c (Tk_MeasureChars): Added a workaround for a bug + in GetTextExtentExPoint on Win NT 4.0/Japanese. [Bug: 1006] - * Makefile.in (Makefile): Removed redundant target. + * unix/tkUnixSend.c (Tk_SetAppName): Fixed uninitialized memory + access bug. [Bug: 919] -Thu Feb 29 21:32:44 1996 Fred Fish +1999-1-28 - * Makefile.in (srcdir): Add macro. - (configure): Run autoconf in source dir, not build dir. + * generic/tkGrid.c: Fixed bug in "grid forget" that failed to cancel + pending idle handlers, resulting in a crash in a few odd cases. -Thu Feb 29 14:59:03 1996 Tom Tromey +1999-01-06 - * Makefile.in (Makefile): New rule. - (config.status): New rule. + * generic/tk.h, generic/tkGet.c, generic/tkConfig.c, + * generic/tkOldConfig.c, generic/tkEntry.c, generic/tkMenubutton.c, + * generic/tkMenubutton.h, generic/tkScale.c, generic/tkScale.h, + * generic/tkTextDisplay.c, generic/tkText.c, unix/tkUnixMenubu.c, + * unix/tkUnixScale.c, mac/tkMacMenu.c, mac/tkMacMenubutton.c, + + Removed global Tk_Uids dealing with "-state" configuration option + and added new TK_CONFIG_STATE configSpec that doesn't use + Tk_Uids. -Wed Jan 24 09:42:29 1996 Tom Tromey +1998-12-11 === Tk 8.1b1 Release === + +1998-12-11 - * Makefile.in: Replaced realclean with maintainer-clean. + * generic/tkMain.c (Tk_Main): Fixed improper command line encoding + handling. -Fri Jan 12 11:00:06 1996 Tom Tromey +1998-12-08 - * library/tclIndex: Removed all references to console.tcl. - (Hack). + * win/tkWinClipboard.c (TkSelGetSelection, TkWinClipboardRender): + Changed to handle multibyte characters properly. [Bug: 935] - * library/console.tcl (tkConsoleInvoke): Use "interp eval" with - history command, not nonexistent "interp record" command. - (tkConsoleHistory, tkConsolePrompt): Include pathname argument to - "interp eval". +1998-12-07 -Wed Jan 10 12:49:00 1996 Tom Tromey + * library/xmfbox.tcl (tkMotifFDialog_Create): In the cached case, + the data array was not being initialized with the correct set of + widgets. - * configure.in, configure, Makefile.in, README.configure: New - files. +1998-12-4 - * Tk: Updated to Tk4.1a2. Entries after this line mostly likely - apply to files in some subdirectory. + * Changed patchLevel to 8.1b1 -Tue Dec 19 18:32:36 1995 Brendan Kehoe + * generic/tkMenu.c (ConfigureMenuCloneEntries): The -menu configuration + option was being incorrectly specified as just "menu". - * Makefile.in (check, installcheck): New null rules. +1998-11-30 -Wed Oct 25 20:12:01 1995 Brendan Kehoe + * generic/tkButton.c (ConfigureButton): The error result was + getting lost when restoring configuration options. [Bug: 619] - * Makefile.in (prefix, exec_prefix): Set to @prefix@ and - @exec_prefix@, so configure can substitute them properly. +1998-11-25 -Tue Oct 24 18:49:59 1995 Jason Molenda (crash@phydeaux.cygnus.com) + * unix/tkUnixFont.c (GetFontAttributes): Initialize an unspecified + family to an empty string. + (FontMapLoadPage): if the font included characters below 32, the + index computation was incorrect because the range was shifted up + to 32. + (CreateClosestFont): check for empty locale as well as NULL. - * Makefile.in (X11_INCLUDES, X11_LIB_SWITCHES): switch to - X11_CFLAGS, X11_LDFLAGS and X11_LIBS. - (CC_SWITCHES): Use X11_CFLAGS. + * generic/tkFont.c (TkFontParseXLFD): initialize charset to + iso8859-1 if no charset is specified. - * configure.in: Statically link X libraries on Solaris, SunOS, - and HPUX. + * mac/tkMacHLEvents.c (OdocHandler): added conversion from + external string to UTF [Bug: 869] -Tue Oct 10 14:33:17 1995 Stu Grossman (grossman@cygnus.com) + * integrated tk8.0.4 changes. + + * generic/tkBind.c: fixed deletion order bug where a crash would + result if a binding deleted "." - * tkConfig.c (Tk_ConfigureInfo), tkSelect.c (HandleTclCommand - LostSelection): Use free() instead of TCL_DYNAMIC in - interp->freeProc to prevent crashes. Apparantly tcl7.4 changed - the result protocol around slightly. + * generic/tkMenu.c (MenuWidgetObjCmd): disabled menu entries were + getting reenabled whenever the mouse passed over the entry [Bug: 860] -Sat Sep 30 09:39:11 1995 Jason Molenda (crash@phydeaux.cygnus.com) + * unix/tkUnixMenu.c (TkpComputeStandardMenuGeometry): hidemargin + option was not honored properly in menus [Bug: 859] - * configure.in: Upgraded to autoconf v2, removed cruft which did a poor - job of finding X location in favor of AC_PATH_X. - * configure: Regenerated. +1998-11-24 -Sun Aug 20 00:15:51 1995 Jason Molenda (crash@phydeaux.cygnus.com) + * tkMacMenu.c, tkUnixMenu.c, tkWinMenu.c, tkMenuDraw.c, tkMenu.h, + * tkMenu.c: Backed out the previous fix for bug 620 and + eliminated a bunch of code that created unnecessary objects. + Changed back to using internal types instead of objects for many + configuration options. There are many more fixes like this that + could be made, but some require a little restructuring of the + code. In any case the leaks are fixed and there is a lot less + allocation happening. [Bug: 620] - * tkMain.c: make tcl_RcFileName defn an extern so it doesn't - conflict with the one in the new tcl/tclBasic.c. +1998-11-19 -Mon Jun 12 17:09:28 1995 Stu Grossman (grossman@cygnus.com) + * tkMenu.c (DestroyMenuEntry): fixed memory leaks [Bug: 620] - * configure: Ignore --cache-file option instead of bombing out. - -Mon Dec 12 12:17:16 1994 Stu Grossman (grossman@cygnus.com) - - * tkConfig.h: Don't use prototype for select. This allows HPUX - 8.x build. - -Tue Oct 18 12:41:49 1994 Jim Wilson (wilson@chestnut.cygnus.com) + * tkWinX.c (GetTranslatedKey): fixed bad code merge - * Makefile.in (CC_SWITCHES): Add X11_INCLUDE_FLAGS. + * tkWinWm.c, tkWinMenu.c: fixed titles and menus so they properly + display Unicode [Bug: 819] diff --git a/tk/README b/tk/README index 15233d6471c..45c0ea1d2d7 100644 --- a/tk/README +++ b/tk/README @@ -1,9 +1,9 @@ README: Tk - This is the Tk 8.3.2 source distribution. - You can get any release of Tcl from: - http://dev.scriptics.com/registration/.html + This is the Tk 8.4.0 source distribution. Tcl/Tk is also available through NetCVS: - http://dev.scriptics.com/software/tcltk/netcvs.html + http://tcl.sourceforge.net/ + You can get any source release of Tcl from the file distributions + link at the above URL. RCS: @(#) $Id$ @@ -14,18 +14,22 @@ 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.3 Web page at +this release, see the Tcl/Tk 8.4 Web page at - http://dev.scriptics.com/software/tcltk/8.3.html + http://www.tcl.tk/software/tcltk/8.4.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 as a -service to the Tcl community by Scriptics Corporation. -The official home for Tcl/Tk is on the Scriptics Web site: +Tk is maintained, enhanced, and distributed freely by members of the +Tcl community. The home for Tcl/Tk sources and bug database is on +SourceForge at: - http://dev.scriptics.com + http://tcl.sourceforge.net/ + +with the Tcl Developer Xchange at: + + http://www.tcl.tk/ Tk is a freely available open source package. You can do virtually anything you like with it, such as modifying it, redistributing it, @@ -39,5 +43,3 @@ 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/tk/changes b/tk/changes index 21e10a07dcf..8d8da5bf953 100644 --- a/tk/changes +++ b/tk/changes @@ -4849,6 +4849,9 @@ then widget was destroyed (hobbs) 2000-03-02 (feature enhancement) added %V substitution to entry widget validation to clarify type of validation occuring (hobbs) +2000-03-07 (feature enhancement) added -disabledforeground/-state to labels +(melski) + 2000-03-29 (config enhancement) improved build support for gcc/mingw on Windows (nijtmans, hobbs) and added RPM target (melski) @@ -4900,6 +4903,49 @@ redraws (hobbs) 2000-04 more docs for public APIs (melski) --- Released 8.3.1, April 26, 2000 --- See ChangeLog for details --- +2000-04 (doc updates) extended, updated docs (melski) + +2000-05-09 (feature change) removed WS_EX_TOOLWINDOW style bit for +transient windows on Windows platforms, so that transients have +full-size titlebars (melski) + +2000-05-09 (bug fix) fixed calling of takeFocus proc (nemethi) + +2000-05-11 (bug fix) corrected handling of 3DBorder, Cursor and Color +objects on multiple screens (hobbs) + +2000-05-12 (feature enhancement) improved support for chars in 0-255 +range for bitmap ANSI fonts (spjuth, hobbs) + +2000-05-12 (widget enhancement) added support for -repeatdelay, +-repeatinterval for command buttons; and -compound (image and text +simultaneously) for labels, check-, radio-, and command buttons (melski) + +2000-05-14 (widget change) added "readonly" state for entries and +changed behavior of "disabled" entries; added -readonlybackground +option for entries (melski) +*** THIS IS A BACKWARDS INCOMPATIBLE BEHAVIOR CHANGE *** + +2000-05-15 (feature enhancement) added [image inuse] command (melski) + +2000-05-15 (feature enhancement) added -nice option to [bell] command (duncan) + +2000-05-17 (widget enhancement) added -overrelief option for +check/radio/buttons (melski) + +2000-05-26 (feature change) added support for new syntax in +Tk_OptionSpec tables; if the database name for an option contains an +embedded "." it indicates that the name contains an overriding window +class specifier in addition to the database name, which allows widgets +to perform queries for certain options as if they were options for a +different widget class (melski) + +2000-05-28 (new widget) added spinbox widget (hobbs) + +2000-05-31 (feature change) replaced bgerror dialog with a new and +improved one (fellows, melski) + +--- Released 8.4a1, June 6, 2000 --- See ChangeLog for details --- 2000-05-15 (bug fix) changed wm deiconify from using idle callback to calling restack and focus code immediately. (hobbs) @@ -4926,3 +4972,343 @@ and corrected search combining -regexp and -nocase. (melski) borders on multiple screens simultaneously. (hobbs, hipp) --- Released 8.3.2, August 9, 2000 --- See ChangeLog for details --- + +2000-06-15 (new feature) [tk_getOpenFile ... -multiple] (melski) + +2000-06-29 (new feature) localization support in Tk dialogs (duperval, +melski, et al) + +200-07-28 (new feature) -state option for listbox, better native color +defaults (melski) + +2000-08 (feature rewrites) Tcl_Obj'ified clipboard, message, tkwait, +bindtags, grab. place, selection commands (melski) + +2000-08-24 (new feature) More correct GNU configure support (no more +--enable-gcc) (dejong) + *** POTENTIAL INCOMPATIBILITY *** + +2000-08-29 (bug fix) Corrected Windows menu indicator drawing (oberhumer) + +2000-09-01 (bug fix) Added tkPlatDecls.h to default install (melski) + +2000-09-17 (new feature) Added TK_OPTION_CUSTOM type, similar to +TK_CONFIG_CUSTOM (melski) + +2000-09-29 (bug fix) Several fixes for multi-display uses of Tk (hipp, hobbs) + +2000-10-05 (new feature) Tk_CreateAnonymousWindow API to create anonymous +Tk windows controllable from C (melski) + +2000-10-27 (new default behavior) [tk useinputmethods 1] is the default +in tk.tcl, for users of XIM and "dead" keys (hobbs) + +2000-10-30 Improved support for static builds on Windows (gravereaux) + + * Added support for mingw (gcc on Windows), AIX-5 and Win64 builds + (dejong, hobbs) + + * Improved error checking in Windows native dialogs (melski, hobbs) + +--- Released 8.4a2, November 3, 2000 --- See ChangeLog for details --- + +2001-04-04 (build improvements) redid Mac build structure (steffen) +Corrected IRIX-5* configure (english). Added support for AIX-5 (hobbs). +Added support for Win64 (hobbs). + +2001-04-04 (doc fixes) numerous doc corrections and clarifications. +Update of READMEs. + +2001-04-04 (bug fix) corrected reseting of service mode to only occur when +it was set (hedin, hobbs) + +2001-04-02 (bug fix) Improved tests on Windows for correctness. +Checked for menu deletion before calling associated menu entry command. +Fixed listbox, canvas and entry destruction to be more aware of current +widget activity. (hobbs) + +2001-03-30 (feature enhancement) added support for changing IME on the fly +in Windows (2000) (lam) +(bug fix) handled the error case where a valid-looking but invalid +identifier could be passed in certain event generate options causing a +crash (hobbs) + +2001-03-29 (bug fix) corrected handling of drag-selection (dejong) + +2001-01-02 (feature enhancement) added Windows icon support in wm +iconbitmap (darley) + +2000-10-27 (feature enhancement) made [tk useinputmethods 1] the default +for Tk (hobbs) + +2000-10-18 (bug fix) Corrected rendering of 1-pixel wide stippled lines on +Windows. Correct use of active- and disabledwidth values for displaying +lines. Enhanced error handling in Windows native dialogs (melski) + +2000-09-29 (bug fix) corrected BadMatch errors when using Tk on multiple +screens (hipp) + +2000-08-18 (feature enhancement) Removed redundant call to DitherInstance +(melski) + +--- Released 8.3.3, April 6, 2001 --- See ChangeLog for details --- + +2000-11-21 (new feature)[TIP 5] Tk_ClassProcs, Tk_SetClassProcs API (melski) + +2000-12-13 (performance enhancement)[403327] Tcl_Objs of type "double" +are recognized in SetMMFromAny to speed up canvas coord calculations (hobbs) + +2001-01-02 (new feature)[TIP 8] [wn iconbitmap -default] on Windows (darley) + +2001-02-12 (new feature)[TIP #21] asymmetric padding in the pack and grid +geometry managers (hipp) + +2001-05-21 (new feature)[TIP #11], -compound for [menubutton] widget (helfter) + +2001-06-03 (bug fix) corrected support for is10646 fonts on Unix, added a +ucs-2be encoding (welch) + +2001-07-02 (bug fix) allowed tkwin to be Tcl_EventuallyFree'd in +Tk_DestroyWindow so other widgets could register their use of it. Updated +entry and listbox widgets to use this, correcting potential crashes. (hobbs) + +2001-08-01 (interface rewrite)[TIP 44] moved all private tk[A-Z]* commands and +variables into the ::tk:: namespace (porter) + *** POTENTIAL INCOMPATIBILITY *** + + * overhaul of configure scripts for cleaner standard support and support + of mingw gcc on Windows. (mdejong) + + * improved tests to better handle results on variant systems (hobbs) + + * correct several minor Purify complaints (hobbs) + +--- Released 8.4a3, August 6, 2000 --- See ChangeLog for details --- + +2001-08-06 (new feature) added GNU (HURD) build support. (brinkman) + +2001-08-23 (new feature) added QNX-6 build support. (loverso) + +2001-08-24 (bug fix) correct several possible free memory reads and array +bounds read errors reported by purify. (hobbs) + +2001-08-27 (new feature) added call to Tcl_SetMainLoop which enables Tk to +be loaded interactively into tclsh and have the event loop kick in +correctly. (hobbs) + +2001-08-28 (bug fix) fixed tk_chooseDirectory crash on Win95. (baker) + +2001-08-28 (bug fix) removed 2 second 'raise' delay seen by some Unix +window managers. (hobbs, baker) + +2001-09-14 (bug fix) fixed memory leaks that occured if errors were +thrown while initializing the channel for an image. (darley) + +2001-09-20 (new feature) --enable-64bit support was added for HP 11 when +using the native compiler. + +2001-10-03 (new feature) finalized Win64 support with latest RC1 release +and SDK. (hobbs, stacy) + +2001-10-04 (new feature) added enhanced bgerror dialog from Hipp. (hobbs) + +2001-10-09 (new feature) added brace/quote matching and file/path/var +expansion to the Win/Mac console. (hobbs) + +2001-10-17 (bug fix) fixed file filtering in the motif file dialog (nelson) + +2001-10-17 (bug fix) updated Mac build support. (steffen) + +--- Released 8.3.4, October 19, 2001 --- See ChangeLog for details --- + +2001-08-14 (bug fix)[450545] Tk's Tcl_ObjTypes now registered (fellows) + +2001-08-20 (performance enhancement) internal use of a "window" Tcl_ObjType +(fellows) + +2001-08-20 (performance enhancement) Obj-ified [grid] and [pack] (spjuth) + +2001-09-26 (new feature)[TIP 18] add labels to frames, update geometry +managers (spjuth) + +2001-09-30 (new feature)[TIP 37] [grid {row|column}configure -uniform] (spjuth) + +2001-10-12 (new feature)[TIP 63] [$menu add ... -compound] (helfter) + +2001-10-18 (build improvement) no more warnings about building with +thread-enabled Tcl (hobbs) + +2001-11-10 (build improvement) new make target 'make gdb' (dejong) + +2001-11-12 (new feature)[TIP 26] simple undo/redo in text widget (callewaert) + +2001-11-12 (build improvement) revitalized makefile.vc (gravereaux) + +2001-11-17 (visual change) default button size on Windows changed to +conform to Windows style (hobbs) + **** POTENTIAL VISUAL INCOMPATABILITY **** + +2001-12-03 (new feature)[TIP 74] [wm stackorder] (dejong, steffen) + +2001-12 (new feature) more use of Unicode in native widgets on Windows (hobbs) + +2001-12-18 (bug fix)[413735] event-click-drag-1.2 test failure (porter) + +2001-12-28 (new feature) On Windows, buttons accept negative widths, meaning +minimum size, enabling native L&F (hobbs) + +2002-01 (bug fix) updates for CONST-ification in Tcl API, notably +Tcl_ParseArgv. Use -DUSE_NON_CONST to suppress source incompatibility + **** POTENTIAL INCOMPATABILITY **** + +2002-01-31 (bug fix)[508988] logic error in menu cloning (helfter) + +2002-02-01 (new feature)[TIP 14] [$photo transparency] (fellows) + +2002-02-01 (bug fix)[511956] C99 spec: avoid 'bool' as a variable name (hobbs) + +2002-02-19 (bug fix) updates to image code calls of Tcl_Seek/Tcl_Tell to +address TIP 72 changes (64-bit) in Tcl (fellows) + +2002-02-21 (new widget)[TIP 41] added [panedwindow] (hobbs) + +2002-02-22 (new feature) 64-bit support for xlc compiler on AIX-4 (hobbs) + +2002-02-25 (bug fix)[503772] blinking cursor fix in [text] (hobbs) + +2002-02-25 (bug fix)[503613] [listbox] handling of invalid listvar (hobbs) + +2002-02-25 (feature change)[493145] mirror B2 bindings to B3 on Windows (hobbs) + + * (updated demos) many updates to show new features (fellows) + +--- Released 8.4a4, March 5, 2002 --- See ChangeLog for details --- + +2002-03-20 (feature change)[TIP 27][532644] Constness changes (porter) + +2002-03-21 (bug fix)[528441] Change in optimization flags for windows +(gravereaux) + +2002-04-08 (bug fix) MSL stdin/out fixes prevent crash on exit (steffen) + +2002-04-12 (bug fix) Centralized closing of display, mem-leak fixes (hobbs) + +2002-04-22 (bug fix)[223739] More robust FP comparisons for odd +architectures (fellows) + +2002-04-22 (bug fix)[541999] Fixed posible overun of 16-bit size limit +of X windows in drawchars (hobbs,bonfield) + +2002-04-22 (bug fix)[541849] ButtonLeave implementation corrected (hobbs) + +2002-04-24 (new feature) TCLTK_NO_LIBRARY_TEXT_RESOURCES check added, +allowing disable of inclusion of tk lib into resources (steffen) + +2002-05-07 (bug fix)[553208] Makefile/Win fix (TCLDIR, INSTALLDIR +forward slash trouble resolved) (gravereaux) + +2002-05-20 (bug fix) msgcat added to resources, fixed setup of bindings +on startup (steffen, porter) + +2002-05-21 (bug fix) Build system fix, SC_ENABLE_SHARED before +SC_CONFIG_CFLAGS for usage for SHARED_BUILD (dejong) + +2002-05-26 (bug fix)[548765] Fixed -value "" redraw error for variable +created by radiobutton (spjuth) + +2002-05-27 (feature change) [wm transient .t .t] now raises an error (dejong) + *** POTENTIAL INCOMPATIBILITY *** + +2002-06-10 (new feature)[566605] Utilities for -underline, ampersand magic +(kovalenko) + +2002-06-12 (feature change) A transient toplevel now mirrors state changes +in the master. (dejong) + *** POTENTIAL INCOMPATIBILITY *** + +2002-06-13 (bug fix) Fixed handling of cursor specs across platforms to +be consistent. (fellows) + +2002-06-14 (new feature) [TIP 98] Enhanced photo compositing (fellows) + *** POTENTIAL INCOMPATIBILITY *** + +2002-06-14 (bug fix) Removed references to matherr (kupries) + +2002-06-14 (new feature) [TIP 47] Reorganized Tk to allow usage in writing +an X wm (english) + +2002-06-14 (new feature) [TIP 84] Full motion events upon request (hobbs) + +2002-06-17 (new feature) [TIP 82] -offrelief option for check/radiobutton +(hipp) + +2002-06-17 (enhancement) Added msg catalog for UK English. (porter) + +2002-06-17 (new feature) [TIP 96] Added caret handling (hobbs) + +2002-06-19 (new feature) [TIP 48] Added style engine (bonnet) + +2002-06-19 (bug fix)[570902] Reorganized Tk shutdown to work around bugs in +X (dejong) + +2002-06-20 (new feature) [TIP 94] Added -activestyle for [listbox] (hobbs) + +2002-06-21 (new feature) [TIP 104] generalized text undo/redo (callewart, +hobbs) + +2002-06-22 (new feature) [TIP 95] Added [wm attributes] command (hobbs) + +2002-06-22 (new feature) [TIP 93] enhanced get/delete to accept accept +multiple range pairs (hobbs) + +--- Released 8.4b1, July 5, 2002 --- See ChangeLog for details --- + +2002-07-11 (bug fix) some memory allocation failures now result in + error messages rather than panic (fellows) + +2002-07-15 (platform support) Borland makefile on Windows (gravereaux,giese) + +2002-07-16 (bug fix)[220800,581627] icon reading (darley) + +2002-07-19 (bug fix) Postscript generation on Win2K (hipp) + +2002-07-22 (bug fix)[570764,568278] transient windows (dejong) + +2002-07-24 (bug fix)[581560] canvas memory management (hobbs) + +2002-07-24 (bug fix)[584691] focus ring on compound button (hobbs) + +2002-07-25 (feature enhancement)[564521] Obj-ified [wm] (spjuth) + +2002-08-04 (new feature)[589853][TIP 27] Tk interfaces are now fully + CONST-ified. Use the symbols USE_NON_CONST or USE_COMPAT_CONST + to select interfaces with fewer changes. + *** POTENTIAL INCOMPATIBILITY *** + +2002-08-07 (bug fix)[578654] bezier curves on canvas (hobbs) + +2002-08-07 (platform support)[468139] native directory browser on Win (hobbs) + +2002-08-07 (bug fix)[467524] fixed -from handling for gifs (obermeier) + +2002-08-08 (bug fix)[592201] wm transient panic (english,dejong) + +Rewrote Tk test suite to use tcltest package. + +--- Released 8.4b2, August 9, 2002 --- See ChangeLog for details --- + +2002-08-20 (bug fix) tk.h checks for matching tcl.h version (porter) + +2002-08-27 (bug fix)[582457] toolbar button bindings (hipp) + +2002-08-31 (platform support)[602770] Mac OS X / Aqua port (steffen) + +2002-09-02 (bug fix)[565485] button height on windows (hobbs) + +2002-09-02 (new feature)[TIP 108] new comand [tk windowingsystem] (steffen) + +2002-09-02 (new feature)[TIP 107][601518] [raise] is non-blocking (english) + +2002-09-02 (platfrom support) 64-bit compile on HP-11 (martin) + +--- Released 8.4.0, September 10, 2002 --- See ChangeLog for details --- diff --git a/tk/compat/limits.h b/tk/compat/limits.h index cdeea13d40b..9487dac2200 100644 --- a/tk/compat/limits.h +++ b/tk/compat/limits.h @@ -22,4 +22,3 @@ #define INT_MAX 0x7fffffff #define SHRT_MIN 0x8000 #define SHRT_MAX 0x7fff - diff --git a/tk/compat/stdlib.h b/tk/compat/stdlib.h index 908d1fae288..45f39551de6 100644 --- a/tk/compat/stdlib.h +++ b/tk/compat/stdlib.h @@ -43,4 +43,3 @@ extern unsigned long strtoul _ANSI_ARGS_((CONST char *string, char **endPtr, int base)); #endif /* _STDLIB */ - diff --git a/tk/compat/unistd.h b/tk/compat/unistd.h index 1eb01cae482..1a13f585e63 100644 --- a/tk/compat/unistd.h +++ b/tk/compat/unistd.h @@ -82,4 +82,3 @@ extern int vfork _ANSI_ARGS_((void)); #endif /* _UNISTD */ - diff --git a/tk/doc/3DBorder.3 b/tk/doc/3DBorder.3 index 34482f08c08..e57dfef0cff 100644 --- a/tk/doc/3DBorder.3 +++ b/tk/doc/3DBorder.3 @@ -48,7 +48,7 @@ void void \fBTk_SetBackgroundFromBorder(\fItkwin, border\fB)\fR .sp -char * +CONST char * \fBTk_NameOf3DBorder(\fIborder\fB)\fR .sp XColor * @@ -303,4 +303,3 @@ or \fBTk_Get3DBorder\fR. .SH KEYWORDS 3D, background, border, color, depressed, illumination, object, polygon, raised, shadow, three-dimensional effect - diff --git a/tk/doc/AddOption.3 b/tk/doc/AddOption.3 index 4aadf526a62..93a482e4380 100644 --- a/tk/doc/AddOption.3 +++ b/tk/doc/AddOption.3 @@ -19,9 +19,9 @@ void .SH ARGUMENTS .AP Tk_Window tkwin in Token for window. -.AP char *name in +.AP "CONST char" *name in Multi-element name of option. -.AP char *value in +.AP "CONST char" *value in Value of option. .AP int priority in Overall priority level to use for option. diff --git a/tk/doc/BindTable.3 b/tk/doc/BindTable.3 index bbfa74b41de..b5e78748e62 100644 --- a/tk/doc/BindTable.3 +++ b/tk/doc/BindTable.3 @@ -27,7 +27,7 @@ unsigned long int \fBTk_DeleteBinding(\fIinterp, bindingTable, object, eventString\fB)\fR .sp -char * +CONST char * \fBTk_GetBinding(\fIinterp, bindingTable, object, eventString\fB)\fR .sp \fBTk_GetAllBindings(\fIinterp, bindingTable, object\fB)\fR @@ -45,7 +45,7 @@ Token for binding table; must have been returned by some previous call to \fBTk_CreateBindingTable\fR. .AP ClientData object in Identifies object with which binding is associated. -.AP char *eventString in +.AP "CONST char" *eventString in String describing event sequence. .AP char *script in Tcl script to invoke when binding triggers. @@ -155,4 +155,3 @@ described in the documentation for \fBbind\fR. .SH KEYWORDS binding, event, object, script - diff --git a/tk/doc/CanvPsY.3 b/tk/doc/CanvPsY.3 index 3901af5dcf5..fda70a767e8 100644 --- a/tk/doc/CanvPsY.3 +++ b/tk/doc/CanvPsY.3 @@ -7,7 +7,7 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH Tk_CanvasPsY 3 4.0 Tk "Tk Library Procedures" +.TH Tk_CanvasPs 3 4.0 Tk "Tk Library Procedures" .BS .SH NAME Tk_CanvasPsY, Tk_CanvasPsBitmap, Tk_CanvasPsColor, Tk_CanvasPsFont, Tk_CanvasPsPath, Tk_CanvasPsStipple \- utility procedures for generating Postscript for canvases @@ -25,14 +25,14 @@ int \fBTk_CanvasPsColor\fR(\fIinterp, canvas, colorPtr\fR) .sp int -\fBTk_CanvasPsFont\fR(\fIinterp, canvas, fontStructPtr\fR) +\fBTk_CanvasPsFont\fR(\fIinterp, canvas, tkFont\fR) .sp \fBTk_CanvasPsPath\fR(\fIinterp, canvas, coordPtr, numPoints\fR) .sp int \fBTk_CanvasPsStipple\fR(\fIinterp, canvas, bitmap\fR) .SH ARGUMENTS -.AS "unsigned int" *fontStructPtr +.AS "unsigned int" "numPoints" .AP Tk_Canvas canvas in A token that identifies a canvas widget for which Postscript is being generated. @@ -53,7 +53,7 @@ Width of region of bitmap to output, in pixels. Height of region of bitmap to output, in pixels. .AP XColor *colorPtr in Information about color value to set in Postscript. -.AP XFontStruct *fontStructPtr in +.AP Tk_Font tkFont in Font for which Postscript is to be generated. .AP double *coordPtr in Pointer to an array of coordinates for one or more @@ -97,7 +97,7 @@ TCL_OK unless an error occurs, in which case TCL_ERROR is returned and \fIinterp->result\fR is overwritten with an error message. .PP \fBTk_CanvasPsFont\fR generates Postscript that sets the current font -to match \fIfontStructPtr\fR as closely as possible. +to match \fItkFont\fR as closely as possible. \fBTk_CanvasPsFont\fR takes into account any font map specified in the \fBpostscript\fR command, and it does the best it can at mapping X fonts to Postscript fonts. @@ -120,4 +120,3 @@ returned, unless an error occurs, in which case TCL_ERROR is returned and .SH KEYWORDS bitmap, canvas, color, font, path, Postscript, stipple - diff --git a/tk/doc/CanvTkwin.3 b/tk/doc/CanvTkwin.3 index a35a0a5fc7c..7a214228330 100644 --- a/tk/doc/CanvTkwin.3 +++ b/tk/doc/CanvTkwin.3 @@ -38,7 +38,7 @@ Tk_OptionPrintProc *\fBTk_CanvasTagsPrintProc\fR; A token that identifies a canvas widget. .AP Tcl_Interp *interp in/out Interpreter to use for error reporting. -.AP char *string in +.AP "CONST char" *string in Textual description of a canvas coordinate. .AP double *doublePtr out Points to place to store a converted coordinate. @@ -159,4 +159,3 @@ static Tk_ConfigSpec configSpecs[] = { .SH KEYWORDS canvas, focus, item type, redisplay, selection, type manager - diff --git a/tk/doc/CanvTxtInfo.3 b/tk/doc/CanvTxtInfo.3 index 5eafcf565af..81d069a52dc 100644 --- a/tk/doc/CanvTxtInfo.3 +++ b/tk/doc/CanvTxtInfo.3 @@ -102,4 +102,3 @@ selection. .SH KEYWORDS canvas, focus, insertion cursor, selection, selection anchor, text - diff --git a/tk/doc/Clipboard.3 b/tk/doc/Clipboard.3 index 573bd90d96e..612c17ae0dc 100644 --- a/tk/doc/Clipboard.3 +++ b/tk/doc/Clipboard.3 @@ -78,4 +78,3 @@ any calling function should take care to be reentrant at the point .SH KEYWORDS append, clipboard, clear, format, type - diff --git a/tk/doc/ClrSelect.3 b/tk/doc/ClrSelect.3 index b40c4e56ddc..1de0c1887b0 100644 --- a/tk/doc/ClrSelect.3 +++ b/tk/doc/ClrSelect.3 @@ -40,4 +40,3 @@ procedure has no effect. .SH KEYWORDS clear, selection - diff --git a/tk/doc/ConfigWidg.3 b/tk/doc/ConfigWidg.3 index c558352eae1..dd4be4e1f21 100644 --- a/tk/doc/ConfigWidg.3 +++ b/tk/doc/ConfigWidg.3 @@ -40,7 +40,7 @@ Pointer to table specifying legal configuration options for this widget. .AP int argc in Number of arguments in \fIargv\fR. -.AP char **argv in +.AP "CONST char" **argv in Command-line options for configuring widget. .AP char *widgRec in/out Points to widget record structure. Fields in this structure get @@ -55,7 +55,7 @@ selectively disable entries in \fIspecs\fR. The name of the type of a widget record. .AP "field name" field in The name of a field in records of type \fItype\fR. -.AP char *argvName in +.AP "CONST char" *argvName in The name used on Tcl command lines to refer to a particular option (e.g. when creating a widget or invoking the \fBconfigure\fR widget command). If non-NULL, then information is returned only for this @@ -66,6 +66,12 @@ Display containing widget whose record is being freed; needed in order to free up resources. .BE .SH DESCRIPTION +.VS 8.1 +.PP +Note: \fBTk_ConfigureWidget\fP should be replaced with the new +\fBTcl_Obj\fP based API \fBTk_SetOptions\fP. The old interface is +retained for backward compatibility. +.VE .PP \fBTk_ConfigureWidget\fR is called to configure various aspects of a widget, such as colors, fonts, border width, etc. @@ -259,7 +265,7 @@ will never match any arguments. \fBTK_CONFIG_FONT\fR The value must be an ASCII string identifying a font in a form suitable for passing to \fBTk_GetFont\fR. The value is converted -to an (\fBXFontStruct *\fR) by calling \fBTk_GetFont\fR and the result +to a \fBTk_Font\fR by calling \fBTk_GetFont\fR and the result is stored in the target. If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value may be an empty string, in which case the target will be set to NULL. @@ -613,8 +619,10 @@ The library implementation of frames implementation of buttons (tkButton.c) has a much more complex table that uses many of the fancy \fIspecFlags\fR mechanisms. +.SH "SEE ALSO" +Tk_SetOptions(3) + .SH KEYWORDS anchor, bitmap, boolean, border, cap style, color, configuration options, cursor, custom, double, font, integer, join style, justify, millimeters, pixels, relief, synonym, uid - diff --git a/tk/doc/ConfigWind.3 b/tk/doc/ConfigWind.3 index ae9c1da9480..fd1c2c6919e 100644 --- a/tk/doc/ConfigWind.3 +++ b/tk/doc/ConfigWind.3 @@ -151,4 +151,3 @@ Tk_MoveToplevelWindow, Tk_RestackWindow .SH KEYWORDS attributes, border, color, configure, height, pixel, pixmap, width, window, x, y - diff --git a/tk/doc/CoordToWin.3 b/tk/doc/CoordToWin.3 index 90467211417..9cfd2ee5dc9 100644 --- a/tk/doc/CoordToWin.3 +++ b/tk/doc/CoordToWin.3 @@ -49,4 +49,3 @@ both contain the point then the highest one in the stacking order .SH KEYWORDS containing, coordinates, root window - diff --git a/tk/doc/CrtCmHdlr.3 b/tk/doc/CrtCmHdlr.3 new file mode 100644 index 00000000000..10cae345e5b --- /dev/null +++ b/tk/doc/CrtCmHdlr.3 @@ -0,0 +1,69 @@ +'\" +'\" Copyright (c) 2000 Ajuba Solutions. +'\" +'\" See the file "license.terms" for information on usage and redistribution +'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. +'\" +'\" RCS: @(#) $Id$ +'\" +.so man.macros +.TH Tk_CreateClientMessageHandler 3 "8.4" Tk "Tk Library Procedures" +.BS +.SH NAME +Tk_CreateClientMessageHandler, Tk_DeleteClientMessageHandler \- associate procedure callback with ClientMessage type X events +.SH SYNOPSIS +.nf +\fB#include \fR +.sp +\fBTk_CreateClientMessageHandler\fR(\fIproc\fR) +.sp +\fBTk_DeleteClientMessageHandler\fR(\fIproc\fR) +.SH ARGUMENTS +.AP Tk_ClientMessageProc *proc in +Procedure to invoke whenever a ClientMessage X event occurs on any display. +.BE + +.SH DESCRIPTION +.PP + +\fBTk_CreateClientMessageHandler\fR arranges for \fIproc\fR to be invoked +in the future whenever a ClientMessage X event occurs that isn't handled by +\fBWM_PROTOCOL\fR. \fBTk_CreateClientMessageHandler\fR is intended for use +by applications which need to watch X ClientMessage events, such as drag and +drop applications. +.PP +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 +\fBTk_MainLoop\fR). +.PP +\fIProc\fR should have arguments and result that match the +type \fBTk_ClientMessageProc\fR: +.CS +typedef int Tk_ClientMessageProc( + Tk_Window \fItkwin\fR, + XEvent *\fIeventPtr\fR); +.CE +The \fItkwin\fR parameter to \fIproc\fR is the Tk window which is +associated with this event. \fIEventPtr\fR is a pointer to the X event. +.PP +Whenever an X ClientMessage event is processed by \fBTk_HandleEvent\fR, +the \fIproc\fR is called if it wasn't handled as a \fBWM_PROTOCOL\fR. +The return value from \fIproc\fR is normally 0. +A non-zero return value indicates that the event is not to be handled +further; that is, \fIproc\fR has done all processing that is to be +allowed for the event. +.PP +If there are multiple ClientMessage event handlers, each one is called +for each event, in the order in which they were established. +.PP +\fBTk_DeleteClientMessageHandler\fR may be called to delete a +previously-created ClientMessage event handler: it deletes each handler it +finds that matches the \fIproc\fR argument. If no such handler exists, +then \fBTk_DeleteClientMessageHandler\fR returns without doing anything. +Although Tk supports it, it's probably a bad idea to have more than one +callback with the same \fIproc\fR argument. + +.SH KEYWORDS +bind, callback, event, handler diff --git a/tk/doc/CrtErrHdlr.3 b/tk/doc/CrtErrHdlr.3 index 58fee382f90..77495830332 100644 --- a/tk/doc/CrtErrHdlr.3 +++ b/tk/doc/CrtErrHdlr.3 @@ -143,4 +143,3 @@ applications should use only \fBTk_CreateErrorHandler\fR. .SH KEYWORDS callback, error, event, handler - diff --git a/tk/doc/CrtGenHdlr.3 b/tk/doc/CrtGenHdlr.3 index 43aec19bec7..c4d6609bfae 100644 --- a/tk/doc/CrtGenHdlr.3 +++ b/tk/doc/CrtGenHdlr.3 @@ -82,4 +82,3 @@ For example, it is the caller's responsibility to invoke \fBXSelectInput\fR to select the desired events, if that is necessary. .SH KEYWORDS bind, callback, event, handler - diff --git a/tk/doc/CrtImgType.3 b/tk/doc/CrtImgType.3 index ebbae05ef3e..e0f4d72da29 100644 --- a/tk/doc/CrtImgType.3 +++ b/tk/doc/CrtImgType.3 @@ -31,14 +31,14 @@ Must be static: a pointer to this structure is retained by the image code. .AP Tcl_Interp *interp in Interpreter in which image was created. -.AP char *name in +.AP "CONST char" *name in Name of existing image. .AP Tk_ImageType **typePtrPtr out Points to word in which to store a pointer to type information for the given image, if it exists. -.AP int argc +.AP int argc in Number of arguments -.AP char ***argvPtr +.AP char ***argvPtr in/out Pointer to argument list .VE .BE @@ -281,4 +281,3 @@ Tk_ImageChanged, Tk_GetImage, Tk_FreeImage, Tk_RedrawImage, Tk_SizeOfImage .SH KEYWORDS image manager, image type, instance, master - diff --git a/tk/doc/CrtItemType.3 b/tk/doc/CrtItemType.3 index 4d839cdd13b..d389c7bc8d0 100644 --- a/tk/doc/CrtItemType.3 +++ b/tk/doc/CrtItemType.3 @@ -531,7 +531,7 @@ It is only relevant for item types that support an insertion cursor; that don't support an insertion cursor. The procedure must match the following prototype: .CS -typedef void Tk_ItemIndexProc( +typedef void Tk_ItemCursorProc( Tk_Canvas \fIcanvas\fR, Tk_Item *\fIitemPtr\fR, int \fIindex\fR); @@ -624,5 +624,3 @@ Tk_CanvasPsY, Tk_CanvasTextInfo, Tk_CanvasTkwin .SH KEYWORDS canvas, focus, item type, selection, type manager - - diff --git a/tk/doc/CrtPhImgFmt.3 b/tk/doc/CrtPhImgFmt.3 index c150267c563..7ad3c87a070 100644 --- a/tk/doc/CrtPhImgFmt.3 +++ b/tk/doc/CrtPhImgFmt.3 @@ -19,7 +19,6 @@ Tk_CreatePhotoImageFormat \- define new file format for photo images .SH SYNOPSIS .nf \fB#include \fR -\fB#include \fR .sp \fBTk_CreatePhotoImageFormat\fR(\fIformatPtr\fR) .SH ARGUMENTS @@ -244,4 +243,3 @@ Tk_FindPhoto, Tk_PhotoPutBlock .SH KEYWORDS photo image, image file - diff --git a/tk/doc/CrtSelHdlr.3 b/tk/doc/CrtSelHdlr.3 index e8ec7a111a6..91d4dfbfe89 100644 --- a/tk/doc/CrtSelHdlr.3 +++ b/tk/doc/CrtSelHdlr.3 @@ -118,4 +118,3 @@ If there is no such handler then it has no effect. .SH KEYWORDS format, handler, selection, target - diff --git a/tk/doc/CrtWindow.3 b/tk/doc/CrtWindow.3 index 4f477057618..2e7ff4d72b7 100644 --- a/tk/doc/CrtWindow.3 +++ b/tk/doc/CrtWindow.3 @@ -20,6 +20,9 @@ Tk_Window \fBTk_CreateWindow\fR(\fIinterp, parent, name, topLevScreen\fR) .sp Tk_Window +\fBTk_CreateAnonymousWindow\fR(\fIinterp, parent, topLevScreen\fR) +.sp +Tk_Window \fBTk_CreateWindowFromPath\fR(\fIinterp, tkwin, pathName, topLevScreen\fR) .sp \fBTk_DestroyWindow\fR(\fItkwin\fR) @@ -33,10 +36,10 @@ then \fI*interp\fR isn't modified. .AP Tk_Window parent in Token for the window that is to serve as the logical parent of the new window. -.AP char *name in +.AP "CONST char" *name in Name to use for this window. Must be unique among all children of the same \fIparent\fR. -.AP char *topLevScreen in +.AP "CONST char" *topLevScreen in Has same format as \fIscreenName\fR. If NULL, then new window is created as an internal window. If non-NULL, new window is created as a top-level window on screen \fItopLevScreen\fR. If \fItopLevScreen\fR @@ -44,16 +47,16 @@ is an empty string (``'') then new window is created as top-level window of \fIparent\fR's screen. .AP Tk_Window tkwin in Token for window. -.AP char *pathName in +.AP "CONST char" *pathName in Name of new window, specified as path name within application (e.g. \fB.a.b.c\fR). .BE .SH DESCRIPTION .PP -The procedures \fBTk_CreateWindow\fR +The procedures \fBTk_CreateWindow\fR, .VS -and \fBTk_CreateWindowFromPath\fR +\fBTk_CreateAnonymousWindow\fR, and \fBTk_CreateWindowFromPath\fR are used to create new windows for use in Tk-based applications. Each of the procedures returns a token that can be used to manipulate the window in other calls to the Tk @@ -86,6 +89,12 @@ menu's \fIparent\fR would be the button-like window used to invoke it, which would in turn be a child of the menu bar window. A dialog box might have the application's main window as its parent. .PP +\fBTk_CreateAnonymousWindow\fR differs from \fBTk_CreateWindow\fR in +that it creates an unnamed window. This window will be manipulable +only using C interfaces, and will not be visible to Tcl scripts. Both +interior windows and top-level windows may be created with +\fBTk_CreateAnonymousWindow\fR. +.PP \fBTk_CreateWindowFromPath\fR offers an alternate way of specifying new windows. In \fBTk_CreateWindowFromPath\fR the new window is specified with a token for any window in the target @@ -140,4 +149,3 @@ the X commands to instantiate the window given by \fItkwin\fR. .SH KEYWORDS create, deferred creation, destroy, display, internal window, screen, top-level window, window - diff --git a/tk/doc/DeleteImg.3 b/tk/doc/DeleteImg.3 index ddfd1f0a325..6cdbffd6aa6 100644 --- a/tk/doc/DeleteImg.3 +++ b/tk/doc/DeleteImg.3 @@ -20,7 +20,7 @@ Tk_DeleteImage \- Destroy an image. .AS Tcl_Interp *interp .AP Tcl_Interp *interp in Interpreter for which the image was created. -.AP char *name in +.AP "CONST char" *name in Name of the image. .BE @@ -33,4 +33,3 @@ exist then the procedure has no effect. .SH KEYWORDS delete image, image manager - diff --git a/tk/doc/DrawFocHlt.3 b/tk/doc/DrawFocHlt.3 index b3d810d1769..d659933b08c 100644 --- a/tk/doc/DrawFocHlt.3 +++ b/tk/doc/DrawFocHlt.3 @@ -38,5 +38,3 @@ It is typically invoked by widgets during redisplay. .SH KEYWORDS focus, traversal highlight - - diff --git a/tk/doc/EventHndlr.3 b/tk/doc/EventHndlr.3 index a77d957f231..234daea0f03 100644 --- a/tk/doc/EventHndlr.3 +++ b/tk/doc/EventHndlr.3 @@ -77,4 +77,3 @@ order they were created. .SH KEYWORDS bind, callback, event, handler - diff --git a/tk/doc/FindPhoto.3 b/tk/doc/FindPhoto.3 index 1d6b5468aad..60a0fdb9705 100644 --- a/tk/doc/FindPhoto.3 +++ b/tk/doc/FindPhoto.3 @@ -27,11 +27,11 @@ Tk_PhotoHandle .VE .sp void -\fBTk_PhotoPutBlock\fR(\fIhandle, blockPtr, x, y, width, height\fR) +\fBTk_PhotoPutBlock\fR(\fIhandle, blockPtr, x, y, width, height, compRule\fR) .sp void \fBTk_PhotoPutZoomedBlock\fR(\fIhandle, blockPtr, x, y, width, height,\ -zoomX, zoomY, subsampleX, subsampleY\fR) +zoomX, zoomY, subsampleX, subsampleY, compRule\fR) .sp int \fBTk_PhotoGetImage\fR(\fIhandle, blockPtr\fR) @@ -53,7 +53,7 @@ void .VS Interpreter in which image was created. .VE -.AP char *imageName in +.AP "CONST char" *imageName in Name of the photo image. .AP Tk_PhotoHandle handle in Opaque handle identifying the photo image to be affected. @@ -69,6 +69,16 @@ to be placed within the image. Specifies the width of the image area to be affected (for \fBTk_PhotoPutBlock\fR) or the desired image width (for \fBTk_PhotoExpand\fR and \fBTk_PhotoSetSize\fR). +.VS 8.4 +.AP int compRule in +Specifies the compositing rule used when combining transparent pixels +in a block of data with a photo image. Must be one of +TK_PHOTO_COMPOSITE_OVERLAY (which puts the block of data over the top +of the existing photo image, with the previous contents showing +through in the transparent bits) or TK_PHOTO_COMPOSITE_SET (which +discards the existing photo image contents in the rectangle covered by +the data block.) +.VE 8.4 .AP int height in Specifies the height of the image area to be affected (for \fBTk_PhotoPutBlock\fR) or the desired image height (for @@ -135,6 +145,17 @@ to the addresses of the bytes containing the red, green, blue and alpha have other values, e.g., for images that are stored as separate red, green and blue planes. .PP +.VS 8.4 +The \fIcompRule\fR parameter to \fBTk_PhotoPutBlock\fR specifies a +compositing rule that says what to do with transparent pixels. The +value TK_PHOTO_COMPOSITE_OVERLAY says that the previous contents of +the photo image should show through, and the value +TK_PHOTO_COMPOSITE_SET says that the previous contents of the photo +image should be completely ignored, and the values from the block be +copied directly across. The behavior in Tk8.3 and earlier was +equivalent to having TK_PHOTO_COMPOSITE_OVERLAY as a compositing rule. +.VE 8.4 +.PP The value given for the \fIwidth\fR and \fIheight\fR parameters to \fBTk_PhotoPutBlock\fR do not have to correspond to the values specified in \fIblock\fR. If they are smaller, \fBTk_PhotoPutBlock\fR extracts a @@ -193,6 +214,17 @@ calls to \fBTk_PhotoPutBlock\fR, \fBTk_PhotoPutZoomedBlock\fR or \fBTk_PhotoGetSize\fR returns the dimensions of the image in *\fIwidthPtr\fR and *\fIheightPtr\fR. +.SH PORTABILITY +.VS 8.4 +.PP +In Tk 8.3 and earlier, \fBTk_PhotoPutBlock\fR and +\fBTk_PhotoPutZoomedBlock\fR had different signatures. If you want to +compile code that uses the old interface against 8.4 without updating +your code, compile it with the flag +-DUSE_COMPOSITELESS_PHOTO_PUT_BLOCK. Code linked using Stubs against +older versions of Tk will continue to work. +.VE 8.4 + .SH CREDITS .PP The code for the photo image type was developed by Paul Mackerras, @@ -200,4 +232,3 @@ based on his earlier photo widget code. .SH KEYWORDS photo, image - diff --git a/tk/doc/FontId.3 b/tk/doc/FontId.3 index fc7bd83795d..2c55153e4f0 100644 --- a/tk/doc/FontId.3 +++ b/tk/doc/FontId.3 @@ -10,7 +10,7 @@ .TH Tk_FontId 3 8.0 Tk "Tk Library Procedures" .BS .SH NAME -Tk_FontId, Tk_FontMetrics, Tk_PostscriptFontName \- accessor functions for +Tk_FontId, Tk_GetFontMetrics, Tk_PostscriptFontName \- accessor functions for fonts .SH SYNOPSIS .nf @@ -68,7 +68,7 @@ following screen font families should print correctly: Any other font families may not print correctly because the computed Postscript font name may be incorrect or not exist on the printer. .VS 8.0 br -.SH DATA STRUCTURES +.SH "DATA STRUCTURES" The Tk_FontMetrics data structure is used by Tk_GetFontMetrics to return information about a font and is defined as follows: .CS @@ -93,4 +93,3 @@ other line. .VE .SH KEYWORDS font - diff --git a/tk/doc/FreeXId.3 b/tk/doc/FreeXId.3 index a9cb1fb8d36..3f8419c737b 100644 --- a/tk/doc/FreeXId.3 +++ b/tk/doc/FreeXId.3 @@ -50,4 +50,3 @@ to lose all of the available identifiers. .SH KEYWORDS resource identifier - diff --git a/tk/doc/GeomReq.3 b/tk/doc/GeomReq.3 index 6bdd459c600..71278f3ae81 100644 --- a/tk/doc/GeomReq.3 +++ b/tk/doc/GeomReq.3 @@ -9,17 +9,21 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH Tk_GeometryRequest 3 "" Tk "Tk Library Procedures" +.TH Tk_GeometryRequest 3 "8.4" Tk "Tk Library Procedures" .BS .SH NAME -Tk_GeometryRequest, Tk_SetInternalBorder \- specify desired geometry or internal border for a window +Tk_GeometryRequest, Tk_SetMinimumRequestSize, Tk_SetInternalBorder, Tk_SetInternalBorderEx \- specify desired geometry or internal border for a window .SH SYNOPSIS .nf \fB#include \fR .sp \fBTk_GeometryRequest\fR(\fItkwin, reqWidth, reqHeight\fR) .sp +\fBTk_SetMinimumRequestSize\fR(\fItkwin, minWidth, minHeight\fR) +.sp \fBTk_SetInternalBorder\fR(\fItkwin, width\fR) +.sp +\fBTk_SetInternalBorderEx\fR(\fItkwin, left, right, top, bottom\fR) .SH ARGUMENTS .AS baseHeight clientData .AP Tk_Window tkwin in @@ -28,8 +32,20 @@ Window for which geometry is being requested. Desired width for \fItkwin\fR, in pixel units. .AP int reqHeight in Desired height for \fItkwin\fR, in pixel units. +.AP int minWidth in +Desired minimum requested width for \fItkwin\fR, in pixel units. +.AP int minHeight in +Desired minimum requested height for \fItkwin\fR, in pixel units. .AP int width in Space to leave for internal border for \fItkwin\fR, in pixel units. +.AP int left in +Space to leave for left side of internal border for \fItkwin\fR, in pixel units. +.AP int right in +Space to leave for right side of internal border for \fItkwin\fR, in pixel units. +.AP int top in +Space to leave for top side of internal border for \fItkwin\fR, in pixel units. +.AP int bottom in +Space to leave for bottom side of internal border for \fItkwin\fR, in pixel units. .BE .SH DESCRIPTION @@ -60,11 +76,22 @@ specifies the width of the border in pixels. Geometry managers will use this information to avoid placing any children of \fItkwin\fR overlapping the outermost \fIwidth\fR pixels of \fItkwin\fR's area. .PP -The information specified in calls to \fBTk_GeometryRequest\fR and -\fBTk_SetInternalBorder\fR can be retrieved using the macros -\fBTk_ReqWidth\fR, \fBTk_ReqHeight\fR, and \fBTk_InternalBorderWidth\fR. +\fBTk_SetInternalBorderEx\fR works like \fBTk_SetInternalBorder\fR +but lets you specify different widths for different sides of the window. +.PP +\fBTk_SetMinimumRequestSize\fR is called by widget code to indicate +that a geometry manager should request at least this size for the +widget. This allows a widget to have some control over its size when +a propagating geometry manager is used inside it. +.PP +The information specified in calls to \fBTk_GeometryRequest\fR, +\fBTk_SetMinimumRequestSize\fR, \fBTk_SetInternalBorder\fR and +\fBTk_SetInternalBorderEx\fR can be retrieved using the macros +\fBTk_ReqWidth\fR, \fBTk_ReqHeight\fR, \fBTk_MinReqWidth\fR, +\fBTk_MinReqHeight\fR, \fBTk_MinReqWidth\fR, \fBTk_InternalBorderLeft\fR, +\fBTk_InternalBorderRight\fR, \fBTk_InternalBorderTop\fR and +\fBTk_InternalBorderBottom\fR. See the \fBTk_WindowId\fR manual entry for details. .SH KEYWORDS geometry, request - diff --git a/tk/doc/GetAnchor.3 b/tk/doc/GetAnchor.3 index 3c1f7cb3e6b..a245349ba70 100644 --- a/tk/doc/GetAnchor.3 +++ b/tk/doc/GetAnchor.3 @@ -24,7 +24,7 @@ int int \fBTk_GetAnchor(\fIinterp, string, anchorPtr\fB)\fR .sp -char * +CONST char * \fBTk_NameOfAnchor(\fIanchor\fB)\fR .SH ARGUMENTS .AS "Tk_Anchor" *anchorPtr @@ -35,7 +35,7 @@ Interpreter to use for error reporting, or NULL. String value contains name of anchor point: \fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR, \fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, or \fBcenter\fR; internal rep will be modified to cache corresponding Tk_Anchor. -.AP char *string in +.AP "CONST char" *string in Same as \fIobjPtr\fR except description of anchor point is passed as a string. .VE @@ -84,4 +84,3 @@ If \fIanchor\fR isn't a legal anchor value, then .SH KEYWORDS anchor position - diff --git a/tk/doc/GetBitmap.3 b/tk/doc/GetBitmap.3 index 4705b95b6f4..b0da2f26382 100644 --- a/tk/doc/GetBitmap.3 +++ b/tk/doc/GetBitmap.3 @@ -11,7 +11,7 @@ .TH Tk_AllocBitmapFromObj 3 8.1 Tk "Tk Library Procedures" .BS .SH NAME -Tk_AllocBitmapFromObj, Tk_GetBitmap, Tk_GetBitmapFromObj, Tk_DefineBitmap, Tk_NameOfBitmap, Tk_SizeOfBitmap, Tk_FreeBitmapFromObj, Tk_FreeBitmap, Tk_GetBitmapFromData \- maintain database of single-plane pixmaps +Tk_AllocBitmapFromObj, Tk_GetBitmap, Tk_GetBitmapFromObj, Tk_DefineBitmap, Tk_NameOfBitmap, Tk_SizeOfBitmap, Tk_FreeBitmapFromObj, Tk_FreeBitmap \- maintain database of single-plane pixmaps .SH SYNOPSIS .nf \fB#include \fR @@ -30,7 +30,7 @@ Pixmap int \fBTk_DefineBitmap(\fIinterp, name, source, width, height\fB)\fR .sp -char * +CONST char * \fBTk_NameOfBitmap(\fIdisplay, bitmap\fB)\fR .sp \fBTk_SizeOfBitmap(\fIdisplay, bitmap, widthPtr, heightPtr\fB)\fR @@ -57,7 +57,7 @@ resulting Pixmap isn't cached. .VE .AP "CONST char" *name in Name for new bitmap to be defined. -.AP char *source in +.AP "CONST char" *source in Data for bitmap, in standard bitmap format. Must be stored in static memory whose value will never change. .AP "int" width in @@ -316,4 +316,3 @@ a different file. .SH KEYWORDS bitmap, pixmap - diff --git a/tk/doc/GetCapStyl.3 b/tk/doc/GetCapStyl.3 index 0e847473d62..5a88045a824 100644 --- a/tk/doc/GetCapStyl.3 +++ b/tk/doc/GetCapStyl.3 @@ -19,13 +19,13 @@ Tk_GetCapStyle, Tk_NameOfCapStyle \- translate between strings and cap styles int \fBTk_GetCapStyle(\fIinterp, string, capPtr\fB)\fR .sp -char * +CONST char * \fBTk_NameOfCapStyle(\fIcap\fB)\fR .SH ARGUMENTS .AS "Tcl_Interp" *capPtr .AP Tcl_Interp *interp in Interpreter to use for error reporting. -.AP char *string in +.AP "CONST char" *string in String containing name of cap style: one of ```butt'', ``projecting'', or ``round''. .AP int *capPtr out @@ -61,4 +61,3 @@ If \fIcap\fR isn't a legal cap style, then .SH KEYWORDS butt, cap style, projecting, round - diff --git a/tk/doc/GetClrmap.3 b/tk/doc/GetClrmap.3 index ce94295c3df..490ef780108 100644 --- a/tk/doc/GetClrmap.3 +++ b/tk/doc/GetClrmap.3 @@ -26,7 +26,7 @@ Colormap Interpreter to use for error reporting. .AP Tk_Window tkwin in Token for window in which colormap will be used. -.AP char *string in +.AP "CONST char" *string in Selects a colormap: either \fBnew\fR or the name of a window with the same screen and visual as \fItkwin\fR. .AP Display *display in @@ -71,4 +71,3 @@ name as \fIstring\fR. .SH KEYWORDS colormap - diff --git a/tk/doc/GetColor.3 b/tk/doc/GetColor.3 index 178dafe3820..cd67e41ec00 100644 --- a/tk/doc/GetColor.3 +++ b/tk/doc/GetColor.3 @@ -30,7 +30,7 @@ XColor * XColor * \fBTk_GetColorByValue(\fItkwin, prefPtr\fB)\fR .sp -char * +CONST char * \fBTk_NameOfColor(\fIcolorPtr\fB)\fR .sp GC @@ -188,4 +188,3 @@ or \fBTk_FreeColor\fR for each call to \fBTk_AllocColorFromObj\fR, .VE .SH KEYWORDS color, intensity, object, pixel value - diff --git a/tk/doc/GetCursor.3 b/tk/doc/GetCursor.3 index a0a3bcb350c..ab1d103fa8e 100644 --- a/tk/doc/GetCursor.3 +++ b/tk/doc/GetCursor.3 @@ -30,7 +30,7 @@ Tk_Cursor Tk_Cursor \fBTk_GetCursorFromData(\fIinterp, tkwin, source, mask, width, height, xHot, yHot, fg, bg\fB)\fR .sp -char * +CONST char * \fBTk_NameOfCursor(\fIdisplay, cursor\fB)\fR .sp .VS 8.1 @@ -52,9 +52,9 @@ modified to cache pointer to corresponding Tk_Cursor. Same as \fIobjPtr\fR except description of cursor is passed as a string and resulting Tk_Cursor isn't cached. .VE -.AP char *source in +.AP "CONST char" *source in Data for cursor cursor, in standard cursor format. -.AP char *mask in +.AP "CONST char" *mask in Data for mask cursor, in standard cursor format. .AP "int" width in Width of \fIsource\fR and \fImask\fR. @@ -244,4 +244,3 @@ see if the actual data values have changed. .SH KEYWORDS cursor - diff --git a/tk/doc/GetDash.3 b/tk/doc/GetDash.3 index c7e0f8a43a3..c9cc357f19f 100644 --- a/tk/doc/GetDash.3 +++ b/tk/doc/GetDash.3 @@ -68,4 +68,3 @@ displayed identically as the first one. .SH KEYWORDS dash, conversion - diff --git a/tk/doc/GetFont.3 b/tk/doc/GetFont.3 index 1df9fc26ad5..259b8fa1f88 100644 --- a/tk/doc/GetFont.3 +++ b/tk/doc/GetFont.3 @@ -27,7 +27,7 @@ Tk_Font \fBTk_GetFontFromObj(\fItkwin, objPtr\fB)\fR .VE .sp -char * +CONST char * \fBTk_NameOfFont(\fItkfont\fB)\fR .sp .VS 8.1 @@ -62,7 +62,7 @@ Opaque font token. .VS 8.1 \fBTk_AllocFontFromObj\fR finds the font indicated by \fIobjPtr\fR and returns a token that represents the font. The return value can be used -in subsequent calls to procedures such as \fBTk_FontMetrics\fR, +in subsequent calls to procedures such as \fBTk_GetFontMetrics\fR, \fBTk_MeasureChars\fR, and \fBTk_FreeFont\fR. The Tk_Font token will remain valid until \fBTk_FreeFontFromObj\fR or \fBTk_FreeFont\fR is called to release it. @@ -118,6 +118,8 @@ exactly one call to \fBTk_FreeFontFromObj\fR or \fBTk_FreeFont\fR for each call to \fBTk_AllocFontFromObj\fR or \fBTk_GetFont\fR. .VE +.SH "SEE ALSO" +Tk_FontId(3) + .SH KEYWORDS font - diff --git a/tk/doc/GetGC.3 b/tk/doc/GetGC.3 index 4bc7f911a14..53e120663c7 100644 --- a/tk/doc/GetGC.3 +++ b/tk/doc/GetGC.3 @@ -72,4 +72,3 @@ will release it to the X server and delete it from the database. .SH KEYWORDS graphics context - diff --git a/tk/doc/GetHWND.3 b/tk/doc/GetHWND.3 index fb1684c0689..5ed1b22ca4a 100644 --- a/tk/doc/GetHWND.3 +++ b/tk/doc/GetHWND.3 @@ -12,7 +12,7 @@ Tk_GetHWND \- retrieve the Windows handle for an X window .SH SYNOPSIS .nf -\fB#include \fR +\fB#include \fR .sp HWND \fBTk_GetHWND\fR(\fIwindow\fR) diff --git a/tk/doc/GetImage.3 b/tk/doc/GetImage.3 index de795c49ea0..da3f751d2fc 100644 --- a/tk/doc/GetImage.3 +++ b/tk/doc/GetImage.3 @@ -30,7 +30,7 @@ Tk_Image Place to leave error message. .AP Tk_Window tkwin in Window in which image will be used. -.AP char *name in +.AP "CONST char" *name in Name of image. .AP Tk_ImageChangedProc *changeProc in Procedure for Tk to invoke whenever image content or size changes. @@ -133,4 +133,3 @@ Tk_CreateImageType .SH KEYWORDS images, redisplay - diff --git a/tk/doc/GetJoinStl.3 b/tk/doc/GetJoinStl.3 index 6cd457ad006..44f6777cd5c 100644 --- a/tk/doc/GetJoinStl.3 +++ b/tk/doc/GetJoinStl.3 @@ -19,13 +19,13 @@ Tk_GetJoinStyle, Tk_NameOfJoinStyle \- translate between strings and join styles int \fBTk_GetJoinStyle(\fIinterp, string, joinPtr\fB)\fR .sp -char * +CONST char * \fBTk_NameOfJoinStyle(\fIjoin\fB)\fR .SH ARGUMENTS .AS "Tcl_Interp" *joinPtr .AP Tcl_Interp *interp in Interpreter to use for error reporting. -.AP char *string in +.AP "CONST char" *string in String containing name of join style: one of ``bevel'', ``miter'', or ``round''. .AP int *joinPtr out @@ -60,4 +60,3 @@ If \fIjoin\fR isn't a legal join style, then .SH KEYWORDS bevel, join style, miter, round - diff --git a/tk/doc/GetJustify.3 b/tk/doc/GetJustify.3 index b6416ff9f65..3604c3e028a 100644 --- a/tk/doc/GetJustify.3 +++ b/tk/doc/GetJustify.3 @@ -23,7 +23,7 @@ int int \fBTk_GetJustify(\fIinterp, string, justifyPtr\fB)\fR .sp -char * +CONST char * \fBTk_NameOfJustify(\fIjustify\fB)\fR .SH ARGUMENTS .AS "Tk_Justify" *justifyPtr @@ -34,7 +34,7 @@ Interpreter to use for error reporting, or NULL. String value contains name of justification style (\fBleft\fR, \fBright\fR, or \fBcenter\fR). The internal rep will be modified to cache corresponding justify value. -.AP char *string in +.AP "CONST char" *string in Same as \fIobjPtr\fR except description of justification style is passed as a string. .VE @@ -91,4 +91,3 @@ If \fIjustify\fR isn't a legal justify value, then .SH KEYWORDS center, fill, justification, string - diff --git a/tk/doc/GetOption.3 b/tk/doc/GetOption.3 index 5d848c8630b..775d59215c9 100644 --- a/tk/doc/GetOption.3 +++ b/tk/doc/GetOption.3 @@ -22,9 +22,9 @@ Tk_Uid .AS Tk_Window *class .AP Tk_Window tkwin in Token for window. -.AP char *name in +.AP "CONST char" *name in Name of desired option. -.AP char *class in +.AP "CONST char" *class in Class of desired option. Null means there is no class for this option; do lookup based on name only. .BE @@ -44,4 +44,3 @@ quickly than successive calls for different windows. .SH KEYWORDS class, name, option, retrieve - diff --git a/tk/doc/GetPixels.3 b/tk/doc/GetPixels.3 index bb32539f8e4..6ec9f57ac76 100644 --- a/tk/doc/GetPixels.3 +++ b/tk/doc/GetPixels.3 @@ -42,7 +42,7 @@ units and pixels. .AP Tcl_Obj *objPtr in/out String value specifies a distance on the screen; internal rep will be modified to cache converted distance. -.AP char *string in +.AP "CONST char" *string in Same as \fIobjPtr\fR except specification of distance is passed as a string. .VE @@ -109,4 +109,3 @@ store a double-precision floating-point result at \fI*doublePtr\fR. .SH KEYWORDS centimeters, convert, inches, millimeters, pixels, points, screen units - diff --git a/tk/doc/GetPixmap.3 b/tk/doc/GetPixmap.3 index c96624f0276..777ba33e482 100644 --- a/tk/doc/GetPixmap.3 +++ b/tk/doc/GetPixmap.3 @@ -54,4 +54,3 @@ its resource identifier available for reuse. .SH KEYWORDS pixmap, resource identifier - diff --git a/tk/doc/GetRelief.3 b/tk/doc/GetRelief.3 index 4d80fe6fc66..28532e6fe4c 100644 --- a/tk/doc/GetRelief.3 +++ b/tk/doc/GetRelief.3 @@ -24,7 +24,7 @@ int int \fBTk_GetRelief(\fIinterp, name, reliefPtr\fB)\fR .sp -char * +CONST char * \fBTk_NameOfRelief(\fIrelief\fB)\fR .SH ARGUMENTS .AS "Tcl_Interp" *reliefPtr @@ -42,6 +42,8 @@ a string. .AP int *reliefPtr out Pointer to location in which to store relief value corresponding to \fIobjPtr\fR or \fIname\fR. +.AP "CONST char" *name +Name of the relief. .AP int relief in Relief value (one of TK_RELIEF_FLAT, TK_RELIEF_RAISED, TK_RELIEF_SUNKEN, TK_RELIEF_GROOVE, TK_RELIEF_SOLID, or TK_RELIEF_RIDGE). @@ -79,4 +81,3 @@ is returned. .SH KEYWORDS name, relief, string - diff --git a/tk/doc/GetRootCrd.3 b/tk/doc/GetRootCrd.3 index 283433a0dae..9726a382b54 100644 --- a/tk/doc/GetRootCrd.3 +++ b/tk/doc/GetRootCrd.3 @@ -41,4 +41,3 @@ communicate with the X server. .SH KEYWORDS coordinates, root window - diff --git a/tk/doc/GetScroll.3 b/tk/doc/GetScroll.3 index 576f1905d52..985d2c1bab8 100644 --- a/tk/doc/GetScroll.3 +++ b/tk/doc/GetScroll.3 @@ -27,7 +27,7 @@ int Interpreter to use for error reporting. .AP int argc in Number of strings in \fIargv\fR array. -.AP char *argv[] in +.AP "CONST char" *argv[] in Argument strings. These represent the entire widget command, of which the first word is typically the widget name and the second word is typically \fBxview\fR or \fByview\fR. @@ -76,5 +76,3 @@ development. .SH KEYWORDS parse, scrollbar, scrolling command, xview, yview - - diff --git a/tk/doc/GetSelect.3 b/tk/doc/GetSelect.3 index d4a0ce0d646..92c03eb6f19 100644 --- a/tk/doc/GetSelect.3 +++ b/tk/doc/GetSelect.3 @@ -77,4 +77,3 @@ and return TCL_ERROR; this will abort the selection retrieval. .SH KEYWORDS format, get, selection retrieval - diff --git a/tk/doc/GetUid.3 b/tk/doc/GetUid.3 index 433a1fad1a0..77e896771dc 100644 --- a/tk/doc/GetUid.3 +++ b/tk/doc/GetUid.3 @@ -48,4 +48,3 @@ same string value as its argument (strcmp(Tk_GetUid(a), a) == 0). .SH KEYWORDS atom, unique identifier - diff --git a/tk/doc/GetVRoot.3 b/tk/doc/GetVRoot.3 index cc7bc918836..9cf7d1bd0f3 100644 --- a/tk/doc/GetVRoot.3 +++ b/tk/doc/GetVRoot.3 @@ -47,4 +47,3 @@ will be set to the dimensions of the screen containing \fItkwin\fR. .SH KEYWORDS geometry, height, location, virtual root, width, window manager - diff --git a/tk/doc/GetVisual.3 b/tk/doc/GetVisual.3 index b210abc50b3..943dad7559c 100644 --- a/tk/doc/GetVisual.3 +++ b/tk/doc/GetVisual.3 @@ -24,7 +24,7 @@ Visual * Interpreter to use for error reporting. .AP Tk_Window tkwin in Token for window in which the visual will be used. -.AP char *string in +.AP "CONST char" *string in String that identifies the desired visual. See below for valid formats. .AP int *depthPtr out @@ -96,4 +96,3 @@ from Paul Mackerras. .SH KEYWORDS colormap, screen, visual - diff --git a/tk/doc/HWNDToWindow.3 b/tk/doc/HWNDToWindow.3 index 05367bf4f8c..34baf022a1b 100644 --- a/tk/doc/HWNDToWindow.3 +++ b/tk/doc/HWNDToWindow.3 @@ -11,7 +11,7 @@ Tk_HWNDToWindow \- Find Tk's window information for a Windows window .SH SYNOPSIS .nf -\fB#include \fR +\fB#include \fR .sp Tk_Window \fBTk_HWNDToWindow\fR(\fIhwnd\fR) diff --git a/tk/doc/HandleEvent.3 b/tk/doc/HandleEvent.3 index 1d8de4395d3..26b75278bec 100644 --- a/tk/doc/HandleEvent.3 +++ b/tk/doc/HandleEvent.3 @@ -47,4 +47,3 @@ doing anything else. .SH KEYWORDS callback, event, handler, window - diff --git a/tk/doc/IdToWindow.3 b/tk/doc/IdToWindow.3 index e8235b35926..0755f35bbb9 100644 --- a/tk/doc/IdToWindow.3 +++ b/tk/doc/IdToWindow.3 @@ -34,4 +34,3 @@ NULL is returned. .SH KEYWORDS X window id - diff --git a/tk/doc/ImgChanged.3 b/tk/doc/ImgChanged.3 index fa2093f8e89..7588fb8cc4d 100644 --- a/tk/doc/ImgChanged.3 +++ b/tk/doc/ImgChanged.3 @@ -67,4 +67,3 @@ Tk_CreateImageType .SH KEYWORDS images, redisplay, image size changes - diff --git a/tk/doc/InternAtom.3 b/tk/doc/InternAtom.3 index d4b0f2fbcbd..6264a265d59 100644 --- a/tk/doc/InternAtom.3 +++ b/tk/doc/InternAtom.3 @@ -19,13 +19,13 @@ Tk_InternAtom, Tk_GetAtomName \- manage cache of X atoms Atom \fBTk_InternAtom(\fItkwin, name\fR) .sp -char * +CONST char * \fBTk_GetAtomName(\fItkwin, atom\fR) .SH ARGUMENTS .AS Tk_Window parent .AP Tk_Window tkwin in Token for window. Used to map atom or name relative to a particular display. -.AP char *name in +.AP "CONST char" *name in String name for which atom is desired. .AP Atom atom in Atom for which corresponding string name is desired. @@ -56,4 +56,3 @@ should be used in place of the Xlib procedures. .SH KEYWORDS atom, cache, display - diff --git a/tk/doc/MainLoop.3 b/tk/doc/MainLoop.3 index e1947e621bb..2cbe3c9d06b 100644 --- a/tk/doc/MainLoop.3 +++ b/tk/doc/MainLoop.3 @@ -30,4 +30,3 @@ entirely of callbacks invoked via \fBTcl_DoOneEvent\fR. .SH KEYWORDS application, event, main loop - diff --git a/tk/doc/MainWin.3 b/tk/doc/MainWin.3 index 81f2144c163..b409509b93f 100644 --- a/tk/doc/MainWin.3 +++ b/tk/doc/MainWin.3 @@ -44,5 +44,3 @@ windows currently open in the process. .SH KEYWORDS application, main window - - diff --git a/tk/doc/MaintGeom.3 b/tk/doc/MaintGeom.3 index 20a8cf84d79..7137973f487 100644 --- a/tk/doc/MaintGeom.3 +++ b/tk/doc/MaintGeom.3 @@ -64,7 +64,8 @@ is unmapped, the slave is automatically removed by the screen by X. .PP \fBTk_MaintainGeometry\fR deals with these problems for slaves -whose masters aren't their parents. +whose masters aren't their parents, as well as handling the simpler +case of slaves whose masters are their parents. \fBTk_MaintainGeometry\fR is typically called by a window manager once it has decided where a slave should be positioned relative to its master. @@ -100,4 +101,3 @@ pair that is isn't currently managed, the call has no effect. .SH KEYWORDS geometry manager, map, master, parent, position, slave, unmap - diff --git a/tk/doc/ManageGeom.3 b/tk/doc/ManageGeom.3 index e72249cd4c2..50e0c7aa682 100644 --- a/tk/doc/ManageGeom.3 +++ b/tk/doc/ManageGeom.3 @@ -92,4 +92,3 @@ corresponding parameters passed to \fBTk_ManageGeometry\fR. .SH KEYWORDS callback, geometry, managed, request, unmanaged - diff --git a/tk/doc/MapWindow.3 b/tk/doc/MapWindow.3 index 4f8a550262a..b23cee7a14f 100644 --- a/tk/doc/MapWindow.3 +++ b/tk/doc/MapWindow.3 @@ -51,4 +51,3 @@ directly. .SH KEYWORDS map, unmap, window - diff --git a/tk/doc/MeasureChar.3 b/tk/doc/MeasureChar.3 index 57ba4b1fa9c..38cbf754153 100644 --- a/tk/doc/MeasureChar.3 +++ b/tk/doc/MeasureChar.3 @@ -135,4 +135,3 @@ text, the appropriate underlined font should be constructed and used. .SH KEYWORDS font - diff --git a/tk/doc/MoveToplev.3 b/tk/doc/MoveToplev.3 index 915a70c9283..b0b076f4ada 100644 --- a/tk/doc/MoveToplev.3 +++ b/tk/doc/MoveToplev.3 @@ -53,4 +53,3 @@ using the \fBTk_DoWhenIdle\fR mechanism. .SH KEYWORDS position, top-level window, window manager - diff --git a/tk/doc/Name.3 b/tk/doc/Name.3 index 867745b33b5..d4a2dbed7b2 100644 --- a/tk/doc/Name.3 +++ b/tk/doc/Name.3 @@ -30,7 +30,7 @@ Tk_Window Token for window. .AP Tcl_Interp *interp out Interpreter to use for error reporting. -.AP char *pathName in +.AP "CONST char" *pathName in Character string containing path name of window. .BE @@ -80,4 +80,3 @@ need not be the case: any window in the desired hierarchy may be used. .SH KEYWORDS name, path name, token, window - diff --git a/tk/doc/NameOfImg.3 b/tk/doc/NameOfImg.3 index 2b2edb7b8f9..fdc71f52b9c 100644 --- a/tk/doc/NameOfImg.3 +++ b/tk/doc/NameOfImg.3 @@ -15,7 +15,7 @@ Tk_NameOfImage \- Return name of image. .nf \fB#include \fR .sp -char * +CONST char * \fBTk_NameOfImage\fR(\fItypePtr\fR) .SH ARGUMENTS .AS Tk_ImageMaster *masterPtr @@ -32,4 +32,3 @@ string name for the image. .SH KEYWORDS image manager, image name - diff --git a/tk/doc/OwnSelect.3 b/tk/doc/OwnSelect.3 index ad300a69acc..9b2e59d1e14 100644 --- a/tk/doc/OwnSelect.3 +++ b/tk/doc/OwnSelect.3 @@ -50,4 +50,3 @@ information about \fItkwin\fR. .SH KEYWORDS own, selection owner - diff --git a/tk/doc/ParseArgv.3 b/tk/doc/ParseArgv.3 index 791a8e36726..4fc886d2fe0 100644 --- a/tk/doc/ParseArgv.3 +++ b/tk/doc/ParseArgv.3 @@ -28,7 +28,7 @@ no Tk options will be processed. .AP int argcPtr in/out Pointer to number of arguments in argv; gets modified to hold number of unprocessed arguments that remain after the call. -.AP char **argv in/out +.AP "CONST char" **argv in/out Command line arguments passed to main program. Modified to hold unprocessed arguments that remain after the call. .AP Tk_ArgvInfo *argTable in @@ -349,4 +349,3 @@ and \fIargv\fR[2] will be NULL. .SH KEYWORDS arguments, command line, options - diff --git a/tk/doc/QWinEvent.3 b/tk/doc/QWinEvent.3 index a07d399152a..7e58055d465 100644 --- a/tk/doc/QWinEvent.3 +++ b/tk/doc/QWinEvent.3 @@ -10,14 +10,21 @@ .TH Tk_QueueWindowEvent 3 7.5 Tk "Tk Library Procedures" .BS .SH NAME -Tk_QueueWindowEvent \- Add a window event to the Tcl event queue +Tk_CollapseMotionEvents, Tk_QueueWindowEvent \- Add a window event to the Tcl event queue .SH SYNOPSIS .nf \fB#include \fR .sp +int +\fBTk_CollapseMotionEvents\fR(\fIdisplay, collapse\fR) +.sp \fBTk_QueueWindowEvent\fR(\fIeventPtr, position\fR) .SH ARGUMENTS .AS Tcl_QueuePosition position +.AP Display *display in +Display for which to control motion event collapsing. +.AP int collapse in +Indicates whether motion events should be collapsed or not. .AP XEvent *eventPtr in An event to add to the event queue. .AP Tcl_QueuePosition position in @@ -27,17 +34,20 @@ Where to add the new event in the queue: \fBTCL_QUEUE_TAIL\fR, .SH DESCRIPTION .PP -This procedure places a window event on Tcl's -internal event queue for eventual servicing. It creates a -Tcl_Event structure, copies the event into that structure, -and calls \fBTcl_QueueEvent\fR to add the event to the queue. -When the event is eventually removed from the queue it is +\fBTk_QueueWindowEvent\fR places a window event on Tcl's internal event +queue for eventual servicing. It creates a Tcl_Event structure, copies the +event into that structure, and calls \fBTcl_QueueEvent\fR to add the event +to the queue. When the event is eventually removed from the queue it is processed just like all window events. .PP +When multiple motion events are received for the same window in rapid +succession, they are collapsed by default. This behavior can be controlled +with \fBTk_CollapseMotionEvents\fR. \fBTk_CollapseMotionEvents\fR always +returns the previous value for collapse behavior on the \fIdisplay\fR. +.PP The \fIposition\fR argument to \fBTk_QueueWindowEvent\fR has the same significance as for \fBTcl_QueueEvent\fR; see the documentation for \fBTcl_QueueEvent\fR for details. .SH KEYWORDS -callback, clock, handler, modal timeout - +callback, clock, handler, modal timeout, events diff --git a/tk/doc/Restack.3 b/tk/doc/Restack.3 index c7e41d3bab9..6389d09d36f 100644 --- a/tk/doc/Restack.3 +++ b/tk/doc/Restack.3 @@ -47,4 +47,3 @@ Both of these values are defined by the include file . .SH KEYWORDS above, below, obscure, stacking order - diff --git a/tk/doc/RestrictEv.3 b/tk/doc/RestrictEv.3 index d9508a15219..cb5653fe03a 100644 --- a/tk/doc/RestrictEv.3 +++ b/tk/doc/RestrictEv.3 @@ -79,4 +79,3 @@ queue. Instead, call \fBTk_RestrictEvents\fR to set up a filter, then call \fBTk_DoOneEvent\fR to retrieve the desired event(s). .SH KEYWORDS delay, event, filter, restriction - diff --git a/tk/doc/SetAppName.3 b/tk/doc/SetAppName.3 index 0601c802095..293129fd153 100644 --- a/tk/doc/SetAppName.3 +++ b/tk/doc/SetAppName.3 @@ -16,14 +16,14 @@ Tk_SetAppName \- Set the name of an application for ``send'' commands .nf \fB#include \fR .sp -char * +CONST char * \fBTk_SetAppName\fR(\fItkwin, name\fR) .SH ARGUMENTS .AS Tk_Window parent .AP Tk_Window tkwin in Token for window in application. Used only to select a particular application. -.AP char *name in +.AP "CONST char" *name in Name under which to register the application. .BE @@ -63,4 +63,3 @@ functionality of \fBTk_SetAppName\fR. .SH KEYWORDS application, name, register, send command - diff --git a/tk/doc/SetCaret.3 b/tk/doc/SetCaret.3 new file mode 100644 index 00000000000..067ee4a5d92 --- /dev/null +++ b/tk/doc/SetCaret.3 @@ -0,0 +1,40 @@ +'\" +'\" Copyright (c) 2002 ActiveState Corporation. +'\" +'\" See the file "license.terms" for information on usage and redistribution +'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. +'\" +'\" RCS: @(#) $Id$ +'\" +.so man.macros +.TH Tk_SetCaretPos 3 8.4 Tk "Tk Library Procedures" +.BS +.SH NAME +Tk_SetCaretPos \- set the display caret location +.SH SYNOPSIS +.nf +\fB#include \fR +.sp +int +\fBTk_SetCaretPos\fR(\fItkwin, x, y, height\fR) +.SH ARGUMENTS +.AP Tk_Window tkwin in +Token for window. +.AP int x in +Window-relative x coordinate. +.AP int y in +Window-relative y coordinate. +.AP int h in +Height of the caret in the window. +.BE + +.SH DESCRIPTION +.PP +\fBTk_SetCaretPos\fR sets the caret location for the display of the +specified Tk_Window \fItkwin\fR. The caret is the per-display cursor +location used for indicating global focus (e.g. to comply with Microsoft +Accessibility guidelines), as well as for location of the over-the-spot XIM +(X Input Methods) or Windows IME windows. + +.SH KEYWORDS +caret, cursor diff --git a/tk/doc/SetClass.3 b/tk/doc/SetClass.3 index 47baa9f6c49..9b2f9814724 100644 --- a/tk/doc/SetClass.3 +++ b/tk/doc/SetClass.3 @@ -59,4 +59,3 @@ If \fItkwin\fR has not yet been given a class, then .SH KEYWORDS class, unique identifier, window, window manager - diff --git a/tk/doc/SetClassProcs.3 b/tk/doc/SetClassProcs.3 new file mode 100644 index 00000000000..5b563ee3dc8 --- /dev/null +++ b/tk/doc/SetClassProcs.3 @@ -0,0 +1,91 @@ +'\" +'\" Copyright (c) 2000 Ajuba Solutions. +'\" +'\" See the file "license.terms" for information on usage and redistribution +'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. +'\" +'\" RCS: @(#) $Id$ +'\" +.so man.macros +.TH Tk_SetClassProcs 3 8.4 Tk "Tk Library Procedures" +.BS +.SH NAME +Tk_SetClassProcs \- register widget specific procedures +.SH SYNOPSIS +.nf +\fB#include \fR +.sp +\fBTk_SetClassProcs\fR(\fItkwin, procs, instanceData\fR) +.SH ARGUMENTS +.AS Tk_ClassProc instanceData +.AP Tk_Window tkwin in +Token for window to modify. +.AP Tk_ClassProcs *procs in +Pointer to data structure containing widget specific procedures. +The data structure pointed to by \fIprocs\fR must be static: +Tk keeps a reference to it as long as the window exists. +.AP ClientData instanceData in +Arbitrary one-word value to pass to widget callbacks. +.BE + +.SH DESCRIPTION +.PP +\fBTk_SetClassProcs\fR is called to register a set of procedures that +are used as callbacks in different places. +.PP +The structure pointed to by \fIprocs\fR contains the following: +.CS +typedef struct Tk_ClassProcs { + unsigned int \fIsize\fR; + Tk_ClassWorldChangedProc *\fIworldChangedProc\fR; + Tk_ClassCreateProc *\fIcreateProc\fR; + Tk_ClassModalProc *\fImodalProc\fR; +} Tk_ClassProcs; +.CE +The \fIsize\fR field is used to simplify future expansion of the +structure. It should always be set to (literally) \fBsizeof(Tk_ClassProcs)\fR. +.PP +\fIworldChangedProc\fR is invoked when the system has altered +in some way that requires some reaction from the widget. For example, +when a font alias (see the \fBfont\fR manual entry) is reconfigured, +widgets configured to use that font alias must update their display +accordingly. \fIworldChangedProc\fR should have arguments and results +that match the type \fBTk_ClassWorldChangedProc\fR: +.CS +typedef void Tk_ClassWorldChangedProc( + ClientData \fIinstanceData\fR); +.CE +The \fIinstanceData\fR parameter passed to the \fIworldChangedProc\fR +will be identical to the \fIinstanceData\fR paramter passed to +\fBTk_SetClassProcs\fR. +.PP +\fIcreateProc\fR is used to create platform-dependant windows. It is +invoked by \fBTk_MakeWindowExist\fR. \fIcreateProc\fR should have +arguments and results that match the type \fBTk_ClassCreateProc\fR: +.CS +typedef Window Tk_ClassCreateProc( + Tk_Window \fItkwin\fR, + Window \fIparent\fR, + ClientData \fIinstanceData\fR); +.CE +The \fItkwin\fR and \fIinstanceData\fR parameters will be identical to +the \fItkwin\fR and \fIinstanceData\fR parameters passed to +\fBTk_SetClassProcs\fR. The \fIparent\fR parameter will be the parent +of the window to be created. The \fIcreateProc\fR should return the +created window. +.PP +\fImodalProc\fR is invoked after all bindings on a widget have been +triggered in order to handle a modal loop. \fImodalProc\fR should +have arguments and results that match the type \fBTk_ClassModalProc\fR: +.CS +typedef void Tk_ClassModalProc( + Tk_Window \fItkwin\fR, + XEvent *\fIeventPtr\fR); +.CE +The \fItkwin\fR parameter to \fImodalProc\fR will be identical to the +\fItkwin\fR parameter passed to \fBTk_SetClassProcs\fR. The +\fIeventPtr\fR parameter will be a pointer to an XEvent structure +describing the event being processed. + +.SH KEYWORDS +callback, class diff --git a/tk/doc/SetGrid.3 b/tk/doc/SetGrid.3 index 6602b632876..d867ca4c3ee 100644 --- a/tk/doc/SetGrid.3 +++ b/tk/doc/SetGrid.3 @@ -65,4 +65,3 @@ management. .SH KEYWORDS grid, window, window manager - diff --git a/tk/doc/SetOptions.3 b/tk/doc/SetOptions.3 index dcb8f969719..925a68767d5 100644 --- a/tk/doc/SetOptions.3 +++ b/tk/doc/SetOptions.3 @@ -311,8 +311,8 @@ The \fIflags\fR field consists of one or more bits ORed together. At present only a single flag is supported: TK_OPTION_NULL_OK. If this bit is set for an option then an empty string will be accepted as the value for the option and the resulting internal form will be a -NULL pointer or \fBNone\fR, depending on the type of the option. -If the flag is not set then empty strings will result +NULL pointer, a zero value, or \fBNone\fR, depending on the type of +the option. If the flag is not set then empty strings will result in errors. TK_OPTION_NULL_OK is typically used to allow a feature to be turned off entirely, e.g. set a cursor value to @@ -368,10 +368,16 @@ such as \fBTk_SetOptions\fR, and when the option is set the cursor for the window is changed by calling \fBXDefineCursor\fR. This option type also supports the TK_OPTION_NULL_OK flag. .TP +\fBTK_OPTION_CUSTOM\fR +This option allows applications to define new option types. The +clientData field of the entry points to a structure defining the new +option type. See the section CUSTOM OPTION TYPES below for details. +.TP \fBTK_OPTION_DOUBLE\fR The string value must be a floating-point number in the format accepted by \fBstrtol\fR. The internal form is a C -\fBdouble\fR value. +\fBdouble\fR value. This option type supports the TK_OPTION_NULL_OK +flag; if a NULL value is set, the internal representation is set to zero. .TP \fBTK_OPTION_END\fR Marks the end of the template. There must be a Tk_OptionSpec structure @@ -406,12 +412,16 @@ The internal form is an integer value giving a distance in pixels, like the values returned by \fBTk_GetPixelsFromObj\fR. Note: if the \fIobjOffset\fR field isn't used then information about the original value of this option will be lost. -See \fBOBJOFFSET VS. INTERNALOFFSET\fR below for details. +See \fBOBJOFFSET VS. INTERNALOFFSET\fR below for details. This option +type supports the TK_OPTION_NULL_OK flag; if a NULL value is set, the +internal representation is set to zero. .TP \fBTK_OPTION_RELIEF\fR The value must be standard relief such as \fBraised\fR. The internal form is an integer relief value such as -TK_RELIEF_RAISED. +TK_RELIEF_RAISED. This option type supports the TK_OPTION_NULL_OK +flag; if the empty string is specified as the value for the option, +the integer relief value is set to TK_RELIEF_NULL. .TP \fBTK_OPTION_STRING\fR The value may be any string. The internal form is a (char *) pointer @@ -447,7 +457,7 @@ If a field of a widget record has its offset stored in the \fIobjOffset\fR or \fIinternalOffset\fR field of a Tk_OptionSpec structure then the procedures described here will handle all of the storage allocation and resource management issues associated with the field. When the value -of an option is changed, \fBTk_SetOptions\fR (or \fBTk_FreeSavedOptions\fR +of an option is changed, \fBTk_SetOptions\fR (or \fBTk_FreeSavedOptions\fR) will automatically free any resources associated with the old value, such as Tk_Fonts for TK_OPTION_FONT options or dynamically allocated memory for TK_OPTION_STRING options. For an option stored as an object using the @@ -491,13 +501,153 @@ on retrievals exists only for TK_OPTION_PIXELS options. .PP The second reason to use the \fIobjOffset\fR field is in order to implement new types of options not supported by these procedures. -To implement a new type of option, use TK_OPTION_STRING as +To implement a new type of option, you can use TK_OPTION_STRING as the type in the Tk_OptionSpec structure and set the \fIobjOffset\fR field but not the \fIinternalOffset\fR field. Then, after calling \fBTk_SetOptions\fR, convert the object to internal form yourself. +.SH "CUSTOM OPTION TYPES" +.PP +Applications can extend the built-in configuration types with +additional configuration types by writing procedures to parse, print, +free, and restore saved copies of the type and creating a structure +pointing to those procedures: +.CS +typedef struct Tk_ObjCustomOption { + char *name; + Tk_CustomOptionSetProc *\fIsetProc\fR; + Tk_CustomOptionGetProc *\fIgetProc\fR; + Tk_CustomOptionRestoreProc *\fIrestoreProc\fR; + Tk_CustomOptionFreeProc *\fIfreeProc\fR; + ClientData \fIclientData\fR; +} Tk_ObjCustomOption; + +typedef int Tk_CustomOptionSetProc( + ClientData \fIclientData\fR, + Tcl_Interp *\fIinterp\fR, + Tk_Window \fItkwin\fR, + Tcl_Obj **\fIvaluePtr\fR, + char *\fIrecordPtr\fR, + int \fIinternalOffset\fR, + char *\fIsaveInternalPtr\fR, + int \fIflags\fR); + +typedef Tcl_Obj *Tk_CustomOptionGetProc( + ClientData \fIclientData\fR, + Tk_Window \fItkwin\fR, + char *\fIrecordPtr\fR, + int \fIinternalOffset\fR); + +typedef void Tk_CustomOptionRestoreProc( + ClientData \fIclientData\fR, + Tk_Window \fItkwin\fR, + char *\fIinternalPtr\fR, + char *\fIsaveInternalPtr\fR); + +typedef void Tk_CustomOptionFreeProc( + ClientData \fIclientData\fR, + Tk_Window \fItkwin\fR, + char *\fIinternalPtr\fR); +.CE +.PP +The Tk_ObjCustomOption structure contains six fields: a name +for the custom option type; pointers to the four procedures; and a +\fIclientData\fR value to be passed to those procedures when they are +invoked. The \fIclientData\fR value typically points to a structure +containing information that is needed by the procedures when they are +parsing and printing options. \fIRestoreProc\fR and \fIfreeProc\fR +may be NULL, indicating that no function should be called for those +operations. +.PP +The \fIsetProc\fR procedure is invoked by \fBTk_SetOptions\fR to +convert a Tcl_Obj into an internal representation and store the +resulting value in the widget record. The arguments are: +.RS +.TP +\fIclientData\fR +A copy of the \fIclientData\fR field in the Tk_ObjCustomOption +structure. +.TP +\fIinterp\fR +A pointer to a Tcl interpreter, used for error reporting. +.TP +\fITkwin\fR +A copy of the \fItkwin\fR argument to \fBTk_SetOptions\fR +.TP +\fIvaluePtr\fR +A pointer to a reference to a Tcl_Obj describing the new value for the +option; it could have been specified explicitly in the call to +\fBTk_SetOptions\fR or it could come from the option database or a +default. If the objOffset for the option is non-negative (the option +value is stored as a (Tcl_Obj *) in the widget record), the Tcl_Obj +pointer referenced by \fIvaluePtr\fR is the pointer that will be +stored at the objOffset for the option. \fISetProc\fR may modify the +value if necessary; for example, \fIsetProc\fR may change the value to +NULL to support the TK_OPTION_NULL_OK flag. +.TP +\fIrecordPtr\fR +A pointer to the start of the widget record to modify. +.TP +\fIinternalOffset\fR +Offset in bytes from the start of the widget record to the location +where the internal representation of the option value is to be placed. +.TP +\fIsaveInternalPtr\fR +A pointer to storage allocated in a Tk_SavedOptions structure for the +internal representation of the original option value. Before setting +the option to its new value, \fIsetProc\fR should set the value +referenced by \fIsaveInternalPtr\fR to the original value of the +option in order to support \fBTk_RestoreSavedOptions\fR. +.TP +\fIflags\fR +A copy of the \fIflags\fR field in the Tk_OptionSpec structure for the +option +.RE +.PP +\fISetProc\fR returns a standard Tcl result: TCL_OK to indicate successful +processing, or TCL_ERROR to indicate a failure of any kind. An error +message may be left in the Tcl interpreter given by \fIinterp\fR in +the case of an error. +.PP +The \fIgetProc\fR procedure is invoked by \fBTk_GetOptionValue\fR and +\fBTk_GetOptionInfo\fR to retrieve a Tcl_Obj representation of the +internal representation of an option. The \fIclientData\fR argument +is a copy of the \fIclientData\fR field in the Tk_ObjCustomOption +structure. \fITkwin\fR is a copy of the \fItkwin\fR argument to +\fBTk_GetOptionValue\fR or \fBTk_GetOptionInfo\fR. \fIRecordPtr\fR +is a pointer to the beginning of the widget record to query. +\fIInternalOffset\fR is the offset in bytes from the beginning of the +widget record to the location where the internal representation of the +option value is stored. \fIGetProc\fR must return a pointer to a +Tcl_Obj representing the value of the option. +.PP +The \fIrestoreProc\fR procedure is invoked by +\fBTk_RestoreSavedOptions\fR to restore a previously saved internal +representation of a custom option value. The \fIclientData\fR argument +is a copy of the \fIclientData\fR field in the Tk_ObjCustomOption +structure. \fITkwin\fR is a copy of the \fItkwin\fR argument to +\fBTk_GetOptionValue\fR or \fBTk_GetOptionInfo\fR. \fIInternalPtr\fR +is a pointer to the location where internal representation of the +option value is stored. +\fISaveInternalPtr\fR is a pointer to the saved value. +\fIRestoreProc\fR must copy the value from \fIsaveInternalPtr\fR to +\fIinternalPtr\fR to restore the value. \fIRestoreProc\fR need not +free any memory associated with either \fIinternalPtr\fR or +\fIsaveInternalPtr\fR; \fIfreeProc\fR will be invoked to free that +memory if necessary. \fIRestoreProc\fR has no return value. +.PP +The \fIfreeProc\fR procedure is invoked by \fBTk_SetOptions\fR and +\fBTk_FreeSavedOptions\fR to free any storage allocated for the +internal representation of a custom option. The \fIclientData\fR argument +is a copy of the \fIclientData\fR field in the Tk_ObjCustomOption +structure. \fITkwin\fR is a copy of the \fItkwin\fR argument to +\fBTk_GetOptionValue\fR or \fBTk_GetOptionInfo\fR. \fIInternalPtr\fR +is a pointer to the location where the internal representation of the +option value is stored. The \fIfreeProc\fR must free any storage +associated with the option. \fIFreeProc\fR has no return value. + + .SH KEYWORDS anchor, bitmap, boolean, border, color, configuration option, cursor, double, font, integer, justify, pixels, relief, screen distance, synonym - diff --git a/tk/doc/SetVisual.3 b/tk/doc/SetVisual.3 index f349fe7b669..8895d3a36f9 100644 --- a/tk/doc/SetVisual.3 +++ b/tk/doc/SetVisual.3 @@ -52,4 +52,3 @@ call \fBTk_SetWindowColormap\fR instead. .SH KEYWORDS colormap, depth, visual - diff --git a/tk/doc/StrictMotif.3 b/tk/doc/StrictMotif.3 index 4b12e63b0b0..24c99051a2a 100644 --- a/tk/doc/StrictMotif.3 +++ b/tk/doc/StrictMotif.3 @@ -39,4 +39,3 @@ faster access to the variable's value than could be had by calling .SH KEYWORDS Motif compliance, tk_strictMotif variable - diff --git a/tk/doc/TextLayout.3 b/tk/doc/TextLayout.3 index bb00bb480aa..ba1273c5c99 100644 --- a/tk/doc/TextLayout.3 +++ b/tk/doc/TextLayout.3 @@ -278,4 +278,3 @@ actually drawn \- they are merely placeholders maintained in the \fIlayout\fR. .SH KEYWORDS font - diff --git a/tk/doc/TkInitStubs.3 b/tk/doc/TkInitStubs.3 index c8d6fc28181..3edd93555b4 100644 --- a/tk/doc/TkInitStubs.3 +++ b/tk/doc/TkInitStubs.3 @@ -7,7 +7,7 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH Tk_InitStubs 3 8.1 Tk "Tk Library Procedures" +.TH Tk_InitStubs 3 8.4 Tk "Tk Library Procedures" .BS .SH NAME Tk_InitStubs \- initialize the Tk stubs mechanism @@ -15,7 +15,7 @@ Tk_InitStubs \- initialize the Tk stubs mechanism .nf \fB#include \fR .sp -char * +CONST char * \fBTk_InitStubs\fR(\fIinterp, version, exact\fR) .SH ARGUMENTS .AS Tcl_Interp *interp in @@ -55,9 +55,9 @@ Define the USE_TCL_STUBS symbol. Typically, you would include the .IP 3) 5 Link the extension with the Tcl and Tk stubs libraries instead of the standard Tcl and Tk libraries. On Unix platforms, the library -names are \fIlibtclstub8.1.a\fR and \fIlibtkstub8.1.a\fR; on Windows -platforms, the library names are -\fItclstub81.lib\fR and \fItkstub81.lib\fR. +names are \fIlibtclstub8.4.a\fR and \fIlibtkstub8.4.a\fR; on Windows +platforms, the library names are \fItclstub84.lib\fR and \fItkstub84.lib\fR +(adjust names with appropriate version number). .SH DESCRIPTION \fBTk_InitStubs\fR attempts to initialize the Tk stub table pointers and ensure that the correct version of Tk is loaded. In addition diff --git a/tk/doc/Tk_Init.3 b/tk/doc/Tk_Init.3 index 4587f5012b5..b9be1e227f5 100644 --- a/tk/doc/Tk_Init.3 +++ b/tk/doc/Tk_Init.3 @@ -7,18 +7,20 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH Tk_Init 3 4.1 Tk "Tk Library Procedures" +.TH Tk_Init 3 8.0 Tk "Tk Library Procedures" .BS .SH NAME -Tk_Init \- add Tk to an interpreter and make a new Tk application. +Tk_Init, Tk_SafeInit \- add Tk to an interpreter and make a new Tk application. .SH SYNOPSIS .nf \fB#include \fR .sp int \fBTk_Init\fR(\fIinterp\fR) +.sp +int +\fBTk_SafeInit\fR(\fIinterp\fR) .SH ARGUMENTS -.AS Tcl_Interp *interp .AP Tcl_Interp *interp in Interpreter in which to load Tk. Tk should not already be loaded in this interpreter. @@ -42,7 +44,45 @@ new Tk application. The options may have any of the forms documented for the \fBwish\fR application (in fact, \fBwish\fR uses Tk_Init to process its command-line arguments). +.PP +\fBTk_SafeInit\fR is identical to \fBTk_Init\fR except that it removes +all Tk commands that are considered unsafe. Those commands and the +reasons for their exclusion are: +.TP +\fBbell\fR +Continuous ringing of the bell is a nuisance. +.TP +\fBclipboard\fR +A malicious script could replace the contents of the clipboard with +the string \fB"rm -r *"\fR and lead to surprises when the contents of +the clipboard are pasted. +.TP +\fBgrab\fR +Grab can be used to block the user from using any other applications. +.TP +\fBmenu\fR +Menus can be used to cover the entire screen and to steal input from +the user. +.TP +\fBselection\fR +See clipboard. +.TP +\fBsend\fR +Send can be used to cause unsafe interpreters to execute commands. +.TP +\fBtk\fR +The tk command recreates the send command, which is unsafe. +.TP +\fBtkwait\fR +Tkwait can block the containing process forever +.TP +\fBtoplevel\fR +Toplevels can be used to cover the entire screen and to steal input +from the user. +.TP +\fBwm\fR +If toplevels are ever allowed, wm can be used to remove decorations, +move windows around, etc. .SH KEYWORDS -application, initialization, load, main window - +safe, application, initialization, load, main window diff --git a/tk/doc/Tk_Main.3 b/tk/doc/Tk_Main.3 index 813f6ba6f88..72f506638ed 100644 --- a/tk/doc/Tk_Main.3 +++ b/tk/doc/Tk_Main.3 @@ -59,4 +59,3 @@ for \fBTcl_AppInit\fR. .SH KEYWORDS application-specific initialization, command-line arguments, main program - diff --git a/tk/doc/WindowId.3 b/tk/doc/WindowId.3 index 26cf5828fdb..c414644597b 100644 --- a/tk/doc/WindowId.3 +++ b/tk/doc/WindowId.3 @@ -8,10 +8,10 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH Tk_WindowId 3 "" Tk "Tk Library Procedures" +.TH Tk_WindowId 3 "8.4" Tk "Tk Library Procedures" .BS .SH NAME -Tk_WindowId, Tk_Parent, Tk_Display, Tk_DisplayName, Tk_ScreenNumber, Tk_Screen, Tk_X, Tk_Y, Tk_Width, Tk_Height, Tk_Changes, Tk_Attributes, Tk_IsContainer, Tk_IsEmbedded, Tk_IsMapped, Tk_IsTopLevel, Tk_ReqWidth, Tk_ReqHeight, Tk_InternalBorderWidth, Tk_Visual, Tk_Depth, Tk_Colormap \- retrieve information from Tk's local data structure +Tk_WindowId, Tk_Parent, Tk_Display, Tk_DisplayName, Tk_ScreenNumber, Tk_Screen, Tk_X, Tk_Y, Tk_Width, Tk_Height, Tk_Changes, Tk_Attributes, Tk_IsContainer, Tk_IsEmbedded, Tk_IsMapped, Tk_IsTopLevel, Tk_ReqWidth, Tk_ReqHeight, Tk_MinReqWidth, Tk_MinReqHeight, Tk_InternalBorderLeft, Tk_InternalBorderRight, Tk_InternalBorderTop, Tk_InternalBorderBottom, Tk_Visual, Tk_Depth, Tk_Colormap \- retrieve information from Tk's local data structure .SH SYNOPSIS .nf \fB#include \fR @@ -25,7 +25,7 @@ Tk_Window Display * \fBTk_Display\fR(\fItkwin\fR) .sp -char * +CONST char * \fBTk_DisplayName\fR(\fItkwin\fR) .sp int @@ -71,7 +71,22 @@ int \fBTk_ReqHeight\fR(\fItkwin\fR) .sp int -\fBTk_InternalBorderWidth\fR(\fItkwin\fR) +\fBTk_MinReqWidth\fR(\fItkwin\fR) +.sp +int +\fBTk_MinReqHeight\fR(\fItkwin\fR) +.sp +int +\fBTk_InternalBorderLeft\fR(\fItkwin\fR) +.sp +int +\fBTk_InternalBorderRight\fR(\fItkwin\fR) +.sp +int +\fBTk_InternalBorderTop\fR(\fItkwin\fR) +.sp +int +\fBTk_InternalBorderBottom\fR(\fItkwin\fR) .sp Visual * \fBTk_Visual\fR(\fItkwin\fR) @@ -145,10 +160,16 @@ screen) and zero if \fItkwin\fR isn't a top-level window. the window's requested size. These values correspond to the last call to \fBTk_GeometryRequest\fR for \fItkwin\fR. .PP -\fBTk_InternalBorderWidth\fR returns the width of internal border -that has been requested for \fItkwin\fR, or 0 if no internal border -was requested. The return value is simply the last value passed -to \fBTk_SetInternalBorder\fR for \fItkwin\fR. +\fBTk_MinReqWidth\fR and \fBTk_MinReqHeight\fR return information about +the window's minimum requested size. These values correspond to the last +call to \fBTk_SetMinimumRequestSize\fR for \fItkwin\fR. +.PP +\fBTk_InternalBorderLeft\fR, \fBTk_InternalBorderRight\fR, +\fBTk_InternalBorderTop\fR and \fBTk_InternalBorderBottom\fR +return the width of one side of the internal border +that has been requested for \fItkwin\fR, or 0 if no internal border was +requested. The return value is simply the last value passed to +\fBTk_SetInternalBorder\fR or \fBTk_SetInternalBorderEx\fR for \fItkwin\fR. .PP \fBTk_Visual\fR, \fBTk_Depth\fR, and \fBTk_Colormap\fR return information about the visual characteristics of a window. @@ -163,4 +184,3 @@ they may be overridden by calling \fBTk_SetWindowVisual\fR. attributes, colormap, depth, display, height, geometry manager, identifier, mapped, requested size, screen, top-level, visual, width, window, x, y - diff --git a/tk/doc/bell.n b/tk/doc/bell.n index 312983d360a..3b0e50cbd86 100644 --- a/tk/doc/bell.n +++ b/tk/doc/bell.n @@ -1,6 +1,7 @@ '\" '\" Copyright (c) 1994 The Regents of the University of California. '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. +'\" Copyright (c) 2000 Ajuba Solutions. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -8,13 +9,13 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH bell n 4.0 Tk "Tk Built-In Commands" +.TH bell n 8.4 Tk "Tk Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME bell \- Ring a display's bell .SH SYNOPSIS -\fBbell \fR?\fB\-displayof \fIwindow\fR? +\fBbell \fR?\fB\-displayof \fIwindow\fR? ?\fB\-nice\fR? .BE .SH DESCRIPTION @@ -26,10 +27,9 @@ application's main window is used by default. The command uses the current bell-related settings for the display, which may be modified with programs such as \fBxset\fR. .PP -This command also resets the screen saver for the screen. Some -screen savers will ignore this, but others will reset so that the -screen becomes visible again. +If \fB\-nice\fR is not specified, this command also resets the screen saver +for the screen. Some screen savers will ignore this, but others will reset +so that the screen becomes visible again. .SH KEYWORDS beep, bell, ring - diff --git a/tk/doc/bind.n b/tk/doc/bind.n index 6618f446c05..82b3e1b6d67 100644 --- a/tk/doc/bind.n +++ b/tk/doc/bind.n @@ -119,7 +119,7 @@ Modifiers consist of any of the following values: \fBButton3, B3\fR \fBAlt\fR \fBButton4, B4\fR \fBDouble\fR \fBButton5, B5\fR \fBTriple\fR -\fBMod1, M1\fR +\fBMod1, M1\fR \fBQuadruple\fR .DE Where more than one value is listed, separated by commas, the values are equivalent. @@ -145,16 +145,15 @@ Similarly, the \fBAlt\fR modifier refers to whichever modifier is associated with the alt key(s) on the keyboard (keysyms \fBAlt_L\fR and \fBAlt_R\fR). .PP -The \fBDouble\fR and \fBTriple\fR modifiers are a convenience -for specifying double mouse clicks and other repeated -events. They cause a particular event pattern to be -repeated 2 or 3 times, and also place a time and space requirement -on the sequence: for a sequence of events to match a \fBDouble\fR -or \fBTriple\fR pattern, all of the events must occur close together -in time and without substantial mouse motion in between. -For example, \fB\fR -is equivalent to \fB\fR with the extra -time and space requirement. +The \fBDouble\fR, \fBTriple\fR and \fBQuadruple\fR modifiers are a +convenience for specifying double mouse clicks and other repeated +events. They cause a particular event pattern to be repeated 2, 3 or 4 +times, and also place a time and space requirement on the sequence: for a +sequence of events to match a \fBDouble\fR, \fBTriple\fR or \fBQuadruple\fR +pattern, all of the events must occur close together in time and without +substantial mouse motion in between. For example, \fB\fR +is equivalent to \fB\fR with the extra time and space +requirement. .SH "EVENT TYPES" .PP @@ -163,18 +162,18 @@ few extra abbreviations. The \fItype\fR field will also accept a 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 C +.DS .ta 5c 10c -\fBActivate Enter Map -ButtonPress, Button Expose Motion -.VS -ButtonRelease FocusIn MouseWheel -.VE -Circulate FocusOut Property +\fBActivate Destroy Map +ButtonPress, Button Enter MapRequest +ButtonRelease Expose Motion +Circulate FocusIn MouseWheel +CirculateRequest FocusOut Property Colormap Gravity Reparent -Configure KeyPress, Key Unmap -Deactivate KeyRelease Visibility -Destroy Leave\fR +Configure KeyPress, Key ResizeRequest +ConfigureRequest KeyRelease Unmap +Create Leave Visibility +Deactivate\fR .DE .PP .VS @@ -291,6 +290,13 @@ NotifyDetailNone NotifyPointer NotifyInferior NotifyPointerRoot NotifyNonlinear NotifyVirtual\fR .DE +For \fBConfigureRequest\fR events, the string will be one of: +.DS +.ta 6c +\fBAbove Opposite +Below None +BottomIf TopIf\fR +.DE For events other than these, the substituted string is undefined. .RE .IP \fB%f\fR 5 @@ -298,9 +304,13 @@ The \fIfocus\fR field from the event (\fB0\fR or \fB1\fR). Valid only for \fBEnter\fR and \fBLeave\fR events. .IP \fB%h\fR 5 .VS -The \fIheight\fR field from the event. Valid for the \fBConfigure\fR and +The \fIheight\fR field from the event. Valid for the \fBConfigure\fR, +\fBConfigureRequest\fR, \fBCreate\fR, \fBResizeRequest\fR, and \fBExpose\fR events. .VE +.IP \fB%i\fR 5 +The \fIwindow\fR field from the event, represented as a hexadecimal +integer. .IP \fB%k\fR 5 The \fIkeycode\fR field from the event. Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events. @@ -317,7 +327,7 @@ The \fIoverride_redirect\fR field from the event. Valid only for .IP \fB%p\fR 5 The \fIplace\fR field from the event, substituted as one of the strings \fBPlaceOnTop\fR or \fBPlaceOnBottom\fR. Valid only -for \fBCirculate\fR events. +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, @@ -331,7 +341,8 @@ contain a \fItime\fR field. .IP \fB%w\fR 5 The \fIwidth\fR field from the event. Valid only for .VS -\fBConfigure\fR and \fBExpose\fR events. +\fBConfigure\fR, \fBConfigureRequest\fR, \fBCreate\fR, +\fBResizeRequest\fR, and \fBExpose\fR events. .VE .IP \fB%x\fR 5 The \fIx\fR field from the event. Valid only for events containing @@ -347,7 +358,7 @@ work of translating from the event to an ASCII character. Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events. .IP \fB%B\fR 5 The \fIborder_width\fR field from the event. Valid only for -\fBConfigure\fR events. +\fBConfigure\fR, \fBConfigureRequest\fR, and \fBCreate\fR events. .VS .IP \fB%D\fR 5 This reports the \fIdelta\fR value of a \fBMouseWheel\fR event. The @@ -417,7 +428,7 @@ string (open square bracket) as its first argument. If the extra backslash hadn't been added, Tcl would not have been able to parse the script correctly. -.SH MULTIPLE MATCHES +.SH "MULTIPLE MATCHES" .PP It is possible for several bindings to match a given X event. If the bindings are associated with different \fItag\fR's, @@ -437,7 +448,6 @@ associated with other \fItag\fR's. If the \fBbreak\fR command is invoked within a binding script, then that script terminates and no other scripts will be invoked for the event. -.VS .PP If more than one binding matches a particular event and they have the same \fItag\fR, then the most specific binding @@ -451,7 +461,6 @@ of events matched) is more specific than a shorter sequence; (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. -.VS (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. @@ -478,7 +487,6 @@ If the user types Control-y, the \fB<>\fR binding will be invoked, but if the user presses button 2 then one of either the \fB<>\fR or the \fB<>\fR bindings will be invoked, but exactly which one gets invoked is undefined. -.VE .PP If an X event does not match any of the existing bindings, then the event is ignored. @@ -517,8 +525,7 @@ The \fBbgerror\fR command will be executed at global level (outside the context of any Tcl procedure). .SH "SEE ALSO" -bgerror +bgerror, keysyms .SH KEYWORDS form, manual - diff --git a/tk/doc/bindtags.n b/tk/doc/bindtags.n index 1f6a30a5323..20e5291f459 100644 --- a/tk/doc/bindtags.n +++ b/tk/doc/bindtags.n @@ -79,4 +79,3 @@ bind .SH KEYWORDS binding, event, tag - diff --git a/tk/doc/bitmap.n b/tk/doc/bitmap.n index 21c4135337a..0fa1c5afda9 100644 --- a/tk/doc/bitmap.n +++ b/tk/doc/bitmap.n @@ -112,4 +112,3 @@ this case the command returns an empty string. .SH KEYWORDS bitmap, image - diff --git a/tk/doc/button.n b/tk/doc/button.n index 6cda7367623..ca07c4827cd 100644 --- a/tk/doc/button.n +++ b/tk/doc/button.n @@ -16,18 +16,31 @@ button \- Create and manipulate button widgets .SH SYNOPSIS \fBbutton\fR \fIpathName \fR?\fIoptions\fR? .SO -\-activebackground \-cursor \-highlightthickness \-takefocus -\-activeforeground \-disabledforeground \-image \-text -\-anchor \-font \-justify \-textvariable -\-background \-foreground \-padx \-underline -\-bitmap \-highlightbackground \-pady \-wraplength -\-borderwidth \-highlightcolor \-relief +\-activebackground \-foreground \-repeatdelay +\-activeforeground \-highlightbackground \-repeatinterval +\-anchor \-highlightcolor \-takefocus +\-background \-highlightthickness \-text +\-bitmap \-image \-textvariable +\-borderwidth \-justify \-underline +\-cursor \-padx \-wraplength +\-disabledforeground \-pady +\-font \-relief .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-command command Command Specifies a Tcl command to associate with the button. This command is typically invoked when mouse button 1 is released over the button window. +.VS 8.4 +.OP \-compound compound Compound +Specifies whether the button should display both an image and text, +and if so, where the image should be placed relative to the text. +Valid values for this option are \fBbottom\fR, \fBcenter\fR, +\fBleft\fR, \fBnone\fR, \fBright\fR and \fBtop\fR. The default value +is \fBnone\fR, meaning that the button will display either an image or +text, depending on the values of the \fB\-image\fR and \fB\-bitmap\fR +options. +.VE .OP \-default default Default .VS Specifies one of three states for the default ring: \fBnormal\fR, @@ -49,6 +62,15 @@ screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR); for text it is in lines of text. If this option isn't specified, the button's desired height is computed from the size of the image or bitmap or text being displayed in it. +.VS 8.4 +.OP \-overrelief overRelief OverRelief +Specifies an alternative relief for the button, to be used when the +mouse cursor is over the widget. This option can be used to make +toolbar buttons, by configuring \fB\-relief flat \-overrelief +raised\fR. If the value of this option is the empty string, then no +alternative relief is used when the mouse cursor is over the button. +The empty string is the default value. +.VE 8.4 .OP \-state state State Specifies one of three states for the button: \fBnormal\fR, \fBactive\fR, or \fBdisabled\fR. In normal state the button is displayed using the @@ -174,4 +196,3 @@ individual widgets or by redefining the class bindings. .SH KEYWORDS button, widget - diff --git a/tk/doc/canvas.n b/tk/doc/canvas.n index b4c7d90c6d1..b67622799a2 100644 --- a/tk/doc/canvas.n +++ b/tk/doc/canvas.n @@ -17,11 +17,13 @@ canvas \- Create and manipulate canvas widgets .SH SYNOPSIS \fBcanvas\fR \fIpathName \fR?\fIoptions\fR? .SO -\-background \-highlightthickness \-insertwidth \-relief -\-borderwidth \-insertbackground \-state -\-cursor \-insertborderwidth \-selectbackground \-takefocus -\-highlightbackground \-insertofftime \-selectborderwidth \-xscrollcommand -\-highlightcolor \-insertontime \-selectforeground \-yscrollcommand +\-background \-insertborderwidth \-selectborderwidth +\-borderwidth \-insertofftime \-selectforeground +\-cursor \-insertontime \-takefocus +\-highlightbackground \-insertwidth \-xscrollcommand +\-highlightcolor \-relief \-yscrollcommand +\-highlightthickness \-state +\-insertbackground \-selectbackground .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-closeenough closeEnough CloseEnough @@ -167,7 +169,7 @@ item or a tag that selects zero or more items. tags by using operators: '&&', '||', '^' '!', and parenthezised subexpressions. For example: .CS - .c find withtag {(a&&!b)|(!a&&b)} + .c find withtag {(a&&!b)||(!a&&b)} .CE or equivalently: .CS @@ -196,6 +198,11 @@ the screen; if it is \fBc\fR then the distance is in centimeters; \fBi\fR means inches, and \fBp\fR means printers points (1/72 inch). Larger y-coordinates refer to points lower on the screen; larger x-coordinates refer to points farther to the right. +.VS +Coordinates can be specified either as an even number of parameters, +or as a single list parameter containing an even number of x and y +coordinate values. +.VE .SH TRANSFORMATIONS .PP @@ -283,7 +290,7 @@ are drawn transparant. The second possible syntax is a character list containing only 5 possible characters \fB[.,-_ ]\fR. The space can be used to enlarge the space between other line elements, and can not -occur as the first posibion in the string. Some examples: +occur as the first position in the string. Some examples: -dash . = -dash {2 4} -dash - = -dash {6 4} -dash -. = -dash {6 4 2 4} @@ -297,11 +304,11 @@ list will be multiplied by the line width before display. This assures that "." will always be displayed as a dot and "-" always as a dash regardless of the line width. .PP -On systems where only a limited set of dash patterns, the dash -pattern will be displayed as the most close dash pattern that -is available. For example, on Windows only the first 4 of the -above examples are available. The last 2 examples will be -displayed identically as the first one. +On systems which support only a limited set of dash patterns, the dash +pattern will be displayed as the closest dash pattern that is available. +For example, on Windows only the first 4 of the above examples are +available. The last 2 examples will be displayed identically to the first +one. .SH "WIDGET COMMAND" .PP @@ -485,6 +492,8 @@ this case the command returns an empty string. command. .TP \fIpathName\fR \fBcoords \fItagOrId \fR?\fIx0 y0 ...\fR? +.TP +\fIpathName\fR \fBcoords \fItagOrId \fR?\fIcoordList\fR? Query or modify the coordinates that define an item. If no coordinates are specified, this command returns a list whose elements are the coordinates of the item named by @@ -495,6 +504,8 @@ If \fItagOrId\fR refers to multiple items, then the first one in the display list is used. .TP \fIpathName \fBcreate \fItype x y \fR?\fIx y ...\fR? ?\fIoption value ...\fR? +.TP +\fIpathName \fBcreate \fItype coordList \fR?\fIoption value ...\fR? Create a new item in \fIpathName\fR of type \fItype\fR. The exact format of the arguments after \fBtype\fR depends on \fBtype\fR, but usually they consist of the coordinates for @@ -1023,15 +1034,17 @@ explained here, and then referred to be each widget type for brevity. \fB\-activedash \fIpattern\fR .TP \fB\-disableddash \fIpattern\fR -This option specifies dash patterns for the normal state, the active -state, and the disabled state of an arc item. +This option specifies dash patterns for the normal, active +state, and disabled state of an item. \fIpattern\fR may have any of the forms accepted by \fBTk_GetDash\fR. If the dash options are omitted then the default is a solid outline. See "DASH PATTERNS" for more information. .TP \fB\-dashoffset \fIoffset\fR -The starting \fIoffset\fR into the pattern provided by the \fB\-dash\fR option. -\fB\-dashoffset\fR is ignored if there is no \fB-dash\fR pattern. +The starting \fIoffset\fR in pixels into the pattern provided by the +\fB\-dash\fR option. \fB\-dashoffset\fR is ignored if there is no +\fB-dash\fR pattern. The \fIoffset\fR may have any of the forms described +in the COORDINATES section above. .TP \fB\-fill \fIcolor\fR .TP @@ -1064,7 +1077,7 @@ Specifies the offset of stipples. The offset value can be of the form first case the origin is the origin of the toplevel of the current window. For the canvas itself and canvas objects the origin is the canvas origin, but putting \fB#\fR in front of the coordinate pair indicates using the -toplevel origin in stead. For canvas objects, the \fB-offset\fR option is +toplevel origin instead. For canvas objects, the \fB-offset\fR option is used for stippling as well. For the line and polygon canvas items you can also specify an index as argument, which connects the stipple origin to one of the coordinate points of the line/polygon. @@ -1132,8 +1145,9 @@ one of several ways (specified by the \fB\-style\fR option). Arcs are created with widget commands of the following form: .CS \fIpathName \fBcreate arc \fIx1 y1 x2 y2 \fR?\fIoption value option value ...\fR? +\fIpathName \fBcreate arc \fIcoordList\fR ?\fIoption value option value ...\fR? .CE -The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR give +The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR or \fIcoordList\fR give the coordinates of two diagonally opposite corners of a rectangular region enclosing the oval that defines the arc. After the coordinates there may be any number of \fIoption\fR\-\fIvalue\fR @@ -1202,8 +1216,9 @@ two colors, foreground and background. Bitmaps are created with widget commands of the following form: .CS \fIpathName \fBcreate bitmap \fIx y \fR?\fIoption value option value ...\fR? +\fIpathName \fBcreate bitmap \fIcoordList\fR ?\fIoption value option value ...\fR? .CE -The arguments \fIx\fR and \fIy\fR specify the coordinates of a +The arguments \fIx\fR and \fIy\fR or \fIcoordList\fR specify the coordinates of a point used to position the bitmap on the display (see the \fB\-anchor\fR option below for more information on how bitmaps are displayed). After the coordinates there may be any number of \fIoption\fR\-\fIvalue\fR @@ -1266,8 +1281,9 @@ canvas. Images are created with widget commands of the following form: .CS \fIpathName \fBcreate image \fIx y \fR?\fIoption value option value ...\fR? +\fIpathName \fBcreate image \fIcoordList\fR ?\fIoption value option value ...\fR? .CE -The arguments \fIx\fR and \fIy\fR specify the coordinates of a +The arguments \fIx\fR and \fIy\fR or \fIcoordList\fR specify the coordinates of a point used to position the image on the display (see the \fB\-anchor\fR option below for more information). After the coordinates there may be any number of \fIoption\fR\-\fIvalue\fR @@ -1311,8 +1327,9 @@ widget commands: \fBdchars, index, insert.\fR Lines are created with widget commands of the following form: .CS \fIpathName \fBcreate line \fIx1 y1... xn yn \fR?\fIoption value option value ...\fR? +\fIpathName \fBcreate line \fIcoordList\fR ?\fIoption value option value ...\fR? .CE -The arguments \fIx1\fR through \fIyn\fR give +The arguments \fIx1\fR through \fIyn\fR or \fIcoordList\fR give the coordinates for a series of two or more points that describe a series of connected line segments. After the coordinates there may be any number of \fIoption\fR\-\fIvalue\fR @@ -1380,8 +1397,12 @@ If this option isn't specified then it defaults to \fBmiter\fR. If the line only contains two points then this option is irrelevant. .TP -\fB\-smooth \fIboolean\fR -\fIBoolean\fR must have one of the forms accepted by \fBTk_GetBoolean\fR. +\fB\-smooth \fIsmoothMethod\fR +\fIsmoothMethod\fR must have one of the forms accepted by +\fBTk_GetBoolean\fR or a line smoothing method. Only \fBbezier\fR is +supported in the core, but more can be added at runtime. If a boolean +false value or empty string is given, no smoothing is applied. A boolean +truth value assume \fBbezier\fR smoothing. It indicates whether or not the line should be drawn as a curve. If so, the line is rendered as a set of parabolic splines: one spline is drawn for the first and second line segments, one for the second @@ -1401,8 +1422,9 @@ both. Ovals are created with widget commands of the following form: .CS \fIpathName \fBcreate oval \fIx1 y1 x2 y2 \fR?\fIoption value option value ...\fR? +\fIpathName \fBcreate oval \fIcoordList\fR ?\fIoption value option value ...\fR? .CE -The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR give +The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR or \fIcoordList\fR give the coordinates of two diagonally opposite corners of a rectangular region enclosing the oval. The oval will include the top and left edges of the rectangle @@ -1450,8 +1472,9 @@ widget commands: \fBdchars, index, insert.\fR Polygons are created with widget commands of the following form: .CS \fIpathName \fBcreate polygon \fIx1 y1 ... xn yn \fR?\fIoption value option value ...\fR? +\fIpathName \fBcreate polygon \fIcoordList\fR ?\fIoption value option value ...\fR? .CE -The arguments \fIx1\fR through \fIyn\fR specify the coordinates for +The arguments \fIx1\fR through \fIyn\fR or \fIcoordList\fR specify the coordinates for three or more points that define a polygon. The first point should not be repeated as the last to close the shape; Tk will automatically close the periphery between @@ -1528,8 +1551,9 @@ both. Rectangles are created with widget commands of the following form: .CS \fIpathName \fBcreate rectangle \fIx1 y1 x2 y2 \fR?\fIoption value option value ...\fR? +\fIpathName \fBcreate rectangle \fIcoordList\fR ?\fIoption value option value ...\fR? .CE -The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR give +The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR or \fIcoordList\fR give the coordinates of two diagonally opposite corners of the rectangle (the rectangle will include its upper and left edges but not its lower or right edges). @@ -1577,8 +1601,9 @@ Text items are created with widget commands of the following form: .CS \fIpathName \fBcreate text \fIx y \fR?\fIoption value option value ...\fR? +\fIpathName \fBcreate text \fIcoordList\fR ?\fIoption value option value ...\fR? .CE -The arguments \fIx\fR and \fIy\fR specify the coordinates of a +The arguments \fIx\fR and \fIy\fR or \fIcoordList\fR specify the coordinates of a point used to position the text on the display (see the options below for more information on how text is displayed). After the coordinates there may be any number of \fIoption\fR\-\fIvalue\fR @@ -1612,7 +1637,7 @@ This option defaults to \fBcenter\fR. .TP \fB\-font \fIfontName\fR Specifies the font to use for the text item. -\fIFontName\fR may be any string acceptable to \fBTk_GetFontStruct\fR. +\fIFontName\fR may be any string acceptable to \fBTk_GetFont\fR. If this option isn't specified, it defaults to a system-dependent font. .TP @@ -1649,8 +1674,9 @@ at a given position on the canvas. Window items are created with widget commands of the following form: .CS \fIpathName \fBcreate window \fIx y \fR?\fIoption value option value ...\fR? +\fIpathName \fBcreate window \fIcoordList\fR ?\fIoption value option value ...\fR? .CE -The arguments \fIx\fR and \fIy\fR specify the coordinates of a +The arguments \fIx\fR and \fIy\fR or \fIcoordList\fR specify the coordinates of a point used to position the window on the display (see the \fB\-anchor\fR option below for more information on how bitmaps are displayed). After the coordinates there may be any number of \fIoption\fR\-\fIvalue\fR @@ -1722,4 +1748,3 @@ functions of canvases. .SH KEYWORDS canvas, widget - diff --git a/tk/doc/checkbutton.n b/tk/doc/checkbutton.n index 4e8a2c01319..15e457f47c1 100644 --- a/tk/doc/checkbutton.n +++ b/tk/doc/checkbutton.n @@ -16,12 +16,14 @@ checkbutton \- Create and manipulate checkbutton widgets .SH SYNOPSIS \fBcheckbutton\fI pathName \fR?\fIoptions\fR? .SO -\-activebackground \-cursor \-highlightthickness \-takefocus -\-activeforeground \-disabledforeground \-image \-text -\-anchor \-font \-justify \-textvariable -\-background \-foreground \-padx \-underline -\-bitmap \-highlightbackground \-pady \-wraplength -\-borderwidth \-highlightcolor \-relief +\-activebackground \-font \-pady +\-activeforeground \-foreground \-relief +\-anchor \-highlightbackground \-takefocus +\-background \-highlightcolor \-text +\-bitmap \-highlightthickness \-textvariable +\-borderwidth \-image \-underline +\-cursor \-justify \-wraplength +\-disabledforeground \-padx .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-command command Command @@ -41,12 +43,32 @@ Specifies whether or not the indicator should be drawn. Must be a proper boolean value. If false, the \fBrelief\fR option is ignored and the widget's relief is always sunken if the widget is selected and raised otherwise. +.VS 8.4 +.OP \-offrelief offRelief OffRelief +Specifies the relief for the checkbutton when the indicator is not drawn and +the checkbutton is off. The default value is "raised". By setting this option +to "flat" and setting -indicatoron to false and -overrelief to raised, +the effect is achieved +of having a flat button that raises on mouse-over and which is +depressed when activated. This is the behavior typically exhibited by +the Bold, Italic, and Underline checkbuttons on the toolbar of a +word-processor, for example. +.VE 8.4 .OP \-offvalue offValue Value Specifies value to store in the button's associated variable whenever this button is deselected. Defaults to ``0''. .OP \-onvalue onValue Value Specifies value to store in the button's associated variable whenever this button is selected. Defaults to ``1''. +.VS 8.4 +.OP \-overrelief overRelief OverRelief +Specifies an alternative relief for the checkbutton, to be used when the +mouse cursor is over the widget. This option can be used to make +toolbar buttons, by configuring \fB\-relief flat \-overrelief +raised\fR. If the value of this option is the empty string, then no +alternative relief is used when the mouse cursor is over the checkbutton. +The empty string is the default value. +.VE 8.4 .OP \-selectcolor selectColor Background Specifies a background color to use when the button is selected. If \fBindicatorOn\fR is true then the color applies to the indicator. @@ -236,4 +258,3 @@ individual widgets or by redefining the class bindings. .SH KEYWORDS checkbutton, widget - diff --git a/tk/doc/chooseColor.n b/tk/doc/chooseColor.n index 6936030f169..18b5feffe2f 100644 --- a/tk/doc/chooseColor.n +++ b/tk/doc/chooseColor.n @@ -47,4 +47,3 @@ button .b \-fg [tk_chooseColor \-initialcolor gray \-title "Choose color"] .SH KEYWORDS color selection dialog - diff --git a/tk/doc/chooseDirectory.n b/tk/doc/chooseDirectory.n index 0322b294ba8..17edd7e5cc3 100644 --- a/tk/doc/chooseDirectory.n +++ b/tk/doc/chooseDirectory.n @@ -50,4 +50,3 @@ tk_getOpenFile, tk_getSaveFile .SH KEYWORDS directory selection dialog - diff --git a/tk/doc/clipboard.n b/tk/doc/clipboard.n index 76a28d647fc..0825cf8c0ff 100644 --- a/tk/doc/clipboard.n +++ b/tk/doc/clipboard.n @@ -8,7 +8,7 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH clipboard n 4.0 Tk "Tk Built-In Commands" +.TH clipboard n 8.4 Tk "Tk Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME @@ -20,7 +20,8 @@ clipboard \- Manipulate Tk clipboard .SH DESCRIPTION .PP This command provides a Tcl interface to the Tk clipboard, -which stores data for later retrieval using the selection mechanism. +which stores data for later retrieval using the selection mechanism +(via the \fB-selection CLIPBOARD\fR option). In order to copy data into the clipboard, \fBclipboard clear\fR must be called, followed by a sequence of one or more calls to \fBclipboard append\fR. To ensure that the clipboard is updated atomically, all @@ -76,7 +77,18 @@ next argument will always be used as \fIdata\fR. This feature may be convenient if, for example, \fIdata\fR starts with a \fB\-\fR. .RE +.TP +.VS 8.4 +\fBclipboard get\fR ?\fB\-displayof\fR \fIwindow\fR? ?\fB\-type\fR? +Retrieve data from the clipboard on \fIwindow\fR's display. +\fIwindow\fR defaults to ".". \fIType\fR specifies the form in which +the data is to be returned and should be an atom name such as STRING +or FILE_NAME. \fIType\fR defaults to STRING. This command is +equivalent to \fBselection get -selection CLIPBOARD\fR. +.VE 8.4 + +.SH "SEE ALSO" +selection .SH KEYWORDS clear, format, clipboard, append, selection, type - diff --git a/tk/doc/colors.n b/tk/doc/colors.n index 8b304fac72b..239de5bcd02 100644 --- a/tk/doc/colors.n +++ b/tk/doc/colors.n @@ -45,12 +45,12 @@ bisque4 139 125 125 black 0 0 0 blanched almond 255 235 235 BlanchedAlmond 255 235 235 -blue 0 0 0 +blue 0 0 255 blue violet 138 43 43 -blue1 0 0 0 -blue2 0 0 0 -blue3 0 0 0 -blue4 0 0 0 +blue1 0 0 255 +blue2 0 0 238 +blue3 0 0 205 +blue4 0 0 139 BlueViolet 138 43 43 brown 165 42 42 brown1 255 64 64 @@ -95,7 +95,7 @@ cyan1 0 255 255 cyan2 0 238 238 cyan3 0 205 205 cyan4 0 139 139 -dark blue 0 0 0 +dark blue 0 0 139 dark cyan 0 139 139 dark goldenrod 184 134 134 dark gray 169 169 169 @@ -114,7 +114,7 @@ dark slate gray 47 79 79 dark slate grey 47 79 79 dark turquoise 0 206 206 dark violet 148 0 0 -DarkBlue 0 0 0 +DarkBlue 0 0 139 DarkCyan 0 139 139 DarkGoldenrod 184 134 134 DarkGoldenrod1 255 185 185 @@ -538,7 +538,7 @@ maroon2 238 48 48 maroon3 205 41 41 maroon4 139 28 28 medium aquamarine 102 205 205 -medium blue 0 0 0 +medium blue 0 0 205 medium orchid 186 85 85 medium purple 147 112 112 medium sea green 60 179 179 @@ -547,7 +547,7 @@ medium spring green 0 250 250 medium turquoise 72 209 209 medium violet red 199 21 21 MediumAquamarine 102 205 205 -MediumBlue 0 0 0 +MediumBlue 0 0 205 MediumOrchid 186 85 85 MediumOrchid1 224 102 102 MediumOrchid2 209 95 95 @@ -580,9 +580,9 @@ NavajoWhite1 255 222 222 NavajoWhite2 238 207 207 NavajoWhite3 205 179 179 NavajoWhite4 139 121 121 -navy 0 0 0 -navy blue 0 0 0 -NavyBlue 0 0 0 +navy 0 0 128 +navy blue 0 0 128 +NavyBlue 0 0 128 old lace 253 245 245 OldLace 253 245 245 olive drab 107 142 142 diff --git a/tk/doc/console.n b/tk/doc/console.n new file mode 100644 index 00000000000..8b80e4bb52f --- /dev/null +++ b/tk/doc/console.n @@ -0,0 +1,142 @@ +'\" +'\" Copyright (c) 2001 Donal K. Fellows +'\" +'\" See the file "license.terms" for information on usage and redistribution +'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. +'\" +'\" RCS: @(#) $Id$ +'\" +.so man.macros +.TH console n 8.4 Tk "Tk Built-In Commands" +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +console \- Control the console on systems without a real console +.SH SYNOPSIS +\fBconsole title \fR?\fIstring\fR? +.sp +\fBconsole hide\fR +.sp +\fBconsole show\fR +.sp +\fBconsole eval \fIscript\fR +.BE + +.SH DESCRIPTION +.PP +The console window is a replacement for a real console to allow input +and output on the standard I/O channels on platforms that do not have +a real console. It is implemented as a separate interpreter with the +Tk toolkit loaded, and control over this interpreter is given through +the \fBconsole\fR command. The behaviour of the console window is +defined mainly through the contents of the \fIconsole.tcl\fR file in +the Tk library (or the \fIConsole\fR resource on Macintosh systems.) +.PP +.TP +\fBconsole eval \fIscript\fR +Evaluate the \fIscript\fR argument as a Tcl script in the console +interpreter. The normal interpreter is accessed through the +\fBconsoleinterp\fR command in the console interpreter. +.TP +\fBconsole hide\fR +Hide the console window from view. Precisely equivalent to +withdrawing the \fB.\fR window in the console interpreter. +.TP +\fBconsole show\fR +Display the console window. Precisely equivalent to deiconifying the +\fB.\fR window in the console interpreter. +.TP +\fBconsole title \fR?\fIstring\fR? +Query or modify the title of the console window. If \fIstring\fR is +not specified, queries the title of the console window, and sets the +title of the console window to \fIstring\fR otherwise. Precisely +equivalent to using the \fBwm title\fR command in the console +interpreter. + +.SH "ACCESS TO THE MAIN INTERPRETER" +.PP +The \fBconsoleinterp\fR command in the console interpreter allows +scripts to be evaluated in the main interpreter. It supports two +subcommands: \fBeval\fR and \fBrecord\fR. +.PP +.TP +\fBconsoleinterp eval \fIscript\fR +Evaluates \fIscript\fR as a Tcl script at the global level in the main +interpreter. +.TP +\fBconsoleinterp record \fIscript\fR +Records and evaluates \fIscript\fR as a Tcl script at the global level +in the main interpreter as if \fIscript\fR had been typed in at the +console. + +.SH "ADDITIONAL TRAP CALLS" +.PP +There are several additional commands in the console interpreter that +are called in response to activity in the main interpreter. +\fIThese are documented here for completeness only; they form part of +the internal implementation of the console and are likely to change or +be modified without warning.\fR +.PP +Output to the console from the main interpreter via the stdout and +stderr channels is handled by invoking the \fBtk::ConsoleOutput\fR +command in the console interpreter with two arguments. The first +argument is the name of the channel being written to, and the second +argument is the string being written to the channel (after encoding +and end-of-line translation processing has been performed.) +.PP +When the \fB.\fR window of the main interpreter is destroyed, the +\fBtk::ConsoleExit\fR command in the console interpreter is called +(assuming the console interpreter has not already been deleted itself, +that is.) + +.SH "DEFAULT BINDINGS" +.PP +The default script creates a console window (implemented using a text +widget) that has the following behaviour: +.IP [1] +Pressing the tab key inserts a TAB character (as defined by the Tcl +\et escape.) +.IP [2] +Pressing the return key causes the current line (if complete by the +rules of \fBinfo complete\fR) to be passed to the main interpreter for +evaluation. +.IP [3] +Pressing the delete key deletes the selected text (if any text is +selected) or the character to the right of the cursor (if not at the +end of the line.) +.IP [4] +Pressing the backspace key deletes the selected text (if any text is +selected) or the character to the left of the cursor (of not at the +start of the line.) +.IP [5] +Pressing either Control+A or the home key causes the cursor to go to +the start of the line (but after the prompt, if a prompt is present on +the line.) +.IP [6] +Pressing either Control+E or the end key causes the cursor to go to +the end of the line. +.IP [7] +Pressing either Control+P or the up key causes the previous entry in +the command history to be selected. +.IP [8] +Pressing either Control+N or the down key causes the next entry in the +command history to be selected. +.IP [9] +Pressing either Control+B or the left key causes the cursor to move +one character backward as long as the cursor is not at the prompt. +.IP [10] +Pressing either Control+F or the right key causes the cursor to move +one character forward. +.IP [11] +Pressing F9 rebuilds the console window by destroying all its children +and reloading the Tcl script that defined the console's behaviour. +.PP +Most other behaviour is the same as a conventional text widget except +for the way that the \fI<>\fR event is handled identically to the +\fI<>\fR event. + +.SH KEYWORDS +console, interpreter, window, interactive, output channels + +.SH "SEE ALSO" +destroy(n), fconfigure(n), history(n), interp(n), puts(n), text(n), wm(n) diff --git a/tk/doc/destroy.n b/tk/doc/destroy.n index 11c3cf8e70f..f144ad86ebd 100644 --- a/tk/doc/destroy.n +++ b/tk/doc/destroy.n @@ -32,4 +32,3 @@ No error is returned if \fIwindow\fR does not exist. .SH KEYWORDS application, destroy, window - diff --git a/tk/doc/dialog.n b/tk/doc/dialog.n index 17665d21f30..bd30e197b14 100644 --- a/tk/doc/dialog.n +++ b/tk/doc/dialog.n @@ -63,4 +63,3 @@ in any way except to invoke the dialog box. .SH KEYWORDS bitmap, dialog, modal - diff --git a/tk/doc/entry.n b/tk/doc/entry.n index a62e551fc49..a00fb6c2fb2 100644 --- a/tk/doc/entry.n +++ b/tk/doc/entry.n @@ -17,14 +17,24 @@ entry \- Create and manipulate entry widgets .SH SYNOPSIS \fBentry\fR \fIpathName \fR?\fIoptions\fR? .SO -\-background \-highlightbackground \-insertontime \-selectforeground -\-borderwidth \-highlightcolor \-insertwidth \-takefocus -\-cursor \-highlightthickness \-justify \-textvariable -\-exportselection \-insertbackground \-relief \-xscrollcommand -\-font \-insertborderwidth \-selectbackground -\-foreground \-insertofftime \-selectborderwidth +\-background \-highlightthickness \-selectbackground +\-borderwidth \-insertbackground \-selectborderwidth +\-cursor \-insertborderwidth \-selectforeground +\-exportselection \-insertofftime \-takefocus +\-font \-insertontime \-textvariable +\-foreground \-insertwidth \-xscrollcommand +\-highlightbackground \-justify +\-highlightcolor \-relief .SE .SH "WIDGET-SPECIFIC OPTIONS" +.VS 8.4 +.OP \-disabledbackground disabledBackground DisabledBackground +Specifies the background color to use when the entry is disabled. If +this option is the empty string, the normal background color is used. +.OP \-disabledforeground disabledForeground DisabledForeground +Specifies the foreground color to use when the entry is disabled. If +this option is the empty string, the normal foreground color is used. +.VE 8.4 .VS 8.3 .OP "\-invalidcommand or \-invcmd" invalidCommand InvalidCommand Specifies a script to eval when \fBvalidateCommand\fR returns 0. @@ -32,6 +42,11 @@ Setting it to {} disables this feature (the default). The best use of this option is to set it to \fIbell\fR. See \fBValidation\fR below for more information. .VE +.VS 8.4 +.OP \-readonlybackground readonlyBackground ReadonlyBackground +Specifies the background color to use when the entry is readonly. If +this option is the empty string, the normal background color is used. +.VE .OP \-show show Show If this option is specified, then the true contents of the entry are not displayed in the window. @@ -42,11 +57,18 @@ a password. If characters in the entry are selected and copied elsewhere, the information copied will be what is displayed, not the true contents of the entry. +.VS 8.4 .OP \-state state State -Specifies one of two states for the entry: \fBnormal\fR or \fBdisabled\fR. -If the entry is disabled then the value may not be changed using widget -commands and no insertion cursor will be displayed, even if the input focus is -in the widget. +Specifies one of three states for the entry: \fBnormal\fR, +\fBdisabled\fR, or \fBreadonly\fR. If the entry is readonly, then the +value may not be changed using widget commands and no insertion cursor +will be displayed, even if the input focus is in the widget; the +contents of the widget may still be selected. If the entry is +disabled, the value may not be changed, no insertion cursor will be +displayed, the contents will not be selectable, and the entry may +be displayed in a different color, depending on the values of the +\fB-disabledforeground\fR and \fB-disabledbackground\fR options. +.VE 8.4 .VS 8.3 .OP \-validate validate Validate Specifies the mode in which validation should operate: \fBnone\fR, @@ -123,7 +145,7 @@ loses focus. .IP \fBall\fR 10 \fBvalidateCommand\fR will be called for all above conditions. .PP -It is posible to perform percent substitutions on the \fBvalidateCommand\fR +It is possible to perform percent substitutions on the \fBvalidateCommand\fR and \fBinvalidCommand\fR, just as you would in a \fBbind\fR script. The following substitutions are recognized: @@ -513,12 +535,15 @@ the insertion cursor. If the entry is disabled using the \fB\-state\fR option, then the entry's view can still be adjusted and text in the entry can still be selected, but no insertion cursor will be displayed and no text modifications will -take place. +take place +.VS +except if the entry is linked to a variable using the \fB\-textvariable\fR +option, in which case any changes to the variable are reflected by the +entry whatever the value of its \fB\-state\fR option. +.VE .PP The behavior of entries can be changed by defining new bindings for individual widgets or by redefining the class bindings. .SH KEYWORDS entry, widget - - diff --git a/tk/doc/event.n b/tk/doc/event.n index dc63b699126..1df47c4ada5 100644 --- a/tk/doc/event.n +++ b/tk/doc/event.n @@ -1,6 +1,6 @@ '\" '\" Copyright (c) 1996 Sun Microsystems, Inc. -'\" Copyright (c) 1998 by Scriptics Corporation. +'\" Copyright (c) 1998-2000 Ajuba Solutions. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -68,7 +68,8 @@ EVENT FIELDS below. If the \fB\-when\fR option is not specified, the event is processed immediately: all of the handlers for the event will complete before the \fBevent generate\fR command returns. If the \fB\-when\fR option is specified then it determines when the -event is processed. +event is processed. Certain events, such as key events, require +that the window has focus to receive the event properly. .TP \fBevent info \fR?<<\fIvirtual\fB>>\fR? Returns information about virtual events. @@ -363,4 +364,3 @@ bind .SH KEYWORDS event, binding, define, handle, virtual event - diff --git a/tk/doc/focus.n b/tk/doc/focus.n index 98015763b54..496563c943f 100644 --- a/tk/doc/focus.n +++ b/tk/doc/focus.n @@ -111,4 +111,3 @@ you use C code to query the X server directly. .SH KEYWORDS events, focus, keyboard, top-level, window manager - diff --git a/tk/doc/focusNext.n b/tk/doc/focusNext.n index 34d4be22d3e..a98e0fc56ad 100644 --- a/tk/doc/focusNext.n +++ b/tk/doc/focusNext.n @@ -58,4 +58,3 @@ to write a script that deletes the bindings created by .SH KEYWORDS focus, keyboard traversal, top-level - diff --git a/tk/doc/font.n b/tk/doc/font.n index 8da646a986b..e644ebeb13c 100644 --- a/tk/doc/font.n +++ b/tk/doc/font.n @@ -269,12 +269,14 @@ All valid X font names, including those listed by xlsfonts(1), are available. .TP MS Windows: .DS +.ta 3c 6c \fBsystem ansi device systemfixed ansifixed oemfixed\fR .DE .TP Macintosh: .DS +.ta 3c 6c \fBsystem application\fR .DE .RE @@ -283,4 +285,3 @@ options .SH KEYWORDS font - diff --git a/tk/doc/frame.n b/tk/doc/frame.n index fb15271f5ae..b2e88d472f0 100644 --- a/tk/doc/frame.n +++ b/tk/doc/frame.n @@ -9,7 +9,7 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH frame n 8.0 Tk "Tk Built-In Commands" +.TH frame n 8.4 Tk "Tk Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME @@ -17,8 +17,9 @@ frame \- Create and manipulate frame widgets .SH SYNOPSIS \fBframe\fR \fIpathName\fR ?\fIoptions\fR? .SO -\-borderwidth \-highlightbackground \-highlightthickness \-takefocus -\-cursor \-highlightcolor \-relief +\-borderwidth \-highlightcolor \-pady +\-cursor \-highlightthickness \-relief +\-highlightbackground \-padx \-takefocus .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-background background Background @@ -45,7 +46,6 @@ If the \fBcolormap\fR option is not specified, the new window uses the same colormap as its parent. This option may not be changed with the \fBconfigure\fR widget command. -.VS "" br .OP \-container container Container The value must be a boolean. If true, it means that this window will be used as a container in which some other application will be embedded @@ -55,7 +55,6 @@ things like geometry requests. The window should not have any children of its own in this application. This option may not be changed with the \fBconfigure\fR widget command. -.VE .OP \-height height Height Specifies the desired height for the window in any of the forms acceptable to \fBTk_GetPixels\fR. @@ -130,6 +129,8 @@ command. When a new frame is created, it has no default event bindings: frames are not intended to be interactive. +.SH "SEE ALSO" +labelframe(n), toplevel(n) + .SH KEYWORDS frame, widget - diff --git a/tk/doc/getOpenFile.n b/tk/doc/getOpenFile.n index 88390e29fef..3c12dc1a7c5 100644 --- a/tk/doc/getOpenFile.n +++ b/tk/doc/getOpenFile.n @@ -12,8 +12,6 @@ '\" Note: do not modify the .SH NAME line immediately below! .SH NAME tk_getOpenFile, tk_getSaveFile \- pop up a dialog box for the user to select a file to open or save. -.PP -.PP .SH SYNOPSIS \fBtk_getOpenFile \fR?\fIoption value ...\fR? .br @@ -44,7 +42,11 @@ Specifies a string that will be appended to the filename if the user enters a filename without an extension. The defaut value is the empty string, which means no extension will be appended to the filename in any case. This option is ignored on the Macintosh platform, which -does not require extensions to filenames. +does not require extensions to filenames, +.VS 8.4 +and the UNIX implementation guesses reasonable values for this from +the \fB\-filetypes\fR option when this is not supplied. +.VE 8.4 .TP \fB\-filetypes\fR \fIfilePatternList\fR If a \fBFile types\fR listbox exists in the file dialog on the particular @@ -72,10 +74,10 @@ option is ignored on the Macintosh platform. .TP \fB\-multiple\fR Allows the user to choose multiple files from the Open dialog. -This is only available on the Macintosh, and only when Navigation -Services are installed. +On the Macintosh, this is only available when Navigation Services are +installed. .TP -\fB\-message\fR +\fB\-message\fR \fIstring\fR Specifies a message to include in the client area of the dialog. This is only available on the Macintosh, and only when Navigation Services are installed. diff --git a/tk/doc/grab.n b/tk/doc/grab.n index e4038b94c8f..2d261d9c723 100644 --- a/tk/doc/grab.n +++ b/tk/doc/grab.n @@ -120,4 +120,3 @@ processes, this restriction doesn't exist. .SH KEYWORDS grab, keyboard events, pointer events, window - diff --git a/tk/doc/grid.n b/tk/doc/grid.n index d4a8ac844dc..ee40d2169c9 100644 --- a/tk/doc/grid.n +++ b/tk/doc/grid.n @@ -7,7 +7,7 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH grid n 4.1 Tk "Tk Built-In Commands" +.TH grid n 8.4 Tk "Tk Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME @@ -25,9 +25,11 @@ The \fBgrid\fR command can have any of several forms, depending on the \fIoption\fR argument: .TP \fBgrid \fIslave \fR?\fIslave ...\fR? ?\fIoptions\fR? -If the first argument to \fBgrid\fR is a window name (any value -starting with ``.''), then the command is processed in the same -way as \fBgrid configure\fR. +If the first argument to \fBgrid\fR is suitable as the first slave +argument to \fBgrid configure\fR, either a window name (any value +starting with \fB.\fP) or one of the characters \fBx\fP or \fB^\fP +(see the ``RELATIVE PLACEMENT'' section below), then the command is +processed in the same way as \fBgrid configure\fR. .TP \fBgrid bbox \fImaster\fR ?\fIcolumn row\fR? ?\fIcolumn2 row2\fR? With no arguments, @@ -44,11 +46,12 @@ indicated is returned. \fBgrid columnconfigure \fImaster index \fR?\fI\-option value...\fR? Query or set the column properties of the \fIindex\fP column of the geometry master, \fImaster\fP. -The valid options are \fB\-minsize\fP, \fB\-weight\fP and \fB-pad\fP. -.VS +.VS 8.4 +The valid options are \fB\-minsize\fP, \fB\-weight\fP, \fB\-uniform\fP +and \fB-pad\fP. +.VE If one or more options are provided, then \fIindex\fP may be given as a list of column indeces to which the configuration options will operate on. -.VE The \fB\-minsize\fP option sets the minimum size, in screen units, that will be permitted for this column. The \fB\-weight\fP option (an integer value) @@ -58,6 +61,14 @@ columns. A weight of zero (0) indicates the column will not deviate from its requested size. A column whose weight is two will grow at twice the rate as a column of weight one when extra space is allocated to the layout. +.VS 8.4 +The \fB-uniform\fP option, when a non-empty value is supplied, places +the column in a \fIuniform group\fP with other columns that have the +same value for \fB-uniform\fP. The space for columns belonging to a +uniform group is allocated so that their sizes are always in strict +proportion to their \fB-weight\fP values. See +``THE GRID ALGORITHM'' below for further details. +.VE The \fB-pad\fP option specifies the number of screen units that will be added to the largest window contained completely in that column when the grid geometry manager requests a size from the containing window. @@ -113,12 +124,16 @@ The \fIamount\fR defaults to 0. \fB\-padx \fIamount\fR The \fIamount\fR specifies how much horizontal external padding to leave on each side of the slave(s), in screen units. +\fIAmount\fR may be a list +of two values to specify padding for left and right separately. The \fIamount\fR defaults to 0. This space is added outside the slave(s) border. .TP \fB\-pady \fIamount\fR The \fIamount\fR specifies how much vertical external padding to leave on the top and bottom of the slave(s), in screen units. +\fIAmount\fR may be a list +of two values to specify padding for top and bottom separately. The \fIamount\fR defaults to 0. This space is added outside the slave(s) border. .TP @@ -189,11 +204,12 @@ Propagation is enabled by default. \fBgrid rowconfigure \fImaster index \fR?\fI\-option value...\fR? Query or set the row properties of the \fIindex\fP row of the geometry master, \fImaster\fP. -The valid options are \fB\-minsize\fP, \fB\-weight\fP and \fB-pad\fP. -.VS +.VS 8.4 +The valid options are \fB\-minsize\fP, \fB\-weight\fP, \fB\-uniform\fP +and \fB-pad\fP. +.VE If one or more options are provided, then \fIindex\fP may be given as a list of row indeces to which the configuration options will operate on. -.VE The \fB\-minsize\fP option sets the minimum size, in screen units, that will be permitted for this row. The \fB\-weight\fP option (an integer value) @@ -203,6 +219,14 @@ rows. A weight of zero (0) indicates the row will not deviate from its requested size. A row whose weight is two will grow at twice the rate as a row of weight one when extra space is allocated to the layout. +.VS 8.4 +The \fB-uniform\fP option, when a non-empty value is supplied, places +the row in a \fIuniform group\fP with other rows that have the +same value for \fB-uniform\fP. The space for rows belonging to a +uniform group is allocated so that their sizes are always in strict +proportion to their \fB-weight\fP values. See +``THE GRID ALGORITHM'' below for further details. +.VE The \fB-pad\fP option specifies the number of screen units that will be added to the largest window contained completely in that row when the grid geometry manager requests a size from the containing window. @@ -245,14 +269,15 @@ default values are chosen for at the time the \fIslave\fP is managed. The values are chosen based upon the current layout of the grid, the position of the \fIslave\fP relative to other \fIslave\fPs in the same grid command, and the presence -of the characters \fB\-\fP, \fB^\fP, and \fB^\fP in \fBgrid\fP +of the characters \fB\-\fP, \fBx\fP, and \fB^\fP in \fBgrid\fP command where \fIslave\fP names are normally expected. .RS .TP \fB\-\fP This increases the columnspan of the \fIslave\fP to the left. Several \fB\-\fP's in a row will successively increase the columnspan. A \fB\-\fP -may not follow a \fB^\fP or a \fBx\fP. +may not follow a \fB^\fP or a \fBx\fP, nor may it be the first \fIslave\fP +argument to \fBgrid configure\fR. .TP \fBx\fP This leaves an empty column between the \fIslave\fP on the left and @@ -279,14 +304,31 @@ To compute the minimum size of a layout, the grid geometry manager first looks at all slaves whose columnspan and rowspan values are one, and computes the nominal size of each row or column to be either the \fIminsize\fP for that row or column, or the sum of the \fIpad\fPding -plus the size of the largest slave, whichever is greater. Then the -slaves whose rowspans or columnspans are greater than one are +plus the size of the largest slave, whichever is greater. After that +the rows or columns in each uniform group adapt to each other. Then +the slaves whose rowspans or columnspans are greater than one are examined. If a group of rows or columns need to be increased in size in order to accommodate these slaves, then extra space is added to each row or column in the group according to its \fIweight\fP. For each group whose weights are all zero, the additional space is apportioned equally. .PP +When multiple rows or columns belong to a uniform group, the space +allocated to them is always in proportion to their weights. (A weight +of zero is considered to be 1.) In other words, a row or column +configured with \fB-weight 1 -uniform a\fP will have exactly the same +size as any other row or column configured with \fB-weight 1 -uniform +a\fP. A row or column configured with \fB-weight 2 -uniform b\fR will +be exactly twice as large as one that is configured with \fB-weight 1 +-uniform b\fP. +.PP +More technically, each row or column in the group will have a size +equal to \fIk*weight\fP for some constant \fIk\fP. The constant +\fIk\fP is chosen so that no row or column becomes smaller than its +minimum size. For example, if all rows or columns in a group have the +same weight, then each row or column will have the same size as the +largest row or column in the group. +.PP For masters whose size is larger than the requested layout, the additional space is apportioned according to the row and column weights. If all of the weights are zero, the layout is centered within its master. @@ -335,4 +377,3 @@ geometry manager written by Doug. Stein, and the \fBblt_table\fR geometry manager, written by George Howlett. .SH KEYWORDS geometry manager, location, grid, cell, propagation, size, pack - diff --git a/tk/doc/image.n b/tk/doc/image.n index e03cc849c02..7f26cbf94a0 100644 --- a/tk/doc/image.n +++ b/tk/doc/image.n @@ -37,6 +37,10 @@ type; see below for details on the options for built-in image types. If an image already exists by the given name then it is replaced with the new image and any instances of that image will redisplay with the new contents. +It is important to note that the image command will silently overwrite any +procedure that may currently be defined by the given name, so choose the +name wisely. It is recommended to use a separate namespace for image names +(e.g., \fB::img::logo\fR, \fB::img::large\fR). .TP \fBimage delete \fR?\fIname name\fR ...? Deletes each of the named images and returns an empty string. @@ -54,6 +58,10 @@ the existing instances will use the new image. Returns a decimal string giving the height of image \fIname\fR in pixels. .TP +\fBimage inuse \fIname\fR +Returns a boolean value indicating whether or not the image given by +\fIname\fR is in use by any widgets. +.TP \fBimage names\fR Returns a list containing the names of all existing images. .TP @@ -88,4 +96,3 @@ See the \fBphoto\fR manual entry for more information. .SH KEYWORDS height, image, types of images, width - diff --git a/tk/doc/label.n b/tk/doc/label.n index 0410d82d848..274592d1e79 100644 --- a/tk/doc/label.n +++ b/tk/doc/label.n @@ -16,14 +16,14 @@ label \- Create and manipulate label widgets .SH SYNOPSIS \fBlabel\fR \fIpathName \fR?\fIoptions\fR? .SO -\-activebackground \-activeforeground \-anchor -\-background \-bitmap \-borderwidth -\-cursor \-disabledforeground \-font -\-foreground \-highlightbackground \-highlightcolor -\-highlightthickness \-image \-justify -\-padx \-pady \-relief -\-takefocus \-text \-textvariable -\-underline \-wraplength +\-activebackground \-font \-pady +\-activeforeground \-foreground \-relief +\-anchor \-highlightbackground \-takefocus +\-background \-highlightcolor \-text +\-bitmap \-highlightthickness \-textvariable +\-borderwidth \-image \-underline +\-cursor \-justify \-wraplength +\-disabledforeground \-padx .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-height height Height @@ -112,5 +112,3 @@ labels are not intended to be interactive. .SH KEYWORDS label, widget - - diff --git a/tk/doc/labelframe.n b/tk/doc/labelframe.n new file mode 100644 index 00000000000..29ac99c29c6 --- /dev/null +++ b/tk/doc/labelframe.n @@ -0,0 +1,147 @@ +'\" +'\" Copyright (c) 1990-1994 The Regents of the University of California. +'\" Copyright (c) 1994-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. +'\" +'\" +'\" RCS: @(#) $Id$ +'\" +.so man.macros +.TH labelframe n 8.4 Tk "Tk Built-In Commands" +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +labelframe \- Create and manipulate labelframe widgets +.SH SYNOPSIS +\fBlabelframe\fR \fIpathName\fR ?\fIoptions\fR? +.SO +\-borderwidth \-highlightbackground \-pady +\-cursor \-highlightcolor \-relief +\-font \-highlightthickness \-takefocus +\-foreground \-padx \-text +.SE +.SH "WIDGET-SPECIFIC OPTIONS" +.OP \-background background Background +This option is the same as the standard \fBbackground\fR option +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. +.OP \-class class Class +Specifies a class for the window. +This class will be used when querying the option database for +the window's other options, and it will also be used later for +other purposes such as bindings. +The \fBclass\fR option may not be changed with the \fBconfigure\fR +widget command. +.OP \-colormap colormap Colormap +Specifies a colormap to use for the window. +The value may be either \fBnew\fR, in which case a new colormap is +created for the window and its children, or the name of another +window (which must be on the same screen and have the same visual +as \fIpathName\fR), in which case the new window will use the colormap +from the specified window. +If the \fBcolormap\fR option is not specified, the new window +uses the same colormap as its parent. +This option may not be changed with the \fBconfigure\fR +widget command. +.OP \-container container Container +The value must be a boolean. If true, it means that this window will +be used as a container in which some other application will be embedded +(for example, a Tk toplevel can be embedded using the \fB\-use\fR option). +The window will support the appropriate window manager protocols for +things like geometry requests. The window should not have any +children of its own in this application. +This option may not be changed with the \fBconfigure\fR +widget command. +.OP \-height height Height +Specifies the desired height for the window in any of the forms +acceptable to \fBTk_GetPixels\fR. +If this option is less than or equal to zero then the window will +not request any size at all. +.OP \-labelanchor labelAnchor LabelAnchor +Specifies where to place the label. A label is only displayed if the +\fB\-text\fR option is not the empty string. +Valid values for this option are (listing them clockwise) +\fBnw\fR, \fBn\fR, \fBne\fR, \fBen\fR, \fBe\fR, \fBes\fR, +\fBse\fR, \fBs\fR,\fBsw\fR, \fBws\fR, \fBw\fR and \fBwn\fR. +The default value is \fBnw\fR. +.OP \-labelwidget labelWidget LabelWidget +Specifies a widget to use as label. This overrides any \fB\-text\fR +option. The widget must exist before being used as \fB\-labelwidget\fR +and if it is not a descendant of this window, it will be raised +above it in the stacking order. +.OP \-visual visual Visual +Specifies visual information for the new window in any of the +forms accepted by \fBTk_GetVisual\fR. +If this option is not specified, the new window will use the same +visual as its parent. +The \fBvisual\fR option may not be modified with the \fBconfigure\fR +widget command. +.OP \-width width Width +Specifies the desired width for the window in any of the forms +acceptable to \fBTk_GetPixels\fR. +If this option is less than or equal to zero then the window will +not request any size at all. +.BE + +.SH DESCRIPTION +.PP +The \fBlabelframe\fR command creates a new window (given by the +\fIpathName\fR argument) and makes it into a labelframe widget. +Additional +options, described above, may be specified on the command line +or in the option database +to configure aspects of the labelframe such as its background color +and relief. The \fBlabelframe\fR command returns the +path name of the new window. +.PP +A labelframe is a simple widget. Its primary purpose is to act as a +spacer or container for complex window layouts. It has the features +of a \fBframe\fR plus the ability to display a label. +.SH "WIDGET COMMAND" +.PP +The \fBlabelframe\fR command creates a new Tcl command whose +name is the same as the path name of the labelframe's window. This +command may be used to invoke various +operations on the widget. It has the following general form: +.CS +\fIpathName option \fR?\fIarg arg ...\fR? +.CE +\fIPathName\fR is the name of the command, which is the same as +the labelframe 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 \fBlabelframe\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 +information on the format of this list). If \fIoption\fR is specified +with no \fIvalue\fR, then the command returns a list describing the +one named option (this list will be identical to the corresponding +sublist of the value returned if no \fIoption\fR is specified). If +one or more \fIoption\-value\fR pairs are specified, then the command +modifies the given widget option(s) to have the given value(s); in +this case the command returns an empty string. +\fIOption\fR may have any of the values accepted by the \fBlabelframe\fR +command. + +.SH BINDINGS +.PP +When a new labelframe is created, it has no default event bindings: +labelframes are not intended to be interactive. + +.SH "SEE ALSO" +frame(n), label(n) + +.SH KEYWORDS +labelframe, widget diff --git a/tk/doc/listbox.n b/tk/doc/listbox.n index 424e8d473d9..ad86edf567c 100644 --- a/tk/doc/listbox.n +++ b/tk/doc/listbox.n @@ -8,7 +8,7 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH listbox n 8.0 Tk "Tk Built-In Commands" +.TH listbox n 8.4 Tk "Tk Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME @@ -16,29 +16,45 @@ listbox \- Create and manipulate listbox widgets .SH SYNOPSIS \fBlistbox\fR \fIpathName \fR?\fIoptions\fR? .SO -\-background \-foreground \-relief \-takefocus -\-borderwidth \-height \-listvar \-selectbackground \-width -\-cursor \-highlightbackground \-selectborderwidth \-xscrollcommand -\-exportselection \-highlightcolor \-selectforeground \-yscrollcommand -\-font \-highlightthickness \-setgrid +\-activestyle \-height \-selectforeground +\-background \-highlightbackground \-setgrid +\-borderwidth \-highlightcolor \-state +\-cursor \-highlightthickness \-takefocus +\-disabledforeground \-relief \-width +\-exportselection \-selectbackground \-xscrollcommand +\-font \-selectborderwidth \-yscrollcommand +\-foreground .SE .SH "WIDGET-SPECIFIC OPTIONS" +.VS 8.4 +.OP \-activestyle activeStyle ActiveStyle +Specifies the style in which to draw the active element. This must be +one of \fBdotbox\fR (show a focus ring around the active element), +\fBnone\fR (nospecial indication of active element) or +\fBunderline\fR (underline the active element). +The default is \fBunderline\fR. +.VS 8.4 .OP \-height height Height Specifies the desired height for the window, in lines. If zero or less, then the desired height for the window is made just large enough to hold all the elements in the listbox. -.OP \-listvar listVariable Variable -Specifies the name of a variable. The value of the variable is a list -to be displayed inside the widget; if the variable value changes -then the widget will automatically update itself to reflect the new value. -Attempts to assign a bad list value to a variable in use as a listvar -will cause an error. Attempts to unset a variable in use as a listvar -will fail but will not generate an error. +.OP \-listvariable listVariable Variable +Specifies the name of a variable. The value of the variable is a list to +be displayed inside the widget; if the variable value changes then the +widget will automatically update itself to reflect the new value. Attempts +to assign a variable with an invalid list value to \fB\-listvariable\fR +will cause an error. Attempts to unset a variable in use as a +\fB\-listvariable\fR will fail but will not generate an error. .OP \-selectmode selectMode SelectMode Specifies one of several styles for manipulating the selection. The value of the option may be arbitrary, but the default bindings expect it to be either \fBsingle\fR, \fBbrowse\fR, \fBmultiple\fR, or \fBextended\fR; the default value is \fBbrowse\fR. +.OP \-state state State +Specifies one of two states for the listbox: \fBnormal\fR or \fBdisabled\fR. +If the listbox is disabled then items may not be inserted or deleted, +items are drawn in the \fB-disabledforeground\fR color, and selection +cannot be modified and is not shown (though selection information is retained). .OP \-width width Width Specifies the desired width for the window in characters. If the font doesn't have a uniform width then the width of the @@ -93,8 +109,8 @@ to the first element in the listbox. .TP 12 \fBactive\fR Indicates the element that has the location cursor. This element -will be displayed with an underline when the listbox has the -keyboard focus, and it is specified with the \fBactivate\fR +will be displayed as specified by \fB\-activestyle\fR when the listbox +has the keyboard focus, and it is specified with the \fBactivate\fR widget command. .TP 12 \fBanchor\fR @@ -138,8 +154,8 @@ Sets the active element to the one indicated by \fIindex\fR. If \fIindex\fR is outside the range of elements in the listbox then the closest element is activated. .VE -The active element is drawn with an underline when the widget -has the input focus, and its index may be retrieved with the +The active element is drawn as specified by \fB\-activestyle\fR when the +widget has the input focus, and its index may be retrieved with the index \fBactive\fR. .TP \fIpathName \fBbbox\fR \fIindex\fR @@ -538,4 +554,3 @@ individual widgets or by redefining the class bindings. .SH KEYWORDS listbox, widget - diff --git a/tk/doc/loadTk.n b/tk/doc/loadTk.n index ef73f381937..4a1ca940b5d 100644 --- a/tk/doc/loadTk.n +++ b/tk/doc/loadTk.n @@ -29,20 +29,20 @@ The \fB::safe::loadTk\fR command initializes the required data structures in the named safe interpreter and then loads Tk into it. The command returns the name of the safe interpreter. If \fB\-use\fR is specified, the window identified by the specified system -dependent identifier \fIwindowId\fR is used to contain the \fB``.''\fR +dependent identifier \fIwindowId\fR is used to contain the ``.'' window of the safe interpreter; it can be any valid id, eventually referencing a window belonging to another application. As a convenience, if the window you plan to use is a Tk Window of the application you can use the window name (eg: \fB.x.y\fR) instead of its window Id (\fB[winfo id .x.y]\fR). When \fB\-use\fR is not specified, -a new toplevel window is created for the \fB``.''\fR window of +a new toplevel window is created for the ``.'' window of the safe interpreter. On X11 if you want the embedded window to use another display than the default one, specify it with \fB\-display\fR. See the \fBSECURITY ISSUES\fR section below for implementation details. -.SH SECURITY ISSUES +.SH "SECURITY ISSUES" .PP Please read the \fBsafe\fR manual page for Tcl to learn about the basic security considerations for Safe Tcl. @@ -74,4 +74,3 @@ safe(n), interp(n), library(n), load(n), package(n), source(n), unknown(n) .SH KEYWORDS alias, auto\-loading, auto_mkindex, load, master interpreter, safe interpreter, slave interpreter, source - diff --git a/tk/doc/lower.n b/tk/doc/lower.n index c2c81b4d276..8738c23e465 100644 --- a/tk/doc/lower.n +++ b/tk/doc/lower.n @@ -36,4 +36,3 @@ raise .SH KEYWORDS lower, obscure, stacking order - diff --git a/tk/doc/man.macros b/tk/doc/man.macros index ae66ef928af..2f418cbae96 100644 --- a/tk/doc/man.macros +++ b/tk/doc/man.macros @@ -199,7 +199,7 @@ .SH "STANDARD OPTIONS" .LP .nf -.ta 4c 8c 12c +.ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options diff --git a/tk/doc/menu.n b/tk/doc/menu.n index 07a169c461d..b14c6a050f1 100644 --- a/tk/doc/menu.n +++ b/tk/doc/menu.n @@ -12,13 +12,17 @@ .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -menu \- Create and manipulate menu widgets +menu, tk_menuSetFocus \- Create and manipulate menu widgets .SH SYNOPSIS +.nf \fBmenu\fR \fIpathName \fR?\fIoptions\fR? +\fBtk_menuSetFocus\fR \fIpathName\fR .SO -\-activebackground \-background \-disabledforeground \-relief -\-activeborderwidth \-borderwidth \-font \-takefocus -\-activeforeground \-cursor \-foreground +\-activebackground \-borderwidth \-foreground +\-activeborderwidth \-cursor \-relief +\-activeforeground \-disabledforeground \-takefocus +\-background \-font + .SE .SH "WIDGET-SPECIFIC OPTIONS" .VS @@ -423,6 +427,17 @@ menu. Specifies a Tcl command to execute when the menu entry is invoked. Not available for separator or tear-off entries. .TP +.VS 8.4 +\fB\-compound \fIvalue\fR +Specifies whether the menu entry should display both an image and text, +and if so, where the image should be placed relative to the text. +Valid values for this option are \fBbottom\fR, \fBcenter\fR, +\fBleft\fR, \fBnone\fR, \fBright\fR and \fBtop\fR. The default value +is \fBnone\fR, meaning that the button will display either an image or +text, depending on the values of the \fB\-image\fR and \fB\-bitmap\fR +options. +.VE +.TP \fB\-font \fIvalue\fR Specifies the font to use when drawing the label or accelerator string in this entry. @@ -750,6 +765,12 @@ next menubutton to the right is posted. Disabled menu entries are non-responsive: they don't activate and they ignore mouse button presses and releases. .PP +.VS 8.4 +Several of the bindings make use of the command \fBtk_menuSetFocus\fR. +It saves the current focus and sets the focus to its \fIpathName\fR +argument, which is a menu widget. +.VE +.PP The behavior of menus can be changed by defining new bindings for individual widgets or by redefining the class bindings. @@ -761,5 +782,3 @@ entries. .SH KEYWORDS menu, widget - - diff --git a/tk/doc/menubar.n b/tk/doc/menubar.n index a58dcb3f3e1..59fc252860e 100644 --- a/tk/doc/menubar.n +++ b/tk/doc/menubar.n @@ -31,4 +31,3 @@ procedures will go away. .SH KEYWORDS keyboard traversal, menu, menu bar, post - diff --git a/tk/doc/menubutton.n b/tk/doc/menubutton.n index aaf166e0511..c0cb46625ce 100644 --- a/tk/doc/menubutton.n +++ b/tk/doc/menubutton.n @@ -16,14 +16,24 @@ menubutton \- Create and manipulate menubutton widgets .SH SYNOPSIS \fBmenubutton\fR \fIpathName \fR?\fIoptions\fR? .SO -\-activebackground \-cursor \-highlightthickness \-takefocus -\-activeforeground \-disabledforeground \-image \-text -\-anchor \-font \-justify \-textvariable -\-background \-foreground \-padx \-underline -\-bitmap \-highlightbackground \-pady \-wraplength -\-borderwidth \-highlightcolor \-relief +\-activebackground \-font \-pady +\-activeforeground \-foreground \-relief +\-anchor \-highlightbackground \-takefocus +\-background \-highlightcolor \-text +\-bitmap \-highlightthickness \-textvariable +\-borderwidth \-image \-underline +\-cursor \-justify \-wraplength +\-disabledforeground \-padx .SE .SH "WIDGET-SPECIFIC OPTIONS" +.OP \-compound compound Compound +Specifies whether the menubutton should display both an image and text, +and if so, where the image should be placed relative to the text. +Valid values for this option are \fBbottom\fR, \fBcenter\fR, +\fBleft\fR, \fBnone\fR, \fBright\fR and \fBtop\fR. The default value +is \fBnone\fR, meaning that the menubutton will display either an image or +text, depending on the values of the \fB\-image\fR and \fB\-bitmap\fR +options. .VS .OP \-direction direction Height Specifies where the menu is going to be popup up. \fBabove\fR tries to @@ -191,4 +201,3 @@ individual widgets or by redefining the class bindings. .SH KEYWORDS menubutton, widget - diff --git a/tk/doc/message.n b/tk/doc/message.n index 8f4280e4185..dedbf7e899e 100644 --- a/tk/doc/message.n +++ b/tk/doc/message.n @@ -16,10 +16,12 @@ message \- Create and manipulate message widgets .SH SYNOPSIS \fBmessage\fR \fIpathName \fR?\fIoptions\fR? .SO -\-anchor \-font \-highlightthickness \-takefocus -\-background \-foreground \-padx \-text -\-borderwidth \-highlightbackground \-pady \-textvariable -\-cursor \-highlightcolor \-relief \-width +\-anchor \-highlightbackground \-takefocus +\-background \-highlightcolor \-text +\-borderwidth \-highlightthickness \-textvariable +\-cursor \-padx \-width +\-font \-pady +\-foreground \-relief .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-aspect aspect Aspect @@ -145,4 +147,3 @@ The most common result is that the line is justified wrong. .SH KEYWORDS message, widget - diff --git a/tk/doc/messageBox.n b/tk/doc/messageBox.n index 4bebf4481bc..e06ee514548 100644 --- a/tk/doc/messageBox.n +++ b/tk/doc/messageBox.n @@ -30,9 +30,8 @@ The following option-value pairs are supported: \fB\-default\fR \fIname\fR \fIName\fR gives the symbolic name of the default button for this message window ('ok', 'cancel', and so on). See \fB\-type\fR -for a list of the symbolic names. If the message box has just one -button it will automatically be made the default, otherwise if this -option is not specified, there won't be any default button. +for a list of the symbolic names. If this option is not specified, +the first button in the dialog will be made the default. .TP \fB\-icon\fR \fIiconImage\fR Specifies an icon to display. \fIIconImage\fR must be one of the @@ -88,4 +87,3 @@ switch -- $answer { .SH KEYWORDS message box - diff --git a/tk/doc/option.n b/tk/doc/option.n index 8e942a891f9..8f0dd6ad5de 100644 --- a/tk/doc/option.n +++ b/tk/doc/option.n @@ -89,4 +89,3 @@ levels other than the ones given above. .SH KEYWORDS database, option, priority, retrieve - diff --git a/tk/doc/optionMenu.n b/tk/doc/optionMenu.n index 04f582bed09..9dd7147ed16 100644 --- a/tk/doc/optionMenu.n +++ b/tk/doc/optionMenu.n @@ -38,4 +38,3 @@ options or manipulate it in other ways. .SH KEYWORDS option menu - diff --git a/tk/doc/options.n b/tk/doc/options.n index a556351e2a7..16e9a49eddd 100644 --- a/tk/doc/options.n +++ b/tk/doc/options.n @@ -108,6 +108,7 @@ requests when it has a selection. The default is usually for widgets to export selections. .OP \-font font Font Specifies the font to use when drawing text inside the widget. +The value may have any of the forms accepted by \fBTk_GetFont\fR. .OP "\-foreground or \-fg" foreground Foreground Specifies the normal foreground color to use when displaying the widget. .OP \-highlightbackground highlightBackground HighlightBackground @@ -325,6 +326,8 @@ scrollbars and is provided by widgets that support vertical scrolling. See the description of \fBxScrollCommand\fR for details on how this option is used. +.SH "SEE ALSO" +colors, cursors, font + .SH KEYWORDS class, name, standard option, switch - diff --git a/tk/doc/pack-old.n b/tk/doc/pack-old.n index d31e1825963..902fcc5970e 100644 --- a/tk/doc/pack-old.n +++ b/tk/doc/pack-old.n @@ -194,4 +194,3 @@ such that zero space would be leftover for \fBexpand\fR options. .SH KEYWORDS geometry manager, location, packer, parcel, size - diff --git a/tk/doc/pack.n b/tk/doc/pack.n index ff00682ac7d..2ece2c92951 100644 --- a/tk/doc/pack.n +++ b/tk/doc/pack.n @@ -101,12 +101,14 @@ leave on each side of the slave(s). .TP \fB\-padx \fIamount\fR \fIAmount\fR specifies how much horizontal external padding to -leave on each side of the slave(s). +leave on each side of the slave(s). \fIAmount\fR may be a list +of two values to specify padding for left and right separately. \fIAmount\fR defaults to 0. .TP \fB\-pady \fIamount\fR \fIAmount\fR specifies how much vertical external padding to -leave on each side of the slave(s). +leave on each side of the slave(s). \fIAmount\fR may be a list +of two values to specify padding for top and bottom separtely. \fIAmount\fR defaults to 0. .TP \fB\-side \fIside\fR @@ -264,4 +266,3 @@ the stacking order of either the master or the slave. .SH KEYWORDS geometry manager, location, packer, parcel, propagation, size - diff --git a/tk/doc/palette.n b/tk/doc/palette.n index d340dd943d3..a0a3433e362 100644 --- a/tk/doc/palette.n +++ b/tk/doc/palette.n @@ -71,4 +71,3 @@ color scheme used in Tk 3.6 and earlier versions. .SH KEYWORDS bisque, color, palette - diff --git a/tk/doc/panedwindow.n b/tk/doc/panedwindow.n new file mode 100644 index 00000000000..23edc37b2c5 --- /dev/null +++ b/tk/doc/panedwindow.n @@ -0,0 +1,246 @@ +'\" +'\" Copyright (c) 1992 The Regents of the University of California. +'\" Copyright (c) 1994-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. +'\" +'\" RCS: @(#) $Id$ +'\" +.so man.macros +.TH panedwindow n 8.4 Tk "Tk Built-In Commands" +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +panedwindow \- Create and manipulate panedwindow widgets +.SH SYNOPSIS +\fBpanedwindow\fR \fIpathName \fR?\fIoptions\fR? +.SO +\-background \-height \-width +\-borderwidth \-orient +\-cursor \-relief +.SE +.SH "WIDGET-SPECIFIC OPTIONS" +.OP \-handlepad handlePad HandlePad +When sash handles are drawn, specifies the distance from the top or +left end of the sash (depending on the orientation of the widget) at +which to draw the handle. May be any value accepted by \fBTk_GetPixels\fR. +.OP \-handlesize handleSize HandleSize +Specifies the side length of a sash handle. Handles are always +drawn as squares. May be any value accepted by \fBTk_GetPixels\fR. +.OP \-opaqueresize opaqueResize OpaqueResize +Specifies whether panes should be resized as a sash is moved (true), +or if resizing should be deferred until the sash is placed (false). +.OP \-sashcursor sashCursor SashCursor +Mouse cursor to use when over a sash. If null, +\fBsb_h_double_arrow\fR will be used for horizontal panedwindows, and +\fBsb_v_double_arrow\fR will be used for vertical panedwindows. +.OP \-sashpad sashPad SashPad +Specifies the amount of padding to leave of each side of a sash. May +be any value accepted by \fBTk_GetPixels\fR. +.OP \-sashrelief sashRelief SashRelief +Relief to use when drawing a sash. May be any of the standard Tk +relief values. +.OP \-sashwidth sashWidth SashWidth +Specifies the width of each sash. May be any value accepted by +\fBTk_GetPixels\fR. +.OP \-showhandle showHandle ShowHandle +Specifies whether sash handles should be shown. May be any valid Tcl +boolean value. +.BE + +.SH DESCRIPTION +.PP +The \fBpanedwindow\fR command creates a new window (given by the +\fIpathName\fR argument) and makes it into a panedwindow widget. +Additional options, described above, may be specified on the command +line or in the option database to configure aspects of the panedwindow +such as its default background color and relief. The +\fBpanedwindow\fR command returns the path name of the new window. +.PP +A panedwindow widget contains any number of panes, arranged +horizontally or vertically, according to the value of the +\fB\-orient\fR option. Each pane contains one widget, and each pair of +panes is separated by a moveable (via mouse movements) sash. Moving a +sash causes the widgets on either side of the sash to be resized. + +.SH "WIDGET COMMAND" +.PP +The \fBpanedwindow\fR command creates a new Tcl command whose name is +the same as the path name of the panedwindow's window. This command +may be used to invoke various operations on the widget. It has the +following general form: +.CS +\fIpathName option \fR?\fIarg arg ...\fR? +.CE +\fIPathName\fR is the name of the command, which is the same as +the panedwindow widget's path name. \fIOption\fR and the \fIarg\fRs +determine the exact behavior of the command. The following +commands are possible for panedwindow widgets: +.TP +\fIpathName \fBadd \fIwindow ?window ...? ?option value ...?\fR +Add one or more windows to the panedwindow, each in a separate pane. +The arguments consist of the names of one or more windows +followed by pairs of arguments that specify how to manage the windows. +\fIOption\fR may have any of the values accepted by the +\fBconfigure\fR subcommand. +.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 +\fBpanedwindow\fR command. +.TP +\fIpathName \fBconfigure \fI?option? ?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 +information on the format of this list). If \fIoption\fR is specified +with no \fIvalue\fR, then the command returns a list describing the +one named option (this list will be identical to the corresponding +sublist of the value returned if no \fIoption\fR is specified). If +one or more \fIoption\-value\fR pairs are specified, then the command +modifies the given widget option(s) to have the given value(s); in +this case the command returns an empty string. \fIOption\fR may have +any of the values accepted by the \fBpanedwindow\fR command. +.TP +\fIpathName \fBforget \fIwindow ?window ...?\fR +Remove the pane containing \fIwindow\fR from the panedwindow. All +geometry management options for \fIwindow\fR will be forgotten. +.TP +\fIpathName \fBidentify \fIx y\fR +Identify the panedwindow component underneath the point given by +\fIx\fR and \fIy\fR, in window coordinates. If the point is over a +sash or a sash handle, the result is a two element list containing the +index of the sash or handle, and a word indicating whether it is over +a sash or a handle, such as {0 sash} or {2 handle}. If the point is +over any other part of the panedwindow, the result is an empty list. +.TP +\fIpathName \fBproxy \fI?args?\fR +This command is used to query and change the position of the sash +proxy, used for rubberband-style pane resizing. It can take any of +the following forms: +.RS +.TP +\fIpathName \fBproxy coord\fR +Return a list containing the x and y coordinates of the most recent +proxy location. +.TP +\fIpathname \fBproxy forget\fR +Remove the proxy from the display. +.TP +\fIpathName \fBproxy place \fIx y\fR +Place the proxy at the given \fIx\fR and \fIy\fR coordinates. +.RE +.TP +\fIpathName \fBsash \fI?args?\fR +This command is used to query and change the position of sashes in the +panedwindow. It can take any of the following forms: +.RS +.TP +\fIpathName \fBsash coord \fIindex\fR +Return the current x and y coordinate pair for the sash given by +\fIindex\fR. \fIIndex\fR must be an integer between 0 and 1 less than +the number of panes in the panedwindow. The coordinates given are +those of the top left corner of the region containing the sash. +\fIpathName \fBsash dragto \fIindex x y\fR +This command computes the difference between the given coordinates and the +coordinates given to the last \fBsash coord\fR command for the given +sash. It then moves that sash the computed difference. The return +value is the empty string. +.TP +\fIpathName \fBsash mark \fIindex x y\fR +Records \fIx\fR and \fIy\fR for the sash given by \fIindex\fR; used in +conjunction with later dragto commands to move the sash. +.TP +\fIpathName \fBsash place \fIindex x y\fR +Place the sash given by \fIindex\fR at the given coordinates. +.RE +.TP +\fIpathName \fBpanecget \fIwindow option\fR +Query a management option for \fIwindow\fR. \fIOption\fR may be any +value allowed by the \fBpaneconfigure\fR subcommand. +.TP +\fIpathName \fBpaneconfigure \fIwindow ?option? ?value option value ...?\fR +Query or modify the management options for \fIwindow\fR. If no +\fIoption\fR is specified, returns a list describing all of the +available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for +information on the format of this list). If \fIoption\fR is specified +with no \fIvalue\fR, then the command returns a list describing the +one named option (this list will be identical to the corresponding +sublist of the value returned if no \fIoption\fR is specified). If +one or more \fIoption\-value\fR pairs are specified, then the command +modifies the given widget option(s) to have the given value(s); in +this case the command returns an empty string. The following options +are supported: +.RS +.TP +\fB\-after \fIwindow\fR +Insert the window after the window specified. \fIwindow\fR should be the +name of a window already managed by \fIpathName\fR. +.TP +\fB\-before \fIwindow\fR +Insert the window before the window specified. \fIwindow\fR should be +the name of a window already managed by \fIpathName\fR. +.TP +\fB\-height \fIsize\fR +Specify a height for the window. The height will be the outer +dimension of the window including its border, if any. If \fIsize\fR +is an empty string, or if \fB\-height\fR is not specified, then the +height requested internally by the window will be used initially; the +height may later be adjusted by the movement of sashes in the +panedwindow. \fISize\fR may be any value accepted by \fBTk_GetPixels\fR. +.TP +\fB\-minsize \fIn\fR +Specifies that the size of the window cannot be made less than +\fIn\fR. This constraint only affects the size of the widget in the +paned dimension -- the x dimension for horizontal panedwindows, the y +dimension for vertical panedwindows. May be any value accepted by +\fBTk_GetPixels\fR. +.TP +\fB\-padx \fIn\fR +Specifies a non-negative value indicating how much extra space to +leave on each side of the window in the X-direction. The value may +have any of the forms accepted by \fBTk_GetPixels\fR. +.TP +\fB\-pady \fIn\fR +Specifies a non-negative value indicating how much extra space to +leave on each side of the window in the Y-direction. The value may +have any of the forms accepted by \fBTk_GetPixels\fR. +.TP +\fB\-sticky \fIstyle\fR +If a window's pane is larger than the requested dimensions of the +window, this option may be used to position (or stretch) the window +within its pane. \fIStyle\fR is a string that contains zero or more +of the characters \fBn\fP, \fBs\fP, \fBe\fP or \fBw\fP. The string +can optionally contains spaces or commas, but they are ignored. Each +letter refers to a side (north, south, east, or west) that the window +will "stick" to. If both \fBn\fP and \fBs\fP (or \fBe\fP and \fBw\fP) +are specified, the window will be stretched to fill the entire height +(or width) of its cavity. +.TP +\fB\-width \fIsize\fR +Specify a width for the window. The width will be the outer +dimension of the window including its border, if any. If \fIsize\fR +is an empty string, or if \fB\-width\fR is not specified, then the +width requested internally by the window will be used initially; the +width may later be adjusted by the movement of sashes in the +panedwindow. \fISize\fR may be any value accepted by \fBTk_GetPixels\fR. +.RE +.TP +\fIpathName \fBpanes\fR +Returns an ordered list of the widgets managed by \fIpathName\fR. + +.SH "RESIZING PANES" + +A pane is resized by grabbing the sash (or sash handle if present) and +dragging with the mouse. This is accomplished via mouse motion +bindings on the widget. When a sash is moved, the sizes of the panes +on each side of the sash, and thus the widgets in those panes, are +adjusted. +.PP +When a pane is resized from outside (eg, it is packed to expand and +fill, and the containing toplevel is resized), space is added to the final +(rightmost or bottommost) pane in the window. + +.SH KEYWORDS +panedwindow, widget, geometry management diff --git a/tk/doc/photo.n b/tk/doc/photo.n index ddc491bd72a..e66d34e3eda 100644 --- a/tk/doc/photo.n +++ b/tk/doc/photo.n @@ -31,7 +31,11 @@ can be supplied from C code through a procedural interface. At present, only GIF and PPM/PGM formats are supported, but an interface exists to allow additional image file formats to be added easily. A photo image is transparent -in regions where no image data has been supplied. +in regions where no image data has been supplied +.VS 8.4 +or where it has been set transparent by the \fBtransparency set\fR +subcommand. +.VE 8.4 .SH "CREATING PHOTOS" .PP @@ -185,6 +189,18 @@ only every \fIx\fRth pixel in the X direction and \fIy\fRth pixel in the Y direction. Negative values will cause the image to be flipped about the Y or X axes, respectively. If \fIy\fR is not given, the default value is the same as \fIx\fR. +.TP +\fB\-compositingrule \fIrule\fR +.VS 8.4 +Specifies how transparent pixels in the source image are combined with +the destination image. When a compositing rule of \fIoverlay\fR is +set, the old contents of the destination image are visible, as if the +source image were printed on a piece of transparent film and placed +over the top of the destination. When a compositing rule of \fIset\fR +is set, the old contents of the destination image are discarded and +the source image is used as-is. The default compositing rule is +\fIoverlay\fR. +.VE 8.4 .RE .TP \fIimageName \fBdata ?\fIoption value(s) ...\fR? @@ -198,20 +214,21 @@ information. In all transparent pixels the color will be replaced by the specified color. .TP \fB\-format\fI format-name\fR -Specifies the name of the image file format handler to be used to -write the data to the file. Specifically, this subcommand searches +Specifies the name of the image file format handler to be used. +Specifically, this subcommand searches for the first handler whose name matches a initial substring of -\fIformat-name\fR and which has the capability to write an image -file. If this option is not given, this subcommand uses the first -handler that has the capability to write an image file. +\fIformat-name\fR and which has the capability to read this image data. +If this option is not given, this subcommand uses the first +handler that has the capability to read the image data. .TP \fB\-from \fIx1 y1 x2 y2\fR -Specifies a rectangular region of \fIimageName\fR to be written to the -image file. If only \fIx1\fR and \fIy1\fR are specified, the region +Specifies a rectangular region of \fIimageName\fR to be returned. +If only \fIx1\fR and \fIy1\fR are specified, the region extends from \fI(x1,y1)\fR to the bottom-right corner of \fIimageName\fR. If all four coordinates are given, they specify -diagonally opposite corners of the rectangular region. The default, -if this option is not given, is the whole image. +diagonally opposite corners of the rectangular region, including x1,y1 +and excluding x2,y2. The default, if this option is not given, is the +whole image. .TP \fB\-grayscale\fR If this options is specified, the data will not contain color @@ -307,6 +324,21 @@ not noticeable, but if it is a problem, this command can be used to recalculate the dithered image in each window where the image is displayed. .TP +\fIimageName \fBtransparency \fIsubcommand ?arg arg ...?\fR +.VS 8.4 +Allows examination and manipulation of the transparency information in +the photo image. Several subcommands are available: +.RS +.TP +\fIimageName \fBtransparency get \fIx y\fR +Returns a boolean indicating if the pixel at (\fIx\fR,\fIy\fR) is +transparent. +\fIimageName \fBtransparency set \fIx y boolean\fR +Makes the pixel at (\fIx\fR,\fIy\fR) transparent if \fIboolean\fR is +true, and makes that pixel opaque otherwise. +.RE +.VE 8.4 +.TP \fIimageName \fBwrite \fIfilename\fR ?\fIoption value(s) ...\fR? Writes image data from \fIimageName\fR to a file named \fIfilename\fR. The following options may be specified: @@ -337,7 +369,6 @@ if this option is not given, is the whole image. If this options is specified, the data will not contain color information. All pixel data will be transformed into grayscale. .RE -.TP .SH "IMAGE FORMATS" .PP The photo image code is structured to allow handlers for additional @@ -367,6 +398,10 @@ for the \fB\-format\fR option must begin with the complete name of the requested handler, and may contain additional information following that, which the handler can use, for example, to specify which variant to use of the formats supported by the handler. +.VS 8.4 +Note that not all image handlers may support writing transparency data +to a file, even where the target image format does. +.VE 8.4 .SH "COLOR ALLOCATION" .PP @@ -406,4 +441,3 @@ John Ousterhout. .SH KEYWORDS photo, image, color - diff --git a/tk/doc/place.n b/tk/doc/place.n index aaddaba37dd..4c21d72edf6 100644 --- a/tk/doc/place.n +++ b/tk/doc/place.n @@ -16,7 +16,7 @@ place \- Geometry manager for fixed or rubber-sheet placement .SH SYNOPSIS \fBplace \fIwindow option value \fR?\fIoption value ...\fR? .sp -\fBplace configure \fIwindow option value \fR?\fIoption value ...\fR? +\fBplace configure \fIwindow \fR?\fIoption\fR? ?\fIvalue option value ...\fR? .sp \fBplace forget \fIwindow\fR .sp @@ -39,16 +39,69 @@ Lastly, the placer allows you to mix these styles of placement so that, for example, the slave has a fixed width and height but is centered inside the master. .PP -If the first argument to the \fBplace\fR command is a window path -name or \fBconfigure\fR then the command arranges for the placer -to manage the geometry of a slave whose path name is \fIwindow\fR. -The remaining arguments consist of one or more \fIoption\-value\fR -pairs that specify the way in which \fIwindow\fR's -geometry is managed. -If the placer is already managing \fIwindow\fR, then the -\fIoption\-value\fR pairs modify the configuration for \fIwindow\fR. -In this form the \fBplace\fR command returns an empty string as result. +.TP +\fBplace \fIwindow option value \fR?\fIoption value ...\fR? +Arrange for the placer to manage the geometry of a slave whose +pathName is \fIwindow\fR. The remaining arguments consist of one or +more \fIoption\-value\fR pairs that specify the way in which +\fIwindow\fR's geometry is managed. \fIOption\fR may have any of the +values accepted by the \fBplace configure\fR command. +.TP +\fBplace configure \fIwindow \fR?\fIoption\fR? ?\fIvalue option value ...\fR? +Query or modify the geometry options of the slave given by +\fIwindow\fR. If no \fIoption\fR is specified, this command returns a +list describing the available options (see \fBTk_ConfigureInfo\fR for +information on the format of this list). If \fIoption\fR is specified +with no \fIvalue\fR, then the command returns a list describing the +one named option (this list will be identical to the corresponding +sublist of the value returned if no \fIoption\fR is specified). If +one or more \fIoption\-value\fR pairs are specified, then the command +modifies the given option(s) to have the given value(s); in this case +the command returns an empty string. + The following \fIoption\-value\fR pairs are supported: +.RS +.TP +\fB\-anchor \fIwhere\fR +\fIWhere\fR specifies which point of \fIwindow\fR is to be positioned +at the (x,y) location selected by the \fB\-x\fR, \fB\-y\fR, +\fB\-relx\fR, and \fB\-rely\fR options. +The anchor point is in terms of the outer area of \fIwindow\fR +including its border, if any. +Thus if \fIwhere\fR is \fBse\fR then the lower-right corner of +\fIwindow\fR's border will appear at the given (x,y) location +in the master. +The anchor position defaults to \fBnw\fR. +.TP +\fB\-bordermode \fImode\fR +\fIMode\fR determines the degree to which borders within the +master are used in determining the placement of the slave. +The default and most common value is \fBinside\fR. +In this case the placer considers the area of the master to +be the innermost area of the master, inside any border: +an option of \fB\-x 0\fR corresponds to an x-coordinate just +inside the border and an option of \fB\-relwidth 1.0\fR +means \fIwindow\fR will fill the area inside the master's +border. + +If \fImode\fR is \fBoutside\fR then the placer considers +the area of the master to include its border; +this mode is typically used when placing \fIwindow\fR +outside its master, as with the options \fB\-x 0 \-y 0 \-anchor ne\fR. +Lastly, \fImode\fR may be specified as \fBignore\fR, in which +case borders are ignored: the area of the master is considered +to be its official X area, which includes any internal border but +no external border. A bordermode of \fBignore\fR is probably +not very useful. +.TP +\fB\-height \fIsize\fR +\fISize\fR specifies the height for \fIwindow\fR in screen units +(i.e. any of the forms accepted by \fBTk_GetPixels\fR). +The height will be the outer dimension of \fIwindow\fR including its +border, if any. +If \fIsize\fR is an empty string, or if no \fB\-height\fR or +\fB\-relheight\fR option is specified, then the height requested +internally by the window will be used. .TP \fB\-in \fImaster\fR \fIMaster\fR specifes the path name of the window relative @@ -62,12 +115,25 @@ that \fIwindow\fR is visible whenever \fImaster\fR is visible. If this option isn't specified then the master defaults to \fIwindow\fR's parent. .TP -\fB\-x \fIlocation\fR -\fILocation\fR specifies the x-coordinate within the master window -of the anchor point for \fIwindow\fR. -The location is specified in screen units (i.e. any of the forms -accepted by \fBTk_GetPixels\fR) and need not lie within the bounds -of the master window. +\fB\-relheight \fIsize\fR +\fISize\fR specifies the height for \fIwindow\fR. +In this case the height is specified as a floating-point number +relative to the height of the master: 0.5 means \fIwindow\fR will +be half as high as the master, 1.0 means \fIwindow\fR will have +the same height as the master, and so on. +If both \fB\-height\fR and \fB\-relheight\fR are specified for a slave, +their values are summed. For example, \fB\-relheight 1.0 \-height \-2\fR +makes the slave 2 pixels shorter than the master. +.TP +\fB\-relwidth \fIsize\fR +\fISize\fR specifies the width for \fIwindow\fR. +In this case the width is specified as a floating-point number +relative to the width of the master: 0.5 means \fIwindow\fR will +be half as wide as the master, 1.0 means \fIwindow\fR will have +the same width as the master, and so on. +If both \fB\-width\fR and \fB\-relwidth\fR are specified for a slave, +their values are summed. For example, \fB\-relwidth 1.0 \-width 5\fR +makes the slave 5 pixels wider than the master. .TP \fB\-relx \fIlocation\fR \fILocation\fR specifies the x-coordinate within the master window @@ -81,13 +147,6 @@ then their values are summed. For example, \fB\-relx 0.5 \-x \-2\fR positions the left edge of the slave 2 pixels to the left of the center of its master. .TP -\fB\-y \fIlocation\fR -\fILocation\fR specifies the y-coordinate within the master window -of the anchor point for \fIwindow\fR. -The location is specified in screen units (i.e. any of the forms -accepted by \fBTk_GetPixels\fR) and need not lie within the bounds -of the master window. -.TP \fB\-rely \fIlocation\fR \fILocation\fR specifies the y-coordinate within the master window of the anchor point for \fIwindow\fR. @@ -100,17 +159,6 @@ then their values are summed. For example, \fB\-rely 0.5 \-x 3\fR positions the top edge of the slave 3 pixels below the center of its master. .TP -\fB\-anchor \fIwhere\fR -\fIWhere\fR specifies which point of \fIwindow\fR is to be positioned -at the (x,y) location selected by the \fB\-x\fR, \fB\-y\fR, -\fB\-relx\fR, and \fB\-rely\fR options. -The anchor point is in terms of the outer area of \fIwindow\fR -including its border, if any. -Thus if \fIwhere\fR is \fBse\fR then the lower-right corner of -\fIwindow\fR's border will appear at the given (x,y) location -in the master. -The anchor position defaults to \fBnw\fR. -.TP \fB\-width \fIsize\fR \fISize\fR specifies the width for \fIwindow\fR in screen units (i.e. any of the forms accepted by \fBTk_GetPixels\fR). @@ -120,77 +168,42 @@ If \fIsize\fR is an empty string, or if no \fB\-width\fR or \fB\-relwidth\fR option is specified, then the width requested internally by the window will be used. .TP -\fB\-relwidth \fIsize\fR -\fISize\fR specifies the width for \fIwindow\fR. -In this case the width is specified as a floating-point number -relative to the width of the master: 0.5 means \fIwindow\fR will -be half as wide as the master, 1.0 means \fIwindow\fR will have -the same width as the master, and so on. -If both \fB\-width\fR and \fB\-relwidth\fR are specified for a slave, -their values are summed. For example, \fB\-relwidth 1.0 \-width 5\fR -makes the slave 5 pixels wider than the master. -.TP -\fB\-height \fIsize\fR -\fISize\fR specifies the height for \fIwindow\fR in screen units -(i.e. any of the forms accepted by \fBTk_GetPixels\fR). -The height will be the outer dimension of \fIwindow\fR including its -border, if any. -If \fIsize\fR is an empty string, or if no \fB\-height\fR or -\fB\-relheight\fR option is specified, then the height requested -internally by the window will be used. -.TP -\fB\-relheight \fIsize\fR -\fISize\fR specifies the height for \fIwindow\fR. -In this case the height is specified as a floating-point number -relative to the height of the master: 0.5 means \fIwindow\fR will -be half as high as the master, 1.0 means \fIwindow\fR will have -the same height as the master, and so on. -If both \fB\-height\fR and \fB\-relheight\fR are specified for a slave, -their values are summed. For example, \fB\-relheight 1.0 \-height \-2\fR -makes the slave 2 pixels shorter than the master. +\fB\-x \fIlocation\fR +\fILocation\fR specifies the x-coordinate within the master window +of the anchor point for \fIwindow\fR. +The location is specified in screen units (i.e. any of the forms +accepted by \fBTk_GetPixels\fR) and need not lie within the bounds +of the master window. .TP -\fB\-bordermode \fImode\fR -\fIMode\fR determines the degree to which borders within the -master are used in determining the placement of the slave. -The default and most common value is \fBinside\fR. -In this case the placer considers the area of the master to -be the innermost area of the master, inside any border: -an option of \fB\-x 0\fR corresponds to an x-coordinate just -inside the border and an option of \fB\-relwidth 1.0\fR -means \fIwindow\fR will fill the area inside the master's -border. -If \fImode\fR is \fBoutside\fR then the placer considers -the area of the master to include its border; -this mode is typically used when placing \fIwindow\fR -outside its master, as with the options \fB\-x 0 \-y 0 \-anchor ne\fR. -Lastly, \fImode\fR may be specified as \fBignore\fR, in which -case borders are ignored: the area of the master is considered -to be its official X area, which includes any internal border but -no external border. A bordermode of \fBignore\fR is probably -not very useful. +\fB\-y \fIlocation\fR +\fILocation\fR specifies the y-coordinate within the master window +of the anchor point for \fIwindow\fR. +The location is specified in screen units (i.e. any of the forms +accepted by \fBTk_GetPixels\fR) and need not lie within the bounds +of the master window. .PP If the same value is specified separately with two different options, such as \fB\-x\fR and \fB\-relx\fR, then the most recent option is used and the older one is ignored. -.PP -The \fBplace slaves\fR command returns a list of all the slave -windows for which \fIwindow\fR is the master. -If there are no slaves for \fIwindow\fR then an empty string is -returned. -.PP -The \fBplace forget\fR command causes the placer to stop managing -the geometry of \fIwindow\fR. As a side effect of this command -\fIwindow\fR will be unmapped so that it doesn't appear on the -screen. -If \fIwindow\fR isn't currently managed by the placer then the -command has no effect. -\fBPlace forget\fR returns an empty string as result. -.PP -The \fBplace info\fR command returns a list giving the current -configuration of \fIwindow\fR. +.RE +.TP +\fBplace forget \fIwindow\fR +Causes the placer to stop managing the geometry of \fIwindow\fR. As a +side effect of this command \fIwindow\fR will be unmapped so that it +doesn't appear on the screen. If \fIwindow\fR isn't currently managed +by the placer then the command has no effect. This command returns an +empty string. +.TP +\fBplace info \fIwindow\fR +Returns a list giving the current configuration of \fIwindow\fR. The list consists of \fIoption\-value\fR pairs in exactly the same form as might be specified to the \fBplace configure\fR command. +.TP +\fBplace slaves \fIwindow\fR +Returns a list of all the slave windows for which \fIwindow\fR is the master. +If there are no slaves for \fIwindow\fR then an empty string is returned. + If the configuration of a window has been retrieved with \fBplace info\fR, that configuration can be restored later by first using \fBplace forget\fR to erase any existing information @@ -235,4 +248,3 @@ frames and canvases that provide configuration options for this purpose. .SH KEYWORDS geometry manager, height, location, master, place, rubber sheet, slave, width - diff --git a/tk/doc/popup.n b/tk/doc/popup.n index 6103ac34f46..8f574c85ead 100644 --- a/tk/doc/popup.n +++ b/tk/doc/popup.n @@ -31,4 +31,3 @@ the given point. .SH KEYWORDS menu, popup - diff --git a/tk/doc/radiobutton.n b/tk/doc/radiobutton.n index 977cb703bd8..db33fe66a68 100644 --- a/tk/doc/radiobutton.n +++ b/tk/doc/radiobutton.n @@ -16,12 +16,14 @@ radiobutton \- Create and manipulate radiobutton widgets .SH SYNOPSIS \fBradiobutton\fR \fIpathName \fR?\fIoptions\fR? .SO -\-activebackground \-cursor \-highlightthickness \-takefocus -\-activeforeground \-disabledforeground \-image \-text -\-anchor \-font \-justify \-textvariable -\-background \-foreground \-padx \-underline -\-bitmap \-highlightbackground \-pady \-wraplength -\-borderwidth \-highlightcolor \-relief +\-activebackground \-font \-pady +\-activeforeground \-foreground \-relief +\-anchor \-highlightbackground \-takefocus +\-background \-highlightcolor \-text +\-bitmap \-highlightthickness \-textvariable +\-borderwidth \-image \-underline +\-cursor \-justify \-wraplength +\-disabledforeground \-padx .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-command command Command @@ -51,6 +53,27 @@ for the entire widget, in place of \fBbackground\fR or \fBactiveBackground\fR, whenever the widget is selected. If specified as an empty string then no special color is used for displaying when the widget is selected. +.VS 8.4 +.OP \-offrelief offRelief OffRelief +Specifies the relief for the checkbutton when the indicator is not drawn and +the checkbutton is off. The default value is "raised". By setting this option +to "flat" and setting -indicatoron to false and -overrelief to raised, +the effect is achieved +of having a flat button that raises on mouse-over and which is +depressed when activated. This is the behavior typically exhibited by +the Align-Left, Align-Right, and Center radiobuttons on the toolbar of a +word-processor, for example. + +.VE 8.4 +.VS 8.4 +.OP \-overrelief overRelief OverRelief +Specifies an alternative relief for the radiobutton, to be used when the +mouse cursor is over the widget. This option can be used to make +toolbar buttons, by configuring \fB\-relief flat \-overrelief +raised\fR. If the value of this option is the empty string, then no +alternative relief is used when the mouse cursor is over the radiobutton. +The empty string is the default value. +.VE 8.4 .OP \-selectimage selectImage SelectImage Specifies an image to display (in place of the \fBimage\fR option) when the radiobutton is selected. @@ -231,4 +254,3 @@ individual widgets or by redefining the class bindings. .SH KEYWORDS radiobutton, widget - diff --git a/tk/doc/raise.n b/tk/doc/raise.n index aedab0b021b..550e0914eba 100644 --- a/tk/doc/raise.n +++ b/tk/doc/raise.n @@ -36,4 +36,3 @@ lower .SH KEYWORDS obscure, raise, stacking order - diff --git a/tk/doc/scale.n b/tk/doc/scale.n index 6daaa142923..9c21d8fa91e 100644 --- a/tk/doc/scale.n +++ b/tk/doc/scale.n @@ -16,10 +16,11 @@ scale \- Create and manipulate scale widgets .SH SYNOPSIS \fBscale\fR \fIpathName \fR?\fIoptions\fR? .SO -\-activebackground \-font \-highlightthickness \-repeatinterval -\-background \-foreground \-orient \-takefocus -\-borderwidth \-highlightbackground \-relief \-troughcolor -\-cursor \-highlightcolor \-repeatdelay +\-activebackground \-foreground \-relief +\-background \-highlightbackground \-repeatdelay +\-borderwidth \-highlightcolor \-repeatinterval +\-cursor \-highlightthickness \-takefocus +\-font \-orient \-troughcolor .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-bigincrement bigIncrement BigIncrement @@ -244,4 +245,3 @@ individual widgets or by redefining the class bindings. .SH KEYWORDS scale, slider, trough, widget - diff --git a/tk/doc/scrollbar.n b/tk/doc/scrollbar.n index a52cf95ce80..744889dec5d 100644 --- a/tk/doc/scrollbar.n +++ b/tk/doc/scrollbar.n @@ -16,10 +16,11 @@ scrollbar \- Create and manipulate scrollbar widgets .SH SYNOPSIS \fBscrollbar\fR \fIpathName \fR?\fIoptions\fR? .SO -\-activebackground \-highlightbackground \-orient \-takefocus -\-background \-highlightcolor \-relief \-troughcolor -\-borderwidth \-highlightthickness \-repeatdelay -\-cursor \-jump \-repeatinterval +\-activebackground \-highlightcolor \-repeatdelay +\-background \-highlightthickness \-repeatinterval +\-borderwidth \-jump \-takefocus +\-cursor \-orient \-troughcolor +\-highlightbackground \-relief .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-activerelief activeRelief ActiveRelief @@ -338,4 +339,3 @@ The End key adjusts the view to the bottom (right edge) of the document. .SH KEYWORDS scrollbar, widget - diff --git a/tk/doc/selection.n b/tk/doc/selection.n index 72feff07328..3c41f88fd72 100644 --- a/tk/doc/selection.n +++ b/tk/doc/selection.n @@ -23,6 +23,9 @@ This command provides a Tcl interface to the X selection mechanism and implements the full selection functionality described in the X Inter-Client Communication Conventions Manual (ICCCM). .PP +Note that for management of the CLIPBOARD selection (see below), the +\fBclipboard\fR command may also be used. +.PP The first argument to \fBselection\fR determines the format of the rest of the arguments and the behavior of the command. The following forms are currently supported: @@ -126,6 +129,8 @@ If \fIcommand\fR is specified, it is a Tcl script to execute when some other window claims ownership of the selection away from \fIwindow\fR. \fISelection\fR defaults to PRIMARY. +.SH "SEE ALSO" +clipboard + .SH KEYWORDS clear, format, handler, ICCCM, own, selection, target, type - diff --git a/tk/doc/send.n b/tk/doc/send.n index 4e35474f512..96056777d25 100644 --- a/tk/doc/send.n +++ b/tk/doc/send.n @@ -95,4 +95,3 @@ functionality is provided by the \fBdde\fR command instead. .VS application, dde, name, remote execution, security, send .VE - diff --git a/tk/doc/spinbox.n b/tk/doc/spinbox.n new file mode 100644 index 00000000000..7fe92995576 --- /dev/null +++ b/tk/doc/spinbox.n @@ -0,0 +1,582 @@ +'\" +'\" Copyright (c) 2000 Jeffrey Hobbs. +'\" Copyright (c) 2000 Ajuba Solutions. +'\" +'\" See the file "license.terms" for information on usage and redistribution +'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. +'\" +'\" RCS: @(#) $Id$ +'\" +.so man.macros +.TH spinbox n 8.4 Tk "Tk Built-In Commands" +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +spinbox \- Create and manipulate spinbox widgets +.SH SYNOPSIS +\fBspinbox\fR \fIpathName \fR?\fIoptions\fR? +.SO +\-activebackground \-highlightthickness \-repeatinterval +\-background \-insertbackground \-selectbackground +\-borderwidth \-insertborderwidth \-selectborderwidth +\-cursor \-insertontime \-selectforeground +\-exportselection \-insertwidth \-takefocus +\-font \-insertofftime \-textvariable +\-foreground \-justify \-xscrollcommand +\-highlightbackground \-relief +\-highlightcolor \-repeatdelay +.SE +.SH "WIDGET-SPECIFIC OPTIONS" +.OP \-buttonbackground buttonBackground Background +The background color to be used for the spin buttons. +.OP \-buttoncursor buttonCursor Cursor +The cursor to be used when over the spin buttons. If this is empty +(the default), a default cursor will be used. +.OP \-buttondownrelief buttonDownRelief Relief +The relief to be used for the upper spin button. +.OP \-buttonuprelief buttonUpRelief Relief +The relief to be used for the lower spin button. +.OP \-command command Command +Specifies a Tcl command to invoke whenever a spinbutton is invoked. +The command recognizes several percent substitutions: \fB%W\fR for +the widget path, \fB%s\fR for the current value of the widget, and +\fB%d\fR for the direction of the button pressed (\fBup\fR or \fBdown\fR). +.OP \-disabledbackground disabledBackground DisabledBackground +Specifies the background color to use when the spinbox is disabled. If +this option is the empty string, the normal background color is used. +.OP \-disabledforeground disabledForeground DisabledForeground +Specifies the foreground color to use when the spinbox is disabled. If +this option is the empty string, the normal foreground color is used. +.OP \-format format Format +Specifies an alternate format to use when setting the string value +when using the \fB\-from\fR and \fB\-to\fR range. +This must be a format specifier of the form \fB%.f\fR, +as it will format a floating-point number. +.OP \-from from From +A floating-point value corresponding to the lowest value for a spinbox, to +be used in conjunction with \fB\-to\fR and \fB\-increment\fR. When all +are specified correctly, the spinbox will use these values to control its +contents. This value must be less than the \fB\-to\fR option. +If \fB\-values\fR is specified, it supercedes this option. +.OP "\-invalidcommand or \-invcmd" invalidCommand InvalidCommand +Specifies a script to eval when \fBvalidateCommand\fR returns 0. Setting +it to an empty string disables this feature (the default). The best use of +this option is to set it to \fIbell\fR. See \fBValidation\fR below for +more information. +.OP \-increment increment Increment +A floating-point value specifying the increment. When used with +\fB\-from\fR and \fB\-to\fR, the value in the widget will be adjusted by +\fB\-increment\fR when a spin button is pressed (up adds the value, +down subtracts the value). +.OP \-readonlybackground readonlyBackground ReadonlyBackground +Specifies the background color to use when the spinbox is readonly. If +this option is the empty string, the normal background color is used. +.OP \-state state State +Specifies one of three states for the spinbox: \fBnormal\fR, +\fBdisabled\fR, or \fBreadonly\fR. If the spinbox is readonly, then the +value may not be changed using widget commands and no insertion cursor +will be displayed, even if the input focus is in the widget; the +contents of the widget may still be selected. If the spinbox is +disabled, the value may not be changed, no insertion cursor will be +displayed, the contents will not be selectable, and the spinbox may +be displayed in a different color, depending on the values of the +\fB-disabledforeground\fR and \fB-disabledbackground\fR options. +.OP \-to to To +A floating-point value corresponding to the highest value for the spinbox, +to be used in conjunction with \fB\-from\fR and \fB\-increment\fR. When +all are specified correctly, the spinbox will use these values to control +its contents. This value must be greater than the \fB\-from\fR option. +If \fB\-values\fR is specified, it supercedes this option. +.OP \-validate validate Validate +Specifies the mode in which validation should operate: \fBnone\fR, +\fBfocus\fR, \fBfocusin\fR, \fBfocusout\fR, \fBkey\fR, or \fBall\fR. +It defaults to \fBnone\fR. When you want validation, you must explicitly +state which mode you wish to use. See \fBValidation\fR below for more. +.OP "\-validatecommand or \-vcmd" validateCommand ValidateCommand +Specifies a script to evaluate when you want to validate the input in the +widget. Setting it to an empty string disables this feature (the default). +Validation occurs according to the value of \fB\-validate\fR. +This command must return a valid Tcl boolean value. If it returns 0 (or +the valid Tcl boolean equivalent) then the value of the widget will not +change and the \fBinvalidCommand\fR will be evaluated if it is set. If it +returns 1, then value will be changed. +See \fBValidation\fR below for more information. +.OP \-values values Values +Must be a proper list value. If specified, the spinbox will use these +values as to control its contents, starting with the first value. This +option has precedence over the \fB\-from\fR and \fB\-to\fR range. +.OP \-width width Width +Specifies an integer value indicating the desired width of the spinbox window, +in average-size characters of the widget's font. +If the value is less than or equal to zero, the widget picks a +size just large enough to hold its current text. +.OP \-wrap wrap wrap +Must be a proper boolean value. If on, the spinbox will wrap around the +values of data in the widget. +.BE + +.SH DESCRIPTION +.PP +The \fBspinbox\fR command creates a new window (given by the +\fIpathName\fR argument) and makes it into a spinbox widget. +Additional options, described above, may be specified on the +command line or in the option database +to configure aspects of the spinbox such as its colors, font, +and relief. The \fBspinbox\fR command returns its +\fIpathName\fR argument. At the time this command is invoked, +there must not exist a window named \fIpathName\fR, but +\fIpathName\fR's parent must exist. +.PP +A \fBspinbox\fR is an extended \fBentry\fR widget that allows he user +to move, or spin, through a fixed set of ascending or descending values +such as times or dates in addition to editing the value as in an +\fBentry\fR. When first created, a spinbox's string is empty. +A portion of the spinbox may be selected as described below. +If a spinbox is exporting its selection (see the \fBexportSelection\fR +option), then it will observe the standard protocols for handling the +selection; spinbox selections are available as type \fBSTRING\fR. +Spinboxes also observe the standard Tk rules for dealing with the +input focus. When a spinbox has the input focus it displays an +\fIinsertion cursor\fR to indicate where new characters will be +inserted. +.PP +Spinboxes are capable of displaying strings that are too long to +fit entirely within the widget's window. In this case, only a +portion of the string will be displayed; commands described below +may be used to change the view in the window. Spinboxes use +the standard \fBxScrollCommand\fR mechanism for interacting with +scrollbars (see the description of the \fBxScrollCommand\fR option +for details). They also support scanning, as described below. + +.SH VALIDATION +.PP +Validation works by setting the \fBvalidateCommand\fR +option to a script which will be evaluated according to the \fBvalidate\fR +option as follows: +.PP +.IP \fBnone\fR 10 +Default. This means no validation will occur. +.IP \fBfocus\fR 10 +\fBvalidateCommand\fR will be called when the spinbox receives or +loses focus. +.IP \fBfocusin\fR 10 +\fBvalidateCommand\fR will be called when the spinbox receives focus. +.IP \fBfocusout\fR 10 +\fBvalidateCommand\fR will be called when the spinbox loses focus. +.IP \fBkey\fR 10 +\fBvalidateCommand\fR will be called when the spinbox is edited. +.IP \fBall\fR 10 +\fBvalidateCommand\fR will be called for all above conditions. +.PP +It is posible to perform percent substitutions on the \fBvalidateCommand\fR +and \fBinvalidCommand\fR, just as you would in a \fBbind\fR script. The +following substitutions are recognized: +.PP +.IP \fB%d\fR 5 +Type of action: 1 for \fBinsert\fR, 0 for \fBdelete\fR, +or -1 for focus, forced or textvariable validation. +.IP \fB%i\fR 5 +Index of char string to be inserted/deleted, if any, otherwise -1. +.IP \fB%P\fR 5 +The value of the spinbox should edition occur. If you are configuring the +spinbox widget to have a new textvariable, this will be the value of that +textvariable. +.IP \fB%s\fR 5 +The current value of spinbox before edition. +.IP \fB%S\fR 5 +The text string being inserted/deleted, if any. +Otherwise it is an empty string. +.IP \fB%v\fR 5 +The type of validation currently set. +.IP \fB%V\fR 5 +The type of validation that triggered the callback +(key, focusin, focusout, forced). +.IP \fB%W\fR 5 +The name of the spinbox widget. +.PP +In general, the \fBtextVariable\fR and \fBvalidateCommand\fR can be +dangerous to mix. Any problems have been overcome so that using the +\fBvalidateCommand\fR will not interfere with the traditional behavior of +the spinbox widget. Using the \fBtextVariable\fR for read-only purposes will +never cause problems. The danger comes when you try set the +\fBtextVariable\fR to something that the \fBvalidateCommand\fR would not +accept, which causes \fBvalidate\fR to become \fInone\fR (the +\fBinvalidCommand\fR will not be triggered). The same happens +when an error occurs evaluating the \fBvalidateCommand\fR. +.PP +Primarily, an error will occur when the \fBvalidateCommand\fR or +\fBinvalidCommand\fR encounters an error in its script while evaluating or +\fBvalidateCommand\fR does not return a valid Tcl boolean value. The +\fBvalidate\fR option will also set itself to \fBnone\fR when you edit the +spinbox widget from within either the \fBvalidateCommand\fR or the +\fBinvalidCommand\fR. Such editions will override the one that was being +validated. If you wish to edit the value of the widget +during validation and still have the \fBvalidate\fR option set, you should +include the command +.CS + \fI%W config -validate %v\fR +.CE +in the \fBvalidateCommand\fR or \fBinvalidCommand\fR (whichever one you +were editing the spinbox widget from). It is also recommended to not set an +associated \fBtextVariable\fR during validation, as that can cause the +spinbox widget to become out of sync with the \fBtextVariable\fR. + +.SH "WIDGET COMMAND" +.PP +The \fBspinbox\fR command creates a new Tcl command whose +name is \fIpathName\fR. This command may be used to invoke various +operations on the widget. It has the following general form: +.CS +\fIpathName option \fR?\fIarg arg ...\fR? +.CE +\fIOption\fR and the \fIarg\fRs +determine the exact behavior of the command. +.PP +Many of the widget commands for spinboxes take one or more indices as +arguments. An index specifies a particular character in the spinbox's +string, in any of the following ways: +.TP 12 +\fInumber\fR +Specifies the character as a numerical index, where 0 corresponds +to the first character in the string. +.TP 12 +\fBanchor\fR +Indicates the anchor point for the selection, which is set with the +\fBselect from\fR and \fBselect adjust\fR widget commands. +.TP 12 +\fBend\fR +Indicates the character just after the last one in the spinbox's string. +This is equivalent to specifying a numerical index equal to the length +of the spinbox's string. +.TP 12 +\fBinsert\fR +Indicates the character adjacent to and immediately following the +insertion cursor. +.TP 12 +\fBsel.first\fR +Indicates the first character in the selection. It is an error to +use this form if the selection isn't in the spinbox window. +.TP 12 +\fBsel.last\fR +Indicates the character just after the last one in the selection. +It is an error to use this form if the selection isn't in the +spinbox window. +.TP 12 +\fB@\fInumber\fR +In this form, \fInumber\fR is treated as an x-coordinate in the +spinbox's window; the character spanning that x-coordinate is used. +For example, ``\fB@0\fR'' indicates the left-most character in the +window. +.LP +Abbreviations may be used for any of the forms above, e.g. ``\fBe\fR'' +or ``\fBsel.f\fR''. In general, out-of-range indices are automatically +rounded to the nearest legal value. +.PP +The following commands are possible for spinbox widgets: +.TP +\fIpathName \fBbbox \fIindex\fR +Returns a list of four numbers describing the bounding box of the +character given by \fIindex\fR. +The first two elements of the list give the x and y coordinates of +the upper-left corner of the screen area covered by the character +(in pixels relative to the widget) and the last two elements give +the width and height of the character, in pixels. +The bounding box may refer to a region outside the visible area +of the window. +.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 \fBspinbox\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 +information on the format of this list). If \fIoption\fR is specified +with no \fIvalue\fR, then the command returns a list describing the +one named option (this list will be identical to the corresponding +sublist of the value returned if no \fIoption\fR is specified). If +one or more \fIoption\-value\fR pairs are specified, then the command +modifies the given widget option(s) to have the given value(s); in +this case the command returns an empty string. +\fIOption\fR may have any of the values accepted by the \fBspinbox\fR +command. +.TP +\fIpathName \fBdelete \fIfirst \fR?\fIlast\fR? +Delete one or more elements of the spinbox. +\fIFirst\fR is the index of the first character to delete, and +\fIlast\fR is the index of the character just after the last +one to delete. +If \fIlast\fR isn't specified it defaults to \fIfirst\fR+1, +i.e. a single character is deleted. +This command returns an empty string. +.TP +\fIpathName \fBget\fR +Returns the spinbox's string. +.TP +\fIpathName \fBicursor \fIindex\fR +Arrange for the insertion cursor to be displayed just before the character +given by \fIindex\fR. Returns an empty string. +.TP +\fIpathName \fBidentify\fI x y\fR +Returns the name of the window element corresponding to coordinates +\fIx\fR and \fIy\fR in the spinbox. Return value is one of: +\fBnone\fR, \fBbuttondown\fR, \fBbuttonup\fR, \fBentry\fR. +.TP +\fIpathName \fBindex\fI index\fR +Returns the numerical index corresponding to \fIindex\fR. +.TP +\fIpathName \fBinsert \fIindex string\fR +Insert the characters of \fIstring\fR just before the character +indicated by \fIindex\fR. Returns an empty string. +.TP +\fIpathName \fBinvoke\fI element\fR +Causes the specified element, either \fBbuttondown\fR or \fBbuttonup\fR, +to be invoked, triggering the action associated with it. +.TP +\fIpathName \fBscan\fR \fIoption args\fR +This command is used to implement scanning on spinboxes. It has +two forms, depending on \fIoption\fR: +.RS +.TP +\fIpathName \fBscan mark \fIx\fR +Records \fIx\fR and the current view in the spinbox window; used in +conjunction with later \fBscan dragto\fR commands. Typically this +command is associated with a mouse button press in the widget. It +returns an empty string. +.TP +\fIpathName \fBscan dragto \fIx\fR +This command computes the difference between its \fIx\fR argument +and the \fIx\fR argument to the last \fBscan mark\fR command for +the widget. It then adjusts the view left or right by 10 times the +difference in x-coordinates. This command is typically associated +with mouse motion events in the widget, to produce the effect of +dragging the spinbox at high speed through the window. The return +value is an empty string. +.RE +.TP +\fIpathName \fBselection \fIoption arg\fR +This command is used to adjust the selection within a spinbox. It +has several forms, depending on \fIoption\fR: +.RS +.TP +\fIpathName \fBselection adjust \fIindex\fR +Locate the end of the selection nearest to the character given by +\fIindex\fR, and adjust that end of the selection to be at \fIindex\fR +(i.e including but not going beyond \fIindex\fR). The other +end of the selection is made the anchor point for future +\fBselect to\fR commands. If the selection +isn't currently in the spinbox, then a new selection is created to +include the characters between \fIindex\fR and the most recent +selection anchor point, inclusive. +Returns an empty string. +.TP +\fIpathName \fBselection clear\fR +Clear the selection if it is currently in this widget. If the +selection isn't in this widget then the command has no effect. +Returns an empty string. +.TP +\fIpathName \fBselection element\fR ?\fIelement\fR? +Sets or gets the currently selected element. If a spinbutton element +is specified, it will be displayed depressed. +.TP +\fIpathName \fBselection from \fIindex\fR +Set the selection anchor point to just before the character +given by \fIindex\fR. Doesn't change the selection. +Returns an empty string. +.TP +\fIpathName \fBselection present\fR +Returns 1 if there is are characters selected in the spinbox, +0 if nothing is selected. +.TP +\fIpathName \fBselection range \fIstart\fR \fIend\fR +Sets the selection to include the characters starting with +the one indexed by \fIstart\fR and ending with the one just +before \fIend\fR. +If \fIend\fR refers to the same character as \fIstart\fR or an +earlier one, then the spinbox's selection is cleared. +.TP +\fIpathName \fBselection to \fIindex\fR +If \fIindex\fR is before the anchor point, set the selection +to the characters from \fIindex\fR up to but not including +the anchor point. +If \fIindex\fR is the same as the anchor point, do nothing. +If \fIindex\fR is after the anchor point, set the selection +to the characters from the anchor point up to but not including +\fIindex\fR. +The anchor point is determined by the most recent \fBselect from\fR +or \fBselect adjust\fR command in this widget. +If the selection isn't in this widget then a new selection is +created using the most recent anchor point specified for the widget. +Returns an empty string. +.RE +.TP +\fIpathName \fBset\fR ?\fIstring\fR? +If \fIstring\fR is specified, the spinbox will try and set it to this +value, otherwise it just returns the spinbox's string. +If validation is on, it will occur when setting the string. +.TP +\fIpathName \fBvalidate\fR +This command is used to force an evaluation of the \fBvalidateCommand\fR +independent of the conditions specified by the \fBvalidate\fR option. +This is done by temporarily setting the \fBvalidate\fR option to \fBall\fR. +It returns 0 or 1. +.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 spinbox'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. +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 + +.SH "DEFAULT BINDINGS" +.PP +Tk automatically creates class bindings for spinboxes that give them +the following default behavior. +In the descriptions below, ``word'' refers to a contiguous group +of letters, digits, or ``_'' characters, or any single character +other than these. +.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, and clears any selection in the widget. +Dragging with mouse button 1 strokes out a selection between +the insertion cursor and the character under the mouse. +.IP [2] +Double-clicking with mouse button 1 selects the word under the mouse +and positions the insertion cursor at the beginning of the word. +Dragging after a double click will stroke out a selection consisting +of whole words. +.IP [3] +Triple-clicking with mouse button 1 selects all of the text in the +spinbox and positions the insertion cursor before the first character. +.IP [4] +The ends of the selection can be adjusted by dragging with mouse +button 1 while the Shift key is down; this will adjust the end +of the selection that was nearest to the mouse cursor when button +1 was pressed. +If the button is double-clicked before dragging then the selection +will be adjusted in units of whole words. +.IP [5] +Clicking mouse button 1 with the Control key down will position the +insertion cursor in the spinbox without affecting the selection. +.IP [6] +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. +.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 +make more text visible (if there is more text off-screen on the side +where the mouse left the window). +.IP [9] +The Left and Right keys move the insertion cursor one character to the +left or right; they also clear any selection in the spinbox and set +the selection anchor. +If Left or Right is typed with the Shift key down, then the insertion +cursor moves and the selection is extended to include the new character. +Control-Left and Control-Right move the insertion cursor by words, and +Control-Shift-Left and Control-Shift-Right move the insertion cursor +by words and also extend the selection. +Control-b and Control-f behave the same as Left and Right, respectively. +Meta-b and Meta-f behave the same as Control-Left and Control-Right, +respectively. +.IP [10] +The Home key, or Control-a, will move the insertion cursor to the +beginning of the spinbox and clear any selection in the spinbox. +Shift-Home moves the insertion cursor to the beginning of the spinbox +and also extends the selection to that point. +.IP [11] +The End key, or Control-e, will move the insertion cursor to the +end of the spinbox and clear any selection in the spinbox. +Shift-End moves the cursor to the end and extends the selection +to that point. +.IP [12] +The Select key and Control-Space set the selection anchor to the position +of the insertion cursor. They don't affect the current selection. +Shift-Select and Control-Shift-Space adjust the selection to the +current position of the insertion cursor, selecting from the anchor +to the insertion cursor if there was not any selection previously. +.IP [13] +Control-/ selects all the text in the spinbox. +.IP [14] +Control-\e clears any selection in the spinbox. +.IP [15] +The F16 key (labelled Copy on many Sun workstations) or Meta-w +copies the selection in the widget to the clipboard, if there is a selection. +.IP [16] +The F20 key (labelled Cut on many Sun workstations) or Control-w +copies the selection in the widget to the clipboard and deletes +the selection. +If there is no selection in the widget then these keys have no effect. +.IP [17] +The F18 key (labelled Paste on many Sun workstations) or Control-y +inserts the contents of the clipboard at the position of the +insertion cursor. +.IP [18] +The Delete key deletes the selection, if there is one in the spinbox. +If there is no selection, it deletes the character to the right of +the insertion cursor. +.IP [19] +The BackSpace key and Control-h delete the selection, if there is one +in the spinbox. +If there is no selection, it deletes the character to the left of +the insertion cursor. +.IP [20] +Control-d deletes the character to the right of the insertion cursor. +.IP [21] +Meta-d deletes the word to the right of the insertion cursor. +.IP [22] +Control-k deletes all the characters to the right of the insertion +cursor. +.IP [23] +Control-t reverses the order of the two characters to the right of +the insertion cursor. +.PP +If the spinbox is disabled using the \fB\-state\fR option, then the spinbox's +view can still be adjusted and text in the spinbox can still be selected, +but no insertion cursor will be displayed and no text modifications will +take place. +.PP +The behavior of spinboxes can be changed by defining new bindings for +individual widgets or by redefining the class bindings. + +.SH KEYWORDS +spinbox, entry, widget diff --git a/tk/doc/text.n b/tk/doc/text.n index 5a0892d76fc..5cf8d9603c8 100644 --- a/tk/doc/text.n +++ b/tk/doc/text.n @@ -8,26 +8,45 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH text n 4.0 Tk "Tk Built-In Commands" +.TH text n 8.4 Tk "Tk Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME -text \- Create and manipulate text widgets +text, tk_textCopy, tk_textCut, tk_textPaste \- Create and manipulate text widgets .SH SYNOPSIS +.nf \fBtext\fR \fIpathName \fR?\fIoptions\fR? +.VS 8.4 +\fBtk_textCopy\fR \fIpathName\fR +\fBtk_textCut\fR \fIpathName\fR +\fBtk_textPaste\fR \fIpathName\fR +.VE 8.4 .SO -\-background \-highlightbackground \-insertontime \-selectborderwidth -\-borderwidth \-highlightcolor \-insertwidth \-selectforeground -\-cursor \-highlightthickness \-padx \-setgrid -\-exportselection \-insertbackground \-pady \-takefocus -\-font \-insertborderwidth \-relief \-xscrollcommand -\-foreground \-insertofftime \-selectbackground \-yscrollcommand +\-background \-highlightthickness \-relief +\-borderwidth \-insertbackground \-selectbackground +\-cursor \-insertborderwidth \-selectborderwidth +\-exportselection \-insertofftime \-selectforeground +\-font \-insertontime \-setgrid +\-foreground \-insertwidth \-takefocus +\-highlightbackground \-padx \-xscrollcommand +\-highlightcolor \-pady \-yscrollcommand .SE .SH "WIDGET-SPECIFIC OPTIONS" +.OP \-autoseparators autoSeparators AutoSeparators +.VS 8.4 +Specifies a boolean that says whether separators are automatically +inserted in the undo stack. Only meaningful when the \fB\-undo\fR +option is true. +.VE 8.4 .OP \-height height Height Specifies the desired height for the window, in units of characters in the font given by the \fB\-font\fR option. Must be at least one. +.OP \-maxundo maxUndo MaxUndo +.VS 8.4 +Specifies the maximum number of compound undo actions on the undo +stack. A zero or a negative value imply an unlimited undo stack. +.VE 8.4 .OP \-spacing1 spacing1 Spacing1 Requests additional space above each text line in the widget, using any of the standard forms for screen distances. @@ -81,6 +100,11 @@ options in tags. If no \fB\-tabs\fR option is specified, or if it is specified as an empty list, then Tk uses default tabs spaced every eight (average size) characters. +.OP \-undo undo Undo +.VS 8.4 +Specifies a boolean that says whether the undo mechanism is active or +not. +.VE 8.4 .OP \-width width Width Specifies the desired width for the window in units of characters in the font given by the \fB\-font\fR option. @@ -113,10 +137,8 @@ path name of the new window. .PP A text widget displays one or more lines of text and allows that text to be edited. -.VS Text widgets support four different kinds of annotations on the text, called tags, marks, embedded windows or embedded images. -.VE Tags allow different portions of the text to be displayed with different fonts and colors. In addition, Tcl commands can be associated with tags so @@ -134,11 +156,14 @@ The third form of annotation allows arbitrary windows to be embedded in a text widget. See EMBEDDED WINDOWS below for more details. .PP -.VS The fourth form of annotation allows Tk images to be embedded in a text widget. See EMBEDDED IMAGES below for more details. -.VE +.PP +.VS 8.4 +The text widget also has a built-in undo/redo mechanism. +See UNDO MECHANISM below for more details. +.VE 8.4 .SH INDICES .PP @@ -195,13 +220,11 @@ Indicates the position of the embedded window whose name is This form generates an error if there is no embedded window by the given name. .TP 12 -.VS \fIimageName\fR Indicates the position of the embedded image whose name is \fIimageName\fR. This form generates an error if there is no embedded image by the given name. -.VE .PP If the \fIbase\fP could match more than one of the above forms, such as a \fImark\fP and \fIimageName\fP both having the same value, then @@ -339,7 +362,7 @@ as an empty string, then a solid fill will be used. .TP \fB\-font \fIfontName\fR \fIFontName\fR is the name of a font to use for drawing characters. -It may have any of the forms accepted by \fBTk_GetFontStruct\fR. +It may have any of the forms accepted by \fBTk_GetFont\fR. .TP \fB\-foreground \fIcolor\fR \fIColor\fR specifies the color to use when drawing text and other @@ -524,7 +547,7 @@ motions if a mouse button is down; the update will be deferred until all mouse buttons have been released). Neither of these special marks may be deleted. -.SH EMBEDDED WINDOWS +.SH "EMBEDDED WINDOWS" .PP The third form of annotation in text widgets is an embedded window. Each embedded window annotation causes a window to be displayed @@ -594,8 +617,7 @@ stretched. \fB\-window \fIpathName\fR Specifies the name of a window to display in the annotation. -.VS -.SH EMBEDDED IMAGES +.SH "EMBEDDED IMAGES" .PP The final form of annotation in text widgets is an embedded image. Each embedded image annotation causes an image to be displayed @@ -662,9 +684,8 @@ It may have any of the usual forms defined for a screen distance. \fIPixels\fR specifies the amount of extra space to leave on the top and on the bottom of the embedded image. It may have any of the usual forms defined for a screen distance. -.VE -.SH THE SELECTION +.SH "THE SELECTION" .PP Selection support is implemented via tags. If the \fBexportSelection\fR option for the text widget is true @@ -680,6 +701,9 @@ characters with the \fBsel\fR tag. If the selection is claimed away by another application or by another window within this application, then the \fBsel\fR tag will be removed from all characters in the text. +.IP [4] +Whenever the \fBsel\fR tag range changes a virtual event +\fB<>\fR is generated. .PP The \fBsel\fR tag is automatically defined when a text widget is created, and it may not be deleted with the ``\fIpathName \fBtag delete\fR'' @@ -690,7 +714,7 @@ the text widget are tied to the \fB\-background\fR, tag: changes in either will automatically be reflected in the other. -.SH THE INSERTION CURSOR +.SH "THE INSERTION CURSOR" .PP The mark named \fBinsert\fR has special significance in text widgets. It is defined automatically when a text widget is created and it @@ -700,6 +724,47 @@ The \fBinsert\fR mark represents the position of the insertion cursor, and the insertion cursor will automatically be drawn at this point whenever the text widget has the input focus. +.SH "THE MODIFIED FLAG" +The text widget can keep track of changes to the content of the widget +by means of the modified flag. Inserting or deleting text will set +this flag. The flag can be queried, set and cleared programatically +as well. Whenever the flag changes state a \fB<>\fR virtual +event is generated. See the \fBedit modified\fR widget command for +more details. + +.SH "THE UNDO MECHANISM" +.PP +.VS 8.4 +The text widget has an unlimited undo and redo mechanism (when the +\fB-undo\fR widget option is true) which records every insert and +delete action on a stack. +.PP +Boundaries (called "separators") are inserted between edit actions. +The purpose of these separators is to group inserts and deletes into +one compound edit action. When undoing a change everything between +two separators will be undone. The undone changes are then moved to +the redo stack, so that an undone edit can be redone again. The redo +stack is cleared whenever new edit actions are recorded on the undo +stack. The undo and redo stacks can be cleared to keep their depth +under control. +.PP +Separators are inserted automatically when the \fB-autoseparators\fR +widget option is true. You can insert separators programatically as +well. If a separator is already present at the top of the undo stack +no other will be inserted. That means that two separators on the undo +stack are always separated by at least one insert or delete action. +.PP +The undo mechanism is also linked to the modified flag. This means +that undoing or redoing changes can take a modified text widget back +to the unmodified state or vice versa. The modified flag will be set +automatically to the appropriate state. This automatic coupling +does not work when the modified flag has been set by the user, until +the flag has been reset again. +.PP +See below for the \fBedit\fR widget command that controls the undo +mechanism. +.VE 8.4 + .SH "WIDGET COMMAND" .PP The \fBtext\fR command creates a new Tcl command whose @@ -770,8 +835,15 @@ There is a single debugging switch shared by all text widgets: turning debugging on or off in any widget turns it on or off for all widgets. For widgets with large amounts of text, the consistency checks may cause a noticeable slow-down. -.TP -\fIpathName \fBdelete \fIindex1 \fR?\fIindex2\fR? +.PP +.VS 8.4 +When debugging is turned on, the drawing routines of the text widget +set the global variables \fBtk_textRedraw\fR and \fBtk_textRelayout\fR +to the lists of indices that are redrawn. The values of these variables +are tested by Tk's test suite. +.VE 8.4 +.TP +\fIpathName \fBdelete \fIindex1 \fR?\fIindex2 ...\fR? Delete a range of characters from the text. If both \fIindex1\fR and \fIindex2\fR are specified, then delete all the characters starting with the one given by \fIindex1\fR @@ -784,6 +856,16 @@ If \fIindex2\fR isn't specified then the single character at It is not allowable to delete characters in a way that would leave the text without a newline as the last character. The command returns an empty string. +.VS 8.4 +If more indices are given, multiple ranges of text will be deleted. +All indices are first checked for validity before any deletions are made. +They are sorted and the text is removed from the last range to the +first range to deleted text does not cause a undesired index shifting +side-effects. If multiple ranges with the same start index are given, +then the longest range is used. If overlapping ranges are given, then +they will be merged into spans that do not cause deletion of text +outside the given ranges due to text shifted during deletion. +.VE 8.4 .TP \fIpathName \fBdlineinfo \fIindex\fR Returns a list with five elements describing the area occupied @@ -861,7 +943,43 @@ In this case an empty string is returned, and you must query the window by its index position to get more information. .RE .TP -\fIpathName \fBget \fIindex1 \fR?\fIindex2\fR? +\fIpathName \fBedit \fIoption \fR?\fIarg arg ...\fR? +.VS 8.4 +This command controls the undo mechanism and the modified flag. The +exact behavior of the command depends on the \fIoption\fR argument +that follows the \fBedit\fR argument. The following forms of the +command are currently supported: +.RS +.TP +\fIpathName \fBedit modified ?\fIboolean\fR? +If \fIboolean\fR is not specified, returns the modified flag of the +widget. The insert, delete, edit undo and edit redo commands or the +user can set or clear the modified flag. If \fIboolean\fR is +specified, sets the modified flag of the widget to \fIboolean\fR. +.TP +\fIpathName \fBedit redo\fR +When the \fB-undo\fR option is true, reapplies the last undone edits +provided no other edits were done since then. Generates an error when +the redo stack is empty. Does nothing when the \fB-undo\fR option is +false. +.TP +\fIpathName \fBedit reset\fR +Clears the undo and redo stacks. +.TP +\fIpathName \fBedit separator\fR +Inserts a separator (boundary) on the undo stack. Does nothing when +the \fB-undo\fR option is false. +.TP +\fIpathName \fBedit undo\fR +Undoes the last edit action when the \fB-undo\fR option is true. An +edit action is defined as all the insert and delete commands that are +recorded on the undo stack in between two separators. Generates an +error when the undo stack is empty. Does nothing when the \fB-undo\fR +option is false. +.RE +.VE 8.4 +.TP +\fIpathName \fBget \fIindex1 \fR?\fIindex2 ...\fR? Return a range of characters from the text. The return value will be all the characters in the text starting with the one whose index is \fIindex1\fR and ending just before @@ -874,6 +992,11 @@ is past the end of the file or \fIindex2\fR is less than or equal to \fIindex1\fR) then an empty string is returned. If the specified range contains embedded windows, no information about them is included in the returned string. +.VS 8.4 +If multiple index pairs are given, multiple ranges of text will be returned +in a list. Invalid ranges will not be represented with empty strings in +the list. The ranges are returned in the order passed to \fBget\fR. +.VE 8.4 .TP \fIpathName \fBimage \fIoption \fR?\fIarg arg ...\fR? This command is used to manipulate embedded images. @@ -1552,15 +1675,24 @@ Control-\e clears any selection in the widget. .IP [20] The F16 key (labelled Copy on many Sun workstations) or Meta-w copies the selection in the widget to the clipboard, if there is a selection. +.VS 8.4 +This action is carried out by the command \fBtk_textCopy\fR. +.VE 8.4 .IP [21] The F20 key (labelled Cut on many Sun workstations) or Control-w copies the selection in the widget to the clipboard and deletes the selection. +.VS 8.4 +This action is carried out by the command \fBtk_textCut\fR. +.VE 8.4 If there is no selection in the widget then these keys have no effect. .IP [22] The F18 key (labelled Paste on many Sun workstations) or Control-y inserts the contents of the clipboard at the position of the insertion cursor. +.VS 8.4 +This action is carried out by the command \fBtk_textPaste\fR. +.VE 8.4 .IP [23] The Delete key deletes the selection, if there is one in the widget. If there is no selection, it deletes the character to the right of @@ -1589,6 +1721,15 @@ Control-x deletes whatever is selected in the text widget. .IP [31] Control-t reverses the order of the two characters to the right of the insertion cursor. +.IP [32] +.VS 8.4 +Control-z (and Control-underscore on UNIX when \fBtk_strictMotif\fR is +true) undoes the last edit action if the \fB-undo\fR option is true. +Does nothing otherwise. +.IP [33] +Control-Z (or Control-y on Windows) reapplies the last undone edit +action if the \fB-undo\fR option is true. Does nothing otherwise. +.VE 8.4 .PP If the widget is disabled using the \fB\-state\fR option, then its view can still be adjusted and text can still be selected, @@ -1632,5 +1773,4 @@ The display line with the insert cursor is redrawn each time the cursor blinks, which causes a steady stream of graphics traffic. Set the \fBinsertOffTime\fP attribute to 0 avoid this. .SH KEYWORDS -text, widget - +text, widget, tkvars diff --git a/tk/doc/tk.n b/tk/doc/tk.n index 590ca6d5f4b..b60aa9e9e0c 100644 --- a/tk/doc/tk.n +++ b/tk/doc/tk.n @@ -8,7 +8,7 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH tk n 8.3 Tk "Tk Built-In Commands" +.TH tk n 8.4 Tk "Tk Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME @@ -43,6 +43,20 @@ be able to find some options for the application. If sends have been disabled by deleting the \fBsend\fR command, this command will reenable them and recreate the \fBsend\fR command. +.VS 8.4 +.TP +\fBtk caret window \fR?\fB\-x \fIx\fR? ?\fB\-y \fIy\fR? ?\fB\-height \fIheight\fR? +. +Sets and queries the caret location for the display of the specified +Tk window \fIwindow\fR. The caret is the per-display cursor location +used for indicating global focus (e.g. to comply with Microsoft +Accessibility guidelines), as well as for location of the over-the-spot +XIM (X Input Methods) or Windows IME windows. If no options are specified, +the last values used for setting the caret are return in option-value pair +format. \fI\-x\fR and \fI\-y\fR represent window-relative coordinates, and +\fI\-height\fR is the height of the current cursor location, or the height +of the specified \fIwindow\fR if none is given. +.VE .TP \fBtk scaling \fR?\fB\-displayof \fIwindow\fR? ?\fInumber\fR? . @@ -76,8 +90,15 @@ some locales (ie: Japanese, Korean), to handle special input devices. This feature is only significant on X. If XIM support is not available, this will always return 0. If the \fIwindow\fR argument is omitted, it defaults to the main window. If the \fIboolean\fR argument is omitted, the current -state is returned. +state is returned. This is turned on by default for the main display. +.VE +.VS 8.4 +.TP +\fBtk windowingsystem\fR +. +Returns the current Tk windowing system, one of +\fBx11\fR (X11-based), \fBwin32\fR (MS Windows), +\fBclassic\fR (Mac OS Classic), or \fBaqua\fR (Mac OS X Aqua). .VE .SH KEYWORDS application name, send - diff --git a/tk/doc/tkerror.n b/tk/doc/tkerror.n index 115eb033f89..9ccee96b1bc 100644 --- a/tk/doc/tkerror.n +++ b/tk/doc/tkerror.n @@ -36,4 +36,3 @@ documentation. .SH KEYWORDS background error, reporting - diff --git a/tk/doc/tkvars.n b/tk/doc/tkvars.n index 652fc77b866..fe8b2e7d611 100644 --- a/tk/doc/tkvars.n +++ b/tk/doc/tkvars.n @@ -44,9 +44,9 @@ Contains a decimal integer giving the current patch level for Tk. The patch level is incremented for each new release or patch, and it uniquely identifies an official version of Tk. .TP -\fBtkPriv\fR +\fBtk::Priv\fR This variable is an array containing several pieces of information -that are private to Tk. The elements of \fBtkPriv\fR are used by +that are private to Tk. The elements of \fBtk::Priv\fR are used by Tk library procedures and default bindings. They should not be accessed by any code outside Tk. .TP @@ -56,6 +56,14 @@ If an application sets it to one, then Tk attempts to adhere as closely as possible to Motif look-and-feel standards. For example, active elements such as buttons and scrollbar sliders will not change color when the pointer passes over them. +.TP +\fBtk_textRedraw\fR +.TP +\fBtk_textRelayout\fR +These variables are set by text widgets when they have debugging +turned on. The values written to these variables can be used to +test or debug text widget operations. These variables are mostly +used by Tk's test suite. .TP 15 \fBtk_version\fR Tk sets this variable in the interpreter for each application. @@ -69,5 +77,4 @@ each new release of Tk, except that it resets to zero whenever the major version number changes. .SH KEYWORDS -variables, version - +variables, version, text diff --git a/tk/doc/tkwait.n b/tk/doc/tkwait.n index e5da82a0beb..0c39f384975 100644 --- a/tk/doc/tkwait.n +++ b/tk/doc/tkwait.n @@ -49,4 +49,3 @@ to \fBtkwait\fR must complete before the outer call can complete. .SH KEYWORDS variable, visibility, wait, window - diff --git a/tk/doc/toplevel.n b/tk/doc/toplevel.n index c8e7fc43a3e..070da077132 100644 --- a/tk/doc/toplevel.n +++ b/tk/doc/toplevel.n @@ -8,7 +8,7 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH toplevel n 8.0 Tk "Tk Built-In Commands" +.TH toplevel n 8.4 Tk "Tk Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME @@ -16,8 +16,9 @@ toplevel \- Create and manipulate toplevel widgets .SH SYNOPSIS \fBtoplevel\fR \fIpathName \fR?\fIoptions\fR? .SO -\-borderwidth \-highlightbackground \-highlightthickness \-takefocus -\-cursor \-highlightcolor \-relief +\-borderwidth \-highlightcolor \-pady +\-cursor \-highlightthickness \-relief +\-highlightbackground \-padx \-takefocus .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-background background Background @@ -44,7 +45,6 @@ If the \fBcolormap\fR option is not specified, the new window uses the default colormap of its screen. This option may not be changed with the \fBconfigure\fR widget command. -.VS 8.0 br .OP \-container container Container The value must be a boolean. If true, it means that this window will be used as a container in which some other application will be embedded @@ -54,20 +54,17 @@ things like geometry requests. The window should not have any children of its own in this application. This option may not be changed with the \fBconfigure\fR widget command. -.VE .OP \-height height Height Specifies the desired height for the window in any of the forms acceptable to \fBTk_GetPixels\fR. If this option is less than or equal to zero then the window will not request any size at all. -.VS 8.0 br .OP \-menu menu Menu Specifies a menu widget to be used as a menubar. On the Macintosh, the menubar will be displayed accross the top of the main monitor. On Microsoft Windows and all UNIX platforms, the menu will appear accross the toplevel window as part of the window dressing maintained by the window manager. -.VE .OP \-screen "" "" Specifies the screen on which to place the new window. Any valid screen name may be used, even one associated with a @@ -76,7 +73,6 @@ 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. -.VS 8.0 br .OP \-use use Use This option is used for embedding. If the value isn't an empty string, it must be the the window identifier of a container window, specified as @@ -87,7 +83,6 @@ window is in a Tk application, it must be a frame or toplevel widget for which the \fB\-container\fR option was specified. This option may not be changed with the \fBconfigure\fR widget command. -.VE .OP \-visual visual Visual Specifies visual information for the new window in any of the forms accepted by \fBTk_GetVisual\fR. @@ -159,6 +154,8 @@ command. When a new toplevel is created, it has no default event bindings: toplevels are not intended to be interactive. +.SH "SEE ALSO" +frame(n) + .SH KEYWORDS toplevel, widget - diff --git a/tk/doc/winfo.n b/tk/doc/winfo.n index e8cae44aabb..2d1303e2b21 100644 --- a/tk/doc/winfo.n +++ b/tk/doc/winfo.n @@ -46,9 +46,11 @@ color map for \fIwindow\fR. .TP \fBwinfo children \fIwindow\fR Returns a list containing the path names of all the children -of \fIwindow\fR. The list is in stacking order, with the lowest -window first. Top-level windows are returned as children -of their logical parents. +of \fIwindow\fR. Top-level windows are returned as children +of their logical parents. The list is in stacking order, with +the lowest window first, except for Top-level windows which +are not returned in stacking order. Use the \fBwm stackorder\fR +command to query the stacking order of Top-level windows. .TP \fBwinfo class \fIwindow\fR Returns the class name for \fIwindow\fR. @@ -328,4 +330,3 @@ has no border). .SH KEYWORDS atom, children, class, geometry, height, identifier, information, interpreters, mapped, parent, path name, screen, virtual root, width, window - diff --git a/tk/doc/wish.1 b/tk/doc/wish.1 index 157729f01c0..4afc2be5dff 100644 --- a/tk/doc/wish.1 +++ b/tk/doc/wish.1 @@ -184,4 +184,3 @@ incomplete commands. .SH KEYWORDS shell, toolkit - diff --git a/tk/doc/wm.n b/tk/doc/wm.n index 6d146bb4a6b..ab21e01afef 100644 --- a/tk/doc/wm.n +++ b/tk/doc/wm.n @@ -8,7 +8,7 @@ '\" RCS: @(#) $Id$ '\" .so man.macros -.TH wm n 4.3 Tk "Tk Built-In Commands" +.TH wm n 8.4 Tk "Tk Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME @@ -44,6 +44,30 @@ a Tcl list containing four elements, which are the current values of \fIminNumer\fR, \fIminDenom\fR, \fImaxNumer\fR, and \fImaxDenom\fR (if no aspect restrictions are in effect, then an empty string is returned). +.VS 8.4 +.TP +\fBwm attributes \fIwindow\fR +.TP +\fBwm attributes \fIwindow\fR ?\fBoption\fR? +.TP +\fBwm attributes \fIwindow\fR ?\fBoption value option value...\fR? +.RS +This subcommand returns or sets platform specific attributes associated +with a window. The first form returns a list of the platform specific +flags and their values. The second form returns the value for the +specific option. The third form sets one or more of the values. The +values are as follows: +.PP +On Windows, \fB-disabled\fR gets or sets whether the window is in a +disabled state. \fB-toolwindow\fR gets or sets the style of the window +to toolwindow (as defined in the MSDN). \fB-topmost\fR gets or sets +whether this is a topmost window (displays above all other windows). +.PP +On Macintosh, +.PP +On Unix, there are currently no special attribute values. +.RE +.VE 8.4 .TP \fBwm client \fIwindow\fR ?\fIname\fR? If \fIname\fR is specified, this command stores \fIname\fR (which @@ -208,7 +232,19 @@ bitmap is cancelled for \fIwindow\fR. If \fIbitmap\fR is specified then the command returns an empty string. Otherwise it returns the name of the current icon bitmap associated with \fIwindow\fR, or an empty -string if \fIwindow\fR has no icon bitmap. +string if \fIwindow\fR has no icon bitmap. On the Windows operating +system, an additional flag is supported: +\fBwm iconbitmap \fIwindow\fR ?\fI-default\fR? ?\fIimage\fR?. +If the \fI-default\fR +flag is given, the icon is applied to all toplevel windows (existing +and future) to which no other specific icon has yet been applied. +In addition to bitmap image types, a full path specification to +any file which contains a valid +Windows icon is also accepted (usually .ico or .icr files), or any +file for which the shell has assigned an icon. Tcl will +first test if the file contains an icon, then if it has an assigned +icon, and finally, if that fails, test for +a bitmap. .TP \fBwm iconify \fIwindow\fR Arrange for \fIwindow\fR to be iconified. It \fIwindow\fR hasn't @@ -391,6 +427,19 @@ source of the window's current size, or an empty string if no source has been specified yet. Most window managers interpret ``no source'' as equivalent to \fBprogram\fR. .TP +\fBwm stackorder \fIwindow\fR ?\fIisabove|isbelow window\fR? +The stackorder command returns a list of toplevel windows +in stacking order, from lowest to highest. When a single toplevel +window is passed, the returned list recursively includes all of the +window's children that are toplevels. Only those toplevels +that are currently mapped to the screen are returned. +The stackorder command can also be used to determine if one +toplevel is positioned above or below a second toplevel. +When two window arguments separated by either \fIisabove\fR or +\fIisbelow\fR are passed, a boolean result indicates whether +or not the first window is currently above or below the second +window in the stacking order. +.TP \fBwm state \fIwindow\fR ?newstate? If \fInewstate\fR is specified, the window will be set to the new state, otherwise it returns the current state of \fIwindow\fR: either @@ -413,13 +462,14 @@ specified then the command returns the current title for the If \fImaster\fR is specified, then the window manager is informed that \fIwindow\fR is a transient window (e.g. pull-down menu) working on behalf of \fImaster\fR (where \fImaster\fR is the -path name for a top-level window). Some window managers will use -this information to manage \fIwindow\fR specially. If \fImaster\fR +path name for a top-level window). If \fImaster\fR is specified as an empty string then \fIwindow\fR is marked as not -being a transient window any more. If \fImaster\fR is specified, -then the command returns an empty string. Otherwise the command +being a transient window any more. Otherwise the command returns the path name of \fIwindow\fR's current master, or an empty string if \fIwindow\fR isn't currently a transient window. +A transient window will mirror state changes in the master and +inherit the state of the master when initially mapped. It is an +error to attempt to make a window a transient of itself. .TP \fBwm withdraw \fIwindow\fR Arranges for \fIwindow\fR to be withdrawn from the screen. This @@ -504,4 +554,3 @@ to be withdrawn and de-iconified in order to make the change happen. .SH KEYWORDS aspect ratio, deiconify, focus model, geometry, grid, group, icon, iconify, increments, position, size, title, top-level window, units, window manager - diff --git a/tk/generic/default.h b/tk/generic/default.h index 8db5f297b58..73e76864fc8 100644 --- a/tk/generic/default.h +++ b/tk/generic/default.h @@ -20,7 +20,9 @@ defined(__CYGWIN__) || defined(__MINGW32__) # include "tkWinDefault.h" #else -# if defined(MAC_TCL) +# if defined(MAC_OSX_TK) +# include "tkMacOSXDefault.h" +# elif defined(MAC_TCL) # include "tkMacDefault.h" # else # include "tkUnixDefault.h" @@ -28,4 +30,3 @@ #endif #endif /* _DEFAULT */ - diff --git a/tk/generic/ks_names.h b/tk/generic/ks_names.h index 7c299e8b5f6..75b914981b5 100644 --- a/tk/generic/ks_names.h +++ b/tk/generic/ks_names.h @@ -921,5 +921,3 @@ { "hebrew_shin", 0xcf9 }, { "hebrew_taf", 0xcfa }, { "Hebrew_switch", 0xFF7E }, - - diff --git a/tk/generic/prolog.ps b/tk/generic/prolog.ps index 2ab137266ef..546408a34e6 100644 --- a/tk/generic/prolog.ps +++ b/tk/generic/prolog.ps @@ -282,4 +282,3 @@ systemdict /ISOLatin1Encoding known not { } bind def %%EndProlog - diff --git a/tk/generic/tk.decls b/tk/generic/tk.decls index 51679e2ad3d..b35dbe16516 100644 --- a/tk/generic/tk.decls +++ b/tk/generic/tk.decls @@ -6,7 +6,8 @@ # tkStub.c, and tkPlatStub.c files. # # -# Copyright (c) 1998-1999 by Scriptics Corporation. +# Copyright (c) 1998-2000 Ajuba Solutions. +# # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # @@ -35,49 +36,49 @@ declare 1 generic { } declare 2 generic { - GC Tk_3DBorderGC (Tk_Window tkwin, Tk_3DBorder border, \ + GC Tk_3DBorderGC (Tk_Window tkwin, Tk_3DBorder border, int which) } declare 3 generic { - void Tk_3DHorizontalBevel (Tk_Window tkwin, \ - Drawable drawable, Tk_3DBorder border, int x, \ - int y, int width, int height, int leftIn, \ + void Tk_3DHorizontalBevel (Tk_Window tkwin, + Drawable drawable, Tk_3DBorder border, int x, + int y, int width, int height, int leftIn, int rightIn, int topBevel, int relief) } declare 4 generic { - void Tk_3DVerticalBevel (Tk_Window tkwin, \ - Drawable drawable, Tk_3DBorder border, int x, \ - int y, int width, int height, int leftBevel, \ + void Tk_3DVerticalBevel (Tk_Window tkwin, + Drawable drawable, Tk_3DBorder border, int x, + int y, int width, int height, int leftBevel, int relief) } declare 5 generic { - void Tk_AddOption (Tk_Window tkwin, char *name, \ - char *value, int priority) + void Tk_AddOption (Tk_Window tkwin, CONST char *name, + CONST char *value, int priority) } declare 6 generic { - void Tk_BindEvent (Tk_BindingTable bindingTable, \ - XEvent *eventPtr, Tk_Window tkwin, int numObjects, \ + void Tk_BindEvent (Tk_BindingTable bindingTable, + XEvent *eventPtr, Tk_Window tkwin, int numObjects, ClientData *objectPtr) } declare 7 generic { - void Tk_CanvasDrawableCoords (Tk_Canvas canvas, \ - double x, double y, short *drawableXPtr, \ + void Tk_CanvasDrawableCoords (Tk_Canvas canvas, + double x, double y, short *drawableXPtr, short *drawableYPtr) } declare 8 generic { - void Tk_CanvasEventuallyRedraw (Tk_Canvas canvas, int x1, int y1, \ + void Tk_CanvasEventuallyRedraw (Tk_Canvas canvas, int x1, int y1, int x2, int y2) } declare 9 generic { - int Tk_CanvasGetCoord (Tcl_Interp *interp, \ - Tk_Canvas canvas, char *str, double *doublePtr) + int Tk_CanvasGetCoord (Tcl_Interp *interp, + Tk_Canvas canvas, CONST char *str, double *doublePtr) } declare 10 generic { @@ -85,28 +86,28 @@ declare 10 generic { } declare 11 generic { - int Tk_CanvasPsBitmap (Tcl_Interp *interp, \ - Tk_Canvas canvas, Pixmap bitmap, int x, int y, \ + int Tk_CanvasPsBitmap (Tcl_Interp *interp, + Tk_Canvas canvas, Pixmap bitmap, int x, int y, int width, int height) } declare 12 generic { - int Tk_CanvasPsColor (Tcl_Interp *interp, \ + int Tk_CanvasPsColor (Tcl_Interp *interp, Tk_Canvas canvas, XColor *colorPtr) } declare 13 generic { - int Tk_CanvasPsFont (Tcl_Interp *interp, \ + int Tk_CanvasPsFont (Tcl_Interp *interp, Tk_Canvas canvas, Tk_Font font) } declare 14 generic { - void Tk_CanvasPsPath (Tcl_Interp *interp, \ + void Tk_CanvasPsPath (Tcl_Interp *interp, Tk_Canvas canvas, double *coordPtr, int numPoints) } declare 15 generic { - int Tk_CanvasPsStipple (Tcl_Interp *interp, \ + int Tk_CanvasPsStipple (Tcl_Interp *interp, Tk_Canvas canvas, Pixmap bitmap) } @@ -119,12 +120,12 @@ declare 17 generic { } declare 18 generic { - int Tk_CanvasTagsParseProc (ClientData clientData, Tcl_Interp *interp, \ - Tk_Window tkwin, char *value, char *widgRec, int offset) + int Tk_CanvasTagsParseProc (ClientData clientData, Tcl_Interp *interp, + Tk_Window tkwin, CONST char *value, char *widgRec, int offset) } declare 19 generic { - char * Tk_CanvasTagsPrintProc (ClientData clientData, Tk_Window tkwin, \ + char * Tk_CanvasTagsPrintProc (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr) } @@ -133,17 +134,17 @@ declare 20 generic { } declare 21 generic { - void Tk_CanvasWindowCoords (Tk_Canvas canvas, double x, double y, \ + void Tk_CanvasWindowCoords (Tk_Canvas canvas, double x, double y, short *screenXPtr, short *screenYPtr) } declare 22 generic { - void Tk_ChangeWindowAttributes (Tk_Window tkwin, unsigned long valueMask, \ + void Tk_ChangeWindowAttributes (Tk_Window tkwin, unsigned long valueMask, XSetWindowAttributes *attsPtr) } declare 23 generic { - int Tk_CharBbox (Tk_TextLayout layout, int index, int *xPtr, \ + int Tk_CharBbox (Tk_TextLayout layout, int index, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr) } @@ -152,7 +153,7 @@ declare 24 generic { } declare 25 generic { - int Tk_ClipboardAppend (Tcl_Interp *interp,Tk_Window tkwin, \ + int Tk_ClipboardAppend (Tcl_Interp *interp,Tk_Window tkwin, Atom target, Atom format, char* buffer) } @@ -161,33 +162,33 @@ declare 26 generic { } declare 27 generic { - int Tk_ConfigureInfo (Tcl_Interp *interp, \ - Tk_Window tkwin, Tk_ConfigSpec *specs, \ - char *widgRec, char *argvName, int flags) + int Tk_ConfigureInfo (Tcl_Interp *interp, + Tk_Window tkwin, Tk_ConfigSpec *specs, + char *widgRec, CONST char *argvName, int flags) } declare 28 generic { - int Tk_ConfigureValue (Tcl_Interp *interp, \ - Tk_Window tkwin, Tk_ConfigSpec *specs, \ - char *widgRec, char *argvName, int flags) + int Tk_ConfigureValue (Tcl_Interp *interp, + Tk_Window tkwin, Tk_ConfigSpec *specs, + char *widgRec, CONST char *argvName, int flags) } declare 29 generic { - int Tk_ConfigureWidget (Tcl_Interp *interp, \ - Tk_Window tkwin, Tk_ConfigSpec *specs, \ - int argc, char **argv, char *widgRec, \ + int Tk_ConfigureWidget (Tcl_Interp *interp, + Tk_Window tkwin, Tk_ConfigSpec *specs, + int argc, CONST84 char **argv, char *widgRec, int flags) } declare 30 generic { - void Tk_ConfigureWindow (Tk_Window tkwin, \ + void Tk_ConfigureWindow (Tk_Window tkwin, unsigned int valueMask, XWindowChanges *valuePtr) } declare 31 generic { - Tk_TextLayout Tk_ComputeTextLayout (Tk_Font font, \ - CONST char *str, int numChars, int wrapLength, \ - Tk_Justify justify, int flags, int *widthPtr, \ + Tk_TextLayout Tk_ComputeTextLayout (Tk_Font font, + CONST char *str, int numChars, int wrapLength, + Tk_Justify justify, int flags, int *widthPtr, int *heightPtr) } @@ -196,9 +197,9 @@ declare 32 generic { } declare 33 generic { - unsigned long Tk_CreateBinding (Tcl_Interp *interp, \ - Tk_BindingTable bindingTable, ClientData object, \ - char *eventStr, char *command, int append) + unsigned long Tk_CreateBinding (Tcl_Interp *interp, + Tk_BindingTable bindingTable, ClientData object, + CONST char *eventStr, CONST char *command, int append) } declare 34 generic { @@ -206,14 +207,14 @@ declare 34 generic { } declare 35 generic { - Tk_ErrorHandler Tk_CreateErrorHandler (Display *display, \ - int errNum, int request, int minorCode, \ + Tk_ErrorHandler Tk_CreateErrorHandler (Display *display, + int errNum, int request, int minorCode, Tk_ErrorProc *errorProc, ClientData clientData) } declare 36 generic { - void Tk_CreateEventHandler (Tk_Window token, \ - unsigned long mask, Tk_EventProc *proc, \ + void Tk_CreateEventHandler (Tk_Window token, + unsigned long mask, Tk_EventProc *proc, ClientData clientData) } @@ -234,25 +235,25 @@ declare 40 generic { } declare 41 generic { - void Tk_CreateSelHandler (Tk_Window tkwin, \ - Atom selection, Atom target, \ - Tk_SelectionProc *proc, ClientData clientData, \ + void Tk_CreateSelHandler (Tk_Window tkwin, + Atom selection, Atom target, + Tk_SelectionProc *proc, ClientData clientData, Atom format) } declare 42 generic { - Tk_Window Tk_CreateWindow (Tcl_Interp *interp, \ - Tk_Window parent, char *name, char *screenName) + Tk_Window Tk_CreateWindow (Tcl_Interp *interp, + Tk_Window parent, CONST char *name, CONST char *screenName) } declare 43 generic { - Tk_Window Tk_CreateWindowFromPath (Tcl_Interp *interp, Tk_Window tkwin, \ - char *pathName, char *screenName) + Tk_Window Tk_CreateWindowFromPath (Tcl_Interp *interp, Tk_Window tkwin, + CONST char *pathName, CONST char *screenName) } declare 44 generic { - int Tk_DefineBitmap (Tcl_Interp *interp, CONST char *name, char *source, \ - int width, int height) + int Tk_DefineBitmap (Tcl_Interp *interp, CONST char *name, + CONST char *source, int width, int height) } declare 45 generic { @@ -264,9 +265,9 @@ declare 46 generic { } declare 47 generic { - int Tk_DeleteBinding (Tcl_Interp *interp, \ - Tk_BindingTable bindingTable, ClientData object, \ - char *eventStr) + int Tk_DeleteBinding (Tcl_Interp *interp, + Tk_BindingTable bindingTable, ClientData object, + CONST char *eventStr) } declare 48 generic { @@ -278,8 +279,8 @@ declare 49 generic { } declare 50 generic { - void Tk_DeleteEventHandler (Tk_Window token, \ - unsigned long mask, Tk_EventProc *proc, \ + void Tk_DeleteEventHandler (Tk_Window token, + unsigned long mask, Tk_EventProc *proc, ClientData clientData) } @@ -288,7 +289,7 @@ declare 51 generic { } declare 52 generic { - void Tk_DeleteImage (Tcl_Interp *interp, char *name) + void Tk_DeleteImage (Tcl_Interp *interp, CONST char *name) } declare 53 generic { @@ -300,7 +301,7 @@ declare 54 generic { } declare 55 generic { - char * Tk_DisplayName (Tk_Window tkwin) + CONST84_RETURN char * Tk_DisplayName (Tk_Window tkwin) } declare 56 generic { @@ -308,50 +309,50 @@ declare 56 generic { } declare 57 generic { - void Tk_Draw3DPolygon (Tk_Window tkwin, \ - Drawable drawable, Tk_3DBorder border, \ - XPoint *pointPtr, int numPoints, int borderWidth, \ + void Tk_Draw3DPolygon (Tk_Window tkwin, + Drawable drawable, Tk_3DBorder border, + XPoint *pointPtr, int numPoints, int borderWidth, int leftRelief) } declare 58 generic { - void Tk_Draw3DRectangle (Tk_Window tkwin, Drawable drawable, \ - Tk_3DBorder border, int x, int y, int width, int height, \ + void Tk_Draw3DRectangle (Tk_Window tkwin, Drawable drawable, + Tk_3DBorder border, int x, int y, int width, int height, int borderWidth, int relief) } declare 59 generic { - void Tk_DrawChars (Display *display, Drawable drawable, GC gc, \ + void Tk_DrawChars (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, CONST char *source, int numBytes, int x, int y) } declare 60 generic { - void Tk_DrawFocusHighlight (Tk_Window tkwin, GC gc, int width, \ + void Tk_DrawFocusHighlight (Tk_Window tkwin, GC gc, int width, Drawable drawable) } declare 61 generic { - void Tk_DrawTextLayout (Display *display, \ - Drawable drawable, GC gc, Tk_TextLayout layout, \ + void Tk_DrawTextLayout (Display *display, + Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, int firstChar, int lastChar) } declare 62 generic { - void Tk_Fill3DPolygon (Tk_Window tkwin, \ - Drawable drawable, Tk_3DBorder border, \ - XPoint *pointPtr, int numPoints, int borderWidth, \ + void Tk_Fill3DPolygon (Tk_Window tkwin, + Drawable drawable, Tk_3DBorder border, + XPoint *pointPtr, int numPoints, int borderWidth, int leftRelief) } declare 63 generic { - void Tk_Fill3DRectangle (Tk_Window tkwin, \ - Drawable drawable, Tk_3DBorder border, int x, \ - int y, int width, int height, int borderWidth, \ + void Tk_Fill3DRectangle (Tk_Window tkwin, + Drawable drawable, Tk_3DBorder border, int x, + int y, int width, int height, int borderWidth, int relief) } declare 64 generic { - Tk_PhotoHandle Tk_FindPhoto (Tcl_Interp *interp, char *imageName) + Tk_PhotoHandle Tk_FindPhoto (Tcl_Interp *interp, CONST char *imageName) } declare 65 generic { @@ -391,7 +392,7 @@ declare 73 generic { } declare 74 generic { - void Tk_FreeOptions (Tk_ConfigSpec *specs, \ + void Tk_FreeOptions (Tk_ConfigSpec *specs, char *widgRec, Display *display, int needFlags) } @@ -416,28 +417,28 @@ declare 79 generic { } declare 80 generic { - Tk_3DBorder Tk_Get3DBorder (Tcl_Interp *interp, Tk_Window tkwin, \ + Tk_3DBorder Tk_Get3DBorder (Tcl_Interp *interp, Tk_Window tkwin, Tk_Uid colorName) } declare 81 generic { - void Tk_GetAllBindings (Tcl_Interp *interp, \ + void Tk_GetAllBindings (Tcl_Interp *interp, Tk_BindingTable bindingTable, ClientData object) } declare 82 generic { - int Tk_GetAnchor (Tcl_Interp *interp, \ - char *str, Tk_Anchor *anchorPtr) + int Tk_GetAnchor (Tcl_Interp *interp, + CONST char *str, Tk_Anchor *anchorPtr) } declare 83 generic { - char * Tk_GetAtomName (Tk_Window tkwin, Atom atom) + CONST84_RETURN char * Tk_GetAtomName (Tk_Window tkwin, Atom atom) } declare 84 generic { - char * Tk_GetBinding (Tcl_Interp *interp, \ - Tk_BindingTable bindingTable, ClientData object, \ - char *eventStr) + CONST84_RETURN char * Tk_GetBinding (Tcl_Interp *interp, + Tk_BindingTable bindingTable, ClientData object, + CONST char *eventStr) } declare 85 generic { @@ -445,12 +446,12 @@ declare 85 generic { } declare 86 generic { - Pixmap Tk_GetBitmapFromData (Tcl_Interp *interp, \ - Tk_Window tkwin, char *source, int width, int height) + Pixmap Tk_GetBitmapFromData (Tcl_Interp *interp, + Tk_Window tkwin, CONST char *source, int width, int height) } declare 87 generic { - int Tk_GetCapStyle (Tcl_Interp *interp, char *str, int *capPtr) + int Tk_GetCapStyle (Tcl_Interp *interp, CONST char *str, int *capPtr) } declare 88 generic { @@ -462,23 +463,24 @@ declare 89 generic { } declare 90 generic { - Colormap Tk_GetColormap (Tcl_Interp *interp, Tk_Window tkwin, char *str) + Colormap Tk_GetColormap (Tcl_Interp *interp, Tk_Window tkwin, + CONST char *str) } declare 91 generic { - Tk_Cursor Tk_GetCursor (Tcl_Interp *interp, Tk_Window tkwin, \ + Tk_Cursor Tk_GetCursor (Tcl_Interp *interp, Tk_Window tkwin, Tk_Uid str) } declare 92 generic { - Tk_Cursor Tk_GetCursorFromData (Tcl_Interp *interp, \ - Tk_Window tkwin, char *source, char *mask, \ - int width, int height, int xHot, int yHot, \ + Tk_Cursor Tk_GetCursorFromData (Tcl_Interp *interp, + Tk_Window tkwin, CONST char *source, CONST char *mask, + int width, int height, int xHot, int yHot, Tk_Uid fg, Tk_Uid bg) } declare 93 generic { - Tk_Font Tk_GetFont (Tcl_Interp *interp, \ + Tk_Font Tk_GetFont (Tcl_Interp *interp, Tk_Window tkwin, CONST char *str) } @@ -495,13 +497,13 @@ declare 96 generic { } declare 97 generic { - Tk_Image Tk_GetImage (Tcl_Interp *interp, Tk_Window tkwin, char *name, \ + Tk_Image Tk_GetImage (Tcl_Interp *interp, Tk_Window tkwin, CONST char *name, Tk_ImageChangedProc *changeProc, ClientData clientData) } declare 98 generic { - ClientData Tk_GetImageMasterData (Tcl_Interp *interp, \ - char *name, Tk_ImageType **typePtrPtr) + ClientData Tk_GetImageMasterData (Tcl_Interp *interp, + CONST char *name, Tk_ImageType **typePtrPtr) } declare 99 generic { @@ -509,12 +511,12 @@ declare 99 generic { } declare 100 generic { - int Tk_GetJoinStyle (Tcl_Interp *interp, char *str, int *joinPtr) + int Tk_GetJoinStyle (Tcl_Interp *interp, CONST char *str, int *joinPtr) } declare 101 generic { - int Tk_GetJustify (Tcl_Interp *interp, \ - char *str, Tk_Justify *justifyPtr) + int Tk_GetJustify (Tcl_Interp *interp, + CONST char *str, Tk_Justify *justifyPtr) } declare 102 generic { @@ -522,21 +524,22 @@ declare 102 generic { } declare 103 generic { - Tk_Uid Tk_GetOption (Tk_Window tkwin, char *name, char *className) + Tk_Uid Tk_GetOption (Tk_Window tkwin, CONST char *name, + CONST char *className) } declare 104 generic { - int Tk_GetPixels (Tcl_Interp *interp, \ - Tk_Window tkwin, char *str, int *intPtr) + int Tk_GetPixels (Tcl_Interp *interp, + Tk_Window tkwin, CONST char *str, int *intPtr) } declare 105 generic { - Pixmap Tk_GetPixmap (Display *display, Drawable d, \ + Pixmap Tk_GetPixmap (Display *display, Drawable d, int width, int height, int depth) } declare 106 generic { - int Tk_GetRelief (Tcl_Interp *interp, char *name, int *reliefPtr) + int Tk_GetRelief (Tcl_Interp *interp, CONST char *name, int *reliefPtr) } declare 107 generic { @@ -544,18 +547,18 @@ declare 107 generic { } declare 108 generic { - int Tk_GetScrollInfo (Tcl_Interp *interp, \ - int argc, char **argv, double *dblPtr, int *intPtr) + int Tk_GetScrollInfo (Tcl_Interp *interp, + int argc, CONST84 char **argv, double *dblPtr, int *intPtr) } declare 109 generic { - int Tk_GetScreenMM (Tcl_Interp *interp, \ - Tk_Window tkwin, char *str, double *doublePtr) + int Tk_GetScreenMM (Tcl_Interp *interp, + Tk_Window tkwin, CONST char *str, double *doublePtr) } declare 110 generic { - int Tk_GetSelection (Tcl_Interp *interp, \ - Tk_Window tkwin, Atom selection, Atom target, \ + int Tk_GetSelection (Tcl_Interp *interp, + Tk_Window tkwin, Atom selection, Atom target, Tk_GetSelProc *proc, ClientData clientData) } @@ -564,13 +567,13 @@ declare 111 generic { } declare 112 generic { - Visual * Tk_GetVisual (Tcl_Interp *interp, \ - Tk_Window tkwin, char *str, int *depthPtr, \ + Visual * Tk_GetVisual (Tcl_Interp *interp, + Tk_Window tkwin, CONST char *str, int *depthPtr, Colormap *colormapPtr) } declare 113 generic { - void Tk_GetVRootGeometry (Tk_Window tkwin, \ + void Tk_GetVRootGeometry (Tk_Window tkwin, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr) } @@ -587,7 +590,7 @@ declare 116 generic { } declare 117 generic { - void Tk_ImageChanged (Tk_ImageMaster master, int x, int y, \ + void Tk_ImageChanged (Tk_ImageMaster master, int x, int y, int width, int height, int imageWidth, int imageHeight) } @@ -596,16 +599,16 @@ declare 118 generic { } declare 119 generic { - Atom Tk_InternAtom (Tk_Window tkwin, char *name) + Atom Tk_InternAtom (Tk_Window tkwin, CONST char *name) } declare 120 generic { - int Tk_IntersectTextLayout (Tk_TextLayout layout, int x, int y, \ + int Tk_IntersectTextLayout (Tk_TextLayout layout, int x, int y, int width, int height) } declare 121 generic { - void Tk_MaintainGeometry (Tk_Window slave, \ + void Tk_MaintainGeometry (Tk_Window slave, Tk_Window master, int x, int y, int width, int height) } @@ -618,7 +621,7 @@ declare 123 generic { } declare 124 generic { - void Tk_ManageGeometry (Tk_Window tkwin, \ + void Tk_ManageGeometry (Tk_Window tkwin, Tk_GeomMgr *mgrPtr, ClientData clientData) } @@ -627,13 +630,13 @@ declare 125 generic { } declare 126 generic { - int Tk_MeasureChars (Tk_Font tkfont, \ - CONST char *source, int numBytes, int maxPixels, \ + int Tk_MeasureChars (Tk_Font tkfont, + CONST char *source, int numBytes, int maxPixels, int flags, int *lengthPtr) } declare 127 generic { - void Tk_MoveResizeWindow (Tk_Window tkwin, \ + void Tk_MoveResizeWindow (Tk_Window tkwin, int x, int y, int width, int height) } @@ -646,76 +649,76 @@ declare 129 generic { } declare 130 generic { - char * Tk_NameOf3DBorder (Tk_3DBorder border) + CONST84_RETURN char * Tk_NameOf3DBorder (Tk_3DBorder border) } declare 131 generic { - char * Tk_NameOfAnchor (Tk_Anchor anchor) + CONST84_RETURN char * Tk_NameOfAnchor (Tk_Anchor anchor) } declare 132 generic { - char * Tk_NameOfBitmap (Display *display, Pixmap bitmap) + CONST84_RETURN char * Tk_NameOfBitmap (Display *display, Pixmap bitmap) } declare 133 generic { - char * Tk_NameOfCapStyle (int cap) + CONST84_RETURN char * Tk_NameOfCapStyle (int cap) } declare 134 generic { - char * Tk_NameOfColor (XColor *colorPtr) + CONST84_RETURN char * Tk_NameOfColor (XColor *colorPtr) } declare 135 generic { - char * Tk_NameOfCursor (Display *display, Tk_Cursor cursor) + CONST84_RETURN char * Tk_NameOfCursor (Display *display, Tk_Cursor cursor) } declare 136 generic { - char * Tk_NameOfFont (Tk_Font font) + CONST84_RETURN char * Tk_NameOfFont (Tk_Font font) } declare 137 generic { - char * Tk_NameOfImage (Tk_ImageMaster imageMaster) + CONST84_RETURN char * Tk_NameOfImage (Tk_ImageMaster imageMaster) } declare 138 generic { - char * Tk_NameOfJoinStyle (int join) + CONST84_RETURN char * Tk_NameOfJoinStyle (int join) } declare 139 generic { - char * Tk_NameOfJustify (Tk_Justify justify) + CONST84_RETURN char * Tk_NameOfJustify (Tk_Justify justify) } declare 140 generic { - char * Tk_NameOfRelief (int relief) + CONST84_RETURN char * Tk_NameOfRelief (int relief) } declare 141 generic { - Tk_Window Tk_NameToWindow (Tcl_Interp *interp, \ - char *pathName, Tk_Window tkwin) + Tk_Window Tk_NameToWindow (Tcl_Interp *interp, + CONST char *pathName, Tk_Window tkwin) } declare 142 generic { - void Tk_OwnSelection (Tk_Window tkwin, \ - Atom selection, Tk_LostSelProc *proc, \ + void Tk_OwnSelection (Tk_Window tkwin, + Atom selection, Tk_LostSelProc *proc, ClientData clientData) } declare 143 generic { - int Tk_ParseArgv (Tcl_Interp *interp, \ - Tk_Window tkwin, int *argcPtr, char **argv, \ + int Tk_ParseArgv (Tcl_Interp *interp, + Tk_Window tkwin, int *argcPtr, CONST84 char **argv, Tk_ArgvInfo *argTable, int flags) } declare 144 generic { - void Tk_PhotoPutBlock (Tk_PhotoHandle handle, \ - Tk_PhotoImageBlock *blockPtr, int x, int y, \ + void Tk_PhotoPutBlock_NoComposite (Tk_PhotoHandle handle, + Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height) } declare 145 generic { - void Tk_PhotoPutZoomedBlock (Tk_PhotoHandle handle, \ - Tk_PhotoImageBlock *blockPtr, int x, int y, \ - int width, int height, int zoomX, int zoomY, \ + void Tk_PhotoPutZoomedBlock_NoComposite (Tk_PhotoHandle handle, + Tk_PhotoImageBlock *blockPtr, int x, int y, + int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY) } @@ -756,8 +759,8 @@ declare 154 generic { } declare 155 generic { - void Tk_RedrawImage (Tk_Image image, int imageX, \ - int imageY, int width, int height, \ + void Tk_RedrawImage (Tk_Image image, int imageX, + int imageY, int width, int height, Drawable drawable, int drawableX, int drawableY) } @@ -770,7 +773,7 @@ declare 157 generic { } declare 158 generic { - Tk_RestrictProc *Tk_RestrictEvents (Tk_RestrictProc *proc, \ + Tk_RestrictProc *Tk_RestrictEvents (Tk_RestrictProc *proc, ClientData arg, ClientData *prevArgPtr) } @@ -779,7 +782,7 @@ declare 159 generic { } declare 160 generic { - char * Tk_SetAppName (Tk_Window tkwin, char *name) + CONST char * Tk_SetAppName (Tk_Window tkwin, CONST char *name) } declare 161 generic { @@ -787,11 +790,11 @@ declare 161 generic { } declare 162 generic { - void Tk_SetClass (Tk_Window tkwin, char *className) + void Tk_SetClass (Tk_Window tkwin, CONST char *className) } declare 163 generic { - void Tk_SetGrid (Tk_Window tkwin, int reqWidth, int reqHeight, \ + void Tk_SetGrid (Tk_Window tkwin, int reqWidth, int reqHeight, int gridWidth, int gridHeight) } @@ -824,12 +827,12 @@ declare 170 generic { } declare 171 generic { - int Tk_SetWindowVisual (Tk_Window tkwin, Visual *visual, int depth,\ + int Tk_SetWindowVisual (Tk_Window tkwin, Visual *visual, int depth, Colormap colormap) } declare 172 generic { - void Tk_SizeOfBitmap (Display *display, Pixmap bitmap, int *widthPtr, \ + void Tk_SizeOfBitmap (Display *display, Pixmap bitmap, int *widthPtr, int *heightPtr) } @@ -854,15 +857,15 @@ declare 177 generic { } declare 178 generic { - void Tk_UnderlineChars (Display *display, \ - Drawable drawable, GC gc, Tk_Font tkfont, \ - CONST char *source, int x, int y, int firstByte, \ + void Tk_UnderlineChars (Display *display, + Drawable drawable, GC gc, Tk_Font tkfont, + CONST char *source, int x, int y, int firstByte, int lastByte) } declare 179 generic { - void Tk_UnderlineTextLayout (Display *display, Drawable drawable, GC gc, \ - Tk_TextLayout layout, int x, int y, \ + void Tk_UnderlineTextLayout (Display *display, Drawable drawable, GC gc, + Tk_TextLayout layout, int x, int y, int underline) } @@ -889,33 +892,33 @@ declare 184 generic { # new functions for 8.1 declare 185 generic { - Pixmap Tk_AllocBitmapFromObj (Tcl_Interp *interp, Tk_Window tkwin, \ + Pixmap Tk_AllocBitmapFromObj (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr) } declare 186 generic { - Tk_3DBorder Tk_Alloc3DBorderFromObj (Tcl_Interp *interp, Tk_Window tkwin, \ + Tk_3DBorder Tk_Alloc3DBorderFromObj (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr) } declare 187 generic { - XColor * Tk_AllocColorFromObj (Tcl_Interp *interp, Tk_Window tkwin, \ + XColor * Tk_AllocColorFromObj (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr) } declare 188 generic { - Tk_Cursor Tk_AllocCursorFromObj (Tcl_Interp *interp, Tk_Window tkwin, \ + Tk_Cursor Tk_AllocCursorFromObj (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr) } declare 189 generic { - Tk_Font Tk_AllocFontFromObj (Tcl_Interp *interp, Tk_Window tkwin, \ + Tk_Font Tk_AllocFontFromObj (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr) } declare 190 generic { - Tk_OptionTable Tk_CreateOptionTable (Tcl_Interp *interp, \ + Tk_OptionTable Tk_CreateOptionTable (Tcl_Interp *interp, CONST Tk_OptionSpec *templatePtr) } @@ -936,7 +939,7 @@ declare 194 generic { } declare 195 generic { - void Tk_FreeConfigOptions (char *recordPtr, Tk_OptionTable optionToken, \ + void Tk_FreeConfigOptions (char *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin) } @@ -958,7 +961,7 @@ declare 199 generic { } declare 200 generic { - int Tk_GetAnchorFromObj (Tcl_Interp *interp, Tcl_Obj *objPtr, \ + int Tk_GetAnchorFromObj (Tcl_Interp *interp, Tcl_Obj *objPtr, Tk_Anchor *anchorPtr) } @@ -975,49 +978,48 @@ declare 203 generic { } declare 204 generic { - Tcl_Obj * Tk_GetOptionInfo (Tcl_Interp *interp, \ - char *recordPtr, Tk_OptionTable optionTable, \ + Tcl_Obj * Tk_GetOptionInfo (Tcl_Interp *interp, + char *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin) } declare 205 generic { - Tcl_Obj * Tk_GetOptionValue (Tcl_Interp *interp, char *recordPtr, \ + Tcl_Obj * Tk_GetOptionValue (Tcl_Interp *interp, char *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin) } declare 206 generic { - int Tk_GetJustifyFromObj (Tcl_Interp *interp, \ + int Tk_GetJustifyFromObj (Tcl_Interp *interp, Tcl_Obj *objPtr, Tk_Justify *justifyPtr) } declare 207 generic { - int Tk_GetMMFromObj (Tcl_Interp *interp, \ + int Tk_GetMMFromObj (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, double *doublePtr) } declare 208 generic { - int Tk_GetPixelsFromObj (Tcl_Interp *interp, \ + int Tk_GetPixelsFromObj (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, int *intPtr) } declare 209 generic { - int Tk_GetReliefFromObj (Tcl_Interp *interp, \ + int Tk_GetReliefFromObj (Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr) } declare 210 generic { - int Tk_GetScrollInfoObj (Tcl_Interp *interp, \ + int Tk_GetScrollInfoObj (Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], double *dblPtr, int *intPtr) } declare 211 generic { - int Tk_InitOptions ( - Tcl_Interp *interp, char *recordPtr, \ - Tk_OptionTable optionToken, Tk_Window tkwin) + int Tk_InitOptions (Tcl_Interp *interp, char *recordPtr, + Tk_OptionTable optionToken, Tk_Window tkwin) } declare 212 generic { - void Tk_MainEx (int argc, char **argv, Tcl_AppInitProc *appInitProc, \ + void Tk_MainEx (int argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp) } @@ -1026,9 +1028,9 @@ declare 213 generic { } declare 214 generic { - int Tk_SetOptions (Tcl_Interp *interp, char *recordPtr, \ - Tk_OptionTable optionTable, int objc, \ - Tcl_Obj *CONST objv[], Tk_Window tkwin, \ + int Tk_SetOptions (Tcl_Interp *interp, char *recordPtr, + Tk_OptionTable optionTable, int objc, + Tcl_Obj *CONST objv[], Tk_Window tkwin, Tk_SavedOptions *savePtr, int *maskPtr) } @@ -1062,70 +1064,186 @@ declare 222 generic { void Tk_DeleteOutline (Display *display, Tk_Outline *outline) } declare 223 generic { - int Tk_ConfigOutlineGC (XGCValues *gcValues, Tk_Canvas canvas, \ + int Tk_ConfigOutlineGC (XGCValues *gcValues, Tk_Canvas canvas, Tk_Item *item, Tk_Outline *outline) } declare 224 generic { - int Tk_ChangeOutlineGC (Tk_Canvas canvas, Tk_Item *item, \ + int Tk_ChangeOutlineGC (Tk_Canvas canvas, Tk_Item *item, Tk_Outline *outline) } declare 225 generic { - int Tk_ResetOutlineGC (Tk_Canvas canvas, Tk_Item *item, \ + int Tk_ResetOutlineGC (Tk_Canvas canvas, Tk_Item *item, Tk_Outline *outline) } declare 226 generic { - int Tk_CanvasPsOutline (Tk_Canvas canvas, Tk_Item *item, \ + int Tk_CanvasPsOutline (Tk_Canvas canvas, Tk_Item *item, Tk_Outline *outline) } declare 227 generic { void Tk_SetTSOrigin (Tk_Window tkwin, GC gc, int x, int y) } declare 228 generic { - int Tk_CanvasGetCoordFromObj (Tcl_Interp *interp, Tk_Canvas canvas, \ + int Tk_CanvasGetCoordFromObj (Tcl_Interp *interp, Tk_Canvas canvas, Tcl_Obj *obj, double *doublePtr) } declare 229 generic { void Tk_CanvasSetOffset (Tk_Canvas canvas, GC gc, Tk_TSOffset *offset) } declare 230 generic { - void Tk_DitherPhoto (Tk_PhotoHandle handle, int x, int y, int width, \ + void Tk_DitherPhoto (Tk_PhotoHandle handle, int x, int y, int width, int height) } declare 231 generic { - int Tk_PostscriptBitmap (Tcl_Interp *interp, Tk_Window tkwin, \ - Tk_PostscriptInfo psInfo, Pixmap bitmap, int startX, \ + int Tk_PostscriptBitmap (Tcl_Interp *interp, Tk_Window tkwin, + Tk_PostscriptInfo psInfo, Pixmap bitmap, int startX, int startY, int width, int height) } declare 232 generic { - int Tk_PostscriptColor (Tcl_Interp *interp, Tk_PostscriptInfo psInfo, \ + int Tk_PostscriptColor (Tcl_Interp *interp, Tk_PostscriptInfo psInfo, XColor *colorPtr) } declare 233 generic { - int Tk_PostscriptFont (Tcl_Interp *interp, Tk_PostscriptInfo psInfo, \ + int Tk_PostscriptFont (Tcl_Interp *interp, Tk_PostscriptInfo psInfo, Tk_Font font) } declare 234 generic { - int Tk_PostscriptImage (Tk_Image image, Tcl_Interp *interp, \ - Tk_Window tkwin, Tk_PostscriptInfo psinfo, int x, int y, \ + int Tk_PostscriptImage (Tk_Image image, Tcl_Interp *interp, + Tk_Window tkwin, Tk_PostscriptInfo psinfo, int x, int y, int width, int height, int prepass) } declare 235 generic { - void Tk_PostscriptPath (Tcl_Interp *interp, Tk_PostscriptInfo psInfo, \ + void Tk_PostscriptPath (Tcl_Interp *interp, Tk_PostscriptInfo psInfo, double *coordPtr, int numPoints) } declare 236 generic { - int Tk_PostscriptStipple (Tcl_Interp *interp, Tk_Window tkwin, \ + int Tk_PostscriptStipple (Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psInfo, Pixmap bitmap) } declare 237 generic { double Tk_PostscriptY (double y, Tk_PostscriptInfo psInfo) } declare 238 generic { - int Tk_PostscriptPhoto (Tcl_Interp *interp, \ - Tk_PhotoImageBlock *blockPtr, Tk_PostscriptInfo psInfo, \ + int Tk_PostscriptPhoto (Tcl_Interp *interp, + Tk_PhotoImageBlock *blockPtr, Tk_PostscriptInfo psInfo, int width, int height) } +# New in 8.4a1 +# +declare 239 generic { + void Tk_CreateClientMessageHandler (Tk_ClientMessageProc *proc) +} +declare 240 generic { + void Tk_DeleteClientMessageHandler (Tk_ClientMessageProc *proc) +} + +# New in 8.4a2 +# +declare 241 generic { + Tk_Window Tk_CreateAnonymousWindow (Tcl_Interp *interp, + Tk_Window parent, CONST char *screenName) +} +declare 242 generic { + void Tk_SetClassProcs (Tk_Window tkwin, + Tk_ClassProcs *procs, ClientData instanceData) +} + +# New in 8.4a4 +# +declare 243 generic { + void Tk_SetInternalBorderEx (Tk_Window tkwin, int left, int right, + int top, int bottom) +} +declare 244 generic { + void Tk_SetMinimumRequestSize (Tk_Window tkwin, + int minWidth, int minHeight) +} + +# New in 8.4a5 +# +declare 245 generic { + void Tk_SetCaretPos (Tk_Window tkwin, int x, int y, int height) +} + +declare 246 generic { + void Tk_PhotoPutBlock (Tk_PhotoHandle handle, + Tk_PhotoImageBlock *blockPtr, int x, int y, + int width, int height, int compRule) +} +declare 247 generic { + void Tk_PhotoPutZoomedBlock (Tk_PhotoHandle handle, + Tk_PhotoImageBlock *blockPtr, int x, int y, + int width, int height, int zoomX, int zoomY, + int subsampleX, int subsampleY, int compRule) +} + +declare 248 generic { + int Tk_CollapseMotionEvents (Display *display, int collapse) +} + +# Style engine +declare 249 generic { + Tk_StyleEngine Tk_RegisterStyleEngine (CONST char *name, + Tk_StyleEngine parent) +} +declare 250 generic { + Tk_StyleEngine Tk_GetStyleEngine (CONST char *name) +} +declare 251 generic { + int Tk_RegisterStyledElement (Tk_StyleEngine engine, + Tk_ElementSpec *templatePtr) +} +declare 252 generic { + int Tk_GetElementId (CONST char *name) +} +declare 253 generic { + Tk_Style Tk_CreateStyle (CONST char *name, Tk_StyleEngine engine, + ClientData clientData) +} +declare 254 generic { + Tk_Style Tk_GetStyle (Tcl_Interp *interp, CONST char *name) +} +declare 255 generic { + void Tk_FreeStyle (Tk_Style style) +} +declare 256 generic { + CONST char * Tk_NameOfStyle (Tk_Style style) +} +declare 257 generic { + Tk_Style Tk_AllocStyleFromObj (Tcl_Interp *interp, Tcl_Obj *objPtr) +} +declare 258 generic { + Tk_Style Tk_GetStyleFromObj (Tcl_Obj *objPtr) +} +declare 259 generic { + void Tk_FreeStyleFromObj (Tcl_Obj *objPtr) +} +declare 260 generic { + Tk_StyledElement Tk_GetStyledElement (Tk_Style style, int elementId, + Tk_OptionTable optionTable) +} +declare 261 generic { + void Tk_GetElementSize (Tk_Style style, Tk_StyledElement element, + char *recordPtr, Tk_Window tkwin, int width, int height, + int inner, int *widthPtr, int *heightPtr) +} +declare 262 generic { + void Tk_GetElementBox (Tk_Style style, Tk_StyledElement element, + char *recordPtr, Tk_Window tkwin, int x, int y, int width, + int height, int inner, int *xPtr, int *yPtr, int *widthPtr, + int *heightPtr) +} +declare 263 generic { + int Tk_GetElementBorderWidth (Tk_Style style, Tk_StyledElement element, + char *recordPtr, Tk_Window tkwin) +} +declare 264 generic { + void Tk_DrawElement (Tk_Style style, Tk_StyledElement element, + char *recordPtr, Tk_Window tkwin, Drawable d, int x, int y, + int width, int height, int state) +} + + # Define the platform specific public Tk interface. These functions are # only available on the designated platform. @@ -1157,18 +1275,18 @@ declare 4 win { } declare 5 win { - int Tk_TranslateWinEvent (HWND hwnd, \ + int Tk_TranslateWinEvent (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result) } # Mac specific functions declare 0 mac { - void Tk_MacSetEmbedHandler ( \ - Tk_MacEmbedRegisterWinProc *registerWinProcPtr, \ - Tk_MacEmbedGetGrafPortProc *getPortProcPtr, \ - Tk_MacEmbedMakeContainerExistProc *containerExistProcPtr, \ - Tk_MacEmbedGetClipProc *getClipProc, \ + void Tk_MacSetEmbedHandler ( + Tk_MacEmbedRegisterWinProc *registerWinProcPtr, + Tk_MacEmbedGetGrafPortProc *getPortProcPtr, + Tk_MacEmbedMakeContainerExistProc *containerExistProcPtr, + Tk_MacEmbedGetClipProc *getClipProc, Tk_MacEmbedGetOffsetInParentProc *getOffsetProc) } @@ -1197,7 +1315,7 @@ declare 6 mac { } declare 7 mac { - void TkGenWMConfigureEvent (Tk_Window tkwin, \ + void TkGenWMConfigureEvent (Tk_Window tkwin, int x, int y, int width, int height, int flags) } @@ -1213,3 +1331,54 @@ declare 10 mac { GWorldPtr TkMacGetDrawablePort (Drawable drawable) } +# Mac OS X specific functions + +declare 0 aqua { + void Tk_MacOSXSetEmbedHandler ( \ + Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr, \ + Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr, \ + Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr, \ + Tk_MacOSXEmbedGetClipProc *getClipProc, \ + Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc) +} + +declare 1 aqua { + void Tk_MacOSXTurnOffMenus (void) +} + +declare 2 aqua { + void Tk_MacOSXTkOwnsCursor (int tkOwnsIt) +} + +declare 3 aqua { + void TkMacOSXInitMenus (Tcl_Interp *interp) +} + +declare 4 aqua { + void TkMacOSXInitAppleEvents (Tcl_Interp *interp) +} + +declare 5 aqua { + void TkGenWMConfigureEvent (Tk_Window tkwin, \ + int x, int y, int width, int height, int flags) +} + +declare 6 aqua { + void TkMacOSXInvalClipRgns (TkWindow *winPtr) +} + +declare 7 aqua { + GWorldPtr TkMacOSXGetDrawablePort (Drawable drawable) +} + +declare 8 aqua { + ControlRef TkMacOSXGetRootControl (Drawable drawable) +} + +declare 9 aqua { + void Tk_MacOSXSetupTkNotifier (void) +} + +declare 10 aqua { + int Tk_MacOSXIsAppInFront (void) +} diff --git a/tk/generic/tk.h b/tk/generic/tk.h index c4eb7145d56..49f7940a736 100644 --- a/tk/generic/tk.h +++ b/tk/generic/tk.h @@ -39,26 +39,34 @@ extern "C" { * win/README (not patchlevel) * unix/README (not patchlevel) * unix/tk.spec (3 LOC Major/Minor, 2 LOC patch) - * win/aclocal.m4 (not patchlevel) + * win/tcl.m4 (not patchlevel) * * You may also need to update some of these files when the numbers change * for the version of Tcl that this release of Tk is compiled against. */ #define TK_MAJOR_VERSION 8 -#define TK_MINOR_VERSION 3 +#define TK_MINOR_VERSION 4 #define TK_RELEASE_LEVEL TCL_FINAL_RELEASE -#define TK_RELEASE_SERIAL 2 +#define TK_RELEASE_SERIAL 0 -#define TK_VERSION "8.3" -#define TK_PATCH_LEVEL "8.3.2" +#define TK_VERSION "8.4" +#define TK_PATCH_LEVEL "8.4.0" +/* + * A special define for MacOS & MacOS X, allows us to use the header + * in the resource compiler without having it choke on the more complex + * C preprocessor constructs. + */ + +#ifndef RESOURCE_INCLUDED + /* * The following definitions set up the proper options for Macintosh * compilers. We use this method because there is no autoconf equivalent. */ -#ifdef MAC_TCL +#if defined(MAC_TCL) || defined(MAC_OSX_TK) # ifndef REDO_KEYSYM_LOOKUP # define REDO_KEYSYM_LOOKUP # endif @@ -66,6 +74,9 @@ extern "C" { #ifndef _TCL # include +# if (TCL_MAJOR_VERSION != 8) || (TCL_MINOR_VERSION != 4) +# error Tk 8.4 must be compiled with tcl.h from Tcl 8.4 +# endif #endif /* @@ -73,12 +84,15 @@ extern "C" { * in resource files. */ -#ifndef RESOURCE_INCLUDED +#ifndef RC_INVOKED #ifndef _XLIB_H -# ifdef MAC_TCL +# if defined (MAC_TCL) # include # include +# elif defined(MAC_OSX_TK) +# include +# include # else # include # endif @@ -116,12 +130,15 @@ typedef struct Tk_PostscriptInfo_ *Tk_PostscriptInfo; typedef struct Tk_TextLayout_ *Tk_TextLayout; typedef struct Tk_Window_ *Tk_Window; typedef struct Tk_3DBorder_ *Tk_3DBorder; +typedef struct Tk_Style_ *Tk_Style; +typedef struct Tk_StyleEngine_ *Tk_StyleEngine; +typedef struct Tk_StyledElement_ *Tk_StyledElement; /* * Additional types exported to clients. */ -typedef char *Tk_Uid; +typedef CONST char *Tk_Uid; /* * The enum below defines the valid types for Tk configuration options @@ -145,9 +162,9 @@ typedef enum { TK_OPTION_SYNONYM, TK_OPTION_PIXELS, TK_OPTION_WINDOW, -/* CYGNUS LOCAL: Support -version argument. */ - TK_OPTION_VERSION, - TK_OPTION_END + TK_OPTION_END, + TK_OPTION_CUSTOM, + TK_OPTION_STYLE } Tk_OptionType; /* @@ -203,8 +220,41 @@ typedef struct Tk_OptionSpec { * carefully. */ -#define TK_OPTION_NULL_OK 1 -#define TK_OPTION_DONT_SET_DEFAULT 8 +#define TK_OPTION_NULL_OK (1 << 0) +#define TK_OPTION_DONT_SET_DEFAULT (1 << 3) + +/* + * The following structure and function types are used by TK_OPTION_CUSTOM + * options; the structure holds pointers to the functions needed by the Tk + * option config code to handle a custom option. + */ + +typedef int (Tk_CustomOptionSetProc) _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj **value, char *widgRec, + int offset, char *saveInternalPtr, int flags)); +typedef Tcl_Obj *(Tk_CustomOptionGetProc) _ANSI_ARGS_((ClientData clientData, + Tk_Window tkwin, char *widgRec, int offset)); +typedef void (Tk_CustomOptionRestoreProc) _ANSI_ARGS_((ClientData clientData, + Tk_Window tkwin, char *internalPtr, char *saveInternalPtr)); +typedef void (Tk_CustomOptionFreeProc) _ANSI_ARGS_((ClientData clientData, + Tk_Window tkwin, char *internalPtr)); + +typedef struct Tk_ObjCustomOption { + char *name; /* Name of the custom option. */ + Tk_CustomOptionSetProc *setProc; /* Function to use to set a record's + * option value from a Tcl_Obj */ + Tk_CustomOptionGetProc *getProc; /* Function to use to get a Tcl_Obj + * representation from an internal + * representation of an option. */ + Tk_CustomOptionRestoreProc *restoreProc; /* Function to use to restore a + * saved value for the internal + * representation. */ + Tk_CustomOptionFreeProc *freeProc; /* Function to use to free the internal + * representation of an option. */ + ClientData clientData; /* Arbitrary one-word value passed to + * the handling procs. */ +} Tk_ObjCustomOption; + /* * Macro to use to fill in "offset" fields of the Tk_OptionSpec. @@ -286,7 +336,7 @@ typedef struct Tk_SavedOptions { #ifndef __NO_OLD_CONFIG typedef int (Tk_OptionParseProc) _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, Tk_Window tkwin, char *value, char *widgRec, + Tcl_Interp *interp, Tk_Window tkwin, CONST84 char *value, char *widgRec, int offset)); typedef char *(Tk_OptionPrintProc) _ANSI_ARGS_((ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, @@ -317,9 +367,9 @@ typedef struct Tk_ConfigSpec { * table must have type TK_CONFIG_END. */ char *argvName; /* Switch used to specify option in argv. * NULL means this spec is part of a group. */ - char *dbName; /* Name for option in option database. */ - char *dbClass; /* Class for option in database. */ - char *defValue; /* Default value for option if not + Tk_Uid dbName; /* Name for option in option database. */ + Tk_Uid dbClass; /* Class for option in database. */ + Tk_Uid defValue; /* Default value for option if not * specified in command line or database. */ int offset; /* Where in widget record to store value; * use Tk_Offset macro to generate values @@ -362,11 +412,11 @@ typedef enum { * tkOldConfig.c (internal-use-only flags are defined there). */ -#define TK_CONFIG_NULL_OK 1 -#define TK_CONFIG_COLOR_ONLY 2 -#define TK_CONFIG_MONO_ONLY 4 -#define TK_CONFIG_DONT_SET_DEFAULT 8 -#define TK_CONFIG_OPTION_SPECIFIED 0x10 +#define TK_CONFIG_NULL_OK (1 << 0) +#define TK_CONFIG_COLOR_ONLY (1 << 1) +#define TK_CONFIG_MONO_ONLY (1 << 2) +#define TK_CONFIG_DONT_SET_DEFAULT (1 << 3) +#define TK_CONFIG_OPTION_SPECIFIED (1 << 4) #define TK_CONFIG_USER_BIT 0x100 #endif /* __NO_OLD_CONFIG */ @@ -402,9 +452,7 @@ typedef struct { #define TK_ARGV_CONST_OPTION 24 #define TK_ARGV_OPTION_VALUE 25 #define TK_ARGV_OPTION_NAME_VALUE 26 -/* CYGNUS LOCAL: Support -version argument. */ -#define TK_ARGV_VERSION 27 -#define TK_ARGV_END 28 +#define TK_ARGV_END 27 /* * Flag bits for passing to Tk_ParseArgv: @@ -438,6 +486,7 @@ typedef enum { * Relief values returned by Tk_GetRelief: */ +#define TK_RELIEF_NULL -1 #define TK_RELIEF_FLAT 0 #define TK_RELIEF_GROOVE 1 #define TK_RELIEF_RAISED 2 @@ -516,6 +565,51 @@ typedef struct Tk_FontMetrics { #define TK_IGNORE_TABS 8 #define TK_IGNORE_NEWLINES 16 +/* + * Widget class procedures used to implement platform specific widget + * behavior. + */ + +typedef Window (Tk_ClassCreateProc) _ANSI_ARGS_((Tk_Window tkwin, + Window parent, ClientData instanceData)); +typedef void (Tk_ClassWorldChangedProc) _ANSI_ARGS_((ClientData instanceData)); +typedef void (Tk_ClassModalProc) _ANSI_ARGS_((Tk_Window tkwin, + XEvent *eventPtr)); + +typedef struct Tk_ClassProcs { + unsigned int size; + Tk_ClassWorldChangedProc *worldChangedProc; + /* Procedure to invoke when the widget needs to + * respond in some way to a change in the + * world (font changes, etc.) */ + Tk_ClassCreateProc *createProc; + /* Procedure to invoke when the + * platform-dependent window needs to be + * created. */ + Tk_ClassModalProc *modalProc; + /* Procedure to invoke after all bindings on a + * widget have been triggered in order to + * handle a modal loop. */ +} Tk_ClassProcs; + +/* + * Simple accessor for Tk_ClassProcs structure. Checks that the structure + * is not NULL, then checks the size field and returns either the requested + * field, if present, or NULL if the structure is too small to have the field + * (or NULL if the structure is NULL). + * + * A more general version of this function may be useful if other + * size-versioned structure pop up in the future: + * + * #define Tk_GetField(name, who, which) \ + * (((who) == NULL) ? NULL : + * (((who)->size <= Tk_Offset(name, which)) ? NULL :(name)->which)) + */ + +#define Tk_GetClassProc(procs, which) \ + (((procs) == NULL) ? NULL : \ + (((procs)->size <= Tk_Offset(Tk_ClassProcs, which)) ? NULL:(procs)->which)) + /* * Each geometry manager (the packer, the placer, etc.) is represented * by a structure of the following form, which indicates procedures @@ -639,10 +733,27 @@ typedef XActivateDeactivateEvent XDeactivateEvent; (((Tk_FakeWin *) (tkwin))->flags & TK_MAPPED) #define Tk_IsTopLevel(tkwin) \ (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_LEVEL) +#define Tk_HasWrapper(tkwin) \ + (((Tk_FakeWin *) (tkwin))->flags & TK_HAS_WRAPPER) +#define Tk_WinManaged(tkwin) \ + (((Tk_FakeWin *) (tkwin))->flags & TK_WIN_MANAGED) +#define Tk_TopWinHierarchy(tkwin) \ + (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY) #define Tk_ReqWidth(tkwin) (((Tk_FakeWin *) (tkwin))->reqWidth) #define Tk_ReqHeight(tkwin) (((Tk_FakeWin *) (tkwin))->reqHeight) +/* Tk_InternalBorderWidth is deprecated */ #define Tk_InternalBorderWidth(tkwin) \ - (((Tk_FakeWin *) (tkwin))->internalBorderWidth) + (((Tk_FakeWin *) (tkwin))->internalBorderLeft) +#define Tk_InternalBorderLeft(tkwin) \ + (((Tk_FakeWin *) (tkwin))->internalBorderLeft) +#define Tk_InternalBorderRight(tkwin) \ + (((Tk_FakeWin *) (tkwin))->internalBorderRight) +#define Tk_InternalBorderTop(tkwin) \ + (((Tk_FakeWin *) (tkwin))->internalBorderTop) +#define Tk_InternalBorderBottom(tkwin) \ + (((Tk_FakeWin *) (tkwin))->internalBorderBottom) +#define Tk_MinReqWidth(tkwin) (((Tk_FakeWin *) (tkwin))->minReqWidth) +#define Tk_MinReqHeight(tkwin) (((Tk_FakeWin *) (tkwin))->minReqHeight) #define Tk_Parent(tkwin) (((Tk_FakeWin *) (tkwin))->parentPtr) #define Tk_Colormap(tkwin) (((Tk_FakeWin *) (tkwin))->atts.colormap) @@ -659,40 +770,45 @@ typedef XActivateDeactivateEvent XDeactivateEvent; typedef struct Tk_FakeWin { Display *display; - char *dummy1; + char *dummy1; /* dispPtr */ int screenNum; Visual *visual; int depth; Window window; - char *dummy2; - char *dummy3; - Tk_Window parentPtr; - char *dummy4; - char *dummy5; + char *dummy2; /* childList */ + char *dummy3; /* lastChildPtr */ + Tk_Window parentPtr; /* parentPtr */ + char *dummy4; /* nextPtr */ + char *dummy5; /* mainPtr */ char *pathName; Tk_Uid nameUid; Tk_Uid classUid; XWindowChanges changes; - unsigned int dummy6; + unsigned int dummy6; /* dirtyChanges */ XSetWindowAttributes atts; - unsigned long dummy7; + unsigned long dummy7; /* dirtyAtts */ unsigned int flags; - char *dummy8; + char *dummy8; /* handlerList */ #ifdef TK_USE_INPUT_METHODS - XIC dummy9; + XIC dummy9; /* inputContext */ #endif /* TK_USE_INPUT_METHODS */ - ClientData *dummy10; - int dummy11; - int dummy12; - char *dummy13; - char *dummy14; - ClientData dummy15; + ClientData *dummy10; /* tagPtr */ + int dummy11; /* numTags */ + int dummy12; /* optionLevel */ + char *dummy13; /* selHandlerList */ + char *dummy14; /* geomMgrPtr */ + ClientData dummy15; /* geomData */ int reqWidth, reqHeight; - int internalBorderWidth; - char *dummy16; - char *dummy17; - ClientData dummy18; - char *dummy19; + int internalBorderLeft; + char *dummy16; /* wmInfoPtr */ + char *dummy17; /* classProcPtr */ + ClientData dummy18; /* instanceData */ + char *dummy19; /* privatePtr */ + int internalBorderRight; + int internalBorderTop; + int internalBorderBottom; + int minReqWidth; + int minReqHeight; } Tk_FakeWin; /* @@ -700,9 +816,7 @@ typedef struct Tk_FakeWin { * * TK_MAPPED: 1 means window is currently mapped, * 0 means unmapped. - * TK_TOP_LEVEL: 1 means this is a top-level window (it - * was or will be created as a child of - * a root window). + * TK_TOP_LEVEL: 1 means this is a top-level widget. * TK_ALREADY_DEAD: 1 means the window is in the process of * being destroyed already. * TK_NEED_CONFIG_NOTIFY: 1 means that the window has been reconfigured @@ -752,6 +866,20 @@ typedef struct Tk_FakeWin { * concerned it isn't a child of its Tk * parent. Initially this is used only for * special Unix menubar windows. + * TK_ANONYMOUS_WINDOW: 1 means that this window has no name, and is + * thus not accessible from Tk. + * TK_HAS_WRAPPER 1 means that this window has a wrapper window + * TK_WIN_MANAGED 1 means that this window is a child of the + * root window, and is managed by the window + * manager. + * TK_TOP_HIERARCHY 1 means this window is at the top of a + * physical window hierarchy within this + * process, i.e. the window's parent + * either doesn't exist or is not owned by + * this Tk application. + * TK_PROP_PROPCHANGE 1 means that PropertyNotify events in + * this window's children should propagate + * up to this window. */ @@ -769,6 +897,11 @@ typedef struct Tk_FakeWin { #define TK_DEFER_MODAL 0x800 #define TK_WRAPPER 0x1000 #define TK_REPARENTED 0x2000 +#define TK_ANONYMOUS_WINDOW 0x4000 +#define TK_HAS_WRAPPER 0x8000 +#define TK_WIN_MANAGED 0x10000 +#define TK_TOP_HIERARCHY 0x20000 +#define TK_PROP_PROPCHANGE 0x40000 /* *-------------------------------------------------------------- @@ -1174,6 +1307,15 @@ typedef struct Tk_PhotoImageBlock { * the pixel as a whole. */ } Tk_PhotoImageBlock; +/* + * The following values control how blocks are combined into photo + * images when the alpha component of a pixel is not 255, a.k.a. the + * compositing rule. + */ + +#define TK_PHOTO_COMPOSITE_OVERLAY 0 +#define TK_PHOTO_COMPOSITE_SET 1 + /* * Procedure prototypes and structures used in reading and * writing photo images: @@ -1183,14 +1325,14 @@ typedef struct Tk_PhotoImageFormat Tk_PhotoImageFormat; #ifdef USE_OLD_IMAGE typedef int (Tk_ImageFileMatchProc) _ANSI_ARGS_((Tcl_Channel chan, char *fileName, char *formatString, int *widthPtr, int *heightPtr)); -typedef int (Tk_ImageStringMatchProc) _ANSI_ARGS_((Tcl_Obj *dataObj, +typedef int (Tk_ImageStringMatchProc) _ANSI_ARGS_((char *string, char *formatString, int *widthPtr, int *heightPtr)); typedef int (Tk_ImageFileReadProc) _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Channel chan, char *fileName, char *formatString, Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height, int srcX, int srcY)); typedef int (Tk_ImageStringReadProc) _ANSI_ARGS_((Tcl_Interp *interp, - Tcl_Obj *dataObj, char *formatString, Tk_PhotoHandle imageHandle, + char *string, char *formatString, Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height, int srcX, int srcY)); typedef int (Tk_ImageFileWriteProc) _ANSI_ARGS_((Tcl_Interp *interp, char *fileName, char *formatString, Tk_PhotoImageBlock *blockPtr)); @@ -1262,6 +1404,77 @@ EXTERN void Tk_CreateOldPhotoImageFormat _ANSI_ARGS_(( #endif +/* + *-------------------------------------------------------------- + * + * Procedure prototypes and structures used for managing styles: + * + *-------------------------------------------------------------- + */ + +/* + * Style support version tag. + */ +#define TK_STYLE_VERSION_1 0x1 +#define TK_STYLE_VERSION TK_STYLE_VERSION_1 + +/* + * The following structures and prototypes are used as static templates to + * declare widget elements. + */ + +typedef void (Tk_GetElementSizeProc) _ANSI_ARGS_((ClientData clientData, + char *recordPtr, CONST Tk_OptionSpec **optionsPtr, Tk_Window tkwin, + int width, int height, int inner, int *widthPtr, int *heightPtr)); +typedef void (Tk_GetElementBoxProc) _ANSI_ARGS_((ClientData clientData, + char *recordPtr, CONST Tk_OptionSpec **optionsPtr, Tk_Window tkwin, + int x, int y, int width, int height, int inner, int *xPtr, int *yPtr, + int *widthPtr, int *heightPtr)); +typedef int (Tk_GetElementBorderWidthProc) _ANSI_ARGS_((ClientData clientData, + char *recordPtr, CONST Tk_OptionSpec **optionsPtr, Tk_Window tkwin)); +typedef void (Tk_DrawElementProc) _ANSI_ARGS_((ClientData clientData, + char *recordPtr, CONST Tk_OptionSpec **optionsPtr, Tk_Window tkwin, + Drawable d, int x, int y, int width, int height, int state)); + +typedef struct Tk_ElementOptionSpec { + char *name; /* Name of the required option. */ + Tk_OptionType type; /* Accepted option type. TK_OPTION_END means + * any. */ +} Tk_ElementOptionSpec; + +typedef struct Tk_ElementSpec { + int version; /* Version of the style support. */ + char *name; /* Name of element. */ + Tk_ElementOptionSpec *options; + /* List of required options. Last one's name + * must be NULL. */ + + /* + * Hooks + */ + + Tk_GetElementSizeProc *getSize; + /* Compute the external (resp. internal) size of + * the element from its desired internal (resp. + * external) size. */ + Tk_GetElementBoxProc *getBox; + /* Compute the inscribed or bounding boxes + * within a given area. */ + Tk_GetElementBorderWidthProc *getBorderWidth; + /* Return the element's internal border width. + * Mostly useful for widgets. */ + Tk_DrawElementProc *draw; /* Draw the element in the given bounding box.*/ +} Tk_ElementSpec; + +/* + * Element state flags. Can be OR'ed. + */ + +#define TK_ELEMENT_STATE_ACTIVE 1<<0 +#define TK_ELEMENT_STATE_DISABLED 1<<1 +#define TK_ELEMENT_STATE_FOCUS 1<<2 +#define TK_ELEMENT_STATE_PRESSED 1<<3 + /* *-------------------------------------------------------------- * @@ -1301,7 +1514,6 @@ EXTERN void Tk_CreateOldPhotoImageFormat _ANSI_ARGS_(( /* Additional stuff that has moved to Tcl: */ -#define Tk_AfterCmd Tcl_AfterCmd #define Tk_EventuallyFree Tcl_EventuallyFree #define Tk_FreeProc Tcl_FreeProc #define Tk_Preserve Tcl_Preserve @@ -1311,7 +1523,7 @@ EXTERN void Tk_CreateOldPhotoImageFormat _ANSI_ARGS_(( #define Tk_Main(argc, argv, proc) \ Tk_MainEx(argc, argv, proc, Tcl_CreateInterp()) -char *Tk_InitStubs _ANSI_ARGS_((Tcl_Interp *interp, char *version, int exact)); +CONST char *Tk_InitStubs _ANSI_ARGS_((Tcl_Interp *interp, char *version, int exact)); #ifndef USE_TK_STUBS @@ -1343,6 +1555,8 @@ typedef void (Tk_EventProc) _ANSI_ARGS_((ClientData clientData, XEvent *eventPtr)); typedef int (Tk_GenericProc) _ANSI_ARGS_((ClientData clientData, XEvent *eventPtr)); +typedef int (Tk_ClientMessageProc) _ANSI_ARGS_((Tk_Window tkwin, + XEvent *eventPtr)); typedef int (Tk_GetSelProc) _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, char *portion)); typedef void (Tk_LostSelProc) _ANSI_ARGS_((ClientData clientData)); @@ -1355,23 +1569,45 @@ typedef int (Tk_SelectionProc) _ANSI_ARGS_((ClientData clientData, /* *-------------------------------------------------------------- * - * Exported procedures and variables. + * Platform independant exported procedures and variables. * *-------------------------------------------------------------- */ #include "tkDecls.h" +/* + * Allow users to say that they don't want to alter their source to + * add the extra argument to Tk_PhotoPutBlock(); DO NOT DEFINE THIS + * WHEN BUILDING TK. + * + * This goes after the inclusion of the stubbed-decls so that the + * declarations of what is actually there can be correct. + */ + +#ifdef USE_COMPOSITELESS_PHOTO_PUT_BLOCK +# ifdef Tk_PhotoPutBlock +# undef Tk_PhotoPutBlock +# endif +# define Tk_PhotoPutBlock Tk_PhotoPutBlock_NoComposite +# ifdef Tk_PhotoPutZoomedBlock +# undef Tk_PhotoPutZoomedBlock +# endif +# define Tk_PhotoPutZoomedBlock Tk_PhotoPutZoomedBlock_NoComposite +#endif /* USE_COMPOSITELESS_PHOTO_PUT_BLOCK */ + /* * Tcl commands exported by Tk: */ -#endif /* RESOURCE_INCLUDED */ +#endif /* RC_INVOKED */ #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT +#endif /* RESOURCE_INCLUDED */ + /* * end block for C++ */ @@ -1381,5 +1617,3 @@ typedef int (Tk_SelectionProc) _ANSI_ARGS_((ClientData clientData, #endif #endif /* _TK */ - - diff --git a/tk/generic/tk3d.c b/tk/generic/tk3d.c index 3073d2dfcbd..670b002f7a4 100644 --- a/tk/generic/tk3d.c +++ b/tk/generic/tk3d.c @@ -20,8 +20,9 @@ * used by Tk_GetReliefFromObj. */ -static char *reliefStrings[] = {"flat", "groove", "raised", "ridge", "solid", - "sunken", (char *) NULL}; +static CONST char *reliefStrings[] = {"flat", "groove", "raised", + "ridge", "solid", "sunken", + (char *) NULL}; /* * Forward declarations for procedures defined in this file: @@ -45,7 +46,7 @@ static void ShiftLine _ANSI_ARGS_((XPoint *p1Ptr, XPoint *p2Ptr, * is set. */ -static Tcl_ObjType borderObjType = { +Tcl_ObjType tkBorderObjType = { "border", /* name */ FreeBorderObjProc, /* freeIntRepProc */ DupBorderObjProc, /* dupIntRepProc */ @@ -86,7 +87,7 @@ Tk_Alloc3DBorderFromObj(interp, tkwin, objPtr) { TkBorder *borderPtr; - if (objPtr->typePtr != &borderObjType) { + if (objPtr->typePtr != &tkBorderObjType) { InitBorderObj(objPtr); } borderPtr = (TkBorder *) objPtr->internalRep.twoPtrValue.ptr1; @@ -185,7 +186,7 @@ Tk_Get3DBorder(interp, tkwin, colorName) Tcl_Interp *interp; /* Place to store an error message. */ Tk_Window tkwin; /* Token for window in which border will * be drawn. */ - char *colorName; /* String giving name of color + Tk_Uid colorName; /* String giving name of color * for window background. */ { Tcl_HashEntry *hashPtr; @@ -323,7 +324,7 @@ Tk_Draw3DRectangle(tkwin, drawable, border, x, y, width, height, *-------------------------------------------------------------- */ -char * +CONST char * Tk_NameOf3DBorder(border) Tk_3DBorder border; /* Token for border. */ { @@ -651,7 +652,7 @@ Tk_GetReliefFromObj(interp, objPtr, resultPtr) int Tk_GetRelief(interp, name, reliefPtr) Tcl_Interp *interp; /* For error messages. */ - char *name; /* Name of a relief type. */ + CONST char *name; /* Name of a relief type. */ int *reliefPtr; /* Where to store converted relief. */ { char c; @@ -702,7 +703,7 @@ Tk_GetRelief(interp, name, reliefPtr) *-------------------------------------------------------------- */ -char * +CONST char * Tk_NameOfRelief(relief) int relief; /* One of TK_RELIEF_FLAT, TK_RELIEF_RAISED, * or TK_RELIEF_SUNKEN. */ @@ -719,6 +720,8 @@ Tk_NameOfRelief(relief) return "ridge"; } else if (relief == TK_RELIEF_SOLID) { return "solid"; + } else if (relief == TK_RELIEF_NULL) { + return ""; } else { return "unknown relief"; } @@ -1260,7 +1263,7 @@ Tk_Get3DBorderFromObj(tkwin, objPtr) Tcl_HashEntry *hashPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; - if (objPtr->typePtr != &borderObjType) { + if (objPtr->typePtr != &tkBorderObjType) { InitBorderObj(objPtr); } @@ -1353,7 +1356,7 @@ InitBorderObj(objPtr) if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) { (*typePtr->freeIntRepProc)(objPtr); } - objPtr->typePtr = &borderObjType; + objPtr->typePtr = &tkBorderObjType; objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) NULL; } @@ -1405,5 +1408,3 @@ TkDebugBorder(tkwin, name) } return resultPtr; } - - diff --git a/tk/generic/tk3d.h b/tk/generic/tk3d.h index c62cf12de5a..babc7844293 100644 --- a/tk/generic/tk3d.h +++ b/tk/generic/tk3d.h @@ -100,4 +100,3 @@ EXTERN void TkpFreeBorder _ANSI_ARGS_((TkBorder *borderPtr)); # define TCL_STORAGE_CLASS DLLIMPORT #endif /* _TK3D */ - diff --git a/tk/generic/tkArgv.c b/tk/generic/tkArgv.c index ee86ad75cd4..d62bc082f08 100644 --- a/tk/generic/tkArgv.c +++ b/tk/generic/tkArgv.c @@ -24,8 +24,6 @@ static Tk_ArgvInfo defaultTable[] = { {"-help", TK_ARGV_HELP, (char *) NULL, (char *) NULL, "Print summary of command-line options and abort"}, - {"-version", TK_ARGV_VERSION, (char *) NULL, (char *) NULL, - "Print version number and abort"}, {NULL, TK_ARGV_END, (char *) NULL, (char *) NULL, (char *) NULL} }; @@ -69,7 +67,7 @@ Tk_ParseArgv(interp, tkwin, argcPtr, argv, argTable, flags) * NULL means ignore Tk option specs. */ int *argcPtr; /* Number of arguments in argv. Modified * to hold # args left in argv at end. */ - char **argv; /* Array of arguments. Modified to hold + CONST char **argv; /* Array of arguments. Modified to hold * those that couldn't be processed here. */ Tk_ArgvInfo *argTable; /* Array of option descriptions */ int flags; /* Or'ed combination of various flag bits, @@ -79,7 +77,7 @@ Tk_ParseArgv(interp, tkwin, argcPtr, argv, argTable, flags) /* Pointer to the current entry in the * table of argument descriptions. */ Tk_ArgvInfo *matchPtr; /* Descriptor that matches current argument. */ - char *curArg; /* Current argument */ + CONST char *curArg; /* Current argument */ register char c; /* Second character of current arg (used for * quick check for matching; use 2nd char. * because first char. will almost always @@ -204,7 +202,7 @@ Tk_ParseArgv(interp, tkwin, argcPtr, argv, argTable, flags) if (argc == 0) { goto missingArg; } else { - *((char **)infoPtr->dst) = argv[srcIndex]; + *((CONST char **)infoPtr->dst) = argv[srcIndex]; srcIndex++; argc--; } @@ -241,7 +239,8 @@ Tk_ParseArgv(interp, tkwin, argcPtr, argv, argTable, flags) } break; case TK_ARGV_FUNC: { - typedef int (ArgvFunc)_ANSI_ARGS_((char *, char *, char *)); + typedef int (ArgvFunc) _ANSI_ARGS_ ((char *, char *, + CONST char *)); ArgvFunc *handlerProc; handlerProc = (ArgvFunc *) infoPtr->src; @@ -254,7 +253,7 @@ Tk_ParseArgv(interp, tkwin, argcPtr, argv, argTable, flags) } case TK_ARGV_GENFUNC: { typedef int (ArgvGenFunc)_ANSI_ARGS_((char *, Tcl_Interp *, - char *, int, char **)); + char *, int, CONST char **)); ArgvGenFunc *handlerProc; handlerProc = (ArgvGenFunc *) infoPtr->src; @@ -293,10 +292,6 @@ Tk_ParseArgv(interp, tkwin, argcPtr, argv, argTable, flags) srcIndex += 2; argc -= 2; break; - case TK_ARGV_VERSION: - Tcl_AppendResult(interp, "Tk version ", TK_VERSION, "-snavigator-99r1", - (char *) NULL); - return TCL_ERROR; default: { char buf[64 + TCL_INTEGER_SPACE]; @@ -441,4 +436,3 @@ PrintUsage(interp, argTable, flags) (char *) NULL); } } - diff --git a/tk/generic/tkAtom.c b/tk/generic/tkAtom.c index 45260d940e0..e095183427a 100644 --- a/tk/generic/tkAtom.c +++ b/tk/generic/tkAtom.c @@ -80,7 +80,7 @@ Atom Tk_InternAtom(tkwin, name) Tk_Window tkwin; /* Window token; map name to atom * for this window's display. */ - char *name; /* Name to turn into atom. */ + CONST char *name; /* Name to turn into atom. */ { register TkDisplay *dispPtr; register Tcl_HashEntry *hPtr; @@ -127,7 +127,7 @@ Tk_InternAtom(tkwin, name) *-------------------------------------------------------------- */ -char * +CONST char * Tk_GetAtomName(tkwin, atom) Tk_Window tkwin; /* Window token; map atom to name * relative to this window's @@ -168,7 +168,7 @@ Tk_GetAtomName(tkwin, atom) &new); Tcl_SetHashValue(hPtr, name); } - return (char *) Tcl_GetHashValue(hPtr); + return Tcl_GetHashValue(hPtr); } /* @@ -215,4 +215,3 @@ AtomInit(dispPtr) } } } - diff --git a/tk/generic/tkBind.c b/tk/generic/tkBind.c index 233f3c308c4..143af5a2e7b 100644 --- a/tk/generic/tkBind.c +++ b/tk/generic/tkBind.c @@ -21,6 +21,11 @@ #include "tkWinInt.h" #endif +#if !(defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) /* UNIX */ +#include "tkUnixInt.h" +#endif + + /* * File structure: * @@ -293,7 +298,7 @@ typedef struct PhysicalsOwned { * One of the following structures exists for each interpreter. This * structure keeps track of the current display and screen in the * interpreter, so that a script can be invoked whenever the display/screen - * changes (the script does things like point tkPriv at a display-specific + * changes (the script does things like point tk::Priv at a display-specific * structure). */ @@ -501,6 +506,11 @@ static EventInfo eventArray[] = { {"Activate", ActivateNotify, ActivateMask}, {"Deactivate", DeactivateNotify, ActivateMask}, {"MouseWheel", MouseWheelEvent, MouseWheelMask}, + {"CirculateRequest", CirculateRequest, SubstructureRedirectMask}, + {"ConfigureRequest", ConfigureRequest, SubstructureRedirectMask}, + {"Create", CreateNotify, SubstructureNotifyMask}, + {"MapRequest", MapRequest, SubstructureRedirectMask}, + {"ResizeRequest", ResizeRequest, ResizeRedirectMask}, {(char *) NULL, 0, 0} }; static Tcl_HashTable eventTable; @@ -532,6 +542,10 @@ static Tcl_HashTable eventTable; #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) @@ -556,12 +570,12 @@ static int flagArray[TK_LASTEVENT] = { /* DestroyNotify */ DESTROY, /* UnmapNotify */ UNMAP, /* MapNotify */ MAP, - /* MapRequest */ 0, + /* MapRequest */ MAPREQ, /* ReparentNotify */ REPARENT, /* ConfigureNotify */ CONFIG, - /* ConfigureRequest */ 0, + /* ConfigureRequest */ CONFIGREQ, /* GravityNotify */ GRAVITY, - /* ResizeRequest */ 0, + /* ResizeRequest */ RESIZEREQ, /* CirculateNotify */ CIRC, /* CirculateRequest */ 0, /* PropertyNotify */ PROP, @@ -631,6 +645,22 @@ static TkStateMap visNotify[] = { {-1, NULL} }; +static TkStateMap configureRequestDetail[] = { + {None, "None"}, + {Above, "Above"}, + {Below, "Below"}, + {BottomIf, "BottomIf"}, + {TopIf, "TopIf"}, + {Opposite, "Opposite"}, + {-1, NULL} +}; + +static TkStateMap propNotify[] = { + {PropertyNewValue, "NewValue"}, + {PropertyDelete, "Delete"}, + {-1, NULL} +}; + /* * Prototypes for local procedures defined in this file: */ @@ -646,13 +676,13 @@ static int DeleteVirtualEvent _ANSI_ARGS_((Tcl_Interp *interp, static void DeleteVirtualEventTable _ANSI_ARGS_(( VirtualEventTable *vetPtr)); static void ExpandPercents _ANSI_ARGS_((TkWindow *winPtr, - char *before, XEvent *eventPtr, KeySym keySym, + CONST char *before, XEvent *eventPtr, KeySym keySym, Tcl_DString *dsPtr)); static void FreeTclBinding _ANSI_ARGS_((ClientData clientData)); static PatSeq * FindSequence _ANSI_ARGS_((Tcl_Interp *interp, Tcl_HashTable *patternTablePtr, ClientData object, - char *eventString, int create, int allowVirtual, - unsigned long *maskPtr)); + CONST char *eventString, int create, + int allowVirtual, unsigned long *maskPtr)); static void GetAllVirtualEvents _ANSI_ARGS_((Tcl_Interp *interp, VirtualEventTable *vetPtr)); static char * GetField _ANSI_ARGS_((char *p, char *copy, int size)); @@ -675,7 +705,7 @@ static int NameToWindow _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window main, Tcl_Obj *objPtr, Tk_Window *tkwinPtr)); static int ParseEventDescription _ANSI_ARGS_((Tcl_Interp *interp, - char **eventStringPtr, Pattern *patPtr, + CONST char **eventStringPtr, Pattern *patPtr, unsigned long *eventMaskPtr)); static void DoWarp _ANSI_ARGS_((ClientData clientData)); @@ -805,7 +835,7 @@ TkBindFree(mainPtr) bindInfoPtr = (BindInfo *) mainPtr->bindInfo; DeleteVirtualEventTable(&bindInfoPtr->virtualEventTable); bindInfoPtr->deleted = 1; - Tcl_EventuallyFree((ClientData) bindInfoPtr, Tcl_Free); + Tcl_EventuallyFree((ClientData) bindInfoPtr, TCL_DYNAMIC); mainPtr->bindInfo = NULL; } @@ -942,9 +972,9 @@ Tk_CreateBinding(interp, bindingTable, object, eventString, command, append) /* Table in which to create binding. */ ClientData object; /* Token for object with which binding is * associated. */ - char *eventString; /* String describing event sequence that + CONST char *eventString; /* String describing event sequence that * triggers binding. */ - char *command; /* Contains Tcl command to execute when + CONST char *command; /* Contains Tcl command to execute when * binding triggers. */ int append; /* 0 means replace any existing binding for * eventString; 1 means append to that @@ -1046,7 +1076,7 @@ TkCreateBindingProcedure(interp, bindingTable, object, eventString, /* Table in which to create binding. */ ClientData object; /* Token for object with which binding is * associated. */ - char *eventString; /* String describing event sequence that + CONST char *eventString; /* String describing event sequence that * triggers binding. */ TkBindEvalProc *eventProc; /* Procedure to invoke when binding * triggers. Must not be NULL. */ @@ -1124,7 +1154,7 @@ Tk_DeleteBinding(interp, bindingTable, object, eventString) Tk_BindingTable bindingTable; /* Table in which to delete binding. */ ClientData object; /* Token for object with which binding * is associated. */ - char *eventString; /* String describing event sequence + CONST char *eventString; /* String describing event sequence * that triggers binding. */ { BindingTable *bindPtr = (BindingTable *) bindingTable; @@ -1213,14 +1243,14 @@ Tk_DeleteBinding(interp, bindingTable, object, eventString) *-------------------------------------------------------------- */ -char * +CONST char * Tk_GetBinding(interp, bindingTable, object, eventString) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_BindingTable bindingTable; /* Table in which to look for * binding. */ ClientData object; /* Token for object with which binding * is associated. */ - char *eventString; /* String describing event sequence + CONST char *eventString; /* String describing event sequence * that triggers binding. */ { BindingTable *bindPtr = (BindingTable *) bindingTable; @@ -1233,7 +1263,7 @@ Tk_GetBinding(interp, bindingTable, object, eventString) return NULL; } if (psPtr->eventProc == EvalTclBinding) { - return (char *) psPtr->clientData; + return (CONST char *) psPtr->clientData; } return ""; } @@ -1426,7 +1456,7 @@ Tk_BindEvent(bindingTable, eventPtr, tkwin, numObjects, objectPtr) PendingBinding staticPending; TkWindow *winPtr = (TkWindow *)tkwin; PatternTableKey key; - + Tk_ClassModalProc *modalProc; /* * Ignore events on windows that don't have names: these are windows * like wrapper windows that shouldn't be visible to the @@ -1805,7 +1835,10 @@ Tk_BindEvent(bindingTable, eventPtr, tkwin, numObjects, objectPtr) winPtr->flags = (winPtr->flags & (unsigned int) ~TK_DEFER_MODAL) | (flags & TK_DEFER_MODAL); if (deferModal) { - (*winPtr->classProcsPtr->modalProc)(tkwin, eventPtr); + modalProc = Tk_GetClassProc(winPtr->classProcsPtr, modalProc); + if (modalProc != NULL) { + (*modalProc)(tkwin, eventPtr); + } } } @@ -1874,6 +1907,13 @@ TkBindDeadWindow(winPtr) BindInfo *bindInfoPtr; PendingBinding *curPtr; + /* + * Certain special windows like those used for send and clipboard + * have no mainPtr. + */ + if (winPtr->mainPtr == NULL) + return; + bindInfoPtr = (BindInfo *) winPtr->mainPtr->bindInfo; curPtr = bindInfoPtr->pendingList; while (curPtr != NULL) { @@ -2024,6 +2064,10 @@ MatchPatterns(dispPtr, bindPtr, psPtr, bestPtr, objectPtr, sourcePtrPtr) } goto nextEvent; } + if (eventPtr->xany.type == CreateNotify + && eventPtr->xcreatewindow.parent != window) { + goto nextSequence; + } else if (eventPtr->xany.window != window) { goto nextSequence; } @@ -2237,6 +2281,7 @@ MatchPatterns(dispPtr, bindPtr, psPtr, bestPtr, objectPtr, sourcePtrPtr) *sourcePtrPtr = bestSourcePtr; return bestPtr; } + /* *-------------------------------------------------------------- @@ -2261,7 +2306,7 @@ static void ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) TkWindow *winPtr; /* Window where event occurred: needed to * get input context. */ - char *before; /* Command containing percent expressions + CONST char *before; /* Command containing percent expressions * to be replaced. */ XEvent *eventPtr; /* X event containing information to be * used in % replacements. */ @@ -2274,7 +2319,7 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) * list element. */ int number, flags, length; #define NUM_SIZE 40 - char *string; + CONST char *string; Tcl_DString buf; char numStorage[NUM_SIZE+1]; @@ -2295,7 +2340,7 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) /* Empty loop body. */ } if (string != before) { - Tcl_DStringAppend(dsPtr, before, string-before); + Tcl_DStringAppend(dsPtr, before, (int) (string-before)); before = string; } if (*before == 0) { @@ -2335,6 +2380,14 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) } string = TkFindStateString(notifyDetail, number); } + else if (flags & CONFIGREQ) { + if (eventPtr->xconfigurerequest.value_mask & CWStackMode) { + string = TkFindStateString(configureRequestDetail, + eventPtr->xconfigurerequest.detail); + } else { + string = ""; + } + } goto doString; case 'f': number = eventPtr->xcrossing.focus; @@ -2345,7 +2398,26 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) } else if (flags & (CONFIG)) { number = eventPtr->xconfigure.height; } + else if (flags & CREATE) { + number = eventPtr->xcreatewindow.height; + } else if (flags & CONFIGREQ) { + number = eventPtr->xconfigurerequest.height; + } else if (flags & RESIZEREQ) { + number = eventPtr->xresizerequest.height; + } goto doNumber; + case 'i': + if (flags & CREATE) { + TkpPrintWindowId(numStorage, eventPtr->xcreatewindow.window); + } else if (flags & CONFIGREQ) { + TkpPrintWindowId(numStorage, eventPtr->xconfigurerequest.window); + } else if (flags & MAPREQ) { + TkpPrintWindowId(numStorage, eventPtr->xmaprequest.window); + } else { + TkpPrintWindowId(numStorage, eventPtr->xany.window); + } + string = numStorage; + goto doString; case 'k': number = eventPtr->xkey.keycode; goto doNumber; @@ -2369,13 +2441,21 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) } goto doNumber; case 'p': - string = TkFindStateString(circPlace, eventPtr->xcirculate.place); + if (flags & CIRC) { + string = TkFindStateString(circPlace, eventPtr->xcirculate.place); + } else if (flags & CIRCREQ) { + string = TkFindStateString(circPlace, eventPtr->xcirculaterequest.place); + } goto doString; case 's': if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) { number = eventPtr->xkey.state; } else if (flags & CROSSING) { number = eventPtr->xcrossing.state; + } else if (flags & PROP) { + string = TkFindStateString(propNotify, + eventPtr->xproperty.state); + goto doString; } else if (flags & VISIBILITY) { string = TkFindStateString(visNotify, eventPtr->xvisibility.state); @@ -2400,6 +2480,13 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) } else if (flags & CONFIG) { number = eventPtr->xconfigure.width; } + else if (flags & CREATE) { + number = eventPtr->xcreatewindow.width; + } else if (flags & CONFIGREQ) { + number = eventPtr->xconfigurerequest.width; + } else if (flags & RESIZEREQ) { + number = eventPtr->xresizerequest.width; + } goto doNumber; case 'x': if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) { @@ -2413,6 +2500,11 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) } else if (flags & REPARENT) { number = eventPtr->xreparent.x; } + else if (flags & CREATE) { + number = eventPtr->xcreatewindow.x; + } else if (flags & CONFIGREQ) { + number = eventPtr->xconfigurerequest.x; + } goto doNumber; case 'y': if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) { @@ -2427,6 +2519,11 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) number = eventPtr->xcrossing.y; } + else if (flags & CREATE) { + number = eventPtr->xcreatewindow.y; + } else if (flags & CONFIGREQ) { + number = eventPtr->xconfigurerequest.y; + } goto doNumber; case 'A': if (flags & KEY) { @@ -2435,7 +2532,13 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) } goto doString; case 'B': - number = eventPtr->xcreatewindow.border_width; + if (flags & CREATE) { + number = eventPtr->xcreatewindow.border_width; + } else if (flags & CONFIGREQ) { + number = eventPtr->xconfigurerequest.border_width; + } else { + number = eventPtr->xconfigure.border_width; + } goto doNumber; case 'D': /* @@ -2460,6 +2563,11 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) case 'N': number = (int) keySym; goto doNumber; + case 'P': + if (flags & PROP) { + string = Tk_GetAtomName((Tk_Window) winPtr, eventPtr->xproperty.atom); + } + goto doString; case 'R': TkpPrintWindowId(numStorage, eventPtr->xkey.root); string = numStorage; @@ -2542,16 +2650,16 @@ ExpandPercents(winPtr, before, eventPtr, keySym, dsPtr) * * This procedure is invoked whenever the current screen changes * in an application. It invokes a Tcl procedure named - * "tkScreenChanged", passing it the screen name as argument. - * tkScreenChanged does things like making the tkPriv variable + * "tk::ScreenChanged", passing it the screen name as argument. + * tk::ScreenChanged does things like making the tk::Priv variable * point to an array for the current display. * * Results: * None. * * Side effects: - * Depends on what tkScreenChanged does. If an error occurs - * them tkError will be invoked. + * Depends on what tk::ScreenChanged does. If an error occurs + * them bgerror will be invoked. * *---------------------------------------------------------------------- */ @@ -2568,7 +2676,7 @@ ChangeScreen(interp, dispName, screenIndex) char screen[TCL_INTEGER_SPACE]; Tcl_DStringInit(&cmd); - Tcl_DStringAppend(&cmd, "tkScreenChanged ", 16); + Tcl_DStringAppend(&cmd, "tk::ScreenChanged ", 18); Tcl_DStringAppend(&cmd, dispName, -1); sprintf(screen, ".%d", screenIndex); Tcl_DStringAppend(&cmd, screen, -1); @@ -2609,7 +2717,7 @@ Tk_EventObjCmd(clientData, interp, objc, objv) Tk_Window tkwin; VirtualEventTable *vetPtr; TkBindInfo bindInfo; - static char *optionStrings[] = { + static CONST char *optionStrings[] = { "add", "delete", "generate", "info", NULL }; @@ -2933,7 +3041,7 @@ DeleteVirtualEvent(interp, vetPtr, virtString, eventString) eventPSPtr = FindSequence(interp, &vetPtr->patternTable, NULL, eventString, 0, 0, &eventMask); if (eventPSPtr == NULL) { - char *string; + CONST char *string; string = Tcl_GetStringResult(interp); return (string[0] != '\0') ? TCL_ERROR : TCL_OK; @@ -3171,14 +3279,15 @@ HandleEventGenerate(interp, mainWin, objc, objv) Tcl_Obj *CONST objv[]; /* Argument objects. */ { XEvent event; - char *name, *p, *windowName; + CONST char *p; + char *name, *windowName; int count, flags, synch, i, number, warp; Tcl_QueuePosition pos; Pattern pat; Tk_Window tkwin, tkwin2; TkWindow *mainPtr; unsigned long eventMask; - static char *fieldStrings[] = { + static CONST char *fieldStrings[] = { "-when", "-above", "-borderwidth", "-button", "-count", "-delta", "-detail", "-focus", "-height", @@ -3691,9 +3800,9 @@ HandleEventGenerate(interp, mainWin, objc, objv) if ((warp != 0) && Tk_IsMapped(tkwin)) { TkDisplay *dispPtr; dispPtr = TkGetDisplay(event.xmotion.display); - if (!dispPtr->warpInProgress) { + if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) { Tcl_DoWhenIdle(DoWarp, (ClientData) dispPtr); - dispPtr->warpInProgress = 1; + dispPtr->flags |= TK_DISPLAY_IN_WARP; } dispPtr->warpWindow = event.xany.window; dispPtr->warpX = event.xkey.x; @@ -3712,8 +3821,8 @@ NameToWindow(interp, mainWin, objPtr, tkwinPtr) { char *name; Tk_Window tkwin; - int id; - + Window id; + name = Tcl_GetStringFromObj(objPtr, NULL); if (name[0] == '.') { tkwin = Tk_NameToWindow(interp, name, mainWin); @@ -3722,12 +3831,18 @@ NameToWindow(interp, mainWin, objPtr, tkwinPtr) } *tkwinPtr = tkwin; } else { - if (TkpScanWindowId(NULL, name, &id) != TCL_OK) { + /* + * Check for the winPtr being valid, even if it looks ok to + * TkpScanWindowId. [Bug #411307] + */ + + if ((TkpScanWindowId(NULL, name, &id) != TCL_OK) || + ((*tkwinPtr = Tk_IdToWindow(Tk_Display(mainWin), id)) + == NULL)) { Tcl_AppendResult(interp, "bad window name/identifier \"", name, "\"", (char *) NULL); return TCL_ERROR; } - *tkwinPtr = Tk_IdToWindow(Tk_Display(mainWin), (Window) id); } return TCL_OK; } @@ -3756,7 +3871,7 @@ DoWarp(clientData) XWarpPointer(dispPtr->display, (Window) None, (Window) dispPtr->warpWindow, 0, 0, 0, 0, (int) dispPtr->warpX, (int) dispPtr->warpY); XForceScreenSaver(dispPtr->display, ScreenSaverReset); - dispPtr->warpInProgress = 0; + dispPtr->flags &= ~TK_DISPLAY_IN_WARP; } /* @@ -3837,7 +3952,7 @@ FindSequence(interp, patternTablePtr, object, eventString, create, ClientData object; /* For binding table, token for object with * which binding is associated. * For virtual event table, NULL. */ - char *eventString; /* String description of pattern to + 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 @@ -3853,7 +3968,7 @@ FindSequence(interp, patternTablePtr, object, eventString, create, Pattern pats[EVENT_BUFFER_SIZE]; int numPats, virtualFound; - char *p; + CONST char *p; Pattern *patPtr; PatSeq *psPtr; Tcl_HashEntry *hPtr; @@ -4008,7 +4123,7 @@ static int ParseEventDescription(interp, eventStringPtr, patPtr, eventMaskPtr) Tcl_Interp *interp; /* For error messages. */ - char **eventStringPtr; /* On input, holds a pointer to start of + CONST char **eventStringPtr;/* On input, holds a pointer to start of * event string. On exit, gets pointer to * rest of string after parsed event. */ Pattern *patPtr; /* Filled with the pattern parsed from the @@ -4022,8 +4137,10 @@ ParseEventDescription(interp, eventStringPtr, patPtr, #define FIELD_SIZE 48 char field[FIELD_SIZE]; Tcl_HashEntry *hPtr; + Tcl_DString copy; - p = *eventStringPtr; + Tcl_DStringInit(©); + p = Tcl_DStringAppend(©, *eventStringPtr, -1); patPtr->eventType = -1; patPtr->needMods = 0; @@ -4052,7 +4169,8 @@ ParseEventDescription(interp, eventStringPtr, patPtr, sprintf(buf, "bad ASCII character 0x%x", (unsigned char) *p); Tcl_SetResult(interp, buf, TCL_VOLATILE); - return 0; + count = 0; + goto done; } } p++; @@ -4093,12 +4211,14 @@ ParseEventDescription(interp, eventStringPtr, patPtr, if (p == field) { Tcl_SetResult(interp, "virtual event \"<<>>\" is badly formed", TCL_STATIC); - return 0; + count = 0; + goto done; } if ((p == NULL) || (p[1] != '>')) { Tcl_SetResult(interp, "missing \">\" in virtual binding", TCL_STATIC); - return 0; + count = 0; + goto done; } *p = '\0'; patPtr->eventType = VirtualEvent; @@ -4161,7 +4281,8 @@ ParseEventDescription(interp, eventStringPtr, patPtr, } else if ((eventFlags & BUTTON) == 0) { Tcl_AppendResult(interp, "specified button \"", field, "\" for non-button event", (char *) NULL); - return 0; + count = 0; + goto done; } patPtr->detail.button = (*field - '0'); } else { @@ -4170,7 +4291,8 @@ ParseEventDescription(interp, eventStringPtr, patPtr, if (patPtr->detail.keySym == NoSymbol) { Tcl_AppendResult(interp, "bad event type or keysym \"", field, "\"", (char *) NULL); - return 0; + count = 0; + goto done; } if (eventFlags == 0) { patPtr->eventType = KeyPress; @@ -4178,13 +4300,15 @@ ParseEventDescription(interp, eventStringPtr, patPtr, } else if ((eventFlags & KEY) == 0) { Tcl_AppendResult(interp, "specified keysym \"", field, "\" for non-key event", (char *) NULL); - return 0; + count = 0; + goto done; } } } else if (eventFlags == 0) { Tcl_SetResult(interp, "no event type or button # or keysym", TCL_STATIC); - return 0; + count = 0; + goto done; } while ((*p == '-') || isspace(UCHAR(*p))) { @@ -4197,17 +4321,21 @@ ParseEventDescription(interp, eventStringPtr, patPtr, Tcl_SetResult(interp, "extra characters after detail in binding", TCL_STATIC); - return 0; + count = 0; + goto done; } } Tcl_SetResult(interp, "missing \">\" in binding", TCL_STATIC); - return 0; + count = 0; + goto done; } p++; end: - *eventStringPtr = p; + *eventStringPtr += (p - Tcl_DStringValue(©)); *eventMaskPtr |= eventMask; +done: + Tcl_DStringFree(©); return count; } @@ -4514,5 +4642,3 @@ TkCopyAndGlobalEval(interp, script) } - - diff --git a/tk/generic/tkBitmap.c b/tk/generic/tkBitmap.c index ff8e7e3e5a2..4d2b6749c80 100644 --- a/tk/generic/tkBitmap.c +++ b/tk/generic/tkBitmap.c @@ -57,6 +57,7 @@ typedef struct TkBitmap { * and it isn't currently in use. */ int width, height; /* Dimensions of bitmap. */ Display *display; /* Display for which bitmap is valid. */ + int screenNum; /* Screen on which bitmap is valid */ int resourceRefCount; /* Number of active uses of this bitmap (each * active use corresponds to a call to * Tk_AllocBitmapFromObj or Tk_GetBitmap). @@ -75,9 +76,9 @@ typedef struct TkBitmap { * (needed when deleting). */ struct TkBitmap *nextPtr; /* Points to the next TkBitmap structure with * the same name. All bitmaps with the - * same name (but different displays) are - * chained together off a single entry in - * nameTable. */ + * same name (but different displays or + * screens) are chained together off a + * single entry in nameTable. */ } TkBitmap; /* @@ -86,7 +87,7 @@ typedef struct TkBitmap { */ typedef struct { - char *source; /* Bitmap bits. */ + CONST char *source; /* Bitmap bits. */ int width, height; /* Dimensions of bitmap. */ } DataKey; @@ -124,7 +125,7 @@ static void InitBitmapObj _ANSI_ARGS_((Tcl_Obj *objPtr)); * ptr1 field of the Tcl_Obj points to a TkBitmap object. */ -static Tcl_ObjType bitmapObjType = { +Tcl_ObjType tkBitmapObjType = { "bitmap", /* name */ FreeBitmapObjProc, /* freeIntRepProc */ DupBitmapObjProc, /* dupIntRepProc */ @@ -167,7 +168,7 @@ Tk_AllocBitmapFromObj(interp, tkwin, objPtr) { TkBitmap *bitmapPtr; - if (objPtr->typePtr != &bitmapObjType) { + if (objPtr->typePtr != &tkBitmapObjType) { InitBitmapObj(objPtr); } bitmapPtr = (TkBitmap *) objPtr->internalRep.twoPtrValue.ptr1; @@ -186,7 +187,8 @@ Tk_AllocBitmapFromObj(interp, tkwin, objPtr) FreeBitmapObjProc(objPtr); bitmapPtr = NULL; - } else if (Tk_Display(tkwin) == bitmapPtr->display) { + } else if ( (Tk_Display(tkwin) == bitmapPtr->display) + && (Tk_ScreenNumber(tkwin) == bitmapPtr->screenNum) ) { bitmapPtr->resourceRefCount++; return bitmapPtr->bitmap; } @@ -204,7 +206,8 @@ Tk_AllocBitmapFromObj(interp, tkwin, objPtr) FreeBitmapObjProc(objPtr); for (bitmapPtr = firstBitmapPtr; bitmapPtr != NULL; bitmapPtr = bitmapPtr->nextPtr) { - if (Tk_Display(tkwin) == bitmapPtr->display) { + if ( (Tk_Display(tkwin) == bitmapPtr->display) && + (Tk_ScreenNumber(tkwin) == bitmapPtr->screenNum) ) { bitmapPtr->resourceRefCount++; bitmapPtr->objRefCount++; objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) bitmapPtr; @@ -321,7 +324,8 @@ GetBitmap(interp, tkwin, string) existingBitmapPtr = (TkBitmap *) Tcl_GetHashValue(nameHashPtr); for (bitmapPtr = existingBitmapPtr; bitmapPtr != NULL; bitmapPtr = bitmapPtr->nextPtr) { - if (Tk_Display(tkwin) == bitmapPtr->display) { + if ( (Tk_Display(tkwin) == bitmapPtr->display) && + (Tk_ScreenNumber(tkwin) == bitmapPtr->screenNum) ) { bitmapPtr->resourceRefCount++; return bitmapPtr; } @@ -418,6 +422,7 @@ GetBitmap(interp, tkwin, string) bitmapPtr->width = width; bitmapPtr->height = height; bitmapPtr->display = Tk_Display(tkwin); + bitmapPtr->screenNum = Tk_ScreenNumber(tkwin); bitmapPtr->resourceRefCount = 1; bitmapPtr->objRefCount = 0; bitmapPtr->nameHashPtr = nameHashPtr; @@ -463,7 +468,7 @@ Tk_DefineBitmap(interp, name, source, width, height) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ CONST char *name; /* Name to use for bitmap. Must not already * be defined as a bitmap. */ - char *source; /* Address of bits for bitmap. */ + CONST char *source; /* Address of bits for bitmap. */ int width; /* Width of bitmap. */ int height; /* Height of bitmap. */ { @@ -518,7 +523,7 @@ Tk_DefineBitmap(interp, name, source, width, height) *-------------------------------------------------------------- */ -char * +CONST char * Tk_NameOfBitmap(display, bitmap) Display *display; /* Display for which bitmap was * allocated. */ @@ -804,7 +809,7 @@ Pixmap Tk_GetBitmapFromData(interp, tkwin, source, width, height) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ Tk_Window tkwin; /* Window in which bitmap will be used. */ - char *source; /* Bitmap data for bitmap shape. */ + CONST char *source; /* Bitmap data for bitmap shape. */ int width, height; /* Dimensions of bitmap. */ { DataKey nameKey; @@ -895,7 +900,7 @@ GetBitmapFromObj(tkwin, objPtr) Tcl_HashEntry *hashPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; - if (objPtr->typePtr != &bitmapObjType) { + if (objPtr->typePtr != &tkBitmapObjType) { InitBitmapObj(objPtr); } @@ -970,7 +975,7 @@ InitBitmapObj(objPtr) if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) { (*typePtr->freeIntRepProc)(objPtr); } - objPtr->typePtr = &bitmapObjType; + objPtr->typePtr = &tkBitmapObjType; objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) NULL; } @@ -1183,4 +1188,3 @@ TkGetBitmapPredefTable() return &tsdPtr->predefBitmapTable; } - diff --git a/tk/generic/tkButton.c b/tk/generic/tkButton.c index 8a52f91217c..2d74fffee9f 100644 --- a/tk/generic/tkButton.c +++ b/tk/generic/tkButton.c @@ -17,6 +17,11 @@ #include "tkButton.h" #include "default.h" +typedef struct ThreadSpecificData { + int defaultsInitialized; +} ThreadSpecificData; +static Tcl_ThreadDataKey dataKey; + /* * Class names for buttons, indexed by one of the type values defined * in tkButton.h. @@ -42,6 +47,15 @@ static char *stateStrings[] = { "active", "disabled", "normal", (char *) NULL }; +/* + * The following table defines the legal values for the -compound option. + * It is used with the "enum compound" declaration in tkButton.h + */ + +static char *compoundStrings[] = { + "bottom", "center", "left", "none", "right", "top", (char *) NULL +}; + /* * Information used for parsing configuration options. There is a * separate table for each of the four widget classes. @@ -69,6 +83,9 @@ static Tk_OptionSpec labelOptionSpecs[] = { {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_BUTTON_BORDER_WIDTH, Tk_Offset(TkButton, borderWidthPtr), Tk_Offset(TkButton, borderWidth), 0, 0, 0}, + {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", + DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0, + (ClientData) compoundStrings, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor), TK_OPTION_NULL_OK, 0, 0}, @@ -155,6 +172,9 @@ static Tk_OptionSpec buttonOptionSpecs[] = { {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1, TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", + DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0, + (ClientData) compoundStrings, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor), TK_OPTION_NULL_OK, 0, 0}, @@ -189,6 +209,9 @@ static Tk_OptionSpec buttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0}, + {TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief", + DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief), + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", DEF_BUTTON_PADX, Tk_Offset(TkButton, padXPtr), Tk_Offset(TkButton, padX), 0, 0, 0}, @@ -196,7 +219,14 @@ static Tk_OptionSpec buttonOptionSpecs[] = { DEF_BUTTON_PADY, Tk_Offset(TkButton, padYPtr), Tk_Offset(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", - DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0}, + DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, relief), + 0, 0, 0}, + {TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay", + DEF_BUTTON_REPEAT_DELAY, -1, Tk_Offset(TkButton, repeatDelay), + 0, 0, 0}, + {TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval", + DEF_BUTTON_REPEAT_INTERVAL, -1, Tk_Offset(TkButton, repeatInterval), + 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state), 0, (ClientData) stateStrings, 0}, @@ -244,6 +274,9 @@ static Tk_OptionSpec checkbuttonOptionSpecs[] = { {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1, TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", + DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0, + (ClientData) compoundStrings, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor), TK_OPTION_NULL_OK, 0, 0}, @@ -277,10 +310,15 @@ static Tk_OptionSpec checkbuttonOptionSpecs[] = { DEF_BUTTON_INDICATOR, -1, Tk_Offset(TkButton, indicatorOn), 0, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0}, + {TK_OPTION_RELIEF, "-offrelief", "offRelief", "OffRelief", + DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, offRelief), 0, 0, 0}, {TK_OPTION_STRING, "-offvalue", "offValue", "Value", DEF_BUTTON_OFF_VALUE, Tk_Offset(TkButton, offValuePtr), -1, 0, 0, 0}, {TK_OPTION_STRING, "-onvalue", "onValue", "Value", DEF_BUTTON_ON_VALUE, Tk_Offset(TkButton, onValuePtr), -1, 0, 0, 0}, + {TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief", + DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief), + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", DEF_LABCHKRAD_PADX, Tk_Offset(TkButton, padXPtr), Tk_Offset(TkButton, padX), 0, 0, 0}, @@ -345,6 +383,9 @@ static Tk_OptionSpec radiobuttonOptionSpecs[] = { {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1, TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", + DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0, + (ClientData) compoundStrings, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor), TK_OPTION_NULL_OK, 0, 0}, @@ -379,6 +420,11 @@ static Tk_OptionSpec radiobuttonOptionSpecs[] = { 0, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0}, + {TK_OPTION_RELIEF, "-offrelief", "offRelief", "OffRelief", + DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, offRelief), 0, 0, 0}, + {TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief", + DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief), + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", DEF_LABCHKRAD_PADX, Tk_Offset(TkButton, padXPtr), Tk_Offset(TkButton, padX), 0, 0, 0}, @@ -439,7 +485,7 @@ static Tk_OptionSpec *optionSpecs[] = { * into a single enumerated type used to dispatch the widget command. */ -static char *commandNames[][8] = { +static CONST char *commandNames[][8] = { {"cget", "configure", (char *) NULL}, {"cget", "configure", "flash", "invoke", (char *) NULL}, {"cget", "configure", "deselect", "flash", "invoke", "select", @@ -478,11 +524,11 @@ static void ButtonSelectImageProc _ANSI_ARGS_(( ClientData clientData, int x, int y, int width, int height, int imgWidth, int imgHeight)); static char * ButtonTextVarProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); + Tcl_Interp *interp, CONST char *name1, + CONST char *name2, int flags)); static char * ButtonVarProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); + Tcl_Interp *interp, CONST char *name1, + CONST char *name2, int flags)); static int ButtonWidgetObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); @@ -570,8 +616,7 @@ Tk_RadiobuttonObjCmd(clientData, interp, objc, objv) static int ButtonCreate(clientData, interp, objc, objv, type) - ClientData clientData; /* Option table for this widget class, or - * NULL if not created yet. */ + ClientData clientData; /* NULL. */ Tcl_Interp *interp; /* Current interpreter. */ int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument values. */ @@ -582,25 +627,12 @@ ButtonCreate(clientData, interp, objc, objv, type) TkButton *butPtr; Tk_OptionTable optionTable; Tk_Window tkwin; + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - optionTable = (Tk_OptionTable) clientData; - if (optionTable == NULL) { - Tcl_CmdInfo info; - char *name; - - /* - * We haven't created the option table for this widget class - * yet. Do it now and save the table as the clientData for - * the command, so we'll have access to it in future - * invocations of the command. - */ - + if (!tsdPtr->defaultsInitialized) { TkpButtonSetDefaults(optionSpecs[type]); - optionTable = Tk_CreateOptionTable(interp, optionSpecs[type]); - name = Tcl_GetString(objv[0]); - Tcl_GetCommandInfo(interp, name, &info); - info.objClientData = (ClientData) optionTable; - Tcl_SetCommandInfo(interp, name, &info); + tsdPtr->defaultsInitialized = 1; } if (objc < 2) { @@ -618,10 +650,17 @@ ButtonCreate(clientData, interp, objc, objv, type) return TCL_ERROR; } + /* + * Create the option table for this widget class. If it has already + * been created, the cached pointer will be returned. + */ + + optionTable = Tk_CreateOptionTable(interp, optionSpecs[type]); + Tk_SetClass(tkwin, classNames[type]); butPtr = TkpCreateButton(tkwin); - TkSetClassProcs(tkwin, &tkpButtonProcs, (ClientData) butPtr); + Tk_SetClassProcs(tkwin, &tkpButtonProcs, (ClientData) butPtr); /* * Initialize the data structure for the button. @@ -907,9 +946,9 @@ static void DestroyButton(butPtr) TkButton *butPtr; /* Info about button widget. */ { + butPtr->flags |= BUTTON_DELETED; TkpDestroyButton(butPtr); - butPtr->flags |= BUTTON_DELETED; if (butPtr->flags & REDRAW_PENDING) { Tcl_CancelIdleCall(TkpDisplayButton, (ClientData) butPtr); } @@ -991,7 +1030,7 @@ ConfigureButton(interp, butPtr, objc, objv) { Tk_SavedOptions savedOptions; Tcl_Obj *errorResult = NULL; - int error; + int error, haveImage; Tk_Image image; /* @@ -1094,6 +1133,16 @@ ConfigureButton(interp, butPtr, objc, objv) == NULL) { continue; } + + /* + * If a radiobutton has the empty string as value + * it should be selected. + */ + + if ((butPtr->type == TYPE_RADIO_BUTTON) && + (*Tcl_GetString(butPtr->onValuePtr) == 0)) { + butPtr->flags |= SELECTED; + } } } @@ -1132,7 +1181,11 @@ ConfigureButton(interp, butPtr, objc, objv) } butPtr->selectImage = image; - if ((butPtr->imagePtr == NULL) && (butPtr->bitmap == None) + haveImage = 0; + if (butPtr->imagePtr != NULL || butPtr->bitmap != None) { + haveImage = 1; + } + if ((!haveImage || butPtr->compound != COMPOUND_NONE) && (butPtr->textVarNamePtr != NULL)) { /* * The button must display the value of a variable: set up a trace @@ -1295,6 +1348,9 @@ TkButtonWorldChanged(instanceData) } else { gcValues.foreground = gcValues.background; mask = GCForeground; + if (butPtr->compound != COMPOUND_NONE) { + mask |= GCFont; + } if (butPtr->gray == None) { butPtr->gray = Tk_GetBitmap(NULL, butPtr->tkwin, "gray50"); } @@ -1499,8 +1555,8 @@ static char * ButtonVarProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Information about button. */ Tcl_Interp *interp; /* Interpreter containing variable. */ - char *name1; /* Name of variable. */ - char *name2; /* Second part of variable name. */ + CONST char *name1; /* Name of variable. */ + CONST char *name2; /* Second part of variable name. */ int flags; /* Information about what happened. */ { register TkButton *butPtr = (TkButton *) clientData; @@ -1578,14 +1634,18 @@ static char * ButtonTextVarProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Information about button. */ Tcl_Interp *interp; /* Interpreter containing variable. */ - char *name1; /* Not used. */ - char *name2; /* Not used. */ + CONST char *name1; /* Not used. */ + CONST char *name2; /* Not used. */ int flags; /* Information about what happened. */ { TkButton *butPtr = (TkButton *) clientData; char *name; Tcl_Obj *valuePtr; + if (butPtr->flags & BUTTON_DELETED) { + return (char *) NULL; + } + name = Tcl_GetString(butPtr->textVarNamePtr); /* diff --git a/tk/generic/tkButton.h b/tk/generic/tkButton.h index d0e28822c16..e9a78c32f84 100644 --- a/tk/generic/tkButton.h +++ b/tk/generic/tkButton.h @@ -24,6 +24,15 @@ # define TCL_STORAGE_CLASS DLLEXPORT #endif +/* + * Legal values for the "compound" field of TkButton records. + */ + +enum compound { + COMPOUND_BOTTOM, COMPOUND_CENTER, COMPOUND_LEFT, COMPOUND_NONE, + COMPOUND_RIGHT, COMPOUND_TOP +}; + /* * Legal values for the "state" field of TkButton records. */ @@ -107,6 +116,15 @@ typedef struct { int relief; /* Value of -relief option: specifies 3-d * effect for border, such as * TK_RELIEF_RAISED. */ + int overRelief; /* Value of -overrelief option: specifies a 3-d + * effect for the border, such as + * TK_RELIEF_RAISED, to be used when the mouse + * is over the button. */ + int offRelief; /* Value of -offrelief option: specifies a 3-d + * effect for the border, such as + * TK_RELIEF_RAISED, to be used when a + * checkbutton or radiobutton without + * indicator is off */ Tcl_Obj *highlightWidthPtr; /* Value of -highlightthickness option: * specifies width in pixels of highlight to * draw around widget when it has the focus. @@ -226,6 +244,15 @@ typedef struct { * to execute when button is invoked. If * widget is label or has no command, this * is NULL. */ + int compound; /* Value of -compound option; specifies whether + * the button should show both an image and + * text, and, if so, how. */ + int repeatDelay; /* Value of -repeatdelay option; specifies + * the number of ms after which the button will + * start to auto-repeat its command. */ + int repeatInterval; /* Value of -repeatinterval option; specifies + * the number of ms between auto-repeat + * invocataions of the button command. */ int flags; /* Various flags; see below for * definitions. */ } TkButton; @@ -257,16 +284,15 @@ typedef struct { * deleted. */ -#define REDRAW_PENDING 1 -#define SELECTED 2 -#define GOT_FOCUS 4 -#define BUTTON_DELETED 0x8 - +#define REDRAW_PENDING (1 << 0) +#define SELECTED (1 << 1) +#define GOT_FOCUS (1 << 2) +#define BUTTON_DELETED (1 << 3) /* * Declaration of variables shared between the files in the button module. */ -extern TkClassProcs tkpButtonProcs; +extern Tk_ClassProcs tkpButtonProcs; /* * Declaration of procedures used in the implementation of the button @@ -294,4 +320,3 @@ EXTERN int TkInvokeButton _ANSI_ARGS_((TkButton *butPtr)); # define TCL_STORAGE_CLASS DLLIMPORT #endif /* _TKBUTTON */ - diff --git a/tk/generic/tkCanvArc.c b/tk/generic/tkCanvArc.c index e2c3504fd1e..a229d3fc250 100644 --- a/tk/generic/tkCanvArc.c +++ b/tk/generic/tkCanvArc.c @@ -196,19 +196,19 @@ static Tk_ConfigSpec configSpecs[] = { static void ComputeArcBbox _ANSI_ARGS_((Tk_Canvas canvas, ArcItem *arcPtr)); static int ConfigureArc _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int argc, - Tcl_Obj *CONST argv[], int flags)); + Tk_Canvas canvas, Tk_Item *itemPtr, int objc, + Tcl_Obj *CONST objv[], int flags)); static int CreateArc _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, - int argc, Tcl_Obj *CONST argv[])); + int objc, Tcl_Obj *CONST objv[])); static void DeleteArc _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, Display *display)); static void DisplayArc _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, Display *display, Drawable dst, int x, int y, int width, int height)); static int ArcCoords _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int argc, - Tcl_Obj *CONST argv[])); + Tk_Canvas canvas, Tk_Item *itemPtr, int objc, + Tcl_Obj *CONST objv[])); static int ArcToArea _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, double *rectPtr)); static double ArcToPoint _ANSI_ARGS_((Tk_Canvas canvas, @@ -286,29 +286,27 @@ Tk_ItemType tkArcType = { */ static int -CreateArc(interp, canvas, itemPtr, argc, argv) +CreateArc(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_Canvas canvas; /* Canvas to hold new item. */ Tk_Item *itemPtr; /* Record to hold new item; header * has been initialized by caller. */ - int argc; /* Number of arguments in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing arc. */ + int objc; /* Number of arguments in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing arc. */ { ArcItem *arcPtr = (ArcItem *) itemPtr; - int i; + int i = 4; - if (argc==1) { + if (objc == 1) { i = 1; - } else { - char *arg = Tcl_GetStringFromObj(argv[1], NULL); - if ((argc>1) && (arg[0] == '-') - && (arg[1] >= 'a') && (arg[1] <= 'z')) { + } else if (objc > 1) { + char *arg = Tcl_GetString(objv[1]); + if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) { i = 1; - } else { - i = 4; } } - if (argc < i) { + + if (objc < i) { Tcl_AppendResult(interp, "wrong # args: should be \"", Tk_PathName(Tk_CanvasTkwin(canvas)), " create ", itemPtr->typePtr->name, " x1 y1 x2 y2 ?options?\"", @@ -342,10 +340,10 @@ CreateArc(interp, canvas, itemPtr, argc, argv) * Process the arguments to fill in the item record. */ - if ((ArcCoords(interp, canvas, itemPtr, i, argv) != TCL_OK)) { + if ((ArcCoords(interp, canvas, itemPtr, i, objv) != TCL_OK)) { goto error; } - if (ConfigureArc(interp, canvas, itemPtr, argc-4, argv+4, 0) == TCL_OK) { + if (ConfigureArc(interp, canvas, itemPtr, objc-4, objv+4, 0) == TCL_OK) { return TCL_OK; } error: @@ -372,19 +370,19 @@ CreateArc(interp, canvas, itemPtr, argc, argv) */ static int -ArcCoords(interp, canvas, itemPtr, argc, argv) +ArcCoords(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Used for error reporting. */ Tk_Canvas canvas; /* Canvas containing item. */ Tk_Item *itemPtr; /* Item whose coordinates are to be * read or modified. */ - int argc; /* Number of coordinates supplied in - * argv. */ - Tcl_Obj *CONST argv[]; /* Array of coordinates: x1, y1, + int objc; /* Number of coordinates supplied in + * objv. */ + Tcl_Obj *CONST objv[]; /* Array of coordinates: x1, y1, * x2, y2, ... */ { ArcItem *arcPtr = (ArcItem *) itemPtr; - if (argc == 0) { + if (objc == 0) { Tcl_Obj *obj = Tcl_NewObj(); Tcl_Obj *subobj = Tcl_NewDoubleObj(arcPtr->bbox[0]); Tcl_ListObjAppendElement(interp, obj, subobj); @@ -395,26 +393,26 @@ ArcCoords(interp, canvas, itemPtr, argc, argv) subobj = Tcl_NewDoubleObj(arcPtr->bbox[3]); Tcl_ListObjAppendElement(interp, obj, subobj); Tcl_SetObjResult(interp, obj); - } else if ((argc == 1)||(argc == 4)) { - if (argc==1) { - if (Tcl_ListObjGetElements(interp, argv[0], &argc, - (Tcl_Obj ***) &argv) != TCL_OK) { + } else if ((objc == 1)||(objc == 4)) { + if (objc==1) { + if (Tcl_ListObjGetElements(interp, objv[0], &objc, + (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; - } else if (argc != 4) { + } else if (objc != 4) { char buf[64 + TCL_INTEGER_SPACE]; - sprintf(buf, "wrong # coordinates: expected 4, got %d", argc); + sprintf(buf, "wrong # coordinates: expected 4, got %d", objc); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_ERROR; } } - if ((Tk_CanvasGetCoordFromObj(interp, canvas, argv[0], + if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], &arcPtr->bbox[0]) != TCL_OK) - || (Tk_CanvasGetCoordFromObj(interp, canvas, argv[1], + || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], &arcPtr->bbox[1]) != TCL_OK) - || (Tk_CanvasGetCoordFromObj(interp, canvas, argv[2], + || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[2], &arcPtr->bbox[2]) != TCL_OK) - || (Tk_CanvasGetCoordFromObj(interp, canvas, argv[3], + || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[3], &arcPtr->bbox[3]) != TCL_OK)) { return TCL_ERROR; } @@ -422,7 +420,7 @@ ArcCoords(interp, canvas, itemPtr, argc, argv) } else { char buf[64 + TCL_INTEGER_SPACE]; - sprintf(buf, "wrong # coordinates: expected 0 or 4, got %d", argc); + sprintf(buf, "wrong # coordinates: expected 0 or 4, got %d", objc); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_ERROR; } @@ -449,12 +447,12 @@ ArcCoords(interp, canvas, itemPtr, argc, argv) */ static int -ConfigureArc(interp, canvas, itemPtr, argc, argv, flags) +ConfigureArc(interp, canvas, itemPtr, objc, objv, flags) Tcl_Interp *interp; /* Used for error reporting. */ Tk_Canvas canvas; /* Canvas containing itemPtr. */ Tk_Item *itemPtr; /* Arc item to reconfigure. */ - int argc; /* Number of elements in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing things to configure. */ + int objc; /* Number of elements in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing things to configure. */ int flags; /* Flags to pass to Tk_ConfigureWidget. */ { ArcItem *arcPtr = (ArcItem *) itemPtr; @@ -469,8 +467,8 @@ ConfigureArc(interp, canvas, itemPtr, argc, argv, flags) Tk_State state; tkwin = Tk_CanvasTkwin(canvas); - if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, (char **) argv, - (char *) arcPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { + if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, + (CONST char **) objv, (char *) arcPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } @@ -2145,4 +2143,3 @@ StylePrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) return "pieslice"; } } - diff --git a/tk/generic/tkCanvBmap.c b/tk/generic/tkCanvBmap.c index dc35890505d..d015689f47f 100644 --- a/tk/generic/tkCanvBmap.c +++ b/tk/generic/tkCanvBmap.c @@ -92,8 +92,8 @@ static Tk_ConfigSpec configSpecs[] = { */ static int BitmapCoords _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int argc, - Tcl_Obj *CONST argv[])); + Tk_Canvas canvas, Tk_Item *itemPtr, int objc, + Tcl_Obj *CONST objv[])); static int BitmapToArea _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, double *rectPtr)); static double BitmapToPoint _ANSI_ARGS_((Tk_Canvas canvas, @@ -103,11 +103,11 @@ static int BitmapToPostscript _ANSI_ARGS_((Tcl_Interp *interp, static void ComputeBitmapBbox _ANSI_ARGS_((Tk_Canvas canvas, BitmapItem *bmapPtr)); static int ConfigureBitmap _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int argc, - Tcl_Obj *CONST argv[], int flags)); + Tk_Canvas canvas, Tk_Item *itemPtr, int objc, + Tcl_Obj *CONST objv[], int flags)); static int CreateBitmap _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, - int argc, Tcl_Obj *CONST argv[])); + int objc, Tcl_Obj *CONST objv[])); static void DeleteBitmap _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, Display *display)); static void DisplayBitmap _ANSI_ARGS_((Tk_Canvas canvas, @@ -168,22 +168,22 @@ Tk_ItemType tkBitmapType = { */ static int -CreateBitmap(interp, canvas, itemPtr, argc, argv) +CreateBitmap(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_Canvas canvas; /* Canvas to hold new item. */ Tk_Item *itemPtr; /* Record to hold new item; header * has been initialized by caller. */ - int argc; /* Number of arguments in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing rectangle. */ + int objc; /* Number of arguments in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing rectangle. */ { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; int i; - if (argc==1) { + if (objc==1) { i = 1; } else { - char *arg = Tcl_GetStringFromObj(argv[1], NULL); - if (((argc>1) && (arg[0] == '-') + char *arg = Tcl_GetStringFromObj(objv[1], NULL); + if (((objc>1) && (arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z'))) { i = 1; } else { @@ -191,7 +191,7 @@ CreateBitmap(interp, canvas, itemPtr, argc, argv) } } - if (argc < i) { + if (objc < i) { Tcl_AppendResult(interp, "wrong # args: should be \"", Tk_PathName(Tk_CanvasTkwin(canvas)), " create ", itemPtr->typePtr->name, " x y ?options?\"", @@ -219,10 +219,10 @@ CreateBitmap(interp, canvas, itemPtr, argc, argv) * Process the arguments to fill in the item record. */ - if ((BitmapCoords(interp, canvas, itemPtr, i, argv) != TCL_OK)) { + if ((BitmapCoords(interp, canvas, itemPtr, i, objv) != TCL_OK)) { goto error; } - if (ConfigureBitmap(interp, canvas, itemPtr, argc-i, argv+i, 0) == TCL_OK) { + if (ConfigureBitmap(interp, canvas, itemPtr, objc-i, objv+i, 0) == TCL_OK) { return TCL_OK; } @@ -250,40 +250,40 @@ CreateBitmap(interp, canvas, itemPtr, argc, argv) */ static int -BitmapCoords(interp, canvas, itemPtr, argc, argv) +BitmapCoords(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Used for error reporting. */ Tk_Canvas canvas; /* Canvas containing item. */ Tk_Item *itemPtr; /* Item whose coordinates are to be * read or modified. */ - int argc; /* Number of coordinates supplied in - * argv. */ - Tcl_Obj *CONST argv[]; /* Array of coordinates: x1, y1, + int objc; /* Number of coordinates supplied in + * objv. */ + Tcl_Obj *CONST objv[]; /* Array of coordinates: x1, y1, * x2, y2, ... */ { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; - if (argc == 0) { + if (objc == 0) { Tcl_Obj *obj = Tcl_NewObj(); Tcl_Obj *subobj = Tcl_NewDoubleObj(bmapPtr->x); Tcl_ListObjAppendElement(interp, obj, subobj); subobj = Tcl_NewDoubleObj(bmapPtr->y); Tcl_ListObjAppendElement(interp, obj, subobj); Tcl_SetObjResult(interp, obj); - } else if (argc <3) { - if (argc==1) { - if (Tcl_ListObjGetElements(interp, argv[0], &argc, - (Tcl_Obj ***) &argv) != TCL_OK) { + } else if (objc <3) { + if (objc==1) { + if (Tcl_ListObjGetElements(interp, objv[0], &objc, + (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; - } else if (argc != 2) { + } else if (objc != 2) { char buf[64 + TCL_INTEGER_SPACE]; - sprintf(buf, "wrong # coordinates: expected 2, got %d", argc); + sprintf(buf, "wrong # coordinates: expected 2, got %d", objc); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_ERROR; } } - if ((Tk_CanvasGetCoordFromObj(interp, canvas, argv[0], &bmapPtr->x) != TCL_OK) - || (Tk_CanvasGetCoordFromObj(interp, canvas, argv[1], &bmapPtr->y) + if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], &bmapPtr->x) != TCL_OK) + || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], &bmapPtr->y) != TCL_OK)) { return TCL_ERROR; } @@ -291,7 +291,7 @@ BitmapCoords(interp, canvas, itemPtr, argc, argv) } else { char buf[64 + TCL_INTEGER_SPACE]; - sprintf(buf, "wrong # coordinates: expected 0 or 2, got %d", argc); + sprintf(buf, "wrong # coordinates: expected 0 or 2, got %d", objc); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_ERROR; } @@ -317,12 +317,12 @@ BitmapCoords(interp, canvas, itemPtr, argc, argv) */ static int -ConfigureBitmap(interp, canvas, itemPtr, argc, argv, flags) +ConfigureBitmap(interp, canvas, itemPtr, objc, objv, flags) Tcl_Interp *interp; /* Used for error reporting. */ Tk_Canvas canvas; /* Canvas containing itemPtr. */ Tk_Item *itemPtr; /* Bitmap item to reconfigure. */ - int argc; /* Number of elements in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing things to configure. */ + int objc; /* Number of elements in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing things to configure. */ int flags; /* Flags to pass to Tk_ConfigureWidget. */ { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; @@ -336,8 +336,8 @@ ConfigureBitmap(interp, canvas, itemPtr, argc, argv, flags) Tk_State state; tkwin = Tk_CanvasTkwin(canvas); - if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, (char **) argv, - (char *) bmapPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { + if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, + (CONST char **) objv, (char *) bmapPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } diff --git a/tk/generic/tkCanvImg.c b/tk/generic/tkCanvImg.c index ebfed526748..7bd7b4e3f91 100644 --- a/tk/generic/tkCanvImg.c +++ b/tk/generic/tkCanvImg.c @@ -319,8 +319,8 @@ ConfigureImage(interp, canvas, itemPtr, argc, argv, flags) Tk_Image image; tkwin = Tk_CanvasTkwin(canvas); - if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, (char **) argv, - (char *) imgPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { + if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, + (CONST char **) argv, (char *) imgPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } @@ -897,4 +897,3 @@ ImageChangedProc(clientData, x, y, width, height, imgWidth, imgHeight) imgPtr->header.y1 + y, (int) (imgPtr->header.x1 + x + width), (int) (imgPtr->header.y1 + y + height)); } - diff --git a/tk/generic/tkCanvLine.c b/tk/generic/tkCanvLine.c index fc2174b710b..af1ab3504bd 100644 --- a/tk/generic/tkCanvLine.c +++ b/tk/generic/tkCanvLine.c @@ -83,13 +83,13 @@ static int ArrowheadPostscript _ANSI_ARGS_((Tcl_Interp *interp, static void ComputeLineBbox _ANSI_ARGS_((Tk_Canvas canvas, LineItem *linePtr)); static int ConfigureLine _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int argc, - Tcl_Obj *CONST argv[], int flags)); + Tk_Canvas canvas, Tk_Item *itemPtr, int objc, + Tcl_Obj *CONST objv[], int flags)); static int ConfigureArrows _ANSI_ARGS_((Tk_Canvas canvas, LineItem *linePtr)); static int CreateLine _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, - int argc, Tcl_Obj *CONST argv[])); + int objc, Tcl_Obj *CONST objv[])); static void DeleteLine _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, Display *display)); static void DisplayLine _ANSI_ARGS_((Tk_Canvas canvas, @@ -100,7 +100,7 @@ static int GetLineIndex _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *obj, int *indexPtr)); static int LineCoords _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, - int argc, Tcl_Obj *CONST argv[])); + int objc, Tcl_Obj *CONST objv[])); static void LineDeleteCoords _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, int first, int last)); static void LineInsert _ANSI_ARGS_((Tk_Canvas canvas, @@ -291,13 +291,13 @@ Tk_ItemType tkLineType = { */ static int -CreateLine(interp, canvas, itemPtr, argc, argv) +CreateLine(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_Canvas canvas; /* Canvas to hold new item. */ Tk_Item *itemPtr; /* Record to hold new item; header * has been initialized by caller. */ - int argc; /* Number of arguments in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing line. */ + int objc; /* Number of arguments in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing line. */ { LineItem *linePtr = (LineItem *) itemPtr; int i; @@ -330,17 +330,16 @@ CreateLine(interp, canvas, itemPtr, argc, argv) * start with a digit or a minus sign followed by a digit. */ - for (i = 0; i < argc; i++) { - char *arg = Tcl_GetStringFromObj(argv[i], NULL); - if ((arg[0] == '-') && (arg[1] >= 'a') - && (arg[1] <= 'z')) { + for (i = 0; i < objc; i++) { + char *arg = Tcl_GetString(objv[i]); + if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) { break; } } - if (i && (LineCoords(interp, canvas, itemPtr, i, argv) != TCL_OK)) { + if (i && (LineCoords(interp, canvas, itemPtr, i, objv) != TCL_OK)) { goto error; } - if (ConfigureLine(interp, canvas, itemPtr, argc-i, argv+i, 0) == TCL_OK) { + if (ConfigureLine(interp, canvas, itemPtr, objc-i, objv+i, 0) == TCL_OK) { return TCL_OK; } @@ -368,21 +367,21 @@ CreateLine(interp, canvas, itemPtr, argc, argv) */ static int -LineCoords(interp, canvas, itemPtr, argc, argv) +LineCoords(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Used for error reporting. */ Tk_Canvas canvas; /* Canvas containing item. */ Tk_Item *itemPtr; /* Item whose coordinates are to be * read or modified. */ - int argc; /* Number of coordinates supplied in - * argv. */ - Tcl_Obj *CONST argv[]; /* Array of coordinates: x1, y1, + int objc; /* Number of coordinates supplied in + * objv. */ + Tcl_Obj *CONST objv[]; /* Array of coordinates: x1, y1, * x2, y2, ... */ { LineItem *linePtr = (LineItem *) itemPtr; int i, numPoints; double *coordPtr; - if (argc == 0) { + if (objc == 0) { int numCoords; Tcl_Obj *subobj, *obj = Tcl_NewObj(); @@ -405,27 +404,27 @@ LineCoords(interp, canvas, itemPtr, argc, argv) Tcl_SetObjResult(interp, obj); return TCL_OK; } - if (argc == 1) { - if (Tcl_ListObjGetElements(interp, argv[0], &argc, - (Tcl_Obj ***) &argv) != TCL_OK) { + if (objc == 1) { + if (Tcl_ListObjGetElements(interp, objv[0], &objc, + (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; } } - if (argc & 1) { + if (objc & 1) { Tcl_AppendResult(interp, "odd number of coordinates specified for line", (char *) NULL); return TCL_ERROR; - } else if (argc < 4) { + } else if (objc < 4) { Tcl_AppendResult(interp, "too few coordinates specified for line", (char *) NULL); return TCL_ERROR; } else { - numPoints = argc/2; + numPoints = objc/2; if (linePtr->numPoints != numPoints) { coordPtr = (double *) ckalloc((unsigned) - (sizeof(double) * argc)); + (sizeof(double) * objc)); if (linePtr->coordPtr != NULL) { ckfree((char *) linePtr->coordPtr); } @@ -433,8 +432,8 @@ LineCoords(interp, canvas, itemPtr, argc, argv) linePtr->numPoints = numPoints; } coordPtr = linePtr->coordPtr; - for (i = 0; i outline.width; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (linePtr->outline.activeStipple!=None) { + if (linePtr->outline.activeStipple != None) { stipple = linePtr->outline.activeStipple; } - if (linePtr->outline.activeWidth>linewidth) { + if (linePtr->outline.activeWidth != linewidth) { linewidth = linePtr->outline.activeWidth; } } else if (state==TK_STATE_DISABLED) { - if (linePtr->outline.disabledStipple!=None) { + if (linePtr->outline.disabledStipple != None) { stipple = linePtr->outline.disabledStipple; } - if (linePtr->outline.disabledWidth>linewidth) { - linewidth = linePtr->outline.activeWidth; + if (linePtr->outline.disabledWidth != linewidth) { + linewidth = linePtr->outline.disabledWidth; } } /* @@ -981,7 +980,7 @@ LineInsert(canvas, itemPtr, beforeThis, obj) Tcl_Obj *obj; /* New coordinates to be inserted. */ { LineItem *linePtr = (LineItem *) itemPtr; - int length, argc, i; + int length, objc, i; double *new, *coordPtr; Tk_State state = itemPtr->state; Tcl_Obj **objv; @@ -990,8 +989,8 @@ LineInsert(canvas, itemPtr, beforeThis, obj) state = ((TkCanvas *)canvas)->canvas_state; } - if (!obj || (Tcl_ListObjGetElements((Tcl_Interp *) NULL, obj, &argc, &objv) != TCL_OK) - || !argc || argc&1) { + if (!obj || (Tcl_ListObjGetElements((Tcl_Interp *) NULL, obj, &objc, &objv) != TCL_OK) + || !objc || objc&1) { return; } length = 2*linePtr->numPoints; @@ -1009,11 +1008,11 @@ LineInsert(canvas, itemPtr, beforeThis, obj) linePtr->coordPtr[length-2] = linePtr->lastArrowPtr[0]; linePtr->coordPtr[length-1] = linePtr->lastArrowPtr[1]; } - new = (double *) ckalloc((unsigned)(sizeof(double) * (length + argc))); + new = (double *) ckalloc((unsigned)(sizeof(double) * (length + objc))); for(i=0; icoordPtr[i]; } - for(i=0; iinterp); @@ -1023,11 +1022,11 @@ LineInsert(canvas, itemPtr, beforeThis, obj) } for(i=beforeThis; icoordPtr[i]; + new[i+objc] = linePtr->coordPtr[i]; } if(linePtr->coordPtr) ckfree((char *)linePtr->coordPtr); linePtr->coordPtr = new; - linePtr->numPoints = (length + argc)/2; + linePtr->numPoints = (length + objc)/2; if ((length>3) && (state != TK_STATE_HIDDEN)) { /* @@ -1040,14 +1039,14 @@ LineInsert(canvas, itemPtr, beforeThis, obj) */ itemPtr->redraw_flags |= TK_ITEM_DONT_REDRAW; - if (beforeThis>0) {beforeThis -= 2; argc+=2; } - if ((beforeThis+argc)0) {beforeThis -= 2; objc+=2; } + if ((beforeThis+objc)smooth) { if(beforeThis>0) { - beforeThis-=2; argc+=2; + beforeThis-=2; objc+=2; } - if((beforeThis+argc+2)x1 = itemPtr->x2 = (int) linePtr->coordPtr[beforeThis]; @@ -1059,7 +1058,7 @@ LineInsert(canvas, itemPtr, beforeThis, obj) TkIncludePoint(itemPtr, coordPtr); } } - if ((linePtr->lastArrowPtr != NULL) && ((beforeThis+argc)>=length)) { + if ((linePtr->lastArrowPtr != NULL) && ((beforeThis+objc)>=length)) { /* include old last arrow */ for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { @@ -1067,7 +1066,7 @@ LineInsert(canvas, itemPtr, beforeThis, obj) } } coordPtr = linePtr->coordPtr+beforeThis+2; - for(i=2; ilastArrowPtr != NULL) && ((beforeThis+argc)<(length-2))) { + if ((linePtr->lastArrowPtr != NULL) && ((beforeThis+objc)<(length-2))) { /* include new right arrow */ for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { @@ -1873,7 +1872,7 @@ ParseArrowShape(clientData, interp, tkwin, value, recordPtr, offset) LineItem *linePtr = (LineItem *) recordPtr; double a, b, c; int argc; - char **argv = NULL; + CONST char **argv = NULL; if (offset != Tk_Offset(LineItem, arrowShapeA)) { panic("ParseArrowShape received bogus offset"); @@ -2466,4 +2465,3 @@ ArrowheadPostscript(interp, canvas, linePtr, arrowPtr) } return TCL_OK; } - diff --git a/tk/generic/tkCanvPoly.c b/tk/generic/tkCanvPoly.c index 60616e173b9..58ffab55090 100644 --- a/tk/generic/tkCanvPoly.c +++ b/tk/generic/tkCanvPoly.c @@ -165,11 +165,11 @@ static Tk_ConfigSpec configSpecs[] = { static void ComputePolygonBbox _ANSI_ARGS_((Tk_Canvas canvas, PolygonItem *polyPtr)); static int ConfigurePolygon _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int argc, - Tcl_Obj *CONST argv[], int flags)); + Tk_Canvas canvas, Tk_Item *itemPtr, int objc, + Tcl_Obj *CONST objv[], int flags)); static int CreatePolygon _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, - int argc, Tcl_Obj *CONST argv[])); + int objc, Tcl_Obj *CONST objv[])); static void DeletePolygon _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, Display *display)); static void DisplayPolygon _ANSI_ARGS_((Tk_Canvas canvas, @@ -180,7 +180,7 @@ static int GetPolygonIndex _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *obj, int *indexPtr)); static int PolygonCoords _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, - int argc, Tcl_Obj *CONST argv[])); + int objc, Tcl_Obj *CONST objv[])); static void PolygonDeleteCoords _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, int first, int last)); static void PolygonInsert _ANSI_ARGS_((Tk_Canvas canvas, @@ -255,13 +255,13 @@ Tk_ItemType tkPolygonType = { */ static int -CreatePolygon(interp, canvas, itemPtr, argc, argv) +CreatePolygon(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_Canvas canvas; /* Canvas to hold new item. */ Tk_Item *itemPtr; /* Record to hold new item; header * has been initialized by caller. */ - int argc; /* Number of arguments in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing polygon. */ + int objc; /* Number of arguments in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing polygon. */ { PolygonItem *polyPtr = (PolygonItem *) itemPtr; int i; @@ -296,18 +296,17 @@ CreatePolygon(interp, canvas, itemPtr, argc, argv) * start with a digit or a minus sign followed by a digit. */ - for (i = 0; i < argc; i++) { - char *arg = Tcl_GetStringFromObj((Tcl_Obj *) argv[i], NULL); - if ((arg[0] == '-') && (arg[1] >= 'a') - && (arg[1] <= 'z')) { + for (i = 0; i < objc; i++) { + char *arg = Tcl_GetString(objv[i]); + if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) { break; } } - if (i && PolygonCoords(interp, canvas, itemPtr, i, argv) != TCL_OK) { + if (i && PolygonCoords(interp, canvas, itemPtr, i, objv) != TCL_OK) { goto error; } - if (ConfigurePolygon(interp, canvas, itemPtr, argc-i, argv+i, 0) + if (ConfigurePolygon(interp, canvas, itemPtr, objc-i, objv+i, 0) == TCL_OK) { return TCL_OK; } @@ -336,20 +335,20 @@ CreatePolygon(interp, canvas, itemPtr, argc, argv) */ static int -PolygonCoords(interp, canvas, itemPtr, argc, argv) +PolygonCoords(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Used for error reporting. */ Tk_Canvas canvas; /* Canvas containing item. */ Tk_Item *itemPtr; /* Item whose coordinates are to be * read or modified. */ - int argc; /* Number of coordinates supplied in - * argv. */ - Tcl_Obj *CONST argv[]; /* Array of coordinates: x1, y1, + int objc; /* Number of coordinates supplied in + * objv. */ + Tcl_Obj *CONST objv[]; /* Array of coordinates: x1, y1, * x2, y2, ... */ { PolygonItem *polyPtr = (PolygonItem *) itemPtr; int i, numPoints; - if (argc == 0) { + if (objc == 0) { /* * Print the coords used to create the polygon. If we auto * closed the polygon then we don't report the last point. @@ -362,19 +361,19 @@ PolygonCoords(interp, canvas, itemPtr, argc, argv) Tcl_SetObjResult(interp, obj); return TCL_OK; } - if (argc == 1) { - if (Tcl_ListObjGetElements(interp, argv[0], &argc, - (Tcl_Obj ***) &argv) != TCL_OK) { + if (objc == 1) { + if (Tcl_ListObjGetElements(interp, objv[0], &objc, + (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; } } - if (argc & 1) { + if (objc & 1) { Tcl_AppendResult(interp, "odd number of coordinates specified for polygon", (char *) NULL); return TCL_ERROR; } else { - numPoints = argc/2; + numPoints = objc/2; if (polyPtr->pointsAllocated <= numPoints) { if (polyPtr->coordPtr != NULL) { ckfree((char *) polyPtr->coordPtr); @@ -386,11 +385,11 @@ PolygonCoords(interp, canvas, itemPtr, argc, argv) */ polyPtr->coordPtr = (double *) ckalloc((unsigned) - (sizeof(double) * (argc+2))); + (sizeof(double) * (objc+2))); polyPtr->pointsAllocated = numPoints+1; } - for (i = argc-1; i >= 0; i--) { - if (Tk_CanvasGetCoordFromObj(interp, canvas, argv[i], + for (i = objc-1; i >= 0; i--) { + if (Tk_CanvasGetCoordFromObj(interp, canvas, objv[i], &polyPtr->coordPtr[i]) != TCL_OK) { return TCL_ERROR; } @@ -402,12 +401,12 @@ PolygonCoords(interp, canvas, itemPtr, argc, argv) * Close the polygon if it isn't already closed. */ - if (argc>2 && ((polyPtr->coordPtr[argc-2] != polyPtr->coordPtr[0]) - || (polyPtr->coordPtr[argc-1] != polyPtr->coordPtr[1]))) { + if (objc>2 && ((polyPtr->coordPtr[objc-2] != polyPtr->coordPtr[0]) + || (polyPtr->coordPtr[objc-1] != polyPtr->coordPtr[1]))) { polyPtr->autoClosed = 1; polyPtr->numPoints++; - polyPtr->coordPtr[argc] = polyPtr->coordPtr[0]; - polyPtr->coordPtr[argc+1] = polyPtr->coordPtr[1]; + polyPtr->coordPtr[objc] = polyPtr->coordPtr[0]; + polyPtr->coordPtr[objc+1] = polyPtr->coordPtr[1]; } ComputePolygonBbox(canvas, polyPtr); } @@ -434,12 +433,12 @@ PolygonCoords(interp, canvas, itemPtr, argc, argv) */ static int -ConfigurePolygon(interp, canvas, itemPtr, argc, argv, flags) +ConfigurePolygon(interp, canvas, itemPtr, objc, objv, flags) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_Canvas canvas; /* Canvas containing itemPtr. */ Tk_Item *itemPtr; /* Polygon item to reconfigure. */ - int argc; /* Number of elements in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing things to configure. */ + int objc; /* Number of elements in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing things to configure. */ int flags; /* Flags to pass to Tk_ConfigureWidget. */ { PolygonItem *polyPtr = (PolygonItem *) itemPtr; @@ -452,8 +451,8 @@ ConfigurePolygon(interp, canvas, itemPtr, argc, argv, flags) Tk_State state; tkwin = Tk_CanvasTkwin(canvas); - if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, (char **) argv, - (char *) polyPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { + if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, + (CONST char **) objv, (char *) polyPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } @@ -1022,7 +1021,7 @@ PolygonInsert(canvas, itemPtr, beforeThis, obj) Tcl_Obj *obj; /* New coordinates to be inserted. */ { PolygonItem *polyPtr = (PolygonItem *) itemPtr; - int length, argc, i; + int length, objc, i; Tcl_Obj **objv; double *new; Tk_State state = itemPtr->state; @@ -1031,18 +1030,18 @@ PolygonInsert(canvas, itemPtr, beforeThis, obj) state = ((TkCanvas *)canvas)->canvas_state; } - if (!obj || (Tcl_ListObjGetElements((Tcl_Interp *) NULL, obj, &argc, &objv) != TCL_OK) - || !argc || argc&1) { + if (!obj || (Tcl_ListObjGetElements((Tcl_Interp *) NULL, obj, &objc, &objv) != TCL_OK) + || !objc || objc&1) { return; } length = 2*(polyPtr->numPoints - polyPtr->autoClosed); while(beforeThis>length) beforeThis-=length; while(beforeThis<0) beforeThis+=length; - new = (double *) ckalloc((unsigned)(sizeof(double) * (length + 2 + argc))); + new = (double *) ckalloc((unsigned)(sizeof(double) * (length + 2 + objc))); for (i=0; icoordPtr[i]; } - for (i=0; icoordPtr[i]; + new[i+objc] = polyPtr->coordPtr[i]; } if(polyPtr->coordPtr) ckfree((char *) polyPtr->coordPtr); - length+=argc; + length+=objc; polyPtr->coordPtr = new; polyPtr->numPoints = (length/2) + polyPtr->autoClosed; @@ -1078,7 +1077,7 @@ PolygonInsert(canvas, itemPtr, beforeThis, obj) new[length] = new[0]; new[length+1] = new[1]; - if (((length-argc)>3) && (state != TK_STATE_HIDDEN)) { + if (((length-objc)>3) && (state != TK_STATE_HIDDEN)) { /* * This is some optimizing code that will result that only the part * of the polygon that changed (and the objects that are overlapping @@ -1101,11 +1100,11 @@ PolygonInsert(canvas, itemPtr, beforeThis, obj) itemPtr->x1 = itemPtr->x2 = (int) polyPtr->coordPtr[beforeThis]; itemPtr->y1 = itemPtr->y2 = (int) polyPtr->coordPtr[beforeThis+1]; - beforeThis-=2; argc+=4; + beforeThis-=2; objc+=4; if(polyPtr->smooth) { - beforeThis-=2; argc+=4; + beforeThis-=2; objc+=4; } /* be carefull; beforeThis could now be negative */ - for(i=beforeThis; i=length) j-=length; @@ -1485,21 +1484,16 @@ PolygonToArea(canvas, itemPtr, rectPtr) polyPoints = polyPtr->coordPtr; } - if (polyPtr->fillGC != None) { - inside = TkPolygonToArea(polyPoints, numPoints, rectPtr); - if (inside==0) goto donearea; - } else { - if ((polyPoints[0] >= rectPtr[0]) - && (polyPoints[0] <= rectPtr[2]) - && (polyPoints[1] >= rectPtr[1]) - && (polyPoints[1] <= rectPtr[3])) { - inside = 1; - } - } + /* + * Simple test to see if we are in the polygon. Polygons are + * different from othe canvas items in that they register points + * being inside even if it isn't filled. + */ + inside = TkPolygonToArea(polyPoints, numPoints, rectPtr); + if (inside==0) goto donearea; if (polyPtr->outline.gc == None) goto donearea ; - /* * Iterate through all of the edges of the line, computing a polygon * for each edge and testing the area against that polygon. In @@ -1932,5 +1926,3 @@ PolygonToPostscript(interp, canvas, itemPtr, prepass) } return TCL_OK; } - - diff --git a/tk/generic/tkCanvPs.c b/tk/generic/tkCanvPs.c index 66b1cc9d7df..18ffd3ab6fb 100644 --- a/tk/generic/tkCanvPs.c +++ b/tk/generic/tkCanvPs.c @@ -115,320 +115,6 @@ static Tk_ConfigSpec configSpecs[] = { (char *) NULL, 0, 0} }; -/* - * The prolog data. Generated by str2c from prolog.ps - * This was split in small chunks by str2c because - * some C compiler have limitations on the size of static strings. - * (str2c is a small tcl script in tcl's tool directory (source release)) - */ -static CONST char * CONST prolog[]= { - /* Start of part 1 (2000 characters) */ - "%%BeginProlog\n\ -50 dict begin\n\ -\n\ -% This is a standard prolog for Postscript generated by Tk's canvas\n\ -% widget.\n\ -% RCS: @(#) $Id$\n\ -\n\ -% The definitions below just define all of the variables used in\n\ -% any of the procedures here. This is needed for obscure reasons\n\ -% explained on p. 716 of the Postscript manual (Section H.2.7,\n\ -% \"Initializing Variables,\" in the section on Encapsulated Postscript).\n\ -\n\ -/baseline 0 def\n\ -/stipimage 0 def\n\ -/height 0 def\n\ -/justify 0 def\n\ -/lineLength 0 def\n\ -/spacing 0 def\n\ -/stipple 0 def\n\ -/strings 0 def\n\ -/xoffset 0 def\n\ -/yoffset 0 def\n\ -/tmpstip null def\n\ -\n\ -% Define the array ISOLatin1Encoding (which specifies how characters are\n\ -% encoded for ISO-8859-1 fonts), if it isn't already present (Postscript\n\ -% level 2 is supposed to define it, but level 1 doesn't).\n\ -\n\ -systemdict /ISOLatin1Encoding known not {\n\ - /ISOLatin1Encoding [\n\ - /space /space /space /space /space /space /space /space\n\ - /space /space /space /space /space /space /space /space\n\ - /space /space /space /space /space /space /space /space\n\ - /space /space /space /space /space /space /space /space\n\ - /space /exclam /quotedbl /numbersign /dollar /percent /ampersand\n\ - /quoteright\n\ - /parenleft /parenright /asterisk /plus /comma /minus /period /slash\n\ - /zero /one /two /three /four /five /six /seven\n\ - /eight /nine /colon /semicolon /less /equal /greater /question\n\ - /at /A /B /C /D /E /F /G\n\ - /H /I /J /K /L /M /N /O\n\ - /P /Q /R /S /T /U /V /W\n\ - /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore\n\ - /quoteleft /a /b /c /d /e /f /g\n\ - /h /i /j /k /l /m /n /o\n\ - /p /q /r /s /t /u /v /w\n\ - /x /y /z /braceleft /bar /braceright /asciitilde /space\n\ - /space /space /space /space /space /space /space /space\n\ - /space /space /space /space /space /space /space /space\n\ - /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent\n\ - /dieresis /space /ring /cedilla /space /hungarumlaut /ogonek /caron\n\ - /space /exclamdown /cent /sterling /currency /yen /brokenbar /section\n\ - /dieresis /copyright /ordfem", - /* End of part 1 */ - - /* Start of part 2 (2000 characters) */ - "inine /guillemotleft /logicalnot /hyphen\n\ - /registered /macron\n\ - /degree /plusminus /twosuperior /threesuperior /acute /mu /paragraph\n\ - /periodcentered\n\ - /cedillar /onesuperior /ordmasculine /guillemotright /onequarter\n\ - /onehalf /threequarters /questiondown\n\ - /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla\n\ - /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex\n\ - /Idieresis\n\ - /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply\n\ - /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn\n\ - /germandbls\n\ - /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla\n\ - /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex\n\ - /idieresis\n\ - /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide\n\ - /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn\n\ - /ydieresis\n\ - ] def\n\ -} if\n\ -\n\ -% font ISOEncode font\n\ -% This procedure changes the encoding of a font from the default\n\ -% Postscript encoding to ISOLatin1. It's typically invoked just\n\ -% before invoking \"setfont\". The body of this procedure comes from\n\ -% Section 5.6.1 of the Postscript book.\n\ -\n\ -/ISOEncode {\n\ - dup length dict begin\n\ - {1 index /FID ne {def} {pop pop} ifelse} forall\n\ - /Encoding ISOLatin1Encoding def\n\ - currentdict\n\ - end\n\ -\n\ - % I'm not sure why it's necessary to use \"definefont\" on this new\n\ - % font, but it seems to be important; just use the name \"Temporary\"\n\ - % for the font.\n\ -\n\ - /Temporary exch definefont\n\ -} bind def\n\ -\n\ -% StrokeClip\n\ -%\n\ -% This procedure converts the current path into a clip area under\n\ -% the assumption of stroking. It's a bit tricky because some Postscript\n\ -% interpreters get errors during strokepath for dashed lines. If\n\ -% this happens then turn off dashes and try again.\n\ -\n\ -/StrokeClip {\n\ - {strokepath} stopped {\n\ - (This Postscript printer gets limitcheck overflows when) =\n\ - (stippling dashed lines; lines will be printed solid instead.) =\n\ - [] 0 setdash strokepath} if\n\ - clip\n\ -} bind def\n\ -\n\ -% d", - /* End of part 2 */ - - /* Start of part 3 (2000 characters) */ - "esiredSize EvenPixels closestSize\n\ -%\n\ -% The procedure below is used for stippling. Given the optimal size\n\ -% of a dot in a stipple pattern in the current user coordinate system,\n\ -% compute the closest size that is an exact multiple of the device's\n\ -% pixel size. This allows stipple patterns to be displayed without\n\ -% aliasing effects.\n\ -\n\ -/EvenPixels {\n\ - % Compute exact number of device pixels per stipple dot.\n\ - dup 0 matrix currentmatrix dtransform\n\ - dup mul exch dup mul add sqrt\n\ -\n\ - % Round to an integer, make sure the number is at least 1, and compute\n\ - % user coord distance corresponding to this.\n\ - dup round dup 1 lt {pop 1} if\n\ - exch div mul\n\ -} bind def\n\ -\n\ -% width height string StippleFill --\n\ -%\n\ -% Given a path already set up and a clipping region generated from\n\ -% it, this procedure will fill the clipping region with a stipple\n\ -% pattern. \"String\" contains a proper image description of the\n\ -% stipple pattern and \"width\" and \"height\" give its dimensions. Each\n\ -% stipple dot is assumed to be about one unit across in the current\n\ -% user coordinate system. This procedure trashes the graphics state.\n\ -\n\ -/StippleFill {\n\ - % The following code is needed to work around a NeWSprint bug.\n\ -\n\ - /tmpstip 1 index def\n\ -\n\ - % Change the scaling so that one user unit in user coordinates\n\ - % corresponds to the size of one stipple dot.\n\ - 1 EvenPixels dup scale\n\ -\n\ - % Compute the bounding box occupied by the path (which is now\n\ - % the clipping region), and round the lower coordinates down\n\ - % to the nearest starting point for the stipple pattern. Be\n\ - % careful about negative numbers, since the rounding works\n\ - % differently on them.\n\ -\n\ - pathbbox\n\ - 4 2 roll\n\ - 5 index div dup 0 lt {1 sub} if cvi 5 index mul 4 1 roll\n\ - 6 index div dup 0 lt {1 sub} if cvi 6 index mul 3 2 roll\n\ -\n\ - % Stack now: width height string y1 y2 x1 x2\n\ - % Below is a doubly-nested for loop to iterate across this area\n\ - % in units of the stipple pattern size, going up columns then\n\ - % acr", - /* End of part 3 */ - - /* Start of part 4 (2000 characters) */ - "oss rows, blasting out a stipple-pattern-sized rectangle at\n\ - % each position\n\ -\n\ - 6 index exch {\n\ - 2 index 5 index 3 index {\n\ - % Stack now: width height string y1 y2 x y\n\ -\n\ - gsave\n\ - 1 index exch translate\n\ - 5 index 5 index true matrix tmpstip imagemask\n\ - grestore\n\ - } for\n\ - pop\n\ - } for\n\ - pop pop pop pop pop\n\ -} bind def\n\ -\n\ -% -- AdjustColor --\n\ -% Given a color value already set for output by the caller, adjusts\n\ -% that value to a grayscale or mono value if requested by the CL\n\ -% variable.\n\ -\n\ -/AdjustColor {\n\ - CL 2 lt {\n\ - currentgray\n\ - CL 0 eq {\n\ - .5 lt {0} {1} ifelse\n\ - } if\n\ - setgray\n\ - } if\n\ -} bind def\n\ -\n\ -% x y strings spacing xoffset yoffset justify stipple DrawText --\n\ -% This procedure does all of the real work of drawing text. The\n\ -% color and font must already have been set by the caller, and the\n\ -% following arguments must be on the stack:\n\ -%\n\ -% x, y - Coordinates at which to draw text.\n\ -% strings - An array of strings, one for each line of the text item,\n\ -% in order from top to bottom.\n\ -% spacing - Spacing between lines.\n\ -% xoffset - Horizontal offset for text bbox relative to x and y: 0 for\n\ -% nw/w/sw anchor, -0.5 for n/center/s, and -1.0 for ne/e/se.\n\ -% yoffset - Vertical offset for text bbox relative to x and y: 0 for\n\ -% nw/n/ne anchor, +0.5 for w/center/e, and +1.0 for sw/s/se.\n\ -% justify - 0 for left justification, 0.5 for center, 1 for right justify.\n\ -% stipple - Boolean value indicating whether or not text is to be\n\ -% drawn in stippled fashion. If text is stippled,\n\ -% procedure StippleText must have been defined to call\n\ -% StippleFill in the right way.\n\ -%\n\ -% Also, when this procedure is invoked, the color and font must already\n\ -% have been set for the text.\n\ -\n\ -/DrawText {\n\ - /stipple exch def\n\ - /justify exch def\n\ - /yoffset exch def\n\ - /xoffset exch def\n\ - /spacing exch def\n\ - /strings exch def\n\ -\n\ - % First scan through all of the text to find the widest line.\n\ -\n\ - /lineLength 0 def\n\ - strings {\n\ - stringwidth pop\n\ - dup lineLength gt {/lineLength exch def}", - /* End of part 4 */ - - /* Start of part 5 (1546 characters) */ - " {pop} ifelse\n\ - newpath\n\ - } forall\n\ -\n\ - % Compute the baseline offset and the actual font height.\n\ -\n\ - 0 0 moveto (TXygqPZ) false charpath\n\ - pathbbox dup /baseline exch def\n\ - exch pop exch sub /height exch def pop\n\ - newpath\n\ -\n\ - % Translate coordinates first so that the origin is at the upper-left\n\ - % corner of the text's bounding box. Remember that x and y for\n\ - % positioning are still on the stack.\n\ -\n\ - translate\n\ - lineLength xoffset mul\n\ - strings length 1 sub spacing mul height add yoffset mul translate\n\ -\n\ - % Now use the baseline and justification information to translate so\n\ - % that the origin is at the baseline and positioning point for the\n\ - % first line of text.\n\ -\n\ - justify lineLength mul baseline neg translate\n\ -\n\ - % Iterate over each of the lines to output it. For each line,\n\ - % compute its width again so it can be properly justified, then\n\ - % display it.\n\ -\n\ - strings {\n\ - dup stringwidth pop\n\ - justify neg mul 0 moveto\n\ - stipple {\n\ -\n\ - % The text is stippled, so turn it into a path and print\n\ - % by calling StippledText, which in turn calls StippleFill.\n\ - % Unfortunately, many Postscript interpreters will get\n\ - % overflow errors if we try to do the whole string at\n\ - % once, so do it a character at a time.\n\ -\n\ - gsave\n\ - /char (X) def\n\ - {\n\ - char 0 3 -1 roll put\n\ - currentpoint\n\ - gsave\n\ - char true charpath clip StippleText\n\ - grestore\n\ - char stringwidth translate\n\ - moveto\n\ - } forall\n\ - grestore\n\ - } {show} ifelse\n\ - 0 spacing neg translate\n\ - } forall\n\ -} bind def\n\ -\n\ -%%EndProlog\n\ -", - /* End of part 5 */ - - NULL /* End of data marker */ -}; - /* * Forward declarations for procedures defined later in this file: */ @@ -460,7 +146,7 @@ TkCanvPostscriptCmd(canvasPtr, interp, argc, argv) TkCanvas *canvasPtr; /* Information about canvas widget. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. Caller has + CONST char **argv; /* Argument strings. Caller has * already parsed this command enough * to know that argv[1] is * "postscript". */ @@ -470,7 +156,8 @@ TkCanvPostscriptCmd(canvasPtr, interp, argc, argv) int result; Tk_Item *itemPtr; #define STRING_LENGTH 400 - char string[STRING_LENGTH+1], *p; + char string[STRING_LENGTH+1]; + CONST char *p; time_t now; size_t length; Tk_Window tkwin = canvasPtr->tkwin; @@ -484,7 +171,7 @@ TkCanvPostscriptCmd(canvasPtr, interp, argc, argv) Tcl_HashSearch search; Tcl_HashEntry *hPtr; Tcl_DString buffer; - CONST char * CONST *chunk; + char psenccmd[]="::tk::ensure_psenc_is_loaded"; /* *---------------------------------------------------------------- @@ -492,7 +179,10 @@ TkCanvPostscriptCmd(canvasPtr, interp, argc, argv) * then process all the arguments to fill the data structure in. *---------------------------------------------------------------- */ - + result = Tcl_EvalEx(interp,psenccmd,-1,TCL_EVAL_GLOBAL); + if (result != TCL_OK) { + return result; + } oldInfoPtr = canvasPtr->psInfo; canvasPtr->psInfo = (Tk_PostscriptInfo) &psInfo; psInfo.x = canvasPtr->xOrigin; @@ -717,8 +407,8 @@ TkCanvPostscriptCmd(canvasPtr, interp, argc, argv) */ if (psInfo.prolog) { - Tcl_AppendResult(interp, "%!PS-Adobe-3.0 EPSF-3.0\n", - "%%Creator: Tk Canvas Widget\n", (char *) NULL); + Tcl_AppendResult(interp, "%!PS-Adobe-3.0 EPSF-3.0\n", + "%%Creator: Tk Canvas Widget\n", (char *) NULL); #ifdef HAVE_PW_GECOS if (!Tcl_IsSafe(interp)) { struct passwd *pwPtr = getpwuid(getuid()); /* INTL: Native. */ @@ -768,14 +458,12 @@ TkCanvPostscriptCmd(canvasPtr, interp, argc, argv) /* * Insert the prolog */ - for (chunk=prolog; *chunk; chunk++) { - Tcl_AppendResult(interp, *chunk, (char *) NULL); - } - + Tcl_AppendResult(interp, Tcl_GetVar(interp,"::tk::ps_preamable",TCL_GLOBAL_ONLY), (char *) NULL); if (psInfo.chan != NULL) { - Tcl_Write(psInfo.chan, Tcl_GetStringResult(interp), -1); + Tcl_Write(psInfo.chan, Tcl_GetStringResult(interp), -1); Tcl_ResetResult(canvasPtr->interp); } + /* *----------------------------------------------------------- @@ -967,7 +655,7 @@ Tk_PostscriptColor(interp, psInfo, colorPtr) */ if (psInfoPtr->colorVar != NULL) { - char *cmdString; + CONST char *cmdString; cmdString = Tcl_GetVar2(interp, psInfoPtr->colorVar, Tk_NameOfColor(colorPtr), 0); @@ -1047,10 +735,11 @@ Tk_PostscriptFont(interp, psInfo, tkfont) Tcl_DStringInit(&ds); if (psInfoPtr->fontVar != NULL) { - char *list, **argv; + CONST char *list; int argc; double size; - char *name; + CONST char **argv; + CONST char *name; name = Tk_NameOfFont(tkfont); list = Tcl_GetVar2(interp, psInfoPtr->fontVar, name, 0); @@ -2143,4 +1832,3 @@ Tk_PostscriptPhoto(interp, blockPtr, psInfo, width, height) Tcl_AppendResult(interp, ">\n", (char *) NULL); return TCL_OK; } - diff --git a/tk/generic/tkCanvText.c b/tk/generic/tkCanvText.c index 688d86b6b05..d2ef1b865f3 100644 --- a/tk/generic/tkCanvText.c +++ b/tk/generic/tkCanvText.c @@ -141,10 +141,10 @@ static void ComputeTextBbox _ANSI_ARGS_((Tk_Canvas canvas, TextItem *textPtr)); static int ConfigureText _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int argc, - Tcl_Obj *CONST argv[], int flags)); + Tcl_Obj *CONST objv[], int flags)); static int CreateText _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, - int argc, Tcl_Obj *CONST argv[])); + int argc, Tcl_Obj *CONST objv[])); static void DeleteText _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, Display *display)); static void DisplayCanvText _ANSI_ARGS_((Tk_Canvas canvas, @@ -163,7 +163,7 @@ static void SetTextCursor _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, int index)); static int TextCoords _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, - int argc, Tcl_Obj *CONST argv[])); + int argc, Tcl_Obj *CONST objv[])); static void TextDeleteChars _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, int first, int last)); static void TextInsert _ANSI_ARGS_((Tk_Canvas canvas, @@ -226,30 +226,27 @@ Tk_ItemType tkTextType = { */ static int -CreateText(interp, canvas, itemPtr, argc, argv) +CreateText(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_Canvas canvas; /* Canvas to hold new item. */ Tk_Item *itemPtr; /* Record to hold new item; header has been * initialized by caller. */ - int argc; /* Number of arguments in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing rectangle. */ + int objc; /* Number of arguments in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing rectangle. */ { TextItem *textPtr = (TextItem *) itemPtr; - int i; + int i = 2; - if (argc==1) { + if (objc == 1) { i = 1; - } else { - char *arg = Tcl_GetStringFromObj(argv[1], NULL); - if ((argc>1) && (arg[0] == '-') - && (arg[1] >= 'a') && (arg[1] <= 'z')) { + } else if (objc > 1) { + char *arg = Tcl_GetString(objv[1]); + if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) { i = 1; - } else { - i = 2; } } - if (argc < i) { + if (objc < i) { Tcl_AppendResult(interp, "wrong # args: should be \"", Tk_PathName(Tk_CanvasTkwin(canvas)), " create ", itemPtr->typePtr->name, " x y ?options?\"", (char *) NULL); @@ -293,10 +290,10 @@ CreateText(interp, canvas, itemPtr, argc, argv) * Process the arguments to fill in the item record. */ - if ((TextCoords(interp, canvas, itemPtr, i, argv) != TCL_OK)) { + if ((TextCoords(interp, canvas, itemPtr, i, objv) != TCL_OK)) { goto error; } - if (ConfigureText(interp, canvas, itemPtr, argc-i, argv+i, 0) == TCL_OK) { + if (ConfigureText(interp, canvas, itemPtr, objc-i, objv+i, 0) == TCL_OK) { return TCL_OK; } @@ -324,38 +321,38 @@ CreateText(interp, canvas, itemPtr, argc, argv) */ static int -TextCoords(interp, canvas, itemPtr, argc, argv) +TextCoords(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Used for error reporting. */ Tk_Canvas canvas; /* Canvas containing item. */ Tk_Item *itemPtr; /* Item whose coordinates are to be read or * modified. */ - int argc; /* Number of coordinates supplied in argv. */ - Tcl_Obj *CONST argv[]; /* Array of coordinates: x1, y1, x2, y2, ... */ + int objc; /* Number of coordinates supplied in objv. */ + Tcl_Obj *CONST objv[]; /* Array of coordinates: x1, y1, x2, y2, ... */ { TextItem *textPtr = (TextItem *) itemPtr; - if (argc == 0) { + if (objc == 0) { Tcl_Obj *obj = Tcl_NewObj(); Tcl_Obj *subobj = Tcl_NewDoubleObj(textPtr->x); Tcl_ListObjAppendElement(interp, obj, subobj); subobj = Tcl_NewDoubleObj(textPtr->y); Tcl_ListObjAppendElement(interp, obj, subobj); Tcl_SetObjResult(interp, obj); - } else if (argc < 3) { - if (argc==1) { - if (Tcl_ListObjGetElements(interp, argv[0], &argc, - (Tcl_Obj ***) &argv) != TCL_OK) { + } else if (objc < 3) { + if (objc==1) { + if (Tcl_ListObjGetElements(interp, objv[0], &objc, + (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; - } else if (argc != 2) { + } else if (objc != 2) { char buf[64 + TCL_INTEGER_SPACE]; - sprintf(buf, "wrong # coordinates: expected 2, got %d", argc); + sprintf(buf, "wrong # coordinates: expected 2, got %d", objc); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_ERROR; } } - if ((Tk_CanvasGetCoordFromObj(interp, canvas, argv[0], &textPtr->x) != TCL_OK) - || (Tk_CanvasGetCoordFromObj(interp, canvas, argv[1], + if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], &textPtr->x) != TCL_OK) + || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], &textPtr->y) != TCL_OK)) { return TCL_ERROR; } @@ -363,7 +360,7 @@ TextCoords(interp, canvas, itemPtr, argc, argv) } else { char buf[64 + TCL_INTEGER_SPACE]; - sprintf(buf, "wrong # coordinates: expected 0 or 2, got %d", argc); + sprintf(buf, "wrong # coordinates: expected 0 or 2, got %d", objc); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_ERROR; } @@ -390,12 +387,12 @@ TextCoords(interp, canvas, itemPtr, argc, argv) */ static int -ConfigureText(interp, canvas, itemPtr, argc, argv, flags) +ConfigureText(interp, canvas, itemPtr, objc, objv, flags) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_Canvas canvas; /* Canvas containing itemPtr. */ Tk_Item *itemPtr; /* Rectangle item to reconfigure. */ - int argc; /* Number of elements in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing things to configure. */ + int objc; /* Number of elements in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing things to configure. */ int flags; /* Flags to pass to Tk_ConfigureWidget. */ { TextItem *textPtr = (TextItem *) itemPtr; @@ -410,8 +407,8 @@ ConfigureText(interp, canvas, itemPtr, argc, argv, flags) Tk_State state; tkwin = Tk_CanvasTkwin(canvas); - if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, (char **) argv, - (char *) textPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { + if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, + (CONST char **) objv, (char *) textPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } @@ -638,8 +635,8 @@ ComputeTextBbox(canvas, textPtr) * of the bounding box for the text item. */ - leftX = (int) (textPtr->x + 0.5); - topY = (int) (textPtr->y + 0.5); + leftX = (int) floor(textPtr->x + 0.5); + topY = (int) floor(textPtr->y + 0.5); switch (textPtr->anchor) { case TK_ANCHOR_NW: case TK_ANCHOR_N: @@ -774,7 +771,7 @@ DisplayCanvText(canvas, itemPtr, display, drawable, x, y, width, height) } if ((selFirstChar >= 0) && (selFirstChar <= selLastChar)) { int xFirst, yFirst, hFirst; - int xLast, yLast; + int xLast, yLast, wLast; /* * Draw a special background under the selection. @@ -783,7 +780,7 @@ DisplayCanvText(canvas, itemPtr, display, drawable, x, y, width, height) Tk_CharBbox(textPtr->textLayout, selFirstChar, &xFirst, &yFirst, NULL, &hFirst); Tk_CharBbox(textPtr->textLayout, selLastChar, &xLast, &yLast, - NULL, NULL); + &wLast, NULL); /* * If the selection spans the end of this line, then display @@ -796,7 +793,7 @@ DisplayCanvText(canvas, itemPtr, display, drawable, x, y, width, height) height = hFirst; for (y = yFirst ; y <= yLast; y += height) { if (y == yLast) { - width = xLast - x; + width = xLast + wLast - x; } else { width = textPtr->rightEdge - textPtr->leftEdge - x; } @@ -831,6 +828,8 @@ DisplayCanvText(canvas, itemPtr, display, drawable, x, y, width, height) - (textInfoPtr->insertWidth / 2)), (double) (textPtr->header.y1 + y), &drawableX, &drawableY); + Tk_SetCaretPos(Tk_CanvasTkwin(canvas), drawableX, drawableY, + height); if (textInfoPtr->cursorOn) { Tk_Fill3DRectangle(Tk_CanvasTkwin(canvas), drawable, textInfoPtr->insertBorder, @@ -1379,7 +1378,8 @@ GetSelText(canvas, itemPtr, offset, buffer, maxBytes) { TextItem *textPtr = (TextItem *) itemPtr; int byteCount; - char *text, *selStart, *selEnd; + char *text; + CONST char *selStart, *selEnd; Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; if ((textInfoPtr->selectFirst < 0) || @@ -1513,4 +1513,3 @@ TextToPostscript(interp, canvas, itemPtr, prepass) return TCL_OK; } - diff --git a/tk/generic/tkCanvUtil.c b/tk/generic/tkCanvUtil.c index 0abf9665574..50594016940 100644 --- a/tk/generic/tkCanvUtil.c +++ b/tk/generic/tkCanvUtil.c @@ -189,7 +189,7 @@ int Tk_CanvasGetCoord(interp, canvas, string, doublePtr) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_Canvas canvas; /* Canvas to which coordinate applies. */ - char *string; /* Describes coordinate (any screen + CONST char *string; /* Describes coordinate (any screen * coordinate form may be used here). */ double *doublePtr; /* Place to store converted coordinate. */ { @@ -369,14 +369,14 @@ Tk_CanvasTagsParseProc(clientData, interp, tkwin, value, widgRec, offset) ClientData clientData; /* Not used.*/ Tcl_Interp *interp; /* Used for reporting errors. */ Tk_Window tkwin; /* Window containing canvas widget. */ - char *value; /* Value of option (list of tag + 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; int argc, i; - char **argv; + CONST char **argv; Tk_Uid *newPtr; /* @@ -454,7 +454,7 @@ Tk_CanvasTagsPrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) return (char *) itemPtr->tagPtr[0]; } *freeProcPtr = TCL_DYNAMIC; - return Tcl_Merge(itemPtr->numTags, (char **) itemPtr->tagPtr); + return Tcl_Merge(itemPtr->numTags, (CONST char **) itemPtr->tagPtr); } @@ -706,8 +706,15 @@ TkSmoothParseProc(clientData, interp, tkwin, value, widgRec, offset) if (smooth) { *smoothPtr = smooth; return TCL_OK; + } else if (strncmp(value, tkBezierSmoothMethod.name, length) == 0) { + /* + * We need to do handle the built-in bezier method. + */ + *smoothPtr = &tkBezierSmoothMethod; + return TCL_OK; } + if (Tcl_GetBoolean(interp, (char *) value, &b) != TCL_OK) { return TCL_ERROR; } @@ -777,7 +784,7 @@ Tk_GetDash(interp, value, dash) * store dash information. */ { int argc, i; - char **largv, **argv = NULL; + CONST char **largv, **argv = NULL; char *pt; if ((value==(char *) NULL) || (*value==0) ) { @@ -1472,4 +1479,3 @@ DashConvert (l, p, n, width) } return result; } - diff --git a/tk/generic/tkCanvWind.c b/tk/generic/tkCanvWind.c index 8a452b70d39..af18628a888 100644 --- a/tk/generic/tkCanvWind.c +++ b/tk/generic/tkCanvWind.c @@ -75,11 +75,11 @@ static Tk_ConfigSpec configSpecs[] = { static void ComputeWindowBbox _ANSI_ARGS_((Tk_Canvas canvas, WindowItem *winItemPtr)); static int ConfigureWinItem _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int argc, - Tcl_Obj *CONST argv[], int flags)); + Tk_Canvas canvas, Tk_Item *itemPtr, int objc, + Tcl_Obj *CONST objv[], int flags)); static int CreateWinItem _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, - int argc, Tcl_Obj *CONST argv[])); + int objc, Tcl_Obj *CONST objv[])); static void DeleteWinItem _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, Display *display)); static void DisplayWinItem _ANSI_ARGS_((Tk_Canvas canvas, @@ -91,8 +91,8 @@ static void ScaleWinItem _ANSI_ARGS_((Tk_Canvas canvas, static void TranslateWinItem _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, double deltaX, double deltaY)); static int WinItemCoords _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int argc, - Tcl_Obj *CONST argv[])); + Tk_Canvas canvas, Tk_Item *itemPtr, int objc, + Tcl_Obj *CONST objv[])); static void WinItemLostSlaveProc _ANSI_ARGS_(( ClientData clientData, Tk_Window tkwin)); static void WinItemRequestProc _ANSI_ARGS_((ClientData clientData, @@ -175,30 +175,27 @@ static Tk_GeomMgr canvasGeomType = { */ static int -CreateWinItem(interp, canvas, itemPtr, argc, argv) +CreateWinItem(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_Canvas canvas; /* Canvas to hold new item. */ Tk_Item *itemPtr; /* Record to hold new item; header * has been initialized by caller. */ - int argc; /* Number of arguments in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing window. */ + int objc; /* Number of arguments in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing window. */ { WindowItem *winItemPtr = (WindowItem *) itemPtr; - int i; + int i = 2; - if (argc==1) { + if (objc == 1) { i = 1; - } else { - char *arg = Tcl_GetStringFromObj(argv[1], NULL); - if (((argc>1) && (arg[0] == '-') - && (arg[1] >= 'a') && (arg[1] <= 'z'))) { + } else if (objc > 1) { + char *arg = Tcl_GetString(objv[1]); + if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) { i = 1; - } else { - i = 2; } } - if (argc < i) { + if (objc < i) { Tcl_AppendResult(interp, "wrong # args: should be \"", Tk_PathName(Tk_CanvasTkwin(canvas)), " create ", itemPtr->typePtr->name, " x y ?options?\"", @@ -220,10 +217,10 @@ CreateWinItem(interp, canvas, itemPtr, argc, argv) * Process the arguments to fill in the item record. */ - if ((WinItemCoords(interp, canvas, itemPtr, i, argv) != TCL_OK)) { + if ((WinItemCoords(interp, canvas, itemPtr, i, objv) != TCL_OK)) { goto error; } - if (ConfigureWinItem(interp, canvas, itemPtr, argc-i, argv+i, 0) == TCL_OK) { + if (ConfigureWinItem(interp, canvas, itemPtr, objc-i, objv+i, 0) == TCL_OK) { return TCL_OK; } @@ -251,40 +248,40 @@ CreateWinItem(interp, canvas, itemPtr, argc, argv) */ static int -WinItemCoords(interp, canvas, itemPtr, argc, argv) +WinItemCoords(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Used for error reporting. */ Tk_Canvas canvas; /* Canvas containing item. */ Tk_Item *itemPtr; /* Item whose coordinates are to be * read or modified. */ - int argc; /* Number of coordinates supplied in - * argv. */ - Tcl_Obj *CONST argv[]; /* Array of coordinates: x1, y1, + int objc; /* Number of coordinates supplied in + * objv. */ + Tcl_Obj *CONST objv[]; /* Array of coordinates: x1, y1, * x2, y2, ... */ { WindowItem *winItemPtr = (WindowItem *) itemPtr; - if (argc == 0) { + if (objc == 0) { Tcl_Obj *obj = Tcl_NewObj(); Tcl_Obj *subobj = Tcl_NewDoubleObj(winItemPtr->x); Tcl_ListObjAppendElement(interp, obj, subobj); subobj = Tcl_NewDoubleObj(winItemPtr->y); Tcl_ListObjAppendElement(interp, obj, subobj); Tcl_SetObjResult(interp, obj); - } else if (argc < 3) { - if (argc==1) { - if (Tcl_ListObjGetElements(interp, argv[0], &argc, - (Tcl_Obj ***) &argv) != TCL_OK) { + } else if (objc < 3) { + if (objc==1) { + if (Tcl_ListObjGetElements(interp, objv[0], &objc, + (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; - } else if (argc != 2) { + } else if (objc != 2) { char buf[64 + TCL_INTEGER_SPACE]; - sprintf(buf, "wrong # coordinates: expected 2, got %d", argc); + sprintf(buf, "wrong # coordinates: expected 2, got %d", objc); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_ERROR; } } - if ((Tk_CanvasGetCoordFromObj(interp, canvas, argv[0], &winItemPtr->x) - != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp, canvas, argv[1], + if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], &winItemPtr->x) + != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], &winItemPtr->y) != TCL_OK)) { return TCL_ERROR; } @@ -292,7 +289,7 @@ WinItemCoords(interp, canvas, itemPtr, argc, argv) } else { char buf[64 + TCL_INTEGER_SPACE]; - sprintf(buf, "wrong # coordinates: expected 0 or 2, got %d", argc); + sprintf(buf, "wrong # coordinates: expected 0 or 2, got %d", objc); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_ERROR; } @@ -318,12 +315,12 @@ WinItemCoords(interp, canvas, itemPtr, argc, argv) */ static int -ConfigureWinItem(interp, canvas, itemPtr, argc, argv, flags) +ConfigureWinItem(interp, canvas, itemPtr, objc, objv, flags) Tcl_Interp *interp; /* Used for error reporting. */ Tk_Canvas canvas; /* Canvas containing itemPtr. */ Tk_Item *itemPtr; /* Window item to reconfigure. */ - int argc; /* Number of elements in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing things to configure. */ + int objc; /* Number of elements in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing things to configure. */ int flags; /* Flags to pass to Tk_ConfigureWidget. */ { WindowItem *winItemPtr = (WindowItem *) itemPtr; @@ -332,8 +329,8 @@ ConfigureWinItem(interp, canvas, itemPtr, argc, argv, flags) oldWindow = winItemPtr->tkwin; canvasTkwin = Tk_CanvasTkwin(canvas); - if (Tk_ConfigureWidget(interp, canvasTkwin, configSpecs, argc, (char **) argv, - (char *) winItemPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { + if (TCL_OK != Tk_ConfigureWidget(interp, canvasTkwin, configSpecs, objc, + (CONST char **) objv, (char *) winItemPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } @@ -356,7 +353,7 @@ ConfigureWinItem(interp, canvas, itemPtr, argc, argv, flags) /* * Make sure that the canvas is either the parent of the * window associated with the item or a descendant of that - * parent. Also, don't allow a top-level window to be + * parent. Also, don't allow a top-of-hierarchy window to be * managed inside a canvas. */ @@ -366,7 +363,7 @@ ConfigureWinItem(interp, canvas, itemPtr, argc, argv, flags) if (ancestor == parent) { break; } - if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_LEVEL) { + if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_HIERARCHY) { badWindow: Tcl_AppendResult(interp, "can't use ", Tk_PathName(winItemPtr->tkwin), @@ -375,7 +372,7 @@ ConfigureWinItem(interp, canvas, itemPtr, argc, argv, flags) return TCL_ERROR; } } - if (((Tk_FakeWin *) (winItemPtr->tkwin))->flags & TK_TOP_LEVEL) { + if (((Tk_FakeWin *) (winItemPtr->tkwin))->flags & TK_TOP_HIERARCHY) { goto badWindow; } if (winItemPtr->tkwin == canvasTkwin) { @@ -1101,4 +1098,3 @@ WinItemLostSlaveProc(clientData, tkwin) Tk_UnmapWindow(winItemPtr->tkwin); winItemPtr->tkwin = NULL; } - diff --git a/tk/generic/tkCanvas.c b/tk/generic/tkCanvas.c index aea03485631..089ee3398a3 100644 --- a/tk/generic/tkCanvas.c +++ b/tk/generic/tkCanvas.c @@ -291,7 +291,7 @@ static int FindArea _ANSI_ARGS_((Tcl_Interp *interp, TkCanvas *canvasPtr, Tcl_Obj *CONST *argv, Tk_Uid uid, int enclosed)); static double GridAlign _ANSI_ARGS_((double coord, double spacing)); -static char** GetStringsFromObjs _ANSI_ARGS_((int argc, +static CONST char** GetStringsFromObjs _ANSI_ARGS_((int argc, Tcl_Obj *CONST *objv)); static void InitCanvas _ANSI_ARGS_((void)); #ifdef USE_OLD_TAG_SEARCH @@ -299,9 +299,8 @@ static Tk_Item * NextItem _ANSI_ARGS_((TagSearch *searchPtr)); #endif /* USE_OLD_TAG_SEARCH */ static void PickCurrentItem _ANSI_ARGS_((TkCanvas *canvasPtr, XEvent *eventPtr)); -static void PrintScrollFractions _ANSI_ARGS_((int screen1, - int screen2, int object1, int object2, - char *string)); +static Tcl_Obj * ScrollFractions _ANSI_ARGS_((int screen1, + int screen2, int object1, int object2)); #ifdef USE_OLD_TAG_SEARCH static void RelinkItems _ANSI_ARGS_((TkCanvas *canvasPtr, Tcl_Obj *tag, Tk_Item *prevPtr)); @@ -330,10 +329,9 @@ static Tk_Item * TagSearchNext _ANSI_ARGS_((TagSearch *searchPtr)); * that can be invoked from generic window code. */ -static TkClassProcs canvasClass = { - NULL, /* createProc. */ - CanvasWorldChanged, /* geometryProc. */ - NULL /* modalProc. */ +static Tk_ClassProcs canvasClass = { + sizeof(Tk_ClassProcs), /* size */ + CanvasWorldChanged, /* worldChangedProc */ }; @@ -467,7 +465,7 @@ Tk_CanvasObjCmd(clientData, interp, argc, argv) Tcl_InitHashTable(&canvasPtr->idTable, TCL_ONE_WORD_KEYS); Tk_SetClass(canvasPtr->tkwin, "Canvas"); - TkSetClassProcs(canvasPtr->tkwin, &canvasClass, (ClientData) canvasPtr); + Tk_SetClassProcs(canvasPtr->tkwin, &canvasClass, (ClientData) canvasPtr); Tk_CreateEventHandler(canvasPtr->tkwin, ExposureMask|StructureNotifyMask|FocusChangeMask, CanvasEventProc, (ClientData) canvasPtr); @@ -528,7 +526,7 @@ CanvasWidgetCmd(clientData, interp, argc, argv) #endif /* USE_OLD_TAG_SEARCH */ int index; - static char *optionStrings[] = { + static CONST char *optionStrings[] = { "addtag", "bbox", "bind", "canvasx", "canvasy", "cget", "configure", "coords", "create", "dchars", "delete", "dtag", @@ -772,12 +770,12 @@ CanvasWidgetCmd(clientData, interp, argc, argv) goto done; } } else if (argc == 4) { - char *command; + CONST char *command; command = Tk_GetBinding(interp, canvasPtr->bindingTable, object, Tcl_GetStringFromObj(argv[3], NULL)); if (command == NULL) { - char *string; + CONST char *string; string = Tcl_GetStringResult(interp); /* @@ -793,7 +791,7 @@ CanvasWidgetCmd(clientData, interp, argc, argv) Tcl_ResetResult(interp); } } else { - Tcl_SetResult(interp, command, TCL_STATIC); + Tcl_SetResult(interp, (char *) command, TCL_STATIC); } } else { Tk_GetAllBindings(interp, canvasPtr->bindingTable, object); @@ -902,7 +900,7 @@ CanvasWidgetCmd(clientData, interp, argc, argv) result = (*itemPtr->typePtr->coordProc)(interp, (Tk_Canvas) canvasPtr, itemPtr, argc-3, argv+3); } else { - char **args = GetStringsFromObjs(argc-3, argv+3); + CONST char **args = GetStringsFromObjs(argc-3, argv+3); result = (*itemPtr->typePtr->coordProc)(interp, (Tk_Canvas) canvasPtr, itemPtr, argc-3, (Tcl_Obj **) args); if (args) ckfree((char *) args); @@ -961,7 +959,7 @@ CanvasWidgetCmd(clientData, interp, argc, argv) result = (*typePtr->createProc)(interp, (Tk_Canvas) canvasPtr, itemPtr, argc-3, argv+3); } else { - char **args = GetStringsFromObjs(argc-3, argv+3); + CONST char **args = GetStringsFromObjs(argc-3, argv+3); result = (*typePtr->createProc)(interp, (Tk_Canvas) canvasPtr, itemPtr, argc-3, (Tcl_Obj **) args); if (args) ckfree((char *) args); @@ -1390,7 +1388,8 @@ CanvasWidgetCmd(clientData, interp, argc, argv) case CANV_ITEMCGET: { if (argc != 4) { Tcl_WrongNumArgs(interp, 2, argv, "tagOrId option"); - return TCL_ERROR; + result = TCL_ERROR; + goto done; } #ifdef USE_OLD_TAG_SEARCH itemPtr = StartTagSearch(canvasPtr, argv[2], &search); @@ -1438,7 +1437,7 @@ CanvasWidgetCmd(clientData, interp, argc, argv) (Tk_Canvas) canvasPtr, itemPtr, argc-3, argv+3, TK_CONFIG_ARGV_ONLY); } else { - char **args = GetStringsFromObjs(argc-3, argv+3); + CONST char **args = GetStringsFromObjs(argc-3, argv+3); result = (*itemPtr->typePtr->configProc)(interp, (Tk_Canvas) canvasPtr, itemPtr, argc-3, (Tcl_Obj **) args, TK_CONFIG_ARGV_ONLY); @@ -1527,7 +1526,7 @@ CanvasWidgetCmd(clientData, interp, argc, argv) break; } case CANV_POSTSCRIPT: { - char **args = GetStringsFromObjs(argc, argv); + CONST char **args = GetStringsFromObjs(argc, argv); result = TkCanvPostscriptCmd(canvasPtr, interp, argc, args); if (args) ckfree((char *) args); break; @@ -1621,30 +1620,26 @@ CanvasWidgetCmd(clientData, interp, argc, argv) } case CANV_SCAN: { int x, y, gain=10; - static char *optionStrings[] = { + static CONST char *optionStrings[] = { "mark", "dragto", NULL }; - if (Tcl_GetIndexFromObj(interp, argv[2], optionStrings, "scan option", 0, - &index) != TCL_OK) { - return TCL_ERROR; - } - - if ((argc != 5) && (argc != 5+index)) { + if (argc < 5) { + Tcl_WrongNumArgs(interp, 2, argv, "mark|dragto x y ?dragGain?"); + result = TCL_ERROR; + } else if (Tcl_GetIndexFromObj(interp, argv[2], optionStrings, + "scan option", 0, &index) != TCL_OK) { + result = TCL_ERROR; + } else if ((argc != 5) && (argc != 5+index)) { Tcl_WrongNumArgs(interp, 3, argv, index?"x y ?gain?":"x y"); result = TCL_ERROR; - goto done; - } - if ((Tcl_GetIntFromObj(interp, argv[3], &x) != TCL_OK) + } else if ((Tcl_GetIntFromObj(interp, argv[3], &x) != TCL_OK) || (Tcl_GetIntFromObj(interp, argv[4], &y) != TCL_OK)){ result = TCL_ERROR; - goto done; - } - if ((argc == 6) && (Tcl_GetIntFromObj(interp, argv[5], &gain) != TCL_OK)) { + } else if ((argc == 6) && + (Tcl_GetIntFromObj(interp, argv[5], &gain) != TCL_OK)) { result = TCL_ERROR; - goto done; - } - if (!index) { + } else if (!index) { canvasPtr->scanX = x; canvasPtr->scanXOrigin = canvasPtr->xOrigin; canvasPtr->scanY = y; @@ -1669,7 +1664,7 @@ CanvasWidgetCmd(clientData, interp, argc, argv) } case CANV_SELECT: { int index, optionindex; - static char *optionStrings[] = { + static CONST char *optionStrings[] = { "adjust", "clear", "from", "item", "to", NULL }; enum options { @@ -1719,7 +1714,8 @@ CanvasWidgetCmd(clientData, interp, argc, argv) } if (Tcl_GetIndexFromObj(interp, argv[2], optionStrings, "select option", 0, &optionindex) != TCL_OK) { - return TCL_ERROR; + result = TCL_ERROR; + goto done; } switch ((enum options) optionindex) { case CANV_ADJUST: { @@ -1817,12 +1813,13 @@ CanvasWidgetCmd(clientData, interp, argc, argv) double fraction; if (argc == 2) { - PrintScrollFractions(canvasPtr->xOrigin + canvasPtr->inset, + Tcl_SetObjResult(interp, ScrollFractions( + canvasPtr->xOrigin + canvasPtr->inset, canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin) - canvasPtr->inset, canvasPtr->scrollX1, - canvasPtr->scrollX2, Tcl_GetStringResult(interp)); + canvasPtr->scrollX2)); } else { - char **args = GetStringsFromObjs(argc, argv); + CONST char **args = GetStringsFromObjs(argc, argv); type = Tk_GetScrollInfo(interp, argc, args, &fraction, &count); if (args) ckfree((char *) args); switch (type) { @@ -1860,12 +1857,13 @@ CanvasWidgetCmd(clientData, interp, argc, argv) double fraction; if (argc == 2) { - PrintScrollFractions(canvasPtr->yOrigin + canvasPtr->inset, + Tcl_SetObjResult(interp,ScrollFractions(\ + canvasPtr->yOrigin + canvasPtr->inset, canvasPtr->yOrigin + Tk_Height(canvasPtr->tkwin) - canvasPtr->inset, canvasPtr->scrollY1, - canvasPtr->scrollY2, Tcl_GetStringResult(interp)); + canvasPtr->scrollY2)); } else { - char **args = GetStringsFromObjs(argc, argv); + CONST char **args = GetStringsFromObjs(argc, argv); type = Tk_GetScrollInfo(interp, argc, args, &fraction, &count); if (args) ckfree((char *) args); switch (type) { @@ -1930,14 +1928,10 @@ DestroyCanvas(memPtr) { TkCanvas *canvasPtr = (TkCanvas *) memPtr; Tk_Item *itemPtr; +#ifndef USE_OLD_TAG_SEARCH + TagSearchExpr *expr, *next; +#endif - if (canvasPtr->tkwin != NULL) { - Tcl_DeleteCommandFromToken(canvasPtr->interp, canvasPtr->widgetCmd); - } - if (canvasPtr->flags & REDRAW_PENDING) { - Tcl_CancelIdleCall(DisplayCanvas, (ClientData) canvasPtr); - } - /* * Free up all of the items in the canvas. */ @@ -1964,15 +1958,11 @@ DestroyCanvas(memPtr) Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC); } #ifndef USE_OLD_TAG_SEARCH - { - TagSearchExpr *expr, *next; - - expr = canvasPtr->bindTagExprs; - while (expr) { - next = expr->next; - TagSearchExprDestroy(expr); - expr = next; - } + expr = canvasPtr->bindTagExprs; + while (expr) { + next = expr->next; + TagSearchExprDestroy(expr); + expr = next; } #endif Tcl_DeleteTimerHandler(canvasPtr->insertBlinkHandler); @@ -2018,7 +2008,8 @@ ConfigureCanvas(interp, canvasPtr, argc, argv, flags) GC new; if (Tk_ConfigureWidget(interp, canvasPtr->tkwin, configSpecs, - argc, (char **) argv, (char *) canvasPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { + argc, (CONST char **) argv, (char *) canvasPtr, + flags|TK_CONFIG_OBJS) != TCL_OK) { return TCL_ERROR; } @@ -2071,7 +2062,7 @@ ConfigureCanvas(interp, canvasPtr, argc, argv, flags) canvasPtr->scrollY2 = 0; if (canvasPtr->regionString != NULL) { int argc2; - char **argv2; + CONST char **argv2; if (Tcl_SplitList(canvasPtr->interp, canvasPtr->regionString, &argc2, &argv2) != TCL_OK) { @@ -2448,7 +2439,16 @@ CanvasEventProc(clientData, eventPtr) canvasPtr->flags |= REDRAW_BORDERS; } } else if (eventPtr->type == DestroyNotify) { - DestroyCanvas((char *) canvasPtr); + if (canvasPtr->tkwin != NULL) { + canvasPtr->tkwin = NULL; + Tcl_DeleteCommandFromToken(canvasPtr->interp, + canvasPtr->widgetCmd); + } + if (canvasPtr->flags & REDRAW_PENDING) { + Tcl_CancelIdleCall(DisplayCanvas, (ClientData) canvasPtr); + } + Tcl_EventuallyFree((ClientData) canvasPtr, + (Tcl_FreeProc *) DestroyCanvas); } else if (eventPtr->type == ConfigureNotify) { canvasPtr->flags |= UPDATE_SCROLLBARS; @@ -3972,7 +3972,7 @@ FindItems(interp, canvasPtr, argc, argv, newTag, first, searchPtrPtr) Tk_Item *itemPtr; Tk_Uid uid; int index; - static char *optionStrings[] = { + static CONST char *optionStrings[] = { "above", "all", "below", "closest", "enclosed", "overlapping", "withtag", NULL }; @@ -5205,12 +5205,12 @@ GridAlign(coord, spacing) /* *---------------------------------------------------------------------- * - * PrintScrollFractions -- + * ScrollFractions -- * * Given the range that's visible in the window and the "100% - * range" for what's in the canvas, print a string containing - * the scroll fractions. This procedure is used for both x - * and y scrolling. + * range" for what's in the canvas, return a list of two + * doubles representing the scroll fractions. This procedure + * is used for both x and y scrolling. * * Results: * The memory pointed to by string is modified to hold @@ -5223,17 +5223,15 @@ GridAlign(coord, spacing) *---------------------------------------------------------------------- */ -static void -PrintScrollFractions(screen1, screen2, object1, object2, string) +static Tcl_Obj * +ScrollFractions(screen1, screen2, object1, object2) int screen1; /* Lowest coordinate visible in the window. */ int screen2; /* Highest coordinate visible in the window. */ int object1; /* Lowest coordinate in the object. */ int object2; /* Highest coordinate in the object. */ - char *string; /* Two real numbers get printed here. Must - * have enough storage for two %g - * conversions. */ { double range, f1, f2; + char buffer[2*TCL_DOUBLE_SPACE+2]; range = object2 - object1; if (range <= 0) { @@ -5252,7 +5250,8 @@ PrintScrollFractions(screen1, screen2, object1, object2, string) f2 = f1; } } - sprintf(string, "%g %g", f1, f2); + sprintf(buffer, "%g %g", f1, f2); + return Tcl_NewStringObj(buffer, -1); } /* @@ -5281,7 +5280,6 @@ CanvasUpdateScrollbars(canvasPtr) TkCanvas *canvasPtr; /* Information about canvas. */ { int result; - char buffer[200]; Tcl_Interp *interp; int xOrigin, yOrigin, inset, width, height, scrollX1, scrollX2, scrollY1, scrollY2; @@ -5313,9 +5311,11 @@ CanvasUpdateScrollbars(canvasPtr) scrollY2 = canvasPtr->scrollY2; canvasPtr->flags &= ~UPDATE_SCROLLBARS; if (canvasPtr->xScrollCmd != NULL) { - PrintScrollFractions(xOrigin + inset, xOrigin + width - inset, - scrollX1, scrollX2, buffer); - result = Tcl_VarEval(interp, xScrollCmd, " ", buffer, (char *) NULL); + Tcl_Obj *fractions = ScrollFractions(xOrigin + inset, + xOrigin + width - inset, scrollX1, scrollX2); + result = Tcl_VarEval(interp, xScrollCmd, " ", + Tcl_GetString(fractions), (char *) NULL); + Tcl_DecrRefCount(fractions); if (result != TCL_OK) { Tcl_BackgroundError(interp); } @@ -5324,9 +5324,11 @@ CanvasUpdateScrollbars(canvasPtr) } if (yScrollCmd != NULL) { - PrintScrollFractions(yOrigin + inset, yOrigin + height - inset, - scrollY1, scrollY2, buffer); - result = Tcl_VarEval(interp, yScrollCmd, " ", buffer, (char *) NULL); + Tcl_Obj *fractions = ScrollFractions(yOrigin + inset, + yOrigin + height - inset, scrollY1, scrollY2); + result = Tcl_VarEval(interp, yScrollCmd, " ", + Tcl_GetString(fractions), (char *) NULL); + Tcl_DecrRefCount(fractions); if (result != TCL_OK) { Tcl_BackgroundError(interp); } @@ -5484,17 +5486,17 @@ CanvasSetOrigin(canvasPtr, xOrigin, yOrigin) *---------------------------------------------------------------------- */ /* ARGSUSED */ -static char ** +static CONST char ** GetStringsFromObjs(argc, objv) int argc; Tcl_Obj *CONST objv[]; { register int i; - char **argv; + CONST char **argv; if (argc <= 0) { return NULL; } - argv = (char **) ckalloc((argc+1) * sizeof(char *)); + argv = (CONST char **) ckalloc((argc+1) * sizeof(char *)); for (i = 0; i < argc; i++) { argv[i]=Tcl_GetStringFromObj(objv[i], (int *) NULL); } @@ -5700,5 +5702,3 @@ Tk_CanvasPsPath(interp, canvas, coordPtr, numPoints) Tk_PostscriptPath(interp, ((TkCanvas *) canvas)->psInfo, coordPtr, numPoints); } - - diff --git a/tk/generic/tkCanvas.h b/tk/generic/tkCanvas.h index 103c874aee1..169f659294f 100644 --- a/tk/generic/tkCanvas.h +++ b/tk/generic/tkCanvas.h @@ -293,7 +293,7 @@ typedef struct TkCanvas { */ extern int TkCanvPostscriptCmd _ANSI_ARGS_((TkCanvas *canvasPtr, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); /* * The following definition is shared between tkCanvPs.c and tkCanvImg.c, @@ -310,4 +310,3 @@ typedef struct TkColormapData { /* Hold color information for a window */ } TkColormapData; #endif /* _TKCANVAS */ - diff --git a/tk/generic/tkClipboard.c b/tk/generic/tkClipboard.c index c1a8c81ba5f..110b6ee3ecc 100644 --- a/tk/generic/tkClipboard.c +++ b/tk/generic/tkClipboard.c @@ -30,6 +30,8 @@ static int ClipboardWindowHandler _ANSI_ARGS_(( ClientData clientData, int offset, char *buffer, int maxBytes)); static void ClipboardLostSel _ANSI_ARGS_((ClientData clientData)); +static int ClipboardGetProc _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, char *portion)); /* *---------------------------------------------------------------------- @@ -139,7 +141,7 @@ ClipboardAppHandler(clientData, offset, buffer, maxBytes) { TkDisplay *dispPtr = (TkDisplay *) clientData; size_t length; - char *p; + CONST char *p; p = dispPtr->clipboardAppPtr->winPtr->nameUid; length = strlen(p); @@ -406,7 +408,7 @@ Tk_ClipboardAppend(interp, tkwin, type, format, buffer) /* *---------------------------------------------------------------------- * - * Tk_ClipboardCmd -- + * Tk_ClipboardObjCmd -- * * This procedure is invoked to process the "clipboard" Tcl * command. See the user documentation for details on what @@ -422,117 +424,235 @@ Tk_ClipboardAppend(interp, tkwin, type, format, buffer) */ int -Tk_ClipboardCmd(clientData, interp, argc, argv) +Tk_ClipboardObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Main window associated with * interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument strings. */ { Tk_Window tkwin = (Tk_Window) clientData; char *path = NULL; - size_t length; - int count; - char c; - char **args; + Atom selection; + static CONST char *optionStrings[] = { "append", "clear", "get", NULL }; + enum options { CLIPBOARD_APPEND, CLIPBOARD_CLEAR, CLIPBOARD_GET }; + int index, i; - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " option ?arg arg ...?\"", (char *) NULL); + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); return TCL_ERROR; } - c = argv[1][0]; - length = strlen(argv[1]); - if ((c == 'a') && (strncmp(argv[1], "append", length) == 0)) { - Atom target, format; - char *targetName = NULL; - char *formatName = NULL; - - for (count = argc-2, args = argv+2; count > 1; count -= 2, args += 2) { - if (args[0][0] != '-') { - break; + + if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, + &index) != TCL_OK) { + return TCL_ERROR; + } + + switch ((enum options) index) { + case CLIPBOARD_APPEND: { + Atom target, format; + char *targetName = NULL; + char *formatName = NULL; + char *string; + static CONST char *appendOptionStrings[] = { + "-displayof", "-format", "-type", NULL + }; + enum appendOptions { APPEND_DISPLAYOF, APPEND_FORMAT, + APPEND_TYPE }; + int subIndex, length; + + for (i = 2; i < objc - 1; i++) { + string = Tcl_GetStringFromObj(objv[i], &length); + if (string[0] != '-') { + break; + } + + /* + * If the argument is "--", it signifies the end of arguments. + */ + if (string[1] == '-' && length == 2) { + i++; + break; + } + if (Tcl_GetIndexFromObj(interp, objv[i], appendOptionStrings, + "option", 0, &subIndex) != TCL_OK) { + return TCL_ERROR; + } + + /* + * Increment i so that it points to the value for the flag + * instead of the flag itself. + */ + + i++; + if (i >= objc) { + Tcl_AppendResult(interp, "value for \"", string, + "\" missing", (char *) NULL); + return TCL_ERROR; + } + switch ((enum appendOptions) subIndex) { + case APPEND_DISPLAYOF: + path = Tcl_GetString(objv[i]); + break; + case APPEND_FORMAT: + formatName = Tcl_GetString(objv[i]); + break; + case APPEND_TYPE: + targetName = Tcl_GetString(objv[i]); + break; + } } - c = args[0][1]; - length = strlen(args[0]); - if ((c == '-') && (length == 2)) { - args++; - count--; - break; + if (objc - i != 1) { + Tcl_WrongNumArgs(interp, 2, objv, "?options? data"); + return TCL_ERROR; } - if ((c == 'd') && (strncmp(args[0], "-displayof", length) == 0)) { - path = args[1]; - } else if ((c == 'f') - && (strncmp(args[0], "-format", length) == 0)) { - formatName = args[1]; - } else if ((c == 't') - && (strncmp(args[0], "-type", length) == 0)) { - targetName = args[1]; - } else { - Tcl_AppendResult(interp, "unknown option \"", args[0], - "\"", (char *) NULL); + if (path != NULL) { + tkwin = Tk_NameToWindow(interp, path, tkwin); + } + if (tkwin == NULL) { return TCL_ERROR; } + if (targetName != NULL) { + target = Tk_InternAtom(tkwin, targetName); + } else { + target = XA_STRING; + } + if (formatName != NULL) { + format = Tk_InternAtom(tkwin, formatName); + } else { + format = XA_STRING; + } + return Tk_ClipboardAppend(interp, tkwin, target, format, + Tcl_GetString(objv[i])); } - if (count != 1) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " append ?options? data\"", (char *) NULL); - return TCL_ERROR; - } - if (path != NULL) { - tkwin = Tk_NameToWindow(interp, path, tkwin); - } - if (tkwin == NULL) { - return TCL_ERROR; - } - if (targetName != NULL) { - target = Tk_InternAtom(tkwin, targetName); - } else { - target = XA_STRING; - } - if (formatName != NULL) { - format = Tk_InternAtom(tkwin, formatName); - } else { - format = XA_STRING; + case CLIPBOARD_CLEAR: { + static CONST char *clearOptionStrings[] = { "-displayof", NULL }; + enum clearOptions { CLEAR_DISPLAYOF }; + int subIndex; + if (objc != 2 && objc != 4) { + Tcl_WrongNumArgs(interp, 2, objv, "?-displayof window?"); + return TCL_ERROR; + } + + if (objc == 4) { + if (Tcl_GetIndexFromObj(interp, objv[2], clearOptionStrings, + "option", 0, &subIndex) != TCL_OK) { + return TCL_ERROR; + } + if ((enum clearOptions) subIndex == CLEAR_DISPLAYOF) { + path = Tcl_GetString(objv[3]); + } + } + if (path != NULL) { + tkwin = Tk_NameToWindow(interp, path, tkwin); + } + if (tkwin == NULL) { + return TCL_ERROR; + } + return Tk_ClipboardClear(interp, tkwin); } - return Tk_ClipboardAppend(interp, tkwin, target, format, args[0]); - } else if ((c == 'c') && (strncmp(argv[1], "clear", length) == 0)) { - for (count = argc-2, args = argv+2; count > 0; count -= 2, args += 2) { - if (args[0][0] != '-') { - break; + case CLIPBOARD_GET: { + Atom target; + char *targetName = NULL; + Tcl_DString selBytes; + int result; + char *string; + static CONST char *getOptionStrings[] = { + "-displayof", "-type", NULL + }; + enum getOptions { APPEND_DISPLAYOF, APPEND_TYPE }; + int subIndex; + + for (i = 2; i < objc; i++) { + string = Tcl_GetString(objv[i]); + if (string[0] != '-') { + break; + } + if (Tcl_GetIndexFromObj(interp, objv[i], getOptionStrings, + "option", 0, &subIndex) != TCL_OK) { + return TCL_ERROR; + } + i++; + if (i >= objc) { + Tcl_AppendResult(interp, "value for \"", string, + "\" missing", (char *) NULL); + return TCL_ERROR; + } + switch ((enum getOptions) subIndex) { + case APPEND_DISPLAYOF: + path = Tcl_GetString(objv[i]); + break; + case APPEND_TYPE: + targetName = Tcl_GetString(objv[i]); + break; + } + } + if (path != NULL) { + tkwin = Tk_NameToWindow(interp, path, tkwin); } - if (count < 2) { - Tcl_AppendResult(interp, "value for \"", *args, - "\" missing", (char *) NULL); + if (tkwin == NULL) { return TCL_ERROR; } - c = args[0][1]; - length = strlen(args[0]); - if ((c == 'd') && (strncmp(args[0], "-displayof", length) == 0)) { - path = args[1]; - } else { - Tcl_AppendResult(interp, "unknown option \"", args[0], - "\"", (char *) NULL); + selection = Tk_InternAtom(tkwin, "CLIPBOARD"); + + if (objc - i > 1) { + Tcl_WrongNumArgs(interp, 2, objv, "?options?"); return TCL_ERROR; + } else if (objc - i == 1) { + target = Tk_InternAtom(tkwin, Tcl_GetString(objv[i])); + } else if (targetName != NULL) { + target = Tk_InternAtom(tkwin, targetName); + } else { + target = XA_STRING; } + + Tcl_DStringInit(&selBytes); + result = Tk_GetSelection(interp, tkwin, selection, target, + ClipboardGetProc, (ClientData) &selBytes); + if (result == TCL_OK) { + Tcl_DStringResult(interp, &selBytes); + } else { + Tcl_DStringFree(&selBytes); + } + return result; } - if (count > 0) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " clear ?options?\"", (char *) NULL); - return TCL_ERROR; - } - if (path != NULL) { - tkwin = Tk_NameToWindow(interp, path, tkwin); - } - if (tkwin == NULL) { - return TCL_ERROR; - } - return Tk_ClipboardClear(interp, tkwin); - } else { - char buf[100 + TCL_INTEGER_SPACE]; - - sprintf(buf, "bad option \"%.50s\": must be clear or append", argv[1]); - Tcl_SetResult(interp, buf, TCL_VOLATILE); - return TCL_ERROR; + } + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * TkClipCleanup -- + * + * This procedure is called to cleanup resources associated with + * claiming clipboard ownership and for receiving selection get + * results. This function is called in tkWindow.c. This has to be + * called by the display cleanup function because we still need the + * access display elements. + * + * Results: + * None. + * + * Side effects: + * Resources are freed - the clipboard may no longer be used. + * + *---------------------------------------------------------------------- + */ + +void +TkClipCleanup(dispPtr) + TkDisplay *dispPtr; /* display associated with clipboard */ +{ + if (dispPtr->clipWindow != NULL) { + Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom, + dispPtr->applicationAtom); + Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom, + dispPtr->windowAtom); + + Tk_DestroyWindow(dispPtr->clipWindow); + Tcl_Release((ClientData) dispPtr->clipWindow); + dispPtr->clipWindow = NULL; } } @@ -578,6 +698,7 @@ TkClipInit(interp, dispPtr) if (dispPtr->clipWindow == NULL) { return TCL_ERROR; } + Tcl_Preserve((ClientData) dispPtr->clipWindow); atts.override_redirect = True; Tk_ChangeWindowAttributes(dispPtr->clipWindow, CWOverrideRedirect, &atts); Tk_MakeWindowExist(dispPtr->clipWindow); @@ -605,4 +726,35 @@ TkClipInit(interp, dispPtr) (ClientData) dispPtr, XA_STRING); return TCL_OK; } + +/* + *-------------------------------------------------------------- + * + * ClipboardGetProc -- + * + * This procedure is invoked to process pieces of the selection + * as they arrive during "clipboard get" commands. + * + * Results: + * Always returns TCL_OK. + * + * Side effects: + * Bytes get appended to the dynamic string pointed to by the + * clientData argument. + * + *-------------------------------------------------------------- + */ + + /* ARGSUSED */ +static int +ClipboardGetProc(clientData, interp, portion) + ClientData clientData; /* Dynamic string holding partially + * assembled selection. */ + Tcl_Interp *interp; /* Interpreter used for error + * reporting (not used). */ + char *portion; /* New information to be appended. */ +{ + Tcl_DStringAppend((Tcl_DString *) clientData, portion, -1); + return TCL_OK; +} diff --git a/tk/generic/tkCmds.c b/tk/generic/tkCmds.c index 78f44ca294a..10843a10ceb 100644 --- a/tk/generic/tkCmds.c +++ b/tk/generic/tkCmds.c @@ -6,6 +6,7 @@ * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright (c) 2000 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -17,10 +18,12 @@ #include "tkInt.h" #include -#if defined(__WIN32__) +#if defined(WIN32) #include "tkWinInt.h" #elif defined(MAC_TCL) #include "tkMacInt.h" +#elif defined(MAC_OSX_TK) +#include "tkMacOSXInt.h" #else #include "tkUnixInt.h" #endif @@ -31,8 +34,8 @@ static TkWindow * GetToplevel _ANSI_ARGS_((Tk_Window tkwin)); static char * WaitVariableProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); + Tcl_Interp *interp, CONST char *name1, + CONST char *name2, int flags)); static void WaitVisibilityProc _ANSI_ARGS_((ClientData clientData, XEvent *eventPtr)); static void WaitWindowProc _ANSI_ARGS_((ClientData clientData, @@ -62,30 +65,42 @@ Tk_BellObjCmd(clientData, interp, objc, objv) int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ { - static char *bellOptions[] = {"-displayof", (char *) NULL}; + static CONST char *bellOptions[] = {"-displayof", "-nice", (char *) NULL}; + enum options { TK_BELL_DISPLAYOF, TK_BELL_NICE }; Tk_Window tkwin = (Tk_Window) clientData; - char *displayName; - int index; + int i, index, nice = 0; - if ((objc != 1) && (objc != 3)) { - Tcl_WrongNumArgs(interp, 1, objv, "?-displayof window?"); + if (objc > 4) { + Tcl_WrongNumArgs(interp, 1, objv, "?-displayof window? ?-nice?"); return TCL_ERROR; } - if (objc == 3) { - if (Tcl_GetIndexFromObj(interp, objv[1], bellOptions, "option", 0, + for (i = 1; i < objc; i++) { + if (Tcl_GetIndexFromObj(interp, objv[i], bellOptions, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } - displayName = Tcl_GetStringFromObj(objv[2], (int *) NULL); - - tkwin = Tk_NameToWindow(interp, displayName, tkwin); - if (tkwin == NULL) { - return TCL_ERROR; + switch ((enum options) index) { + case TK_BELL_DISPLAYOF: + if (++i >= objc) { + Tcl_WrongNumArgs(interp, 1, objv, + "?-displayof window? ?-nice?"); + return TCL_ERROR; + } + tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[i]), tkwin); + if (tkwin == NULL) { + return TCL_ERROR; + } + break; + case TK_BELL_NICE: + nice = 1; + break; } } XBell(Tk_Display(tkwin), 0); - XForceScreenSaver(Tk_Display(tkwin), ScreenSaverReset); + if (!nice) { + XForceScreenSaver(Tk_Display(tkwin), ScreenSaverReset); + } XFlush(Tk_Display(tkwin)); return TCL_OK; } @@ -93,7 +108,7 @@ Tk_BellObjCmd(clientData, interp, objc, objv) /* *---------------------------------------------------------------------- * - * Tk_BindCmd -- + * Tk_BindObjCmd -- * * This procedure is invoked to process the "bind" Tcl command. * See the user documentation for details on what it does. @@ -108,59 +123,87 @@ Tk_BellObjCmd(clientData, interp, objc, objv) */ int -Tk_BindCmd(clientData, interp, argc, argv) +Tk_BindObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Main window associated with interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window tkwin = (Tk_Window) clientData; TkWindow *winPtr; ClientData object; - - if ((argc < 2) || (argc > 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " window ?pattern? ?command?\"", (char *) NULL); + char *string; + + if ((objc < 2) || (objc > 4)) { + Tcl_WrongNumArgs(interp, 1, objv, "window ?pattern? ?command?"); return TCL_ERROR; } - if (argv[1][0] == '.') { - winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[1], tkwin); + string = Tcl_GetString(objv[1]); + + /* + * Bind tags either a window name or a tag name for the first argument. + * If the argument starts with ".", assume it is a window; otherwise, it + * is a tag. + */ + + if (string[0] == '.') { + winPtr = (TkWindow *) Tk_NameToWindow(interp, string, tkwin); if (winPtr == NULL) { return TCL_ERROR; } object = (ClientData) winPtr->pathName; } else { winPtr = (TkWindow *) clientData; - object = (ClientData) Tk_GetUid(argv[1]); + object = (ClientData) Tk_GetUid(string); } - if (argc == 4) { + /* + * If there are four arguments, the command is modifying a binding. If + * there are three arguments, the command is querying a binding. If there + * are only two arguments, the command is querying all the bindings for + * the given tag/window. + */ + + if (objc == 4) { int append = 0; unsigned long mask; + char *sequence, *script; + sequence = Tcl_GetString(objv[2]); + script = Tcl_GetString(objv[3]); + + /* + * If the script is null, just delete the binding. + */ - if (argv[3][0] == 0) { + if (script[0] == 0) { return Tk_DeleteBinding(interp, winPtr->mainPtr->bindingTable, - object, argv[2]); + object, sequence); } - if (argv[3][0] == '+') { - argv[3]++; + + /* + * If the script begins with "+", append this script to the existing + * binding. + */ + + if (script[0] == '+') { + script++; append = 1; } mask = Tk_CreateBinding(interp, winPtr->mainPtr->bindingTable, - object, argv[2], argv[3], append); + object, sequence, script, append); if (mask == 0) { return TCL_ERROR; } - } else if (argc == 3) { - char *command; + } else if (objc == 3) { + CONST char *command; command = Tk_GetBinding(interp, winPtr->mainPtr->bindingTable, - object, argv[2]); + object, Tcl_GetString(objv[2])); if (command == NULL) { Tcl_ResetResult(interp); return TCL_OK; } - Tcl_SetResult(interp, command, TCL_STATIC); + Tcl_SetResult(interp, (char *) command, TCL_STATIC); } else { Tk_GetAllBindings(interp, winPtr->mainPtr->bindingTable, object); } @@ -229,7 +272,7 @@ TkBindEventProc(winPtr, eventPtr) objPtr[0] = (ClientData) winPtr->pathName; objPtr[1] = (ClientData) winPtr->classUid; for (topLevPtr = winPtr; - (topLevPtr != NULL) && !(topLevPtr->flags & TK_TOP_LEVEL); + (topLevPtr != NULL) && !(topLevPtr->flags & TK_TOP_HIERARCHY); topLevPtr = topLevPtr->parentPtr) { /* Empty loop body. */ } @@ -251,7 +294,7 @@ TkBindEventProc(winPtr, eventPtr) /* *---------------------------------------------------------------------- * - * Tk_BindtagsCmd -- + * Tk_BindtagsObjCmd -- * * This procedure is invoked to process the "bindtags" Tcl command. * See the user documentation for details on what it does. @@ -266,60 +309,70 @@ TkBindEventProc(winPtr, eventPtr) */ int -Tk_BindtagsCmd(clientData, interp, argc, argv) +Tk_BindtagsObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Main window associated with interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window tkwin = (Tk_Window) clientData; TkWindow *winPtr, *winPtr2; - int i, tagArgc; - char *p, **tagArgv; - - if ((argc < 2) || (argc > 3)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " window ?tags?\"", (char *) NULL); + int i, length; + char *p; + Tcl_Obj *listPtr, **tags; + + if ((objc < 2) || (objc > 3)) { + Tcl_WrongNumArgs(interp, 1, objv, "window ?taglist?"); return TCL_ERROR; } - winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[1], tkwin); + winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[1]), + tkwin); if (winPtr == NULL) { return TCL_ERROR; } - if (argc == 2) { + if (objc == 2) { + listPtr = Tcl_NewObj(); + Tcl_IncrRefCount(listPtr); if (winPtr->numTags == 0) { - Tcl_AppendElement(interp, winPtr->pathName); - Tcl_AppendElement(interp, winPtr->classUid); - for (winPtr2 = winPtr; - (winPtr2 != NULL) && !(winPtr2->flags & TK_TOP_LEVEL); - winPtr2 = winPtr2->parentPtr) { - /* Empty loop body. */ + Tcl_ListObjAppendElement(interp, listPtr, + Tcl_NewStringObj(winPtr->pathName, -1)); + Tcl_ListObjAppendElement(interp, listPtr, + Tcl_NewStringObj(winPtr->classUid, -1)); + winPtr2 = winPtr; + while ((winPtr2 != NULL) && !(Tk_TopWinHierarchy(winPtr2))) { + winPtr2 = winPtr2->parentPtr; } if ((winPtr != winPtr2) && (winPtr2 != NULL)) { - Tcl_AppendElement(interp, winPtr2->pathName); + Tcl_ListObjAppendElement(interp, listPtr, + Tcl_NewStringObj(winPtr2->pathName, -1)); } - Tcl_AppendElement(interp, "all"); + Tcl_ListObjAppendElement(interp, listPtr, + Tcl_NewStringObj("all", -1)); } else { for (i = 0; i < winPtr->numTags; i++) { - Tcl_AppendElement(interp, (char *) winPtr->tagPtr[i]); + Tcl_ListObjAppendElement(interp, listPtr, + Tcl_NewStringObj((char *)winPtr->tagPtr[i], -1)); } } + Tcl_SetObjResult(interp, listPtr); + Tcl_DecrRefCount(listPtr); return TCL_OK; } if (winPtr->tagPtr != NULL) { TkFreeBindingTags(winPtr); } - if (argv[2][0] == 0) { - return TCL_OK; - } - if (Tcl_SplitList(interp, argv[2], &tagArgc, &tagArgv) != TCL_OK) { + if (Tcl_ListObjGetElements(interp, objv[2], &length, &tags) != TCL_OK) { return TCL_ERROR; } - winPtr->numTags = tagArgc; + if (length == 0) { + return TCL_OK; + } + + winPtr->numTags = length; winPtr->tagPtr = (ClientData *) ckalloc((unsigned) - (tagArgc * sizeof(ClientData))); - for (i = 0; i < tagArgc; i++) { - p = tagArgv[i]; + (length * sizeof(ClientData))); + for (i = 0; i < length; i++) { + p = Tcl_GetString(tags[i]); if (p[0] == '.') { char *copy; @@ -337,7 +390,6 @@ Tk_BindtagsCmd(clientData, interp, argc, argv) winPtr->tagPtr[i] = (ClientData) Tk_GetUid(p); } } - ckfree((char *) tagArgv); return TCL_OK; } @@ -567,11 +619,13 @@ Tk_TkObjCmd(clientData, interp, objc, objv) { int index; Tk_Window tkwin; - static char *optionStrings[] = { - "appname", "scaling", "useinputmethods", NULL + static CONST char *optionStrings[] = { + "appname", "caret", "scaling", "useinputmethods", + "windowingsystem", NULL }; enum options { - TK_APPNAME, TK_SCALING, TK_USE_IM + TK_APPNAME, TK_CARET, TK_SCALING, TK_USE_IM, + TK_WINDOWINGSYSTEM }; tkwin = (Tk_Window) clientData; @@ -590,6 +644,13 @@ Tk_TkObjCmd(clientData, interp, objc, objv) TkWindow *winPtr; char *string; + if (Tcl_IsSafe(interp)) { + Tcl_SetResult(interp, + "appname not accessible in a safe interpreter", + TCL_STATIC); + return TCL_ERROR; + } + winPtr = (TkWindow *) tkwin; if (objc > 3) { @@ -603,11 +664,97 @@ Tk_TkObjCmd(clientData, interp, objc, objv) Tcl_AppendResult(interp, winPtr->nameUid, NULL); break; } + case TK_CARET: { + Tcl_Obj *objPtr; + TkCaret *caretPtr; + Tk_Window window; + static CONST char *caretStrings[] + = { "-x", "-y", "-height", NULL }; + enum caretOptions + { TK_CARET_X, TK_CARET_Y, TK_CARET_HEIGHT }; + + if ((objc < 3) || ((objc > 4) && !(objc & 1))) { + Tcl_WrongNumArgs(interp, 2, objv, + "window ?-x x? ?-y y? ?-height height?"); + return TCL_ERROR; + } + window = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); + if (window == NULL) { + return TCL_ERROR; + } + caretPtr = &(((TkWindow *) window)->dispPtr->caret); + if (objc == 3) { + /* + * Return all the current values + */ + objPtr = Tcl_NewObj(); + Tcl_ListObjAppendElement(interp, objPtr, + Tcl_NewStringObj("-height", 7)); + Tcl_ListObjAppendElement(interp, objPtr, + Tcl_NewIntObj(caretPtr->height)); + Tcl_ListObjAppendElement(interp, objPtr, + Tcl_NewStringObj("-x", 2)); + Tcl_ListObjAppendElement(interp, objPtr, + Tcl_NewIntObj(caretPtr->x)); + Tcl_ListObjAppendElement(interp, objPtr, + Tcl_NewStringObj("-y", 2)); + Tcl_ListObjAppendElement(interp, objPtr, + Tcl_NewIntObj(caretPtr->y)); + Tcl_SetObjResult(interp, objPtr); + } else if (objc == 4) { + int value; + /* + * Return the current value of the selected option + */ + if (Tcl_GetIndexFromObj(interp, objv[3], caretStrings, + "caret option", 0, &index) != TCL_OK) { + return TCL_ERROR; + } + if (index == TK_CARET_X) { + value = caretPtr->x; + } else if (index == TK_CARET_Y) { + value = caretPtr->y; + } else /* if (index == TK_CARET_HEIGHT) -- last case */ { + value = caretPtr->height; + } + Tcl_SetIntObj(Tcl_GetObjResult(interp), value); + } else { + int i, value, x = 0, y = 0, height = -1; + + for (i = 3; i < objc; i += 2) { + if ((Tcl_GetIndexFromObj(interp, objv[i], caretStrings, + "caret option", 0, &index) != TCL_OK) || + (Tcl_GetIntFromObj(interp, objv[i+1], &value) + != TCL_OK)) { + return TCL_ERROR; + } + if (index == TK_CARET_X) { + x = value; + } else if (index == TK_CARET_Y) { + y = value; + } else /* if (index == TK_CARET_HEIGHT) -- last case */ { + height = value; + } + } + if (height < 0) { + height = Tk_Height(window); + } + Tk_SetCaretPos(window, x, y, height); + } + break; + } case TK_SCALING: { Screen *screenPtr; int skip, width, height; double d; + if (Tcl_IsSafe(interp)) { + Tcl_SetResult(interp, + "scaling not accessible in a safe interpreter", + TCL_STATIC); + return TCL_ERROR; + } + screenPtr = Tk_Screen(tkwin); skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin); @@ -645,6 +792,13 @@ Tk_TkObjCmd(clientData, interp, objc, objv) TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; int skip; + if (Tcl_IsSafe(interp)) { + Tcl_SetResult(interp, + "useinputmethods not accessible in a safe interpreter", + TCL_STATIC); + return TCL_ERROR; + } + skip = TkGetDisplayOf(interp, objc-2, objv+2, &tkwin); if (skip < 0) { return TCL_ERROR; @@ -658,13 +812,17 @@ Tk_TkObjCmd(clientData, interp, objc, objv) * That will indicate to the user that input methods * are just not available. */ - int bool; - if (Tcl_GetBooleanFromObj(interp, objv[2+skip], &bool) + int boolVal; + if (Tcl_GetBooleanFromObj(interp, objv[2+skip], &boolVal) != TCL_OK) { return TCL_ERROR; } #ifdef TK_USE_INPUT_METHODS - dispPtr->useInputMethods = bool; + if (boolVal) { + dispPtr->flags |= TK_DISPLAY_USE_IM; + } else { + dispPtr->flags &= ~TK_DISPLAY_USE_IM; + } #endif /* TK_USE_INPUT_METHODS */ } else if ((objc - skip) != 2) { Tcl_WrongNumArgs(interp, 2, objv, @@ -672,7 +830,26 @@ Tk_TkObjCmd(clientData, interp, objc, objv) return TCL_ERROR; } Tcl_SetBooleanObj(Tcl_GetObjResult(interp), - dispPtr->useInputMethods); + (int) (dispPtr->flags & TK_DISPLAY_USE_IM)); + break; + } + case TK_WINDOWINGSYSTEM: { + CONST char *windowingsystem; + + if (objc != 2) { + Tcl_WrongNumArgs(interp, 2, objv, NULL); + return TCL_ERROR; + } +#if defined(WIN32) + windowingsystem = "win32"; +#elif defined(MAC_TCL) + windowingsystem = "classic"; +#elif defined(MAC_OSX_TK) + windowingsystem = "aqua"; +#else + windowingsystem = "x11"; +#endif + Tcl_SetStringObj(Tcl_GetObjResult(interp), windowingsystem, -1); break; } } @@ -682,7 +859,7 @@ Tk_TkObjCmd(clientData, interp, objc, objv) /* *---------------------------------------------------------------------- * - * Tk_TkwaitCmd -- + * Tk_TkwaitObjCmd -- * * This procedure is invoked to process the "tkwait" Tcl command. * See the user documentation for details on what it does. @@ -698,87 +875,97 @@ Tk_TkObjCmd(clientData, interp, objc, objv) /* ARGSUSED */ int -Tk_TkwaitCmd(clientData, interp, argc, argv) +Tk_TkwaitObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Main window associated with * interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window tkwin = (Tk_Window) clientData; - int c, done; - size_t length; + int done, index; + static CONST char *optionStrings[] = { "variable", "visibility", "window", + (char *) NULL }; + enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW }; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name"); + return TCL_ERROR; + } - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " variable|visibility|window name\"", (char *) NULL); + if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, + &index) != TCL_OK) { return TCL_ERROR; } - c = argv[1][0]; - length = strlen(argv[1]); - if ((c == 'v') && (strncmp(argv[1], "variable", length) == 0) - && (length >= 2)) { - if (Tcl_TraceVar(interp, argv[2], - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - WaitVariableProc, (ClientData) &done) != TCL_OK) { - return TCL_ERROR; - } - done = 0; - while (!done) { - Tcl_DoOneEvent(0); - } - Tcl_UntraceVar(interp, argv[2], - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - WaitVariableProc, (ClientData) &done); - } else if ((c == 'v') && (strncmp(argv[1], "visibility", length) == 0) - && (length >= 2)) { - Tk_Window window; - window = Tk_NameToWindow(interp, argv[2], tkwin); - if (window == NULL) { - return TCL_ERROR; + switch ((enum options) index) { + case TKWAIT_VARIABLE: { + if (Tcl_TraceVar(interp, Tcl_GetString(objv[2]), + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + WaitVariableProc, (ClientData) &done) != TCL_OK) { + return TCL_ERROR; + } + done = 0; + while (!done) { + Tcl_DoOneEvent(0); + } + Tcl_UntraceVar(interp, Tcl_GetString(objv[2]), + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + WaitVariableProc, (ClientData) &done); + break; } - Tk_CreateEventHandler(window, VisibilityChangeMask|StructureNotifyMask, - WaitVisibilityProc, (ClientData) &done); - done = 0; - while (!done) { - Tcl_DoOneEvent(0); + + case TKWAIT_VISIBILITY: { + Tk_Window window; + + window = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); + if (window == NULL) { + return TCL_ERROR; + } + Tk_CreateEventHandler(window, + VisibilityChangeMask|StructureNotifyMask, + WaitVisibilityProc, (ClientData) &done); + done = 0; + while (!done) { + Tcl_DoOneEvent(0); + } + if (done != 1) { + /* + * Note that we do not delete the event handler because it + * was deleted automatically when the window was destroyed. + */ + + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "window \"", Tcl_GetString(objv[2]), + "\" was deleted before its visibility changed", + (char *) NULL); + return TCL_ERROR; + } + Tk_DeleteEventHandler(window, + VisibilityChangeMask|StructureNotifyMask, + WaitVisibilityProc, (ClientData) &done); + break; } - if (done != 1) { + + case TKWAIT_WINDOW: { + Tk_Window window; + + window = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); + if (window == NULL) { + return TCL_ERROR; + } + Tk_CreateEventHandler(window, StructureNotifyMask, + WaitWindowProc, (ClientData) &done); + done = 0; + while (!done) { + Tcl_DoOneEvent(0); + } /* - * Note that we do not delete the event handler because it - * was deleted automatically when the window was destroyed. + * Note: there's no need to delete the event handler. It was + * deleted automatically when the window was destroyed. */ - - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "window \"", argv[2], - "\" was deleted before its visibility changed", - (char *) NULL); - return TCL_ERROR; - } - Tk_DeleteEventHandler(window, VisibilityChangeMask|StructureNotifyMask, - WaitVisibilityProc, (ClientData) &done); - } else if ((c == 'w') && (strncmp(argv[1], "window", length) == 0)) { - Tk_Window window; - - window = Tk_NameToWindow(interp, argv[2], tkwin); - if (window == NULL) { - return TCL_ERROR; - } - Tk_CreateEventHandler(window, StructureNotifyMask, - WaitWindowProc, (ClientData) &done); - done = 0; - while (!done) { - Tcl_DoOneEvent(0); + break; } - /* - * Note: there's no need to delete the event handler. It was - * deleted automatically when the window was destroyed. - */ - } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": must be variable, visibility, or window", (char *) NULL); - return TCL_ERROR; } /* @@ -795,8 +982,8 @@ static char * WaitVariableProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Pointer to integer to set to 1. */ Tcl_Interp *interp; /* Interpreter containing variable. */ - char *name1; /* Name of variable. */ - char *name2; /* Second part of variable name. */ + CONST char *name1; /* Name of variable. */ + CONST char *name2; /* Second part of variable name. */ int flags; /* Information about what happened. */ { int *donePtr = (int *) clientData; @@ -859,7 +1046,7 @@ Tk_UpdateObjCmd(clientData, interp, objc, objv) int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ { - static char *updateOptions[] = {"idletasks", (char *) NULL}; + static CONST char *updateOptions[] = {"idletasks", (char *) NULL}; int flags, index; TkDisplay *dispPtr; @@ -947,7 +1134,7 @@ Tk_WinfoObjCmd(clientData, interp, objc, objv) {StaticGray, "staticgray"}, {-1, NULL} }; - static char *optionStrings[] = { + static CONST char *optionStrings[] = { "cells", "children", "class", "colormapfull", "depth", "geometry", "height", "id", "ismapped", "manager", "name", "parent", @@ -1021,8 +1208,10 @@ Tk_WinfoObjCmd(clientData, interp, objc, objv) winPtr = winPtr->childList; for ( ; winPtr != NULL; winPtr = winPtr->nextPtr) { - strPtr = Tcl_NewStringObj(winPtr->pathName, -1); - Tcl_ListObjAppendElement(NULL, resultPtr, strPtr); + if (!(winPtr->flags & TK_ANONYMOUS_WINDOW)) { + strPtr = Tcl_NewStringObj(winPtr->pathName, -1); + Tcl_ListObjAppendElement(NULL, resultPtr, strPtr); + } } break; } @@ -1184,7 +1373,7 @@ Tk_WinfoObjCmd(clientData, interp, objc, objv) if ((winPtr == NULL) || !(winPtr->flags & TK_MAPPED)) { break; } - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_TOP_HIERARCHY) { viewable = 1; break; } @@ -1264,7 +1453,7 @@ Tk_WinfoObjCmd(clientData, interp, objc, objv) break; } case WIN_ATOMNAME: { - char *name; + CONST char *name; long id; skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin); @@ -1329,7 +1518,7 @@ Tk_WinfoObjCmd(clientData, interp, objc, objv) return result; } case WIN_PATHNAME: { - int id; + Window id; skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin); if (skip < 0) { @@ -1343,8 +1532,7 @@ Tk_WinfoObjCmd(clientData, interp, objc, objv) if (TkpScanWindowId(interp, string, &id) != TCL_OK) { return TCL_ERROR; } - winPtr = (TkWindow *) - Tk_IdToWindow(Tk_Display(tkwin), (Window) id); + winPtr = (TkWindow *)Tk_IdToWindow(Tk_Display(tkwin), id); if ((winPtr == NULL) || (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr)) { Tcl_AppendStringsToObj(resultPtr, "window id \"", string, @@ -1537,7 +1725,7 @@ Tk_WmObjCmd(clientData, interp, objc, objv) Tk_Window tkwin; TkWindow *winPtr; - static char *optionStrings[] = { + static CONST char *optionStrings[] = { "aspect", "client", "command", "deiconify", "focusmodel", "frame", "geometry", "grid", "group", "iconbitmap", "iconify", "iconmask", @@ -1568,6 +1756,7 @@ Tk_WmObjCmd(clientData, interp, objc, objv) } if (index == TKWM_TRACING) { + int wmTracing; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; if ((objc != 2) && (objc != 3)) { @@ -1575,10 +1764,19 @@ Tk_WmObjCmd(clientData, interp, objc, objv) return TCL_ERROR; } if (objc == 2) { - Tcl_SetObjResult(interp, Tcl_NewBooleanObj(dispPtr->wmTracing)); + Tcl_SetObjResult(interp, + Tcl_NewBooleanObj(dispPtr->flags & TK_DISPLAY_WM_TRACING)); return TCL_OK; } - return Tcl_GetBooleanFromObj(interp, objv[2], &dispPtr->wmTracing); + 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) { @@ -1811,7 +2009,7 @@ TkDeadAppCmd(clientData, interp, argc, argv) ClientData clientData; /* Dummy. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { Tcl_AppendResult(interp, "can't invoke \"", argv[0], "\" command: application has been destroyed", (char *) NULL); @@ -1851,5 +2049,3 @@ GetToplevel(tkwin) } return winPtr; } - - diff --git a/tk/generic/tkColor.c b/tk/generic/tkColor.c index 19659fcf159..94ea80c09be 100644 --- a/tk/generic/tkColor.c +++ b/tk/generic/tkColor.c @@ -54,7 +54,7 @@ static void InitColorObj _ANSI_ARGS_((Tcl_Obj *objPtr)); * ptr1 field of the Tcl_Obj points to a TkColor object. */ -static Tcl_ObjType colorObjType = { +Tcl_ObjType tkColorObjType = { "color", /* name */ FreeColorObjProc, /* freeIntRepProc */ DupColorObjProc, /* dupIntRepProc */ @@ -98,7 +98,7 @@ Tk_AllocColorFromObj(interp, tkwin, objPtr) { TkColor *tkColPtr; - if (objPtr->typePtr != &colorObjType) { + if (objPtr->typePtr != &tkColorObjType) { InitColorObj(objPtr); } tkColPtr = (TkColor *) objPtr->internalRep.twoPtrValue.ptr1; @@ -187,7 +187,7 @@ Tk_GetColor(interp, tkwin, name) Tcl_Interp *interp; /* Place to leave error message if * color can't be found. */ Tk_Window tkwin; /* Window in which color will be used. */ - char *name; /* Name of color to be allocated (in form + Tk_Uid name; /* Name of color to be allocated (in form * suitable for passing to XParseColor). */ { Tcl_HashEntry *nameHashPtr; @@ -257,7 +257,6 @@ Tk_GetColor(interp, tkwin, name) tkColPtr->type = TK_COLOR_BY_NAME; tkColPtr->hashPtr = nameHashPtr; tkColPtr->nextPtr = existingColPtr; - tkColPtr->gcList = NULL; Tcl_SetHashValue(nameHashPtr, tkColPtr); return &tkColPtr->color; @@ -338,7 +337,6 @@ Tk_GetColorByValue(tkwin, colorPtr) tkColPtr->type = TK_COLOR_BY_VALUE; tkColPtr->hashPtr = valueHashPtr; tkColPtr->nextPtr = NULL; - tkColPtr->gcList = NULL; Tcl_SetHashValue(valueHashPtr, tkColPtr); return &tkColPtr->color; } @@ -365,7 +363,7 @@ Tk_GetColorByValue(tkwin, colorPtr) *-------------------------------------------------------------- */ -char * +CONST char * Tk_NameOfColor(colorPtr) XColor *colorPtr; /* Color whose name is desired. */ { @@ -645,7 +643,7 @@ Tk_GetColorFromObj(tkwin, objPtr) Tcl_HashEntry *hashPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; - if (objPtr->typePtr != &colorObjType) { + if (objPtr->typePtr != &tkColorObjType) { InitColorObj(objPtr); } @@ -733,7 +731,7 @@ InitColorObj(objPtr) if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) { (*typePtr->freeIntRepProc)(objPtr); } - objPtr->typePtr = &colorObjType; + objPtr->typePtr = &tkColorObjType; objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) NULL; } @@ -813,4 +811,3 @@ TkDebugColor(tkwin, name) } return resultPtr; } - diff --git a/tk/generic/tkColor.h b/tk/generic/tkColor.h index 2f38ac4db65..c82a87f7454 100644 --- a/tk/generic/tkColor.h +++ b/tk/generic/tkColor.h @@ -22,23 +22,6 @@ # define TCL_STORAGE_CLASS DLLEXPORT #endif -/* CYGNUS LOCAL. */ - -/* A linked list of GC structures. */ - -typedef struct TkGCList { - /* Next item on list. */ - struct TkGCList *next; - /* The display for the GC. */ - Display *display; - /* The GC. */ - GC gc; - /* GCForeground or GCBackground. */ - unsigned long mask; -} TkGCList; - -/* END CYGNUS LOCAL */ - /* * One of the following data structures is used to keep track of * each color that is being used by the application; typically there @@ -86,8 +69,6 @@ typedef struct TkColor { * valueTable (those allocated by * Tk_GetColorByValue) this field is always * NULL. */ - /* CYGNUS LOCAL */ - TkGCList *gcList; /* List of GCs which use this color. */ } TkColor; /* @@ -102,12 +83,7 @@ EXTERN TkColor * TkpGetColor _ANSI_ARGS_((Tk_Window tkwin, EXTERN TkColor * TkpGetColorByValue _ANSI_ARGS_((Tk_Window tkwin, XColor *colorPtr)); -/* CYGNUS LOCAL. */ -EXTERN void TkMapOverColors _ANSI_ARGS_((void (*) (TkColor *))); -EXTERN void TkColorChanged _ANSI_ARGS_((TkColor *)); - # undef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLIMPORT #endif /* _TKCOLOR */ - diff --git a/tk/generic/tkConfig.c b/tk/generic/tkConfig.c index f12893607c7..c3ded1cda43 100644 --- a/tk/generic/tkConfig.c +++ b/tk/generic/tkConfig.c @@ -66,6 +66,7 @@ typedef struct TkOption { * use on monochrome displays. */ struct TkOption *synonymPtr; /* For synonym options, this points to * the master entry. */ + struct Tk_ObjCustomOption *custom; /* For TK_OPTION_CUSTOM. */ } extra; int flags; /* Miscellaneous flag values; see * below for definitions. */ @@ -126,6 +127,8 @@ static Tcl_Obj * GetConfigList _ANSI_ARGS_((char *recordPtr, Option *optionPtr, Tk_Window tkwin)); static Tcl_Obj * GetObjectForOption _ANSI_ARGS_((char *recordPtr, Option *optionPtr, Tk_Window tkwin)); +static Option * GetOption _ANSI_ARGS_((CONST char *name, + OptionTable *tablePtr)); static Option * GetOptionFromObj _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *objPtr, OptionTable *tablePtr)); static int ObjectIsEmpty _ANSI_ARGS_((Tcl_Obj *objPtr)); @@ -139,7 +142,7 @@ static int SetOptionFromAny _ANSI_ARGS_((Tcl_Interp *interp, * and the internalPtr2 field points to the entry that matched. */ -Tcl_ObjType optionType = { +Tcl_ObjType tkOptionObjType = { "option", /* name */ (Tcl_FreeInternalRepProc *) NULL, /* freeIntRepProc */ (Tcl_DupInternalRepProc *) NULL, /* dupIntRepProc */ @@ -279,6 +282,14 @@ Tk_CreateOptionTable(interp, templatePtr) Tcl_NewStringObj((char *) specPtr->clientData, -1); Tcl_IncrRefCount(optionPtr->extra.monoColorPtr); } + + if (specPtr->type == TK_OPTION_CUSTOM) { + /* + * Get the custom parsing, etc., functions. + */ + optionPtr->extra.custom = + (Tk_ObjCustomOption *)specPtr->clientData; + } } if (((specPtr->type == TK_OPTION_STRING) && (specPtr->internalOffset >= 0)) @@ -286,7 +297,8 @@ Tk_CreateOptionTable(interp, templatePtr) || (specPtr->type == TK_OPTION_FONT) || (specPtr->type == TK_OPTION_BITMAP) || (specPtr->type == TK_OPTION_BORDER) - || (specPtr->type == TK_OPTION_CURSOR)) { + || (specPtr->type == TK_OPTION_CURSOR) + || (specPtr->type == TK_OPTION_CUSTOM)) { optionPtr->flags |= OPTION_NEEDS_FREEING; } } @@ -453,7 +465,7 @@ Tk_InitOptions(interp, recordPtr, optionTable, tkwin) OptionTable *tablePtr = (OptionTable *) optionTable; Option *optionPtr; int count; - char *value; + Tk_Uid value; Tcl_Obj *valuePtr; enum { OPTION_DATABASE, SYSTEM_DEFAULT, TABLE_DEFAULT @@ -539,6 +551,13 @@ Tk_InitOptions(interp, recordPtr, optionTable, tkwin) continue; } + /* + * Bump the reference count on valuePtr, so that it is strongly + * referenced here, and will be properly free'd when finished, + * regardless of what DoObjConfig does. + */ + Tcl_IncrRefCount(valuePtr); + if (DoObjConfig(interp, recordPtr, optionPtr, valuePtr, tkwin, (Tk_SavedOption *) NULL) != TCL_OK) { if (interp != NULL) { @@ -563,8 +582,10 @@ Tk_InitOptions(interp, recordPtr, optionTable, tkwin) } Tcl_AddErrorInfo(interp, msg); } + Tcl_DecrRefCount(valuePtr); return TCL_ERROR; } + Tcl_DecrRefCount(valuePtr); } return TCL_OK; } @@ -685,10 +706,15 @@ DoObjConfig(interp, recordPtr, optionPtr, valuePtr, tkwin, savedOptionPtr) case TK_OPTION_DOUBLE: { double new; - if (Tcl_GetDoubleFromObj(interp, valuePtr, &new) - != TCL_OK) { - return TCL_ERROR; + if (nullOK && ObjectIsEmpty(valuePtr)) { + valuePtr = NULL; + new = 0; + } else { + if (Tcl_GetDoubleFromObj(interp, valuePtr, &new) != TCL_OK) { + return TCL_ERROR; + } } + if (internalPtr != NULL) { *((double *) oldInternalPtr) = *((double *) internalPtr); *((double *) internalPtr) = new; @@ -719,7 +745,7 @@ DoObjConfig(interp, recordPtr, optionPtr, valuePtr, tkwin, savedOptionPtr) int new; if (Tcl_GetIndexFromObj(interp, valuePtr, - (char **) optionPtr->specPtr->clientData, + (CONST char **) optionPtr->specPtr->clientData, optionPtr->specPtr->optionName+1, 0, &new) != TCL_OK) { return TCL_ERROR; } @@ -765,6 +791,24 @@ DoObjConfig(interp, recordPtr, optionPtr, valuePtr, tkwin, savedOptionPtr) } break; } + case TK_OPTION_STYLE: { + Tk_Style new; + + if (nullOK && ObjectIsEmpty(valuePtr)) { + valuePtr = NULL; + new = NULL; + } else { + new = Tk_AllocStyleFromObj(interp, valuePtr); + if (new == NULL) { + return TCL_ERROR; + } + } + if (internalPtr != NULL) { + *((Tk_Style *) oldInternalPtr) = *((Tk_Style *) internalPtr); + *((Tk_Style *) internalPtr) = new; + } + break; + } case TK_OPTION_BITMAP: { Pixmap new; @@ -805,8 +849,13 @@ DoObjConfig(interp, recordPtr, optionPtr, valuePtr, tkwin, savedOptionPtr) case TK_OPTION_RELIEF: { int new; - if (Tk_GetReliefFromObj(interp, valuePtr, &new) != TCL_OK) { - return TCL_ERROR; + if (nullOK && ObjectIsEmpty(valuePtr)) { + valuePtr = NULL; + new = TK_RELIEF_NULL; + } else { + if (Tk_GetReliefFromObj(interp, valuePtr, &new) != TCL_OK) { + return TCL_ERROR; + } } if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); @@ -861,10 +910,15 @@ DoObjConfig(interp, recordPtr, optionPtr, valuePtr, tkwin, savedOptionPtr) } case TK_OPTION_PIXELS: { int new; - - if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, - &new) != TCL_OK) { - return TCL_ERROR; + + if (nullOK && ObjectIsEmpty(valuePtr)) { + valuePtr = NULL; + new = 0; + } else { + if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, + &new) != TCL_OK) { + return TCL_ERROR; + } } if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); @@ -890,6 +944,17 @@ DoObjConfig(interp, recordPtr, optionPtr, valuePtr, tkwin, savedOptionPtr) } break; } + case TK_OPTION_CUSTOM: { + Tk_ObjCustomOption *custom = optionPtr->extra.custom; + if (custom->setProc(custom->clientData, interp, tkwin, + &valuePtr, recordPtr, optionPtr->specPtr->internalOffset, + (char *)oldInternalPtr, + optionPtr->specPtr->flags) != TCL_OK) { + return TCL_ERROR; + } + break; + } + default: { char buf[40+TCL_INTEGER_SPACE]; sprintf(buf, "bad config table: unknown type %d", @@ -959,53 +1024,38 @@ ObjectIsEmpty(objPtr) /* *---------------------------------------------------------------------- * - * GetOptionFromObj -- + * GetOption -- * * This procedure searches through a chained option table to find * the entry for a particular option name. * * Results: * The return value is a pointer to the matching entry, or NULL - * if no matching entry could be found. If NULL is returned and - * interp is not NULL than an error message is left in its result. + * if no matching entry could be found. * Note: if the matching entry is a synonym then this procedure * returns a pointer to the synonym entry, *not* the "real" entry * that the synonym refers to. * * Side effects: - * Information about the matching entry is cached in the object - * containing the name, so that future lookups can proceed more - * quickly. + * None. * *---------------------------------------------------------------------- */ static Option * -GetOptionFromObj(interp, objPtr, tablePtr) - Tcl_Interp *interp; /* Used only for error reporting; if NULL - * no message is left after an error. */ - Tcl_Obj *objPtr; /* Object whose string value is to be - * looked up in the option table. */ - OptionTable *tablePtr; /* Table in which to look up objPtr. */ +GetOption(name, tablePtr) + CONST char *name; /* String balue to be looked up in the + * option table. */ + OptionTable *tablePtr; /* Table in which to look up name. */ { Option *bestPtr, *optionPtr; OptionTable *tablePtr2; - char *p1, *p2, *name; + CONST char *p1, *p2; int count; /* - * First, check to see if the object already has the answer cached. - */ - - if (objPtr->typePtr == &optionType) { - if (objPtr->internalRep.twoPtrValue.ptr1 == (VOID *) tablePtr) { - return (Option *) objPtr->internalRep.twoPtrValue.ptr2; - } - } - - /* - * The answer isn't cached. Search through all of the option tables - * in the chain to find the best match. Some tricky aspects: + * Search through all of the option tables in the chain to find the + * best match. Some tricky aspects: * * 1. We have to accept unique abbreviations. * 2. The same name could appear in different tables in the chain. @@ -1015,7 +1065,6 @@ GetOptionFromObj(interp, objPtr, tablePtr) */ bestPtr = NULL; - name = Tcl_GetStringFromObj(objPtr, (int *) NULL); for (tablePtr2 = tablePtr; tablePtr2 != NULL; tablePtr2 = tablePtr2->nextPtr) { for (optionPtr = tablePtr2->options, count = tablePtr2->numOptions; @@ -1052,18 +1101,76 @@ GetOptionFromObj(interp, objPtr, tablePtr) } } } + + done: + return bestPtr; + + error: + return NULL; +} + +/* + *---------------------------------------------------------------------- + * + * GetOptionFromObj -- + * + * This procedure searches through a chained option table to find + * the entry for a particular option name. + * + * Results: + * The return value is a pointer to the matching entry, or NULL + * if no matching entry could be found. If NULL is returned and + * interp is not NULL than an error message is left in its result. + * Note: if the matching entry is a synonym then this procedure + * returns a pointer to the synonym entry, *not* the "real" entry + * that the synonym refers to. + * + * Side effects: + * Information about the matching entry is cached in the object + * containing the name, so that future lookups can proceed more + * quickly. + * + *---------------------------------------------------------------------- + */ + +static Option * +GetOptionFromObj(interp, objPtr, tablePtr) + Tcl_Interp *interp; /* Used only for error reporting; if NULL + * no message is left after an error. */ + Tcl_Obj *objPtr; /* Object whose string value is to be + * looked up in the option table. */ + OptionTable *tablePtr; /* Table in which to look up objPtr. */ +{ + Option *bestPtr; + char *name; + + /* + * First, check to see if the object already has the answer cached. + */ + + if (objPtr->typePtr == &tkOptionObjType) { + if (objPtr->internalRep.twoPtrValue.ptr1 == (VOID *) tablePtr) { + return (Option *) objPtr->internalRep.twoPtrValue.ptr2; + } + } + + /* + * The answer isn't cached. + */ + + name = Tcl_GetStringFromObj(objPtr, (int *) NULL); + bestPtr = GetOption(name, tablePtr); if (bestPtr == NULL) { goto error; } - done: if ((objPtr->typePtr != NULL) && (objPtr->typePtr->freeIntRepProc != NULL)) { objPtr->typePtr->freeIntRepProc(objPtr); } objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) tablePtr; objPtr->internalRep.twoPtrValue.ptr2 = (VOID *) bestPtr; - objPtr->typePtr = &optionType; + objPtr->typePtr = &tkOptionObjType; return bestPtr; error: @@ -1074,6 +1181,44 @@ GetOptionFromObj(interp, objPtr, tablePtr) return NULL; } +/* + *---------------------------------------------------------------------- + * + * TkGetOptionSpec -- + * + * This procedure searches through a chained option table to find + * the option spec for a particular option name. + * + * Results: + * The return value is a pointer to the option spec of the matching + * entry, or NULL if no matching entry could be found. + * Note: if the matching entry is a synonym then this procedure + * returns a pointer to the option spec of the synonym entry, *not* + * the "real" entry that the synonym refers to. + * Note: this call is primarily used by the style management code + * (tkStyle.c) to look up an element's option spec into a widget's + * option table. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +CONST Tk_OptionSpec * +TkGetOptionSpec(name, optionTable) + CONST char *name; /* String value to be looked up. */ + Tk_OptionTable optionTable; /* Table in which to look up name. */ +{ + Option *optionPtr; + + optionPtr = GetOption(name, (OptionTable *) optionTable); + if (optionPtr == NULL) { + return NULL; + } + return optionPtr->specPtr; +} + /* *---------------------------------------------------------------------- * @@ -1352,6 +1497,11 @@ Tk_RestoreSavedOptions(savePtr) = *((Tk_Font *) &savePtr->items[i].internalForm); break; } + case TK_OPTION_STYLE: { + *((Tk_Style *) internalPtr) + = *((Tk_Style *) &savePtr->items[i].internalForm); + break; + } case TK_OPTION_BITMAP: { *((Pixmap *) internalPtr) = *((Pixmap *) &savePtr->items[i].internalForm); @@ -1394,6 +1544,15 @@ Tk_RestoreSavedOptions(savePtr) = *((Tk_Window *) &savePtr->items[i].internalForm); break; } + case TK_OPTION_CUSTOM: { + Tk_ObjCustomOption *custom = optionPtr->extra.custom; + if (custom->restoreProc != NULL) { + custom->restoreProc(custom->clientData, savePtr->tkwin, + internalPtr, + (char *)&savePtr->items[i].internalForm); + } + break; + } default: { panic("bad option type in Tk_RestoreSavedOptions"); } @@ -1573,6 +1732,14 @@ FreeResources(optionPtr, objPtr, internalPtr, tkwin) Tk_FreeFontFromObj(tkwin, objPtr); } break; + case TK_OPTION_STYLE: + if (internalFormExists) { + Tk_FreeStyle(*((Tk_Style *) internalPtr)); + *((Tk_Style *) internalPtr) = NULL; + } else if (objPtr != NULL) { + Tk_FreeStyleFromObj(objPtr); + } + break; case TK_OPTION_BITMAP: if (internalFormExists) { if (*((Pixmap *) internalPtr) != None) { @@ -1604,6 +1771,13 @@ FreeResources(optionPtr, objPtr, internalPtr, tkwin) Tk_FreeCursorFromObj(tkwin, objPtr); } break; + case TK_OPTION_CUSTOM: { + Tk_ObjCustomOption *custom = optionPtr->extra.custom; + if (internalFormExists && custom->freeProc != NULL) { + custom->freeProc(custom->clientData, tkwin, internalPtr); + } + break; + } default: break; } @@ -1839,6 +2013,13 @@ GetObjectForOption(recordPtr, optionPtr, tkwin) } break; } + case TK_OPTION_STYLE: { + Tk_Style style = *((Tk_Style *) internalPtr); + if (style != NULL) { + objPtr = Tcl_NewStringObj(Tk_NameOfStyle(style), -1); + } + break; + } case TK_OPTION_BITMAP: { Pixmap pixmap = *((Pixmap *) internalPtr); if (pixmap != None) { @@ -1888,6 +2069,12 @@ GetObjectForOption(recordPtr, optionPtr, tkwin) } break; } + case TK_OPTION_CUSTOM: { + Tk_ObjCustomOption *custom = optionPtr->extra.custom; + objPtr = custom->getProc(custom->clientData, tkwin, recordPtr, + optionPtr->specPtr->internalOffset); + break; + } default: { panic("bad option type in GetObjectForOption"); } @@ -2028,5 +2215,3 @@ TkDebugConfig(interp, table) } return objPtr; } - - diff --git a/tk/generic/tkConsole.c b/tk/generic/tkConsole.c index 69b113b13ba..62f5237ca21 100644 --- a/tk/generic/tkConsole.c +++ b/tk/generic/tkConsole.c @@ -47,21 +47,18 @@ TCL_DECLARE_MUTEX(consoleMutex) * The first three will be used in the tk app shells... */ -void TkConsolePrint _ANSI_ARGS_((Tcl_Interp *interp, - int devId, char *buffer, long size)); - static int ConsoleCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); static void ConsoleDeleteProc _ANSI_ARGS_((ClientData clientData)); static void ConsoleEventProc _ANSI_ARGS_((ClientData clientData, XEvent *eventPtr)); static int InterpreterCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); static int ConsoleInput _ANSI_ARGS_((ClientData instanceData, char *buf, int toRead, int *errorCode)); static int ConsoleOutput _ANSI_ARGS_((ClientData instanceData, - char *buf, int toWrite, int *errorCode)); + CONST char *buf, int toWrite, int *errorCode)); static int ConsoleClose _ANSI_ARGS_((ClientData instanceData, Tcl_Interp *interp)); static void ConsoleWatch _ANSI_ARGS_((ClientData instanceData, @@ -151,6 +148,23 @@ static int ShouldUseConsoleChannel(type) if ((handle == INVALID_HANDLE_VALUE) || (handle == 0)) { return 1; } + + /* + * Win2K BUG: GetStdHandle(STD_OUTPUT_HANDLE) can return what appears + * to be a valid handle. See TclpGetDefaultStdChannel() for this change + * implemented. We didn't change it here because GetFileType() [below] + * will catch this with FILE_TYPE_UNKNOWN and appropriately return a + * value of 1, anyways. + * + * char dummyBuff[1]; + * DWORD dummyWritten; + * + * if ((type == TCL_STDOUT) + * && !WriteFile(handle, dummyBuff, 0, &dummyWritten, NULL)) { + * return 1; + * } + */ + fileType = GetFileType(handle); /* @@ -319,7 +333,7 @@ Tk_CreateConsoleWindow(interp) ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); #ifdef MAC_TCL - static char initCmd[] = "source -rsrc {Console}"; + static char initCmd[] = "if {[catch {source $tk_library:console.tcl}]} {source -rsrc console}"; #else static char initCmd[] = "source $tk_library/console.tcl"; #endif @@ -391,7 +405,7 @@ Tk_CreateConsoleWindow(interp) static int ConsoleOutput(instanceData, buf, toWrite, errorCode) ClientData instanceData; /* Indicates which device to use. */ - char *buf; /* The data buffer. */ + CONST char *buf; /* The data buffer. */ int toWrite; /* How many bytes to write? */ int *errorCode; /* Where to store error code. */ { @@ -459,6 +473,9 @@ ConsoleClose(instanceData, interp) ClientData instanceData; /* Unused. */ Tcl_Interp *interp; /* Unused. */ { + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + tsdPtr->gStdoutInterp = NULL; return 0; } @@ -543,7 +560,7 @@ ConsoleCmd(clientData, interp, argc, argv) ClientData clientData; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { ConsoleInfo *info = (ConsoleInfo *) clientData; char c; @@ -585,7 +602,7 @@ ConsoleCmd(clientData, interp, argc, argv) } else { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " eval command\"", (char *) NULL); - return TCL_ERROR; + result = TCL_ERROR; } } else { Tcl_AppendResult(interp, "bad option \"", argv[1], @@ -620,7 +637,7 @@ InterpreterCmd(clientData, interp, argc, argv) ClientData clientData; /* Not used. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { ConsoleInfo *info = (ConsoleInfo *) clientData; char c; @@ -691,13 +708,13 @@ ConsoleDeleteProc(clientData) * This event procedure is registered on the main window of the * slave interpreter. If the user or a running script causes the * main window to be destroyed, then we need to inform the console - * interpreter by invoking "tkConsoleExit". + * interpreter by invoking "::tk::ConsoleExit". * * Results: * None. * * Side effects: - * Invokes the "tkConsoleExit" procedure in the console interp. + * Invokes the "::tk::ConsoleExit" procedure in the console interp. * *---------------------------------------------------------------------- */ @@ -728,7 +745,7 @@ ConsoleEventProc(clientData, eventPtr) return; } Tcl_Preserve((ClientData) consoleInterp); - Tcl_DStringAppend(&dString, "tkConsoleExit", -1); + Tcl_DStringAppend(&dString, "::tk::ConsoleExit", -1); Tcl_Eval(consoleInterp, Tcl_DStringValue(&dString)); Tcl_DStringFree(&dString); Tcl_Release((ClientData) consoleInterp); @@ -758,7 +775,7 @@ TkConsolePrint(interp, devId, buffer, size) Tcl_Interp *interp; /* Main interpreter. */ int devId; /* TCL_STDOUT for stdout, TCL_STDERR for * stderr. */ - char *buffer; /* Text buffer. */ + CONST char *buffer; /* Text buffer. */ long size; /* Size of text buffer. */ { Tcl_DString command, output; @@ -773,9 +790,9 @@ TkConsolePrint(interp, devId, buffer, size) } if (devId == TCL_STDERR) { - cmd = "tkConsoleOutput stderr "; + cmd = "::tk::ConsoleOutput stderr "; } else { - cmd = "tkConsoleOutput stdout "; + cmd = "::tk::ConsoleOutput stdout "; } result = Tcl_GetCommandInfo(interp, "console", &cmdInfo); @@ -799,4 +816,3 @@ TkConsolePrint(interp, devId, buffer, size) Tcl_DStringFree(&command); Tcl_DStringFree(&output); } - diff --git a/tk/generic/tkCursor.c b/tk/generic/tkCursor.c index 6782550b3ba..e389d267150 100644 --- a/tk/generic/tkCursor.c +++ b/tk/generic/tkCursor.c @@ -26,8 +26,8 @@ */ typedef struct { - char *source; /* Cursor bits. */ - char *mask; /* Mask bits. */ + CONST char *source; /* Cursor bits. */ + CONST char *mask; /* Mask bits. */ int width, height; /* Dimensions of cursor (and data * and mask). */ int xHot, yHot; /* Location of cursor hot-spot. */ @@ -45,7 +45,7 @@ static void DupCursorObjProc _ANSI_ARGS_((Tcl_Obj *srcObjPtr, static void FreeCursor _ANSI_ARGS_((TkCursor *cursorPtr)); static void FreeCursorObjProc _ANSI_ARGS_((Tcl_Obj *objPtr)); static TkCursor * GetCursor _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Window tkwin, char *name)); + Tk_Window tkwin, CONST char *name)); static TkCursor * GetCursorFromObj _ANSI_ARGS_((Tk_Window tkwin, Tcl_Obj *objPtr)); static void InitCursorObj _ANSI_ARGS_((Tcl_Obj *objPtr)); @@ -58,7 +58,7 @@ static void InitCursorObj _ANSI_ARGS_((Tcl_Obj *objPtr)); * option is set. */ -static Tcl_ObjType cursorObjType = { +Tcl_ObjType tkCursorObjType = { "cursor", /* name */ FreeCursorObjProc, /* freeIntRepProc */ DupCursorObjProc, /* dupIntRepProc */ @@ -101,7 +101,7 @@ Tk_AllocCursorFromObj(interp, tkwin, objPtr) { TkCursor *cursorPtr; - if (objPtr->typePtr != &cursorObjType) { + if (objPtr->typePtr != &tkCursorObjType) { InitCursorObj(objPtr); } cursorPtr = (TkCursor *) objPtr->internalRep.twoPtrValue.ptr1; @@ -189,7 +189,7 @@ Tk_Cursor Tk_GetCursor(interp, tkwin, string) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ Tk_Window tkwin; /* Window in which cursor will be used. */ - char *string; /* Description of cursor. See manual entry + Tk_Uid string; /* Description of cursor. See manual entry * for details on legal syntax. */ { TkCursor *cursorPtr = GetCursor(interp, tkwin, string); @@ -230,7 +230,7 @@ static TkCursor * GetCursor(interp, tkwin, string) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ Tk_Window tkwin; /* Window in which cursor will be used. */ - char *string; /* Description of cursor. See manual entry + CONST char *string; /* Description of cursor. See manual entry * for details on legal syntax. */ { Tcl_HashEntry *nameHashPtr; @@ -276,13 +276,12 @@ GetCursor(interp, tkwin, string) cursorPtr->objRefCount = 0; cursorPtr->otherTable = &dispPtr->cursorNameTable; cursorPtr->hashPtr = nameHashPtr; - cursorPtr->nextPtr = NULL; + cursorPtr->nextPtr = existingCursorPtr; cursorPtr->idHashPtr = Tcl_CreateHashEntry(&dispPtr->cursorIdTable, (char *) cursorPtr->cursor, &new); if (!new) { panic("cursor already registered in Tk_GetCursor"); } - cursorPtr->nextPtr = existingCursorPtr; Tcl_SetHashValue(nameHashPtr, cursorPtr); Tcl_SetHashValue(cursorPtr->idHashPtr, cursorPtr); @@ -319,8 +318,8 @@ Tk_GetCursorFromData(interp, tkwin, source, mask, width, height, xHot, yHot, fg, bg) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ Tk_Window tkwin; /* Window in which cursor will be used. */ - char *source; /* Bitmap data for cursor shape. */ - char *mask; /* Bitmap data for cursor mask. */ + CONST char *source; /* Bitmap data for cursor shape. */ + CONST char *mask; /* Bitmap data for cursor mask. */ int width, height; /* Dimensions of cursor. */ int xHot, yHot; /* Location of hot-spot in cursor. */ Tk_Uid fg; /* Foreground color for cursor. */ @@ -384,6 +383,7 @@ Tk_GetCursorFromData(interp, tkwin, source, mask, width, height, cursorPtr->objRefCount = 0; cursorPtr->idHashPtr = Tcl_CreateHashEntry(&dispPtr->cursorIdTable, (char *) cursorPtr->cursor, &new); + cursorPtr->nextPtr = NULL; if (!new) { panic("cursor already registered in Tk_GetCursorFromData"); @@ -418,7 +418,7 @@ Tk_GetCursorFromData(interp, tkwin, source, mask, width, height, *-------------------------------------------------------------- */ -char * +CONST char * Tk_NameOfCursor(display, cursor) Display *display; /* Display for which cursor was allocated. */ Tk_Cursor cursor; /* Identifier for cursor whose name is @@ -694,7 +694,7 @@ GetCursorFromObj(tkwin, objPtr) Tcl_HashEntry *hashPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; - if (objPtr->typePtr != &cursorObjType) { + if (objPtr->typePtr != &tkCursorObjType) { InitCursorObj(objPtr); } @@ -770,7 +770,7 @@ InitCursorObj(objPtr) if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) { (*typePtr->freeIntRepProc)(objPtr); } - objPtr->typePtr = &cursorObjType; + objPtr->typePtr = &tkCursorObjType; objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) NULL; } @@ -866,5 +866,3 @@ TkDebugCursor(tkwin, name) } return resultPtr; } - - diff --git a/tk/generic/tkDecls.h b/tk/generic/tkDecls.h index c60345ad2f7..b80e12be9ad 100644 --- a/tk/generic/tkDecls.h +++ b/tk/generic/tkDecls.h @@ -50,7 +50,8 @@ EXTERN void Tk_3DVerticalBevel _ANSI_ARGS_((Tk_Window tkwin, int relief)); /* 5 */ EXTERN void Tk_AddOption _ANSI_ARGS_((Tk_Window tkwin, - char * name, char * value, int priority)); + CONST char * name, CONST char * value, + int priority)); /* 6 */ EXTERN void Tk_BindEvent _ANSI_ARGS_(( Tk_BindingTable bindingTable, @@ -66,7 +67,7 @@ EXTERN void Tk_CanvasEventuallyRedraw _ANSI_ARGS_(( int y2)); /* 9 */ EXTERN int Tk_CanvasGetCoord _ANSI_ARGS_((Tcl_Interp * interp, - Tk_Canvas canvas, char * str, + Tk_Canvas canvas, CONST char * str, double * doublePtr)); /* 10 */ EXTERN Tk_CanvasTextInfo * Tk_CanvasGetTextInfo _ANSI_ARGS_(( @@ -96,7 +97,7 @@ EXTERN void Tk_CanvasSetStippleOrigin _ANSI_ARGS_(( /* 18 */ EXTERN int Tk_CanvasTagsParseProc _ANSI_ARGS_(( ClientData clientData, Tcl_Interp * interp, - Tk_Window tkwin, char * value, + Tk_Window tkwin, CONST char * value, char * widgRec, int offset)); /* 19 */ EXTERN char * Tk_CanvasTagsPrintProc _ANSI_ARGS_(( @@ -130,16 +131,18 @@ EXTERN int Tk_ClipboardClear _ANSI_ARGS_((Tcl_Interp * interp, /* 27 */ EXTERN int Tk_ConfigureInfo _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_ConfigSpec * specs, - char * widgRec, char * argvName, int flags)); + char * widgRec, CONST char * argvName, + int flags)); /* 28 */ EXTERN int Tk_ConfigureValue _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_ConfigSpec * specs, - char * widgRec, char * argvName, int flags)); + char * widgRec, CONST char * argvName, + int flags)); /* 29 */ EXTERN int Tk_ConfigureWidget _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_ConfigSpec * specs, - int argc, char ** argv, char * widgRec, - int flags)); + int argc, CONST84 char ** argv, + char * widgRec, int flags)); /* 30 */ EXTERN void Tk_ConfigureWindow _ANSI_ARGS_((Tk_Window tkwin, unsigned int valueMask, @@ -155,8 +158,8 @@ EXTERN Tk_Window Tk_CoordsToWindow _ANSI_ARGS_((int rootX, int rootY, /* 33 */ EXTERN unsigned long Tk_CreateBinding _ANSI_ARGS_((Tcl_Interp * interp, Tk_BindingTable bindingTable, - ClientData object, char * eventStr, - char * command, int append)); + ClientData object, CONST char * eventStr, + CONST char * command, int append)); /* 34 */ EXTERN Tk_BindingTable Tk_CreateBindingTable _ANSI_ARGS_(( Tcl_Interp * interp)); @@ -187,16 +190,17 @@ EXTERN void Tk_CreateSelHandler _ANSI_ARGS_((Tk_Window tkwin, ClientData clientData, Atom format)); /* 42 */ EXTERN Tk_Window Tk_CreateWindow _ANSI_ARGS_((Tcl_Interp * interp, - Tk_Window parent, char * name, - char * screenName)); + Tk_Window parent, CONST char * name, + CONST char * screenName)); /* 43 */ EXTERN Tk_Window Tk_CreateWindowFromPath _ANSI_ARGS_(( Tcl_Interp * interp, Tk_Window tkwin, - char * pathName, char * screenName)); + CONST char * pathName, + CONST char * screenName)); /* 44 */ EXTERN int Tk_DefineBitmap _ANSI_ARGS_((Tcl_Interp * interp, - CONST char * name, char * source, int width, - int height)); + CONST char * name, CONST char * source, + int width, int height)); /* 45 */ EXTERN void Tk_DefineCursor _ANSI_ARGS_((Tk_Window window, Tk_Cursor cursor)); @@ -207,7 +211,7 @@ EXTERN void Tk_DeleteAllBindings _ANSI_ARGS_(( /* 47 */ EXTERN int Tk_DeleteBinding _ANSI_ARGS_((Tcl_Interp * interp, Tk_BindingTable bindingTable, - ClientData object, char * eventStr)); + ClientData object, CONST char * eventStr)); /* 48 */ EXTERN void Tk_DeleteBindingTable _ANSI_ARGS_(( Tk_BindingTable bindingTable)); @@ -223,14 +227,14 @@ EXTERN void Tk_DeleteGenericHandler _ANSI_ARGS_(( Tk_GenericProc * proc, ClientData clientData)); /* 52 */ EXTERN void Tk_DeleteImage _ANSI_ARGS_((Tcl_Interp * interp, - char * name)); + CONST char * name)); /* 53 */ EXTERN void Tk_DeleteSelHandler _ANSI_ARGS_((Tk_Window tkwin, Atom selection, Atom target)); /* 54 */ EXTERN void Tk_DestroyWindow _ANSI_ARGS_((Tk_Window tkwin)); /* 55 */ -EXTERN char * Tk_DisplayName _ANSI_ARGS_((Tk_Window tkwin)); +EXTERN CONST84_RETURN char * Tk_DisplayName _ANSI_ARGS_((Tk_Window tkwin)); /* 56 */ EXTERN int Tk_DistanceToTextLayout _ANSI_ARGS_(( Tk_TextLayout layout, int x, int y)); @@ -269,7 +273,7 @@ EXTERN void Tk_Fill3DRectangle _ANSI_ARGS_((Tk_Window tkwin, int borderWidth, int relief)); /* 64 */ EXTERN Tk_PhotoHandle Tk_FindPhoto _ANSI_ARGS_((Tcl_Interp * interp, - char * imageName)); + CONST char * imageName)); /* 65 */ EXTERN Font Tk_FontId _ANSI_ARGS_((Tk_Font font)); /* 66 */ @@ -318,24 +322,24 @@ EXTERN void Tk_GetAllBindings _ANSI_ARGS_((Tcl_Interp * interp, ClientData object)); /* 82 */ EXTERN int Tk_GetAnchor _ANSI_ARGS_((Tcl_Interp * interp, - char * str, Tk_Anchor * anchorPtr)); + CONST char * str, Tk_Anchor * anchorPtr)); /* 83 */ -EXTERN char * Tk_GetAtomName _ANSI_ARGS_((Tk_Window tkwin, +EXTERN CONST84_RETURN char * Tk_GetAtomName _ANSI_ARGS_((Tk_Window tkwin, Atom atom)); /* 84 */ -EXTERN char * Tk_GetBinding _ANSI_ARGS_((Tcl_Interp * interp, +EXTERN CONST84_RETURN char * Tk_GetBinding _ANSI_ARGS_((Tcl_Interp * interp, Tk_BindingTable bindingTable, - ClientData object, char * eventStr)); + ClientData object, CONST char * eventStr)); /* 85 */ EXTERN Pixmap Tk_GetBitmap _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * str)); /* 86 */ EXTERN Pixmap Tk_GetBitmapFromData _ANSI_ARGS_(( Tcl_Interp * interp, Tk_Window tkwin, - char * source, int width, int height)); + CONST char * source, int width, int height)); /* 87 */ EXTERN int Tk_GetCapStyle _ANSI_ARGS_((Tcl_Interp * interp, - char * str, int * capPtr)); + CONST char * str, int * capPtr)); /* 88 */ EXTERN XColor * Tk_GetColor _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_Uid name)); @@ -344,16 +348,16 @@ EXTERN XColor * Tk_GetColorByValue _ANSI_ARGS_((Tk_Window tkwin, XColor * colorPtr)); /* 90 */ EXTERN Colormap Tk_GetColormap _ANSI_ARGS_((Tcl_Interp * interp, - Tk_Window tkwin, char * str)); + Tk_Window tkwin, CONST char * str)); /* 91 */ EXTERN Tk_Cursor Tk_GetCursor _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_Uid str)); /* 92 */ EXTERN Tk_Cursor Tk_GetCursorFromData _ANSI_ARGS_(( Tcl_Interp * interp, Tk_Window tkwin, - char * source, char * mask, int width, - int height, int xHot, int yHot, Tk_Uid fg, - Tk_Uid bg)); + CONST char * source, CONST char * mask, + int width, int height, int xHot, int yHot, + Tk_Uid fg, Tk_Uid bg)); /* 93 */ EXTERN Tk_Font Tk_GetFont _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * str)); @@ -369,45 +373,46 @@ EXTERN GC Tk_GetGC _ANSI_ARGS_((Tk_Window tkwin, XGCValues * valuePtr)); /* 97 */ EXTERN Tk_Image Tk_GetImage _ANSI_ARGS_((Tcl_Interp * interp, - Tk_Window tkwin, char * name, + Tk_Window tkwin, CONST char * name, Tk_ImageChangedProc * changeProc, ClientData clientData)); /* 98 */ EXTERN ClientData Tk_GetImageMasterData _ANSI_ARGS_(( - Tcl_Interp * interp, char * name, + Tcl_Interp * interp, CONST char * name, Tk_ImageType ** typePtrPtr)); /* 99 */ EXTERN Tk_ItemType * Tk_GetItemTypes _ANSI_ARGS_((void)); /* 100 */ EXTERN int Tk_GetJoinStyle _ANSI_ARGS_((Tcl_Interp * interp, - char * str, int * joinPtr)); + CONST char * str, int * joinPtr)); /* 101 */ EXTERN int Tk_GetJustify _ANSI_ARGS_((Tcl_Interp * interp, - char * str, Tk_Justify * justifyPtr)); + CONST char * str, Tk_Justify * justifyPtr)); /* 102 */ EXTERN int Tk_GetNumMainWindows _ANSI_ARGS_((void)); /* 103 */ EXTERN Tk_Uid Tk_GetOption _ANSI_ARGS_((Tk_Window tkwin, - char * name, char * className)); + CONST char * name, CONST char * className)); /* 104 */ EXTERN int Tk_GetPixels _ANSI_ARGS_((Tcl_Interp * interp, - Tk_Window tkwin, char * str, int * intPtr)); + Tk_Window tkwin, CONST char * str, + int * intPtr)); /* 105 */ EXTERN Pixmap Tk_GetPixmap _ANSI_ARGS_((Display * display, Drawable d, int width, int height, int depth)); /* 106 */ EXTERN int Tk_GetRelief _ANSI_ARGS_((Tcl_Interp * interp, - char * name, int * reliefPtr)); + CONST char * name, int * reliefPtr)); /* 107 */ EXTERN void Tk_GetRootCoords _ANSI_ARGS_((Tk_Window tkwin, int * xPtr, int * yPtr)); /* 108 */ EXTERN int Tk_GetScrollInfo _ANSI_ARGS_((Tcl_Interp * interp, - int argc, char ** argv, double * dblPtr, - int * intPtr)); + int argc, CONST84 char ** argv, + double * dblPtr, int * intPtr)); /* 109 */ EXTERN int Tk_GetScreenMM _ANSI_ARGS_((Tcl_Interp * interp, - Tk_Window tkwin, char * str, + Tk_Window tkwin, CONST char * str, double * doublePtr)); /* 110 */ EXTERN int Tk_GetSelection _ANSI_ARGS_((Tcl_Interp * interp, @@ -417,8 +422,8 @@ EXTERN int Tk_GetSelection _ANSI_ARGS_((Tcl_Interp * interp, EXTERN Tk_Uid Tk_GetUid _ANSI_ARGS_((CONST char * str)); /* 112 */ EXTERN Visual * Tk_GetVisual _ANSI_ARGS_((Tcl_Interp * interp, - Tk_Window tkwin, char * str, int * depthPtr, - Colormap * colormapPtr)); + Tk_Window tkwin, CONST char * str, + int * depthPtr, Colormap * colormapPtr)); /* 113 */ EXTERN void Tk_GetVRootGeometry _ANSI_ARGS_((Tk_Window tkwin, int * xPtr, int * yPtr, int * widthPtr, @@ -439,7 +444,7 @@ EXTERN void Tk_ImageChanged _ANSI_ARGS_((Tk_ImageMaster master, EXTERN int Tk_Init _ANSI_ARGS_((Tcl_Interp * interp)); /* 119 */ EXTERN Atom Tk_InternAtom _ANSI_ARGS_((Tk_Window tkwin, - char * name)); + CONST char * name)); /* 120 */ EXTERN int Tk_IntersectTextLayout _ANSI_ARGS_(( Tk_TextLayout layout, int x, int y, @@ -471,47 +476,51 @@ EXTERN void Tk_MoveWindow _ANSI_ARGS_((Tk_Window tkwin, int x, EXTERN void Tk_MoveToplevelWindow _ANSI_ARGS_((Tk_Window tkwin, int x, int y)); /* 130 */ -EXTERN char * Tk_NameOf3DBorder _ANSI_ARGS_((Tk_3DBorder border)); +EXTERN CONST84_RETURN char * Tk_NameOf3DBorder _ANSI_ARGS_(( + Tk_3DBorder border)); /* 131 */ -EXTERN char * Tk_NameOfAnchor _ANSI_ARGS_((Tk_Anchor anchor)); +EXTERN CONST84_RETURN char * Tk_NameOfAnchor _ANSI_ARGS_((Tk_Anchor anchor)); /* 132 */ -EXTERN char * Tk_NameOfBitmap _ANSI_ARGS_((Display * display, +EXTERN CONST84_RETURN char * Tk_NameOfBitmap _ANSI_ARGS_((Display * display, Pixmap bitmap)); /* 133 */ -EXTERN char * Tk_NameOfCapStyle _ANSI_ARGS_((int cap)); +EXTERN CONST84_RETURN char * Tk_NameOfCapStyle _ANSI_ARGS_((int cap)); /* 134 */ -EXTERN char * Tk_NameOfColor _ANSI_ARGS_((XColor * colorPtr)); +EXTERN CONST84_RETURN char * Tk_NameOfColor _ANSI_ARGS_((XColor * colorPtr)); /* 135 */ -EXTERN char * Tk_NameOfCursor _ANSI_ARGS_((Display * display, +EXTERN CONST84_RETURN char * Tk_NameOfCursor _ANSI_ARGS_((Display * display, Tk_Cursor cursor)); /* 136 */ -EXTERN char * Tk_NameOfFont _ANSI_ARGS_((Tk_Font font)); +EXTERN CONST84_RETURN char * Tk_NameOfFont _ANSI_ARGS_((Tk_Font font)); /* 137 */ -EXTERN char * Tk_NameOfImage _ANSI_ARGS_(( +EXTERN CONST84_RETURN char * Tk_NameOfImage _ANSI_ARGS_(( Tk_ImageMaster imageMaster)); /* 138 */ -EXTERN char * Tk_NameOfJoinStyle _ANSI_ARGS_((int join)); +EXTERN CONST84_RETURN char * Tk_NameOfJoinStyle _ANSI_ARGS_((int join)); /* 139 */ -EXTERN char * Tk_NameOfJustify _ANSI_ARGS_((Tk_Justify justify)); +EXTERN CONST84_RETURN char * Tk_NameOfJustify _ANSI_ARGS_(( + Tk_Justify justify)); /* 140 */ -EXTERN char * Tk_NameOfRelief _ANSI_ARGS_((int relief)); +EXTERN CONST84_RETURN char * Tk_NameOfRelief _ANSI_ARGS_((int relief)); /* 141 */ EXTERN Tk_Window Tk_NameToWindow _ANSI_ARGS_((Tcl_Interp * interp, - char * pathName, Tk_Window tkwin)); + CONST char * pathName, Tk_Window tkwin)); /* 142 */ EXTERN void Tk_OwnSelection _ANSI_ARGS_((Tk_Window tkwin, Atom selection, Tk_LostSelProc * proc, ClientData clientData)); /* 143 */ EXTERN int Tk_ParseArgv _ANSI_ARGS_((Tcl_Interp * interp, - Tk_Window tkwin, int * argcPtr, char ** argv, - Tk_ArgvInfo * argTable, int flags)); + Tk_Window tkwin, int * argcPtr, + CONST84 char ** argv, Tk_ArgvInfo * argTable, + int flags)); /* 144 */ -EXTERN void Tk_PhotoPutBlock _ANSI_ARGS_((Tk_PhotoHandle handle, +EXTERN void Tk_PhotoPutBlock_NoComposite _ANSI_ARGS_(( + Tk_PhotoHandle handle, Tk_PhotoImageBlock * blockPtr, int x, int y, int width, int height)); /* 145 */ -EXTERN void Tk_PhotoPutZoomedBlock _ANSI_ARGS_(( +EXTERN void Tk_PhotoPutZoomedBlock_NoComposite _ANSI_ARGS_(( Tk_PhotoHandle handle, Tk_PhotoImageBlock * blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, @@ -560,14 +569,14 @@ EXTERN Tk_RestrictProc * Tk_RestrictEvents _ANSI_ARGS_(( /* 159 */ EXTERN int Tk_SafeInit _ANSI_ARGS_((Tcl_Interp * interp)); /* 160 */ -EXTERN char * Tk_SetAppName _ANSI_ARGS_((Tk_Window tkwin, - char * name)); +EXTERN CONST char * Tk_SetAppName _ANSI_ARGS_((Tk_Window tkwin, + CONST char * name)); /* 161 */ EXTERN void Tk_SetBackgroundFromBorder _ANSI_ARGS_(( Tk_Window tkwin, Tk_3DBorder border)); /* 162 */ EXTERN void Tk_SetClass _ANSI_ARGS_((Tk_Window tkwin, - char * className)); + CONST char * className)); /* 163 */ EXTERN void Tk_SetGrid _ANSI_ARGS_((Tk_Window tkwin, int reqWidth, int reqHeight, int gridWidth, @@ -820,6 +829,93 @@ EXTERN int Tk_PostscriptPhoto _ANSI_ARGS_((Tcl_Interp * interp, Tk_PhotoImageBlock * blockPtr, Tk_PostscriptInfo psInfo, int width, int height)); +/* 239 */ +EXTERN void Tk_CreateClientMessageHandler _ANSI_ARGS_(( + Tk_ClientMessageProc * proc)); +/* 240 */ +EXTERN void Tk_DeleteClientMessageHandler _ANSI_ARGS_(( + Tk_ClientMessageProc * proc)); +/* 241 */ +EXTERN Tk_Window Tk_CreateAnonymousWindow _ANSI_ARGS_(( + Tcl_Interp * interp, Tk_Window parent, + CONST char * screenName)); +/* 242 */ +EXTERN void Tk_SetClassProcs _ANSI_ARGS_((Tk_Window tkwin, + Tk_ClassProcs * procs, + ClientData instanceData)); +/* 243 */ +EXTERN void Tk_SetInternalBorderEx _ANSI_ARGS_((Tk_Window tkwin, + int left, int right, int top, int bottom)); +/* 244 */ +EXTERN void Tk_SetMinimumRequestSize _ANSI_ARGS_(( + Tk_Window tkwin, int minWidth, int minHeight)); +/* 245 */ +EXTERN void Tk_SetCaretPos _ANSI_ARGS_((Tk_Window tkwin, int x, + int y, int height)); +/* 246 */ +EXTERN void Tk_PhotoPutBlock _ANSI_ARGS_((Tk_PhotoHandle handle, + Tk_PhotoImageBlock * blockPtr, int x, int y, + int width, int height, int compRule)); +/* 247 */ +EXTERN void Tk_PhotoPutZoomedBlock _ANSI_ARGS_(( + Tk_PhotoHandle handle, + Tk_PhotoImageBlock * blockPtr, int x, int y, + int width, int height, int zoomX, int zoomY, + int subsampleX, int subsampleY, int compRule)); +/* 248 */ +EXTERN int Tk_CollapseMotionEvents _ANSI_ARGS_(( + Display * display, int collapse)); +/* 249 */ +EXTERN Tk_StyleEngine Tk_RegisterStyleEngine _ANSI_ARGS_(( + CONST char * name, Tk_StyleEngine parent)); +/* 250 */ +EXTERN Tk_StyleEngine Tk_GetStyleEngine _ANSI_ARGS_((CONST char * name)); +/* 251 */ +EXTERN int Tk_RegisterStyledElement _ANSI_ARGS_(( + Tk_StyleEngine engine, + Tk_ElementSpec * templatePtr)); +/* 252 */ +EXTERN int Tk_GetElementId _ANSI_ARGS_((CONST char * name)); +/* 253 */ +EXTERN Tk_Style Tk_CreateStyle _ANSI_ARGS_((CONST char * name, + Tk_StyleEngine engine, ClientData clientData)); +/* 254 */ +EXTERN Tk_Style Tk_GetStyle _ANSI_ARGS_((Tcl_Interp * interp, + CONST char * name)); +/* 255 */ +EXTERN void Tk_FreeStyle _ANSI_ARGS_((Tk_Style style)); +/* 256 */ +EXTERN CONST char * Tk_NameOfStyle _ANSI_ARGS_((Tk_Style style)); +/* 257 */ +EXTERN Tk_Style Tk_AllocStyleFromObj _ANSI_ARGS_(( + Tcl_Interp * interp, Tcl_Obj * objPtr)); +/* 258 */ +EXTERN Tk_Style Tk_GetStyleFromObj _ANSI_ARGS_((Tcl_Obj * objPtr)); +/* 259 */ +EXTERN void Tk_FreeStyleFromObj _ANSI_ARGS_((Tcl_Obj * objPtr)); +/* 260 */ +EXTERN Tk_StyledElement Tk_GetStyledElement _ANSI_ARGS_((Tk_Style style, + int elementId, Tk_OptionTable optionTable)); +/* 261 */ +EXTERN void Tk_GetElementSize _ANSI_ARGS_((Tk_Style style, + Tk_StyledElement element, char * recordPtr, + Tk_Window tkwin, int width, int height, + int inner, int * widthPtr, int * heightPtr)); +/* 262 */ +EXTERN void Tk_GetElementBox _ANSI_ARGS_((Tk_Style style, + Tk_StyledElement element, char * recordPtr, + Tk_Window tkwin, int x, int y, int width, + int height, int inner, int * xPtr, + int * yPtr, int * widthPtr, int * heightPtr)); +/* 263 */ +EXTERN int Tk_GetElementBorderWidth _ANSI_ARGS_((Tk_Style style, + Tk_StyledElement element, char * recordPtr, + Tk_Window tkwin)); +/* 264 */ +EXTERN void Tk_DrawElement _ANSI_ARGS_((Tk_Style style, + Tk_StyledElement element, char * recordPtr, + Tk_Window tkwin, Drawable d, int x, int y, + int width, int height, int state)); typedef struct TkStubHooks { struct TkPlatStubs *tkPlatStubs; @@ -837,11 +933,11 @@ typedef struct TkStubs { GC (*tk_3DBorderGC) _ANSI_ARGS_((Tk_Window tkwin, Tk_3DBorder border, int which)); /* 2 */ void (*tk_3DHorizontalBevel) _ANSI_ARGS_((Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, int x, int y, int width, int height, int leftIn, int rightIn, int topBevel, int relief)); /* 3 */ void (*tk_3DVerticalBevel) _ANSI_ARGS_((Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, int x, int y, int width, int height, int leftBevel, int relief)); /* 4 */ - void (*tk_AddOption) _ANSI_ARGS_((Tk_Window tkwin, char * name, char * value, int priority)); /* 5 */ + void (*tk_AddOption) _ANSI_ARGS_((Tk_Window tkwin, CONST char * name, CONST char * value, int priority)); /* 5 */ void (*tk_BindEvent) _ANSI_ARGS_((Tk_BindingTable bindingTable, XEvent * eventPtr, Tk_Window tkwin, int numObjects, ClientData * objectPtr)); /* 6 */ void (*tk_CanvasDrawableCoords) _ANSI_ARGS_((Tk_Canvas canvas, double x, double y, short * drawableXPtr, short * drawableYPtr)); /* 7 */ void (*tk_CanvasEventuallyRedraw) _ANSI_ARGS_((Tk_Canvas canvas, int x1, int y1, int x2, int y2)); /* 8 */ - int (*tk_CanvasGetCoord) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Canvas canvas, char * str, double * doublePtr)); /* 9 */ + int (*tk_CanvasGetCoord) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Canvas canvas, CONST char * str, double * doublePtr)); /* 9 */ Tk_CanvasTextInfo * (*tk_CanvasGetTextInfo) _ANSI_ARGS_((Tk_Canvas canvas)); /* 10 */ int (*tk_CanvasPsBitmap) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Canvas canvas, Pixmap bitmap, int x, int y, int width, int height)); /* 11 */ int (*tk_CanvasPsColor) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Canvas canvas, XColor * colorPtr)); /* 12 */ @@ -850,7 +946,7 @@ typedef struct TkStubs { int (*tk_CanvasPsStipple) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Canvas canvas, Pixmap bitmap)); /* 15 */ double (*tk_CanvasPsY) _ANSI_ARGS_((Tk_Canvas canvas, double y)); /* 16 */ void (*tk_CanvasSetStippleOrigin) _ANSI_ARGS_((Tk_Canvas canvas, GC gc)); /* 17 */ - int (*tk_CanvasTagsParseProc) _ANSI_ARGS_((ClientData clientData, Tcl_Interp * interp, Tk_Window tkwin, char * value, char * widgRec, int offset)); /* 18 */ + int (*tk_CanvasTagsParseProc) _ANSI_ARGS_((ClientData clientData, Tcl_Interp * interp, Tk_Window tkwin, CONST char * value, char * widgRec, int offset)); /* 18 */ char * (*tk_CanvasTagsPrintProc) _ANSI_ARGS_((ClientData clientData, Tk_Window tkwin, char * widgRec, int offset, Tcl_FreeProc ** freeProcPtr)); /* 19 */ Tk_Window (*tk_CanvasTkwin) _ANSI_ARGS_((Tk_Canvas canvas)); /* 20 */ void (*tk_CanvasWindowCoords) _ANSI_ARGS_((Tk_Canvas canvas, double x, double y, short * screenXPtr, short * screenYPtr)); /* 21 */ @@ -859,13 +955,13 @@ typedef struct TkStubs { void (*tk_ClearSelection) _ANSI_ARGS_((Tk_Window tkwin, Atom selection)); /* 24 */ int (*tk_ClipboardAppend) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Atom target, Atom format, char* buffer)); /* 25 */ int (*tk_ClipboardClear) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin)); /* 26 */ - int (*tk_ConfigureInfo) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_ConfigSpec * specs, char * widgRec, char * argvName, int flags)); /* 27 */ - int (*tk_ConfigureValue) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_ConfigSpec * specs, char * widgRec, char * argvName, int flags)); /* 28 */ - int (*tk_ConfigureWidget) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_ConfigSpec * specs, int argc, char ** argv, char * widgRec, int flags)); /* 29 */ + int (*tk_ConfigureInfo) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_ConfigSpec * specs, char * widgRec, CONST char * argvName, int flags)); /* 27 */ + int (*tk_ConfigureValue) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_ConfigSpec * specs, char * widgRec, CONST char * argvName, int flags)); /* 28 */ + int (*tk_ConfigureWidget) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_ConfigSpec * specs, int argc, CONST84 char ** argv, char * widgRec, int flags)); /* 29 */ void (*tk_ConfigureWindow) _ANSI_ARGS_((Tk_Window tkwin, unsigned int valueMask, XWindowChanges * valuePtr)); /* 30 */ Tk_TextLayout (*tk_ComputeTextLayout) _ANSI_ARGS_((Tk_Font font, CONST char * str, int numChars, int wrapLength, Tk_Justify justify, int flags, int * widthPtr, int * heightPtr)); /* 31 */ Tk_Window (*tk_CoordsToWindow) _ANSI_ARGS_((int rootX, int rootY, Tk_Window tkwin)); /* 32 */ - unsigned long (*tk_CreateBinding) _ANSI_ARGS_((Tcl_Interp * interp, Tk_BindingTable bindingTable, ClientData object, char * eventStr, char * command, int append)); /* 33 */ + unsigned long (*tk_CreateBinding) _ANSI_ARGS_((Tcl_Interp * interp, Tk_BindingTable bindingTable, ClientData object, CONST char * eventStr, CONST char * command, int append)); /* 33 */ Tk_BindingTable (*tk_CreateBindingTable) _ANSI_ARGS_((Tcl_Interp * interp)); /* 34 */ Tk_ErrorHandler (*tk_CreateErrorHandler) _ANSI_ARGS_((Display * display, int errNum, int request, int minorCode, Tk_ErrorProc * errorProc, ClientData clientData)); /* 35 */ void (*tk_CreateEventHandler) _ANSI_ARGS_((Tk_Window token, unsigned long mask, Tk_EventProc * proc, ClientData clientData)); /* 36 */ @@ -874,20 +970,20 @@ typedef struct TkStubs { void (*tk_CreateItemType) _ANSI_ARGS_((Tk_ItemType * typePtr)); /* 39 */ void (*tk_CreatePhotoImageFormat) _ANSI_ARGS_((Tk_PhotoImageFormat * formatPtr)); /* 40 */ void (*tk_CreateSelHandler) _ANSI_ARGS_((Tk_Window tkwin, Atom selection, Atom target, Tk_SelectionProc * proc, ClientData clientData, Atom format)); /* 41 */ - Tk_Window (*tk_CreateWindow) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window parent, char * name, char * screenName)); /* 42 */ - Tk_Window (*tk_CreateWindowFromPath) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * pathName, char * screenName)); /* 43 */ - int (*tk_DefineBitmap) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * name, char * source, int width, int height)); /* 44 */ + Tk_Window (*tk_CreateWindow) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window parent, CONST char * name, CONST char * screenName)); /* 42 */ + Tk_Window (*tk_CreateWindowFromPath) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * pathName, CONST char * screenName)); /* 43 */ + int (*tk_DefineBitmap) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * name, CONST char * source, int width, int height)); /* 44 */ void (*tk_DefineCursor) _ANSI_ARGS_((Tk_Window window, Tk_Cursor cursor)); /* 45 */ void (*tk_DeleteAllBindings) _ANSI_ARGS_((Tk_BindingTable bindingTable, ClientData object)); /* 46 */ - int (*tk_DeleteBinding) _ANSI_ARGS_((Tcl_Interp * interp, Tk_BindingTable bindingTable, ClientData object, char * eventStr)); /* 47 */ + int (*tk_DeleteBinding) _ANSI_ARGS_((Tcl_Interp * interp, Tk_BindingTable bindingTable, ClientData object, CONST char * eventStr)); /* 47 */ void (*tk_DeleteBindingTable) _ANSI_ARGS_((Tk_BindingTable bindingTable)); /* 48 */ void (*tk_DeleteErrorHandler) _ANSI_ARGS_((Tk_ErrorHandler handler)); /* 49 */ void (*tk_DeleteEventHandler) _ANSI_ARGS_((Tk_Window token, unsigned long mask, Tk_EventProc * proc, ClientData clientData)); /* 50 */ void (*tk_DeleteGenericHandler) _ANSI_ARGS_((Tk_GenericProc * proc, ClientData clientData)); /* 51 */ - void (*tk_DeleteImage) _ANSI_ARGS_((Tcl_Interp * interp, char * name)); /* 52 */ + void (*tk_DeleteImage) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * name)); /* 52 */ void (*tk_DeleteSelHandler) _ANSI_ARGS_((Tk_Window tkwin, Atom selection, Atom target)); /* 53 */ void (*tk_DestroyWindow) _ANSI_ARGS_((Tk_Window tkwin)); /* 54 */ - char * (*tk_DisplayName) _ANSI_ARGS_((Tk_Window tkwin)); /* 55 */ + CONST84_RETURN char * (*tk_DisplayName) _ANSI_ARGS_((Tk_Window tkwin)); /* 55 */ int (*tk_DistanceToTextLayout) _ANSI_ARGS_((Tk_TextLayout layout, int x, int y)); /* 56 */ void (*tk_Draw3DPolygon) _ANSI_ARGS_((Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, XPoint * pointPtr, int numPoints, int borderWidth, int leftRelief)); /* 57 */ void (*tk_Draw3DRectangle) _ANSI_ARGS_((Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, int x, int y, int width, int height, int borderWidth, int relief)); /* 58 */ @@ -896,7 +992,7 @@ typedef struct TkStubs { void (*tk_DrawTextLayout) _ANSI_ARGS_((Display * display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, int firstChar, int lastChar)); /* 61 */ void (*tk_Fill3DPolygon) _ANSI_ARGS_((Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, XPoint * pointPtr, int numPoints, int borderWidth, int leftRelief)); /* 62 */ void (*tk_Fill3DRectangle) _ANSI_ARGS_((Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, int x, int y, int width, int height, int borderWidth, int relief)); /* 63 */ - Tk_PhotoHandle (*tk_FindPhoto) _ANSI_ARGS_((Tcl_Interp * interp, char * imageName)); /* 64 */ + Tk_PhotoHandle (*tk_FindPhoto) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * imageName)); /* 64 */ Font (*tk_FontId) _ANSI_ARGS_((Tk_Font font)); /* 65 */ void (*tk_Free3DBorder) _ANSI_ARGS_((Tk_3DBorder border)); /* 66 */ void (*tk_FreeBitmap) _ANSI_ARGS_((Display * display, Pixmap bitmap)); /* 67 */ @@ -914,44 +1010,44 @@ typedef struct TkStubs { void (*tk_GeometryRequest) _ANSI_ARGS_((Tk_Window tkwin, int reqWidth, int reqHeight)); /* 79 */ Tk_3DBorder (*tk_Get3DBorder) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_Uid colorName)); /* 80 */ void (*tk_GetAllBindings) _ANSI_ARGS_((Tcl_Interp * interp, Tk_BindingTable bindingTable, ClientData object)); /* 81 */ - int (*tk_GetAnchor) _ANSI_ARGS_((Tcl_Interp * interp, char * str, Tk_Anchor * anchorPtr)); /* 82 */ - char * (*tk_GetAtomName) _ANSI_ARGS_((Tk_Window tkwin, Atom atom)); /* 83 */ - char * (*tk_GetBinding) _ANSI_ARGS_((Tcl_Interp * interp, Tk_BindingTable bindingTable, ClientData object, char * eventStr)); /* 84 */ + int (*tk_GetAnchor) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * str, Tk_Anchor * anchorPtr)); /* 82 */ + CONST84_RETURN char * (*tk_GetAtomName) _ANSI_ARGS_((Tk_Window tkwin, Atom atom)); /* 83 */ + CONST84_RETURN char * (*tk_GetBinding) _ANSI_ARGS_((Tcl_Interp * interp, Tk_BindingTable bindingTable, ClientData object, CONST char * eventStr)); /* 84 */ Pixmap (*tk_GetBitmap) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * str)); /* 85 */ - Pixmap (*tk_GetBitmapFromData) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * source, int width, int height)); /* 86 */ - int (*tk_GetCapStyle) _ANSI_ARGS_((Tcl_Interp * interp, char * str, int * capPtr)); /* 87 */ + Pixmap (*tk_GetBitmapFromData) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * source, int width, int height)); /* 86 */ + int (*tk_GetCapStyle) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * str, int * capPtr)); /* 87 */ XColor * (*tk_GetColor) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_Uid name)); /* 88 */ XColor * (*tk_GetColorByValue) _ANSI_ARGS_((Tk_Window tkwin, XColor * colorPtr)); /* 89 */ - Colormap (*tk_GetColormap) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * str)); /* 90 */ + Colormap (*tk_GetColormap) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * str)); /* 90 */ Tk_Cursor (*tk_GetCursor) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_Uid str)); /* 91 */ - Tk_Cursor (*tk_GetCursorFromData) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * source, char * mask, int width, int height, int xHot, int yHot, Tk_Uid fg, Tk_Uid bg)); /* 92 */ + Tk_Cursor (*tk_GetCursorFromData) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * source, CONST char * mask, int width, int height, int xHot, int yHot, Tk_Uid fg, Tk_Uid bg)); /* 92 */ Tk_Font (*tk_GetFont) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * str)); /* 93 */ Tk_Font (*tk_GetFontFromObj) _ANSI_ARGS_((Tk_Window tkwin, Tcl_Obj * objPtr)); /* 94 */ void (*tk_GetFontMetrics) _ANSI_ARGS_((Tk_Font font, Tk_FontMetrics * fmPtr)); /* 95 */ GC (*tk_GetGC) _ANSI_ARGS_((Tk_Window tkwin, unsigned long valueMask, XGCValues * valuePtr)); /* 96 */ - Tk_Image (*tk_GetImage) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * name, Tk_ImageChangedProc * changeProc, ClientData clientData)); /* 97 */ - ClientData (*tk_GetImageMasterData) _ANSI_ARGS_((Tcl_Interp * interp, char * name, Tk_ImageType ** typePtrPtr)); /* 98 */ + Tk_Image (*tk_GetImage) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * name, Tk_ImageChangedProc * changeProc, ClientData clientData)); /* 97 */ + ClientData (*tk_GetImageMasterData) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * name, Tk_ImageType ** typePtrPtr)); /* 98 */ Tk_ItemType * (*tk_GetItemTypes) _ANSI_ARGS_((void)); /* 99 */ - int (*tk_GetJoinStyle) _ANSI_ARGS_((Tcl_Interp * interp, char * str, int * joinPtr)); /* 100 */ - int (*tk_GetJustify) _ANSI_ARGS_((Tcl_Interp * interp, char * str, Tk_Justify * justifyPtr)); /* 101 */ + int (*tk_GetJoinStyle) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * str, int * joinPtr)); /* 100 */ + int (*tk_GetJustify) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * str, Tk_Justify * justifyPtr)); /* 101 */ int (*tk_GetNumMainWindows) _ANSI_ARGS_((void)); /* 102 */ - Tk_Uid (*tk_GetOption) _ANSI_ARGS_((Tk_Window tkwin, char * name, char * className)); /* 103 */ - int (*tk_GetPixels) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * str, int * intPtr)); /* 104 */ + Tk_Uid (*tk_GetOption) _ANSI_ARGS_((Tk_Window tkwin, CONST char * name, CONST char * className)); /* 103 */ + int (*tk_GetPixels) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * str, int * intPtr)); /* 104 */ Pixmap (*tk_GetPixmap) _ANSI_ARGS_((Display * display, Drawable d, int width, int height, int depth)); /* 105 */ - int (*tk_GetRelief) _ANSI_ARGS_((Tcl_Interp * interp, char * name, int * reliefPtr)); /* 106 */ + int (*tk_GetRelief) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * name, int * reliefPtr)); /* 106 */ void (*tk_GetRootCoords) _ANSI_ARGS_((Tk_Window tkwin, int * xPtr, int * yPtr)); /* 107 */ - int (*tk_GetScrollInfo) _ANSI_ARGS_((Tcl_Interp * interp, int argc, char ** argv, double * dblPtr, int * intPtr)); /* 108 */ - int (*tk_GetScreenMM) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * str, double * doublePtr)); /* 109 */ + int (*tk_GetScrollInfo) _ANSI_ARGS_((Tcl_Interp * interp, int argc, CONST84 char ** argv, double * dblPtr, int * intPtr)); /* 108 */ + int (*tk_GetScreenMM) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * str, double * doublePtr)); /* 109 */ int (*tk_GetSelection) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Atom selection, Atom target, Tk_GetSelProc * proc, ClientData clientData)); /* 110 */ Tk_Uid (*tk_GetUid) _ANSI_ARGS_((CONST char * str)); /* 111 */ - Visual * (*tk_GetVisual) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * str, int * depthPtr, Colormap * colormapPtr)); /* 112 */ + Visual * (*tk_GetVisual) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * str, int * depthPtr, Colormap * colormapPtr)); /* 112 */ void (*tk_GetVRootGeometry) _ANSI_ARGS_((Tk_Window tkwin, int * xPtr, int * yPtr, int * widthPtr, int * heightPtr)); /* 113 */ int (*tk_Grab) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, int grabGlobal)); /* 114 */ void (*tk_HandleEvent) _ANSI_ARGS_((XEvent * eventPtr)); /* 115 */ Tk_Window (*tk_IdToWindow) _ANSI_ARGS_((Display * display, Window window)); /* 116 */ void (*tk_ImageChanged) _ANSI_ARGS_((Tk_ImageMaster master, int x, int y, int width, int height, int imageWidth, int imageHeight)); /* 117 */ int (*tk_Init) _ANSI_ARGS_((Tcl_Interp * interp)); /* 118 */ - Atom (*tk_InternAtom) _ANSI_ARGS_((Tk_Window tkwin, char * name)); /* 119 */ + Atom (*tk_InternAtom) _ANSI_ARGS_((Tk_Window tkwin, CONST char * name)); /* 119 */ int (*tk_IntersectTextLayout) _ANSI_ARGS_((Tk_TextLayout layout, int x, int y, int width, int height)); /* 120 */ void (*tk_MaintainGeometry) _ANSI_ARGS_((Tk_Window slave, Tk_Window master, int x, int y, int width, int height)); /* 121 */ Tk_Window (*tk_MainWindow) _ANSI_ARGS_((Tcl_Interp * interp)); /* 122 */ @@ -962,22 +1058,22 @@ typedef struct TkStubs { void (*tk_MoveResizeWindow) _ANSI_ARGS_((Tk_Window tkwin, int x, int y, int width, int height)); /* 127 */ void (*tk_MoveWindow) _ANSI_ARGS_((Tk_Window tkwin, int x, int y)); /* 128 */ void (*tk_MoveToplevelWindow) _ANSI_ARGS_((Tk_Window tkwin, int x, int y)); /* 129 */ - char * (*tk_NameOf3DBorder) _ANSI_ARGS_((Tk_3DBorder border)); /* 130 */ - char * (*tk_NameOfAnchor) _ANSI_ARGS_((Tk_Anchor anchor)); /* 131 */ - char * (*tk_NameOfBitmap) _ANSI_ARGS_((Display * display, Pixmap bitmap)); /* 132 */ - char * (*tk_NameOfCapStyle) _ANSI_ARGS_((int cap)); /* 133 */ - char * (*tk_NameOfColor) _ANSI_ARGS_((XColor * colorPtr)); /* 134 */ - char * (*tk_NameOfCursor) _ANSI_ARGS_((Display * display, Tk_Cursor cursor)); /* 135 */ - char * (*tk_NameOfFont) _ANSI_ARGS_((Tk_Font font)); /* 136 */ - char * (*tk_NameOfImage) _ANSI_ARGS_((Tk_ImageMaster imageMaster)); /* 137 */ - char * (*tk_NameOfJoinStyle) _ANSI_ARGS_((int join)); /* 138 */ - char * (*tk_NameOfJustify) _ANSI_ARGS_((Tk_Justify justify)); /* 139 */ - char * (*tk_NameOfRelief) _ANSI_ARGS_((int relief)); /* 140 */ - Tk_Window (*tk_NameToWindow) _ANSI_ARGS_((Tcl_Interp * interp, char * pathName, Tk_Window tkwin)); /* 141 */ + CONST84_RETURN char * (*tk_NameOf3DBorder) _ANSI_ARGS_((Tk_3DBorder border)); /* 130 */ + CONST84_RETURN char * (*tk_NameOfAnchor) _ANSI_ARGS_((Tk_Anchor anchor)); /* 131 */ + CONST84_RETURN char * (*tk_NameOfBitmap) _ANSI_ARGS_((Display * display, Pixmap bitmap)); /* 132 */ + CONST84_RETURN char * (*tk_NameOfCapStyle) _ANSI_ARGS_((int cap)); /* 133 */ + CONST84_RETURN char * (*tk_NameOfColor) _ANSI_ARGS_((XColor * colorPtr)); /* 134 */ + CONST84_RETURN char * (*tk_NameOfCursor) _ANSI_ARGS_((Display * display, Tk_Cursor cursor)); /* 135 */ + CONST84_RETURN char * (*tk_NameOfFont) _ANSI_ARGS_((Tk_Font font)); /* 136 */ + CONST84_RETURN char * (*tk_NameOfImage) _ANSI_ARGS_((Tk_ImageMaster imageMaster)); /* 137 */ + CONST84_RETURN char * (*tk_NameOfJoinStyle) _ANSI_ARGS_((int join)); /* 138 */ + CONST84_RETURN char * (*tk_NameOfJustify) _ANSI_ARGS_((Tk_Justify justify)); /* 139 */ + CONST84_RETURN char * (*tk_NameOfRelief) _ANSI_ARGS_((int relief)); /* 140 */ + Tk_Window (*tk_NameToWindow) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * pathName, Tk_Window tkwin)); /* 141 */ void (*tk_OwnSelection) _ANSI_ARGS_((Tk_Window tkwin, Atom selection, Tk_LostSelProc * proc, ClientData clientData)); /* 142 */ - int (*tk_ParseArgv) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, int * argcPtr, char ** argv, Tk_ArgvInfo * argTable, int flags)); /* 143 */ - void (*tk_PhotoPutBlock) _ANSI_ARGS_((Tk_PhotoHandle handle, Tk_PhotoImageBlock * blockPtr, int x, int y, int width, int height)); /* 144 */ - void (*tk_PhotoPutZoomedBlock) _ANSI_ARGS_((Tk_PhotoHandle handle, Tk_PhotoImageBlock * blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY)); /* 145 */ + int (*tk_ParseArgv) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, int * argcPtr, CONST84 char ** argv, Tk_ArgvInfo * argTable, int flags)); /* 143 */ + void (*tk_PhotoPutBlock_NoComposite) _ANSI_ARGS_((Tk_PhotoHandle handle, Tk_PhotoImageBlock * blockPtr, int x, int y, int width, int height)); /* 144 */ + void (*tk_PhotoPutZoomedBlock_NoComposite) _ANSI_ARGS_((Tk_PhotoHandle handle, Tk_PhotoImageBlock * blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY)); /* 145 */ int (*tk_PhotoGetImage) _ANSI_ARGS_((Tk_PhotoHandle handle, Tk_PhotoImageBlock * blockPtr)); /* 146 */ void (*tk_PhotoBlank) _ANSI_ARGS_((Tk_PhotoHandle handle)); /* 147 */ void (*tk_PhotoExpand) _ANSI_ARGS_((Tk_PhotoHandle handle, int width, int height)); /* 148 */ @@ -992,9 +1088,9 @@ typedef struct TkStubs { int (*tk_RestackWindow) _ANSI_ARGS_((Tk_Window tkwin, int aboveBelow, Tk_Window other)); /* 157 */ Tk_RestrictProc * (*tk_RestrictEvents) _ANSI_ARGS_((Tk_RestrictProc * proc, ClientData arg, ClientData * prevArgPtr)); /* 158 */ int (*tk_SafeInit) _ANSI_ARGS_((Tcl_Interp * interp)); /* 159 */ - char * (*tk_SetAppName) _ANSI_ARGS_((Tk_Window tkwin, char * name)); /* 160 */ + CONST char * (*tk_SetAppName) _ANSI_ARGS_((Tk_Window tkwin, CONST char * name)); /* 160 */ void (*tk_SetBackgroundFromBorder) _ANSI_ARGS_((Tk_Window tkwin, Tk_3DBorder border)); /* 161 */ - void (*tk_SetClass) _ANSI_ARGS_((Tk_Window tkwin, char * className)); /* 162 */ + void (*tk_SetClass) _ANSI_ARGS_((Tk_Window tkwin, CONST char * className)); /* 162 */ void (*tk_SetGrid) _ANSI_ARGS_((Tk_Window tkwin, int reqWidth, int reqHeight, int gridWidth, int gridHeight)); /* 163 */ void (*tk_SetInternalBorder) _ANSI_ARGS_((Tk_Window tkwin, int width)); /* 164 */ void (*tk_SetWindowBackground) _ANSI_ARGS_((Tk_Window tkwin, unsigned long pixel)); /* 165 */ @@ -1071,6 +1167,32 @@ typedef struct TkStubs { int (*tk_PostscriptStipple) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_PostscriptInfo psInfo, Pixmap bitmap)); /* 236 */ double (*tk_PostscriptY) _ANSI_ARGS_((double y, Tk_PostscriptInfo psInfo)); /* 237 */ int (*tk_PostscriptPhoto) _ANSI_ARGS_((Tcl_Interp * interp, Tk_PhotoImageBlock * blockPtr, Tk_PostscriptInfo psInfo, int width, int height)); /* 238 */ + void (*tk_CreateClientMessageHandler) _ANSI_ARGS_((Tk_ClientMessageProc * proc)); /* 239 */ + void (*tk_DeleteClientMessageHandler) _ANSI_ARGS_((Tk_ClientMessageProc * proc)); /* 240 */ + Tk_Window (*tk_CreateAnonymousWindow) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window parent, CONST char * screenName)); /* 241 */ + void (*tk_SetClassProcs) _ANSI_ARGS_((Tk_Window tkwin, Tk_ClassProcs * procs, ClientData instanceData)); /* 242 */ + void (*tk_SetInternalBorderEx) _ANSI_ARGS_((Tk_Window tkwin, int left, int right, int top, int bottom)); /* 243 */ + void (*tk_SetMinimumRequestSize) _ANSI_ARGS_((Tk_Window tkwin, int minWidth, int minHeight)); /* 244 */ + void (*tk_SetCaretPos) _ANSI_ARGS_((Tk_Window tkwin, int x, int y, int height)); /* 245 */ + void (*tk_PhotoPutBlock) _ANSI_ARGS_((Tk_PhotoHandle handle, Tk_PhotoImageBlock * blockPtr, int x, int y, int width, int height, int compRule)); /* 246 */ + void (*tk_PhotoPutZoomedBlock) _ANSI_ARGS_((Tk_PhotoHandle handle, Tk_PhotoImageBlock * blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY, int compRule)); /* 247 */ + int (*tk_CollapseMotionEvents) _ANSI_ARGS_((Display * display, int collapse)); /* 248 */ + Tk_StyleEngine (*tk_RegisterStyleEngine) _ANSI_ARGS_((CONST char * name, Tk_StyleEngine parent)); /* 249 */ + Tk_StyleEngine (*tk_GetStyleEngine) _ANSI_ARGS_((CONST char * name)); /* 250 */ + int (*tk_RegisterStyledElement) _ANSI_ARGS_((Tk_StyleEngine engine, Tk_ElementSpec * templatePtr)); /* 251 */ + int (*tk_GetElementId) _ANSI_ARGS_((CONST char * name)); /* 252 */ + Tk_Style (*tk_CreateStyle) _ANSI_ARGS_((CONST char * name, Tk_StyleEngine engine, ClientData clientData)); /* 253 */ + Tk_Style (*tk_GetStyle) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * name)); /* 254 */ + void (*tk_FreeStyle) _ANSI_ARGS_((Tk_Style style)); /* 255 */ + CONST char * (*tk_NameOfStyle) _ANSI_ARGS_((Tk_Style style)); /* 256 */ + Tk_Style (*tk_AllocStyleFromObj) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * objPtr)); /* 257 */ + Tk_Style (*tk_GetStyleFromObj) _ANSI_ARGS_((Tcl_Obj * objPtr)); /* 258 */ + void (*tk_FreeStyleFromObj) _ANSI_ARGS_((Tcl_Obj * objPtr)); /* 259 */ + Tk_StyledElement (*tk_GetStyledElement) _ANSI_ARGS_((Tk_Style style, int elementId, Tk_OptionTable optionTable)); /* 260 */ + void (*tk_GetElementSize) _ANSI_ARGS_((Tk_Style style, Tk_StyledElement element, char * recordPtr, Tk_Window tkwin, int width, int height, int inner, int * widthPtr, int * heightPtr)); /* 261 */ + void (*tk_GetElementBox) _ANSI_ARGS_((Tk_Style style, Tk_StyledElement element, char * recordPtr, Tk_Window tkwin, int x, int y, int width, int height, int inner, int * xPtr, int * yPtr, int * widthPtr, int * heightPtr)); /* 262 */ + int (*tk_GetElementBorderWidth) _ANSI_ARGS_((Tk_Style style, Tk_StyledElement element, char * recordPtr, Tk_Window tkwin)); /* 263 */ + void (*tk_DrawElement) _ANSI_ARGS_((Tk_Style style, Tk_StyledElement element, char * recordPtr, Tk_Window tkwin, Drawable d, int x, int y, int width, int height, int state)); /* 264 */ } TkStubs; #ifdef __cplusplus @@ -1663,13 +1785,13 @@ extern TkStubs *tkStubsPtr; #define Tk_ParseArgv \ (tkStubsPtr->tk_ParseArgv) /* 143 */ #endif -#ifndef Tk_PhotoPutBlock -#define Tk_PhotoPutBlock \ - (tkStubsPtr->tk_PhotoPutBlock) /* 144 */ +#ifndef Tk_PhotoPutBlock_NoComposite +#define Tk_PhotoPutBlock_NoComposite \ + (tkStubsPtr->tk_PhotoPutBlock_NoComposite) /* 144 */ #endif -#ifndef Tk_PhotoPutZoomedBlock -#define Tk_PhotoPutZoomedBlock \ - (tkStubsPtr->tk_PhotoPutZoomedBlock) /* 145 */ +#ifndef Tk_PhotoPutZoomedBlock_NoComposite +#define Tk_PhotoPutZoomedBlock_NoComposite \ + (tkStubsPtr->tk_PhotoPutZoomedBlock_NoComposite) /* 145 */ #endif #ifndef Tk_PhotoGetImage #define Tk_PhotoGetImage \ @@ -2037,6 +2159,110 @@ extern TkStubs *tkStubsPtr; #define Tk_PostscriptPhoto \ (tkStubsPtr->tk_PostscriptPhoto) /* 238 */ #endif +#ifndef Tk_CreateClientMessageHandler +#define Tk_CreateClientMessageHandler \ + (tkStubsPtr->tk_CreateClientMessageHandler) /* 239 */ +#endif +#ifndef Tk_DeleteClientMessageHandler +#define Tk_DeleteClientMessageHandler \ + (tkStubsPtr->tk_DeleteClientMessageHandler) /* 240 */ +#endif +#ifndef Tk_CreateAnonymousWindow +#define Tk_CreateAnonymousWindow \ + (tkStubsPtr->tk_CreateAnonymousWindow) /* 241 */ +#endif +#ifndef Tk_SetClassProcs +#define Tk_SetClassProcs \ + (tkStubsPtr->tk_SetClassProcs) /* 242 */ +#endif +#ifndef Tk_SetInternalBorderEx +#define Tk_SetInternalBorderEx \ + (tkStubsPtr->tk_SetInternalBorderEx) /* 243 */ +#endif +#ifndef Tk_SetMinimumRequestSize +#define Tk_SetMinimumRequestSize \ + (tkStubsPtr->tk_SetMinimumRequestSize) /* 244 */ +#endif +#ifndef Tk_SetCaretPos +#define Tk_SetCaretPos \ + (tkStubsPtr->tk_SetCaretPos) /* 245 */ +#endif +#ifndef Tk_PhotoPutBlock +#define Tk_PhotoPutBlock \ + (tkStubsPtr->tk_PhotoPutBlock) /* 246 */ +#endif +#ifndef Tk_PhotoPutZoomedBlock +#define Tk_PhotoPutZoomedBlock \ + (tkStubsPtr->tk_PhotoPutZoomedBlock) /* 247 */ +#endif +#ifndef Tk_CollapseMotionEvents +#define Tk_CollapseMotionEvents \ + (tkStubsPtr->tk_CollapseMotionEvents) /* 248 */ +#endif +#ifndef Tk_RegisterStyleEngine +#define Tk_RegisterStyleEngine \ + (tkStubsPtr->tk_RegisterStyleEngine) /* 249 */ +#endif +#ifndef Tk_GetStyleEngine +#define Tk_GetStyleEngine \ + (tkStubsPtr->tk_GetStyleEngine) /* 250 */ +#endif +#ifndef Tk_RegisterStyledElement +#define Tk_RegisterStyledElement \ + (tkStubsPtr->tk_RegisterStyledElement) /* 251 */ +#endif +#ifndef Tk_GetElementId +#define Tk_GetElementId \ + (tkStubsPtr->tk_GetElementId) /* 252 */ +#endif +#ifndef Tk_CreateStyle +#define Tk_CreateStyle \ + (tkStubsPtr->tk_CreateStyle) /* 253 */ +#endif +#ifndef Tk_GetStyle +#define Tk_GetStyle \ + (tkStubsPtr->tk_GetStyle) /* 254 */ +#endif +#ifndef Tk_FreeStyle +#define Tk_FreeStyle \ + (tkStubsPtr->tk_FreeStyle) /* 255 */ +#endif +#ifndef Tk_NameOfStyle +#define Tk_NameOfStyle \ + (tkStubsPtr->tk_NameOfStyle) /* 256 */ +#endif +#ifndef Tk_AllocStyleFromObj +#define Tk_AllocStyleFromObj \ + (tkStubsPtr->tk_AllocStyleFromObj) /* 257 */ +#endif +#ifndef Tk_GetStyleFromObj +#define Tk_GetStyleFromObj \ + (tkStubsPtr->tk_GetStyleFromObj) /* 258 */ +#endif +#ifndef Tk_FreeStyleFromObj +#define Tk_FreeStyleFromObj \ + (tkStubsPtr->tk_FreeStyleFromObj) /* 259 */ +#endif +#ifndef Tk_GetStyledElement +#define Tk_GetStyledElement \ + (tkStubsPtr->tk_GetStyledElement) /* 260 */ +#endif +#ifndef Tk_GetElementSize +#define Tk_GetElementSize \ + (tkStubsPtr->tk_GetElementSize) /* 261 */ +#endif +#ifndef Tk_GetElementBox +#define Tk_GetElementBox \ + (tkStubsPtr->tk_GetElementBox) /* 262 */ +#endif +#ifndef Tk_GetElementBorderWidth +#define Tk_GetElementBorderWidth \ + (tkStubsPtr->tk_GetElementBorderWidth) /* 263 */ +#endif +#ifndef Tk_DrawElement +#define Tk_DrawElement \ + (tkStubsPtr->tk_DrawElement) /* 264 */ +#endif #endif /* defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) */ @@ -2047,4 +2273,3 @@ extern TkStubs *tkStubsPtr; #endif /* _TKDECLS */ - diff --git a/tk/generic/tkEntry.c b/tk/generic/tkEntry.c index 6ed11d6f9b7..5ab3846d292 100644 --- a/tk/generic/tkEntry.c +++ b/tk/generic/tkEntry.c @@ -1,12 +1,15 @@ /* - * tkEntry.c -- + * Entry.c -- * - * This module implements entry widgets for the Tk - * toolkit. An entry displays a string and allows - * the string to be edited. + * This module implements entry and spinbox widgets for the Tk toolkit. + * An entry displays a string and allows the string to be edited. + * A spinbox expands on the entry by adding up/down buttons that control + * the value of the entry widget. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright (c) 2000 Ajuba Solutions. + * Copyright (c) 2002 ActiveState Corporation. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -17,8 +20,12 @@ #include "tkInt.h" #include "default.h" +enum EntryType { + TK_ENTRY, TK_SPINBOX +}; + /* - * A data structure of the following type is kept for each entry + * A data structure of the following type is kept for each Entry * widget managed by this file: */ @@ -34,13 +41,13 @@ typedef struct { Tcl_Command widgetCmd; /* Token for entry's widget command. */ Tk_OptionTable optionTable; /* Table that defines configuration options * available for this widget. */ - + enum EntryType type; /* Specialized type of Entry widget */ /* * Fields that are set by widget commands other than "configure". */ - char *string; /* Pointer to storage for string; + CONST char *string; /* Pointer to storage for string; * NULL-terminated; malloc-ed. */ int insertPos; /* Character index before which next typed * character will be inserted. */ @@ -72,12 +79,19 @@ typedef struct { Tk_3DBorder normalBorder; /* Used for drawing border around whole * window, plus used for background. */ + Tk_3DBorder disabledBorder; /* Used for drawing border around whole + * window in disabled state, plus used for + * background. */ + Tk_3DBorder readonlyBorder; /* Used for drawing border around whole + * window in readonly state, plus used for + * background. */ int borderWidth; /* Width of 3-D border around window. */ Tk_Cursor cursor; /* Current cursor for window, or None. */ int exportSelection; /* Non-zero means tie internal entry selection * to X selection. */ Tk_Font tkfont; /* Information about text font, or NULL. */ XColor *fgColorPtr; /* Text color in normal mode. */ + XColor *dfgColorPtr; /* Text color in disabled mode. */ XColor *highlightBgColorPtr;/* Color for drawing traversal highlight * area when highlight is off. */ XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ @@ -99,9 +113,6 @@ typedef struct { * characters. */ int selBorderWidth; /* Width of border around selection. */ XColor *selFgColorPtr; /* Foreground color for selected text. */ - char *showChar; /* Value of -show option. If non-NULL, first - * character is used for displaying all - * characters in entry. Malloc'ed. */ int state; /* Normal or disabled. Entry is read-only * when disabled. */ char *textVarName; /* Name of variable (malloc'ed) or NULL. @@ -115,23 +126,27 @@ typedef struct { char *scrollCmd; /* Command prefix for communicating with * scrollbar(s). Malloc'ed. NULL means * no command to issue. */ + char *showChar; /* Value of -show option. If non-NULL, first + * character is used for displaying all + * characters in entry. Malloc'ed. + * This is only used by the Entry widget. */ /* * Fields whose values are derived from the current values of the * configuration settings above. */ + CONST char *displayString; /* String to use when displaying. This may + * be a pointer to string, or a pointer to + * malloced memory with the same character + * length as string but whose characters + * are all equal to showChar. */ int numBytes; /* Length of string in bytes. */ int numChars; /* Length of string in characters. Both * string and displayString have the same * character length, but may have different * byte lengths due to being made from * different UTF-8 characters. */ - char *displayString; /* String to use when displaying. This may - * be a pointer to string, or a pointer to - * malloced memory with the same character - * length as string but whose characters - * are all equal to showChar. */ int numDisplayBytes; /* Length of displayString in bytes. */ int inset; /* Number of pixels on the left and right * sides that are taken up by XPAD, borderWidth @@ -149,18 +164,77 @@ typedef struct { GC selTextGC; /* For drawing selected text. */ GC highlightGC; /* For drawing traversal highlight. */ int avgWidth; /* Width of average character. */ + int xWidth; /* Extra width to reserve for widget. + * Used by spinboxes for button space. */ int flags; /* Miscellaneous flags; see below for * definitions. */ - Tk_TSOffset tsoffset; + int validate; /* Non-zero means try to validate */ char *validateCmd; /* Command prefix to use when invoking * validate command. NULL means don't * invoke commands. Malloc'ed. */ - int validate; /* Non-zero means try to validate */ char *invalidCmd; /* Command called when a validation returns 0 * (successfully fails), defaults to {}. */ + } Entry; +/* + * A data structure of the following type is kept for each spinbox + * widget managed by this file: + */ + +typedef struct { + Entry entry; /* A pointer to the generic entry structure. + * This must be the first element of the + * Spinbox. */ + + /* + * Spinbox specific configuration settings. + */ + + Tk_3DBorder activeBorder; /* Used for drawing border around active + * buttons. */ + Tk_3DBorder buttonBorder; /* Used for drawing border around buttons. */ + Tk_Cursor bCursor; /* cursor for buttons, or None. */ + int bdRelief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ + int buRelief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ + char *command; /* Command to invoke for spin buttons. + * NULL means no command to issue. */ + + /* + * Spinbox specific fields for use with configuration settings above. + */ + + int wrap; /* whether to wrap around when spinning */ + + int selElement; /* currently selected control */ + int curElement; /* currently mouseover control */ + + int repeatDelay; /* repeat delay */ + int repeatInterval; /* repeat interval */ + + double fromValue; /* Value corresponding to left/top of dial */ + double toValue; /* Value corresponding to right/bottom + * of dial */ + double increment; /* If > 0, all values are rounded to an + * even multiple of this value. */ + char *formatBuf; /* string into which to format value. + * Malloc'ed. */ + char *reqFormat; /* Sprintf conversion specifier used for the + * value that the users requests. Malloc'ed. */ + char *valueFormat; /* Sprintf conversion specifier used for + * the value. */ + char digitFormat[10]; /* Sprintf conversion specifier computed from + * digits and other information; used for + * the value. */ + + char *valueStr; /* Values List. Malloc'ed. */ + Tcl_Obj *listObj; /* Pointer to the list object being used */ + int eIndex; /* Holds the current index into elements */ + int nElements; /* Holds the current count of elements */ + +} Spinbox; + /* * Assigned bits of "flags" fields of Entry structures, and what those * bits mean: @@ -204,6 +278,12 @@ typedef struct { #define XPAD 1 #define YPAD 1 +/* + * A comparison function for double values. For Spinboxes. + */ +#define MIN_DBL_VAL 1E-9 +#define DOUBLES_EQ(d1, d2) (fabs((d1) - (d2)) < MIN_DBL_VAL) + /* * The following enum is used to define a type for the -state option * of the Entry widget. These values are used as indices into the @@ -211,11 +291,11 @@ typedef struct { */ enum state { - STATE_DISABLED, STATE_NORMAL + STATE_DISABLED, STATE_NORMAL, STATE_READONLY }; static char *stateStrings[] = { - "disabled", "normal", (char *) NULL + "disabled", "normal", "readonly", (char *) NULL }; /* @@ -231,16 +311,16 @@ enum validateType { /* * These extra enums are for use with EntryValidateChange */ - VALIDATE_FORCED, VALIDATE_DELETE, VALIDATE_INSERT + VALIDATE_FORCED, VALIDATE_DELETE, VALIDATE_INSERT, VALIDATE_BUTTON }; #define DEF_ENTRY_VALIDATE "none" #define DEF_ENTRY_INVALIDCMD "" /* - * Information used for argv parsing. + * Information used for Entry objv parsing. */ -static Tk_OptionSpec optionSpecs[] = { +static Tk_OptionSpec entryOptSpec[] = { {TK_OPTION_BORDER, "-background", "background", "Background", DEF_ENTRY_BG_COLOR, -1, Tk_Offset(Entry, normalBorder), 0, (ClientData) DEF_ENTRY_BG_MONO, 0}, @@ -254,6 +334,13 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_ENTRY_CURSOR, -1, Tk_Offset(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, + (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}, {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection", "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, -1, Tk_Offset(Entry, exportSelection), 0, 0, 0}, @@ -298,6 +385,10 @@ static Tk_OptionSpec optionSpecs[] = { (char *) NULL, 0, -1, 0, (ClientData) "-invalidcommand", 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_ENTRY_JUSTIFY, -1, Tk_Offset(Entry, justify), 0, 0, 0}, + {TK_OPTION_BORDER, "-readonlybackground", "readonlyBackground", + "ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, -1, + Tk_Offset(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}, @@ -341,11 +432,166 @@ static Tk_OptionSpec optionSpecs[] = { }; /* - * Flags for GetEntryIndex procedure: + * Information used for Spinbox objv parsing. */ -#define ZERO_OK 1 -#define LAST_PLUS_ONE_OK 2 +#define DEF_SPINBOX_REPEAT_DELAY "400" +#define DEF_SPINBOX_REPEAT_INTERVAL "100" + +#define DEF_SPINBOX_CMD "" + +#define DEF_SPINBOX_FROM "0" +#define DEF_SPINBOX_TO "0" +#define DEF_SPINBOX_INCREMENT "1" +#define DEF_SPINBOX_FORMAT "" + +#define DEF_SPINBOX_VALUES "" +#define DEF_SPINBOX_WRAP "0" + +static Tk_OptionSpec sbOptSpec[] = { + {TK_OPTION_BORDER, "-activebackground", "activeBackground", "Background", + DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(Spinbox, activeBorder), + 0, (ClientData) DEF_BUTTON_ACTIVE_BG_MONO, 0}, + {TK_OPTION_BORDER, "-background", "background", "Background", + DEF_ENTRY_BG_COLOR, -1, Tk_Offset(Entry, normalBorder), + 0, (ClientData) DEF_ENTRY_BG_MONO, 0}, + {TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, + (char *) NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, + {TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, + (char *) NULL, 0, -1, 0, (ClientData) "-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), + 0, (ClientData) DEF_BUTTON_BG_MONO, 0}, + {TK_OPTION_CURSOR, "-buttoncursor", "Button.cursor", "Cursor", + DEF_BUTTON_CURSOR, -1, Tk_Offset(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_STRING, "-command", "command", "Command", + DEF_SPINBOX_CMD, -1, Tk_Offset(Spinbox, command), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", + DEF_ENTRY_CURSOR, -1, Tk_Offset(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, + (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}, + {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection", + "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, -1, + Tk_Offset(Entry, exportSelection), 0, 0, 0}, + {TK_OPTION_SYNONYM, "-fg", "foreground", (char *) NULL, + (char *) NULL, 0, -1, 0, (ClientData) "-foreground", 0}, + {TK_OPTION_FONT, "-font", "font", "Font", + DEF_ENTRY_FONT, -1, Tk_Offset(Entry, tkfont), 0, 0, 0}, + {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", + DEF_ENTRY_FG, -1, Tk_Offset(Entry, fgColorPtr), 0, + 0, 0}, + {TK_OPTION_STRING, "-format", "format", "Format", + DEF_SPINBOX_FORMAT, -1, Tk_Offset(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}, + {TK_OPTION_COLOR, "-highlightbackground", "highlightBackground", + "HighlightBackground", DEF_ENTRY_HIGHLIGHT_BG, + -1, Tk_Offset(Entry, highlightBgColorPtr), + 0, 0, 0}, + {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", + DEF_ENTRY_HIGHLIGHT, -1, Tk_Offset(Entry, highlightColorPtr), + 0, 0, 0}, + {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", + "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, -1, + Tk_Offset(Entry, highlightWidth), 0, 0, 0}, + {TK_OPTION_DOUBLE, "-increment", "increment", "Increment", + DEF_SPINBOX_INCREMENT, -1, Tk_Offset(Spinbox, increment), 0, 0, 0}, + {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground", + DEF_ENTRY_INSERT_BG, -1, Tk_Offset(Entry, insertBorder), + 0, 0, 0}, + {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth", + "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, -1, + Tk_Offset(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), + 0, 0, 0}, + {TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime", + DEF_ENTRY_INSERT_ON_TIME, -1, Tk_Offset(Entry, insertOnTime), + 0, 0, 0}, + {TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth", + DEF_ENTRY_INSERT_WIDTH, -1, Tk_Offset(Entry, insertWidth), + 0, 0, 0}, + {TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand", + DEF_ENTRY_INVALIDCMD, -1, Tk_Offset(Entry, invalidCmd), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_SYNONYM, "-invcmd", (char *) NULL, (char *) NULL, + (char *) NULL, 0, -1, 0, (ClientData) "-invalidcommand", 0}, + {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", + DEF_ENTRY_JUSTIFY, -1, Tk_Offset(Entry, justify), 0, 0, 0}, + {TK_OPTION_RELIEF, "-relief", "relief", "Relief", + DEF_ENTRY_RELIEF, -1, Tk_Offset(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, + (ClientData) DEF_ENTRY_READONLY_BG_MONO, 0}, + {TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay", + DEF_SPINBOX_REPEAT_DELAY, -1, Tk_Offset(Spinbox, repeatDelay), + 0, 0, 0}, + {TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval", + DEF_SPINBOX_REPEAT_INTERVAL, -1, Tk_Offset(Spinbox, repeatInterval), + 0, 0, 0}, + {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", + DEF_ENTRY_SELECT_COLOR, -1, Tk_Offset(Entry, selBorder), + 0, (ClientData) DEF_ENTRY_SELECT_MONO, 0}, + {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth", + "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, -1, + Tk_Offset(Entry, selBorderWidth), + 0, (ClientData) DEF_ENTRY_SELECT_BD_MONO, 0}, + {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", + DEF_ENTRY_SELECT_FG_COLOR, -1, Tk_Offset(Entry, selFgColorPtr), + 0, (ClientData) DEF_ENTRY_SELECT_FG_MONO, 0}, + {TK_OPTION_STRING_TABLE, "-state", "state", "State", + DEF_ENTRY_STATE, -1, Tk_Offset(Entry, state), + 0, (ClientData) stateStrings, 0}, + {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", + DEF_ENTRY_TAKE_FOCUS, -1, Tk_Offset(Entry, takeFocus), + TK_CONFIG_NULL_OK, 0, 0}, + {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", + DEF_ENTRY_TEXT_VARIABLE, -1, Tk_Offset(Entry, textVarName), + TK_CONFIG_NULL_OK, 0, 0}, + {TK_OPTION_DOUBLE, "-to", "to", "To", + DEF_SPINBOX_TO, -1, Tk_Offset(Spinbox, toValue), 0, 0, 0}, + {TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate", + DEF_ENTRY_VALIDATE, -1, Tk_Offset(Entry, validate), + 0, (ClientData) validateStrings, 0}, + {TK_OPTION_STRING, "-validatecommand", "validateCommand", "ValidateCommand", + (char *) NULL, -1, Tk_Offset(Entry, validateCmd), + TK_CONFIG_NULL_OK, 0, 0}, + {TK_OPTION_STRING, "-values", "values", "Values", + DEF_SPINBOX_VALUES, -1, Tk_Offset(Spinbox, valueStr), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_SYNONYM, "-vcmd", (char *) NULL, (char *) NULL, + (char *) NULL, 0, -1, 0, (ClientData) "-validatecommand", 0}, + {TK_OPTION_INT, "-width", "width", "Width", + DEF_ENTRY_WIDTH, -1, Tk_Offset(Entry, prefWidth), 0, 0, 0}, + {TK_OPTION_BOOLEAN, "-wrap", "wrap", "Wrap", + DEF_SPINBOX_WRAP, -1, Tk_Offset(Spinbox, wrap), 0, 0, 0}, + {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand", + DEF_ENTRY_SCROLL_COMMAND, -1, Tk_Offset(Entry, scrollCmd), + TK_CONFIG_NULL_OK, 0, 0}, + {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, + (char *) NULL, 0, -1, 0, 0, 0} +}; /* * The following tables define the entry widget commands (and sub- @@ -353,26 +599,73 @@ static Tk_OptionSpec optionSpecs[] = { * enumerated types used to dispatch the entry widget command. */ -static char *commandNames[] = { +static CONST char *entryCmdNames[] = { "bbox", "cget", "configure", "delete", "get", "icursor", "index", "insert", "scan", "selection", "validate", "xview", (char *) NULL }; -enum command { +enum entryCmd { COMMAND_BBOX, COMMAND_CGET, COMMAND_CONFIGURE, COMMAND_DELETE, COMMAND_GET, COMMAND_ICURSOR, COMMAND_INDEX, COMMAND_INSERT, COMMAND_SCAN, COMMAND_SELECTION, COMMAND_VALIDATE, COMMAND_XVIEW }; -static char *selCommandNames[] = { +static CONST char *selCmdNames[] = { "adjust", "clear", "from", "present", "range", "to", (char *) NULL }; -enum selcommand { +enum selCmd { SELECTION_ADJUST, SELECTION_CLEAR, SELECTION_FROM, SELECTION_PRESENT, SELECTION_RANGE, SELECTION_TO }; +/* + * The following tables define the spinbox widget commands (and sub- + * commands) and map the indexes into the string tables into + * enumerated types used to dispatch the spinbox widget command. + */ + +static CONST char *sbCmdNames[] = { + "bbox", "cget", "configure", "delete", "get", "icursor", "identify", + "index", "insert", "invoke", "scan", "selection", "set", + "validate", "xview", (char *) NULL +}; + +enum sbCmd { + SB_CMD_BBOX, SB_CMD_CGET, SB_CMD_CONFIGURE, SB_CMD_DELETE, + SB_CMD_GET, SB_CMD_ICURSOR, SB_CMD_IDENTIFY, SB_CMD_INDEX, + SB_CMD_INSERT, SB_CMD_INVOKE, SB_CMD_SCAN, SB_CMD_SELECTION, + SB_CMD_SET, SB_CMD_VALIDATE, SB_CMD_XVIEW +}; + +static CONST char *sbSelCmdNames[] = { + "adjust", "clear", "element", "from", "present", "range", "to", + (char *) NULL +}; + +enum sbselCmd { + SB_SEL_ADJUST, SB_SEL_CLEAR, SB_SEL_ELEMENT, SB_SEL_FROM, + SB_SEL_PRESENT, SB_SEL_RANGE, SB_SEL_TO +}; + +/* + * Extra for selection of elements + */ + +static CONST char *selElementNames[] = { + "none", "buttondown", "buttonup", (char *) NULL, "entry" +}; +enum selelement { + SEL_NONE, SEL_BUTTONDOWN, SEL_BUTTONUP, SEL_NULL, SEL_ENTRY +}; + +/* + * Flags for GetEntryIndex procedure: + */ + +#define ZERO_OK 1 +#define LAST_PLUS_ONE_OK 2 + /* * Forward declarations for procedures defined later in this file: */ @@ -399,21 +692,23 @@ static void EntryLostSelection _ANSI_ARGS_(( static void EventuallyRedraw _ANSI_ARGS_((Entry *entryPtr)); static void EntryScanTo _ANSI_ARGS_((Entry *entryPtr, int y)); static void EntrySetValue _ANSI_ARGS_((Entry *entryPtr, - char *value)); + CONST char *value)); static void EntrySelectTo _ANSI_ARGS_(( Entry *entryPtr, int index)); static char * EntryTextVarProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); + Tcl_Interp *interp, CONST char *name1, + CONST char *name2, int flags)); static void EntryUpdateScrollbar _ANSI_ARGS_((Entry *entryPtr)); static int EntryValidate _ANSI_ARGS_((Entry *entryPtr, char *cmd)); static int EntryValidateChange _ANSI_ARGS_((Entry *entryPtr, - char *change, char *new, int index, int type)); + char *change, CONST char *new, int index, + int type)); static void ExpandPercents _ANSI_ARGS_((Entry *entryPtr, - char *before, char *change, char *new, + CONST char *before, char *change, CONST char *new, int index, int type, Tcl_DString *dsPtr)); -static void EntryValueChanged _ANSI_ARGS_((Entry *entryPtr)); +static void EntryValueChanged _ANSI_ARGS_((Entry *entryPtr, + CONST char *newValue)); static void EntryVisibleRange _ANSI_ARGS_((Entry *entryPtr, double *firstPtr, double *lastPtr)); static int EntryWidgetObjCmd _ANSI_ARGS_((ClientData clientData, @@ -427,14 +722,26 @@ static void InsertChars _ANSI_ARGS_((Entry *entryPtr, int index, char *string)); /* - * The structure below defines entry class behavior by means of procedures + * These forward declarations are the spinbox specific ones: + */ + +static int SpinboxWidgetObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); +static int GetSpinboxElement _ANSI_ARGS_((Spinbox *sbPtr, + int x, int y)); +static int SpinboxInvoke _ANSI_ARGS_((Tcl_Interp *interp, + Spinbox *sbPtr, int element)); +static int ComputeFormat _ANSI_ARGS_((Spinbox *sbPtr)); + +/* + * The structure below defines widget class behavior by means of procedures * that can be invoked from generic window code. */ -static TkClassProcs entryClass = { - NULL, /* createProc. */ - EntryWorldChanged, /* geometryProc. */ - NULL /* modalProc. */ +static Tk_ClassProcs entryClass = { + sizeof(Tk_ClassProcs), /* size */ + EntryWorldChanged, /* worldChangedProc */ }; @@ -458,7 +765,7 @@ static TkClassProcs entryClass = { int Tk_EntryObjCmd(clientData, interp, objc, objv) - ClientData clientData; /* Either NULL or pointer to option table. */ + ClientData clientData; /* NULL. */ Tcl_Interp *interp; /* Current interpreter. */ int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ @@ -466,25 +773,7 @@ Tk_EntryObjCmd(clientData, interp, objc, objv) register Entry *entryPtr; Tk_OptionTable optionTable; Tk_Window tkwin; - - optionTable = (Tk_OptionTable) clientData; - if (optionTable == NULL) { - Tcl_CmdInfo info; - char *name; - - /* - * We haven't created the option table for this widget class - * yet. Do it now and save the table as the clientData for - * the command, so we'll have access to it in future - * invocations of the command. - */ - - optionTable = Tk_CreateOptionTable(interp, optionSpecs); - name = Tcl_GetString(objv[0]); - Tcl_GetCommandInfo(interp, name, &info); - info.objClientData = (ClientData) optionTable; - Tcl_SetCommandInfo(interp, name, &info); - } + char *tmp; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); @@ -497,13 +786,23 @@ Tk_EntryObjCmd(clientData, interp, objc, objv) return TCL_ERROR; } + /* + * Create the option table for this widget class. If it has already + * been created, Tk will return the cached value. + */ + + optionTable = Tk_CreateOptionTable(interp, entryOptSpec); + /* * Initialize the fields of the structure that won't be initialized * by ConfigureEntry, or that ConfigureEntry requires to be - * initialized already (e.g. resource pointers). + * initialized already (e.g. resource pointers). Only the non-NULL/0 + * data must be initialized as memset covers the rest. */ entryPtr = (Entry *) ckalloc(sizeof(Entry)); + memset((VOID *) entryPtr, 0, sizeof(Entry)); + entryPtr->tkwin = tkwin; entryPtr->display = Tk_Display(tkwin); entryPtr->interp = interp; @@ -511,62 +810,35 @@ Tk_EntryObjCmd(clientData, interp, objc, objv) Tk_PathName(entryPtr->tkwin), EntryWidgetObjCmd, (ClientData) entryPtr, EntryCmdDeletedProc); entryPtr->optionTable = optionTable; - entryPtr->string = (char *) ckalloc(1); - entryPtr->string[0] = '\0'; - entryPtr->insertPos = 0; + entryPtr->type = TK_ENTRY; + tmp = (char *) ckalloc(1); + tmp[0] = '\0'; + entryPtr->string = tmp; entryPtr->selectFirst = -1; entryPtr->selectLast = -1; - entryPtr->selectAnchor = 0; - entryPtr->scanMarkX = 0; - entryPtr->scanMarkIndex = 0; - entryPtr->normalBorder = NULL; - entryPtr->borderWidth = 0; entryPtr->cursor = None; entryPtr->exportSelection = 1; - entryPtr->tkfont = NULL; - entryPtr->fgColorPtr = NULL; - entryPtr->highlightBgColorPtr = NULL; - entryPtr->highlightColorPtr = NULL; - entryPtr->highlightWidth = 0; - entryPtr->insertBorder = NULL; - entryPtr->insertBorderWidth = 0; - entryPtr->insertOffTime = 0; - entryPtr->insertOnTime = 0; - entryPtr->insertWidth = 0; entryPtr->justify = TK_JUSTIFY_LEFT; entryPtr->relief = TK_RELIEF_FLAT; - entryPtr->selBorder = NULL; - entryPtr->selBorderWidth = 0; - entryPtr->selFgColorPtr = NULL; - entryPtr->showChar = NULL; entryPtr->state = STATE_NORMAL; - entryPtr->textVarName = NULL; - entryPtr->takeFocus = NULL; - entryPtr->prefWidth = 0; - entryPtr->scrollCmd = NULL; - entryPtr->numBytes = 0; - entryPtr->numChars = 0; entryPtr->displayString = entryPtr->string; - entryPtr->numDisplayBytes = 0; entryPtr->inset = XPAD; - entryPtr->textLayout = NULL; - entryPtr->layoutX = 0; - entryPtr->layoutY = 0; - entryPtr->leftX = 0; - entryPtr->leftIndex = 0; - entryPtr->insertBlinkHandler = (Tcl_TimerToken) NULL; entryPtr->textGC = None; entryPtr->selTextGC = None; entryPtr->highlightGC = None; entryPtr->avgWidth = 1; - entryPtr->flags = 0; - entryPtr->validateCmd = NULL; entryPtr->validate = VALIDATE_NONE; - entryPtr->invalidCmd = NULL; + + /* + * Keep a hold of the associated tkwin until we destroy the listbox, + * otherwise Tk might free it while we still need it. + */ + + Tcl_Preserve((ClientData) entryPtr->tkwin); Tk_SetClass(entryPtr->tkwin, "Entry"); - TkSetClassProcs(entryPtr->tkwin, &entryClass, (ClientData) entryPtr); + Tk_SetClassProcs(entryPtr->tkwin, &entryClass, (ClientData) entryPtr); Tk_CreateEventHandler(entryPtr->tkwin, ExposureMask|StructureNotifyMask|FocusChangeMask, EntryEventProc, (ClientData) entryPtr); @@ -579,7 +851,7 @@ Tk_EntryObjCmd(clientData, interp, objc, objv) Tk_DestroyWindow(entryPtr->tkwin); return TCL_ERROR; } - + Tcl_SetResult(interp, Tk_PathName(entryPtr->tkwin), TCL_STATIC); return TCL_OK; } @@ -617,20 +889,20 @@ EntryWidgetObjCmd(clientData, interp, objc, objv) Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); return TCL_ERROR; } - Tcl_Preserve((ClientData) entryPtr); /* * Parse the widget command by looking up the second token in * the list of valid command names. */ - result = Tcl_GetIndexFromObj(interp, objv[1], commandNames, + result = Tcl_GetIndexFromObj(interp, objv[1], entryCmdNames, "option", 0, &cmdIndex); if (result != TCL_OK) { return result; } - switch (cmdIndex) { + Tcl_Preserve((ClientData) entryPtr); + switch ((enum entryCmd) cmdIndex) { case COMMAND_BBOX: { int index, x, y, width, height; char buf[TCL_INTEGER_SPACE * 4]; @@ -717,7 +989,7 @@ EntryWidgetObjCmd(clientData, interp, objc, objv) Tcl_WrongNumArgs(interp, 2, objv, (char *) NULL); goto error; } - Tcl_SetResult(interp, entryPtr->string, TCL_STATIC); + Tcl_SetStringObj(Tcl_GetObjResult(interp), entryPtr->string, -1); break; } @@ -799,19 +1071,27 @@ EntryWidgetObjCmd(clientData, interp, objc, objv) int index, index2; if (objc < 3) { - Tcl_WrongNumArgs(interp, 2, objv, "option ?index?"); + Tcl_WrongNumArgs(interp, 2, objv, "option ?index?"); goto error; } - + /* * Parse the selection sub-command, using the command - * table "selCommandNames" defined above. + * table "selCmdNames" defined above. */ - result = Tcl_GetIndexFromObj(interp, objv[2], selCommandNames, - "selection option", 0, &selIndex); + result = Tcl_GetIndexFromObj(interp, objv[2], selCmdNames, + "selection option", 0, &selIndex); if (result != TCL_OK) { - goto error; + goto error; + } + + /* + * Disabled entries don't allow the selection to be modified. + */ + + if (entryPtr->state == STATE_DISABLED) { + goto done; } switch(selIndex) { @@ -1043,12 +1323,6 @@ DestroyEntry(memPtr) char *memPtr; /* Info about entry widget. */ { Entry *entryPtr = (Entry *) memPtr; - entryPtr->flags |= ENTRY_DELETED; - - Tcl_DeleteCommandFromToken(entryPtr->interp, entryPtr->widgetCmd); - if (entryPtr->flags & REDRAW_PENDING) { - Tcl_CancelIdleCall(DisplayEntry, (ClientData) entryPtr); - } /* * Free up all the stuff that requires special handling, then @@ -1056,7 +1330,7 @@ DestroyEntry(memPtr) * stuff. */ - ckfree(entryPtr->string); + ckfree((char *)entryPtr->string); if (entryPtr->textVarName != NULL) { Tcl_UntraceVar(entryPtr->interp, entryPtr->textVarName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, @@ -1070,12 +1344,25 @@ DestroyEntry(memPtr) } Tcl_DeleteTimerHandler(entryPtr->insertBlinkHandler); if (entryPtr->displayString != entryPtr->string) { - ckfree(entryPtr->displayString); + ckfree((char *)entryPtr->displayString); + } + if (entryPtr->type == TK_SPINBOX) { + Spinbox *sbPtr = (Spinbox *) entryPtr; + + if (sbPtr->listObj != NULL) { + Tcl_DecrRefCount(sbPtr->listObj); + sbPtr->listObj = NULL; + } + if (sbPtr->formatBuf) { + ckfree(sbPtr->formatBuf); + } } Tk_FreeTextLayout(entryPtr->textLayout); Tk_FreeConfigOptions((char *) entryPtr, entryPtr->optionTable, entryPtr->tkwin); + Tcl_Release((ClientData) entryPtr->tkwin); entryPtr->tkwin = NULL; + ckfree((char *) entryPtr); } @@ -1110,9 +1397,17 @@ ConfigureEntry(interp, entryPtr, objc, objv, flags) int flags; /* Flags to pass to Tk_ConfigureWidget. */ { Tk_SavedOptions savedOptions; + Tk_3DBorder border; Tcl_Obj *errorResult = NULL; + Spinbox *sbPtr = (Spinbox *) entryPtr; /* Only used when this widget + * is of type TK_SPINBOX */ + char *oldValues = NULL; /* lint initialization */ + char *oldFormat = NULL; /* lint initialization */ int error; - int oldExport; + int oldExport = 0; /* lint initialization */ + int valuesChanged = 0; /* lint initialization */ + double oldFrom = 0.0; /* lint initialization */ + double oldTo = 0.0; /* lint initialization */ /* * Eliminate any existing trace on a variable monitored by the entry. @@ -1124,7 +1419,17 @@ ConfigureEntry(interp, entryPtr, objc, objv, flags) EntryTextVarProc, (ClientData) entryPtr); } - oldExport = entryPtr->exportSelection; + /* + * Store old values that we need to effect certain behavior if + * they change value + */ + oldExport = entryPtr->exportSelection; + if (entryPtr->type == TK_SPINBOX) { + oldValues = sbPtr->valueStr; + oldFormat = sbPtr->reqFormat; + oldFrom = sbPtr->fromValue; + oldTo = sbPtr->toValue; + } for (error = 0; error <= 1; error++) { if (!error) { @@ -1152,7 +1457,16 @@ ConfigureEntry(interp, entryPtr, objc, objv, flags) * the geometry and setting the background from a 3-D border. */ - Tk_SetBackgroundFromBorder(entryPtr->tkwin, entryPtr->normalBorder); + if ((entryPtr->state == STATE_DISABLED) && + (entryPtr->disabledBorder != NULL)) { + border = entryPtr->disabledBorder; + } else if ((entryPtr->state == STATE_READONLY) && + (entryPtr->readonlyBorder != NULL)) { + border = entryPtr->readonlyBorder; + } else { + border = entryPtr->normalBorder; + } + Tk_SetBackgroundFromBorder(entryPtr->tkwin, border); if (entryPtr->insertWidth <= 0) { entryPtr->insertWidth = 2; @@ -1161,6 +1475,80 @@ ConfigureEntry(interp, entryPtr, objc, objv, flags) entryPtr->insertBorderWidth = entryPtr->insertWidth/2; } + if (entryPtr->type == TK_SPINBOX) { + if (sbPtr->fromValue > sbPtr->toValue) { + Tcl_SetResult(interp, + "-to value must be greater than -from value", + TCL_VOLATILE); + continue; + } + + if (sbPtr->reqFormat && (oldFormat != sbPtr->reqFormat)) { + /* + * Make sure that the given format is somewhat correct, and + * calculate the minimum space we'll need for the values as + * strings. + */ + int min, max; + size_t formatLen, formatSpace = TCL_DOUBLE_SPACE; + char fbuf[4], *fmt = sbPtr->reqFormat; + + formatLen = strlen(fmt); + if ((fmt[0] != '%') || (fmt[formatLen-1] != 'f')) { + badFormatOpt: + Tcl_AppendResult(interp, "bad spinbox format specifier \"", + sbPtr->reqFormat, "\"", (char *) NULL); + continue; + } + if ((sscanf(fmt, "%%%d.%d%[f]", &min, &max, fbuf) == 3) + && (max >= 0)) { + formatSpace = min + max + 1; + } else if (((sscanf(fmt, "%%.%d%[f]", &min, fbuf) == 2) + || (sscanf(fmt, "%%%d%[f]", &min, fbuf) == 2) + || (sscanf(fmt, "%%%d.%[f]", &min, fbuf) == 2)) + && (min >= 0)) { + formatSpace = min + 1; + } else { + goto badFormatOpt; + } + if (formatSpace < TCL_DOUBLE_SPACE) { + formatSpace = TCL_DOUBLE_SPACE; + } + sbPtr->formatBuf = ckrealloc(sbPtr->formatBuf, formatSpace); + /* + * We perturb the value of oldFrom to allow us to go into + * the branch below that will reformat the displayed value. + */ + oldFrom = sbPtr->fromValue - 1; + } + + /* + * See if we have to rearrange our listObj data + */ + if (oldValues != sbPtr->valueStr) { + if (sbPtr->listObj != NULL) { + Tcl_DecrRefCount(sbPtr->listObj); + } + sbPtr->listObj = NULL; + if (sbPtr->valueStr != NULL) { + Tcl_Obj *newObjPtr; + int nelems; + + newObjPtr = Tcl_NewStringObj(sbPtr->valueStr, -1); + if (Tcl_ListObjLength(interp, newObjPtr, &nelems) + != TCL_OK) { + valuesChanged = -1; + continue; + } + sbPtr->listObj = newObjPtr; + Tcl_IncrRefCount(sbPtr->listObj); + sbPtr->nElements = nelems; + sbPtr->eIndex = 0; + valuesChanged++; + } + } + } + /* * Restart the cursor timing sequence in case the on-time or * off-time just changed. Set validate temporarily to none, @@ -1205,20 +1593,67 @@ ConfigureEntry(interp, entryPtr, objc, objv, flags) } /* - * If the entry is tied to the value of a variable, then set up - * a trace on the variable's value, create the variable if it doesn't - * exist, and set the entry's value from the variable's value. + * If the entry is tied to the value of a variable, create the variable if + * it doesn't exist, and set the entry's value from the variable's value. */ if (entryPtr->textVarName != NULL) { - char *value; + CONST char *value; value = Tcl_GetVar(interp, entryPtr->textVarName, TCL_GLOBAL_ONLY); if (value == NULL) { - EntryValueChanged(entryPtr); + EntryValueChanged(entryPtr, NULL); } else { EntrySetValue(entryPtr, value); } + } + + if (entryPtr->type == TK_SPINBOX) { + ComputeFormat(sbPtr); + + if (valuesChanged > 0) { + Tcl_Obj *objPtr; + + /* + * No check for error return, because there shouldn't be one + * given the check for valid list above + */ + Tcl_ListObjIndex(interp, sbPtr->listObj, 0, &objPtr); + EntryValueChanged(entryPtr, Tcl_GetString(objPtr)); + } else if ((sbPtr->valueStr == NULL) + && !DOUBLES_EQ(sbPtr->fromValue, sbPtr->toValue) + && (!DOUBLES_EQ(sbPtr->fromValue, oldFrom) + || !DOUBLES_EQ(sbPtr->toValue, oldTo))) { + /* + * If the valueStr is empty and -from && -to are specified, check + * to see if the current string is within the range. If not, + * it will be constrained to the nearest edge. If the current + * string isn't a double value, we set it to -from. + */ + int code; + double dvalue; + + code = Tcl_GetDouble(NULL, entryPtr->string, &dvalue); + if (code != TCL_OK) { + dvalue = sbPtr->fromValue; + } else { + if (dvalue > sbPtr->toValue) { + dvalue = sbPtr->toValue; + } else if (dvalue < sbPtr->fromValue) { + dvalue = sbPtr->fromValue; + } + } + sprintf(sbPtr->formatBuf, sbPtr->valueFormat, dvalue); + EntryValueChanged(entryPtr, sbPtr->formatBuf); + } + } + + /* + * Set up a trace on the variable's value after we've possibly + * constrained the value according to new -from/-to values. + */ + + if (entryPtr->textVarName != NULL) { Tcl_TraceVar(interp, entryPtr->textVarName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, EntryTextVarProc, (ClientData) entryPtr); @@ -1259,20 +1694,52 @@ EntryWorldChanged(instanceData) XGCValues gcValues; GC gc = None; unsigned long mask; - Entry *entryPtr; - - entryPtr = (Entry *) instanceData; + Tk_3DBorder border; + XColor *colorPtr; + Entry *entryPtr = (Entry *) instanceData; entryPtr->avgWidth = Tk_TextWidth(entryPtr->tkfont, "0", 1); if (entryPtr->avgWidth == 0) { entryPtr->avgWidth = 1; } - if (entryPtr->normalBorder != NULL) { - Tk_SetBackgroundFromBorder(entryPtr->tkwin, entryPtr->normalBorder); - } + if (entryPtr->type == TK_SPINBOX) { + /* + * Compute the button width for a spinbox + */ + + entryPtr->xWidth = entryPtr->avgWidth + 2 * (1+XPAD); + if (entryPtr->xWidth < 11) { + entryPtr->xWidth = 11; /* we want a min visible size */ + } + } + + /* + * Default background and foreground are from the normal state. + * In a disabled state, both of those may be overridden; in the readonly + * state, the background may be overridden. + */ - gcValues.foreground = entryPtr->fgColorPtr->pixel; + border = entryPtr->normalBorder; + colorPtr = entryPtr->fgColorPtr; + switch (entryPtr->state) { + case STATE_DISABLED: + if (entryPtr->disabledBorder != NULL) { + border = entryPtr->disabledBorder; + } + if (entryPtr->dfgColorPtr != NULL) { + colorPtr = entryPtr->dfgColorPtr; + } + break; + case STATE_READONLY: + if (entryPtr->readonlyBorder != NULL) { + border = entryPtr->readonlyBorder; + } + break; + } + + Tk_SetBackgroundFromBorder(entryPtr->tkwin, border); + gcValues.foreground = colorPtr->pixel; gcValues.font = Tk_FontId(entryPtr->tkfont); gcValues.graphics_exposures = False; mask = GCForeground | GCFont | GCGraphicsExposures; @@ -1324,13 +1791,13 @@ DisplayEntry(clientData) Entry *entryPtr = (Entry *) clientData; Tk_Window tkwin = entryPtr->tkwin; int baseY, selStartX, selEndX, cursorX; - int xBound; + int showSelection, xBound; Tk_FontMetrics fm; Pixmap pixmap; - int showSelection; + Tk_3DBorder border; entryPtr->flags &= ~REDRAW_PENDING; - if ((entryPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { + if ((entryPtr->flags & ENTRY_DELETED) || !Tk_IsMapped(tkwin)) { return; } @@ -1342,7 +1809,20 @@ DisplayEntry(clientData) if (entryPtr->flags & UPDATE_SCROLLBAR) { entryPtr->flags &= ~UPDATE_SCROLLBAR; + + /* + * Preserve/Release because updating the scrollbar can have + * the side-effect of destroying or unmapping the entry widget. + */ + + Tcl_Preserve((ClientData) entryPtr); EntryUpdateScrollbar(entryPtr); + + if ((entryPtr->flags & ENTRY_DELETED) || !Tk_IsMapped(tkwin)) { + Tcl_Release((ClientData) entryPtr); + return; + } + Tcl_Release((ClientData) entryPtr); } /* @@ -1360,7 +1840,7 @@ DisplayEntry(clientData) * one, plus vertical position of baseline of text. */ - xBound = Tk_Width(tkwin) - entryPtr->inset; + xBound = Tk_Width(tkwin) - entryPtr->inset - entryPtr->xWidth; baseY = (Tk_Height(tkwin) + fm.ascent - fm.descent) / 2; /* @@ -1380,10 +1860,19 @@ DisplayEntry(clientData) * insertion cursor background. */ - Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->normalBorder, - 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); + if ((entryPtr->state == STATE_DISABLED) && + (entryPtr->disabledBorder != NULL)) { + border = entryPtr->disabledBorder; + } else if ((entryPtr->state == STATE_READONLY) && + (entryPtr->readonlyBorder != NULL)) { + border = entryPtr->readonlyBorder; + } else { + border = entryPtr->normalBorder; + } + Tk_Fill3DRectangle(tkwin, pixmap, border, + 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); - if (showSelection + if (showSelection && (entryPtr->state != STATE_DISABLED) && (entryPtr->selectLast > entryPtr->leftIndex)) { if (entryPtr->selectFirst <= entryPtr->leftIndex) { selStartX = entryPtr->leftX; @@ -1414,23 +1903,26 @@ DisplayEntry(clientData) * cursor isn't on. Otherwise the selection would hide the cursor. */ - if ((entryPtr->insertPos >= entryPtr->leftIndex) - && (entryPtr->state == STATE_NORMAL) - && (entryPtr->flags & GOT_FOCUS)) { + if ((entryPtr->state == STATE_NORMAL) && (entryPtr->flags & GOT_FOCUS)) { Tk_CharBbox(entryPtr->textLayout, entryPtr->insertPos, &cursorX, NULL, NULL, NULL); cursorX += entryPtr->layoutX; cursorX -= (entryPtr->insertWidth)/2; - if (cursorX < xBound) { - if (entryPtr->flags & CURSOR_ON) { - Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->insertBorder, - cursorX, baseY - fm.ascent, entryPtr->insertWidth, - fm.ascent + fm.descent, entryPtr->insertBorderWidth, - TK_RELIEF_RAISED); - } else if (entryPtr->insertBorder == entryPtr->selBorder) { - Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->normalBorder, - cursorX, baseY - fm.ascent, entryPtr->insertWidth, - fm.ascent + fm.descent, 0, TK_RELIEF_FLAT); + Tk_SetCaretPos(entryPtr->tkwin, cursorX, baseY - fm.ascent, + fm.ascent + fm.descent); + if (entryPtr->insertPos >= entryPtr->leftIndex) { + if (cursorX < xBound) { + if (entryPtr->flags & CURSOR_ON) { + Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->insertBorder, + cursorX, baseY - fm.ascent, entryPtr->insertWidth, + fm.ascent + fm.descent, + entryPtr->insertBorderWidth, + TK_RELIEF_RAISED); + } else if (entryPtr->insertBorder == entryPtr->selBorder) { + Tk_Fill3DRectangle(tkwin, pixmap, border, + cursorX, baseY - fm.ascent, entryPtr->insertWidth, + fm.ascent + fm.descent, 0, TK_RELIEF_FLAT); + } } } } @@ -1444,7 +1936,7 @@ DisplayEntry(clientData) entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, entryPtr->leftIndex, entryPtr->numChars); - if (showSelection + if (showSelection && (entryPtr->state != STATE_DISABLED) && (entryPtr->selTextGC != entryPtr->textGC) && (entryPtr->selectFirst < entryPtr->selectLast)) { int selFirst; @@ -1459,29 +1951,106 @@ DisplayEntry(clientData) selFirst, entryPtr->selectLast); } + if (entryPtr->type == TK_SPINBOX) { + int startx, height, inset, pad, tHeight, xWidth; + Spinbox *sbPtr = (Spinbox *) entryPtr; + + /* + * Draw the spin button controls. + */ + xWidth = entryPtr->xWidth; + pad = XPAD + 1; + inset = entryPtr->inset - XPAD; + startx = Tk_Width(tkwin) - (xWidth + inset); + height = (Tk_Height(tkwin) - 2*inset)/2; +#if 0 + Tk_Fill3DRectangle(tkwin, pixmap, sbPtr->buttonBorder, + startx, inset, xWidth, height, 1, sbPtr->buRelief); + Tk_Fill3DRectangle(tkwin, pixmap, sbPtr->buttonBorder, + startx, inset+height, xWidth, height, 1, sbPtr->bdRelief); +#else + Tk_Fill3DRectangle(tkwin, pixmap, sbPtr->buttonBorder, + startx, inset, xWidth, height, 1, + (sbPtr->selElement == SEL_BUTTONUP) ? + TK_RELIEF_SUNKEN : TK_RELIEF_RAISED); + Tk_Fill3DRectangle(tkwin, pixmap, sbPtr->buttonBorder, + startx, inset+height, xWidth, height, 1, + (sbPtr->selElement == SEL_BUTTONDOWN) ? + TK_RELIEF_SUNKEN : TK_RELIEF_RAISED); +#endif + + xWidth -= 2*pad; + /* + * Only draw the triangles if we have enough display space + */ + if ((xWidth > 1)) { + XPoint points[3]; + int starty, space, offset; + + space = height - 2*pad; + /* + * Ensure width of triangle is odd to guarantee a sharp tip + */ + if (!(xWidth % 2)) { + xWidth++; + } + tHeight = (xWidth + 1) / 2; + if (tHeight > space) { + tHeight = space; + } + space = (space - tHeight) / 2; + startx += pad; + starty = inset + height - pad - space; + offset = (sbPtr->selElement == SEL_BUTTONUP); + /* + * The points are slightly different for the up and down arrows + * because (for *.x), we need to account for a bug in the way + * XFillPolygon draws triangles, and we want to shift + * the arrows differently when allowing for depressed behavior. + */ + points[0].x = startx + offset; + points[0].y = starty + (offset ? 0 : -1); + points[1].x = startx + xWidth/2 + offset; + points[1].y = starty - tHeight + (offset ? 0 : -1); + points[2].x = startx + xWidth + offset; + points[2].y = points[0].y; + XFillPolygon(entryPtr->display, pixmap, entryPtr->textGC, + points, 3, Convex, CoordModeOrigin); + + starty = inset + height + pad + space; + offset = (sbPtr->selElement == SEL_BUTTONDOWN); + points[0].x = startx + 1 + offset; + points[0].y = starty + (offset ? 1 : 0); + points[1].x = startx + xWidth/2 + offset; + points[1].y = starty + tHeight + (offset ? 0 : -1); + points[2].x = startx - 1 + xWidth + offset; + points[2].y = points[0].y; + XFillPolygon(entryPtr->display, pixmap, entryPtr->textGC, + points, 3, Convex, CoordModeOrigin); + } + } + /* * Draw the border and focus highlight last, so they will overwrite * any text that extends past the viewable part of the window. */ + xBound = entryPtr->highlightWidth; if (entryPtr->relief != TK_RELIEF_FLAT) { - Tk_Draw3DRectangle(tkwin, pixmap, entryPtr->normalBorder, - entryPtr->highlightWidth, entryPtr->highlightWidth, - Tk_Width(tkwin) - 2 * entryPtr->highlightWidth, - Tk_Height(tkwin) - 2 * entryPtr->highlightWidth, + Tk_Draw3DRectangle(tkwin, pixmap, border, xBound, xBound, + Tk_Width(tkwin) - 2 * xBound, + Tk_Height(tkwin) - 2 * xBound, entryPtr->borderWidth, entryPtr->relief); } - if (entryPtr->highlightWidth != 0) { + if (xBound > 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(entryPtr->highlightBgColorPtr, pixmap); if (entryPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(entryPtr->highlightColorPtr, pixmap); - TkpDrawHighlightBorder(tkwin, fgGC, bgGC, - entryPtr->highlightWidth, pixmap); + TkpDrawHighlightBorder(tkwin, fgGC, bgGC, xBound, pixmap); } else { - TkpDrawHighlightBorder(tkwin, bgGC, bgGC, - entryPtr->highlightWidth, pixmap); + TkpDrawHighlightBorder(tkwin, bgGC, bgGC, xBound, pixmap); } } @@ -1527,7 +2096,7 @@ EntryComputeGeometry(entryPtr) char *p; if (entryPtr->displayString != entryPtr->string) { - ckfree(entryPtr->displayString); + ckfree((char *)entryPtr->displayString); entryPtr->displayString = entryPtr->string; entryPtr->numDisplayBytes = entryPtr->numBytes; } @@ -1553,15 +2122,15 @@ EntryComputeGeometry(entryPtr) size = Tcl_UniCharToUtf(ch, buf); entryPtr->numDisplayBytes = entryPtr->numChars * size; - entryPtr->displayString = - (char *) ckalloc((unsigned) (entryPtr->numDisplayBytes + 1)); + p = (char *) ckalloc((unsigned) (entryPtr->numDisplayBytes + 1)); + entryPtr->displayString = p; - p = entryPtr->displayString; for (i = entryPtr->numChars; --i >= 0; ) { p += Tcl_UniCharToUtf(ch, p); } *p = '\0'; } + Tk_FreeTextLayout(entryPtr->textLayout); entryPtr->textLayout = Tk_ComputeTextLayout(entryPtr->tkfont, entryPtr->displayString, entryPtr->numChars, 0, @@ -1576,16 +2145,18 @@ EntryComputeGeometry(entryPtr) * window unless the entire window is full. */ - overflow = totalLength - (Tk_Width(entryPtr->tkwin) - 2*entryPtr->inset); + overflow = totalLength - + (Tk_Width(entryPtr->tkwin) - 2*entryPtr->inset - entryPtr->xWidth); if (overflow <= 0) { entryPtr->leftIndex = 0; if (entryPtr->justify == TK_JUSTIFY_LEFT) { entryPtr->leftX = entryPtr->inset; } else if (entryPtr->justify == TK_JUSTIFY_RIGHT) { entryPtr->leftX = Tk_Width(entryPtr->tkwin) - entryPtr->inset - - totalLength; + - entryPtr->xWidth - totalLength; } else { - entryPtr->leftX = (Tk_Width(entryPtr->tkwin) - totalLength)/2; + entryPtr->leftX = (Tk_Width(entryPtr->tkwin) + - entryPtr->xWidth - totalLength)/2; } entryPtr->layoutX = entryPtr->leftX; } else { @@ -1622,6 +2193,12 @@ EntryComputeGeometry(entryPtr) width = totalLength + 2*entryPtr->inset; } } + + /* + * Add one extra length for the spin buttons + */ + width += entryPtr->xWidth; + Tk_GeometryRequest(entryPtr->tkwin, width, height); } @@ -1651,7 +2228,8 @@ InsertChars(entryPtr, index, value) * string). */ { int byteIndex, byteCount, oldChars, charsAdded, newByteCount; - char *new, *string; + CONST char *string; + char *new; string = entryPtr->string; byteIndex = Tcl_UtfAtIndex(string, index) - string; @@ -1674,7 +2252,7 @@ InsertChars(entryPtr, index, value) return; } - ckfree(string); + ckfree((char *)string); entryPtr->string = new; /* @@ -1721,7 +2299,7 @@ InsertChars(entryPtr, index, value) if (entryPtr->insertPos >= index) { entryPtr->insertPos += charsAdded; } - EntryValueChanged(entryPtr); + EntryValueChanged(entryPtr, NULL); } /* @@ -1748,7 +2326,8 @@ DeleteChars(entryPtr, index, count) int count; /* How many characters to delete. */ { int byteIndex, byteCount, newByteCount; - char *new, *string, *todelete; + CONST char *string; + char *new, *todelete; if ((index + count) > entryPtr->numChars) { count = entryPtr->numChars - index; @@ -1780,7 +2359,7 @@ DeleteChars(entryPtr, index, count) } ckfree(todelete); - ckfree(entryPtr->string); + ckfree((char *)entryPtr->string); entryPtr->string = new; entryPtr->numChars -= count; entryPtr->numBytes -= byteCount; @@ -1835,7 +2414,7 @@ DeleteChars(entryPtr, index, count) entryPtr->insertPos = index; } } - EntryValueChanged(entryPtr); + EntryValueChanged(entryPtr, NULL); } /* @@ -1858,10 +2437,14 @@ DeleteChars(entryPtr, index, count) */ static void -EntryValueChanged(entryPtr) +EntryValueChanged(entryPtr, newValue) Entry *entryPtr; /* Entry whose value just changed. */ + CONST char *newValue; /* If this value is not NULL, we first + * force the value of the entry to this */ { - char *newValue; + if (newValue != NULL) { + EntrySetValue(entryPtr, newValue); + } if (entryPtr->textVarName == NULL) { newValue = NULL; @@ -1916,9 +2499,9 @@ EntryValueChanged(entryPtr) static void EntrySetValue(entryPtr, value) Entry *entryPtr; /* Entry whose value is to be changed. */ - char *value; /* New text to display in entry. */ + CONST char *value; /* New text to display in entry. */ { - char *oldSource; + CONST char *oldSource; int code, valueLen, malloced = 0; if (strcmp(value, entryPtr->string) == 0) { @@ -1934,9 +2517,9 @@ EntrySetValue(entryPtr, value) * point to volatile memory, like the value of the -textvar * which may get freed during validation */ - oldSource = (char *) ckalloc((unsigned) (valueLen + 1)); - strcpy(oldSource, value); - value = oldSource; + char *tmp = (char *) ckalloc((unsigned) (valueLen + 1)); + strcpy(tmp, value); + value = tmp; malloced = 1; entryPtr->flags |= VALIDATE_VAR; @@ -1949,19 +2532,20 @@ EntrySetValue(entryPtr, value) */ if (entryPtr->flags & VALIDATE_ABORT) { entryPtr->flags &= ~VALIDATE_ABORT; - ckfree(value); + ckfree((char *)value); return; } } oldSource = entryPtr->string; - ckfree(entryPtr->string); + ckfree((char *)entryPtr->string); if (malloced) { entryPtr->string = value; } else { - entryPtr->string = (char *) ckalloc((unsigned) (valueLen + 1)); - strcpy(entryPtr->string, value); + char *tmp = (char *) ckalloc((unsigned) (valueLen + 1)); + strcpy(tmp, value); + entryPtr->string = tmp; } entryPtr->numBytes = valueLen; entryPtr->numChars = Tcl_NumUtfChars(value, valueLen); @@ -2001,7 +2585,7 @@ EntrySetValue(entryPtr, value) * EntryEventProc -- * * This procedure is invoked by the Tk dispatcher for various - * events on entryes. + * events on entries. * * Results: * None. @@ -2019,25 +2603,62 @@ EntryEventProc(clientData, eventPtr) XEvent *eventPtr; /* Information about event. */ { Entry *entryPtr = (Entry *) clientData; - if (eventPtr->type == Expose) { - EventuallyRedraw(entryPtr); - entryPtr->flags |= BORDER_NEEDED; - } else if (eventPtr->type == DestroyNotify) { - DestroyEntry((char *) clientData); - } else if (eventPtr->type == ConfigureNotify) { - Tcl_Preserve((ClientData) entryPtr); - entryPtr->flags |= UPDATE_SCROLLBAR; - EntryComputeGeometry(entryPtr); - EventuallyRedraw(entryPtr); - Tcl_Release((ClientData) entryPtr); - } else if (eventPtr->type == FocusIn) { - if (eventPtr->xfocus.detail != NotifyInferior) { - EntryFocusProc(entryPtr, 1); - } - } else if (eventPtr->type == FocusOut) { - if (eventPtr->xfocus.detail != NotifyInferior) { - EntryFocusProc(entryPtr, 0); + + if ((entryPtr->type == TK_SPINBOX) && (eventPtr->type == MotionNotify)) { + Spinbox *sbPtr = (Spinbox *) clientData; + int elem; + + elem = GetSpinboxElement(sbPtr, eventPtr->xmotion.x, + eventPtr->xmotion.y); + if (elem != sbPtr->curElement) { + Tk_Cursor cursor; + + sbPtr->curElement = elem; + if (elem == SEL_ENTRY) { + cursor = entryPtr->cursor; + } else if ((elem == SEL_BUTTONDOWN) || (elem == SEL_BUTTONUP)) { + cursor = sbPtr->bCursor; + } else { + cursor = None; + } + if (cursor != None) { + Tk_DefineCursor(entryPtr->tkwin, cursor); + } else { + Tk_UndefineCursor(entryPtr->tkwin); + } } + return; + } + + switch (eventPtr->type) { + case Expose: + EventuallyRedraw(entryPtr); + entryPtr->flags |= BORDER_NEEDED; + break; + case DestroyNotify: + if (!(entryPtr->flags & ENTRY_DELETED)) { + entryPtr->flags |= (ENTRY_DELETED | VALIDATE_ABORT); + Tcl_DeleteCommandFromToken(entryPtr->interp, + entryPtr->widgetCmd); + if (entryPtr->flags & REDRAW_PENDING) { + Tcl_CancelIdleCall(DisplayEntry, clientData); + } + Tcl_EventuallyFree(clientData, DestroyEntry); + } + break; + case ConfigureNotify: + Tcl_Preserve((ClientData) entryPtr); + entryPtr->flags |= UPDATE_SCROLLBAR; + EntryComputeGeometry(entryPtr); + EventuallyRedraw(entryPtr); + Tcl_Release((ClientData) entryPtr); + break; + case FocusIn: + case FocusOut: + if (eventPtr->xfocus.detail != NotifyInferior) { + EntryFocusProc(entryPtr, (eventPtr->type == FocusIn)); + } + break; } } @@ -2123,8 +2744,9 @@ GetEntryIndex(interp, entryPtr, string, indexPtr) */ Tcl_SetResult(interp, (char *) NULL, TCL_STATIC); - Tcl_AppendResult(interp, "bad entry index \"", string, - "\"", (char *) NULL); + Tcl_AppendResult(interp, "bad ", + (entryPtr->type == TK_ENTRY) ? "entry" : "spinbox", + " index \"", string, "\"", (char *) NULL); return TCL_ERROR; } } else if (string[0] == 'e') { @@ -2141,7 +2763,9 @@ GetEntryIndex(interp, entryPtr, string, indexPtr) } } else if (string[0] == 's') { if (entryPtr->selectFirst < 0) { - Tcl_SetResult(interp, "selection isn't in entry", TCL_STATIC); + Tcl_SetResult(interp, (char *) NULL, TCL_STATIC); + Tcl_AppendResult(interp, "selection isn't in widget ", + Tk_PathName(entryPtr->tkwin), (char *) NULL); return TCL_ERROR; } if (length < 5) { @@ -2155,7 +2779,7 @@ GetEntryIndex(interp, entryPtr, string, indexPtr) goto badIndex; } } else if (string[0] == '@') { - int x, roundUp; + int x, roundUp, maxWidth; if (Tcl_GetInt(interp, string + 1, &x) != TCL_OK) { goto badIndex; @@ -2164,8 +2788,10 @@ GetEntryIndex(interp, entryPtr, string, indexPtr) x = entryPtr->inset; } roundUp = 0; - if (x >= (Tk_Width(entryPtr->tkwin) - entryPtr->inset)) { - x = Tk_Width(entryPtr->tkwin) - entryPtr->inset - 1; + maxWidth = Tk_Width(entryPtr->tkwin) - entryPtr->inset + - entryPtr->xWidth - 1; + if (x > maxWidth) { + x = maxWidth; roundUp = 1; } *indexPtr = Tk_PointToChar(entryPtr->textLayout, @@ -2191,8 +2817,6 @@ GetEntryIndex(interp, entryPtr, string, indexPtr) *indexPtr = entryPtr->numChars; } } - if(*indexPtr > entryPtr->numChars) - *indexPtr = entryPtr->numChars; return TCL_OK; } @@ -2348,7 +2972,8 @@ EntryFetchSelection(clientData, offset, buffer, maxBytes) { Entry *entryPtr = (Entry *) clientData; int byteCount; - char *string, *selStart, *selEnd; + CONST char *string; + CONST char *selStart, *selEnd; if ((entryPtr->selectFirst < 0) || !(entryPtr->exportSelection)) { return -1; @@ -2433,7 +3058,7 @@ static void EventuallyRedraw(entryPtr) Entry *entryPtr; /* Information about widget. */ { - if ((entryPtr->tkwin == NULL) || !Tk_IsMapped(entryPtr->tkwin)) { + if ((entryPtr->flags & ENTRY_DELETED) || !Tk_IsMapped(entryPtr->tkwin)) { return; } @@ -2484,7 +3109,7 @@ EntryVisibleRange(entryPtr, firstPtr, lastPtr) } else { charsInWindow = Tk_PointToChar(entryPtr->textLayout, Tk_Width(entryPtr->tkwin) - entryPtr->inset - - entryPtr->layoutX - 1, 0); + - entryPtr->xWidth - entryPtr->layoutX - 1, 0); if (charsInWindow < entryPtr->numChars) { charsInWindow++; } @@ -2539,7 +3164,9 @@ EntryUpdateScrollbar(entryPtr) code = Tcl_VarEval(interp, entryPtr->scrollCmd, args, (char *) NULL); if (code != TCL_OK) { Tcl_AddErrorInfo(interp, - "\n (horizontal scrolling command executed by entry)"); + "\n (horizontal scrolling command executed by "); + Tcl_AddErrorInfo(interp, Tk_PathName(entryPtr->tkwin)); + Tcl_AddErrorInfo(interp, ")"); Tcl_BackgroundError(interp); } Tcl_SetResult(interp, (char *) NULL, TCL_STATIC); @@ -2571,17 +3198,18 @@ EntryBlinkProc(clientData) Entry *entryPtr = (Entry *) clientData; if ((entryPtr->state == STATE_DISABLED) || + (entryPtr->state == STATE_READONLY) || !(entryPtr->flags & GOT_FOCUS) || (entryPtr->insertOffTime == 0)) { return; } if (entryPtr->flags & CURSOR_ON) { entryPtr->flags &= ~CURSOR_ON; entryPtr->insertBlinkHandler = Tcl_CreateTimerHandler( - entryPtr->insertOffTime, EntryBlinkProc, (ClientData) entryPtr); + entryPtr->insertOffTime, EntryBlinkProc, (ClientData) entryPtr); } else { entryPtr->flags |= CURSOR_ON; entryPtr->insertBlinkHandler = Tcl_CreateTimerHandler( - entryPtr->insertOnTime, EntryBlinkProc, (ClientData) entryPtr); + entryPtr->insertOnTime, EntryBlinkProc, (ClientData) entryPtr); } EventuallyRedraw(entryPtr); } @@ -2660,12 +3288,12 @@ static char * EntryTextVarProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Information about button. */ Tcl_Interp *interp; /* Interpreter containing variable. */ - char *name1; /* Not used. */ - char *name2; /* Not used. */ + CONST char *name1; /* Not used. */ + CONST char *name2; /* Not used. */ int flags; /* Information about what happened. */ { Entry *entryPtr = (Entry *) clientData; - char *value; + CONST char *value; /* * If the variable is unset, then immediately recreate it unless @@ -2729,13 +3357,21 @@ EntryValidate(entryPtr, cmd) code = Tcl_EvalEx(interp, cmd, -1, TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); + /* + * We accept TCL_OK and TCL_RETURN as valid return codes from the + * command callback. + */ if (code != TCL_OK && code != TCL_RETURN) { - Tcl_AddErrorInfo(interp, - "\n\t(in validation command executed by entry)"); + Tcl_AddErrorInfo(interp, "\n\t(in validation command executed by "); + Tcl_AddErrorInfo(interp, Tk_PathName(entryPtr->tkwin)); + Tcl_AddErrorInfo(interp, ")"); Tcl_BackgroundError(interp); return TCL_ERROR; } + /* + * The command callback should return an acceptable Tcl boolean. + */ if (Tcl_GetBooleanFromObj(interp, Tcl_GetObjResult(interp), &bool) != TCL_OK) { Tcl_AddErrorInfo(interp, @@ -2774,7 +3410,7 @@ EntryValidateChange(entryPtr, change, new, index, type) register Entry *entryPtr; /* Entry that needs validation. */ char *change; /* Characters to be added/deleted * (NULL-terminated string). */ - char *new; /* Potential new value of entry string */ + CONST char *new; /* Potential new value of entry string */ int index; /* index of insert/delete, -1 otherwise */ int type; /* forced, delete, insert, * focusin or focusout */ @@ -2819,15 +3455,27 @@ EntryValidateChange(entryPtr, change, new, index, type) * it means that a loop condition almost occured. Do not allow * this validation result to finish. */ + if (entryPtr->validate == VALIDATE_NONE || (!varValidate && (entryPtr->flags & VALIDATE_VAR))) { code = TCL_ERROR; } + + /* + * It's possible that the user deleted the entry during validation. + * In that case, abort future validation and return an error. + */ + + if (entryPtr->flags & ENTRY_DELETED) { + return TCL_ERROR; + } + /* * If validate will return ERROR, then disallow further validations * Otherwise, if it didn't accept the new string (returned TCL_BREAK) * then eval the invalidCmd (if it's set) */ + if (code == TCL_ERROR) { entryPtr->validate = VALIDATE_NONE; } else if (code == TCL_BREAK) { @@ -2839,6 +3487,7 @@ EntryValidateChange(entryPtr, change, new, index, type) * may want to do entry manipulation which the setting of the * var will later wipe anyway. */ + if (varValidate) { entryPtr->validate = VALIDATE_NONE; } else if (entryPtr->invalidCmd != NULL) { @@ -2856,6 +3505,15 @@ EntryValidateChange(entryPtr, change, new, index, type) entryPtr->validate = VALIDATE_NONE; } Tcl_DStringFree(&script); + + /* + * It's possible that the user deleted the entry during validation. + * In that case, abort future validation and return an error. + */ + + if (entryPtr->flags & ENTRY_DELETED) { + return TCL_ERROR; + } } } @@ -2886,11 +3544,12 @@ EntryValidateChange(entryPtr, change, new, index, type) static void ExpandPercents(entryPtr, before, change, new, index, type, dsPtr) register Entry *entryPtr; /* Entry that needs validation. */ - register char *before; /* Command containing percent + register CONST char *before; + /* Command containing percent * expressions to be replaced. */ char *change; /* Characters to added/deleted * (NULL-terminated string). */ - char *new; /* Potential new value of entry string */ + CONST char *new; /* Potential new value of entry string */ int index; /* index of insert/delete */ int type; /* INSERT or DELETE */ Tcl_DString *dsPtr; /* Dynamic string in which to append @@ -2899,7 +3558,7 @@ ExpandPercents(entryPtr, before, change, new, index, type, dsPtr) int spaceNeeded, cvtFlags; /* Used to substitute string as proper Tcl * list element. */ int number, length; - register char *string; + register CONST char *string; Tcl_UniChar ch; char numStorage[2*TCL_INTEGER_SPACE]; @@ -2933,60 +3592,85 @@ ExpandPercents(entryPtr, before, change, new, index, type, dsPtr) } else { ch = '%'; } - switch (ch) { - case 'd': /* Type of call that caused validation */ - switch (type) { - case VALIDATE_INSERT: - number = 1; - break; - case VALIDATE_DELETE: - number = 0; - break; - default: - number = -1; - break; - } - sprintf(numStorage, "%d", number); - string = numStorage; - break; - case 'i': /* index of insert/delete */ - sprintf(numStorage, "%d", index); - string = numStorage; - break; - case 'P': /* 'Peeked' new value of the string */ - string = new; - break; - case 's': /* Current string value of entry */ - string = entryPtr->string; - break; - case 'S': /* string to be inserted/deleted, if any */ - string = change; - break; - case 'v': /* type of validation currently set */ - string = validateStrings[entryPtr->validate]; - break; - case 'V': /* type of validation in effect */ - switch (type) { - case VALIDATE_INSERT: - case VALIDATE_DELETE: - string = validateStrings[VALIDATE_KEY]; - break; - case VALIDATE_FORCED: - string = "forced"; - break; - default: - string = validateStrings[type]; - break; + if (type == VALIDATE_BUTTON) { + /* + * -command %-substitution + */ + switch (ch) { + case 's': /* Current string value of spinbox */ + string = entryPtr->string; + break; + case 'd': /* direction, up or down */ + string = change; + break; + case 'W': /* widget name */ + string = Tk_PathName(entryPtr->tkwin); + break; + default: + length = Tcl_UniCharToUtf(ch, numStorage); + numStorage[length] = '\0'; + string = numStorage; + break; + } + } else { + /* + * -validatecommand / -invalidcommand %-substitution + */ + switch (ch) { + case 'd': /* Type of call that caused validation */ + switch (type) { + case VALIDATE_INSERT: + number = 1; + break; + case VALIDATE_DELETE: + number = 0; + break; + default: + number = -1; + break; + } + sprintf(numStorage, "%d", number); + string = numStorage; + break; + case 'i': /* index of insert/delete */ + sprintf(numStorage, "%d", index); + string = numStorage; + break; + case 'P': /* 'Peeked' new value of the string */ + string = new; + break; + case 's': /* Current string value of spinbox */ + string = entryPtr->string; + break; + case 'S': /* string to be inserted/deleted, if any */ + string = change; + break; + case 'v': /* type of validation currently set */ + string = validateStrings[entryPtr->validate]; + break; + case 'V': /* type of validation in effect */ + switch (type) { + case VALIDATE_INSERT: + case VALIDATE_DELETE: + string = validateStrings[VALIDATE_KEY]; + break; + case VALIDATE_FORCED: + string = "forced"; + break; + default: + string = validateStrings[type]; + break; + } + break; + case 'W': /* widget name */ + string = Tk_PathName(entryPtr->tkwin); + break; + default: + length = Tcl_UniCharToUtf(ch, numStorage); + numStorage[length] = '\0'; + string = numStorage; + break; } - break; - case 'W': /* widget name */ - string = Tk_PathName(entryPtr->tkwin); - break; - default: - length = Tcl_UniCharToUtf(ch, numStorage); - numStorage[length] = '\0'; - string = numStorage; - break; } spaceNeeded = Tcl_ScanCountedElement(string, -1, &cvtFlags); @@ -2998,4 +3682,939 @@ ExpandPercents(entryPtr, before, change, new, index, type, dsPtr) Tcl_DStringSetLength(dsPtr, length + spaceNeeded); } } + +/* + *-------------------------------------------------------------- + * + * Tk_SpinboxObjCmd -- + * + * This procedure is invoked to process the "spinbox" Tcl + * command. See the user documentation for details on what + * it does. + * + * Results: + * A standard Tcl result. + * + * Side effects: + * See the user documentation. + * + *-------------------------------------------------------------- + */ + +int +Tk_SpinboxObjCmd(clientData, interp, objc, objv) + ClientData clientData; /* NULL. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ +{ + register Entry *entryPtr; + register Spinbox *sbPtr; + Tk_OptionTable optionTable; + Tk_Window tkwin; + char *tmp; + + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); + return TCL_ERROR; + } + + tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), + Tcl_GetString(objv[1]), (char *) NULL); + if (tkwin == NULL) { + return TCL_ERROR; + } + + /* + * Create the option table for this widget class. If it has already + * been created, Tk will return the cached value. + */ + + optionTable = Tk_CreateOptionTable(interp, sbOptSpec); + + /* + * Initialize the fields of the structure that won't be initialized + * by ConfigureEntry, or that ConfigureEntry requires to be + * initialized already (e.g. resource pointers). Only the non-NULL/0 + * data must be initialized as memset covers the rest. + */ + + sbPtr = (Spinbox *) ckalloc(sizeof(Spinbox)); + entryPtr = (Entry *) sbPtr; + memset((VOID *) sbPtr, 0, sizeof(Spinbox)); + + entryPtr->tkwin = tkwin; + entryPtr->display = Tk_Display(tkwin); + entryPtr->interp = interp; + entryPtr->widgetCmd = Tcl_CreateObjCommand(interp, + Tk_PathName(entryPtr->tkwin), SpinboxWidgetObjCmd, + (ClientData) sbPtr, EntryCmdDeletedProc); + entryPtr->optionTable = optionTable; + entryPtr->type = TK_SPINBOX; + tmp = (char *) ckalloc(1); + tmp[0] = '\0'; + entryPtr->string = tmp; + entryPtr->selectFirst = -1; + entryPtr->selectLast = -1; + + entryPtr->cursor = None; + entryPtr->exportSelection = 1; + entryPtr->justify = TK_JUSTIFY_LEFT; + entryPtr->relief = TK_RELIEF_FLAT; + entryPtr->state = STATE_NORMAL; + entryPtr->displayString = entryPtr->string; + entryPtr->inset = XPAD; + entryPtr->textGC = None; + entryPtr->selTextGC = None; + entryPtr->highlightGC = None; + entryPtr->avgWidth = 1; + entryPtr->validate = VALIDATE_NONE; + + sbPtr->selElement = SEL_NONE; + sbPtr->curElement = SEL_NONE; + sbPtr->bCursor = None; + sbPtr->repeatDelay = 400; + sbPtr->repeatInterval = 100; + sbPtr->fromValue = 0.0; + sbPtr->toValue = 100.0; + sbPtr->increment = 1.0; + sbPtr->formatBuf = (char *) ckalloc(TCL_DOUBLE_SPACE); + sbPtr->bdRelief = TK_RELIEF_FLAT; + sbPtr->buRelief = TK_RELIEF_FLAT; + + /* + * Keep a hold of the associated tkwin until we destroy the listbox, + * otherwise Tk might free it while we still need it. + */ + + Tcl_Preserve((ClientData) entryPtr->tkwin); + + Tk_SetClass(entryPtr->tkwin, "Spinbox"); + Tk_SetClassProcs(entryPtr->tkwin, &entryClass, (ClientData) entryPtr); + Tk_CreateEventHandler(entryPtr->tkwin, + PointerMotionMask|ExposureMask|StructureNotifyMask|FocusChangeMask, + EntryEventProc, (ClientData) entryPtr); + Tk_CreateSelHandler(entryPtr->tkwin, XA_PRIMARY, XA_STRING, + EntryFetchSelection, (ClientData) entryPtr, XA_STRING); + + if (Tk_InitOptions(interp, (char *) sbPtr, optionTable, tkwin) + != TCL_OK) { + Tk_DestroyWindow(entryPtr->tkwin); + return TCL_ERROR; + } + if (ConfigureEntry(interp, entryPtr, objc-2, objv+2, 0) != TCL_OK) { + goto error; + } + + Tcl_SetResult(interp, Tk_PathName(entryPtr->tkwin), TCL_STATIC); + return TCL_OK; + + error: + Tk_DestroyWindow(entryPtr->tkwin); + return TCL_ERROR; +} + +/* + *-------------------------------------------------------------- + * + * SpinboxWidgetObjCmd -- + * + * This procedure is invoked to process the Tcl command + * that corresponds to a widget managed by this module. + * See the user documentation for details on what it does. + * + * Results: + * A standard Tcl result. + * + * Side effects: + * See the user documentation. + * + *-------------------------------------------------------------- + */ + +static int +SpinboxWidgetObjCmd(clientData, interp, objc, objv) + ClientData clientData; /* Information about spinbox widget. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ +{ + Entry *entryPtr = (Entry *) clientData; + Spinbox *sbPtr = (Spinbox *) clientData; + int cmdIndex, selIndex, result; + Tcl_Obj *objPtr; + + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } + /* + * Parse the widget command by looking up the second token in + * the list of valid command names. + */ + + result = Tcl_GetIndexFromObj(interp, objv[1], sbCmdNames, + "option", 0, &cmdIndex); + if (result != TCL_OK) { + return result; + } + + Tcl_Preserve((ClientData) entryPtr); + switch ((enum sbCmd) cmdIndex) { + case SB_CMD_BBOX: { + int index, x, y, width, height; + char buf[TCL_INTEGER_SPACE * 4]; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "index"); + goto error; + } + if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + &index) != TCL_OK) { + goto error; + } + if ((index == entryPtr->numChars) && (index > 0)) { + index--; + } + Tk_CharBbox(entryPtr->textLayout, index, &x, &y, + &width, &height); + sprintf(buf, "%d %d %d %d", x + entryPtr->layoutX, + y + entryPtr->layoutY, width, height); + Tcl_SetResult(interp, buf, TCL_VOLATILE); + break; + } + + case SB_CMD_CGET: { + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "option"); + goto error; + } + + objPtr = Tk_GetOptionValue(interp, (char *) entryPtr, + entryPtr->optionTable, objv[2], entryPtr->tkwin); + if (objPtr == NULL) { + goto error; + } else { + Tcl_SetObjResult(interp, objPtr); + } + break; + } + + case SB_CMD_CONFIGURE: { + if (objc <= 3) { + objPtr = Tk_GetOptionInfo(interp, (char *) entryPtr, + entryPtr->optionTable, + (objc == 3) ? objv[2] : (Tcl_Obj *) NULL, + entryPtr->tkwin); + if (objPtr == NULL) { + goto error; + } else { + Tcl_SetObjResult(interp, objPtr); + } + } else { + result = ConfigureEntry(interp, entryPtr, objc-2, objv+2, 0); + } + break; + } + + case SB_CMD_DELETE: { + int first, last; + + if ((objc < 3) || (objc > 4)) { + Tcl_WrongNumArgs(interp, 2, objv, "firstIndex ?lastIndex?"); + goto error; + } + if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + &first) != TCL_OK) { + goto error; + } + if (objc == 3) { + last = first + 1; + } else { + if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[3]), + &last) != TCL_OK) { + goto error; + } + } + if ((last >= first) && (entryPtr->state == STATE_NORMAL)) { + DeleteChars(entryPtr, first, last - first); + } + break; + } + + case SB_CMD_GET: { + if (objc != 2) { + Tcl_WrongNumArgs(interp, 2, objv, (char *) NULL); + goto error; + } + Tcl_SetStringObj(Tcl_GetObjResult(interp), entryPtr->string, -1); + break; + } + + case SB_CMD_ICURSOR: { + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "pos"); + goto error; + } + if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + &entryPtr->insertPos) != TCL_OK) { + goto error; + } + EventuallyRedraw(entryPtr); + break; + } + + case SB_CMD_IDENTIFY: { + int x, y, elem; + + if (objc != 4) { + Tcl_WrongNumArgs(interp, 2, objv, "x y"); + goto error; + } + if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) || + (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) { + goto error; + } + elem = GetSpinboxElement(sbPtr, x, y); + if (elem != SEL_NONE) { + Tcl_SetStringObj(Tcl_GetObjResult(interp), + selElementNames[elem], -1); + } + break; + } + + case SB_CMD_INDEX: { + int index; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "string"); + goto error; + } + if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + &index) != TCL_OK) { + goto error; + } + Tcl_SetObjResult(interp, Tcl_NewIntObj(index)); + break; + } + + case SB_CMD_INSERT: { + int index; + + if (objc != 4) { + Tcl_WrongNumArgs(interp, 2, objv, "index text"); + goto error; + } + if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + &index) != TCL_OK) { + goto error; + } + if (entryPtr->state == STATE_NORMAL) { + InsertChars(entryPtr, index, Tcl_GetString(objv[3])); + } + break; + } + + case SB_CMD_INVOKE: { + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "elemName"); + goto error; + } + result = Tcl_GetIndexFromObj(interp, objv[2], + selElementNames, "element", 0, &cmdIndex); + if (result != TCL_OK) { + goto error; + } + if (entryPtr->state != STATE_DISABLED) { + if (SpinboxInvoke(interp, sbPtr, cmdIndex) != TCL_OK) { + goto error; + } + } + break; + } + + case SB_CMD_SCAN: { + int x; + char *minorCmd; + + if (objc != 4) { + Tcl_WrongNumArgs(interp, 2, objv, "mark|dragto x"); + goto error; + } + if (Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK) { + goto error; + } + + minorCmd = Tcl_GetString(objv[2]); + if (minorCmd[0] == 'm' + && (strncmp(minorCmd, "mark", strlen(minorCmd)) == 0)) { + entryPtr->scanMarkX = x; + entryPtr->scanMarkIndex = entryPtr->leftIndex; + } else if ((minorCmd[0] == 'd') + && (strncmp(minorCmd, "dragto", strlen(minorCmd)) == 0)) { + EntryScanTo(entryPtr, x); + } else { + Tcl_AppendResult(interp, "bad scan option \"", + Tcl_GetString(objv[2]), "\": must be mark or dragto", + (char *) NULL); + goto error; + } + break; + } + + case SB_CMD_SELECTION: { + int index, index2; + + if (objc < 3) { + Tcl_WrongNumArgs(interp, 2, objv, "option ?index?"); + goto error; + } + + /* + * Parse the selection sub-command, using the command + * table "sbSelCmdNames" defined above. + */ + + result = Tcl_GetIndexFromObj(interp, objv[2], sbSelCmdNames, + "selection option", 0, &selIndex); + if (result != TCL_OK) { + goto error; + } + + /* + * Disabled entries don't allow the selection to be modified. + */ + + if (entryPtr->state == STATE_DISABLED) { + goto done; + } + + switch(selIndex) { + case SB_SEL_ADJUST: { + if (objc != 4) { + Tcl_WrongNumArgs(interp, 3, objv, "index"); + goto error; + } + if (GetEntryIndex(interp, entryPtr, + Tcl_GetString(objv[3]), &index) != TCL_OK) { + goto error; + } + if (entryPtr->selectFirst >= 0) { + int half1, half2; + + half1 = (entryPtr->selectFirst + + entryPtr->selectLast)/2; + half2 = (entryPtr->selectFirst + + entryPtr->selectLast + 1)/2; + if (index < half1) { + entryPtr->selectAnchor = entryPtr->selectLast; + } else if (index > half2) { + entryPtr->selectAnchor = entryPtr->selectFirst; + } else { + /* + * We're at about the halfway point in the + * selection; just keep the existing anchor. + */ + } + } + EntrySelectTo(entryPtr, index); + break; + } + + case SB_SEL_CLEAR: { + if (objc != 3) { + Tcl_WrongNumArgs(interp, 3, objv, (char *) NULL); + goto error; + } + if (entryPtr->selectFirst >= 0) { + entryPtr->selectFirst = -1; + entryPtr->selectLast = -1; + EventuallyRedraw(entryPtr); + } + goto done; + } + + case SB_SEL_FROM: { + if (objc != 4) { + Tcl_WrongNumArgs(interp, 3, objv, "index"); + goto error; + } + if (GetEntryIndex(interp, entryPtr, + Tcl_GetString(objv[3]), &index) != TCL_OK) { + goto error; + } + entryPtr->selectAnchor = index; + break; + } + + case SB_SEL_PRESENT: { + if (objc != 3) { + Tcl_WrongNumArgs(interp, 3, objv, (char *) NULL); + goto error; + } + Tcl_SetObjResult(interp, + Tcl_NewBooleanObj((entryPtr->selectFirst >= 0))); + goto done; + } + + case SB_SEL_RANGE: { + if (objc != 5) { + Tcl_WrongNumArgs(interp, 3, objv, "start end"); + goto error; + } + if (GetEntryIndex(interp, entryPtr, + Tcl_GetString(objv[3]), &index) != TCL_OK) { + goto error; + } + if (GetEntryIndex(interp, entryPtr, + Tcl_GetString(objv[4]),& index2) != TCL_OK) { + goto error; + } + if (index >= index2) { + entryPtr->selectFirst = -1; + entryPtr->selectLast = -1; + } else { + entryPtr->selectFirst = index; + entryPtr->selectLast = index2; + } + if (!(entryPtr->flags & GOT_SELECTION) + && (entryPtr->exportSelection)) { + Tk_OwnSelection(entryPtr->tkwin, XA_PRIMARY, + EntryLostSelection, (ClientData) entryPtr); + entryPtr->flags |= GOT_SELECTION; + } + EventuallyRedraw(entryPtr); + break; + } + + case SB_SEL_TO: { + if (objc != 4) { + Tcl_WrongNumArgs(interp, 3, objv, "index"); + goto error; + } + if (GetEntryIndex(interp, entryPtr, + Tcl_GetString(objv[3]), &index) != TCL_OK) { + goto error; + } + EntrySelectTo(entryPtr, index); + break; + } + + case SB_SEL_ELEMENT: { + if ((objc < 3) || (objc > 4)) { + Tcl_WrongNumArgs(interp, 3, objv, "?elemName?"); + goto error; + } + if (objc == 3) { + Tcl_SetStringObj(Tcl_GetObjResult(interp), + selElementNames[sbPtr->selElement], -1); + } else { + int lastElement = sbPtr->selElement; + + result = Tcl_GetIndexFromObj(interp, objv[3], + selElementNames, "selection element", 0, + &(sbPtr->selElement)); + if (result != TCL_OK) { + goto error; + } + if (lastElement != sbPtr->selElement) { + EventuallyRedraw(entryPtr); + } + } + break; + } + } + break; + } + + case SB_CMD_SET: { + if (objc > 3) { + Tcl_WrongNumArgs(interp, 2, objv, "?string?"); + goto error; + } + if (objc == 3) { + EntryValueChanged(entryPtr, Tcl_GetString(objv[2])); + } + Tcl_SetStringObj(Tcl_GetObjResult(interp), entryPtr->string, -1); + break; + } + + case SB_CMD_VALIDATE: { + int code; + + if (objc != 2) { + Tcl_WrongNumArgs(interp, 2, objv, (char *) NULL); + goto error; + } + selIndex = entryPtr->validate; + entryPtr->validate = VALIDATE_ALL; + code = EntryValidateChange(entryPtr, (char *) NULL, + entryPtr->string, -1, VALIDATE_FORCED); + if (entryPtr->validate != VALIDATE_NONE) { + entryPtr->validate = selIndex; + } + Tcl_SetObjResult(interp, Tcl_NewBooleanObj((code == TCL_OK))); + break; + } + + case SB_CMD_XVIEW: { + int index; + + if (objc == 2) { + double first, last; + char buf[TCL_DOUBLE_SPACE * 2]; + + EntryVisibleRange(entryPtr, &first, &last); + sprintf(buf, "%g %g", first, last); + Tcl_SetResult(interp, buf, TCL_VOLATILE); + goto done; + } else if (objc == 3) { + if (GetEntryIndex(interp, entryPtr, Tcl_GetString(objv[2]), + &index) != TCL_OK) { + goto error; + } + } else { + double fraction; + int count; + + index = entryPtr->leftIndex; + switch (Tk_GetScrollInfoObj(interp, objc, objv, &fraction, + &count)) { + case TK_SCROLL_ERROR: { + goto error; + } + case TK_SCROLL_MOVETO: { + index = (int) ((fraction * entryPtr->numChars) + 0.5); + break; + } + case TK_SCROLL_PAGES: { + int charsPerPage; + + charsPerPage = ((Tk_Width(entryPtr->tkwin) + - 2 * entryPtr->inset - entryPtr->xWidth) + / entryPtr->avgWidth) - 2; + if (charsPerPage < 1) { + charsPerPage = 1; + } + index += count * charsPerPage; + break; + } + case TK_SCROLL_UNITS: { + index += count; + break; + } + } + } + if (index >= entryPtr->numChars) { + index = entryPtr->numChars - 1; + } + if (index < 0) { + index = 0; + } + entryPtr->leftIndex = index; + entryPtr->flags |= UPDATE_SCROLLBAR; + EntryComputeGeometry(entryPtr); + EventuallyRedraw(entryPtr); + break; + } + } + + done: + Tcl_Release((ClientData) entryPtr); + return result; + + error: + Tcl_Release((ClientData) entryPtr); + return TCL_ERROR; +} + +/* + *--------------------------------------------------------------------------- + * + * GetSpinboxElement -- + * + * Return the element associated with an x,y coord. + * + * Results: + * Element type as enum selelement. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +static int +GetSpinboxElement(sbPtr, x, y) + Spinbox *sbPtr; /* Spinbox for which the index is being + * specified. */ + int x; /* x coord */ + int y; /* y coord */ +{ + Entry *entryPtr = (Entry *) sbPtr; + + if ((x < 0) || (y < 0) || (y > Tk_Height(entryPtr->tkwin)) + || (x > Tk_Width(entryPtr->tkwin))) { + return SEL_NONE; + } + + if (x > (Tk_Width(entryPtr->tkwin) - entryPtr->inset - entryPtr->xWidth)) { + if (y > (Tk_Height(entryPtr->tkwin) / 2)) { + return SEL_BUTTONDOWN; + } else { + return SEL_BUTTONUP; + } + } + return SEL_ENTRY; +} + +/* + *-------------------------------------------------------------- + * + * SpinboxInvoke -- + * + * This procedure is invoked when the invoke method for the + * widget is called. + * + * Results: + * TCL_OK. + * + * Side effects: + * An background error condition may arise when invoking the + * callback. The widget value may change. + * + *-------------------------------------------------------------- + */ + +static int +SpinboxInvoke(interp, sbPtr, element) + register Tcl_Interp *interp; /* Current interpreter. */ + register Spinbox *sbPtr; /* Spinbox to invoke. */ + int element; /* element to invoke, either the "up" + * or "down" button. */ +{ + Entry *entryPtr = (Entry *) sbPtr; + char *type; + int code, up; + Tcl_DString script; + + switch (element) { + case SEL_BUTTONUP: + type = "up"; + up = 1; + break; + case SEL_BUTTONDOWN: + type = "down"; + up = 0; + break; + default: + return TCL_OK; + } + + if (fabs(sbPtr->increment) > MIN_DBL_VAL) { + if (sbPtr->listObj != NULL) { + Tcl_Obj *objPtr; + + Tcl_ListObjIndex(interp, sbPtr->listObj, sbPtr->eIndex, &objPtr); + if (strcmp(Tcl_GetString(objPtr), entryPtr->string)) { + /* + * Somehow the string changed from what we expected, + * so let's do a search on the list to see if the current + * value is there. If not, move to the first element of + * the list. + */ + int i, listc, elemLen, length = entryPtr->numChars; + char *bytes; + Tcl_Obj **listv; + + Tcl_ListObjGetElements(interp, sbPtr->listObj, &listc, &listv); + for (i = 0; i < listc; i++) { + bytes = Tcl_GetStringFromObj(listv[i], &elemLen); + if ((length == elemLen) && + (memcmp(bytes, entryPtr->string, + (size_t) length) == 0)) { + sbPtr->eIndex = i; + break; + } + } + } + if (up) { + if (++sbPtr->eIndex >= sbPtr->nElements) { + if (sbPtr->wrap) { + sbPtr->eIndex = 0; + } else { + sbPtr->eIndex = sbPtr->nElements-1; + } + } + } else { + if (--sbPtr->eIndex < 0) { + if (sbPtr->wrap) { + sbPtr->eIndex = sbPtr->nElements-1; + } else { + sbPtr->eIndex = 0; + } + } + } + Tcl_ListObjIndex(interp, sbPtr->listObj, sbPtr->eIndex, &objPtr); + EntryValueChanged(entryPtr, Tcl_GetString(objPtr)); + } else if (!DOUBLES_EQ(sbPtr->fromValue, sbPtr->toValue)) { + double dvalue; + + if (Tcl_GetDouble(NULL, entryPtr->string, &dvalue) != TCL_OK) { + /* + * If the string is empty, or isn't a valid double value, + * just use the -from value + */ + dvalue = sbPtr->fromValue; + } else { + if (up) { + dvalue += sbPtr->increment; + if (dvalue > sbPtr->toValue) { + if (sbPtr->wrap) { + dvalue = sbPtr->fromValue; + } else { + dvalue = sbPtr->toValue; + } + } else if (dvalue < sbPtr->fromValue) { + /* + * It's possible that when pressing up, we are + * still less than the fromValue, because the + * user may have manipulated the value by hand. + */ + dvalue = sbPtr->fromValue; + } + } else { + dvalue -= sbPtr->increment; + if (dvalue < sbPtr->fromValue) { + if (sbPtr->wrap) { + dvalue = sbPtr->toValue; + } else { + dvalue = sbPtr->fromValue; + } + } else if (dvalue > sbPtr->toValue) { + /* + * It's possible that when pressing down, we are + * still greater than the toValue, because the + * user may have manipulated the value by hand. + */ + dvalue = sbPtr->toValue; + } + } + } + sprintf(sbPtr->formatBuf, sbPtr->valueFormat, dvalue); + EntryValueChanged(entryPtr, sbPtr->formatBuf); + } + } + + if (sbPtr->command != NULL) { + Tcl_DStringInit(&script); + ExpandPercents(entryPtr, sbPtr->command, type, "", 0, + VALIDATE_BUTTON, &script); + Tcl_DStringAppend(&script, "", 1); + + code = Tcl_EvalEx(interp, Tcl_DStringValue(&script), -1, + TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT); + Tcl_DStringFree(&script); + + if (code != TCL_OK) { + Tcl_AddErrorInfo(interp, "\n\t(in command executed by spinbox)"); + Tcl_BackgroundError(interp); + /* + * Yes, it's an error, but a bg one, so we return OK + */ + return TCL_OK; + } + + Tcl_SetResult(interp, NULL, 0); + } + + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * ComputeFormat -- + * + * This procedure is invoked to recompute the "format" fields + * of a spinbox's widget record, which determines how the value + * of the dial is converted to a string. + * + * Results: + * Tcl result code. + * + * Side effects: + * The format fields of the spinbox are modified. + * + *---------------------------------------------------------------------- + */ +static int +ComputeFormat(sbPtr) + Spinbox *sbPtr; /* Information about dial widget. */ +{ + double maxValue, x; + int mostSigDigit, numDigits, leastSigDigit, afterDecimal; + int eDigits, fDigits; + + /* + * Compute the displacement from the decimal of the most significant + * digit required for any number in the dial's range. + */ + + if (sbPtr->reqFormat) { + sbPtr->valueFormat = sbPtr->reqFormat; + return TCL_OK; + } + + maxValue = fabs(sbPtr->fromValue); + x = fabs(sbPtr->toValue); + if (x > maxValue) { + maxValue = x; + } + if (maxValue == 0) { + maxValue = 1; + } + mostSigDigit = (int) floor(log10(maxValue)); + + if (fabs(sbPtr->increment) > MIN_DBL_VAL) { + /* + * A increment was specified, so use it. + */ + leastSigDigit = (int) floor(log10(sbPtr->increment)); + } else { + leastSigDigit = 0; + } + numDigits = mostSigDigit - leastSigDigit + 1; + if (numDigits < 1) { + numDigits = 1; + } + + /* + * Compute the number of characters required using "e" format and + * "f" format, and then choose whichever one takes fewer characters. + */ + + eDigits = numDigits + 4; + if (numDigits > 1) { + eDigits++; /* Decimal point. */ + } + afterDecimal = numDigits - mostSigDigit - 1; + if (afterDecimal < 0) { + afterDecimal = 0; + } + fDigits = (mostSigDigit >= 0) ? mostSigDigit + afterDecimal : afterDecimal; + if (afterDecimal > 0) { + fDigits++; /* Decimal point. */ + } + if (mostSigDigit < 0) { + fDigits++; /* Zero to left of decimal point. */ + } + if (fDigits <= eDigits) { + sprintf(sbPtr->digitFormat, "%%.%df", afterDecimal); + } else { + sprintf(sbPtr->digitFormat, "%%.%de", numDigits-1); + } + sbPtr->valueFormat = sbPtr->digitFormat; + return TCL_OK; +} diff --git a/tk/generic/tkError.c b/tk/generic/tkError.c index aaf7c10b351..77909331a6f 100644 --- a/tk/generic/tkError.c +++ b/tk/generic/tkError.c @@ -305,4 +305,3 @@ ErrorProc(display, errEventPtr) couldntHandle: return (*defaultHandler)(display, errEventPtr); } - diff --git a/tk/generic/tkEvent.c b/tk/generic/tkEvent.c index bd70e881bae..602b044bc08 100644 --- a/tk/generic/tkEvent.c +++ b/tk/generic/tkEvent.c @@ -6,7 +6,7 @@ * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1995 Sun Microsystems, Inc. - * Copyright (c) 1998 by Scriptics Corporation. + * Copyright (c) 1998-2000 Ajuba Solutions. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -130,17 +130,16 @@ static unsigned long eventMasks[TK_LASTEVENT] = { */ typedef struct ThreadSpecificData { - - int genericHandlersActive; - /* The following variable has a non-zero + int handlersActive; /* The following variable has a non-zero * value when a handler is active. */ - InProgress *pendingPtr; - /* Topmost search in progress, or + InProgress *pendingPtr; /* Topmost search in progress, or * NULL if none. */ - GenericHandler *genericList; - /* First handler in the list, or NULL. */ - GenericHandler *lastGenericPtr; - /* Last handler in list. */ + + GenericHandler *genericList; /* First handler in the list, or NULL. */ + GenericHandler *lastGenericPtr; /* Last handler in list. */ + + GenericHandler *cmList; /* First handler in the list, or NULL. */ + GenericHandler *lastCmPtr; /* Last handler in list. */ /* * If someone has called Tk_RestrictEvents, the information below @@ -150,7 +149,7 @@ typedef struct ThreadSpecificData { Tk_RestrictProc *restrictProc; /* Procedure to call. NULL means no * restrictProc is currently in effect. */ - ClientData restrictArg; /* Argument to pass to restrictProc. */ + ClientData restrictArg; /* Argument to pass to restrictProc. */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; @@ -162,6 +161,9 @@ static Tcl_ThreadDataKey dataKey; static void DelayedMotionProc _ANSI_ARGS_((ClientData clientData)); static int WindowEventProc _ANSI_ARGS_((Tcl_Event *evPtr, int flags)); +static int TkXErrorHandler _ANSI_ARGS_((ClientData clientData, + XErrorEvent *errEventPtr)); + /* *-------------------------------------------------------------- @@ -354,16 +356,16 @@ Tk_CreateGenericHandler(proc, clientData) handlerPtr = (GenericHandler *) ckalloc (sizeof (GenericHandler)); - handlerPtr->proc = proc; - handlerPtr->clientData = clientData; - handlerPtr->deleteFlag = 0; - handlerPtr->nextPtr = NULL; + handlerPtr->proc = proc; + handlerPtr->clientData = clientData; + handlerPtr->deleteFlag = 0; + handlerPtr->nextPtr = NULL; if (tsdPtr->genericList == NULL) { - tsdPtr->genericList = handlerPtr; + tsdPtr->genericList = handlerPtr; } else { tsdPtr->lastGenericPtr->nextPtr = handlerPtr; } - tsdPtr->lastGenericPtr = handlerPtr; + tsdPtr->lastGenericPtr = handlerPtr; } /* @@ -392,7 +394,7 @@ Tk_DeleteGenericHandler(proc, clientData) { GenericHandler * handler; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); for (handler = tsdPtr->genericList; handler; handler = handler->nextPtr) { if ((handler->proc == proc) && (handler->clientData == clientData)) { @@ -401,6 +403,86 @@ Tk_DeleteGenericHandler(proc, clientData) } } +/*-------------------------------------------------------------- + * + * Tk_CreateClientMessageHandler -- + * + * Register a procedure to be called on each ClientMessage event. + * ClientMessage handlers are useful for Drag&Drop extensions. + * + * Results: + * None. + * + * Side Effects: + * From now on, whenever a ClientMessage event is received that isn't + * a WM_PROTOCOL event or SelectionEvent, invoke proc, giving it + * tkwin and the event as arguments. + * + *-------------------------------------------------------------- + */ + +void +Tk_CreateClientMessageHandler(proc) + Tk_ClientMessageProc *proc; /* Procedure to call on event. */ +{ + GenericHandler *handlerPtr; + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + + /* + * We use a GenericHandler struct, because it's basically the same, + * except with an extra clientData field we'll never use. + */ + handlerPtr = (GenericHandler *) + ckalloc (sizeof (GenericHandler)); + + handlerPtr->proc = (Tk_GenericProc *) proc; + handlerPtr->clientData = NULL; /* never used */ + handlerPtr->deleteFlag = 0; + handlerPtr->nextPtr = NULL; + if (tsdPtr->cmList == NULL) { + tsdPtr->cmList = handlerPtr; + } else { + tsdPtr->lastCmPtr->nextPtr = handlerPtr; + } + tsdPtr->lastCmPtr = handlerPtr; +} + +/* + *-------------------------------------------------------------- + * + * Tk_DeleteClientMessageHandler -- + * + * Delete a previously-created ClientMessage handler. + * + * Results: + * None. + * + * Side Effects: + * If there existed a handler as described by the parameters, + * that handler is logically deleted so that proc will not be + * invoked again. The physical deletion happens in the event + * loop in TkClientMessageEventProc. + * + *-------------------------------------------------------------- + */ + +void +Tk_DeleteClientMessageHandler(proc) + Tk_ClientMessageProc *proc; +{ + GenericHandler * handler; + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + + for (handler = tsdPtr->cmList; handler != NULL; + handler = handler->nextPtr) { + if (handler->proc == (Tk_GenericProc *) proc) { + handler->deleteFlag = 1; + } + } +} + /* *-------------------------------------------------------------- * @@ -424,14 +506,101 @@ void TkEventInit _ANSI_ARGS_((void)) { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + + tsdPtr->handlersActive = 0; + tsdPtr->pendingPtr = NULL; + tsdPtr->genericList = NULL; + tsdPtr->lastGenericPtr = NULL; + tsdPtr->cmList = NULL; + tsdPtr->lastCmPtr = NULL; + tsdPtr->restrictProc = NULL; + tsdPtr->restrictArg = NULL; +} + +/* + *-------------------------------------------------------------- + * + * TkXErrorHandler -- + * + * TkXErrorHandler is an error handler, to be installed + * via Tk_CreateErrorHandler, that will set a flag if an + * X error occurred. + * + * Results: + * Always returns 0, indicating that the X error was + * handled. + * + * Side effects: + * None. + * + *-------------------------------------------------------------- + */ - tsdPtr->genericHandlersActive = 0; - tsdPtr->pendingPtr = NULL; - tsdPtr->genericList = NULL; - tsdPtr->lastGenericPtr = NULL; - tsdPtr->restrictProc = NULL; - tsdPtr->restrictArg = NULL; +static int +TkXErrorHandler (clientData, errEventPtr) + ClientData clientData; /* Pointer to flag we set */ + XErrorEvent *errEventPtr; /* X error info */ +{ + int *error; + + error = (int *) clientData; + *error = 1; + return 0; +} + +/* + *-------------------------------------------------------------- + * + * ParentXId -- + * + * Returns the parent of the given window, or "None" + * if the window doesn't exist. + * + * Results: + * Returns an X window ID. + * + * Side effects: + * None. + * + *-------------------------------------------------------------- + */ + +static Window +ParentXId(display, w) + Display *display; + Window w; +{ + Tk_ErrorHandler handler; + int gotXError; + Status status; + Window parent; + Window root; + Window *childList; + unsigned int nChildren; + + /* Handle errors ourselves. */ + + gotXError = 0; + handler = Tk_CreateErrorHandler(display, -1, -1, -1, + TkXErrorHandler, (ClientData) (&gotXError)); + + /* Get the parent window. */ + + status = XQueryTree(display, w, &root, &parent, &childList, &nChildren); + + /* Do some cleanup; gotta return "None" if we got an error. */ + + Tk_DeleteErrorHandler(handler); + XSync(display, False); + if (status != 0 && childList != NULL) { + XFree(childList); + } + if (status == 0) { + parent = None; + } + + return parent; } /* @@ -462,10 +631,11 @@ Tk_HandleEvent(eventPtr) unsigned long mask; InProgress ip; Window handlerWindow; + Window parentXId; TkDisplay *dispPtr; Tcl_Interp *interp = (Tcl_Interp *) NULL; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Hack for simulated X-events: Correct the state field @@ -503,7 +673,7 @@ Tk_HandleEvent(eventPtr) for (genPrevPtr = NULL, genericPtr = tsdPtr->genericList; genericPtr != NULL; ) { if (genericPtr->deleteFlag) { - if (!tsdPtr->genericHandlersActive) { + if (!tsdPtr->handlersActive) { GenericHandler *tmpPtr; /* @@ -528,9 +698,9 @@ Tk_HandleEvent(eventPtr) } else { int done; - tsdPtr->genericHandlersActive++; + tsdPtr->handlersActive++; done = (*genericPtr->proc)(genericPtr->clientData, eventPtr); - tsdPtr->genericHandlersActive--; + tsdPtr->handlersActive--; if (done) { return; } @@ -573,18 +743,38 @@ Tk_HandleEvent(eventPtr) } winPtr = (TkWindow *) Tk_IdToWindow(eventPtr->xany.display, handlerWindow); if (winPtr == NULL) { - /* * There isn't a TkWindow structure for this window. * However, if the event is a PropertyNotify event then call * the selection manager (it deals beneath-the-table with - * certain properties). + * certain properties). Also, if the window's parent is a + * Tk window that has the TK_PROP_PROPCHANGE flag set, then + * we must propagate the PropertyNotify event up to the parent. */ - if (eventPtr->type == PropertyNotify) { - TkSelPropProc(eventPtr); + if (eventPtr->type != PropertyNotify) { + return; } - return; + + TkSelPropProc(eventPtr); + + /* Get handlerWindow's parent. */ + + parentXId = ParentXId(eventPtr->xany.display, handlerWindow); + if (parentXId == None) { + return; + } + + winPtr = (TkWindow *) Tk_IdToWindow(eventPtr->xany.display, parentXId); + if (winPtr == NULL) { + return; + } + + if (!(winPtr->flags & TK_PROP_PROPCHANGE)) { + return; + } + + handlerWindow = parentXId; } /* @@ -667,18 +857,56 @@ Tk_HandleEvent(eventPtr) * Pass the event to the input method(s), if there are any, and * discard the event if the input method(s) insist. Create the * input context for the window if it hasn't already been done - * (XFilterEvent needs this context). + * (XFilterEvent needs this context). XIM is only ever enabled on + * Unix, but this hasn't been factored out of the generic code yet. */ - if (winPtr->dispPtr->useInputMethods) { - if (!(winPtr->flags & TK_CHECKED_IC)) { - if (winPtr->dispPtr->inputMethod != NULL) { - winPtr->inputContext = XCreateIC( - winPtr->dispPtr->inputMethod, XNInputStyle, - XIMPreeditNothing|XIMStatusNothing, - XNClientWindow, winPtr->window, - XNFocusWindow, winPtr->window, NULL); - } + dispPtr = winPtr->dispPtr; + if ((dispPtr->flags & TK_DISPLAY_USE_IM)) { + if (!(winPtr->flags & (TK_CHECKED_IC|TK_ALREADY_DEAD))) { winPtr->flags |= TK_CHECKED_IC; + if (dispPtr->inputMethod != NULL) { +#if TK_XIM_SPOT + if (dispPtr->flags & TK_DISPLAY_XIM_SPOT) { + XVaNestedList preedit_attr; + XPoint spot = {0, 0}; + + if (dispPtr->inputXfs == NULL) { + /* + * We only need to create one XFontSet + */ + char **missing_list; + int missing_count; + char *def_string; + + dispPtr->inputXfs = XCreateFontSet(dispPtr->display, + "-*-*-*-R-Normal--14-130-75-75-*-*", + &missing_list, &missing_count, &def_string); + if (missing_count > 0) { + XFreeStringList(missing_list); + } + } + + preedit_attr = XVaCreateNestedList(0, XNSpotLocation, + &spot, XNFontSet, dispPtr->inputXfs, NULL); + if (winPtr->inputContext != NULL) + panic("inputContext not NULL"); + winPtr->inputContext = XCreateIC(dispPtr->inputMethod, + XNInputStyle, XIMPreeditPosition|XIMStatusNothing, + XNClientWindow, winPtr->window, + XNFocusWindow, winPtr->window, + XNPreeditAttributes, preedit_attr, + NULL); + XFree(preedit_attr); + } else +#endif + if (winPtr->inputContext != NULL) + panic("inputContext not NULL"); + winPtr->inputContext = XCreateIC(dispPtr->inputMethod, + XNInputStyle, XIMPreeditNothing|XIMStatusNothing, + XNClientWindow, winPtr->window, + XNFocusWindow, winPtr->window, + NULL); + } } if (XFilterEvent(eventPtr, None)) { goto done; @@ -710,10 +938,55 @@ Tk_HandleEvent(eventPtr) || (eventPtr->type == SelectionRequest) || (eventPtr->type == SelectionNotify)) { TkSelEventProc((Tk_Window) winPtr, eventPtr); - } else if ((eventPtr->type == ClientMessage) - && (eventPtr->xclient.message_type == - Tk_InternAtom((Tk_Window) winPtr, "WM_PROTOCOLS"))) { - TkWmProtocolEventProc(winPtr, eventPtr); + } else if (eventPtr->type == ClientMessage) { + if (eventPtr->xclient.message_type == + Tk_InternAtom((Tk_Window) winPtr, "WM_PROTOCOLS")) { + TkWmProtocolEventProc(winPtr, eventPtr); + } else { + /* + * Finally, invoke any ClientMessage event handlers. + */ + + for (genPrevPtr = NULL, genericPtr = tsdPtr->cmList; + genericPtr != NULL; ) { + if (genericPtr->deleteFlag) { + if (!tsdPtr->handlersActive) { + GenericHandler *tmpPtr; + + /* + * This handler needs to be deleted and there are + * no calls pending through any handlers, so now + * is a safe time to delete it. + */ + + tmpPtr = genericPtr->nextPtr; + if (genPrevPtr == NULL) { + tsdPtr->cmList = tmpPtr; + } else { + genPrevPtr->nextPtr = tmpPtr; + } + if (tmpPtr == NULL) { + tsdPtr->lastGenericPtr = genPrevPtr; + } + (void) ckfree((char *) genericPtr); + genericPtr = tmpPtr; + continue; + } + } else { + int done; + + tsdPtr->handlersActive++; + done = (*(Tk_ClientMessageProc *)genericPtr->proc) + ((Tk_Window) winPtr, eventPtr); + tsdPtr->handlersActive--; + if (done) { + break; + } + } + genPrevPtr = genericPtr; + genericPtr = genPrevPtr->nextPtr; + } + } } } else { for (handlerPtr = winPtr->handlerList; handlerPtr != NULL; ) { @@ -733,7 +1006,14 @@ Tk_HandleEvent(eventPtr) * these events here than in the lower-level procedures. */ - if ((ip.winPtr != None) && (mask != SubstructureNotifyMask)) { + /* + * ...well, except when we use the tkwm patches, in which case + * we DO handle CreateNotify events, so we gotta pass 'em through. + */ + + if ((ip.winPtr != None) + && ((mask != SubstructureNotifyMask) + || (eventPtr->type == CreateNotify))) { TkBindEventProc(winPtr, eventPtr); } } @@ -893,6 +1173,40 @@ Tk_RestrictEvents(proc, arg, prevArgPtr) return prev; } +/* + *---------------------------------------------------------------------- + * + * Tk_CollapseMotionEvents -- + * + * This procedure controls whether we collapse motion events in a + * particular display or not. + * + * Results: + * The return value is the previous collapse value in effect. + * + * Side effects: + * Filtering of motion events may be changed after calling this. + * + *---------------------------------------------------------------------- + */ + +int +Tk_CollapseMotionEvents(display, collapse) + Display *display; /* Display handling these events. */ + int collapse; /* boolean value that specifies whether + * motion events should be collapsed. */ +{ + TkDisplay *dispPtr = (TkDisplay *) display; + int prev = (dispPtr->flags & TK_DISPLAY_COLLAPSE_MOTION_EVENTS); + + if (collapse) { + dispPtr->flags |= TK_DISPLAY_COLLAPSE_MOTION_EVENTS; + } else { + dispPtr->flags &= ~TK_DISPLAY_COLLAPSE_MOTION_EVENTS; + } + return prev; +} + /* *---------------------------------------------------------------------- * @@ -937,6 +1251,19 @@ Tk_QueueWindowEvent(eventPtr, position) } } + /* + * Don't filter motion events if the user + * defaulting to true (1), which could be set to false (0) when the + * user wishes to receive all the motion data) + */ + if (!(dispPtr->flags & TK_DISPLAY_COLLAPSE_MOTION_EVENTS)) { + wevPtr = (TkWindowEvent *) ckalloc(sizeof(TkWindowEvent)); + wevPtr->header.proc = WindowEventProc; + wevPtr->event = *eventPtr; + Tcl_QueueEvent(&wevPtr->header, position); + return; + } + if ((dispPtr->delayedMotionPtr != NULL) && (position == TCL_QUEUE_TAIL)) { if ((eventPtr->type == MotionNotify) && (eventPtr->xmotion.window == dispPtr->delayedMotionPtr->event.xmotion.window)) { @@ -1012,7 +1339,7 @@ TkQueueEventForAllChildren(winPtr, eventPtr) childPtr = winPtr->childList; while (childPtr != NULL) { - if (!Tk_IsTopLevel(childPtr)) { + if (!Tk_TopWinHierarchy(childPtr)) { TkQueueEventForAllChildren(childPtr, eventPtr); } childPtr = childPtr->nextPtr; @@ -1130,4 +1457,3 @@ Tk_MainLoop() Tcl_DoOneEvent(0); } } - diff --git a/tk/generic/tkFileFilter.c b/tk/generic/tkFileFilter.c index 7604746bf9f..2263ebe4dca 100644 --- a/tk/generic/tkFileFilter.c +++ b/tk/generic/tkFileFilter.c @@ -17,7 +17,7 @@ static int AddClause _ANSI_ARGS_(( Tcl_Interp * interp, FileFilter * filterPtr, - char * patternsStr, char * ostypesStr, + CONST char * patternsStr, CONST char * ostypesStr, int isWindows)); static void FreeClauses _ANSI_ARGS_((FileFilter * filterPtr)); static void FreeGlobPatterns _ANSI_ARGS_(( @@ -25,7 +25,7 @@ static void FreeGlobPatterns _ANSI_ARGS_(( static void FreeMacFileTypes _ANSI_ARGS_(( FileFilterClause * clausePtr)); static FileFilter * GetFilter _ANSI_ARGS_((FileFilterList * flistPtr, - char * name)); + CONST char * name)); /* *---------------------------------------------------------------------- @@ -86,8 +86,8 @@ TkGetFileFilters(interp, flistPtr, string, isWindows) int isWindows; /* True if we are running on Windows. */ { int listArgc; - char ** listArgv = NULL; - char ** typeInfo = NULL; + CONST char ** listArgv = NULL; + CONST char ** typeInfo = NULL; int code = TCL_OK; int i; @@ -206,16 +206,16 @@ TkFreeFileFilters(flistPtr) static int AddClause(interp, filterPtr, patternsStr, ostypesStr, isWindows) Tcl_Interp * interp; /* Interpreter to use for error reporting. */ FileFilter * filterPtr; /* Stores the new filter clause */ - char * patternsStr; /* A TCL list of glob patterns. */ - char * ostypesStr; /* A TCL list of Mac OSType strings. */ + CONST char * patternsStr; /* A TCL list of glob patterns. */ + CONST char * ostypesStr; /* A TCL list of Mac OSType strings. */ int isWindows; /* True if we are running on Windows; False * if we are running on the Mac; Glob * patterns need to be processed differently * on these two platforms */ { - char ** globList = NULL; + CONST char ** globList = NULL; int globCount; - char ** ostypeList = NULL; + CONST char ** ostypeList = NULL; int ostypeCount; FileFilterClause * clausePtr; int i; @@ -270,7 +270,7 @@ static int AddClause(interp, filterPtr, patternsStr, ostypesStr, isWindows) /* * Prepend a "*" to patterns that do not have a leading "*" */ - globPtr->pattern = (char*)ckalloc(len+1); + globPtr->pattern = (char*)ckalloc((unsigned int) len+1); globPtr->pattern[0] = '*'; strcpy(globPtr->pattern+1, globList[i]); } @@ -289,11 +289,11 @@ static int AddClause(interp, filterPtr, patternsStr, ostypesStr, isWindows) strcpy(globPtr->pattern, "*."); } else { - globPtr->pattern = (char*)ckalloc(len); + globPtr->pattern = (char*)ckalloc((unsigned int) len); strcpy(globPtr->pattern, globList[i]); } } else { - globPtr->pattern = (char*)ckalloc(len); + globPtr->pattern = (char*)ckalloc((unsigned int) len); strcpy(globPtr->pattern, globList[i]); } @@ -358,7 +358,7 @@ static int AddClause(interp, filterPtr, patternsStr, ostypesStr, isWindows) static FileFilter * GetFilter(flistPtr, name) FileFilterList * flistPtr; /* The FileFilterList that contains the * newly created filter */ - char * name; /* Name of the filter. It is usually displayed + CONST char * name; /* Name of the filter. It is usually displayed * in the "File Types" listbox in the file * dialogs. */ { @@ -483,4 +483,3 @@ FreeMacFileTypes(clausePtr) } clausePtr->macTypes = NULL; } - diff --git a/tk/generic/tkFileFilter.h b/tk/generic/tkFileFilter.h index ec4d43f9c76..1550d76b45b 100644 --- a/tk/generic/tkFileFilter.h +++ b/tk/generic/tkFileFilter.h @@ -90,4 +90,3 @@ EXTERN int TkGetFileFilters _ANSI_ARGS_ ((Tcl_Interp *interp, # define TCL_STORAGE_CLASS DLLIMPORT #endif - diff --git a/tk/generic/tkFocus.c b/tk/generic/tkFocus.c index 8ed77cbb309..2839aa16d1e 100644 --- a/tk/generic/tkFocus.c +++ b/tk/generic/tkFocus.c @@ -121,8 +121,9 @@ Tk_FocusObjCmd(clientData, interp, objc, objv) int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ { - static char *focusOptions[] = {"-displayof", "-force", "-lastfor", - (char *) NULL}; + static CONST char *focusOptions[] = { + "-displayof", "-force", "-lastfor", (char *) NULL + }; Tk_Window tkwin = (Tk_Window) clientData; TkWindow *winPtr = (TkWindow *) clientData; TkWindow *newPtr, *focusWinPtr, *topLevelPtr; @@ -215,7 +216,7 @@ Tk_FocusObjCmd(clientData, interp, objc, objv) } for (topLevelPtr = newPtr; topLevelPtr != NULL; topLevelPtr = topLevelPtr->parentPtr) { - if (topLevelPtr->flags & TK_TOP_LEVEL) { + if (topLevelPtr->flags & TK_TOP_HIERARCHY) { for (tlFocusPtr = newPtr->mainPtr->tlFocusPtr; tlFocusPtr != NULL; tlFocusPtr = tlFocusPtr->nextPtr) { @@ -587,7 +588,7 @@ TkSetFocusWin(winPtr, force) if (!(topLevelPtr->flags & TK_MAPPED)) { allMapped = 0; } - if (topLevelPtr->flags & TK_TOP_LEVEL) { + if (topLevelPtr->flags & TK_TOP_HIERARCHY) { break; } } @@ -811,6 +812,14 @@ TkFocusDeadWindow(winPtr) DisplayFocusInfo *displayFocusPtr; TkDisplay *dispPtr = winPtr->dispPtr; + /* + * Certain special windows like those used for send and clipboard + * have no mainPtr. + */ + + if (winPtr->mainPtr == NULL) + return; + /* * Search for focus records that refer to this window either as * the top-level window or the current focus window. @@ -1011,4 +1020,39 @@ FindDisplayFocusInfo(mainPtr, dispPtr) mainPtr->displayFocusPtr = displayFocusPtr; return displayFocusPtr; } + +/* + *---------------------------------------------------------------------- + * + * TkFocusFree -- + * + * Free resources associated with maintaining the focus. + * + * Results: + * None. + * + * Side effects: + * This mainPtr should no long access focus information. + * + *---------------------------------------------------------------------- + */ +void +TkFocusFree(mainPtr) + TkMainInfo *mainPtr; /* Record that identifies a particular + * application. */ +{ + DisplayFocusInfo *displayFocusPtr; + ToplevelFocusInfo *tlFocusPtr; + + while (mainPtr->displayFocusPtr != NULL) { + displayFocusPtr = mainPtr->displayFocusPtr; + mainPtr->displayFocusPtr = mainPtr->displayFocusPtr->nextPtr; + ckfree((char *) displayFocusPtr); + } + while (mainPtr->tlFocusPtr != NULL) { + tlFocusPtr = mainPtr->tlFocusPtr; + mainPtr->tlFocusPtr = mainPtr->tlFocusPtr->nextPtr; + ckfree((char *) tlFocusPtr); + } +} diff --git a/tk/generic/tkFont.c b/tk/generic/tkFont.c index 4ced32a9e59..33b3acf4c44 100644 --- a/tk/generic/tkFont.c +++ b/tk/generic/tkFont.c @@ -168,7 +168,7 @@ static TkStateMap xlfdSetwidthMap[] = { * when configuring a set of font attributes. */ -static char *fontOpt[] = { +static CONST char *fontOpt[] = { "-family", "-size", "-weight", @@ -355,7 +355,7 @@ static void UpdateDependentFonts _ANSI_ARGS_((TkFontInfo *fiPtr, * NULL. */ -static Tcl_ObjType fontObjType = { +Tcl_ObjType tkFontObjType = { "font", /* name */ FreeFontObjProc, /* freeIntRepProc */ DupFontObjProc, /* dupIntRepProc */ @@ -435,9 +435,11 @@ TkFontPkgFree(mainPtr) fprintf(stderr, "Font %s still in cache.\n", Tcl_GetHashKey(&fiPtr->fontCache, searchPtr)); } +#ifdef PURIFY if (fontsLeft) { panic("TkFontPkgFree: all fonts should have been freed already"); } +#endif Tcl_DeleteHashTable(&fiPtr->fontCache); hPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search); @@ -479,7 +481,7 @@ Tk_FontObjCmd(clientData, interp, objc, objv) int index; Tk_Window tkwin; TkFontInfo *fiPtr; - static char *optionStrings[] = { + static CONST char *optionStrings[] = { "actual", "configure", "create", "delete", "families", "measure", "metrics", "names", NULL @@ -684,7 +686,7 @@ Tk_FontObjCmd(clientData, interp, objc, objv) Tk_Font tkfont; int skip, index, i; CONST TkFontMetrics *fmPtr; - static char *switches[] = { + static CONST char *switches[] = { "-ascent", "-descent", "-linespace", "-fixed", NULL }; @@ -831,10 +833,30 @@ static void RecomputeWidgets(winPtr) TkWindow *winPtr; /* Window to which command is sent. */ { - if ((winPtr->classProcsPtr != NULL) - && (winPtr->classProcsPtr->geometryProc != NULL)) { - (*winPtr->classProcsPtr->geometryProc)(winPtr->instanceData); + Tk_ClassWorldChangedProc *proc; + proc = Tk_GetClassProc(winPtr->classProcsPtr, worldChangedProc); + if (proc != NULL) { + (*proc)(winPtr->instanceData); } + + /* + * Notify all the descendants of this window that the world has changed. + * + * This could be done recursively or iteratively. The recursive version + * is easier to implement and understand, and typically, windows with a + * -font option will be leaf nodes in the widget heirarchy (buttons, + * labels, etc.), so the recursion depth will be shallow. + * + * However, the additional overhead of the recursive calls may become + * a performance problem if typical usage alters such that -font'ed widgets + * appear high in the heirarchy, causing deep recursion. This could happen + * with text widgets, or more likely with the (not yet existant) labeled + * frame widget. With these widgets it is possible, even likely, that a + * -font'ed widget (text or labeled frame) will not be a leaf node, but + * will instead have many descendants. If this is ever found to cause + * a performance problem, it may be worth investigating an iterative + * version of the code below. + */ for (winPtr = winPtr->childList; winPtr != NULL; winPtr = winPtr->nextPtr) { RecomputeWidgets(winPtr); } @@ -985,7 +1007,7 @@ Tk_AllocFontFromObj(interp, tkwin, objPtr) NamedFont *nfPtr; fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr; - if (objPtr->typePtr != &fontObjType) { + if (objPtr->typePtr != &tkFontObjType) { SetFontFromAny(interp, objPtr); } @@ -1152,7 +1174,7 @@ Tk_GetFontFromObj(tkwin, objPtr) TkFont *fontPtr; Tcl_HashEntry *hashPtr; - if (objPtr->typePtr != &fontObjType) { + if (objPtr->typePtr != &tkFontObjType) { SetFontFromAny((Tcl_Interp *) NULL, objPtr); } @@ -1210,7 +1232,7 @@ Tk_GetFontFromObj(tkwin, objPtr) * Always returns TCL_OK. * * Side effects: - * The object is left with its typePtr pointing to fontObjType. + * The object is left with its typePtr pointing to tkFontObjType. * The TkFont pointer is NULL. * *---------------------------------------------------------------------- @@ -1232,7 +1254,7 @@ SetFontFromAny(interp, objPtr) if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) { (*typePtr->freeIntRepProc)(objPtr); } - objPtr->typePtr = &fontObjType; + objPtr->typePtr = &tkFontObjType; objPtr->internalRep.twoPtrValue.ptr1 = NULL; return TCL_OK; @@ -1257,7 +1279,7 @@ SetFontFromAny(interp, objPtr) *--------------------------------------------------------------------------- */ -char * +CONST char * Tk_NameOfFont(tkfont) Tk_Font tkfont; /* Font whose name is desired. */ { @@ -1528,7 +1550,7 @@ Tk_PostscriptFontName(tkfont, dsPtr) * corresponds to tkfont will be appended. */ { TkFont *fontPtr; - char *family, *weightString, *slantString; + Tk_Uid family, weightString, slantString; char *src, *dest; int upper, len; @@ -2222,21 +2244,18 @@ Tk_UnderlineTextLayout(display, drawable, gc, layout, x, y, underline) int underline; /* Index of the single character to * underline, or -1 for no underline. */ { - TextLayout *layoutPtr = (TextLayout *) layout; + TextLayout *layoutPtr; TkFont *fontPtr; - int xx, yy, width, height, underlineByte; + int xx, yy, width, height; - if (underline > -1) { - underlineByte = Tcl_UtfAtIndex(layoutPtr->string, underline) - - layoutPtr->string; - if ((Tk_CharBbox(layout, underlineByte, &xx, &yy, &width, &height) != 0) - && (width != 0)) { - fontPtr = (TkFont *) layoutPtr->tkfont; + if ((Tk_CharBbox(layout, underline, &xx, &yy, &width, &height) != 0) + && (width != 0)) { + layoutPtr = (TextLayout *) layout; + fontPtr = (TkFont *) layoutPtr->tkfont; - XFillRectangle(display, drawable, gc, x + xx, - y + yy + fontPtr->fm.ascent + fontPtr->underlinePos, - (unsigned int) width, (unsigned int) fontPtr->underlineHeight); - } + XFillRectangle(display, drawable, gc, x + xx, + y + yy + fontPtr->fm.ascent + fontPtr->underlinePos, + (unsigned int) width, (unsigned int) fontPtr->underlineHeight); } } @@ -2437,14 +2456,6 @@ Tk_CharBbox(layout, index, xPtr, yPtr, widthPtr, heightPtr) CONST char *end; if (index < 0) { - if (xPtr) - *xPtr = 0; - if (yPtr) - *yPtr = 0; - if (widthPtr) - *widthPtr = 0; - if (heightPtr) - *heightPtr = 0; return 0; } @@ -2740,22 +2751,29 @@ Tk_TextLayoutToPostscript(interp, layout) Tk_TextLayout layout; /* The layout to be rendered. */ { #define MAXUSE 128 - char buf[MAXUSE+10]; + char buf[MAXUSE+30]; LayoutChunk *chunkPtr; int i, j, used, c, baseline; Tcl_UniChar ch; - CONST char *p; + CONST char *p, *last_p,*glyphname; TextLayout *layoutPtr; + char uindex[5]="\0\0\0\0"; + char one_char[5]; + int charsize; + int bytecount=0; layoutPtr = (TextLayout *) layout; chunkPtr = layoutPtr->chunks; baseline = chunkPtr->y; used = 0; + buf[used++] = '['; buf[used++] = '('; for (i = 0; i < layoutPtr->numChunks; i++) { if (baseline != chunkPtr->y) { buf[used++] = ')'; + buf[used++] = ']'; buf[used++] = '\n'; + buf[used++] = '['; buf[used++] = '('; baseline = chunkPtr->y; } @@ -2772,23 +2790,43 @@ Tk_TextLayoutToPostscript(interp, layout) * data and display the lower byte. Eventually this should * be revised to handle international postscript fonts. */ + last_p=p; + p +=(charsize= Tcl_UtfToUniChar(p,&ch)); + Tcl_UtfToExternal(interp,NULL,last_p,charsize,0,NULL,one_char,4, + NULL,&bytecount,NULL); + if (bytecount == 1) { + c = UCHAR(one_char[0]); + /* c = UCHAR( ch & 0xFF) */; + if ((c == '(') || (c == ')') || (c == '\\') || (c < 0x20) + || (c >= UCHAR(0x7f))) { + /* + * Tricky point: the "03" is necessary in the sprintf + * below, so that a full three digits of octal are + * always generated. Without the "03", a number + * following this sequence could be interpreted by + * Postscript as part of this sequence. + */ - p += Tcl_UtfToUniChar(p, &ch); - c = UCHAR(ch & 0xff); - if ((c == '(') || (c == ')') || (c == '\\') || (c < 0x20) - || (c >= UCHAR(0x7f))) { - /* - * Tricky point: the "03" is necessary in the sprintf - * below, so that a full three digits of octal are - * always generated. Without the "03", a number - * following this sequence could be interpreted by - * Postscript as part of this sequence. - */ - - sprintf(buf + used, "\\%03o", c); - used += 4; + sprintf(buf + used, "\\%03o", c); + used += 4; + } else { + buf[used++] = c; + } } else { - buf[used++] = c; + /* This character doesn't belong to system character set. + * So, we must use full glyph name */ + sprintf(uindex,"%04X",ch); /* endianness? */ + if ((glyphname = Tcl_GetVar2( interp , "::tk::psglyphs",uindex,0))) { + if (used > 0 && buf [used-1] == '(') + --used; + else + buf[used++] = ')'; + buf[used++] = '/'; + while( (*glyphname) && (used < (MAXUSE+27))) + buf[used++] = *glyphname++ ; + buf[used++] = '('; + } + } if (used >= MAXUSE) { buf[used] = '\0'; @@ -2810,6 +2848,7 @@ Tk_TextLayoutToPostscript(interp, layout) chunkPtr++; } buf[used++] = ')'; + buf[used++] = ']'; buf[used++] = '\n'; buf[used] = '\0'; Tcl_AppendResult(interp, buf, (char *) NULL); @@ -2954,7 +2993,7 @@ GetAttributeInfoObj(interp, faPtr, objPtr) * returned for all options. */ { int i, index, start, end; - char *str; + CONST char *str; Tcl_Obj *optionPtr, *valuePtr, *resultPtr; resultPtr = Tcl_GetObjResult(interp); @@ -3675,28 +3714,46 @@ TkDebugFont(tkwin, name) return resultPtr; } -/* CYGNUS LOCAL: This routine is called on Windows to update a named - font to a possibly new set of font attributes. */ +/* + *---------------------------------------------------------------------- + * + * TkFontGetFirstTextLayout -- + * + * This procedure returns the first chunk of a Tk_TextLayout, + * i.e. until the first font change on the first line (or the + * whole first line if there is no such font change). + * + * Results: + * The return value is the byte length of the chunk, the chunk + * itself is copied into dst and its Tk_Font into font. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ -void -TkUpdateFonts(tkwin, changed) - Tk_Window tkwin; - int (*changed) _ANSI_ARGS_((TkFontAttributes *faPtr)); +int +TkFontGetFirstTextLayout( + Tk_TextLayout layout, /* Layout information, from a previous call + * to Tk_ComputeTextLayout(). */ + Tk_Font * font, + char * dst) { - TkFontInfo *fiPtr; - Tcl_HashEntry *namedHashPtr; - Tcl_HashSearch search; - NamedFont *nfPtr; - - fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr; + TextLayout *layoutPtr; + LayoutChunk *chunkPtr; + int numBytesInChunk; - namedHashPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search); - while (namedHashPtr != NULL) { - nfPtr = (NamedFont *) Tcl_GetHashValue(namedHashPtr); - if ((*changed)(&nfPtr->fa)) { - UpdateDependentFonts(fiPtr, tkwin, namedHashPtr); - } - namedHashPtr = Tcl_NextHashEntry(&search); + layoutPtr = (TextLayout *)layout; + if ((layoutPtr==NULL) + || (layoutPtr->numChunks==0) + || (layoutPtr->chunks->numDisplayChars <= 0)) { + dst[0] = '\0'; + return 0; } + chunkPtr = layoutPtr->chunks; + numBytesInChunk = chunkPtr->numBytes; + strncpy(dst, chunkPtr->start, (size_t) numBytesInChunk); + *font = layoutPtr->tkfont; + return numBytesInChunk; } - diff --git a/tk/generic/tkFont.h b/tk/generic/tkFont.h index 5c891e3e8e5..ee99ae74e21 100644 --- a/tk/generic/tkFont.h +++ b/tk/generic/tkFont.h @@ -220,13 +220,7 @@ EXTERN void TkpGetFontFamilies _ANSI_ARGS_((Tcl_Interp *interp, EXTERN TkFont * TkpGetNativeFont _ANSI_ARGS_((Tk_Window tkwin, CONST char *name)); -/* CYGNUS LOCAL */ -EXTERN void TkUpdateFonts _ANSI_ARGS_((Tk_Window tkwin, - int (*changed) (TkFontAttributes *faPtr))); - # undef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLIMPORT #endif /* _TKFONT */ - - diff --git a/tk/generic/tkFrame.c b/tk/generic/tkFrame.c index 949fb18c226..0bf63824032 100644 --- a/tk/generic/tkFrame.c +++ b/tk/generic/tkFrame.c @@ -1,8 +1,8 @@ /* * tkFrame.c -- * - * This module implements "frame" and "toplevel" widgets for - * the Tk toolkit. Frames are windows with a background color + * This module implements "frame", "labelframe" and "toplevel" widgets + * for the Tk toolkit. Frames are windows with a background color * and possibly a 3-D effect, but not much else in the way of * attributes. * @@ -19,6 +19,14 @@ #include "tkPort.h" #include "tkInt.h" +/* + * The following enum is used to define the type of the frame. + */ + +enum FrameType { + TYPE_FRAME, TYPE_TOPLEVEL, TYPE_LABELFRAME +}; + /* * A data structure of the following type is kept for each * frame that currently exists for this process: @@ -35,11 +43,11 @@ typedef struct { Tcl_Interp *interp; /* Interpreter associated with widget. Used * to delete widget command. */ Tcl_Command widgetCmd; /* Token for frame's widget command. */ + Tk_OptionTable optionTable; /* Table that defines configuration options + * available for this widget. */ char *className; /* Class name for widget (from configuration * option). Malloc-ed. */ - int mask; /* Either FRAME or TOPLEVEL; used to select - * which configuration options are valid for - * widget. */ + enum FrameType type; /* Type of widget, such as TYPE_FRAME. */ char *screenName; /* Screen on which widget is created. Non-null * only for top-levels. Malloc-ed, may be * NULL. */ @@ -82,8 +90,62 @@ typedef struct { * windows this is NULL. */ int flags; /* Various flags; see below for * definitions. */ + Tcl_Obj *padXPtr; /* Value of -padx option: specifies how many + * pixels of extra space to leave on left and + * right of child area. */ + int padX; /* Integer value corresponding to padXPtr. */ + Tcl_Obj *padYPtr; /* Value of -padx option: specifies how many + * pixels of extra space to leave above and + * below child area. */ + int padY; /* Integer value corresponding to padYPtr. */ } Frame; +/* + * A data structure of the following type is kept for each labelframe + * widget managed by this file: + */ + +typedef struct { + Frame frame; /* A pointer to the generic frame structure. + * This must be the first element of the + * Labelframe. */ + + /* + * Labelframe specific configuration settings. + */ + + Tcl_Obj *textPtr; /* Value of -text option: specifies text to + * display in button. */ + Tk_Font tkfont; /* Value of -font option: specifies font + * to use for display text. */ + XColor *textColorPtr; /* Value of -fg option: specifies foreground + * color in normal mode. */ + int labelAnchor; /* Value of -labelanchor option: specifies + * where to place the label. */ + Tk_Window labelWin; /* Value of -labelwidget option: Window to + * use as label for the frame. */ + + /* + * Labelframe specific fields for use with configuration settings above. + */ + + GC textGC; /* GC for drawing text in normal mode. */ + Tk_TextLayout textLayout; /* Stored text layout information. */ + XRectangle labelBox; /* The label's actual size and position. */ + int labelReqWidth; /* The label's requested width. */ + int labelReqHeight; /* The label's requested height. */ + int labelTextX, labelTextY; /* Position of the text to be drawn. */ + +} Labelframe; + +/* + * The following macros define how many extra pixels to leave + * around a label's text. + */ + +#define LABELSPACING 1 +#define LABELMARGIN 4 + /* * Flag bits for frames: * @@ -98,129 +160,264 @@ typedef struct { #define GOT_FOCUS 4 /* - * The following flag bits are used so that there can be separate - * defaults for some configuration options for frames and toplevels. + * The following enum is used to define a type for the -labelanchor option + * of the Labelframe widget. These values are used as indices into the + * string table below. */ -#define FRAME TK_CONFIG_USER_BIT -#define TOPLEVEL (TK_CONFIG_USER_BIT << 1) -#define BOTH (FRAME | TOPLEVEL) - -static Tk_ConfigSpec configSpecs[] = { - {TK_CONFIG_BORDER, "-background", "background", "Background", - DEF_FRAME_BG_COLOR, Tk_Offset(Frame, border), - BOTH|TK_CONFIG_COLOR_ONLY|TK_CONFIG_NULL_OK}, - {TK_CONFIG_BORDER, "-background", "background", "Background", - DEF_FRAME_BG_MONO, Tk_Offset(Frame, border), - BOTH|TK_CONFIG_MONO_ONLY|TK_CONFIG_NULL_OK}, - {TK_CONFIG_SYNONYM, "-bd", "borderWidth", (char *) NULL, - (char *) NULL, 0, BOTH}, - {TK_CONFIG_SYNONYM, "-bg", "background", (char *) NULL, - (char *) NULL, 0, BOTH}, - {TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_FRAME_BORDER_WIDTH, Tk_Offset(Frame, borderWidth), BOTH}, - {TK_CONFIG_STRING, "-class", "class", "Class", - DEF_FRAME_CLASS, Tk_Offset(Frame, className), FRAME}, - {TK_CONFIG_STRING, "-class", "class", "Class", - DEF_TOPLEVEL_CLASS, Tk_Offset(Frame, className), TOPLEVEL}, - {TK_CONFIG_STRING, "-colormap", "colormap", "Colormap", - DEF_FRAME_COLORMAP, Tk_Offset(Frame, colormapName), - BOTH|TK_CONFIG_NULL_OK}, - {TK_CONFIG_BOOLEAN, "-container", "container", "Container", - DEF_FRAME_CONTAINER, Tk_Offset(Frame, isContainer), BOTH}, - {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor", - DEF_FRAME_CURSOR, Tk_Offset(Frame, cursor), BOTH|TK_CONFIG_NULL_OK}, - {TK_CONFIG_PIXELS, "-height", "height", "Height", - DEF_FRAME_HEIGHT, Tk_Offset(Frame, height), BOTH}, - {TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground", - "HighlightBackground", DEF_FRAME_HIGHLIGHT_BG, - Tk_Offset(Frame, highlightBgColorPtr), BOTH}, - {TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", - DEF_FRAME_HIGHLIGHT, Tk_Offset(Frame, highlightColorPtr), BOTH}, - {TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness", - "HighlightThickness", - DEF_FRAME_HIGHLIGHT_WIDTH, Tk_Offset(Frame, highlightWidth), BOTH}, - {TK_CONFIG_STRING, "-menu", "menu", "Menu", - DEF_TOPLEVEL_MENU, Tk_Offset(Frame, menuName), - TOPLEVEL|TK_CONFIG_NULL_OK}, - {TK_CONFIG_RELIEF, "-relief", "relief", "Relief", - DEF_FRAME_RELIEF, Tk_Offset(Frame, relief), BOTH}, - {TK_CONFIG_STRING, "-screen", "screen", "Screen", - DEF_TOPLEVEL_SCREEN, Tk_Offset(Frame, screenName), - TOPLEVEL|TK_CONFIG_NULL_OK}, - {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus", - DEF_FRAME_TAKE_FOCUS, Tk_Offset(Frame, takeFocus), - BOTH|TK_CONFIG_NULL_OK}, - {TK_CONFIG_STRING, "-use", "use", "Use", - DEF_FRAME_USE, Tk_Offset(Frame, useThis), TOPLEVEL|TK_CONFIG_NULL_OK}, - {TK_CONFIG_STRING, "-visual", "visual", "Visual", - DEF_FRAME_VISUAL, Tk_Offset(Frame, visualName), - BOTH|TK_CONFIG_NULL_OK}, - {TK_CONFIG_PIXELS, "-width", "width", "Width", - DEF_FRAME_WIDTH, Tk_Offset(Frame, width), BOTH}, - {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL, - (char *) NULL, 0, 0} +enum labelanchor { + LABELANCHOR_E, LABELANCHOR_EN, LABELANCHOR_ES, + LABELANCHOR_N, LABELANCHOR_NE, LABELANCHOR_NW, + LABELANCHOR_S, LABELANCHOR_SE, LABELANCHOR_SW, + LABELANCHOR_W, LABELANCHOR_WN, LABELANCHOR_WS +}; + +static char *labelAnchorStrings[] = { + "e", "en", "es", "n", "ne", "nw", "s", "se", "sw", "w", "wn", "ws", + (char *) NULL +}; + +/* + * Information used for parsing configuration options. There are + * one common table used by all and one table for each widget class. + */ + +static Tk_OptionSpec commonOptSpec[] = { + {TK_OPTION_BORDER, "-background", "background", "Background", + DEF_FRAME_BG_COLOR, -1, Tk_Offset(Frame, border), + TK_OPTION_NULL_OK, (ClientData) DEF_FRAME_BG_MONO, 0}, + {TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, + (char *) NULL, 0, -1, 0, (ClientData) "-background", 0}, + {TK_OPTION_STRING, "-colormap", "colormap", "Colormap", + DEF_FRAME_COLORMAP, -1, Tk_Offset(Frame, colormapName), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_BOOLEAN, "-container", "container", "Container", + DEF_FRAME_CONTAINER, -1, Tk_Offset(Frame, isContainer), + 0, 0, 0}, + {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", + DEF_FRAME_CURSOR, -1, Tk_Offset(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}, + {TK_OPTION_COLOR, "-highlightbackground", "highlightBackground", + "HighlightBackground", DEF_FRAME_HIGHLIGHT_BG, -1, + Tk_Offset(Frame, highlightBgColorPtr), 0, 0, 0}, + {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", + DEF_FRAME_HIGHLIGHT, -1, Tk_Offset(Frame, highlightColorPtr), + 0, 0, 0}, + {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", + "HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH, -1, + Tk_Offset(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}, + {TK_OPTION_PIXELS, "-pady", "padY", "Pad", + DEF_FRAME_PADY, Tk_Offset(Frame, padYPtr), + Tk_Offset(Frame, padY), 0, 0, 0}, + {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", + DEF_FRAME_TAKE_FOCUS, -1, Tk_Offset(Frame, takeFocus), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_STRING, "-visual", "visual", "Visual", + DEF_FRAME_VISUAL, -1, Tk_Offset(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}, + {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, + (char *) NULL, 0, 0, 0, 0, 0} +}; + +static Tk_OptionSpec frameOptSpec[] = { + {TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, + (char *) NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, + {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", + DEF_FRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth), + 0, 0, 0}, + {TK_OPTION_STRING, "-class", "class", "Class", + DEF_FRAME_CLASS, -1, Tk_Offset(Frame, className), + 0, 0, 0}, + {TK_OPTION_RELIEF, "-relief", "relief", "Relief", + DEF_FRAME_RELIEF, -1, Tk_Offset(Frame, relief), + 0, 0, 0}, + {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, + (char *) NULL, 0, 0, 0, (ClientData) commonOptSpec, 0} +}; + +static Tk_OptionSpec toplevelOptSpec[] = { + {TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, + (char *) NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, + {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", + DEF_FRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth), + 0, 0, 0}, + {TK_OPTION_STRING, "-class", "class", "Class", + DEF_TOPLEVEL_CLASS, -1, Tk_Offset(Frame, className), + 0, 0, 0}, + {TK_OPTION_STRING, "-menu", "menu", "Menu", + DEF_TOPLEVEL_MENU, -1, Tk_Offset(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}, + {TK_OPTION_STRING, "-screen", "screen", "Screen", + DEF_TOPLEVEL_SCREEN, -1, Tk_Offset(Frame, screenName), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_STRING, "-use", "use", "Use", + DEF_TOPLEVEL_USE, -1, Tk_Offset(Frame, useThis), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, + (char *) NULL, 0, 0, 0, (ClientData) commonOptSpec, 0} +}; + +static Tk_OptionSpec labelframeOptSpec[] = { + {TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, + (char *) NULL, 0, -1, 0, (ClientData) "-borderwidth", 0}, + {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", + DEF_LABELFRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth), + 0, 0, 0}, + {TK_OPTION_STRING, "-class", "class", "Class", + DEF_LABELFRAME_CLASS, -1, Tk_Offset(Frame, className), + 0, 0, 0}, + {TK_OPTION_SYNONYM, "-fg", "foreground", (char *) NULL, + (char *) NULL, 0, -1, 0, (ClientData) "-foreground", 0}, + {TK_OPTION_FONT, "-font", "font", "Font", + DEF_LABELFRAME_FONT, -1, Tk_Offset(Labelframe, tkfont), 0, 0, 0}, + {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", + DEF_LABELFRAME_FG, -1, Tk_Offset(Labelframe, textColorPtr), 0, 0, 0}, + {TK_OPTION_STRING_TABLE, "-labelanchor", "labelAnchor", "LabelAnchor", + DEF_LABELFRAME_LABELANCHOR, -1, Tk_Offset(Labelframe, labelAnchor), + 0, (ClientData) labelAnchorStrings, 0}, + {TK_OPTION_WINDOW, "-labelwidget", "labelWidget", "LabelWidget", + (char *) NULL, -1, Tk_Offset(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}, + {TK_OPTION_STRING, "-text", "text", "Text", + DEF_LABELFRAME_TEXT, Tk_Offset(Labelframe, textPtr), -1, + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, + (char *) NULL, 0, 0, 0, (ClientData) commonOptSpec, 0} +}; + +/* + * Class names for widgets, indexed by FrameType. + */ + +static char *classNames[] = {"Frame", "Toplevel", "Labelframe"}; + +/* + * The following table maps from FrameType to the option template for + * that class of widgets. + */ + +static Tk_OptionSpec *optionSpecs[] = { + frameOptSpec, + toplevelOptSpec, + labelframeOptSpec, }; /* * Forward declarations for procedures defined later in this file: */ +static void ComputeFrameGeometry _ANSI_ARGS_((Frame *framePtr)); static int ConfigureFrame _ANSI_ARGS_((Tcl_Interp *interp, - Frame *framePtr, int objc, Tcl_Obj *CONST objv[], - int flags)); + Frame *framePtr, int objc, Tcl_Obj *CONST objv[])); static int CreateFrame _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST argv[], - int toplevel, char *appName)); + enum FrameType type, char *appName)); static void DestroyFrame _ANSI_ARGS_((char *memPtr)); +static void DestroyFramePartly _ANSI_ARGS_((Frame *framePtr)); static void DisplayFrame _ANSI_ARGS_((ClientData clientData)); static void FrameCmdDeletedProc _ANSI_ARGS_(( ClientData clientData)); static void FrameEventProc _ANSI_ARGS_((ClientData clientData, XEvent *eventPtr)); +static void FrameLostSlaveProc _ANSI_ARGS_(( + ClientData clientData, Tk_Window tkwin)); +static void FrameRequestProc _ANSI_ARGS_((ClientData clientData, + Tk_Window tkwin)); +static void FrameStructureProc _ANSI_ARGS_(( + ClientData clientData, XEvent *eventPtr)); static int FrameWidgetObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); +static void FrameWorldChanged _ANSI_ARGS_(( + ClientData instanceData)); static void MapFrame _ANSI_ARGS_((ClientData clientData)); + +/* + * The structure below defines frame class behavior by means of procedures + * that can be invoked from generic window code. + */ + +static Tk_ClassProcs frameClass = { + sizeof(Tk_ClassProcs), /* size */ + FrameWorldChanged /* worldChangedProc */ +}; + +/* + * The structure below defines the official type record for the + * labelframe's geometry manager: + */ + +static Tk_GeomMgr frameGeomType = { + "labelframe", /* name */ + FrameRequestProc, /* requestProc */ + FrameLostSlaveProc /* lostSlaveProc */ +}; + /* *-------------------------------------------------------------- * - * Tk_FrameObjCmd, Tk_ToplevelObjCmd -- + * Tk_FrameObjCmd, Tk_ToplevelObjCmd, Tk_LabelframeObjCmd -- * - * These procedures are invoked to process the "frame" and - * "toplevel" Tcl commands. See the user documentation for - * details on what they do. + * These procedures are invoked to process the "frame", + * "toplevel" and "labelframe" Tcl commands. See the user + * documentation for details on what they do. * * Results: * A standard Tcl result. * * Side effects: * See the user documentation. These procedures are just wrappers; - * they call ButtonCreate to do all of the real work. + * they call CreateFrame to do all of the real work. * *-------------------------------------------------------------- */ int Tk_FrameObjCmd(clientData, interp, objc, objv) - ClientData clientData; /* Main window associated with - * interpreter. */ + ClientData clientData; /* Either NULL or pointer to option table. */ Tcl_Interp *interp; /* Current interpreter. */ int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ { - return CreateFrame(clientData, interp, objc, objv, 0, (char *) NULL); + return CreateFrame(clientData, interp, objc, objv, TYPE_FRAME, + (char *) NULL); } int Tk_ToplevelObjCmd(clientData, interp, objc, objv) - ClientData clientData; /* Main window associated with - * interpreter. */ + ClientData clientData; /* Either NULL or pointer to option table. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ +{ + return CreateFrame(clientData, interp, objc, objv, TYPE_TOPLEVEL, + (char *) NULL); +} + +int +Tk_LabelframeObjCmd(clientData, interp, objc, objv) + ClientData clientData; /* Either NULL or pointer to option table. */ Tcl_Interp *interp; /* Current interpreter. */ int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ { - return CreateFrame(clientData, interp, objc, objv, 1, (char *) NULL); + return CreateFrame(clientData, interp, objc, objv, TYPE_LABELFRAME, + (char *) NULL); } /* @@ -228,10 +425,10 @@ Tk_ToplevelObjCmd(clientData, interp, objc, objv) * * TkCreateFrame -- * - * This procedure is invoked to process the "frame" and "toplevel" - * Tcl commands; it is also invoked directly by Tk_Init to create - * a new main window. See the user documentation for the "frame" - * and "toplevel" commands for details on what it does. + * This procedure is the old command procedure for the "frame" + * and "toplevel" commands. Now it is used directly by Tk_Init to + * create a new main window. See the user documentation for the + * "frame" and "toplevel" commands for details on what it does. * * Results: * A standard Tcl result. @@ -244,16 +441,15 @@ Tk_ToplevelObjCmd(clientData, interp, objc, objv) int TkCreateFrame(clientData, interp, argc, argv, toplevel, appName) - ClientData clientData; /* Main window associated with interpreter. - * If we're called by Tk_Init to create a - * new application, then this is NULL. */ + ClientData clientData; /* Either NULL or pointer to option table. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ char **argv; /* Argument strings. */ int toplevel; /* Non-zero means create a toplevel window, * zero means create a frame. */ - char *appName; /* Should only be non-NULL if clientData is - * NULL: gives the base name to use for the + char *appName; /* Should only be non-NULL if there is no main + * window associated with the interpreter. + * Gives the base name to use for the * new application. */ { int result, i; @@ -263,7 +459,8 @@ TkCreateFrame(clientData, interp, argc, argv, toplevel, appName) Tcl_IncrRefCount(objv[i]); } objv[argc] = NULL; - result = CreateFrame(clientData, interp, argc, objv, toplevel, appName); + result = CreateFrame(clientData, interp, argc, objv, + toplevel ? TYPE_TOPLEVEL : TYPE_FRAME, appName); for (i=0; itkwin = new; - framePtr->display = Tk_Display(new); - framePtr->interp = interp; - framePtr->widgetCmd = Tcl_CreateObjCommand(interp, + if (type == TYPE_LABELFRAME) { + framePtr = (Frame *) ckalloc(sizeof(Labelframe)); + memset((void *) framePtr, 0, (sizeof(Labelframe))); + } else { + framePtr = (Frame *) ckalloc(sizeof(Frame)); + memset((void *) framePtr, 0, (sizeof(Frame))); + } + framePtr->tkwin = new; + framePtr->display = Tk_Display(new); + framePtr->interp = interp; + framePtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(new), FrameWidgetObjCmd, (ClientData) framePtr, FrameCmdDeletedProc); - framePtr->className = NULL; - framePtr->mask = (toplevel) ? TOPLEVEL : FRAME; - framePtr->screenName = NULL; - framePtr->visualName = NULL; - framePtr->colormapName = NULL; + framePtr->optionTable = optionTable; + framePtr->type = type; framePtr->colormap = colormap; - framePtr->border = NULL; - framePtr->borderWidth = 0; framePtr->relief = TK_RELIEF_FLAT; - framePtr->highlightWidth = 0; - framePtr->highlightBgColorPtr = NULL; - framePtr->highlightColorPtr = NULL; - framePtr->width = 0; - framePtr->height = 0; framePtr->cursor = None; - framePtr->takeFocus = NULL; - framePtr->isContainer = 0; - framePtr->useThis = NULL; - framePtr->flags = 0; - framePtr->menuName = NULL; + + if (framePtr->type == TYPE_LABELFRAME) { + Labelframe *labelframePtr = (Labelframe *) framePtr; + labelframePtr->labelAnchor = LABELANCHOR_NW; + labelframePtr->textGC = None; + } /* * Store backreference to frame widget in window structure. */ - TkSetClassProcs(new, NULL, (ClientData) framePtr); + Tk_SetClassProcs(new, &frameClass, (ClientData) framePtr); mask = ExposureMask | StructureNotifyMask | FocusChangeMask; - if (toplevel) { + if (type == TYPE_TOPLEVEL) { mask |= ActivateMask; } Tk_CreateEventHandler(new, mask, FrameEventProc, (ClientData) framePtr); - if (ConfigureFrame(interp, framePtr, objc-2, objv+2, 0) != TCL_OK) { + if ((Tk_InitOptions(interp, (char *) framePtr, optionTable, new) + != TCL_OK) || + (ConfigureFrame(interp, framePtr, objc-2, objv+2) != TCL_OK)) { goto error; } if ((framePtr->isContainer)) { if (framePtr->useThis == NULL) { TkpMakeContainer(framePtr->tkwin); } else { - Tcl_AppendResult(interp,"A window cannot have both the -use ", - "and the -container option set."); - return TCL_ERROR; + Tcl_AppendResult(interp, "A window cannot have both the -use ", + "and the -container option set.", (char *) NULL); + goto error; } } - if (toplevel) { + if (type == TYPE_TOPLEVEL) { Tcl_DoWhenIdle(MapFrame, (ClientData) framePtr); } Tcl_SetResult(interp, Tk_PathName(new), TCL_STATIC); @@ -508,7 +718,7 @@ FrameWidgetObjCmd(clientData, interp, objc, objv) int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ { - static char *frameOptions[] = { + static CONST char *frameOptions[] = { "cget", "configure", (char *) NULL }; enum options { @@ -518,6 +728,7 @@ FrameWidgetObjCmd(clientData, interp, objc, objv) int result = TCL_OK, index; size_t length; int c, i; + Tcl_Obj *objPtr; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); @@ -535,17 +746,28 @@ FrameWidgetObjCmd(clientData, interp, objc, objv) result = TCL_ERROR; goto done; } - result = Tk_ConfigureValue(interp, framePtr->tkwin, configSpecs, - (char *) framePtr, Tcl_GetString(objv[2]), framePtr->mask); + objPtr = Tk_GetOptionValue(interp, (char *) framePtr, + framePtr->optionTable, objv[2], framePtr->tkwin); + if (objPtr == NULL) { + result = TCL_ERROR; + goto done; + } else { + Tcl_SetObjResult(interp, objPtr); + } break; } case FRAME_CONFIGURE: { - if (objc == 2) { - result = Tk_ConfigureInfo(interp, framePtr->tkwin, configSpecs, - (char *) framePtr, (char *) NULL, framePtr->mask); - } else if (objc == 3) { - result = Tk_ConfigureInfo(interp, framePtr->tkwin, configSpecs, - (char *) framePtr, Tcl_GetString(objv[2]), framePtr->mask); + if (objc <= 3) { + objPtr = Tk_GetOptionInfo(interp, (char *) framePtr, + framePtr->optionTable, + (objc == 3) ? objv[2] : (Tcl_Obj *) NULL, + framePtr->tkwin); + if (objPtr == NULL) { + result = TCL_ERROR; + goto done; + } else { + Tcl_SetObjResult(interp, objPtr); + } } else { /* * Don't allow the options -class, -colormap, -container, @@ -560,17 +782,17 @@ FrameWidgetObjCmd(clientData, interp, objc, objv) c = arg[1]; if (((c == 'c') && (strncmp(arg, "-class", length) == 0) && (length >= 2)) - || ((c == 'c') && (framePtr->mask == TOPLEVEL) + || ((c == 'c') && (strncmp(arg, "-colormap", length) == 0) && (length >= 3)) || ((c == 'c') && (strncmp(arg, "-container", length) == 0) && (length >= 3)) - || ((c == 's') && (framePtr->mask == TOPLEVEL) + || ((c == 's') && (framePtr->type == TYPE_TOPLEVEL) && (strncmp(arg, "-screen", length) == 0)) - || ((c == 'u') && (framePtr->mask == TOPLEVEL) + || ((c == 'u') && (framePtr->type == TYPE_TOPLEVEL) && (strncmp(arg, "-use", length) == 0)) - || ((c == 'v') && (framePtr->mask == TOPLEVEL) + || ((c == 'v') && (strncmp(arg, "-visual", length) == 0))) { Tcl_AppendResult(interp, "can't modify ", arg, " option after widget is created", (char *) NULL); @@ -578,8 +800,7 @@ FrameWidgetObjCmd(clientData, interp, objc, objv) goto done; } } - result = ConfigureFrame(interp, framePtr, objc-2, objv+2, - TK_CONFIG_ARGV_ONLY); + result = ConfigureFrame(interp, framePtr, objc-2, objv+2); } break; } @@ -613,15 +834,61 @@ DestroyFrame(memPtr) char *memPtr; /* Info about frame widget. */ { register Frame *framePtr = (Frame *) memPtr; + register Labelframe *labelframePtr = (Labelframe *) memPtr; - Tk_FreeOptions(configSpecs, (char *) framePtr, framePtr->display, - framePtr->mask); + if (framePtr->type == TYPE_LABELFRAME) { + Tk_FreeTextLayout(labelframePtr->textLayout); + if (labelframePtr->textGC != None) { + Tk_FreeGC(framePtr->display, labelframePtr->textGC); + } + } if (framePtr->colormap != None) { Tk_FreeColormap(framePtr->display, framePtr->colormap); } ckfree((char *) framePtr); } +/* + *---------------------------------------------------------------------- + * + * DestroyFramePartly -- + * + * This procedure is invoked to clean up everything that needs + * tkwin to be defined when deleted. During the destruction + * process tkwin is always set to NULL and this procedure must + * be called before that happens. + * + * Results: + * None. + * + * Side effects: + * Some things associated with the frame are freed up. + * + *---------------------------------------------------------------------- + */ + +static void +DestroyFramePartly(framePtr) + Frame *framePtr; /* Info about frame widget. */ +{ + register Labelframe *labelframePtr = (Labelframe *) framePtr; + + if (framePtr->type == TYPE_LABELFRAME && labelframePtr->labelWin != NULL) { + Tk_DeleteEventHandler(labelframePtr->labelWin, StructureNotifyMask, + FrameStructureProc, (ClientData) framePtr); + Tk_ManageGeometry(labelframePtr->labelWin, (Tk_GeomMgr *) NULL, + (ClientData) NULL); + if (framePtr->tkwin != Tk_Parent(labelframePtr->labelWin)) { + Tk_UnmaintainGeometry(labelframePtr->labelWin, framePtr->tkwin); + } + Tk_UnmapWindow(labelframePtr->labelWin); + labelframePtr->labelWin = NULL; + } + + Tk_FreeConfigOptions((char *) framePtr, framePtr->optionTable, + framePtr->tkwin); +} + /* *---------------------------------------------------------------------- * @@ -644,16 +911,18 @@ DestroyFrame(memPtr) */ static int -ConfigureFrame(interp, framePtr, objc, objv, flags) +ConfigureFrame(interp, framePtr, objc, objv) Tcl_Interp *interp; /* Used for error reporting. */ register 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. */ - int flags; /* Flags to pass to Tk_ConfigureWidget. */ { + Tk_SavedOptions savedOptions; char *oldMenuName; - + Tk_Window oldWindow = NULL; + Labelframe *labelframePtr = (Labelframe *) framePtr; + /* * Need the old menubar name for the menu code to delete it. */ @@ -664,13 +933,25 @@ ConfigureFrame(interp, framePtr, objc, objv, flags) oldMenuName = ckalloc(strlen(framePtr->menuName) + 1); strcpy(oldMenuName, framePtr->menuName); } - - if (Tk_ConfigureWidget(interp, framePtr->tkwin, configSpecs, - objc, (char **) objv, (char *) framePtr, - flags | framePtr->mask | TK_CONFIG_OBJS) != TCL_OK) { + + if (framePtr->type == TYPE_LABELFRAME) { + oldWindow = labelframePtr->labelWin; + } + if (Tk_SetOptions(interp, (char *) framePtr, + framePtr->optionTable, objc, objv, + framePtr->tkwin, &savedOptions, (int *) NULL) != TCL_OK) { + if (oldMenuName != NULL) { + ckfree(oldMenuName); + } return TCL_ERROR; + } else { + Tk_FreeSavedOptions(&savedOptions); } + /* + * A few of the options require additional processing. + */ + if (((oldMenuName == NULL) && (framePtr->menuName != NULL)) || ((oldMenuName != NULL) && (framePtr->menuName == NULL)) || ((oldMenuName != NULL) && (framePtr->menuName != NULL) @@ -678,7 +959,11 @@ ConfigureFrame(interp, framePtr, objc, objv, flags) TkSetWindowMenuBar(interp, framePtr->tkwin, oldMenuName, framePtr->menuName); } - + + if (oldMenuName != NULL) { + ckfree(oldMenuName); + } + if (framePtr->border != NULL) { Tk_SetBackgroundFromBorder(framePtr->tkwin, framePtr->border); } else { @@ -688,24 +973,391 @@ ConfigureFrame(interp, framePtr, objc, objv, flags) if (framePtr->highlightWidth < 0) { framePtr->highlightWidth = 0; } - Tk_SetInternalBorder(framePtr->tkwin, - framePtr->borderWidth + framePtr->highlightWidth); - if ((framePtr->width > 0) || (framePtr->height > 0)) { - Tk_GeometryRequest(framePtr->tkwin, framePtr->width, - framePtr->height); + if (framePtr->padX < 0) { + framePtr->padX = 0; + } + if (framePtr->padY < 0) { + framePtr->padY = 0; } - if (oldMenuName != NULL) { - ckfree(oldMenuName); + /* + * If a -labelwidget is specified, check that it is valid and set + * up geometry management for it. + */ + + if (framePtr->type == TYPE_LABELFRAME) { + if (oldWindow != labelframePtr->labelWin) { + if (oldWindow != NULL) { + Tk_DeleteEventHandler(oldWindow, StructureNotifyMask, + FrameStructureProc, (ClientData) framePtr); + Tk_ManageGeometry(oldWindow, (Tk_GeomMgr *) NULL, + (ClientData) NULL); + Tk_UnmaintainGeometry(oldWindow, framePtr->tkwin); + Tk_UnmapWindow(oldWindow); + } + if (labelframePtr->labelWin != NULL) { + Tk_Window ancestor, parent, sibling = NULL; + + /* + * Make sure that the frame is either the parent of the + * window used as label or a descendant of that + * parent. Also, don't allow a top-level window to be + * managed inside the frame. + */ + + parent = Tk_Parent(labelframePtr->labelWin); + for (ancestor = framePtr->tkwin; ; + ancestor = Tk_Parent(ancestor)) { + if (ancestor == parent) { + break; + } + sibling = ancestor; + if (Tk_IsTopLevel(ancestor)) { + badWindow: + Tcl_AppendResult(interp, "can't use ", + Tk_PathName(labelframePtr->labelWin), + " as label in this frame", (char *) NULL); + labelframePtr->labelWin = NULL; + return TCL_ERROR; + } + } + if (Tk_IsTopLevel(labelframePtr->labelWin)) { + goto badWindow; + } + if (labelframePtr->labelWin == framePtr->tkwin) { + goto badWindow; + } + Tk_CreateEventHandler(labelframePtr->labelWin, + StructureNotifyMask, FrameStructureProc, + (ClientData) framePtr); + Tk_ManageGeometry(labelframePtr->labelWin, &frameGeomType, + (ClientData) framePtr); + + /* + * If the frame is not parent to the label, make + * sure the label is above its sibling in the stacking + * order. + */ + + if (sibling != NULL) { + Tk_RestackWindow(labelframePtr->labelWin, Above, sibling); + } + } + } + } + + FrameWorldChanged((ClientData) framePtr); + + return TCL_OK; +} + +/* + *--------------------------------------------------------------------------- + * + * FrameWorldChanged -- + * + * This procedure is called when the world has changed in some + * way and the widget needs to recompute all its graphics contexts + * and determine its new geometry. + * + * Results: + * None. + * + * Side effects: + * Frame will be relayed out and redisplayed. + * + *--------------------------------------------------------------------------- + */ + +static void +FrameWorldChanged(instanceData) + ClientData instanceData; /* Information about widget. */ +{ + Frame *framePtr = (Frame *) instanceData; + Labelframe *labelframePtr = (Labelframe *) framePtr; + Tk_Window tkwin = framePtr->tkwin; + XGCValues gcValues; + GC gc; + int anyTextLabel, anyWindowLabel; + int bWidthLeft, bWidthRight, bWidthTop, bWidthBottom; + char *labelText; + + anyTextLabel = (framePtr->type == TYPE_LABELFRAME) && + (labelframePtr->textPtr != NULL) && + (labelframePtr->labelWin == NULL); + anyWindowLabel = (framePtr->type == TYPE_LABELFRAME) && + (labelframePtr->labelWin != NULL); + + if (framePtr->type == TYPE_LABELFRAME) { + /* + * The textGC is needed even in the labelWin case, so it's + * always created for a labelframe. + */ + + gcValues.font = Tk_FontId(labelframePtr->tkfont); + gcValues.foreground = labelframePtr->textColorPtr->pixel; + gcValues.graphics_exposures = False; + gc = Tk_GetGC(tkwin, GCForeground | GCFont | GCGraphicsExposures, + &gcValues); + if (labelframePtr->textGC != None) { + Tk_FreeGC(framePtr->display, labelframePtr->textGC); + } + labelframePtr->textGC = gc; + + /* + * Calculate label size. + */ + + labelframePtr->labelReqWidth = labelframePtr->labelReqHeight = 0; + + if (anyTextLabel) { + labelText = Tcl_GetString(labelframePtr->textPtr); + Tk_FreeTextLayout(labelframePtr->textLayout); + labelframePtr->textLayout = Tk_ComputeTextLayout(labelframePtr->tkfont, + labelText, -1, 0, TK_JUSTIFY_CENTER, 0, + &labelframePtr->labelReqWidth, &labelframePtr->labelReqHeight); + labelframePtr->labelReqWidth += 2 * LABELSPACING; + labelframePtr->labelReqHeight += 2 * LABELSPACING; + } else if (anyWindowLabel) { + labelframePtr->labelReqWidth = Tk_ReqWidth(labelframePtr->labelWin); + labelframePtr->labelReqHeight = Tk_ReqHeight(labelframePtr->labelWin); + } + + /* + * Make sure label size is at least as big as the border. + * This simplifies later calculations and gives a better + * appearance with thick borders. + */ + + if ((labelframePtr->labelAnchor >= LABELANCHOR_N) && + (labelframePtr->labelAnchor <= LABELANCHOR_SW)) { + if (labelframePtr->labelReqHeight < framePtr->borderWidth) { + labelframePtr->labelReqHeight = framePtr->borderWidth; + } + } else { + if (labelframePtr->labelReqWidth < framePtr->borderWidth) { + labelframePtr->labelReqWidth = framePtr->borderWidth; + } + } + } + + /* + * Calculate individual border widths. + */ + + bWidthBottom = bWidthTop = bWidthRight = bWidthLeft = + framePtr->borderWidth + framePtr->highlightWidth; + + bWidthLeft += framePtr->padX; + bWidthRight += framePtr->padX; + bWidthTop += framePtr->padY; + bWidthBottom += framePtr->padY; + + if (anyTextLabel || anyWindowLabel) { + switch (labelframePtr->labelAnchor) { + case LABELANCHOR_E: + case LABELANCHOR_EN: + case LABELANCHOR_ES: + bWidthRight += labelframePtr->labelReqWidth - + framePtr->borderWidth; + break; + case LABELANCHOR_N: + case LABELANCHOR_NE: + case LABELANCHOR_NW: + bWidthTop += labelframePtr->labelReqHeight - framePtr->borderWidth; + break; + case LABELANCHOR_S: + case LABELANCHOR_SE: + case LABELANCHOR_SW: + bWidthBottom += labelframePtr->labelReqHeight - + framePtr->borderWidth; + break; + default: + bWidthLeft += labelframePtr->labelReqWidth - framePtr->borderWidth; + break; + } + } + + Tk_SetInternalBorderEx(tkwin, bWidthLeft, bWidthRight, bWidthTop, + bWidthBottom); + + ComputeFrameGeometry(framePtr); + + /* + * A labelframe should request size for its label. + */ + + if (framePtr->type == TYPE_LABELFRAME) { + int minwidth = labelframePtr->labelReqWidth; + int minheight = labelframePtr->labelReqHeight; + int padding = framePtr->highlightWidth; + if (framePtr->borderWidth > 0) { + padding += framePtr->borderWidth + LABELMARGIN; + } + padding *= 2; + if ((labelframePtr->labelAnchor >= LABELANCHOR_N) && + (labelframePtr->labelAnchor <= LABELANCHOR_SW)) { + minwidth += padding; + minheight += framePtr->borderWidth + framePtr->highlightWidth; + } else { + minheight += padding; + minwidth += framePtr->borderWidth + framePtr->highlightWidth; + } + Tk_SetMinimumRequestSize(tkwin, minwidth, minheight); + } + + if ((framePtr->width > 0) || (framePtr->height > 0)) { + Tk_GeometryRequest(tkwin, framePtr->width, framePtr->height); } - if (Tk_IsMapped(framePtr->tkwin)) { + if (Tk_IsMapped(tkwin)) { if (!(framePtr->flags & REDRAW_PENDING)) { Tcl_DoWhenIdle(DisplayFrame, (ClientData) framePtr); } framePtr->flags |= REDRAW_PENDING; } - return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * ComputeFrameGeometry -- + * + * This procedure is called to compute various geometrical + * information for a frame, such as where various things get + * displayed. It's called when the window is reconfigured. + * + * Results: + * None. + * + * Side effects: + * Display-related numbers get changed in *framePtr. + * + *---------------------------------------------------------------------- + */ + +static void +ComputeFrameGeometry(framePtr) + register Frame *framePtr; /* Information about widget. */ +{ + int otherWidth, otherHeight, otherWidthT, otherHeightT, padding; + int maxWidth, maxHeight; + Tk_Window tkwin; + Labelframe *labelframePtr = (Labelframe *) framePtr; + + /* + * We have nothing to do here unless there is a label. + */ + + if (framePtr->type != TYPE_LABELFRAME) return; + if ((labelframePtr->textPtr == NULL) && + (labelframePtr->labelWin == NULL)) return; + + tkwin = framePtr->tkwin; + + /* + * Calculate the available size for the label + */ + + labelframePtr->labelBox.width = labelframePtr->labelReqWidth; + labelframePtr->labelBox.height = labelframePtr->labelReqHeight; + + padding = framePtr->highlightWidth; + if (framePtr->borderWidth > 0) { + padding += framePtr->borderWidth + LABELMARGIN; + } + padding *= 2; + + maxHeight = Tk_Height(tkwin); + maxWidth = Tk_Width(tkwin); + + if ((labelframePtr->labelAnchor >= LABELANCHOR_N) && + (labelframePtr->labelAnchor <= LABELANCHOR_SW)) { + maxWidth -= padding; + if (maxWidth < 1) maxWidth = 1; + } else { + maxHeight -= padding; + if (maxHeight < 1) maxHeight = 1; + } + if (labelframePtr->labelBox.width > maxWidth) { + labelframePtr->labelBox.width = maxWidth; + } + if (labelframePtr->labelBox.height > maxHeight) { + labelframePtr->labelBox.height = maxHeight; + } + + /* + * Calculate label and text position. + * The text's position is based on the requested size (= the text's + * real size) to get proper alignment if the text does not fit. + */ + + otherWidth = Tk_Width(tkwin) - labelframePtr->labelBox.width; + otherHeight = Tk_Height(tkwin) - labelframePtr->labelBox.height; + otherWidthT = Tk_Width(tkwin) - labelframePtr->labelReqWidth; + otherHeightT = Tk_Height(tkwin) - labelframePtr->labelReqHeight; + padding = framePtr->highlightWidth; + + switch (labelframePtr->labelAnchor) { + case LABELANCHOR_E: + case LABELANCHOR_EN: + case LABELANCHOR_ES: + labelframePtr->labelTextX = otherWidthT - padding; + labelframePtr->labelBox.x = otherWidth - padding; + break; + case LABELANCHOR_N: + case LABELANCHOR_NE: + case LABELANCHOR_NW: + labelframePtr->labelTextY = padding; + labelframePtr->labelBox.y = padding; + break; + case LABELANCHOR_S: + case LABELANCHOR_SE: + case LABELANCHOR_SW: + labelframePtr->labelTextY = otherHeightT - padding; + labelframePtr->labelBox.y = otherHeight - padding; + break; + default: + labelframePtr->labelTextX = padding; + labelframePtr->labelBox.x = padding; + break; + } + + if (framePtr->borderWidth > 0) { + padding += framePtr->borderWidth + LABELMARGIN; + } + + switch (labelframePtr->labelAnchor) { + case LABELANCHOR_NW: + case LABELANCHOR_SW: + labelframePtr->labelTextX = padding; + labelframePtr->labelBox.x = padding; + break; + case LABELANCHOR_N: + case LABELANCHOR_S: + labelframePtr->labelTextX = otherWidthT / 2; + labelframePtr->labelBox.x = otherWidth / 2; + break; + case LABELANCHOR_NE: + case LABELANCHOR_SE: + labelframePtr->labelTextX = otherWidthT - padding; + labelframePtr->labelBox.x = otherWidth - padding; + break; + case LABELANCHOR_EN: + case LABELANCHOR_WN: + labelframePtr->labelTextY = padding; + labelframePtr->labelBox.y = padding; + break; + case LABELANCHOR_E: + case LABELANCHOR_W: + labelframePtr->labelTextY = otherHeightT / 2; + labelframePtr->labelBox.y = otherHeight / 2; + break; + default: + labelframePtr->labelTextY = otherHeightT - padding; + labelframePtr->labelBox.y = otherHeight - padding; + break; + } } /* @@ -731,8 +1383,9 @@ DisplayFrame(clientData) { register Frame *framePtr = (Frame *) clientData; register Tk_Window tkwin = framePtr->tkwin; - void (* drawFunction) _ANSI_ARGS_((Tk_Window, Drawable, Tk_3DBorder, - int, int, int, int, int, int)) = Tk_Fill3DRectangle; + int bdX1, bdY1, bdX2, bdY2, hlWidth; + Pixmap pixmap; + TkRegion clipRegion = NULL; framePtr->flags &= ~REDRAW_PENDING; if ((framePtr->tkwin == NULL) || !Tk_IsMapped(tkwin) @@ -740,15 +1393,13 @@ DisplayFrame(clientData) return; } - if (framePtr->border != NULL) { - drawFunction(tkwin, Tk_WindowId(tkwin), - framePtr->border, framePtr->highlightWidth, - framePtr->highlightWidth, - Tk_Width(tkwin) - 2*framePtr->highlightWidth, - Tk_Height(tkwin) - 2*framePtr->highlightWidth, - framePtr->borderWidth, framePtr->relief); - } - if (framePtr->highlightWidth != 0) { + /* + * Highlight shall always be drawn if it exists, so do that first. + */ + + hlWidth = framePtr->highlightWidth; + + if (hlWidth != 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(framePtr->highlightBgColorPtr, @@ -756,13 +1407,179 @@ DisplayFrame(clientData) if (framePtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(framePtr->highlightColorPtr, Tk_WindowId(tkwin)); - TkpDrawHighlightBorder(tkwin, fgGC, bgGC, framePtr->highlightWidth, + TkpDrawHighlightBorder(tkwin, fgGC, bgGC, hlWidth, Tk_WindowId(tkwin)); } else { - TkpDrawHighlightBorder(tkwin, bgGC, bgGC, framePtr->highlightWidth, + TkpDrawHighlightBorder(tkwin, bgGC, bgGC, hlWidth, Tk_WindowId(tkwin)); } } + + /* + * If -background is set to "", no interior is drawn. + */ + + if (framePtr->border == NULL) return; + + if (framePtr->type != TYPE_LABELFRAME) { + /* + * There is no label so there is just a simple rectangle to draw. + */ + + noLabel: + Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), + framePtr->border, hlWidth, hlWidth, + Tk_Width(tkwin) - 2 * hlWidth, + Tk_Height(tkwin) - 2 * hlWidth, + framePtr->borderWidth, framePtr->relief); + } else { + Labelframe *labelframePtr = (Labelframe *) framePtr; + + if ((labelframePtr->textPtr == NULL) && + (labelframePtr->labelWin == NULL)) { + goto noLabel; + } + + /* + * In order to avoid screen flashes, this procedure 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)); + + /* + * Clear the pixmap. + */ + + Tk_Fill3DRectangle(tkwin, pixmap, framePtr->border, 0, 0, + Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); + + /* + * Calculate how the label affects the border's position. + */ + + bdX1 = bdY1 = hlWidth; + bdX2 = Tk_Width(tkwin) - hlWidth; + bdY2 = Tk_Height(tkwin) - hlWidth; + + switch (labelframePtr->labelAnchor) { + case LABELANCHOR_E: + case LABELANCHOR_EN: + case LABELANCHOR_ES: + bdX2 -= (labelframePtr->labelBox.width - framePtr->borderWidth) + / 2; + break; + case LABELANCHOR_N: + case LABELANCHOR_NE: + case LABELANCHOR_NW: + /* + * Since the glyphs of the text tend to be in the lower part + * we favor a lower border position by rounding up. + */ + + bdY1 += (labelframePtr->labelBox.height - framePtr->borderWidth +1) + / 2; + break; + case LABELANCHOR_S: + case LABELANCHOR_SE: + case LABELANCHOR_SW: + bdY2 -= (labelframePtr->labelBox.height - framePtr->borderWidth) + / 2; + break; + default: + bdX1 += (labelframePtr->labelBox.width - framePtr->borderWidth) + / 2; + break; + } + + /* + * Draw border + */ + + Tk_Draw3DRectangle(tkwin, pixmap, framePtr->border, bdX1, bdY1, + bdX2 - bdX1, bdY2 - bdY1, framePtr->borderWidth, + framePtr->relief); + + if (labelframePtr->labelWin == NULL) { + /* + * Clear behind the label + */ + + Tk_Fill3DRectangle(tkwin, pixmap, + framePtr->border, labelframePtr->labelBox.x, + labelframePtr->labelBox.y, labelframePtr->labelBox.width, + labelframePtr->labelBox.height, 0, TK_RELIEF_FLAT); + + /* + * Draw label. + * If there is not room for the entire label, use clipping to + * get a nice appearance. + */ + + if ((labelframePtr->labelBox.width < labelframePtr->labelReqWidth) + || (labelframePtr->labelBox.height < + labelframePtr->labelReqHeight)) { + clipRegion = TkCreateRegion(); + TkUnionRectWithRegion(&labelframePtr->labelBox, clipRegion, + clipRegion); + TkSetRegion(framePtr->display, labelframePtr->textGC, + clipRegion); + } + + Tk_DrawTextLayout(framePtr->display, pixmap, + labelframePtr->textGC, labelframePtr->textLayout, + labelframePtr->labelTextX + LABELSPACING, + labelframePtr->labelTextY + LABELSPACING, 0, -1); + + if (clipRegion != NULL) { + XSetClipMask(framePtr->display, labelframePtr->textGC, None); + TkDestroyRegion(clipRegion); + } + } else { + /* + * Reposition and map the window (but in different ways depending + * on whether the frame is the window's parent). + */ + + if (framePtr->tkwin == Tk_Parent(labelframePtr->labelWin)) { + if ((labelframePtr->labelBox.x != Tk_X(labelframePtr->labelWin)) + || (labelframePtr->labelBox.y != + Tk_Y(labelframePtr->labelWin)) + || (labelframePtr->labelBox.width != + Tk_Width(labelframePtr->labelWin)) + || (labelframePtr->labelBox.height != + Tk_Height(labelframePtr->labelWin))) { + Tk_MoveResizeWindow(labelframePtr->labelWin, + labelframePtr->labelBox.x, labelframePtr->labelBox.y, + labelframePtr->labelBox.width, + labelframePtr->labelBox.height); + } + Tk_MapWindow(labelframePtr->labelWin); + } else { + Tk_MaintainGeometry(labelframePtr->labelWin, framePtr->tkwin, + labelframePtr->labelBox.x, labelframePtr->labelBox.y, + labelframePtr->labelBox.width, + labelframePtr->labelBox.height); + } + } + + + /* + * 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); + } + } /* @@ -791,8 +1608,10 @@ FrameEventProc(clientData, eventPtr) { register Frame *framePtr = (Frame *) clientData; - if (((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) - || (eventPtr->type == ConfigureNotify)) { + if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) { + goto redraw; + } else if (eventPtr->type == ConfigureNotify) { + ComputeFrameGeometry(framePtr); goto redraw; } else if (eventPtr->type == DestroyNotify) { if (framePtr->menuName != NULL) { @@ -812,7 +1631,14 @@ FrameEventProc(clientData, eventPtr) * could be gone by then. To do so, delete the event handler * explicitly (normally it's done implicitly by Tk_DestroyWindow). */ - + + /* + * Since the tkwin pointer will be gone when we reach + * DestroyFrame, we must free all options now. + */ + + DestroyFramePartly(framePtr); + Tk_DeleteEventHandler(framePtr->tkwin, ExposureMask|StructureNotifyMask|FocusChangeMask, FrameEventProc, (ClientData) framePtr); @@ -891,6 +1717,13 @@ FrameCmdDeletedProc(clientData) */ if (tkwin != NULL) { + /* + * Some options need tkwin to be freed, so we free them here, + * before setting tkwin to NULL. + */ + + DestroyFramePartly(framePtr); + framePtr->tkwin = NULL; Tk_DestroyWindow(tkwin); } @@ -982,4 +1815,115 @@ TkInstallFrameMenu(tkwin) framePtr->menuName); } } + +/* + *-------------------------------------------------------------- + * + * FrameStructureProc -- + * + * This procedure is invoked whenever StructureNotify events + * occur for a window that's managed as label for the frame. + * This procudure's only purpose is to clean up when windows + * are deleted. + * + * Results: + * None. + * + * Side effects: + * The window is disassociated from the frame when it is + * deleted. + * + *-------------------------------------------------------------- + */ + +static void +FrameStructureProc(clientData, eventPtr) + ClientData clientData; /* Pointer to record describing frame. */ + XEvent *eventPtr; /* Describes what just happened. */ +{ + Labelframe *labelframePtr = (Labelframe *) clientData; + + if (eventPtr->type == DestroyNotify) { + /* + * This should only happen in a labelframe but it doesn't + * hurt to be careful. + */ + + if (labelframePtr->frame.type == TYPE_LABELFRAME) { + labelframePtr->labelWin = NULL; + FrameWorldChanged((ClientData) labelframePtr); + } + } +} + +/* + *-------------------------------------------------------------- + * + * FrameRequestProc -- + * + * This procedure is invoked whenever a window that's associated + * with a frame changes its requested dimensions. + * + * Results: + * None. + * + * Side effects: + * The size and location on the screen of the window may change. + * depending on the options specified for the frame. + * + *-------------------------------------------------------------- + */ +static void +FrameRequestProc(clientData, tkwin) + ClientData clientData; /* Pointer to record for frame. */ + Tk_Window tkwin; /* Window that changed its desired + * size. */ +{ + Frame *framePtr = (Frame *) clientData; + + FrameWorldChanged((ClientData) framePtr); +} + +/* + *-------------------------------------------------------------- + * + * FrameLostSlaveProc -- + * + * This procedure is invoked by Tk whenever some other geometry + * claims control over a slave that used to be managed by us. + * + * Results: + * None. + * + * Side effects: + * Forgets all frame-related information about the slave. + * + *-------------------------------------------------------------- + */ + +static void +FrameLostSlaveProc(clientData, tkwin) + ClientData clientData; /* Frame structure for slave window that + * was stolen away. */ + Tk_Window tkwin; /* Tk's handle for the slave window. */ +{ + Frame *framePtr = (Frame *) clientData; + Labelframe *labelframePtr = (Labelframe *) clientData; + + /* + * This should only happen in a labelframe but it doesn't + * hurt to be careful. + */ + + if (labelframePtr->frame.type == TYPE_LABELFRAME) { + Tk_DeleteEventHandler(labelframePtr->labelWin, StructureNotifyMask, + FrameStructureProc, (ClientData) labelframePtr); + if (framePtr->tkwin != Tk_Parent(labelframePtr->labelWin)) { + Tk_UnmaintainGeometry(labelframePtr->labelWin, framePtr->tkwin); + } + Tk_UnmapWindow(labelframePtr->labelWin); + labelframePtr->labelWin = NULL; + } + FrameWorldChanged((ClientData) framePtr); +} diff --git a/tk/generic/tkGC.c b/tk/generic/tkGC.c index 8ddcd391e4c..8096d39e7d1 100644 --- a/tk/generic/tkGC.c +++ b/tk/generic/tkGC.c @@ -84,7 +84,7 @@ Tk_GetGC(tkwin, valueMask, valuePtr) Drawable d, freeDrawable; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; - if (!dispPtr->gcInit) { + if (dispPtr->gcInit <= 0) { GCInit(dispPtr); } @@ -300,6 +300,14 @@ Tk_FreeGC(display, gc) if (!dispPtr->gcInit) { panic("Tk_FreeGC called before Tk_GetGC"); } + if (dispPtr->gcInit < 0) { + /* + * The GCCleanup has been called, and remaining GCs have been + * freed. This may still get called by other things shutting + * down, but the GCs should no longer be in use. + */ + return; + } idHashPtr = Tcl_FindHashEntry(&dispPtr->gcIdTable, (char *) gc); if (idHashPtr == NULL) { @@ -316,6 +324,51 @@ Tk_FreeGC(display, gc) } } +/* + *---------------------------------------------------------------------- + * + * TkGCCleanup -- + * + * Frees the structures used for GC management. + * We need to have it called near the end, when other cleanup that + * calls Tk_FreeGC is all done. + * + * Results: + * None. + * + * Side effects: + * GC resources are freed. + * + *---------------------------------------------------------------------- + */ + +void +TkGCCleanup(dispPtr) + TkDisplay *dispPtr; /* display to clean up resources in */ +{ + Tcl_HashEntry *entryPtr; + Tcl_HashSearch search; + TkGC *gcPtr; + + for (entryPtr = Tcl_FirstHashEntry(&dispPtr->gcIdTable, &search); + entryPtr != NULL; + entryPtr = Tcl_NextHashEntry(&search)) { + gcPtr = (TkGC *) Tcl_GetHashValue(entryPtr); + /* + * This call is not needed, as it is only used on Unix to restore + * the Id to the stack pool, and we don't want to use them anymore. + * Tk_FreeXId(gcPtr->display, (XID) XGContextFromGC(gcPtr->gc)); + */ + XFreeGC(gcPtr->display, gcPtr->gc); + Tcl_DeleteHashEntry(gcPtr->valueHashPtr); + Tcl_DeleteHashEntry(entryPtr); + ckfree((char *) gcPtr); + } + Tcl_DeleteHashTable(&dispPtr->gcValueTable); + Tcl_DeleteHashTable(&dispPtr->gcIdTable); + dispPtr->gcInit = -1; +} + /* *---------------------------------------------------------------------- * @@ -336,6 +389,9 @@ static void GCInit(dispPtr) TkDisplay *dispPtr; { + if (dispPtr->gcInit < 0) { + panic("called GCInit after GCCleanup"); + } dispPtr->gcInit = 1; Tcl_InitHashTable(&dispPtr->gcValueTable, sizeof(ValueKey)/sizeof(int)); Tcl_InitHashTable(&dispPtr->gcIdTable, TCL_ONE_WORD_KEYS); diff --git a/tk/generic/tkGeometry.c b/tk/generic/tkGeometry.c index fcc33e33d55..fed10c9a6fe 100644 --- a/tk/generic/tkGeometry.c +++ b/tk/generic/tkGeometry.c @@ -162,6 +162,79 @@ Tk_GeometryRequest(tkwin, reqWidth, reqHeight) } } +/* + *---------------------------------------------------------------------- + * + * Tk_SetInternalBorderEx -- + * + * Notify relevant geometry managers that a window has an internal + * border of a given width and that child windows should not be + * placed on that border. + * + * Results: + * None. + * + * Side effects: + * The border widths are recorded for the window, and all geometry + * managers of all children are notified so that can re-layout, if + * necessary. + * + *---------------------------------------------------------------------- + */ + +void +Tk_SetInternalBorderEx(tkwin, left, right, top, bottom) + Tk_Window tkwin; /* Window that will have internal border. */ + int left, right; /* Width of internal border, in pixels. */ + int top, bottom; +{ + register TkWindow *winPtr = (TkWindow *) tkwin; + register int changed = 0; + + if (left < 0) { + left = 0; + } + if (left != winPtr->internalBorderLeft) { + winPtr->internalBorderLeft = left; + changed = 1; + } + + if (right < 0) { + right = 0; + } + if (right != winPtr->internalBorderRight) { + winPtr->internalBorderRight = right; + changed = 1; + } + + if (top < 0) { + top = 0; + } + if (top != winPtr->internalBorderTop) { + winPtr->internalBorderTop = top; + changed = 1; + } + + if (bottom < 0) { + bottom = 0; + } + if (bottom != winPtr->internalBorderBottom) { + winPtr->internalBorderBottom = bottom; + changed = 1; + } + + /* + * 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. + */ + + if (changed) { + Tk_ResizeWindow(tkwin, Tk_Width(tkwin), Tk_Height(tkwin)); + } +} /* *---------------------------------------------------------------------- * @@ -186,20 +259,46 @@ void Tk_SetInternalBorder(tkwin, width) Tk_Window tkwin; /* Window that will have internal border. */ int width; /* Width of internal border, in pixels. */ +{ + Tk_SetInternalBorderEx(tkwin, width, width, width, width); +} + +/* + *---------------------------------------------------------------------- + * + * Tk_SetMinimumRequestSize -- + * + * Notify relevant geometry managers that a window has a minimum + * request size. + * + * Results: + * None. + * + * Side effects: + * The minimum request size is recorded for the window, and + * a new size is requested for the window, if necessary. + * + *---------------------------------------------------------------------- + */ + +void +Tk_SetMinimumRequestSize(tkwin, minWidth, minHeight) + Tk_Window tkwin; /* Window that will have internal border. */ + int minWidth, minHeight; /* Minimum requested size, in pixels. */ { register TkWindow *winPtr = (TkWindow *) tkwin; - if (width == winPtr->internalBorderWidth) { + if ((winPtr->minReqWidth == minWidth) && + (winPtr->minReqHeight == minHeight)) { return; } - if (width < 0) { - width = 0; - } - winPtr->internalBorderWidth = width; + + winPtr->minReqWidth = minWidth; + winPtr->minReqHeight = minHeight; /* - * All the slaves for which this is the master window must now be - * repositioned to take account of the new internal border width. + * The changed min size may cause geometry managers to get a + * different result, so make them recompute. * 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. @@ -250,6 +349,26 @@ Tk_MaintainGeometry(slave, master, x, y, width, height) Tk_Window ancestor, parent; TkDisplay *dispPtr = ((TkWindow *) master)->dispPtr; + if (master == Tk_Parent(slave)) { + /* + * If the slave is a direct descendant of the master, don't bother + * setting up the extra infrastructure for management, just make a + * call to Tk_MoveResizeWindow; the parent/child relationship will + * take care of the rest. + */ + Tk_MoveResizeWindow(slave, x, y, width, height); + + /* + * Map the slave if the master is already mapped; otherwise, wait + * until the master is mapped later (in which case mapping the slave + * is taken care of elsewhere). + */ + if (Tk_IsMapped(master)) { + Tk_MapWindow(slave); + } + return; + } + if (!dispPtr->geomInit) { dispPtr->geomInit = 1; Tcl_InitHashTable(&dispPtr->maintainHashTable, TCL_ONE_WORD_KEYS); @@ -374,6 +493,15 @@ Tk_UnmaintainGeometry(slave, master) Tk_Window ancestor; TkDisplay *dispPtr = ((TkWindow *) slave)->dispPtr; + if (master == Tk_Parent(slave)) { + /* + * If the slave is a direct descendant of the master, + * Tk_MaintainGeometry will not have set up any of the extra + * infrastructure. Don't even bother to look for it, just return. + */ + return; + } + if (!dispPtr->geomInit) { dispPtr->geomInit = 1; Tcl_InitHashTable(&dispPtr->maintainHashTable, TCL_ONE_WORD_KEYS); @@ -570,4 +698,3 @@ MaintainCheckProc(clientData) } } } - diff --git a/tk/generic/tkGet.c b/tk/generic/tkGet.c index f9df1acb1a2..f102fac9b74 100644 --- a/tk/generic/tkGet.c +++ b/tk/generic/tkGet.c @@ -32,14 +32,19 @@ typedef struct ThreadSpecificData { } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; +static void FreeUidThreadExitProc _ANSI_ARGS_((ClientData clientData)); + /* * The following tables defines the string values for reliefs, which are * used by Tk_GetAnchorFromObj and Tk_GetJustifyFromObj. */ -static char *anchorStrings[] = {"n", "ne", "e", "se", "s", "sw", "w", "nw", - "center", (char *) NULL}; -static char *justifyStrings[] = {"left", "right", "center", (char *) NULL}; +static CONST char *anchorStrings[] = { + "n", "ne", "e", "se", "s", "sw", "w", "nw", "center", (char *) NULL +}; +static CONST char *justifyStrings[] = { + "left", "right", "center", (char *) NULL +}; /* @@ -102,7 +107,7 @@ Tk_GetAnchorFromObj(interp, objPtr, anchorPtr) int Tk_GetAnchor(interp, string, anchorPtr) Tcl_Interp *interp; /* Use this for error reporting. */ - char *string; /* String describing a direction. */ + CONST char *string; /* String describing a direction. */ Tk_Anchor *anchorPtr; /* Where to store Tk_Anchor corresponding * to string. */ { @@ -176,7 +181,7 @@ Tk_GetAnchor(interp, string, anchorPtr) *-------------------------------------------------------------- */ -char * +CONST char * Tk_NameOfAnchor(anchor) Tk_Anchor anchor; /* Anchor for which identifying string * is desired. */ @@ -218,7 +223,7 @@ Tk_NameOfAnchor(anchor) int Tk_GetJoinStyle(interp, string, joinPtr) Tcl_Interp *interp; /* Use this for error reporting. */ - char *string; /* String describing a justification style. */ + CONST char *string; /* String describing a justification style. */ int *joinPtr; /* Where to store join style corresponding * to string. */ { @@ -264,7 +269,7 @@ Tk_GetJoinStyle(interp, string, joinPtr) *-------------------------------------------------------------- */ -char * +CONST char * Tk_NameOfJoinStyle(join) int join; /* Join style for which identifying string * is desired. */ @@ -300,7 +305,7 @@ Tk_NameOfJoinStyle(join) int Tk_GetCapStyle(interp, string, capPtr) Tcl_Interp *interp; /* Use this for error reporting. */ - char *string; /* String describing a justification style. */ + CONST char *string; /* String describing a justification style. */ int *capPtr; /* Where to store cap style corresponding * to string. */ { @@ -346,7 +351,7 @@ Tk_GetCapStyle(interp, string, capPtr) *-------------------------------------------------------------- */ -char * +CONST char * Tk_NameOfCapStyle(cap) int cap; /* Cap style for which identifying string * is desired. */ @@ -419,7 +424,7 @@ Tk_GetJustifyFromObj(interp, objPtr, justifyPtr) int Tk_GetJustify(interp, string, justifyPtr) Tcl_Interp *interp; /* Use this for error reporting. */ - char *string; /* String describing a justification style. */ + CONST char *string; /* String describing a justification style. */ Tk_Justify *justifyPtr; /* Where to store Tk_Justify corresponding * to string. */ { @@ -465,7 +470,7 @@ Tk_GetJustify(interp, string, justifyPtr) *-------------------------------------------------------------- */ -char * +CONST char * Tk_NameOfJustify(justify) Tk_Justify justify; /* Justification style for which * identifying string is desired. */ @@ -478,6 +483,32 @@ Tk_NameOfJustify(justify) return "unknown justification style"; } +/* + *---------------------------------------------------------------------- + * + * FreeUidThreadExitProc -- + * + * Cleans up memory used for Tk_Uids in the thread. + * + * Results: + * None. + * + * Side effects: + * All information in the identifier table is deleted. + * + *---------------------------------------------------------------------- + */ + +static void +FreeUidThreadExitProc(clientData) + ClientData clientData; /* Not used. */ +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_DeleteHashTable(&tsdPtr->uidTable); + tsdPtr->initialized = 0; +} + /* *---------------------------------------------------------------------- * @@ -512,6 +543,7 @@ Tk_GetUid(string) if (!tsdPtr->initialized) { Tcl_InitHashTable(tablePtr, TCL_STRING_KEYS); + Tcl_CreateThreadExitHandler(FreeUidThreadExitProc, NULL); tsdPtr->initialized = 1; } return (Tk_Uid) Tcl_GetHashKey(tablePtr, @@ -545,7 +577,7 @@ Tk_GetScreenMM(interp, tkwin, string, doublePtr) Tk_Window tkwin; /* Window whose screen determines conversion * from centimeters and other absolute * units. */ - char *string; /* String describing a screen distance. */ + CONST char *string; /* String describing a screen distance. */ double *doublePtr; /* Place to store converted result. */ { char *end; @@ -621,7 +653,7 @@ Tk_GetPixels(interp, tkwin, string, intPtr) Tk_Window tkwin; /* Window whose screen determines conversion * from centimeters and other absolute * units. */ - char *string; /* String describing a number of pixels. */ + CONST char *string; /* String describing a number of pixels. */ int *intPtr; /* Place to store converted result. */ { double d; @@ -717,4 +749,3 @@ TkGetDoublePixels(interp, tkwin, string, doublePtr) } - diff --git a/tk/generic/tkGrab.c b/tk/generic/tkGrab.c index 1ff6b8e1bcf..b5493a997cd 100644 --- a/tk/generic/tkGrab.c +++ b/tk/generic/tkGrab.c @@ -15,7 +15,7 @@ #include "tkPort.h" #include "tkInt.h" -#if !defined(__WIN32__) && !defined(MAC_TCL) +#if !(defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) #include "tkUnixInt.h" #endif @@ -173,7 +173,7 @@ static void ReleaseButtonGrab _ANSI_ARGS_((TkDisplay *dispPtr)); /* *---------------------------------------------------------------------- * - * Tk_GrabCmd -- + * Tk_GrabObjCmd -- * * This procedure is invoked to process the "grab" Tcl command. * See the user documentation for details on what it does. @@ -189,137 +189,192 @@ static void ReleaseButtonGrab _ANSI_ARGS_((TkDisplay *dispPtr)); /* ARGSUSED */ int -Tk_GrabCmd(clientData, interp, argc, argv) +Tk_GrabObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Main window associated with * interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { - int globalGrab, c; + int globalGrab; Tk_Window tkwin; TkDisplay *dispPtr; - size_t length; - - if (argc < 2) { - badArgs: + char *arg; + int index; + int len; + static CONST char *optionStrings[] = { "current", "release", + "set", "status", (char *) NULL }; + + static CONST char *flagStrings[] = { "-global", (char *) NULL }; + + enum options { GRABCMD_CURRENT, GRABCMD_RELEASE, + GRABCMD_SET, GRABCMD_STATUS }; + + if (objc < 2) { + /* + * Can't use Tcl_WrongNumArgs here because we want the message to + * read: + * wrong # args: should be "cmd ?-global window" or "cmd option + * ?arg arg ...?" + * We can fake it with Tcl_WrongNumArgs if we assume the command name + * is "grab", but if it has been aliased, the message will be + * incorrect. + */ + Tcl_ResetResult(interp); Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " ?-global? window\" or \"", argv[0], - " option ?arg arg ...?\"", (char *) NULL); + Tcl_GetString(objv[0]), " ?-global? window\" or \"", + Tcl_GetString(objv[0]), " option ?arg arg ...?\"", + (char *) NULL); return TCL_ERROR; } - c = argv[1][0]; - length = strlen(argv[1]); - if (c == '.') { - if (argc != 2) { - goto badArgs; + + /* + * First check for a window name or "-global" as the first argument. + */ + + arg = Tcl_GetStringFromObj(objv[1], &len); + if (arg[0] == '.') { + /* [grab window] */ + if (objc != 2) { + Tcl_WrongNumArgs(interp, 1, objv, "?-global? window"); + return TCL_ERROR; } - tkwin = Tk_NameToWindow(interp, argv[1], (Tk_Window) clientData); + tkwin = Tk_NameToWindow(interp, arg, (Tk_Window) clientData); if (tkwin == NULL) { return TCL_ERROR; } return Tk_Grab(interp, tkwin, 0); - } else if ((c == '-') && (strncmp(argv[1], "-global", length) == 0) - && (length >= 2)) { - if (argc != 3) { - goto badArgs; + } else if (arg[0] == '-' && len > 1) { + if (Tcl_GetIndexFromObj(interp, objv[1], flagStrings, "option", 0, + &index) != TCL_OK) { + return TCL_ERROR; } - tkwin = Tk_NameToWindow(interp, argv[2], (Tk_Window) clientData); - if (tkwin == NULL) { + + /* [grab -global window] */ + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "?-global? window"); return TCL_ERROR; } - return Tk_Grab(interp, tkwin, 1); - } else if ((c == 'c') && (strncmp(argv[1], "current", length) == 0)) { - if (argc > 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " current ?window?\"", (char *) NULL); + tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), + (Tk_Window) clientData); + if (tkwin == NULL) { return TCL_ERROR; } - if (argc == 3) { - tkwin = Tk_NameToWindow(interp, argv[2], (Tk_Window) clientData); - if (tkwin == NULL) { + return Tk_Grab(interp, tkwin, 1); + } + + /* + * First argument is not a window name and not "-global", find out + * which option it is. + */ + + if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, + &index) != TCL_OK) { + return TCL_ERROR; + } + + switch ((enum options) index) { + case GRABCMD_CURRENT: { + /* [grab current ?window?] */ + if (objc > 3) { + Tcl_WrongNumArgs(interp, 1, objv, "current ?window?"); return TCL_ERROR; } - dispPtr = ((TkWindow *) tkwin)->dispPtr; - if (dispPtr->eventualGrabWinPtr != NULL) { - Tcl_SetResult(interp, dispPtr->eventualGrabWinPtr->pathName, - TCL_STATIC); - } - } else { - for (dispPtr = TkGetDisplayList(); dispPtr != NULL; - dispPtr = dispPtr->nextPtr) { + if (objc == 3) { + tkwin = Tk_NameToWindow(interp, + Tcl_GetString(objv[2]), (Tk_Window) clientData); + if (tkwin == NULL) { + return TCL_ERROR; + } + dispPtr = ((TkWindow *) tkwin)->dispPtr; if (dispPtr->eventualGrabWinPtr != NULL) { - Tcl_AppendElement(interp, - dispPtr->eventualGrabWinPtr->pathName); + Tcl_SetResult(interp, + dispPtr->eventualGrabWinPtr->pathName, TCL_STATIC); + } + } else { + for (dispPtr = TkGetDisplayList(); dispPtr != NULL; + dispPtr = dispPtr->nextPtr) { + if (dispPtr->eventualGrabWinPtr != NULL) { + Tcl_AppendElement(interp, + dispPtr->eventualGrabWinPtr->pathName); + } } } + return TCL_OK; } - return TCL_OK; - } else if ((c == 'r') && (strncmp(argv[1], "release", length) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " release window\"", (char *) NULL); - return TCL_ERROR; - } - tkwin = Tk_NameToWindow(interp, argv[2], (Tk_Window) clientData); - if (tkwin == NULL) { - Tcl_ResetResult(interp); - } else { - Tk_Ungrab(tkwin); - } - } else if ((c == 's') && (strncmp(argv[1], "set", length) == 0) - && (length >= 2)) { - if ((argc != 3) && (argc != 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " set ?-global? window\"", (char *) NULL); - return TCL_ERROR; - } - if (argc == 3) { - globalGrab = 0; - tkwin = Tk_NameToWindow(interp, argv[2], (Tk_Window) clientData); - } else { - globalGrab = 1; - length = strlen(argv[2]); - if ((strncmp(argv[2], "-global", length) != 0) || (length < 2)) { - Tcl_AppendResult(interp, "bad argument \"", argv[2], - "\": must be \"", argv[0], " set ?-global? window\"", - (char *) NULL); + + case GRABCMD_RELEASE: { + /* [grab release window] */ + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "release window"); return TCL_ERROR; } - tkwin = Tk_NameToWindow(interp, argv[3], (Tk_Window) clientData); - } - if (tkwin == NULL) { - return TCL_ERROR; - } - return Tk_Grab(interp, tkwin, globalGrab); - } else if ((c == 's') && (strncmp(argv[1], "status", length) == 0) - && (length >= 2)) { - TkWindow *winPtr; - - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " status window\"", (char *) NULL); - return TCL_ERROR; + tkwin = Tk_NameToWindow(interp, + Tcl_GetString(objv[2]), (Tk_Window) clientData); + if (tkwin == NULL) { + Tcl_ResetResult(interp); + } else { + Tk_Ungrab(tkwin); + } + break; } - winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[2], - (Tk_Window) clientData); - if (winPtr == NULL) { - return TCL_ERROR; + + case GRABCMD_SET: { + /* [grab set ?-global? window] */ + if ((objc != 3) && (objc != 4)) { + Tcl_WrongNumArgs(interp, 1, objv, "set ?-global? window"); + return TCL_ERROR; + } + if (objc == 3) { + globalGrab = 0; + tkwin = Tk_NameToWindow(interp, + Tcl_GetString(objv[2]), (Tk_Window) clientData); + } else { + globalGrab = 1; + /* + * We could just test the argument by hand instead of using + * Tcl_GetIndexFromObj; the benefit of using the function is + * that it sets up the error message for us, so we are + * certain to be consistant with the rest of Tcl. + */ + if (Tcl_GetIndexFromObj(interp, objv[2], flagStrings, "option", + 0, &index) != TCL_OK) { + return TCL_ERROR; + } + tkwin = Tk_NameToWindow(interp, + Tcl_GetString(objv[3]), (Tk_Window) clientData); + } + if (tkwin == NULL) { + return TCL_ERROR; + } + return Tk_Grab(interp, tkwin, globalGrab); } - dispPtr = winPtr->dispPtr; - if (dispPtr->eventualGrabWinPtr != winPtr) { - Tcl_SetResult(interp, "none", TCL_STATIC); - } else if (dispPtr->grabFlags & GRAB_GLOBAL) { - Tcl_SetResult(interp, "global", TCL_STATIC); - } else { - Tcl_SetResult(interp, "local", TCL_STATIC); + + case GRABCMD_STATUS: { + /* [grab status window] */ + TkWindow *winPtr; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "status window"); + return TCL_ERROR; + } + winPtr = (TkWindow *) Tk_NameToWindow(interp, + Tcl_GetString(objv[2]), (Tk_Window) clientData); + if (winPtr == NULL) { + return TCL_ERROR; + } + dispPtr = winPtr->dispPtr; + if (dispPtr->eventualGrabWinPtr != winPtr) { + Tcl_SetResult(interp, "none", TCL_STATIC); + } else if (dispPtr->grabFlags & GRAB_GLOBAL) { + Tcl_SetResult(interp, "global", TCL_STATIC); + } else { + Tcl_SetResult(interp, "local", TCL_STATIC); + } + break; } - } else { - Tcl_AppendResult(interp, "unknown or ambiguous option \"", argv[1], - "\": must be current, release, set, or status", - (char *) NULL); - return TCL_ERROR; } + return TCL_OK; } @@ -687,7 +742,7 @@ TkPointerEvent(eventPtr, winPtr) if (eventPtr->xcrossing.send_event != GENERATED_EVENT_MAGIC) { if ((eventPtr->type == LeaveNotify) && - (winPtr->flags & TK_TOP_LEVEL)) { + (winPtr->flags & TK_TOP_HIERARCHY)) { dispPtr->serverWinPtr = NULL; } else { dispPtr->serverWinPtr = winPtr; @@ -886,7 +941,7 @@ TkChangeEventWindow(eventPtr, winPtr) eventPtr->xmotion.subwindow = None; for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { - if (childPtr->flags & TK_TOP_LEVEL) { + if (childPtr->flags & TK_TOP_HIERARCHY) { continue; } x = eventPtr->xmotion.x - childPtr->changes.x; @@ -1171,7 +1226,7 @@ TkGrabDeadWindow(winPtr) ReleaseButtonGrab(dispPtr); } if (dispPtr->serverWinPtr == winPtr) { - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_TOP_HIERARCHY) { dispPtr->serverWinPtr = NULL; } else { dispPtr->serverWinPtr = winPtr->parentPtr; @@ -1396,7 +1451,7 @@ FindCommonAncestor(winPtr1, winPtr2, countPtr1, countPtr2) if (winPtr1 != NULL) { for (winPtr = winPtr1; winPtr != NULL; winPtr = winPtr->parentPtr) { winPtr->flags |= TK_GRAB_FLAG; - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_TOP_HIERARCHY) { break; } } @@ -1416,7 +1471,7 @@ FindCommonAncestor(winPtr1, winPtr2, countPtr1, countPtr2) ancestorPtr = winPtr; break; } - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_TOP_HIERARCHY) { count2++; break; } @@ -1438,7 +1493,7 @@ FindCommonAncestor(winPtr1, winPtr2, countPtr1, countPtr2) if (winPtr == ancestorPtr) { count1 = i; } - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_TOP_HIERARCHY) { if (count1 == -1) { count1 = i+1; } @@ -1488,7 +1543,7 @@ TkPositionInTree(winPtr, treePtr) if (winPtr2 == winPtr) { return TK_GRAB_ANCESTOR; } - if (winPtr2->flags & TK_TOP_LEVEL) { + if (winPtr2->flags & TK_TOP_HIERARCHY) { break; } } @@ -1542,4 +1597,3 @@ TkGrabState(winPtr) return TkPositionInTree(winPtr, grabWinPtr); } - diff --git a/tk/generic/tkGrid.c b/tk/generic/tkGrid.c index def4a434d49..9a94970dcba 100644 --- a/tk/generic/tkGrid.c +++ b/tk/generic/tkGrid.c @@ -42,6 +42,12 @@ #define TYPICAL_SIZE 25 /* (arbitrary guess) */ #define PREALLOC 10 /* extra slots to allocate */ +/* + * Pre-allocate room for uniform groups during layout. + */ + +#define UNIFORM_PREALLOC 10 + /* * Data structures are allocated dynamically to support arbitrary sized tables. * However, the space is proportional to the highest numbered slot with @@ -75,6 +81,9 @@ typedef struct SlotInfo { int pad; /* Extra padding, in pixels, required for * this slot. This amount is "added" to the * largest slave in the slot. */ + Tk_Uid uniform; /* Value of -uniform option. It is used to + * group slots that should have the same + * size. */ int offset; /* This is a cached value used for * introspection. It is the pixel * offset of the right or bottom edge @@ -103,6 +112,9 @@ typedef struct GridLayout { * constrants, such as size or padding. */ int pad; /* Padding needed for this slot */ int weight; /* Slot weight, controls resizing. */ + Tk_Uid uniform; /* Value of -uniform option. It is used to + * group slots that should have the same + * size. */ int minOffset; /* The minimum offset, in pixels, from * the beginning of the layout to the * right/bottom edge of the slot calculated @@ -161,10 +173,13 @@ typedef struct Gridder { int numCols, numRows; /* Number of columns or rows this slave spans. * Should be at least 1. */ int padX, padY; /* Total additional pixels to leave around the - * window (half of this space is left on each - * side). This is space *outside* the window: + * window. Some is of this space is on each + * side. This is space *outside* the window: * we'll allocate extra space in frame but * won't enlarge window). */ + int padLeft, padTop; /* The part of padX or padY to use on the + * left or top of the widget, respectively. + * By default, this is half of padX or padY. */ int iPadX, iPadY; /* Total extra pixels to allocate inside the * window (half this amount will appear on * each side). */ @@ -205,6 +220,16 @@ typedef struct Gridder { #define STICK_SOUTH 4 #define STICK_WEST 8 + +/* + * Structure to gather information about uniform groups during layout. + */ + +typedef struct UniformGroup { + Tk_Uid group; + int minSize; +} UniformGroup; + /* * Flag values for Grid structures: * @@ -233,9 +258,25 @@ static void ArrangeGrid _ANSI_ARGS_((ClientData clientData)); static int CheckSlotData _ANSI_ARGS_((Gridder *masterPtr, int slot, int slotType, int checkOnly)); static int ConfigureSlaves _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Window tkwin, int argc, char *argv[])); + Tk_Window tkwin, int objc, Tcl_Obj *CONST objv[])); static void DestroyGrid _ANSI_ARGS_((char *memPtr)); static Gridder *GetGrid _ANSI_ARGS_((Tk_Window tkwin)); +static int GridBboxCommand _ANSI_ARGS_((Tk_Window tkwin, + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); +static int GridForgetRemoveCommand _ANSI_ARGS_((Tk_Window tkwin, + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); +static int GridInfoCommand _ANSI_ARGS_((Tk_Window tkwin, + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); +static int GridLocationCommand _ANSI_ARGS_((Tk_Window tkwin, + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); +static int GridPropagateCommand _ANSI_ARGS_((Tk_Window tkwin, + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); +static int GridRowColumnConfigureCommand _ANSI_ARGS_((Tk_Window tkwin, + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); +static int GridSizeCommand _ANSI_ARGS_((Tk_Window tkwin, + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); +static int GridSlavesCommand _ANSI_ARGS_((Tk_Window tkwin, + Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); static void GridStructureProc _ANSI_ARGS_(( ClientData clientData, XEvent *eventPtr)); static void GridLostSlaveProc _ANSI_ARGS_((ClientData clientData, @@ -243,6 +284,8 @@ static void GridLostSlaveProc _ANSI_ARGS_((ClientData clientData, static void GridReqProc _ANSI_ARGS_((ClientData clientData, Tk_Window tkwin)); static void InitMasterData _ANSI_ARGS_((Gridder *masterPtr)); +static Tcl_Obj *NewPairObj _ANSI_ARGS_((Tcl_Interp*, int, int)); +static Tcl_Obj *NewQuadObj _ANSI_ARGS_((Tcl_Interp*, int, int, int, int)); static int ResolveConstraints _ANSI_ARGS_((Gridder *gridPtr, int rowOrColumn, int maxOffset)); static void SetGridSize _ANSI_ARGS_((Gridder *gridPtr)); @@ -250,6 +293,14 @@ static void StickyToString _ANSI_ARGS_((int flags, char *result)); static int StringToSticky _ANSI_ARGS_((char *string)); static void Unlink _ANSI_ARGS_((Gridder *gridPtr)); +/* + * Prototypes for procedures contained in other files but not exported + * using tkIntDecls.h + */ + +void TkPrintPadAmount _ANSI_ARGS_((Tcl_Interp*, char*, int, int)); +int TkParsePadAmount _ANSI_ARGS_((Tcl_Interp*, Tk_Window, Tcl_Obj*, int*, int*)); + static Tk_GeomMgr gridMgrType = { "grid", /* name */ GridReqProc, /* requestProc */ @@ -274,632 +325,851 @@ static Tk_GeomMgr gridMgrType = { */ int -Tk_GridCmd(clientData, interp, argc, argv) +Tk_GridObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Main window associated with * interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window tkwin = (Tk_Window) clientData; - Gridder *masterPtr; /* master grid record */ - GridMaster *gridPtr; /* pointer to grid data */ - size_t length; /* streing length of argument */ - char c; /* 1st character of argument */ + static CONST char *optionStrings[] = { + "bbox", "columnconfigure", "configure", "forget", + "info", "location", "propagate", "remove", + "rowconfigure", "size", "slaves", (char *) NULL }; + enum options { + GRID_BBOX, GRID_COLUMNCONFIGURE, GRID_CONFIGURE, GRID_FORGET, + GRID_INFO, GRID_LOCATION, GRID_PROPAGATE, GRID_REMOVE, + GRID_ROWCONFIGURE, GRID_SIZE, GRID_SLAVES }; + int index; + - if ((argc >= 2) && ((argv[1][0] == '.') || (argv[1][0] == REL_SKIP) || - (argv[1][0] == REL_VERT))) { - return ConfigureSlaves(interp, tkwin, argc-1, argv+1); + if (objc >= 2) { + char *argv1 = Tcl_GetString(objv[1]); + if ((argv1[0] == '.') || (argv1[0] == REL_SKIP) || + (argv1[0] == REL_VERT)) { + return ConfigureSlaves(interp, tkwin, objc-1, objv+1); + } } - if (argc < 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " option arg ?arg ...?\"", (char *) NULL); + if (objc < 3) { + Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?"); return TCL_ERROR; } - c = argv[1][0]; - length = strlen(argv[1]); - - if ((c == 'b') && (strncmp(argv[1], "bbox", length) == 0)) { - Tk_Window master; - int row, column; /* origin for bounding box */ - int row2, column2; /* end of bounding box */ - int endX, endY; /* last column/row in the layout */ - int x=0, y=0; /* starting pixels for this bounding box */ - int width, height; /* size of the bounding box */ - char buf[TCL_INTEGER_SPACE * 4]; - - if (argc!=3 && argc != 5 && argc != 7) { - Tcl_AppendResult(interp, "wrong number of arguments: ", - "must be \"",argv[0], - " bbox master ?column row ?column row??\"", - (char *) NULL); - return TCL_ERROR; - } - - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { - return TCL_ERROR; - } - masterPtr = GetGrid(master); - - if (argc >= 5) { - if (Tcl_GetInt(interp, argv[3], &column) != TCL_OK) { - return TCL_ERROR; - } - if (Tcl_GetInt(interp, argv[4], &row) != TCL_OK) { - return TCL_ERROR; - } - column2 = column; - row2 = row; - } - - if (argc == 7) { - if (Tcl_GetInt(interp, argv[5], &column2) != TCL_OK) { - return TCL_ERROR; - } - if (Tcl_GetInt(interp, argv[6], &row2) != TCL_OK) { - return TCL_ERROR; - } - } - - gridPtr = masterPtr->masterDataPtr; - if (gridPtr == NULL) { - Tcl_SetResult(interp, "0 0 0 0", TCL_STATIC); - return(TCL_OK); - } - SetGridSize(masterPtr); - endX = MAX(gridPtr->columnEnd, gridPtr->columnMax); - endY = MAX(gridPtr->rowEnd, gridPtr->rowMax); - - if ((endX == 0) || (endY == 0)) { - Tcl_SetResult(interp, "0 0 0 0", TCL_STATIC); - return(TCL_OK); - } - if (argc == 3) { - row = column = 0; - row2 = endY; - column2 = endX; - } + if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, + &index) != TCL_OK) { + return TCL_ERROR; + } - if (column > column2) { - int temp = column; - column = column2, column2 = temp; - } - if (row > row2) { - int temp = row; - row = row2, row2 = temp; - } + switch ((enum options) index) { + case GRID_BBOX: + return GridBboxCommand(tkwin, interp, objc, objv); + case GRID_CONFIGURE: + return ConfigureSlaves(interp, tkwin, objc-2, objv+2); + case GRID_FORGET: + case GRID_REMOVE: + return GridForgetRemoveCommand(tkwin, interp, objc, objv); + case GRID_INFO: + return GridInfoCommand(tkwin, interp, objc, objv); + case GRID_LOCATION: + return GridLocationCommand(tkwin, interp, objc, objv); + case GRID_PROPAGATE: + return GridPropagateCommand(tkwin, interp, objc, objv); + case GRID_SIZE: + return GridSizeCommand(tkwin, interp, objc, objv); + case GRID_SLAVES: + return GridSlavesCommand(tkwin, interp, objc, objv); - if (column > 0 && column < endX) { - x = gridPtr->columnPtr[column-1].offset; - } else if (column > 0) { - x = gridPtr->columnPtr[endX-1].offset; - } + /* + * Sample argument combinations: + * grid columnconfigure -option + * grid columnconfigure -option value -option value + * grid rowconfigure + * grid rowconfigure -option + * grid rowconfigure -option value -option value. + */ - if (row > 0 && row < endY) { - y = gridPtr->rowPtr[row-1].offset; - } else if (row > 0) { - y = gridPtr->rowPtr[endY-1].offset; - } + case GRID_COLUMNCONFIGURE: + case GRID_ROWCONFIGURE: + return GridRowColumnConfigureCommand(tkwin, interp, objc, objv); + } - if (column2 < 0) { - width = 0; - } else if (column2 >= endX) { - width = gridPtr->columnPtr[endX-1].offset - x; - } else { - width = gridPtr->columnPtr[column2].offset - x; - } + /* This should not happen */ + Tcl_SetResult(interp, "Internal error in grid.", TCL_STATIC); + return TCL_ERROR; +} + +/* + *---------------------------------------------------------------------- + * + * GridBboxCommand -- + * + * Implementation of the [grid bbox] subcommand. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * Places bounding box information in the interp's result field. + * + *---------------------------------------------------------------------- + */ - if (row2 < 0) { - height = 0; - } else if (row2 >= endY) { - height = gridPtr->rowPtr[endY-1].offset - y; - } else { - height = gridPtr->rowPtr[row2].offset - y; - } - - sprintf(buf, "%d %d %d %d", x + gridPtr->startX, y + gridPtr->startY, - width, height); - Tcl_SetResult(interp, buf, TCL_VOLATILE); - } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)) { - if (argv[2][0] != '.') { - Tcl_AppendResult(interp, "bad argument \"", argv[2], - "\": must be name of window", (char *) NULL); - return TCL_ERROR; - } - return ConfigureSlaves(interp, tkwin, argc-2, argv+2); - } else if (((c == 'f') && (strncmp(argv[1], "forget", length) == 0)) || - ((c == 'r') && (strncmp(argv[1], "remove", length) == 0))) { - Tk_Window slave; - Gridder *slavePtr; - int i; +static int +GridBboxCommand(tkwin, interp, objc, objv) + Tk_Window tkwin; /* Main window of the application. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ +{ + Tk_Window master; + Gridder *masterPtr; /* master grid record */ + GridMaster *gridPtr; /* pointer to grid data */ + int row, column; /* origin for bounding box */ + int row2, column2; /* end of bounding box */ + int endX, endY; /* last column/row in the layout */ + int x=0, y=0; /* starting pixels for this bounding box */ + int width, height; /* size of the bounding box */ - for (i = 2; i < argc; i++) { - slave = Tk_NameToWindow(interp, argv[i], tkwin); - if (slave == NULL) { - return TCL_ERROR; - } - slavePtr = GetGrid(slave); - if (slavePtr->masterPtr != NULL) { - - /* - * For "forget", reset all the settings to their defaults - */ - - if (c == 'f') { - slavePtr->column = slavePtr->row = -1; - slavePtr->numCols = 1; - slavePtr->numRows = 1; - slavePtr->padX = slavePtr->padY = 0; - slavePtr->iPadX = slavePtr->iPadY = 0; - slavePtr->doubleBw = 2*Tk_Changes(tkwin)->border_width; - if (slavePtr->flags & REQUESTED_RELAYOUT) { - Tcl_CancelIdleCall(ArrangeGrid, (ClientData) slavePtr); - } - slavePtr->flags = 0; - slavePtr->sticky = 0; - } - Tk_ManageGeometry(slave, (Tk_GeomMgr *) NULL, - (ClientData) NULL); - if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, - slavePtr->masterPtr->tkwin); - } - Unlink(slavePtr); - Tk_UnmapWindow(slavePtr->tkwin); - } - } - } else if ((c == 'i') && (strncmp(argv[1], "info", length) == 0)) { - register Gridder *slavePtr; - Tk_Window slave; - char buffer[64 + TCL_INTEGER_SPACE * 4]; + if (objc!=3 && objc != 5 && objc != 7) { + Tcl_WrongNumArgs(interp, 2, objv, "master ?column row ?column row??"); + return TCL_ERROR; + } - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " info window\"", (char *) NULL); - return TCL_ERROR; - } - slave = Tk_NameToWindow(interp, argv[2], tkwin); - if (slave == NULL) { - return TCL_ERROR; - } - slavePtr = GetGrid(slave); - if (slavePtr->masterPtr == NULL) { - Tcl_ResetResult(interp); - return TCL_OK; - } + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + return TCL_ERROR; + } + masterPtr = GetGrid(master); - Tcl_AppendElement(interp, "-in"); - Tcl_AppendElement(interp, Tk_PathName(slavePtr->masterPtr->tkwin)); - sprintf(buffer, " -column %d -row %d -columnspan %d -rowspan %d", - slavePtr->column, slavePtr->row, - slavePtr->numCols, slavePtr->numRows); - Tcl_AppendResult(interp, buffer, (char *) NULL); - sprintf(buffer, " -ipadx %d -ipady %d -padx %d -pady %d", - slavePtr->iPadX/2, slavePtr->iPadY/2, slavePtr->padX/2, - slavePtr->padY/2); - Tcl_AppendResult(interp, buffer, (char *) NULL); - StickyToString(slavePtr->sticky,buffer); - Tcl_AppendResult(interp, " -sticky ", buffer, (char *) NULL); - } else if((c == 'l') && (strncmp(argv[1], "location", length) == 0)) { - Tk_Window master; - register SlotInfo *slotPtr; - int x, y; /* Offset in pixels, from edge of parent. */ - int i, j; /* Corresponding column and row indeces. */ - int endX, endY; /* end of grid */ - char buf[TCL_INTEGER_SPACE * 2]; - - if (argc != 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " location master x y\"", (char *)NULL); + if (objc >= 5) { + if (Tcl_GetIntFromObj(interp, objv[3], &column) != TCL_OK) { return TCL_ERROR; } - - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { + if (Tcl_GetIntFromObj(interp, objv[4], &row) != TCL_OK) { return TCL_ERROR; } - - if (Tk_GetPixels(interp, master, argv[3], &x) != TCL_OK) { + column2 = column; + row2 = row; + } + + if (objc == 7) { + if (Tcl_GetIntFromObj(interp, objv[5], &column2) != TCL_OK) { return TCL_ERROR; } - if (Tk_GetPixels(interp, master, argv[4], &y) != TCL_OK) { + if (Tcl_GetIntFromObj(interp, objv[6], &row2) != TCL_OK) { return TCL_ERROR; } + } + + gridPtr = masterPtr->masterDataPtr; + if (gridPtr == NULL) { + Tcl_SetObjResult(interp, NewQuadObj(interp, 0, 0, 0, 0)); + return TCL_OK; + } + + SetGridSize(masterPtr); + endX = MAX(gridPtr->columnEnd, gridPtr->columnMax); + endY = MAX(gridPtr->rowEnd, gridPtr->rowMax); + + if ((endX == 0) || (endY == 0)) { + Tcl_SetObjResult(interp, NewQuadObj(interp, 0, 0, 0, 0)); + return TCL_OK; + } + if (objc == 3) { + row = column = 0; + row2 = endY; + column2 = endX; + } + + if (column > column2) { + int temp = column; + column = column2, column2 = temp; + } + if (row > row2) { + int temp = row; + row = row2, row2 = temp; + } + + if (column > 0 && column < endX) { + x = gridPtr->columnPtr[column-1].offset; + } else if (column > 0) { + x = gridPtr->columnPtr[endX-1].offset; + } + + if (row > 0 && row < endY) { + y = gridPtr->rowPtr[row-1].offset; + } else if (row > 0) { + y = gridPtr->rowPtr[endY-1].offset; + } + + if (column2 < 0) { + width = 0; + } else if (column2 >= endX) { + width = gridPtr->columnPtr[endX-1].offset - x; + } else { + width = gridPtr->columnPtr[column2].offset - x; + } + + if (row2 < 0) { + height = 0; + } else if (row2 >= endY) { + height = gridPtr->rowPtr[endY-1].offset - y; + } else { + height = gridPtr->rowPtr[row2].offset - y; + } + + Tcl_SetObjResult(interp, NewQuadObj(interp, + x + gridPtr->startX, y + gridPtr->startY, width, height)); + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * GridForgetRemoveCommand -- + * + * Implementation of the [grid forget]/[grid remove] subcommands. + * See the user documentation for details on what these do. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * Removes a window from a grid layout. + * + *---------------------------------------------------------------------- + */ - masterPtr = GetGrid(master); - if (masterPtr->masterDataPtr == NULL) { - Tcl_SetResult(interp, "-1 -1", TCL_STATIC); - return TCL_OK; - } - gridPtr = masterPtr->masterDataPtr; - - /* - * Update any pending requests. This is not always the - * steady state value, as more configure events could be in - * the pipeline, but its as close as its easy to get. - */ - - while (masterPtr->flags & REQUESTED_RELAYOUT) { - Tcl_CancelIdleCall(ArrangeGrid, (ClientData) masterPtr); - ArrangeGrid ((ClientData) masterPtr); - } - SetGridSize(masterPtr); - endX = MAX(gridPtr->columnEnd, gridPtr->columnMax); - endY = MAX(gridPtr->rowEnd, gridPtr->rowMax); - - slotPtr = masterPtr->masterDataPtr->columnPtr; - if (x < masterPtr->masterDataPtr->startX) { - i = -1; - } else { - x -= masterPtr->masterDataPtr->startX; - for (i=0;slotPtr[i].offset < x && i < endX; i++) { - /* null body */ - } - } - - slotPtr = masterPtr->masterDataPtr->rowPtr; - if (y < masterPtr->masterDataPtr->startY) { - j = -1; - } else { - y -= masterPtr->masterDataPtr->startY; - for (j=0;slotPtr[j].offset < y && j < endY; j++) { - /* null body */ - } - } - - sprintf(buf, "%d %d", i, j); - Tcl_SetResult(interp, buf, TCL_VOLATILE); - } else if ((c == 'p') && (strncmp(argv[1], "propagate", length) == 0)) { - Tk_Window master; - int propagate; +static int +GridForgetRemoveCommand(tkwin, interp, objc, objv) + Tk_Window tkwin; /* Main window of the application. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ +{ + Tk_Window slave; + Gridder *slavePtr; + int i; + char *string = Tcl_GetString(objv[1]); + char c = string[0]; - if (argc > 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " propagate window ?boolean?\"", - (char *) NULL); - return TCL_ERROR; - } - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { + for (i = 2; i < objc; i++) { + if (TkGetWindowFromObj(interp, tkwin, objv[i], &slave) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetGrid(master); - if (argc == 3) { - Tcl_SetResult(interp, - ((masterPtr->flags & DONT_PROPAGATE) ? "0" : "1"), - TCL_STATIC); - return TCL_OK; - } - if (Tcl_GetBoolean(interp, argv[3], &propagate) != TCL_OK) { - return TCL_ERROR; - } - - /* Only request a relayout if the propagation bit changes */ - - if ((!propagate) ^ (masterPtr->flags&DONT_PROPAGATE)) { - if (propagate) { - masterPtr->flags &= ~DONT_PROPAGATE; - } else { - masterPtr->flags |= DONT_PROPAGATE; - } - + + slavePtr = GetGrid(slave); + if (slavePtr->masterPtr != NULL) { + /* - * Re-arrange the master to allow new geometry information to - * propagate upwards to the master's master. + * For "forget", reset all the settings to their defaults */ - - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + + if (c == 'f') { + slavePtr->column = slavePtr->row = -1; + slavePtr->numCols = 1; + slavePtr->numRows = 1; + slavePtr->padX = slavePtr->padY = 0; + slavePtr->padLeft = slavePtr->padTop = 0; + slavePtr->iPadX = slavePtr->iPadY = 0; + slavePtr->doubleBw = 2*Tk_Changes(tkwin)->border_width; + if (slavePtr->flags & REQUESTED_RELAYOUT) { + Tcl_CancelIdleCall(ArrangeGrid, (ClientData) slavePtr); + } + slavePtr->flags = 0; + slavePtr->sticky = 0; } - if (!(masterPtr->flags & REQUESTED_RELAYOUT)) { - masterPtr->flags |= REQUESTED_RELAYOUT; - Tcl_DoWhenIdle(ArrangeGrid, (ClientData) masterPtr); + Tk_ManageGeometry(slave, (Tk_GeomMgr *) NULL, + (ClientData) NULL); + if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { + Tk_UnmaintainGeometry(slavePtr->tkwin, + slavePtr->masterPtr->tkwin); } + Unlink(slavePtr); + Tk_UnmapWindow(slavePtr->tkwin); } - } else if ((c == 's') && (strncmp(argv[1], "size", length) == 0) - && (length > 1)) { - Tk_Window master; + } + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * GridInfoCommand -- + * + * Implementation of the [grid info] subcommand. See the user + * documentation for details on what it does. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * Puts gridding information in the interpreter's result. + * + *---------------------------------------------------------------------- + */ - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " size window\"", (char *) NULL); - return TCL_ERROR; +static int +GridInfoCommand(tkwin, interp, objc, objv) + Tk_Window tkwin; /* Main window of the application. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ +{ + register Gridder *slavePtr; + Tk_Window slave; + char buffer[64 + TCL_INTEGER_SPACE * 4]; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "window"); + return TCL_ERROR; + } + if (TkGetWindowFromObj(interp, tkwin, objv[2], &slave) != TCL_OK) { + return TCL_ERROR; + } + slavePtr = GetGrid(slave); + if (slavePtr->masterPtr == NULL) { + Tcl_ResetResult(interp); + return TCL_OK; + } + + Tcl_AppendElement(interp, "-in"); + Tcl_AppendElement(interp, Tk_PathName(slavePtr->masterPtr->tkwin)); + sprintf(buffer, " -column %d -row %d -columnspan %d -rowspan %d", + slavePtr->column, slavePtr->row, + slavePtr->numCols, slavePtr->numRows); + Tcl_AppendResult(interp, buffer, (char *) NULL); + TkPrintPadAmount(interp, "ipadx", slavePtr->iPadX/2, slavePtr->iPadX); + TkPrintPadAmount(interp, "ipady", slavePtr->iPadY/2, slavePtr->iPadY); + TkPrintPadAmount(interp, "padx", slavePtr->padLeft, slavePtr->padX); + TkPrintPadAmount(interp, "pady", slavePtr->padTop, slavePtr->padY); + StickyToString(slavePtr->sticky, buffer); + Tcl_AppendResult(interp, " -sticky ", buffer, (char *) NULL); + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * GridLocationCommand -- + * + * Implementation of the [grid location] subcommand. See the user + * documentation for details on what it does. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * Puts location information in the interpreter's result field. + * + *---------------------------------------------------------------------- + */ + +static int +GridLocationCommand(tkwin, interp, objc, objv) + Tk_Window tkwin; /* Main window of the application. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ +{ + Tk_Window master; + Gridder *masterPtr; /* master grid record */ + GridMaster *gridPtr; /* pointer to grid data */ + register SlotInfo *slotPtr; + int x, y; /* Offset in pixels, from edge of parent. */ + int i, j; /* Corresponding column and row indeces. */ + int endX, endY; /* end of grid */ + + if (objc != 5) { + Tcl_WrongNumArgs(interp, 2, objv, "master x y"); + return TCL_ERROR; + } + + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + return TCL_ERROR; + } + + if (Tk_GetPixelsFromObj(interp, master, objv[3], &x) != TCL_OK) { + return TCL_ERROR; + } + if (Tk_GetPixelsFromObj(interp, master, objv[4], &y) != TCL_OK) { + return TCL_ERROR; + } + + masterPtr = GetGrid(master); + if (masterPtr->masterDataPtr == NULL) { + Tcl_SetObjResult(interp, NewPairObj(interp, -1, -1)); + return TCL_OK; + } + gridPtr = masterPtr->masterDataPtr; + + /* + * Update any pending requests. This is not always the + * steady state value, as more configure events could be in + * the pipeline, but its as close as its easy to get. + */ + + while (masterPtr->flags & REQUESTED_RELAYOUT) { + Tcl_CancelIdleCall(ArrangeGrid, (ClientData) masterPtr); + ArrangeGrid ((ClientData) masterPtr); + } + SetGridSize(masterPtr); + endX = MAX(gridPtr->columnEnd, gridPtr->columnMax); + endY = MAX(gridPtr->rowEnd, gridPtr->rowMax); + + slotPtr = masterPtr->masterDataPtr->columnPtr; + if (x < masterPtr->masterDataPtr->startX) { + i = -1; + } else { + x -= masterPtr->masterDataPtr->startX; + for (i = 0; slotPtr[i].offset < x && i < endX; i++) { + /* null body */ } - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { - return TCL_ERROR; + } + + slotPtr = masterPtr->masterDataPtr->rowPtr; + if (y < masterPtr->masterDataPtr->startY) { + j = -1; + } else { + y -= masterPtr->masterDataPtr->startY; + for (j = 0; slotPtr[j].offset < y && j < endY; j++) { + /* null body */ } - masterPtr = GetGrid(master); + } + + Tcl_SetObjResult(interp, NewPairObj(interp, i, j)); + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * GridPropagateCommand -- + * + * Implementation of the [grid propagate] subcommand. See the user + * documentation for details on what it does. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * May alter geometry propagation for a widget. + * + *---------------------------------------------------------------------- + */ - if (masterPtr->masterDataPtr != NULL) { - char buf[TCL_INTEGER_SPACE * 2]; +static int +GridPropagateCommand(tkwin, interp, objc, objv) + Tk_Window tkwin; /* Main window of the application. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ +{ + Tk_Window master; + Gridder *masterPtr; + int propagate, old; + + if (objc > 4) { + Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); + return TCL_ERROR; + } - SetGridSize(masterPtr); - gridPtr = masterPtr->masterDataPtr; - sprintf(buf, "%d %d", - MAX(gridPtr->columnEnd, gridPtr->columnMax), - MAX(gridPtr->rowEnd, gridPtr->rowMax)); - Tcl_SetResult(interp, buf, TCL_VOLATILE); + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + return TCL_ERROR; + } + masterPtr = GetGrid(master); + if (objc == 3) { + Tcl_SetObjResult(interp, + Tcl_NewBooleanObj(!(masterPtr->flags & DONT_PROPAGATE))); + return TCL_OK; + } + if (Tcl_GetBooleanFromObj(interp, objv[3], &propagate) != TCL_OK) { + return TCL_ERROR; + } + + /* Only request a relayout if the propagation bit changes */ + + old = !(masterPtr->flags & DONT_PROPAGATE); + if (propagate != old) { + if (propagate) { + masterPtr->flags &= ~DONT_PROPAGATE; } else { - Tcl_SetResult(interp, "0 0", TCL_STATIC); - } - } else if ((c == 's') && (strncmp(argv[1], "slaves", length) == 0) - && (length > 1)) { - Tk_Window master; - Gridder *slavePtr; - int i, value; - int row = -1, column = -1; - - if ((argc < 3) || ((argc%2) == 0)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " slaves window ?-option value...?\"", - (char *) NULL); - return TCL_ERROR; - } - - for (i=3; islavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - if (column>=0 && (slavePtr->column > column - || slavePtr->column+slavePtr->numCols-1 < column)) { - continue; - } - if (row>=0 && (slavePtr->row > row || - slavePtr->row+slavePtr->numRows-1 < row)) { - continue; - } - Tcl_AppendElement(interp, Tk_PathName(slavePtr->tkwin)); + masterPtr->flags |= DONT_PROPAGATE; } - - /* - * Sample argument combinations: - * grid columnconfigure -option - * grid columnconfigure -option value -option value - * grid rowconfigure - * grid rowconfigure -option - * grid rowconfigure -option value -option value. - */ - - } else if(((c == 'c') && (strncmp(argv[1], "columnconfigure", length) == 0) - && (length >= 3)) || - ((c == 'r') && (strncmp(argv[1], "rowconfigure", length) == 0) - && (length >=2))) { - Tk_Window master; - SlotInfo *slotPtr = NULL; - int slot; /* the column or row number */ - size_t length; /* the # of chars in the "-option" string */ - int slotType; /* COLUMN or ROW */ - int size; /* the configuration value */ - int checkOnly; /* check the size only */ - int argcPtr; /* Number of items in index list */ - char **argvPtr; /* array of indeces */ - char **indexP; /* String value of current index list item. */ - int ok; /* temporary TCL result code */ - int i; - - if (((argc%2 != 0) && (argc>6)) || (argc < 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " ", argv[1], " master index ?-option value...?\"", - (char *)NULL); - return TCL_ERROR; + + /* + * Re-arrange the master to allow new geometry information to + * propagate upwards to the master's master. + */ + + if (masterPtr->abortPtr != NULL) { + *masterPtr->abortPtr = 1; } - - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { - return TCL_ERROR; + if (!(masterPtr->flags & REQUESTED_RELAYOUT)) { + masterPtr->flags |= REQUESTED_RELAYOUT; + Tcl_DoWhenIdle(ArrangeGrid, (ClientData) masterPtr); } + } + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * GridRowColumnConfigureCommand -- + * + * Implementation of the [grid rowconfigure] and [grid columnconfigure] + * subcommands. See the user documentation for details on what these + * do. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * Depends on arguments; see user documentation. + * + *---------------------------------------------------------------------- + */ - if (Tcl_SplitList(interp, argv[3], &argcPtr, &argvPtr) != TCL_OK) { +static int +GridRowColumnConfigureCommand(tkwin, interp, objc, objv) + Tk_Window tkwin; /* Main window of the application. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ +{ + Tk_Window master; + Gridder *masterPtr; + SlotInfo *slotPtr = NULL; + int slot; /* the column or row number */ + int slotType; /* COLUMN or ROW */ + int size; /* the configuration value */ + int checkOnly; /* check the size only */ + int lObjc; /* Number of items in index list */ + Tcl_Obj **lObjv; /* array of indices */ + int ok; /* temporary TCL result code */ + int i, j; + char *string; + static CONST char *optionStrings[] = { + "-minsize", "-pad", "-uniform", "-weight", (char *) NULL }; + enum options { ROWCOL_MINSIZE, ROWCOL_PAD, ROWCOL_UNIFORM, ROWCOL_WEIGHT }; + int index; + + if (((objc % 2 != 0) && (objc > 6)) || (objc < 4)) { + Tcl_WrongNumArgs(interp, 2, objv, "master index ?-option value...?"); + return TCL_ERROR; + } + + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + return TCL_ERROR; + } + + if (Tcl_ListObjGetElements(interp, objv[3], &lObjc, &lObjv) != TCL_OK) { + return TCL_ERROR; + } + + string = Tcl_GetString(objv[1]); + checkOnly = ((objc == 4) || (objc == 5)); + masterPtr = GetGrid(master); + slotType = (*string == 'c') ? COLUMN : ROW; + if (checkOnly && lObjc > 1) { + Tcl_AppendResult(interp, Tcl_GetString(objv[3]), + " must be a single element.", (char *) NULL); + return TCL_ERROR; + } + for (j = 0; j < lObjc; j++) { + if (Tcl_GetIntFromObj(interp, lObjv[j], &slot) != TCL_OK) { return TCL_ERROR; } - - checkOnly = ((argc == 4) || (argc == 5)); - masterPtr = GetGrid(master); - slotType = (c == 'c') ? COLUMN : ROW; - if (checkOnly && argcPtr > 1) { - Tcl_AppendResult(interp, argv[3], - " must be a single element.", (char *) NULL); - Tcl_Free((char *)argvPtr); + ok = CheckSlotData(masterPtr, slot, slotType, checkOnly); + if ((ok != TCL_OK) && ((objc < 4) || (objc > 5))) { + Tcl_AppendResult(interp, Tcl_GetString(objv[0]), " ", + Tcl_GetString(objv[1]), ": \"", Tcl_GetString(lObjv[j]), + "\" is out of range", (char *) NULL); return TCL_ERROR; + } else if (ok == TCL_OK) { + slotPtr = (slotType == COLUMN) ? + masterPtr->masterDataPtr->columnPtr : + masterPtr->masterDataPtr->rowPtr; } - for (indexP=argvPtr; *indexP != NULL; indexP++) { - if (Tcl_GetInt(interp, *indexP, &slot) != TCL_OK) { - Tcl_Free((char *)argvPtr); - return TCL_ERROR; + + /* + * Return all of the options for this row or column. If the + * request is out of range, return all 0's. + */ + + if (objc == 4) { + int minsize = 0, pad = 0, weight = 0; + Tk_Uid uniform = NULL; + Tcl_Obj *res = Tcl_NewListObj(0, NULL); + + if (ok == TCL_OK) { + minsize = slotPtr[slot].minSize; + pad = slotPtr[slot].pad; + weight = slotPtr[slot].weight; + uniform = slotPtr[slot].uniform; } - ok = CheckSlotData(masterPtr, slot, slotType, checkOnly); - if ((ok!=TCL_OK) && ((argc<4) || (argc>5))) { - Tcl_AppendResult(interp, argv[0], - " ", argv[1], ": \"", *argvPtr,"\" is out of range", - (char *) NULL); - Tcl_Free((char *)argvPtr); + + Tcl_ListObjAppendElement(interp, res, + Tcl_NewStringObj("-minsize", -1)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(minsize)); + Tcl_ListObjAppendElement(interp, res, + Tcl_NewStringObj("-pad", -1)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(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_SetObjResult(interp, res); + return TCL_OK; + } + + /* + * Loop through each option value pair, setting the values as + * required. If only one option is given, with no value, the + * current value is returned. + */ + + for (i = 4; i < objc; i += 2) { + if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", 0, + &index) != TCL_OK) { return TCL_ERROR; - } else if (ok == TCL_OK) { - slotPtr = (slotType == COLUMN) ? - masterPtr->masterDataPtr->columnPtr : - masterPtr->masterDataPtr->rowPtr; - } - - /* - * Return all of the options for this row or column. If the - * request is out of range, return all 0's. - */ - - if (argc == 4) { - Tcl_Free((char *)argvPtr); } - if ((argc == 4) && (ok == TCL_OK)) { - char buf[64 + TCL_INTEGER_SPACE * 3]; - - sprintf(buf, "-minsize %d -pad %d -weight %d", - slotPtr[slot].minSize,slotPtr[slot].pad, - slotPtr[slot].weight); - Tcl_SetResult(interp, buf, TCL_VOLATILE); - return (TCL_OK); - } else if (argc == 4) { - Tcl_SetResult(interp, "-minsize 0 -pad 0 -weight 0", - TCL_STATIC); - return (TCL_OK); + if (index == ROWCOL_MINSIZE) { + if (objc == 5) { + Tcl_SetObjResult(interp, Tcl_NewIntObj( + (ok == TCL_OK) ? slotPtr[slot].minSize : 0)); + } else if (Tk_GetPixelsFromObj(interp, master, objv[i+1], &size) + != TCL_OK) { + return TCL_ERROR; + } else { + slotPtr[slot].minSize = size; + } } - - /* - * Loop through each option value pair, setting the values as required. - * If only one option is given, with no value, the current value is - * returned. - */ - - for (i=4; imasterDataPtr->rowMax - 1; - while ((last >= 0) && (slotPtr[last].weight == 0) - && (slotPtr[last].pad == 0) - && (slotPtr[last].minSize == 0)) { - last--; - } - masterPtr->masterDataPtr->rowMax = last+1; - } else { - int last = masterPtr->masterDataPtr->columnMax - 1; - while ((last >= 0) && (slotPtr[last].weight == 0) - && (slotPtr[last].pad == 0) - && (slotPtr[last].minSize == 0)) { - last--; - } - masterPtr->masterDataPtr->columnMax = last + 1; - } - - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + } + + /* + * If we changed a property, re-arrange the table, + * and check for constraint shrinkage. + */ + + if (objc != 5) { + if (slotType == ROW) { + int last = masterPtr->masterDataPtr->rowMax - 1; + while ((last >= 0) && (slotPtr[last].weight == 0) + && (slotPtr[last].pad == 0) + && (slotPtr[last].minSize == 0) + && (slotPtr[last].uniform == NULL)) { + last--; } - if (!(masterPtr->flags & REQUESTED_RELAYOUT)) { - masterPtr->flags |= REQUESTED_RELAYOUT; - Tcl_DoWhenIdle(ArrangeGrid, (ClientData) masterPtr); + masterPtr->masterDataPtr->rowMax = last+1; + } else { + int last = masterPtr->masterDataPtr->columnMax - 1; + while ((last >= 0) && (slotPtr[last].weight == 0) + && (slotPtr[last].pad == 0) + && (slotPtr[last].minSize == 0) + && (slotPtr[last].uniform == NULL)) { + last--; } + masterPtr->masterDataPtr->columnMax = last + 1; + } + + if (masterPtr->abortPtr != NULL) { + *masterPtr->abortPtr = 1; + } + if (!(masterPtr->flags & REQUESTED_RELAYOUT)) { + masterPtr->flags |= REQUESTED_RELAYOUT; + Tcl_DoWhenIdle(ArrangeGrid, (ClientData) masterPtr); } + } + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * GridSizeCommand -- + * + * Implementation of the [grid size] subcommand. See the user + * documentation for details on what it does. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * Puts grid size information in the interpreter's result. + * + *---------------------------------------------------------------------- + */ + +static int +GridSizeCommand(tkwin, interp, objc, objv) + Tk_Window tkwin; /* Main window of the application. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ +{ + Tk_Window master; + Gridder *masterPtr; + GridMaster *gridPtr; /* pointer to grid data */ + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "window"); + return TCL_ERROR; + } + + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + return TCL_ERROR; + } + masterPtr = GetGrid(master); + + if (masterPtr->masterDataPtr != NULL) { + SetGridSize(masterPtr); + gridPtr = masterPtr->masterDataPtr; + Tcl_SetObjResult(interp, NewPairObj(interp, + MAX(gridPtr->columnEnd, gridPtr->columnMax), + MAX(gridPtr->rowEnd, gridPtr->rowMax))); } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": must be bbox, columnconfigure, configure, forget, info, ", - "location, propagate, remove, rowconfigure, size, or slaves.", - (char *) NULL); + Tcl_SetObjResult(interp, NewPairObj(interp, 0, 0)); + } + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * GridSlavesCommand -- + * + * Implementation of the [grid slaves] subcommand. See the user + * documentation for details on what it does. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * Places a list of slaves of the specified window in the + * interpreter's result field. + * + *---------------------------------------------------------------------- + */ + +static int +GridSlavesCommand(tkwin, interp, objc, objv) + Tk_Window tkwin; /* Main window of the application. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ +{ + Tk_Window master; + Gridder *masterPtr; /* master grid record */ + Gridder *slavePtr; + int i, value; + int row = -1, column = -1; + static CONST char *optionStrings[] = { + "-column", "-row", (char *) NULL }; + enum options { SLAVES_COLUMN, SLAVES_ROW }; + int index; + Tcl_Obj *res; + + if ((objc < 3) || ((objc % 2) == 0)) { + Tcl_WrongNumArgs(interp, 2, objv, "window ?-option value...?"); + return TCL_ERROR; + } + + for (i = 3; i < objc; i += 2) { + if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", 0, + &index) != TCL_OK) { + return TCL_ERROR; + } + if (Tcl_GetIntFromObj(interp, objv[i+1], &value) != TCL_OK) { + return TCL_ERROR; + } + if (value < 0) { + Tcl_AppendResult(interp, Tcl_GetString(objv[i]), + " is an invalid value: should NOT be < 0", + (char *) NULL); + return TCL_ERROR; + } + if (index == SLAVES_COLUMN) { + column = value; + } else { + row = value; + } + } + + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { return TCL_ERROR; } + masterPtr = GetGrid(master); + + res = Tcl_NewListObj(0, NULL); + for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; + slavePtr = slavePtr->nextPtr) { + if (column>=0 && (slavePtr->column > column + || slavePtr->column+slavePtr->numCols-1 < column)) { + continue; + } + if (row>=0 && (slavePtr->row > row || + slavePtr->row+slavePtr->numRows-1 < row)) { + continue; + } + Tcl_ListObjAppendElement(interp, res, + Tcl_NewStringObj(Tk_PathName(slavePtr->tkwin), -1)); + } + Tcl_SetObjResult(interp, res); return TCL_OK; } @@ -932,7 +1202,7 @@ GridReqProc(clientData, tkwin) register Gridder *gridPtr = (Gridder *) clientData; gridPtr = gridPtr->masterPtr; - if (!(gridPtr->flags & REQUESTED_RELAYOUT)) { + if (gridPtr && !(gridPtr->flags & REQUESTED_RELAYOUT)) { gridPtr->flags |= REQUESTED_RELAYOUT; Tcl_DoWhenIdle(ArrangeGrid, (ClientData) gridPtr); } @@ -1166,9 +1436,9 @@ AdjustForSticky(slavePtr, xPtr, yPtr, widthPtr, heightPtr) int diffy=0; /* Cavity hight - slave height. */ int sticky = slavePtr->sticky; - *xPtr += slavePtr->padX/2; + *xPtr += slavePtr->padLeft; *widthPtr -= slavePtr->padX; - *yPtr += slavePtr->padY/2; + *yPtr += slavePtr->padTop; *heightPtr -= slavePtr->padY; if (*widthPtr > (Tk_ReqWidth(slavePtr->tkwin) + slavePtr->iPadX)) { @@ -1264,13 +1534,22 @@ ArrangeGrid(clientData) SetGridSize(masterPtr); width = ResolveConstraints(masterPtr, COLUMN, 0); height = ResolveConstraints(masterPtr, ROW, 0); - width += 2*Tk_InternalBorderWidth(masterPtr->tkwin); - height += 2*Tk_InternalBorderWidth(masterPtr->tkwin); + width += Tk_InternalBorderLeft(masterPtr->tkwin) + + Tk_InternalBorderRight(masterPtr->tkwin); + height += Tk_InternalBorderTop(masterPtr->tkwin) + + Tk_InternalBorderBottom(masterPtr->tkwin); + + if (width < Tk_MinReqWidth(masterPtr->tkwin)) { + width = Tk_MinReqWidth(masterPtr->tkwin); + } + if (height < Tk_MinReqHeight(masterPtr->tkwin)) { + height = Tk_MinReqHeight(masterPtr->tkwin); + } if (((width != Tk_ReqWidth(masterPtr->tkwin)) - || (height != Tk_ReqHeight(masterPtr->tkwin))) - && !(masterPtr->flags & DONT_PROPAGATE)) { - Tk_GeometryRequest(masterPtr->tkwin, width, height); + || (height != Tk_ReqHeight(masterPtr->tkwin))) + && !(masterPtr->flags & DONT_PROPAGATE)) { + Tk_GeometryRequest(masterPtr->tkwin, width, height); if (width>1 && height>1) { masterPtr->flags |= REQUESTED_RELAYOUT; Tcl_DoWhenIdle(ArrangeGrid, (ClientData) masterPtr); @@ -1289,15 +1568,17 @@ ArrangeGrid(clientData) */ realWidth = Tk_Width(masterPtr->tkwin) - - 2*Tk_InternalBorderWidth(masterPtr->tkwin); + Tk_InternalBorderLeft(masterPtr->tkwin) - + Tk_InternalBorderRight(masterPtr->tkwin); realHeight = Tk_Height(masterPtr->tkwin) - - 2*Tk_InternalBorderWidth(masterPtr->tkwin); + Tk_InternalBorderTop(masterPtr->tkwin) - + Tk_InternalBorderBottom(masterPtr->tkwin); slotPtr->startX = AdjustOffsets(realWidth, MAX(slotPtr->columnEnd,slotPtr->columnMax), slotPtr->columnPtr); slotPtr->startY = AdjustOffsets(realHeight, MAX(slotPtr->rowEnd,slotPtr->rowMax), slotPtr->rowPtr); - slotPtr->startX += Tk_InternalBorderWidth(masterPtr->tkwin); - slotPtr->startY += Tk_InternalBorderWidth(masterPtr->tkwin); + slotPtr->startX += Tk_InternalBorderLeft(masterPtr->tkwin); + slotPtr->startY += Tk_InternalBorderTop(masterPtr->tkwin); /* * Now adjust the actual size of the slave to its cavity by @@ -1414,6 +1695,14 @@ ResolveConstraints(masterPtr, slotType, maxOffset) * constraints are not yet fully resolved. */ int end; /* The Last slot of a contiguous set whose * constraints are not yet fully resolved. */ + UniformGroup uniformPre[UNIFORM_PREALLOC]; + /* Pre-allocated space for uniform groups. */ + UniformGroup *uniformGroupPtr; + /* Uniform groups data. */ + int uniformGroups; /* Number of currently used uniform groups. */ + int uniformGroupsAlloced; /* Size of allocated space for uniform groups. + */ + int weight, minSize; /* * For typical sized tables, we'll use stack space for the layout data @@ -1463,13 +1752,15 @@ ResolveConstraints(masterPtr, slotType, maxOffset) for (slot=0; slot < constraintCount; slot++) { layoutPtr[slot].minSize = slotPtr[slot].minSize; - layoutPtr[slot].weight = slotPtr[slot].weight; + layoutPtr[slot].weight = slotPtr[slot].weight; + layoutPtr[slot].uniform = slotPtr[slot].uniform; layoutPtr[slot].pad = slotPtr[slot].pad; layoutPtr[slot].binNextPtr = NULL; } for(;slot= uniformGroups) { + /* + * Have not seen that group before, set up data for it. + */ + + if (uniformGroups >= uniformGroupsAlloced) { + /* + * We need to allocate more space. + */ + + size_t oldSize = uniformGroupsAlloced + * sizeof(UniformGroup); + size_t newSize = (uniformGroupsAlloced + UNIFORM_PREALLOC) + * sizeof(UniformGroup); + UniformGroup *new = (UniformGroup *) ckalloc(newSize); + UniformGroup *old = uniformGroupPtr; + memcpy((VOID *) new, (VOID *) old, oldSize); + if (old != uniformPre) { + ckfree((char *) old); + } + uniformGroupPtr = new; + uniformGroupsAlloced += UNIFORM_PREALLOC; + } + uniformGroups++; + uniformGroupPtr[start].group = layoutPtr[slot].uniform; + uniformGroupPtr[start].minSize = 0; + } + weight = layoutPtr[slot].weight; + weight = weight > 0 ? weight : 1; + minSize = (layoutPtr[slot].minSize + weight - 1) / weight; + if (minSize > uniformGroupPtr[start].minSize) { + uniformGroupPtr[start].minSize = minSize; + } + } + } + + /* + * Data has been gathered about uniform groups. Now relayout accordingly. + */ + + if (uniformGroups > 0) { + for (slot = 0; slot < gridCount; slot++) { + if (layoutPtr[slot].uniform != NULL) { + for (start = 0; start < uniformGroups; start++) { + if (uniformGroupPtr[start].group == + layoutPtr[slot].uniform) { + weight = layoutPtr[slot].weight; + weight = weight > 0 ? weight : 1; + layoutPtr[slot].minSize = + uniformGroupPtr[start].minSize * weight; + break; + } + } + } + } + } + + if (uniformGroupPtr != uniformPre) { + ckfree((char *) uniformGroupPtr); + } + /* * Step 3. * Determine the minimum slot offsets going from left to right @@ -1707,7 +2075,7 @@ ResolveConstraints(masterPtr, slotType, maxOffset) --layoutPtr; if (layoutPtr != layoutData) { - Tcl_Free((char *)layoutPtr); + ckfree((char *)layoutPtr); } return requiredSize; } @@ -1770,6 +2138,7 @@ GetGrid(tkwin) gridPtr->numRows = 1; gridPtr->padX = gridPtr->padY = 0; + gridPtr->padLeft = gridPtr->padTop = 0; gridPtr->iPadX = gridPtr->iPadY = 0; gridPtr->doubleBw = 2*Tk_Changes(tkwin)->border_width; gridPtr->abortPtr = NULL; @@ -1886,7 +2255,7 @@ CheckSlotData(masterPtr, slot, slotType, checkOnly) masterPtr->masterDataPtr->columnPtr; memcpy((VOID *) new, (VOID *) old, oldSize ); memset((VOID *) (new+numSlot), 0, newSize - oldSize ); - Tcl_Free((char *) old); + ckfree((char *) old); if (slotType == ROW) { masterPtr->masterDataPtr->rowPtr = new ; masterPtr->masterDataPtr->rowSpace = newNumSlot ; @@ -2037,14 +2406,14 @@ DestroyGrid(memPtr) if (gridPtr->masterDataPtr != NULL) { if (gridPtr->masterDataPtr->rowPtr != NULL) { - Tcl_Free((char *) gridPtr->masterDataPtr -> rowPtr); + ckfree((char *) gridPtr->masterDataPtr -> rowPtr); } if (gridPtr->masterDataPtr->columnPtr != NULL) { - Tcl_Free((char *) gridPtr->masterDataPtr -> columnPtr); + ckfree((char *) gridPtr->masterDataPtr -> columnPtr); } - Tcl_Free((char *) gridPtr->masterDataPtr); + ckfree((char *) gridPtr->masterDataPtr); } - Tcl_Free((char *) gridPtr); + ckfree((char *) gridPtr); } /* @@ -2145,12 +2514,12 @@ GridStructureProc(clientData, eventPtr) */ static int -ConfigureSlaves(interp, tkwin, argc, argv) +ConfigureSlaves(interp, tkwin, objc, objv) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_Window tkwin; /* Any window in application containing * slaves. Used to look up slave names. */ - int argc; /* Number of elements in argv. */ - char *argv[]; /* Argument strings: contains one or more + int objc; /* Number of elements in argv. */ + Tcl_Obj *CONST objv[]; /* Argument objects: contains one or more * window names followed by any number * of "option value" pairs. Caller must * make sure that there is at least one @@ -2159,38 +2528,57 @@ ConfigureSlaves(interp, tkwin, argc, argv) Gridder *masterPtr; Gridder *slavePtr; Tk_Window other, slave, parent, ancestor; - int i, j, c, tmp; - size_t length; + int i, j, tmp; + int length; int numWindows; int width; int defaultColumn = 0; /* default column number */ int defaultColumnSpan = 1; /* default number of columns */ char *lastWindow; /* use this window to base current * Row/col on */ + int numSkip; /* number of 'x' found */ + static CONST char *optionStrings[] = { + "-column", "-columnspan", "-in", "-ipadx", "-ipady", + "-padx", "-pady", "-row", "-rowspan", "-sticky", + (char *) NULL }; + enum options { + CONF_COLUMN, CONF_COLUMNSPAN, CONF_IN, CONF_IPADX, CONF_IPADY, + CONF_PADX, CONF_PADY, CONF_ROW, CONF_ROWSPAN, CONF_STICKY }; + int index; + char *string; + char firstChar, prevChar; /* * Count the number of windows, or window short-cuts. */ - for(numWindows=i=0;i 1 && i == 0) { + Tcl_AppendResult(interp, "bad argument \"", string, + "\": must be name of window", (char *) NULL); + return TCL_ERROR; + } if (length > 1 && firstChar == '-') { break; } if (length > 1) { Tcl_AppendResult(interp, "unexpected parameter, \"", - argv[i], "\", in configure list. ", + string, "\", in configure list. ", "Should be window name or option", (char *) NULL); return TCL_ERROR; } if ((firstChar == REL_HORIZ) && ((numWindows == 0) || - (*argv[i-1] == REL_SKIP) || (*argv[i-1] == REL_VERT))) { + (prevChar == REL_SKIP) || (prevChar == REL_VERT))) { Tcl_AppendResult(interp, "Must specify window before shortcut '-'.", (char *) NULL); @@ -2203,12 +2591,12 @@ ConfigureSlaves(interp, tkwin, argc, argv) } Tcl_AppendResult(interp, "invalid window shortcut, \"", - argv[i], "\" should be '-', 'x', or '^'", (char *) NULL); + string, "\" should be '-', 'x', or '^'", (char *) NULL); return TCL_ERROR; } numWindows = i; - if ((argc-numWindows)&1) { + if ((objc - numWindows) & 1) { Tcl_AppendResult(interp, "extra option or", " option with no value", (char *) NULL); return TCL_ERROR; @@ -2227,7 +2615,8 @@ ConfigureSlaves(interp, tkwin, argc, argv) masterPtr = NULL; for (j = 0; j < numWindows; j++) { - char firstChar = *argv[j]; + string = Tcl_GetString(objv[j]); + firstChar = string[0]; /* * '^' and 'x' cause us to skip a column. '-' is processed @@ -2242,19 +2631,20 @@ ConfigureSlaves(interp, tkwin, argc, argv) continue; } - for (defaultColumnSpan=1; - j + defaultColumnSpan < numWindows && - (*argv[j+defaultColumnSpan] == REL_HORIZ); + for (defaultColumnSpan = 1; j + defaultColumnSpan < numWindows; defaultColumnSpan++) { - /* null body */ + char *string = Tcl_GetString(objv[j + defaultColumnSpan]); + if (*string != REL_HORIZ) { + break; + } } - slave = Tk_NameToWindow(interp, argv[j], tkwin); - if (slave == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) { return TCL_ERROR; } - if (Tk_IsTopLevel(slave)) { - Tcl_AppendResult(interp, "can't manage \"", argv[j], + + if (Tk_TopWinHierarchy(slave)) { + Tcl_AppendResult(interp, "can't manage \"", Tcl_GetString(objv[j]), "\": it's a top-level window", (char *) NULL); return TCL_ERROR; } @@ -2275,38 +2665,34 @@ ConfigureSlaves(interp, tkwin, argc, argv) * about keeping track of the old state. */ - for (i = numWindows; i < argc; i+=2) { - length = strlen(argv[i]); - c = argv[i][1]; - - if (length < 2) { - Tcl_AppendResult(interp, "unknown or ambiguous option \"", - argv[i], "\": must be ", - "-column, -columnspan, -in, -ipadx, -ipady, ", - "-padx, -pady, -row, -rowspan, or -sticky", - (char *) NULL); + for (i = numWindows; i < objc; i += 2) { + if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", 0, + &index) != TCL_OK) { return TCL_ERROR; } - if ((c == 'c') && (strncmp(argv[i], "-column", length) == 0)) { - if (Tcl_GetInt(interp, argv[i+1], &tmp) != TCL_OK || tmp<0) { + if (index == CONF_COLUMN) { + if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK || + tmp < 0) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad column value \"", argv[i+1], + Tcl_AppendResult(interp, "bad column value \"", + Tcl_GetString(objv[i+1]), "\": must be a non-negative integer", (char *)NULL); return TCL_ERROR; } slavePtr->column = tmp; - } else if ((c == 'c') - && (strncmp(argv[i], "-columnspan", length) == 0)) { - if (Tcl_GetInt(interp, argv[i+1], &tmp) != TCL_OK || tmp <= 0) { + } else if (index == CONF_COLUMNSPAN) { + if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK || + tmp <= 0) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad columnspan value \"", argv[i+1], + Tcl_AppendResult(interp, "bad columnspan value \"", + Tcl_GetString(objv[i+1]), "\": must be a positive integer", (char *)NULL); return TCL_ERROR; } slavePtr->numCols = tmp; - } else if ((c == 'i') && (strncmp(argv[i], "-in", length) == 0)) { - other = Tk_NameToWindow(interp, argv[i+1], tkwin); - if (other == NULL) { + } else if (index == CONF_IN) { + if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) != + TCL_OK) { return TCL_ERROR; } if (other == slave) { @@ -2316,84 +2702,70 @@ ConfigureSlaves(interp, tkwin, argc, argv) } masterPtr = GetGrid(other); InitMasterData(masterPtr); - } else if ((c == 'i') - && (strncmp(argv[i], "-ipadx", length) == 0)) { - if ((Tk_GetPixels(interp, slave, argv[i+1], &tmp) != TCL_OK) + } else if (index == CONF_IPADX) { + if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) + != TCL_OK) || (tmp < 0)) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad ipadx value \"", argv[i+1], + Tcl_AppendResult(interp, "bad ipadx value \"", + Tcl_GetString(objv[i+1]), "\": must be positive screen distance", (char *) NULL); return TCL_ERROR; } slavePtr->iPadX = tmp*2; - } else if ((c == 'i') - && (strncmp(argv[i], "-ipady", length) == 0)) { - if ((Tk_GetPixels(interp, slave, argv[i+1], &tmp) != TCL_OK) - || (tmp< 0)) { + } else if (index == CONF_IPADY) { + if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) + != TCL_OK) + || (tmp < 0)) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad ipady value \"", argv[i+1], + Tcl_AppendResult(interp, "bad ipady value \"", + Tcl_GetString(objv[i+1]), "\": must be positive screen distance", (char *) NULL); return TCL_ERROR; } slavePtr->iPadY = tmp*2; - } else if ((c == 'p') - && (strncmp(argv[i], "-padx", length) == 0)) { - if ((Tk_GetPixels(interp, slave, argv[i+1], &tmp) != TCL_OK) - || (tmp< 0)) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad padx value \"", argv[i+1], - "\": must be positive screen distance", - (char *) NULL); + } else if (index == CONF_PADX) { + if (TkParsePadAmount(interp, tkwin, objv[i+1], + &slavePtr->padLeft, &slavePtr->padX) != TCL_OK) { return TCL_ERROR; } - slavePtr->padX = tmp*2; - } else if ((c == 'p') - && (strncmp(argv[i], "-pady", length) == 0)) { - if ((Tk_GetPixels(interp, slave, argv[i+1], &tmp) != TCL_OK) - || (tmp< 0)) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad pady value \"", argv[i+1], - "\": must be positive screen distance", - (char *) NULL); + } else if (index == CONF_PADY) { + if (TkParsePadAmount(interp, tkwin, objv[i+1], + &slavePtr->padTop, &slavePtr->padY) != TCL_OK) { return TCL_ERROR; } - slavePtr->padY = tmp*2; - } else if ((c == 'r') && (strncmp(argv[i], "-row", length) == 0)) { - if (Tcl_GetInt(interp, argv[i+1], &tmp) != TCL_OK || tmp<0) { + } else if (index == CONF_ROW) { + if (Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK + || tmp < 0) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad grid value \"", argv[i+1], + Tcl_AppendResult(interp, "bad grid value \"", + Tcl_GetString(objv[i+1]), "\": must be a non-negative integer", (char *)NULL); return TCL_ERROR; } slavePtr->row = tmp; - } else if ((c == 'r') - && (strncmp(argv[i], "-rowspan", length) == 0)) { - if ((Tcl_GetInt(interp, argv[i+1], &tmp) != TCL_OK) || tmp<=0) { + } else if (index == CONF_ROWSPAN) { + if ((Tcl_GetIntFromObj(interp, objv[i+1], &tmp) != TCL_OK) + || tmp <= 0) { Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad rowspan value \"", argv[i+1], + Tcl_AppendResult(interp, "bad rowspan value \"", + Tcl_GetString(objv[i+1]), "\": must be a positive integer", (char *)NULL); return TCL_ERROR; } slavePtr->numRows = tmp; - } else if ((c == 's') - && strncmp(argv[i], "-sticky", length) == 0) { - int sticky = StringToSticky(argv[i+1]); + } else if (index == CONF_STICKY) { + int sticky = StringToSticky(Tcl_GetString(objv[i+1])); if (sticky == -1) { - Tcl_AppendResult(interp, "bad stickyness value \"", argv[i+1], + Tcl_AppendResult(interp, "bad stickyness value \"", + Tcl_GetString(objv[i+1]), "\": must be a string containing n, e, s, and/or w", (char *)NULL); return TCL_ERROR; } slavePtr->sticky = sticky; - } else { - Tcl_AppendResult(interp, "unknown or ambiguous option \"", - argv[i], "\": must be ", - "-column, -columnspan, -in, -ipadx, -ipady, ", - "-padx, -pady, -row, -rowspan, or -sticky", - (char *) NULL); - return TCL_ERROR; } } @@ -2435,8 +2807,8 @@ ConfigureSlaves(interp, tkwin, argc, argv) if (ancestor == parent) { break; } - if (Tk_IsTopLevel(ancestor)) { - Tcl_AppendResult(interp, "can't put ", argv[j], + if (Tk_TopWinHierarchy(ancestor)) { + Tcl_AppendResult(interp, "can't put ", Tcl_GetString(objv[j]), " inside ", Tk_PathName(masterPtr->tkwin), (char *) NULL); Unlink(slavePtr); @@ -2449,7 +2821,7 @@ ConfigureSlaves(interp, tkwin, argc, argv) */ if (masterPtr->masterPtr == slavePtr) { - Tcl_AppendResult(interp, "can't put ", argv[j], + Tcl_AppendResult(interp, "can't put ", Tcl_GetString(objv[j]), " inside ", Tk_PathName(masterPtr->tkwin), ", would cause management loop.", (char *) NULL); @@ -2494,15 +2866,23 @@ ConfigureSlaves(interp, tkwin, argc, argv) /* Now look for all the "^"'s. */ lastWindow = NULL; + numSkip = 0; for (j = 0; j < numWindows; j++) { struct Gridder *otherPtr; int match; /* found a match for the ^ */ - int lastRow, lastColumn; /* implied end of table */ + int lastRow, lastColumn; /* implied end of table */ - if (*argv[j] == '.') { - lastWindow = argv[j]; + string = Tcl_GetString(objv[j]); + firstChar = string[0]; + + if (firstChar == '.') { + lastWindow = string; + numSkip = 0; + } + if (firstChar == REL_SKIP) { + numSkip++; } - if (*argv[j] != REL_VERT) { + if (firstChar != REL_VERT) { continue; } @@ -2513,9 +2893,9 @@ ConfigureSlaves(interp, tkwin, argc, argv) } /* Count the number of consecutive ^'s starting from this position */ - for (width=1; width+j < numWindows && *argv[j+width] == REL_VERT; - width++) { - /* Null Body */ + for (width = 1; width + j < numWindows; width++) { + char *string = Tcl_GetString(objv[j+width]); + if (*string != REL_VERT) break; } /* @@ -2537,6 +2917,8 @@ ConfigureSlaves(interp, tkwin, argc, argv) lastColumn = otherPtr->column + otherPtr->numCols; } + lastColumn += numSkip; + for (match=0, slavePtr = masterPtr->slavePtr; slavePtr != NULL; slavePtr = slavePtr->nextPtr) { @@ -2547,6 +2929,7 @@ ConfigureSlaves(interp, tkwin, argc, argv) match++; j += slavePtr->numCols - 1; lastWindow = Tk_PathName(slavePtr->tkwin); + numSkip = 0; break; } } @@ -2556,7 +2939,6 @@ ConfigureSlaves(interp, tkwin, argc, argv) (char *) NULL); return TCL_ERROR; } -/* j += width - 1; */ } if (masterPtr == NULL) { @@ -2646,6 +3028,60 @@ StringToSticky(string) } } return sticky; -} +} + +/* + *---------------------------------------------------------------------- + * + * NewPairObj -- + * + * Creates a new list object and fills it with two integer objects. + * + * Results: + * The newly created list object is returned. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +static Tcl_Obj * +NewPairObj(interp, val1, val2) + Tcl_Interp *interp; /* Current interpreter. */ + int val1, val2; +{ + Tcl_Obj *res = Tcl_NewListObj(0, NULL); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(val1)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(val2)); + return res; +} + +/* + *---------------------------------------------------------------------- + * + * NewQuadObj -- + * + * Creates a new list object and fills it with four integer objects. + * + * Results: + * The newly created list object is returned. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +static Tcl_Obj * +NewQuadObj(interp, val1, val2, val3, val4) + Tcl_Interp *interp; /* Current interpreter. */ + int val1, val2, val3, val4; +{ + Tcl_Obj *res = Tcl_NewListObj(0, NULL); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(val1)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(val2)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(val3)); + Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(val4)); + return res; +} diff --git a/tk/generic/tkImage.c b/tk/generic/tkImage.c index 778081002a9..98e5dcbee53 100644 --- a/tk/generic/tkImage.c +++ b/tk/generic/tkImage.c @@ -69,6 +69,9 @@ typedef struct ImageMaster { * entry). */ Image *instancePtr; /* Pointer to first in list of instances * derived from this name. */ + int deleted; /* Flag set when image is being deleted. */ + TkWindow *winPtr; /* Main window of interpreter (used to + * detect when the world is falling apart.) */ } ImageMaster; typedef struct ThreadSpecificData { @@ -83,7 +86,8 @@ static Tcl_ThreadDataKey dataKey; * Prototypes for local procedures: */ -static void DeleteImage _ANSI_ARGS_((ImageMaster *masterPtr)); +static void DeleteImage _ANSI_ARGS_((ImageMaster *masterPtr)); +static void EventuallyDeleteImage _ANSI_ARGS_((ImageMaster *masterPtr)); /* *---------------------------------------------------------------------- @@ -156,12 +160,12 @@ Tk_ImageObjCmd(clientData, interp, objc, objv) int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument strings. */ { - static char *imageOptions[] = { - "create", "delete", "height", "names", "type", "types", "width", - (char *) NULL + static CONST char *imageOptions[] = { + "create", "delete", "height", "inuse", "names", "type", "types", + "width", (char *) NULL }; enum options { - IMAGE_CREATE, IMAGE_DELETE, IMAGE_HEIGHT, IMAGE_NAMES, + IMAGE_CREATE, IMAGE_DELETE, IMAGE_HEIGHT, IMAGE_INUSE, IMAGE_NAMES, IMAGE_TYPE, IMAGE_TYPES, IMAGE_WIDTH }; TkWindow *winPtr = (TkWindow *) clientData; @@ -251,6 +255,9 @@ Tk_ImageObjCmd(clientData, interp, objc, objv) masterPtr->tablePtr = &winPtr->mainPtr->imageTable; masterPtr->hPtr = hPtr; masterPtr->instancePtr = NULL; + masterPtr->deleted = 0; + masterPtr->winPtr = winPtr->mainPtr->winPtr; + Tcl_Preserve((ClientData) masterPtr->winPtr); Tcl_SetHashValue(hPtr, masterPtr); } else { /* @@ -290,15 +297,18 @@ Tk_ImageObjCmd(clientData, interp, objc, objv) } args[objc] = NULL; } + Tcl_Preserve((ClientData) masterPtr); if ((*typePtr->createProc)(interp, name, objc, args, typePtr, (Tk_ImageMaster) masterPtr, &masterPtr->masterData) != TCL_OK) { - DeleteImage(masterPtr); + EventuallyDeleteImage(masterPtr); + Tcl_Release((ClientData) masterPtr); if (oldimage) { ckfree((char *) args); } return TCL_ERROR; } + Tcl_Release((ClientData) masterPtr); if (oldimage) { ckfree((char *) args); } @@ -322,8 +332,7 @@ Tk_ImageObjCmd(clientData, interp, objc, objv) "\" doesn't exist", (char *) NULL); return TCL_ERROR; } - masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr); - DeleteImage(masterPtr); + DeleteImage((ImageMaster *) Tcl_GetHashValue(hPtr)); } break; } @@ -344,18 +353,42 @@ Tk_ImageObjCmd(clientData, interp, objc, objv) Tcl_SetIntObj(Tcl_GetObjResult(interp), masterPtr->height); break; } + + case IMAGE_INUSE: { + int count = 0; + char *arg; + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "name"); + return TCL_ERROR; + } + arg = Tcl_GetString(objv[2]); + hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg); + if (hPtr == NULL) { + Tcl_AppendResult(interp, "image \"", arg, + "\" doesn't exist", (char *) NULL); + return TCL_ERROR; + } + masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr); + if (masterPtr->typePtr != NULL && masterPtr->instancePtr != NULL) { + count = 1; + } + Tcl_SetBooleanObj(Tcl_GetObjResult(interp), count); + break; + } + case IMAGE_NAMES: { if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); return TCL_ERROR; } - for (hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { + hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search); + for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { Tcl_AppendElement(interp, Tcl_GetHashKey( &winPtr->mainPtr->imageTable, hPtr)); } break; } + case IMAGE_TYPE: { char *arg; if (objc != 3) { @@ -473,7 +506,7 @@ Tk_ImageChanged(imageMaster, x, y, width, height, imageWidth, *---------------------------------------------------------------------- */ -char * +CONST char * Tk_NameOfImage(imageMaster) Tk_ImageMaster imageMaster; /* Token for image. */ { @@ -511,7 +544,7 @@ Tk_GetImage(interp, tkwin, name, changeProc, clientData) * can't be found. */ Tk_Window tkwin; /* Token for window in which image will * be used. */ - char *name; /* Name of desired image. */ + CONST char *name; /* Name of desired image. */ Tk_ImageChangedProc *changeProc; /* Procedure to invoke when redisplay is * needed because image's pixels or size @@ -820,7 +853,7 @@ void Tk_DeleteImage(interp, name) Tcl_Interp *interp; /* Interpreter in which the image was * created. */ - char *name; /* Name of image. */ + CONST char *name; /* Name of image. */ { Tcl_HashEntry *hPtr; TkWindow *winPtr; @@ -833,7 +866,7 @@ Tk_DeleteImage(interp, name) if (hPtr == NULL) { return; } - DeleteImage((ImageMaster *) Tcl_GetHashValue(hPtr)); + DeleteImage((ImageMaster *)Tcl_GetHashValue(hPtr)); } /* @@ -875,11 +908,43 @@ DeleteImage(masterPtr) (*typePtr->deleteProc)(masterPtr->masterData); } if (masterPtr->instancePtr == NULL) { - Tcl_DeleteHashEntry(masterPtr->hPtr); + if ((masterPtr->winPtr->flags & TK_ALREADY_DEAD) == 0) { + Tcl_DeleteHashEntry(masterPtr->hPtr); + } + Tcl_Release((ClientData) masterPtr->winPtr); ckfree((char *) masterPtr); } } +/* + *---------------------------------------------------------------------- + * + * EventuallyDeleteImage -- + * + * Arrange for an image to be deleted when it is safe to do so. + * + * Results: + * None. + * + * Side effects: + * Image will get freed, though not until it is no longer + * Tcl_Preserve()d by anything. May be called multiple times on + * the same image without ill effects. + * + *---------------------------------------------------------------------- + */ + +static void +EventuallyDeleteImage(masterPtr) + ImageMaster *masterPtr; /* Pointer to main data structure for image. */ +{ + if (!masterPtr->deleted) { + masterPtr->deleted = 1; + Tcl_EventuallyFree((ClientData) masterPtr, + (Tcl_FreeProc *)DeleteImage); + } +} + /* *---------------------------------------------------------------------- * @@ -906,12 +971,10 @@ TkDeleteAllImages(mainPtr) { Tcl_HashSearch search; Tcl_HashEntry *hPtr; - ImageMaster *masterPtr; for (hPtr = Tcl_FirstHashEntry(&mainPtr->imageTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr); - DeleteImage(masterPtr); + EventuallyDeleteImage((ImageMaster *) Tcl_GetHashValue(hPtr)); } Tcl_DeleteHashTable(&mainPtr->imageTable); } @@ -941,7 +1004,7 @@ ClientData Tk_GetImageMasterData(interp, name, typePtrPtr) Tcl_Interp *interp; /* Interpreter in which the image was * created. */ - char *name; /* Name of image. */ + CONST char *name; /* Name of image. */ Tk_ImageType **typePtrPtr; /* Points to location to fill in with * pointer to type information for image. */ { @@ -987,7 +1050,7 @@ Tk_SetTSOrigin(tkwin, gc, x, y) GC gc; int x, y; { - while (!Tk_IsTopLevel(tkwin)) { + while (!Tk_TopWinHierarchy(tkwin)) { x -= Tk_X(tkwin) + Tk_Changes(tkwin)->border_width; y -= Tk_Y(tkwin) + Tk_Changes(tkwin)->border_width; tkwin = Tk_Parent(tkwin); @@ -995,5 +1058,3 @@ Tk_SetTSOrigin(tkwin, gc, x, y) XSetTSOrigin(Tk_Display(tkwin), gc, x, y); } - - diff --git a/tk/generic/tkImgBmap.c b/tk/generic/tkImgBmap.c index 47eacf2f560..9eaa8db6b5f 100644 --- a/tk/generic/tkImgBmap.c +++ b/tk/generic/tkImgBmap.c @@ -214,7 +214,6 @@ ImgBmapCreate(interp, name, argc, argv, typePtr, master, clientDataPtr) masterPtr->maskFileString = NULL; masterPtr->maskDataString = NULL; masterPtr->instancePtr = NULL; - if (ImgBmapConfigureMaster(masterPtr, argc, argv, 0) != TCL_OK) { ImgBmapDelete((ClientData) masterPtr); return TCL_ERROR; @@ -255,7 +254,7 @@ ImgBmapConfigureMaster(masterPtr, objc, objv, flags) BitmapInstance *instancePtr; int maskWidth, maskHeight, dummy1, dummy2; - char **argv = (char **) 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]); } @@ -499,7 +498,8 @@ TkGetBitmapData(interp, string, fileName, widthPtr, heightPtr, int *hotXPtr, *hotYPtr; /* Position of hot spot or -1,-1. */ { int width, height, numBytes, hotX, hotY; - char *p, *end, *expandedFileName; + CONST char *expandedFileName; + char *p, *end; ParseInfo pi; char *data = NULL; Tcl_DString buffer; @@ -762,7 +762,7 @@ ImgBmapCmd(clientData, interp, objc, objv) int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ { - static char *bmapOptions[] = {"cget", "configure", (char *) NULL}; + static CONST char *bmapOptions[] = {"cget", "configure", (char *) NULL}; BitmapMaster *masterPtr = (BitmapMaster *) clientData; int code, index; @@ -1103,16 +1103,109 @@ GetByte(chan) } +/* + *---------------------------------------------------------------------- + * + * ImgBmapPsImagemask -- + * + * This procedure generates postscript suitable for rendering a + * single bitmap of an image. A single bitmap image might contain both + * a foreground and a background bitmap. This routine is called once + * for each such bitmap in a bitmap image. + * + * Prior to invoking this routine, the following setup has occurred: + * + * 1. The postscript foreground color has been set to the color + * used to render the bitmap. + * + * 2. The origin of the postscript coordinate system is set to + * the lower left corner of the bitmap. + * + * 3. The postscript coordinate system has been scaled so that + * the entire bitmap is one unit squared. + * + * Some postscript implementations cannot handle bitmap strings + * longer than about 60k characters. If the bitmap data is that big + * or bigger, then we render it by splitting it into several smaller + * bitmaps. + * + * Results: + * Returns TCL_OK on success. Returns TCL_ERROR and leaves and error + * message in interp->result if there is a problem. + * + * Side effects: + * Postscript code is appended to interp->result. + * + *---------------------------------------------------------------------- + */ + +static int +ImgBmapPsImagemask(interp, width, height, data) + Tcl_Interp *interp; /* Append postscript to this interpreter */ + int width, height; /* Width and height of the bitmap in pixels */ + char *data; /* Data for the bitmap */ +{ + int i, j, nBytePerRow; + char buffer[200]; + + /* + * The bit order of bitmaps in Tk is the opposite of the bit order that + * postscript uses. (In Tk, the least significant bit is on the right + * side of the bitmap and in postscript the least significant bit is shown + * on the left.) The following array is used to reverse the order of bits + * within a byte so that the bits will be in the order postscript expects. + */ + static unsigned char bit_reverse[] = { + 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, + 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, + 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, + 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, + 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, + 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, + 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, + 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, + 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, + 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, + 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, + 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, + 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, + 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, + 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, + 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255, + }; + + if (width*height > 60000) { + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "unable to generate postscript for bitmaps " + "larger than 60000 pixels", 0); + return TCL_ERROR; + } + sprintf(buffer, "0 0 moveto %d %d true [%d 0 0 %d 0 %d] {<\n", + width, height, width, -height, height); + Tcl_AppendResult(interp, buffer, 0); + nBytePerRow = (width+7)/8; + for(i=0; i} imagemask \n", 0); + return TCL_OK; +} + /* *---------------------------------------------------------------------- * * ImgBmapPostscript -- * - * This procedure is called by the image code to create - * postscript output for an image. + * This procedure generates postscript for rendering a bitmap image. * * Results: - * None. + * On success, this routine writes postscript code into interp->result + * and returns TCL_OK TCL_ERROR is returned and an error + * message is left in interp->result if anything goes wrong. * * Side effects: * None. @@ -1130,75 +1223,75 @@ ImgBmapPostscript(clientData, interp, tkwin, psinfo, x, y, width, height, int x, y, width, height, prepass; { BitmapMaster *masterPtr = (BitmapMaster *) clientData; - int rowsAtOnce, rowsThisTime; - int curRow, yy; char buffer[200]; if (prepass) { return TCL_OK; } + /* - * Color the background, if there is one. + * There is nothing to do for bitmaps with zero width or height */ + if( width<=0 || height<=0 || masterPtr->width<=0 || masterPtr->height<=0 ){ + return TCL_OK; + } - if (masterPtr->bgUid != NULL) { + /* + * Translate the origin of the coordinate system to be the lower-left + * corner of the bitmap and adjust the scale of the coordinate system + * so that entire bitmap covers one square unit of the page. + * The calling function put a "gsave" into the postscript and + * will add a "grestore" at after this routine returns, so it is safe + * to make whatever changes are necessary here. + */ + if( x!=0 || y!=0 ){ + sprintf(buffer, "%d %d moveto\n", x, y); + Tcl_AppendResult(interp, buffer, 0); + } + if( width!=1 || height!=1 ){ + sprintf(buffer, "%d %d scale\n", width, height); + Tcl_AppendResult(interp, buffer, 0); + } + + /* + * Color the background, if there is one. This step is skipped if the + * background is transparent. If the background is not transparent and + * there is no background mask, then color the complete rectangle that + * encloses the bitmap. If there is a background mask, then only apply + * color to the bits specified by the mask. + */ + if ((masterPtr->bgUid != NULL) && (masterPtr->bgUid[0] != '\000')) { XColor color; XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->bgUid, &color); - sprintf(buffer, - "%d %d moveto %d 0 rlineto 0 %d rlineto %d %s\n", - x, y, width, height, -width,"0 rlineto closepath"); - Tcl_AppendResult(interp, buffer, (char *) NULL); if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) { return TCL_ERROR; } - Tcl_AppendResult(interp, "fill\n", (char *) NULL); + if (masterPtr->maskData == NULL) { + Tcl_AppendResult(interp, + "0 0 moveto 1 0 rlineto 0 1 rlineto -1 0 rlineto " + "closepath fill\n", 0 + ); + } else if (ImgBmapPsImagemask(interp, masterPtr->width, + masterPtr->height, masterPtr->maskData) != TCL_OK) { + return TCL_ERROR; + } } /* - * Draw the bitmap, if there is a foreground color. If the bitmap - * is very large, then chop it up into multiple bitmaps, each - * consisting of one or more rows. This is needed because Postscript - * can't handle single strings longer than 64 KBytes long. + * Draw the bitmap foreground, assuming there is one. */ - - if (masterPtr->fgUid != NULL) { + if ( (masterPtr->fgUid != NULL) && (masterPtr->data != NULL) ) { XColor color; XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->fgUid, &color); if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) { return TCL_ERROR; } - if (width > 60000) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "can't generate Postscript", - " for bitmaps more than 60000 pixels wide", - (char *) NULL); + if (ImgBmapPsImagemask(interp, masterPtr->width, masterPtr->height, + masterPtr->data) != TCL_OK) { return TCL_ERROR; } - rowsAtOnce = 60000/width; - if (rowsAtOnce < 1) { - rowsAtOnce = 1; - } - sprintf(buffer, "%d %d translate\n", x, y); - Tcl_AppendResult(interp, buffer, (char *) NULL); - for (curRow = y+height-1; curRow >= y; curRow -= rowsAtOnce) { - rowsThisTime = rowsAtOnce; - if (rowsThisTime > (curRow + 1 - y)) { - rowsThisTime = curRow + 1 - y; - } - sprintf(buffer, "%d %d", width, rowsThisTime); - Tcl_AppendResult(interp, buffer, " true matrix {\n<", - (char *) NULL); - for (yy = curRow; yy >= (curRow - rowsThisTime + 1); yy--) { - sprintf(buffer, "row %d\n", yy); - Tcl_AppendResult(interp, buffer, (char *) NULL); - } - sprintf(buffer, "0 %.15g", (double) rowsThisTime); - Tcl_AppendResult(interp, ">\n} imagemask\n", buffer, - " translate\n", (char *) NULL); - } } return TCL_OK; } - diff --git a/tk/generic/tkImgGIF.c b/tk/generic/tkImgGIF.c index f9588892b4a..632f900165f 100644 --- a/tk/generic/tkImgGIF.c +++ b/tk/generic/tkImgGIF.c @@ -19,14 +19,14 @@ * This file also contains code from the giftoppm program, which is * copyrighted as follows: * - * +-------------------------------------------------------------------+ - * | Copyright 1990, David Koblas. | - * | 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. This software is | - * | provided "as is" without express or implied warranty. | + * +--------------------------------------------------------------------+ + * | Copyright 1990, David Koblas. | + * | 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. This software is | + * | provided "as is" without express or implied warranty. | * +-------------------------------------------------------------------+ * * RCS: @(#) $Id$ @@ -41,7 +41,7 @@ * Any other invalid character is treated as an EOF */ -#define GIF_SPECIAL (256) +#define GIF_SPECIAL (256) #define GIF_PAD (GIF_SPECIAL+1) #define GIF_SPACE (GIF_SPECIAL+2) #define GIF_BAD (GIF_SPECIAL+3) @@ -72,13 +72,15 @@ typedef struct mFile { * encoding independant. */ -static CONST char GIF87a[] = - { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x00 }; /* ASCII GIF87a */ -static CONST char GIF89a[] = - { 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x00 }; /* ASCII GIF89a */ -# define GIF_TERMINATOR 0x3b /* ASCII ; */ -# define GIF_EXTENSION 0x21 /* ASCII ! */ -# define GIF_START 0x2c /* ASCII , */ +static CONST char GIF87a[] = { /* ASCII GIF87a */ + 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x00 +}; +static CONST char GIF89a[] = { /* ASCII GIF89a */ + 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x00 +}; +# define GIF_TERMINATOR 0x3b /* ASCII ; */ +# define GIF_EXTENSION 0x21 /* ASCII ! */ +# define GIF_START 0x2c /* ASCII , */ /* * HACK ALERT!! HACK ALERT!! HACK ALERT!! @@ -96,10 +98,10 @@ static Tcl_ThreadDataKey dataKey; * The format record for the GIF file format: */ -static int FileMatchGIF _ANSI_ARGS_((Tcl_Channel chan, CONST char *fileName, +static int FileMatchGIF _ANSI_ARGS_((Tcl_Channel chan, CONST char *fileName, Tcl_Obj *format, int *widthPtr, int *heightPtr, Tcl_Interp *interp)); -static int FileReadGIF _ANSI_ARGS_((Tcl_Interp *interp, +static int FileReadGIF _ANSI_ARGS_((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)); @@ -118,13 +120,13 @@ static int CommonWriteGIF _ANSI_ARGS_((Tcl_Interp *interp, Tk_PhotoImageBlock *blockPtr)); Tk_PhotoImageFormat tkImgFmtGIF = { - "gif", /* name */ - FileMatchGIF, /* fileMatchProc */ - StringMatchGIF, /* stringMatchProc */ - FileReadGIF, /* fileReadProc */ - StringReadGIF, /* stringReadProc */ - FileWriteGIF, /* fileWriteProc */ - NULL, /* stringWriteProc */ + "gif", /* name */ + FileMatchGIF, /* fileMatchProc */ + StringMatchGIF, /* stringMatchProc */ + FileReadGIF, /* fileReadProc */ + StringReadGIF, /* stringReadProc */ + FileWriteGIF, /* fileWriteProc */ + NULL, /* stringWriteProc */ }; #define INTERLACE 0x40 @@ -136,7 +138,7 @@ Tk_PhotoImageFormat tkImgFmtGIF = { #define CM_BLUE 2 #define CM_ALPHA 3 #define MAX_LWZ_BITS 12 -#define LM_to_uint(a,b) (((b)<<8)|(a)) +#define LM_to_uint(a,b) (((b)<<8)|(a)) #define ReadOK(file,buffer,len) (Fread(buffer, len, 1, file) != 0) /* @@ -216,7 +218,7 @@ FileMatchGIF(chan, fileName, format, widthPtr, heightPtr, interp) * * Results: * A standard TCL completion code. If TCL_ERROR is returned - * then an error message is left in interp->result. + * 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 @@ -249,7 +251,7 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, int bitPixel; unsigned char colorMap[MAXCOLORMAPSIZE][4]; int transparent = -1; - static char *optionStrings[] = { + static CONST char *optionStrings[] = { "-index", NULL }; @@ -288,7 +290,7 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, } bitPixel = 2<<(buf[0]&0x07); - if (BitSet(buf[0], LOCALCOLORMAP)) { /* Global Colormap */ + if (BitSet(buf[0], LOCALCOLORMAP)) { /* Global Colormap */ if (!ReadColorMap(chan, bitPixel, colorMap)) { Tcl_AppendResult(interp, "error reading color map", (char *) NULL); @@ -345,12 +347,14 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, */ if (Fread(buf, 1, 1, chan) != 1) { - interp->result = - "error reading extension function code in GIF image"; + Tcl_SetResult(interp, + "error reading extension function code in GIF image", + TCL_STATIC); goto error; } if (DoExtension(chan, buf[0], &transparent) < 0) { - interp->result = "error reading extension in GIF image"; + Tcl_SetResult(interp, "error reading extension in GIF image", + TCL_STATIC); goto error; } continue; @@ -364,7 +368,9 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, } if (Fread(buf, 1, 9, chan) != 9) { - interp->result = "couldn't read left/top/width/height in GIF image"; + Tcl_SetResult(interp, + "couldn't read left/top/width/height in GIF image", + TCL_STATIC); goto error; } @@ -374,7 +380,9 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, bitPixel = 1<<((buf[8]&0x07)+1); if (index--) { - /* this is not the image we want to read: skip it. */ + /* + * This is not the image we want to read: skip it. + */ if (BitSet(buf[8], LOCALCOLORMAP)) { if (!ReadColorMap(chan, bitPixel, colorMap)) { Tcl_AppendResult(interp, @@ -383,7 +391,9 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, } } - /* If we've not yet allocated a trash buffer, do so now */ + /* + * If we've not yet allocated a trash buffer, do so now. + */ if (trashBuffer == NULL) { nBytes = fileWidth * fileHeight * 3; trashBuffer = @@ -391,28 +401,32 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, } /* - * Slurp! Process the data for this image and stuff it in a - * trash buffer. + * Slurp! Process the data for this image and stuff it in + * a trash buffer. * - * Yes, it might be more efficient here to *not* store the data - * (we're just going to throw it away later). However, I elected - * to implement it this way for good reasons. First, I wanted to - * avoid duplicating the (fairly complex) LWZ decoder in ReadImage. - * Fine, you say, why didn't you just modify it to allow the use of - * a NULL specifier for the output buffer? I tried that, but it - * negatively impacted the performance of what I think will be the - * common case: reading the first image in the file. Rather than - * marginally improve the speed of the less frequent case, I chose - * to maintain high performance for the common case. + * Yes, it might be more efficient here to *not* store the + * data (we're just going to throw it away later). + * However, I elected to implement it this way for good + * reasons. First, I wanted to avoid duplicating the + * (fairly complex) LWZ decoder in ReadImage. Fine, you + * say, why didn't you just modify it to allow the use of + * a NULL specifier for the output buffer? I tried that, + * but it negatively impacted the performance of what I + * think will be the common case: reading the first image + * in the file. Rather than marginally improve the speed + * of the less frequent case, I chose to maintain high + * performance for the common case. */ if (ReadImage(interp, (char *) trashBuffer, chan, fileWidth, - fileHeight, colorMap, 0, 0, 0, 0, 0, -1) != TCL_OK) { - goto error; + fileHeight, colorMap, 0, 0, 0, 0, 0, -1) != TCL_OK) { + goto error; } continue; } - /* If a trash buffer has been allocated, free it now */ + /* + * If a trash buffer has been allocated, free it now. + */ if (trashBuffer != NULL) { ckfree((char *)trashBuffer); trashBuffer = NULL; @@ -455,19 +469,20 @@ FileReadGIF(interp, chan, fileName, format, imageHandle, destX, destY, block.height = height; block.pixelSize = (transparent>=0) ? 4 : 3; block.offset[3] = (transparent>=0) ? 3 : 0; - block.pitch = block.pixelSize * width; - nBytes = block.pitch * height; + block.pitch = block.pixelSize * fileWidth; + nBytes = block.pitch * fileHeight; block.pixelPtr = (unsigned char *) ckalloc((unsigned) nBytes); - if (ReadImage(interp, (char *) block.pixelPtr, chan, width, - height, colorMap, fileWidth, fileHeight, srcX, srcY, + if (ReadImage(interp, (char *) block.pixelPtr, chan, fileWidth, + fileHeight, colorMap, fileWidth, fileHeight, srcX, srcY, BitSet(buf[8], INTERLACE), transparent) != TCL_OK) { goto error; } break; } - Tk_PhotoPutBlock(imageHandle, &block, destX, destY, width, height); + Tk_PhotoPutBlock(imageHandle, &block, destX, destY, width, height, + TK_PHOTO_COMPOSITE_SET); noerror: if (block.pixelPtr) { @@ -516,25 +531,31 @@ StringMatchGIF(dataObj, format, widthPtr, heightPtr, interp) data = Tcl_GetByteArrayFromObj(dataObj, &length); - /* Header is a minimum of 10 bytes */ + /* + * Header is a minimum of 10 bytes. + */ if (length < 10) { - return 0; + return 0; } - /* Check whether the data is Base64 encoded */ + /* + * Check whether the data is Base64 encoded. + */ if ((strncmp(GIF87a, (char *) data, 6) != 0) && - (strncmp(GIF89a, (char *) data, 6) != 0)) { - /* Try interpreting the data as Base64 encoded */ - mInit((unsigned char *) data, &handle); - got = Mread(header, 10, 1, &handle); - if (got != 10 - || ((strncmp(GIF87a, (char *) header, 6) != 0) - && (strncmp(GIF89a, (char *) header, 6) != 0))) { - return 0; - } + (strncmp(GIF89a, (char *) data, 6) != 0)) { + /* + * Try interpreting the data as Base64 encoded + */ + mInit((unsigned char *) data, &handle); + got = Mread(header, 10, 1, &handle); + if (got != 10 + || ((strncmp(GIF87a, (char *) header, 6) != 0) + && (strncmp(GIF89a, (char *) header, 6) != 0))) { + return 0; + } } else { - memcpy((VOID *) header, (VOID *) data, 10); + memcpy((VOID *) header, (VOID *) data, 10); } *widthPtr = LM_to_uint(header[6],header[7]); *heightPtr = LM_to_uint(header[8],header[9]); @@ -552,7 +573,7 @@ StringMatchGIF(dataObj, format, widthPtr, heightPtr, interp) * * Results: * A standard TCL completion code. If TCL_ERROR is returned - * then an error message is left in interp->result. + * then an error message is left in the interp's result. * * Side effects: * new data is added to the image given by imageHandle. This @@ -570,13 +591,13 @@ StringReadGIF(interp, dataObj, format, imageHandle, Tcl_Obj *format; /* format object, or NULL */ Tk_PhotoHandle imageHandle; /* the image to write this data into */ int destX, destY; /* The rectangular region of the */ - int width, height; /* image to copy */ + int width, height; /* image to copy */ int srcX, srcY; { int result; MFile handle; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); Tcl_Channel dataSrc; char *data; @@ -584,8 +605,7 @@ StringReadGIF(interp, dataObj, format, imageHandle, * Check whether the data is Base64 encoded */ data = (char *) Tcl_GetByteArrayFromObj(dataObj, NULL); - if ((strncmp(GIF87a, data, 6) != 0) && - (strncmp(GIF89a, data, 6) != 0)) { + if ((strncmp(GIF87a, data, 6) != 0) && (strncmp(GIF89a, data, 6) != 0)) { mInit((unsigned char *)data, &handle); tsdPtr->fromData = 1; dataSrc = (Tcl_Channel) &handle; @@ -597,7 +617,7 @@ StringReadGIF(interp, dataObj, format, imageHandle, result = FileReadGIF(interp, dataSrc, "inline data", format, imageHandle, destX, destY, width, height, srcX, srcY); tsdPtr->fromData = 0; - return(result); + return result; } /* @@ -652,65 +672,65 @@ ReadGIFHeader(chan, widthPtr, heightPtr) static int ReadColorMap(chan, number, buffer) - Tcl_Channel chan; - int number; - unsigned char buffer[MAXCOLORMAPSIZE][4]; + Tcl_Channel chan; + int number; + unsigned char buffer[MAXCOLORMAPSIZE][4]; { - int i; - unsigned char rgb[3]; + int i; + unsigned char rgb[3]; - for (i = 0; i < number; ++i) { - if (! ReadOK(chan, rgb, sizeof(rgb))) { - return 0; - } - - if (buffer) { - buffer[i][CM_RED] = rgb[0] ; - buffer[i][CM_GREEN] = rgb[1] ; - buffer[i][CM_BLUE] = rgb[2] ; - buffer[i][CM_ALPHA] = 255 ; - } + for (i = 0; i < number; ++i) { + if (! ReadOK(chan, rgb, sizeof(rgb))) { + return 0; } - return 1; + + if (buffer) { + buffer[i][CM_RED] = rgb[0] ; + buffer[i][CM_GREEN] = rgb[1] ; + buffer[i][CM_BLUE] = rgb[2] ; + buffer[i][CM_ALPHA] = 255 ; + } + } + return 1; } static int DoExtension(chan, label, transparent) - Tcl_Channel chan; - int label; - int *transparent; + Tcl_Channel chan; + int label; + int *transparent; { static unsigned char buf[256]; int count; switch (label) { - case 0x01: /* Plain Text Extension */ - break; - - case 0xff: /* Application Extension */ - break; + case 0x01: /* Plain Text Extension */ + break; - case 0xfe: /* Comment Extension */ - do { - count = GetDataBlock(chan, (unsigned char*) buf); - } while (count > 0); - return count; + case 0xff: /* Application Extension */ + break; - case 0xf9: /* Graphic Control Extension */ + case 0xfe: /* Comment Extension */ + do { count = GetDataBlock(chan, (unsigned char*) buf); - if (count < 0) { - return 1; - } - if ((buf[0] & 0x1) != 0) { - *transparent = buf[3]; - } + } while (count > 0); + return count; + + case 0xf9: /* Graphic Control Extension */ + count = GetDataBlock(chan, (unsigned char*) buf); + if (count < 0) { + return 1; + } + if ((buf[0] & 0x1) != 0) { + *transparent = buf[3]; + } - do { - count = GetDataBlock(chan, (unsigned char*) buf); - } while (count > 0); - return count; + do { + count = GetDataBlock(chan, (unsigned char*) buf); + } while (count > 0); + return count; } do { @@ -723,8 +743,8 @@ static int ZeroDataBlock = 0; static int GetDataBlock(chan, buf) - Tcl_Channel chan; - unsigned char *buf; + Tcl_Channel chan; + unsigned char *buf; { unsigned char count; @@ -749,17 +769,17 @@ GetDataBlock(chan, buf) * ReadImage -- * * Process a GIF image from a given source, with a given height, - * width, transparency, etc. + * width, transparency, etc. * - * This code is based on the code found in the ImageMagick GIF decoder, - * which is (c) 2000 ImageMagick Studio. + * This code is based on the code found in the ImageMagick GIF decoder, + * which is (c) 2000 ImageMagick Studio. * - * Some thoughts on our implementation: - * It sure would be nice if ReadImage didn't take 11 parameters! I think - * that if we were smarter, we could avoid doing that. + * Some thoughts on our implementation: + * It sure would be nice if ReadImage didn't take 11 parameters! I think + * that if we were smarter, we could avoid doing that. * - * Possible further optimizations: we could pull the GetCode function - * directly into ReadImage, which would improve our speed. + * Possible further optimizations: we could pull the GetCode function + * directly into ReadImage, which would improve our speed. * * Results: * Processes a GIF image and loads the pixel data into a memory array. @@ -773,15 +793,15 @@ GetDataBlock(chan, buf) static int ReadImage(interp, imagePtr, chan, len, rows, cmap, width, height, srcX, srcY, interlace, transparent) - Tcl_Interp *interp; - char *imagePtr; - Tcl_Channel chan; - int len, rows; - unsigned char cmap[MAXCOLORMAPSIZE][4]; - int width, height; - int srcX, srcY; - int interlace; - int transparent; + Tcl_Interp *interp; + char *imagePtr; + Tcl_Channel chan; + int len, rows; + unsigned char cmap[MAXCOLORMAPSIZE][4]; + int width, height; + int srcX, srcY; + int interlace; + int transparent; { unsigned char initialCodeSize; int v; @@ -793,9 +813,9 @@ ReadImage(interp, imagePtr, chan, len, rows, cmap, unsigned char append[(1 << MAX_LWZ_BITS)]; unsigned char stack[(1 << MAX_LWZ_BITS)*2]; register unsigned char *top; - int codeSize, clearCode, inCode, endCode, oldCode, maxCode, - code, firstCode; - + int codeSize, clearCode, inCode, endCode, oldCode, maxCode; + int code, firstCode; + /* * Initialize the decoder */ @@ -804,7 +824,7 @@ ReadImage(interp, imagePtr, chan, len, rows, cmap, Tcl_PosixError(interp), (char *) NULL); return TCL_ERROR; } - if (transparent!=-1) { + if (transparent != -1) { cmap[transparent][CM_RED] = 0; cmap[transparent][CM_GREEN] = 0; cmap[transparent][CM_BLUE] = 0; @@ -813,19 +833,21 @@ ReadImage(interp, imagePtr, chan, len, rows, cmap, pixelPtr = imagePtr; - /* Initialize the decoder */ - /* Set values for "special" numbers: + /* + * Initialize the decoder. + * + * Set values for "special" numbers: * clear code reset the decoder * end code stop decoding * code size size of the next code to retrieve * max code next available table position */ - clearCode = 1 << (int) initialCodeSize; - endCode = clearCode + 1; - codeSize = (int) initialCodeSize + 1; - maxCode = clearCode + 2; - oldCode = -1; - firstCode = -1; + clearCode = 1 << (int) initialCodeSize; + endCode = clearCode + 1; + codeSize = (int) initialCodeSize + 1; + maxCode = clearCode + 2; + oldCode = -1; + firstCode = -1; memset((void *)prefix, 0, (1 << MAX_LWZ_BITS) * sizeof(short)); memset((void *)append, 0, (1 << MAX_LWZ_BITS) * sizeof(char)); @@ -836,12 +858,16 @@ ReadImage(interp, imagePtr, chan, len, rows, cmap, GetCode(chan, 0, 1); - /* Read until we finish the image */ + /* + * Read until we finish the image + */ for (i = 0, ypos = 0; i < rows; i++) { for (xpos = 0; xpos < len; ) { if (top == stack) { - /* Bummer -- our stack is empty. Now we have to work! */ + /* + * Bummer -- our stack is empty. Now we have to work! + */ code = GetCode(chan, codeSize, 0); if (code < 0) { return TCL_OK; @@ -860,10 +886,12 @@ ReadImage(interp, imagePtr, chan, len, rows, cmap, } if (code == clearCode) { - /* Reset the decoder */ - codeSize = initialCodeSize + 1; - maxCode = clearCode + 2; - oldCode = -1; + /* + * Reset the decoder. + */ + codeSize = initialCodeSize + 1; + maxCode = clearCode + 2; + oldCode = -1; continue; } @@ -876,7 +904,7 @@ ReadImage(interp, imagePtr, chan, len, rows, cmap, * roll this into the clearCode test above, because * at that point we have not yet read the next code. */ - *top++=append[code]; + *top++ = append[code]; oldCode = code; firstCode = code; continue; @@ -912,15 +940,20 @@ ReadImage(interp, imagePtr, chan, len, rows, cmap, return TCL_OK; } - /* Push the head of the string onto the stack */ + /* + * Push the head of the string onto the stack. + */ *top++ = firstCode; - /* Add a new string to the string table */ + /* + * Add a new string to the string table + */ prefix[maxCode] = oldCode; append[maxCode] = firstCode; maxCode++; - /* maxCode tells us the maximum code value we can accept. + /* + * maxCode tells us the maximum code value we can accept. * If we see that we need more bits to represent it than * we are requesting from the unpacker, we need to increase * the number we ask for. @@ -932,7 +965,9 @@ ReadImage(interp, imagePtr, chan, len, rows, cmap, oldCode = inCode; } - /* Pop the next color index off the stack */ + /* + * Pop the next color index off the stack. + */ v = *(--top); if (v < 0) { return TCL_OK; @@ -953,7 +988,9 @@ ReadImage(interp, imagePtr, chan, len, rows, cmap, } - /* If interlacing, the next ypos is not just +1 */ + /* + * If interlacing, the next ypos is not just +1 + */ if (interlace) { ypos += interlaceStep[pass]; while (ypos >= height) { @@ -977,23 +1014,23 @@ ReadImage(interp, imagePtr, chan, len, rows, cmap, * * GetCode -- * - * Extract the next compression code from the file. In GIF's, the - * compression codes are between 3 and 12 bits long and are then - * packed into 8 bit bytes, left to right, for example: - * bbbaaaaa - * dcccccbb - * eeeedddd - * ... - * We use a byte buffer read from the file and a sliding window - * to unpack the bytes. Thanks to ImageMagick for the sliding window - * idea. - * args: chan the channel to read from - * code_size size of the code to extract - * flag boolean indicating whether the extractor - * should be reset or not + * Extract the next compression code from the file. In GIF's, the + * compression codes are between 3 and 12 bits long and are then + * packed into 8 bit bytes, left to right, for example: + * bbbaaaaa + * dcccccbb + * eeeedddd + * ... + * We use a byte buffer read from the file and a sliding window + * to unpack the bytes. Thanks to ImageMagick for the sliding window + * idea. + * args: chan the channel to read from + * code_size size of the code to extract + * flag boolean indicating whether the extractor + * should be reset or not * * Results: - * code the next compression code + * code the next compression code * * Side effects: * May consume more input from chan. @@ -1003,9 +1040,9 @@ ReadImage(interp, imagePtr, chan, len, rows, cmap, static int GetCode(chan, code_size, flag) - Tcl_Channel chan; - int code_size; - int flag; + Tcl_Channel chan; + int code_size; + int flag; { static unsigned char buf[280]; static int bytes = 0, done; @@ -1016,7 +1053,9 @@ GetCode(chan, code_size, flag) int ret; if (flag) { - /* Initialize the decoder */ + /* + * Initialize the decoder. + */ bitsInWindow = 0; bytes = 0; window = 0; @@ -1026,12 +1065,16 @@ GetCode(chan, code_size, flag) } while (bitsInWindow < code_size) { - /* Not enough bits in our window to cover the request */ + /* + * Not enough bits in our window to cover the request. + */ if (done) { return -1; } if (bytes == 0) { - /* Not enough bytes in our buffer to add to the window */ + /* + * Not enough bytes in our buffer to add to the window. + */ bytes = GetDataBlock(chan, buf); c = buf; if (bytes <= 0) { @@ -1039,17 +1082,24 @@ GetCode(chan, code_size, flag) break; } } - /* Tack another byte onto the window, see if that's enough */ + /* + * Tack another byte onto the window, see if that's enough. + */ window += (*c) << bitsInWindow; c++; bitsInWindow += 8; bytes--; } - /* The next code will always be the last code_size bits of the window */ + + /* + * The next code will always be the last code_size bits of the window. + */ ret = window & ((1 << code_size) - 1); - /* Shift data in the window to put the next code at the end */ + /* + * Shift data in the window to put the next code at the end. + */ window >>= code_size; bitsInWindow -= code_size; return ret; @@ -1139,45 +1189,45 @@ Mread(dst, chunkSize, numChunks, handle) static int Mgetc(handle) - MFile *handle; /* Handle containing decoder data and state. */ + MFile *handle; /* Handle containing decoder data and state */ { int c; int result = 0; /* Initialization needed only to prevent * gcc compiler warning. */ - + if (handle->state == GIF_DONE) { - return(GIF_DONE); + return GIF_DONE; } do { c = char64(*handle->data); handle->data++; - } while (c==GIF_SPACE); + } while (c == GIF_SPACE); if (c>GIF_SPECIAL) { handle->state = GIF_DONE; - return(handle->state ? handle->c : GIF_DONE); + return handle->c; } switch (handle->state++) { - case 0: - handle->c = c<<2; - result = Mgetc(handle); - break; - case 1: - result = handle->c | (c>>4); - handle->c = (c&0xF)<<4; - break; - case 2: - result = handle->c | (c>>2); - handle->c = (c&0x3) << 6; - break; - case 3: - result = handle->c | c; - handle->state = 0; - break; - } - return(result); + case 0: + handle->c = c<<2; + result = Mgetc(handle); + break; + case 1: + result = handle->c | (c>>4); + handle->c = (c&0xF)<<4; + break; + case 2: + result = handle->c | (c>>2); + handle->c = (c&0x3) << 6; + break; + case 3: + result = handle->c | c; + handle->state = 0; + break; + } + return result; } /* @@ -1202,33 +1252,37 @@ char64(c) int c; { switch(c) { - case 'A': return(0); case 'B': return(1); case 'C': return(2); - case 'D': return(3); case 'E': return(4); case 'F': return(5); - case 'G': return(6); case 'H': return(7); case 'I': return(8); - case 'J': return(9); case 'K': return(10); case 'L': return(11); - case 'M': return(12); case 'N': return(13); case 'O': return(14); - case 'P': return(15); case 'Q': return(16); case 'R': return(17); - case 'S': return(18); case 'T': return(19); case 'U': return(20); - case 'V': return(21); case 'W': return(22); case 'X': return(23); - case 'Y': return(24); case 'Z': return(25); case 'a': return(26); - case 'b': return(27); case 'c': return(28); case 'd': return(29); - case 'e': return(30); case 'f': return(31); case 'g': return(32); - case 'h': return(33); case 'i': return(34); case 'j': return(35); - case 'k': return(36); case 'l': return(37); case 'm': return(38); - case 'n': return(39); case 'o': return(40); case 'p': return(41); - case 'q': return(42); case 'r': return(43); case 's': return(44); - case 't': return(45); case 'u': return(46); case 'v': return(47); - case 'w': return(48); case 'x': return(49); case 'y': return(50); - case 'z': return(51); case '0': return(52); case '1': return(53); - case '2': return(54); case '3': return(55); case '4': return(56); - case '5': return(57); case '6': return(58); case '7': return(59); - case '8': return(60); case '9': return(61); case '+': return(62); - case '/': return(63); - - case ' ': case '\t': case '\n': case '\r': case '\f': return(GIF_SPACE); - case '=': return(GIF_PAD); - case '\0': return(GIF_DONE); - default: return(GIF_BAD); + case 'A': return 0; case 'B': return 1; case 'C': return 2; + case 'D': return 3; case 'E': return 4; case 'F': return 5; + case 'G': return 6; case 'H': return 7; case 'I': return 8; + case 'J': return 9; case 'K': return 10; case 'L': return 11; + case 'M': return 12; case 'N': return 13; case 'O': return 14; + case 'P': return 15; case 'Q': return 16; case 'R': return 17; + case 'S': return 18; case 'T': return 19; case 'U': return 20; + case 'V': return 21; case 'W': return 22; case 'X': return 23; + case 'Y': return 24; case 'Z': return 25; case 'a': return 26; + case 'b': return 27; case 'c': return 28; case 'd': return 29; + case 'e': return 30; case 'f': return 31; case 'g': return 32; + case 'h': return 33; case 'i': return 34; case 'j': return 35; + case 'k': return 36; case 'l': return 37; case 'm': return 38; + case 'n': return 39; case 'o': return 40; case 'p': return 41; + case 'q': return 42; case 'r': return 43; case 's': return 44; + case 't': return 45; case 'u': return 46; case 'v': return 47; + case 'w': return 48; case 'x': return 49; case 'y': return 50; + case 'z': return 51; case '0': return 52; case '1': return 53; + case '2': return 54; case '3': return 55; case '4': return 56; + case '5': return 57; case '6': return 58; case '7': return 59; + case '8': return 60; case '9': return 61; case '+': return 62; + case '/': return 63; + + case ' ': case '\t': case '\n': case '\r': case '\f': + return GIF_SPACE; + case '=': + return GIF_PAD; + case '\0': + return GIF_DONE; + default: + return GIF_BAD; } } @@ -1252,18 +1306,18 @@ Fread(dst, hunk, count, chan) Tcl_Channel chan; { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); MFile *handle; switch (tsdPtr->fromData) { - case 1: - return(Mread(dst, hunk, count, (MFile *) chan)); - case 2: + case 1: + return Mread(dst, hunk, count, (MFile *) chan); + case 2: handle = (MFile *) chan; memcpy((VOID *)dst, (VOID *) handle->data, (size_t) (hunk * count)); handle->data += hunk * count; - return((int) (hunk * count)); - default: + return (int)(hunk * count); + default: return Tcl_Read(chan, (char *) dst, (int) (hunk * count)); } } @@ -1272,13 +1326,13 @@ Fread(dst, hunk, count, chan) /* * ChanWriteGIF - writes a image in GIF format. *------------------------------------------------------------------------- - * Author: Lolo - * Engeneering Projects Area - * Department of Mining - * University of Oviedo + * Author: Lolo + * Engeneering Projects Area + * Department of Mining + * University of Oviedo * e-mail zz11425958@zeus.etsimo.uniovi.es - * lolo@pcsig22.etsimo.uniovi.es - * Date: Fri September 20 1996 + * lolo@pcsig22.etsimo.uniovi.es + * Date: Fri September 20 1996 * * Modified for transparency handling (gif89a) and miGIF compression * by Jan Nijtmans @@ -1302,11 +1356,11 @@ Fread(dst, hunk, count, chan) typedef int (* ifunptr) _ANSI_ARGS_((void)); -#define LSB(a) ((unsigned char) (((short)(a)) & 0x00FF)) -#define MSB(a) ((unsigned char) (((short)(a)) >> 8)) +#define LSB(a) ((unsigned char) (((short)(a)) & 0x00FF)) +#define MSB(a) ((unsigned char) (((short)(a)) >> 8)) #define GIFBITS 12 -#define HSIZE 5003 /* 80% occupancy */ +#define HSIZE 5003 /* 80% occupancy */ static int ssize; static int csize; @@ -1335,7 +1389,7 @@ static void savemap _ANSI_ARGS_((Tk_PhotoImageBlock *blockPtr, static int ReadValue _ANSI_ARGS_((void)); static int -FileWriteGIF (interp, filename, format, blockPtr) +FileWriteGIF(interp, filename, format, blockPtr) Tcl_Interp *interp; /* Interpreter to use for reporting errors. */ CONST char *filename; Tcl_Obj *format; @@ -1349,6 +1403,7 @@ FileWriteGIF (interp, filename, format, blockPtr) return TCL_ERROR; } if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) { + Tcl_Close(NULL, chan); return TCL_ERROR; } @@ -1377,9 +1432,9 @@ CommonWriteGIF(interp, handle, format, blockPtr) top = 0; left = 0; - pixelSize=blockPtr->pixelSize; - greenOffset=blockPtr->offset[1]-blockPtr->offset[0]; - blueOffset=blockPtr->offset[2]-blockPtr->offset[0]; + pixelSize = blockPtr->pixelSize; + greenOffset = blockPtr->offset[1]-blockPtr->offset[0]; + blueOffset = blockPtr->offset[2]-blockPtr->offset[0]; alphaOffset = blockPtr->offset[0]; if (alphaOffset < blockPtr->offset[2]) { alphaOffset = blockPtr->offset[2]; @@ -1392,30 +1447,32 @@ CommonWriteGIF(interp, handle, format, blockPtr) Tcl_Write(handle, (char *) (alphaOffset ? GIF89a : GIF87a), 6); - for (x=0;xwidth; - height=blockPtr->height; - pixelo=blockPtr->pixelPtr + blockPtr->offset[0]; - pixelPitch=blockPtr->pitch; + width = blockPtr->width; + height = blockPtr->height; + pixelo = blockPtr->pixelPtr + blockPtr->offset[0]; + pixelPitch = blockPtr->pitch; savemap(blockPtr,mapa); - if (num>=MAXCOLORMAPSIZE) { + if (num >= MAXCOLORMAPSIZE) { Tcl_AppendResult(interp, "too many colors", (char *) NULL); return TCL_ERROR; } - if (num<2) num=2; - c=LSB(width); + if (num<2) { + num = 2; + } + c = LSB(width); Mputc(c,handle); - c=MSB(width); + c = MSB(width); Mputc(c,handle); - c=LSB(height); + c = LSB(height); Mputc(c,handle); - c=MSB(height); + c = MSB(height); Mputc(c,handle); resolution = 0; @@ -1427,16 +1484,20 @@ CommonWriteGIF(interp, handle, format, blockPtr) num = 1 << resolution; - /* background color */ + /* + * background color + */ c = 0; Mputc(c,handle); - /* zero for future expansion */ + /* + * zero for future expansion. + */ Mputc(c,handle); - for (x=0; xwidth; @@ -1501,9 +1562,9 @@ color(red, green, blue, mapa) unsigned char mapa[MAXCOLORMAPSIZE][3]; { int x; - for (x=(alphaOffset != 0);x<=MAXCOLORMAPSIZE;x++) { - if ((mapa[x][CM_RED]==red) && (mapa[x][CM_GREEN]==green) && - (mapa[x][CM_BLUE]==blue)) { + for (x=(alphaOffset != 0) ; x<=MAXCOLORMAPSIZE ; x++) { + if ((mapa[x][CM_RED] == red) && (mapa[x][CM_GREEN] == green) && + (mapa[x][CM_BLUE] == blue)) { return x; } } @@ -1516,10 +1577,10 @@ nuevo(red, green, blue, mapa) int red,green,blue; unsigned char mapa[MAXCOLORMAPSIZE][3]; { - int x; - for (x=(alphaOffset != 0);x<=num;x++) { - if ((mapa[x][CM_RED]==red) && (mapa[x][CM_GREEN]==green) && - (mapa[x][CM_BLUE]==blue)) { + int x = (alphaOffset != 0); + for (; x<=num ; x++) { + if ((mapa[x][CM_RED] == red) && (mapa[x][CM_GREEN] == green) && + (mapa[x][CM_BLUE] == blue)) { return 0; } } @@ -1531,9 +1592,9 @@ savemap(blockPtr,mapa) Tk_PhotoImageBlock *blockPtr; unsigned char mapa[MAXCOLORMAPSIZE][3]; { - unsigned char *colores; + unsigned char *colores; int x,y; - unsigned char red,green,blue; + unsigned char red,green,blue; if (alphaOffset) { num = 0; @@ -1544,22 +1605,22 @@ savemap(blockPtr,mapa) num = -1; } - for(y=0;yheight;y++) { - colores=blockPtr->pixelPtr + blockPtr->offset[0] + for(y=0 ; yheight ; y++) { + colores = blockPtr->pixelPtr + blockPtr->offset[0] + y * blockPtr->pitch; - for(x=0;xwidth;x++) { + for(x=0 ; xwidth ; x++) { if (!alphaOffset || (colores[alphaOffset] != 0)) { red = colores[0]; green = colores[greenOffset]; blue = colores[blueOffset]; if (nuevo(red,green,blue,mapa)) { num++; - if (num>=MAXCOLORMAPSIZE) { + if (num >= MAXCOLORMAPSIZE) { return; } - mapa[num][CM_RED]=red; - mapa[num][CM_GREEN]=green; - mapa[num][CM_BLUE]=blue; + mapa[num][CM_RED] = red; + mapa[num][CM_GREEN] = green; + mapa[num][CM_BLUE] = blue; } } colores += pixelSize; @@ -1576,10 +1637,10 @@ ReadValue() if (csize == 0) { return EOF; } - if (alphaOffset && (pixelo[alphaOffset]==0)) { + if (alphaOffset && (pixelo[alphaOffset] == 0)) { col = 0; } else { - col = color(pixelo[0],pixelo[greenOffset],pixelo[blueOffset], mapa); + col = color(pixelo[0], pixelo[greenOffset], pixelo[blueOffset], mapa); } pixelo += pixelSize; if (--ssize <= 0) { @@ -1593,48 +1654,53 @@ ReadValue() -/*----------------------------------------------------------------------- +/* + *----------------------------------------------------------------------- * * miGIF Compression - mouse and ivo's GIF-compatible compression * - * -run length encoding compression routines- + * -run length encoding compression routines- * * Copyright (C) 1998 Hutchison Avenue Software Corporation - * http://www.hasc.com - * info@hasc.com - * - * 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. This software is provided "AS IS." The Hutchison Avenue - * Software Corporation disclaims all warranties, either express or implied, - * including but not limited to implied warranties of merchantability and - * fitness for a particular purpose, with respect to this code and accompanying - * documentation. + * http://www.hasc.com + * info@hasc.com + * + * 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. This software is + * provided "AS IS." The Hutchison Avenue Software Corporation + * disclaims all warranties, either express or implied, including but + * not limited to implied warranties of merchantability and fitness + * for a particular purpose, with respect to this code and + * accompanying documentation. * - * The miGIF compression routines do not, strictly speaking, generate files - * conforming to the GIF spec, since the image data is not LZW-compressed - * (this is the point: in order to avoid transgression of the Unisys patent - * on the LZW algorithm.) However, miGIF generates data streams that any - * reasonably sane LZW decompresser will decompress to what we want. - * - * miGIF compression uses run length encoding. It compresses horizontal runs - * of pixels of the same color. This type of compression gives good results - * on images with many runs, for example images with lines, text and solid - * shapes on a solid-colored background. It gives little or no compression - * on images with few runs, for example digital or scanned photos. - * - * der Mouse - * mouse@rodents.montreal.qc.ca - * 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B - * - * ivo@hasc.com + * The miGIF compression routines do not, strictly speaking, generate + * files conforming to the GIF spec, since the image data is not + * LZW-compressed (this is the point: in order to avoid transgression + * of the Unisys patent on the LZW algorithm.) However, miGIF + * generates data streams that any reasonably sane LZW decompresser + * will decompress to what we want. + * + * miGIF compression uses run length encoding. It compresses + * horizontal runs of pixels of the same color. This type of + * compression gives good results on images with many runs, for + * example images with lines, text and solid shapes on a solid-colored + * background. It gives little or no compression on images with few + * runs, for example digital or scanned photos. + * + * der Mouse + * mouse@rodents.montreal.qc.ca + * 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B + * + * ivo@hasc.com * * The Graphics Interchange Format(c) is the Copyright property of * CompuServe Incorporated. GIF(sm) is a Service Mark property of * CompuServe Incorporated. * + *----------------------------------------------------------------------- */ static int rl_pixel; @@ -1659,145 +1725,172 @@ static Tcl_Channel ofile; static unsigned char oblock[256]; static int oblen; -/* Used only when debugging GIF compression code */ -/* #define DEBUGGING_ENVARS */ +/* + * Used only when debugging GIF compression code + */ +/* #define MIGIF_DEBUGGING_ENVARS */ -#ifdef DEBUGGING_ENVARS +#ifdef MIGIF_DEBUGGING_ENVARS static int verbose_set = 0; static int verbose; -#define VERBOSE (verbose_set?verbose:set_verbose()) +#define MIGIF_VERBOSE (verbose_set?verbose:set_verbose()) +#define DEBUGMSG(printf_args) if (MIGIF_VERBOSE) { printf printf_args; } -static int set_verbose(void) +static int +set_verbose(void) { - verbose = !!getenv("GIF_VERBOSE"); - verbose_set = 1; - return(verbose); + verbose = !!getenv("MIGIF_VERBOSE"); + verbose_set = 1; + return verbose; } -#else - -#define VERBOSE 0 - -#endif - - static CONST char * binformat(v, nbits) unsigned int v; int nbits; { - static char bufs[8][64]; - static int bhand = 0; - unsigned int bit; - int bno; - char *bp; - - bhand --; - if (bhand < 0) bhand = (sizeof(bufs)/sizeof(bufs[0]))-1; - bp = &bufs[bhand][0]; - for (bno=nbits-1,bit=((unsigned int)1)<=0;bno--,bit>>=1) - { *bp++ = (v & bit) ? '1' : '0'; - if (((bno&3) == 0) && (bno != 0)) *bp++ = '.'; - } - *bp = '\0'; - return(&bufs[bhand][0]); + static char bufs[8][64]; + static int bhand = 0; + unsigned int bit; + int bno; + char *bp; + + bhand--; + if (bhand < 0) { + bhand = (sizeof(bufs) / sizeof(bufs[0])) - 1; + } + bp = &bufs[bhand][0]; + for (bno=nbits-1,bit=((unsigned int)1)<=0 ; bno--,bit>>=1) { + *bp++ = (v & bit) ? '1' : '0'; + if (((bno&3) == 0) && (bno != 0)) { + *bp++ = '.'; + } + } + *bp = '\0'; + return &bufs[bhand][0]; } -static void write_block() +#else + +#define MIGIF_VERBOSE 0 +#define DEBUGMSG(printf_args) /* do nothing */ + +#endif + +static void +write_block() { - int i; - unsigned char c; - - if (VERBOSE) - { printf("write_block %d:",oblen); - for (i=0;i= 255) write_block(); + DEBUGMSG(("block_out %s\n", binformat(c, 8))); + oblock[oblen++] = c; + if (oblen >= 255) { + write_block(); + } } -static void block_flush() +static void +block_flush() { - if (VERBOSE) printf("block_flush\n"); - if (oblen > 0) write_block(); + DEBUGMSG(("block_flush\n")); + if (oblen > 0) { + write_block(); + } } -static void output(val) +static void +output(val) int val; { - if (VERBOSE) printf("output %s [%s %d %d]\n",binformat(val,out_bits),binformat(obuf,obits),obits,out_bits); - obuf |= val << obits; - obits += out_bits; - while (obits >= 8) - { block_out(obuf&0xff); - obuf >>= 8; - obits -= 8; - } - if (VERBOSE) printf("output leaving [%s %d]\n",binformat(obuf,obits),obits); + DEBUGMSG(("output %s [%s %d %d]\n", binformat(val, out_bits), + binformat(obuf, obits), obits, out_bits)); + obuf |= val << obits; + obits += out_bits; + while (obits >= 8) { + block_out(obuf&0xff); + obuf >>= 8; + obits -= 8; + } + DEBUGMSG(("output leaving [%s %d]\n", binformat(obuf, obits), obits)); } -static void output_flush() +static void +output_flush() { - if (VERBOSE) printf("output_flush\n"); - if (obits > 0) block_out(obuf); - block_flush(); + DEBUGMSG(("output_flush\n")); + if (obits > 0) { + block_out(obuf); + } + block_flush(); } -static void did_clear() +static void +did_clear() { - if (VERBOSE) printf("did_clear\n"); - out_bits = out_bits_init; - out_bump = out_bump_init; - out_clear = out_clear_init; - out_count = 0; - rl_table_max = 0; - just_cleared = 1; + DEBUGMSG(("did_clear\n")); + out_bits = out_bits_init; + out_bump = out_bump_init; + out_clear = out_clear_init; + out_count = 0; + rl_table_max = 0; + just_cleared = 1; } static void output_plain(c) int c; { - if (VERBOSE) printf("output_plain %s\n",binformat(c,out_bits)); - just_cleared = 0; - output(c); - out_count ++; - if (out_count >= out_bump) - { out_bits ++; - out_bump += 1 << (out_bits - 1); - } - if (out_count >= out_clear) - { output(code_clear); - did_clear(); - } + DEBUGMSG(("output_plain %s\n", binformat(c, out_bits))); + just_cleared = 0; + output(c); + out_count++; + if (out_count >= out_bump) { + out_bits++; + out_bump += 1 << (out_bits - 1); + } + if (out_count >= out_clear) { + output(code_clear); + did_clear(); + } } -static unsigned int isqrt(x) +static unsigned int +isqrt(x) unsigned int x; { - unsigned int r; - unsigned int v; - - if (x < 2) return(x); - for (v=x,r=1;v;v>>=2,r<<=1) ; - while (1) - { v = ((x / r) + r) / 2; - if ((v == r) || (v == r+1)) return(r); - r = v; - } + unsigned int r; + unsigned int v; + + if (x < 2) { + return x; + } + for (v=x,r=1 ; v ; v>>=2,r<<=1); + while (1) { + v = ((x / r) + r) / 2; + if (v==r || v==r+1) { + return r; + } + r = v; + } } static unsigned int @@ -1805,207 +1898,224 @@ compute_triangle_count(count, nrepcodes) unsigned int count; unsigned int nrepcodes; { - unsigned int perrep; - unsigned int cost; - - cost = 0; - perrep = (nrepcodes * (nrepcodes+1)) / 2; - while (count >= perrep) - { cost += nrepcodes; - count -= perrep; - } - if (count > 0) - { unsigned int n; - n = isqrt(count); - while ((n*(n+1)) >= 2*count) n --; - while ((n*(n+1)) < 2*count) n ++; - cost += n; - } - return(cost); + unsigned int perrep; + unsigned int cost; + + cost = 0; + perrep = (nrepcodes * (nrepcodes+1)) / 2; + while (count >= perrep) { + cost += nrepcodes; + count -= perrep; + } + if (count > 0) { + unsigned int n; + n = isqrt(count); + while (n*(n+1) >= 2*count) { + n--; + } + while (n*(n+1) < 2*count) { + n++; + } + cost += n; + } + return cost; } -static void max_out_clear() +static void +max_out_clear() { - out_clear = max_ocodes; + out_clear = max_ocodes; } -static void reset_out_clear() +static void +reset_out_clear() { - out_clear = out_clear_init; - if (out_count >= out_clear) - { output(code_clear); - did_clear(); - } + out_clear = out_clear_init; + if (out_count >= out_clear) { + output(code_clear); + did_clear(); + } } static void rl_flush_fromclear(count) int count; { - int n; - - if (VERBOSE) printf("rl_flush_fromclear %d\n",count); - max_out_clear(); - rl_table_pixel = rl_pixel; - n = 1; - while (count > 0) - { if (n == 1) - { rl_table_max = 1; - output_plain(rl_pixel); - count --; - } - else if (count >= n) - { rl_table_max = n; - output_plain(rl_basecode+n-2); - count -= n; - } - else if (count == 1) - { rl_table_max ++; - output_plain(rl_pixel); - count = 0; - } - else - { rl_table_max ++; - output_plain(rl_basecode+count-2); - count = 0; - } - if (out_count == 0) n = 1; else n ++; - } - reset_out_clear(); - if (VERBOSE) printf("rl_flush_fromclear leaving table_max=%d\n",rl_table_max); + int n; + + DEBUGMSG(("rl_flush_fromclear %d\n", count)); + max_out_clear(); + rl_table_pixel = rl_pixel; + n = 1; + while (count > 0) { + if (n == 1) { + rl_table_max = 1; + output_plain(rl_pixel); + count--; + } else if (count >= n) { + rl_table_max = n; + output_plain(rl_basecode+n-2); + count -= n; + } else if (count == 1) { + rl_table_max++; + output_plain(rl_pixel); + count = 0; + } else { + rl_table_max++; + output_plain(rl_basecode+count-2); + count = 0; + } + if (out_count == 0) { + n = 1; + } else { + n++; + } + } + reset_out_clear(); + DEBUGMSG(("rl_flush_fromclear leaving table_max=%d\n", rl_table_max)); } -static void rl_flush_clearorrep(count) +static void +rl_flush_clearorrep(count) int count; { - int withclr; - - if (VERBOSE) printf("rl_flush_clearorrep %d\n",count); - withclr = 1 + compute_triangle_count(count,max_ocodes); - if (withclr < count) - { output(code_clear); - did_clear(); - rl_flush_fromclear(count); - } - else - { for (;count>0;count--) output_plain(rl_pixel); - } + int withclr; + + DEBUGMSG(("rl_flush_clearorrep %d\n", count)); + withclr = 1 + compute_triangle_count(count, max_ocodes); + if (withclr < count) { + output(code_clear); + did_clear(); + rl_flush_fromclear(count); + } else { + for (; count>0 ; count--) { + output_plain(rl_pixel); + } + } } -static void rl_flush_withtable(count) +static void +rl_flush_withtable(count) int count; { - int repmax; - int repleft; - int leftover; - - if (VERBOSE) printf("rl_flush_withtable %d\n",count); - repmax = count / rl_table_max; - leftover = count % rl_table_max; - repleft = (leftover ? 1 : 0); - if (out_count+repmax+repleft > max_ocodes) - { repmax = max_ocodes - out_count; - leftover = count - (repmax * rl_table_max); - repleft = 1 + compute_triangle_count(leftover,max_ocodes); - } - if (VERBOSE) printf("rl_flush_withtable repmax=%d leftover=%d repleft=%d\n",repmax,leftover,repleft); - if (1+(int)compute_triangle_count(count,max_ocodes) < repmax+repleft) - { output(code_clear); - did_clear(); - rl_flush_fromclear(count); - return; - } - max_out_clear(); - for (;repmax>0;repmax--) output_plain(rl_basecode+rl_table_max-2); - if (leftover) - { if (just_cleared) - { rl_flush_fromclear(leftover); - } - else if (leftover == 1) - { output_plain(rl_pixel); - } - else - { output_plain(rl_basecode+leftover-2); - } - } - reset_out_clear(); + int repmax; + int repleft; + int leftover; + + DEBUGMSG(("rl_flush_withtable %d\n", count)); + repmax = count / rl_table_max; + leftover = count % rl_table_max; + repleft = (leftover ? 1 : 0); + if (out_count+repmax+repleft > max_ocodes) { + repmax = max_ocodes - out_count; + leftover = count - (repmax * rl_table_max); + repleft = 1 + compute_triangle_count(leftover, max_ocodes); + } + DEBUGMSG(("rl_flush_withtable repmax=%d leftover=%d repleft=%d\n", + repmax, leftover, repleft)); + if (1+(int)compute_triangle_count(count, max_ocodes) < repmax+repleft) { + output(code_clear); + did_clear(); + rl_flush_fromclear(count); + return; + } + max_out_clear(); + for (; repmax>0 ; repmax--) { + output_plain(rl_basecode + rl_table_max - 2); + } + if (leftover) { + if (just_cleared) { + rl_flush_fromclear(leftover); + } else if (leftover == 1) { + output_plain(rl_pixel); + } else { + output_plain(rl_basecode + leftover - 2); + } + } + reset_out_clear(); } -static void rl_flush() +static void +rl_flush() { - if (VERBOSE) printf("rl_flush [ %d %d\n",rl_count,rl_pixel); - if (rl_count == 1) - { output_plain(rl_pixel); + DEBUGMSG(("rl_flush [ %d %d\n", rl_count, rl_pixel)); + if (rl_count == 1) { + output_plain(rl_pixel); + rl_count = 0; + DEBUGMSG(("rl_flush ]\n")); + return; + } + if (just_cleared) { + rl_flush_fromclear(rl_count); + } else if ((rl_table_max < 2) || (rl_table_pixel != rl_pixel)) { + rl_flush_clearorrep(rl_count); + } else { + rl_flush_withtable(rl_count); + } + DEBUGMSG(("rl_flush ]\n")); rl_count = 0; - if (VERBOSE) printf("rl_flush ]\n"); - return; - } - if (just_cleared) - { rl_flush_fromclear(rl_count); - } - else if ((rl_table_max < 2) || (rl_table_pixel != rl_pixel)) - { rl_flush_clearorrep(rl_count); - } - else - { rl_flush_withtable(rl_count); - } - if (VERBOSE) printf("rl_flush ]\n"); - rl_count = 0; } -static void compress( init_bits, handle, readValue ) +static void +compress(init_bits, handle, readValue) int init_bits; Tcl_Channel handle; ifunptr readValue; { - int c; - - ofile = handle; - obuf = 0; - obits = 0; - oblen = 0; - code_clear = 1 << (init_bits - 1); - code_eof = code_clear + 1; - rl_basecode = code_eof + 1; - out_bump_init = (1 << (init_bits - 1)) - 1; - /* for images with a lot of runs, making out_clear_init larger will - give better compression. */ - out_clear_init = (init_bits <= 3) ? 9 : (out_bump_init-1); -#ifdef DEBUGGING_ENVARS - { const char *ocienv; - ocienv = getenv("GIF_OUT_CLEAR_INIT"); - if (ocienv) - { out_clear_init = atoi(ocienv); - if (VERBOSE) printf("[overriding out_clear_init to %d]\n",out_clear_init); - } - } + int c; + + ofile = handle; + obuf = 0; + obits = 0; + oblen = 0; + code_clear = 1 << (init_bits - 1); + code_eof = code_clear + 1; + rl_basecode = code_eof + 1; + out_bump_init = (1 << (init_bits - 1)) - 1; + /* + * For images with a lot of runs, making out_clear_init larger + * will give better compression. + */ + out_clear_init = (init_bits <= 3) ? 9 : (out_bump_init-1); +#ifdef MIGIF_DEBUGGING_ENVARS + { + const char *ocienv; + ocienv = getenv("MIGIF_OUT_CLEAR_INIT"); + if (ocienv) { + out_clear_init = atoi(ocienv); + DEBUGMSG(("[overriding out_clear_init to %d]\n", out_clear_init)); + } + } #endif - out_bits_init = init_bits; - max_ocodes = (1 << GIFBITS) - ((1 << (out_bits_init - 1)) + 3); - did_clear(); - output(code_clear); - rl_count = 0; - while (1) - { c = readValue(); - if ((rl_count > 0) && (c != rl_pixel)) rl_flush(); - if (c == EOF) break; - if (rl_pixel == c) - { rl_count ++; - } - else - { rl_pixel = c; - rl_count = 1; - } - } - output(code_eof); - output_flush(); + out_bits_init = init_bits; + max_ocodes = (1 << GIFBITS) - ((1 << (out_bits_init - 1)) + 3); + did_clear(); + output(code_clear); + rl_count = 0; + while (1) { + c = readValue(); + if ((rl_count > 0) && (c != rl_pixel)) { + rl_flush(); + } + if (c == EOF) { + break; + } + if (rl_pixel == c) { + rl_count++; + } else { + rl_pixel = c; + rl_count = 1; + } + } + output(code_eof); + output_flush(); } -/*----------------------------------------------------------------------- +/* + *----------------------------------------------------------------------- * * End of miGIF section - See copyright notice at start of section. * - *-----------------------------------------------------------------------*/ - - + *----------------------------------------------------------------------- + */ diff --git a/tk/generic/tkImgPPM.c b/tk/generic/tkImgPPM.c index 8e5d17aee2b..c509648cb1c 100644 --- a/tk/generic/tkImgPPM.c +++ b/tk/generic/tkImgPPM.c @@ -192,7 +192,7 @@ FileReadPPM(interp, chan, fileName, formatString, imageHandle, destX, destY, Tk_PhotoExpand(imageHandle, destX + width, destY + height); if (srcY > 0) { - Tcl_Seek(chan, (srcY * block.pitch), SEEK_CUR); + Tcl_Seek(chan, (Tcl_WideInt)(srcY * block.pitch), SEEK_CUR); } nLines = (MAX_MEMORY + block.pitch - 1) / block.pitch; @@ -228,7 +228,8 @@ FileReadPPM(interp, chan, fileName, formatString, imageHandle, destX, destY, } } block.height = nLines; - Tk_PhotoPutBlock(imageHandle, &block, destX, destY, width, nLines); + Tk_PhotoPutBlock(imageHandle, &block, destX, destY, width, nLines, + TK_PHOTO_COMPOSITE_SET); destY += nLines; } @@ -274,10 +275,12 @@ FileWritePPM(interp, fileName, formatString, blockPtr) if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) { + Tcl_Close(NULL, chan); return TCL_ERROR; } if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") != TCL_OK) { + Tcl_Close(NULL, chan); return TCL_ERROR; } @@ -427,4 +430,3 @@ ReadPPMFileHeader(chan, widthPtr, heightPtr, maxIntensityPtr) } return type; } - diff --git a/tk/generic/tkImgPhoto.c b/tk/generic/tkImgPhoto.c index 7416771041b..d2b0cb02711 100644 --- a/tk/generic/tkImgPhoto.c +++ b/tk/generic/tkImgPhoto.c @@ -7,6 +7,7 @@ * * Copyright (c) 1994 The Australian National University. * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright (c) 2002 Donal K. Fellows * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -231,6 +232,7 @@ struct SubcommandOptions { int subsampleX, subsampleY; /* Values specified for -subsample option. */ Tcl_Obj *format; /* Value specified for -format option. */ XColor *background; /* Value specified for -background option. */ + int compositingRule; /* Value specified for -compositingrule opt */ }; /* @@ -241,6 +243,7 @@ struct SubcommandOptions { * field of the SubcommandOptions structure if that option was specified. * * OPT_BACKGROUND: Set if -format option allowed/specified. + * OPT_COMPOSITE: Set if -compositingrule option allowed/spec'd. * OPT_FORMAT: Set if -format option allowed/specified. * OPT_FROM: Set if -from option allowed/specified. * OPT_GRAYSCALE: Set if -grayscale option allowed/specified. @@ -251,13 +254,14 @@ struct SubcommandOptions { */ #define OPT_BACKGROUND 1 -#define OPT_FORMAT 2 -#define OPT_FROM 4 -#define OPT_GRAYSCALE 8 -#define OPT_SHRINK 0x10 -#define OPT_SUBSAMPLE 0x20 -#define OPT_TO 0x40 -#define OPT_ZOOM 0x80 +#define OPT_COMPOSITE 2 +#define OPT_FORMAT 4 +#define OPT_FROM 8 +#define OPT_GRAYSCALE 0x10 +#define OPT_SHRINK 0x20 +#define OPT_SUBSAMPLE 0x40 +#define OPT_TO 0x80 +#define OPT_ZOOM 0x100 /* * List of option names. The order here must match the order of @@ -266,6 +270,7 @@ struct SubcommandOptions { static char *optionNames[] = { "-background", + "-compositingrule", "-format", "-from", "-grayscale", @@ -277,7 +282,14 @@ static char *optionNames[] = { }; /* - * The type record for photo images: + * Message to generate when an attempt to resize an image fails due + * to memory problems. + */ +#define TK_PHOTO_ALLOC_FAILURE_MESSAGE \ + "not enough free memory for image buffer" + +/* + * Functions used in the type record for photo images. */ static int ImgPhotoCreate _ANSI_ARGS_((Tcl_Interp *interp, @@ -298,6 +310,10 @@ static int ImgPhotoPostscript _ANSI_ARGS_((ClientData clientData, Tk_PostscriptInfo psInfo, int x, int y, int width, int height, int prepass)); +/* + * The type record itself for photo images: + */ + Tk_ImageType tkPhotoImageType = { "photo", /* name */ ImgPhotoCreate, /* createProc */ @@ -314,6 +330,7 @@ typedef struct ThreadSpecificData { * list of known photo image formats.*/ Tk_PhotoImageFormat *oldFormatList; /* Pointer to the first in the * list of known photo image formats.*/ + int initialized; /* set to 1 if we've initialized the strucuture */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; @@ -357,6 +374,8 @@ static int imgPhotoColorHashInitialized; * Forward declarations */ +static void PhotoFormatThreadExitProc _ANSI_ARGS_(( + ClientData clientData)); static int ImgPhotoCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); static int ParseSubcommandOptions _ANSI_ARGS_(( @@ -370,7 +389,7 @@ static int ImgPhotoConfigureMaster _ANSI_ARGS_(( int objc, Tcl_Obj *CONST objv[], int flags)); static void ImgPhotoConfigureInstance _ANSI_ARGS_(( PhotoInstance *instancePtr)); -static void ImgPhotoSetSize _ANSI_ARGS_((PhotoMaster *masterPtr, +static int ImgPhotoSetSize _ANSI_ARGS_((PhotoMaster *masterPtr, int width, int height)); static void ImgPhotoInstanceSetSize _ANSI_ARGS_(( PhotoInstance *instancePtr)); @@ -381,7 +400,7 @@ static char * ImgGetPhoto _ANSI_ARGS_((PhotoMaster *masterPtr, Tk_PhotoImageBlock *blockPtr, struct SubcommandOptions *optPtr)); static int IsValidPalette _ANSI_ARGS_((PhotoInstance *instancePtr, - char *palette)); + CONST char *palette)); static int CountBits _ANSI_ARGS_((pixel mask)); static void GetColorTable _ANSI_ARGS_((PhotoInstance *instancePtr)); static void FreeColorTable _ANSI_ARGS_((ColorTable *colorPtr, @@ -411,6 +430,48 @@ static void PhotoOptionCleanupProc _ANSI_ARGS_(( #undef MAX #define MAX(a, b) ((a) > (b)? (a): (b)) +/* + *---------------------------------------------------------------------- + * + * Tk_CreateOldPhotoImageFormat, Tk_CreatePhotoImageFormat -- + * + * This procedure is invoked by an image file handler to register + * a new photo image format and the procedures that handle the + * new format. The procedure is typically invoked during + * Tcl_AppInit. + * + * Results: + * None. + * + * Side effects: + * The new image file format is entered into a table used in the + * photo image "read" and "write" subcommands. + * + *---------------------------------------------------------------------- + */ + +static void +PhotoFormatThreadExitProc(clientData) + ClientData clientData; /* not used */ +{ + Tk_PhotoImageFormat *freePtr; + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + + while (tsdPtr->oldFormatList != NULL) { + freePtr = tsdPtr->oldFormatList; + tsdPtr->oldFormatList = tsdPtr->oldFormatList->nextPtr; + ckfree((char *) freePtr->name); + ckfree((char *) freePtr); + } + while (tsdPtr->formatList != NULL) { + freePtr = tsdPtr->formatList; + tsdPtr->formatList = tsdPtr->formatList->nextPtr; + ckfree((char *) freePtr->name); + ckfree((char *) freePtr); + } +} + /* *---------------------------------------------------------------------- * @@ -442,6 +503,10 @@ Tk_CreateOldPhotoImageFormat(formatPtr) ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + if (!tsdPtr->initialized) { + tsdPtr->initialized = 1; + Tcl_CreateThreadExitHandler(PhotoFormatThreadExitProc, NULL); + } copyPtr = (Tk_PhotoImageFormat *) ckalloc(sizeof(Tk_PhotoImageFormat)); *copyPtr = *formatPtr; copyPtr->name = (char *) ckalloc((unsigned) (strlen(formatPtr->name) + 1)); @@ -462,6 +527,10 @@ Tk_CreatePhotoImageFormat(formatPtr) ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + if (!tsdPtr->initialized) { + tsdPtr->initialized = 1; + Tcl_CreateThreadExitHandler(PhotoFormatThreadExitProc, NULL); + } copyPtr = (Tk_PhotoImageFormat *) ckalloc(sizeof(Tk_PhotoImageFormat)); *copyPtr = *formatPtr; copyPtr->name = (char *) ckalloc((unsigned) (strlen(formatPtr->name) + 1)); @@ -563,13 +632,14 @@ ImgPhotoCmd(clientData, interp, objc, objv) Tcl_Obj *CONST objv[]; /* Argument objects. */ { int oldformat = 0; - static char *photoOptions[] = { + static CONST char *photoOptions[] = { "blank", "cget", "configure", "copy", "data", "get", "put", - "read", "redither", "write", (char *) NULL + "read", "redither", "transparency", "write", (char *) NULL }; enum options { PHOTO_BLANK, PHOTO_CGET, PHOTO_CONFIGURE, PHOTO_COPY, PHOTO_DATA, - PHOTO_GET, PHOTO_PUT, PHOTO_READ, PHOTO_REDITHER, PHOTO_WRITE + PHOTO_GET, PHOTO_PUT, PHOTO_READ, PHOTO_REDITHER, PHOTO_TRANS, + PHOTO_WRITE }; PhotoMaster *masterPtr = (PhotoMaster *) clientData; @@ -578,8 +648,8 @@ ImgPhotoCmd(clientData, interp, objc, objv) int dataWidth, dataHeight; struct SubcommandOptions options; int listArgc; - char **listArgv; - char **srcArgv; + CONST char **listArgv; + CONST char **srcArgv; unsigned char *pixelPtr; Tk_PhotoImageBlock block; Tk_Window tkwin; @@ -607,8 +677,9 @@ ImgPhotoCmd(clientData, interp, objc, objv) } return proc(clientData, interp, objc, objv); } + switch ((enum options) index) { - case PHOTO_BLANK: { + case PHOTO_BLANK: /* * photo blank command - just call Tk_PhotoBlank. */ @@ -620,9 +691,10 @@ ImgPhotoCmd(clientData, interp, objc, objv) return TCL_ERROR; } break; - } - case PHOTO_CGET: { + + case PHOTO_CGET: { char *arg; + if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); return TCL_ERROR; @@ -643,12 +715,12 @@ ImgPhotoCmd(clientData, interp, objc, objv) Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs, (char *) masterPtr, Tcl_GetString(objv[2]), 0); break; - } - case PHOTO_CONFIGURE: { + } + + case PHOTO_CONFIGURE: /* * photo configure command - handle this in the standard way. */ - char *opt, *arg; if (objc == 2) { Tcl_Obj *obj, *subobj; @@ -677,39 +749,38 @@ ImgPhotoCmd(clientData, interp, objc, objv) return TCL_OK; } if (objc == 3) { - char *arg = Tcl_GetStringFromObj(objv[2], (int *) &length); - if (!strncmp(arg, "-data", length)) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - "-data {} {} {}", (char *) NULL); - if (masterPtr->dataString) { - Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp), - masterPtr->dataString); - } else { + char *arg = Tcl_GetStringFromObj(objv[2], (int *) &length); + if (!strncmp(arg, "-data", length)) { Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - " {}", (char *) NULL); - } - return TCL_OK; - } else if (!strncmp(arg, "-format", length)) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - "-format {} {} {}", (char *) NULL); - if (masterPtr->format) { - Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp), - masterPtr->format); - } else { + "-data {} {} {}", (char *) NULL); + if (masterPtr->dataString) { + Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp), + masterPtr->dataString); + } else { + Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), + " {}", (char *) NULL); + } + return TCL_OK; + } else if (!strncmp(arg, "-format", length)) { Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - " {}", (char *) NULL); + "-format {} {} {}", (char *) NULL); + if (masterPtr->format) { + Tcl_ListObjAppendElement(interp, Tcl_GetObjResult(interp), + masterPtr->format); + } else { + Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), + " {}", (char *) NULL); + } + return TCL_OK; + } else { + return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), + configSpecs, (char *) masterPtr, arg, 0); } - return TCL_OK; - } else { - return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), - configSpecs, (char *) masterPtr, arg, 0); - } } return ImgPhotoConfigureMaster(interp, masterPtr, objc-2, objv+2, TK_CONFIG_ARGV_ONLY); - break; - } - case PHOTO_COPY: { + + case PHOTO_COPY: /* * photo copy command - first parse options. */ @@ -719,14 +790,15 @@ ImgPhotoCmd(clientData, interp, objc, objv) options.zoomX = options.zoomY = 1; options.subsampleX = options.subsampleY = 1; options.name = NULL; + options.compositingRule = TK_PHOTO_COMPOSITE_OVERLAY; if (ParseSubcommandOptions(&options, interp, - OPT_FROM | OPT_TO | OPT_ZOOM | OPT_SUBSAMPLE | OPT_SHRINK, - &index, objc, objv) != TCL_OK) { + OPT_FROM | OPT_TO | OPT_ZOOM | OPT_SUBSAMPLE | OPT_SHRINK | + OPT_COMPOSITE, &index, objc, objv) != TCL_OK) { return TCL_ERROR; } if (options.name == NULL || index < objc) { Tcl_WrongNumArgs(interp, 2, objv, - "source-image ?-from x1 y1 x2 y2? ?-to x1 y1 x2 y2? ?-zoom x y? ?-subsample x y?"); + "source-image ?-compositingrule rule? ?-from x1 y1 x2 y2? ?-to x1 y1 x2 y2? ?-zoom x y? ?-subsample x y?"); return TCL_ERROR; } @@ -735,7 +807,8 @@ ImgPhotoCmd(clientData, interp, objc, objv) * Check the values given for the -from option. */ - if ((srcHandle = Tk_FindPhoto(interp, Tcl_GetString(options.name))) == NULL) { + srcHandle = Tk_FindPhoto(interp, Tcl_GetString(options.name)); + if (srcHandle == NULL) { Tcl_AppendResult(interp, "image \"", Tcl_GetString(options.name), "\" doesn't", " exist or is not a photo image", (char *) NULL); @@ -754,11 +827,11 @@ ImgPhotoCmd(clientData, interp, objc, objv) * Fill in default values for unspecified parameters. */ - if (((options.options & OPT_FROM) == 0) || (options.fromX2 < 0)) { + if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) { options.fromX2 = block.width; options.fromY2 = block.height; } - if (((options.options & OPT_TO) == 0) || (options.toX2 < 0)) { + if (!(options.options & OPT_TO) || (options.toX2 < 0)) { width = options.fromX2 - options.fromX; if (options.subsampleX > 0) { width = (width + options.subsampleX - 1) / options.subsampleX; @@ -787,7 +860,13 @@ ImgPhotoCmd(clientData, interp, objc, objv) */ if (options.options & OPT_SHRINK) { - ImgPhotoSetSize(masterPtr, options.toX2, options.toY2); + if (ImgPhotoSetSize(masterPtr, options.toX2, + options.toY2) != TCL_OK) { + Tcl_ResetResult(interp); + Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), + TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + return TCL_ERROR; + } } /* @@ -795,17 +874,18 @@ ImgPhotoCmd(clientData, interp, objc, objv) */ block.pixelPtr += options.fromX * block.pixelSize - + options.fromY * block.pitch; + + options.fromY * block.pitch; block.width = options.fromX2 - options.fromX; block.height = options.fromY2 - options.fromY; Tk_PhotoPutZoomedBlock((Tk_PhotoHandle) masterPtr, &block, options.toX, options.toY, options.toX2 - options.toX, options.toY2 - options.toY, options.zoomX, options.zoomY, - options.subsampleX, options.subsampleY); + options.subsampleX, options.subsampleY, + options.compositingRule); break; - } - case PHOTO_DATA: { + + case PHOTO_DATA: { char *data; /* @@ -878,7 +958,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) data = ImgGetPhoto(masterPtr, &block, &options); - result = ((int (*) _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *formatString, + result = ((int (*) _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *formatString, Tk_PhotoImageBlock *blockPtr, VOID *dummy))) stringWriteProc) (interp, options.format, &block, (VOID *) NULL); if (options.background) { @@ -889,8 +969,9 @@ ImgPhotoCmd(clientData, interp, objc, objv) } return result; break; - } - case PHOTO_GET: { + } + + case PHOTO_GET: { /* * photo get command - first parse and check parameters. */ @@ -921,8 +1002,9 @@ ImgPhotoCmd(clientData, interp, objc, objv) pixelPtr[2]); Tcl_AppendResult(interp, string, (char *) NULL); break; - } - case PHOTO_PUT: { + } + + case PHOTO_PUT: /* * photo put command - first parse the options and colors specified. */ @@ -931,7 +1013,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) memset((VOID *) &options, 0, sizeof(options)); options.name = NULL; if (ParseSubcommandOptions(&options, interp, OPT_TO|OPT_FORMAT, - &index, objc, objv) != TCL_OK) { + &index, objc, objv) != TCL_OK) { return TCL_ERROR; } if ((options.name == NULL) || (index < objc)) { @@ -942,8 +1024,8 @@ ImgPhotoCmd(clientData, interp, objc, objv) if (MatchStringFormat(interp, options.name ? objv[2]:NULL, options.format, &imageFormat, &imageWidth, &imageHeight, &oldformat) == TCL_OK) { - Tcl_Obj *format; - Tcl_Obj *data; + Tcl_Obj *format, *data; + if (((options.options & OPT_TO) == 0) || (options.toX2 < 0)) { options.toX2 = options.toX + imageWidth; options.toY2 = options.toY + imageHeight; @@ -964,8 +1046,8 @@ ImgPhotoCmd(clientData, interp, objc, objv) } if ((*imageFormat->stringReadProc)(interp, data, format, (Tk_PhotoHandle) masterPtr, - 0, 0, imageWidth, imageHeight, options.toX, options.toY) - != TCL_OK) { + options.toX, options.toY, imageWidth, imageHeight, + 0, 0) != TCL_OK) { return TCL_ERROR; } masterPtr->flags |= IMAGE_CHANGED; @@ -976,8 +1058,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) } Tcl_ResetResult(interp); if (Tcl_SplitList(interp, Tcl_GetString(options.name), - &dataHeight, &srcArgv) - != TCL_OK) { + &dataHeight, &srcArgv) != TCL_OK) { return TCL_ERROR; } tkwin = Tk_MainWindow(interp); @@ -991,17 +1072,14 @@ ImgPhotoCmd(clientData, interp, objc, objv) } if (y == 0) { dataWidth = listArgc; - pixelPtr = (unsigned char *) ckalloc((unsigned) - dataWidth * dataHeight * 3); + pixelPtr = (unsigned char *) + ckalloc((unsigned) dataWidth * dataHeight * 3); block.pixelPtr = pixelPtr; - } else { - if (listArgc != dataWidth) { - Tcl_AppendResult(interp, "all elements of color list must", - " have the same number of elements", - (char *) NULL); - ckfree((char *) listArgv); - break; - } + } else if (listArgc != dataWidth) { + Tcl_AppendResult(interp, "all elements of color list must", + " have the same number of elements", (char *) NULL); + ckfree((char *) listArgv); + break; } for (x = 0; x < dataWidth; ++x) { if (!XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), @@ -1015,8 +1093,9 @@ ImgPhotoCmd(clientData, interp, objc, objv) *pixelPtr++ = color.blue >> 8; } ckfree((char *) listArgv); - if (x < dataWidth) + if (x < dataWidth) { break; + } } ckfree((char *) srcArgv); if (y < dataHeight || dataHeight == 0 || dataWidth == 0) { @@ -1034,7 +1113,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) * copy the block in using Tk_PhotoPutBlock. */ - if (((options.options & OPT_TO) == 0) || (options.toX2 < 0)) { + if (!(options.options & OPT_TO) || (options.toX2 < 0)) { options.toX2 = options.toX + dataWidth; options.toY2 = options.toY + dataHeight; } @@ -1048,16 +1127,17 @@ ImgPhotoCmd(clientData, interp, objc, objv) block.offset[3] = 0; Tk_PhotoPutBlock((ClientData)masterPtr, &block, options.toX, options.toY, options.toX2 - options.toX, - options.toY2 - options.toY); + options.toY2 - options.toY, TK_PHOTO_COMPOSITE_SET); ckfree((char *) block.pixelPtr); break; - } - case PHOTO_READ: { + + case PHOTO_READ: { + Tcl_Obj *format; + /* * photo read command - first parse the options specified. */ - Tcl_Obj *format; index = 2; memset((VOID *) &options, 0, sizeof(options)); options.name = NULL; @@ -1068,8 +1148,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) return TCL_ERROR; } if ((options.name == NULL) || (index < objc)) { - Tcl_WrongNumArgs(interp, 2, objv, - "fileName ?options?"); + Tcl_WrongNumArgs(interp, 2, objv, "fileName ?options?"); return TCL_ERROR; } @@ -1079,7 +1158,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) if (Tcl_IsSafe(interp)) { Tcl_AppendResult(interp, "can't get image from a file in a", - " safe interpreter", (char *) NULL); + " safe interpreter", (char *) NULL); return TCL_ERROR; } @@ -1094,16 +1173,18 @@ ImgPhotoCmd(clientData, interp, objc, objv) } if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) { + Tcl_Close(NULL, chan); return TCL_ERROR; } if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") != TCL_OK) { + Tcl_Close(NULL, chan); return TCL_ERROR; } if (MatchFileFormat(interp, chan, - Tcl_GetString(options.name), options.format, - &imageFormat, &imageWidth, &imageHeight, &oldformat) != TCL_OK) { + Tcl_GetString(options.name), options.format, &imageFormat, + &imageWidth, &imageHeight, &oldformat) != TCL_OK) { Tcl_Close(NULL, chan); return TCL_ERROR; } @@ -1133,8 +1214,13 @@ ImgPhotoCmd(clientData, interp, objc, objv) */ if (options.options & OPT_SHRINK) { - ImgPhotoSetSize(masterPtr, options.toX + width, - options.toY + height); + if (ImgPhotoSetSize(masterPtr, options.toX + width, + options.toY + height) != TCL_OK) { + Tcl_ResetResult(interp); + Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), + TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + return TCL_ERROR; + } } /* @@ -1155,42 +1241,163 @@ ImgPhotoCmd(clientData, interp, objc, objv) } return result; break; - } - case PHOTO_REDITHER: { - if (objc == 2) { + } + + case PHOTO_REDITHER: + if (objc != 2) { + Tcl_WrongNumArgs(interp, 2, objv, (char *) NULL); + return TCL_ERROR; + } + + /* + * Call Dither if any part of the image is not correctly + * dithered at present. + */ + + x = masterPtr->ditherX; + y = masterPtr->ditherY; + if (masterPtr->ditherX != 0) { + Tk_DitherPhoto((Tk_PhotoHandle) masterPtr, x, y, + masterPtr->width - x, 1); + } + if (masterPtr->ditherY < masterPtr->height) { + x = 0; + Tk_DitherPhoto((Tk_PhotoHandle)masterPtr, 0, + masterPtr->ditherY, masterPtr->width, + masterPtr->height - masterPtr->ditherY); + } + + if (y < masterPtr->height) { /* - * Call Dither if any part of the image is not correctly - * dithered at present. + * Tell the core image code that part of the image has changed. */ - x = masterPtr->ditherX; - y = masterPtr->ditherY; - if (masterPtr->ditherX != 0) { - Tk_DitherPhoto((Tk_PhotoHandle) masterPtr, x, y, masterPtr->width - x, 1); + Tk_ImageChanged(masterPtr->tkMaster, x, y, + (masterPtr->width - x), (masterPtr->height - y), + masterPtr->width, masterPtr->height); + } + break; + + case PHOTO_TRANS: { + static CONST char *photoTransOptions[] = { + "get", "set", (char *) NULL + }; + enum transOptions { + PHOTO_TRANS_GET, PHOTO_TRANS_SET + }; + + if (objc < 3) { + Tcl_WrongNumArgs(interp, 2, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } + if (Tcl_GetIndexFromObj(interp, objv[2], photoTransOptions, "option", + 0, &index) != TCL_OK) { + return TCL_ERROR; + } + + switch ((enum transOptions) index) { + case PHOTO_TRANS_GET: { + XRectangle testBox; + TkRegion testRegion; + + if (objc != 5) { + Tcl_WrongNumArgs(interp, 3, objv, "x y"); + return TCL_ERROR; + } + if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)) { + return TCL_ERROR; + } + if ((x < 0) || (x >= masterPtr->width) + || (y < 0) || (y >= masterPtr->height)) { + Tcl_AppendResult(interp, Tcl_GetString(objv[0]), + " transparency get: coordinates out of range", + (char *) NULL); + return TCL_ERROR; + } + + testBox.x = x; + testBox.y = y; + testBox.width = 1; + testBox.height = 1; + /* What a way to do a test! */ + testRegion = TkCreateRegion(); + TkUnionRectWithRegion(&testBox, testRegion, testRegion); + TkIntersectRegion(testRegion, masterPtr->validRegion, testRegion); + TkClipBox(testRegion, &testBox); + TkDestroyRegion(testRegion); + + Tcl_SetBooleanObj(Tcl_GetObjResult(interp), + (testBox.width==0 && testBox.height==0)); + return TCL_OK; + } + + case PHOTO_TRANS_SET: { + int transFlag; + XRectangle setBox; + + if (objc != 6) { + Tcl_WrongNumArgs(interp, 3, objv, "x y boolean"); + return TCL_ERROR; + } + if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK) + || (Tcl_GetBooleanFromObj(interp, objv[5], + &transFlag) != TCL_OK)) { + return TCL_ERROR; } - if (masterPtr->ditherY < masterPtr->height) { - x = 0; - Tk_DitherPhoto((Tk_PhotoHandle)masterPtr, 0, masterPtr->ditherY, masterPtr->width, - masterPtr->height - masterPtr->ditherY); + if ((x < 0) || (x >= masterPtr->width) + || (y < 0) || (y >= masterPtr->height)) { + Tcl_AppendResult(interp, Tcl_GetString(objv[0]), + " transparency set: coordinates out of range", + (char *) NULL); + return TCL_ERROR; } - if (y < masterPtr->height) { + setBox.x = x; + setBox.y = y; + setBox.width = 1; + setBox.height = 1; + pixelPtr = masterPtr->pix24 + (y * masterPtr->width + x) * 4; + + if (transFlag) { /* - * Tell the core image code that part of the image has changed. + * Make pixel transparent. */ + TkRegion clearRegion = TkCreateRegion(); - Tk_ImageChanged(masterPtr->tkMaster, x, y, - (masterPtr->width - x), (masterPtr->height - y), - masterPtr->width, masterPtr->height); + TkUnionRectWithRegion(&setBox, clearRegion, clearRegion); + TkSubtractRegion(masterPtr->validRegion, clearRegion, + masterPtr->validRegion); + TkDestroyRegion(clearRegion); + /* + * Set the alpha value correctly. + */ + pixelPtr[3] = 0; + } else { + /* + * Make pixel opaque. + */ + TkUnionRectWithRegion(&setBox, masterPtr->validRegion, + masterPtr->validRegion); + pixelPtr[3] = 255; } - } else { - Tcl_WrongNumArgs(interp, 2, objv, (char *) NULL); - return TCL_ERROR; + /* + * Inform the generic image code that the image + * has (potentially) changed. + */ + + Tk_ImageChanged(masterPtr->tkMaster, x, y, 1, 1, + masterPtr->width, masterPtr->height); + masterPtr->flags &= ~IMAGE_CHANGED; } - break; - } - case PHOTO_WRITE: { + + } + return TCL_OK; + } + + case PHOTO_WRITE: { char *data; Tcl_Obj *format; @@ -1200,7 +1407,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) if (Tcl_IsSafe(interp)) { Tcl_AppendResult(interp, "can't write image to a file in a", - " safe interpreter", (char *) NULL); + " safe interpreter", (char *) NULL); return TCL_ERROR; } @@ -1234,7 +1441,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) * Fill in default values for unspecified parameters. */ - if (((options.options & OPT_FROM) == 0) || (options.fromX2 < 0)) { + if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) { options.fromX2 = masterPtr->width; options.fromY2 = masterPtr->height; } @@ -1246,7 +1453,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) matched = 0; for (imageFormat = tsdPtr->formatList; imageFormat != NULL; - imageFormat = imageFormat->nextPtr) { + imageFormat = imageFormat->nextPtr) { if ((options.format == NULL) || (strncasecmp(Tcl_GetString(options.format), imageFormat->name, strlen(imageFormat->name)) == 0)) { @@ -1257,18 +1464,18 @@ ImgPhotoCmd(clientData, interp, objc, objv) } } if (imageFormat == NULL) { - oldformat = 1; - for (imageFormat = tsdPtr->oldFormatList; imageFormat != NULL; - imageFormat = imageFormat->nextPtr) { - if ((options.format == NULL) - || (strncasecmp(Tcl_GetString(options.format), - imageFormat->name, strlen(imageFormat->name)) == 0)) { - matched = 1; - if (imageFormat->fileWriteProc != NULL) { - break; + oldformat = 1; + for (imageFormat = tsdPtr->oldFormatList; imageFormat != NULL; + imageFormat = imageFormat->nextPtr) { + if ((options.format == NULL) + || (strncasecmp(Tcl_GetString(options.format), + imageFormat->name, strlen(imageFormat->name)) == 0)) { + matched = 1; + if (imageFormat->fileWriteProc != NULL) { + break; + } } } - } } if (imageFormat == NULL) { if (options.format == NULL) { @@ -1298,8 +1505,7 @@ ImgPhotoCmd(clientData, interp, objc, objv) format = (Tcl_Obj *) Tcl_GetString(options.format); } result = (*imageFormat->fileWriteProc)(interp, - Tcl_GetString(options.name), - format, &block); + Tcl_GetString(options.name), format, &block); if (options.background) { Tk_FreeColor(options.background); } @@ -1307,10 +1513,9 @@ ImgPhotoCmd(clientData, interp, objc, objv) ckfree(data); } return result; - break; - } } + } return TCL_OK; } @@ -1321,7 +1526,8 @@ ImgPhotoCmd(clientData, interp, objc, objv) * * This procedure is invoked to process one of the options * which may be specified for the photo image subcommands, - * namely, -from, -to, -zoom, -subsample, -format, and -shrink. + * namely, -from, -to, -zoom, -subsample, -format, -shrink, + * and -compositingrule. * * Results: * A standard Tcl result. @@ -1436,7 +1642,9 @@ ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, objc, objv) } } else if (bit == OPT_FORMAT) { /* - * The -format option takes a single string value. + * The -format option takes a single string value. Note + * that parsing this is outside the scope of this + * function. */ if (index + 1 < objc) { @@ -1447,6 +1655,34 @@ ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, objc, objv) "requires a value", (char *) NULL); return TCL_ERROR; } + } else if (bit == OPT_COMPOSITE) { + /* + * The -compositingrule option takes a single value from + * a well-known set. + */ + + if (index + 1 < objc) { + /* + * Note that these must match the TK_PHOTO_COMPOSITE_* + * constants. + */ + static CONST char *compositingRules[] = { + "overlay", "set", + NULL + }; + + index++; + if (Tcl_GetIndexFromObj(interp, objv[index], compositingRules, + "compositing rule", 0, &optPtr->compositingRule) + != TCL_OK) { + return TCL_ERROR; + } + *optIndexPtr = index; + } else { + Tcl_AppendResult(interp, "the \"-compositingrule\" option ", + "requires a value", (char *) NULL); + return TCL_ERROR; + } } else if ((bit != OPT_SHRINK) && (bit != OPT_GRAYSCALE)) { char *val; maxValues = ((bit == OPT_FROM) || (bit == OPT_TO))? 4: 2; @@ -1588,7 +1824,7 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) * such as TK_CONFIG_ARGV_ONLY. */ { PhotoInstance *instancePtr; - char *oldFileString, *oldPaletteString; + CONST char *oldFileString, *oldPaletteString; Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL; int length, i, j; double oldGamma; @@ -1596,11 +1832,11 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) Tcl_Channel chan; Tk_PhotoImageFormat *imageFormat; int imageWidth, imageHeight; - char **args; + CONST char **args; int oldformat; Tcl_Obj *tempdata, *tempformat; - args = (char **) ckalloc((objc + 1) * sizeof(char *)); + args = (CONST char **) ckalloc((objc + 1) * sizeof(char *)); for (i = 0, j = 0; i < objc; i++,j++) { args[j] = Tcl_GetStringFromObj(objv[i], &length); if ((length > 1) && (args[j][0] == '-')) { @@ -1630,8 +1866,18 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) */ oldFileString = masterPtr->fileString; - oldData = (oldFileString == NULL) ? masterPtr->dataString: NULL; + if (oldFileString == NULL) { + oldData = masterPtr->dataString; + if (oldData != NULL) { + Tcl_IncrRefCount(oldData); + } + } else { + oldData = NULL; + } oldFormat = masterPtr->format; + if (oldFormat != NULL) { + Tcl_IncrRefCount(oldFormat); + } oldPaletteString = masterPtr->palette; oldGamma = masterPtr->gamma; @@ -1642,7 +1888,7 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) if (Tk_ConfigureWidget(interp, Tk_MainWindow(interp), configSpecs, j, args, (char *) masterPtr, flags) != TCL_OK) { ckfree((char *) args); - return TCL_ERROR; + goto errorExit; } ckfree((char *) args); @@ -1684,7 +1930,13 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) * and make sure storage is correctly allocated for this image. */ - ImgPhotoSetSize(masterPtr, masterPtr->width, masterPtr->height); + if (ImgPhotoSetSize(masterPtr, masterPtr->width, + masterPtr->height) != TCL_OK) { + Tcl_ResetResult(interp); + Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), + TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + goto errorExit; + } /* * Read in the image from the file or string if the user has @@ -1700,30 +1952,36 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) */ if (Tcl_IsSafe(interp)) { - Tcl_AppendResult(interp, "can't get image from a file in a", - " safe interpreter", (char *) NULL); - return TCL_ERROR; + Tcl_ResetResult(interp); + Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), + "can't get image from a file in a safe interpreter", + (char *) NULL); + goto errorExit; } chan = Tcl_OpenFileChannel(interp, masterPtr->fileString, "r", 0); if (chan == NULL) { - return TCL_ERROR; + goto errorExit; } - if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") - != TCL_OK) { - return TCL_ERROR; - } - if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") - != TCL_OK) { - return TCL_ERROR; - } - if (MatchFileFormat(interp, chan, masterPtr->fileString, - masterPtr->format, &imageFormat, &imageWidth, - &imageHeight, &oldformat) != TCL_OK) { + /* + * -translation binary also sets -encoding binary + */ + if ((Tcl_SetChannelOption(interp, chan, + "-translation", "binary") != TCL_OK) || + (MatchFileFormat(interp, chan, masterPtr->fileString, + masterPtr->format, &imageFormat, &imageWidth, + &imageHeight, &oldformat) != TCL_OK)) { Tcl_Close(NULL, chan); - return TCL_ERROR; + goto errorExit; + } + result = ImgPhotoSetSize(masterPtr, imageWidth, imageHeight); + if (result != TCL_OK) { + Tcl_Close(NULL, chan); + Tcl_ResetResult(interp); + Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), + TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + goto errorExit; } - ImgPhotoSetSize(masterPtr, imageWidth, imageHeight); tempformat = masterPtr->format; if (oldformat && tempformat) { tempformat = (Tcl_Obj *) Tcl_GetString(tempformat); @@ -1734,7 +1992,7 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) imageWidth, imageHeight, 0, 0); Tcl_Close(NULL, chan); if (result != TCL_OK) { - return TCL_ERROR; + goto errorExit; } Tcl_ResetResult(interp); @@ -1743,14 +2001,19 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) if ((masterPtr->fileString == NULL) && (masterPtr->dataString != NULL) && ((masterPtr->dataString != oldData) - || (masterPtr->format != oldFormat))) { + || (masterPtr->format != oldFormat))) { - if (MatchStringFormat(interp, masterPtr->dataString, + if (MatchStringFormat(interp, masterPtr->dataString, masterPtr->format, &imageFormat, &imageWidth, &imageHeight, &oldformat) != TCL_OK) { - return TCL_ERROR; + goto errorExit; + } + if (ImgPhotoSetSize(masterPtr, imageWidth, imageHeight) != TCL_OK) { + Tcl_ResetResult(interp); + Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), + TK_PHOTO_ALLOC_FAILURE_MESSAGE, (char *) NULL); + goto errorExit; } - ImgPhotoSetSize(masterPtr, imageWidth, imageHeight); tempformat = masterPtr->format; tempdata = masterPtr->dataString; if (oldformat) { @@ -1762,7 +2025,7 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) if ((*imageFormat->stringReadProc)(interp, tempdata, tempformat, (Tk_PhotoHandle) masterPtr, 0, 0, imageWidth, imageHeight, 0, 0) != TCL_OK) { - return TCL_ERROR; + goto errorExit; } Tcl_ResetResult(interp); @@ -1802,7 +2065,22 @@ ImgPhotoConfigureMaster(interp, masterPtr, objc, objv, flags) masterPtr->height, masterPtr->width, masterPtr->height); masterPtr->flags &= ~IMAGE_CHANGED; + if (oldData != NULL) { + Tcl_DecrRefCount(oldData); + } + if (oldFormat != NULL) { + Tcl_DecrRefCount(oldFormat); + } return TCL_OK; + + errorExit: + if (oldData != NULL) { + Tcl_DecrRefCount(oldData); + } + if (oldFormat != NULL) { + Tcl_DecrRefCount(oldFormat); + } + return TCL_ERROR; } /* @@ -1900,6 +2178,8 @@ ImgPhotoConfigureInstance(instancePtr) * to byte-swap any 16 or 32 bit values that we store in the * image in those situations where the server's endianness * is different from ours. + * + * Can't we use autoconf to figure this out? */ if (imagePtr != NULL) { @@ -1977,7 +2257,6 @@ ImgPhotoGet(tkwin, masterData) Colormap colormap; int mono, nRed, nGreen, nBlue; XVisualInfo visualInfo, *visInfoPtr; - XRectangle validBox; char buf[TCL_INTEGER_SPACE * 3]; int numVisuals; XColor *white, *black; @@ -2121,8 +2400,10 @@ ImgPhotoGet(tkwin, masterData) gcValues.graphics_exposures = False; instancePtr->gc = Tk_GetGC(tkwin, GCForeground|GCBackground|GCGraphicsExposures, &gcValues); + /* * Set configuration options and finish the initialization of the instance. + * This will also dither the image if necessary. */ ImgPhotoConfigureInstance(instancePtr); @@ -2136,16 +2417,6 @@ ImgPhotoGet(tkwin, masterData) masterPtr->width, masterPtr->height); } - /* - * Dither the image to fill in this instance's pixmap. - */ - - TkClipBox(masterPtr->validRegion, &validBox); - if ((validBox.width > 0) && (validBox.height > 0)) { - DitherInstance(instancePtr, validBox.x, validBox.y, validBox.width, - validBox.height); - } - return (ClientData) instancePtr; } @@ -2346,7 +2617,8 @@ ImgPhotoCmdDeletedProc(clientData) * image's size to `width' x `height' pixels. * * Results: - * None. + * TCL_OK if successful, TCL_ERROR if failure occurred (currently + * just with memory allocation.) * * Side effects: * Storage gets reallocated, for the master and all its instances. @@ -2354,12 +2626,12 @@ ImgPhotoCmdDeletedProc(clientData) *---------------------------------------------------------------------- */ -static void +static int ImgPhotoSetSize(masterPtr, width, height) PhotoMaster *masterPtr; int width, height; { - unsigned char *newPix24; + unsigned char *newPix24 = NULL; int h, offset, pitch; unsigned char *srcPtr, *destPtr; XRectangle validBox, clipBox; @@ -2373,6 +2645,21 @@ ImgPhotoSetSize(masterPtr, width, height) height = masterPtr->userHeight; } + pitch = width * 4; + + /* + * Test if we're going to (re)allocate the main buffer now, so + * that any failures will leave the photo unchanged. + */ + if ((width != masterPtr->width) || (height != masterPtr->height) + || (masterPtr->pix24 == NULL)) { + newPix24 = (unsigned char *) + attemptckalloc((unsigned) (height * pitch)); + if (newPix24 == NULL) { + return TCL_ERROR; + } + } + /* * We have to trim the valid region if it is currently * larger than the new image size. @@ -2393,17 +2680,12 @@ ImgPhotoSetSize(masterPtr, width, height) TkClipBox(masterPtr->validRegion, &validBox); } - if ((width != masterPtr->width) || (height != masterPtr->height) - || (masterPtr->pix24 == NULL)) { - - /* - * Reallocate storage for the 24-bit image and copy - * over valid regions. - */ - - pitch = width * 4; - newPix24 = (unsigned char *) ckalloc((unsigned) (height * pitch)); - + /* + * Use the reallocated storage (allocation above) for the 24-bit + * image and copy over valid regions. Note that this test is true + * precisely when the allocation has already been done. + */ + if (newPix24 != NULL) { /* * Zero the new array. The dithering code shouldn't read the * areas outside validBox, but they might be copied to another @@ -2479,12 +2761,10 @@ ImgPhotoSetSize(masterPtr, width, height) masterPtr->ditherX = 0; masterPtr->ditherY = validBox.height; } - } else { - if ((masterPtr->ditherY > 0) - || ((int) validBox.width < masterPtr->ditherX)) { - masterPtr->ditherX = validBox.width; - masterPtr->ditherY = 0; - } + } else if ((masterPtr->ditherY > 0) + || ((int) validBox.width < masterPtr->ditherX)) { + masterPtr->ditherX = validBox.width; + masterPtr->ditherY = 0; } } @@ -2496,6 +2776,8 @@ ImgPhotoSetSize(masterPtr, width, height) instancePtr = instancePtr->nextPtr) { ImgPhotoInstanceSetSize(instancePtr); } + + return TCL_OK; } /* @@ -2540,6 +2822,10 @@ ImgPhotoInstanceSetSize(instancePtr) (masterPtr->width > 0) ? masterPtr->width: 1, (masterPtr->height > 0) ? masterPtr->height: 1, instancePtr->visualInfo.depth); + if (!newPixmap) { + panic("Fail to create pixmap with Tk_GetPixmap in ImgPhotoInstanceSetSize.\n"); + return; + } /* * The following is a gross hack needed to properly support colormaps @@ -2654,7 +2940,7 @@ static int IsValidPalette(instancePtr, palette) PhotoInstance *instancePtr; /* Instance to which the palette * specification is to be applied. */ - char *palette; /* Palette specification string. */ + CONST char *palette; /* Palette specification string. */ { int nRed, nGreen, nBlue, mono, numColors; char *endp; @@ -2932,7 +3218,6 @@ AllocateColors(colorPtr) * shades of each primary. */ - nRed = nGreen = nBlue = 0; mono = sscanf(colorPtr->id.palette, "%d/%d/%d", &nRed, &nGreen, &nBlue) <= 1; igam = 1.0 / colorPtr->id.gamma; @@ -3436,7 +3721,7 @@ MatchFileFormat(interp, chan, fileName, formatObj, imageFormatPtr, } } if (formatPtr->fileMatchProc != NULL) { - (void) Tcl_Seek(chan, 0L, SEEK_SET); + (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET); if ((*formatPtr->fileMatchProc)(chan, fileName, formatObj, widthPtr, heightPtr, interp)) { @@ -3451,35 +3736,35 @@ MatchFileFormat(interp, chan, fileName, formatObj, imageFormatPtr, } } if (formatPtr == NULL) { - useoldformat = 1; - for (formatPtr = tsdPtr->oldFormatList; formatPtr != NULL; - formatPtr = formatPtr->nextPtr) { - if (formatString != NULL) { - if (strncasecmp(formatString, - formatPtr->name, strlen(formatPtr->name)) != 0) { - continue; - } - matched = 1; - if (formatPtr->fileMatchProc == NULL) { - Tcl_AppendResult(interp, "-file option isn't supported for ", - formatString, " images", (char *) NULL); - return TCL_ERROR; - } - } - if (formatPtr->fileMatchProc != NULL) { - (void) Tcl_Seek(chan, 0L, SEEK_SET); - if ((*formatPtr->fileMatchProc)(chan, fileName, (Tcl_Obj *) formatString, - widthPtr, heightPtr, interp)) { - if (*widthPtr < 1) { - *widthPtr = 1; + useoldformat = 1; + for (formatPtr = tsdPtr->oldFormatList; formatPtr != NULL; + formatPtr = formatPtr->nextPtr) { + if (formatString != NULL) { + if (strncasecmp(formatString, + formatPtr->name, strlen(formatPtr->name)) != 0) { + continue; } - if (*heightPtr < 1) { - *heightPtr = 1; + matched = 1; + if (formatPtr->fileMatchProc == NULL) { + Tcl_AppendResult(interp, "-file option isn't supported", + " for ", formatString, " images", (char *) NULL); + return TCL_ERROR; + } + } + if (formatPtr->fileMatchProc != NULL) { + (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET); + if ((*formatPtr->fileMatchProc)(chan, fileName, (Tcl_Obj *) + formatString, widthPtr, heightPtr, interp)) { + if (*widthPtr < 1) { + *widthPtr = 1; + } + if (*heightPtr < 1) { + *heightPtr = 1; + } + break; } - break; } } - } } if (formatPtr == NULL) { @@ -3497,7 +3782,7 @@ MatchFileFormat(interp, chan, fileName, formatObj, imageFormatPtr, *imageFormatPtr = formatPtr; *oldformat = useoldformat; - (void) Tcl_Seek(chan, 0L, SEEK_SET); + (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET); return TCL_OK; } @@ -3576,34 +3861,34 @@ MatchStringFormat(interp, data, formatObj, imageFormatPtr, } if (formatPtr == NULL) { - useoldformat = 1; - for (formatPtr = tsdPtr->oldFormatList; formatPtr != NULL; - formatPtr = formatPtr->nextPtr) { - if (formatObj != NULL) { - if (strncasecmp(formatString, - formatPtr->name, strlen(formatPtr->name)) != 0) { - continue; + useoldformat = 1; + for (formatPtr = tsdPtr->oldFormatList; formatPtr != NULL; + formatPtr = formatPtr->nextPtr) { + if (formatObj != NULL) { + if (strncasecmp(formatString, + formatPtr->name, strlen(formatPtr->name)) != 0) { + continue; + } + matched = 1; + if (formatPtr->stringMatchProc == NULL) { + Tcl_AppendResult(interp, "-data option isn't supported", + " for ", formatString, " images", (char *) NULL); + return TCL_ERROR; + } } - matched = 1; - if (formatPtr->stringMatchProc == NULL) { - Tcl_AppendResult(interp, "-data option isn't supported for ", - formatString, " images", (char *) NULL); - return TCL_ERROR; + if ((formatPtr->stringMatchProc != NULL) + && (formatPtr->stringReadProc != NULL) + && (*formatPtr->stringMatchProc)( + (Tcl_Obj *) Tcl_GetString(data), + (Tcl_Obj *) formatString, + widthPtr, heightPtr, interp)) { + break; } } - if ((formatPtr->stringMatchProc != NULL) - && (formatPtr->stringReadProc != NULL) - && (*formatPtr->stringMatchProc)((Tcl_Obj *) Tcl_GetString(data), - (Tcl_Obj *) formatString, - widthPtr, heightPtr, interp)) { - break; - } - } } if (formatPtr == NULL) { if ((formatObj != NULL) && !matched) { - Tcl_AppendResult(interp, "image format \"", - formatString, + Tcl_AppendResult(interp, "image format \"", formatString, "\" is not supported", (char *) NULL); } else { Tcl_AppendResult(interp, "couldn't recognize image data", @@ -3641,7 +3926,7 @@ Tk_PhotoHandle Tk_FindPhoto(interp, imageName) Tcl_Interp *interp; /* Interpreter (application) in which image * exists. */ - char *imageName; /* Name of the desired photo image. */ + CONST char *imageName; /* Name of the desired photo image. */ { ClientData clientData; Tk_ImageType *typePtr; @@ -3670,7 +3955,7 @@ Tk_FindPhoto(interp, imageName) *---------------------------------------------------------------------- */ void -Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height) +Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height, compRule) Tk_PhotoHandle handle; /* Opaque handle for the photo image * to be updated. */ register Tk_PhotoImageBlock *blockPtr; @@ -3680,6 +3965,8 @@ Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height) * be updated in the image. */ int width, height; /* Dimensions of the area of the image * to be updated. */ + int compRule; /* Compositing rule to use when processing + * transparent pixels. */ { register PhotoMaster *masterPtr; int xEnd, yEnd; @@ -3700,14 +3987,17 @@ Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height) && ((y + height) > masterPtr->userHeight)) { height = masterPtr->userHeight - y; } - if ((width <= 0) || (height <= 0)) + if ((width <= 0) || (height <= 0)) { return; + } xEnd = x + width; yEnd = y + height; if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) { - ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width), - MAX(yEnd, masterPtr->height)); + if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width), + MAX(yEnd, masterPtr->height)) == TCL_ERROR) { + panic(TK_PHOTO_ALLOC_FAILURE_MESSAGE); + } } if ((y < masterPtr->ditherY) || ((y == masterPtr->ditherY) @@ -3753,40 +4043,82 @@ Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height) && (greenOffset == 1) && (blueOffset == 2) && (alphaOffset == 3) && (width <= blockPtr->width) && (height <= blockPtr->height) && ((height == 1) || ((x == 0) && (width == masterPtr->width) - && (blockPtr->pitch == pitch)))) { + && (blockPtr->pitch == pitch))) + && (compRule == TK_PHOTO_COMPOSITE_SET)) { memcpy((VOID *) destLinePtr, (VOID *) (blockPtr->pixelPtr + blockPtr->offset[0]), (size_t) (height * width * 4)); } else { + int alpha; for (hLeft = height; hLeft > 0;) { srcLinePtr = blockPtr->pixelPtr + blockPtr->offset[0]; hCopy = MIN(hLeft, blockPtr->height); hLeft -= hCopy; for (; hCopy > 0; --hCopy) { - destPtr = destLinePtr; - for (wLeft = width; wLeft > 0;) { - wCopy = MIN(wLeft, blockPtr->width); - wLeft -= wCopy; - srcPtr = srcLinePtr; - for (; wCopy > 0; --wCopy) { - if (!destPtr[3]) { - destPtr[0] = destPtr[1] = destPtr[2] = 0xd9; - } - if (!alphaOffset || (srcPtr[alphaOffset] == 255)) { - *destPtr++ = srcPtr[0]; - *destPtr++ = srcPtr[greenOffset]; - *destPtr++ = srcPtr[blueOffset]; - *destPtr++ = 255; - } else { - if (srcPtr[alphaOffset]) { - destPtr[0] += (srcPtr[0] - destPtr[0]) * srcPtr[alphaOffset] / 255; - destPtr[1] += (srcPtr[greenOffset] - destPtr[1]) * srcPtr[alphaOffset] / 255; - destPtr[2] += (srcPtr[blueOffset] - destPtr[2]) * srcPtr[alphaOffset] / 255; - destPtr[3] += (255 - destPtr[3]) * srcPtr[alphaOffset] / 255; - } - destPtr+=4; - } - srcPtr += blockPtr->pixelSize; + if ((blockPtr->pixelSize == 4) && (greenOffset == 1) + && (blueOffset == 2) && (alphaOffset == 3) + && (width <= blockPtr->width) + && (compRule == TK_PHOTO_COMPOSITE_SET)) { + memcpy((VOID *) destLinePtr, (VOID *) srcLinePtr, + (size_t) (width * 4)); + } else { + destPtr = destLinePtr; + for (wLeft = width; wLeft > 0;) { + wCopy = MIN(wLeft, blockPtr->width); + wLeft -= wCopy; + srcPtr = srcLinePtr; + for (; wCopy > 0; --wCopy) { + alpha = srcPtr[alphaOffset]; + /* + * In the easy case, we can just copy. + */ + if (!alphaOffset || (alpha == 255)) { + /* new solid part of the image */ + *destPtr++ = srcPtr[0]; + *destPtr++ = srcPtr[greenOffset]; + *destPtr++ = srcPtr[blueOffset]; + *destPtr++ = 255; + srcPtr += blockPtr->pixelSize; + continue; + } + + /* + * Combine according to the compositing rule. + */ + switch (compRule) { + case TK_PHOTO_COMPOSITE_SET: + *destPtr++ = srcPtr[0]; + *destPtr++ = srcPtr[greenOffset]; + *destPtr++ = srcPtr[blueOffset]; + *destPtr++ = alpha; + break; + + case TK_PHOTO_COMPOSITE_OVERLAY: + if (!destPtr[3]) { + /* + * There must be a better way to select a + * background colour! + */ + destPtr[0] = destPtr[1] = destPtr[2] = 0xd9; + } + + if (alpha) { + destPtr[0] += (srcPtr[0] - destPtr[0]) * alpha / 255; + destPtr[1] += (srcPtr[greenOffset] - destPtr[1]) * alpha / 255; + destPtr[2] += (srcPtr[blueOffset] - destPtr[2]) * alpha / 255; + destPtr[3] += (255 - destPtr[3]) * alpha / 255; + } + /* + * else should be empty space + */ + destPtr += 4; + break; + + default: + panic("unknown compositing rule: %d", compRule); + } + srcPtr += blockPtr->pixelSize; + } } } srcLinePtr += blockPtr->pitch; @@ -3799,61 +4131,81 @@ Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height) * Add this new block to the region which specifies which data is valid. */ - if (alphaOffset) { - int x1, y1, end; - - /* - * This block is grossly inefficient. For each row in the image, it - * finds each continguous string of transparent pixels, then marks those - * areas as invalid in the validRegion mask. This makes drawing very - * efficient, because of the way we use X: we just say, here's your - * mask, and here's your data. We need not worry about the current - * background color, etc. But this costs us a lot on the image setup. - * Still, image setup only happens once, whereas the drawing happens - * many times, so this might be the best way to go. - * - * An alternative might be to not set up this mask, and instead, at - * drawing time, for each transparent pixel, set its color to the - * color of the background behind that pixel. This is what I suspect - * most of programs do. However, they don't have to deal with the canvas, - * which could have many different background colors. Determining the - * correct bg color for a given pixel might be expensive. - */ - - destLinePtr = masterPtr->pix24 + (y * masterPtr->width + x) * 4 + 3; - for (y1 = 0; y1 < height; y1++) { - x1 = 0; - destPtr = destLinePtr; - while (x1 < width) { - /* search for first non-transparent pixel */ - while ((x1 < width) && !*destPtr) { - x1++; destPtr += 4; - } - end = x1; - /* search for first transparent pixel */ - while ((end < width) && *destPtr) { - end++; destPtr += 4; - } - if (end > x1) { - rect.x = x + x1; - rect.y = y + y1; - rect.width = end - x1; - rect.height = 1; - TkUnionRectWithRegion(&rect, masterPtr->validRegion, - masterPtr->validRegion); + if (alphaOffset) { + int x1, y1, end; + + /* + * This block is grossly inefficient. For each row in the image, it + * finds each continguous string of nontransparent pixels, then marks + * those areas as valid in the validRegion mask. This makes drawing + * very efficient, because of the way we use X: we just say, here's + * your mask, and here's your data. We need not worry about the + * current background color, etc. But this costs us a lot on the + * image setup. Still, image setup only happens once, whereas the + * drawing happens many times, so this might be the best way to go. + * + * An alternative might be to not set up this mask, and instead, at + * drawing time, for each transparent pixel, set its color to the + * color of the background behind that pixel. This is what I suspect + * most of programs do. However, they don't have to deal with the + * canvas, which could have many different background colors. + * Determining the correct bg color for a given pixel might be + * expensive. + */ + + if (compRule != TK_PHOTO_COMPOSITE_OVERLAY) { + /* + * Don't need this when using the OVERLAY compositing rule, + * which always strictly increases the valid region. + */ + TkRegion workRgn = TkCreateRegion(); + + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + TkUnionRectWithRegion(&rect, workRgn, workRgn); + TkSubtractRegion(masterPtr->validRegion, workRgn, + masterPtr->validRegion); + TkDestroyRegion(workRgn); + } + + destLinePtr = masterPtr->pix24 + (y * masterPtr->width + x) * 4 + 3; + for (y1 = 0; y1 < height; y1++) { + x1 = 0; + destPtr = destLinePtr; + while (x1 < width) { + /* search for first non-transparent pixel */ + while ((x1 < width) && !*destPtr) { + x1++; + destPtr += 4; + } + end = x1; + /* search for first transparent pixel */ + while ((end < width) && *destPtr) { + end++; + destPtr += 4; + } + if (end > x1) { + rect.x = x + x1; + rect.y = y + y1; + rect.width = end - x1; + rect.height = 1; + TkUnionRectWithRegion(&rect, masterPtr->validRegion, + masterPtr->validRegion); + } + x1 = end; } - x1 = end; + destLinePtr += masterPtr->width * 4; } - destLinePtr += masterPtr->width * 4; + } else { + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + TkUnionRectWithRegion(&rect, masterPtr->validRegion, + masterPtr->validRegion); } - } else { - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height; - TkUnionRectWithRegion(&rect, masterPtr->validRegion, - masterPtr->validRegion); - } /* * Update each instance. @@ -3889,7 +4241,7 @@ Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height) void Tk_PhotoPutZoomedBlock(handle, blockPtr, x, y, width, height, zoomX, zoomY, - subsampleX, subsampleY) + subsampleX, subsampleY, compRule) Tk_PhotoHandle handle; /* Opaque handle for the photo image * to be updated. */ register Tk_PhotoImageBlock *blockPtr; @@ -3901,6 +4253,8 @@ Tk_PhotoPutZoomedBlock(handle, blockPtr, x, y, width, height, zoomX, zoomY, * to be updated. */ int zoomX, zoomY; /* Zoom factors for the X and Y axes. */ int subsampleX, subsampleY; /* Subsampling factors for the X and Y axes. */ + int compRule; /* Compositing rule to use when processing + * transparent pixels. */ { register PhotoMaster *masterPtr; int xEnd, yEnd; @@ -3915,16 +4269,16 @@ Tk_PhotoPutZoomedBlock(handle, blockPtr, x, y, width, height, zoomX, zoomY, int blockXSkip, blockYSkip; XRectangle rect; - if ((zoomX == 1) && (zoomY == 1) && (subsampleX == 1) - && (subsampleY == 1)) { - Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height); + if (zoomX==1 && zoomY==1 && subsampleX==1 && subsampleY==1) { + Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height, compRule); return; } masterPtr = (PhotoMaster *) handle; - if ((zoomX <= 0) || (zoomY <= 0)) + if (zoomX <= 0 || zoomY <= 0) { return; + } if ((masterPtr->userWidth != 0) && ((x + width) > masterPtr->userWidth)) { width = masterPtr->userWidth - x; } @@ -3932,15 +4286,18 @@ Tk_PhotoPutZoomedBlock(handle, blockPtr, x, y, width, height, zoomX, zoomY, && ((y + height) > masterPtr->userHeight)) { height = masterPtr->userHeight - y; } - if ((width <= 0) || (height <= 0)) + if (width <= 0 || height <= 0) { return; + } xEnd = x + width; yEnd = y + height; if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) { int sameSrc = (blockPtr->pixelPtr == masterPtr->pix24); - ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width), - MAX(yEnd, masterPtr->height)); + if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width), + MAX(yEnd, masterPtr->height)) == TCL_ERROR) { + panic(TK_PHOTO_ALLOC_FAILURE_MESSAGE); + } if (sameSrc) { blockPtr->pixelPtr = masterPtr->pix24; } @@ -3980,18 +4337,20 @@ Tk_PhotoPutZoomedBlock(handle, blockPtr, x, y, width, height, zoomX, zoomY, blockXSkip = subsampleX * blockPtr->pixelSize; blockYSkip = subsampleY * blockPtr->pitch; - if (subsampleX > 0) + if (subsampleX > 0) { blockWid = ((blockPtr->width + subsampleX - 1) / subsampleX) * zoomX; - else if (subsampleX == 0) + } else if (subsampleX == 0) { blockWid = width; - else + } else { blockWid = ((blockPtr->width - subsampleX - 1) / -subsampleX) * zoomX; - if (subsampleY > 0) + } + if (subsampleY > 0) { blockHt = ((blockPtr->height + subsampleY - 1) / subsampleY) * zoomY; - else if (subsampleY == 0) + } else if (subsampleY == 0) { blockHt = height; - else + } else { blockHt = ((blockPtr->height - subsampleY - 1) / -subsampleY) * zoomY; + } /* * Copy the data into our local 24-bit/pixel array. @@ -4020,23 +4379,43 @@ Tk_PhotoPutZoomedBlock(handle, blockPtr, x, y, width, height, zoomX, zoomY, srcPtr = srcLinePtr; for (; wCopy > 0; wCopy -= zoomX) { for (xRepeat = MIN(wCopy, zoomX); xRepeat > 0; xRepeat--) { - if (!destPtr[3]) { - destPtr[0] = destPtr[1] = destPtr[2] = 0xd9; - } - if (!alphaOffset || (srcPtr[alphaOffset] == 255)) { - *destPtr++ = srcPtr[0]; - *destPtr++ = srcPtr[greenOffset]; - *destPtr++ = srcPtr[blueOffset]; - *destPtr++ = 255; - } else { - if (srcPtr[alphaOffset]) { - destPtr[0] += (srcPtr[0] - destPtr[0]) * srcPtr[alphaOffset] / 255; - destPtr[1] += (srcPtr[greenOffset] - destPtr[1]) * srcPtr[alphaOffset] / 255; - destPtr[2] += (srcPtr[blueOffset] - destPtr[2]) * srcPtr[alphaOffset] / 255; - destPtr[3] += (255 - destPtr[3]) * srcPtr[alphaOffset] / 255; - } - destPtr+=4; - } + /* + * Common case (solid pixels) first + */ + if (!alphaOffset || (srcPtr[alphaOffset] == 255)) { + *destPtr++ = srcPtr[0]; + *destPtr++ = srcPtr[greenOffset]; + *destPtr++ = srcPtr[blueOffset]; + *destPtr++ = 255; + continue; + } + + switch (compRule) { + case TK_PHOTO_COMPOSITE_SET: + *destPtr++ = srcPtr[0]; + *destPtr++ = srcPtr[greenOffset]; + *destPtr++ = srcPtr[blueOffset]; + *destPtr++ = srcPtr[alphaOffset]; + break; + case TK_PHOTO_COMPOSITE_OVERLAY: + if (!destPtr[3]) { + /* + * There must be a better way to select a + * background colour! + */ + destPtr[0] = destPtr[1] = destPtr[2] = 0xd9; + } + if (srcPtr[alphaOffset]) { + destPtr[0] += (srcPtr[0] - destPtr[0]) * srcPtr[alphaOffset] / 255; + destPtr[1] += (srcPtr[greenOffset] - destPtr[1]) * srcPtr[alphaOffset] / 255; + destPtr[2] += (srcPtr[blueOffset] - destPtr[2]) * srcPtr[alphaOffset] / 255; + destPtr[3] += (255 - destPtr[3]) * srcPtr[alphaOffset] / 255; + } + destPtr += 4; + break; + default: + panic("unknown compositing rule: %d", compRule); + } } srcPtr += blockXSkip; } @@ -4051,46 +4430,65 @@ Tk_PhotoPutZoomedBlock(handle, blockPtr, x, y, width, height, zoomX, zoomY, } /* - * Add this new block to the region that specifies which data is valid. + * Recompute the region of data for which we have valid pixels to plot. */ - if (alphaOffset) { - int x1, y1, end; - - destLinePtr = masterPtr->pix24 + (y * masterPtr->width + x) * 4 + 3; - for (y1 = 0; y1 < height; y1++) { - x1 = 0; - destPtr = destLinePtr; - while (x1 < width) { - /* search for first non-transparent pixel */ - while ((x1 < width) && !*destPtr) { - x1++; destPtr += 4; - } - end = x1; - /* search for first transparent pixel */ - while ((end < width) && *destPtr) { - end++; destPtr += 4; - } - if (end > x1) { - rect.x = x + x1; - rect.y = y + y1; - rect.width = end - x1; - rect.height = 1; - TkUnionRectWithRegion(&rect, masterPtr->validRegion, - masterPtr->validRegion); + if (alphaOffset) { + int x1, y1, end; + + if (compRule != TK_PHOTO_COMPOSITE_OVERLAY) { + /* + * Don't need this when using the OVERLAY compositing rule, which + * always strictly increases the valid region. + */ + TkRegion workRgn = TkCreateRegion(); + + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = 1; + TkUnionRectWithRegion(&rect, workRgn, workRgn); + TkSubtractRegion(masterPtr->validRegion, workRgn, + masterPtr->validRegion); + TkDestroyRegion(workRgn); + } + + destLinePtr = masterPtr->pix24 + (y * masterPtr->width + x) * 4 + 3; + for (y1 = 0; y1 < height; y1++) { + x1 = 0; + destPtr = destLinePtr; + while (x1 < width) { + /* search for first non-transparent pixel */ + while ((x1 < width) && !*destPtr) { + x1++; + destPtr += 4; + } + end = x1; + /* search for first transparent pixel */ + while ((end < width) && *destPtr) { + end++; + destPtr += 4; + } + if (end > x1) { + rect.x = x + x1; + rect.y = y + y1; + rect.width = end - x1; + rect.height = 1; + TkUnionRectWithRegion(&rect, masterPtr->validRegion, + masterPtr->validRegion); + } + x1 = end; } - x1 = end; + destLinePtr += masterPtr->width * 4; } - destLinePtr += masterPtr->width * 4; + } else { + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + TkUnionRectWithRegion(&rect, masterPtr->validRegion, + masterPtr->validRegion); } - } else { - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height; - TkUnionRectWithRegion(&rect, masterPtr->validRegion, - masterPtr->validRegion); - } /* * Update each instance. @@ -4626,8 +5024,10 @@ Tk_PhotoExpand(handle, width, height) height = masterPtr->height; } if ((width != masterPtr->width) || (height != masterPtr->height)) { - ImgPhotoSetSize(masterPtr, MAX(width, masterPtr->width), - MAX(height, masterPtr->height)); + if (ImgPhotoSetSize(masterPtr, MAX(width, masterPtr->width), + MAX(height, masterPtr->height)) == TCL_ERROR) { + panic(TK_PHOTO_ALLOC_FAILURE_MESSAGE); + } Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width, masterPtr->height); } @@ -4696,12 +5096,45 @@ Tk_PhotoSetSize(handle, width, height) masterPtr->userWidth = width; masterPtr->userHeight = height; - ImgPhotoSetSize(masterPtr, ((width > 0) ? width: masterPtr->width), - ((height > 0) ? height: masterPtr->height)); + if (ImgPhotoSetSize(masterPtr, ((width > 0) ? width: masterPtr->width), + ((height > 0) ? height: masterPtr->height)) == TCL_ERROR) { + panic(TK_PHOTO_ALLOC_FAILURE_MESSAGE); + } Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width, masterPtr->height); } +/* + *---------------------------------------------------------------------- + * + * TkGetPhotoValidRegion -- + * + * This procedure is called to get the part of the photo where + * there is valid data. Or, conversely, the part of the photo + * which is transparent. + * + * Results: + * A TkRegion value that indicates the current area of the photo + * that is valid. This value should not be used after any + * modification to the photo image. + * + * Side Effects: + * None. + * + *---------------------------------------------------------------------- + */ + +TkRegion +TkPhotoGetValidRegion(handle) + Tk_PhotoHandle handle; /* Handle for the image whose valid region + * is to obtained. */ +{ + PhotoMaster *masterPtr; + + masterPtr = (PhotoMaster *) handle; + return masterPtr->validRegion; +} + /* *---------------------------------------------------------------------- * @@ -4754,11 +5187,14 @@ ImgGetPhoto(masterPtr, blockPtr, optPtr) + blockPtr->pixelSize - 1; for (x = 0; x < blockPtr->width; x++) { if (*pixelPtr != 255) { - alphaOffset = 3; break; + alphaOffset = 3; + break; } pixelPtr += blockPtr->pixelSize; } - if (alphaOffset) break; + if (alphaOffset) { + break; + } } if (!alphaOffset) { blockPtr->pixelPtr--; @@ -5138,13 +5574,13 @@ Tk_CreatePhotoOption(interp, name, proc) static int ImgPhotoPostscript(clientData, interp, tkwin, psInfo, x, y, width, height, prepass) - ClientData clientData; - Tcl_Interp *interp; - Tk_Window tkwin; - Tk_PostscriptInfo psInfo; /* postscript info */ - int x, y; /* First pixel to output */ - int width, height; /* Width and height of area */ - int prepass; + ClientData clientData; /* Handle for the photo image */ + Tcl_Interp *interp; /* Interpreter */ + Tk_Window tkwin; /* (unused) */ + Tk_PostscriptInfo psInfo; /* postscript info */ + int x, y; /* First pixel to output */ + int width, height; /* Width and height of area */ + int prepass; /* (unused) */ { Tk_PhotoImageBlock block; @@ -5153,4 +5589,35 @@ ImgPhotoPostscript(clientData, interp, tkwin, psInfo, return Tk_PostscriptPhoto(interp, &block, psInfo, width, height); } + +/* + *---------------------------------------------------------------------- + * + * Tk_PhotoPutBlock_NoComposite, Tk_PhotoPutZoomedBlock_NoComposite -- + * + * These backward-compatability functions just exist to fill slots in + * stubs table. For the behaviour of *_NoComposite, refer to the + * corresponding function without the extra suffix. + * + *---------------------------------------------------------------------- + */ +void +Tk_PhotoPutBlock_NoComposite(handle, blockPtr, x, y, width, height) + Tk_PhotoHandle handle; + Tk_PhotoImageBlock *blockPtr; + int x, y, width, height; +{ + Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height, + TK_PHOTO_COMPOSITE_OVERLAY); +} +void +Tk_PhotoPutZoomedBlock_NoComposite(handle, blockPtr, x, y, width, height, + zoomX, zoomY, subsampleX, subsampleY) + Tk_PhotoHandle handle; + Tk_PhotoImageBlock *blockPtr; + int x, y, width, height, zoomX, zoomY, subsampleX, subsampleY; +{ + Tk_PhotoPutZoomedBlock(handle, blockPtr, x, y, width, height, + zoomX, zoomY, subsampleX, subsampleY, TK_PHOTO_COMPOSITE_OVERLAY); +} diff --git a/tk/generic/tkImgUtil.c b/tk/generic/tkImgUtil.c index 810611ddded..b865c9ca18f 100644 --- a/tk/generic/tkImgUtil.c +++ b/tk/generic/tkImgUtil.c @@ -76,4 +76,3 @@ TkAlignImageData(image, alignment, bitOrder) } return data; } - diff --git a/tk/generic/tkInitScript.h b/tk/generic/tkInitScript.h index 0ff30077918..e64c1436be3 100644 --- a/tk/generic/tkInitScript.h +++ b/tk/generic/tkInitScript.h @@ -48,12 +48,11 @@ */ static char initScript[] = "if {[info proc tkInit]==\"\"} {\n\ - proc tkInit {} {\n\ - global tk_library tk_version tk_patchLevel\n\ - rename tkInit {}\n\ - tcl_findLibrary tk $tk_version $tk_patchLevel tk.tcl TK_LIBRARY tk_library\n\ -}\n\ + proc tkInit {} {\n\ + global tk_library tk_version tk_patchLevel\n\ + rename tkInit {}\n\ + tcl_findLibrary tk $tk_version $tk_patchLevel tk.tcl TK_LIBRARY tk_library\n\ + }\n\ }\n\ tkInit"; - diff --git a/tk/generic/tkInt.decls b/tk/generic/tkInt.decls index b4d3d470477..9046efd34b8 100644 --- a/tk/generic/tkInt.decls +++ b/tk/generic/tkInt.decls @@ -73,14 +73,14 @@ declare 10 generic { declare 11 generic { unsigned long TkCreateBindingProcedure (Tcl_Interp *interp, \ Tk_BindingTable bindingTable, \ - ClientData object, char *eventString, \ + ClientData object, CONST char *eventString, \ TkBindEvalProc *evalProc, TkBindFreeProc *freeProc, \ ClientData clientData) } declare 12 generic { TkCursor * TkCreateCursorFromData (Tk_Window tkwin, \ - char *source, char *mask, int width, int height, \ + CONST char *source, CONST char *mask, int width, int height, \ int xHot, int yHot, XColor fg, XColor bg) } @@ -92,7 +92,7 @@ declare 13 generic { declare 14 generic { Tk_Window TkCreateMainWindow (Tcl_Interp *interp, \ - char *screenName, char *baseName) + CONST char *screenName, char *baseName) } declare 15 generic { @@ -178,7 +178,8 @@ declare 32 generic { } declare 33 generic { - char * TkGetDefaultScreenName (Tcl_Interp *interp, char *screenName) + CONST84_RETURN char * TkGetDefaultScreenName (Tcl_Interp *interp, \ + CONST char *screenName) } declare 34 generic { @@ -287,7 +288,7 @@ declare 57 generic { } declare 58 generic { - void TkpDisplayWarning (char *msg, char *title) + void TkpDisplayWarning (CONST char *msg, CONST char *title) } declare 59 generic { @@ -328,7 +329,7 @@ declare 67 generic { } declare 68 generic { - TkDisplay * TkpOpenDisplay (char *display_name) + TkDisplay * TkpOpenDisplay (CONST char *display_name) } declare 69 generic { @@ -357,7 +358,7 @@ declare 74 generic { } declare 75 generic { - int TkpUseWindow (Tcl_Interp *interp, Tk_Window tkwin, char *string) + int TkpUseWindow (Tcl_Interp *interp, Tk_Window tkwin, CONST char *string) } declare 76 generic { @@ -396,10 +397,11 @@ declare 83 generic { void TkSelPropProc (XEvent *eventPtr) } -declare 84 generic { - void TkSetClassProcs (Tk_Window tkwin, \ - TkClassProcs *procs, ClientData instanceData) -} +# Exported publically as Tk_SetClassProcs in 8.4a2 +#declare 84 generic { +# void TkSetClassProcs (Tk_Window tkwin, \ +# TkClassProcs *procs, ClientData instanceData) +#} declare 85 generic { void TkSetWindowMenuBar (Tcl_Interp *interp, \ @@ -518,91 +520,101 @@ declare 110 generic { declare 111 generic { Tcl_Obj * TkpGetSystemDefault (Tk_Window tkwin, \ - char *dbName, char *className) + CONST char *dbName, CONST char *className) } declare 112 generic { void TkpMenuThreadInit (void) } -declare 113 win { +declare 113 {mac aqua win} { void TkClipBox (TkRegion rgn, XRectangle* rect_return) } -declare 113 mac { - void TkClipBox (TkRegion rgn, XRectangle* rect_return) -} - -declare 114 win { - TkRegion TkCreateRegion (void) -} - -declare 114 mac { +declare 114 {mac aqua win} { TkRegion TkCreateRegion (void) } -declare 115 win { - void TkDestroyRegion (TkRegion rgn) -} - -declare 115 mac { +declare 115 {mac aqua win} { void TkDestroyRegion (TkRegion rgn) } -declare 116 win { +declare 116 {mac aqua win} { void TkIntersectRegion (TkRegion sra, TkRegion srcb, TkRegion dr_return) } -declare 116 mac { - void TkIntersectRegion (TkRegion sra, TkRegion srcb, TkRegion dr_return) -} - -declare 117 win { +declare 117 {mac aqua win} { int TkRectInRegion (TkRegion rgn, int x, int y, unsigned int width, \ unsigned int height) } -declare 117 mac { - int TkRectInRegion (TkRegion rgn, int x, int y, unsigned int width, \ - unsigned int height) -} - -declare 118 win { +declare 118 {mac aqua win} { void TkSetRegion (Display* display, GC gc, TkRegion rgn) } -declare 118 mac { - void TkSetRegion (Display* display, GC gc, TkRegion rgn) -} - -declare 119 win { +declare 119 {mac aqua win} { void TkUnionRectWithRegion (XRectangle* rect, \ TkRegion src, TkRegion dr_return) } -declare 119 mac { - void TkUnionRectWithRegion (XRectangle* rect, \ - TkRegion src, TkRegion dr_return) -} +# removed duplicate from tkIntPlat table +#declare 120 mac { +# void TkGenerateActivateEvents (TkWindow *winPtr, int active) +#} -declare 130 mac { - Window TkGetTransientMaster (TkWindow *winPtr) +declare 121 {mac aqua} { + Pixmap TkpCreateNativeBitmap (Display *display, CONST char * source) } -declare 131 mac { - int TkGenerateButtonEvent (int x, int y, \ - Window window, unsigned int state) +declare 122 {mac aqua} { + void TkpDefineNativeBitmaps (void) } -declare 133 mac { - void TkGenWMDestroyEvent (Tk_Window tkwin) -} +# removed duplicate from tkIntPlat table +#declare 123 mac { +# unsigned long TkpGetMS (void) +#} -declare 134 mac { - void TkGenWMConfigureEvent (Tk_Window tkwin, int x, int y, \ - int width, int height, int flags) +declare 124 {mac aqua} { + Pixmap TkpGetNativeAppBitmap (Display *display, \ + CONST char *name, int *width, int *height) } +# removed duplicates from tkIntPlat table +#declare 125 mac { +# void TkPointerDeadWindow (TkWindow *winPtr) +#} +# +#declare 126 mac { +# void TkpSetCapture (TkWindow *winPtr) +#} +# +#declare 127 mac { +# void TkpSetCursor (TkpCursor cursor) +#} +# +#declare 128 mac { +# void TkpWmSetState (TkWindow *winPtr, int state) +#} +# +#declare 130 mac { +# Window TkGetTransientMaster (TkWindow *winPtr) +#} +# +#declare 131 mac { +# int TkGenerateButtonEvent (int x, int y, \ +# Window window, unsigned int state) +#} +# +#declare 133 mac { +# void TkGenWMDestroyEvent (Tk_Window tkwin) +#} +# +#declare 134 mac { +# void TkGenWMConfigureEvent (Tk_Window tkwin, int x, int y, \ +# int width, int height, int flags) +#} + declare 135 generic { void TkpDrawHighlightBorder (Tk_Window tkwin, GC fgGC, GC bgGC, \ int highlightWidth, Drawable drawable) @@ -625,6 +637,37 @@ declare 139 generic { void TkpInitKeymapInfo (TkDisplay *dispPtr) } +declare 140 generic { + TkRegion TkPhotoGetValidRegion (Tk_PhotoHandle handle) +} + +declare 141 generic { + TkWindow ** TkWmStackorderToplevel(TkWindow *parentPtr) +} + +declare 142 generic { + void TkFocusFree(TkMainInfo *mainPtr) +} + +declare 143 generic { + void TkClipCleanup(TkDisplay *dispPtr) +} + +declare 144 generic { + void TkGCCleanup(TkDisplay *dispPtr) +} + +declare 145 {mac win aqua} { + void TkSubtractRegion (TkRegion sra, TkRegion srcb, TkRegion dr_return) +} + +declare 146 generic { + void TkStylePkgInit (TkMainInfo *mainPtr) +} +declare 147 generic { + void TkStylePkgFree (TkMainInfo *mainPtr) +} + ############################################################################## # Define the platform specific internal Tcl interface. These functions are @@ -635,39 +678,57 @@ interface tkIntPlat ######################### # Unix specific functions -declare 0 unix { +declare 0 x11 { void TkCreateXEventSource (void) } -declare 1 unix { +declare 1 x11 { void TkFreeWindowId (TkDisplay *dispPtr, Window w) } -declare 2 unix { +declare 2 x11 { void TkInitXId (TkDisplay *dispPtr) } -declare 3 unix { +declare 3 x11 { int TkpCmapStressed (Tk_Window tkwin, Colormap colormap) } -declare 4 unix { +declare 4 x11 { void TkpSync (Display *display) } -declare 5 unix { +declare 5 x11 { Window TkUnixContainerId (TkWindow *winPtr) } -declare 6 unix { +declare 6 x11 { int TkUnixDoOneXEvent (Tcl_Time *timePtr) } -declare 7 unix { +declare 7 x11 { void TkUnixSetMenubar (Tk_Window tkwin, Tk_Window menubar) } - +declare 8 x11 { + int TkpScanWindowId (Tcl_Interp *interp, CONST char *string, Window *idPtr) +} + +declare 9 x11 { + void TkWmCleanup (TkDisplay *dispPtr) +} + +declare 10 x11 { + void TkSendCleanup (TkDisplay *dispPtr) +} + +declare 11 x11 { + void TkFreeXId (TkDisplay *dispPtr) +} + +declare 12 x11 { + int TkpWmSetState (TkWindow *winPtr, int state) +} ############################ # Windows specific functions @@ -693,7 +754,7 @@ declare 5 win { } declare 6 win { - int TkpScanWindowId (Tcl_Interp *interp, char *string, int *idPtr) + int TkpScanWindowId (Tcl_Interp *interp, CONST char *string, Window *idPtr) } declare 7 win { @@ -805,7 +866,7 @@ declare 31 win { declare 32 win { Tcl_Obj * TkWinGetMenuSystemDefault (Tk_Window tkwin, \ - char *dbName, char *className) + CONST char *dbName, CONST char *className) } declare 33 win { @@ -819,23 +880,19 @@ declare 0 mac { void TkGenerateActivateEvents (TkWindow *winPtr, int active) } -declare 1 mac { - Pixmap TkpCreateNativeBitmap (Display *display, char * source) -} - -declare 2 mac { - void TkpDefineNativeBitmaps (void) -} +# removed duplicates from tkInt table +#declare 1 mac { +# Pixmap TkpCreateNativeBitmap (Display *display, CONST char * source) +#} +# +#declare 2 mac { +# void TkpDefineNativeBitmaps (void) +#} declare 3 mac { unsigned long TkpGetMS (void) } -declare 4 mac { - Pixmap TkpGetNativeAppBitmap (Display *display, \ - char *name, int *width, int *height) -} - declare 5 mac { void TkPointerDeadWindow (TkWindow *winPtr) } @@ -852,22 +909,10 @@ declare 8 mac { void TkpWmSetState (TkWindow *winPtr, int state) } -declare 9 mac { - int HandleWMEvent (EventRecord *theEvent) -} - declare 10 mac { void TkAboutDlg (void) } -declare 11 mac { - void TkCreateMacEventSource (void) -} - -declare 12 mac { - void TkFontList (Tcl_Interp *interp, Display *display) -} - declare 13 mac { Window TkGetTransientMaster (TkWindow *winPtr) } @@ -877,19 +922,15 @@ declare 14 mac { Window window, unsigned int state) } -declare 15 mac { - int TkGetCharPositions (XFontStruct *font_struct, char *string, \ - int count, short *buffer) -} - declare 16 mac { void TkGenWMDestroyEvent (Tk_Window tkwin) } -declare 17 mac { - void TkGenWMConfigureEvent (Tk_Window tkwin, int x, int y, \ - int width, int height, int flags) -} +# removed duplicate from tkPlat table (tk.decls) +#declare 17 mac { +# void TkGenWMConfigureEvent (Tk_Window tkwin, int x, int y, \ +# int width, int height, int flags) +#} declare 18 mac { unsigned int TkMacButtonKeyState (void) @@ -899,9 +940,10 @@ declare 19 mac { void TkMacClearMenubarActive (void) } -declare 20 mac { - int TkMacConvertEvent (EventRecord *eventPtr) -} +# removed duplicate from tkPlat table (tk.decls) +#declare 20 mac { +# int TkMacConvertEvent (EventRecord *eventPtr) +#} declare 21 mac { int TkMacDispatchMenuEvent (int menuID, int index) @@ -911,38 +953,32 @@ declare 22 mac { void TkMacInstallCursor (int resizeOverride) } -declare 23 mac { - int TkMacConvertTkEvent (EventRecord *eventPtr, Window window) -} +# removed duplicate from tkPlat table (tk.decls) +#declare 23 mac { +# int TkMacConvertTkEvent (EventRecord *eventPtr, Window window) +#} declare 24 mac { void TkMacHandleTearoffMenu (void) } -declare 25 mac { - void tkMacInstallMWConsole (Tcl_Interp *interp) -} - -declare 26 mac { - void TkMacInvalClipRgns (TkWindow *winPtr) -} +# removed duplicate from tkPlat table (tk.decls) +#declare 26 mac { +# void TkMacInvalClipRgns (TkWindow *winPtr) +#} declare 27 mac { void TkMacDoHLEvent (EventRecord *theEvent) } -declare 28 mac { - void TkMacFontInfo (Font fontId, short *family, \ - short *style, short *size) -} - declare 29 mac { Time TkMacGenerateTime (void) } -declare 30 mac { - GWorldPtr TkMacGetDrawablePort (Drawable drawable) -} +# removed duplicate from tkPlat table (tk.decls) +#declare 30 mac { +# GWorldPtr TkMacGetDrawablePort (Drawable drawable) +#} declare 31 mac { TkWindow * TkMacGetScrollbarGrowWindow (TkWindow *winPtr) @@ -960,17 +996,18 @@ declare 34 mac { void TkMacHandleMenuSelect (long mResult, int optionKeyPressed) } -declare 35 mac { - int TkMacHaveAppearance (void) -} - -declare 36 mac { - void TkMacInitAppleEvents (Tcl_Interp *interp) -} - -declare 37 mac { - void TkMacInitMenus (Tcl_Interp *interp) -} +# removed duplicates from tkPlat table (tk.decls) +#declare 35 mac { +# int TkMacHaveAppearance (void) +#} +# +#declare 36 mac { +# void TkMacInitAppleEvents (Tcl_Interp *interp) +#} +# +#declare 37 mac { +# void TkMacInitMenus (Tcl_Interp *interp) +#} declare 38 mac { void TkMacInvalidateWindow (MacDrawable *macWin, int flag) @@ -1000,10 +1037,6 @@ declare 44 mac { int TkMacResizable (TkWindow *winPtr) } -declare 45 mac { - void TkMacSetEmbedRgn (TkWindow *winPtr, RgnHandle rgn) -} - declare 46 mac { void TkMacSetHelpMenuItemCount (void) } @@ -1044,10 +1077,6 @@ declare 55 mac { void TkMacWindowOffset (WindowRef wRef, int *xOffset, int *yOffset) } -declare 56 mac { - void TkResumeClipboard (void) -} - declare 57 mac { int TkSetMacColor (unsigned long pixel, RGBColor *macColor) } @@ -1060,10 +1089,6 @@ declare 59 mac { void TkSuspendClipboard (void) } -declare 60 mac { - int TkWMGrowToplevel (WindowRef whichWindow, Point start) -} - declare 61 mac { int TkMacZoomToplevel (WindowPtr whichWindow, Point where, short zoomPart) } @@ -1081,6 +1106,236 @@ declare 64 mac { MacDrawable * TkMacGetHostToplevel (TkWindow *winPtr) } +declare 65 mac { + void TkMacPreprocessMenu (void) +} + +declare 66 mac { + int TkpIsWindowFloating (WindowRef window) +} + +######################## +# Mac OS X specific functions + +declare 0 aqua { + void TkGenerateActivateEvents (TkWindow *winPtr, int active) +} + +# removed duplicates from tkInt table +#declare 1 aqua { +# Pixmap TkpCreateNativeBitmap (Display *display, CONST char * source) +#} +# +#declare 2 aqua { +# void TkpDefineNativeBitmaps (void) +#} + +declare 3 aqua { + void TkPointerDeadWindow (TkWindow *winPtr) +} + +declare 4 aqua { + void TkpSetCapture (TkWindow *winPtr) +} + +declare 5 aqua { + void TkpSetCursor (TkpCursor cursor) +} + +declare 6 aqua { + void TkpWmSetState (TkWindow *winPtr, int state) +} + +declare 7 aqua { + void TkAboutDlg (void) +} + +declare 8 aqua { + unsigned int TkMacOSXButtonKeyState (void) +} + +declare 9 aqua { + void TkMacOSXClearMenubarActive (void) +} + +declare 10 aqua { + int TkMacOSXDispatchMenuEvent (int menuID, int index) +} + +declare 11 aqua { + void TkMacOSXInstallCursor (int resizeOverride) +} + +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 (EventRecord *theEvent) +} + +# removed duplicate from tkPlat table (tk.decls) +#declare 15 aqua { +# GWorldPtr TkMacOSXGetDrawablePort (Drawable drawable) +#} + +declare 16 aqua { + Window TkMacOSXGetXWindow (WindowRef macWinPtr) +} + +declare 17 aqua { + int TkMacOSXGrowToplevel (WindowRef whichWindow, Point start) +} + +declare 18 aqua { + void TkMacOSXHandleMenuSelect (long mResult, int optionKeyPressed) +} + +# removed duplicates from tkPlat table (tk.decls) +#declare 19 aqua { +# void TkMacOSXInitAppleEvents (Tcl_Interp *interp) +#} +# +#declare 20 aqua { +# void TkMacOSXInitMenus (Tcl_Interp *interp) +#} + +declare 21 aqua { + void TkMacOSXInvalidateWindow (MacDrawable *macWin, int flag) +} + +declare 22 aqua { + int TkMacOSXIsCharacterMissing (Tk_Font tkfont, unsigned int searchChar) +} + +declare 23 aqua { + void TkMacOSXMakeRealWindowExist (TkWindow *winPtr) +} + +declare 24 aqua { + BitMapPtr TkMacOSXMakeStippleMap(Drawable d1, Drawable d2) +} + +declare 25 aqua { + void TkMacOSXMenuClick (void) +} + +declare 26 aqua { + void TkMacOSXRegisterOffScreenWindow (Window window, GWorldPtr portPtr) +} + +declare 27 aqua { + int TkMacOSXResizable (TkWindow *winPtr) +} + +declare 28 aqua { + void TkMacOSXSetHelpMenuItemCount (void) +} + +declare 29 aqua { + void TkMacOSXSetScrollbarGrow (TkWindow *winPtr, int flag) +} + +declare 30 aqua { + void TkMacOSXSetUpClippingRgn (Drawable drawable) +} + +declare 31 aqua { + void TkMacOSXSetUpGraphicsPort (GC gc, GWorldPtr destPort) +} + +declare 32 aqua { + void TkMacOSXUpdateClipRgn (TkWindow *winPtr) +} + +declare 33 aqua { + void TkMacOSXUnregisterMacWindow (WindowRef portPtr) +} + +declare 34 aqua { + int TkMacOSXUseMenuID (short macID) +} + +declare 35 aqua { + RgnHandle TkMacOSXVisableClipRgn (TkWindow *winPtr) +} + +declare 36 aqua { + void TkMacOSXWinBounds (TkWindow *winPtr, Rect *geometry) +} + +declare 37 aqua { + void TkMacOSXWindowOffset (WindowRef wRef, int *xOffset, int *yOffset) +} + +declare 38 aqua { + int TkSetMacColor (unsigned long pixel, RGBColor *macColor) +} + +declare 39 aqua { + void TkSetWMName (TkWindow *winPtr, Tk_Uid titleUid) +} + +declare 40 aqua { + void TkSuspendClipboard (void) +} + +declare 41 aqua { + int TkMacOSXZoomToplevel (WindowPtr whichWindow, Point where, short zoomPart) +} + +declare 42 aqua { + Tk_Window Tk_TopCoordsToWindow (Tk_Window tkwin, \ + int rootX, int rootY, int *newX, int *newY) +} + +declare 43 aqua { + MacDrawable * TkMacOSXContainerId (TkWindow *winPtr) +} + +declare 44 aqua { + MacDrawable * TkMacOSXGetHostToplevel (TkWindow *winPtr) +} + +declare 45 aqua { + void TkMacOSXPreprocessMenu (void) +} + +declare 46 aqua { + int TkpIsWindowFloating (WindowRef window) +} + +declare 47 aqua { + Tk_Window TkMacOSXGetCapture (void) +} + +declare 49 aqua { + Window TkGetTransientMaster (TkWindow *winPtr) +} + +declare 50 aqua { + int TkGenerateButtonEvent (int x, int y, \ + Window window, unsigned int state) +} + +declare 51 aqua { + void TkGenWMDestroyEvent (Tk_Window tkwin) +} + +# 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) +} ############################################################################## @@ -1091,10 +1346,11 @@ interface tkIntXlib # X functions for Windows -# This slot is reserved for use by the dash patch: -# declare 0 win { -# XSetDashes -# } +declare 0 win { + void XSetDashes (Display* display, GC gc, int dash_offset, + _Xconst char* dash_list, int n) +} + declare 1 win { XModifierKeymap* XGetModifierMapping (Display* d) } @@ -1373,7 +1629,7 @@ declare 61 win { } declare 62 win { - void XSetCommand (Display* d, Window w, char** c, int i) + void XSetCommand (Display* d, Window w, CONST char** c, int i) } declare 63 win { @@ -1557,376 +1813,422 @@ declare 103 win { Status XStringListToTextProperty(char** list, int count, \ XTextProperty* text_prop_return) } +declare 104 win { + void XDrawLine (Display* d, Drawable dr, GC g, int x1, int y1, \ + int x2, int y2) +} +declare 106 win { + void XFillRectangle (Display* display, Drawable d, GC gc, \ + int x, int y, unsigned int width, unsigned int height) +} +declare 105 win { + void XWarpPointer (Display* d, Window s, Window dw, int sx, int sy, \ + unsigned int sw, unsigned int sh, int dx, int dy) +} -# X functions for Mac +# X functions for Mac and Aqua -# This slot is reserved for use by the dash patch: -# declare 0 win { -# XSetDashes -# } +declare 0 {mac aqua} { + void XSetDashes (Display* display, GC gc, int dash_offset, + _Xconst char* dash_list, int n) +} -declare 1 mac { +declare 1 {mac aqua} { XModifierKeymap* XGetModifierMapping (Display* d) } -declare 2 mac { +declare 2 {mac aqua} { 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 mac { +declare 3 {mac aqua} { XImage *XGetImage (Display* d, Drawable dr, int i1, int i2, \ unsigned int ui1, unsigned int ui2, unsigned long ul, int i3) } -declare 4 mac { +declare 4 {mac aqua} { char *XGetAtomName (Display* d,Atom a) } -declare 5 mac { +declare 5 {mac aqua} { char *XKeysymToString (KeySym k) } -declare 6 mac { +declare 6 {mac aqua} { Colormap XCreateColormap (Display* d, Window w, Visual* v, int i) } -declare 7 mac { +declare 7 {mac aqua} { GContext XGContextFromGC (GC g) } -declare 8 mac { +declare 8 {mac aqua} { KeySym XKeycodeToKeysym (Display* d, KeyCode k, int i) } -declare 9 mac { +declare 9 {mac aqua} { KeySym XStringToKeysym (_Xconst char* c) } -declare 10 mac { +declare 10 {mac aqua} { Window XRootWindow (Display* d, int i) } -declare 11 mac { +declare 11 {mac aqua} { XErrorHandler XSetErrorHandler (XErrorHandler x) } -declare 12 mac { +declare 12 {mac aqua} { Status XAllocColor (Display* d, Colormap c, XColor* xp) } -declare 13 mac { +declare 13 {mac aqua} { void XBell (Display* d, int i) } -declare 14 mac { - void XChangeProperty (Display* d, Window w, Atom a, Atom a, int i1, \ +declare 14 {mac aqua} { + void XChangeProperty (Display* d, Window w, Atom a1, Atom a2, int i1, \ int i2, _Xconst unsigned char* c, int i3) } -declare 15 mac { +declare 15 {mac aqua} { void XChangeWindowAttributes (Display* d, Window w, unsigned long ul, \ XSetWindowAttributes* x) } -declare 16 mac { +declare 16 {mac aqua} { void XConfigureWindow (Display* d, Window w, unsigned int i, \ XWindowChanges* x) } -declare 17 mac { +declare 17 {mac aqua} { void 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 mac { +declare 18 {mac aqua} { 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) } -declare 19 mac { +declare 19 {mac aqua} { Pixmap XCreateBitmapFromData(Display* display, Drawable d, \ _Xconst char* data, unsigned int width,unsigned int height) } -declare 20 mac { +declare 20 {mac aqua} { void XDefineCursor (Display* d, Window w, Cursor c) } -declare 21 mac { +declare 21 {mac aqua} { void XDestroyWindow (Display* d, Window w) } -declare 22 mac { +declare 22 {mac aqua} { void XDrawArc (Display* d, Drawable dr, GC g, int i1, int i2, \ unsigned int ui1, unsigned int ui2, int i3, int i4) } -declare 23 mac { +declare 23 {mac aqua} { void XDrawLines (Display* d, Drawable dr, GC g, XPoint* x, int i1, int i2) } -declare 24 mac { +declare 24 {mac aqua} { void XDrawRectangle (Display* d, Drawable dr, GC g, int i1, int i2,\ unsigned int ui1, unsigned int ui2) } -declare 25 mac { +declare 25 {mac aqua} { void XFillArc (Display* d, Drawable dr, GC g, int i1, int i2, \ unsigned int ui1, unsigned int ui2, int i3, int i4) } -declare 26 mac { +declare 26 {mac aqua} { void XFillPolygon (Display* d, Drawable dr, GC g, XPoint* x, \ int i1, int i2, int i3) } -declare 27 mac { +declare 27 {mac aqua} { void XFillRectangles (Display* d, Drawable dr, GC g, XRectangle* x, int i) } -declare 28 mac { +declare 28 {mac aqua} { void XFreeColormap (Display* d, Colormap c) } -declare 29 mac { +declare 29 {mac aqua} { void XFreeColors (Display* d, Colormap c, \ unsigned long* ulp, int i, unsigned long ul) } -declare 30 mac { +declare 30 {mac aqua} { void XFreeModifiermap (XModifierKeymap* x) } -declare 31 mac { +declare 31 {mac aqua} { 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 mac { +declare 32 {mac aqua} { 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 mac { +declare 33 {mac aqua} { int XGrabKeyboard (Display* d, Window w, Bool b, int i1, int i2, Time t) } -declare 34 mac { +declare 34 {mac aqua} { int XGrabPointer (Display* d, Window w1, Bool b, unsigned int ui, \ int i1, int i2, Window w2, Cursor c, Time t) } -declare 35 mac { +declare 35 {mac aqua} { KeyCode XKeysymToKeycode (Display* d, KeySym k) } -declare 36 mac { +declare 36 {mac aqua} { void XMapWindow (Display* d, Window w) } -declare 37 mac { +declare 37 {mac aqua} { void XMoveResizeWindow (Display* d, Window w, int i1, int i2, \ unsigned int ui1, unsigned int ui2) } -declare 38 mac { +declare 38 {mac aqua} { void XMoveWindow (Display* d, Window w, int i1, int i2) } -declare 39 mac { +declare 39 {mac aqua} { Bool XQueryPointer (Display* d, Window w1, Window* w2, Window* w3, \ int* i1, int* i2, int* i3, int* i4, unsigned int* ui) } -declare 40 mac { +declare 40 {mac aqua} { void XRaiseWindow (Display* d, Window w) } -declare 41 mac { +declare 41 {mac aqua} { void XRefreshKeyboardMapping (XMappingEvent* x) } -declare 42 mac { +declare 42 {mac aqua} { void XResizeWindow (Display* d, Window w, unsigned int ui1, \ unsigned int ui2) } -declare 43 mac { +declare 43 {mac aqua} { void XSelectInput (Display* d, Window w, long l) } -declare 44 mac { +declare 44 {mac aqua} { Status XSendEvent (Display* d, Window w, Bool b, long l, XEvent* x) } -declare 45 mac { +declare 45 {mac aqua} { void XSetIconName (Display* d, Window w, _Xconst char* c) } -declare 46 mac { +declare 46 {mac aqua} { void XSetInputFocus (Display* d, Window w, int i, Time t) } -declare 47 mac { +declare 47 {mac aqua} { void XSetSelectionOwner (Display* d, Atom a, Window w, Time t) } -declare 48 mac { +declare 48 {mac aqua} { void XSetWindowBackground (Display* d, Window w, unsigned long ul) } -declare 49 mac { +declare 49 {mac aqua} { void XSetWindowBackgroundPixmap (Display* d, Window w, Pixmap p) } -declare 50 mac { +declare 50 {mac aqua} { void XSetWindowBorder (Display* d, Window w, unsigned long ul) } -declare 51 mac { +declare 51 {mac aqua} { void XSetWindowBorderPixmap (Display* d, Window w, Pixmap p) } -declare 52 mac { +declare 52 {mac aqua} { void XSetWindowBorderWidth (Display* d, Window w, unsigned int ui) } -declare 53 mac { +declare 53 {mac aqua} { void XSetWindowColormap (Display* d, Window w, Colormap c) } -declare 54 mac { +declare 54 {mac aqua} { void XUngrabKeyboard (Display* d, Time t) } -declare 55 mac { +declare 55 {mac aqua} { void XUngrabPointer (Display* d, Time t) } -declare 56 mac { +declare 56 {mac aqua} { void XUnmapWindow (Display* d, Window w) } -declare 57 mac { +declare 57 {mac aqua} { void 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 mac { +declare 58 {mac aqua} { Status XParseColor (Display *display, Colormap map, \ _Xconst char* spec, XColor *colorPtr) } -declare 59 mac { +declare 59 {mac aqua} { GC XCreateGC(Display* display, Drawable d, \ unsigned long valuemask, XGCValues* values) } -declare 60 mac { +declare 60 {mac aqua} { void XFreeGC(Display* display, GC gc) } -declare 61 mac { +declare 61 {mac aqua} { Atom XInternAtom(Display* display,_Xconst char* atom_name, \ Bool only_if_exists) } -declare 62 mac { +declare 62 {mac aqua} { void XSetBackground(Display* display, GC gc, \ unsigned long foreground) } -declare 63 mac { +declare 63 {mac aqua} { void XSetForeground(Display* display, GC gc, \ unsigned long foreground) } -declare 64 mac { +declare 64 {mac aqua} { void XSetClipMask(Display* display, GC gc, Pixmap pixmap) } -declare 65 mac { +declare 65 {mac aqua} { void XSetClipOrigin(Display* display, GC gc, \ int clip_x_origin, int clip_y_origin) } -declare 66 mac { +declare 66 {mac aqua} { void XSetTSOrigin(Display* display, GC gc, \ int ts_x_origin, int ts_y_origin) } -declare 67 mac { +declare 67 {mac aqua} { void XChangeGC(Display * d, GC gc, unsigned long mask, XGCValues *values) } -declare 68 mac { +declare 68 {mac aqua} { void XSetFont(Display *display, GC gc, Font font) } -declare 69 mac { +declare 69 {mac aqua} { void XSetArcMode(Display *display, GC gc, int arc_mode) } -declare 70 mac { +declare 70 {mac aqua} { void XSetStipple(Display *display, GC gc, Pixmap stipple) } -declare 71 mac { +declare 71 {mac aqua} { void XSetFillRule(Display *display, GC gc, int fill_rule) } -declare 72 mac { +declare 72 {mac aqua} { void XSetFillStyle(Display *display, GC gc, int fill_style) } -declare 73 mac { +declare 73 {mac aqua} { void XSetFunction(Display *display, GC gc, int function) } -declare 74 mac { +declare 74 {mac aqua} { void XSetLineAttributes(Display *display, GC gc, \ unsigned int line_width, int line_style, \ int cap_style, int join_style) } -declare 75 mac { +declare 75 {mac aqua} { int _XInitImageFuncPtrs(XImage *image) } -declare 76 mac { +declare 76 {mac aqua} { XIC XCreateIC(void) } -declare 77 mac { +declare 77 {mac aqua} { XVisualInfo *XGetVisualInfo(Display* display, long vinfo_mask, \ XVisualInfo* vinfo_template, int* nitems_return) } -declare 78 mac { +declare 78 {mac aqua} { void XSetWMClientMachine(Display* display, Window w, \ XTextProperty* text_prop) } -declare 79 mac { +declare 79 {mac aqua} { Status XStringListToTextProperty(char** list, int count, \ XTextProperty* text_prop_return) } -declare 80 mac { +declare 80 {mac aqua} { void XDrawSegments(Display *display, Drawable d, GC gc, \ XSegment *segments, int nsegments) } -declare 81 mac { +declare 81 {mac aqua} { void XForceScreenSaver(Display* display, int mode) } +declare 82 {mac aqua} { + void XDrawLine (Display* d, Drawable dr, GC g, int x1, int y1, \ + int x2, int y2) +} +declare 83 {mac aqua} { + void XFillRectangle (Display* display, Drawable d, GC gc, \ + int x, int y, unsigned int width, unsigned int height) +} +declare 84 {mac aqua} { + void XClearWindow (Display* d, Window w) +} +declare 85 {mac aqua} { + void XDrawPoint (Display* display, Drawable d, GC gc, int x, int y) +} + +declare 86 {mac aqua} { + void XDrawPoints (Display* display, Drawable d, GC gc, XPoint *points, \ + int npoints, int mode) +} + +declare 87 {mac aqua} { + void 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 {mac aqua} { + void XQueryColor (Display *display, Colormap colormap, XColor *def_in_out) +} + +declare 89 {mac aqua} { + void XQueryColors (Display *display, Colormap colormap, \ + XColor *defs_in_out, int ncolors) +} diff --git a/tk/generic/tkInt.h b/tk/generic/tkInt.h index 1164edd4b1c..f51496483ec 100644 --- a/tk/generic/tkInt.h +++ b/tk/generic/tkInt.h @@ -46,32 +46,6 @@ typedef int (TkBindEvalProc) _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, XEvent *eventPtr, Tk_Window tkwin, KeySym keySym)); typedef void (TkBindFreeProc) _ANSI_ARGS_((ClientData clientData)); -typedef Window (TkClassCreateProc) _ANSI_ARGS_((Tk_Window tkwin, - Window parent, ClientData instanceData)); -typedef void (TkClassGeometryProc) _ANSI_ARGS_((ClientData instanceData)); -typedef void (TkClassModalProc) _ANSI_ARGS_((Tk_Window tkwin, - XEvent *eventPtr)); - - -/* - * Widget class procedures used to implement platform specific widget - * behavior. - */ - -typedef struct TkClassProcs { - TkClassCreateProc *createProc; - /* Procedure to invoke when the - platform-dependent window needs to be - created. */ - TkClassGeometryProc *geometryProc; - /* Procedure to invoke when the geometry of a - window needs to be recalculated as a result - of some change in the system. */ - TkClassModalProc *modalProc; - /* Procedure to invoke after all bindings on a - widget have been triggered in order to - handle a modal loop. */ -} TkClassProcs; /* * One of the following structures is maintained for each cursor in @@ -107,6 +81,31 @@ typedef struct TkCursor { * together off a single hash table entry. */ } TkCursor; +/* + * This defines whether we should try to use XIM over-the-spot style + * input. Allow users to override it. It is a much more elegant use + * of XIM, but uses a bit more memory. + */ + +#ifndef TK_XIM_SPOT +# define TK_XIM_SPOT 1 +#endif + +/* + * The following structure is kept one-per-TkDisplay to maintain information + * about the caret (cursor location) on this display. This is used to + * dictate global focus location (Windows Accessibility guidelines) and to + * position the IME or XIM over-the-spot window. + */ + +typedef struct TkCaret { + struct TkWindow *winPtr; /* the window on which we requested caret + * placement */ + int x; /* relative x coord of the caret */ + int y; /* relative y coord of the caret */ + int height; /* specified height of the window */ +} TkCaret; + /* * One of the following structures is maintained for each display * containing a window managed by Tk. In part, the structure is @@ -395,6 +394,7 @@ typedef struct TkDisplay { Atom applicationAtom; /* Atom for TK_APPLICATION. */ Atom windowAtom; /* Atom for TK_WINDOW. */ Atom clipboardAtom; /* Atom for CLIPBOARD. */ + Atom utf8Atom; /* Atom for UTF8_STRING. */ Tk_Window clipWindow; /* Window used for clipboard ownership and to * retrieve selections between processes. NULL @@ -438,19 +438,15 @@ typedef struct TkDisplay { /* First in list of chunks of window * identifers that can't be reused right * now. */ - int idCleanupScheduled; /* 1 means a call to WindowIdCleanup has - * already been scheduled, 0 means it + Tcl_TimerToken idCleanupScheduled; + /* If set, it means a call to WindowIdCleanup + * has already been scheduled, 0 means it * hasn't. */ /* * Information used by tkUnixWm.c and tkWinWm.c only: */ - int wmTracing; /* Used to enable or disable tracing in - * this module. If tracing is enabled, - * then information is printed on - * standard output about interesting - * interactions with the window manager. */ struct TkWmInfo *firstWmPtr; /* Points to first top-level window. */ struct TkWmInfo *foregroundWmPtr; /* Points to the foreground window. */ @@ -481,6 +477,9 @@ typedef struct TkDisplay { #ifdef TK_USE_INPUT_METHODS XIM inputMethod; /* Input method for this display */ +#if TK_XIM_SPOT + XFontSet inputXfs; /* XFontSet cached for over-the-spot XIM. */ +#endif #endif /* TK_USE_INPUT_METHODS */ Tcl_HashTable winTable; /* Maps from X window ids to TkWindow ptrs. */ @@ -494,13 +493,40 @@ typedef struct TkDisplay { */ int mouseButtonState; /* current mouse button state for this * display */ - int warpInProgress; Window warpWindow; int warpX; int warpY; - int useInputMethods; /* Whether to use input methods */ + + /* + * The following field(s) were all added for Tk8.4 + */ + long deletionEpoch; /* Incremented by window deletions */ + unsigned int flags; /* Various flag values: these are all + * defined in below. */ + TkCaret caret; /* information about the caret for this + * display. This is not a pointer. */ } TkDisplay; +/* + * Flag values for TkDisplay flags. + * TK_DISPLAY_COLLAPSE_MOTION_EVENTS: (default on) + * Indicates that we should collapse motion events on this display + * TK_DISPLAY_USE_IM: (default on, set via tk.tcl) + * Whether to use input methods for this display + * TK_DISPLAY_XIM_SPOT: (default off) + * Indicates that we should use over-the-spot XIM on this display + * TK_DISPLAY_WM_TRACING: (default off) + * Whether we should do wm tracing on this display. + * TK_DISPLAY_IN_WARP: (default off) + * Indicates that we are in a pointer warp + */ + +#define TK_DISPLAY_COLLAPSE_MOTION_EVENTS (1 << 0) +#define TK_DISPLAY_USE_IM (1 << 1) +#define TK_DISPLAY_XIM_SPOT (1 << 2) +#define TK_DISPLAY_WM_TRACING (1 << 3) +#define TK_DISPLAY_IN_WARP (1 << 4) + /* * One of the following structures exists for each error handler * created by a call to Tk_CreateErrorHandler. The structure @@ -537,8 +563,6 @@ typedef struct TkErrorHandler { } TkErrorHandler; - - /* * One of the following structures exists for each event handler * created by calling Tk_CreateEventHandler. This information @@ -619,7 +643,7 @@ typedef struct TkMainInfo { */ typedef struct { - char *source; /* Bits for bitmap. */ + CONST char *source; /* Bits for bitmap. */ int width, height; /* Dimensions of bitmap. */ int native; /* 0 means generic (X style) bitmap, * 1 means native style bitmap. */ @@ -720,7 +744,7 @@ typedef struct TkWindow { * declared for this window, or * NULL if none. */ #ifdef TK_USE_INPUT_METHODS - XIC inputContext; /* Input context (for input methods). */ + XIC inputContext; /* XIM input context. */ #endif /* TK_USE_INPUT_METHODS */ /* @@ -763,10 +787,12 @@ typedef struct TkWindow { * Tk_GeometryRequest, or 0's if * Tk_GeometryRequest hasn't been * called. */ - int internalBorderWidth; /* Width of internal border of window + int internalBorderLeft; /* Width of internal border of window * (0 means no internal border). Geometry * managers should not normally place children - * on top of the border. */ + * on top of the border. + * Fields for the other three sides are found + * below. */ /* * Information maintained by tkWm.c for window manager communication. @@ -782,7 +808,7 @@ typedef struct TkWindow { * Information used by widget classes. */ - TkClassProcs *classProcsPtr; + Tk_ClassProcs *classProcsPtr; ClientData instanceData; /* @@ -790,6 +816,18 @@ typedef struct TkWindow { */ struct TkWindowPrivate *privatePtr; + + /* + * More information used by tkGeometry.c for geometry management. + */ + + /* The remaining fields of internal border. */ + int internalBorderRight; + int internalBorderTop; + int internalBorderBottom; + + int minReqWidth; /* Minimum requested width. */ + int minReqHeight; /* Minimum requested height. */ } TkWindow; /* @@ -859,6 +897,19 @@ extern TkDisplay *tkDisplayList; #define META_MASK (AnyModifier<<1) #define ALT_MASK (AnyModifier<<2) +/* + * Object types not declared in tkObj.c need to be mentioned here so + * they can be properly registered with Tcl: + */ + +extern Tcl_ObjType tkBorderObjType; +extern Tcl_ObjType tkBitmapObjType; +extern Tcl_ObjType tkColorObjType; +extern Tcl_ObjType tkCursorObjType; +extern Tcl_ObjType tkFontObjType; +extern Tcl_ObjType tkOptionObjType; +extern Tcl_ObjType tkStateKeyObjType; + /* * Miscellaneous variables shared among Tk modules but not exported * to the outside world: @@ -887,25 +938,28 @@ extern int tkSendSerial; * to the outside world: */ -EXTERN int Tk_AfterCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); EXTERN int Tk_BellObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int Tk_BindCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tk_BindtagsCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); +EXTERN int Tk_BindObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); +EXTERN int Tk_BindtagsObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); EXTERN int Tk_ButtonObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); EXTERN int Tk_CanvasObjCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, Tcl_Obj *CONST objv[])); -EXTERN int Tk_CheckbuttonObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int argc, + Tcl_Obj *CONST objv[])); +EXTERN int Tk_CheckbuttonObjCmd _ANSI_ARGS_(( + ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int Tk_ClipboardCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); +EXTERN int Tk_ClipboardObjCmd _ANSI_ARGS_(( + ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[])); EXTERN int Tk_ChooseColorObjCmd _ANSI_ARGS_(( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); @@ -935,22 +989,29 @@ EXTERN int Tk_FocusObjCmd _ANSI_ARGS_((ClientData clientData, EXTERN int Tk_FontObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int Tk_GetOpenFileObjCmd _ANSI_ARGS_((ClientData clientData, +EXTERN int Tk_GetOpenFileObjCmd _ANSI_ARGS_(( + ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int Tk_GetSaveFileObjCmd _ANSI_ARGS_((ClientData clientData, +EXTERN int Tk_GetSaveFileObjCmd _ANSI_ARGS_(( + ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int Tk_GrabCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tk_GridCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); +EXTERN int Tk_GrabObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); +EXTERN int Tk_GridObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); EXTERN int Tk_ImageObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); EXTERN int Tk_LabelObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); +EXTERN int Tk_LabelframeObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); EXTERN int Tk_ListboxObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); @@ -963,16 +1024,24 @@ EXTERN int Tk_MenubuttonObjCmd _ANSI_ARGS_((ClientData clientData, EXTERN int Tk_MessageBoxObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int Tk_MessageCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); +EXTERN int Tk_MessageObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); +EXTERN int Tk_PanedWindowObjCmd _ANSI_ARGS_(( + ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); EXTERN int Tk_OptionObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int Tk_PackCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tk_PlaceCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tk_RadiobuttonObjCmd _ANSI_ARGS_((ClientData clientData, +EXTERN int Tk_PackObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); +EXTERN int Tk_PlaceObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); +EXTERN int Tk_RadiobuttonObjCmd _ANSI_ARGS_(( + ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); EXTERN int Tk_RaiseObjCmd _ANSI_ARGS_((ClientData clientData, @@ -982,21 +1051,26 @@ EXTERN int Tk_ScaleObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); EXTERN int Tk_ScrollbarCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); -EXTERN int Tk_SelectionCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); +EXTERN int Tk_SelectionObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); EXTERN int Tk_SendCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); EXTERN int Tk_SendObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); +EXTERN int Tk_SpinboxObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); EXTERN int Tk_TextCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); EXTERN int Tk_TkObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int Tk_TkwaitCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); +EXTERN int Tk_TkwaitObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); EXTERN int Tk_ToplevelObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); @@ -1006,20 +1080,23 @@ EXTERN int Tk_UpdateObjCmd _ANSI_ARGS_((ClientData clientData, EXTERN int Tk_WinfoObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); -EXTERN int Tk_WmCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); +EXTERN int Tk_WmObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); -void TkConsolePrint _ANSI_ARGS_((Tcl_Interp *interp, - int devId, char *buffer, long size)); +EXTERN void TkConsolePrint _ANSI_ARGS_((Tcl_Interp *interp, + int devId, CONST char *buffer, long size)); EXTERN void TkEventInit _ANSI_ARGS_((void)); +EXTERN void TkRegisterObjTypes _ANSI_ARGS_((void)); + EXTERN int TkCreateMenuCmd _ANSI_ARGS_((Tcl_Interp *interp)); EXTERN int TkDeadAppCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); EXTERN int TkpTestembedCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); EXTERN int TkCanvasGetCoordObj _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, Tcl_Obj *obj, double *doublePtr)); @@ -1034,6 +1111,9 @@ EXTERN char * TkCanvasDashPrintProc _ANSI_ARGS_(( EXTERN int TkGetDoublePixels _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin, CONST char *string, double *doublePtr)); +EXTERN CONST Tk_OptionSpec * + TkGetOptionSpec _ANSI_ARGS_((CONST char *name, + Tk_OptionTable optionTable)); EXTERN int TkOffsetParseProc _ANSI_ARGS_(( ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, CONST char *value, char *widgRec, @@ -1089,17 +1169,9 @@ EXTERN char * TkTilePrintProc _ANSI_ARGS_(( * Unsupported commands. */ EXTERN int TkUnsupported1Cmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); - -/* CYGNUS LOCAL. */ -EXTERN void TkRegisterColorGC _ANSI_ARGS_((XColor *, Display *, - GC, unsigned long)); -EXTERN void TkDeregisterColorGC _ANSI_ARGS_((XColor *, GC, - unsigned long)); + Tcl_Interp *interp, int argc, CONST char **argv)); # undef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLIMPORT #endif /* _TKINT */ - - diff --git a/tk/generic/tkIntDecls.h b/tk/generic/tkIntDecls.h index 0e37d59f8b1..51c14910512 100644 --- a/tk/generic/tkIntDecls.h +++ b/tk/generic/tkIntDecls.h @@ -71,22 +71,22 @@ EXTERN int TkCopyAndGlobalEval _ANSI_ARGS_((Tcl_Interp * interp, EXTERN unsigned long TkCreateBindingProcedure _ANSI_ARGS_(( Tcl_Interp * interp, Tk_BindingTable bindingTable, - ClientData object, char * eventString, + ClientData object, CONST char * eventString, TkBindEvalProc * evalProc, TkBindFreeProc * freeProc, ClientData clientData)); /* 12 */ EXTERN TkCursor * TkCreateCursorFromData _ANSI_ARGS_((Tk_Window tkwin, - char * source, char * mask, int width, - int height, int xHot, int yHot, XColor fg, - XColor bg)); + CONST char * source, CONST char * mask, + int width, int height, int xHot, int yHot, + XColor fg, XColor bg)); /* 13 */ EXTERN int TkCreateFrame _ANSI_ARGS_((ClientData clientData, Tcl_Interp * interp, int argc, char ** argv, int toplevel, char * appName)); /* 14 */ EXTERN Tk_Window TkCreateMainWindow _ANSI_ARGS_((Tcl_Interp * interp, - char * screenName, char * baseName)); + CONST char * screenName, char * baseName)); /* 15 */ EXTERN Time TkCurrentTime _ANSI_ARGS_((TkDisplay * dispPtr)); /* 16 */ @@ -141,8 +141,8 @@ EXTERN void TkGetButtPoints _ANSI_ARGS_((double p1[], EXTERN TkCursor * TkGetCursorByName _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_Uid string)); /* 33 */ -EXTERN char * TkGetDefaultScreenName _ANSI_ARGS_(( - Tcl_Interp * interp, char * screenName)); +EXTERN CONST84_RETURN char * TkGetDefaultScreenName _ANSI_ARGS_(( + Tcl_Interp * interp, CONST char * screenName)); /* 34 */ EXTERN TkDisplay * TkGetDisplay _ANSI_ARGS_((Display * display)); /* 35 */ @@ -214,8 +214,8 @@ EXTERN void TkpCloseDisplay _ANSI_ARGS_((TkDisplay * dispPtr)); EXTERN void TkpClaimFocus _ANSI_ARGS_((TkWindow * topLevelPtr, int force)); /* 58 */ -EXTERN void TkpDisplayWarning _ANSI_ARGS_((char * msg, - char * title)); +EXTERN void TkpDisplayWarning _ANSI_ARGS_((CONST char * msg, + CONST char * title)); /* 59 */ EXTERN void TkpGetAppName _ANSI_ARGS_((Tcl_Interp * interp, Tcl_DString * name)); @@ -241,7 +241,8 @@ EXTERN Window TkpMakeWindow _ANSI_ARGS_((TkWindow * winPtr, EXTERN void TkpMenuNotifyToplevelCreate _ANSI_ARGS_(( Tcl_Interp * interp1, char * menuName)); /* 68 */ -EXTERN TkDisplay * TkpOpenDisplay _ANSI_ARGS_((char * display_name)); +EXTERN TkDisplay * TkpOpenDisplay _ANSI_ARGS_(( + CONST char * display_name)); /* 69 */ EXTERN int TkPointerEvent _ANSI_ARGS_((XEvent * eventPtr, TkWindow * winPtr)); @@ -262,7 +263,7 @@ EXTERN void TkpSetMainMenubar _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * menuName)); /* 75 */ EXTERN int TkpUseWindow _ANSI_ARGS_((Tcl_Interp * interp, - Tk_Window tkwin, char * string)); + Tk_Window tkwin, CONST char * string)); /* 76 */ EXTERN int TkpWindowWasRecentlyDeleted _ANSI_ARGS_((Window win, TkDisplay * dispPtr)); @@ -289,10 +290,7 @@ EXTERN void TkSelEventProc _ANSI_ARGS_((Tk_Window tkwin, EXTERN void TkSelInit _ANSI_ARGS_((Tk_Window tkwin)); /* 83 */ EXTERN void TkSelPropProc _ANSI_ARGS_((XEvent * eventPtr)); -/* 84 */ -EXTERN void TkSetClassProcs _ANSI_ARGS_((Tk_Window tkwin, - TkClassProcs * procs, - ClientData instanceData)); +/* Slot 84 is reserved */ /* 85 */ EXTERN void TkSetWindowMenuBar _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * oldMenuName, @@ -367,7 +365,7 @@ EXTERN void TkpGetSubFonts _ANSI_ARGS_((Tcl_Interp * interp, Tk_Font tkfont)); /* 111 */ EXTERN Tcl_Obj * TkpGetSystemDefault _ANSI_ARGS_((Tk_Window tkwin, - char * dbName, char * className)); + CONST char * dbName, CONST char * className)); /* 112 */ EXTERN void TkpMenuThreadInit _ANSI_ARGS_((void)); #ifdef __WIN32__ @@ -380,6 +378,11 @@ EXTERN void TkClipBox _ANSI_ARGS_((TkRegion rgn, EXTERN void TkClipBox _ANSI_ARGS_((TkRegion rgn, XRectangle* rect_return)); #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 113 */ +EXTERN void TkClipBox _ANSI_ARGS_((TkRegion rgn, + XRectangle* rect_return)); +#endif /* MAC_OSX_TK */ #ifdef __WIN32__ /* 114 */ EXTERN TkRegion TkCreateRegion _ANSI_ARGS_((void)); @@ -388,6 +391,10 @@ EXTERN TkRegion TkCreateRegion _ANSI_ARGS_((void)); /* 114 */ EXTERN TkRegion TkCreateRegion _ANSI_ARGS_((void)); #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 114 */ +EXTERN TkRegion TkCreateRegion _ANSI_ARGS_((void)); +#endif /* MAC_OSX_TK */ #ifdef __WIN32__ /* 115 */ EXTERN void TkDestroyRegion _ANSI_ARGS_((TkRegion rgn)); @@ -396,6 +403,10 @@ EXTERN void TkDestroyRegion _ANSI_ARGS_((TkRegion rgn)); /* 115 */ EXTERN void TkDestroyRegion _ANSI_ARGS_((TkRegion rgn)); #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 115 */ +EXTERN void TkDestroyRegion _ANSI_ARGS_((TkRegion rgn)); +#endif /* MAC_OSX_TK */ #ifdef __WIN32__ /* 116 */ EXTERN void TkIntersectRegion _ANSI_ARGS_((TkRegion sra, @@ -406,6 +417,11 @@ EXTERN void TkIntersectRegion _ANSI_ARGS_((TkRegion sra, EXTERN void TkIntersectRegion _ANSI_ARGS_((TkRegion sra, TkRegion srcb, TkRegion dr_return)); #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 116 */ +EXTERN void TkIntersectRegion _ANSI_ARGS_((TkRegion sra, + TkRegion srcb, TkRegion dr_return)); +#endif /* MAC_OSX_TK */ #ifdef __WIN32__ /* 117 */ EXTERN int TkRectInRegion _ANSI_ARGS_((TkRegion rgn, int x, @@ -418,6 +434,12 @@ EXTERN int TkRectInRegion _ANSI_ARGS_((TkRegion rgn, int x, int y, unsigned int width, unsigned int height)); #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 117 */ +EXTERN int TkRectInRegion _ANSI_ARGS_((TkRegion rgn, int x, + int y, unsigned int width, + unsigned int height)); +#endif /* MAC_OSX_TK */ #ifdef __WIN32__ /* 118 */ EXTERN void TkSetRegion _ANSI_ARGS_((Display* display, GC gc, @@ -428,6 +450,11 @@ EXTERN void TkSetRegion _ANSI_ARGS_((Display* display, GC gc, EXTERN void TkSetRegion _ANSI_ARGS_((Display* display, GC gc, TkRegion rgn)); #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 118 */ +EXTERN void TkSetRegion _ANSI_ARGS_((Display* display, GC gc, + TkRegion rgn)); +#endif /* MAC_OSX_TK */ #ifdef __WIN32__ /* 119 */ EXTERN void TkUnionRectWithRegion _ANSI_ARGS_((XRectangle* rect, @@ -438,67 +465,51 @@ EXTERN void TkUnionRectWithRegion _ANSI_ARGS_((XRectangle* rect, EXTERN void TkUnionRectWithRegion _ANSI_ARGS_((XRectangle* rect, TkRegion src, TkRegion dr_return)); #endif /* MAC_TCL */ -#ifdef MAC_TCL -/* 120 */ -EXTERN void TkGenerateActivateEvents _ANSI_ARGS_(( - TkWindow * winPtr, int active)); -#endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 119 */ +EXTERN void TkUnionRectWithRegion _ANSI_ARGS_((XRectangle* rect, + TkRegion src, TkRegion dr_return)); +#endif /* MAC_OSX_TK */ +/* Slot 120 is reserved */ #ifdef MAC_TCL /* 121 */ EXTERN Pixmap TkpCreateNativeBitmap _ANSI_ARGS_((Display * display, - char * source)); + CONST char * source)); #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 121 */ +EXTERN Pixmap TkpCreateNativeBitmap _ANSI_ARGS_((Display * display, + CONST char * source)); +#endif /* MAC_OSX_TK */ #ifdef MAC_TCL /* 122 */ EXTERN void TkpDefineNativeBitmaps _ANSI_ARGS_((void)); #endif /* MAC_TCL */ -#ifdef MAC_TCL -/* 123 */ -EXTERN unsigned long TkpGetMS _ANSI_ARGS_((void)); -#endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 122 */ +EXTERN void TkpDefineNativeBitmaps _ANSI_ARGS_((void)); +#endif /* MAC_OSX_TK */ +/* Slot 123 is reserved */ #ifdef MAC_TCL /* 124 */ EXTERN Pixmap TkpGetNativeAppBitmap _ANSI_ARGS_((Display * display, CONST char * name, int * width, int * height)); #endif /* MAC_TCL */ -#ifdef MAC_TCL -/* 125 */ -EXTERN void TkPointerDeadWindow _ANSI_ARGS_((TkWindow * winPtr)); -#endif /* MAC_TCL */ -#ifdef MAC_TCL -/* 126 */ -EXTERN void TkpSetCapture _ANSI_ARGS_((TkWindow * winPtr)); -#endif /* MAC_TCL */ -#ifdef MAC_TCL -/* 127 */ -EXTERN void TkpSetCursor _ANSI_ARGS_((TkpCursor cursor)); -#endif /* MAC_TCL */ -#ifdef MAC_TCL -/* 128 */ -EXTERN void TkpWmSetState _ANSI_ARGS_((TkWindow * winPtr, - int state)); -#endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 124 */ +EXTERN Pixmap TkpGetNativeAppBitmap _ANSI_ARGS_((Display * display, + CONST char * name, int * width, int * height)); +#endif /* MAC_OSX_TK */ +/* Slot 125 is reserved */ +/* Slot 126 is reserved */ +/* Slot 127 is reserved */ +/* Slot 128 is reserved */ /* Slot 129 is reserved */ -#ifdef MAC_TCL -/* 130 */ -EXTERN Window TkGetTransientMaster _ANSI_ARGS_((TkWindow * winPtr)); -#endif /* MAC_TCL */ -#ifdef MAC_TCL -/* 131 */ -EXTERN int TkGenerateButtonEvent _ANSI_ARGS_((int x, int y, - Window window, unsigned int state)); -#endif /* MAC_TCL */ +/* Slot 130 is reserved */ +/* Slot 131 is reserved */ /* Slot 132 is reserved */ -#ifdef MAC_TCL -/* 133 */ -EXTERN void TkGenWMDestroyEvent _ANSI_ARGS_((Tk_Window tkwin)); -#endif /* MAC_TCL */ -#ifdef MAC_TCL -/* 134 */ -EXTERN void TkGenWMConfigureEvent _ANSI_ARGS_((Tk_Window tkwin, - int x, int y, int width, int height, - int flags)); -#endif /* MAC_TCL */ +/* Slot 133 is reserved */ +/* Slot 134 is reserved */ /* 135 */ EXTERN void TkpDrawHighlightBorder _ANSI_ARGS_((Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, @@ -514,6 +525,37 @@ EXTERN KeySym TkpGetKeySym _ANSI_ARGS_((TkDisplay * dispPtr, XEvent * eventPtr)); /* 139 */ EXTERN void TkpInitKeymapInfo _ANSI_ARGS_((TkDisplay * dispPtr)); +/* 140 */ +EXTERN TkRegion TkPhotoGetValidRegion _ANSI_ARGS_(( + Tk_PhotoHandle handle)); +/* 141 */ +EXTERN TkWindow ** TkWmStackorderToplevel _ANSI_ARGS_(( + TkWindow * parentPtr)); +/* 142 */ +EXTERN void TkFocusFree _ANSI_ARGS_((TkMainInfo * mainPtr)); +/* 143 */ +EXTERN void TkClipCleanup _ANSI_ARGS_((TkDisplay * dispPtr)); +/* 144 */ +EXTERN void TkGCCleanup _ANSI_ARGS_((TkDisplay * dispPtr)); +#ifdef __WIN32__ +/* 145 */ +EXTERN void TkSubtractRegion _ANSI_ARGS_((TkRegion sra, + TkRegion srcb, TkRegion dr_return)); +#endif /* __WIN32__ */ +#ifdef MAC_TCL +/* 145 */ +EXTERN void TkSubtractRegion _ANSI_ARGS_((TkRegion sra, + TkRegion srcb, TkRegion dr_return)); +#endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 145 */ +EXTERN void TkSubtractRegion _ANSI_ARGS_((TkRegion sra, + TkRegion srcb, TkRegion dr_return)); +#endif /* MAC_OSX_TK */ +/* 146 */ +EXTERN void TkStylePkgInit _ANSI_ARGS_((TkMainInfo * mainPtr)); +/* 147 */ +EXTERN void TkStylePkgFree _ANSI_ARGS_((TkMainInfo * mainPtr)); typedef struct TkIntStubs { int magic; @@ -530,10 +572,10 @@ typedef struct TkIntStubs { int (*tkClipInit) _ANSI_ARGS_((Tcl_Interp * interp, TkDisplay * dispPtr)); /* 8 */ void (*tkComputeAnchor) _ANSI_ARGS_((Tk_Anchor anchor, Tk_Window tkwin, int padX, int padY, int innerWidth, int innerHeight, int * xPtr, int * yPtr)); /* 9 */ int (*tkCopyAndGlobalEval) _ANSI_ARGS_((Tcl_Interp * interp, char * script)); /* 10 */ - unsigned long (*tkCreateBindingProcedure) _ANSI_ARGS_((Tcl_Interp * interp, Tk_BindingTable bindingTable, ClientData object, char * eventString, TkBindEvalProc * evalProc, TkBindFreeProc * freeProc, ClientData clientData)); /* 11 */ - TkCursor * (*tkCreateCursorFromData) _ANSI_ARGS_((Tk_Window tkwin, char * source, char * mask, int width, int height, int xHot, int yHot, XColor fg, XColor bg)); /* 12 */ + unsigned long (*tkCreateBindingProcedure) _ANSI_ARGS_((Tcl_Interp * interp, Tk_BindingTable bindingTable, ClientData object, CONST char * eventString, TkBindEvalProc * evalProc, TkBindFreeProc * freeProc, ClientData clientData)); /* 11 */ + TkCursor * (*tkCreateCursorFromData) _ANSI_ARGS_((Tk_Window tkwin, CONST char * source, CONST char * mask, int width, int height, int xHot, int yHot, XColor fg, XColor bg)); /* 12 */ int (*tkCreateFrame) _ANSI_ARGS_((ClientData clientData, Tcl_Interp * interp, int argc, char ** argv, int toplevel, char * appName)); /* 13 */ - Tk_Window (*tkCreateMainWindow) _ANSI_ARGS_((Tcl_Interp * interp, char * screenName, char * baseName)); /* 14 */ + Tk_Window (*tkCreateMainWindow) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * screenName, char * baseName)); /* 14 */ Time (*tkCurrentTime) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 15 */ void (*tkDeleteAllImages) _ANSI_ARGS_((TkMainInfo * mainPtr)); /* 16 */ void (*tkDoConfigureNotify) _ANSI_ARGS_((TkWindow * winPtr)); /* 17 */ @@ -552,7 +594,7 @@ typedef struct TkIntStubs { char * (*tkGetBitmapData) _ANSI_ARGS_((Tcl_Interp * interp, char * string, char * fileName, int * widthPtr, int * heightPtr, int * hotXPtr, int * hotYPtr)); /* 30 */ void (*tkGetButtPoints) _ANSI_ARGS_((double p1[], double p2[], double width, int project, double m1[], double m2[])); /* 31 */ TkCursor * (*tkGetCursorByName) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tk_Uid string)); /* 32 */ - char * (*tkGetDefaultScreenName) _ANSI_ARGS_((Tcl_Interp * interp, char * screenName)); /* 33 */ + CONST84_RETURN char * (*tkGetDefaultScreenName) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * screenName)); /* 33 */ TkDisplay * (*tkGetDisplay) _ANSI_ARGS_((Display * display)); /* 34 */ int (*tkGetDisplayOf) _ANSI_ARGS_((Tcl_Interp * interp, int objc, Tcl_Obj *CONST objv[], Tk_Window * tkwinPtr)); /* 35 */ TkWindow * (*tkGetFocusWin) _ANSI_ARGS_((TkWindow * winPtr)); /* 36 */ @@ -577,7 +619,7 @@ typedef struct TkIntStubs { int (*tkpChangeFocus) _ANSI_ARGS_((TkWindow * winPtr, int force)); /* 55 */ void (*tkpCloseDisplay) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 56 */ void (*tkpClaimFocus) _ANSI_ARGS_((TkWindow * topLevelPtr, int force)); /* 57 */ - void (*tkpDisplayWarning) _ANSI_ARGS_((char * msg, char * title)); /* 58 */ + void (*tkpDisplayWarning) _ANSI_ARGS_((CONST char * msg, CONST char * title)); /* 58 */ void (*tkpGetAppName) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_DString * name)); /* 59 */ TkWindow * (*tkpGetOtherWindow) _ANSI_ARGS_((TkWindow * winPtr)); /* 60 */ TkWindow * (*tkpGetWrapperWindow) _ANSI_ARGS_((TkWindow * winPtr)); /* 61 */ @@ -587,14 +629,14 @@ typedef struct TkIntStubs { void (*tkpMakeMenuWindow) _ANSI_ARGS_((Tk_Window tkwin, int transient)); /* 65 */ Window (*tkpMakeWindow) _ANSI_ARGS_((TkWindow * winPtr, Window parent)); /* 66 */ void (*tkpMenuNotifyToplevelCreate) _ANSI_ARGS_((Tcl_Interp * interp1, char * menuName)); /* 67 */ - TkDisplay * (*tkpOpenDisplay) _ANSI_ARGS_((char * display_name)); /* 68 */ + TkDisplay * (*tkpOpenDisplay) _ANSI_ARGS_((CONST char * display_name)); /* 68 */ int (*tkPointerEvent) _ANSI_ARGS_((XEvent * eventPtr, TkWindow * winPtr)); /* 69 */ int (*tkPolygonToArea) _ANSI_ARGS_((double * polyPtr, int numPoints, double * rectPtr)); /* 70 */ double (*tkPolygonToPoint) _ANSI_ARGS_((double * polyPtr, int numPoints, double * pointPtr)); /* 71 */ int (*tkPositionInTree) _ANSI_ARGS_((TkWindow * winPtr, TkWindow * treePtr)); /* 72 */ void (*tkpRedirectKeyEvent) _ANSI_ARGS_((TkWindow * winPtr, XEvent * eventPtr)); /* 73 */ void (*tkpSetMainMenubar) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * menuName)); /* 74 */ - int (*tkpUseWindow) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * string)); /* 75 */ + int (*tkpUseWindow) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, CONST char * string)); /* 75 */ int (*tkpWindowWasRecentlyDeleted) _ANSI_ARGS_((Window win, TkDisplay * dispPtr)); /* 76 */ void (*tkQueueEventForAllChildren) _ANSI_ARGS_((TkWindow * winPtr, XEvent * eventPtr)); /* 77 */ int (*tkReadBitmapFile) _ANSI_ARGS_((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 */ @@ -603,7 +645,7 @@ typedef struct TkIntStubs { void (*tkSelEventProc) _ANSI_ARGS_((Tk_Window tkwin, XEvent * eventPtr)); /* 81 */ void (*tkSelInit) _ANSI_ARGS_((Tk_Window tkwin)); /* 82 */ void (*tkSelPropProc) _ANSI_ARGS_((XEvent * eventPtr)); /* 83 */ - void (*tkSetClassProcs) _ANSI_ARGS_((Tk_Window tkwin, TkClassProcs * procs, ClientData instanceData)); /* 84 */ + void *reserved84; void (*tkSetWindowMenuBar) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, char * oldMenuName, char * menuName)); /* 85 */ KeySym (*tkStringToKeysym) _ANSI_ARGS_((char * name)); /* 86 */ int (*tkThickPolyLineToArea) _ANSI_ARGS_((double * coordPtr, int numPoints, double width, int capStyle, int joinStyle, double * rectPtr)); /* 87 */ @@ -630,7 +672,7 @@ typedef struct TkIntStubs { int (*tkGetWindowFromObj) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Window tkwin, Tcl_Obj * objPtr, Tk_Window * windowPtr)); /* 108 */ char * (*tkpGetString) _ANSI_ARGS_((TkWindow * winPtr, XEvent * eventPtr, Tcl_DString * dsPtr)); /* 109 */ void (*tkpGetSubFonts) _ANSI_ARGS_((Tcl_Interp * interp, Tk_Font tkfont)); /* 110 */ - Tcl_Obj * (*tkpGetSystemDefault) _ANSI_ARGS_((Tk_Window tkwin, char * dbName, char * className)); /* 111 */ + Tcl_Obj * (*tkpGetSystemDefault) _ANSI_ARGS_((Tk_Window tkwin, CONST char * dbName, CONST char * className)); /* 111 */ void (*tkpMenuThreadInit) _ANSI_ARGS_((void)); /* 112 */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved113; @@ -641,6 +683,9 @@ typedef struct TkIntStubs { #ifdef MAC_TCL void (*tkClipBox) _ANSI_ARGS_((TkRegion rgn, XRectangle* rect_return)); /* 113 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + void (*tkClipBox) _ANSI_ARGS_((TkRegion rgn, XRectangle* rect_return)); /* 113 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved114; #endif /* UNIX */ @@ -650,6 +695,9 @@ typedef struct TkIntStubs { #ifdef MAC_TCL TkRegion (*tkCreateRegion) _ANSI_ARGS_((void)); /* 114 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + TkRegion (*tkCreateRegion) _ANSI_ARGS_((void)); /* 114 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved115; #endif /* UNIX */ @@ -659,6 +707,9 @@ typedef struct TkIntStubs { #ifdef MAC_TCL void (*tkDestroyRegion) _ANSI_ARGS_((TkRegion rgn)); /* 115 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + void (*tkDestroyRegion) _ANSI_ARGS_((TkRegion rgn)); /* 115 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved116; #endif /* UNIX */ @@ -668,6 +719,9 @@ typedef struct TkIntStubs { #ifdef MAC_TCL void (*tkIntersectRegion) _ANSI_ARGS_((TkRegion sra, TkRegion srcb, TkRegion dr_return)); /* 116 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + void (*tkIntersectRegion) _ANSI_ARGS_((TkRegion sra, TkRegion srcb, TkRegion dr_return)); /* 116 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved117; #endif /* UNIX */ @@ -677,6 +731,9 @@ typedef struct TkIntStubs { #ifdef MAC_TCL int (*tkRectInRegion) _ANSI_ARGS_((TkRegion rgn, int x, int y, unsigned int width, unsigned int height)); /* 117 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + int (*tkRectInRegion) _ANSI_ARGS_((TkRegion rgn, int x, int y, unsigned int width, unsigned int height)); /* 117 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved118; #endif /* UNIX */ @@ -686,6 +743,9 @@ typedef struct TkIntStubs { #ifdef MAC_TCL void (*tkSetRegion) _ANSI_ARGS_((Display* display, GC gc, TkRegion rgn)); /* 118 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + void (*tkSetRegion) _ANSI_ARGS_((Display* display, GC gc, TkRegion rgn)); /* 118 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved119; #endif /* UNIX */ @@ -695,15 +755,10 @@ typedef struct TkIntStubs { #ifdef MAC_TCL void (*tkUnionRectWithRegion) _ANSI_ARGS_((XRectangle* rect, TkRegion src, TkRegion dr_return)); /* 119 */ #endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ - void *reserved120; -#endif /* UNIX */ -#ifdef __WIN32__ +#ifdef MAC_OSX_TK + void (*tkUnionRectWithRegion) _ANSI_ARGS_((XRectangle* rect, TkRegion src, TkRegion dr_return)); /* 119 */ +#endif /* MAC_OSX_TK */ void *reserved120; -#endif /* __WIN32__ */ -#ifdef MAC_TCL - void (*tkGenerateActivateEvents) _ANSI_ARGS_((TkWindow * winPtr, int active)); /* 120 */ -#endif /* MAC_TCL */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved121; #endif /* UNIX */ @@ -711,8 +766,11 @@ typedef struct TkIntStubs { void *reserved121; #endif /* __WIN32__ */ #ifdef MAC_TCL - Pixmap (*tkpCreateNativeBitmap) _ANSI_ARGS_((Display * display, char * source)); /* 121 */ + Pixmap (*tkpCreateNativeBitmap) _ANSI_ARGS_((Display * display, CONST char * source)); /* 121 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + Pixmap (*tkpCreateNativeBitmap) _ANSI_ARGS_((Display * display, CONST char * source)); /* 121 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved122; #endif /* UNIX */ @@ -722,15 +780,10 @@ typedef struct TkIntStubs { #ifdef MAC_TCL void (*tkpDefineNativeBitmaps) _ANSI_ARGS_((void)); /* 122 */ #endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ - void *reserved123; -#endif /* UNIX */ -#ifdef __WIN32__ +#ifdef MAC_OSX_TK + void (*tkpDefineNativeBitmaps) _ANSI_ARGS_((void)); /* 122 */ +#endif /* MAC_OSX_TK */ void *reserved123; -#endif /* __WIN32__ */ -#ifdef MAC_TCL - unsigned long (*tkpGetMS) _ANSI_ARGS_((void)); /* 123 */ -#endif /* MAC_TCL */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved124; #endif /* UNIX */ @@ -740,85 +793,43 @@ typedef struct TkIntStubs { #ifdef MAC_TCL Pixmap (*tkpGetNativeAppBitmap) _ANSI_ARGS_((Display * display, CONST char * name, int * width, int * height)); /* 124 */ #endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ - void *reserved125; -#endif /* UNIX */ -#ifdef __WIN32__ +#ifdef MAC_OSX_TK + Pixmap (*tkpGetNativeAppBitmap) _ANSI_ARGS_((Display * display, CONST char * name, int * width, int * height)); /* 124 */ +#endif /* MAC_OSX_TK */ void *reserved125; -#endif /* __WIN32__ */ -#ifdef MAC_TCL - void (*tkPointerDeadWindow) _ANSI_ARGS_((TkWindow * winPtr)); /* 125 */ -#endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved126; -#endif /* UNIX */ -#ifdef __WIN32__ - void *reserved126; -#endif /* __WIN32__ */ -#ifdef MAC_TCL - void (*tkpSetCapture) _ANSI_ARGS_((TkWindow * winPtr)); /* 126 */ -#endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved127; -#endif /* UNIX */ -#ifdef __WIN32__ - void *reserved127; -#endif /* __WIN32__ */ -#ifdef MAC_TCL - void (*tkpSetCursor) _ANSI_ARGS_((TkpCursor cursor)); /* 127 */ -#endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved128; -#endif /* UNIX */ -#ifdef __WIN32__ - void *reserved128; -#endif /* __WIN32__ */ -#ifdef MAC_TCL - void (*tkpWmSetState) _ANSI_ARGS_((TkWindow * winPtr, int state)); /* 128 */ -#endif /* MAC_TCL */ void *reserved129; -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ - void *reserved130; -#endif /* UNIX */ -#ifdef __WIN32__ void *reserved130; -#endif /* __WIN32__ */ -#ifdef MAC_TCL - Window (*tkGetTransientMaster) _ANSI_ARGS_((TkWindow * winPtr)); /* 130 */ -#endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved131; -#endif /* UNIX */ -#ifdef __WIN32__ - void *reserved131; -#endif /* __WIN32__ */ -#ifdef MAC_TCL - int (*tkGenerateButtonEvent) _ANSI_ARGS_((int x, int y, Window window, unsigned int state)); /* 131 */ -#endif /* MAC_TCL */ void *reserved132; -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved133; -#endif /* UNIX */ -#ifdef __WIN32__ - void *reserved133; -#endif /* __WIN32__ */ -#ifdef MAC_TCL - void (*tkGenWMDestroyEvent) _ANSI_ARGS_((Tk_Window tkwin)); /* 133 */ -#endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ void *reserved134; -#endif /* UNIX */ -#ifdef __WIN32__ - void *reserved134; -#endif /* __WIN32__ */ -#ifdef MAC_TCL - void (*tkGenWMConfigureEvent) _ANSI_ARGS_((Tk_Window tkwin, int x, int y, int width, int height, int flags)); /* 134 */ -#endif /* MAC_TCL */ void (*tkpDrawHighlightBorder) _ANSI_ARGS_((Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable)); /* 135 */ void (*tkSetFocusWin) _ANSI_ARGS_((TkWindow * winPtr, int force)); /* 136 */ void (*tkpSetKeycodeAndState) _ANSI_ARGS_((Tk_Window tkwin, KeySym keySym, XEvent * eventPtr)); /* 137 */ KeySym (*tkpGetKeySym) _ANSI_ARGS_((TkDisplay * dispPtr, XEvent * eventPtr)); /* 138 */ void (*tkpInitKeymapInfo) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 139 */ + TkRegion (*tkPhotoGetValidRegion) _ANSI_ARGS_((Tk_PhotoHandle handle)); /* 140 */ + TkWindow ** (*tkWmStackorderToplevel) _ANSI_ARGS_((TkWindow * parentPtr)); /* 141 */ + void (*tkFocusFree) _ANSI_ARGS_((TkMainInfo * mainPtr)); /* 142 */ + void (*tkClipCleanup) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 143 */ + void (*tkGCCleanup) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 144 */ +#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ + void *reserved145; +#endif /* UNIX */ +#ifdef __WIN32__ + void (*tkSubtractRegion) _ANSI_ARGS_((TkRegion sra, TkRegion srcb, TkRegion dr_return)); /* 145 */ +#endif /* __WIN32__ */ +#ifdef MAC_TCL + void (*tkSubtractRegion) _ANSI_ARGS_((TkRegion sra, TkRegion srcb, TkRegion dr_return)); /* 145 */ +#endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + void (*tkSubtractRegion) _ANSI_ARGS_((TkRegion sra, TkRegion srcb, TkRegion dr_return)); /* 145 */ +#endif /* MAC_OSX_TK */ + void (*tkStylePkgInit) _ANSI_ARGS_((TkMainInfo * mainPtr)); /* 146 */ + void (*tkStylePkgFree) _ANSI_ARGS_((TkMainInfo * mainPtr)); /* 147 */ } TkIntStubs; #ifdef __cplusplus @@ -1171,10 +1182,7 @@ extern TkIntStubs *tkIntStubsPtr; #define TkSelPropProc \ (tkIntStubsPtr->tkSelPropProc) /* 83 */ #endif -#ifndef TkSetClassProcs -#define TkSetClassProcs \ - (tkIntStubsPtr->tkSetClassProcs) /* 84 */ -#endif +/* Slot 84 is reserved */ #ifndef TkSetWindowMenuBar #define TkSetWindowMenuBar \ (tkIntStubsPtr->tkSetWindowMenuBar) /* 85 */ @@ -1299,6 +1307,12 @@ extern TkIntStubs *tkIntStubsPtr; (tkIntStubsPtr->tkClipBox) /* 113 */ #endif #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +#ifndef TkClipBox +#define TkClipBox \ + (tkIntStubsPtr->tkClipBox) /* 113 */ +#endif +#endif /* MAC_OSX_TK */ #ifdef __WIN32__ #ifndef TkCreateRegion #define TkCreateRegion \ @@ -1311,6 +1325,12 @@ extern TkIntStubs *tkIntStubsPtr; (tkIntStubsPtr->tkCreateRegion) /* 114 */ #endif #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +#ifndef TkCreateRegion +#define TkCreateRegion \ + (tkIntStubsPtr->tkCreateRegion) /* 114 */ +#endif +#endif /* MAC_OSX_TK */ #ifdef __WIN32__ #ifndef TkDestroyRegion #define TkDestroyRegion \ @@ -1323,6 +1343,12 @@ extern TkIntStubs *tkIntStubsPtr; (tkIntStubsPtr->tkDestroyRegion) /* 115 */ #endif #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +#ifndef TkDestroyRegion +#define TkDestroyRegion \ + (tkIntStubsPtr->tkDestroyRegion) /* 115 */ +#endif +#endif /* MAC_OSX_TK */ #ifdef __WIN32__ #ifndef TkIntersectRegion #define TkIntersectRegion \ @@ -1335,6 +1361,12 @@ extern TkIntStubs *tkIntStubsPtr; (tkIntStubsPtr->tkIntersectRegion) /* 116 */ #endif #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +#ifndef TkIntersectRegion +#define TkIntersectRegion \ + (tkIntStubsPtr->tkIntersectRegion) /* 116 */ +#endif +#endif /* MAC_OSX_TK */ #ifdef __WIN32__ #ifndef TkRectInRegion #define TkRectInRegion \ @@ -1347,6 +1379,12 @@ extern TkIntStubs *tkIntStubsPtr; (tkIntStubsPtr->tkRectInRegion) /* 117 */ #endif #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +#ifndef TkRectInRegion +#define TkRectInRegion \ + (tkIntStubsPtr->tkRectInRegion) /* 117 */ +#endif +#endif /* MAC_OSX_TK */ #ifdef __WIN32__ #ifndef TkSetRegion #define TkSetRegion \ @@ -1359,6 +1397,12 @@ extern TkIntStubs *tkIntStubsPtr; (tkIntStubsPtr->tkSetRegion) /* 118 */ #endif #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +#ifndef TkSetRegion +#define TkSetRegion \ + (tkIntStubsPtr->tkSetRegion) /* 118 */ +#endif +#endif /* MAC_OSX_TK */ #ifdef __WIN32__ #ifndef TkUnionRectWithRegion #define TkUnionRectWithRegion \ @@ -1371,87 +1415,60 @@ extern TkIntStubs *tkIntStubsPtr; (tkIntStubsPtr->tkUnionRectWithRegion) /* 119 */ #endif #endif /* MAC_TCL */ - -#ifdef MAC_TCL -#ifndef TkGenerateActivateEvents -#define TkGenerateActivateEvents \ - (tkIntStubsPtr->tkGenerateActivateEvents) /* 120 */ +#ifdef MAC_OSX_TK +#ifndef TkUnionRectWithRegion +#define TkUnionRectWithRegion \ + (tkIntStubsPtr->tkUnionRectWithRegion) /* 119 */ #endif -#endif /* MAC_TCL */ +#endif /* MAC_OSX_TK */ +/* Slot 120 is reserved */ #ifdef MAC_TCL #ifndef TkpCreateNativeBitmap #define TkpCreateNativeBitmap \ (tkIntStubsPtr->tkpCreateNativeBitmap) /* 121 */ #endif #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +#ifndef TkpCreateNativeBitmap +#define TkpCreateNativeBitmap \ + (tkIntStubsPtr->tkpCreateNativeBitmap) /* 121 */ +#endif +#endif /* MAC_OSX_TK */ #ifdef MAC_TCL #ifndef TkpDefineNativeBitmaps #define TkpDefineNativeBitmaps \ (tkIntStubsPtr->tkpDefineNativeBitmaps) /* 122 */ #endif #endif /* MAC_TCL */ -#ifdef MAC_TCL -#ifndef TkpGetMS -#define TkpGetMS \ - (tkIntStubsPtr->tkpGetMS) /* 123 */ +#ifdef MAC_OSX_TK +#ifndef TkpDefineNativeBitmaps +#define TkpDefineNativeBitmaps \ + (tkIntStubsPtr->tkpDefineNativeBitmaps) /* 122 */ #endif -#endif /* MAC_TCL */ +#endif /* MAC_OSX_TK */ +/* Slot 123 is reserved */ #ifdef MAC_TCL #ifndef TkpGetNativeAppBitmap #define TkpGetNativeAppBitmap \ (tkIntStubsPtr->tkpGetNativeAppBitmap) /* 124 */ #endif #endif /* MAC_TCL */ -#ifdef MAC_TCL -#ifndef TkPointerDeadWindow -#define TkPointerDeadWindow \ - (tkIntStubsPtr->tkPointerDeadWindow) /* 125 */ -#endif -#endif /* MAC_TCL */ -#ifdef MAC_TCL -#ifndef TkpSetCapture -#define TkpSetCapture \ - (tkIntStubsPtr->tkpSetCapture) /* 126 */ -#endif -#endif /* MAC_TCL */ -#ifdef MAC_TCL -#ifndef TkpSetCursor -#define TkpSetCursor \ - (tkIntStubsPtr->tkpSetCursor) /* 127 */ -#endif -#endif /* MAC_TCL */ -#ifdef MAC_TCL -#ifndef TkpWmSetState -#define TkpWmSetState \ - (tkIntStubsPtr->tkpWmSetState) /* 128 */ +#ifdef MAC_OSX_TK +#ifndef TkpGetNativeAppBitmap +#define TkpGetNativeAppBitmap \ + (tkIntStubsPtr->tkpGetNativeAppBitmap) /* 124 */ #endif -#endif /* MAC_TCL */ +#endif /* MAC_OSX_TK */ +/* Slot 125 is reserved */ +/* Slot 126 is reserved */ +/* Slot 127 is reserved */ +/* Slot 128 is reserved */ /* Slot 129 is reserved */ -#ifdef MAC_TCL -#ifndef TkGetTransientMaster -#define TkGetTransientMaster \ - (tkIntStubsPtr->tkGetTransientMaster) /* 130 */ -#endif -#endif /* MAC_TCL */ -#ifdef MAC_TCL -#ifndef TkGenerateButtonEvent -#define TkGenerateButtonEvent \ - (tkIntStubsPtr->tkGenerateButtonEvent) /* 131 */ -#endif -#endif /* MAC_TCL */ +/* Slot 130 is reserved */ +/* Slot 131 is reserved */ /* Slot 132 is reserved */ -#ifdef MAC_TCL -#ifndef TkGenWMDestroyEvent -#define TkGenWMDestroyEvent \ - (tkIntStubsPtr->tkGenWMDestroyEvent) /* 133 */ -#endif -#endif /* MAC_TCL */ -#ifdef MAC_TCL -#ifndef TkGenWMConfigureEvent -#define TkGenWMConfigureEvent \ - (tkIntStubsPtr->tkGenWMConfigureEvent) /* 134 */ -#endif -#endif /* MAC_TCL */ +/* Slot 133 is reserved */ +/* Slot 134 is reserved */ #ifndef TkpDrawHighlightBorder #define TkpDrawHighlightBorder \ (tkIntStubsPtr->tkpDrawHighlightBorder) /* 135 */ @@ -1472,6 +1489,52 @@ extern TkIntStubs *tkIntStubsPtr; #define TkpInitKeymapInfo \ (tkIntStubsPtr->tkpInitKeymapInfo) /* 139 */ #endif +#ifndef TkPhotoGetValidRegion +#define TkPhotoGetValidRegion \ + (tkIntStubsPtr->tkPhotoGetValidRegion) /* 140 */ +#endif +#ifndef TkWmStackorderToplevel +#define TkWmStackorderToplevel \ + (tkIntStubsPtr->tkWmStackorderToplevel) /* 141 */ +#endif +#ifndef TkFocusFree +#define TkFocusFree \ + (tkIntStubsPtr->tkFocusFree) /* 142 */ +#endif +#ifndef TkClipCleanup +#define TkClipCleanup \ + (tkIntStubsPtr->tkClipCleanup) /* 143 */ +#endif +#ifndef TkGCCleanup +#define TkGCCleanup \ + (tkIntStubsPtr->tkGCCleanup) /* 144 */ +#endif +#ifdef __WIN32__ +#ifndef TkSubtractRegion +#define TkSubtractRegion \ + (tkIntStubsPtr->tkSubtractRegion) /* 145 */ +#endif +#endif /* __WIN32__ */ +#ifdef MAC_TCL +#ifndef TkSubtractRegion +#define TkSubtractRegion \ + (tkIntStubsPtr->tkSubtractRegion) /* 145 */ +#endif +#endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +#ifndef TkSubtractRegion +#define TkSubtractRegion \ + (tkIntStubsPtr->tkSubtractRegion) /* 145 */ +#endif +#endif /* MAC_OSX_TK */ +#ifndef TkStylePkgInit +#define TkStylePkgInit \ + (tkIntStubsPtr->tkStylePkgInit) /* 146 */ +#endif +#ifndef TkStylePkgFree +#define TkStylePkgFree \ + (tkIntStubsPtr->tkStylePkgFree) /* 147 */ +#endif #endif /* defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) */ @@ -1482,4 +1545,3 @@ extern TkIntStubs *tkIntStubsPtr; #endif /* _TKINTDECLS */ - diff --git a/tk/generic/tkIntPlatDecls.h b/tk/generic/tkIntPlatDecls.h index d3240233fe8..0dbb21c8b8e 100644 --- a/tk/generic/tkIntPlatDecls.h +++ b/tk/generic/tkIntPlatDecls.h @@ -32,27 +32,6 @@ * Exported function declarations: */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ -/* 0 */ -EXTERN void TkCreateXEventSource _ANSI_ARGS_((void)); -/* 1 */ -EXTERN void TkFreeWindowId _ANSI_ARGS_((TkDisplay * dispPtr, - Window w)); -/* 2 */ -EXTERN void TkInitXId _ANSI_ARGS_((TkDisplay * dispPtr)); -/* 3 */ -EXTERN int TkpCmapStressed _ANSI_ARGS_((Tk_Window tkwin, - Colormap colormap)); -/* 4 */ -EXTERN void TkpSync _ANSI_ARGS_((Display * display)); -/* 5 */ -EXTERN Window TkUnixContainerId _ANSI_ARGS_((TkWindow * winPtr)); -/* 6 */ -EXTERN int TkUnixDoOneXEvent _ANSI_ARGS_((Tcl_Time * timePtr)); -/* 7 */ -EXTERN void TkUnixSetMenubar _ANSI_ARGS_((Tk_Window tkwin, - Tk_Window menubar)); -#endif /* UNIX */ #ifdef __WIN32__ /* 0 */ EXTERN char * TkAlignImageData _ANSI_ARGS_((XImage * image, @@ -70,7 +49,7 @@ EXTERN void TkpPrintWindowId _ANSI_ARGS_((char * buf, Window window)); /* 6 */ EXTERN int TkpScanWindowId _ANSI_ARGS_((Tcl_Interp * interp, - char * string, int * idPtr)); + CONST char * string, Window * idPtr)); /* 7 */ EXTERN void TkpSetCapture _ANSI_ARGS_((TkWindow * winPtr)); /* 8 */ @@ -138,8 +117,8 @@ EXTERN void TkWinSetForegroundWindow _ANSI_ARGS_(( EXTERN void TkWinDialogDebug _ANSI_ARGS_((int debug)); /* 32 */ EXTERN Tcl_Obj * TkWinGetMenuSystemDefault _ANSI_ARGS_(( - Tk_Window tkwin, char * dbName, - char * className)); + Tk_Window tkwin, CONST char * dbName, + CONST char * className)); /* 33 */ EXTERN int TkWinGetPlatformId _ANSI_ARGS_((void)); #endif /* __WIN32__ */ @@ -147,16 +126,11 @@ EXTERN int TkWinGetPlatformId _ANSI_ARGS_((void)); /* 0 */ EXTERN void TkGenerateActivateEvents _ANSI_ARGS_(( TkWindow * winPtr, int active)); -/* 1 */ -EXTERN Pixmap TkpCreateNativeBitmap _ANSI_ARGS_((Display * display, - char * source)); -/* 2 */ -EXTERN void TkpDefineNativeBitmaps _ANSI_ARGS_((void)); +/* Slot 1 is reserved */ +/* Slot 2 is reserved */ /* 3 */ EXTERN unsigned long TkpGetMS _ANSI_ARGS_((void)); -/* 4 */ -EXTERN Pixmap TkpGetNativeAppBitmap _ANSI_ARGS_((Display * display, - char * name, int * width, int * height)); +/* Slot 4 is reserved */ /* 5 */ EXTERN void TkPointerDeadWindow _ANSI_ARGS_((TkWindow * winPtr)); /* 6 */ @@ -166,61 +140,41 @@ EXTERN void TkpSetCursor _ANSI_ARGS_((TkpCursor cursor)); /* 8 */ EXTERN void TkpWmSetState _ANSI_ARGS_((TkWindow * winPtr, int state)); -/* 9 */ -EXTERN int HandleWMEvent _ANSI_ARGS_((EventRecord * theEvent)); +/* Slot 9 is reserved */ /* 10 */ EXTERN void TkAboutDlg _ANSI_ARGS_((void)); -/* 11 */ -EXTERN void TkCreateMacEventSource _ANSI_ARGS_((void)); -/* 12 */ -EXTERN void TkFontList _ANSI_ARGS_((Tcl_Interp * interp, - Display * display)); +/* Slot 11 is reserved */ +/* Slot 12 is reserved */ /* 13 */ EXTERN Window TkGetTransientMaster _ANSI_ARGS_((TkWindow * winPtr)); /* 14 */ EXTERN int TkGenerateButtonEvent _ANSI_ARGS_((int x, int y, Window window, unsigned int state)); -/* 15 */ -EXTERN int TkGetCharPositions _ANSI_ARGS_(( - XFontStruct * font_struct, char * string, - int count, short * buffer)); +/* Slot 15 is reserved */ /* 16 */ EXTERN void TkGenWMDestroyEvent _ANSI_ARGS_((Tk_Window tkwin)); -/* 17 */ -EXTERN void TkGenWMConfigureEvent _ANSI_ARGS_((Tk_Window tkwin, - int x, int y, int width, int height, - int flags)); +/* Slot 17 is reserved */ /* 18 */ EXTERN unsigned int TkMacButtonKeyState _ANSI_ARGS_((void)); /* 19 */ EXTERN void TkMacClearMenubarActive _ANSI_ARGS_((void)); -/* 20 */ -EXTERN int TkMacConvertEvent _ANSI_ARGS_(( - EventRecord * eventPtr)); +/* Slot 20 is reserved */ /* 21 */ EXTERN int TkMacDispatchMenuEvent _ANSI_ARGS_((int menuID, int index)); /* 22 */ EXTERN void TkMacInstallCursor _ANSI_ARGS_((int resizeOverride)); -/* 23 */ -EXTERN int TkMacConvertTkEvent _ANSI_ARGS_(( - EventRecord * eventPtr, Window window)); +/* Slot 23 is reserved */ /* 24 */ EXTERN void TkMacHandleTearoffMenu _ANSI_ARGS_((void)); -/* 25 */ -EXTERN void tkMacInstallMWConsole _ANSI_ARGS_(( - Tcl_Interp * interp)); -/* 26 */ -EXTERN void TkMacInvalClipRgns _ANSI_ARGS_((TkWindow * winPtr)); +/* Slot 25 is reserved */ +/* Slot 26 is reserved */ /* 27 */ EXTERN void TkMacDoHLEvent _ANSI_ARGS_((EventRecord * theEvent)); -/* 28 */ -EXTERN void TkMacFontInfo _ANSI_ARGS_((Font fontId, - short * family, short * style, short * size)); +/* Slot 28 is reserved */ /* 29 */ EXTERN Time TkMacGenerateTime _ANSI_ARGS_((void)); -/* 30 */ -EXTERN GWorldPtr TkMacGetDrawablePort _ANSI_ARGS_((Drawable drawable)); +/* Slot 30 is reserved */ /* 31 */ EXTERN TkWindow * TkMacGetScrollbarGrowWindow _ANSI_ARGS_(( TkWindow * winPtr)); @@ -232,13 +186,9 @@ EXTERN int TkMacGrowToplevel _ANSI_ARGS_((WindowRef whichWindow, /* 34 */ EXTERN void TkMacHandleMenuSelect _ANSI_ARGS_((long mResult, int optionKeyPressed)); -/* 35 */ -EXTERN int TkMacHaveAppearance _ANSI_ARGS_((void)); -/* 36 */ -EXTERN void TkMacInitAppleEvents _ANSI_ARGS_(( - Tcl_Interp * interp)); -/* 37 */ -EXTERN void TkMacInitMenus _ANSI_ARGS_((Tcl_Interp * interp)); +/* Slot 35 is reserved */ +/* Slot 36 is reserved */ +/* Slot 37 is reserved */ /* 38 */ EXTERN void TkMacInvalidateWindow _ANSI_ARGS_(( MacDrawable * macWin, int flag)); @@ -258,9 +208,7 @@ EXTERN void TkMacRegisterOffScreenWindow _ANSI_ARGS_(( Window window, GWorldPtr portPtr)); /* 44 */ EXTERN int TkMacResizable _ANSI_ARGS_((TkWindow * winPtr)); -/* 45 */ -EXTERN void TkMacSetEmbedRgn _ANSI_ARGS_((TkWindow * winPtr, - RgnHandle rgn)); +/* Slot 45 is reserved */ /* 46 */ EXTERN void TkMacSetHelpMenuItemCount _ANSI_ARGS_((void)); /* 47 */ @@ -285,8 +233,7 @@ EXTERN void TkMacWinBounds _ANSI_ARGS_((TkWindow * winPtr, /* 55 */ EXTERN void TkMacWindowOffset _ANSI_ARGS_((WindowRef wRef, int * xOffset, int * yOffset)); -/* 56 */ -EXTERN void TkResumeClipboard _ANSI_ARGS_((void)); +/* Slot 56 is reserved */ /* 57 */ EXTERN int TkSetMacColor _ANSI_ARGS_((unsigned long pixel, RGBColor * macColor)); @@ -295,9 +242,7 @@ EXTERN void TkSetWMName _ANSI_ARGS_((TkWindow * winPtr, Tk_Uid titleUid)); /* 59 */ EXTERN void TkSuspendClipboard _ANSI_ARGS_((void)); -/* 60 */ -EXTERN int TkWMGrowToplevel _ANSI_ARGS_((WindowRef whichWindow, - Point start)); +/* Slot 60 is reserved */ /* 61 */ EXTERN int TkMacZoomToplevel _ANSI_ARGS_((WindowPtr whichWindow, Point where, short zoomPart)); @@ -308,22 +253,177 @@ EXTERN Tk_Window Tk_TopCoordsToWindow _ANSI_ARGS_((Tk_Window tkwin, EXTERN MacDrawable * TkMacContainerId _ANSI_ARGS_((TkWindow * winPtr)); /* 64 */ EXTERN MacDrawable * TkMacGetHostToplevel _ANSI_ARGS_((TkWindow * winPtr)); +/* 65 */ +EXTERN void TkMacPreprocessMenu _ANSI_ARGS_((void)); +/* 66 */ +EXTERN int TkpIsWindowFloating _ANSI_ARGS_((WindowRef window)); #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 0 */ +EXTERN void TkGenerateActivateEvents _ANSI_ARGS_(( + TkWindow * winPtr, int active)); +/* Slot 1 is reserved */ +/* Slot 2 is reserved */ +/* 3 */ +EXTERN void TkPointerDeadWindow _ANSI_ARGS_((TkWindow * winPtr)); +/* 4 */ +EXTERN void TkpSetCapture _ANSI_ARGS_((TkWindow * winPtr)); +/* 5 */ +EXTERN void TkpSetCursor _ANSI_ARGS_((TkpCursor cursor)); +/* 6 */ +EXTERN void TkpWmSetState _ANSI_ARGS_((TkWindow * winPtr, + int state)); +/* 7 */ +EXTERN void TkAboutDlg _ANSI_ARGS_((void)); +/* 8 */ +EXTERN unsigned int TkMacOSXButtonKeyState _ANSI_ARGS_((void)); +/* 9 */ +EXTERN void TkMacOSXClearMenubarActive _ANSI_ARGS_((void)); +/* 10 */ +EXTERN int TkMacOSXDispatchMenuEvent _ANSI_ARGS_((int menuID, + int index)); +/* 11 */ +EXTERN void TkMacOSXInstallCursor _ANSI_ARGS_(( + int resizeOverride)); +/* 12 */ +EXTERN void TkMacOSXHandleTearoffMenu _ANSI_ARGS_((void)); +/* Slot 13 is reserved */ +/* 14 */ +EXTERN int TkMacOSXDoHLEvent _ANSI_ARGS_(( + EventRecord * theEvent)); +/* Slot 15 is reserved */ +/* 16 */ +EXTERN Window TkMacOSXGetXWindow _ANSI_ARGS_((WindowRef macWinPtr)); +/* 17 */ +EXTERN int TkMacOSXGrowToplevel _ANSI_ARGS_(( + WindowRef whichWindow, Point start)); +/* 18 */ +EXTERN void TkMacOSXHandleMenuSelect _ANSI_ARGS_((long mResult, + int optionKeyPressed)); +/* Slot 19 is reserved */ +/* Slot 20 is reserved */ +/* 21 */ +EXTERN void TkMacOSXInvalidateWindow _ANSI_ARGS_(( + MacDrawable * macWin, int flag)); +/* 22 */ +EXTERN int TkMacOSXIsCharacterMissing _ANSI_ARGS_(( + Tk_Font tkfont, unsigned int searchChar)); +/* 23 */ +EXTERN void TkMacOSXMakeRealWindowExist _ANSI_ARGS_(( + TkWindow * winPtr)); +/* 24 */ +EXTERN BitMapPtr TkMacOSXMakeStippleMap _ANSI_ARGS_((Drawable d1, + Drawable d2)); +/* 25 */ +EXTERN void TkMacOSXMenuClick _ANSI_ARGS_((void)); +/* 26 */ +EXTERN void TkMacOSXRegisterOffScreenWindow _ANSI_ARGS_(( + Window window, GWorldPtr portPtr)); +/* 27 */ +EXTERN int TkMacOSXResizable _ANSI_ARGS_((TkWindow * winPtr)); +/* 28 */ +EXTERN void TkMacOSXSetHelpMenuItemCount _ANSI_ARGS_((void)); +/* 29 */ +EXTERN void TkMacOSXSetScrollbarGrow _ANSI_ARGS_(( + TkWindow * winPtr, int flag)); +/* 30 */ +EXTERN void TkMacOSXSetUpClippingRgn _ANSI_ARGS_(( + Drawable drawable)); +/* 31 */ +EXTERN void TkMacOSXSetUpGraphicsPort _ANSI_ARGS_((GC gc, + GWorldPtr destPort)); +/* 32 */ +EXTERN void TkMacOSXUpdateClipRgn _ANSI_ARGS_((TkWindow * winPtr)); +/* 33 */ +EXTERN void TkMacOSXUnregisterMacWindow _ANSI_ARGS_(( + WindowRef portPtr)); +/* 34 */ +EXTERN int TkMacOSXUseMenuID _ANSI_ARGS_((short macID)); +/* 35 */ +EXTERN RgnHandle TkMacOSXVisableClipRgn _ANSI_ARGS_(( + TkWindow * winPtr)); +/* 36 */ +EXTERN void TkMacOSXWinBounds _ANSI_ARGS_((TkWindow * winPtr, + Rect * geometry)); +/* 37 */ +EXTERN void TkMacOSXWindowOffset _ANSI_ARGS_((WindowRef wRef, + int * xOffset, int * yOffset)); +/* 38 */ +EXTERN int TkSetMacColor _ANSI_ARGS_((unsigned long pixel, + RGBColor * macColor)); +/* 39 */ +EXTERN void TkSetWMName _ANSI_ARGS_((TkWindow * winPtr, + Tk_Uid titleUid)); +/* 40 */ +EXTERN void TkSuspendClipboard _ANSI_ARGS_((void)); +/* 41 */ +EXTERN int TkMacOSXZoomToplevel _ANSI_ARGS_(( + WindowPtr whichWindow, Point where, + short zoomPart)); +/* 42 */ +EXTERN Tk_Window Tk_TopCoordsToWindow _ANSI_ARGS_((Tk_Window tkwin, + int rootX, int rootY, int * newX, int * newY)); +/* 43 */ +EXTERN MacDrawable * TkMacOSXContainerId _ANSI_ARGS_((TkWindow * winPtr)); +/* 44 */ +EXTERN MacDrawable * TkMacOSXGetHostToplevel _ANSI_ARGS_(( + TkWindow * winPtr)); +/* 45 */ +EXTERN void TkMacOSXPreprocessMenu _ANSI_ARGS_((void)); +/* 46 */ +EXTERN int TkpIsWindowFloating _ANSI_ARGS_((WindowRef window)); +/* 47 */ +EXTERN Tk_Window TkMacOSXGetCapture _ANSI_ARGS_((void)); +/* Slot 48 is reserved */ +/* 49 */ +EXTERN Window TkGetTransientMaster _ANSI_ARGS_((TkWindow * winPtr)); +/* 50 */ +EXTERN int TkGenerateButtonEvent _ANSI_ARGS_((int x, int y, + Window window, unsigned int state)); +/* 51 */ +EXTERN void TkGenWMDestroyEvent _ANSI_ARGS_((Tk_Window tkwin)); +/* Slot 52 is reserved */ +/* 53 */ +EXTERN unsigned long TkpGetMS _ANSI_ARGS_((void)); +#endif /* MAC_OSX_TK */ +#if !(defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) /* X11 */ +/* 0 */ +EXTERN void TkCreateXEventSource _ANSI_ARGS_((void)); +/* 1 */ +EXTERN void TkFreeWindowId _ANSI_ARGS_((TkDisplay * dispPtr, + Window w)); +/* 2 */ +EXTERN void TkInitXId _ANSI_ARGS_((TkDisplay * dispPtr)); +/* 3 */ +EXTERN int TkpCmapStressed _ANSI_ARGS_((Tk_Window tkwin, + Colormap colormap)); +/* 4 */ +EXTERN void TkpSync _ANSI_ARGS_((Display * display)); +/* 5 */ +EXTERN Window TkUnixContainerId _ANSI_ARGS_((TkWindow * winPtr)); +/* 6 */ +EXTERN int TkUnixDoOneXEvent _ANSI_ARGS_((Tcl_Time * timePtr)); +/* 7 */ +EXTERN void TkUnixSetMenubar _ANSI_ARGS_((Tk_Window tkwin, + Tk_Window menubar)); +/* 8 */ +EXTERN int TkpScanWindowId _ANSI_ARGS_((Tcl_Interp * interp, + CONST char * string, Window * idPtr)); +/* 9 */ +EXTERN void TkWmCleanup _ANSI_ARGS_((TkDisplay * dispPtr)); +/* 10 */ +EXTERN void TkSendCleanup _ANSI_ARGS_((TkDisplay * dispPtr)); +/* 11 */ +EXTERN void TkFreeXId _ANSI_ARGS_((TkDisplay * dispPtr)); +/* 12 */ +EXTERN int TkpWmSetState _ANSI_ARGS_((TkWindow * winPtr, + int state)); +#endif /* X11 */ typedef struct TkIntPlatStubs { int magic; struct TkIntPlatStubHooks *hooks; -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ - void (*tkCreateXEventSource) _ANSI_ARGS_((void)); /* 0 */ - void (*tkFreeWindowId) _ANSI_ARGS_((TkDisplay * dispPtr, Window w)); /* 1 */ - void (*tkInitXId) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 2 */ - int (*tkpCmapStressed) _ANSI_ARGS_((Tk_Window tkwin, Colormap colormap)); /* 3 */ - void (*tkpSync) _ANSI_ARGS_((Display * display)); /* 4 */ - Window (*tkUnixContainerId) _ANSI_ARGS_((TkWindow * winPtr)); /* 5 */ - int (*tkUnixDoOneXEvent) _ANSI_ARGS_((Tcl_Time * timePtr)); /* 6 */ - void (*tkUnixSetMenubar) _ANSI_ARGS_((Tk_Window tkwin, Tk_Window menubar)); /* 7 */ -#endif /* UNIX */ #ifdef __WIN32__ char * (*tkAlignImageData) _ANSI_ARGS_((XImage * image, int alignment, int bitOrder)); /* 0 */ void *reserved1; @@ -331,7 +431,7 @@ typedef struct TkIntPlatStubs { unsigned long (*tkpGetMS) _ANSI_ARGS_((void)); /* 3 */ void (*tkPointerDeadWindow) _ANSI_ARGS_((TkWindow * winPtr)); /* 4 */ void (*tkpPrintWindowId) _ANSI_ARGS_((char * buf, Window window)); /* 5 */ - int (*tkpScanWindowId) _ANSI_ARGS_((Tcl_Interp * interp, char * string, int * idPtr)); /* 6 */ + int (*tkpScanWindowId) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * string, Window * idPtr)); /* 6 */ void (*tkpSetCapture) _ANSI_ARGS_((TkWindow * winPtr)); /* 7 */ void (*tkpSetCursor) _ANSI_ARGS_((TkpCursor cursor)); /* 8 */ void (*tkpWmSetState) _ANSI_ARGS_((TkWindow * winPtr, int state)); /* 9 */ @@ -357,48 +457,48 @@ typedef struct TkIntPlatStubs { void (*tkWinXInit) _ANSI_ARGS_((HINSTANCE hInstance)); /* 29 */ void (*tkWinSetForegroundWindow) _ANSI_ARGS_((TkWindow * winPtr)); /* 30 */ void (*tkWinDialogDebug) _ANSI_ARGS_((int debug)); /* 31 */ - Tcl_Obj * (*tkWinGetMenuSystemDefault) _ANSI_ARGS_((Tk_Window tkwin, char * dbName, char * className)); /* 32 */ + Tcl_Obj * (*tkWinGetMenuSystemDefault) _ANSI_ARGS_((Tk_Window tkwin, CONST char * dbName, CONST char * className)); /* 32 */ int (*tkWinGetPlatformId) _ANSI_ARGS_((void)); /* 33 */ #endif /* __WIN32__ */ #ifdef MAC_TCL void (*tkGenerateActivateEvents) _ANSI_ARGS_((TkWindow * winPtr, int active)); /* 0 */ - Pixmap (*tkpCreateNativeBitmap) _ANSI_ARGS_((Display * display, char * source)); /* 1 */ - void (*tkpDefineNativeBitmaps) _ANSI_ARGS_((void)); /* 2 */ + void *reserved1; + void *reserved2; unsigned long (*tkpGetMS) _ANSI_ARGS_((void)); /* 3 */ - Pixmap (*tkpGetNativeAppBitmap) _ANSI_ARGS_((Display * display, char * name, int * width, int * height)); /* 4 */ + void *reserved4; void (*tkPointerDeadWindow) _ANSI_ARGS_((TkWindow * winPtr)); /* 5 */ void (*tkpSetCapture) _ANSI_ARGS_((TkWindow * winPtr)); /* 6 */ void (*tkpSetCursor) _ANSI_ARGS_((TkpCursor cursor)); /* 7 */ void (*tkpWmSetState) _ANSI_ARGS_((TkWindow * winPtr, int state)); /* 8 */ - int (*handleWMEvent) _ANSI_ARGS_((EventRecord * theEvent)); /* 9 */ + void *reserved9; void (*tkAboutDlg) _ANSI_ARGS_((void)); /* 10 */ - void (*tkCreateMacEventSource) _ANSI_ARGS_((void)); /* 11 */ - void (*tkFontList) _ANSI_ARGS_((Tcl_Interp * interp, Display * display)); /* 12 */ + void *reserved11; + void *reserved12; Window (*tkGetTransientMaster) _ANSI_ARGS_((TkWindow * winPtr)); /* 13 */ int (*tkGenerateButtonEvent) _ANSI_ARGS_((int x, int y, Window window, unsigned int state)); /* 14 */ - int (*tkGetCharPositions) _ANSI_ARGS_((XFontStruct * font_struct, char * string, int count, short * buffer)); /* 15 */ + void *reserved15; void (*tkGenWMDestroyEvent) _ANSI_ARGS_((Tk_Window tkwin)); /* 16 */ - void (*tkGenWMConfigureEvent) _ANSI_ARGS_((Tk_Window tkwin, int x, int y, int width, int height, int flags)); /* 17 */ + void *reserved17; unsigned int (*tkMacButtonKeyState) _ANSI_ARGS_((void)); /* 18 */ void (*tkMacClearMenubarActive) _ANSI_ARGS_((void)); /* 19 */ - int (*tkMacConvertEvent) _ANSI_ARGS_((EventRecord * eventPtr)); /* 20 */ + void *reserved20; int (*tkMacDispatchMenuEvent) _ANSI_ARGS_((int menuID, int index)); /* 21 */ void (*tkMacInstallCursor) _ANSI_ARGS_((int resizeOverride)); /* 22 */ - int (*tkMacConvertTkEvent) _ANSI_ARGS_((EventRecord * eventPtr, Window window)); /* 23 */ + void *reserved23; void (*tkMacHandleTearoffMenu) _ANSI_ARGS_((void)); /* 24 */ - void (*tkMacInstallMWConsole) _ANSI_ARGS_((Tcl_Interp * interp)); /* 25 */ - void (*tkMacInvalClipRgns) _ANSI_ARGS_((TkWindow * winPtr)); /* 26 */ + void *reserved25; + void *reserved26; void (*tkMacDoHLEvent) _ANSI_ARGS_((EventRecord * theEvent)); /* 27 */ - void (*tkMacFontInfo) _ANSI_ARGS_((Font fontId, short * family, short * style, short * size)); /* 28 */ + void *reserved28; Time (*tkMacGenerateTime) _ANSI_ARGS_((void)); /* 29 */ - GWorldPtr (*tkMacGetDrawablePort) _ANSI_ARGS_((Drawable drawable)); /* 30 */ + void *reserved30; TkWindow * (*tkMacGetScrollbarGrowWindow) _ANSI_ARGS_((TkWindow * winPtr)); /* 31 */ Window (*tkMacGetXWindow) _ANSI_ARGS_((WindowRef macWinPtr)); /* 32 */ int (*tkMacGrowToplevel) _ANSI_ARGS_((WindowRef whichWindow, Point start)); /* 33 */ void (*tkMacHandleMenuSelect) _ANSI_ARGS_((long mResult, int optionKeyPressed)); /* 34 */ - int (*tkMacHaveAppearance) _ANSI_ARGS_((void)); /* 35 */ - void (*tkMacInitAppleEvents) _ANSI_ARGS_((Tcl_Interp * interp)); /* 36 */ - void (*tkMacInitMenus) _ANSI_ARGS_((Tcl_Interp * interp)); /* 37 */ + void *reserved35; + void *reserved36; + void *reserved37; void (*tkMacInvalidateWindow) _ANSI_ARGS_((MacDrawable * macWin, int flag)); /* 38 */ int (*tkMacIsCharacterMissing) _ANSI_ARGS_((Tk_Font tkfont, unsigned int searchChar)); /* 39 */ void (*tkMacMakeRealWindowExist) _ANSI_ARGS_((TkWindow * winPtr)); /* 40 */ @@ -406,7 +506,7 @@ typedef struct TkIntPlatStubs { void (*tkMacMenuClick) _ANSI_ARGS_((void)); /* 42 */ void (*tkMacRegisterOffScreenWindow) _ANSI_ARGS_((Window window, GWorldPtr portPtr)); /* 43 */ int (*tkMacResizable) _ANSI_ARGS_((TkWindow * winPtr)); /* 44 */ - void (*tkMacSetEmbedRgn) _ANSI_ARGS_((TkWindow * winPtr, RgnHandle rgn)); /* 45 */ + void *reserved45; void (*tkMacSetHelpMenuItemCount) _ANSI_ARGS_((void)); /* 46 */ void (*tkMacSetScrollbarGrow) _ANSI_ARGS_((TkWindow * winPtr, int flag)); /* 47 */ void (*tkMacSetUpClippingRgn) _ANSI_ARGS_((Drawable drawable)); /* 48 */ @@ -417,16 +517,89 @@ typedef struct TkIntPlatStubs { RgnHandle (*tkMacVisableClipRgn) _ANSI_ARGS_((TkWindow * winPtr)); /* 53 */ void (*tkMacWinBounds) _ANSI_ARGS_((TkWindow * winPtr, Rect * geometry)); /* 54 */ void (*tkMacWindowOffset) _ANSI_ARGS_((WindowRef wRef, int * xOffset, int * yOffset)); /* 55 */ - void (*tkResumeClipboard) _ANSI_ARGS_((void)); /* 56 */ + void *reserved56; int (*tkSetMacColor) _ANSI_ARGS_((unsigned long pixel, RGBColor * macColor)); /* 57 */ void (*tkSetWMName) _ANSI_ARGS_((TkWindow * winPtr, Tk_Uid titleUid)); /* 58 */ void (*tkSuspendClipboard) _ANSI_ARGS_((void)); /* 59 */ - int (*tkWMGrowToplevel) _ANSI_ARGS_((WindowRef whichWindow, Point start)); /* 60 */ + void *reserved60; int (*tkMacZoomToplevel) _ANSI_ARGS_((WindowPtr whichWindow, Point where, short zoomPart)); /* 61 */ Tk_Window (*tk_TopCoordsToWindow) _ANSI_ARGS_((Tk_Window tkwin, int rootX, int rootY, int * newX, int * newY)); /* 62 */ MacDrawable * (*tkMacContainerId) _ANSI_ARGS_((TkWindow * winPtr)); /* 63 */ MacDrawable * (*tkMacGetHostToplevel) _ANSI_ARGS_((TkWindow * winPtr)); /* 64 */ + void (*tkMacPreprocessMenu) _ANSI_ARGS_((void)); /* 65 */ + int (*tkpIsWindowFloating) _ANSI_ARGS_((WindowRef window)); /* 66 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + void (*tkGenerateActivateEvents) _ANSI_ARGS_((TkWindow * winPtr, int active)); /* 0 */ + void *reserved1; + void *reserved2; + void (*tkPointerDeadWindow) _ANSI_ARGS_((TkWindow * winPtr)); /* 3 */ + void (*tkpSetCapture) _ANSI_ARGS_((TkWindow * winPtr)); /* 4 */ + void (*tkpSetCursor) _ANSI_ARGS_((TkpCursor cursor)); /* 5 */ + void (*tkpWmSetState) _ANSI_ARGS_((TkWindow * winPtr, int state)); /* 6 */ + void (*tkAboutDlg) _ANSI_ARGS_((void)); /* 7 */ + unsigned int (*tkMacOSXButtonKeyState) _ANSI_ARGS_((void)); /* 8 */ + void (*tkMacOSXClearMenubarActive) _ANSI_ARGS_((void)); /* 9 */ + int (*tkMacOSXDispatchMenuEvent) _ANSI_ARGS_((int menuID, int index)); /* 10 */ + void (*tkMacOSXInstallCursor) _ANSI_ARGS_((int resizeOverride)); /* 11 */ + void (*tkMacOSXHandleTearoffMenu) _ANSI_ARGS_((void)); /* 12 */ + void *reserved13; + int (*tkMacOSXDoHLEvent) _ANSI_ARGS_((EventRecord * theEvent)); /* 14 */ + void *reserved15; + Window (*tkMacOSXGetXWindow) _ANSI_ARGS_((WindowRef macWinPtr)); /* 16 */ + int (*tkMacOSXGrowToplevel) _ANSI_ARGS_((WindowRef whichWindow, Point start)); /* 17 */ + void (*tkMacOSXHandleMenuSelect) _ANSI_ARGS_((long mResult, int optionKeyPressed)); /* 18 */ + void *reserved19; + void *reserved20; + void (*tkMacOSXInvalidateWindow) _ANSI_ARGS_((MacDrawable * macWin, int flag)); /* 21 */ + int (*tkMacOSXIsCharacterMissing) _ANSI_ARGS_((Tk_Font tkfont, unsigned int searchChar)); /* 22 */ + void (*tkMacOSXMakeRealWindowExist) _ANSI_ARGS_((TkWindow * winPtr)); /* 23 */ + BitMapPtr (*tkMacOSXMakeStippleMap) _ANSI_ARGS_((Drawable d1, Drawable d2)); /* 24 */ + void (*tkMacOSXMenuClick) _ANSI_ARGS_((void)); /* 25 */ + void (*tkMacOSXRegisterOffScreenWindow) _ANSI_ARGS_((Window window, GWorldPtr portPtr)); /* 26 */ + int (*tkMacOSXResizable) _ANSI_ARGS_((TkWindow * winPtr)); /* 27 */ + void (*tkMacOSXSetHelpMenuItemCount) _ANSI_ARGS_((void)); /* 28 */ + void (*tkMacOSXSetScrollbarGrow) _ANSI_ARGS_((TkWindow * winPtr, int flag)); /* 29 */ + void (*tkMacOSXSetUpClippingRgn) _ANSI_ARGS_((Drawable drawable)); /* 30 */ + void (*tkMacOSXSetUpGraphicsPort) _ANSI_ARGS_((GC gc, GWorldPtr destPort)); /* 31 */ + void (*tkMacOSXUpdateClipRgn) _ANSI_ARGS_((TkWindow * winPtr)); /* 32 */ + void (*tkMacOSXUnregisterMacWindow) _ANSI_ARGS_((WindowRef portPtr)); /* 33 */ + int (*tkMacOSXUseMenuID) _ANSI_ARGS_((short macID)); /* 34 */ + RgnHandle (*tkMacOSXVisableClipRgn) _ANSI_ARGS_((TkWindow * winPtr)); /* 35 */ + void (*tkMacOSXWinBounds) _ANSI_ARGS_((TkWindow * winPtr, Rect * geometry)); /* 36 */ + void (*tkMacOSXWindowOffset) _ANSI_ARGS_((WindowRef wRef, int * xOffset, int * yOffset)); /* 37 */ + int (*tkSetMacColor) _ANSI_ARGS_((unsigned long pixel, RGBColor * macColor)); /* 38 */ + void (*tkSetWMName) _ANSI_ARGS_((TkWindow * winPtr, Tk_Uid titleUid)); /* 39 */ + void (*tkSuspendClipboard) _ANSI_ARGS_((void)); /* 40 */ + int (*tkMacOSXZoomToplevel) _ANSI_ARGS_((WindowPtr whichWindow, Point where, short zoomPart)); /* 41 */ + Tk_Window (*tk_TopCoordsToWindow) _ANSI_ARGS_((Tk_Window tkwin, int rootX, int rootY, int * newX, int * newY)); /* 42 */ + MacDrawable * (*tkMacOSXContainerId) _ANSI_ARGS_((TkWindow * winPtr)); /* 43 */ + MacDrawable * (*tkMacOSXGetHostToplevel) _ANSI_ARGS_((TkWindow * winPtr)); /* 44 */ + void (*tkMacOSXPreprocessMenu) _ANSI_ARGS_((void)); /* 45 */ + int (*tkpIsWindowFloating) _ANSI_ARGS_((WindowRef window)); /* 46 */ + Tk_Window (*tkMacOSXGetCapture) _ANSI_ARGS_((void)); /* 47 */ + void *reserved48; + Window (*tkGetTransientMaster) _ANSI_ARGS_((TkWindow * winPtr)); /* 49 */ + int (*tkGenerateButtonEvent) _ANSI_ARGS_((int x, int y, Window window, unsigned int state)); /* 50 */ + void (*tkGenWMDestroyEvent) _ANSI_ARGS_((Tk_Window tkwin)); /* 51 */ + void *reserved52; + unsigned long (*tkpGetMS) _ANSI_ARGS_((void)); /* 53 */ +#endif /* MAC_OSX_TK */ +#if !(defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) /* X11 */ + void (*tkCreateXEventSource) _ANSI_ARGS_((void)); /* 0 */ + void (*tkFreeWindowId) _ANSI_ARGS_((TkDisplay * dispPtr, Window w)); /* 1 */ + void (*tkInitXId) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 2 */ + int (*tkpCmapStressed) _ANSI_ARGS_((Tk_Window tkwin, Colormap colormap)); /* 3 */ + void (*tkpSync) _ANSI_ARGS_((Display * display)); /* 4 */ + Window (*tkUnixContainerId) _ANSI_ARGS_((TkWindow * winPtr)); /* 5 */ + int (*tkUnixDoOneXEvent) _ANSI_ARGS_((Tcl_Time * timePtr)); /* 6 */ + void (*tkUnixSetMenubar) _ANSI_ARGS_((Tk_Window tkwin, Tk_Window menubar)); /* 7 */ + int (*tkpScanWindowId) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * string, Window * idPtr)); /* 8 */ + void (*tkWmCleanup) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 9 */ + void (*tkSendCleanup) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 10 */ + void (*tkFreeXId) _ANSI_ARGS_((TkDisplay * dispPtr)); /* 11 */ + int (*tkpWmSetState) _ANSI_ARGS_((TkWindow * winPtr, int state)); /* 12 */ +#endif /* X11 */ } TkIntPlatStubs; #ifdef __cplusplus @@ -443,40 +616,6 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; * Inline function declarations: */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ -#ifndef TkCreateXEventSource -#define TkCreateXEventSource \ - (tkIntPlatStubsPtr->tkCreateXEventSource) /* 0 */ -#endif -#ifndef TkFreeWindowId -#define TkFreeWindowId \ - (tkIntPlatStubsPtr->tkFreeWindowId) /* 1 */ -#endif -#ifndef TkInitXId -#define TkInitXId \ - (tkIntPlatStubsPtr->tkInitXId) /* 2 */ -#endif -#ifndef TkpCmapStressed -#define TkpCmapStressed \ - (tkIntPlatStubsPtr->tkpCmapStressed) /* 3 */ -#endif -#ifndef TkpSync -#define TkpSync \ - (tkIntPlatStubsPtr->tkpSync) /* 4 */ -#endif -#ifndef TkUnixContainerId -#define TkUnixContainerId \ - (tkIntPlatStubsPtr->tkUnixContainerId) /* 5 */ -#endif -#ifndef TkUnixDoOneXEvent -#define TkUnixDoOneXEvent \ - (tkIntPlatStubsPtr->tkUnixDoOneXEvent) /* 6 */ -#endif -#ifndef TkUnixSetMenubar -#define TkUnixSetMenubar \ - (tkIntPlatStubsPtr->tkUnixSetMenubar) /* 7 */ -#endif -#endif /* UNIX */ #ifdef __WIN32__ #ifndef TkAlignImageData #define TkAlignImageData \ @@ -617,22 +756,13 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkGenerateActivateEvents \ (tkIntPlatStubsPtr->tkGenerateActivateEvents) /* 0 */ #endif -#ifndef TkpCreateNativeBitmap -#define TkpCreateNativeBitmap \ - (tkIntPlatStubsPtr->tkpCreateNativeBitmap) /* 1 */ -#endif -#ifndef TkpDefineNativeBitmaps -#define TkpDefineNativeBitmaps \ - (tkIntPlatStubsPtr->tkpDefineNativeBitmaps) /* 2 */ -#endif +/* Slot 1 is reserved */ +/* Slot 2 is reserved */ #ifndef TkpGetMS #define TkpGetMS \ (tkIntPlatStubsPtr->tkpGetMS) /* 3 */ #endif -#ifndef TkpGetNativeAppBitmap -#define TkpGetNativeAppBitmap \ - (tkIntPlatStubsPtr->tkpGetNativeAppBitmap) /* 4 */ -#endif +/* Slot 4 is reserved */ #ifndef TkPointerDeadWindow #define TkPointerDeadWindow \ (tkIntPlatStubsPtr->tkPointerDeadWindow) /* 5 */ @@ -649,22 +779,13 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkpWmSetState \ (tkIntPlatStubsPtr->tkpWmSetState) /* 8 */ #endif -#ifndef HandleWMEvent -#define HandleWMEvent \ - (tkIntPlatStubsPtr->handleWMEvent) /* 9 */ -#endif +/* Slot 9 is reserved */ #ifndef TkAboutDlg #define TkAboutDlg \ (tkIntPlatStubsPtr->tkAboutDlg) /* 10 */ #endif -#ifndef TkCreateMacEventSource -#define TkCreateMacEventSource \ - (tkIntPlatStubsPtr->tkCreateMacEventSource) /* 11 */ -#endif -#ifndef TkFontList -#define TkFontList \ - (tkIntPlatStubsPtr->tkFontList) /* 12 */ -#endif +/* Slot 11 is reserved */ +/* Slot 12 is reserved */ #ifndef TkGetTransientMaster #define TkGetTransientMaster \ (tkIntPlatStubsPtr->tkGetTransientMaster) /* 13 */ @@ -673,18 +794,12 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkGenerateButtonEvent \ (tkIntPlatStubsPtr->tkGenerateButtonEvent) /* 14 */ #endif -#ifndef TkGetCharPositions -#define TkGetCharPositions \ - (tkIntPlatStubsPtr->tkGetCharPositions) /* 15 */ -#endif +/* Slot 15 is reserved */ #ifndef TkGenWMDestroyEvent #define TkGenWMDestroyEvent \ (tkIntPlatStubsPtr->tkGenWMDestroyEvent) /* 16 */ #endif -#ifndef TkGenWMConfigureEvent -#define TkGenWMConfigureEvent \ - (tkIntPlatStubsPtr->tkGenWMConfigureEvent) /* 17 */ -#endif +/* Slot 17 is reserved */ #ifndef TkMacButtonKeyState #define TkMacButtonKeyState \ (tkIntPlatStubsPtr->tkMacButtonKeyState) /* 18 */ @@ -693,10 +808,7 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkMacClearMenubarActive \ (tkIntPlatStubsPtr->tkMacClearMenubarActive) /* 19 */ #endif -#ifndef TkMacConvertEvent -#define TkMacConvertEvent \ - (tkIntPlatStubsPtr->tkMacConvertEvent) /* 20 */ -#endif +/* Slot 20 is reserved */ #ifndef TkMacDispatchMenuEvent #define TkMacDispatchMenuEvent \ (tkIntPlatStubsPtr->tkMacDispatchMenuEvent) /* 21 */ @@ -705,38 +817,23 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkMacInstallCursor \ (tkIntPlatStubsPtr->tkMacInstallCursor) /* 22 */ #endif -#ifndef TkMacConvertTkEvent -#define TkMacConvertTkEvent \ - (tkIntPlatStubsPtr->tkMacConvertTkEvent) /* 23 */ -#endif +/* Slot 23 is reserved */ #ifndef TkMacHandleTearoffMenu #define TkMacHandleTearoffMenu \ (tkIntPlatStubsPtr->tkMacHandleTearoffMenu) /* 24 */ #endif -#ifndef tkMacInstallMWConsole -#define tkMacInstallMWConsole \ - (tkIntPlatStubsPtr->tkMacInstallMWConsole) /* 25 */ -#endif -#ifndef TkMacInvalClipRgns -#define TkMacInvalClipRgns \ - (tkIntPlatStubsPtr->tkMacInvalClipRgns) /* 26 */ -#endif +/* Slot 25 is reserved */ +/* Slot 26 is reserved */ #ifndef TkMacDoHLEvent #define TkMacDoHLEvent \ (tkIntPlatStubsPtr->tkMacDoHLEvent) /* 27 */ #endif -#ifndef TkMacFontInfo -#define TkMacFontInfo \ - (tkIntPlatStubsPtr->tkMacFontInfo) /* 28 */ -#endif +/* Slot 28 is reserved */ #ifndef TkMacGenerateTime #define TkMacGenerateTime \ (tkIntPlatStubsPtr->tkMacGenerateTime) /* 29 */ #endif -#ifndef TkMacGetDrawablePort -#define TkMacGetDrawablePort \ - (tkIntPlatStubsPtr->tkMacGetDrawablePort) /* 30 */ -#endif +/* Slot 30 is reserved */ #ifndef TkMacGetScrollbarGrowWindow #define TkMacGetScrollbarGrowWindow \ (tkIntPlatStubsPtr->tkMacGetScrollbarGrowWindow) /* 31 */ @@ -753,18 +850,9 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkMacHandleMenuSelect \ (tkIntPlatStubsPtr->tkMacHandleMenuSelect) /* 34 */ #endif -#ifndef TkMacHaveAppearance -#define TkMacHaveAppearance \ - (tkIntPlatStubsPtr->tkMacHaveAppearance) /* 35 */ -#endif -#ifndef TkMacInitAppleEvents -#define TkMacInitAppleEvents \ - (tkIntPlatStubsPtr->tkMacInitAppleEvents) /* 36 */ -#endif -#ifndef TkMacInitMenus -#define TkMacInitMenus \ - (tkIntPlatStubsPtr->tkMacInitMenus) /* 37 */ -#endif +/* Slot 35 is reserved */ +/* Slot 36 is reserved */ +/* Slot 37 is reserved */ #ifndef TkMacInvalidateWindow #define TkMacInvalidateWindow \ (tkIntPlatStubsPtr->tkMacInvalidateWindow) /* 38 */ @@ -793,10 +881,7 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkMacResizable \ (tkIntPlatStubsPtr->tkMacResizable) /* 44 */ #endif -#ifndef TkMacSetEmbedRgn -#define TkMacSetEmbedRgn \ - (tkIntPlatStubsPtr->tkMacSetEmbedRgn) /* 45 */ -#endif +/* Slot 45 is reserved */ #ifndef TkMacSetHelpMenuItemCount #define TkMacSetHelpMenuItemCount \ (tkIntPlatStubsPtr->tkMacSetHelpMenuItemCount) /* 46 */ @@ -837,10 +922,7 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkMacWindowOffset \ (tkIntPlatStubsPtr->tkMacWindowOffset) /* 55 */ #endif -#ifndef TkResumeClipboard -#define TkResumeClipboard \ - (tkIntPlatStubsPtr->tkResumeClipboard) /* 56 */ -#endif +/* Slot 56 is reserved */ #ifndef TkSetMacColor #define TkSetMacColor \ (tkIntPlatStubsPtr->tkSetMacColor) /* 57 */ @@ -853,10 +935,7 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkSuspendClipboard \ (tkIntPlatStubsPtr->tkSuspendClipboard) /* 59 */ #endif -#ifndef TkWMGrowToplevel -#define TkWMGrowToplevel \ - (tkIntPlatStubsPtr->tkWMGrowToplevel) /* 60 */ -#endif +/* Slot 60 is reserved */ #ifndef TkMacZoomToplevel #define TkMacZoomToplevel \ (tkIntPlatStubsPtr->tkMacZoomToplevel) /* 61 */ @@ -873,7 +952,263 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkMacGetHostToplevel \ (tkIntPlatStubsPtr->tkMacGetHostToplevel) /* 64 */ #endif +#ifndef TkMacPreprocessMenu +#define TkMacPreprocessMenu \ + (tkIntPlatStubsPtr->tkMacPreprocessMenu) /* 65 */ +#endif +#ifndef TkpIsWindowFloating +#define TkpIsWindowFloating \ + (tkIntPlatStubsPtr->tkpIsWindowFloating) /* 66 */ +#endif #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +#ifndef TkGenerateActivateEvents +#define TkGenerateActivateEvents \ + (tkIntPlatStubsPtr->tkGenerateActivateEvents) /* 0 */ +#endif +/* Slot 1 is reserved */ +/* Slot 2 is reserved */ +#ifndef TkPointerDeadWindow +#define TkPointerDeadWindow \ + (tkIntPlatStubsPtr->tkPointerDeadWindow) /* 3 */ +#endif +#ifndef TkpSetCapture +#define TkpSetCapture \ + (tkIntPlatStubsPtr->tkpSetCapture) /* 4 */ +#endif +#ifndef TkpSetCursor +#define TkpSetCursor \ + (tkIntPlatStubsPtr->tkpSetCursor) /* 5 */ +#endif +#ifndef TkpWmSetState +#define TkpWmSetState \ + (tkIntPlatStubsPtr->tkpWmSetState) /* 6 */ +#endif +#ifndef TkAboutDlg +#define TkAboutDlg \ + (tkIntPlatStubsPtr->tkAboutDlg) /* 7 */ +#endif +#ifndef TkMacOSXButtonKeyState +#define TkMacOSXButtonKeyState \ + (tkIntPlatStubsPtr->tkMacOSXButtonKeyState) /* 8 */ +#endif +#ifndef TkMacOSXClearMenubarActive +#define TkMacOSXClearMenubarActive \ + (tkIntPlatStubsPtr->tkMacOSXClearMenubarActive) /* 9 */ +#endif +#ifndef TkMacOSXDispatchMenuEvent +#define TkMacOSXDispatchMenuEvent \ + (tkIntPlatStubsPtr->tkMacOSXDispatchMenuEvent) /* 10 */ +#endif +#ifndef TkMacOSXInstallCursor +#define TkMacOSXInstallCursor \ + (tkIntPlatStubsPtr->tkMacOSXInstallCursor) /* 11 */ +#endif +#ifndef TkMacOSXHandleTearoffMenu +#define TkMacOSXHandleTearoffMenu \ + (tkIntPlatStubsPtr->tkMacOSXHandleTearoffMenu) /* 12 */ +#endif +/* Slot 13 is reserved */ +#ifndef TkMacOSXDoHLEvent +#define TkMacOSXDoHLEvent \ + (tkIntPlatStubsPtr->tkMacOSXDoHLEvent) /* 14 */ +#endif +/* Slot 15 is reserved */ +#ifndef TkMacOSXGetXWindow +#define TkMacOSXGetXWindow \ + (tkIntPlatStubsPtr->tkMacOSXGetXWindow) /* 16 */ +#endif +#ifndef TkMacOSXGrowToplevel +#define TkMacOSXGrowToplevel \ + (tkIntPlatStubsPtr->tkMacOSXGrowToplevel) /* 17 */ +#endif +#ifndef TkMacOSXHandleMenuSelect +#define TkMacOSXHandleMenuSelect \ + (tkIntPlatStubsPtr->tkMacOSXHandleMenuSelect) /* 18 */ +#endif +/* Slot 19 is reserved */ +/* Slot 20 is reserved */ +#ifndef TkMacOSXInvalidateWindow +#define TkMacOSXInvalidateWindow \ + (tkIntPlatStubsPtr->tkMacOSXInvalidateWindow) /* 21 */ +#endif +#ifndef TkMacOSXIsCharacterMissing +#define TkMacOSXIsCharacterMissing \ + (tkIntPlatStubsPtr->tkMacOSXIsCharacterMissing) /* 22 */ +#endif +#ifndef TkMacOSXMakeRealWindowExist +#define TkMacOSXMakeRealWindowExist \ + (tkIntPlatStubsPtr->tkMacOSXMakeRealWindowExist) /* 23 */ +#endif +#ifndef TkMacOSXMakeStippleMap +#define TkMacOSXMakeStippleMap \ + (tkIntPlatStubsPtr->tkMacOSXMakeStippleMap) /* 24 */ +#endif +#ifndef TkMacOSXMenuClick +#define TkMacOSXMenuClick \ + (tkIntPlatStubsPtr->tkMacOSXMenuClick) /* 25 */ +#endif +#ifndef TkMacOSXRegisterOffScreenWindow +#define TkMacOSXRegisterOffScreenWindow \ + (tkIntPlatStubsPtr->tkMacOSXRegisterOffScreenWindow) /* 26 */ +#endif +#ifndef TkMacOSXResizable +#define TkMacOSXResizable \ + (tkIntPlatStubsPtr->tkMacOSXResizable) /* 27 */ +#endif +#ifndef TkMacOSXSetHelpMenuItemCount +#define TkMacOSXSetHelpMenuItemCount \ + (tkIntPlatStubsPtr->tkMacOSXSetHelpMenuItemCount) /* 28 */ +#endif +#ifndef TkMacOSXSetScrollbarGrow +#define TkMacOSXSetScrollbarGrow \ + (tkIntPlatStubsPtr->tkMacOSXSetScrollbarGrow) /* 29 */ +#endif +#ifndef TkMacOSXSetUpClippingRgn +#define TkMacOSXSetUpClippingRgn \ + (tkIntPlatStubsPtr->tkMacOSXSetUpClippingRgn) /* 30 */ +#endif +#ifndef TkMacOSXSetUpGraphicsPort +#define TkMacOSXSetUpGraphicsPort \ + (tkIntPlatStubsPtr->tkMacOSXSetUpGraphicsPort) /* 31 */ +#endif +#ifndef TkMacOSXUpdateClipRgn +#define TkMacOSXUpdateClipRgn \ + (tkIntPlatStubsPtr->tkMacOSXUpdateClipRgn) /* 32 */ +#endif +#ifndef TkMacOSXUnregisterMacWindow +#define TkMacOSXUnregisterMacWindow \ + (tkIntPlatStubsPtr->tkMacOSXUnregisterMacWindow) /* 33 */ +#endif +#ifndef TkMacOSXUseMenuID +#define TkMacOSXUseMenuID \ + (tkIntPlatStubsPtr->tkMacOSXUseMenuID) /* 34 */ +#endif +#ifndef TkMacOSXVisableClipRgn +#define TkMacOSXVisableClipRgn \ + (tkIntPlatStubsPtr->tkMacOSXVisableClipRgn) /* 35 */ +#endif +#ifndef TkMacOSXWinBounds +#define TkMacOSXWinBounds \ + (tkIntPlatStubsPtr->tkMacOSXWinBounds) /* 36 */ +#endif +#ifndef TkMacOSXWindowOffset +#define TkMacOSXWindowOffset \ + (tkIntPlatStubsPtr->tkMacOSXWindowOffset) /* 37 */ +#endif +#ifndef TkSetMacColor +#define TkSetMacColor \ + (tkIntPlatStubsPtr->tkSetMacColor) /* 38 */ +#endif +#ifndef TkSetWMName +#define TkSetWMName \ + (tkIntPlatStubsPtr->tkSetWMName) /* 39 */ +#endif +#ifndef TkSuspendClipboard +#define TkSuspendClipboard \ + (tkIntPlatStubsPtr->tkSuspendClipboard) /* 40 */ +#endif +#ifndef TkMacOSXZoomToplevel +#define TkMacOSXZoomToplevel \ + (tkIntPlatStubsPtr->tkMacOSXZoomToplevel) /* 41 */ +#endif +#ifndef Tk_TopCoordsToWindow +#define Tk_TopCoordsToWindow \ + (tkIntPlatStubsPtr->tk_TopCoordsToWindow) /* 42 */ +#endif +#ifndef TkMacOSXContainerId +#define TkMacOSXContainerId \ + (tkIntPlatStubsPtr->tkMacOSXContainerId) /* 43 */ +#endif +#ifndef TkMacOSXGetHostToplevel +#define TkMacOSXGetHostToplevel \ + (tkIntPlatStubsPtr->tkMacOSXGetHostToplevel) /* 44 */ +#endif +#ifndef TkMacOSXPreprocessMenu +#define TkMacOSXPreprocessMenu \ + (tkIntPlatStubsPtr->tkMacOSXPreprocessMenu) /* 45 */ +#endif +#ifndef TkpIsWindowFloating +#define TkpIsWindowFloating \ + (tkIntPlatStubsPtr->tkpIsWindowFloating) /* 46 */ +#endif +#ifndef TkMacOSXGetCapture +#define TkMacOSXGetCapture \ + (tkIntPlatStubsPtr->tkMacOSXGetCapture) /* 47 */ +#endif +/* Slot 48 is reserved */ +#ifndef TkGetTransientMaster +#define TkGetTransientMaster \ + (tkIntPlatStubsPtr->tkGetTransientMaster) /* 49 */ +#endif +#ifndef TkGenerateButtonEvent +#define TkGenerateButtonEvent \ + (tkIntPlatStubsPtr->tkGenerateButtonEvent) /* 50 */ +#endif +#ifndef TkGenWMDestroyEvent +#define TkGenWMDestroyEvent \ + (tkIntPlatStubsPtr->tkGenWMDestroyEvent) /* 51 */ +#endif +/* Slot 52 is reserved */ +#ifndef TkpGetMS +#define TkpGetMS \ + (tkIntPlatStubsPtr->tkpGetMS) /* 53 */ +#endif +#endif /* MAC_OSX_TK */ +#if !(defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) /* X11 */ +#ifndef TkCreateXEventSource +#define TkCreateXEventSource \ + (tkIntPlatStubsPtr->tkCreateXEventSource) /* 0 */ +#endif +#ifndef TkFreeWindowId +#define TkFreeWindowId \ + (tkIntPlatStubsPtr->tkFreeWindowId) /* 1 */ +#endif +#ifndef TkInitXId +#define TkInitXId \ + (tkIntPlatStubsPtr->tkInitXId) /* 2 */ +#endif +#ifndef TkpCmapStressed +#define TkpCmapStressed \ + (tkIntPlatStubsPtr->tkpCmapStressed) /* 3 */ +#endif +#ifndef TkpSync +#define TkpSync \ + (tkIntPlatStubsPtr->tkpSync) /* 4 */ +#endif +#ifndef TkUnixContainerId +#define TkUnixContainerId \ + (tkIntPlatStubsPtr->tkUnixContainerId) /* 5 */ +#endif +#ifndef TkUnixDoOneXEvent +#define TkUnixDoOneXEvent \ + (tkIntPlatStubsPtr->tkUnixDoOneXEvent) /* 6 */ +#endif +#ifndef TkUnixSetMenubar +#define TkUnixSetMenubar \ + (tkIntPlatStubsPtr->tkUnixSetMenubar) /* 7 */ +#endif +#ifndef TkpScanWindowId +#define TkpScanWindowId \ + (tkIntPlatStubsPtr->tkpScanWindowId) /* 8 */ +#endif +#ifndef TkWmCleanup +#define TkWmCleanup \ + (tkIntPlatStubsPtr->tkWmCleanup) /* 9 */ +#endif +#ifndef TkSendCleanup +#define TkSendCleanup \ + (tkIntPlatStubsPtr->tkSendCleanup) /* 10 */ +#endif +#ifndef TkFreeXId +#define TkFreeXId \ + (tkIntPlatStubsPtr->tkFreeXId) /* 11 */ +#endif +#ifndef TkpWmSetState +#define TkpWmSetState \ + (tkIntPlatStubsPtr->tkpWmSetState) /* 12 */ +#endif +#endif /* X11 */ #endif /* defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) */ diff --git a/tk/generic/tkIntXlibDecls.h b/tk/generic/tkIntXlibDecls.h index 7126dd6bcc6..9f9e00e7e89 100644 --- a/tk/generic/tkIntXlibDecls.h +++ b/tk/generic/tkIntXlibDecls.h @@ -231,7 +231,7 @@ EXTERN Status XSendEvent _ANSI_ARGS_((Display* d, Window w, Bool b, long l, XEvent* x)); /* 62 */ EXTERN void XSetCommand _ANSI_ARGS_((Display* d, Window w, - char** c, int i)); + CONST char** c, int i)); /* 63 */ EXTERN void XSetIconName _ANSI_ARGS_((Display* d, Window w, _Xconst char* c)); @@ -652,6 +652,292 @@ EXTERN void XQueryColors _ANSI_ARGS_((Display * display, Colormap colormap, XColor * defs_in_out, int ncolors)); #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 0 */ +EXTERN void XSetDashes _ANSI_ARGS_((Display* display, GC gc, + int dash_offset, _Xconst char* dash_list, + int n)); +/* 1 */ +EXTERN XModifierKeymap* XGetModifierMapping _ANSI_ARGS_((Display* d)); +/* 2 */ +EXTERN XImage * XCreateImage _ANSI_ARGS_((Display* d, Visual* v, + unsigned int ui1, int i1, int i2, char* cp, + unsigned int ui2, unsigned int ui3, int i3, + int i4)); +/* 3 */ +EXTERN XImage * XGetImage _ANSI_ARGS_((Display* d, Drawable dr, + int i1, int i2, unsigned int ui1, + unsigned int ui2, unsigned long ul, int i3)); +/* 4 */ +EXTERN char * XGetAtomName _ANSI_ARGS_((Display* d, Atom a)); +/* 5 */ +EXTERN char * XKeysymToString _ANSI_ARGS_((KeySym k)); +/* 6 */ +EXTERN Colormap XCreateColormap _ANSI_ARGS_((Display* d, Window w, + Visual* v, int i)); +/* 7 */ +EXTERN GContext XGContextFromGC _ANSI_ARGS_((GC g)); +/* 8 */ +EXTERN KeySym XKeycodeToKeysym _ANSI_ARGS_((Display* d, KeyCode k, + int i)); +/* 9 */ +EXTERN KeySym XStringToKeysym _ANSI_ARGS_((_Xconst char* c)); +/* 10 */ +EXTERN Window XRootWindow _ANSI_ARGS_((Display* d, int i)); +/* 11 */ +EXTERN XErrorHandler XSetErrorHandler _ANSI_ARGS_((XErrorHandler x)); +/* 12 */ +EXTERN Status XAllocColor _ANSI_ARGS_((Display* d, Colormap c, + XColor* xp)); +/* 13 */ +EXTERN void XBell _ANSI_ARGS_((Display* d, int i)); +/* 14 */ +EXTERN void XChangeProperty _ANSI_ARGS_((Display* d, Window w, + Atom a1, Atom a2, int i1, int i2, + _Xconst unsigned char* c, int i3)); +/* 15 */ +EXTERN void XChangeWindowAttributes _ANSI_ARGS_((Display* d, + Window w, unsigned long ul, + XSetWindowAttributes* x)); +/* 16 */ +EXTERN void XConfigureWindow _ANSI_ARGS_((Display* d, Window w, + unsigned int i, XWindowChanges* x)); +/* 17 */ +EXTERN void XCopyArea _ANSI_ARGS_((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 _ANSI_ARGS_((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)); +/* 19 */ +EXTERN Pixmap XCreateBitmapFromData _ANSI_ARGS_((Display* display, + Drawable d, _Xconst char* data, + unsigned int width, unsigned int height)); +/* 20 */ +EXTERN void XDefineCursor _ANSI_ARGS_((Display* d, Window w, + Cursor c)); +/* 21 */ +EXTERN void XDestroyWindow _ANSI_ARGS_((Display* d, Window w)); +/* 22 */ +EXTERN void XDrawArc _ANSI_ARGS_((Display* d, Drawable dr, GC g, + int i1, int i2, unsigned int ui1, + unsigned int ui2, int i3, int i4)); +/* 23 */ +EXTERN void XDrawLines _ANSI_ARGS_((Display* d, Drawable dr, + GC g, XPoint* x, int i1, int i2)); +/* 24 */ +EXTERN void XDrawRectangle _ANSI_ARGS_((Display* d, Drawable dr, + GC g, int i1, int i2, unsigned int ui1, + unsigned int ui2)); +/* 25 */ +EXTERN void XFillArc _ANSI_ARGS_((Display* d, Drawable dr, GC g, + int i1, int i2, unsigned int ui1, + unsigned int ui2, int i3, int i4)); +/* 26 */ +EXTERN void XFillPolygon _ANSI_ARGS_((Display* d, Drawable dr, + GC g, XPoint* x, int i1, int i2, int i3)); +/* 27 */ +EXTERN void XFillRectangles _ANSI_ARGS_((Display* d, Drawable dr, + GC g, XRectangle* x, int i)); +/* 28 */ +EXTERN void XFreeColormap _ANSI_ARGS_((Display* d, Colormap c)); +/* 29 */ +EXTERN void XFreeColors _ANSI_ARGS_((Display* d, Colormap c, + unsigned long* ulp, int i, unsigned long ul)); +/* 30 */ +EXTERN void XFreeModifiermap _ANSI_ARGS_((XModifierKeymap* x)); +/* 31 */ +EXTERN Status XGetGeometry _ANSI_ARGS_((Display* d, Drawable dr, + Window* w, int* i1, int* i2, + unsigned int* ui1, unsigned int* ui2, + unsigned int* ui3, unsigned int* ui4)); +/* 32 */ +EXTERN int XGetWindowProperty _ANSI_ARGS_((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)); +/* 33 */ +EXTERN int XGrabKeyboard _ANSI_ARGS_((Display* d, Window w, + Bool b, int i1, int i2, Time t)); +/* 34 */ +EXTERN int XGrabPointer _ANSI_ARGS_((Display* d, Window w1, + Bool b, unsigned int ui, int i1, int i2, + Window w2, Cursor c, Time t)); +/* 35 */ +EXTERN KeyCode XKeysymToKeycode _ANSI_ARGS_((Display* d, KeySym k)); +/* 36 */ +EXTERN void XMapWindow _ANSI_ARGS_((Display* d, Window w)); +/* 37 */ +EXTERN void XMoveResizeWindow _ANSI_ARGS_((Display* d, Window w, + int i1, int i2, unsigned int ui1, + unsigned int ui2)); +/* 38 */ +EXTERN void XMoveWindow _ANSI_ARGS_((Display* d, Window w, + int i1, int i2)); +/* 39 */ +EXTERN Bool XQueryPointer _ANSI_ARGS_((Display* d, Window w1, + Window* w2, Window* w3, int* i1, int* i2, + int* i3, int* i4, unsigned int* ui)); +/* 40 */ +EXTERN void XRaiseWindow _ANSI_ARGS_((Display* d, Window w)); +/* 41 */ +EXTERN void XRefreshKeyboardMapping _ANSI_ARGS_(( + XMappingEvent* x)); +/* 42 */ +EXTERN void XResizeWindow _ANSI_ARGS_((Display* d, Window w, + unsigned int ui1, unsigned int ui2)); +/* 43 */ +EXTERN void XSelectInput _ANSI_ARGS_((Display* d, Window w, + long l)); +/* 44 */ +EXTERN Status XSendEvent _ANSI_ARGS_((Display* d, Window w, Bool b, + long l, XEvent* x)); +/* 45 */ +EXTERN void XSetIconName _ANSI_ARGS_((Display* d, Window w, + _Xconst char* c)); +/* 46 */ +EXTERN void XSetInputFocus _ANSI_ARGS_((Display* d, Window w, + int i, Time t)); +/* 47 */ +EXTERN void XSetSelectionOwner _ANSI_ARGS_((Display* d, Atom a, + Window w, Time t)); +/* 48 */ +EXTERN void XSetWindowBackground _ANSI_ARGS_((Display* d, + Window w, unsigned long ul)); +/* 49 */ +EXTERN void XSetWindowBackgroundPixmap _ANSI_ARGS_((Display* d, + Window w, Pixmap p)); +/* 50 */ +EXTERN void XSetWindowBorder _ANSI_ARGS_((Display* d, Window w, + unsigned long ul)); +/* 51 */ +EXTERN void XSetWindowBorderPixmap _ANSI_ARGS_((Display* d, + Window w, Pixmap p)); +/* 52 */ +EXTERN void XSetWindowBorderWidth _ANSI_ARGS_((Display* d, + Window w, unsigned int ui)); +/* 53 */ +EXTERN void XSetWindowColormap _ANSI_ARGS_((Display* d, Window w, + Colormap c)); +/* 54 */ +EXTERN void XUngrabKeyboard _ANSI_ARGS_((Display* d, Time t)); +/* 55 */ +EXTERN void XUngrabPointer _ANSI_ARGS_((Display* d, Time t)); +/* 56 */ +EXTERN void XUnmapWindow _ANSI_ARGS_((Display* d, Window w)); +/* 57 */ +EXTERN void TkPutImage _ANSI_ARGS_((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)); +/* 58 */ +EXTERN Status XParseColor _ANSI_ARGS_((Display * display, + Colormap map, _Xconst char* spec, + XColor * colorPtr)); +/* 59 */ +EXTERN GC XCreateGC _ANSI_ARGS_((Display* display, Drawable d, + unsigned long valuemask, XGCValues* values)); +/* 60 */ +EXTERN void XFreeGC _ANSI_ARGS_((Display* display, GC gc)); +/* 61 */ +EXTERN Atom XInternAtom _ANSI_ARGS_((Display* display, + _Xconst char* atom_name, Bool only_if_exists)); +/* 62 */ +EXTERN void XSetBackground _ANSI_ARGS_((Display* display, GC gc, + unsigned long foreground)); +/* 63 */ +EXTERN void XSetForeground _ANSI_ARGS_((Display* display, GC gc, + unsigned long foreground)); +/* 64 */ +EXTERN void XSetClipMask _ANSI_ARGS_((Display* display, GC gc, + Pixmap pixmap)); +/* 65 */ +EXTERN void XSetClipOrigin _ANSI_ARGS_((Display* display, GC gc, + int clip_x_origin, int clip_y_origin)); +/* 66 */ +EXTERN void XSetTSOrigin _ANSI_ARGS_((Display* display, GC gc, + int ts_x_origin, int ts_y_origin)); +/* 67 */ +EXTERN void XChangeGC _ANSI_ARGS_((Display * d, GC gc, + unsigned long mask, XGCValues * values)); +/* 68 */ +EXTERN void XSetFont _ANSI_ARGS_((Display * display, GC gc, + Font font)); +/* 69 */ +EXTERN void XSetArcMode _ANSI_ARGS_((Display * display, GC gc, + int arc_mode)); +/* 70 */ +EXTERN void XSetStipple _ANSI_ARGS_((Display * display, GC gc, + Pixmap stipple)); +/* 71 */ +EXTERN void XSetFillRule _ANSI_ARGS_((Display * display, GC gc, + int fill_rule)); +/* 72 */ +EXTERN void XSetFillStyle _ANSI_ARGS_((Display * display, GC gc, + int fill_style)); +/* 73 */ +EXTERN void XSetFunction _ANSI_ARGS_((Display * display, GC gc, + int function)); +/* 74 */ +EXTERN void XSetLineAttributes _ANSI_ARGS_((Display * display, + GC gc, unsigned int line_width, + int line_style, int cap_style, + int join_style)); +/* 75 */ +EXTERN int _XInitImageFuncPtrs _ANSI_ARGS_((XImage * image)); +/* 76 */ +EXTERN XIC XCreateIC _ANSI_ARGS_((void)); +/* 77 */ +EXTERN XVisualInfo * XGetVisualInfo _ANSI_ARGS_((Display* display, + long vinfo_mask, XVisualInfo* vinfo_template, + int* nitems_return)); +/* 78 */ +EXTERN void XSetWMClientMachine _ANSI_ARGS_((Display* display, + Window w, XTextProperty* text_prop)); +/* 79 */ +EXTERN Status XStringListToTextProperty _ANSI_ARGS_((char** list, + int count, XTextProperty* text_prop_return)); +/* 80 */ +EXTERN void XDrawSegments _ANSI_ARGS_((Display * display, + Drawable d, GC gc, XSegment * segments, + int nsegments)); +/* 81 */ +EXTERN void XForceScreenSaver _ANSI_ARGS_((Display* display, + int mode)); +/* 82 */ +EXTERN void XDrawLine _ANSI_ARGS_((Display* d, Drawable dr, GC g, + int x1, int y1, int x2, int y2)); +/* 83 */ +EXTERN void XFillRectangle _ANSI_ARGS_((Display* display, + Drawable d, GC gc, int x, int y, + unsigned int width, unsigned int height)); +/* 84 */ +EXTERN void XClearWindow _ANSI_ARGS_((Display* d, Window w)); +/* 85 */ +EXTERN void XDrawPoint _ANSI_ARGS_((Display* display, Drawable d, + GC gc, int x, int y)); +/* 86 */ +EXTERN void XDrawPoints _ANSI_ARGS_((Display* display, + Drawable d, GC gc, XPoint * points, + int npoints, int mode)); +/* 87 */ +EXTERN void XWarpPointer _ANSI_ARGS_((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)); +/* 88 */ +EXTERN void XQueryColor _ANSI_ARGS_((Display * display, + Colormap colormap, XColor * def_in_out)); +/* 89 */ +EXTERN void XQueryColors _ANSI_ARGS_((Display * display, + Colormap colormap, XColor * defs_in_out, + int ncolors)); +#endif /* MAC_OSX_TK */ typedef struct TkIntXlibStubs { int magic; @@ -720,7 +1006,7 @@ typedef struct TkIntXlibStubs { void (*xResizeWindow) _ANSI_ARGS_((Display* d, Window w, unsigned int ui1, unsigned int ui2)); /* 59 */ void (*xSelectInput) _ANSI_ARGS_((Display* d, Window w, long l)); /* 60 */ Status (*xSendEvent) _ANSI_ARGS_((Display* d, Window w, Bool b, long l, XEvent* x)); /* 61 */ - void (*xSetCommand) _ANSI_ARGS_((Display* d, Window w, char** c, int i)); /* 62 */ + void (*xSetCommand) _ANSI_ARGS_((Display* d, Window w, CONST char** c, int i)); /* 62 */ void (*xSetIconName) _ANSI_ARGS_((Display* d, Window w, _Xconst char* c)); /* 63 */ void (*xSetInputFocus) _ANSI_ARGS_((Display* d, Window w, int i, Time t)); /* 64 */ void (*xSetSelectionOwner) _ANSI_ARGS_((Display* d, Atom a, Window w, Time t)); /* 65 */ @@ -857,24 +1143,543 @@ typedef struct TkIntXlibStubs { void (*xWarpPointer) _ANSI_ARGS_((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) _ANSI_ARGS_((Display * display, Colormap colormap, XColor * def_in_out)); /* 88 */ void (*xQueryColors) _ANSI_ARGS_((Display * display, Colormap colormap, XColor * defs_in_out, int ncolors)); /* 89 */ -#endif /* MAC_TCL */ +#endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + void (*xSetDashes) _ANSI_ARGS_((Display* display, GC gc, int dash_offset, _Xconst char* dash_list, int n)); /* 0 */ + XModifierKeymap* (*xGetModifierMapping) _ANSI_ARGS_((Display* d)); /* 1 */ + XImage * (*xCreateImage) _ANSI_ARGS_((Display* d, Visual* v, unsigned int ui1, int i1, int i2, char* cp, unsigned int ui2, unsigned int ui3, int i3, int i4)); /* 2 */ + XImage * (*xGetImage) _ANSI_ARGS_((Display* d, Drawable dr, int i1, int i2, unsigned int ui1, unsigned int ui2, unsigned long ul, int i3)); /* 3 */ + char * (*xGetAtomName) _ANSI_ARGS_((Display* d, Atom a)); /* 4 */ + char * (*xKeysymToString) _ANSI_ARGS_((KeySym k)); /* 5 */ + Colormap (*xCreateColormap) _ANSI_ARGS_((Display* d, Window w, Visual* v, int i)); /* 6 */ + GContext (*xGContextFromGC) _ANSI_ARGS_((GC g)); /* 7 */ + KeySym (*xKeycodeToKeysym) _ANSI_ARGS_((Display* d, KeyCode k, int i)); /* 8 */ + KeySym (*xStringToKeysym) _ANSI_ARGS_((_Xconst char* c)); /* 9 */ + Window (*xRootWindow) _ANSI_ARGS_((Display* d, int i)); /* 10 */ + XErrorHandler (*xSetErrorHandler) _ANSI_ARGS_((XErrorHandler x)); /* 11 */ + Status (*xAllocColor) _ANSI_ARGS_((Display* d, Colormap c, XColor* xp)); /* 12 */ + void (*xBell) _ANSI_ARGS_((Display* d, int i)); /* 13 */ + void (*xChangeProperty) _ANSI_ARGS_((Display* d, Window w, Atom a1, Atom a2, int i1, int i2, _Xconst unsigned char* c, int i3)); /* 14 */ + void (*xChangeWindowAttributes) _ANSI_ARGS_((Display* d, Window w, unsigned long ul, XSetWindowAttributes* x)); /* 15 */ + void (*xConfigureWindow) _ANSI_ARGS_((Display* d, Window w, unsigned int i, XWindowChanges* x)); /* 16 */ + void (*xCopyArea) _ANSI_ARGS_((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) _ANSI_ARGS_((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) _ANSI_ARGS_((Display* display, Drawable d, _Xconst char* data, unsigned int width, unsigned int height)); /* 19 */ + void (*xDefineCursor) _ANSI_ARGS_((Display* d, Window w, Cursor c)); /* 20 */ + void (*xDestroyWindow) _ANSI_ARGS_((Display* d, Window w)); /* 21 */ + void (*xDrawArc) _ANSI_ARGS_((Display* d, Drawable dr, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2, int i3, int i4)); /* 22 */ + void (*xDrawLines) _ANSI_ARGS_((Display* d, Drawable dr, GC g, XPoint* x, int i1, int i2)); /* 23 */ + void (*xDrawRectangle) _ANSI_ARGS_((Display* d, Drawable dr, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2)); /* 24 */ + void (*xFillArc) _ANSI_ARGS_((Display* d, Drawable dr, GC g, int i1, int i2, unsigned int ui1, unsigned int ui2, int i3, int i4)); /* 25 */ + void (*xFillPolygon) _ANSI_ARGS_((Display* d, Drawable dr, GC g, XPoint* x, int i1, int i2, int i3)); /* 26 */ + void (*xFillRectangles) _ANSI_ARGS_((Display* d, Drawable dr, GC g, XRectangle* x, int i)); /* 27 */ + void (*xFreeColormap) _ANSI_ARGS_((Display* d, Colormap c)); /* 28 */ + void (*xFreeColors) _ANSI_ARGS_((Display* d, Colormap c, unsigned long* ulp, int i, unsigned long ul)); /* 29 */ + void (*xFreeModifiermap) _ANSI_ARGS_((XModifierKeymap* x)); /* 30 */ + Status (*xGetGeometry) _ANSI_ARGS_((Display* d, Drawable dr, Window* w, int* i1, int* i2, unsigned int* ui1, unsigned int* ui2, unsigned int* ui3, unsigned int* ui4)); /* 31 */ + int (*xGetWindowProperty) _ANSI_ARGS_((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)); /* 32 */ + int (*xGrabKeyboard) _ANSI_ARGS_((Display* d, Window w, Bool b, int i1, int i2, Time t)); /* 33 */ + int (*xGrabPointer) _ANSI_ARGS_((Display* d, Window w1, Bool b, unsigned int ui, int i1, int i2, Window w2, Cursor c, Time t)); /* 34 */ + KeyCode (*xKeysymToKeycode) _ANSI_ARGS_((Display* d, KeySym k)); /* 35 */ + void (*xMapWindow) _ANSI_ARGS_((Display* d, Window w)); /* 36 */ + void (*xMoveResizeWindow) _ANSI_ARGS_((Display* d, Window w, int i1, int i2, unsigned int ui1, unsigned int ui2)); /* 37 */ + void (*xMoveWindow) _ANSI_ARGS_((Display* d, Window w, int i1, int i2)); /* 38 */ + Bool (*xQueryPointer) _ANSI_ARGS_((Display* d, Window w1, Window* w2, Window* w3, int* i1, int* i2, int* i3, int* i4, unsigned int* ui)); /* 39 */ + void (*xRaiseWindow) _ANSI_ARGS_((Display* d, Window w)); /* 40 */ + void (*xRefreshKeyboardMapping) _ANSI_ARGS_((XMappingEvent* x)); /* 41 */ + void (*xResizeWindow) _ANSI_ARGS_((Display* d, Window w, unsigned int ui1, unsigned int ui2)); /* 42 */ + void (*xSelectInput) _ANSI_ARGS_((Display* d, Window w, long l)); /* 43 */ + Status (*xSendEvent) _ANSI_ARGS_((Display* d, Window w, Bool b, long l, XEvent* x)); /* 44 */ + void (*xSetIconName) _ANSI_ARGS_((Display* d, Window w, _Xconst char* c)); /* 45 */ + void (*xSetInputFocus) _ANSI_ARGS_((Display* d, Window w, int i, Time t)); /* 46 */ + void (*xSetSelectionOwner) _ANSI_ARGS_((Display* d, Atom a, Window w, Time t)); /* 47 */ + void (*xSetWindowBackground) _ANSI_ARGS_((Display* d, Window w, unsigned long ul)); /* 48 */ + void (*xSetWindowBackgroundPixmap) _ANSI_ARGS_((Display* d, Window w, Pixmap p)); /* 49 */ + void (*xSetWindowBorder) _ANSI_ARGS_((Display* d, Window w, unsigned long ul)); /* 50 */ + void (*xSetWindowBorderPixmap) _ANSI_ARGS_((Display* d, Window w, Pixmap p)); /* 51 */ + void (*xSetWindowBorderWidth) _ANSI_ARGS_((Display* d, Window w, unsigned int ui)); /* 52 */ + void (*xSetWindowColormap) _ANSI_ARGS_((Display* d, Window w, Colormap c)); /* 53 */ + void (*xUngrabKeyboard) _ANSI_ARGS_((Display* d, Time t)); /* 54 */ + void (*xUngrabPointer) _ANSI_ARGS_((Display* d, Time t)); /* 55 */ + void (*xUnmapWindow) _ANSI_ARGS_((Display* d, Window w)); /* 56 */ + void (*tkPutImage) _ANSI_ARGS_((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) _ANSI_ARGS_((Display * display, Colormap map, _Xconst char* spec, XColor * colorPtr)); /* 58 */ + GC (*xCreateGC) _ANSI_ARGS_((Display* display, Drawable d, unsigned long valuemask, XGCValues* values)); /* 59 */ + void (*xFreeGC) _ANSI_ARGS_((Display* display, GC gc)); /* 60 */ + Atom (*xInternAtom) _ANSI_ARGS_((Display* display, _Xconst char* atom_name, Bool only_if_exists)); /* 61 */ + void (*xSetBackground) _ANSI_ARGS_((Display* display, GC gc, unsigned long foreground)); /* 62 */ + void (*xSetForeground) _ANSI_ARGS_((Display* display, GC gc, unsigned long foreground)); /* 63 */ + void (*xSetClipMask) _ANSI_ARGS_((Display* display, GC gc, Pixmap pixmap)); /* 64 */ + void (*xSetClipOrigin) _ANSI_ARGS_((Display* display, GC gc, int clip_x_origin, int clip_y_origin)); /* 65 */ + void (*xSetTSOrigin) _ANSI_ARGS_((Display* display, GC gc, int ts_x_origin, int ts_y_origin)); /* 66 */ + void (*xChangeGC) _ANSI_ARGS_((Display * d, GC gc, unsigned long mask, XGCValues * values)); /* 67 */ + void (*xSetFont) _ANSI_ARGS_((Display * display, GC gc, Font font)); /* 68 */ + void (*xSetArcMode) _ANSI_ARGS_((Display * display, GC gc, int arc_mode)); /* 69 */ + void (*xSetStipple) _ANSI_ARGS_((Display * display, GC gc, Pixmap stipple)); /* 70 */ + void (*xSetFillRule) _ANSI_ARGS_((Display * display, GC gc, int fill_rule)); /* 71 */ + void (*xSetFillStyle) _ANSI_ARGS_((Display * display, GC gc, int fill_style)); /* 72 */ + void (*xSetFunction) _ANSI_ARGS_((Display * display, GC gc, int function)); /* 73 */ + void (*xSetLineAttributes) _ANSI_ARGS_((Display * display, GC gc, unsigned int line_width, int line_style, int cap_style, int join_style)); /* 74 */ + int (*_XInitImageFuncPtrs) _ANSI_ARGS_((XImage * image)); /* 75 */ + XIC (*xCreateIC) _ANSI_ARGS_((void)); /* 76 */ + XVisualInfo * (*xGetVisualInfo) _ANSI_ARGS_((Display* display, long vinfo_mask, XVisualInfo* vinfo_template, int* nitems_return)); /* 77 */ + void (*xSetWMClientMachine) _ANSI_ARGS_((Display* display, Window w, XTextProperty* text_prop)); /* 78 */ + Status (*xStringListToTextProperty) _ANSI_ARGS_((char** list, int count, XTextProperty* text_prop_return)); /* 79 */ + void (*xDrawSegments) _ANSI_ARGS_((Display * display, Drawable d, GC gc, XSegment * segments, int nsegments)); /* 80 */ + void (*xForceScreenSaver) _ANSI_ARGS_((Display* display, int mode)); /* 81 */ + void (*xDrawLine) _ANSI_ARGS_((Display* d, Drawable dr, GC g, int x1, int y1, int x2, int y2)); /* 82 */ + void (*xFillRectangle) _ANSI_ARGS_((Display* display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height)); /* 83 */ + void (*xClearWindow) _ANSI_ARGS_((Display* d, Window w)); /* 84 */ + void (*xDrawPoint) _ANSI_ARGS_((Display* display, Drawable d, GC gc, int x, int y)); /* 85 */ + void (*xDrawPoints) _ANSI_ARGS_((Display* display, Drawable d, GC gc, XPoint * points, int npoints, int mode)); /* 86 */ + void (*xWarpPointer) _ANSI_ARGS_((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) _ANSI_ARGS_((Display * display, Colormap colormap, XColor * def_in_out)); /* 88 */ + void (*xQueryColors) _ANSI_ARGS_((Display * display, Colormap colormap, XColor * defs_in_out, int ncolors)); /* 89 */ +#endif /* MAC_OSX_TK */ } TkIntXlibStubs; #ifdef __cplusplus extern "C" { #endif -extern TkIntXlibStubs *tkIntXlibStubsPtr; -#ifdef __cplusplus -} +extern TkIntXlibStubs *tkIntXlibStubsPtr; +#ifdef __cplusplus +} +#endif + +#if defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) + +/* + * Inline function declarations: + */ + +#ifdef __WIN32__ +#ifndef XSetDashes +#define XSetDashes \ + (tkIntXlibStubsPtr->xSetDashes) /* 0 */ +#endif +#ifndef XGetModifierMapping +#define XGetModifierMapping \ + (tkIntXlibStubsPtr->xGetModifierMapping) /* 1 */ +#endif +#ifndef XCreateImage +#define XCreateImage \ + (tkIntXlibStubsPtr->xCreateImage) /* 2 */ +#endif +#ifndef XGetImage +#define XGetImage \ + (tkIntXlibStubsPtr->xGetImage) /* 3 */ +#endif +#ifndef XGetAtomName +#define XGetAtomName \ + (tkIntXlibStubsPtr->xGetAtomName) /* 4 */ +#endif +#ifndef XKeysymToString +#define XKeysymToString \ + (tkIntXlibStubsPtr->xKeysymToString) /* 5 */ +#endif +#ifndef XCreateColormap +#define XCreateColormap \ + (tkIntXlibStubsPtr->xCreateColormap) /* 6 */ +#endif +#ifndef XCreatePixmapCursor +#define XCreatePixmapCursor \ + (tkIntXlibStubsPtr->xCreatePixmapCursor) /* 7 */ +#endif +#ifndef XCreateGlyphCursor +#define XCreateGlyphCursor \ + (tkIntXlibStubsPtr->xCreateGlyphCursor) /* 8 */ +#endif +#ifndef XGContextFromGC +#define XGContextFromGC \ + (tkIntXlibStubsPtr->xGContextFromGC) /* 9 */ +#endif +#ifndef XListHosts +#define XListHosts \ + (tkIntXlibStubsPtr->xListHosts) /* 10 */ +#endif +#ifndef XKeycodeToKeysym +#define XKeycodeToKeysym \ + (tkIntXlibStubsPtr->xKeycodeToKeysym) /* 11 */ +#endif +#ifndef XStringToKeysym +#define XStringToKeysym \ + (tkIntXlibStubsPtr->xStringToKeysym) /* 12 */ +#endif +#ifndef XRootWindow +#define XRootWindow \ + (tkIntXlibStubsPtr->xRootWindow) /* 13 */ +#endif +#ifndef XSetErrorHandler +#define XSetErrorHandler \ + (tkIntXlibStubsPtr->xSetErrorHandler) /* 14 */ +#endif +#ifndef XIconifyWindow +#define XIconifyWindow \ + (tkIntXlibStubsPtr->xIconifyWindow) /* 15 */ +#endif +#ifndef XWithdrawWindow +#define XWithdrawWindow \ + (tkIntXlibStubsPtr->xWithdrawWindow) /* 16 */ +#endif +#ifndef XGetWMColormapWindows +#define XGetWMColormapWindows \ + (tkIntXlibStubsPtr->xGetWMColormapWindows) /* 17 */ +#endif +#ifndef XAllocColor +#define XAllocColor \ + (tkIntXlibStubsPtr->xAllocColor) /* 18 */ +#endif +#ifndef XBell +#define XBell \ + (tkIntXlibStubsPtr->xBell) /* 19 */ +#endif +#ifndef XChangeProperty +#define XChangeProperty \ + (tkIntXlibStubsPtr->xChangeProperty) /* 20 */ +#endif +#ifndef XChangeWindowAttributes +#define XChangeWindowAttributes \ + (tkIntXlibStubsPtr->xChangeWindowAttributes) /* 21 */ +#endif +#ifndef XClearWindow +#define XClearWindow \ + (tkIntXlibStubsPtr->xClearWindow) /* 22 */ +#endif +#ifndef XConfigureWindow +#define XConfigureWindow \ + (tkIntXlibStubsPtr->xConfigureWindow) /* 23 */ +#endif +#ifndef XCopyArea +#define XCopyArea \ + (tkIntXlibStubsPtr->xCopyArea) /* 24 */ +#endif +#ifndef XCopyPlane +#define XCopyPlane \ + (tkIntXlibStubsPtr->xCopyPlane) /* 25 */ +#endif +#ifndef XCreateBitmapFromData +#define XCreateBitmapFromData \ + (tkIntXlibStubsPtr->xCreateBitmapFromData) /* 26 */ +#endif +#ifndef XDefineCursor +#define XDefineCursor \ + (tkIntXlibStubsPtr->xDefineCursor) /* 27 */ +#endif +#ifndef XDeleteProperty +#define XDeleteProperty \ + (tkIntXlibStubsPtr->xDeleteProperty) /* 28 */ +#endif +#ifndef XDestroyWindow +#define XDestroyWindow \ + (tkIntXlibStubsPtr->xDestroyWindow) /* 29 */ +#endif +#ifndef XDrawArc +#define XDrawArc \ + (tkIntXlibStubsPtr->xDrawArc) /* 30 */ +#endif +#ifndef XDrawLines +#define XDrawLines \ + (tkIntXlibStubsPtr->xDrawLines) /* 31 */ +#endif +#ifndef XDrawRectangle +#define XDrawRectangle \ + (tkIntXlibStubsPtr->xDrawRectangle) /* 32 */ +#endif +#ifndef XFillArc +#define XFillArc \ + (tkIntXlibStubsPtr->xFillArc) /* 33 */ +#endif +#ifndef XFillPolygon +#define XFillPolygon \ + (tkIntXlibStubsPtr->xFillPolygon) /* 34 */ +#endif +#ifndef XFillRectangles +#define XFillRectangles \ + (tkIntXlibStubsPtr->xFillRectangles) /* 35 */ +#endif +#ifndef XForceScreenSaver +#define XForceScreenSaver \ + (tkIntXlibStubsPtr->xForceScreenSaver) /* 36 */ +#endif +#ifndef XFreeColormap +#define XFreeColormap \ + (tkIntXlibStubsPtr->xFreeColormap) /* 37 */ +#endif +#ifndef XFreeColors +#define XFreeColors \ + (tkIntXlibStubsPtr->xFreeColors) /* 38 */ +#endif +#ifndef XFreeCursor +#define XFreeCursor \ + (tkIntXlibStubsPtr->xFreeCursor) /* 39 */ +#endif +#ifndef XFreeModifiermap +#define XFreeModifiermap \ + (tkIntXlibStubsPtr->xFreeModifiermap) /* 40 */ +#endif +#ifndef XGetGeometry +#define XGetGeometry \ + (tkIntXlibStubsPtr->xGetGeometry) /* 41 */ +#endif +#ifndef XGetInputFocus +#define XGetInputFocus \ + (tkIntXlibStubsPtr->xGetInputFocus) /* 42 */ +#endif +#ifndef XGetWindowProperty +#define XGetWindowProperty \ + (tkIntXlibStubsPtr->xGetWindowProperty) /* 43 */ +#endif +#ifndef XGetWindowAttributes +#define XGetWindowAttributes \ + (tkIntXlibStubsPtr->xGetWindowAttributes) /* 44 */ +#endif +#ifndef XGrabKeyboard +#define XGrabKeyboard \ + (tkIntXlibStubsPtr->xGrabKeyboard) /* 45 */ +#endif +#ifndef XGrabPointer +#define XGrabPointer \ + (tkIntXlibStubsPtr->xGrabPointer) /* 46 */ +#endif +#ifndef XKeysymToKeycode +#define XKeysymToKeycode \ + (tkIntXlibStubsPtr->xKeysymToKeycode) /* 47 */ +#endif +#ifndef XLookupColor +#define XLookupColor \ + (tkIntXlibStubsPtr->xLookupColor) /* 48 */ +#endif +#ifndef XMapWindow +#define XMapWindow \ + (tkIntXlibStubsPtr->xMapWindow) /* 49 */ +#endif +#ifndef XMoveResizeWindow +#define XMoveResizeWindow \ + (tkIntXlibStubsPtr->xMoveResizeWindow) /* 50 */ +#endif +#ifndef XMoveWindow +#define XMoveWindow \ + (tkIntXlibStubsPtr->xMoveWindow) /* 51 */ +#endif +#ifndef XNextEvent +#define XNextEvent \ + (tkIntXlibStubsPtr->xNextEvent) /* 52 */ +#endif +#ifndef XPutBackEvent +#define XPutBackEvent \ + (tkIntXlibStubsPtr->xPutBackEvent) /* 53 */ +#endif +#ifndef XQueryColors +#define XQueryColors \ + (tkIntXlibStubsPtr->xQueryColors) /* 54 */ #endif - -#if defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) - -/* - * Inline function declarations: - */ - -#ifdef __WIN32__ +#ifndef XQueryPointer +#define XQueryPointer \ + (tkIntXlibStubsPtr->xQueryPointer) /* 55 */ +#endif +#ifndef XQueryTree +#define XQueryTree \ + (tkIntXlibStubsPtr->xQueryTree) /* 56 */ +#endif +#ifndef XRaiseWindow +#define XRaiseWindow \ + (tkIntXlibStubsPtr->xRaiseWindow) /* 57 */ +#endif +#ifndef XRefreshKeyboardMapping +#define XRefreshKeyboardMapping \ + (tkIntXlibStubsPtr->xRefreshKeyboardMapping) /* 58 */ +#endif +#ifndef XResizeWindow +#define XResizeWindow \ + (tkIntXlibStubsPtr->xResizeWindow) /* 59 */ +#endif +#ifndef XSelectInput +#define XSelectInput \ + (tkIntXlibStubsPtr->xSelectInput) /* 60 */ +#endif +#ifndef XSendEvent +#define XSendEvent \ + (tkIntXlibStubsPtr->xSendEvent) /* 61 */ +#endif +#ifndef XSetCommand +#define XSetCommand \ + (tkIntXlibStubsPtr->xSetCommand) /* 62 */ +#endif +#ifndef XSetIconName +#define XSetIconName \ + (tkIntXlibStubsPtr->xSetIconName) /* 63 */ +#endif +#ifndef XSetInputFocus +#define XSetInputFocus \ + (tkIntXlibStubsPtr->xSetInputFocus) /* 64 */ +#endif +#ifndef XSetSelectionOwner +#define XSetSelectionOwner \ + (tkIntXlibStubsPtr->xSetSelectionOwner) /* 65 */ +#endif +#ifndef XSetWindowBackground +#define XSetWindowBackground \ + (tkIntXlibStubsPtr->xSetWindowBackground) /* 66 */ +#endif +#ifndef XSetWindowBackgroundPixmap +#define XSetWindowBackgroundPixmap \ + (tkIntXlibStubsPtr->xSetWindowBackgroundPixmap) /* 67 */ +#endif +#ifndef XSetWindowBorder +#define XSetWindowBorder \ + (tkIntXlibStubsPtr->xSetWindowBorder) /* 68 */ +#endif +#ifndef XSetWindowBorderPixmap +#define XSetWindowBorderPixmap \ + (tkIntXlibStubsPtr->xSetWindowBorderPixmap) /* 69 */ +#endif +#ifndef XSetWindowBorderWidth +#define XSetWindowBorderWidth \ + (tkIntXlibStubsPtr->xSetWindowBorderWidth) /* 70 */ +#endif +#ifndef XSetWindowColormap +#define XSetWindowColormap \ + (tkIntXlibStubsPtr->xSetWindowColormap) /* 71 */ +#endif +#ifndef XTranslateCoordinates +#define XTranslateCoordinates \ + (tkIntXlibStubsPtr->xTranslateCoordinates) /* 72 */ +#endif +#ifndef XUngrabKeyboard +#define XUngrabKeyboard \ + (tkIntXlibStubsPtr->xUngrabKeyboard) /* 73 */ +#endif +#ifndef XUngrabPointer +#define XUngrabPointer \ + (tkIntXlibStubsPtr->xUngrabPointer) /* 74 */ +#endif +#ifndef XUnmapWindow +#define XUnmapWindow \ + (tkIntXlibStubsPtr->xUnmapWindow) /* 75 */ +#endif +#ifndef XWindowEvent +#define XWindowEvent \ + (tkIntXlibStubsPtr->xWindowEvent) /* 76 */ +#endif +#ifndef XDestroyIC +#define XDestroyIC \ + (tkIntXlibStubsPtr->xDestroyIC) /* 77 */ +#endif +#ifndef XFilterEvent +#define XFilterEvent \ + (tkIntXlibStubsPtr->xFilterEvent) /* 78 */ +#endif +#ifndef XmbLookupString +#define XmbLookupString \ + (tkIntXlibStubsPtr->xmbLookupString) /* 79 */ +#endif +#ifndef TkPutImage +#define TkPutImage \ + (tkIntXlibStubsPtr->tkPutImage) /* 80 */ +#endif +/* Slot 81 is reserved */ +#ifndef XParseColor +#define XParseColor \ + (tkIntXlibStubsPtr->xParseColor) /* 82 */ +#endif +#ifndef XCreateGC +#define XCreateGC \ + (tkIntXlibStubsPtr->xCreateGC) /* 83 */ +#endif +#ifndef XFreeGC +#define XFreeGC \ + (tkIntXlibStubsPtr->xFreeGC) /* 84 */ +#endif +#ifndef XInternAtom +#define XInternAtom \ + (tkIntXlibStubsPtr->xInternAtom) /* 85 */ +#endif +#ifndef XSetBackground +#define XSetBackground \ + (tkIntXlibStubsPtr->xSetBackground) /* 86 */ +#endif +#ifndef XSetForeground +#define XSetForeground \ + (tkIntXlibStubsPtr->xSetForeground) /* 87 */ +#endif +#ifndef XSetClipMask +#define XSetClipMask \ + (tkIntXlibStubsPtr->xSetClipMask) /* 88 */ +#endif +#ifndef XSetClipOrigin +#define XSetClipOrigin \ + (tkIntXlibStubsPtr->xSetClipOrigin) /* 89 */ +#endif +#ifndef XSetTSOrigin +#define XSetTSOrigin \ + (tkIntXlibStubsPtr->xSetTSOrigin) /* 90 */ +#endif +#ifndef XChangeGC +#define XChangeGC \ + (tkIntXlibStubsPtr->xChangeGC) /* 91 */ +#endif +#ifndef XSetFont +#define XSetFont \ + (tkIntXlibStubsPtr->xSetFont) /* 92 */ +#endif +#ifndef XSetArcMode +#define XSetArcMode \ + (tkIntXlibStubsPtr->xSetArcMode) /* 93 */ +#endif +#ifndef XSetStipple +#define XSetStipple \ + (tkIntXlibStubsPtr->xSetStipple) /* 94 */ +#endif +#ifndef XSetFillRule +#define XSetFillRule \ + (tkIntXlibStubsPtr->xSetFillRule) /* 95 */ +#endif +#ifndef XSetFillStyle +#define XSetFillStyle \ + (tkIntXlibStubsPtr->xSetFillStyle) /* 96 */ +#endif +#ifndef XSetFunction +#define XSetFunction \ + (tkIntXlibStubsPtr->xSetFunction) /* 97 */ +#endif +#ifndef XSetLineAttributes +#define XSetLineAttributes \ + (tkIntXlibStubsPtr->xSetLineAttributes) /* 98 */ +#endif +#ifndef _XInitImageFuncPtrs +#define _XInitImageFuncPtrs \ + (tkIntXlibStubsPtr->_XInitImageFuncPtrs) /* 99 */ +#endif +#ifndef XCreateIC +#define XCreateIC \ + (tkIntXlibStubsPtr->xCreateIC) /* 100 */ +#endif +#ifndef XGetVisualInfo +#define XGetVisualInfo \ + (tkIntXlibStubsPtr->xGetVisualInfo) /* 101 */ +#endif +#ifndef XSetWMClientMachine +#define XSetWMClientMachine \ + (tkIntXlibStubsPtr->xSetWMClientMachine) /* 102 */ +#endif +#ifndef XStringListToTextProperty +#define XStringListToTextProperty \ + (tkIntXlibStubsPtr->xStringListToTextProperty) /* 103 */ +#endif +#ifndef XDrawLine +#define XDrawLine \ + (tkIntXlibStubsPtr->xDrawLine) /* 104 */ +#endif +#ifndef XWarpPointer +#define XWarpPointer \ + (tkIntXlibStubsPtr->xWarpPointer) /* 105 */ +#endif +#ifndef XFillRectangle +#define XFillRectangle \ + (tkIntXlibStubsPtr->xFillRectangle) /* 106 */ +#endif +#endif /* __WIN32__ */ +#ifdef MAC_TCL #ifndef XSetDashes #define XSetDashes \ (tkIntXlibStubsPtr->xSetDashes) /* 0 */ @@ -903,405 +1708,340 @@ extern TkIntXlibStubs *tkIntXlibStubsPtr; #define XCreateColormap \ (tkIntXlibStubsPtr->xCreateColormap) /* 6 */ #endif -#ifndef XCreatePixmapCursor -#define XCreatePixmapCursor \ - (tkIntXlibStubsPtr->xCreatePixmapCursor) /* 7 */ -#endif -#ifndef XCreateGlyphCursor -#define XCreateGlyphCursor \ - (tkIntXlibStubsPtr->xCreateGlyphCursor) /* 8 */ -#endif #ifndef XGContextFromGC #define XGContextFromGC \ - (tkIntXlibStubsPtr->xGContextFromGC) /* 9 */ -#endif -#ifndef XListHosts -#define XListHosts \ - (tkIntXlibStubsPtr->xListHosts) /* 10 */ + (tkIntXlibStubsPtr->xGContextFromGC) /* 7 */ #endif #ifndef XKeycodeToKeysym #define XKeycodeToKeysym \ - (tkIntXlibStubsPtr->xKeycodeToKeysym) /* 11 */ + (tkIntXlibStubsPtr->xKeycodeToKeysym) /* 8 */ #endif #ifndef XStringToKeysym #define XStringToKeysym \ - (tkIntXlibStubsPtr->xStringToKeysym) /* 12 */ -#endif -#ifndef XRootWindow -#define XRootWindow \ - (tkIntXlibStubsPtr->xRootWindow) /* 13 */ -#endif -#ifndef XSetErrorHandler -#define XSetErrorHandler \ - (tkIntXlibStubsPtr->xSetErrorHandler) /* 14 */ -#endif -#ifndef XIconifyWindow -#define XIconifyWindow \ - (tkIntXlibStubsPtr->xIconifyWindow) /* 15 */ + (tkIntXlibStubsPtr->xStringToKeysym) /* 9 */ #endif -#ifndef XWithdrawWindow -#define XWithdrawWindow \ - (tkIntXlibStubsPtr->xWithdrawWindow) /* 16 */ +#ifndef XRootWindow +#define XRootWindow \ + (tkIntXlibStubsPtr->xRootWindow) /* 10 */ #endif -#ifndef XGetWMColormapWindows -#define XGetWMColormapWindows \ - (tkIntXlibStubsPtr->xGetWMColormapWindows) /* 17 */ +#ifndef XSetErrorHandler +#define XSetErrorHandler \ + (tkIntXlibStubsPtr->xSetErrorHandler) /* 11 */ #endif #ifndef XAllocColor #define XAllocColor \ - (tkIntXlibStubsPtr->xAllocColor) /* 18 */ + (tkIntXlibStubsPtr->xAllocColor) /* 12 */ #endif #ifndef XBell #define XBell \ - (tkIntXlibStubsPtr->xBell) /* 19 */ + (tkIntXlibStubsPtr->xBell) /* 13 */ #endif #ifndef XChangeProperty #define XChangeProperty \ - (tkIntXlibStubsPtr->xChangeProperty) /* 20 */ + (tkIntXlibStubsPtr->xChangeProperty) /* 14 */ #endif #ifndef XChangeWindowAttributes #define XChangeWindowAttributes \ - (tkIntXlibStubsPtr->xChangeWindowAttributes) /* 21 */ -#endif -#ifndef XClearWindow -#define XClearWindow \ - (tkIntXlibStubsPtr->xClearWindow) /* 22 */ + (tkIntXlibStubsPtr->xChangeWindowAttributes) /* 15 */ #endif #ifndef XConfigureWindow #define XConfigureWindow \ - (tkIntXlibStubsPtr->xConfigureWindow) /* 23 */ + (tkIntXlibStubsPtr->xConfigureWindow) /* 16 */ #endif #ifndef XCopyArea #define XCopyArea \ - (tkIntXlibStubsPtr->xCopyArea) /* 24 */ + (tkIntXlibStubsPtr->xCopyArea) /* 17 */ #endif #ifndef XCopyPlane #define XCopyPlane \ - (tkIntXlibStubsPtr->xCopyPlane) /* 25 */ + (tkIntXlibStubsPtr->xCopyPlane) /* 18 */ #endif #ifndef XCreateBitmapFromData #define XCreateBitmapFromData \ - (tkIntXlibStubsPtr->xCreateBitmapFromData) /* 26 */ + (tkIntXlibStubsPtr->xCreateBitmapFromData) /* 19 */ #endif #ifndef XDefineCursor #define XDefineCursor \ - (tkIntXlibStubsPtr->xDefineCursor) /* 27 */ -#endif -#ifndef XDeleteProperty -#define XDeleteProperty \ - (tkIntXlibStubsPtr->xDeleteProperty) /* 28 */ + (tkIntXlibStubsPtr->xDefineCursor) /* 20 */ #endif #ifndef XDestroyWindow #define XDestroyWindow \ - (tkIntXlibStubsPtr->xDestroyWindow) /* 29 */ + (tkIntXlibStubsPtr->xDestroyWindow) /* 21 */ #endif #ifndef XDrawArc #define XDrawArc \ - (tkIntXlibStubsPtr->xDrawArc) /* 30 */ + (tkIntXlibStubsPtr->xDrawArc) /* 22 */ #endif #ifndef XDrawLines #define XDrawLines \ - (tkIntXlibStubsPtr->xDrawLines) /* 31 */ + (tkIntXlibStubsPtr->xDrawLines) /* 23 */ #endif #ifndef XDrawRectangle #define XDrawRectangle \ - (tkIntXlibStubsPtr->xDrawRectangle) /* 32 */ + (tkIntXlibStubsPtr->xDrawRectangle) /* 24 */ #endif #ifndef XFillArc #define XFillArc \ - (tkIntXlibStubsPtr->xFillArc) /* 33 */ + (tkIntXlibStubsPtr->xFillArc) /* 25 */ #endif #ifndef XFillPolygon #define XFillPolygon \ - (tkIntXlibStubsPtr->xFillPolygon) /* 34 */ + (tkIntXlibStubsPtr->xFillPolygon) /* 26 */ #endif #ifndef XFillRectangles #define XFillRectangles \ - (tkIntXlibStubsPtr->xFillRectangles) /* 35 */ -#endif -#ifndef XForceScreenSaver -#define XForceScreenSaver \ - (tkIntXlibStubsPtr->xForceScreenSaver) /* 36 */ + (tkIntXlibStubsPtr->xFillRectangles) /* 27 */ #endif #ifndef XFreeColormap #define XFreeColormap \ - (tkIntXlibStubsPtr->xFreeColormap) /* 37 */ + (tkIntXlibStubsPtr->xFreeColormap) /* 28 */ #endif #ifndef XFreeColors #define XFreeColors \ - (tkIntXlibStubsPtr->xFreeColors) /* 38 */ -#endif -#ifndef XFreeCursor -#define XFreeCursor \ - (tkIntXlibStubsPtr->xFreeCursor) /* 39 */ + (tkIntXlibStubsPtr->xFreeColors) /* 29 */ #endif #ifndef XFreeModifiermap #define XFreeModifiermap \ - (tkIntXlibStubsPtr->xFreeModifiermap) /* 40 */ + (tkIntXlibStubsPtr->xFreeModifiermap) /* 30 */ #endif #ifndef XGetGeometry #define XGetGeometry \ - (tkIntXlibStubsPtr->xGetGeometry) /* 41 */ -#endif -#ifndef XGetInputFocus -#define XGetInputFocus \ - (tkIntXlibStubsPtr->xGetInputFocus) /* 42 */ + (tkIntXlibStubsPtr->xGetGeometry) /* 31 */ #endif #ifndef XGetWindowProperty #define XGetWindowProperty \ - (tkIntXlibStubsPtr->xGetWindowProperty) /* 43 */ -#endif -#ifndef XGetWindowAttributes -#define XGetWindowAttributes \ - (tkIntXlibStubsPtr->xGetWindowAttributes) /* 44 */ + (tkIntXlibStubsPtr->xGetWindowProperty) /* 32 */ #endif #ifndef XGrabKeyboard #define XGrabKeyboard \ - (tkIntXlibStubsPtr->xGrabKeyboard) /* 45 */ + (tkIntXlibStubsPtr->xGrabKeyboard) /* 33 */ #endif #ifndef XGrabPointer #define XGrabPointer \ - (tkIntXlibStubsPtr->xGrabPointer) /* 46 */ + (tkIntXlibStubsPtr->xGrabPointer) /* 34 */ #endif #ifndef XKeysymToKeycode #define XKeysymToKeycode \ - (tkIntXlibStubsPtr->xKeysymToKeycode) /* 47 */ -#endif -#ifndef XLookupColor -#define XLookupColor \ - (tkIntXlibStubsPtr->xLookupColor) /* 48 */ + (tkIntXlibStubsPtr->xKeysymToKeycode) /* 35 */ #endif #ifndef XMapWindow #define XMapWindow \ - (tkIntXlibStubsPtr->xMapWindow) /* 49 */ + (tkIntXlibStubsPtr->xMapWindow) /* 36 */ #endif #ifndef XMoveResizeWindow #define XMoveResizeWindow \ - (tkIntXlibStubsPtr->xMoveResizeWindow) /* 50 */ + (tkIntXlibStubsPtr->xMoveResizeWindow) /* 37 */ #endif #ifndef XMoveWindow #define XMoveWindow \ - (tkIntXlibStubsPtr->xMoveWindow) /* 51 */ -#endif -#ifndef XNextEvent -#define XNextEvent \ - (tkIntXlibStubsPtr->xNextEvent) /* 52 */ -#endif -#ifndef XPutBackEvent -#define XPutBackEvent \ - (tkIntXlibStubsPtr->xPutBackEvent) /* 53 */ -#endif -#ifndef XQueryColors -#define XQueryColors \ - (tkIntXlibStubsPtr->xQueryColors) /* 54 */ + (tkIntXlibStubsPtr->xMoveWindow) /* 38 */ #endif #ifndef XQueryPointer #define XQueryPointer \ - (tkIntXlibStubsPtr->xQueryPointer) /* 55 */ -#endif -#ifndef XQueryTree -#define XQueryTree \ - (tkIntXlibStubsPtr->xQueryTree) /* 56 */ + (tkIntXlibStubsPtr->xQueryPointer) /* 39 */ #endif #ifndef XRaiseWindow #define XRaiseWindow \ - (tkIntXlibStubsPtr->xRaiseWindow) /* 57 */ + (tkIntXlibStubsPtr->xRaiseWindow) /* 40 */ #endif #ifndef XRefreshKeyboardMapping #define XRefreshKeyboardMapping \ - (tkIntXlibStubsPtr->xRefreshKeyboardMapping) /* 58 */ + (tkIntXlibStubsPtr->xRefreshKeyboardMapping) /* 41 */ #endif #ifndef XResizeWindow #define XResizeWindow \ - (tkIntXlibStubsPtr->xResizeWindow) /* 59 */ + (tkIntXlibStubsPtr->xResizeWindow) /* 42 */ #endif #ifndef XSelectInput #define XSelectInput \ - (tkIntXlibStubsPtr->xSelectInput) /* 60 */ + (tkIntXlibStubsPtr->xSelectInput) /* 43 */ #endif #ifndef XSendEvent #define XSendEvent \ - (tkIntXlibStubsPtr->xSendEvent) /* 61 */ -#endif -#ifndef XSetCommand -#define XSetCommand \ - (tkIntXlibStubsPtr->xSetCommand) /* 62 */ + (tkIntXlibStubsPtr->xSendEvent) /* 44 */ #endif #ifndef XSetIconName #define XSetIconName \ - (tkIntXlibStubsPtr->xSetIconName) /* 63 */ + (tkIntXlibStubsPtr->xSetIconName) /* 45 */ #endif #ifndef XSetInputFocus #define XSetInputFocus \ - (tkIntXlibStubsPtr->xSetInputFocus) /* 64 */ + (tkIntXlibStubsPtr->xSetInputFocus) /* 46 */ #endif #ifndef XSetSelectionOwner #define XSetSelectionOwner \ - (tkIntXlibStubsPtr->xSetSelectionOwner) /* 65 */ + (tkIntXlibStubsPtr->xSetSelectionOwner) /* 47 */ #endif #ifndef XSetWindowBackground #define XSetWindowBackground \ - (tkIntXlibStubsPtr->xSetWindowBackground) /* 66 */ + (tkIntXlibStubsPtr->xSetWindowBackground) /* 48 */ #endif #ifndef XSetWindowBackgroundPixmap #define XSetWindowBackgroundPixmap \ - (tkIntXlibStubsPtr->xSetWindowBackgroundPixmap) /* 67 */ + (tkIntXlibStubsPtr->xSetWindowBackgroundPixmap) /* 49 */ #endif #ifndef XSetWindowBorder #define XSetWindowBorder \ - (tkIntXlibStubsPtr->xSetWindowBorder) /* 68 */ + (tkIntXlibStubsPtr->xSetWindowBorder) /* 50 */ #endif #ifndef XSetWindowBorderPixmap #define XSetWindowBorderPixmap \ - (tkIntXlibStubsPtr->xSetWindowBorderPixmap) /* 69 */ + (tkIntXlibStubsPtr->xSetWindowBorderPixmap) /* 51 */ #endif #ifndef XSetWindowBorderWidth #define XSetWindowBorderWidth \ - (tkIntXlibStubsPtr->xSetWindowBorderWidth) /* 70 */ + (tkIntXlibStubsPtr->xSetWindowBorderWidth) /* 52 */ #endif #ifndef XSetWindowColormap #define XSetWindowColormap \ - (tkIntXlibStubsPtr->xSetWindowColormap) /* 71 */ -#endif -#ifndef XTranslateCoordinates -#define XTranslateCoordinates \ - (tkIntXlibStubsPtr->xTranslateCoordinates) /* 72 */ + (tkIntXlibStubsPtr->xSetWindowColormap) /* 53 */ #endif #ifndef XUngrabKeyboard #define XUngrabKeyboard \ - (tkIntXlibStubsPtr->xUngrabKeyboard) /* 73 */ + (tkIntXlibStubsPtr->xUngrabKeyboard) /* 54 */ #endif #ifndef XUngrabPointer #define XUngrabPointer \ - (tkIntXlibStubsPtr->xUngrabPointer) /* 74 */ + (tkIntXlibStubsPtr->xUngrabPointer) /* 55 */ #endif #ifndef XUnmapWindow #define XUnmapWindow \ - (tkIntXlibStubsPtr->xUnmapWindow) /* 75 */ -#endif -#ifndef XWindowEvent -#define XWindowEvent \ - (tkIntXlibStubsPtr->xWindowEvent) /* 76 */ -#endif -#ifndef XDestroyIC -#define XDestroyIC \ - (tkIntXlibStubsPtr->xDestroyIC) /* 77 */ -#endif -#ifndef XFilterEvent -#define XFilterEvent \ - (tkIntXlibStubsPtr->xFilterEvent) /* 78 */ -#endif -#ifndef XmbLookupString -#define XmbLookupString \ - (tkIntXlibStubsPtr->xmbLookupString) /* 79 */ + (tkIntXlibStubsPtr->xUnmapWindow) /* 56 */ #endif #ifndef TkPutImage #define TkPutImage \ - (tkIntXlibStubsPtr->tkPutImage) /* 80 */ + (tkIntXlibStubsPtr->tkPutImage) /* 57 */ #endif -/* Slot 81 is reserved */ #ifndef XParseColor #define XParseColor \ - (tkIntXlibStubsPtr->xParseColor) /* 82 */ + (tkIntXlibStubsPtr->xParseColor) /* 58 */ #endif #ifndef XCreateGC #define XCreateGC \ - (tkIntXlibStubsPtr->xCreateGC) /* 83 */ + (tkIntXlibStubsPtr->xCreateGC) /* 59 */ #endif #ifndef XFreeGC #define XFreeGC \ - (tkIntXlibStubsPtr->xFreeGC) /* 84 */ + (tkIntXlibStubsPtr->xFreeGC) /* 60 */ #endif #ifndef XInternAtom #define XInternAtom \ - (tkIntXlibStubsPtr->xInternAtom) /* 85 */ + (tkIntXlibStubsPtr->xInternAtom) /* 61 */ #endif #ifndef XSetBackground #define XSetBackground \ - (tkIntXlibStubsPtr->xSetBackground) /* 86 */ + (tkIntXlibStubsPtr->xSetBackground) /* 62 */ #endif #ifndef XSetForeground #define XSetForeground \ - (tkIntXlibStubsPtr->xSetForeground) /* 87 */ + (tkIntXlibStubsPtr->xSetForeground) /* 63 */ #endif #ifndef XSetClipMask #define XSetClipMask \ - (tkIntXlibStubsPtr->xSetClipMask) /* 88 */ + (tkIntXlibStubsPtr->xSetClipMask) /* 64 */ #endif #ifndef XSetClipOrigin #define XSetClipOrigin \ - (tkIntXlibStubsPtr->xSetClipOrigin) /* 89 */ + (tkIntXlibStubsPtr->xSetClipOrigin) /* 65 */ #endif #ifndef XSetTSOrigin #define XSetTSOrigin \ - (tkIntXlibStubsPtr->xSetTSOrigin) /* 90 */ + (tkIntXlibStubsPtr->xSetTSOrigin) /* 66 */ #endif #ifndef XChangeGC #define XChangeGC \ - (tkIntXlibStubsPtr->xChangeGC) /* 91 */ + (tkIntXlibStubsPtr->xChangeGC) /* 67 */ #endif #ifndef XSetFont #define XSetFont \ - (tkIntXlibStubsPtr->xSetFont) /* 92 */ + (tkIntXlibStubsPtr->xSetFont) /* 68 */ #endif #ifndef XSetArcMode #define XSetArcMode \ - (tkIntXlibStubsPtr->xSetArcMode) /* 93 */ + (tkIntXlibStubsPtr->xSetArcMode) /* 69 */ #endif #ifndef XSetStipple #define XSetStipple \ - (tkIntXlibStubsPtr->xSetStipple) /* 94 */ + (tkIntXlibStubsPtr->xSetStipple) /* 70 */ #endif #ifndef XSetFillRule #define XSetFillRule \ - (tkIntXlibStubsPtr->xSetFillRule) /* 95 */ + (tkIntXlibStubsPtr->xSetFillRule) /* 71 */ #endif #ifndef XSetFillStyle #define XSetFillStyle \ - (tkIntXlibStubsPtr->xSetFillStyle) /* 96 */ + (tkIntXlibStubsPtr->xSetFillStyle) /* 72 */ #endif #ifndef XSetFunction #define XSetFunction \ - (tkIntXlibStubsPtr->xSetFunction) /* 97 */ + (tkIntXlibStubsPtr->xSetFunction) /* 73 */ #endif #ifndef XSetLineAttributes #define XSetLineAttributes \ - (tkIntXlibStubsPtr->xSetLineAttributes) /* 98 */ + (tkIntXlibStubsPtr->xSetLineAttributes) /* 74 */ #endif #ifndef _XInitImageFuncPtrs #define _XInitImageFuncPtrs \ - (tkIntXlibStubsPtr->_XInitImageFuncPtrs) /* 99 */ + (tkIntXlibStubsPtr->_XInitImageFuncPtrs) /* 75 */ #endif #ifndef XCreateIC #define XCreateIC \ - (tkIntXlibStubsPtr->xCreateIC) /* 100 */ + (tkIntXlibStubsPtr->xCreateIC) /* 76 */ #endif #ifndef XGetVisualInfo #define XGetVisualInfo \ - (tkIntXlibStubsPtr->xGetVisualInfo) /* 101 */ + (tkIntXlibStubsPtr->xGetVisualInfo) /* 77 */ #endif #ifndef XSetWMClientMachine #define XSetWMClientMachine \ - (tkIntXlibStubsPtr->xSetWMClientMachine) /* 102 */ + (tkIntXlibStubsPtr->xSetWMClientMachine) /* 78 */ #endif #ifndef XStringListToTextProperty #define XStringListToTextProperty \ - (tkIntXlibStubsPtr->xStringListToTextProperty) /* 103 */ + (tkIntXlibStubsPtr->xStringListToTextProperty) /* 79 */ +#endif +#ifndef XDrawSegments +#define XDrawSegments \ + (tkIntXlibStubsPtr->xDrawSegments) /* 80 */ +#endif +#ifndef XForceScreenSaver +#define XForceScreenSaver \ + (tkIntXlibStubsPtr->xForceScreenSaver) /* 81 */ #endif #ifndef XDrawLine #define XDrawLine \ - (tkIntXlibStubsPtr->xDrawLine) /* 104 */ + (tkIntXlibStubsPtr->xDrawLine) /* 82 */ +#endif +#ifndef XFillRectangle +#define XFillRectangle \ + (tkIntXlibStubsPtr->xFillRectangle) /* 83 */ +#endif +#ifndef XClearWindow +#define XClearWindow \ + (tkIntXlibStubsPtr->xClearWindow) /* 84 */ +#endif +#ifndef XDrawPoint +#define XDrawPoint \ + (tkIntXlibStubsPtr->xDrawPoint) /* 85 */ +#endif +#ifndef XDrawPoints +#define XDrawPoints \ + (tkIntXlibStubsPtr->xDrawPoints) /* 86 */ #endif #ifndef XWarpPointer #define XWarpPointer \ - (tkIntXlibStubsPtr->xWarpPointer) /* 105 */ + (tkIntXlibStubsPtr->xWarpPointer) /* 87 */ #endif -#ifndef XFillRectangle -#define XFillRectangle \ - (tkIntXlibStubsPtr->xFillRectangle) /* 106 */ +#ifndef XQueryColor +#define XQueryColor \ + (tkIntXlibStubsPtr->xQueryColor) /* 88 */ #endif -#endif /* __WIN32__ */ -#ifdef MAC_TCL +#ifndef XQueryColors +#define XQueryColors \ + (tkIntXlibStubsPtr->xQueryColors) /* 89 */ +#endif +#endif /* MAC_TCL */ +#ifdef MAC_OSX_TK #ifndef XSetDashes #define XSetDashes \ (tkIntXlibStubsPtr->xSetDashes) /* 0 */ @@ -1662,7 +2402,7 @@ extern TkIntXlibStubs *tkIntXlibStubsPtr; #define XQueryColors \ (tkIntXlibStubsPtr->xQueryColors) /* 89 */ #endif -#endif /* MAC_TCL */ +#endif /* MAC_OSX_TK */ #endif /* defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) */ diff --git a/tk/generic/tkListbox.c b/tk/generic/tkListbox.c index f6b0f75f6ca..7cfc23bed7f 100644 --- a/tk/generic/tkListbox.c +++ b/tk/generic/tkListbox.c @@ -18,6 +18,10 @@ #include "default.h" #include "tkInt.h" +#ifdef WIN32 +#include "tkWinInt.h" +#endif + typedef struct { Tk_OptionTable listboxOptionTable; /* Table defining configuration options * available for the listbox */ @@ -74,6 +78,7 @@ typedef struct { * room for borders. */ Tk_Font tkfont; /* Information about text font, or NULL. */ XColor *fgColorPtr; /* Text color in normal mode. */ + XColor *dfgColorPtr; /* Text color in disabled mode. */ GC textGC; /* For drawing normal text. */ Tk_3DBorder selBorder; /* Borders and backgrounds for selected * elements. */ @@ -127,6 +132,8 @@ typedef struct { int active; /* Index of "active" element (the one that * has been selected by keyboard traversal). * -1 means none. */ + int activeStyle; /* style in which to draw the active element. + * One of: underline, none, dotbox */ /* * Information for scanning: @@ -155,6 +162,8 @@ typedef struct { char *xScrollCmd; /* Command prefix for communicating with * horizontal scrollbar. NULL means no command * to issue. Malloc'ed. */ + int state; /* Listbox state. */ + Pixmap gray; /* Pixmap for displaying disabled text. */ int flags; /* Various flag bits: see below for * definitions. */ } Listbox; @@ -193,11 +202,36 @@ typedef struct { #define MAXWIDTH_IS_STALE 16 #define LISTBOX_DELETED 32 +/* + * The following enum is used to define a type for the -state option + * of the Entry widget. These values are used as indices into the + * string table below. + */ + +enum state { + STATE_DISABLED, STATE_NORMAL +}; + +static char *stateStrings[] = { + "disabled", "normal", (char *) NULL +}; + +enum activeStyle { + ACTIVE_STYLE_DOTBOX, ACTIVE_STYLE_NONE, ACTIVE_STYLE_UNDERLINE +}; + +static char *activeStyleStrings[] = { + "dotbox", "none", "underline", (char *) NULL +}; + /* * The optionSpecs table defines the valid configuration options for the * listbox widget */ static Tk_OptionSpec optionSpecs[] = { + {TK_OPTION_STRING_TABLE, "-activestyle", "activeStyle", "ActiveStyle", + DEF_LISTBOX_ACTIVE_STYLE, -1, Tk_Offset(Listbox, activeStyle), + 0, (ClientData) activeStyleStrings, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_LISTBOX_BG_COLOR, -1, Tk_Offset(Listbox, normalBorder), 0, (ClientData) DEF_LISTBOX_BG_MONO, 0}, @@ -211,6 +245,9 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_LISTBOX_CURSOR, -1, Tk_Offset(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}, {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection", "ExportSelection", DEF_LISTBOX_EXPORT_SELECTION, -1, Tk_Offset(Listbox, exportSelection), 0, 0, 0}, @@ -247,6 +284,9 @@ static Tk_OptionSpec optionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid", DEF_LISTBOX_SET_GRID, -1, Tk_Offset(Listbox, setGrid), 0, 0, 0}, + {TK_OPTION_STRING_TABLE, "-state", "state", "State", + DEF_LISTBOX_STATE, -1, Tk_Offset(Listbox, state), + 0, (ClientData) stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_LISTBOX_TAKE_FOCUS, -1, Tk_Offset(Listbox, takeFocus), TK_OPTION_NULL_OK, 0, 0}, @@ -271,26 +311,26 @@ static Tk_OptionSpec optionSpecs[] = { */ static Tk_OptionSpec itemAttrOptionSpecs[] = { {TK_OPTION_BORDER, "-background", "background", "Background", - (char *)NULL, -1, Tk_Offset(ItemAttr, border), - TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, + (char *)NULL, -1, Tk_Offset(ItemAttr, border), + TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, (ClientData) DEF_LISTBOX_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-background", 0}, + (char *) NULL, 0, -1, 0, (ClientData) "-background", 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", (char *) NULL, - (char *) NULL, 0, -1, 0, (ClientData) "-foreground", 0}, + (char *) NULL, 0, -1, 0, (ClientData) "-foreground", 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", - (char *) NULL, -1, Tk_Offset(ItemAttr, fgColor), - TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0}, + (char *) NULL, -1, Tk_Offset(ItemAttr, fgColor), + TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", - (char *) NULL, -1, Tk_Offset(ItemAttr, selBorder), - TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, + (char *) NULL, -1, Tk_Offset(ItemAttr, selBorder), + TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, (ClientData) DEF_LISTBOX_SELECT_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", - (char *) NULL, -1, Tk_Offset(ItemAttr, selFgColor), - TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, + (char *) NULL, -1, Tk_Offset(ItemAttr, selFgColor), + TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, (ClientData) DEF_LISTBOX_SELECT_FG_MONO, 0}, {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, - (char *) NULL, 0, -1, 0, 0, 0} + (char *) NULL, 0, -1, 0, 0, 0} }; /* @@ -298,22 +338,22 @@ static Tk_OptionSpec itemAttrOptionSpecs[] = { * commands) and map the indexes into the string tables into * enumerated types used to dispatch the listbox widget command. */ -static char *commandNames[] = { +static CONST char *commandNames[] = { "activate", "bbox", "cget", "configure", "curselection", "delete", "get", - "index", "insert", "itemcget", "itemconfigure", "nearest", "scan", - "see", "selection", "size", "xview", "yview", + "index", "insert", "itemcget", "itemconfigure", "nearest", "scan", + "see", "selection", "size", "xview", "yview", (char *) NULL }; enum command { COMMAND_ACTIVATE, COMMAND_BBOX, COMMAND_CGET, COMMAND_CONFIGURE, - COMMAND_CURSELECTION, COMMAND_DELETE, COMMAND_GET, COMMAND_INDEX, - COMMAND_INSERT, COMMAND_ITEMCGET, COMMAND_ITEMCONFIGURE, - COMMAND_NEAREST, COMMAND_SCAN, COMMAND_SEE, COMMAND_SELECTION, - COMMAND_SIZE, COMMAND_XVIEW, COMMAND_YVIEW + COMMAND_CURSELECTION, COMMAND_DELETE, COMMAND_GET, COMMAND_INDEX, + COMMAND_INSERT, COMMAND_ITEMCGET, COMMAND_ITEMCONFIGURE, + COMMAND_NEAREST, COMMAND_SCAN, COMMAND_SEE, COMMAND_SELECTION, + COMMAND_SIZE, COMMAND_XVIEW, COMMAND_YVIEW }; -static char *selCommandNames[] = { +static CONST char *selCommandNames[] = { "anchor", "clear", "includes", "set", (char *) NULL }; @@ -321,7 +361,7 @@ enum selcommand { SELECTION_ANCHOR, SELECTION_CLEAR, SELECTION_INCLUDES, SELECTION_SET }; -static char *scanCommandNames[] = { +static CONST char *scanCommandNames[] = { "mark", "dragto", (char *) NULL }; @@ -329,7 +369,7 @@ enum scancommand { SCAN_MARK, SCAN_DRAGTO }; -static char *indexNames[] = { +static CONST char *indexNames[] = { "active", "anchor", "end", (char *)NULL }; @@ -402,8 +442,8 @@ static void ListboxWorldChanged _ANSI_ARGS_(( static int NearestListboxElement _ANSI_ARGS_((Listbox *listPtr, int y)); static char * ListboxListVarProc _ANSI_ARGS_ ((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); + Tcl_Interp *interp, CONST char *name1, + CONST char *name2, int flags)); static void MigrateHashEntries _ANSI_ARGS_ ((Tcl_HashTable *table, int first, int last, int offset)); /* @@ -411,10 +451,9 @@ static void MigrateHashEntries _ANSI_ARGS_ ((Tcl_HashTable *table, * that can be invoked from generic window code. */ -static TkClassProcs listboxClass = { - NULL, /* createProc. */ - ListboxWorldChanged, /* geometryProc. */ - NULL /* modalProc. */ +static Tk_ClassProcs listboxClass = { + sizeof(Tk_ClassProcs), /* size */ + ListboxWorldChanged, /* worldChangedProc */ }; @@ -438,7 +477,7 @@ static TkClassProcs listboxClass = { int Tk_ListboxObjCmd(clientData, interp, objc, objv) - ClientData clientData; /* Either NULL or pointer to option table */ + ClientData clientData; /* NULL. */ Tcl_Interp *interp; /* Current interpreter. */ int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ @@ -447,18 +486,28 @@ Tk_ListboxObjCmd(clientData, interp, objc, objv) Tk_Window tkwin; ListboxOptionTables *optionTables; - optionTables = (ListboxOptionTables *)clientData; - if (optionTables == NULL) { - Tcl_CmdInfo info; - char *name; + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); + return TCL_ERROR; + } + + tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), + Tcl_GetString(objv[1]), (char *) NULL); + if (tkwin == NULL) { + return TCL_ERROR; + } + optionTables = (ListboxOptionTables *) + Tcl_GetAssocData(interp, "ListboxOptionTables", NULL); + if (optionTables == NULL) { /* * We haven't created the option tables for this widget class yet. * Do it now and save the a pointer to them as the ClientData for * the command, so future invocations will have access to it. */ - optionTables = - (ListboxOptionTables *) ckalloc(sizeof(ListboxOptionTables)); + + optionTables = (ListboxOptionTables *) + ckalloc(sizeof(ListboxOptionTables)); /* Set up an exit handler to free the optionTables struct */ Tcl_SetAssocData(interp, "ListboxOptionTables", DestroyListboxOptionTables, (ClientData) optionTables); @@ -468,23 +517,6 @@ Tk_ListboxObjCmd(clientData, interp, objc, objv) Tk_CreateOptionTable(interp, optionSpecs); optionTables->itemAttrOptionTable = Tk_CreateOptionTable(interp, itemAttrOptionSpecs); - - /* Store a pointer to the tables as the ClientData for the command */ - name = Tcl_GetString(objv[0]); - Tcl_GetCommandInfo(interp, name, &info); - info.objClientData = (ClientData) optionTables; - Tcl_SetCommandInfo(interp, name, &info); - } - - if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); - return TCL_ERROR; - } - - tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), - Tcl_GetString(objv[1]), (char *) NULL); - if (tkwin == NULL) { - return TCL_ERROR; } /* @@ -493,6 +525,8 @@ Tk_ListboxObjCmd(clientData, interp, objc, objv) * initialized already (e.g. resource pointers). */ listPtr = (Listbox *) ckalloc(sizeof(Listbox)); + memset((void *) listPtr, 0, (sizeof(Listbox))); + listPtr->tkwin = tkwin; listPtr->display = Tk_Display(tkwin); listPtr->interp = interp; @@ -501,56 +535,32 @@ Tk_ListboxObjCmd(clientData, interp, objc, objv) (ClientData) listPtr, ListboxCmdDeletedProc); listPtr->optionTable = optionTables->listboxOptionTable; listPtr->itemAttrOptionTable = optionTables->itemAttrOptionTable; - listPtr->listVarName = NULL; - listPtr->listObj = NULL; listPtr->selection = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(listPtr->selection, TCL_ONE_WORD_KEYS); listPtr->itemAttrTable = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(listPtr->itemAttrTable, TCL_ONE_WORD_KEYS); - listPtr->nElements = 0; - listPtr->normalBorder = NULL; - listPtr->borderWidth = 0; listPtr->relief = TK_RELIEF_RAISED; - listPtr->highlightWidth = 0; - listPtr->highlightBgColorPtr = NULL; - listPtr->highlightColorPtr = NULL; - listPtr->inset = 0; - listPtr->tkfont = NULL; - listPtr->fgColorPtr = NULL; listPtr->textGC = None; - listPtr->selBorder = NULL; - listPtr->selBorderWidth = 0; listPtr->selFgColorPtr = None; listPtr->selTextGC = None; - listPtr->width = 0; - listPtr->height = 0; - listPtr->lineHeight = 0; - listPtr->topIndex = 0; listPtr->fullLines = 1; - listPtr->partialLine = 0; - listPtr->setGrid = 0; - listPtr->maxWidth = 0; listPtr->xScrollUnit = 1; - listPtr->xOffset = 0; - listPtr->selectMode = NULL; - listPtr->numSelected = 0; - listPtr->selectAnchor = 0; listPtr->exportSelection = 1; - listPtr->active = 0; - listPtr->scanMarkX = 0; - listPtr->scanMarkY = 0; - listPtr->scanMarkXOffset = 0; - listPtr->scanMarkYIndex = 0; listPtr->cursor = None; - listPtr->takeFocus = NULL; - listPtr->xScrollCmd = NULL; - listPtr->yScrollCmd = NULL; - listPtr->flags = 0; + listPtr->state = STATE_NORMAL; + listPtr->gray = None; + + /* + * Keep a hold of the associated tkwin until we destroy the listbox, + * otherwise Tk might free it while we still need it. + */ + + Tcl_Preserve((ClientData) listPtr->tkwin); Tk_SetClass(listPtr->tkwin, "Listbox"); - TkSetClassProcs(listPtr->tkwin, &listboxClass, (ClientData) listPtr); + Tk_SetClassProcs(listPtr->tkwin, &listboxClass, (ClientData) listPtr); Tk_CreateEventHandler(listPtr->tkwin, ExposureMask|StructureNotifyMask|FocusChangeMask, ListboxEventProc, (ClientData) listPtr); @@ -604,7 +614,6 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); return TCL_ERROR; } - Tcl_Preserve((ClientData)listPtr); /* * Parse the command by looking up the second argument in the list @@ -613,10 +622,10 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) result = Tcl_GetIndexFromObj(interp, objv[1], commandNames, "option", 0, &cmdIndex); if (result != TCL_OK) { - Tcl_Release((ClientData)listPtr); return result; } + Tcl_Preserve((ClientData)listPtr); /* The subcommand was valid, so continue processing */ switch (cmdIndex) { case COMMAND_ACTIVATE: { @@ -629,6 +638,11 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) if (result != TCL_OK) { break; } + + if (!(listPtr->state & STATE_NORMAL)) { + break; + } + if (index >= listPtr->nElements) { index = listPtr->nElements-1; } @@ -733,6 +747,11 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) if (result != TCL_OK) { break; } + + if (!(listPtr->state & STATE_NORMAL)) { + break; + } + if (first < listPtr->nElements) { /* * if a "last index" was given, get it now; otherwise, use the @@ -838,6 +857,11 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) if (result != TCL_OK) { break; } + + if (!(listPtr->state & STATE_NORMAL)) { + break; + } + result = ListboxInsertSubCmd(listPtr, index, objc-3, objv+3); break; } @@ -1018,6 +1042,10 @@ ListboxWidgetObjCmd(clientData, interp, objc, objv) } case COMMAND_SELECTION: { + if (!(listPtr->state & STATE_NORMAL)) { + break; + } + result = ListboxSelectionSubCmd(interp, listPtr, objc, objv); break; } @@ -1412,16 +1440,6 @@ DestroyListbox(memPtr) Tcl_HashEntry *entry; Tcl_HashSearch search; - listPtr->flags |= LISTBOX_DELETED; - - Tcl_DeleteCommandFromToken(listPtr->interp, listPtr->widgetCmd); - if (listPtr->setGrid) { - Tk_UnsetGrid(listPtr->tkwin); - } - if (listPtr->flags & REDRAW_PENDING) { - Tcl_CancelIdleCall(DisplayListbox, (ClientData) listPtr); - } - /* If we have an internal list object, free it */ if (listPtr->listObj != NULL) { Tcl_DecrRefCount(listPtr->listObj); @@ -1458,8 +1476,13 @@ DestroyListbox(memPtr) if (listPtr->selTextGC != None) { Tk_FreeGC(listPtr->display, listPtr->selTextGC); } + if (listPtr->gray != None) { + Tk_FreeBitmap(Tk_Display(listPtr->tkwin), listPtr->gray); + } + Tk_FreeConfigOptions((char *)listPtr, listPtr->optionTable, listPtr->tkwin); + Tcl_Release((ClientData) listPtr->tkwin); listPtr->tkwin = NULL; ckfree((char *) listPtr); } @@ -1523,7 +1546,8 @@ ConfigureListbox(interp, listPtr, objc, objv, flags) { Tk_SavedOptions savedOptions; Tcl_Obj *oldListObj = NULL; - int oldExport; + Tcl_Obj *errorResult = NULL; + int oldExport, error; oldExport = listPtr->exportSelection; if (listPtr->listVarName != NULL) { @@ -1531,99 +1555,118 @@ ConfigureListbox(interp, listPtr, objc, objv, flags) TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ListboxListVarProc, (ClientData) listPtr); } - - if (Tk_SetOptions(interp, (char *)listPtr, - listPtr->optionTable, objc, objv, listPtr->tkwin, - &savedOptions, (int *)NULL) != TCL_OK) { - Tk_RestoreSavedOptions(&savedOptions); - return TCL_ERROR; - } - - /* - * A few options need special processing, such as setting the - * background from a 3-D border. - */ - Tk_SetBackgroundFromBorder(listPtr->tkwin, listPtr->normalBorder); + for (error = 0; error <= 1; error++) { + if (!error) { + /* + * First pass: set options to new values. + */ - if (listPtr->highlightWidth < 0) { - listPtr->highlightWidth = 0; - } - listPtr->inset = listPtr->highlightWidth + listPtr->borderWidth; + if (Tk_SetOptions(interp, (char *) listPtr, + listPtr->optionTable, objc, objv, + listPtr->tkwin, &savedOptions, (int *) NULL) != TCL_OK) { + continue; + } + } else { + /* + * Second pass: restore options to old values. + */ - /* - * Claim the selection if we've suddenly started exporting it and - * there is a selection to export. - */ + errorResult = Tcl_GetObjResult(interp); + Tcl_IncrRefCount(errorResult); + Tk_RestoreSavedOptions(&savedOptions); + } - if (listPtr->exportSelection && !oldExport - && (listPtr->numSelected != 0)) { - Tk_OwnSelection(listPtr->tkwin, XA_PRIMARY, ListboxLostSelection, - (ClientData) listPtr); - } + /* + * A few options need special processing, such as setting the + * background from a 3-D border. + */ - - /* Verify the current status of the list var. - * PREVIOUS STATE | NEW STATE | ACTION - * ------------------+---------------+---------------------------------- - * no listvar | listvar | If listvar does not exist, create - * it and copy the internal list obj's - * content to the new var. If it does - * exist, toss the internal list obj. - * - * listvar | no listvar | Copy old listvar content to the - * internal list obj - * - * listvar | listvar | no special action - * - * no listvar | no listvar | no special action - */ - oldListObj = listPtr->listObj; - if (listPtr->listVarName != NULL) { - Tcl_Obj *listVarObj = Tcl_GetVar2Ex(interp, listPtr->listVarName, - (char *)NULL, TCL_GLOBAL_ONLY); - int dummy; - if (listVarObj == NULL) { - if (listPtr->listObj != NULL) { - listVarObj = listPtr->listObj; - } else { - listVarObj = Tcl_NewObj(); + Tk_SetBackgroundFromBorder(listPtr->tkwin, listPtr->normalBorder); + + if (listPtr->highlightWidth < 0) { + listPtr->highlightWidth = 0; + } + listPtr->inset = listPtr->highlightWidth + listPtr->borderWidth; + + /* + * Claim the selection if we've suddenly started exporting it and + * there is a selection to export. + */ + + if (listPtr->exportSelection && !oldExport + && (listPtr->numSelected != 0)) { + Tk_OwnSelection(listPtr->tkwin, XA_PRIMARY, ListboxLostSelection, + (ClientData) listPtr); + } + + /* Verify the current status of the list var. + * PREVIOUS STATE | NEW STATE | ACTION + * ---------------+------------+---------------------------------- + * no listvar | listvar | If listvar does not exist, create + * it and copy the internal list obj's + * content to the new var. If it does + * exist, toss the internal list obj. + * + * listvar | no listvar | Copy old listvar content to the + * internal list obj + * + * listvar | listvar | no special action + * + * no listvar | no listvar | no special action + */ + oldListObj = listPtr->listObj; + if (listPtr->listVarName != NULL) { + Tcl_Obj *listVarObj = Tcl_GetVar2Ex(interp, listPtr->listVarName, + (char *) NULL, TCL_GLOBAL_ONLY); + int dummy; + if (listVarObj == NULL) { + listVarObj = (oldListObj ? oldListObj : Tcl_NewObj()); + if (Tcl_SetVar2Ex(interp, listPtr->listVarName, (char *) NULL, + listVarObj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) + == NULL) { + if (oldListObj == NULL) { + Tcl_DecrRefCount(listVarObj); + } + continue; + } } - if (Tcl_SetVar2Ex(interp, listPtr->listVarName, (char *)NULL, - listVarObj, TCL_GLOBAL_ONLY) == NULL) { - Tcl_DecrRefCount(listVarObj); - Tk_RestoreSavedOptions(&savedOptions); - return TCL_ERROR; + /* Make sure the object is a good list object */ + if (Tcl_ListObjLength(listPtr->interp, listVarObj, &dummy) + != TCL_OK) { + Tcl_AppendResult(listPtr->interp, + ": invalid -listvariable value", (char *) NULL); + continue; } - } - /* Make sure the object is a good list object */ - if (Tcl_ListObjLength(listPtr->interp, listVarObj, &dummy) != TCL_OK) { - Tk_RestoreSavedOptions(&savedOptions); - Tcl_AppendResult(listPtr->interp, ": invalid listvar value", - (char *)NULL); - return TCL_ERROR; - } - - listPtr->listObj = listVarObj; - Tcl_TraceVar(listPtr->interp, listPtr->listVarName, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - ListboxListVarProc, (ClientData) listPtr); - } else { - if (listPtr->listObj == NULL) { + + listPtr->listObj = listVarObj; + Tcl_TraceVar(listPtr->interp, listPtr->listVarName, + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + ListboxListVarProc, (ClientData) listPtr); + } else if (listPtr->listObj == NULL) { listPtr->listObj = Tcl_NewObj(); } + Tcl_IncrRefCount(listPtr->listObj); + if (oldListObj != NULL) { + Tcl_DecrRefCount(oldListObj); + } + break; } - Tcl_IncrRefCount(listPtr->listObj); - if (oldListObj != NULL) { - Tcl_DecrRefCount(oldListObj); + if (!error) { + Tk_FreeSavedOptions(&savedOptions); } /* Make sure that the list length is correct */ Tcl_ListObjLength(listPtr->interp, listPtr->listObj, &listPtr->nElements); - Tk_FreeSavedOptions(&savedOptions); - ListboxWorldChanged((ClientData) listPtr); - return TCL_OK; + if (error) { + Tcl_SetObjResult(interp, errorResult); + Tcl_DecrRefCount(errorResult); + return TCL_ERROR; + } else { + ListboxWorldChanged((ClientData) listPtr); + return TCL_OK; + } } /* @@ -1698,10 +1741,30 @@ ListboxWorldChanged(instanceData) listPtr = (Listbox *) instanceData; - gcValues.foreground = listPtr->fgColorPtr->pixel; + if (listPtr->state & STATE_NORMAL) { + gcValues.foreground = listPtr->fgColorPtr->pixel; + gcValues.graphics_exposures = False; + mask = GCForeground | GCFont | GCGraphicsExposures; + } else { + if (listPtr->dfgColorPtr != NULL) { + gcValues.foreground = listPtr->dfgColorPtr->pixel; + gcValues.graphics_exposures = False; + mask = GCForeground | GCFont | GCGraphicsExposures; + } else { + gcValues.foreground = listPtr->fgColorPtr->pixel; + mask = GCForeground | GCFont; + if (listPtr->gray == None) { + listPtr->gray = Tk_GetBitmap(NULL, listPtr->tkwin, "gray50"); + } + if (listPtr->gray != None) { + gcValues.fill_style = FillStippled; + gcValues.stipple = listPtr->gray; + mask |= GCFillStyle | GCStipple; + } + } + } + gcValues.font = Tk_FontId(listPtr->tkfont); - gcValues.graphics_exposures = False; - mask = GCForeground | GCFont | GCGraphicsExposures; gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); if (listPtr->textGC != None) { Tk_FreeGC(listPtr->display, listPtr->textGC); @@ -1750,7 +1813,7 @@ DisplayListbox(clientData) register Listbox *listPtr = (Listbox *) clientData; register Tk_Window tkwin = listPtr->tkwin; GC gc; - int i, limit, x, y, width, prevSelected; + int i, limit, x, y, width, prevSelected, freeGC; Tk_FontMetrics fm; Tcl_Obj *curElement; Tcl_HashEntry *entry; @@ -1766,6 +1829,9 @@ DisplayListbox(clientData) Pixmap pixmap; listPtr->flags &= ~REDRAW_PENDING; + if (listPtr->flags & LISTBOX_DELETED) { + return; + } if (listPtr->flags & MAXWIDTH_IS_STALE) { ListboxComputeGeometry(listPtr, 0, 1, 0); @@ -1773,16 +1839,23 @@ DisplayListbox(clientData) listPtr->flags |= UPDATE_H_SCROLLBAR; } + Tcl_Preserve((ClientData) listPtr); if (listPtr->flags & UPDATE_V_SCROLLBAR) { ListboxUpdateVScrollbar(listPtr); + if ((listPtr->flags & LISTBOX_DELETED) || !Tk_IsMapped(tkwin)) { + Tcl_Release((ClientData) listPtr); + return; + } } if (listPtr->flags & UPDATE_H_SCROLLBAR) { ListboxUpdateHScrollbar(listPtr); + if ((listPtr->flags & LISTBOX_DELETED) || !Tk_IsMapped(tkwin)) { + Tcl_Release((ClientData) listPtr); + return; + } } listPtr->flags &= ~(REDRAW_PENDING|UPDATE_V_SCROLLBAR|UPDATE_H_SCROLLBAR); - if ((listPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { - return; - } + Tcl_Release((ClientData) listPtr); /* * Redrawing is done in a temporary pixmap that is allocated @@ -1817,106 +1890,131 @@ DisplayListbox(clientData) y = ((i - listPtr->topIndex) * listPtr->lineHeight) + listPtr->inset; gc = listPtr->textGC; + freeGC = 0; /* * Lookup this item in the item attributes table, to see if it has * special foreground/background colors */ entry = Tcl_FindHashEntry(listPtr->itemAttrTable, (char *)i); - /* If the item is selected, it is drawn differently */ - if (Tcl_FindHashEntry(listPtr->selection, (char *)i) != NULL) { - gc = listPtr->selTextGC; - width = Tk_Width(tkwin) - 2*listPtr->inset; - selectedBg = listPtr->selBorder; - - /* If there is attribute information for this item, - * adjust the drawing accordingly */ - if (entry != NULL) { - attrs = (ItemAttr *)Tcl_GetHashValue(entry); - /* The default GC has the settings from the widget at large */ - gcValues.foreground = listPtr->selFgColorPtr->pixel; - gcValues.font = Tk_FontId(listPtr->tkfont); - gcValues.graphics_exposures = False; - mask = GCForeground | GCFont | GCGraphicsExposures; - - if (attrs->selBorder != NULL) { - selectedBg = attrs->selBorder; - } - - if (attrs->selFgColor != NULL) { - gcValues.foreground = attrs->selFgColor->pixel; - gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); + /* + * If the listbox is enabled, items may be drawn differently; + * they may be drawn selected, or they may have special foreground + * or background colors. + */ + if (listPtr->state & STATE_NORMAL) { + if (Tcl_FindHashEntry(listPtr->selection, (char *)i) != NULL) { + /* Selected items are drawn differently. */ + gc = listPtr->selTextGC; + width = Tk_Width(tkwin) - 2*listPtr->inset; + selectedBg = listPtr->selBorder; + + /* If there is attribute information for this item, + * adjust the drawing accordingly */ + if (entry != NULL) { + attrs = (ItemAttr *)Tcl_GetHashValue(entry); + /* Default GC has the values from the widget at large */ + gcValues.foreground = listPtr->selFgColorPtr->pixel; + gcValues.font = Tk_FontId(listPtr->tkfont); + gcValues.graphics_exposures = False; + mask = GCForeground | GCFont | GCGraphicsExposures; + + if (attrs->selBorder != NULL) { + selectedBg = attrs->selBorder; + } + + if (attrs->selFgColor != NULL) { + gcValues.foreground = attrs->selFgColor->pixel; + gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); + freeGC = 1; + } } - } - Tk_Fill3DRectangle(tkwin, pixmap, selectedBg, x, y, - width, listPtr->lineHeight, 0, TK_RELIEF_FLAT); + Tk_Fill3DRectangle(tkwin, pixmap, selectedBg, x, y, + width, listPtr->lineHeight, 0, TK_RELIEF_FLAT); - /* - * Draw beveled edges around the selection, if there are visible - * edges next to this element. Special considerations: - * 1. The left and right bevels may not be visible if horizontal - * scrolling is enabled (the "left" and "right" variables - * are zero to indicate that the corresponding bevel is - * visible). - * 2. Top and bottom bevels are only drawn if this is the - * first or last seleted item. - * 3. If the left or right bevel isn't visible, then the "left" - * and "right" variables, computed above, have non-zero values - * that extend the top and bottom bevels so that the mitered - * corners are off-screen. - */ + /* + * Draw beveled edges around the selection, if there are + * visible edges next to this element. Special considerations: + * + * 1. The left and right bevels may not be visible if + * horizontal scrolling is enabled (the "left" & "right" + * variables are zero to indicate that the corresponding + * bevel is visible). + * 2. Top and bottom bevels are only drawn if this is the + * first or last seleted item. + * 3. If the left or right bevel isn't visible, then the + * "left" & "right" vars, computed above, have non-zero + * values that extend the top and bottom bevels so that + * the mitered corners are off-screen. + */ - /* Draw left bevel */ - if (left == 0) { - Tk_3DVerticalBevel(tkwin, pixmap, selectedBg, - x, y, listPtr->selBorderWidth, listPtr->lineHeight, - 1, TK_RELIEF_RAISED); - } - /* Draw right bevel */ - if (right == 0) { - Tk_3DVerticalBevel(tkwin, pixmap, selectedBg, - x + width - listPtr->selBorderWidth, y, - listPtr->selBorderWidth, listPtr->lineHeight, - 0, TK_RELIEF_RAISED); - } - /* Draw top bevel */ - if (!prevSelected) { - Tk_3DHorizontalBevel(tkwin, pixmap, selectedBg, - x-left, y, width+left+right, listPtr->selBorderWidth, - 1, 1, 1, TK_RELIEF_RAISED); - } - /* Draw bottom bevel */ - if (i + 1 == listPtr->nElements || - Tcl_FindHashEntry(listPtr->selection, - (char *)(i + 1)) == NULL ) { - Tk_3DHorizontalBevel(tkwin, pixmap, selectedBg, x-left, - y + listPtr->lineHeight - listPtr->selBorderWidth, - width+left+right, listPtr->selBorderWidth, 0, 0, 0, - TK_RELIEF_RAISED); - } - prevSelected = 1; - } else { - /* If there is an item attributes record for this item, - * draw the background box and set the foreground color - * accordingly */ - if (entry != NULL) { - attrs = (ItemAttr *)Tcl_GetHashValue(entry); - gcValues.foreground = listPtr->fgColorPtr->pixel; - gcValues.font = Tk_FontId(listPtr->tkfont); - gcValues.graphics_exposures = False; - mask = GCForeground | GCFont | GCGraphicsExposures; - if (attrs->border != NULL) { - width = Tk_Width(tkwin) - 2*listPtr->inset; - Tk_Fill3DRectangle(tkwin, pixmap, attrs->border, x, y, - width, listPtr->lineHeight, 0, TK_RELIEF_FLAT); + /* Draw left bevel */ + if (left == 0) { + Tk_3DVerticalBevel(tkwin, pixmap, selectedBg, + x, y, listPtr->selBorderWidth, listPtr->lineHeight, + 1, TK_RELIEF_RAISED); + } + /* Draw right bevel */ + if (right == 0) { + Tk_3DVerticalBevel(tkwin, pixmap, selectedBg, + x + width - listPtr->selBorderWidth, y, + listPtr->selBorderWidth, listPtr->lineHeight, + 0, TK_RELIEF_RAISED); } - if (attrs->fgColor != NULL) { - gcValues.foreground = attrs->fgColor->pixel; - gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); + /* Draw top bevel */ + if (!prevSelected) { + Tk_3DHorizontalBevel(tkwin, pixmap, selectedBg, + x-left, y, width+left+right, + listPtr->selBorderWidth, + 1, 1, 1, TK_RELIEF_RAISED); } + /* Draw bottom bevel */ + if (i + 1 == listPtr->nElements || + Tcl_FindHashEntry(listPtr->selection, + (char *)(i + 1)) == NULL ) { + Tk_3DHorizontalBevel(tkwin, pixmap, selectedBg, x-left, + y + listPtr->lineHeight - listPtr->selBorderWidth, + width+left+right, listPtr->selBorderWidth, 0, 0, 0, + TK_RELIEF_RAISED); + } + prevSelected = 1; + } else { + /* + * If there is an item attributes record for this item, draw + * the background box and set the foreground color accordingly + */ + if (entry != NULL) { + attrs = (ItemAttr *)Tcl_GetHashValue(entry); + gcValues.foreground = listPtr->fgColorPtr->pixel; + gcValues.font = Tk_FontId(listPtr->tkfont); + gcValues.graphics_exposures = False; + mask = GCForeground | GCFont | GCGraphicsExposures; + + /* + * If the item has its own background color, draw it now. + */ + + if (attrs->border != NULL) { + width = Tk_Width(tkwin) - 2*listPtr->inset; + Tk_Fill3DRectangle(tkwin, pixmap, attrs->border, x, y, + width, listPtr->lineHeight, 0, TK_RELIEF_FLAT); + } + + /* + * If the item has its own foreground, use it to override + * the value in the gcValues structure. + */ + + if ((listPtr->state & STATE_NORMAL) + && attrs->fgColor != NULL) { + gcValues.foreground = attrs->fgColor->pixel; + gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); + freeGC = 1; + } + } + prevSelected = 0; } - prevSelected = 0; } /* Draw the actual text of this item */ @@ -1928,10 +2026,68 @@ DisplayListbox(clientData) Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont, stringRep, stringLen, x, y); - /* If this is the active element, underline it. */ + /* If this is the active element, apply the activestyle to it. */ if ((i == listPtr->active) && (listPtr->flags & GOT_FOCUS)) { - Tk_UnderlineChars(listPtr->display, pixmap, gc, listPtr->tkfont, - stringRep, x, y, 0, stringLen); + if (listPtr->activeStyle == ACTIVE_STYLE_UNDERLINE) { + /* Underline the text. */ + Tk_UnderlineChars(listPtr->display, pixmap, gc, + listPtr->tkfont, stringRep, x, y, 0, stringLen); + } else if (listPtr->activeStyle == ACTIVE_STYLE_DOTBOX) { +#ifdef WIN32 + /* + * This provides for exact default look and feel on Windows. + */ + TkWinDCState state; + HDC dc; + RECT rect; + + dc = TkWinGetDrawableDC(listPtr->display, pixmap, &state); + rect.left = listPtr->inset; + rect.top = ((i - listPtr->topIndex) * listPtr->lineHeight) + + listPtr->inset; + rect.right = rect.left + width; + rect.bottom = rect.top + listPtr->lineHeight; + DrawFocusRect(dc, &rect); + TkWinReleaseDrawableDC(pixmap, dc, &state); +#else + /* + * Draw a dotted box around the text. + */ + x = listPtr->inset; + y = ((i - listPtr->topIndex) * listPtr->lineHeight) + + listPtr->inset; + width = Tk_Width(tkwin) - 2*listPtr->inset - 1; + + gcValues.line_style = LineOnOffDash; + gcValues.line_width = listPtr->selBorderWidth; + if (gcValues.line_width <= 0) { + gcValues.line_width = 1; + } + gcValues.dash_offset = 0; + gcValues.dashes = 1; + /* + * You would think the XSetDashes was necessary, but it + * appears that the default dotting for just saying we + * want dashes appears to work correctly. + static char dashList[] = { 1 }; + static int dashLen = sizeof(dashList); + XSetDashes(listPtr->display, gc, 0, dashList, dashLen); + */ + mask = GCLineWidth | GCLineStyle | GCDashList | GCDashOffset; + XChangeGC(listPtr->display, gc, mask, &gcValues); + XDrawRectangle(listPtr->display, pixmap, gc, x, y, + (unsigned) width, (unsigned) listPtr->lineHeight - 1); + if (!freeGC) { + /* Don't bother changing if it is about to be freed. */ + gcValues.line_style = LineSolid; + XChangeGC(listPtr->display, gc, GCLineStyle, &gcValues); + } +#endif + } + } + + if (freeGC) { + Tk_FreeGC(listPtr->display, gc); } } @@ -2365,7 +2521,17 @@ ListboxEventProc(clientData, eventPtr) NearestListboxElement(listPtr, eventPtr->xexpose.y + eventPtr->xexpose.height)); } else if (eventPtr->type == DestroyNotify) { - DestroyListbox((char *) clientData); + if (!(listPtr->flags & LISTBOX_DELETED)) { + listPtr->flags |= LISTBOX_DELETED; + Tcl_DeleteCommandFromToken(listPtr->interp, listPtr->widgetCmd); + if (listPtr->setGrid) { + Tk_UnsetGrid(listPtr->tkwin); + } + if (listPtr->flags & REDRAW_PENDING) { + Tcl_CancelIdleCall(DisplayListbox, clientData); + } + Tcl_EventuallyFree(clientData, DestroyListbox); + } } else if (eventPtr->type == ConfigureNotify) { int vertSpace; @@ -2607,8 +2773,12 @@ ChangeListboxOffset(listPtr, offset) /* * Make sure that the new offset is within the allowable range, and * round it off to an even multiple of xScrollUnit. + * + * Add half a scroll unit to do entry/text-like synchronization. + * [Bug #225025] */ + offset += listPtr->xScrollUnit / 2; maxOffset = listPtr->maxWidth - (Tk_Width(listPtr->tkwin) - 2*listPtr->inset - 2*listPtr->selBorderWidth) + listPtr->xScrollUnit - 1; @@ -2979,7 +3149,7 @@ EventuallyRedrawRange(listPtr, first, 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 */ if ((listPtr->flags & REDRAW_PENDING) - || (listPtr->tkwin == NULL) + || (listPtr->flags & LISTBOX_DELETED) || !Tk_IsMapped(listPtr->tkwin)) { return; } @@ -3133,8 +3303,8 @@ static char * ListboxListVarProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Information about button. */ Tcl_Interp *interp; /* Interpreter containing variable. */ - char *name1; /* Not used. */ - char *name2; /* Not used. */ + CONST char *name1; /* Not used. */ + CONST char *name2; /* Not used. */ int flags; /* Information about what happened. */ { Listbox *listPtr = (Listbox *)clientData; @@ -3281,5 +3451,3 @@ MigrateHashEntries(table, first, last, offset) return; } - - diff --git a/tk/generic/tkMacWinMenu.c b/tk/generic/tkMacWinMenu.c index 066b96eedce..a0bf8026a11 100644 --- a/tk/generic/tkMacWinMenu.c +++ b/tk/generic/tkMacWinMenu.c @@ -141,4 +141,3 @@ TkPreprocessMenu(menuPtr) menuPtr->postCommandGeneration = tsdPtr->postCommandGeneration; return PreprocessMenu(menuPtr); } - diff --git a/tk/generic/tkMain.c b/tk/generic/tkMain.c index 9f31a9860a2..3fb23290274 100644 --- a/tk/generic/tkMain.c +++ b/tk/generic/tkMain.c @@ -8,7 +8,7 @@ * for Tk applications. * * Copyright (c) 1990-1994 The Regents of the University of California. - * Copyright (c) 1994-1996 Sun Microsystems, Inc. + * Copyright (c) 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -16,9 +16,6 @@ * RCS: @(#) $Id$ */ -#ifdef _WIN32 -# include -#endif #include #include #include @@ -46,7 +43,7 @@ typedef struct ThreadSpecificData { * terminal-like device. Zero means it's * a file. */ } ThreadSpecificData; -Tcl_ThreadDataKey dataKey; +static Tcl_ThreadDataKey dataKey; /* * Declarations for various library procedures and variables (don't want @@ -58,11 +55,13 @@ Tcl_ThreadDataKey dataKey; */ #if !defined(__WIN32__) && !defined(_WIN32) +#if !defined(MAC_TCL) extern int isatty _ANSI_ARGS_((int fd)); +#else +#include +#endif extern char * strrchr _ANSI_ARGS_((CONST char *string, int c)); #endif -extern void TkpDisplayWarning _ANSI_ARGS_((char *msg, - char *title)); /* * Forward declarations for procedures defined later in this file. @@ -100,7 +99,8 @@ Tk_MainEx(argc, argv, appInitProc, interp) * to execute commands. */ Tcl_Interp *interp; { - char *args, *fileName; + char *args; + CONST char *fileName; char buf[TCL_INTEGER_SPACE]; int code; size_t length; @@ -163,18 +163,18 @@ Tk_MainEx(argc, argv, appInitProc, interp) * and "argv". */ - args = Tcl_Merge(argc-1, argv+1); + args = Tcl_Merge(argc-1, (CONST char **)argv+1); Tcl_ExternalToUtfDString(NULL, args, -1, &argString); Tcl_SetVar(interp, "argv", Tcl_DStringValue(&argString), TCL_GLOBAL_ONLY); Tcl_DStringFree(&argString); ckfree(args); sprintf(buf, "%d", argc-1); + if (fileName == NULL) { - Tcl_ExternalToUtfDString(NULL, argv[0], -1, &argString); + Tcl_ExternalToUtfDString(NULL, argv[0], -1, &argString); } else { - fileName = Tcl_ExternalToUtfDString(NULL, fileName, -1, &argString); + fileName = Tcl_ExternalToUtfDString(NULL, fileName, -1, &argString); } - Tcl_SetVar(interp, "argc", buf, TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "argv0", Tcl_DStringValue(&argString), TCL_GLOBAL_ONLY); @@ -221,7 +221,8 @@ Tk_MainEx(argc, argv, appInitProc, interp) */ if ((*appInitProc)(interp) != TCL_OK) { - TkpDisplayWarning(interp->result, "Application initialization failed"); + TkpDisplayWarning(Tcl_GetStringResult(interp), + "Application initialization failed"); } /* @@ -405,12 +406,12 @@ Prompt(interp, partial) * exists a partial command, so use * the secondary prompt. */ { - char *promptCmd; + Tcl_Obj *promptCmd; int code; Tcl_Channel outChannel, errChannel; - promptCmd = Tcl_GetVar(interp, - partial ? "tcl_prompt2" : "tcl_prompt1", TCL_GLOBAL_ONLY); + promptCmd = Tcl_GetVar2Ex(interp, + partial ? "tcl_prompt2" : "tcl_prompt1", NULL, TCL_GLOBAL_ONLY); if (promptCmd == NULL) { defaultPrompt: if (!partial) { @@ -427,7 +428,7 @@ defaultPrompt: } } } else { - code = Tcl_Eval(interp, promptCmd); + code = Tcl_EvalObjEx(interp, promptCmd, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (script that generates prompt)"); @@ -450,5 +451,3 @@ defaultPrompt: Tcl_Flush(outChannel); } } - - diff --git a/tk/generic/tkMenu.c b/tk/generic/tkMenu.c index 2e84ebb59eb..1d5218ac8dd 100644 --- a/tk/generic/tkMenu.c +++ b/tk/generic/tkMenu.c @@ -105,8 +105,19 @@ TCL_DECLARE_MUTEX(menuMutex) char *tkMenuStateStrings[] = {"active", "normal", "disabled", (char *) NULL}; -static char *menuEntryTypeStrings[] = {"cascade", "checkbutton", "command", - "radiobutton", "separator", (char *) NULL}; +static CONST char *menuEntryTypeStrings[] = { + "cascade", "checkbutton", "command", "radiobutton", "separator", + (char *) NULL +}; + +/* + * The following table defines the legal values for the -compound option. + * It is used with the "enum compound" declaration in tkMenu.h + */ + +static char *compoundStrings[] = { + "bottom", "center", "left", "none", "right", "top", (char *) NULL +}; Tk_OptionSpec tkBasicMenuEntryConfigSpecs[] = { {TK_OPTION_BORDER, "-activebackground", (char *) NULL, (char *) NULL, @@ -130,6 +141,9 @@ Tk_OptionSpec tkBasicMenuEntryConfigSpecs[] = { {TK_OPTION_STRING, "-command", (char *) NULL, (char *) NULL, DEF_MENU_ENTRY_COMMAND, Tk_Offset(TkMenuEntry, commandPtr), -1, TK_OPTION_NULL_OK}, + {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", + DEF_MENU_ENTRY_COMPOUND, -1, Tk_Offset(TkMenuEntry, compound), 0, + (ClientData) compoundStrings, 0}, {TK_OPTION_FONT, "-font", (char *) NULL, (char *) NULL, DEF_MENU_ENTRY_FONT, Tk_Offset(TkMenuEntry, fontPtr), -1, TK_OPTION_NULL_OK}, @@ -231,7 +245,7 @@ static Tk_OptionSpec *specsArray[] = { * Menu type strings for use with Tcl_GetIndexFromObj. */ -static char *menuTypeStrings[] = {"normal", "tearoff", "menubar", +static CONST char *menuTypeStrings[] = {"normal", "tearoff", "menubar", (char *) NULL}; Tk_OptionSpec tkMenuConfigSpecs[] = { @@ -299,7 +313,7 @@ Tk_OptionSpec tkMenuConfigSpecs[] = { * along with MenuWidgetObjCmd. */ -static char *menuOptions[] = { +static CONST char *menuOptions[] = { "activate", "add", "cget", "clone", "configure", "delete", "entrycget", "entryconfigure", "index", "insert", "invoke", "post", "postcascade", "type", "unpost", "yposition", (char *) NULL @@ -346,8 +360,8 @@ static void MenuCmdDeletedProc _ANSI_ARGS_(( static TkMenuEntry * MenuNewEntry _ANSI_ARGS_((TkMenu *menuPtr, int index, int type)); static char * MenuVarProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); + Tcl_Interp *interp, CONST char *name1, + CONST char *name2, int flags)); static int MenuWidgetObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); @@ -363,15 +377,15 @@ static void UnhookCascadeEntry _ANSI_ARGS_((TkMenuEntry *mePtr)); * the geometry proc to be called. */ -static TkClassProcs menuClass = { - NULL, /* createProc. */ - MenuWorldChanged /* geometryProc. */ +static Tk_ClassProcs menuClass = { + sizeof(Tk_ClassProcs), /* size */ + MenuWorldChanged /* worldChangedProc */ }; /* *-------------------------------------------------------------- * - * Tk_CreateMenuCmd -- + * TkCreateMenuCmd -- * * Called by Tk at initialization time to create the menu * command. @@ -451,7 +465,7 @@ MenuCmd(clientData, interp, objc, objv) int i, index; int toplevel; char *windowName; - static char *typeStringList[] = {"-type", (char *) NULL}; + static CONST char *typeStringList[] = {"-type", (char *) NULL}; TkMenuOptionTables *optionTablesPtr = (TkMenuOptionTables *) clientData; if (objc < 2) { @@ -523,7 +537,7 @@ MenuCmd(clientData, interp, objc, objv) TkMenuInitializeDrawingFields(menuPtr); Tk_SetClass(menuPtr->tkwin, "Menu"); - TkSetClassProcs(menuPtr->tkwin, &menuClass, (ClientData) menuPtr); + Tk_SetClassProcs(menuPtr->tkwin, &menuClass, (ClientData) menuPtr); if (Tk_InitOptions(interp, (char *) menuPtr, menuPtr->optionTablesPtr->menuOptionTable, menuPtr->tkwin) != TCL_OK) { @@ -700,8 +714,6 @@ MenuWidgetObjCmd(clientData, interp, objc, objv) switch ((enum options) option) { case MENU_ACTIVATE: { int index; - /* patch for menu selection */ - int state; if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "activate index"); @@ -1002,9 +1014,9 @@ MenuWidgetObjCmd(clientData, interp, objc, objv) if (menuPtr->entries[index]->type == TEAROFF_ENTRY) { Tcl_SetResult(interp, "tearoff", TCL_STATIC); } else { - Tcl_SetResult(interp, + Tcl_SetStringObj(Tcl_GetObjResult(interp), menuEntryTypeStrings[menuPtr->entries[index]->type], - TCL_STATIC); + -1); } break; } @@ -1072,7 +1084,7 @@ TkInvokeMenu(interp, menuPtr, index) if (mePtr->type == TEAROFF_ENTRY) { Tcl_DString ds; Tcl_DStringInit(&ds); - Tcl_DStringAppend(&ds, "tkTearOffMenu ", -1); + Tcl_DStringAppend(&ds, "tk::TearOffMenu ", -1); Tcl_DStringAppend(&ds, Tk_PathName(menuPtr->tkwin), -1); result = Tcl_Eval(interp, Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); @@ -1108,7 +1120,13 @@ TkInvokeMenu(interp, menuPtr, index) } Tcl_DecrRefCount(valuePtr); } - if ((result == TCL_OK) && (mePtr->commandPtr != NULL)) { + /* + * We check numEntries in addition to whether the menu entry + * has a command because that goes to zero if the menu gets + * deleted (e.g., during command evaluation). + */ + if ((menuPtr->numEntries != 0) && (result == TCL_OK) + && (mePtr->commandPtr != NULL)) { Tcl_Obj *commandPtr = mePtr->commandPtr; Tcl_IncrRefCount(commandPtr); @@ -1117,7 +1135,7 @@ TkInvokeMenu(interp, menuPtr, index) } Tcl_Release((ClientData) mePtr); done: - return result; + return result; } /* @@ -1265,14 +1283,14 @@ TkDestroyMenu(menuPtr) if (menuPtr->menuFlags & MENU_DELETION_PENDING) { return; } - + /* * Now destroy all non-tearoff instances of this menu if this is a * parent menu. Is this loop safe enough? Are there going to be * destroy bindings on child menus which kill the parent? If not, * we have to do a slightly more complex scheme. */ - + if (menuPtr->masterMenuPtr == menuPtr) { menuPtr->menuFlags |= MENU_DELETION_PENDING; while (menuPtr->nextInstancePtr != NULL) { @@ -1289,13 +1307,13 @@ TkDestroyMenu(menuPtr) * If any toplevel widgets have this menu as their menubar, * the geometry of the window may have to be recalculated. */ - + topLevelListPtr = menuPtr->menuRefPtr->topLevelListPtr; while (topLevelListPtr != NULL) { nextTopLevelPtr = topLevelListPtr->nextPtr; TkpSetWindowMenuBar(topLevelListPtr->tkwin, NULL); topLevelListPtr = nextTopLevelPtr; - } + } DestroyMenuInstance(menuPtr); } @@ -1518,6 +1536,11 @@ ConfigureMenu(interp, menuPtr, objc, objv) ckfree((char *) cleanupPtr->errorStructPtr); cleanupPtr->errorStructPtr = NULL; } + if (menuListPtr->errorStructPtr != NULL) { + Tk_RestoreSavedOptions(menuListPtr->errorStructPtr); + ckfree((char *) menuListPtr->errorStructPtr); + menuListPtr->errorStructPtr = NULL; + } return TCL_ERROR; } @@ -1558,18 +1581,18 @@ ConfigureMenu(interp, menuPtr, objc, objv) if ((menuListPtr->numEntries == 0) || (menuListPtr->entries[0]->type != TEAROFF_ENTRY)) { if (MenuNewEntry(menuListPtr, 0, TEAROFF_ENTRY) == NULL) { - if (menuListPtr->errorStructPtr != NULL) { - for (cleanupPtr = menuPtr->masterMenuPtr; - cleanupPtr != menuListPtr; - cleanupPtr = cleanupPtr->nextInstancePtr) { - Tk_RestoreSavedOptions(cleanupPtr->errorStructPtr); - ckfree((char *) cleanupPtr->errorStructPtr); - cleanupPtr->errorStructPtr = NULL; - } + for (cleanupPtr = menuPtr->masterMenuPtr; + cleanupPtr != menuListPtr; + cleanupPtr = cleanupPtr->nextInstancePtr) { Tk_RestoreSavedOptions(cleanupPtr->errorStructPtr); ckfree((char *) cleanupPtr->errorStructPtr); cleanupPtr->errorStructPtr = NULL; } + if (menuListPtr->errorStructPtr != NULL) { + Tk_RestoreSavedOptions(menuListPtr->errorStructPtr); + ckfree((char *) menuListPtr->errorStructPtr); + menuListPtr->errorStructPtr = NULL; + } return TCL_ERROR; } } @@ -1980,7 +2003,7 @@ ConfigureMenuCloneEntries(interp, menuPtr, index, objc, objv) oldCascadeName = Tcl_GetStringFromObj(oldCascadePtr, NULL); cascadeEntryChanged = (strcmp(oldCascadeName, newCascadeName) - == 0); + != 0); } if (oldCascadePtr != NULL) { Tcl_DecrRefCount(oldCascadePtr); @@ -2445,13 +2468,13 @@ static char * MenuVarProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Information about menu entry. */ Tcl_Interp *interp; /* Interpreter containing variable. */ - char *name1; /* First part of variable's name. */ - char *name2; /* Second part of variable's name. */ + CONST char *name1; /* First part of variable's name. */ + CONST char *name2; /* Second part of variable's name. */ int flags; /* Describes what just happened. */ { TkMenuEntry *mePtr = (TkMenuEntry *) clientData; TkMenu *menuPtr; - char *value; + CONST char *value; char *name = Tcl_GetStringFromObj(mePtr->namePtr, NULL); char *onValue; @@ -2640,7 +2663,7 @@ CloneMenu(menuPtr, newMenuNamePtr, newMenuTypePtr) } } - menuDupCommandArray[0] = Tcl_NewStringObj("tkMenuDup", -1); + menuDupCommandArray[0] = Tcl_NewStringObj("tk::MenuDup", -1); menuDupCommandArray[1] = Tcl_NewStringObj(Tk_PathName(menuPtr->tkwin), -1); menuDupCommandArray[2] = newMenuNamePtr; if (newMenuTypePtr == NULL) { @@ -2667,7 +2690,6 @@ CloneMenu(menuPtr, newMenuNamePtr, newMenuTypePtr) && (menuPtr->numEntries == menuRefPtr->menuPtr->numEntries)) { TkMenu *newMenuPtr = menuRefPtr->menuPtr; Tcl_Obj *newObjv[3]; - char *newArgv[3]; int i, numElements; /* @@ -2694,15 +2716,18 @@ CloneMenu(menuPtr, newMenuNamePtr, newMenuTypePtr) * clone structure. */ - newArgv[0] = "bindtags"; - newArgv[1] = Tk_PathName(newMenuPtr->tkwin); - if (Tk_BindtagsCmd((ClientData)newMenuPtr->tkwin, - newMenuPtr->interp, 2, newArgv) == TCL_OK) { + newObjv[0] = Tcl_NewStringObj("bindtags", -1); + newObjv[1] = Tcl_NewStringObj(Tk_PathName(newMenuPtr->tkwin), -1); + Tcl_IncrRefCount(newObjv[0]); + Tcl_IncrRefCount(newObjv[1]); + if (Tk_BindtagsObjCmd((ClientData)newMenuPtr->tkwin, + newMenuPtr->interp, 2, newObjv) == TCL_OK) { char *windowName; Tcl_Obj *bindingsPtr = Tcl_DuplicateObj(Tcl_GetObjResult(newMenuPtr->interp)); Tcl_Obj *elementPtr; + Tcl_IncrRefCount(bindingsPtr); Tcl_ListObjLength(newMenuPtr->interp, bindingsPtr, &numElements); for (i = 0; i < numElements; i++) { Tcl_ListObjIndex(newMenuPtr->interp, bindingsPtr, i, @@ -2712,17 +2737,22 @@ CloneMenu(menuPtr, newMenuNamePtr, newMenuTypePtr) == 0) { Tcl_Obj *newElementPtr = Tcl_NewStringObj( Tk_PathName(newMenuPtr->masterMenuPtr->tkwin), -1); - Tcl_IncrRefCount(newElementPtr); + /* + * The newElementPtr will have its refCount incremented + * here, so we don't need to worry about it any more. + */ Tcl_ListObjReplace(menuPtr->interp, bindingsPtr, i + 1, 0, 1, &newElementPtr); - newArgv[2] = Tcl_GetStringFromObj(bindingsPtr, NULL); - Tk_BindtagsCmd((ClientData)newMenuPtr->tkwin, - menuPtr->interp, 3, newArgv); + newObjv[2] = bindingsPtr; + Tk_BindtagsObjCmd((ClientData)newMenuPtr->tkwin, + menuPtr->interp, 3, newObjv); break; } } Tcl_DecrRefCount(bindingsPtr); } + Tcl_DecrRefCount(newObjv[0]); + Tcl_DecrRefCount(newObjv[1]); Tcl_ResetResult(menuPtr->interp); /* @@ -3458,5 +3488,3 @@ TkMenuInit() tsdPtr->menusInitialized = 1; } } - - diff --git a/tk/generic/tkMenu.h b/tk/generic/tkMenu.h index d1b8e39dd3a..93dfe1e00a7 100644 --- a/tk/generic/tkMenu.h +++ b/tk/generic/tkMenu.h @@ -38,6 +38,15 @@ typedef struct TkMenuPlatformData_ *TkMenuPlatformData; typedef struct TkMenuPlatformEntryData_ *TkMenuPlatformEntryData; +/* + * Legal values for the "compound" field of TkMenuEntry and TkMenuButton records. + */ + +enum compound { + COMPOUND_BOTTOM, COMPOUND_CENTER, COMPOUND_LEFT, COMPOUND_NONE, + COMPOUND_RIGHT, COMPOUND_TOP +}; + /* * One of the following data structures is kept for each entry of each * menu managed by this file: @@ -115,6 +124,9 @@ typedef struct TkMenuEntry { * entry. */ int labelWidth; /* Number of pixels to allow for displaying * labels in menu entries. */ + int compound; /* Value of -compound option; specifies whether + * the entry should show both an image and + * text, and, if so, how. */ /* * Information used to implement this entry's action: @@ -570,4 +582,3 @@ EXTERN void TkpSetWindowMenuBar _ANSI_ARGS_((Tk_Window tkwin, #endif /* _TKMENU */ - diff --git a/tk/generic/tkMenuDraw.c b/tk/generic/tkMenuDraw.c index 123795c4801..20b99095597 100644 --- a/tk/generic/tkMenuDraw.c +++ b/tk/generic/tkMenuDraw.c @@ -191,7 +191,6 @@ TkMenuConfigureDrawOptions(menuPtr) Tk_3DBorder border, activeBorder; Tk_Font tkfont; XColor *fg, *activeFg, *indicatorFg; - XColor *foreground, *background; /* * A few options need special processing, such as setting the @@ -215,19 +214,15 @@ TkMenuConfigureDrawOptions(menuPtr) menuPtr->textGC = newGC; gcValues.font = Tk_FontId(tkfont); - background = Tk_3DBorderColor(border); - gcValues.background = background->pixel; + gcValues.background = Tk_3DBorderColor(border)->pixel; if (menuPtr->disabledFgPtr != NULL) { XColor *disabledFg; disabledFg = Tk_GetColorFromObj(menuPtr->tkwin, menuPtr->disabledFgPtr); - foreground = disabledFg; - gcValues.foreground = foreground->pixel; + gcValues.foreground = disabledFg->pixel; mask = GCForeground|GCBackground|GCFont; } else { - foreground = background; - background = NULL; gcValues.foreground = gcValues.background; mask = GCForeground; if (menuPtr->gray == None) { @@ -335,18 +330,16 @@ TkMenuConfigureEntryDrawOptions(mePtr, index) || (mePtr->activeBorderPtr != NULL) || (mePtr->activeFgPtr != NULL) || (mePtr->indicatorFgPtr != NULL)) { - XColor *fg, *bg, *indicatorFg, *activeFg; + XColor *fg, *indicatorFg, *activeFg; Tk_3DBorder border, activeBorder; fg = Tk_GetColorFromObj(menuPtr->tkwin, (mePtr->fgPtr != NULL) ? mePtr->fgPtr : menuPtr->fgPtr); - gcValues.foreground = fg->pixel; border = Tk_Get3DBorderFromObj(menuPtr->tkwin, (mePtr->borderPtr != NULL) ? mePtr->borderPtr : menuPtr->borderPtr); - bg = Tk_3DBorderColor(border); - gcValues.background = bg->pixel; + gcValues.background = Tk_3DBorderColor(border)->pixel; gcValues.font = Tk_FontId(tkfont); @@ -360,6 +353,7 @@ TkMenuConfigureEntryDrawOptions(mePtr, index) newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont|GCGraphicsExposures, &gcValues); + indicatorFg = Tk_GetColorFromObj(menuPtr->tkwin, (mePtr->indicatorFgPtr != NULL) ? mePtr->indicatorFgPtr : menuPtr->indicatorFgPtr); @@ -367,13 +361,15 @@ TkMenuConfigureEntryDrawOptions(mePtr, index) newIndicatorGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCGraphicsExposures, &gcValues); + if ((menuPtr->disabledFgPtr != NULL) || (mePtr->image != NULL)) { - fg = Tk_GetColorFromObj(menuPtr->tkwin, + XColor *disabledFg; + + disabledFg = Tk_GetColorFromObj(menuPtr->tkwin, menuPtr->disabledFgPtr); - gcValues.foreground = fg->pixel; + gcValues.foreground = disabledFg->pixel; mask = GCForeground|GCBackground|GCFont|GCGraphicsExposures; } else { - fg = bg; gcValues.foreground = gcValues.background; gcValues.fill_style = FillStippled; gcValues.stipple = menuPtr->gray; @@ -389,8 +385,7 @@ TkMenuConfigureEntryDrawOptions(mePtr, index) : menuPtr->activeBorderPtr); gcValues.foreground = activeFg->pixel; - bg = Tk_3DBorderColor(activeBorder); - gcValues.background = bg->pixel; + gcValues.background = Tk_3DBorderColor(activeBorder)->pixel; newActiveGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont|GCGraphicsExposures, &gcValues); @@ -1054,4 +1049,3 @@ AdjustMenuCoords(menuPtr, mePtr, xPtr, yPtr, string) } sprintf(string, "%d %d", *xPtr, *yPtr); } - diff --git a/tk/generic/tkMenubutton.c b/tk/generic/tkMenubutton.c index 059499a7d24..eb222428431 100644 --- a/tk/generic/tkMenubutton.c +++ b/tk/generic/tkMenubutton.c @@ -36,6 +36,15 @@ static char *stateStrings[] = { "active", "disabled", "normal", (char *) NULL }; +/* + * The following table defines the legal values for the -compound option. + * It is used with the "enum compound" declaration in tkMenuButton.h + */ + +static char *compoundStrings[] = { + "bottom", "center", "left", "none", "right", "top", (char *) NULL +}; + /* * Information used for parsing configuration specs: */ @@ -113,6 +122,9 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_MENUBUTTON_RELIEF, -1, Tk_Offset(TkMenuButton, relief), 0, 0, 0}, + {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", + DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkMenuButton, compound), 0, + (ClientData) compoundStrings, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_MENUBUTTON_STATE, -1, Tk_Offset(TkMenuButton, state), 0, (ClientData) stateStrings, 0}, @@ -143,7 +155,7 @@ static Tk_OptionSpec optionSpecs[] = { * to dispatch the scale widget command. */ -static char *commandNames[] = { +static CONST char *commandNames[] = { "cget", "configure", (char *) NULL }; @@ -164,7 +176,7 @@ static void MenuButtonImageProc _ANSI_ARGS_((ClientData clientData, int imgHeight)); static char * MenuButtonTextVarProc _ANSI_ARGS_(( ClientData clientData, Tcl_Interp *interp, - char *name1, char *name2, int flags)); + CONST char *name1, CONST char *name2, int flags)); static int MenuButtonWidgetObjCmd _ANSI_ARGS_(( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); @@ -193,8 +205,7 @@ static void DestroyMenuButton _ANSI_ARGS_((char *memPtr)); int Tk_MenubuttonObjCmd(clientData, interp, objc, objv) - ClientData clientData; /* Either NULL or pointer to - * option table. */ + ClientData clientData; /* NULL. */ Tcl_Interp *interp; /* Current interpreter. */ int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ @@ -203,25 +214,6 @@ Tk_MenubuttonObjCmd(clientData, interp, objc, objv) Tk_OptionTable optionTable; Tk_Window tkwin; - optionTable = (Tk_OptionTable) clientData; - if (optionTable == NULL) { - Tcl_CmdInfo info; - char *name; - - /* - * We haven't created the option table for this widget class - * yet. Do it now and save the table as the clientData for - * the command, so we'll have access to it in future - * invocations of the command. - */ - - optionTable = Tk_CreateOptionTable(interp, optionSpecs); - name = Tcl_GetString(objv[0]); - Tcl_GetCommandInfo(interp, name, &info); - info.objClientData = (ClientData) optionTable; - Tcl_SetCommandInfo(interp, name, &info); - } - if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); return TCL_ERROR; @@ -231,16 +223,23 @@ Tk_MenubuttonObjCmd(clientData, interp, objc, objv) * Create the new window. */ - tkwin = Tk_CreateWindowFromPath(interp, - Tk_MainWindow(interp), Tcl_GetString(objv[1]), (char *) NULL); + tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), + Tcl_GetString(objv[1]), (char *) NULL); if (tkwin == NULL) { return TCL_ERROR; } + /* + * Create the option table for this widget class. If it has already + * been created, the cached pointer will be returned. + */ + + optionTable = Tk_CreateOptionTable(interp, optionSpecs); + Tk_SetClass(tkwin, "Menubutton"); mbPtr = TkpCreateMenuButton(tkwin); - TkSetClassProcs(tkwin, &tkpMenubuttonClass, (ClientData) mbPtr); + Tk_SetClassProcs(tkwin, &tkpMenubuttonClass, (ClientData) mbPtr); /* * Initialize the data structure for the button. @@ -301,8 +300,7 @@ Tk_MenubuttonObjCmd(clientData, interp, objc, objv) ExposureMask|StructureNotifyMask|FocusChangeMask, MenuButtonEventProc, (ClientData) mbPtr); - if (Tk_InitOptions(interp, (char *) mbPtr, optionTable, tkwin) - != TCL_OK) { + if (Tk_InitOptions(interp, (char *) mbPtr, optionTable, tkwin) != TCL_OK) { Tk_DestroyWindow(mbPtr->tkwin); return TCL_ERROR; } @@ -312,8 +310,7 @@ Tk_MenubuttonObjCmd(clientData, interp, objc, objv) return TCL_ERROR; } - Tcl_SetStringObj(Tcl_GetObjResult(interp), Tk_PathName(mbPtr->tkwin), - -1); + Tcl_SetStringObj(Tcl_GetObjResult(interp), Tk_PathName(mbPtr->tkwin), -1); return TCL_OK; } @@ -630,7 +627,7 @@ ConfigureMenuButton(interp, mbPtr, objc, objv) * current value. */ - char *value; + CONST char *value; value = Tcl_GetVar(interp, mbPtr->textVarName, TCL_GLOBAL_ONLY); if (value == NULL) { @@ -684,7 +681,6 @@ TkMenuButtonWorldChanged(instanceData) GC gc; unsigned long mask; TkMenuButton *mbPtr; - XColor *foreground, *background; mbPtr = (TkMenuButton *) instanceData; @@ -717,15 +713,11 @@ TkMenuButtonWorldChanged(instanceData) mbPtr->activeTextGC = gc; gcValues.font = Tk_FontId(mbPtr->tkfont); - background = Tk_3DBorderColor(mbPtr->normalBorder); - gcValues.background = background->pixel; + gcValues.background = Tk_3DBorderColor(mbPtr->normalBorder)->pixel; if ((mbPtr->disabledFg != NULL) && (mbPtr->imageString == NULL)) { - foreground = mbPtr->disabledFg; - gcValues.foreground = foreground->pixel; + gcValues.foreground = mbPtr->disabledFg->pixel; mask = GCForeground | GCBackground | GCFont; } else { - foreground = background; - background = NULL; gcValues.foreground = gcValues.background; mask = GCForeground; if (mbPtr->gray == None) { @@ -875,12 +867,12 @@ static char * MenuButtonTextVarProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Information about button. */ Tcl_Interp *interp; /* Interpreter containing variable. */ - char *name1; /* Name of variable. */ - char *name2; /* Second part of variable name. */ + CONST char *name1; /* Name of variable. */ + CONST char *name2; /* Second part of variable name. */ int flags; /* Information about what happened. */ { register TkMenuButton *mbPtr = (TkMenuButton *) clientData; - char *value; + CONST char *value; /* * If the variable is unset, then immediately recreate it unless @@ -954,4 +946,3 @@ MenuButtonImageProc(clientData, x, y, width, height, imgWidth, imgHeight) } } } - diff --git a/tk/generic/tkMenubutton.h b/tk/generic/tkMenubutton.h index 2bca6431e73..b3e4b2c34f0 100644 --- a/tk/generic/tkMenubutton.h +++ b/tk/generic/tkMenubutton.h @@ -19,6 +19,10 @@ #include "tkInt.h" #endif +#ifndef _TKMENU +#include "tkMenu.h" +#endif + #ifdef BUILD_tk # undef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLEXPORT @@ -162,6 +166,10 @@ typedef struct { * Miscellaneous information: */ + int compound; /* Value of -compound option; specifies whether + * the menubutton should show both an image and + * text, and, if so, how. */ + enum direction direction; /* Direction for where to pop the menu. * Valid directions are "above", "below", * "left", "right", and "flush". "flush" @@ -211,7 +219,7 @@ typedef struct { * Declaration of variables shared between the files in the button module. */ -extern TkClassProcs tkpMenubuttonClass; +extern Tk_ClassProcs tkpMenubuttonClass; /* * Declaration of procedures used in the implementation of the button @@ -232,4 +240,3 @@ EXTERN void TkMenuButtonWorldChanged _ANSI_ARGS_(( # define TCL_STORAGE_CLASS DLLIMPORT #endif /* _TKMENUBUTTON */ - diff --git a/tk/generic/tkMessage.c b/tk/generic/tkMessage.c index eabffe0197c..1bcb4a87af9 100644 --- a/tk/generic/tkMessage.c +++ b/tk/generic/tkMessage.c @@ -7,6 +7,7 @@ * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * Copyright (c) 1998-2000 by Ajuba Solutions. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -28,6 +29,8 @@ typedef struct { * means that the window has been destroyed * but the data structures haven't yet been * cleaned up.*/ + Tk_OptionTable optionTable; /* Table that defines options available for + * this widget. */ Display *display; /* Display containing widget. Used, among * other things, so that resources can be * freed even after tkwin has gone away. */ @@ -58,6 +61,7 @@ typedef struct { XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ Tk_Font tkfont; /* Information about text font, or NULL. */ XColor *fgColorPtr; /* Foreground color in normal mode. */ + Tcl_Obj *padXPtr, *padYPtr; /* Tcl_Obj rep's of padX, padY values. */ int padX, padY; /* User-requested extra space around text. */ int width; /* User-requested width, in pixels. 0 means * compute width using aspect ratio below. */ @@ -95,68 +99,72 @@ typedef struct { * this window. * GOT_FOCUS: Non-zero means this button currently * has the input focus. + * MESSAGE_DELETED: The message has been effectively deleted. */ #define REDRAW_PENDING 1 #define GOT_FOCUS 4 +#define MESSAGE_DELETED 8 /* * Information used for argv parsing. */ -static Tk_ConfigSpec configSpecs[] = { - {TK_CONFIG_ANCHOR, "-anchor", "anchor", "Anchor", - DEF_MESSAGE_ANCHOR, Tk_Offset(Message, anchor), 0}, - {TK_CONFIG_INT, "-aspect", "aspect", "Aspect", - DEF_MESSAGE_ASPECT, Tk_Offset(Message, aspect), 0}, - {TK_CONFIG_BORDER, "-background", "background", "Background", - DEF_MESSAGE_BG_COLOR, Tk_Offset(Message, border), - TK_CONFIG_COLOR_ONLY}, - {TK_CONFIG_BORDER, "-background", "background", "Background", - DEF_MESSAGE_BG_MONO, Tk_Offset(Message, border), - TK_CONFIG_MONO_ONLY}, - {TK_CONFIG_SYNONYM, "-bd", "borderWidth", (char *) NULL, - (char *) NULL, 0, 0}, - {TK_CONFIG_SYNONYM, "-bg", "background", (char *) NULL, - (char *) NULL, 0, 0}, - {TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_MESSAGE_BORDER_WIDTH, Tk_Offset(Message, borderWidth), 0}, - {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor", - DEF_MESSAGE_CURSOR, Tk_Offset(Message, cursor), TK_CONFIG_NULL_OK}, - {TK_CONFIG_SYNONYM, "-fg", "foreground", (char *) NULL, - (char *) NULL, 0, 0}, - {TK_CONFIG_FONT, "-font", "font", "Font", - DEF_MESSAGE_FONT, Tk_Offset(Message, tkfont), 0}, - {TK_CONFIG_COLOR, "-foreground", "foreground", "Foreground", - DEF_MESSAGE_FG, Tk_Offset(Message, fgColorPtr), 0}, - {TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground", - "HighlightBackground", DEF_MESSAGE_HIGHLIGHT_BG, - Tk_Offset(Message, highlightBgColorPtr), 0}, - {TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", - DEF_MESSAGE_HIGHLIGHT, Tk_Offset(Message, highlightColorPtr), 0}, - {TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness", - "HighlightThickness", - DEF_MESSAGE_HIGHLIGHT_WIDTH, Tk_Offset(Message, highlightWidth), 0}, - {TK_CONFIG_JUSTIFY, "-justify", "justify", "Justify", - DEF_MESSAGE_JUSTIFY, Tk_Offset(Message, justify), 0}, - {TK_CONFIG_PIXELS, "-padx", "padX", "Pad", - DEF_MESSAGE_PADX, Tk_Offset(Message, padX), 0}, - {TK_CONFIG_PIXELS, "-pady", "padY", "Pad", - DEF_MESSAGE_PADY, Tk_Offset(Message, padY), 0}, - {TK_CONFIG_RELIEF, "-relief", "relief", "Relief", - DEF_MESSAGE_RELIEF, Tk_Offset(Message, relief), 0}, - {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus", - DEF_MESSAGE_TAKE_FOCUS, Tk_Offset(Message, takeFocus), - TK_CONFIG_NULL_OK}, - {TK_CONFIG_STRING, "-text", "text", "Text", - DEF_MESSAGE_TEXT, Tk_Offset(Message, string), 0}, - {TK_CONFIG_STRING, "-textvariable", "textVariable", "Variable", - DEF_MESSAGE_TEXT_VARIABLE, Tk_Offset(Message, textVarName), - TK_CONFIG_NULL_OK}, - {TK_CONFIG_PIXELS, "-width", "width", "Width", - DEF_MESSAGE_WIDTH, Tk_Offset(Message, width), 0}, - {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL, - (char *) NULL, 0, 0} +static Tk_OptionSpec optionSpecs[] = { + {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_MESSAGE_ANCHOR, + -1, Tk_Offset(Message, anchor), 0, 0, 0}, + {TK_OPTION_INT, "-aspect", "aspect", "Aspect", DEF_MESSAGE_ASPECT, + -1, Tk_Offset(Message, aspect), 0, 0, 0}, + {TK_OPTION_BORDER, "-background", "background", "Background", + DEF_MESSAGE_BG_COLOR, -1, Tk_Offset(Message, border), 0, + (ClientData) DEF_MESSAGE_BG_MONO, 0}, + {TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, (char *) NULL, + 0, -1, 0, (ClientData) "-borderwidth", 0}, + {TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, (char *) NULL, + 0, -1, 0, (ClientData) "-background", 0}, + {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", + DEF_MESSAGE_BORDER_WIDTH, -1, + Tk_Offset(Message, borderWidth), 0, 0, 0}, + {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", + DEF_MESSAGE_CURSOR, -1, Tk_Offset(Message, cursor), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_SYNONYM, "-fg", (char *) NULL, (char *) NULL, (char *) NULL, + 0, -1, 0, (ClientData) "-foreground", 0}, + {TK_OPTION_FONT, "-font", "font", "Font", + DEF_MESSAGE_FONT, -1, Tk_Offset(Message, tkfont), 0, 0, 0}, + {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", + DEF_MESSAGE_FG, -1, Tk_Offset(Message, fgColorPtr), 0, 0, 0}, + {TK_OPTION_COLOR, "-highlightbackground", "highlightBackground", + "HighlightBackground", DEF_MESSAGE_HIGHLIGHT_BG, -1, + Tk_Offset(Message, highlightBgColorPtr), 0, 0}, + {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", + DEF_MESSAGE_HIGHLIGHT, -1, Tk_Offset(Message, highlightColorPtr), + 0, 0, 0}, + {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", + "HighlightThickness", DEF_MESSAGE_HIGHLIGHT_WIDTH, -1, + Tk_Offset(Message, highlightWidth), 0, 0, 0}, + {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", + DEF_MESSAGE_JUSTIFY, -1, Tk_Offset(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}, + {TK_OPTION_PIXELS, "-pady", "padY", "Pad", + DEF_MESSAGE_PADY, Tk_Offset(Message, padYPtr), + Tk_Offset(Message, padY), 0, 0, 0}, + {TK_OPTION_RELIEF, "-relief", "relief", "Relief", + DEF_MESSAGE_RELIEF, -1, Tk_Offset(Message, relief), 0, 0, 0}, + {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", + DEF_MESSAGE_TAKE_FOCUS, -1, Tk_Offset(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}, + {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", + DEF_MESSAGE_TEXT_VARIABLE, -1, Tk_Offset(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}, + {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL, + (char *) NULL, 0, 0, 0, 0} }; /* @@ -168,15 +176,16 @@ static void MessageCmdDeletedProc _ANSI_ARGS_(( static void MessageEventProc _ANSI_ARGS_((ClientData clientData, XEvent *eventPtr)); static char * MessageTextVarProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); -static int MessageWidgetCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, CONST char *name1, + CONST char *name2, int flags)); +static int MessageWidgetObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[])); static void MessageWorldChanged _ANSI_ARGS_(( ClientData instanceData)); static void ComputeMessageGeometry _ANSI_ARGS_((Message *msgPtr)); static int ConfigureMessage _ANSI_ARGS_((Tcl_Interp *interp, - Message *msgPtr, int argc, char **argv, + Message *msgPtr, int objc, Tcl_Obj *CONST objv[], int flags)); static void DestroyMessage _ANSI_ARGS_((char *memPtr)); static void DisplayMessage _ANSI_ARGS_((ClientData clientData)); @@ -186,17 +195,16 @@ static void DisplayMessage _ANSI_ARGS_((ClientData clientData)); * that can be invoked from generic window code. */ -static TkClassProcs messageClass = { - NULL, /* createProc. */ - MessageWorldChanged, /* geometryProc. */ - NULL /* modalProc. */ +static Tk_ClassProcs messageClass = { + sizeof(Tk_ClassProcs), /* size */ + MessageWorldChanged, /* worldChangedProc */ }; /* *-------------------------------------------------------------- * - * Tk_MessageCmd -- + * Tk_MessageObjCmd -- * * This procedure is invoked to process the "message" Tcl * command. See the user documentation for details on what @@ -212,80 +220,77 @@ static TkClassProcs messageClass = { */ int -Tk_MessageCmd(clientData, interp, argc, argv) - ClientData clientData; /* Main window associated with - * interpreter. */ +Tk_MessageObjCmd(clientData, interp, objc, objv) + ClientData clientData; /* NULL. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument strings. */ { register Message *msgPtr; - Tk_Window new; - Tk_Window tkwin = (Tk_Window) clientData; + Tk_OptionTable optionTable; + Tk_Window tkwin; - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " pathName ?options?\"", (char *) NULL); + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); return TCL_ERROR; } - new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], (char *) NULL); - if (new == NULL) { + tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), + Tcl_GetString(objv[1]), (char *) NULL); + if (tkwin == NULL) { return TCL_ERROR; } + /* + * Create the option table for this widget class. If it has already + * been created, the cached pointer will be returned. + */ + + optionTable = Tk_CreateOptionTable(interp, optionSpecs); + msgPtr = (Message *) ckalloc(sizeof(Message)); - msgPtr->tkwin = new; - msgPtr->display = Tk_Display(new); - msgPtr->interp = interp; - msgPtr->widgetCmd = Tcl_CreateCommand(interp, Tk_PathName(msgPtr->tkwin), - MessageWidgetCmd, (ClientData) msgPtr, MessageCmdDeletedProc); - msgPtr->textLayout = NULL; - msgPtr->string = NULL; - msgPtr->numChars = 0; - msgPtr->textVarName = NULL; - msgPtr->border = NULL; - msgPtr->borderWidth = 0; - msgPtr->relief = TK_RELIEF_FLAT; - msgPtr->highlightWidth = 0; - msgPtr->highlightBgColorPtr = NULL; - msgPtr->highlightColorPtr = NULL; - msgPtr->tkfont = NULL; - msgPtr->fgColorPtr = NULL; - msgPtr->textGC = None; - msgPtr->padX = 0; - msgPtr->padY = 0; - msgPtr->anchor = TK_ANCHOR_CENTER; - msgPtr->width = 0; - msgPtr->aspect = 150; - msgPtr->msgWidth = 0; - msgPtr->msgHeight = 0; - msgPtr->justify = TK_JUSTIFY_LEFT; - msgPtr->cursor = None; - msgPtr->takeFocus = NULL; - msgPtr->flags = 0; + memset(msgPtr, 0, (size_t) sizeof(Message)); + + /* + * Set values for those fields that don't take a 0 or NULL value. + */ + msgPtr->tkwin = tkwin; + msgPtr->display = Tk_Display(tkwin); + msgPtr->interp = interp; + msgPtr->widgetCmd = Tcl_CreateObjCommand(interp, + Tk_PathName(msgPtr->tkwin), MessageWidgetObjCmd, + (ClientData) msgPtr, MessageCmdDeletedProc); + msgPtr->optionTable = optionTable; + msgPtr->relief = TK_RELIEF_FLAT; + msgPtr->textGC = None; + msgPtr->anchor = TK_ANCHOR_CENTER; + msgPtr->aspect = 150; + msgPtr->justify = TK_JUSTIFY_LEFT; + msgPtr->cursor = None; Tk_SetClass(msgPtr->tkwin, "Message"); - TkSetClassProcs(msgPtr->tkwin, &messageClass, (ClientData) msgPtr); + Tk_SetClassProcs(msgPtr->tkwin, &messageClass, (ClientData) msgPtr); Tk_CreateEventHandler(msgPtr->tkwin, ExposureMask|StructureNotifyMask|FocusChangeMask, MessageEventProc, (ClientData) msgPtr); - if (ConfigureMessage(interp, msgPtr, argc-2, argv+2, 0) != TCL_OK) { - goto error; + if (Tk_InitOptions(interp, (char *)msgPtr, optionTable, tkwin) != TCL_OK) { + Tk_DestroyWindow(msgPtr->tkwin); + return TCL_ERROR; + } + + if (ConfigureMessage(interp, msgPtr, objc-2, objv+2, 0) != TCL_OK) { + Tk_DestroyWindow(msgPtr->tkwin); + return TCL_ERROR; } Tcl_SetResult(interp, Tk_PathName(msgPtr->tkwin), TCL_STATIC); return TCL_OK; - - error: - Tk_DestroyWindow(msgPtr->tkwin); - return TCL_ERROR; } /* *-------------------------------------------------------------- * - * MessageWidgetCmd -- + * MessageWidgetObjCmd -- * * This procedure is invoked to process the Tcl command * that corresponds to a widget managed by this module. @@ -301,50 +306,68 @@ Tk_MessageCmd(clientData, interp, argc, argv) */ static int -MessageWidgetCmd(clientData, interp, argc, argv) +MessageWidgetObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Information about message widget. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument strings. */ { register Message *msgPtr = (Message *) clientData; - size_t length; - int c; + static CONST char *optionStrings[] = { "cget", "configure", (char *) NULL }; + enum options { MESSAGE_CGET, MESSAGE_CONFIGURE }; + int index; + int result = TCL_OK; + Tcl_Obj *objPtr; + + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); + return TCL_ERROR; + } - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " option ?arg arg ...?\"", (char *) NULL); + if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, + &index) != TCL_OK) { return TCL_ERROR; } - c = argv[1][0]; - length = strlen(argv[1]); - if ((c == 'c') && (strncmp(argv[1], "cget", length) == 0) - && (length >= 2)) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " cget option\"", - (char *) NULL); - return TCL_ERROR; + + Tcl_Preserve((ClientData) msgPtr); + + switch ((enum options) index) { + case MESSAGE_CGET: { + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "option"); + return TCL_ERROR; + } + objPtr = Tk_GetOptionValue(interp, (char *) msgPtr, + msgPtr->optionTable, objv[2], msgPtr->tkwin); + if (objPtr == NULL) { + result = TCL_ERROR; + } else { + Tcl_SetObjResult(interp, objPtr); + result = TCL_OK; + } + break; } - return Tk_ConfigureValue(interp, msgPtr->tkwin, configSpecs, - (char *) msgPtr, argv[2], 0); - } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0) - && (length >= 2)) { - if (argc == 2) { - return Tk_ConfigureInfo(interp, msgPtr->tkwin, configSpecs, - (char *) msgPtr, (char *) NULL, 0); - } else if (argc == 3) { - return Tk_ConfigureInfo(interp, msgPtr->tkwin, configSpecs, - (char *) msgPtr, argv[2], 0); - } else { - return ConfigureMessage(interp, msgPtr, argc-2, argv+2, - TK_CONFIG_ARGV_ONLY); + case MESSAGE_CONFIGURE: { + if (objc <= 3) { + objPtr = Tk_GetOptionInfo(interp, (char *) msgPtr, + msgPtr->optionTable, + (objc == 3) ? objv[2] : (Tcl_Obj *) NULL, + msgPtr->tkwin); + if (objPtr == NULL) { + result = TCL_ERROR; + } else { + Tcl_SetObjResult(interp, objPtr); + result = TCL_OK; + } + } else { + result = ConfigureMessage(interp, msgPtr, objc-2, objv+2, 0); + } + break; } - } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": must be cget or configure", (char *) NULL); - return TCL_ERROR; } + + Tcl_Release((ClientData) msgPtr); + return result; } /* @@ -371,22 +394,32 @@ DestroyMessage(memPtr) { register Message *msgPtr = (Message *) memPtr; + msgPtr->flags |= MESSAGE_DELETED; + + Tcl_DeleteCommandFromToken(msgPtr->interp, msgPtr->widgetCmd); + if (msgPtr->flags & REDRAW_PENDING) { + Tcl_CancelIdleCall(DisplayMessage, (ClientData) msgPtr); + } + /* * Free up all the stuff that requires special handling, then - * let Tk_FreeOptions handle all the standard option-related + * let Tk_FreeConfigOptions handle all the standard option-related * stuff. */ - Tk_FreeTextLayout(msgPtr->textLayout); + if (msgPtr->textGC != None) { + Tk_FreeGC(msgPtr->display, msgPtr->textGC); + } + if (msgPtr->textLayout != NULL) { + Tk_FreeTextLayout(msgPtr->textLayout); + } if (msgPtr->textVarName != NULL) { Tcl_UntraceVar(msgPtr->interp, msgPtr->textVarName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MessageTextVarProc, (ClientData) msgPtr); } - if (msgPtr->textGC != None) { - Tk_FreeGC(msgPtr->display, msgPtr->textGC); - } - Tk_FreeOptions(configSpecs, (char *) msgPtr, msgPtr->display, 0); + Tk_FreeConfigOptions((char *) msgPtr, msgPtr->optionTable, msgPtr->tkwin); + msgPtr->tkwin = NULL; ckfree((char *) msgPtr); } @@ -412,14 +445,16 @@ DestroyMessage(memPtr) */ static int -ConfigureMessage(interp, msgPtr, argc, argv, flags) +ConfigureMessage(interp, msgPtr, objc, objv, flags) Tcl_Interp *interp; /* Used for error reporting. */ register Message *msgPtr; /* Information about widget; may or may * not already have values for some fields. */ - int argc; /* Number of valid entries in argv. */ - char **argv; /* Arguments. */ + int objc; /* Number of valid entries in argv. */ + Tcl_Obj *CONST objv[]; /* Arguments. */ int flags; /* Flags to pass to Tk_ConfigureWidget. */ { + Tk_SavedOptions savedOptions; + /* * Eliminate any existing trace on a variable monitored by the message. */ @@ -430,10 +465,12 @@ ConfigureMessage(interp, msgPtr, argc, argv, flags) MessageTextVarProc, (ClientData) msgPtr); } - if (Tk_ConfigureWidget(interp, msgPtr->tkwin, configSpecs, - argc, argv, (char *) msgPtr, flags) != TCL_OK) { + if (Tk_SetOptions(interp, (char *) msgPtr, msgPtr->optionTable, objc, objv, + msgPtr->tkwin, &savedOptions, (int *)NULL) != TCL_OK) { + Tk_RestoreSavedOptions(&savedOptions); return TCL_ERROR; } + /* * If the message is to display the value of a variable, then set up @@ -442,7 +479,7 @@ ConfigureMessage(interp, msgPtr, argc, argv, flags) */ if (msgPtr->textVarName != NULL) { - char *value; + CONST char *value; value = Tcl_GetVar(interp, msgPtr->textVarName, TCL_GLOBAL_ONLY); if (value == NULL) { @@ -471,6 +508,7 @@ ConfigureMessage(interp, msgPtr, argc, argv, flags) msgPtr->highlightWidth = 0; } + Tk_FreeSavedOptions(&savedOptions); MessageWorldChanged((ClientData) msgPtr); return TCL_OK; } @@ -725,14 +763,7 @@ MessageEventProc(clientData, eventPtr) || (eventPtr->type == ConfigureNotify)) { goto redraw; } else if (eventPtr->type == DestroyNotify) { - if (msgPtr->tkwin != NULL) { - msgPtr->tkwin = NULL; - Tcl_DeleteCommandFromToken(msgPtr->interp, msgPtr->widgetCmd); - } - if (msgPtr->flags & REDRAW_PENDING) { - Tcl_CancelIdleCall(DisplayMessage, (ClientData) msgPtr); - } - Tcl_EventuallyFree((ClientData) msgPtr, DestroyMessage); + DestroyMessage((char *) clientData); } else if (eventPtr->type == FocusIn) { if (eventPtr->xfocus.detail != NotifyInferior) { msgPtr->flags |= GOT_FOCUS; @@ -780,7 +811,6 @@ MessageCmdDeletedProc(clientData) ClientData clientData; /* Pointer to widget record for widget. */ { Message *msgPtr = (Message *) clientData; - Tk_Window tkwin = msgPtr->tkwin; /* * This procedure could be invoked either because the window was @@ -789,9 +819,8 @@ MessageCmdDeletedProc(clientData) * destroys the widget. */ - if (tkwin != NULL) { - msgPtr->tkwin = NULL; - Tk_DestroyWindow(tkwin); + if (!(msgPtr->flags & MESSAGE_DELETED)) { + Tk_DestroyWindow(msgPtr->tkwin); } } @@ -818,12 +847,12 @@ static char * MessageTextVarProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Information about message. */ Tcl_Interp *interp; /* Interpreter containing variable. */ - char *name1; /* Name of variable. */ - char *name2; /* Second part of variable name. */ + CONST char *name1; /* Name of variable. */ + CONST char *name2; /* Second part of variable name. */ int flags; /* Information about what happened. */ { register Message *msgPtr = (Message *) clientData; - char *value; + CONST char *value; /* * If the variable is unset, then immediately recreate it unless @@ -860,4 +889,3 @@ MessageTextVarProc(clientData, interp, name1, name2, flags) } return (char *) NULL; } - diff --git a/tk/generic/tkObj.c b/tk/generic/tkObj.c index 071cb383f43..2b44ba731f6 100644 --- a/tk/generic/tkObj.c +++ b/tk/generic/tkObj.c @@ -54,6 +54,16 @@ typedef struct MMRep { double returnValue; } MMRep; +/* + * The following structure is the internal representation for window objects. + */ + +typedef struct WindowRep { + Tk_Window tkwin; + Tk_Window mainwin; + long epoch; +} WindowRep; + /* * Prototypes for procedures defined later in this file: */ @@ -62,15 +72,19 @@ static void DupMMInternalRep _ANSI_ARGS_((Tcl_Obj *srcPtr, Tcl_Obj *copyPtr)); static void DupPixelInternalRep _ANSI_ARGS_((Tcl_Obj *srcPtr, Tcl_Obj *copyPtr)); +static void DupWindowInternalRep _ANSI_ARGS_((Tcl_Obj *srcPtr, + Tcl_Obj *copyPtr)); static void FreeMMInternalRep _ANSI_ARGS_((Tcl_Obj *objPtr)); static void FreePixelInternalRep _ANSI_ARGS_((Tcl_Obj *objPtr)); +static void FreeWindowInternalRep _ANSI_ARGS_((Tcl_Obj *objPtr)); +static void UpdateStringOfMM _ANSI_ARGS_((Tcl_Obj *objPtr)); static int SetMMFromAny _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *objPtr)); static int SetPixelFromAny _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *objPtr)); static int SetWindowFromAny _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *objPtr)); - + /* * The following structure defines the implementation of the "pixel" * Tcl object, used for measuring distances. The pixel object remembers @@ -95,7 +109,7 @@ static Tcl_ObjType mmObjType = { "mm", /* name */ FreeMMInternalRep, /* freeIntRepProc */ DupMMInternalRep, /* dupIntRepProc */ - NULL, /* updateStringProc */ + UpdateStringOfMM, /* updateStringProc */ SetMMFromAny /* setFromAnyProc */ }; @@ -106,8 +120,8 @@ static Tcl_ObjType mmObjType = { static Tcl_ObjType windowObjType = { "window", /* name */ - (Tcl_FreeInternalRepProc *) NULL, /* freeIntRepProc */ - (Tcl_DupInternalRepProc *) NULL, /* dupIntRepProc */ + FreeWindowInternalRep, /* freeIntRepProc */ + DupWindowInternalRep, /* dupIntRepProc */ NULL, /* updateStringProc */ SetWindowFromAny /* setFromAnyProc */ }; @@ -470,6 +484,48 @@ DupMMInternalRep(srcPtr, copyPtr) copyPtr->internalRep.otherValuePtr = (VOID *) newPtr; } +/* + *---------------------------------------------------------------------- + * + * UpdateStringOfMM -- + * + * Update the string representation for a pixel Tcl_Obj + * this function is only called, if the pixel Tcl_Obj has no unit, + * because with units the string representation is created by + * SetMMFromAny + * + * Results: + * None. + * + * Side effects: + * The object's string is set to a valid string that results from + * the double-to-string conversion. + * + *---------------------------------------------------------------------- + */ + +static void +UpdateStringOfMM(objPtr) + register Tcl_Obj *objPtr; /* pixel obj with string rep to update. */ +{ + MMRep *mmPtr; + char buffer[TCL_DOUBLE_SPACE]; + register int len; + + mmPtr = (MMRep *) objPtr->internalRep.otherValuePtr; + /* assert( mmPtr->units == -1 && objPtr->bytes == NULL ); */ + if ((mmPtr->units != -1) || (objPtr->bytes != NULL)) { + panic("UpdateStringOfMM: false precondition"); + } + + Tcl_PrintDouble((Tcl_Interp *) NULL, mmPtr->value, buffer); + len = strlen(buffer); + + objPtr->bytes = (char *) ckalloc((unsigned) len + 1); + strcpy(objPtr->bytes, buffer); + objPtr->length = len; +} + /* *---------------------------------------------------------------------- * @@ -501,46 +557,79 @@ SetMMFromAny(interp, objPtr) int units; MMRep *mmPtr; - string = Tcl_GetStringFromObj(objPtr, NULL); + static Tcl_ObjType *tclDoubleObjType = NULL; + static Tcl_ObjType *tclIntObjType = NULL; - d = strtod(string, &rest); - if (rest == string) { + if (tclDoubleObjType == NULL) { /* - * Must copy string before resetting the result in case a caller - * is trying to convert the interpreter's result to mms. + * Cache the object types for comaprison below. + * This allows optimized checks for standard cases. */ - error: - Tcl_AppendResult(interp, "bad screen distance \"", string, - "\"", (char *) NULL); - return TCL_ERROR; - } - while ((*rest != '\0') && isspace(UCHAR(*rest))) { - rest++; + tclDoubleObjType = Tcl_GetObjType("double"); + tclIntObjType = Tcl_GetObjType("int"); } - switch (*rest) { - case '\0': - units = -1; - break; - case 'c': - units = 0; - break; - - case 'i': - units = 1; - break; + if (objPtr->typePtr == tclDoubleObjType) { + Tcl_GetDoubleFromObj(interp, objPtr, &d); + units = -1; + } else if (objPtr->typePtr == tclIntObjType) { + Tcl_GetIntFromObj(interp, objPtr, &units); + d = (double) units; + units = -1; - case 'm': - units = 2; - break; - - case 'p': - units = 3; - break; + /* + * In the case of ints, we need to ensure that a valid + * string exists in order for int-but-not-string objects + * to be converted back to ints again from mm obj types. + */ + (void) Tcl_GetStringFromObj(objPtr, NULL); + } else { + /* + * It wasn't a known int or double, so parse it. + */ - default: - goto error; + string = Tcl_GetStringFromObj(objPtr, NULL); + + d = strtod(string, &rest); + if (rest == string) { + /* + * Must copy string before resetting the result in case a caller + * is trying to convert the interpreter's result to mms. + */ + + error: + Tcl_AppendResult(interp, "bad screen distance \"", string, + "\"", (char *) NULL); + return TCL_ERROR; + } + while ((*rest != '\0') && isspace(UCHAR(*rest))) { + rest++; + } + switch (*rest) { + case '\0': + units = -1; + break; + + case 'c': + units = 0; + break; + + case 'i': + units = 1; + break; + + case 'm': + units = 2; + break; + + case 'p': + units = 3; + break; + + default: + goto error; + } } /* @@ -552,14 +641,16 @@ SetMMFromAny(interp, objPtr) (*typePtr->freeIntRepProc)(objPtr); } - objPtr->typePtr = &mmObjType; + objPtr->typePtr = &mmObjType; + + mmPtr = (MMRep *) ckalloc(sizeof(MMRep)); + mmPtr->value = d; + mmPtr->units = units; + mmPtr->tkwin = NULL; + mmPtr->returnValue = d; - mmPtr = (MMRep *) ckalloc(sizeof(MMRep)); - mmPtr->value = d; - mmPtr->units = units; - mmPtr->tkwin = NULL; - mmPtr->returnValue = d; objPtr->internalRep.otherValuePtr = (VOID *) mmPtr; + return TCL_OK; } @@ -588,31 +679,42 @@ int TkGetWindowFromObj(interp, tkwin, objPtr, windowPtr) Tcl_Interp *interp; /* Used for error reporting if not NULL. */ Tk_Window tkwin; /* A token to get the main window from. */ - register Tcl_Obj *objPtr; /* The object from which to get boolean. */ + Tcl_Obj *objPtr; /* The object from which to get boolean. */ Tk_Window *windowPtr; /* Place to store resulting window. */ { - register int result; - Tk_Window lastWindow; + register WindowRep *winPtr; + TkDisplay *dispPtr = ((TkWindow *)tkwin)->dispPtr; + Tk_Window foundWindow; - result = SetWindowFromAny(interp, objPtr); - if (result != TCL_OK) { - return result; + if (objPtr->typePtr != &windowObjType) { + register int result = SetWindowFromAny(interp, objPtr); + if (result != TCL_OK) { + return result; + } } - lastWindow = (Tk_Window) objPtr->internalRep.twoPtrValue.ptr1; - if (tkwin != lastWindow) { - Tk_Window foundWindow = Tk_NameToWindow(interp, - Tcl_GetStringFromObj(objPtr, NULL), tkwin); + winPtr = (WindowRep *) objPtr->internalRep.otherValuePtr; + if (winPtr == NULL) { + winPtr = (WindowRep *) ckalloc(sizeof(WindowRep)); + objPtr->internalRep.otherValuePtr = (VOID *) winPtr; + goto parseWindowString; + } else if (tkwin != winPtr->mainwin || + dispPtr->deletionEpoch != winPtr->epoch) { + parseWindowString: + foundWindow = Tk_NameToWindow(interp, + Tcl_GetStringFromObj(objPtr, NULL), tkwin); if (foundWindow == NULL) { return TCL_ERROR; } - objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) tkwin; - objPtr->internalRep.twoPtrValue.ptr2 = (VOID *) foundWindow; + + winPtr->tkwin = foundWindow; + winPtr->mainwin = tkwin; + winPtr->epoch = dispPtr->deletionEpoch; } - *windowPtr = (Tk_Window) objPtr->internalRep.twoPtrValue.ptr2; - return result; + *windowPtr = winPtr->tkwin; + return TCL_OK; } /* @@ -652,9 +754,105 @@ SetWindowFromAny(interp, objPtr) (*typePtr->freeIntRepProc)(objPtr); } objPtr->typePtr = &windowObjType; - objPtr->internalRep.twoPtrValue.ptr1 = NULL; - objPtr->internalRep.twoPtrValue.ptr2 = NULL; + objPtr->internalRep.otherValuePtr = NULL; return TCL_OK; } + +/* + *---------------------------------------------------------------------- + * + * DupWindowInternalRep -- + * + * Initialize the internal representation of a window Tcl_Obj to a + * copy of the internal representation of an existing window object. + * + * Results: + * None. + * + * Side effects: + * copyPtr's internal rep is set to refer to the same window as + * srcPtr's internal rep. + * + *---------------------------------------------------------------------- + */ + +static void +DupWindowInternalRep(srcPtr, copyPtr) + register Tcl_Obj *srcPtr; + register Tcl_Obj *copyPtr; +{ + register WindowRep *oldPtr, *newPtr; + + copyPtr->typePtr = srcPtr->typePtr; + oldPtr = srcPtr->internalRep.otherValuePtr; + if (oldPtr == NULL) { + copyPtr->internalRep.otherValuePtr = NULL; + } else { + newPtr = (WindowRep *) ckalloc(sizeof(WindowRep)); + newPtr->tkwin = oldPtr->tkwin; + newPtr->mainwin = oldPtr->mainwin; + newPtr->epoch = oldPtr->epoch; + copyPtr->internalRep.otherValuePtr = (VOID *)newPtr; + } +} + +/* + *---------------------------------------------------------------------- + * + * FreeWindowInternalRep -- + * + * Deallocate the storage associated with a window object's internal + * representation. + * + * Results: + * None. + * + * Side effects: + * Frees objPtr's internal representation and sets objPtr's + * internalRep to NULL. + * + *---------------------------------------------------------------------- + */ + +static void +FreeWindowInternalRep(objPtr) + Tcl_Obj *objPtr; /* Window object with internal rep to free. */ +{ + if (objPtr->internalRep.otherValuePtr != NULL) { + ckfree((char *) objPtr->internalRep.otherValuePtr); + objPtr->internalRep.otherValuePtr = NULL; + } +} + +/* + *---------------------------------------------------------------------- + * + * TkRegisterObjTypes -- + * + * Registers Tk's Tcl_ObjType structures with the Tcl run-time. + * + * Results: + * None + * + * Side effects: + * All instances of Tcl_ObjType structues used in Tk are registered + * with Tcl. + * + *---------------------------------------------------------------------- + */ +void +TkRegisterObjTypes() +{ + Tcl_RegisterObjType(&tkBorderObjType); + Tcl_RegisterObjType(&tkBitmapObjType); + Tcl_RegisterObjType(&tkColorObjType); + Tcl_RegisterObjType(&tkCursorObjType); + Tcl_RegisterObjType(&tkFontObjType); + Tcl_RegisterObjType(&mmObjType); + Tcl_RegisterObjType(&tkOptionObjType); + Tcl_RegisterObjType(&pixelObjType); + Tcl_RegisterObjType(&tkStateKeyObjType); + Tcl_RegisterObjType(&windowObjType); +} diff --git a/tk/generic/tkOldConfig.c b/tk/generic/tkOldConfig.c index 18b22e451ee..e555013000a 100644 --- a/tk/generic/tkOldConfig.c +++ b/tk/generic/tkOldConfig.c @@ -36,12 +36,12 @@ static int DoConfig _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin, Tk_ConfigSpec *specPtr, Tk_Uid value, int valueIsUid, char *widgRec)); static Tk_ConfigSpec * FindConfigSpec _ANSI_ARGS_((Tcl_Interp *interp, - Tk_ConfigSpec *specs, char *argvName, + Tk_ConfigSpec *specs, CONST char *argvName, int needFlags, int hateFlags)); static char * FormatConfigInfo _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin, Tk_ConfigSpec *specPtr, char *widgRec)); -static char * FormatConfigValue _ANSI_ARGS_((Tcl_Interp *interp, +static CONST char * FormatConfigValue _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin, Tk_ConfigSpec *specPtr, char *widgRec, char *buffer, Tcl_FreeProc **freeProcPtr)); @@ -74,7 +74,7 @@ Tk_ConfigureWidget(interp, tkwin, specs, argc, argv, widgRec, flags) * set up X resources). */ Tk_ConfigSpec *specs; /* Describes legal options. */ int argc; /* Number of elements in argv. */ - char **argv; /* Command-line options. */ + CONST char **argv; /* Command-line options. */ char *widgRec; /* Record whose fields are to be * modified. Values must be properly * initialized. */ @@ -134,7 +134,7 @@ Tk_ConfigureWidget(interp, tkwin, specs, argc, argv, widgRec, flags) */ for ( ; argc > 0; argc -= 2, argv += 2) { - char *arg; + CONST char *arg; if (flags & TK_CONFIG_OBJS) { arg = Tcl_GetStringFromObj((Tcl_Obj *) *argv, NULL); @@ -255,7 +255,7 @@ FindConfigSpec(interp, specs, argvName, needFlags, hateFlags) Tcl_Interp *interp; /* Used for reporting errors. */ Tk_ConfigSpec *specs; /* Pointer to table of configuration * specifications for a widget. */ - char *argvName; /* Name (suitable for use in a "config" + CONST char *argvName; /* Name (suitable for use in a "config" * command) identifying particular option. */ int needFlags; /* Flags that must be present in matching * entry. */ @@ -351,7 +351,7 @@ DoConfig(interp, tkwin, specPtr, value, valueIsUid, widgRec) Tk_Window tkwin; /* Window containing widget (needed to * set up X resources). */ Tk_ConfigSpec *specPtr; /* Specifier to apply. */ - char *value; /* Value to use to fill in widgRec. */ + Tk_Uid value; /* Value to use to fill in widgRec. */ int valueIsUid; /* Non-zero means value is a Tk_Uid; * zero means it's an ordinary string. */ char *widgRec; /* Record whose fields are to be @@ -618,7 +618,7 @@ Tk_ConfigureInfo(interp, tkwin, specs, widgRec, argvName, flags) Tk_ConfigSpec *specs; /* Describes legal options. */ char *widgRec; /* Record whose fields contain current * values for options. */ - char *argvName; /* If non-NULL, indicates a single option + CONST char *argvName; /* If non-NULL, indicates a single option * whose info is to be returned. Otherwise * info is returned for all options. */ int flags; /* Used to specify additional flags @@ -707,7 +707,8 @@ FormatConfigInfo(interp, tkwin, specPtr, widgRec) char *widgRec; /* Pointer to record holding current * values of info for widget. */ { - char *argv[6], *result; + CONST char *argv[6]; + char *result; char buffer[200]; Tcl_FreeProc *freeProc = (Tcl_FreeProc *) NULL; @@ -735,9 +736,9 @@ FormatConfigInfo(interp, tkwin, specPtr, widgRec) result = Tcl_Merge(5, argv); if (freeProc != NULL) { if ((freeProc == TCL_DYNAMIC) || (freeProc == (Tcl_FreeProc *) free)) { - ckfree(argv[4]); + ckfree((char *)argv[4]); } else { - (*freeProc)(argv[4]); + (*freeProc)((char *)argv[4]); } } return result; @@ -765,7 +766,7 @@ FormatConfigInfo(interp, tkwin, specPtr, widgRec) *---------------------------------------------------------------------- */ -static char * +static CONST char * FormatConfigValue(interp, tkwin, specPtr, widgRec, buffer, freeProcPtr) Tcl_Interp *interp; /* Interpreter for use in real conversions. */ Tk_Window tkwin; /* Window corresponding to widget. */ @@ -779,7 +780,7 @@ FormatConfigValue(interp, tkwin, specPtr, widgRec, buffer, freeProcPtr) * of procedure to free the result, or NULL * if result is static. */ { - char *ptr, *result; + CONST char *ptr, *result; *freeProcPtr = NULL; ptr = widgRec + specPtr->offset; @@ -919,7 +920,7 @@ Tk_ConfigureValue(interp, tkwin, specs, widgRec, argvName, flags) Tk_ConfigSpec *specs; /* Describes legal options. */ char *widgRec; /* Record whose fields contain current * values for options. */ - char *argvName; /* Gives the command-line name for the + CONST char *argvName; /* Gives the command-line name for the * option whose value is to be returned. */ int flags; /* Used to specify additional flags * that must be present in config specs @@ -927,6 +928,9 @@ Tk_ConfigureValue(interp, tkwin, specs, widgRec, argvName, flags) { Tk_ConfigSpec *specPtr; int needFlags, hateFlags; + Tcl_FreeProc *freeProc; + CONST char *result; + char buffer[200]; needFlags = flags & ~(TK_CONFIG_USER_BIT - 1); if (Tk_Depth(tkwin) <= 1) { @@ -938,8 +942,15 @@ Tk_ConfigureValue(interp, tkwin, specs, widgRec, argvName, flags) if (specPtr == NULL) { return TCL_ERROR; } - interp->result = FormatConfigValue(interp, tkwin, specPtr, widgRec, - interp->result, &interp->freeProc); + result = FormatConfigValue(interp, tkwin, specPtr, widgRec, buffer, &freeProc); + Tcl_SetResult(interp, (char *) result, TCL_VOLATILE); + if (freeProc != NULL) { + if ((freeProc == TCL_DYNAMIC) || (freeProc == (Tcl_FreeProc *) free)) { + ckfree((char *)result); + } else { + (*freeProc)((char *)result); + } + } return TCL_OK; } @@ -1019,5 +1030,3 @@ Tk_FreeOptions(specs, widgRec, display, needFlags) } } } - - diff --git a/tk/generic/tkOption.c b/tk/generic/tkOption.c index 54e1f27d75e..2decd353971 100644 --- a/tk/generic/tkOption.c +++ b/tk/generic/tkOption.c @@ -26,6 +26,35 @@ * structures exists for each node or leaf in the option tree. It is * actually stored as part of the parent node, and describes a particular * child of the parent. + * + * The structure of the option db tree is a little confusing. There are + * four different kinds of nodes in the tree: + * interior class nodes + * interior name nodes + * leaf class nodes + * leaf name nodes + * + * All interior nodes refer to _window_ classes and names; all leaf nodes + * refer to _option_ classes and names. When looking for a particular option, + * therefore, you must compare interior node values to corresponding window + * values, and compare leaf node values to corresponding option values. + * + * The tree is actually stored in a collection of arrays; there is one each + * combination of WILDCARD/EXACT and CLASS/NAME and NODE/LEAF. The NODE arrays + * contain the interior nodes of the tree; each element has a pointer to an + * array of elements which are the leaves of the tree. The LEAF arrays, rather + * than holding the leaves of the tree, hold a cached subset of the option + * database, consisting of the values of all defined options for a single + * window, and some additional information about each ancestor of the window + * (since some options may be inherited from a parent), all the way back to the + * root window. + * + * Each time a call is made to Tk_GetOption, Tk will attempt to use the cached + * information to satisfy the lookup. If the call is for a window other than + * that for which options are currently cached, the portion of the cache that + * contains information for common ancestors of the two windows is retained and + * the remainder is discarded and rebuilt with new information for the new + * window. */ typedef struct Element { @@ -206,6 +235,8 @@ static void ExtendStacks _ANSI_ARGS_((ElArray *arrayPtr, static int GetDefaultOptions _ANSI_ARGS_((Tcl_Interp *interp, TkWindow *winPtr)); static ElArray * NewArray _ANSI_ARGS_((int numEls)); +static void OptionThreadExitProc _ANSI_ARGS_(( + ClientData clientData)); static void OptionInit _ANSI_ARGS_((TkMainInfo *mainPtr)); static int ParsePriority _ANSI_ARGS_((Tcl_Interp *interp, char *string)); @@ -233,8 +264,8 @@ void Tk_AddOption(tkwin, name, value, priority) Tk_Window tkwin; /* Window token; option will be associated * with main window for this window. */ - char *name; /* Multi-element name of option. */ - char *value; /* String value for option. */ + CONST char *name; /* Multi-element name of option. */ + CONST char *value; /* String value for option. */ int priority; /* Overall priority level to use for * this option, such as TK_USER_DEFAULT_PRIO * or TK_INTERACTIVE_PRIO. Must be between @@ -244,8 +275,8 @@ Tk_AddOption(tkwin, name, value, priority) register ElArray **arrayPtrPtr; register Element *elPtr; Element newEl; - register char *p; - char *field; + register CONST char *p; + CONST char *field; int count, firstField, length; #define TMP_SIZE 100 char tmp[TMP_SIZE+1]; @@ -391,14 +422,17 @@ Tk_Uid Tk_GetOption(tkwin, name, className) Tk_Window tkwin; /* Token for window that option is * associated with. */ - char *name; /* Name of option. */ - char *className; /* Class of option. NULL means there + CONST char *name; /* Name of option. */ + CONST char *className; /* Class of option. NULL means there * is no class for this option: just * check for name. */ { - Tk_Uid nameId, classId; + Tk_Uid nameId, classId = NULL; + char *masqName; register Element *elPtr, *bestPtr; register int count; + StackLevel *levelPtr; + int stackDepth[NUM_STACKS]; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -411,43 +445,169 @@ Tk_GetOption(tkwin, name, className) SetupStacks((TkWindow *) tkwin, 1); } - nameId = Tk_GetUid(name); + /* + * Get a default "best" match. + */ + bestPtr = &tsdPtr->defaultMatch; + + /* + * For megawidget support, we want to have some widget options masquerade + * as options for other widgets. For example, a combobox has a button in + * it; this button ought to pick up the *Button.background, etc., options. + * But because the class of the widget is Combobox, our normal search + * won't get that option. + * + * To work around this, the option name field syntax was extended to allow + * for a "." in the name; if this character occurs in the name, then it + * indicates that this name contains a new window class and an option name, + * ie, "Button.foreground". If we see this form in the name field, we + * query the option database directly (since the option stacks will not + * have the information we need). + */ + + masqName = strchr(name, (int)'.'); + if (masqName != NULL) { + /* + * This option is masquerading with a different window class. + * Search the stack to the depth it was before the current window's + * information was pushed (the value for which is stored in the bases + * field). + */ + levelPtr = &tsdPtr->levels[tsdPtr->curLevel]; + nameId = Tk_GetUid(masqName+1); + for (count = 0; count < NUM_STACKS; count++) { + stackDepth[count] = levelPtr->bases[count]; + } + } else { + /* + * No option masquerading here. Just use the current level to get the + * stack depths. + */ + nameId = Tk_GetUid(name); + for (count = 0; count < NUM_STACKS; count++) { + stackDepth[count] = tsdPtr->stacks[count]->numUsed; + } + } + + /* + * Probe the stacks for matches. + */ + for (elPtr = tsdPtr->stacks[EXACT_LEAF_NAME]->els, - count = tsdPtr->stacks[EXACT_LEAF_NAME]->numUsed; count > 0; - elPtr++, count--) { + count = stackDepth[EXACT_LEAF_NAME]; count > 0; + elPtr++, count--) { if ((elPtr->nameUid == nameId) && (elPtr->priority > bestPtr->priority)) { bestPtr = elPtr; } } for (elPtr = tsdPtr->stacks[WILDCARD_LEAF_NAME]->els, - count = tsdPtr->stacks[WILDCARD_LEAF_NAME]->numUsed; count > 0; - elPtr++, count--) { + count = stackDepth[WILDCARD_LEAF_NAME]; count > 0; + elPtr++, count--) { if ((elPtr->nameUid == nameId) && (elPtr->priority > bestPtr->priority)) { bestPtr = elPtr; } } + if (className != NULL) { classId = Tk_GetUid(className); for (elPtr = tsdPtr->stacks[EXACT_LEAF_CLASS]->els, - count = tsdPtr->stacks[EXACT_LEAF_CLASS]->numUsed; count > 0; - elPtr++, count--) { + count = stackDepth[EXACT_LEAF_CLASS]; count > 0; + elPtr++, count--) { if ((elPtr->nameUid == classId) && (elPtr->priority > bestPtr->priority)) { bestPtr = elPtr; } } for (elPtr = tsdPtr->stacks[WILDCARD_LEAF_CLASS]->els, - count = tsdPtr->stacks[WILDCARD_LEAF_CLASS]->numUsed; - count > 0; elPtr++, count--) { + count = stackDepth[WILDCARD_LEAF_CLASS]; count > 0; + elPtr++, count--) { if ((elPtr->nameUid == classId) && (elPtr->priority > bestPtr->priority)) { bestPtr = elPtr; } } } + + /* + * If this option was masquerading with a different window class, + * probe the option database now. Note that this will be inefficient + * if the option database is densely populated, or if the widget has many + * masquerading options. + */ + + if (masqName != NULL) { + char *masqClass; + Tk_Uid nodeId, winClassId, winNameId; + unsigned int classNameLength; + register Element *nodePtr, *leafPtr; + static int searchOrder[] = { EXACT_NODE_NAME, + WILDCARD_NODE_NAME, + EXACT_NODE_CLASS, + WILDCARD_NODE_CLASS, + -1 }; + int *currentPtr, currentStack, leafCount; + + /* + * Extract the masquerade class name from the name field. + */ + + classNameLength = (unsigned int)(masqName - name); + masqClass = (char *)ckalloc(classNameLength + 1); + strncpy(masqClass, name, classNameLength); + masqClass[classNameLength] = '\0'; + + winClassId = Tk_GetUid(masqClass); + ckfree(masqClass); + winNameId = ((TkWindow *)tkwin)->nameUid; + + levelPtr = &tsdPtr->levels[tsdPtr->curLevel]; + + for (currentPtr = searchOrder; *currentPtr != -1; currentPtr++) { + currentStack = *currentPtr; + nodePtr = tsdPtr->stacks[currentStack]->els; + count = levelPtr->bases[currentStack]; + + /* + * For wildcard stacks, check all entries; for non-wildcard + * stacks, only check things that matched in the parent. + */ + + if (!(currentStack & WILDCARD)) { + nodePtr += levelPtr[-1].bases[currentStack]; + count -= levelPtr[-1].bases[currentStack]; + } + + if (currentStack && CLASS) { + nodeId = winClassId; + } else { + nodeId = winNameId; + } + + for ( ; count > 0; nodePtr++, count--) { + if (nodePtr->nameUid == nodeId) { + leafPtr = nodePtr->child.arrayPtr->els; + leafCount = nodePtr->child.arrayPtr->numUsed; + for ( ; leafCount > 0; leafPtr++, leafCount--) { + if (leafPtr->flags & CLASS && className != NULL) { + if (leafPtr->nameUid == classId && + leafPtr->priority > bestPtr->priority) { + bestPtr = leafPtr; + } + } else { + if (leafPtr->nameUid == nameId && + leafPtr->priority > bestPtr->priority) { + bestPtr = leafPtr; + } + } + } + } + } + } + } + return bestPtr->child.valueUid; } @@ -481,7 +641,7 @@ Tk_OptionObjCmd(clientData, interp, objc, objv) ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - static char *optionCmds[] = { + static CONST char *optionCmds[] = { "add", "clear", "get", "readfile", NULL }; @@ -553,7 +713,7 @@ Tk_OptionObjCmd(clientData, interp, objc, objv) value = Tk_GetOption(window, Tcl_GetString(objv[3]), Tcl_GetString(objv[4])); if (value != NULL) { - Tcl_SetResult(interp, value, TCL_STATIC); + Tcl_SetResult(interp, (char *)value, TCL_STATIC); } break; } @@ -627,7 +787,7 @@ TkOptionDeadWindow(winPtr) * database. */ - if ((winPtr->mainPtr->winPtr == winPtr) + if ((winPtr->mainPtr != NULL) && (winPtr->mainPtr->winPtr == winPtr) && (winPtr->mainPtr->optionRootPtr != NULL)) { ClearOptionTree(winPtr->mainPtr->optionRootPtr); winPtr->mainPtr->optionRootPtr = NULL; @@ -934,7 +1094,8 @@ ReadOptionFile(interp, tkwin, fileName, priority) * or TK_INTERACTIVE_PRIO. Must be between * 0 and TK_MAX_PRIO. */ { - char *realName, *buffer; + CONST char *realName; + char *buffer; int result, bufferSize; Tcl_Channel chan; Tcl_DString newName; @@ -967,8 +1128,8 @@ ReadOptionFile(interp, tkwin, fileName, priority) * overallocate if we are performing CRLF translation. */ - bufferSize = Tcl_Seek(chan, 0L, SEEK_END); - (void) Tcl_Seek(chan, 0L, SEEK_SET); + bufferSize = (int) Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_END); + (void) Tcl_Seek(chan, (Tcl_WideInt) 0, SEEK_SET); if (bufferSize < 0) { Tcl_AppendResult(interp, "error seeking to end of file \"", @@ -1195,24 +1356,9 @@ SetupStacks(winPtr, leaf) arrayPtr = tsdPtr->stacks[EXACT_LEAF_CLASS]; arrayPtr->numUsed = 0; arrayPtr->nextToUse = arrayPtr->els; - levelPtr->bases[EXACT_LEAF_NAME] = tsdPtr->stacks[EXACT_LEAF_NAME] - ->numUsed; - levelPtr->bases[EXACT_LEAF_CLASS] = tsdPtr->stacks[EXACT_LEAF_CLASS] - ->numUsed; - levelPtr->bases[EXACT_NODE_NAME] = tsdPtr->stacks[EXACT_NODE_NAME] - ->numUsed; - levelPtr->bases[EXACT_NODE_CLASS] = tsdPtr->stacks[EXACT_NODE_CLASS] - ->numUsed; - levelPtr->bases[WILDCARD_LEAF_NAME] = tsdPtr->stacks[WILDCARD_LEAF_NAME] - ->numUsed; - levelPtr->bases[WILDCARD_LEAF_CLASS] = tsdPtr->stacks[WILDCARD_LEAF_CLASS] - ->numUsed; - levelPtr->bases[WILDCARD_NODE_NAME] = tsdPtr->stacks[WILDCARD_NODE_NAME] - ->numUsed; - levelPtr->bases[WILDCARD_NODE_CLASS] = tsdPtr->stacks[WILDCARD_NODE_CLASS] - ->numUsed; - - + for (i = 0; i < NUM_STACKS; i++) { + levelPtr->bases[i] = tsdPtr->stacks[i]->numUsed; + } /* * Step 5: scan the current stack level looking for matches to this * window's name or class; where found, add new information to the @@ -1291,6 +1437,39 @@ ExtendStacks(arrayPtr, leaf) } } +/* + *-------------------------------------------------------------- + * + * OptionThreadExitProc -- + * + * Free data structures for option handling. + * + * Results: + * None. + * + * Side effects: + * Option-related data structures get freed. + * + *-------------------------------------------------------------- + */ + +static void +OptionThreadExitProc(clientData) + ClientData clientData; /* not used */ +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + + if (tsdPtr->initialized) { + int i; + for (i = 0; i < NUM_STACKS; i++) { + ckfree((char *) tsdPtr->stacks[i]); + } + ckfree((char *) tsdPtr->levels); + tsdPtr->initialized = 0; + } +} + /* *-------------------------------------------------------------- * @@ -1341,6 +1520,7 @@ OptionInit(mainPtr) defaultMatchPtr->child.valueUid = NULL; defaultMatchPtr->priority = -1; defaultMatchPtr->flags = 0; + Tcl_CreateThreadExitHandler(OptionThreadExitProc, NULL); } /* diff --git a/tk/generic/tkPack.c b/tk/generic/tkPack.c index d10d86782b9..ab2157152af 100644 --- a/tk/generic/tkPack.c +++ b/tk/generic/tkPack.c @@ -17,6 +17,9 @@ #include "tkInt.h" typedef enum {TOP, BOTTOM, LEFT, RIGHT} Side; +static CONST char *sideNames[] = { + "top", "bottom", "left", "right", (char *) NULL +}; /* For each window that the packer cares about (either because * the window is managed by the packer or because the window @@ -24,7 +27,7 @@ typedef enum {TOP, BOTTOM, LEFT, RIGHT} Side; * structure of the following type: */ -typedef struct /* Green Bay */ Packer { +typedef struct Packer { Tk_Window tkwin; /* Tk token for window. NULL means that * the window has been deleted, but the * packet hasn't had a chance to clean up @@ -45,12 +48,15 @@ typedef struct /* Green Bay */ Packer { * than window needs, this indicates how * where to position window in frame. */ int padX, padY; /* Total additional pixels to leave around the - * window (half of this space is left on each - * side). This is space *outside* the window: + * window. Some is of this space is on each + * side. This is space *outside* the window: * we'll allocate extra space in frame but * won't enlarge window). */ + int padLeft, padTop; /* The part of padX or padY to use on the + * left or top of the widget, respectively. + * By default, this is half of padX or padY. */ int iPadX, iPadY; /* Total extra pixels to allocate inside the - * window (half this amount will appear on + * window (half of this amount will appear on * each side). */ int doubleBw; /* Twice the window's last known border * width. If this changes, the window @@ -117,12 +123,12 @@ static Tk_GeomMgr packerType = { static void ArrangePacking _ANSI_ARGS_((ClientData clientData)); static int ConfigureSlaves _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Window tkwin, int argc, char *argv[])); + Tk_Window tkwin, int objc, Tcl_Obj *CONST objv[])); static void DestroyPacker _ANSI_ARGS_((char *memPtr)); static Packer * GetPacker _ANSI_ARGS_((Tk_Window tkwin)); static int PackAfter _ANSI_ARGS_((Tcl_Interp *interp, - Packer *prevPtr, Packer *masterPtr, int argc, - char **argv)); + Packer *prevPtr, Packer *masterPtr, int objc, + Tcl_Obj *CONST objv[])); static void PackReqProc _ANSI_ARGS_((ClientData clientData, Tk_Window tkwin)); static void PackStructureProc _ANSI_ARGS_((ClientData clientData, @@ -133,6 +139,43 @@ static int XExpansion _ANSI_ARGS_((Packer *slavePtr, static int YExpansion _ANSI_ARGS_((Packer *slavePtr, int cavityHeight)); +/* + *-------------------------------------------------------------- + * + * TkPrintPadAmount -- + * + * This procedure generates a text value that describes one + * of the -padx, -pady, -ipadx, or -ipady configuration options. + * The text value generated is appended to the interpreter + * result. + * + * Results: + * None. + * + * Side effects: + * None. + * + *-------------------------------------------------------------- + */ +void +TkPrintPadAmount(interp, switchName, halfSpace, allSpace) + Tcl_Interp *interp; /* The interpreter into which the result + * is written. */ + char *switchName; /* One of "padx", "pady", "ipadx" or "ipady" */ + int halfSpace; /* The left or top padding amount */ + int allSpace; /* The total amount of padding */ +{ + char buffer[60 + 2*TCL_INTEGER_SPACE]; + if (halfSpace*2 == allSpace) { + sprintf(buffer, " -%.10s %d", switchName, halfSpace); + } else { + sprintf(buffer, " -%.10s {%d %d}", switchName, halfSpace, + allSpace - halfSpace); + } + Tcl_AppendResult(interp, buffer, (char *)NULL); +} + + /* *-------------------------------------------------------------- * @@ -151,51 +194,71 @@ static int YExpansion _ANSI_ARGS_((Packer *slavePtr, */ int -Tk_PackCmd(clientData, interp, argc, argv) +Tk_PackObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Main window associated with * interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window tkwin = (Tk_Window) clientData; - size_t length; - int c; - - if ((argc >= 2) && (argv[1][0] == '.')) { - return ConfigureSlaves(interp, tkwin, argc-1, argv+1); + char *argv2; + static CONST char *optionStrings[] = { + /* after, append, before and unpack are deprecated */ + "after", "append", "before", "unpack", + "configure", "forget", "info", "propagate", "slaves", (char *) NULL }; + enum options { + PACK_AFTER, PACK_APPEND, PACK_BEFORE, PACK_UNPACK, + PACK_CONFIGURE, PACK_FORGET, PACK_INFO, PACK_PROPAGATE, PACK_SLAVES }; + int index; + + if (objc >= 2) { + char *string = Tcl_GetString(objv[1]); + if (string[0] == '.') { + return ConfigureSlaves(interp, tkwin, objc-1, objv+1); + } } - if (argc < 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " option arg ?arg ...?\"", (char *) NULL); + if (objc < 3) { + Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?"); return TCL_ERROR; } - c = argv[1][0]; - length = strlen(argv[1]); - if ((c == 'a') && (length >= 2) - && (strncmp(argv[1], "after", length) == 0)) { + + if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, + &index) != TCL_OK) { + /* + * Call it again without the deprecated ones to get a proper + * error message. + * This works well since there can't be any ambiguity between + * deprecated and new options. + */ + + Tcl_ResetResult(interp); + Tcl_GetIndexFromObj(interp, objv[1], &optionStrings[4], "option", 0, + &index); + return TCL_ERROR; + } + + argv2 = Tcl_GetString(objv[2]); + if (index == PACK_AFTER) { Packer *prevPtr; Tk_Window tkwin2; - tkwin2 = Tk_NameToWindow(interp, argv[2], tkwin); - if (tkwin2 == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } prevPtr = GetPacker(tkwin2); if (prevPtr->masterPtr == NULL) { - Tcl_AppendResult(interp, "window \"", argv[2], + Tcl_AppendResult(interp, "window \"", argv2, "\" isn't packed", (char *) NULL); return TCL_ERROR; } - return PackAfter(interp, prevPtr, prevPtr->masterPtr, argc-3, argv+3); - } else if ((c == 'a') && (length >= 2) - && (strncmp(argv[1], "append", length) == 0)) { + return PackAfter(interp, prevPtr, prevPtr->masterPtr, objc-3, objv+3); + } else if (index == PACK_APPEND) { Packer *masterPtr; register Packer *prevPtr; Tk_Window tkwin2; - tkwin2 = Tk_NameToWindow(interp, argv[2], tkwin); - if (tkwin2 == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } masterPtr = GetPacker(tkwin2); @@ -205,19 +268,18 @@ Tk_PackCmd(clientData, interp, argc, argv) prevPtr = prevPtr->nextPtr; } } - return PackAfter(interp, prevPtr, masterPtr, argc-3, argv+3); - } else if ((c == 'b') && (strncmp(argv[1], "before", length) == 0)) { + return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3); + } else if (index == PACK_BEFORE) { Packer *packPtr, *masterPtr; register Packer *prevPtr; Tk_Window tkwin2; - tkwin2 = Tk_NameToWindow(interp, argv[2], tkwin); - if (tkwin2 == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } packPtr = GetPacker(tkwin2); if (packPtr->masterPtr == NULL) { - Tcl_AppendResult(interp, "window \"", argv[2], + Tcl_AppendResult(interp, "window \"", argv2, "\" isn't packed", (char *) NULL); return TCL_ERROR; } @@ -235,22 +297,21 @@ Tk_PackCmd(clientData, interp, argc, argv) } } } - return PackAfter(interp, prevPtr, masterPtr, argc-3, argv+3); - } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)) { - if (argv[2][0] != '.') { - Tcl_AppendResult(interp, "bad argument \"", argv[2], + return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3); + } else if (index == PACK_CONFIGURE) { + if (argv2[0] != '.') { + Tcl_AppendResult(interp, "bad argument \"", argv2, "\": must be name of window", (char *) NULL); return TCL_ERROR; } - return ConfigureSlaves(interp, tkwin, argc-2, argv+2); - } else if ((c == 'f') && (strncmp(argv[1], "forget", length) == 0)) { + return ConfigureSlaves(interp, tkwin, objc-2, objv+2); + } else if (index == PACK_FORGET) { Tk_Window slave; Packer *slavePtr; int i; - for (i = 2; i < argc; i++) { - slave = Tk_NameToWindow(interp, argv[i], tkwin); - if (slave == NULL) { + for (i = 2; i < objc; i++) { + if (TkGetWindowFromObj(interp, tkwin, objv[i], &slave) != TCL_OK) { continue; } slavePtr = GetPacker(slave); @@ -265,24 +326,20 @@ Tk_PackCmd(clientData, interp, argc, argv) Tk_UnmapWindow(slavePtr->tkwin); } } - } else if ((c == 'i') && (strncmp(argv[1], "info", length) == 0)) { + } else if (index == PACK_INFO) { register Packer *slavePtr; Tk_Window slave; - char buffer[64 + TCL_INTEGER_SPACE * 4]; - static char *sideNames[] = {"top", "bottom", "left", "right"}; - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " info window\"", (char *) NULL); + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - slave = Tk_NameToWindow(interp, argv[2], tkwin); - if (slave == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &slave) != TCL_OK) { return TCL_ERROR; } slavePtr = GetPacker(slave); if (slavePtr->masterPtr == NULL) { - Tcl_AppendResult(interp, "window \"", argv[2], + Tcl_AppendResult(interp, "window \"", argv2, "\" isn't packed", (char *) NULL); return TCL_ERROR; } @@ -307,35 +364,31 @@ Tk_PackCmd(clientData, interp, argc, argv) Tcl_AppendResult(interp, "both", (char *) NULL); break; } - sprintf(buffer, " -ipadx %d -ipady %d -padx %d -pady %d", - slavePtr->iPadX/2, slavePtr->iPadY/2, slavePtr->padX/2, - slavePtr->padY/2); - Tcl_AppendResult(interp, buffer, " -side ", sideNames[slavePtr->side], + TkPrintPadAmount(interp, "ipadx", slavePtr->iPadX/2, slavePtr->iPadX); + TkPrintPadAmount(interp, "ipady", slavePtr->iPadY/2, slavePtr->iPadY); + TkPrintPadAmount(interp, "padx", slavePtr->padLeft, slavePtr->padX); + TkPrintPadAmount(interp, "pady", slavePtr->padTop, slavePtr->padY); + Tcl_AppendResult(interp, " -side ", sideNames[slavePtr->side], (char *) NULL); - } else if ((c == 'p') && (strncmp(argv[1], "propagate", length) == 0)) { + } else if (index == PACK_PROPAGATE) { Tk_Window master; Packer *masterPtr; int propagate; - if (argc > 4) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " propagate window ?boolean?\"", (char *) NULL); + if (objc > 4) { + Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); return TCL_ERROR; } - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { return TCL_ERROR; } masterPtr = GetPacker(master); - if (argc == 3) { - if (masterPtr->flags & DONT_PROPAGATE) { - Tcl_SetResult(interp, "0", TCL_STATIC); - } else { - Tcl_SetResult(interp, "1", TCL_STATIC); - } + if (objc == 3) { + Tcl_SetObjResult(interp, + Tcl_NewBooleanObj(!(masterPtr->flags & DONT_PROPAGATE))); return TCL_OK; } - if (Tcl_GetBoolean(interp, argv[3], &propagate) != TCL_OK) { + if (Tcl_GetBooleanFromObj(interp, objv[3], &propagate) != TCL_OK) { return TCL_ERROR; } if (propagate) { @@ -356,17 +409,15 @@ Tk_PackCmd(clientData, interp, argc, argv) } else { masterPtr->flags |= DONT_PROPAGATE; } - } else if ((c == 's') && (strncmp(argv[1], "slaves", length) == 0)) { + } else if (index == PACK_SLAVES) { Tk_Window master; Packer *masterPtr, *slavePtr; - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " slaves window\"", (char *) NULL); + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - master = Tk_NameToWindow(interp, argv[2], tkwin); - if (master == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { return TCL_ERROR; } masterPtr = GetPacker(master); @@ -374,17 +425,15 @@ Tk_PackCmd(clientData, interp, argc, argv) slavePtr = slavePtr->nextPtr) { Tcl_AppendElement(interp, Tk_PathName(slavePtr->tkwin)); } - } else if ((c == 'u') && (strncmp(argv[1], "unpack", length) == 0)) { + } else if (index == PACK_UNPACK) { Tk_Window tkwin2; Packer *packPtr; - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " unpack window\"", (char *) NULL); + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - tkwin2 = Tk_NameToWindow(interp, argv[2], tkwin); - if (tkwin2 == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } packPtr = GetPacker(tkwin2); @@ -398,12 +447,8 @@ Tk_PackCmd(clientData, interp, argc, argv) Unlink(packPtr); Tk_UnmapWindow(packPtr->tkwin); } - } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": must be configure, forget, info, ", - "propagate, or slaves", (char *) NULL); - return TCL_ERROR; } + return TCL_OK; } @@ -513,11 +558,11 @@ ArrangePacking(clientData) * allocated to the current window. */ int x, y, width, height; /* These variables are used to hold the * actual geometry of the current window. */ - int intBWidth; /* Width of internal border in parent window, - * if any. */ int abort; /* May get set to non-zero to abort this * repacking operation. */ int borderX, borderY; + int borderTop, borderBtm; + int borderLeft, borderRight; int maxWidth, maxHeight, tmp; masterPtr->flags &= ~REQUESTED_REPACK; @@ -564,8 +609,10 @@ ArrangePacking(clientData) * maxHeight - Same as maxWidth, except keeps height info. */ - intBWidth = Tk_InternalBorderWidth(masterPtr->tkwin); - width = height = maxWidth = maxHeight = 2*intBWidth; + width = maxWidth = Tk_InternalBorderLeft(masterPtr->tkwin) + + Tk_InternalBorderRight(masterPtr->tkwin); + height = maxHeight = Tk_InternalBorderTop(masterPtr->tkwin) + + Tk_InternalBorderBottom(masterPtr->tkwin); for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; slavePtr = slavePtr->nextPtr) { if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) { @@ -593,6 +640,13 @@ ArrangePacking(clientData) maxHeight = height; } + if (maxWidth < Tk_MinReqWidth(masterPtr->tkwin)) { + maxWidth = Tk_MinReqWidth(masterPtr->tkwin); + } + if (maxHeight < Tk_MinReqHeight(masterPtr->tkwin)) { + maxHeight = Tk_MinReqHeight(masterPtr->tkwin); + } + /* * If the total amount of space needed in the parent window has * changed, and if we're propagating geometry information, then @@ -621,9 +675,14 @@ ArrangePacking(clientData) * frame, depending on anchor. */ - cavityX = cavityY = x = y = intBWidth; - cavityWidth = Tk_Width(masterPtr->tkwin) - 2*intBWidth; - cavityHeight = Tk_Height(masterPtr->tkwin) - 2*intBWidth; + cavityX = x = Tk_InternalBorderLeft(masterPtr->tkwin); + cavityY = y = Tk_InternalBorderTop(masterPtr->tkwin); + cavityWidth = Tk_Width(masterPtr->tkwin) - + Tk_InternalBorderLeft(masterPtr->tkwin) - + Tk_InternalBorderRight(masterPtr->tkwin); + cavityHeight = Tk_Height(masterPtr->tkwin) - + Tk_InternalBorderTop(masterPtr->tkwin) - + Tk_InternalBorderBottom(masterPtr->tkwin); for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; slavePtr = slavePtr->nextPtr) { if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) { @@ -678,9 +737,15 @@ ArrangePacking(clientData) if (slavePtr->flags & OLD_STYLE) { borderX = borderY = 0; + borderTop = borderBtm = 0; + borderLeft = borderRight = 0; } else { borderX = slavePtr->padX; borderY = slavePtr->padY; + borderLeft = slavePtr->padLeft; + borderRight = borderX - borderLeft; + borderTop = slavePtr->padTop; + borderBtm = borderY - borderTop; } width = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw + slavePtr->iPadX; @@ -694,44 +759,42 @@ ArrangePacking(clientData) || (height > (frameHeight - borderY))) { height = frameHeight - borderY; } - borderX /= 2; - borderY /= 2; switch (slavePtr->anchor) { case TK_ANCHOR_N: - x = frameX + (frameWidth - width)/2; - y = frameY + borderY; + x = frameX + (borderLeft + frameWidth - width - borderRight)/2; + y = frameY + borderTop; break; case TK_ANCHOR_NE: - x = frameX + frameWidth - width - borderX; - y = frameY + borderY; + x = frameX + frameWidth - width - borderRight; + y = frameY + borderTop; break; case TK_ANCHOR_E: - x = frameX + frameWidth - width - borderX; - y = frameY + (frameHeight - height)/2; + x = frameX + frameWidth - width - borderRight; + y = frameY + (borderTop + frameHeight - height - borderBtm)/2; break; case TK_ANCHOR_SE: - x = frameX + frameWidth - width - borderX; - y = frameY + frameHeight - height - borderY; + x = frameX + frameWidth - width - borderRight; + y = frameY + frameHeight - height - borderBtm; break; case TK_ANCHOR_S: - x = frameX + (frameWidth - width)/2; - y = frameY + frameHeight - height - borderY; + x = frameX + (borderLeft + frameWidth - width - borderRight)/2; + y = frameY + frameHeight - height - borderBtm; break; case TK_ANCHOR_SW: - x = frameX + borderX; - y = frameY + frameHeight - height - borderY; + x = frameX + borderLeft; + y = frameY + frameHeight - height - borderBtm; break; case TK_ANCHOR_W: - x = frameX + borderX; - y = frameY + (frameHeight - height)/2; + x = frameX + borderLeft; + y = frameY + (borderTop + frameHeight - height - borderBtm)/2; break; case TK_ANCHOR_NW: - x = frameX + borderX; - y = frameY + borderY; + x = frameX + borderLeft; + y = frameY + borderTop; break; case TK_ANCHOR_CENTER: - x = frameX + (frameWidth - width)/2; - y = frameY + (frameHeight - height)/2; + x = frameX + (borderLeft + frameWidth - width - borderRight)/2; + y = frameY + (borderTop + frameHeight - height - borderBtm)/2; break; default: panic("bad frame factor in ArrangePacking"); @@ -969,6 +1032,7 @@ GetPacker(tkwin) packPtr->side = TOP; packPtr->anchor = TK_ANCHOR_CENTER; packPtr->padX = packPtr->padY = 0; + packPtr->padLeft = packPtr->padTop = 0; packPtr->iPadX = packPtr->iPadY = 0; packPtr->doubleBw = 2*Tk_Changes(tkwin)->border_width; packPtr->abortPtr = NULL; @@ -979,6 +1043,86 @@ GetPacker(tkwin) return packPtr; } +/* + *-------------------------------------------------------------- + * + * TkParsePadAmount -- + * + * This procedure parses a padding specification and returns + * the appropriate padding values. A padding specification can + * be either a single pixel width, or a list of two pixel widths. + * If a single pixel width, the amount specified is used for + * padding on both sides. If two amounts are specified, then + * they specify the left/right or top/bottom padding. + * + * Results: + * A standard Tcl return value. + * + * Side effects: + * An error message is written to the interpreter is something + * is not right. + * + *-------------------------------------------------------------- + */ + +int +TkParsePadAmount(interp, tkwin, specObj, halfPtr, allPtr) + Tcl_Interp *interp; /* Interpreter for error reporting. */ + Tk_Window tkwin; /* A window. Needed by Tk_GetPixels() */ + Tcl_Obj *specObj; /* The argument to "-padx", "-pady", "-ipadx", + * or "-ipady". The thing to be parsed. */ + int *halfPtr; /* Write the left/top part of padding here */ + int *allPtr; /* Write the total padding here */ +{ + char *secondPart; /* The second pixel amount of the list */ + char *separator = 0; /* Separator between 1st and 2nd pixel widths */ + int sepChar = 0; /* Character used as the separator */ + int firstInt, secondInt; /* The two components of the padding */ + char *padSpec = Tcl_GetString(specObj); + + for (secondPart=padSpec; + (*secondPart != '\0') && !isspace(UCHAR(*secondPart)); + secondPart++) + { /* Do nothing */ } + if (*secondPart != '\0') { + separator = secondPart; + sepChar = *secondPart; + *secondPart = '\0'; + secondPart++; + while ( isspace(UCHAR(*secondPart)) ) { + secondPart++; + } + if (*secondPart == '\0'){ + secondPart = 0; + *separator = sepChar; + } + } else { + secondPart = 0; + } + if ((Tk_GetPixels(interp, tkwin, padSpec, &firstInt) != TCL_OK) || + (firstInt < 0)) { + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "bad pad value \"", padSpec, + "\": must be positive screen distance", (char *) NULL); + return TCL_ERROR; + } + if (secondPart) { + if ((Tk_GetPixels(interp, tkwin, secondPart, &secondInt) != TCL_OK) || + (secondInt < 0)) { + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "bad 2nd pad value \"", secondPart, + "\": must be positive screen distance", (char *) NULL); + return TCL_ERROR; + } + *separator = sepChar; + } else { + secondInt = firstInt; + } + if (halfPtr != 0) *halfPtr = firstInt; + *allPtr = firstInt + secondInt; + return TCL_OK; +} + /* *-------------------------------------------------------------- * @@ -998,22 +1142,22 @@ GetPacker(tkwin) */ static int -PackAfter(interp, prevPtr, masterPtr, argc, argv) +PackAfter(interp, prevPtr, masterPtr, objc, objv) Tcl_Interp *interp; /* Interpreter for error reporting. */ Packer *prevPtr; /* Pack windows in argv just after this * window; NULL means pack as first * child of masterPtr. */ Packer *masterPtr; /* Master in which to pack windows. */ - int argc; /* Number of elements in argv. */ - char **argv; /* Array of lists, each containing 2 + int objc; /* Number of elements in objv. */ + Tcl_Obj *CONST objv[]; /* Array of lists, each containing 2 * elements: window name and side * against which to pack. */ { register Packer *packPtr; Tk_Window tkwin, ancestor, parent; - size_t length; - char **options; - int index, tmp, optionCount, c; + int length; + Tcl_Obj **options; + int index, optionCount, c; /* * Iterate over all of the window specifiers, each consisting of @@ -1022,10 +1166,10 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv) * "padx 20". */ - for ( ; argc > 0; argc -= 2, argv += 2, prevPtr = packPtr) { - if (argc < 2) { + for ( ; objc > 0; objc -= 2, objv += 2, prevPtr = packPtr) { + if (objc < 2) { Tcl_AppendResult(interp, "wrong # args: window \"", - argv[0], "\" should be followed by options", + Tcl_GetString(objv[0]), "\" should be followed by options", (char *) NULL); return TCL_ERROR; } @@ -1036,8 +1180,8 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv) * or a descendant of its parent. */ - tkwin = Tk_NameToWindow(interp, argv[0], masterPtr->tkwin); - if (tkwin == NULL) { + if (TkGetWindowFromObj(interp, masterPtr->tkwin, objv[0], &tkwin) + != TCL_OK) { return TCL_ERROR; } @@ -1046,15 +1190,15 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv) if (ancestor == parent) { break; } - if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_LEVEL) { + if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_HIERARCHY) { badWindow: - Tcl_AppendResult(interp, "can't pack ", argv[0], + Tcl_AppendResult(interp, "can't pack ", Tcl_GetString(objv[0]), " inside ", Tk_PathName(masterPtr->tkwin), (char *) NULL); return TCL_ERROR; } } - if (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_LEVEL) { + if (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY) { goto badWindow; } if (tkwin == masterPtr->tkwin) { @@ -1066,35 +1210,37 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv) * Process options for this window. */ - if (Tcl_SplitList(interp, argv[1], &optionCount, &options) != TCL_OK) { + if (Tcl_ListObjGetElements(interp, objv[1], &optionCount, &options) + != TCL_OK) { return TCL_ERROR; } packPtr->side = TOP; packPtr->anchor = TK_ANCHOR_CENTER; packPtr->padX = packPtr->padY = 0; + packPtr->padLeft = packPtr->padTop = 0; packPtr->iPadX = packPtr->iPadY = 0; packPtr->flags &= ~(FILLX|FILLY|EXPAND); packPtr->flags |= OLD_STYLE; for (index = 0 ; index < optionCount; index++) { - char *curOpt = options[index]; + Tcl_Obj *curOptPtr = options[index]; + char *curOpt = Tcl_GetStringFromObj(curOptPtr, (int *) &length); c = curOpt[0]; - length = strlen(curOpt); if ((c == 't') - && (strncmp(curOpt, "top", length)) == 0) { + && (strncmp(curOpt, "top", (size_t) length)) == 0) { packPtr->side = TOP; } else if ((c == 'b') - && (strncmp(curOpt, "bottom", length)) == 0) { + && (strncmp(curOpt, "bottom", (size_t) length)) == 0) { packPtr->side = BOTTOM; } else if ((c == 'l') - && (strncmp(curOpt, "left", length)) == 0) { + && (strncmp(curOpt, "left", (size_t) length)) == 0) { packPtr->side = LEFT; } else if ((c == 'r') - && (strncmp(curOpt, "right", length)) == 0) { + && (strncmp(curOpt, "right", (size_t) length)) == 0) { packPtr->side = RIGHT; } else if ((c == 'e') - && (strncmp(curOpt, "expand", length)) == 0) { + && (strncmp(curOpt, "expand", (size_t) length)) == 0) { packPtr->flags |= EXPAND; } else if ((c == 'f') && (strcmp(curOpt, "fill")) == 0) { @@ -1109,42 +1255,39 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv) Tcl_AppendResult(interp, "wrong # args: \"", curOpt, "\" option must be followed by screen distance", (char *) NULL); - goto error; + return TCL_ERROR; } - if ((Tk_GetPixels(interp, tkwin, options[index+1], &tmp) - != TCL_OK) || (tmp < 0)) { - badPad: - Tcl_AppendResult(interp, "bad pad value \"", - options[index+1], - "\": must be positive screen distance", - (char *) NULL); - goto error; + if (TkParsePadAmount(interp, tkwin, options[index+1], + &packPtr->padLeft, &packPtr->padX) != TCL_OK) { + return TCL_ERROR; } - packPtr->padX = tmp; + packPtr->padX /= 2; + packPtr->padLeft /= 2; packPtr->iPadX = 0; index++; } else if ((c == 'p') && (strcmp(curOpt, "pady")) == 0) { if (optionCount < (index+2)) { goto missingPad; } - if ((Tk_GetPixels(interp, tkwin, options[index+1], &tmp) - != TCL_OK) || (tmp < 0)) { - goto badPad; + if (TkParsePadAmount(interp, tkwin, options[index+1], + &packPtr->padTop, &packPtr->padY) != TCL_OK) { + return TCL_ERROR; } - packPtr->padY = tmp; + packPtr->padY /= 2; + packPtr->padTop /= 2; packPtr->iPadY = 0; index++; } else if ((c == 'f') && (length > 1) - && (strncmp(curOpt, "frame", length) == 0)) { + && (strncmp(curOpt, "frame", (size_t) length) == 0)) { if (optionCount < (index+2)) { Tcl_AppendResult(interp, "wrong # args: \"frame\" ", "option must be followed by anchor point", (char *) NULL); - goto error; + return TCL_ERROR; } - if (Tk_GetAnchor(interp, options[index+1], + if (Tk_GetAnchorFromObj(interp, options[index+1], &packPtr->anchor) != TCL_OK) { - goto error; + return TCL_ERROR; } index++; } else { @@ -1152,7 +1295,7 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv) "\": should be top, bottom, left, right, ", "expand, fill, fillx, filly, padx, pady, or frame", (char *) NULL); - goto error; + return TCL_ERROR; } } @@ -1188,7 +1331,6 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv) } Tk_ManageGeometry(tkwin, &packerType, (ClientData) packPtr); } - ckfree((char *) options); } /* @@ -1204,10 +1346,6 @@ PackAfter(interp, prevPtr, masterPtr, argc, argv) Tcl_DoWhenIdle(ArrangePacking, (ClientData) masterPtr); } return TCL_OK; - - error: - ckfree((char *) options); - return TCL_ERROR; } /* @@ -1399,12 +1537,12 @@ PackStructureProc(clientData, eventPtr) */ static int -ConfigureSlaves(interp, tkwin, argc, argv) +ConfigureSlaves(interp, tkwin, objc, objv) Tcl_Interp *interp; /* Interpreter for error reporting. */ Tk_Window tkwin; /* Any window in application containing * slaves. Used to look up slave names. */ - int argc; /* Number of elements in argv. */ - char *argv[]; /* Argument strings: contains one or more + int objc; /* Number of elements in argv. */ + Tcl_Obj *CONST objv[]; /* Argument objects: contains one or more * window names followed by any number * of "option value" pairs. Caller must * make sure that there is at least one @@ -1412,15 +1550,23 @@ ConfigureSlaves(interp, tkwin, argc, argv) { Packer *masterPtr, *slavePtr, *prevPtr, *otherPtr; Tk_Window other, slave, parent, ancestor; - int i, j, numWindows, c, tmp, positionGiven; - size_t length; + int i, j, numWindows, tmp, positionGiven; + char *string; + static CONST char *optionStrings[] = { + "-after", "-anchor", "-before", "-expand", "-fill", + "-in", "-ipadx", "-ipady", "-padx", "-pady", "-side", (char *) NULL }; + enum options { + CONF_AFTER, CONF_ANCHOR, CONF_BEFORE, CONF_EXPAND, CONF_FILL, + CONF_IN, CONF_IPADX, CONF_IPADY, CONF_PADX, CONF_PADY, CONF_SIDE }; + int index, side; /* * Find out how many windows are specified. */ - for (numWindows = 0; numWindows < argc; numWindows++) { - if (argv[numWindows][0] != '.') { + for (numWindows = 0; numWindows < objc; numWindows++) { + string = Tcl_GetString(objv[numWindows]); + if (string[0] != '.') { break; } } @@ -1440,12 +1586,11 @@ ConfigureSlaves(interp, tkwin, argc, argv) prevPtr = NULL; positionGiven = 0; for (j = 0; j < numWindows; j++) { - slave = Tk_NameToWindow(interp, argv[j], tkwin); - if (slave == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) { return TCL_ERROR; } - if (Tk_IsTopLevel(slave)) { - Tcl_AppendResult(interp, "can't pack \"", argv[j], + if (Tk_TopWinHierarchy(slave)) { + Tcl_AppendResult(interp, "can't pack \"", Tcl_GetString(objv[j]), "\": it's a top-level window", (char *) NULL); return TCL_ERROR; } @@ -1462,49 +1607,48 @@ ConfigureSlaves(interp, tkwin, argc, argv) slavePtr->side = TOP; slavePtr->anchor = TK_ANCHOR_CENTER; slavePtr->padX = slavePtr->padY = 0; + slavePtr->padLeft = slavePtr->padTop = 0; slavePtr->iPadX = slavePtr->iPadY = 0; slavePtr->flags &= ~(FILLX|FILLY|EXPAND); } - for (i = numWindows; i < argc; i+=2) { - if ((i+2) > argc) { - Tcl_AppendResult(interp, "extra option \"", argv[i], + for (i = numWindows; i < objc; i+=2) { + if ((i+2) > objc) { + Tcl_AppendResult(interp, "extra option \"", + Tcl_GetString(objv[i]), "\" (option with no value?)", (char *) NULL); return TCL_ERROR; } - length = strlen(argv[i]); - if (length < 2) { - goto badOption; + if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", + 0, &index) != TCL_OK) { + return TCL_ERROR; } - c = argv[i][1]; - if ((c == 'a') && (strncmp(argv[i], "-after", length) == 0) - && (length >= 2)) { + if (index == CONF_AFTER) { if (j == 0) { - other = Tk_NameToWindow(interp, argv[i+1], tkwin); - if (other == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) + != TCL_OK) { return TCL_ERROR; } prevPtr = GetPacker(other); if (prevPtr->masterPtr == NULL) { notPacked: - Tcl_AppendResult(interp, "window \"", argv[i+1], + Tcl_AppendResult(interp, "window \"", + Tcl_GetString(objv[i+1]), "\" isn't packed", (char *) NULL); return TCL_ERROR; } masterPtr = prevPtr->masterPtr; positionGiven = 1; } - } else if ((c == 'a') && (strncmp(argv[i], "-anchor", length) == 0) - && (length >= 2)) { - if (Tk_GetAnchor(interp, argv[i+1], &slavePtr->anchor) + } else if (index == CONF_ANCHOR) { + if (Tk_GetAnchorFromObj(interp, objv[i+1], &slavePtr->anchor) != TCL_OK) { return TCL_ERROR; } - } else if ((c == 'b') - && (strncmp(argv[i], "-before", length) == 0)) { + } else if (index == CONF_BEFORE) { if (j == 0) { - other = Tk_NameToWindow(interp, argv[i+1], tkwin); - if (other == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) + != TCL_OK) { return TCL_ERROR; } otherPtr = GetPacker(other); @@ -1522,33 +1666,33 @@ ConfigureSlaves(interp, tkwin, argc, argv) } positionGiven = 1; } - } else if ((c == 'e') - && (strncmp(argv[i], "-expand", length) == 0)) { - if (Tcl_GetBoolean(interp, argv[i+1], &tmp) != TCL_OK) { + } else if (index == CONF_EXPAND) { + if (Tcl_GetBooleanFromObj(interp, objv[i+1], &tmp) != TCL_OK) { return TCL_ERROR; } slavePtr->flags &= ~EXPAND; if (tmp) { slavePtr->flags |= EXPAND; } - } else if ((c == 'f') && (strncmp(argv[i], "-fill", length) == 0)) { - if (strcmp(argv[i+1], "none") == 0) { + } else if (index == CONF_FILL) { + string = Tcl_GetString(objv[i+1]); + if (strcmp(string, "none") == 0) { slavePtr->flags &= ~(FILLX|FILLY); - } else if (strcmp(argv[i+1], "x") == 0) { + } else if (strcmp(string, "x") == 0) { slavePtr->flags = (slavePtr->flags & ~FILLY) | FILLX; - } else if (strcmp(argv[i+1], "y") == 0) { + } else if (strcmp(string, "y") == 0) { slavePtr->flags = (slavePtr->flags & ~FILLX) | FILLY; - } else if (strcmp(argv[i+1], "both") == 0) { + } else if (strcmp(string, "both") == 0) { slavePtr->flags |= FILLX|FILLY; } else { - Tcl_AppendResult(interp, "bad fill style \"", argv[i+1], + Tcl_AppendResult(interp, "bad fill style \"", string, "\": must be none, x, y, or both", (char *) NULL); return TCL_ERROR; } - } else if ((c == 'i') && (strcmp(argv[i], "-in") == 0)) { + } else if (index == CONF_IN) { if (j == 0) { - other = Tk_NameToWindow(interp, argv[i+1], tkwin); - if (other == NULL) { + if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) + != TCL_OK) { return TCL_ERROR; } masterPtr = GetPacker(other); @@ -1560,58 +1704,46 @@ ConfigureSlaves(interp, tkwin, argc, argv) } positionGiven = 1; } - } else if ((c == 'i') && (strcmp(argv[i], "-ipadx") == 0)) { - if ((Tk_GetPixels(interp, slave, argv[i+1], &tmp) != TCL_OK) + } else if (index == CONF_IPADX) { + if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) + != TCL_OK) || (tmp < 0)) { - badPad: Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad pad value \"", argv[i+1], + Tcl_AppendResult(interp, "bad ipadx value \"", + Tcl_GetString(objv[i+1]), "\": must be positive screen distance", (char *) NULL); return TCL_ERROR; } - slavePtr->iPadX = tmp*2; - } else if ((c == 'i') && (strcmp(argv[i], "-ipady") == 0)) { - if ((Tk_GetPixels(interp, slave, argv[i+1], &tmp) != TCL_OK) - || (tmp< 0)) { - goto badPad; + slavePtr->iPadX = tmp * 2; + } else if (index == CONF_IPADY) { + if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) + != TCL_OK) + || (tmp < 0)) { + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "bad ipady value \"", + Tcl_GetString(objv[i+1]), + "\": must be positive screen distance", + (char *) NULL); + return TCL_ERROR; } - slavePtr->iPadY = tmp*2; - } else if ((c == 'p') && (strcmp(argv[i], "-padx") == 0)) { - if ((Tk_GetPixels(interp, slave, argv[i+1], &tmp) != TCL_OK) - || (tmp< 0)) { - goto badPad; + slavePtr->iPadY = tmp * 2; + } else if (index == CONF_PADX) { + if (TkParsePadAmount(interp, slave, objv[i+1], + &slavePtr->padLeft, &slavePtr->padX) != TCL_OK) { + return TCL_ERROR; } - slavePtr->padX = tmp*2; - } else if ((c == 'p') && (strcmp(argv[i], "-pady") == 0)) { - if ((Tk_GetPixels(interp, slave, argv[i+1], &tmp) != TCL_OK) - || (tmp< 0)) { - goto badPad; + } else if (index == CONF_PADY) { + if (TkParsePadAmount(interp, slave, objv[i+1], + &slavePtr->padTop, &slavePtr->padY) != TCL_OK) { + return TCL_ERROR; } - slavePtr->padY = tmp*2; - } else if ((c == 's') && (strncmp(argv[i], "-side", length) == 0)) { - c = argv[i+1][0]; - if ((c == 't') && (strcmp(argv[i+1], "top") == 0)) { - slavePtr->side = TOP; - } else if ((c == 'b') && (strcmp(argv[i+1], "bottom") == 0)) { - slavePtr->side = BOTTOM; - } else if ((c == 'l') && (strcmp(argv[i+1], "left") == 0)) { - slavePtr->side = LEFT; - } else if ((c == 'r') && (strcmp(argv[i+1], "right") == 0)) { - slavePtr->side = RIGHT; - } else { - Tcl_AppendResult(interp, "bad side \"", argv[i+1], - "\": must be top, bottom, left, or right", - (char *) NULL); + } else if (index == CONF_SIDE) { + if (Tcl_GetIndexFromObj(interp, objv[i+1], sideNames, "side", + TCL_EXACT, &side) != TCL_OK) { return TCL_ERROR; } - } else { - badOption: - Tcl_AppendResult(interp, "unknown or ambiguous option \"", - argv[i], "\": must be -after, -anchor, -before, ", - "-expand, -fill, -in, -ipadx, -ipady, -padx, ", - "-pady, or -side", (char *) NULL); - return TCL_ERROR; + slavePtr->side = side; } } @@ -1663,15 +1795,15 @@ ConfigureSlaves(interp, tkwin, argc, argv) if (ancestor == parent) { break; } - if (Tk_IsTopLevel(ancestor)) { - Tcl_AppendResult(interp, "can't pack ", argv[j], + if (Tk_TopWinHierarchy(ancestor)) { + Tcl_AppendResult(interp, "can't pack ", Tcl_GetString(objv[j]), " inside ", Tk_PathName(masterPtr->tkwin), (char *) NULL); return TCL_ERROR; } } if (slave == masterPtr->tkwin) { - Tcl_AppendResult(interp, "can't pack ", argv[j], + Tcl_AppendResult(interp, "can't pack ", Tcl_GetString(objv[j]), " inside itself", (char *) NULL); return TCL_ERROR; } @@ -1717,5 +1849,3 @@ ConfigureSlaves(interp, tkwin, argc, argv) } return TCL_OK; } - - diff --git a/tk/generic/tkPanedWindow.c b/tk/generic/tkPanedWindow.c new file mode 100644 index 00000000000..fffe111673e --- /dev/null +++ b/tk/generic/tkPanedWindow.c @@ -0,0 +1,2752 @@ +/* + * tkPanedWindow.c -- + * + * This module implements "paned window" widgets that are object + * based. A "paned window" is a widget that manages the geometry for + * some number of other widgets, placing a movable "sash" between them, + * which can be used to alter the relative sizes of adjacent widgets. + * + * Copyright (c) 1997 Sun Microsystems, Inc. + * Copyright (c) 2000 Ajuba Solutions. + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * RCS: @(#) $Id$ + */ + +#include "tkPort.h" +#include "default.h" +#include "tkInt.h" + +/* Flag values for "sticky"ness The 16 combinations subsume the packer's + * notion of anchor and fill. + * + * STICK_NORTH This window sticks to the top of its cavity. + * STICK_EAST This window sticks to the right edge of its cavity. + * STICK_SOUTH This window sticks to the bottom of its cavity. + * STICK_WEST This window sticks to the left edge of its cavity. + */ + +#define STICK_NORTH 1 +#define STICK_EAST 2 +#define STICK_SOUTH 4 +#define STICK_WEST 8 +/* + * The following table defines the legal values for the -orient option. + */ + +static char *orientStrings[] = { + "horizontal", "vertical", (char *) NULL +}; + +enum orient { ORIENT_HORIZONTAL, ORIENT_VERTICAL }; + +typedef struct { + Tk_OptionTable pwOptions; /* Token for paned window option table. */ + Tk_OptionTable slaveOpts; /* Token for slave cget option table. */ +} OptionTables; + +/* + * One structure of the following type is kept for each window + * managed by a paned window widget. + */ + +typedef struct Slave { + Tk_Window tkwin; /* Window being managed. */ + + int minSize; /* Minimum size of this pane, on the + * relevant axis, in pixels. */ + int padx; /* Additional padding requested for + * slave, in the x dimension. */ + int pady; /* Additional padding requested for + * slave, in the y dimension. */ + Tcl_Obj *widthPtr, *heightPtr; /* Tcl_Obj rep's of slave width/height, + * to allow for null values. */ + int width; /* Slave width. */ + int height; /* Slave height. */ + int sticky; /* Sticky string. */ + int x, y; /* Coordinates of the widget. */ + int paneWidth, paneHeight; /* Pane dimensions (may be different + * from slave width/height). */ + int sashx, sashy; /* Coordinates of the sash of the + * right or bottom of this pane. */ + int markx, marky; /* Coordinates of the last mark set + * for the sash. */ + int handlex, handley; /* Coordinates of the sash handle. */ + struct PanedWindow *masterPtr; /* Paned window managing the window. */ + Tk_Window after; /* Placeholder for parsing options. */ + Tk_Window before; /* Placeholder for parsing options. */ +} Slave; + +/* + * A data structure of the following type is kept for each paned window + * widget managed by this file: + */ + +typedef struct PanedWindow { + Tk_Window tkwin; /* Window that embodies the paned window. */ + Tk_Window proxywin; /* Window for the resizing proxy. */ + Display *display; /* X's token for the window's display. */ + Tcl_Interp *interp; /* Interpreter associated with widget. */ + Tcl_Command widgetCmd; /* Token for square's widget command. */ + Tk_OptionTable optionTable; /* Token representing the configuration + * specifications. */ + Tk_OptionTable slaveOpts; /* Token for slave cget table. */ + Tk_3DBorder background; /* Background color. */ + int borderWidth; /* Value of -borderwidth option. */ + int relief; /* 3D border effect (TK_RELIEF_RAISED, etc) */ + Tcl_Obj *widthPtr; /* Tcl_Obj rep for width. */ + Tcl_Obj *heightPtr; /* Tcl_Obj rep for height. */ + int width, height; /* Width and height of the widget. */ + enum orient orient; /* Orientation of the widget. */ + Tk_Cursor cursor; /* Current cursor for window, or None. */ + int resizeOpaque; /* Boolean indicating whether resize should be + * opaque or rubberband style. */ + + int sashRelief; /* Relief used to draw sash. */ + int sashWidth; /* Width of each sash, in pixels. */ + Tcl_Obj *sashWidthPtr; /* Tcl_Obj rep for sash width. */ + int sashPad; /* Additional padding around each sash. */ + Tcl_Obj *sashPadPtr; /* Tcl_Obj rep for sash padding. */ + int showHandle; /* Boolean indicating whether sash handles + * should be drawn. */ + int handleSize; /* Size of one side of a sash handle (handles + * are square), in pixels. */ + int handlePad; /* Distance from border to draw handle. */ + Tcl_Obj *handleSizePtr; /* Tcl_Obj rep for handle size. */ + Tk_Cursor sashCursor; /* Cursor used when mouse is above a sash. */ + + GC gc; /* Graphics context for copying from + * off-screen pixmap onto screen. */ + int proxyx, proxyy; /* Proxy x,y coordinates. */ + Slave **slaves; /* Pointer to array of Slaves. */ + int numSlaves; /* Number of slaves. */ + int sizeofSlaves; /* Number of elements in the slaves array. */ + int flags; /* Flags for widget; see below. */ +} PanedWindow; + +/* + * Flags used for paned windows: + * + * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has + * been queued to redraw this window. + * + * WIDGET_DELETED: Non-zero means that the paned window has + * been, or is in the process of being, deleted. + * + * RESIZE_PENDING: Non-zero means that the window might need to + * change its size (or the size of its panes) + * because of a change in the size of one of its + * children. + */ + +#define REDRAW_PENDING 0x0001 +#define WIDGET_DELETED 0x0002 +#define REQUESTED_RELAYOUT 0x0004 +#define RECOMPUTE_GEOMETRY 0x0008 +#define PROXY_REDRAW_PENDING 0x0010 +#define RESIZE_PENDING 0x0020 + +/* + * Forward declarations for procedures defined later in this file: + */ + +int Tk_PanedWindowObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[])); +static void PanedWindowCmdDeletedProc _ANSI_ARGS_((ClientData clientData)); +static int ConfigurePanedWindow _ANSI_ARGS_((Tcl_Interp *interp, + PanedWindow *pwPtr, int objc, Tcl_Obj *CONST objv[])); +static void DestroyPanedWindow _ANSI_ARGS_((PanedWindow *pwPtr)); +static void DisplayPanedWindow _ANSI_ARGS_((ClientData clientData)); +static void PanedWindowEventProc _ANSI_ARGS_((ClientData clientData, + XEvent *eventPtr)); +static void ProxyWindowEventProc _ANSI_ARGS_((ClientData clientData, + XEvent *eventPtr)); +static void DisplayProxyWindow _ANSI_ARGS_((ClientData clientData)); +void PanedWindowWorldChanged _ANSI_ARGS_((ClientData instanceData)); +static int PanedWindowWidgetObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *, int objc, Tcl_Obj * CONST objv[])); +static void PanedWindowLostSlaveProc _ANSI_ARGS_((ClientData clientData, + Tk_Window tkwin)); +static void PanedWindowReqProc _ANSI_ARGS_((ClientData clientData, + Tk_Window tkwin)); +static void ArrangePanes _ANSI_ARGS_((ClientData clientData)); +static void Unlink _ANSI_ARGS_((Slave *slavePtr)); +static Slave * GetPane _ANSI_ARGS_((PanedWindow *pwPtr, Tk_Window tkwin)); +static void SlaveStructureProc _ANSI_ARGS_((ClientData clientData, + XEvent *eventPtr)); +static int PanedWindowSashCommand _ANSI_ARGS_((PanedWindow *pwPtr, + Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[])); +static int PanedWindowProxyCommand _ANSI_ARGS_((PanedWindow *pwPtr, + Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[])); +static void ComputeGeometry _ANSI_ARGS_((PanedWindow *pwPtr)); +static int ConfigureSlaves _ANSI_ARGS_((PanedWindow *pwPtr, + Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[])); +static void DestroyOptionTables _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp)); +static int SetSticky _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, Tk_Window tkwin, + Tcl_Obj **value, char *recordPtr, int internalOffset, + char *oldInternalPtr, int flags)); +static Tcl_Obj *GetSticky _ANSI_ARGS_((ClientData clientData, Tk_Window tkwin, + char *recordPtr, int internalOffset)); +static void RestoreSticky _ANSI_ARGS_((ClientData clientData, + Tk_Window tkwin, char *internalPtr, + char *oldInternalPtr)); +static void AdjustForSticky _ANSI_ARGS_((int sticky, int cavityWidth, + int cavityHeight, int *xPtr, int *yPtr, + int *slaveWidthPtr, int *slaveHeightPtr)); +static void MoveSash _ANSI_ARGS_((PanedWindow *pwPtr, int sash, int diff)); +static int ObjectIsEmpty _ANSI_ARGS_((Tcl_Obj *objPtr)); +static char * ComputeSlotAddress _ANSI_ARGS_((char *recordPtr, int offset)); +static int PanedWindowIdentifyCoords _ANSI_ARGS_((PanedWindow *pwPtr, + Tcl_Interp *interp, int x, int y)); + +#define ValidSashIndex(pwPtr, sash) \ + (((sash) >= 0) && ((sash) < (pwPtr)->numSlaves)) + +static Tk_GeomMgr panedWindowMgrType = { + "panedwindow", /* name */ + PanedWindowReqProc, /* requestProc */ + PanedWindowLostSlaveProc, /* lostSlaveProc */ +}; + +/* + * Information used for objv parsing. + */ + +#define GEOMETRY 0x0001 + +/* + * The following structure contains pointers to functions used for processing + * the custom "-sticky" option for slave windows. + */ + +static Tk_ObjCustomOption stickyOption = { + "sticky", /* name */ + SetSticky, /* setProc */ + GetSticky, /* getProc */ + RestoreSticky, /* restoreProc */ + (Tk_CustomOptionFreeProc *)NULL, /* freeProc */ + 0 +}; + +static Tk_OptionSpec optionSpecs[] = { + {TK_OPTION_BORDER, "-background", "background", "Background", + DEF_PANEDWINDOW_BG_COLOR, -1, Tk_Offset(PanedWindow, background), 0, + (ClientData) DEF_PANEDWINDOW_BG_MONO}, + {TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, + (char *) NULL, 0, -1, 0, (ClientData) "-borderwidth"}, + {TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, + (char *) NULL, 0, -1, 0, (ClientData) "-background"}, + {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", + DEF_PANEDWINDOW_BORDERWIDTH, -1, Tk_Offset(PanedWindow, borderWidth), + 0, 0, GEOMETRY}, + {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", + DEF_PANEDWINDOW_CURSOR, -1, Tk_Offset(PanedWindow, cursor), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_PIXELS, "-handlepad", "handlePad", "HandlePad", + DEF_PANEDWINDOW_HANDLEPAD, -1, Tk_Offset(PanedWindow, handlePad), + 0, 0}, + {TK_OPTION_PIXELS, "-handlesize", "handleSize", "HandleSize", + DEF_PANEDWINDOW_HANDLESIZE, Tk_Offset(PanedWindow, handleSizePtr), + Tk_Offset(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}, + {TK_OPTION_BOOLEAN, "-opaqueresize", "opaqueResize", "OpaqueResize", + DEF_PANEDWINDOW_OPAQUERESIZE, -1, + Tk_Offset(PanedWindow, resizeOpaque), 0, 0, 0}, + {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", + DEF_PANEDWINDOW_ORIENT, -1, Tk_Offset(PanedWindow, orient), + 0, (ClientData) orientStrings, GEOMETRY}, + {TK_OPTION_RELIEF, "-relief", "relief", "Relief", + DEF_PANEDWINDOW_RELIEF, -1, Tk_Offset(PanedWindow, relief), 0, 0, 0}, + {TK_OPTION_CURSOR, "-sashcursor", "sashCursor", "Cursor", + DEF_PANEDWINDOW_SASHCURSOR, -1, Tk_Offset(PanedWindow, sashCursor), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_PIXELS, "-sashpad", "sashPad", "SashPad", + DEF_PANEDWINDOW_SASHPAD, -1, Tk_Offset(PanedWindow, sashPad), + 0, 0, GEOMETRY}, + {TK_OPTION_RELIEF, "-sashrelief", "sashRelief", "Relief", + DEF_PANEDWINDOW_SASHRELIEF, -1, Tk_Offset(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}, + {TK_OPTION_BOOLEAN, "-showhandle", "showHandle", "ShowHandle", + DEF_PANEDWINDOW_SHOWHANDLE, -1, Tk_Offset(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}, + {TK_OPTION_END} +}; + +static Tk_OptionSpec slaveOptionSpecs[] = { + {TK_OPTION_WINDOW, "-after", (char *) NULL, (char *) NULL, + DEF_PANEDWINDOW_PANE_AFTER, -1, Tk_Offset(Slave, after), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_WINDOW, "-before", (char *) NULL, (char *) NULL, + DEF_PANEDWINDOW_PANE_BEFORE, -1, Tk_Offset(Slave, before), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_PIXELS, "-height", (char *) NULL, (char *) NULL, + DEF_PANEDWINDOW_PANE_HEIGHT, Tk_Offset(Slave, heightPtr), + Tk_Offset(Slave, height), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_PIXELS, "-minsize", (char *) NULL, (char *) NULL, + DEF_PANEDWINDOW_PANE_MINSIZE, -1, Tk_Offset(Slave, minSize), 0, 0, 0}, + {TK_OPTION_PIXELS, "-padx", (char *) NULL, (char *) NULL, + DEF_PANEDWINDOW_PANE_PADX, -1, Tk_Offset(Slave, padx), 0, 0, 0}, + {TK_OPTION_PIXELS, "-pady", (char *) NULL, (char *) NULL, + DEF_PANEDWINDOW_PANE_PADY, -1, Tk_Offset(Slave, pady), 0, 0, 0}, + {TK_OPTION_CUSTOM, "-sticky", (char *) NULL, (char *) NULL, + DEF_PANEDWINDOW_PANE_STICKY, -1, Tk_Offset(Slave, sticky), 0, + (ClientData) &stickyOption, 0}, + {TK_OPTION_PIXELS, "-width", (char *) NULL, (char *) NULL, + DEF_PANEDWINDOW_PANE_WIDTH, Tk_Offset(Slave, widthPtr), + Tk_Offset(Slave, width), TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_END} +}; + + +/* + *-------------------------------------------------------------- + * + * Tk_PanedWindowObjCmd -- + * + * This procedure is invoked to process the "panedwindow" Tcl + * command. It creates a new "panedwindow" widget. + * + * Results: + * A standard Tcl result. + * + * Side effects: + * A new widget is created and configured. + * + *-------------------------------------------------------------- + */ + +int +Tk_PanedWindowObjCmd(clientData, interp, objc, objv) + ClientData clientData; /* NULL. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj * CONST objv[]; /* Argument objects. */ +{ + PanedWindow *pwPtr; + Tk_Window tkwin, parent; + OptionTables *pwOpts; + + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); + return TCL_ERROR; + } + + tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), + Tcl_GetStringFromObj(objv[1], NULL), (char *) NULL); + if (tkwin == NULL) { + return TCL_ERROR; + } + + pwOpts = (OptionTables *) + Tcl_GetAssocData(interp, "PanedWindowOptionTables", NULL); + if (pwOpts == NULL) { + /* + * The first time this procedure is invoked, the option tables will + * be NULL. We then create the option tables from the templates + * and store a pointer to the tables as the command's clinical so + * we'll have easy access to it in the future. + */ + pwOpts = (OptionTables *) ckalloc(sizeof(OptionTables)); + /* Set up an exit handler to free the optionTables struct */ + Tcl_SetAssocData(interp, "PanedWindowOptionTables", + DestroyOptionTables, (ClientData) pwOpts); + + /* Create the paned window option tables. */ + pwOpts->pwOptions = Tk_CreateOptionTable(interp, optionSpecs); + pwOpts->slaveOpts = Tk_CreateOptionTable(interp, slaveOptionSpecs); + } + + Tk_SetClass(tkwin, "Panedwindow"); + + /* + * Allocate and initialize the widget record. + */ + + pwPtr = (PanedWindow *) ckalloc(sizeof(PanedWindow)); + memset((void *)pwPtr, 0, (sizeof(PanedWindow))); + pwPtr->tkwin = tkwin; + pwPtr->display = Tk_Display(tkwin); + pwPtr->interp = interp; + pwPtr->widgetCmd = Tcl_CreateObjCommand(interp, + Tk_PathName(pwPtr->tkwin), PanedWindowWidgetObjCmd, + (ClientData) pwPtr, PanedWindowCmdDeletedProc); + pwPtr->optionTable = pwOpts->pwOptions; + pwPtr->slaveOpts = pwOpts->slaveOpts; + pwPtr->relief = TK_RELIEF_RAISED; + pwPtr->gc = None; + pwPtr->cursor = None; + pwPtr->sashCursor = None; + + if (Tk_InitOptions(interp, (char *) pwPtr, pwOpts->pwOptions, + tkwin) != TCL_OK) { + Tk_DestroyWindow(pwPtr->tkwin); + ckfree((char *) pwPtr); + return TCL_ERROR; + } + + Tk_CreateEventHandler(pwPtr->tkwin, ExposureMask|StructureNotifyMask, + PanedWindowEventProc, (ClientData) pwPtr); + + /* + * Find the toplevel ancestor of the panedwindow, and make a proxy + * win as a child of that window; this way the proxy can always float + * above slaves in the panedwindow. + */ + parent = Tk_Parent(pwPtr->tkwin); + while (!(Tk_IsTopLevel(parent))) { + parent = Tk_Parent(parent); + if (parent == NULL) { + parent = pwPtr->tkwin; + break; + } + } + + pwPtr->proxywin = Tk_CreateAnonymousWindow(interp, parent, (char *) NULL); + Tk_CreateEventHandler(pwPtr->proxywin, ExposureMask, ProxyWindowEventProc, + (ClientData) pwPtr); + + if (ConfigurePanedWindow(interp, pwPtr, objc - 2, objv + 2) != TCL_OK) { + Tk_DestroyWindow(pwPtr->tkwin); + Tk_DestroyWindow(pwPtr->proxywin); + ckfree((char *) pwPtr); + return TCL_ERROR; + } + + Tcl_SetStringObj(Tcl_GetObjResult(interp), Tk_PathName(pwPtr->tkwin), -1); + return TCL_OK; +} + +/* + *-------------------------------------------------------------- + * + * PanedWindowWidgetObjCmd -- + * + * This procedure is invoked to process the Tcl command + * that corresponds to a widget managed by this module. + * See the user documentation for details on what it does. + * + * Results: + * A standard Tcl result. + * + * Side effects: + * See the user documentation. + * + *-------------------------------------------------------------- + */ + +static int +PanedWindowWidgetObjCmd(clientData, interp, objc, objv) + ClientData clientData; /* Information about square widget. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj * CONST objv[]; /* Argument objects. */ +{ + PanedWindow *pwPtr = (PanedWindow *) clientData; + int result = TCL_OK; + static CONST char *optionStrings[] = {"add", "cget", "configure", "forget", + "identify", "panecget", + "paneconfigure", "panes", + "proxy", "sash", (char *) NULL}; + enum options { PW_ADD, PW_CGET, PW_CONFIGURE, PW_FORGET, PW_IDENTIFY, + PW_PANECGET, PW_PANECONFIGURE, PW_PANES, PW_PROXY, + PW_SASH }; + Tcl_Obj *resultObj; + int index, count, i, x, y; + Tk_Window tkwin; + Slave *slavePtr; + + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg...?"); + return TCL_ERROR; + } + + if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "command", + 0, &index) != TCL_OK) { + return TCL_ERROR; + } + + Tcl_Preserve((ClientData) pwPtr); + + switch ((enum options) index) { + case PW_ADD: { + if (objc < 3) { + Tcl_WrongNumArgs(interp, 2, objv, "widget ?widget ...?"); + result = TCL_ERROR; + break; + } + + result = ConfigureSlaves(pwPtr, interp, objc, objv); + break; + } + + case PW_CGET: { + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "option"); + result = TCL_ERROR; + break; + } + resultObj = Tk_GetOptionValue(interp, (char *) pwPtr, + pwPtr->optionTable, objv[2], pwPtr->tkwin); + if (resultObj == NULL) { + result = TCL_ERROR; + } else { + Tcl_SetObjResult(interp, resultObj); + } + break; + } + + case PW_CONFIGURE: { + resultObj = NULL; + if (objc <= 3) { + resultObj = Tk_GetOptionInfo(interp, (char *) pwPtr, + pwPtr->optionTable, + (objc == 3) ? objv[2] : (Tcl_Obj *) NULL, + pwPtr->tkwin); + if (resultObj == NULL) { + result = TCL_ERROR; + } else { + Tcl_SetObjResult(interp, resultObj); + } + } else { + result = ConfigurePanedWindow(interp, pwPtr, objc - 2, + objv + 2); + } + break; + } + + case PW_FORGET: { + Tk_Window slave; + int i; + + if (objc < 3) { + Tcl_WrongNumArgs(interp, 2, objv, "widget ?widget ...?"); + result = TCL_ERROR; + break; + } + + /* + * Clean up each window named in the arg list. + */ + for (count = 0, i = 2; i < objc; i++) { + slave = Tk_NameToWindow(interp, Tcl_GetString(objv[i]), + pwPtr->tkwin); + if (slave == NULL) { + continue; + } + slavePtr = GetPane(pwPtr, slave); + if ((slavePtr != NULL) && (slavePtr->masterPtr != NULL)) { + count++; + Tk_ManageGeometry(slave, (Tk_GeomMgr *) NULL, + (ClientData) NULL); + Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin); + Tk_DeleteEventHandler(slavePtr->tkwin, StructureNotifyMask, + SlaveStructureProc, (ClientData) slavePtr); + Tk_UnmapWindow(slavePtr->tkwin); + Unlink(slavePtr); + } + if (count != 0) { + ComputeGeometry(pwPtr); + } + } + break; + } + + case PW_IDENTIFY: { + if (objc != 4) { + Tcl_WrongNumArgs(interp, 2, objv, "x y"); + result = TCL_ERROR; + break; + } + + if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) + || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) { + result = TCL_ERROR; + break; + } + + result = PanedWindowIdentifyCoords(pwPtr, interp, x, y); + break; + } + + case PW_PANECGET: { + if (objc != 4) { + Tcl_WrongNumArgs(interp, 2, objv, "pane option"); + result = TCL_ERROR; + break; + } + tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), + pwPtr->tkwin); + if (tkwin == NULL) { + result = TCL_ERROR; + break; + } + resultObj = NULL; + for (i = 0; i < pwPtr->numSlaves; i++) { + if (pwPtr->slaves[i]->tkwin == tkwin) { + resultObj = Tk_GetOptionValue(interp, + (char *) pwPtr->slaves[i], pwPtr->slaveOpts, + objv[3], tkwin); + } + } + if (i == pwPtr->numSlaves) { + Tcl_SetResult(interp, "not managed by this window", + TCL_STATIC); + } + if (resultObj == NULL) { + result = TCL_ERROR; + } else { + Tcl_SetObjResult(interp, resultObj); + } + break; + } + + case PW_PANECONFIGURE: { + if (objc < 3) { + Tcl_WrongNumArgs(interp, 2, objv, + "pane ?option? ?value option value ...?"); + result = TCL_ERROR; + break; + } + resultObj = NULL; + if (objc <= 4) { + tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), + pwPtr->tkwin); + for (i = 0; i < pwPtr->numSlaves; i++) { + if (pwPtr->slaves[i]->tkwin == tkwin) { + resultObj = Tk_GetOptionInfo(interp, + (char *) pwPtr->slaves[i], + pwPtr->slaveOpts, + (objc == 4) ? objv[3] : (Tcl_Obj *) NULL, + pwPtr->tkwin); + if (resultObj == NULL) { + result = TCL_ERROR; + } else { + Tcl_SetObjResult(interp, resultObj); + } + break; + } + } + } else { + result = ConfigureSlaves(pwPtr, interp, objc, objv); + } + break; + } + + case PW_PANES: { + resultObj = Tcl_NewObj(); + + Tcl_IncrRefCount(resultObj); + + for (i = 0; i < pwPtr->numSlaves; i++) { + Tcl_ListObjAppendElement(interp, resultObj, + Tcl_NewStringObj(Tk_PathName(pwPtr->slaves[i]->tkwin), + -1)); + } + Tcl_SetObjResult(interp, resultObj); + Tcl_DecrRefCount(resultObj); + break; + } + + case PW_PROXY: { + result = PanedWindowProxyCommand(pwPtr, interp, objc, objv); + break; + } + + case PW_SASH: { + result = PanedWindowSashCommand(pwPtr, interp, objc, objv); + break; + } + } + Tcl_Release((ClientData) pwPtr); + return result; +} + +/* + *---------------------------------------------------------------------- + * + * ConfigureSlaves -- + * + * Add or alter the configuration options of a slave in a paned + * window. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * Depends on options; may add a slave to the paned window, may + * alter the geometry management options of a slave. + * + *---------------------------------------------------------------------- + */ + +static int +ConfigureSlaves(pwPtr, interp, objc, objv) + PanedWindow *pwPtr; /* Information about paned window. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj * CONST objv[]; /* Argument objects. */ +{ + int i, firstOptionArg, j, found, doubleBw, index, numNewSlaves, haveLoc; + int insertIndex; + Tk_Window tkwin = NULL, ancestor, parent; + Slave *slavePtr, **inserts, **new; + Slave options; + char *arg; + + /* + * Find the non-window name arguments; these are the configure options + * for the slaves. Also validate that the window names given are + * legitimate (ie, they are real windows, they are not the panedwindow + * itself, etc.). + */ + for (i = 2; i < objc; i++) { + arg = Tcl_GetString(objv[i]); + if (arg[0] == '-') { + break; + } else { + tkwin = Tk_NameToWindow(interp, arg, pwPtr->tkwin); + if (tkwin == NULL) { + /* + * Just a plain old bad window; Tk_NameToWindow filled in an + * error message for us. + */ + return TCL_ERROR; + } else if (tkwin == pwPtr->tkwin) { + /* + * A panedwindow cannot manage itself. + */ + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "can't add ", arg, " to itself", + (char *) NULL); + return TCL_ERROR; + } else if (Tk_IsTopLevel(tkwin)) { + /* + * A panedwindow cannot manage a toplevel. + */ + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "can't add toplevel ", arg, " to ", + Tk_PathName(pwPtr->tkwin), (char *) NULL); + return TCL_ERROR; + } else { + /* + * Make sure the panedwindow is the parent of the slave, + * or a descendant of the slave's parent. + */ + parent = Tk_Parent(tkwin); + for (ancestor = pwPtr->tkwin;;ancestor = Tk_Parent(ancestor)) { + if (ancestor == parent) { + break; + } + if (Tk_IsTopLevel(ancestor)) { + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "can't add ", arg, + " to ", Tk_PathName(pwPtr->tkwin), + (char *) NULL); + return TCL_ERROR; + } + } + } + } + } + firstOptionArg = i; + + /* + * Pre-parse the configuration options, to get the before/after specifiers + * into an easy-to-find location (a local variable). Also, check the + * return from Tk_SetOptions once, here, so we can save a little bit of + * extra testing in the for loop below. + */ + memset((void *)&options, 0, sizeof(Slave)); + if (Tk_SetOptions(interp, (char *) &options, pwPtr->slaveOpts, + objc - firstOptionArg, objv + firstOptionArg, + pwPtr->tkwin, NULL, NULL) != TCL_OK) { + return TCL_ERROR; + } + + /* + * If either -after or -before was given, find the numerical index that + * corresponds to the given window. If both -after and -before are + * given, the option precedence is: -after, then -before. + */ + index = -1; + haveLoc = 0; + if (options.after != None) { + tkwin = options.after; + haveLoc = 1; + for (i = 0; i < pwPtr->numSlaves; i++) { + if (options.after == pwPtr->slaves[i]->tkwin) { + index = i + 1; + break; + } + } + } else if (options.before != None) { + tkwin = options.before; + haveLoc = 1; + for (i = 0; i < pwPtr->numSlaves; i++) { + if (options.before == pwPtr->slaves[i]->tkwin) { + index = i; + break; + } + } + } + + /* + * If a window was given for -after/-before, but it's not a window + * managed by the panedwindow, throw an error + */ + if (haveLoc && index == -1) { + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "window \"", Tk_PathName(tkwin), + "\" is not managed by ", Tk_PathName(pwPtr->tkwin), + (char *) NULL); + Tk_FreeConfigOptions((char *) &options, pwPtr->slaveOpts, + pwPtr->tkwin); + return TCL_ERROR; + } + + /* + * Allocate an array to hold, in order, the pointers to the slave + * structures corresponding to the windows specified. Some of those + * structures may already have existed, some may be new. + */ + inserts = (Slave **)ckalloc(sizeof(Slave *) * (firstOptionArg - 2)); + insertIndex = 0; + + /* + * Populate the inserts array, creating new slave structures as necessary, + * applying the options to each structure as we go, and, if necessary, + * marking the spot in the original slaves array as empty (for pre-existing + * slave structures). + */ + for (i = 0, numNewSlaves = 0; i < firstOptionArg - 2; i++) { + /* + * We don't check that tkwin is NULL here, because the pre-pass above + * guarantees that the input at this stage is good. + */ + tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[i + 2]), + pwPtr->tkwin); + + found = 0; + for (j = 0; j < pwPtr->numSlaves; j++) { + if (pwPtr->slaves[j] != NULL && pwPtr->slaves[j]->tkwin == tkwin) { + Tk_SetOptions(interp, (char *) pwPtr->slaves[j], + pwPtr->slaveOpts, objc - firstOptionArg, + objv + firstOptionArg, pwPtr->tkwin, NULL, NULL); + found = 1; + + /* + * If the slave is supposed to move, add it to the inserts + * array now; otherwise, leave it where it is. + */ + + if (index != -1) { + inserts[insertIndex++] = pwPtr->slaves[j]; + pwPtr->slaves[j] = NULL; + } + break; + } + } + + if (found) { + continue; + } + + /* + * Make sure this slave wasn't already put into the inserts array, + * ie, when the user specifies the same window multiple times in + * a single add commaned. + */ + for (j = 0; j < insertIndex; j++) { + if (inserts[j]->tkwin == tkwin) { + found = 1; + break; + } + } + if (found) { + continue; + } + + /* + * Create a new slave structure and initialize it. All slaves + * start out with their "natural" dimensions. + */ + + slavePtr = (Slave *) ckalloc(sizeof(Slave)); + memset(slavePtr, 0, sizeof(Slave)); + Tk_InitOptions(interp, (char *)slavePtr, pwPtr->slaveOpts, + pwPtr->tkwin); + Tk_SetOptions(interp, (char *)slavePtr, pwPtr->slaveOpts, + objc - firstOptionArg, objv + firstOptionArg, + pwPtr->tkwin, NULL, NULL); + slavePtr->tkwin = tkwin; + slavePtr->masterPtr = pwPtr; + doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width; + if (slavePtr->width > 0) { + slavePtr->paneWidth = slavePtr->width; + } else { + slavePtr->paneWidth = Tk_ReqWidth(tkwin) + doubleBw; + } + if (slavePtr->height > 0) { + slavePtr->paneHeight = slavePtr->height; + } else { + slavePtr->paneHeight = Tk_ReqHeight(tkwin) + doubleBw; + } + + /* + * Set up the geometry management callbacks for this slave. + */ + + Tk_CreateEventHandler(slavePtr->tkwin, StructureNotifyMask, + SlaveStructureProc, (ClientData) slavePtr); + Tk_ManageGeometry(slavePtr->tkwin, &panedWindowMgrType, + (ClientData) slavePtr); + inserts[insertIndex++] = slavePtr; + numNewSlaves++; + } + + /* + * Allocate the new slaves array, then copy the slaves into it, in + * order. + */ + i = sizeof(Slave *) * (pwPtr->numSlaves+numNewSlaves); + new = (Slave **)ckalloc((unsigned) i); + memset(new, 0, (size_t) i); + if (index == -1) { + /* + * If none of the existing slaves have to be moved, just copy the old + * and append the new. + */ + memcpy((void *)&(new[0]), pwPtr->slaves, + sizeof(Slave *) * pwPtr->numSlaves); + memcpy((void *)&(new[pwPtr->numSlaves]), inserts, + sizeof(Slave *) * numNewSlaves); + } else { + /* + * If some of the existing slaves were moved, the old slaves array + * will be partially populated, with some valid and some invalid + * entries. Walk through it, copying valid entries to the new slaves + * array as we go; when we get to the insert location for the new + * slaves, copy the inserts array over, then finish off the old slaves + * array. + */ + for (i = 0, j = 0; i < index; i++) { + if (pwPtr->slaves[i] != NULL) { + new[j] = pwPtr->slaves[i]; + j++; + } + } + + memcpy((void *)&(new[j]), inserts, sizeof(Slave *) * (insertIndex)); + j += firstOptionArg - 2; + + for (i = index; i < pwPtr->numSlaves; i++) { + if (pwPtr->slaves[i] != NULL) { + new[j] = pwPtr->slaves[i]; + j++; + } + } + } + + /* + * Make the new slaves array the paned window's slave array, and clean up. + */ + ckfree((void *)pwPtr->slaves); + ckfree((void *)inserts); + pwPtr->slaves = new; + + /* + * Set the paned window's slave count to the new value. + */ + pwPtr->numSlaves += numNewSlaves; + + Tk_FreeConfigOptions((char *) &options, pwPtr->slaveOpts, pwPtr->tkwin); + + ComputeGeometry(pwPtr); + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * PanedWindowSashCommand -- + * + * Implementation of the panedwindow sash subcommand. See the user + * documentation for details on what it does. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * Depends on the arguments. + * + *---------------------------------------------------------------------- + */ + +static int +PanedWindowSashCommand(pwPtr, interp, objc, objv) + PanedWindow *pwPtr; /* Pointer to paned window information. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj * CONST objv[]; /* Argument objects. */ +{ + static CONST char *sashOptionStrings[] = { "coord", "dragto", "mark", + "place", (char *) NULL }; + enum sashOptions { SASH_COORD, SASH_DRAGTO, SASH_MARK, SASH_PLACE }; + int index, sash, x, y, diff; + Tcl_Obj *coords[2]; + Slave *slavePtr; + + if (objc < 3) { + Tcl_WrongNumArgs(interp, 2, objv, "option ?arg ...?"); + return TCL_ERROR; + } + + if (Tcl_GetIndexFromObj(interp, objv[2], sashOptionStrings, + "option", 0, &index) != TCL_OK) { + return TCL_ERROR; + } + + Tcl_ResetResult(interp); + switch ((enum sashOptions) index) { + case SASH_COORD: { + if (objc != 4) { + Tcl_WrongNumArgs(interp, 3, objv, "index"); + return TCL_ERROR; + } + + if (Tcl_GetIntFromObj(interp, objv[3], &sash) != TCL_OK) { + return TCL_ERROR; + } + + if (!ValidSashIndex(pwPtr, sash)) { + Tcl_ResetResult(interp); + Tcl_SetResult(interp, "invalid sash index", TCL_STATIC); + return TCL_ERROR; + } + slavePtr = pwPtr->slaves[sash]; + + coords[0] = Tcl_NewIntObj(slavePtr->sashx); + coords[1] = Tcl_NewIntObj(slavePtr->sashy); + Tcl_SetListObj(Tcl_GetObjResult(interp), 2, coords); + break; + } + + case SASH_MARK: { + if (objc != 6 && objc != 4) { + Tcl_WrongNumArgs(interp, 3, objv, "index ?x y?"); + return TCL_ERROR; + } + + if (Tcl_GetIntFromObj(interp, objv[3], &sash) != TCL_OK) { + return TCL_ERROR; + } + + if (!ValidSashIndex(pwPtr, sash)) { + Tcl_ResetResult(interp); + Tcl_SetResult(interp, "invalid sash index", TCL_STATIC); + return TCL_ERROR; + } + + if (objc == 6) { + if (Tcl_GetIntFromObj(interp, objv[4], &x) != TCL_OK) { + return TCL_ERROR; + } + + if (Tcl_GetIntFromObj(interp, objv[5], &y) != TCL_OK) { + return TCL_ERROR; + } + + 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); + Tcl_SetListObj(Tcl_GetObjResult(interp), 2, coords); + } + + break; + } + + case SASH_DRAGTO: + case SASH_PLACE: { + if (objc != 6) { + Tcl_WrongNumArgs(interp, 3, objv, "index x y"); + return TCL_ERROR; + } + + if (Tcl_GetIntFromObj(interp, objv[3], &sash) != TCL_OK) { + return TCL_ERROR; + } + + if (!ValidSashIndex(pwPtr, sash)) { + Tcl_ResetResult(interp); + Tcl_SetResult(interp, "invalid sash index", TCL_STATIC); + return TCL_ERROR; + } + + if (Tcl_GetIntFromObj(interp, objv[4], &x) != TCL_OK) { + return TCL_ERROR; + } + + if (Tcl_GetIntFromObj(interp, objv[5], &y) != TCL_OK) { + return TCL_ERROR; + } + + slavePtr = pwPtr->slaves[sash]; + if (pwPtr->orient == ORIENT_HORIZONTAL) { + if (index == SASH_PLACE) { + diff = x - pwPtr->slaves[sash]->sashx; + } else { + diff = x - pwPtr->slaves[sash]->markx; + } + } else { + if (index == SASH_PLACE) { + diff = y - pwPtr->slaves[sash]->sashy; + } else { + diff = y - pwPtr->slaves[sash]->marky; + } + } + + MoveSash(pwPtr, sash, diff); + ComputeGeometry(pwPtr); + } + } + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * ConfigurePanedWindow -- + * + * This procedure is called to process an argv/argc list in + * conjunction with the Tk option database to configure (or + * reconfigure) a paned window widget. + * + * Results: + * The return value is a standard Tcl result. If TCL_ERROR is + * returned, then the interp's result contains an error message. + * + * Side effects: + * Configuration information, such as colors, border width, + * etc. get set for pwPtr; old resources get freed, + * if there were any. + * + *---------------------------------------------------------------------- + */ + +static int +ConfigurePanedWindow(interp, pwPtr, objc, objv) + Tcl_Interp *interp; /* Used for error reporting. */ + PanedWindow *pwPtr; /* Information about widget. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument values. */ +{ + Tk_SavedOptions savedOptions; + int typemask = 0; + + if (Tk_SetOptions(interp, (char *) pwPtr, pwPtr->optionTable, objc, objv, + pwPtr->tkwin, &savedOptions, &typemask) != TCL_OK) { + Tk_RestoreSavedOptions(&savedOptions); + return TCL_ERROR; + } + + Tk_FreeSavedOptions(&savedOptions); + + PanedWindowWorldChanged((ClientData) pwPtr); + + /* + * If an option that affects geometry has changed, make a relayout + * request. + */ + + if (typemask & GEOMETRY) { + ComputeGeometry(pwPtr); + } + + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * PanedWindowWorldChanged -- + * + * This procedure is invoked anytime a paned window's world has + * changed in some way that causes the widget to have to recompute + * graphics contexts and geometry. + * + * Results: + * None. + * + * Side effects: + * Paned window will be relayed out and redisplayed. + * + *---------------------------------------------------------------------- + */ + +void +PanedWindowWorldChanged(instanceData) + ClientData instanceData; /* Information about the paned window. */ +{ + XGCValues gcValues; + GC newGC; + PanedWindow *pwPtr = (PanedWindow *) instanceData; + + /* + * Allocated a graphics context for drawing the paned window widget + * elements (background, sashes, etc.). + */ + + gcValues.background = Tk_3DBorderColor(pwPtr->background)->pixel; + newGC = Tk_GetGC(pwPtr->tkwin, GCBackground, &gcValues); + if (pwPtr->gc != None) { + Tk_FreeGC(pwPtr->display, pwPtr->gc); + } + pwPtr->gc = newGC; + + /* + * Issue geometry size requests to Tk. + */ + + Tk_SetInternalBorder(pwPtr->tkwin, pwPtr->borderWidth); + if (pwPtr->width > 0 || pwPtr->height > 0) { + Tk_GeometryRequest(pwPtr->tkwin, pwPtr->width, pwPtr->height); + } + + /* + * Arrange for the window to be redrawn, if neccessary. + */ + + if (Tk_IsMapped(pwPtr->tkwin) && !(pwPtr->flags & REDRAW_PENDING)) { + Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) pwPtr); + pwPtr->flags |= REDRAW_PENDING; + } +} + +/* + *-------------------------------------------------------------- + * + * PanedWindowEventProc -- + * + * This procedure is invoked by the Tk dispatcher for various + * events on paned windows. + * + * Results: + * None. + * + * Side effects: + * When the window gets deleted, internal structures get + * cleaned up. When it gets exposed, it is redisplayed. + * + *-------------------------------------------------------------- + */ + +static void +PanedWindowEventProc(clientData, eventPtr) + ClientData clientData; /* Information about window. */ + XEvent *eventPtr; /* Information about event. */ +{ + PanedWindow *pwPtr = (PanedWindow *) clientData; + + if (eventPtr->type == Expose) { + if (pwPtr->tkwin != NULL && !(pwPtr->flags & REDRAW_PENDING)) { + Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) pwPtr); + pwPtr->flags |= REDRAW_PENDING; + } + } else if (eventPtr->type == ConfigureNotify) { + pwPtr->flags |= REQUESTED_RELAYOUT; + if (pwPtr->tkwin != NULL && !(pwPtr->flags & REDRAW_PENDING)) { + Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) pwPtr); + pwPtr->flags |= REDRAW_PENDING; + } + } else if (eventPtr->type == DestroyNotify) { + DestroyPanedWindow(pwPtr); + } +} + +/* + *---------------------------------------------------------------------- + * + * PanedWindowCmdDeletedProc -- + * + * This procedure is invoked when a widget command is deleted. If + * the widget isn't already in the process of being destroyed, + * this command destroys it. + * + * Results: + * None. + * + * Side effects: + * The widget is destroyed. + * + *---------------------------------------------------------------------- + */ + +static void +PanedWindowCmdDeletedProc(clientData) + ClientData clientData; /* Pointer to widget record for widget. */ +{ + PanedWindow *pwPtr = (PanedWindow *) clientData; + + /* + * This procedure could be invoked either because the window was + * destroyed and the command was then deleted or because the command was + * deleted, and then this procedure destroys the widget. The + * WIDGET_DELETED flag distinguishes these cases. + */ + + if (!(pwPtr->flags & WIDGET_DELETED)) { + Tk_DestroyWindow(pwPtr->tkwin); + Tk_DestroyWindow(pwPtr->proxywin); + } +} + +/* + *-------------------------------------------------------------- + * + * DisplayPanedWindow -- + * + * This procedure redraws the contents of a paned window widget. + * It is invoked as a do-when-idle handler, so it only runs + * when there's nothing else for the application to do. + * + * Results: + * None. + * + * Side effects: + * Information appears on the screen. + * + *-------------------------------------------------------------- + */ + +static void +DisplayPanedWindow(clientData) + ClientData clientData; /* Information about window. */ +{ + PanedWindow *pwPtr = (PanedWindow *) clientData; + Pixmap pixmap; + Tk_Window tkwin = pwPtr->tkwin; + int i, sashWidth, sashHeight; + + pwPtr->flags &= ~REDRAW_PENDING; + if ((pwPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { + return; + } + + if (pwPtr->flags & REQUESTED_RELAYOUT) { + ArrangePanes(clientData); + } + + /* + * Create a pixmap for double-buffering, if necessary. + */ + + pixmap = Tk_GetPixmap(Tk_Display(tkwin), Tk_WindowId(tkwin), + Tk_Width(tkwin), Tk_Height(tkwin), + DefaultDepthOfScreen(Tk_Screen(tkwin))); + + /* + * Redraw the widget's background and border. + */ + Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->background, 0, 0, + Tk_Width(tkwin), Tk_Height(tkwin), pwPtr->borderWidth, + pwPtr->relief); + + /* + * Set up boilerplate geometry values for sashes (width, height, common + * coordinates). + */ + + if (pwPtr->orient == ORIENT_HORIZONTAL) { + sashHeight = Tk_Height(tkwin) - (2 * Tk_InternalBorderWidth(tkwin)); + sashWidth = pwPtr->sashWidth; + } else { + sashWidth = Tk_Width(tkwin) - (2 * Tk_InternalBorderWidth(tkwin)); + sashHeight = pwPtr->sashWidth; + } + + /* + * Draw the sashes. + */ + for (i = 0; i < pwPtr->numSlaves - 1; i++) { + Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->background, + pwPtr->slaves[i]->sashx, pwPtr->slaves[i]->sashy, + sashWidth, sashHeight, 1, pwPtr->sashRelief); + + if (pwPtr->showHandle) { + Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->background, + pwPtr->slaves[i]->handlex, pwPtr->slaves[i]->handley, + pwPtr->handleSize, pwPtr->handleSize, 1, + TK_RELIEF_RAISED); + } + } + + /* + * Copy the information from the off-screen pixmap onto the screen, + * then delete the pixmap. + */ + + XCopyArea(Tk_Display(tkwin), pixmap, Tk_WindowId(tkwin), pwPtr->gc, + 0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin), + 0, 0); + Tk_FreePixmap(Tk_Display(tkwin), pixmap); +} + +/* + *---------------------------------------------------------------------- + * + * DestroyPanedWindow -- + * + * This procedure is invoked by PanedWindowEventProc to free the + * internal structure of a paned window. + * + * Results: + * None. + * + * Side effects: + * Everything associated with the paned window is freed up. + * + *---------------------------------------------------------------------- + */ + +static void +DestroyPanedWindow(pwPtr) + PanedWindow *pwPtr; /* Info about paned window widget. */ +{ + int i; + + /* + * First mark the widget as in the process of being deleted, + * so that any code that causes calls to other paned window procedures + * will abort. + */ + + pwPtr->flags |= WIDGET_DELETED; + + /* + * Cancel idle callbacks for redrawing the widget and for rearranging + * the panes. + */ + if (pwPtr->flags & REDRAW_PENDING) { + Tcl_CancelIdleCall(DisplayPanedWindow, (ClientData) pwPtr); + } + if (pwPtr->flags & RESIZE_PENDING) { + Tcl_CancelIdleCall(ArrangePanes, (ClientData) pwPtr); + } + + /* + * Clean up the slave list; foreach slave: + * o Cancel the slave's structure notification callback + * o Cancel geometry management for the slave. + * o Free memory for the slave + */ + + for (i = 0; i < pwPtr->numSlaves; i++) { + Tk_DeleteEventHandler(pwPtr->slaves[i]->tkwin, StructureNotifyMask, + SlaveStructureProc, (ClientData) pwPtr->slaves[i]); + Tk_ManageGeometry(pwPtr->slaves[i]->tkwin, NULL, NULL); + Tk_FreeConfigOptions((char *)pwPtr->slaves[i], pwPtr->slaveOpts, + pwPtr->tkwin); + ckfree((void *)pwPtr->slaves[i]); + pwPtr->slaves[i] = NULL; + } + if (pwPtr->slaves) { + ckfree((char *) pwPtr->slaves); + } + + /* + * Remove the widget command from the interpreter. + */ + + Tcl_DeleteCommandFromToken(pwPtr->interp, pwPtr->widgetCmd); + + /* + * Let Tk_FreeConfigOptions clean up the rest. + */ + + Tk_FreeConfigOptions((char *) pwPtr, pwPtr->optionTable, pwPtr->tkwin); + pwPtr->tkwin = NULL; + + Tcl_EventuallyFree((ClientData) pwPtr, TCL_DYNAMIC); +} + +/* + *-------------------------------------------------------------- + * + * PanedWindowReqProc -- + * + * This procedure is invoked by Tk_GeometryRequest for + * windows managed by a paned window. + * + * Results: + * None. + * + * Side effects: + * Arranges for tkwin, and all its managed siblings, to + * be re-arranged at the next idle point. + * + *-------------------------------------------------------------- + */ + +static void +PanedWindowReqProc(clientData, tkwin) + ClientData clientData; /* Paned window's information about + * window that got new preferred + * geometry. */ + Tk_Window tkwin; /* Other Tk-related information + * about the window. */ +{ + Slave *panePtr = (Slave *) clientData; + PanedWindow *pwPtr = (PanedWindow *) (panePtr->masterPtr); + if (Tk_IsMapped(pwPtr->tkwin)) { + if (!(pwPtr->flags & RESIZE_PENDING)) { + pwPtr->flags |= RESIZE_PENDING; + Tcl_DoWhenIdle(ArrangePanes, (ClientData) pwPtr); + } + } else { + ComputeGeometry(pwPtr); + } +} + +/* + *-------------------------------------------------------------- + * + * PanedWindowLostSlaveProc -- + * + * This procedure is invoked by Tk whenever some other geometry + * claims control over a slave that used to be managed by us. + * + * Results: + * None. + * + * Side effects: + * Forgets all information about the slave. Causes geometry to + * be recomputed for the panedwindow. + * + *-------------------------------------------------------------- + */ + +static void +PanedWindowLostSlaveProc(clientData, tkwin) + ClientData clientData; /* Grid structure for slave window that + * was stolen away. */ + Tk_Window tkwin; /* Tk's handle for the slave window. */ +{ + register Slave *slavePtr = (Slave *) clientData; + PanedWindow *pwPtr = (PanedWindow *) (slavePtr->masterPtr); + if (pwPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { + Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin); + } + Unlink(slavePtr); + Tk_DeleteEventHandler(slavePtr->tkwin, StructureNotifyMask, + SlaveStructureProc, (ClientData) slavePtr); + Tk_UnmapWindow(slavePtr->tkwin); + slavePtr->tkwin = NULL; + ckfree((void *)slavePtr); + ComputeGeometry(pwPtr); +} + +/* + *-------------------------------------------------------------- + * + * ArrangePanes -- + * + * This procedure is invoked (using the Tcl_DoWhenIdle + * mechanism) to re-layout a set of windows managed by + * a paned window. It is invoked at idle time so that a + * series of pane requests can be merged into a single + * layout operation. + * + * Results: + * None. + * + * Side effects: + * The slaves of masterPtr may get resized or moved. + * + *-------------------------------------------------------------- + */ + +static void +ArrangePanes(clientData) + ClientData clientData; /* Structure describing parent whose slaves + * are to be re-layed out. */ +{ + register PanedWindow *pwPtr = (PanedWindow *) clientData; + register Slave *slavePtr; + int i, slaveWidth, slaveHeight, slaveX, slaveY, paneWidth, paneHeight; + int doubleBw; + + pwPtr->flags &= ~(REQUESTED_RELAYOUT|RESIZE_PENDING); + + /* + * If the parent has no slaves anymore, then don't do anything + * at all: just leave the parent's size as-is. Otherwise there is + * no way to "relinquish" control over the parent so another geometry + * manager can take over. + */ + + if (pwPtr->numSlaves == 0) { + return; + } + + Tcl_Preserve((ClientData) pwPtr); + for (i = 0; i < pwPtr->numSlaves; i++) { + slavePtr = pwPtr->slaves[i]; + + /* + * Compute the size of this slave. The algorithm (assuming a + * horizontal paned window) is: + * + * 1. Get "base" dimensions. If a width or height is specified + * for this slave, use those values; else use the + * ReqWidth/ReqHeight. + * 2. Using base dimensions, pane dimensions, and sticky values, + * determine the x and y, and actual width and height of the + * widget. + */ + + doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width; + slaveWidth = (slavePtr->width > 0 ? slavePtr->width : + Tk_ReqWidth(slavePtr->tkwin) + doubleBw); + slaveHeight = (slavePtr->height > 0 ? slavePtr->height : + Tk_ReqHeight(slavePtr->tkwin) + doubleBw); + + if (pwPtr->orient == ORIENT_HORIZONTAL) { + paneWidth = slavePtr->paneWidth; + if (i == pwPtr->numSlaves - 1 && Tk_IsMapped(pwPtr->tkwin)) { + if (Tk_Width(pwPtr->tkwin) > Tk_ReqWidth(pwPtr->tkwin)) { + paneWidth += Tk_Width(pwPtr->tkwin) - + Tk_ReqWidth(pwPtr->tkwin) - + Tk_InternalBorderWidth(pwPtr->tkwin); + } + } + paneHeight = Tk_Height(pwPtr->tkwin) - (2 * slavePtr->pady) - + (2 * Tk_InternalBorderWidth(pwPtr->tkwin)); + } else { + paneHeight = slavePtr->paneHeight; + if (i == pwPtr->numSlaves - 1 && Tk_IsMapped(pwPtr->tkwin)) { + if (Tk_Height(pwPtr->tkwin) > Tk_ReqHeight(pwPtr->tkwin)) { + paneHeight += Tk_Height(pwPtr->tkwin) - + Tk_ReqHeight(pwPtr->tkwin) - + Tk_InternalBorderWidth(pwPtr->tkwin); + } + } + paneWidth = Tk_Width(pwPtr->tkwin) - (2 * slavePtr->padx) - + (2 * Tk_InternalBorderWidth(pwPtr->tkwin)); + } + + if (slaveWidth > paneWidth) { + slaveWidth = paneWidth; + } + if (slaveHeight > paneHeight) { + slaveHeight = paneHeight; + } + + slaveX = slavePtr->x; + slaveY = slavePtr->y; + AdjustForSticky(slavePtr->sticky, paneWidth, paneHeight, + &slaveX, &slaveY, &slaveWidth, &slaveHeight); + + slaveX += slavePtr->padx; + slaveY += slavePtr->pady; + + /* + * Now put the window in the proper spot. + */ + if ((slaveWidth <= 0) || (slaveHeight <= 0)) { + Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin); + Tk_UnmapWindow(slavePtr->tkwin); + } else { + Tk_MaintainGeometry(slavePtr->tkwin, pwPtr->tkwin, + slaveX, slaveY, slaveWidth, slaveHeight); + } + } + Tcl_Release((ClientData) pwPtr); +} + +/* + *---------------------------------------------------------------------- + * + * Unlink -- + * + * Remove a slave from a paned window. + * + * Results: + * None. + * + * Side effects: + * The paned window will be scheduled for re-arranging and redrawing. + * + *---------------------------------------------------------------------- + */ + +static void +Unlink(slavePtr) + register Slave *slavePtr; /* Window to unlink. */ +{ + register PanedWindow *masterPtr; + int i, j; + + masterPtr = slavePtr->masterPtr; + if (masterPtr == NULL) { + return; + } + + /* + * Find the specified slave in the panedwindow's list of slaves, then + * remove it from that list. + */ + + for (i = 0; i < masterPtr->numSlaves; i++) { + if (masterPtr->slaves[i] == slavePtr) { + for (j = i; j < masterPtr->numSlaves - 1; j++) { + masterPtr->slaves[j] = masterPtr->slaves[j + 1]; + } + break; + } + } + + masterPtr->flags |= REQUESTED_RELAYOUT; + if (!(masterPtr->flags & REDRAW_PENDING)) { + masterPtr->flags |= REDRAW_PENDING; + Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) masterPtr); + } + + /* + * Set the slave's masterPtr to NULL, so that we can tell that the + * slave is no longer attached to any panedwindow. + */ + slavePtr->masterPtr = NULL; + + masterPtr->numSlaves--; +} + +/* + *---------------------------------------------------------------------- + * + * GetPane -- + * + * Given a token to a Tk window, find the pane that corresponds to + * that token in a given paned window. + * + * Results: + * Pointer to the slave structure, or NULL if the window is not + * managed by this paned window. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static Slave * +GetPane(pwPtr, tkwin) + PanedWindow *pwPtr; /* Pointer to the paned window info. */ + Tk_Window tkwin; /* Window to search for. */ +{ + int i; + for (i = 0; i < pwPtr->numSlaves; i++) { + if (pwPtr->slaves[i]->tkwin == tkwin) { + return pwPtr->slaves[i]; + } + } + return NULL; +} + +/* + *-------------------------------------------------------------- + * + * SlaveStructureProc -- + * + * This procedure is invoked whenever StructureNotify events + * occur for a window that's managed by a paned window. This + * procedure's only purpose is to clean up when windows are + * deleted. + * + * Results: + * None. + * + * Side effects: + * The paned window slave structure associated with the window + * is freed, and the slave is disassociated from the paned + * window which managed it. + * + *-------------------------------------------------------------- + */ + +static void +SlaveStructureProc(clientData, eventPtr) + ClientData clientData; /* Pointer to record describing window item. */ + XEvent *eventPtr; /* Describes what just happened. */ +{ + Slave *slavePtr = (Slave *) clientData; + PanedWindow *pwPtr = slavePtr->masterPtr; + + if (eventPtr->type == DestroyNotify) { + Unlink(slavePtr); + slavePtr->tkwin = NULL; + ckfree((void *)slavePtr); + ComputeGeometry(pwPtr); + } +} + +/* + *---------------------------------------------------------------------- + * + * ComputeGeometry -- + * + * Compute geometry for the paned window, including coordinates of + * all slave windows and each sash. + * + * Results: + * None. + * + * Side effects: + * Recomputes geometry information for a paned window. + * + *---------------------------------------------------------------------- + */ + +static void +ComputeGeometry(pwPtr) + PanedWindow *pwPtr; /* Pointer to the Paned Window structure. */ +{ + int i, x, y, doubleBw, internalBw; + int reqWidth, reqHeight, sashWidth, sxOff, syOff, hxOff, hyOff, dim; + Slave *slavePtr; + + pwPtr->flags |= REQUESTED_RELAYOUT; + + x = y = internalBw = Tk_InternalBorderWidth(pwPtr->tkwin); + reqWidth = reqHeight = 0; + + /* + * Sashes and handles share space on the display. To simplify + * processing below, precompute the x and y offsets of the handles and + * sashes within the space occupied by their combination; later, just add + * those offsets blindly (avoiding the extra showHandle, etc, checks). + */ + sxOff = syOff = hxOff = hyOff = 0; + if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) { + sashWidth = pwPtr->handleSize; + if (pwPtr->orient == ORIENT_HORIZONTAL) { + sxOff = (pwPtr->handleSize - pwPtr->sashWidth) / 2; + hyOff = pwPtr->handlePad; + } else { + syOff = (pwPtr->handleSize - pwPtr->sashWidth) / 2; + hxOff = pwPtr->handlePad; + } + } else { + sashWidth = pwPtr->sashWidth; + if (pwPtr->orient == ORIENT_HORIZONTAL) { + hxOff = (pwPtr->handleSize - pwPtr->sashWidth) / 2; + hyOff = pwPtr->handlePad; + } else { + hyOff = (pwPtr->handleSize - pwPtr->sashWidth) / 2; + hxOff = pwPtr->handlePad; + } + } + + for (i = 0; i < pwPtr->numSlaves; i++) { + slavePtr = pwPtr->slaves[i]; + /* + * First set the coordinates for the top left corner of the slave's + * parcel. + */ + slavePtr->x = x; + slavePtr->y = y; + + /* + * Make sure the pane's paned dimension is at least minsize. + * This check may be redundant, since the only way to change a pane's + * size is by moving a sash, and that code checks the minsize. + */ + if (pwPtr->orient == ORIENT_HORIZONTAL) { + if (slavePtr->paneWidth < slavePtr->minSize) { + slavePtr->paneWidth = slavePtr->minSize; + } + } else { + if (slavePtr->paneHeight < slavePtr->minSize) { + slavePtr->paneHeight = slavePtr->minSize; + } + } + + /* + * Compute the location of the sash at the right or bottom of the + * parcel. + */ + if (pwPtr->orient == ORIENT_HORIZONTAL) { + x += slavePtr->paneWidth + (2 * slavePtr->padx) + pwPtr->sashPad; + } else { + y += slavePtr->paneHeight + (2 * slavePtr->pady) + pwPtr->sashPad; + } + slavePtr->sashx = x + sxOff; + slavePtr->sashy = y + syOff; + slavePtr->handlex = x + hxOff; + slavePtr->handley = y + hyOff; + + /* + * Compute the location of the next parcel. + */ + + if (pwPtr->orient == ORIENT_HORIZONTAL) { + x += sashWidth + pwPtr->sashPad; + } else { + y += sashWidth + pwPtr->sashPad; + } + + /* + * Find the maximum height/width of the slaves, for computing the + * requested height/width of the paned window. + */ + if (pwPtr->orient == ORIENT_HORIZONTAL) { + /* + * If the slave has an explicit height set, use that; otherwise, + * use the slave's requested height. + */ + if (slavePtr->height > 0) { + dim = slavePtr->height; + } else { + doubleBw = (2 * Tk_Changes(slavePtr->tkwin)->border_width); + dim = Tk_ReqHeight(slavePtr->tkwin) + doubleBw; + } + dim += (2 * slavePtr->pady); + if (dim > reqHeight) { + reqHeight = dim; + } + } else { + /* + * If the slave has an explicit width set use that; otherwise, + * use the slave's requested width. + */ + if (slavePtr->width > 0) { + dim = slavePtr->width; + } else { + doubleBw = (2 * Tk_Changes(slavePtr->tkwin)->border_width); + dim = Tk_ReqWidth(slavePtr->tkwin) + doubleBw; + } + dim += (2 * slavePtr->padx); + if (dim > reqWidth) { + reqWidth = dim; + } + } + } + + /* + * The loop above should have left x (or y) equal to the sum of the + * widths (or heights) of the widgets, plus the size of one sash and + * the sash padding for each widget, plus the width of the left (or top) + * border of the paned window. + * + * The requested width (or height) is therefore x (or y) minus the size of + * one sash and padding, plus the width of the right (or bottom) border + * of the paned window. + * + * The height (or width) is equal to the maximum height (or width) of + * the slaves, plus the width of the border of the top and bottom (or left + * and right) of the paned window. + */ + if (pwPtr->orient == ORIENT_HORIZONTAL) { + reqWidth = x - (sashWidth + (2 * pwPtr->sashPad)) + internalBw; + reqHeight += 2 * internalBw; + } else { + reqHeight = y - (sashWidth + (2 * pwPtr->sashPad)) + internalBw; + reqWidth += 2 * internalBw; + } + if (pwPtr->width <= 0 && pwPtr->height <= 0) { + Tk_GeometryRequest(pwPtr->tkwin, reqWidth, reqHeight); + } + if (Tk_IsMapped(pwPtr->tkwin) && !(pwPtr->flags & REDRAW_PENDING)) { + pwPtr->flags |= REDRAW_PENDING; + Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) pwPtr); + } +} + +/* + *---------------------------------------------------------------------- + * + * DestroyOptionTables -- + * + * This procedure is registered as an exit callback when the paned window + * command is first called. It cleans up the OptionTables structure + * allocated by that command. + * + * Results: + * None. + * + * Side effects: + * Frees memory. + * + *---------------------------------------------------------------------- + */ + +static void +DestroyOptionTables(clientData, interp) + ClientData clientData; /* Pointer to the OptionTables struct */ + Tcl_Interp *interp; /* Pointer to the calling interp */ +{ + ckfree((char *)clientData); + return; +} + +/* + *---------------------------------------------------------------------- + * + * GetSticky - + * + * Converts an internal boolean combination of "sticky" bits into a + * a Tcl string obj containing zero or mor of n, s, e, or w. + * + * Results: + * Tcl_Obj containing the string representation of the sticky value. + * + * Side effects: + * Creates a new Tcl_Obj. + * + *---------------------------------------------------------------------- + */ + +static Tcl_Obj * +GetSticky(clientData, tkwin, recordPtr, internalOffset) + ClientData clientData; + Tk_Window tkwin; + char *recordPtr; /* Pointer to widget record. */ + int internalOffset; /* Offset within *recordPtr containing the + * sticky value. */ +{ + int sticky = *(int *)(recordPtr + internalOffset); + static char buffer[5]; + int count = 0; + + if (sticky & STICK_NORTH) { + buffer[count++] = 'n'; + } + if (sticky & STICK_EAST) { + buffer[count++] = 'e'; + } + if (sticky & STICK_SOUTH) { + buffer[count++] = 's'; + } + if (sticky & STICK_WEST) { + buffer[count++] = 'w'; + } + buffer[count] = '\0'; + + return Tcl_NewStringObj(buffer, -1); +} + +/* + *---------------------------------------------------------------------- + * + * SetSticky -- + * + * Converts a Tcl_Obj representing a widgets stickyness into an + * integer value. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * May store the integer value into the internal representation + * pointer. May change the pointer to the Tcl_Obj to NULL to indicate + * that the specified string was empty and that is acceptable. + * + *---------------------------------------------------------------------- + */ + +static int +SetSticky(clientData, interp, tkwin, value, recordPtr, internalOffset, + oldInternalPtr, flags) + ClientData clientData; + 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. + * We use a pointer to the pointer because + * we may need to return a value (NULL). */ + char *recordPtr; /* Pointer to storage for the widget record. */ + int internalOffset; /* Offset within *recordPtr at which the + internal value is to be stored. */ + char *oldInternalPtr; /* Pointer to storage for the old value. */ + int flags; /* Flags for the option, set Tk_SetOptions. */ +{ + int sticky = 0; + char c, *string, *internalPtr; + + internalPtr = ComputeSlotAddress(recordPtr, internalOffset); + + if (flags & TK_OPTION_NULL_OK && ObjectIsEmpty(*value)) { + *value = NULL; + } else { + /* + * Convert the sticky specifier into an integer value. + */ + + string = Tcl_GetString(*value); + + while ((c = *string++) != '\0') { + switch (c) { + case 'n': case 'N': sticky |= STICK_NORTH; break; + case 'e': case 'E': sticky |= STICK_EAST; break; + case 's': case 'S': sticky |= STICK_SOUTH; break; + case 'w': case 'W': sticky |= STICK_WEST; break; + case ' ': case ',': case '\t': case '\r': case '\n': break; + default: { + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "bad stickyness value \"", + Tcl_GetString(*value), "\": must be a string ", + "containing zero or more of n, e, s, and w", + (char *)NULL); + return TCL_ERROR; + } + } + } + } + + if (internalPtr != NULL) { + *((int *) oldInternalPtr) = *((int *) internalPtr); + *((int *) internalPtr) = sticky; + } + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * RestoreSticky -- + * + * Restore a sticky option value from a saved value. + * + * Results: + * None. + * + * Side effects: + * Restores the old value. + * + *---------------------------------------------------------------------- + */ + +static void +RestoreSticky(clientData, tkwin, internalPtr, oldInternalPtr) + ClientData clientData; + Tk_Window tkwin; + char *internalPtr; /* Pointer to storage for value. */ + char *oldInternalPtr; /* Pointer to old value. */ +{ + *(int *)internalPtr = *(int *)oldInternalPtr; +} + +/* + *---------------------------------------------------------------------- + * + * AdjustForSticky -- + * + * Given the x,y coords of the top-left corner of a pane, the + * dimensions of that pane, and the dimensions of a slave, compute + * the x,y coords and actual dimensions of the slave based on the slave's + * sticky value. + * + * Results: + * No direct return; sets the x, y, slaveWidth and slaveHeight to + * correct values. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static void +AdjustForSticky(sticky, cavityWidth, cavityHeight, xPtr, yPtr, + slaveWidthPtr, slaveHeightPtr) + int sticky; /* Sticky value; see top of file for definition. */ + int cavityWidth; /* Width of the cavity. */ + int cavityHeight; /* Height of the cavity. */ + int *xPtr, *yPtr; /* Initially, coordinates of the top-left + * corner of cavity; also return values for + * actual x, y coords of slave. */ + int *slaveWidthPtr; /* Slave width. */ + int *slaveHeightPtr; /* Slave height. */ +{ + int diffx=0; /* Cavity width - slave width. */ + int diffy=0; /* Cavity hight - slave height. */ + + if (cavityWidth > *slaveWidthPtr) { + diffx = cavityWidth - *slaveWidthPtr; + } + + if (cavityHeight > *slaveHeightPtr) { + diffy = cavityHeight - *slaveHeightPtr; + } + + if ((sticky & STICK_EAST) && (sticky & STICK_WEST)) { + *slaveWidthPtr += diffx; + } + if ((sticky & STICK_NORTH) && (sticky & STICK_SOUTH)) { + *slaveHeightPtr += diffy; + } + if (!(sticky & STICK_WEST)) { + *xPtr += (sticky & STICK_EAST) ? diffx : diffx/2; + } + if (!(sticky & STICK_NORTH)) { + *yPtr += (sticky & STICK_SOUTH) ? diffy : diffy/2; + } +} + +/* + *---------------------------------------------------------------------- + * + * MoveSash -- + * + * Move the sash given by index the amount given. + * + * Results: + * None. + * + * Side effects: + * Recomputes the sizes of the panes in a panedwindow. + * + *---------------------------------------------------------------------- + */ + +static void +MoveSash(pwPtr, sash, diff) + PanedWindow *pwPtr; + int sash; + int diff; +{ + int diffConsumed = 0, i, extra, maxCoord, currCoord; + int *lengthPtr, newLength; + Slave *slave; + + if (diff > 0) { + /* + * Growing the pane, at the expense of panes to the right. + */ + + + /* + * First check that moving the sash the requested distance will not + * leave it off the screen. If necessary, clip the requested diff + * to the maximum possible while remaining visible. + */ + if (pwPtr->orient == ORIENT_HORIZONTAL) { + if (Tk_IsMapped(pwPtr->tkwin)) { + maxCoord = Tk_Width(pwPtr->tkwin); + } else { + maxCoord = Tk_ReqWidth(pwPtr->tkwin); + } + extra = Tk_Width(pwPtr->tkwin) - Tk_ReqWidth(pwPtr->tkwin); + currCoord = pwPtr->slaves[sash]->sashx; + } else { + if (Tk_IsMapped(pwPtr->tkwin)) { + maxCoord = Tk_Height(pwPtr->tkwin); + } else { + maxCoord = Tk_ReqHeight(pwPtr->tkwin); + } + extra = Tk_Height(pwPtr->tkwin) - Tk_ReqHeight(pwPtr->tkwin); + currCoord = pwPtr->slaves[sash]->sashy; + } + + maxCoord -= (pwPtr->borderWidth + pwPtr->sashWidth + pwPtr->sashPad); + if (currCoord + diff >= maxCoord) { + diff = maxCoord - currCoord; + } + + for (i = sash + 1; i < pwPtr->numSlaves; i++) { + if (diffConsumed == diff) { + break; + } + slave = pwPtr->slaves[i]; + + if (pwPtr->orient == ORIENT_HORIZONTAL) { + lengthPtr = &(slave->paneWidth); + } else { + lengthPtr = &(slave->paneHeight); + } + + /* + * Remove as much space from this pane as possible (constrained + * by the minsize value and the visible dimensions of the window). + */ + + if (i == pwPtr->numSlaves - 1 && extra > 0) { + /* + * The last pane may have some additional "virtual" space, + * if the width (or height) of the paned window is bigger + * than the requested width (or height). + * + * That extra space is not included in the paneWidth + * (or paneHeight) value, so we have to handle the last + * pane specially. + */ + newLength = (*lengthPtr + extra) - (diff - diffConsumed); + if (newLength < slave->minSize) { + newLength = slave->minSize; + } + if (newLength < 0) { + newLength = 0; + } + diffConsumed += (*lengthPtr + extra) - newLength; + if (newLength < *lengthPtr) { + *lengthPtr = newLength; + } + } else { + newLength = *lengthPtr - (diff - diffConsumed); + if (newLength < slave->minSize) { + newLength = slave->minSize; + } + if (newLength < 0) { + newLength = 0; + } + diffConsumed += *lengthPtr - newLength; + *lengthPtr = newLength; + } + } + if (pwPtr->orient == ORIENT_HORIZONTAL) { + pwPtr->slaves[sash]->paneWidth += diffConsumed; + } else { + pwPtr->slaves[sash]->paneHeight += diffConsumed; + } + } else if (diff < 0) { + /* + * Shrinking the pane; additional space is given to the pane to the + * right. + */ + for (i = sash; i >= 0; i--) { + if (diffConsumed == diff) { + break; + } + /* + * Remove as much space from this pane as possible. + */ + slave = pwPtr->slaves[i]; + + if (pwPtr->orient == ORIENT_HORIZONTAL) { + lengthPtr = &(slave->paneWidth); + } else { + lengthPtr = &(slave->paneHeight); + } + + newLength = *lengthPtr + (diff - diffConsumed); + if (newLength < slave->minSize) { + newLength = slave->minSize; + } + if (newLength < 0) { + newLength = 0; + } + diffConsumed -= *lengthPtr - newLength; + *lengthPtr = newLength; + } + if (pwPtr->orient == ORIENT_HORIZONTAL) { + pwPtr->slaves[sash + 1]->paneWidth -= diffConsumed; + } else { + pwPtr->slaves[sash + 1]->paneHeight -= diffConsumed; + } + } + +} + +/* + *---------------------------------------------------------------------- + * + * ProxyWindowEventProc -- + * + * This procedure is invoked by the Tk dispatcher for various + * events on paned window proxy windows. + * + * Results: + * None. + * + * Side effects: + * When the window gets deleted, internal structures get + * cleaned up. When it gets exposed, it is redisplayed. + * + *-------------------------------------------------------------- + */ + +static void +ProxyWindowEventProc(clientData, eventPtr) + ClientData clientData; /* Information about window. */ + XEvent *eventPtr; /* Information about event. */ +{ + PanedWindow *pwPtr = (PanedWindow *) clientData; + + if (eventPtr->type == Expose) { + if (pwPtr->proxywin != NULL &&!(pwPtr->flags & PROXY_REDRAW_PENDING)) { + Tcl_DoWhenIdle(DisplayProxyWindow, (ClientData) pwPtr); + pwPtr->flags |= PROXY_REDRAW_PENDING; + } + } +} + +/* + *-------------------------------------------------------------- + * + * DisplayProxyWindow -- + * + * This procedure redraws a paned window proxy window. + * It is invoked as a do-when-idle handler, so it only runs + * when there's nothing else for the application to do. + * + * Results: + * None. + * + * Side effects: + * Information appears on the screen. + * + *-------------------------------------------------------------- + */ + +static void +DisplayProxyWindow(clientData) + ClientData clientData; /* Information about window. */ +{ + PanedWindow *pwPtr = (PanedWindow *) clientData; + Pixmap pixmap; + Tk_Window tkwin = pwPtr->proxywin; + pwPtr->flags &= ~PROXY_REDRAW_PENDING; + if ((tkwin == NULL) || !Tk_IsMapped(tkwin)) { + return; + } + + /* + * Create a pixmap for double-buffering, if necessary. + */ + + pixmap = Tk_GetPixmap(Tk_Display(tkwin), Tk_WindowId(tkwin), + Tk_Width(tkwin), Tk_Height(tkwin), + DefaultDepthOfScreen(Tk_Screen(tkwin))); + + /* + * Redraw the widget's background and border. + */ + Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->background, 0, 0, + Tk_Width(tkwin), Tk_Height(tkwin), 2, pwPtr->sashRelief); + + /* + * Copy the pixmap to the display. + */ + XCopyArea(Tk_Display(tkwin), pixmap, Tk_WindowId(tkwin), pwPtr->gc, + 0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin), + 0, 0); + Tk_FreePixmap(Tk_Display(tkwin), pixmap); +} + +/* + *---------------------------------------------------------------------- + * + * PanedWindowProxyCommand -- + * + * Handles the panedwindow proxy subcommand. See the user + * documentation for details. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * May map or unmap the proxy sash. + * + *---------------------------------------------------------------------- + */ + +static int +PanedWindowProxyCommand(pwPtr, interp, objc, objv) + PanedWindow *pwPtr; /* Pointer to paned window information. */ + Tcl_Interp *interp; /* Current interpreter. */ + int objc; /* Number of arguments. */ + Tcl_Obj * CONST objv[]; /* Argument objects. */ +{ + static CONST char *optionStrings[] = { "coord", "forget", "place", + (char *) NULL }; + enum options { PROXY_COORD, PROXY_FORGET, PROXY_PLACE }; + int index, x, y, sashWidth, sashHeight; + Tcl_Obj *coords[2]; + + if (objc < 3) { + Tcl_WrongNumArgs(interp, 2, objv, "option ?arg ...?"); + return TCL_ERROR; + } + + if (Tcl_GetIndexFromObj(interp, objv[2], optionStrings, "option", 0, + &index) != TCL_OK) { + return TCL_ERROR; + } + + switch ((enum options) index) { + case PROXY_COORD: + if (objc != 3) { + Tcl_WrongNumArgs(interp, 3, objv, NULL); + return TCL_ERROR; + } + + coords[0] = Tcl_NewIntObj(pwPtr->proxyx); + coords[1] = Tcl_NewIntObj(pwPtr->proxyy); + Tcl_SetListObj(Tcl_GetObjResult(interp), 2, coords); + break; + + case PROXY_FORGET: + if (objc != 3) { + Tcl_WrongNumArgs(interp, 3, objv, NULL); + return TCL_ERROR; + } + if (Tk_IsMapped(pwPtr->proxywin)) { + Tk_UnmapWindow(pwPtr->proxywin); + Tk_UnmaintainGeometry(pwPtr->proxywin, pwPtr->tkwin); + } + break; + + case PROXY_PLACE: { + if (objc != 5) { + Tcl_WrongNumArgs(interp, 3, objv, "x y"); + return TCL_ERROR; + } + + if (Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK) { + return TCL_ERROR; + } + + if (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK) { + return TCL_ERROR; + } + + if (pwPtr->orient == ORIENT_HORIZONTAL) { + if (x < 0) { + x = 0; + } + y = Tk_InternalBorderWidth(pwPtr->tkwin); + sashWidth = pwPtr->sashWidth; + sashHeight = Tk_Height(pwPtr->tkwin) - + (2 * Tk_InternalBorderWidth(pwPtr->tkwin)); + } else { + if (y < 0) { + y = 0; + } + x = Tk_InternalBorderWidth(pwPtr->tkwin); + sashHeight = pwPtr->sashWidth; + sashWidth = Tk_Width(pwPtr->tkwin) - + (2 * Tk_InternalBorderWidth(pwPtr->tkwin)); + } + + /* + * Stash the proxy coordinates for future "proxy coord" calls. + */ + + pwPtr->proxyx = x; + pwPtr->proxyy = y; + + /* + * Make sure the proxy window is higher in the stacking order + * than the slaves, so that it will be visible when drawn. + * It would be more correct to push the proxy window just high + * enough to appear above the highest slave, but it's much easier + * to just force it all the way to the top of the stacking order. + */ + + Tk_RestackWindow(pwPtr->proxywin, Above, NULL); + + /* + * Let Tk_MaintainGeometry take care of placing the window at + * the right coordinates. + */ + Tk_MaintainGeometry(pwPtr->proxywin, pwPtr->tkwin, + x, y, sashWidth, sashHeight); + break; + } + } + + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * + * ObjectIsEmpty -- + * + * This procedure tests whether the string value of an object is + * empty. + * + * Results: + * The return value is 1 if the string value of objPtr has length + * zero, and 0 otherwise. + * + * Side effects: + * May cause object shimmering, since this function can force a + * conversion to a string object. + * + *---------------------------------------------------------------------- + */ + +static int +ObjectIsEmpty(objPtr) + Tcl_Obj *objPtr; /* Object to test. May be NULL. */ +{ + int length; + + if (objPtr == NULL) { + return 1; + } + if (objPtr->bytes != NULL) { + return (objPtr->length == 0); + } + Tcl_GetStringFromObj(objPtr, &length); + return (length == 0); +} + +/* + *---------------------------------------------------------------------- + * + * ComputeInternalPointer -- + * + * Given a pointer to the start of a record and the offset of a slot + * within that record, compute the address of that slot. + * + * Results: + * If offset is non-negative, returns the computed address; else, + * returns NULL. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static char * +ComputeSlotAddress(recordPtr, offset) + char *recordPtr; /* Pointer to the start of a record. */ + int offset; /* Offset of a slot within that record; may be < 0. */ +{ + if (offset >= 0) { + return recordPtr + offset; + } else { + return NULL; + } +} + +/* + *---------------------------------------------------------------------- + * + * PanedWindowIdentifyCoords -- + * + * Given a pair of x,y coordinates, identify the panedwindow component + * at that point, if any. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * Modifies the interpreter's result to contain either an empty list, + * or a two element list of the form {sash n} or {handle n} to indicate + * that the point lies within the n'th sash or handle. + * + *---------------------------------------------------------------------- + */ + +static int +PanedWindowIdentifyCoords(pwPtr, interp, x, y) + PanedWindow *pwPtr; /* Information about the widget. */ + Tcl_Interp *interp; /* Interpreter in which to store result. */ + int x, y; /* Coordinates of the point to identify. */ +{ + Tcl_Obj *list; + int i, sashHeight, sashWidth, thisx, thisy; + int found, isHandle, lpad, rpad, tpad, bpad; + list = Tcl_NewObj(); + + if (pwPtr->orient == ORIENT_HORIZONTAL) { + if (Tk_IsMapped(pwPtr->tkwin)) { + sashHeight = Tk_Height(pwPtr->tkwin); + } else { + sashHeight = Tk_ReqHeight(pwPtr->tkwin); + } + sashHeight -= 2 * Tk_InternalBorderWidth(pwPtr->tkwin); + if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) { + sashWidth = pwPtr->handleSize; + lpad = (pwPtr->handleSize - pwPtr->sashWidth) / 2; + rpad = pwPtr->handleSize - lpad; + lpad += pwPtr->sashPad; + rpad += pwPtr->sashPad; + } else { + sashWidth = pwPtr->sashWidth; + lpad = rpad = pwPtr->sashPad; + } + tpad = bpad = 0; + } else { + if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) { + sashHeight = pwPtr->handleSize; + tpad = (pwPtr->handleSize - pwPtr->sashWidth) / 2; + bpad = pwPtr->handleSize - tpad; + tpad += pwPtr->sashPad; + bpad += pwPtr->sashPad; + } else { + sashHeight = pwPtr->sashWidth; + tpad = bpad = pwPtr->sashPad; + } + if (Tk_IsMapped(pwPtr->tkwin)) { + sashWidth = Tk_Width(pwPtr->tkwin); + } else { + sashWidth = Tk_ReqWidth(pwPtr->tkwin); + } + sashWidth -= 2 * Tk_InternalBorderWidth(pwPtr->tkwin); + lpad = rpad = 0; + } + + isHandle = 0; + found = -1; + for (i = 0; i < pwPtr->numSlaves - 1; i++) { + thisx = pwPtr->slaves[i]->sashx; + thisy = pwPtr->slaves[i]->sashy; + + if (((thisx - lpad) <= x && x <= (thisx + rpad + sashWidth)) && + ((thisy - tpad) <= y && y <= (thisy + bpad + sashHeight))) { + found = i; + + /* + * Determine if the point is over the handle or the sash. + */ + if (pwPtr->showHandle) { + thisx = pwPtr->slaves[i]->handlex; + thisy = pwPtr->slaves[i]->handley; + if (pwPtr->orient == ORIENT_HORIZONTAL) { + if (thisy <= y && y <= (thisy + pwPtr->handleSize)) { + isHandle = 1; + } + } else { + if (thisx <= x && x <= (thisx + pwPtr->handleSize)) { + isHandle = 1; + } + } + } + break; + } + } + + /* + * Set results. + */ + if (found != -1) { + Tcl_ListObjAppendElement(interp, list, Tcl_NewIntObj(found)); + if (isHandle) { + Tcl_ListObjAppendElement(interp, list, + Tcl_NewStringObj("handle", -1)); + } else { + Tcl_ListObjAppendElement(interp, list, + Tcl_NewStringObj("sash", -1)); + } + } + + Tcl_SetObjResult(interp, list); + return TCL_OK; +} diff --git a/tk/generic/tkPlace.c b/tk/generic/tkPlace.c index d48895b2d41..a2909799e87 100644 --- a/tk/generic/tkPlace.c +++ b/tk/generic/tkPlace.c @@ -16,6 +16,7 @@ #include "tkPort.h" #include "tkInt.h" + /* * Border modes for relative placement: * @@ -27,6 +28,10 @@ * master's actual window size. */ +static char *borderModeStrings[] = { + "inside", "outside", "ignore", (char *) NULL +}; + typedef enum {BM_INSIDE, BM_OUTSIDE, BM_IGNORE} BorderMode; /* @@ -36,6 +41,7 @@ typedef enum {BM_INSIDE, BM_OUTSIDE, BM_IGNORE} BorderMode; typedef struct Slave { Tk_Window tkwin; /* Tk's token for window. */ + Tk_Window inTkwin; /* Token for the -in window. */ struct Master *masterPtr; /* Pointer to information for window * relative to which tkwin is placed. * This isn't necessarily the logical @@ -43,7 +49,6 @@ typedef struct Slave { * master was deleted or never assigned. */ struct Slave *nextPtr; /* Next in list of windows placed relative * to same master (NULL for end of list). */ - /* * Geometry information for window; where there are both relative * and absolute values for the same attribute (e.g. x and relX) only @@ -51,11 +56,17 @@ typedef struct Slave { */ int x, y; /* X and Y pixel coordinates for tkwin. */ - float relX, relY; /* X and Y coordinates relative to size of + Tcl_Obj *xPtr, *yPtr; /* Tcl_Obj rep's of x, y coords, to keep + * pixel spec. information */ + double relX, relY; /* X and Y coordinates relative to size of * master. */ int width, height; /* Absolute dimensions for tkwin. */ - float relWidth, relHeight; /* Dimensions for tkwin relative to size of + Tcl_Obj *widthPtr; /* Tcl_Obj rep of width, to keep pixel spec */ + Tcl_Obj *heightPtr; /* Tcl_Obj rep of height, to keep pixel spec */ + double relWidth, relHeight; /* Dimensions for tkwin relative to size of * master. */ + Tcl_Obj *relWidthPtr; + Tcl_Obj *relHeightPtr; Tk_Anchor anchor; /* Which point on tkwin is placed at the * given position. */ BorderMode borderMode; /* How to treat borders of master window. */ @@ -63,6 +74,40 @@ typedef struct Slave { * definitions. */ } Slave; +/* + * Type masks for options: + */ +#define IN_MASK 1 + +static 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, (ClientData) 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), + 0, 0, IN_MASK}, + {TK_OPTION_DOUBLE, "-relheight", NULL, NULL, "", + Tk_Offset(Slave, relHeightPtr), Tk_Offset(Slave, relHeight), + TK_OPTION_NULL_OK, 0, 0}, + {TK_OPTION_DOUBLE, "-relwidth", NULL, NULL, "", + Tk_Offset(Slave, relWidthPtr), Tk_Offset(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, (char *) NULL, (char *) NULL, (char *) NULL, + (char *) NULL, 0, -1, 0, 0, 0} +}; + /* * Flag definitions for Slave structures: * @@ -121,8 +166,13 @@ static Tk_GeomMgr placerType = { static void SlaveStructureProc _ANSI_ARGS_((ClientData clientData, XEvent *eventPtr)); static int ConfigureSlave _ANSI_ARGS_((Tcl_Interp *interp, - Slave *slavePtr, int argc, char **argv)); + Tk_Window tkwin, Tk_OptionTable table, + int objc, Tcl_Obj *CONST objv[])); +static int PlaceInfoCommand _ANSI_ARGS_((Tcl_Interp *interp, + Tk_Window tkwin)); +static Slave * CreateSlave _ANSI_ARGS_((Tk_Window tkwin)); static Slave * FindSlave _ANSI_ARGS_((Tk_Window tkwin)); +static Master * CreateMaster _ANSI_ARGS_((Tk_Window tkwin)); static Master * FindMaster _ANSI_ARGS_((Tk_Window tkwin)); static void MasterStructureProc _ANSI_ARGS_((ClientData clientData, XEvent *eventPtr)); @@ -132,7 +182,7 @@ static void UnlinkSlave _ANSI_ARGS_((Slave *slavePtr)); /* *-------------------------------------------------------------- * - * Tk_PlaceCmd -- + * Tk_PlaceObjCmd -- * * This procedure is invoked to process the "place" Tcl * commands. See the user documentation for details on @@ -148,33 +198,43 @@ static void UnlinkSlave _ANSI_ARGS_((Slave *slavePtr)); */ int -Tk_PlaceCmd(clientData, interp, argc, argv) - ClientData clientData; /* Main window associated with interpreter. */ +Tk_PlaceObjCmd(clientData, interp, objc, objv) + ClientData clientData; /* NULL. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window tkwin; Slave *slavePtr; - Tcl_HashEntry *hPtr; - size_t length; - int c; + char *string; TkDisplay *dispPtr; - - if (argc < 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " option|pathName args", (char *) NULL); + Tk_OptionTable optionTable; + static CONST char *optionStrings[] = { + "configure", "forget", "info", "slaves", (char *) NULL + }; + enum options { PLACE_CONFIGURE, PLACE_FORGET, PLACE_INFO, PLACE_SLAVES }; + int index; + + + if (objc < 3) { + Tcl_WrongNumArgs(interp, 1, objv, "option|pathName args"); return TCL_ERROR; } - c = argv[1][0]; - length = strlen(argv[1]); + + /* + * Create the option table for this widget class. If it has already + * been created, the cached pointer will be returned. + */ + + optionTable = Tk_CreateOptionTable(interp, optionSpecs); /* * Handle special shortcut where window name is first argument. */ - if (c == '.') { - tkwin = Tk_NameToWindow(interp, argv[1], (Tk_Window) clientData); + string = Tcl_GetString(objv[1]); + if (string[0] == '.') { + tkwin = Tk_NameToWindow(interp, string, Tk_MainWindow(interp)); if (tkwin == NULL) { return TCL_ERROR; } @@ -190,8 +250,7 @@ Tk_PlaceCmd(clientData, interp, argc, argv) dispPtr->placeInit = 1; } - slavePtr = FindSlave(tkwin); - return ConfigureSlave(interp, slavePtr, argc-2, argv+2); + return ConfigureSlave(interp, tkwin, optionTable, objc-2, objv+2); } /* @@ -199,7 +258,8 @@ Tk_PlaceCmd(clientData, interp, argc, argv) * by possible additional arguments. */ - tkwin = Tk_NameToWindow(interp, argv[2], (Tk_Window) clientData); + tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]), + Tk_MainWindow(interp)); if (tkwin == NULL) { return TCL_ERROR; } @@ -215,131 +275,102 @@ Tk_PlaceCmd(clientData, interp, argc, argv) dispPtr->placeInit = 1; } - if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)) { - if (argc < 5) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], - " configure pathName option value ?option value ...?\"", - (char *) NULL); - return TCL_ERROR; - } - slavePtr = FindSlave(tkwin); - return ConfigureSlave(interp, slavePtr, argc-3, argv+3); - } else if ((c == 'f') && (strncmp(argv[1], "forget", length) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " forget pathName\"", (char *) NULL); - return TCL_ERROR; - } - hPtr = Tcl_FindHashEntry(&dispPtr->slaveTable, (char *) tkwin); - if (hPtr == NULL) { - return TCL_OK; - } - slavePtr = (Slave *) Tcl_GetHashValue(hPtr); - if ((slavePtr->masterPtr != NULL) && - (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin))) { - Tk_UnmaintainGeometry(slavePtr->tkwin, - slavePtr->masterPtr->tkwin); - } - UnlinkSlave(slavePtr); - Tcl_DeleteHashEntry(hPtr); - Tk_DeleteEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc, - (ClientData) slavePtr); - Tk_ManageGeometry(tkwin, (Tk_GeomMgr *) NULL, (ClientData) NULL); - Tk_UnmapWindow(tkwin); - ckfree((char *) slavePtr); - } else if ((c == 'i') && (strncmp(argv[1], "info", length) == 0)) { - char buffer[32 + TCL_INTEGER_SPACE]; + if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, + &index) != TCL_OK) { + return TCL_ERROR; + } - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " info pathName\"", (char *) NULL); - return TCL_ERROR; - } - hPtr = Tcl_FindHashEntry(&dispPtr->slaveTable, (char *) tkwin); - if (hPtr == NULL) { - return TCL_OK; - } - slavePtr = (Slave *) Tcl_GetHashValue(hPtr); - sprintf(buffer, "-x %d", slavePtr->x); - Tcl_AppendResult(interp, buffer, (char *) NULL); - sprintf(buffer, " -relx %.4g", slavePtr->relX); - Tcl_AppendResult(interp, buffer, (char *) NULL); - sprintf(buffer, " -y %d", slavePtr->y); - Tcl_AppendResult(interp, buffer, (char *) NULL); - sprintf(buffer, " -rely %.4g", slavePtr->relY); - Tcl_AppendResult(interp, buffer, (char *) NULL); - if (slavePtr->flags & CHILD_WIDTH) { - sprintf(buffer, " -width %d", slavePtr->width); - Tcl_AppendResult(interp, buffer, (char *) NULL); - } else { - Tcl_AppendResult(interp, " -width {}", (char *) NULL); - } - if (slavePtr->flags & CHILD_REL_WIDTH) { - sprintf(buffer, " -relwidth %.4g", slavePtr->relWidth); - Tcl_AppendResult(interp, buffer, (char *) NULL); - } else { - Tcl_AppendResult(interp, " -relwidth {}", (char *) NULL); + switch ((enum options) index) { + case PLACE_CONFIGURE: { + Tcl_Obj *objPtr; + if (objc == 3 || objc == 4) { + slavePtr = FindSlave(tkwin); + if (slavePtr == NULL) { + return TCL_OK; + } + objPtr = Tk_GetOptionInfo(interp, (char *) slavePtr, + optionTable, + (objc == 4) ? objv[3] : (Tcl_Obj *) NULL, tkwin); + if (objPtr == NULL) { + return TCL_ERROR; + } else { + Tcl_SetObjResult(interp, objPtr); + return TCL_OK; + } + } else { + return ConfigureSlave(interp, tkwin, optionTable, objc-3, + objv+3); + } } - if (slavePtr->flags & CHILD_HEIGHT) { - sprintf(buffer, " -height %d", slavePtr->height); - Tcl_AppendResult(interp, buffer, (char *) NULL); - } else { - Tcl_AppendResult(interp, " -height {}", (char *) NULL); + + case PLACE_FORGET: { + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "pathName"); + return TCL_ERROR; + } + slavePtr = FindSlave(tkwin); + if (slavePtr == NULL) { + return TCL_OK; + } + if ((slavePtr->masterPtr != NULL) && + (slavePtr->masterPtr->tkwin != + Tk_Parent(slavePtr->tkwin))) { + Tk_UnmaintainGeometry(slavePtr->tkwin, + slavePtr->masterPtr->tkwin); + } + UnlinkSlave(slavePtr); + Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable, + (char *) tkwin)); + Tk_DeleteEventHandler(tkwin, StructureNotifyMask, + SlaveStructureProc, (ClientData) slavePtr); + Tk_ManageGeometry(tkwin, (Tk_GeomMgr *) NULL, (ClientData) NULL); + Tk_UnmapWindow(tkwin); + ckfree((char *) slavePtr); + break; } - if (slavePtr->flags & CHILD_REL_HEIGHT) { - sprintf(buffer, " -relheight %.4g", slavePtr->relHeight); - Tcl_AppendResult(interp, buffer, (char *) NULL); - } else { - Tcl_AppendResult(interp, " -relheight {}", (char *) NULL); + + case PLACE_INFO: { + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "pathName"); + return TCL_ERROR; + } + return PlaceInfoCommand(interp, tkwin); } - Tcl_AppendResult(interp, " -anchor ", Tk_NameOfAnchor(slavePtr->anchor), - (char *) NULL); - if (slavePtr->borderMode == BM_OUTSIDE) { - Tcl_AppendResult(interp, " -bordermode outside", (char *) NULL); - } else if (slavePtr->borderMode == BM_IGNORE) { - Tcl_AppendResult(interp, " -bordermode ignore", (char *) NULL); - } - if ((slavePtr->masterPtr != NULL) - && (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin))) { - Tcl_AppendResult(interp, " -in ", - Tk_PathName(slavePtr->masterPtr->tkwin), (char *) NULL); - } - } else if ((c == 's') && (strncmp(argv[1], "slaves", length) == 0)) { - if (argc != 3) { - Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " slaves pathName\"", (char *) NULL); - return TCL_ERROR; - } - hPtr = Tcl_FindHashEntry(&dispPtr->masterTable, (char *) tkwin); - if (hPtr != NULL) { + case PLACE_SLAVES: { Master *masterPtr; - masterPtr = (Master *) Tcl_GetHashValue(hPtr); - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - Tcl_AppendElement(interp, Tk_PathName(slavePtr->tkwin)); + Tcl_Obj *listPtr; + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "pathName"); + return TCL_ERROR; } + masterPtr = FindMaster(tkwin); + if (masterPtr != NULL) { + listPtr = Tcl_NewObj(); + for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; + slavePtr = slavePtr->nextPtr) { + Tcl_ListObjAppendElement(interp, listPtr, + Tcl_NewStringObj(Tk_PathName(slavePtr->tkwin),-1)); + } + Tcl_SetObjResult(interp, listPtr); + } + break; } - } else { - Tcl_AppendResult(interp, "unknown or ambiguous option \"", argv[1], - "\": must be configure, forget, info, or slaves", - (char *) NULL); - return TCL_ERROR; } + return TCL_OK; } /* *---------------------------------------------------------------------- * - * FindSlave -- + * CreateSlave -- * * Given a Tk_Window token, find the Slave structure corresponding - * to that token (making a new one if necessary). + * to that token, creating a new one if necessary. * * Results: - * None. + * Pointer to the Slave structure. * * Side effects: * A new Slave structure may be created. @@ -348,7 +379,7 @@ Tk_PlaceCmd(clientData, interp, argc, argv) */ static Slave * -FindSlave(tkwin) +CreateSlave(tkwin) Tk_Window tkwin; /* Token for desired slave. */ { Tcl_HashEntry *hPtr; @@ -359,16 +390,11 @@ FindSlave(tkwin) hPtr = Tcl_CreateHashEntry(&dispPtr->slaveTable, (char *) tkwin, &new); if (new) { slavePtr = (Slave *) ckalloc(sizeof(Slave)); - slavePtr->tkwin = tkwin; - slavePtr->masterPtr = NULL; - slavePtr->nextPtr = NULL; - slavePtr->x = slavePtr->y = 0; - slavePtr->relX = slavePtr->relY = (float) 0.0; - slavePtr->width = slavePtr->height = 0; - slavePtr->relWidth = slavePtr->relHeight = (float) 0.0; - slavePtr->anchor = TK_ANCHOR_NW; - slavePtr->borderMode = BM_INSIDE; - slavePtr->flags = 0; + memset(slavePtr, 0, sizeof(Slave)); + slavePtr->tkwin = tkwin; + slavePtr->inTkwin = None; + slavePtr->anchor = TK_ANCHOR_NW; + slavePtr->borderMode = BM_INSIDE; Tcl_SetHashValue(hPtr, slavePtr); Tk_CreateEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc, (ClientData) slavePtr); @@ -379,6 +405,40 @@ FindSlave(tkwin) return slavePtr; } +/* + *---------------------------------------------------------------------- + * + * FindSlave -- + * + * Given a Tk_Window token, find the Slave structure corresponding + * to that token. This is purely a lookup function; it will not + * create a record if one does not yet exist. + * + * Results: + * Pointer to Slave structure; NULL if none exists. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static Slave * +FindSlave(tkwin) + Tk_Window tkwin; /* Token for desired slave. */ +{ + Tcl_HashEntry *hPtr; + register Slave *slavePtr; + TkDisplay * dispPtr = ((TkWindow *) tkwin)->dispPtr; + + hPtr = Tcl_FindHashEntry(&dispPtr->slaveTable, (char *) tkwin); + if (hPtr == NULL) { + return NULL; + } + slavePtr = (Slave *) Tcl_GetHashValue(hPtr); + return slavePtr; +} + /* *---------------------------------------------------------------------- * @@ -427,13 +487,13 @@ UnlinkSlave(slavePtr) /* *---------------------------------------------------------------------- * - * FindMaster -- + * CreateMaster -- * * Given a Tk_Window token, find the Master structure corresponding - * to that token (making a new one if necessary). + * to that token, creating a new one if necessary. * * Results: - * None. + * Pointer to the Master structure. * * Side effects: * A new Master structure may be created. @@ -442,7 +502,7 @@ UnlinkSlave(slavePtr) */ static Master * -FindMaster(tkwin) +CreateMaster(tkwin) Tk_Window tkwin; /* Token for desired master. */ { Tcl_HashEntry *hPtr; @@ -453,9 +513,9 @@ FindMaster(tkwin) hPtr = Tcl_CreateHashEntry(&dispPtr->masterTable, (char *) tkwin, &new); if (new) { masterPtr = (Master *) ckalloc(sizeof(Master)); - masterPtr->tkwin = tkwin; - masterPtr->slavePtr = NULL; - masterPtr->flags = 0; + masterPtr->tkwin = tkwin; + masterPtr->slavePtr = NULL; + masterPtr->flags = 0; Tcl_SetHashValue(hPtr, masterPtr); Tk_CreateEventHandler(masterPtr->tkwin, StructureNotifyMask, MasterStructureProc, (ClientData) masterPtr); @@ -465,6 +525,41 @@ FindMaster(tkwin) return masterPtr; } +/* + *---------------------------------------------------------------------- + * + * FindMaster -- + * + * Given a Tk_Window token, find the Master structure corresponding + * to that token. This is simply a lookup procedure; a new record + * will not be created if one does not already exist. + * + * Results: + * Pointer to the Master structure; NULL if one does not exist for + * the given Tk_Window token. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static Master * +FindMaster(tkwin) + Tk_Window tkwin; /* Token for desired master. */ +{ + Tcl_HashEntry *hPtr; + register Master *masterPtr; + TkDisplay * dispPtr = ((TkWindow *) tkwin)->dispPtr; + + hPtr = Tcl_FindHashEntry(&dispPtr->masterTable, (char *) tkwin); + if (hPtr == NULL) { + return NULL; + } + masterPtr = (Master *) Tcl_GetHashValue(hPtr); + return masterPtr; +} + /* *---------------------------------------------------------------------- * @@ -485,191 +580,107 @@ FindMaster(tkwin) */ static int -ConfigureSlave(interp, slavePtr, argc, argv) +ConfigureSlave(interp, tkwin, table, objc, objv) Tcl_Interp *interp; /* Used for error reporting. */ - Slave *slavePtr; /* Pointer to current information - * about slave. */ - int argc; /* Number of config arguments. */ - char **argv; /* String values for arguments. */ + Tk_Window tkwin; /* Token for the window to manipulate. */ + Tk_OptionTable table; /* Token for option table. */ + int objc; /* Number of config arguments. */ + Tcl_Obj *CONST objv[]; /* Object values for arguments. */ { register Master *masterPtr; - int c, result; - size_t length; - double d; - - result = TCL_OK; - if (Tk_IsTopLevel(slavePtr->tkwin)) { + Tk_SavedOptions savedOptions; + int mask; + int result = TCL_OK; + Slave *slavePtr; + + if (Tk_TopWinHierarchy(tkwin)) { Tcl_AppendResult(interp, "can't use placer on top-level window \"", - Tk_PathName(slavePtr->tkwin), "\"; use wm command instead", + Tk_PathName(tkwin), "\"; use wm command instead", (char *) NULL); return TCL_ERROR; } - for ( ; argc > 0; argc -= 2, argv += 2) { - if (argc < 2) { - Tcl_AppendResult(interp, "extra option \"", argv[0], - "\" (option with no value?)", (char *) NULL); - result = TCL_ERROR; - goto done; - } - length = strlen(argv[0]); - c = argv[0][1]; - if ((c == 'a') && (strncmp(argv[0], "-anchor", length) == 0)) { - if (Tk_GetAnchor(interp, argv[1], &slavePtr->anchor) != TCL_OK) { - result = TCL_ERROR; - goto done; - } - } else if ((c == 'b') - && (strncmp(argv[0], "-bordermode", length) == 0)) { - c = argv[1][0]; - length = strlen(argv[1]); - if ((c == 'i') && (strncmp(argv[1], "ignore", length) == 0) - && (length >= 2)) { - slavePtr->borderMode = BM_IGNORE; - } else if ((c == 'i') && (strncmp(argv[1], "inside", length) == 0) - && (length >= 2)) { - slavePtr->borderMode = BM_INSIDE; - } else if ((c == 'o') - && (strncmp(argv[1], "outside", length) == 0)) { - slavePtr->borderMode = BM_OUTSIDE; - } else { - Tcl_AppendResult(interp, "bad border mode \"", argv[1], - "\": must be ignore, inside, or outside", - (char *) NULL); - result = TCL_ERROR; - goto done; - } - } else if ((c == 'h') && (strncmp(argv[0], "-height", length) == 0)) { - if (argv[1][0] == 0) { - slavePtr->flags &= ~CHILD_HEIGHT; - } else { - if (Tk_GetPixels(interp, slavePtr->tkwin, argv[1], - &slavePtr->height) != TCL_OK) { - result = TCL_ERROR; - goto done; - } - slavePtr->flags |= CHILD_HEIGHT; - } - } else if ((c == 'i') && (strncmp(argv[0], "-in", length) == 0)) { - Tk_Window tkwin; - Tk_Window ancestor; - - tkwin = Tk_NameToWindow(interp, argv[1], slavePtr->tkwin); - if (tkwin == NULL) { - result = TCL_ERROR; - goto done; - } - /* - * Make sure that the new master is either the logical parent - * of the slave or a descendant of that window, and that the - * master and slave aren't the same. - */ + slavePtr = CreateSlave(tkwin); + + if (Tk_SetOptions(interp, (char *)slavePtr, table, objc, objv, + slavePtr->tkwin, &savedOptions, &mask) != TCL_OK) { + Tk_RestoreSavedOptions(&savedOptions); + result = TCL_ERROR; + goto done; + } - for (ancestor = tkwin; ; ancestor = Tk_Parent(ancestor)) { - if (ancestor == Tk_Parent(slavePtr->tkwin)) { - break; - } - if (Tk_IsTopLevel(ancestor)) { - Tcl_AppendResult(interp, "can't place ", - Tk_PathName(slavePtr->tkwin), " relative to ", - Tk_PathName(tkwin), (char *) NULL); - result = TCL_ERROR; - goto done; - } + if (mask & IN_MASK) { + /* -in changed */ + Tk_Window tkwin; + Tk_Window ancestor; + + tkwin = slavePtr->inTkwin; + + /* + * Make sure that the new master is either the logical parent + * of the slave or a descendant of that window, and that the + * master and slave aren't the same. + */ + + for (ancestor = tkwin; ; ancestor = Tk_Parent(ancestor)) { + if (ancestor == Tk_Parent(slavePtr->tkwin)) { + break; } - if (slavePtr->tkwin == tkwin) { + if (Tk_TopWinHierarchy(ancestor)) { Tcl_AppendResult(interp, "can't place ", - Tk_PathName(slavePtr->tkwin), " relative to itself", - (char *) NULL); - result = TCL_ERROR; - goto done; - } - if ((slavePtr->masterPtr != NULL) - && (slavePtr->masterPtr->tkwin == tkwin)) { - /* - * Re-using same old master. Nothing to do. - */ - } else { - if ((slavePtr->masterPtr != NULL) - && (slavePtr->masterPtr->tkwin - != Tk_Parent(slavePtr->tkwin))) { - Tk_UnmaintainGeometry(slavePtr->tkwin, - slavePtr->masterPtr->tkwin); - } - UnlinkSlave(slavePtr); - slavePtr->masterPtr = FindMaster(tkwin); - slavePtr->nextPtr = slavePtr->masterPtr->slavePtr; - slavePtr->masterPtr->slavePtr = slavePtr; - } - } else if ((c == 'r') && (strncmp(argv[0], "-relheight", length) == 0) - && (length >= 5)) { - if (argv[1][0] == 0) { - slavePtr->flags &= ~CHILD_REL_HEIGHT; - } else { - if (Tcl_GetDouble(interp, argv[1], &d) != TCL_OK) { - result = TCL_ERROR; - goto done; - } - slavePtr->relHeight = (float) d; - slavePtr->flags |= CHILD_REL_HEIGHT; - } - } else if ((c == 'r') && (strncmp(argv[0], "-relwidth", length) == 0) - && (length >= 5)) { - if (argv[1][0] == 0) { - slavePtr->flags &= ~CHILD_REL_WIDTH; - } else { - if (Tcl_GetDouble(interp, argv[1], &d) != TCL_OK) { - result = TCL_ERROR; - goto done; - } - slavePtr->relWidth = (float) d; - slavePtr->flags |= CHILD_REL_WIDTH; - } - } else if ((c == 'r') && (strncmp(argv[0], "-relx", length) == 0) - && (length >= 5)) { - if (Tcl_GetDouble(interp, argv[1], &d) != TCL_OK) { - result = TCL_ERROR; - goto done; - } - slavePtr->relX = (float) d; - } else if ((c == 'r') && (strncmp(argv[0], "-rely", length) == 0) - && (length >= 5)) { - if (Tcl_GetDouble(interp, argv[1], &d) != TCL_OK) { - result = TCL_ERROR; - goto done; - } - slavePtr->relY = (float) d; - } else if ((c == 'w') && (strncmp(argv[0], "-width", length) == 0)) { - if (argv[1][0] == 0) { - slavePtr->flags &= ~CHILD_WIDTH; - } else { - if (Tk_GetPixels(interp, slavePtr->tkwin, argv[1], - &slavePtr->width) != TCL_OK) { - result = TCL_ERROR; - goto done; - } - slavePtr->flags |= CHILD_WIDTH; - } - } else if ((c == 'x') && (strncmp(argv[0], "-x", length) == 0)) { - if (Tk_GetPixels(interp, slavePtr->tkwin, argv[1], - &slavePtr->x) != TCL_OK) { - result = TCL_ERROR; - goto done; - } - } else if ((c == 'y') && (strncmp(argv[0], "-y", length) == 0)) { - if (Tk_GetPixels(interp, slavePtr->tkwin, argv[1], - &slavePtr->y) != TCL_OK) { + Tk_PathName(slavePtr->tkwin), " relative to ", + Tk_PathName(tkwin), (char *) NULL); result = TCL_ERROR; + Tk_RestoreSavedOptions(&savedOptions); goto done; } - } else { - Tcl_AppendResult(interp, "unknown or ambiguous option \"", - argv[0], "\": must be -anchor, -bordermode, -height, ", - "-in, -relheight, -relwidth, -relx, -rely, -width, ", - "-x, or -y", (char *) NULL); + } + if (slavePtr->tkwin == tkwin) { + Tcl_AppendResult(interp, "can't place ", + Tk_PathName(slavePtr->tkwin), " relative to itself", + (char *) NULL); result = TCL_ERROR; + Tk_RestoreSavedOptions(&savedOptions); goto done; } + if ((slavePtr->masterPtr != NULL) + && (slavePtr->masterPtr->tkwin == tkwin)) { + /* + * Re-using same old master. Nothing to do. + */ + } else { + if ((slavePtr->masterPtr != NULL) + && (slavePtr->masterPtr->tkwin + != Tk_Parent(slavePtr->tkwin))) { + Tk_UnmaintainGeometry(slavePtr->tkwin, + slavePtr->masterPtr->tkwin); + } + UnlinkSlave(slavePtr); + slavePtr->masterPtr = CreateMaster(tkwin); + slavePtr->nextPtr = slavePtr->masterPtr->slavePtr; + slavePtr->masterPtr->slavePtr = slavePtr; + } + } + + /* + * Set slave flags. First clear the field, then add bits as needed. + */ + + slavePtr->flags = 0; + if (slavePtr->heightPtr) { + slavePtr->flags |= CHILD_HEIGHT; + } + + if (slavePtr->relHeightPtr) { + slavePtr->flags |= CHILD_REL_HEIGHT; + } + + if (slavePtr->relWidthPtr) { + slavePtr->flags |= CHILD_REL_WIDTH; + } + + if (slavePtr->widthPtr) { + slavePtr->flags |= CHILD_WIDTH; } /* @@ -677,14 +688,16 @@ ConfigureSlave(interp, slavePtr, argc, argv) * Then arrange for a placement recalculation in the master. */ + Tk_FreeSavedOptions(&savedOptions); done: masterPtr = slavePtr->masterPtr; if (masterPtr == NULL) { - masterPtr = FindMaster(Tk_Parent(slavePtr->tkwin)); + masterPtr = CreateMaster(Tk_Parent(slavePtr->tkwin)); slavePtr->masterPtr = masterPtr; slavePtr->nextPtr = masterPtr->slavePtr; masterPtr->slavePtr = slavePtr; } + slavePtr->inTkwin = masterPtr->tkwin; if (!(masterPtr->flags & PARENT_RECONFIG_PENDING)) { masterPtr->flags |= PARENT_RECONFIG_PENDING; Tcl_DoWhenIdle(RecomputePlacement, (ClientData) masterPtr); @@ -692,6 +705,88 @@ ConfigureSlave(interp, slavePtr, argc, argv) return result; } +/* + *---------------------------------------------------------------------- + * + * PlaceInfoCommand -- + * + * Implementation of the [place info] subcommand. See the user + * documentation for information on what it does. + * + * Results: + * Standard Tcl result. + * + * Side effects: + * If the given tkwin is managed by the placer, this function will + * put information about that placement in the interp's result. + * + *---------------------------------------------------------------------- + */ + +static int +PlaceInfoCommand(interp, tkwin) + Tcl_Interp *interp; /* Interp into which to place result. */ + Tk_Window tkwin; /* Token for the window to get info on. */ +{ + char buffer[32 + TCL_INTEGER_SPACE]; + Slave *slavePtr; + + slavePtr = FindSlave(tkwin); + if (slavePtr == NULL) { + return TCL_OK; + } + sprintf(buffer, "-x %d", slavePtr->x); + Tcl_AppendResult(interp, buffer, (char *) NULL); + sprintf(buffer, " -relx %.4g", slavePtr->relX); + Tcl_AppendResult(interp, buffer, (char *) NULL); + sprintf(buffer, " -y %d", slavePtr->y); + Tcl_AppendResult(interp, buffer, (char *) NULL); + sprintf(buffer, " -rely %.4g", slavePtr->relY); + Tcl_AppendResult(interp, buffer, (char *) NULL); + if (slavePtr->flags & CHILD_WIDTH) { + sprintf(buffer, " -width %d", slavePtr->width); + Tcl_AppendResult(interp, buffer, (char *) NULL); + } else { + Tcl_AppendResult(interp, " -width {}", (char *) NULL); + } + if (slavePtr->flags & CHILD_REL_WIDTH) { + sprintf(buffer, " -relwidth %.4g", slavePtr->relWidth); + Tcl_AppendResult(interp, buffer, (char *) NULL); + } else { + Tcl_AppendResult(interp, " -relwidth {}", (char *) NULL); + } + if (slavePtr->flags & CHILD_HEIGHT) { + sprintf(buffer, " -height %d", slavePtr->height); + Tcl_AppendResult(interp, buffer, (char *) NULL); + } else { + Tcl_AppendResult(interp, " -height {}", (char *) NULL); + } + if (slavePtr->flags & CHILD_REL_HEIGHT) { + sprintf(buffer, " -relheight %.4g", slavePtr->relHeight); + Tcl_AppendResult(interp, buffer, (char *) NULL); + } else { + Tcl_AppendResult(interp, " -relheight {}", (char *) NULL); + } + + Tcl_AppendResult(interp, " -anchor ", + Tk_NameOfAnchor(slavePtr->anchor), + (char *) NULL); + if (slavePtr->borderMode == BM_OUTSIDE) { + Tcl_AppendResult(interp, " -bordermode outside", + (char *) NULL); + } else if (slavePtr->borderMode == BM_IGNORE) { + Tcl_AppendResult(interp, " -bordermode ignore", (char *) NULL); + } + if ((slavePtr->masterPtr != NULL) + && (slavePtr->masterPtr->tkwin != + Tk_Parent(slavePtr->tkwin))) { + Tcl_AppendResult(interp, " -in ", + Tk_PathName(slavePtr->masterPtr->tkwin), + (char *) NULL); + } + return TCL_OK; +} + /* *---------------------------------------------------------------------- * @@ -716,7 +811,7 @@ RecomputePlacement(clientData) register Master *masterPtr = (Master *) clientData; register Slave *slavePtr; int x, y, width, height, tmp; - int masterWidth, masterHeight, masterBW; + int masterWidth, masterHeight, masterX, masterY; double x1, y1, x2, y2; masterPtr->flags &= ~PARENT_RECONFIG_PENDING; @@ -733,25 +828,29 @@ RecomputePlacement(clientData) * account desired border mode. */ - masterBW = 0; + masterX = masterY = 0; masterWidth = Tk_Width(masterPtr->tkwin); masterHeight = Tk_Height(masterPtr->tkwin); if (slavePtr->borderMode == BM_INSIDE) { - masterBW = Tk_InternalBorderWidth(masterPtr->tkwin); + masterX = Tk_InternalBorderLeft(masterPtr->tkwin); + masterY = Tk_InternalBorderTop(masterPtr->tkwin); + masterWidth -= masterX + Tk_InternalBorderRight(masterPtr->tkwin); + masterHeight -= masterY + + Tk_InternalBorderBottom(masterPtr->tkwin); } else if (slavePtr->borderMode == BM_OUTSIDE) { - masterBW = -Tk_Changes(masterPtr->tkwin)->border_width; + masterX = masterY = -Tk_Changes(masterPtr->tkwin)->border_width; + masterWidth -= 2 * masterX; + masterHeight -= 2 * masterY; } - masterWidth -= 2*masterBW; - masterHeight -= 2*masterBW; /* * Step 2: compute size of slave (outside dimensions including * border) and location of anchor point within master. */ - x1 = slavePtr->x + masterBW + (slavePtr->relX*masterWidth); + x1 = slavePtr->x + masterX + (slavePtr->relX*masterWidth); x = (int) (x1 + ((x1 > 0) ? 0.5 : -0.5)); - y1 = slavePtr->y + masterBW + (slavePtr->relY*masterHeight); + y1 = slavePtr->y + masterY + (slavePtr->relY*masterHeight); y = (int) (y1 + ((y1 > 0) ? 0.5 : -0.5)); if (slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) { width = 0; @@ -1070,5 +1169,3 @@ PlaceLostSlaveProc(clientData, tkwin) (ClientData) slavePtr); ckfree((char *) slavePtr); } - - diff --git a/tk/generic/tkPlatDecls.h b/tk/generic/tkPlatDecls.h index f2c31235b2a..c39e78ae091 100644 --- a/tk/generic/tkPlatDecls.h +++ b/tk/generic/tkPlatDecls.h @@ -25,7 +25,6 @@ * in the generic/tk.decls script. */ - /* !BEGIN!: Do not edit below this line. */ /* @@ -83,6 +82,40 @@ EXTERN int TkMacHaveAppearance _ANSI_ARGS_((void)); /* 10 */ EXTERN GWorldPtr TkMacGetDrawablePort _ANSI_ARGS_((Drawable drawable)); #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +/* 0 */ +EXTERN void Tk_MacOSXSetEmbedHandler _ANSI_ARGS_(( + Tk_MacOSXEmbedRegisterWinProc * registerWinProcPtr, + Tk_MacOSXEmbedGetGrafPortProc * getPortProcPtr, + Tk_MacOSXEmbedMakeContainerExistProc * containerExistProcPtr, + Tk_MacOSXEmbedGetClipProc * getClipProc, + Tk_MacOSXEmbedGetOffsetInParentProc * getOffsetProc)); +/* 1 */ +EXTERN void Tk_MacOSXTurnOffMenus _ANSI_ARGS_((void)); +/* 2 */ +EXTERN void Tk_MacOSXTkOwnsCursor _ANSI_ARGS_((int tkOwnsIt)); +/* 3 */ +EXTERN void TkMacOSXInitMenus _ANSI_ARGS_((Tcl_Interp * interp)); +/* 4 */ +EXTERN void TkMacOSXInitAppleEvents _ANSI_ARGS_(( + Tcl_Interp * interp)); +/* 5 */ +EXTERN void TkGenWMConfigureEvent _ANSI_ARGS_((Tk_Window tkwin, + int x, int y, int width, int height, + int flags)); +/* 6 */ +EXTERN void TkMacOSXInvalClipRgns _ANSI_ARGS_((TkWindow * winPtr)); +/* 7 */ +EXTERN GWorldPtr TkMacOSXGetDrawablePort _ANSI_ARGS_(( + Drawable drawable)); +/* 8 */ +EXTERN ControlRef TkMacOSXGetRootControl _ANSI_ARGS_(( + Drawable drawable)); +/* 9 */ +EXTERN void Tk_MacOSXSetupTkNotifier _ANSI_ARGS_((void)); +/* 10 */ +EXTERN int Tk_MacOSXIsAppInFront _ANSI_ARGS_((void)); +#endif /* MAC_OSX_TK */ typedef struct TkPlatStubs { int magic; @@ -109,6 +142,19 @@ typedef struct TkPlatStubs { int (*tkMacHaveAppearance) _ANSI_ARGS_((void)); /* 9 */ GWorldPtr (*tkMacGetDrawablePort) _ANSI_ARGS_((Drawable drawable)); /* 10 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + void (*tk_MacOSXSetEmbedHandler) _ANSI_ARGS_((Tk_MacOSXEmbedRegisterWinProc * registerWinProcPtr, Tk_MacOSXEmbedGetGrafPortProc * getPortProcPtr, Tk_MacOSXEmbedMakeContainerExistProc * containerExistProcPtr, Tk_MacOSXEmbedGetClipProc * getClipProc, Tk_MacOSXEmbedGetOffsetInParentProc * getOffsetProc)); /* 0 */ + void (*tk_MacOSXTurnOffMenus) _ANSI_ARGS_((void)); /* 1 */ + void (*tk_MacOSXTkOwnsCursor) _ANSI_ARGS_((int tkOwnsIt)); /* 2 */ + void (*tkMacOSXInitMenus) _ANSI_ARGS_((Tcl_Interp * interp)); /* 3 */ + void (*tkMacOSXInitAppleEvents) _ANSI_ARGS_((Tcl_Interp * interp)); /* 4 */ + void (*tkGenWMConfigureEvent) _ANSI_ARGS_((Tk_Window tkwin, int x, int y, int width, int height, int flags)); /* 5 */ + void (*tkMacOSXInvalClipRgns) _ANSI_ARGS_((TkWindow * winPtr)); /* 6 */ + GWorldPtr (*tkMacOSXGetDrawablePort) _ANSI_ARGS_((Drawable drawable)); /* 7 */ + ControlRef (*tkMacOSXGetRootControl) _ANSI_ARGS_((Drawable drawable)); /* 8 */ + void (*tk_MacOSXSetupTkNotifier) _ANSI_ARGS_((void)); /* 9 */ + int (*tk_MacOSXIsAppInFront) _ANSI_ARGS_((void)); /* 10 */ +#endif /* MAC_OSX_TK */ } TkPlatStubs; #ifdef __cplusplus @@ -197,6 +243,52 @@ extern TkPlatStubs *tkPlatStubsPtr; (tkPlatStubsPtr->tkMacGetDrawablePort) /* 10 */ #endif #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK +#ifndef Tk_MacOSXSetEmbedHandler +#define Tk_MacOSXSetEmbedHandler \ + (tkPlatStubsPtr->tk_MacOSXSetEmbedHandler) /* 0 */ +#endif +#ifndef Tk_MacOSXTurnOffMenus +#define Tk_MacOSXTurnOffMenus \ + (tkPlatStubsPtr->tk_MacOSXTurnOffMenus) /* 1 */ +#endif +#ifndef Tk_MacOSXTkOwnsCursor +#define Tk_MacOSXTkOwnsCursor \ + (tkPlatStubsPtr->tk_MacOSXTkOwnsCursor) /* 2 */ +#endif +#ifndef TkMacOSXInitMenus +#define TkMacOSXInitMenus \ + (tkPlatStubsPtr->tkMacOSXInitMenus) /* 3 */ +#endif +#ifndef TkMacOSXInitAppleEvents +#define TkMacOSXInitAppleEvents \ + (tkPlatStubsPtr->tkMacOSXInitAppleEvents) /* 4 */ +#endif +#ifndef TkGenWMConfigureEvent +#define TkGenWMConfigureEvent \ + (tkPlatStubsPtr->tkGenWMConfigureEvent) /* 5 */ +#endif +#ifndef TkMacOSXInvalClipRgns +#define TkMacOSXInvalClipRgns \ + (tkPlatStubsPtr->tkMacOSXInvalClipRgns) /* 6 */ +#endif +#ifndef TkMacOSXGetDrawablePort +#define TkMacOSXGetDrawablePort \ + (tkPlatStubsPtr->tkMacOSXGetDrawablePort) /* 7 */ +#endif +#ifndef TkMacOSXGetRootControl +#define TkMacOSXGetRootControl \ + (tkPlatStubsPtr->tkMacOSXGetRootControl) /* 8 */ +#endif +#ifndef Tk_MacOSXSetupTkNotifier +#define Tk_MacOSXSetupTkNotifier \ + (tkPlatStubsPtr->tk_MacOSXSetupTkNotifier) /* 9 */ +#endif +#ifndef Tk_MacOSXIsAppInFront +#define Tk_MacOSXIsAppInFront \ + (tkPlatStubsPtr->tk_MacOSXIsAppInFront) /* 10 */ +#endif +#endif /* MAC_OSX_TK */ #endif /* defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) */ diff --git a/tk/generic/tkPointer.c b/tk/generic/tkPointer.c index f51e82b7506..b9f26174335 100644 --- a/tk/generic/tkPointer.c +++ b/tk/generic/tkPointer.c @@ -20,7 +20,13 @@ #include "tkWinInt.h" #endif -#ifdef MAC_TCL +#if defined(MAC_TCL) +#include "tkMacInt.h" +#define Cursor XCursor +#endif + +#if defined(MAC_OSX_TK) +#include "tkMacOSXInt.h" #define Cursor XCursor #endif @@ -561,7 +567,7 @@ UpdateCursor(winPtr) if (winPtr->atts.cursor != None) { cursor = winPtr->atts.cursor; break; - } else if (winPtr->flags & TK_TOP_LEVEL) { + } else if (winPtr->flags & TK_TOP_HIERARCHY) { break; } winPtr = winPtr->parentPtr; @@ -645,4 +651,3 @@ TkGenerateActivateEvents(winPtr, active) TkQueueEventForAllChildren(winPtr, &event); } - diff --git a/tk/generic/tkPort.h b/tk/generic/tkPort.h index aef9026bcc6..bf4b6e6e87e 100644 --- a/tk/generic/tkPort.h +++ b/tk/generic/tkPort.h @@ -28,10 +28,11 @@ #else # if defined(MAC_TCL) # include "tkMacPort.h" +# elif defined(MAC_OSX_TK) +# include "../macosx/tkMacOSXPort.h" # else # include "../unix/tkUnixPort.h" # endif #endif #endif /* _TKPORT */ - diff --git a/tk/generic/tkRectOval.c b/tk/generic/tkRectOval.c index 0bb54885371..7fb0c1e3f8f 100644 --- a/tk/generic/tkRectOval.c +++ b/tk/generic/tkRectOval.c @@ -142,11 +142,11 @@ static Tk_ConfigSpec configSpecs[] = { static void ComputeRectOvalBbox _ANSI_ARGS_((Tk_Canvas canvas, RectOvalItem *rectOvalPtr)); static int ConfigureRectOval _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int argc, - Tcl_Obj *CONST argv[], int flags)); + Tk_Canvas canvas, Tk_Item *itemPtr, int objc, + Tcl_Obj *CONST objv[], int flags)); static int CreateRectOval _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, - int argc, Tcl_Obj *CONST argv[])); + int objc, Tcl_Obj *CONST objv[])); static void DeleteRectOval _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, Display *display)); static void DisplayRectOval _ANSI_ARGS_((Tk_Canvas canvas, @@ -157,8 +157,8 @@ static int OvalToArea _ANSI_ARGS_((Tk_Canvas canvas, static double OvalToPoint _ANSI_ARGS_((Tk_Canvas canvas, Tk_Item *itemPtr, double *pointPtr)); static int RectOvalCoords _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int argc, - Tcl_Obj *CONST argv[])); + Tk_Canvas canvas, Tk_Item *itemPtr, int objc, + Tcl_Obj *CONST objv[])); static int RectOvalToPostscript _ANSI_ARGS_((Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int prepass)); static int RectToArea _ANSI_ARGS_((Tk_Canvas canvas, @@ -243,31 +243,28 @@ Tk_ItemType tkOvalType = { */ static int -CreateRectOval(interp, canvas, itemPtr, argc, argv) +CreateRectOval(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* For error reporting. */ Tk_Canvas canvas; /* Canvas to hold new item. */ Tk_Item *itemPtr; /* Record to hold new item; header * has been initialized by caller. */ - int argc; /* Number of arguments in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing rectangle. */ + int objc; /* Number of arguments in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing rectangle. */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; - int i; + int i = 4; - if (argc==1) { + if (objc == 1) { i = 1; - } else { - char *arg = Tcl_GetStringFromObj(argv[1], NULL); - if ((argc>1) && (arg[0] == '-') - && (arg[1] >= 'a') && (arg[1] <= 'z')) { + } else if (objc > 1) { + char *arg = Tcl_GetString(objv[1]); + if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) { i = 1; - } else { - i = 4; } } - if (argc < i) { + if (objc < i) { Tcl_AppendResult(interp, "wrong # args: should be \"", Tk_PathName(Tk_CanvasTkwin(canvas)), " create ", itemPtr->typePtr->name, " x1 y1 x2 y2 ?options?\"", @@ -296,10 +293,10 @@ CreateRectOval(interp, canvas, itemPtr, argc, argv) * Process the arguments to fill in the item record. */ - if ((RectOvalCoords(interp, canvas, itemPtr, i, argv) != TCL_OK)) { + if ((RectOvalCoords(interp, canvas, itemPtr, i, objv) != TCL_OK)) { goto error; } - if (ConfigureRectOval(interp, canvas, itemPtr, argc-i, argv+i, 0) + if (ConfigureRectOval(interp, canvas, itemPtr, objc-i, objv+i, 0) == TCL_OK) { return TCL_OK; } @@ -328,19 +325,19 @@ CreateRectOval(interp, canvas, itemPtr, argc, argv) */ static int -RectOvalCoords(interp, canvas, itemPtr, argc, argv) +RectOvalCoords(interp, canvas, itemPtr, objc, objv) Tcl_Interp *interp; /* Used for error reporting. */ Tk_Canvas canvas; /* Canvas containing item. */ Tk_Item *itemPtr; /* Item whose coordinates are to be * read or modified. */ - int argc; /* Number of coordinates supplied in - * argv. */ - Tcl_Obj *CONST argv[]; /* Array of coordinates: x1, y1, + int objc; /* Number of coordinates supplied in + * objv. */ + Tcl_Obj *CONST objv[]; /* Array of coordinates: x1, y1, * x2, y2, ... */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; - if (argc == 0) { + if (objc == 0) { Tcl_Obj *obj = Tcl_NewObj(); Tcl_Obj *subobj = Tcl_NewDoubleObj(rectOvalPtr->bbox[0]); Tcl_ListObjAppendElement(interp, obj, subobj); @@ -351,26 +348,26 @@ RectOvalCoords(interp, canvas, itemPtr, argc, argv) subobj = Tcl_NewDoubleObj(rectOvalPtr->bbox[3]); Tcl_ListObjAppendElement(interp, obj, subobj); Tcl_SetObjResult(interp, obj); - } else if ((argc == 1)||(argc == 4)) { - if (argc==1) { - if (Tcl_ListObjGetElements(interp, argv[0], &argc, - (Tcl_Obj ***) &argv) != TCL_OK) { + } else if ((objc == 1)||(objc == 4)) { + if (objc==1) { + if (Tcl_ListObjGetElements(interp, objv[0], &objc, + (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; - } else if (argc != 4) { + } else if (objc != 4) { char buf[64 + TCL_INTEGER_SPACE]; - sprintf(buf, "wrong # coordinates: expected 0 or 4, got %d", argc); + sprintf(buf, "wrong # coordinates: expected 0 or 4, got %d", objc); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_ERROR; } } - if ((Tk_CanvasGetCoordFromObj(interp, canvas, argv[0], + if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], &rectOvalPtr->bbox[0]) != TCL_OK) - || (Tk_CanvasGetCoordFromObj(interp, canvas, argv[1], + || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], &rectOvalPtr->bbox[1]) != TCL_OK) - || (Tk_CanvasGetCoordFromObj(interp, canvas, argv[2], + || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[2], &rectOvalPtr->bbox[2]) != TCL_OK) - || (Tk_CanvasGetCoordFromObj(interp, canvas, argv[3], + || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[3], &rectOvalPtr->bbox[3]) != TCL_OK)) { return TCL_ERROR; } @@ -378,7 +375,7 @@ RectOvalCoords(interp, canvas, itemPtr, argc, argv) } else { char buf[64 + TCL_INTEGER_SPACE]; - sprintf(buf, "wrong # coordinates: expected 0 or 4, got %d", argc); + sprintf(buf, "wrong # coordinates: expected 0 or 4, got %d", objc); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_ERROR; } @@ -406,12 +403,12 @@ RectOvalCoords(interp, canvas, itemPtr, argc, argv) */ static int -ConfigureRectOval(interp, canvas, itemPtr, argc, argv, flags) +ConfigureRectOval(interp, canvas, itemPtr, objc, objv, flags) Tcl_Interp *interp; /* Used for error reporting. */ Tk_Canvas canvas; /* Canvas containing itemPtr. */ Tk_Item *itemPtr; /* Rectangle item to reconfigure. */ - int argc; /* Number of elements in argv. */ - Tcl_Obj *CONST argv[]; /* Arguments describing things to configure. */ + int objc; /* Number of elements in objv. */ + Tcl_Obj *CONST objv[]; /* Arguments describing things to configure. */ int flags; /* Flags to pass to Tk_ConfigureWidget. */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; @@ -426,8 +423,8 @@ ConfigureRectOval(interp, canvas, itemPtr, argc, argv, flags) tkwin = Tk_CanvasTkwin(canvas); - if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, (char **) argv, - (char *) rectOvalPtr, flags|TK_CONFIG_OBJS) != TCL_OK) { + if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, + (CONST char **) objv, (char *) rectOvalPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } state = itemPtr->state; @@ -1392,5 +1389,3 @@ RectOvalToPostscript(interp, canvas, itemPtr, prepass) } return TCL_OK; } - - diff --git a/tk/generic/tkScale.c b/tk/generic/tkScale.c index fb88fc3da7f..0b260726af1 100644 --- a/tk/generic/tkScale.c +++ b/tk/generic/tkScale.c @@ -147,7 +147,7 @@ static Tk_OptionSpec optionSpecs[] = { * to dispatch the scale widget command. */ -static char *commandNames[] = { +static CONST char *commandNames[] = { "cget", "configure", "coords", "get", "identify", "set", (char *) NULL }; @@ -171,8 +171,8 @@ static void ScaleCmdDeletedProc _ANSI_ARGS_(( static void ScaleEventProc _ANSI_ARGS_((ClientData clientData, XEvent *eventPtr)); static char * ScaleVarProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, char *name1, char *name2, - int flags)); + Tcl_Interp *interp, CONST char *name1, + CONST char *name2, int flags)); static int ScaleWidgetObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); @@ -185,10 +185,9 @@ static void ScaleSetVariable _ANSI_ARGS_((TkScale *scalePtr)); * that can be invoked from generic window code. */ -static TkClassProcs scaleClass = { - NULL, /* createProc. */ - ScaleWorldChanged, /* geometryProc. */ - NULL /* modalProc. */ +static Tk_ClassProcs scaleClass = { + sizeof(Tk_ClassProcs), /* size */ + ScaleWorldChanged, /* worldChangedProc */ }; @@ -212,7 +211,7 @@ static TkClassProcs scaleClass = { int Tk_ScaleObjCmd(clientData, interp, objc, objv) - ClientData clientData; /* Either NULL or pointer to option table. */ + ClientData clientData; /* NULL. */ Tcl_Interp *interp; /* Current interpreter. */ int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument values. */ @@ -221,25 +220,6 @@ Tk_ScaleObjCmd(clientData, interp, objc, objv) Tk_OptionTable optionTable; Tk_Window tkwin; - optionTable = (Tk_OptionTable) clientData; - if (optionTable == NULL) { - Tcl_CmdInfo info; - char *name; - - /* - * We haven't created the option table for this widget class - * yet. Do it now and save the table as the clientData for - * the command, so we'll have access to it in future - * invocations of the command. - */ - - optionTable = Tk_CreateOptionTable(interp, optionSpecs); - name = Tcl_GetString(objv[0]); - Tcl_GetCommandInfo(interp, name, &info); - info.objClientData = (ClientData) optionTable; - Tcl_SetCommandInfo(interp, name, &info); - } - if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); return TCL_ERROR; @@ -251,6 +231,13 @@ Tk_ScaleObjCmd(clientData, interp, objc, objv) return TCL_ERROR; } + /* + * Create the option table for this widget class. If it has already + * been created, the cached pointer will be returned. + */ + + optionTable = Tk_CreateOptionTable(interp, optionSpecs); + Tk_SetClass(tkwin, "Scale"); scalePtr = TkpCreateScale(tkwin); @@ -314,7 +301,7 @@ Tk_ScaleObjCmd(clientData, interp, objc, objv) scalePtr->takeFocusPtr = NULL; scalePtr->flags = NEVER_SET; - TkSetClassProcs(scalePtr->tkwin, &scaleClass, (ClientData) scalePtr); + Tk_SetClassProcs(scalePtr->tkwin, &scaleClass, (ClientData) scalePtr); Tk_CreateEventHandler(scalePtr->tkwin, ExposureMask|StructureNotifyMask|FocusChangeMask, ScaleEventProc, (ClientData) scalePtr); @@ -1198,8 +1185,8 @@ static char * ScaleVarProc(clientData, interp, name1, name2, flags) ClientData clientData; /* Information about button. */ Tcl_Interp *interp; /* Interpreter containing variable. */ - char *name1; /* Name of variable. */ - char *name2; /* Second part of variable name. */ + CONST char *name1; /* Name of variable. */ + CONST char *name2; /* Second part of variable name. */ int flags; /* Information about what happened. */ { register TkScale *scalePtr = (TkScale *) clientData; diff --git a/tk/generic/tkScale.h b/tk/generic/tkScale.h index 8168aa7171f..972e571fda3 100644 --- a/tk/generic/tkScale.h +++ b/tk/generic/tkScale.h @@ -254,5 +254,3 @@ EXTERN int TkScaleValueToPixel _ANSI_ARGS_((TkScale *scalePtr, # define TCL_STORAGE_CLASS DLLIMPORT #endif /* _TKSCALE */ - - diff --git a/tk/generic/tkScrollbar.c b/tk/generic/tkScrollbar.c index d0f07c59000..d07e5d0e455 100644 --- a/tk/generic/tkScrollbar.c +++ b/tk/generic/tkScrollbar.c @@ -102,12 +102,12 @@ Tk_ConfigSpec tkpScrollbarConfigSpecs[] = { */ static int ConfigureScrollbar _ANSI_ARGS_((Tcl_Interp *interp, - TkScrollbar *scrollPtr, int argc, char **argv, + TkScrollbar *scrollPtr, int argc, CONST char **argv, int flags)); static void ScrollbarCmdDeletedProc _ANSI_ARGS_(( ClientData clientData)); static int ScrollbarWidgetCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *, int argc, char **argv)); + Tcl_Interp *, int argc, CONST char **argv)); /* *-------------------------------------------------------------- @@ -133,7 +133,7 @@ Tk_ScrollbarCmd(clientData, interp, argc, argv) * interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { Tk_Window tkwin = (Tk_Window) clientData; register TkScrollbar *scrollPtr; @@ -153,7 +153,7 @@ Tk_ScrollbarCmd(clientData, interp, argc, argv) Tk_SetClass(new, "Scrollbar"); scrollPtr = TkpCreateScrollbar(new); - TkSetClassProcs(new, &tkpScrollbarProcs, (ClientData) scrollPtr); + Tk_SetClassProcs(new, &tkpScrollbarProcs, (ClientData) scrollPtr); /* * Initialize fields that won't be initialized by ConfigureScrollbar, @@ -231,7 +231,7 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) * widget. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { register TkScrollbar *scrollPtr = (TkScrollbar *) clientData; int result = TCL_OK; @@ -538,7 +538,7 @@ ConfigureScrollbar(interp, scrollPtr, argc, argv, flags) * may not already have values for * some fields. */ int argc; /* Number of valid entries in argv. */ - char **argv; /* Arguments. */ + CONST char **argv; /* Arguments. */ int flags; /* Flags to pass to * Tk_ConfigureWidget. */ { @@ -709,4 +709,3 @@ TkScrollbarEventuallyRedraw(scrollPtr) scrollPtr->flags |= REDRAW_PENDING; } } - diff --git a/tk/generic/tkScrollbar.h b/tk/generic/tkScrollbar.h index c6580640434..84cb80a75e9 100644 --- a/tk/generic/tkScrollbar.h +++ b/tk/generic/tkScrollbar.h @@ -171,7 +171,7 @@ typedef struct TkScrollbar { * Declaration of scrollbar class procedures structure. */ -extern TkClassProcs tkpScrollbarProcs; +extern Tk_ClassProcs tkpScrollbarProcs; /* * Declaration of scrollbar configuration options. @@ -204,4 +204,3 @@ EXTERN int TkpScrollbarPosition _ANSI_ARGS_(( # define TCL_STORAGE_CLASS DLLIMPORT #endif /* _TKSCROLLBAR */ - diff --git a/tk/generic/tkSelect.c b/tk/generic/tkSelect.c index 45821e1e3b4..ea69a7ca90e 100644 --- a/tk/generic/tkSelect.c +++ b/tk/generic/tkSelect.c @@ -177,6 +177,48 @@ Tk_CreateSelHandler(tkwin, selection, target, proc, clientData, format) } else { selPtr->size = 32; } + + if ((target == XA_STRING) && (winPtr->dispPtr->utf8Atom != (Atom) NULL)) { + /* + * If the user asked for a STRING handler and we understand + * UTF8_STRING, we implicitly create a UTF8_STRING handler for them. + */ + + target = winPtr->dispPtr->utf8Atom; + for (selPtr = winPtr->selHandlerList; ; + selPtr = selPtr->nextPtr) { + if (selPtr == NULL) { + selPtr = (TkSelHandler *) ckalloc(sizeof(TkSelHandler)); + selPtr->nextPtr = winPtr->selHandlerList; + winPtr->selHandlerList = selPtr; + selPtr->selection = selection; + selPtr->target = target; + selPtr->format = target; /* We want UTF8_STRING format */ + selPtr->proc = proc; + if (selPtr->proc == HandleTclCommand) { + /* + * The clientData is selection controlled memory, so + * we should make a copy for this selPtr. + */ + selPtr->clientData = + (ClientData) ckalloc(sizeof(clientData)); + memcpy(selPtr->clientData, clientData, sizeof(clientData)); + } else { + selPtr->clientData = clientData; + } + selPtr->size = 8; + break; + } + if ((selPtr->selection == selection) + && (selPtr->target == target)) { + /* + * Looks like we had a utf-8 target already. Leave it alone. + */ + + break; + } + } + } } /* @@ -247,13 +289,43 @@ Tk_DeleteSelHandler(tkwin, selection, target) } else { prevPtr->nextPtr = selPtr->nextPtr; } + + if ((target == XA_STRING) && (winPtr->dispPtr->utf8Atom != (Atom) NULL)) { + /* + * If the user asked for a STRING handler and we understand + * UTF8_STRING, we may have implicitly created a UTF8_STRING handler + * for them. Look for it and delete it as necessary. + */ + TkSelHandler *utf8selPtr; + + target = winPtr->dispPtr->utf8Atom; + for (utf8selPtr = winPtr->selHandlerList; utf8selPtr != NULL; + utf8selPtr = utf8selPtr->nextPtr) { + if ((utf8selPtr->selection == selection) + && (utf8selPtr->target == target)) { + break; + } + } + if (utf8selPtr != NULL) { + if ((utf8selPtr->format == target) + && (utf8selPtr->proc == selPtr->proc) + && (utf8selPtr->size == selPtr->size)) { + /* + * This recursive call is OK, because we've + * changed the value of 'target' + */ + Tk_DeleteSelHandler(tkwin, selection, target); + } + } + } + if (selPtr->proc == HandleTclCommand) { /* * Mark the CommandInfo as deleted and free it if we can. */ ((CommandInfo*)selPtr->clientData)->interp = NULL; - Tcl_EventuallyFree(selPtr->clientData, Tcl_Free); + Tcl_EventuallyFree(selPtr->clientData, TCL_DYNAMIC); } ckfree((char *) selPtr); } @@ -524,8 +596,8 @@ Tk_GetSelection(interp, tkwin, selection, target, proc, clientData) TkSelInProgress ip; for (selPtr = ((TkWindow *) infoPtr->owner)->selHandlerList; - selPtr != NULL; selPtr = selPtr->nextPtr) { - if ((selPtr->target == target) + selPtr != NULL; selPtr = selPtr->nextPtr) { + if ((selPtr->target == target) && (selPtr->selection == selection)) { break; } @@ -589,7 +661,7 @@ Tk_GetSelection(interp, tkwin, selection, target, proc, clientData) /* *-------------------------------------------------------------- * - * Tk_SelectionCmd -- + * Tk_SelectionObjCmd -- * * This procedure is invoked to process the "selection" Tcl * command. See the user documentation for details on what @@ -605,304 +677,351 @@ Tk_GetSelection(interp, tkwin, selection, target, proc, clientData) */ int -Tk_SelectionCmd(clientData, interp, argc, argv) +Tk_SelectionObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Main window associated with * interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ - int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + int objc; /* Number of arguments. */ + Tcl_Obj *CONST objv[]; /* Argument objects. */ { Tk_Window tkwin = (Tk_Window) clientData; char *path = NULL; Atom selection; - char *selName = NULL; - int c, count; - size_t length; - char **args; - - if (argc < 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " option ?arg arg ...?\"", (char *) NULL); + char *selName = NULL, *string; + int count, index; + Tcl_Obj **objs; + static CONST char *optionStrings[] = { + "clear", "get", "handle", "own", (char *) NULL + }; + enum options { SELECTION_CLEAR, SELECTION_GET, SELECTION_HANDLE, + SELECTION_OWN }; + + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?"); return TCL_ERROR; } - c = argv[1][0]; - length = strlen(argv[1]); - if ((c == 'c') && (strncmp(argv[1], "clear", length) == 0)) { - for (count = argc-2, args = argv+2; count > 0; count -= 2, args += 2) { - if (args[0][0] != '-') { - break; + + if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0, + &index) != TCL_OK) { + return TCL_ERROR; + } + + switch ((enum options) index) { + case SELECTION_CLEAR: { + static CONST char *clearOptionStrings[] = { + "-displayof", "-selection", (char *) NULL + }; + enum clearOptions { CLEAR_DISPLAYOF, CLEAR_SELECTION }; + int clearIndex; + + for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count > 0; + count-=2, objs+=2) { + string = Tcl_GetString(objs[0]); + if (string[0] != '-') { + break; + } + if (count < 2) { + Tcl_AppendResult(interp, "value for \"", string, + "\" missing", (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_GetIndexFromObj(interp, objs[0], clearOptionStrings, + "option", 0, &clearIndex) != TCL_OK) { + return TCL_ERROR; + } + switch ((enum clearOptions) clearIndex) { + case CLEAR_DISPLAYOF: + path = Tcl_GetString(objs[1]); + break; + case CLEAR_SELECTION: + selName = Tcl_GetString(objs[1]); + break; + } } - if (count < 2) { - Tcl_AppendResult(interp, "value for \"", *args, - "\" missing", (char *) NULL); + if (count == 1) { + path = Tcl_GetString(objs[0]); + } else if (count > 1) { + Tcl_WrongNumArgs(interp, 2, objv, "?options?"); return TCL_ERROR; } - c = args[0][1]; - length = strlen(args[0]); - if ((c == 'd') && (strncmp(args[0], "-displayof", length) == 0)) { - path = args[1]; - } else if ((c == 's') - && (strncmp(args[0], "-selection", length) == 0)) { - selName = args[1]; - } else { - Tcl_AppendResult(interp, "unknown option \"", args[0], - "\"", (char *) NULL); + if (path != NULL) { + tkwin = Tk_NameToWindow(interp, path, tkwin); + } + if (tkwin == NULL) { return TCL_ERROR; } + if (selName != NULL) { + selection = Tk_InternAtom(tkwin, selName); + } else { + selection = XA_PRIMARY; + } + + Tk_ClearSelection(tkwin, selection); + break; } - if (count == 1) { - path = args[0]; - } else if (count > 1) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " clear ?options?\"", (char *) NULL); - return TCL_ERROR; - } - if (path != NULL) { - tkwin = Tk_NameToWindow(interp, path, tkwin); - } - if (tkwin == NULL) { - return TCL_ERROR; - } - if (selName != NULL) { - selection = Tk_InternAtom(tkwin, selName); - } else { - selection = XA_PRIMARY; - } + + case SELECTION_GET: { + Atom target; + char *targetName = NULL; + Tcl_DString selBytes; + int result; + static CONST char *getOptionStrings[] = { + "-displayof", "-selection", "-type", (char *) NULL + }; + enum getOptions { GET_DISPLAYOF, GET_SELECTION, GET_TYPE }; + int getIndex; - Tk_ClearSelection(tkwin, selection); - return TCL_OK; - } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) { - Atom target; - char *targetName = NULL; - Tcl_DString selBytes; - int result; - - for (count = argc-2, args = argv+2; count > 0; count -= 2, args += 2) { - if (args[0][0] != '-') { - break; + for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count>0; + count-=2, objs+=2) { + string = Tcl_GetString(objs[0]); + if (string[0] != '-') { + break; + } + if (count < 2) { + Tcl_AppendResult(interp, "value for \"", string, + "\" missing", (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_GetIndexFromObj(interp, objs[0], getOptionStrings, + "option", 0, &getIndex) != TCL_OK) { + return TCL_ERROR; + } + + switch ((enum getOptions) getIndex) { + case GET_DISPLAYOF: + path = Tcl_GetString(objs[1]); + break; + case GET_SELECTION: + selName = Tcl_GetString(objs[1]); + break; + case GET_TYPE: + targetName = Tcl_GetString(objs[1]); + break; + } + } + if (path != NULL) { + tkwin = Tk_NameToWindow(interp, path, tkwin); } - if (count < 2) { - Tcl_AppendResult(interp, "value for \"", *args, - "\" missing", (char *) NULL); + if (tkwin == NULL) { return TCL_ERROR; } - c = args[0][1]; - length = strlen(args[0]); - if ((c == 'd') && (strncmp(args[0], "-displayof", length) == 0)) { - path = args[1]; - } else if ((c == 's') - && (strncmp(args[0], "-selection", length) == 0)) { - selName = args[1]; - } else if ((c == 't') - && (strncmp(args[0], "-type", length) == 0)) { - targetName = args[1]; + if (selName != NULL) { + selection = Tk_InternAtom(tkwin, selName); } else { - Tcl_AppendResult(interp, "unknown option \"", args[0], - "\"", (char *) NULL); + selection = XA_PRIMARY; + } + if (count > 1) { + Tcl_WrongNumArgs(interp, 2, objv, "?options?"); return TCL_ERROR; + } else if (count == 1) { + target = Tk_InternAtom(tkwin, Tcl_GetString(objs[0])); + } else if (targetName != NULL) { + target = Tk_InternAtom(tkwin, targetName); + } else { + target = XA_STRING; } - } - if (path != NULL) { - tkwin = Tk_NameToWindow(interp, path, tkwin); - } - if (tkwin == NULL) { - return TCL_ERROR; - } - if (selName != NULL) { - selection = Tk_InternAtom(tkwin, selName); - } else { - selection = XA_PRIMARY; - } - if (count > 1) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " get ?options?\"", (char *) NULL); - return TCL_ERROR; - } else if (count == 1) { - target = Tk_InternAtom(tkwin, args[0]); - } else if (targetName != NULL) { - target = Tk_InternAtom(tkwin, targetName); - } else { - target = XA_STRING; - } - Tcl_DStringInit(&selBytes); - result = Tk_GetSelection(interp, tkwin, selection, target, SelGetProc, - (ClientData) &selBytes); - if (result == TCL_OK) { - Tcl_DStringResult(interp, &selBytes); - } else { - Tcl_DStringFree(&selBytes); + Tcl_DStringInit(&selBytes); + result = Tk_GetSelection(interp, tkwin, selection, target, + SelGetProc, (ClientData) &selBytes); + if (result == TCL_OK) { + Tcl_DStringResult(interp, &selBytes); + } else { + Tcl_DStringFree(&selBytes); + } + return result; } - return result; - } else if ((c == 'h') && (strncmp(argv[1], "handle", length) == 0)) { - Atom target, format; - char *targetName = NULL; - char *formatName = NULL; - register CommandInfo *cmdInfoPtr; - int cmdLength; - - for (count = argc-2, args = argv+2; count > 0; count -= 2, args += 2) { - if (args[0][0] != '-') { - break; + + case SELECTION_HANDLE: { + Atom target, format; + char *targetName = NULL; + char *formatName = NULL; + register CommandInfo *cmdInfoPtr; + int cmdLength; + static CONST char *handleOptionStrings[] = { + "-format", "-selection", "-type", (char *) NULL + }; + enum handleOptions { HANDLE_FORMAT, HANDLE_SELECTION, + HANDLE_TYPE }; + int handleIndex; + + for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count > 0; + count-=2, objs+=2) { + string = Tcl_GetString(objs[0]); + if (string[0] != '-') { + break; + } + if (count < 2) { + Tcl_AppendResult(interp, "value for \"", string, + "\" missing", (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_GetIndexFromObj(interp, objs[0],handleOptionStrings, + "option", 0, &handleIndex) != TCL_OK) { + return TCL_ERROR; + } + + switch ((enum handleOptions) handleIndex) { + case HANDLE_FORMAT: + formatName = Tcl_GetString(objs[1]); + break; + case HANDLE_SELECTION: + selName = Tcl_GetString(objs[1]); + break; + case HANDLE_TYPE: + targetName = Tcl_GetString(objs[1]); + break; + } } - if (count < 2) { - Tcl_AppendResult(interp, "value for \"", *args, - "\" missing", (char *) NULL); + + if ((count < 2) || (count > 4)) { + Tcl_WrongNumArgs(interp, 2, objv, "?options? window command"); return TCL_ERROR; } - c = args[0][1]; - length = strlen(args[0]); - if ((c == 'f') && (strncmp(args[0], "-format", length) == 0)) { - formatName = args[1]; - } else if ((c == 's') - && (strncmp(args[0], "-selection", length) == 0)) { - selName = args[1]; - } else if ((c == 't') - && (strncmp(args[0], "-type", length) == 0)) { - targetName = args[1]; - } else { - Tcl_AppendResult(interp, "unknown option \"", args[0], - "\"", (char *) NULL); + tkwin = Tk_NameToWindow(interp, Tcl_GetString(objs[0]), tkwin); + if (tkwin == NULL) { return TCL_ERROR; } - } - - if ((count < 2) || (count > 4)) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " handle ?options? window command\"", (char *) NULL); - return TCL_ERROR; - } - tkwin = Tk_NameToWindow(interp, args[0], tkwin); - if (tkwin == NULL) { - return TCL_ERROR; - } - if (selName != NULL) { - selection = Tk_InternAtom(tkwin, selName); - } else { - selection = XA_PRIMARY; - } + if (selName != NULL) { + selection = Tk_InternAtom(tkwin, selName); + } else { + selection = XA_PRIMARY; + } - if (count > 2) { - target = Tk_InternAtom(tkwin, args[2]); - } else if (targetName != NULL) { - target = Tk_InternAtom(tkwin, targetName); - } else { - target = XA_STRING; - } - if (count > 3) { - format = Tk_InternAtom(tkwin, args[3]); - } else if (formatName != NULL) { - format = Tk_InternAtom(tkwin, formatName); - } else { - format = XA_STRING; - } - cmdLength = strlen(args[1]); - if (cmdLength == 0) { - Tk_DeleteSelHandler(tkwin, selection, target); - } else { - cmdInfoPtr = (CommandInfo *) ckalloc((unsigned) ( + if (count > 2) { + target = Tk_InternAtom(tkwin, Tcl_GetString(objs[2])); + } else if (targetName != NULL) { + target = Tk_InternAtom(tkwin, targetName); + } else { + target = XA_STRING; + } + if (count > 3) { + format = Tk_InternAtom(tkwin, Tcl_GetString(objs[3])); + } else if (formatName != NULL) { + format = Tk_InternAtom(tkwin, formatName); + } else { + format = XA_STRING; + } + string = Tcl_GetStringFromObj(objs[1], &cmdLength); + if (cmdLength == 0) { + Tk_DeleteSelHandler(tkwin, selection, target); + } else { + cmdInfoPtr = (CommandInfo *) ckalloc((unsigned) ( sizeof(CommandInfo) - 3 + cmdLength)); - cmdInfoPtr->interp = interp; - cmdInfoPtr->charOffset = 0; - cmdInfoPtr->byteOffset = 0; - cmdInfoPtr->buffer[0] = '\0'; - cmdInfoPtr->cmdLength = cmdLength; - strcpy(cmdInfoPtr->command, args[1]); - Tk_CreateSelHandler(tkwin, selection, target, HandleTclCommand, - (ClientData) cmdInfoPtr, format); + cmdInfoPtr->interp = interp; + cmdInfoPtr->charOffset = 0; + cmdInfoPtr->byteOffset = 0; + cmdInfoPtr->buffer[0] = '\0'; + cmdInfoPtr->cmdLength = cmdLength; + strcpy(cmdInfoPtr->command, string); + Tk_CreateSelHandler(tkwin, selection, target, HandleTclCommand, + (ClientData) cmdInfoPtr, format); + } + return TCL_OK; } - return TCL_OK; - } else if ((c == 'o') && (strncmp(argv[1], "own", length) == 0)) { - register LostCommand *lostPtr; - char *script = NULL; - int cmdLength; - - for (count = argc-2, args = argv+2; count > 0; count -= 2, args += 2) { - if (args[0][0] != '-') { - break; + + case SELECTION_OWN: { + register LostCommand *lostPtr; + char *script = NULL; + int cmdLength; + static CONST char *ownOptionStrings[] = { + "-command", "-displayof", "-selection", (char *) NULL + }; + enum ownOptions { OWN_COMMAND, OWN_DISPLAYOF, OWN_SELECTION }; + int ownIndex; + + for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count > 0; + count-=2, objs+=2) { + string = Tcl_GetString(objs[0]); + if (string[0] != '-') { + break; + } + if (count < 2) { + Tcl_AppendResult(interp, "value for \"", string, + "\" missing", (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_GetIndexFromObj(interp, objs[0], ownOptionStrings, + "option", 0, &ownIndex) != TCL_OK) { + return TCL_ERROR; + } + + switch ((enum ownOptions) ownIndex) { + case OWN_COMMAND: + script = Tcl_GetString(objs[1]); + break; + case OWN_DISPLAYOF: + path = Tcl_GetString(objs[1]); + break; + case OWN_SELECTION: + selName = Tcl_GetString(objs[1]); + break; + } } - if (count < 2) { - Tcl_AppendResult(interp, "value for \"", *args, - "\" missing", (char *) NULL); + + if (count > 2) { + Tcl_WrongNumArgs(interp, 2, objv, "?options? ?window?"); return TCL_ERROR; } - c = args[0][1]; - length = strlen(args[0]); - if ((c == 'c') && (strncmp(args[0], "-command", length) == 0)) { - script = args[1]; - } else if ((c == 'd') - && (strncmp(args[0], "-displayof", length) == 0)) { - path = args[1]; - } else if ((c == 's') - && (strncmp(args[0], "-selection", length) == 0)) { - selName = args[1]; + if (selName != NULL) { + selection = Tk_InternAtom(tkwin, selName); } else { - Tcl_AppendResult(interp, "unknown option \"", args[0], - "\"", (char *) NULL); - return TCL_ERROR; + selection = XA_PRIMARY; } - } - - if (count > 2) { - Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " own ?options? ?window?\"", (char *) NULL); - return TCL_ERROR; - } - if (selName != NULL) { - selection = Tk_InternAtom(tkwin, selName); - } else { - selection = XA_PRIMARY; - } - if (count == 0) { - TkSelectionInfo *infoPtr; - TkWindow *winPtr; - if (path != NULL) { - tkwin = Tk_NameToWindow(interp, path, tkwin); + if (count == 0) { + TkSelectionInfo *infoPtr; + TkWindow *winPtr; + if (path != NULL) { + tkwin = Tk_NameToWindow(interp, path, tkwin); + } + if (tkwin == NULL) { + return TCL_ERROR; + } + winPtr = (TkWindow *)tkwin; + for (infoPtr = winPtr->dispPtr->selectionInfoPtr; + infoPtr != NULL; infoPtr = infoPtr->nextPtr) { + if (infoPtr->selection == selection) + break; + } + + /* + * Ignore the internal clipboard window. + */ + + if ((infoPtr != NULL) + && (infoPtr->owner != winPtr->dispPtr->clipWindow)) { + Tcl_SetResult(interp, Tk_PathName(infoPtr->owner), + TCL_STATIC); + } + return TCL_OK; } + tkwin = Tk_NameToWindow(interp, Tcl_GetString(objs[0]), tkwin); if (tkwin == NULL) { return TCL_ERROR; } - winPtr = (TkWindow *)tkwin; - for (infoPtr = winPtr->dispPtr->selectionInfoPtr; infoPtr != NULL; - infoPtr = infoPtr->nextPtr) { - if (infoPtr->selection == selection) - break; + if (count == 2) { + script = Tcl_GetString(objs[1]); } - - /* - * Ignore the internal clipboard window. - */ - - if ((infoPtr != NULL) - && (infoPtr->owner != winPtr->dispPtr->clipWindow)) { - Tcl_SetResult(interp, Tk_PathName(infoPtr->owner), TCL_STATIC); + if (script == NULL) { + Tk_OwnSelection(tkwin, selection, (Tk_LostSelProc *) NULL, + (ClientData) NULL); + return TCL_OK; } + cmdLength = strlen(script); + lostPtr = (LostCommand *) ckalloc((unsigned) (sizeof(LostCommand) + -3 + cmdLength)); + lostPtr->interp = interp; + strcpy(lostPtr->command, script); + Tk_OwnSelection(tkwin, selection, LostSelection, + (ClientData) lostPtr); return TCL_OK; } - tkwin = Tk_NameToWindow(interp, args[0], tkwin); - if (tkwin == NULL) { - return TCL_ERROR; - } - if (count == 2) { - script = args[1]; - } - if (script == NULL) { - Tk_OwnSelection(tkwin, selection, (Tk_LostSelProc *) NULL, - (ClientData) NULL); - return TCL_OK; - } - cmdLength = strlen(script); - lostPtr = (LostCommand *) ckalloc((unsigned) (sizeof(LostCommand) - -3 + cmdLength)); - lostPtr->interp = interp; - strcpy(lostPtr->command, script); - Tk_OwnSelection(tkwin, selection, LostSelection, (ClientData) lostPtr); - return TCL_OK; - } else { - Tcl_AppendResult(interp, "bad option \"", argv[1], - "\": must be clear, get, handle, or own", (char *) NULL); - return TCL_ERROR; } + return TCL_OK; } /* @@ -1003,11 +1122,11 @@ TkSelDeadWindow(winPtr) } if (selPtr->proc == HandleTclCommand) { /* - * Mark the CommandInfo as deleted and free it if we can. + * Mark the CommandInfo as deleted and free it when we can. */ ((CommandInfo*)selPtr->clientData)->interp = NULL; - Tcl_EventuallyFree(selPtr->clientData, Tcl_Free); + Tcl_EventuallyFree(selPtr->clientData, TCL_DYNAMIC); } ckfree((char *) selPtr); } @@ -1062,15 +1181,29 @@ TkSelInit(tkwin) * Fetch commonly-used atoms. */ - dispPtr->multipleAtom = Tk_InternAtom(tkwin, "MULTIPLE"); - dispPtr->incrAtom = Tk_InternAtom(tkwin, "INCR"); - dispPtr->targetsAtom = Tk_InternAtom(tkwin, "TARGETS"); - dispPtr->timestampAtom = Tk_InternAtom(tkwin, "TIMESTAMP"); - dispPtr->textAtom = Tk_InternAtom(tkwin, "TEXT"); - dispPtr->compoundTextAtom = Tk_InternAtom(tkwin, "COMPOUND_TEXT"); - dispPtr->applicationAtom = Tk_InternAtom(tkwin, "TK_APPLICATION"); - dispPtr->windowAtom = Tk_InternAtom(tkwin, "TK_WINDOW"); - dispPtr->clipboardAtom = Tk_InternAtom(tkwin, "CLIPBOARD"); + dispPtr->multipleAtom = Tk_InternAtom(tkwin, "MULTIPLE"); + dispPtr->incrAtom = Tk_InternAtom(tkwin, "INCR"); + dispPtr->targetsAtom = Tk_InternAtom(tkwin, "TARGETS"); + dispPtr->timestampAtom = Tk_InternAtom(tkwin, "TIMESTAMP"); + dispPtr->textAtom = Tk_InternAtom(tkwin, "TEXT"); + dispPtr->compoundTextAtom = Tk_InternAtom(tkwin, "COMPOUND_TEXT"); + dispPtr->applicationAtom = Tk_InternAtom(tkwin, "TK_APPLICATION"); + dispPtr->windowAtom = Tk_InternAtom(tkwin, "TK_WINDOW"); + dispPtr->clipboardAtom = Tk_InternAtom(tkwin, "CLIPBOARD"); + + /* + * Using UTF8_STRING instead of the XA_UTF8_STRING macro allows us + * to support older X servers that didn't have UTF8_STRING yet. + * This is necessary on Unix systems. + * For more information, see: + * http://www.cl.cam.ac.uk/~mgk25/unicode.html#x11 + */ + +#if !(defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) + dispPtr->utf8Atom = Tk_InternAtom(tkwin, "UTF8_STRING"); +#else + dispPtr->utf8Atom = (Atom) NULL; +#endif } /* @@ -1207,7 +1340,7 @@ HandleTclCommand(clientData, offset, buffer, maxBytes) Tcl_DString oldResult; Tcl_Obj *objPtr; int extraBytes, charOffset, count, numChars; - char *p; + CONST char *p; /* * We must also protect the interpreter and the command from being @@ -1355,7 +1488,7 @@ TkSelDefaultSelection(infoPtr, target, buffer, maxBytes, typePtr) if (target == dispPtr->targetsAtom) { register TkSelHandler *selPtr; - char *atomString; + CONST char *atomString; int length, atomLength; if (maxBytes < 50) { @@ -1384,7 +1517,7 @@ TkSelDefaultSelection(infoPtr, target, buffer, maxBytes, typePtr) if (target == dispPtr->applicationAtom) { int length; - char *name = winPtr->mainPtr->winPtr->nameUid; + Tk_Uid name = winPtr->mainPtr->winPtr->nameUid; length = strlen(name); if (maxBytes <= length) { @@ -1464,4 +1597,3 @@ LostSelection(clientData) ckfree((char *) lostPtr); } - diff --git a/tk/generic/tkSelect.h b/tk/generic/tkSelect.h index 7cce9bbc290..c046f6c4baa 100644 --- a/tk/generic/tkSelect.h +++ b/tk/generic/tkSelect.h @@ -183,4 +183,3 @@ extern void TkSelUpdateClipboard _ANSI_ARGS_((TkWindow *winPtr, #endif #endif /* _TKSELECT */ - diff --git a/tk/generic/tkSquare.c b/tk/generic/tkSquare.c index 983969c1f4d..50615ffbcaf 100644 --- a/tk/generic/tkSquare.c +++ b/tk/generic/tkSquare.c @@ -60,7 +60,7 @@ typedef struct { * Information used for argv parsing. */ -static Tk_OptionSpec configSpecs[] = { +static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BORDER, "-background", "background", "Background", "#d9d9d9", Tk_Offset(Square, bgBorderPtr), -1, 0, (ClientData) "white"}, @@ -104,7 +104,7 @@ static void SquareDisplay _ANSI_ARGS_((ClientData clientData)); static void KeepInWindow _ANSI_ARGS_((Square *squarePtr)); static void SquareObjEventProc _ANSI_ARGS_((ClientData clientData, XEvent *eventPtr)); -static int SquareWidgetCmd _ANSI_ARGS_((ClientData clientData, +static int SquareWidgetObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *, int objc, Tcl_Obj * CONST objv[])); /* @@ -126,32 +126,14 @@ static int SquareWidgetCmd _ANSI_ARGS_((ClientData clientData, int SquareObjCmd(clientData, interp, objc, objv) - ClientData clientData; /* Main window associated with - * interpreter. */ + ClientData clientData; /* NULL. */ Tcl_Interp *interp; /* Current interpreter. */ int objc; /* Number of arguments. */ Tcl_Obj * CONST objv[]; /* Argument objects. */ { Square *squarePtr; Tk_Window tkwin; - Tk_OptionTable optionTable = (Tk_OptionTable) clientData; - Tcl_CmdInfo info; - char *commandName; - - if (optionTable == NULL) { - /* - * The first time this procedure is invoked, optionTable will - * be NULL. We then create the option table from the template - * and store the table pointer as the command's clinical so - * we'll have easy access to it in the future. - */ - - optionTable = Tk_CreateOptionTable(interp, configSpecs); - commandName = Tcl_GetStringFromObj(objv[0], (int *) NULL); - Tcl_GetCommandInfo(interp, commandName, &info); - info.clientData = (ClientData) optionTable; - Tcl_SetCommandInfo(interp, commandName, &info); - } + Tk_OptionTable optionTable; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); @@ -166,29 +148,31 @@ SquareObjCmd(clientData, interp, objc, objv) Tk_SetClass(tkwin, "Square"); /* - * Allocate and initialize the widget record. + * Create the option table for this widget class. If it has + * already been created, the refcount will get bumped and just + * the pointer will be returned. The refcount getting bumped + * does not concern us, because Tk will ensure the table is + * deleted when the interpreter is destroyed. + */ + + optionTable = Tk_CreateOptionTable(interp, optionSpecs); + + /* + * Allocate and initialize the widget record. The memset allows + * us to set just the non-NULL/0 items. */ - squarePtr = (Square *) ckalloc(sizeof(Square)); - squarePtr->tkwin = tkwin; - squarePtr->display = Tk_Display(tkwin); - squarePtr->interp = interp; - squarePtr->widgetCmd = Tcl_CreateObjCommand(interp, - Tk_PathName(squarePtr->tkwin), SquareWidgetCmd, + squarePtr = (Square *) ckalloc(sizeof(Square)); + memset((void *) squarePtr, 0, (sizeof(Square))); + + squarePtr->tkwin = tkwin; + squarePtr->display = Tk_Display(tkwin); + squarePtr->interp = interp; + squarePtr->widgetCmd = Tcl_CreateObjCommand(interp, + Tk_PathName(squarePtr->tkwin), SquareWidgetObjCmd, (ClientData) squarePtr, SquareDeletedProc); - squarePtr->xPtr = NULL; - squarePtr->yPtr = NULL; - squarePtr->x = 0; - squarePtr->y = 0; - squarePtr->sizeObjPtr = NULL; - squarePtr->borderWidthPtr = NULL; - squarePtr->bgBorderPtr = NULL; - squarePtr->fgBorderPtr = NULL; - squarePtr->reliefPtr = NULL; - squarePtr->gc = None; - squarePtr->doubleBufferPtr = NULL; - squarePtr->updatePending = 0; - squarePtr->optionTable = optionTable; + squarePtr->gc = None; + squarePtr->optionTable = optionTable; if (Tk_InitOptions(interp, (char *) squarePtr, optionTable, tkwin) != TCL_OK) { @@ -207,8 +191,8 @@ SquareObjCmd(clientData, interp, objc, objv) goto error; } - Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(squarePtr->tkwin), - -1)); + Tcl_SetObjResult(interp, + Tcl_NewStringObj(Tk_PathName(squarePtr->tkwin), -1)); return TCL_OK; error: @@ -219,7 +203,7 @@ error: /* *-------------------------------------------------------------- * - * SquareWidgetCmd -- + * SquareWidgetObjCmd -- * * This procedure is invoked to process the Tcl command * that corresponds to a widget managed by this module. @@ -235,7 +219,7 @@ error: */ static int -SquareWidgetCmd(clientData, interp, objc, objv) +SquareWidgetObjCmd(clientData, interp, objc, objv) ClientData clientData; /* Information about square widget. */ Tcl_Interp *interp; /* Current interpreter. */ int objc; /* Number of arguments. */ @@ -243,7 +227,7 @@ SquareWidgetCmd(clientData, interp, objc, objv) { Square *squarePtr = (Square *) clientData; int result = TCL_OK; - static char *squareOptions[] = {"cget", "configure", (char *) NULL}; + static CONST char *squareOptions[] = {"cget", "configure", (char *) NULL}; enum { SQUARE_CGET, SQUARE_CONFIGURE }; @@ -635,4 +619,3 @@ KeepInWindow(squarePtr) squarePtr->y = bd; } } - diff --git a/tk/generic/tkStubImg.c b/tk/generic/tkStubImg.c index 024e581c578..842fb0eceb9 100644 --- a/tk/generic/tkStubImg.c +++ b/tk/generic/tkStubImg.c @@ -61,6 +61,8 @@ Tk_InitImageArgs(interp, argc, argvPtr) } if (cmdInfo.isNativeObjectProc == 1) { useNewImage = 1; /* Tk uses the new image interface */ + } else { + useNewImage = 0; /* Tk uses old image interface */ } } if (useNewImage && (argc > 0)) { @@ -72,4 +74,3 @@ Tk_InitImageArgs(interp, argc, argvPtr) *argvPtr = (char **) argv; } } - diff --git a/tk/generic/tkStubInit.c b/tk/generic/tkStubInit.c index 5dc7b43920a..f6558a8f47c 100644 --- a/tk/generic/tkStubInit.c +++ b/tk/generic/tkStubInit.c @@ -14,13 +14,25 @@ #include "tkInt.h" #include "tkPort.h" +#if !(defined(__WIN32__) && defined(MAC_TCL) || defined(MAC_OSX_TK)) +/* UNIX */ +#define UNIX_TK +#endif + #ifdef __WIN32__ #include "tkWinInt.h" #endif -#ifdef MAC_TCL +#if defined(MAC_TCL) +/* set this locally .. we could have used _TKMACINT */ +#define MAC_TK #include "tkMacInt.h" #endif +#if defined(MAC_OSX_TK) +/* set this locally .. we could have used _TKMACINT */ +#include "tkMacOSXInt.h" +#endif + #include "tkDecls.h" #include "tkPlatDecls.h" #include "tkIntDecls.h" @@ -131,7 +143,7 @@ TkIntStubs tkIntStubs = { TkSelEventProc, /* 81 */ TkSelInit, /* 82 */ TkSelPropProc, /* 83 */ - TkSetClassProcs, /* 84 */ + NULL, /* 84 */ TkSetWindowMenuBar, /* 85 */ TkStringToKeysym, /* 86 */ TkThickPolyLineToArea, /* 87 */ @@ -169,6 +181,9 @@ TkIntStubs tkIntStubs = { #ifdef MAC_TCL TkClipBox, /* 113 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + TkClipBox, /* 113 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 114 */ #endif /* UNIX */ @@ -178,6 +193,9 @@ TkIntStubs tkIntStubs = { #ifdef MAC_TCL TkCreateRegion, /* 114 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + TkCreateRegion, /* 114 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 115 */ #endif /* UNIX */ @@ -187,6 +205,9 @@ TkIntStubs tkIntStubs = { #ifdef MAC_TCL TkDestroyRegion, /* 115 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + TkDestroyRegion, /* 115 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 116 */ #endif /* UNIX */ @@ -196,6 +217,9 @@ TkIntStubs tkIntStubs = { #ifdef MAC_TCL TkIntersectRegion, /* 116 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + TkIntersectRegion, /* 116 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 117 */ #endif /* UNIX */ @@ -205,6 +229,9 @@ TkIntStubs tkIntStubs = { #ifdef MAC_TCL TkRectInRegion, /* 117 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + TkRectInRegion, /* 117 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 118 */ #endif /* UNIX */ @@ -214,6 +241,9 @@ TkIntStubs tkIntStubs = { #ifdef MAC_TCL TkSetRegion, /* 118 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + TkSetRegion, /* 118 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 119 */ #endif /* UNIX */ @@ -223,15 +253,10 @@ TkIntStubs tkIntStubs = { #ifdef MAC_TCL TkUnionRectWithRegion, /* 119 */ #endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ - NULL, /* 120 */ -#endif /* UNIX */ -#ifdef __WIN32__ +#ifdef MAC_OSX_TK + TkUnionRectWithRegion, /* 119 */ +#endif /* MAC_OSX_TK */ NULL, /* 120 */ -#endif /* __WIN32__ */ -#ifdef MAC_TCL - TkGenerateActivateEvents, /* 120 */ -#endif /* MAC_TCL */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 121 */ #endif /* UNIX */ @@ -241,6 +266,9 @@ TkIntStubs tkIntStubs = { #ifdef MAC_TCL TkpCreateNativeBitmap, /* 121 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + TkpCreateNativeBitmap, /* 121 */ +#endif /* MAC_OSX_TK */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 122 */ #endif /* UNIX */ @@ -250,15 +278,10 @@ TkIntStubs tkIntStubs = { #ifdef MAC_TCL TkpDefineNativeBitmaps, /* 122 */ #endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ - NULL, /* 123 */ -#endif /* UNIX */ -#ifdef __WIN32__ +#ifdef MAC_OSX_TK + TkpDefineNativeBitmaps, /* 122 */ +#endif /* MAC_OSX_TK */ NULL, /* 123 */ -#endif /* __WIN32__ */ -#ifdef MAC_TCL - TkpGetMS, /* 123 */ -#endif /* MAC_TCL */ #if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 124 */ #endif /* UNIX */ @@ -268,100 +291,48 @@ TkIntStubs tkIntStubs = { #ifdef MAC_TCL TkpGetNativeAppBitmap, /* 124 */ #endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ - NULL, /* 125 */ -#endif /* UNIX */ -#ifdef __WIN32__ +#ifdef MAC_OSX_TK + TkpGetNativeAppBitmap, /* 124 */ +#endif /* MAC_OSX_TK */ NULL, /* 125 */ -#endif /* __WIN32__ */ -#ifdef MAC_TCL - TkPointerDeadWindow, /* 125 */ -#endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 126 */ -#endif /* UNIX */ -#ifdef __WIN32__ - NULL, /* 126 */ -#endif /* __WIN32__ */ -#ifdef MAC_TCL - TkpSetCapture, /* 126 */ -#endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ - NULL, /* 127 */ -#endif /* UNIX */ -#ifdef __WIN32__ NULL, /* 127 */ -#endif /* __WIN32__ */ -#ifdef MAC_TCL - TkpSetCursor, /* 127 */ -#endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 128 */ -#endif /* UNIX */ -#ifdef __WIN32__ - NULL, /* 128 */ -#endif /* __WIN32__ */ -#ifdef MAC_TCL - TkpWmSetState, /* 128 */ -#endif /* MAC_TCL */ NULL, /* 129 */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 130 */ -#endif /* UNIX */ -#ifdef __WIN32__ - NULL, /* 130 */ -#endif /* __WIN32__ */ -#ifdef MAC_TCL - TkGetTransientMaster, /* 130 */ -#endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ - NULL, /* 131 */ -#endif /* UNIX */ -#ifdef __WIN32__ NULL, /* 131 */ -#endif /* __WIN32__ */ -#ifdef MAC_TCL - TkGenerateButtonEvent, /* 131 */ -#endif /* MAC_TCL */ NULL, /* 132 */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ - NULL, /* 133 */ -#endif /* UNIX */ -#ifdef __WIN32__ NULL, /* 133 */ -#endif /* __WIN32__ */ -#ifdef MAC_TCL - TkGenWMDestroyEvent, /* 133 */ -#endif /* MAC_TCL */ -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ NULL, /* 134 */ -#endif /* UNIX */ -#ifdef __WIN32__ - NULL, /* 134 */ -#endif /* __WIN32__ */ -#ifdef MAC_TCL - TkGenWMConfigureEvent, /* 134 */ -#endif /* MAC_TCL */ TkpDrawHighlightBorder, /* 135 */ TkSetFocusWin, /* 136 */ TkpSetKeycodeAndState, /* 137 */ TkpGetKeySym, /* 138 */ TkpInitKeymapInfo, /* 139 */ + TkPhotoGetValidRegion, /* 140 */ + TkWmStackorderToplevel, /* 141 */ + TkFocusFree, /* 142 */ + TkClipCleanup, /* 143 */ + TkGCCleanup, /* 144 */ +#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ + NULL, /* 145 */ +#endif /* UNIX */ +#ifdef __WIN32__ + TkSubtractRegion, /* 145 */ +#endif /* __WIN32__ */ +#ifdef MAC_TCL + TkSubtractRegion, /* 145 */ +#endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + TkSubtractRegion, /* 145 */ +#endif /* MAC_OSX_TK */ + TkStylePkgInit, /* 146 */ + TkStylePkgFree, /* 147 */ }; TkIntPlatStubs tkIntPlatStubs = { TCL_STUB_MAGIC, NULL, -#if !defined(__WIN32__) && !defined(MAC_TCL) /* UNIX */ - TkCreateXEventSource, /* 0 */ - TkFreeWindowId, /* 1 */ - TkInitXId, /* 2 */ - TkpCmapStressed, /* 3 */ - TkpSync, /* 4 */ - TkUnixContainerId, /* 5 */ - TkUnixDoOneXEvent, /* 6 */ - TkUnixSetMenubar, /* 7 */ -#endif /* UNIX */ #ifdef __WIN32__ TkAlignImageData, /* 0 */ NULL, /* 1 */ @@ -400,8 +371,8 @@ TkIntPlatStubs tkIntPlatStubs = { #endif /* __WIN32__ */ #ifdef MAC_TCL TkGenerateActivateEvents, /* 0 */ - TkpCreateNativeBitmap, /* 1 */ - TkpDefineNativeBitmaps, /* 2 */ + NULL, /* 1 */ + NULL, /* 2 */ TkpGetMS, /* 3 */ NULL, /* 4 */ TkPointerDeadWindow, /* 5 */ @@ -416,27 +387,27 @@ TkIntPlatStubs tkIntPlatStubs = { TkGenerateButtonEvent, /* 14 */ NULL, /* 15 */ TkGenWMDestroyEvent, /* 16 */ - TkGenWMConfigureEvent, /* 17 */ + NULL, /* 17 */ TkMacButtonKeyState, /* 18 */ TkMacClearMenubarActive, /* 19 */ - TkMacConvertEvent, /* 20 */ + NULL, /* 20 */ TkMacDispatchMenuEvent, /* 21 */ TkMacInstallCursor, /* 22 */ - TkMacConvertTkEvent, /* 23 */ + NULL, /* 23 */ TkMacHandleTearoffMenu, /* 24 */ NULL, /* 25 */ - TkMacInvalClipRgns, /* 26 */ + NULL, /* 26 */ TkMacDoHLEvent, /* 27 */ NULL, /* 28 */ TkMacGenerateTime, /* 29 */ - TkMacGetDrawablePort, /* 30 */ + NULL, /* 30 */ TkMacGetScrollbarGrowWindow, /* 31 */ TkMacGetXWindow, /* 32 */ TkMacGrowToplevel, /* 33 */ TkMacHandleMenuSelect, /* 34 */ - TkMacHaveAppearance, /* 35 */ - TkMacInitAppleEvents, /* 36 */ - TkMacInitMenus, /* 37 */ + NULL, /* 35 */ + NULL, /* 36 */ + NULL, /* 37 */ TkMacInvalidateWindow, /* 38 */ TkMacIsCharacterMissing, /* 39 */ TkMacMakeRealWindowExist, /* 40 */ @@ -465,7 +436,79 @@ TkIntPlatStubs tkIntPlatStubs = { TkMacContainerId, /* 63 */ TkMacGetHostToplevel, /* 64 */ TkMacPreprocessMenu, /* 65 */ + TkpIsWindowFloating, /* 66 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + TkGenerateActivateEvents, /* 0 */ + NULL, /* 1 */ + NULL, /* 2 */ + TkPointerDeadWindow, /* 3 */ + TkpSetCapture, /* 4 */ + TkpSetCursor, /* 5 */ + TkpWmSetState, /* 6 */ + TkAboutDlg, /* 7 */ + TkMacOSXButtonKeyState, /* 8 */ + TkMacOSXClearMenubarActive, /* 9 */ + TkMacOSXDispatchMenuEvent, /* 10 */ + TkMacOSXInstallCursor, /* 11 */ + TkMacOSXHandleTearoffMenu, /* 12 */ + NULL, /* 13 */ + TkMacOSXDoHLEvent, /* 14 */ + NULL, /* 15 */ + TkMacOSXGetXWindow, /* 16 */ + TkMacOSXGrowToplevel, /* 17 */ + TkMacOSXHandleMenuSelect, /* 18 */ + NULL, /* 19 */ + NULL, /* 20 */ + TkMacOSXInvalidateWindow, /* 21 */ + TkMacOSXIsCharacterMissing, /* 22 */ + TkMacOSXMakeRealWindowExist, /* 23 */ + TkMacOSXMakeStippleMap, /* 24 */ + TkMacOSXMenuClick, /* 25 */ + TkMacOSXRegisterOffScreenWindow, /* 26 */ + TkMacOSXResizable, /* 27 */ + TkMacOSXSetHelpMenuItemCount, /* 28 */ + TkMacOSXSetScrollbarGrow, /* 29 */ + TkMacOSXSetUpClippingRgn, /* 30 */ + TkMacOSXSetUpGraphicsPort, /* 31 */ + TkMacOSXUpdateClipRgn, /* 32 */ + TkMacOSXUnregisterMacWindow, /* 33 */ + TkMacOSXUseMenuID, /* 34 */ + TkMacOSXVisableClipRgn, /* 35 */ + TkMacOSXWinBounds, /* 36 */ + TkMacOSXWindowOffset, /* 37 */ + TkSetMacColor, /* 38 */ + TkSetWMName, /* 39 */ + TkSuspendClipboard, /* 40 */ + TkMacOSXZoomToplevel, /* 41 */ + Tk_TopCoordsToWindow, /* 42 */ + TkMacOSXContainerId, /* 43 */ + TkMacOSXGetHostToplevel, /* 44 */ + TkMacOSXPreprocessMenu, /* 45 */ + TkpIsWindowFloating, /* 46 */ + TkMacOSXGetCapture, /* 47 */ + NULL, /* 48 */ + TkGetTransientMaster, /* 49 */ + TkGenerateButtonEvent, /* 50 */ + TkGenWMDestroyEvent, /* 51 */ + NULL, /* 52 */ + TkpGetMS, /* 53 */ +#endif /* MAC_OSX_TK */ +#if !(defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) /* X11 */ + TkCreateXEventSource, /* 0 */ + TkFreeWindowId, /* 1 */ + TkInitXId, /* 2 */ + TkpCmapStressed, /* 3 */ + TkpSync, /* 4 */ + TkUnixContainerId, /* 5 */ + TkUnixDoOneXEvent, /* 6 */ + TkUnixSetMenubar, /* 7 */ + TkpScanWindowId, /* 8 */ + TkWmCleanup, /* 9 */ + TkSendCleanup, /* 10 */ + TkFreeXId, /* 11 */ + TkpWmSetState, /* 12 */ +#endif /* X11 */ }; TkIntXlibStubs tkIntXlibStubs = { @@ -672,6 +715,98 @@ TkIntXlibStubs tkIntXlibStubs = { XQueryColor, /* 88 */ XQueryColors, /* 89 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + XSetDashes, /* 0 */ + XGetModifierMapping, /* 1 */ + XCreateImage, /* 2 */ + XGetImage, /* 3 */ + XGetAtomName, /* 4 */ + XKeysymToString, /* 5 */ + XCreateColormap, /* 6 */ + XGContextFromGC, /* 7 */ + XKeycodeToKeysym, /* 8 */ + XStringToKeysym, /* 9 */ + XRootWindow, /* 10 */ + XSetErrorHandler, /* 11 */ + XAllocColor, /* 12 */ + XBell, /* 13 */ + XChangeProperty, /* 14 */ + XChangeWindowAttributes, /* 15 */ + XConfigureWindow, /* 16 */ + XCopyArea, /* 17 */ + XCopyPlane, /* 18 */ + XCreateBitmapFromData, /* 19 */ + XDefineCursor, /* 20 */ + XDestroyWindow, /* 21 */ + XDrawArc, /* 22 */ + XDrawLines, /* 23 */ + XDrawRectangle, /* 24 */ + XFillArc, /* 25 */ + XFillPolygon, /* 26 */ + XFillRectangles, /* 27 */ + XFreeColormap, /* 28 */ + XFreeColors, /* 29 */ + XFreeModifiermap, /* 30 */ + XGetGeometry, /* 31 */ + XGetWindowProperty, /* 32 */ + XGrabKeyboard, /* 33 */ + XGrabPointer, /* 34 */ + XKeysymToKeycode, /* 35 */ + XMapWindow, /* 36 */ + XMoveResizeWindow, /* 37 */ + XMoveWindow, /* 38 */ + XQueryPointer, /* 39 */ + XRaiseWindow, /* 40 */ + XRefreshKeyboardMapping, /* 41 */ + XResizeWindow, /* 42 */ + XSelectInput, /* 43 */ + XSendEvent, /* 44 */ + XSetIconName, /* 45 */ + XSetInputFocus, /* 46 */ + XSetSelectionOwner, /* 47 */ + XSetWindowBackground, /* 48 */ + XSetWindowBackgroundPixmap, /* 49 */ + XSetWindowBorder, /* 50 */ + XSetWindowBorderPixmap, /* 51 */ + XSetWindowBorderWidth, /* 52 */ + XSetWindowColormap, /* 53 */ + XUngrabKeyboard, /* 54 */ + XUngrabPointer, /* 55 */ + XUnmapWindow, /* 56 */ + TkPutImage, /* 57 */ + XParseColor, /* 58 */ + XCreateGC, /* 59 */ + XFreeGC, /* 60 */ + XInternAtom, /* 61 */ + XSetBackground, /* 62 */ + XSetForeground, /* 63 */ + XSetClipMask, /* 64 */ + XSetClipOrigin, /* 65 */ + XSetTSOrigin, /* 66 */ + XChangeGC, /* 67 */ + XSetFont, /* 68 */ + XSetArcMode, /* 69 */ + XSetStipple, /* 70 */ + XSetFillRule, /* 71 */ + XSetFillStyle, /* 72 */ + XSetFunction, /* 73 */ + XSetLineAttributes, /* 74 */ + _XInitImageFuncPtrs, /* 75 */ + XCreateIC, /* 76 */ + XGetVisualInfo, /* 77 */ + XSetWMClientMachine, /* 78 */ + XStringListToTextProperty, /* 79 */ + XDrawSegments, /* 80 */ + XForceScreenSaver, /* 81 */ + XDrawLine, /* 82 */ + XFillRectangle, /* 83 */ + XClearWindow, /* 84 */ + XDrawPoint, /* 85 */ + XDrawPoints, /* 86 */ + XWarpPointer, /* 87 */ + XQueryColor, /* 88 */ + XQueryColors, /* 89 */ +#endif /* MAC_OSX_TK */ }; TkPlatStubs tkPlatStubs = { @@ -698,6 +833,19 @@ TkPlatStubs tkPlatStubs = { TkMacHaveAppearance, /* 9 */ TkMacGetDrawablePort, /* 10 */ #endif /* MAC_TCL */ +#ifdef MAC_OSX_TK + Tk_MacOSXSetEmbedHandler, /* 0 */ + Tk_MacOSXTurnOffMenus, /* 1 */ + Tk_MacOSXTkOwnsCursor, /* 2 */ + TkMacOSXInitMenus, /* 3 */ + TkMacOSXInitAppleEvents, /* 4 */ + TkGenWMConfigureEvent, /* 5 */ + TkMacOSXInvalClipRgns, /* 6 */ + TkMacOSXGetDrawablePort, /* 7 */ + TkMacOSXGetRootControl, /* 8 */ + Tk_MacOSXSetupTkNotifier, /* 9 */ + Tk_MacOSXIsAppInFront, /* 10 */ +#endif /* MAC_OSX_TK */ }; static TkStubHooks tkStubHooks = { @@ -854,8 +1002,8 @@ TkStubs tkStubs = { Tk_NameToWindow, /* 141 */ Tk_OwnSelection, /* 142 */ Tk_ParseArgv, /* 143 */ - Tk_PhotoPutBlock, /* 144 */ - Tk_PhotoPutZoomedBlock, /* 145 */ + Tk_PhotoPutBlock_NoComposite, /* 144 */ + Tk_PhotoPutZoomedBlock_NoComposite, /* 145 */ Tk_PhotoGetImage, /* 146 */ Tk_PhotoBlank, /* 147 */ Tk_PhotoExpand, /* 148 */ @@ -949,6 +1097,36 @@ TkStubs tkStubs = { Tk_PostscriptStipple, /* 236 */ Tk_PostscriptY, /* 237 */ Tk_PostscriptPhoto, /* 238 */ + Tk_CreateClientMessageHandler, /* 239 */ + Tk_DeleteClientMessageHandler, /* 240 */ + Tk_CreateAnonymousWindow, /* 241 */ + Tk_SetClassProcs, /* 242 */ + Tk_SetInternalBorderEx, /* 243 */ + Tk_SetMinimumRequestSize, /* 244 */ + Tk_SetCaretPos, /* 245 */ + Tk_PhotoPutBlock, /* 246 */ + Tk_PhotoPutZoomedBlock, /* 247 */ + Tk_CollapseMotionEvents, /* 248 */ + Tk_RegisterStyleEngine, /* 249 */ + Tk_GetStyleEngine, /* 250 */ + Tk_RegisterStyledElement, /* 251 */ + Tk_GetElementId, /* 252 */ + Tk_CreateStyle, /* 253 */ + Tk_GetStyle, /* 254 */ + Tk_FreeStyle, /* 255 */ + Tk_NameOfStyle, /* 256 */ + Tk_AllocStyleFromObj, /* 257 */ + Tk_GetStyleFromObj, /* 258 */ + Tk_FreeStyleFromObj, /* 259 */ + Tk_GetStyledElement, /* 260 */ + Tk_GetElementSize, /* 261 */ + Tk_GetElementBox, /* 262 */ + Tk_GetElementBorderWidth, /* 263 */ + Tk_DrawElement, /* 264 */ }; /* !END!: Do not edit above this line. */ + +#undef UNIX_TK +#undef MAC_TK +#undef MAC_OSX_TK diff --git a/tk/generic/tkStubLib.c b/tk/generic/tkStubLib.c index 7a9e7bd0d53..08868276d3f 100644 --- a/tk/generic/tkStubLib.c +++ b/tk/generic/tkStubLib.c @@ -13,6 +13,7 @@ * RCS: @(#) $Id$ */ + /* * We need to ensure that we use the stub macros so that this file contains * no references to any of the stub functions. This will make it possible @@ -20,7 +21,6 @@ * including the rest of the stub functions. */ - #ifndef USE_TCL_STUBS #define USE_TCL_STUBS #endif @@ -37,10 +37,15 @@ #ifdef __WIN32__ #include "tkWinInt.h" #endif + #ifdef MAC_TCL #include "tkMacInt.h" #endif +#ifdef MAC_OSX_TK +#include "tkMacOSXInt.h" +#endif + #include "tkDecls.h" #include "tkIntDecls.h" #include "tkPlatDecls.h" @@ -80,13 +85,17 @@ TkIntXlibStubs *tkIntXlibStubsPtr; *---------------------------------------------------------------------- */ -char * +#ifdef Tk_InitStubs +#undef Tk_InitStubs +#endif + +CONST char * Tk_InitStubs(interp, version, exact) Tcl_Interp *interp; char *version; int exact; { - char *actualVersion; + CONST char *actualVersion; actualVersion = Tcl_PkgRequireEx(interp, "Tk", version, exact, (ClientData *) &tkStubsPtr); diff --git a/tk/generic/tkStyle.c b/tk/generic/tkStyle.c new file mode 100644 index 00000000000..db1f27e4d34 --- /dev/null +++ b/tk/generic/tkStyle.c @@ -0,0 +1,1664 @@ +/* + * tkStyle.c -- + * + * This file implements the widget styles and themes support. + * + * Copyright (c) 1990-1993 The Regents of the University of California. + * Copyright (c) 1994-1997 Sun Microsystems, Inc. + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * RCS: @(#) $Id$ + */ + +#include "tkInt.h" + +/* + * The following structure is used to cache widget option specs matching an + * element's required options defined by Tk_ElementOptionSpecs. It also holds + * information behind Tk_StyledElement opaque tokens. + */ + +typedef struct StyledWidgetSpec { + struct StyledElement *elementPtr; /* Pointer to the element holding this + * structure. */ + Tk_OptionTable optionTable; /* Option table for the widget class + * using the element. */ + CONST Tk_OptionSpec **optionsPtr; /* Table of option spec pointers, + * matching the option list provided + * during element registration. + * Malloc'd. */ +} StyledWidgetSpec; + +/* + * Elements are declared using static templates. But static + * information must be completed by dynamic information only + * accessible at runtime. For each registered element, an instance of + * the following structure is stored in each style engine and used to + * cache information about the widget types (identified by their + * optionTable) that use the given element. + */ + +typedef struct StyledElement { + struct Tk_ElementSpec *specPtr; + /* Filled with template provided during + * registration. NULL means no implementation + * is available for the current engine. */ + int nbWidgetSpecs; /* Size of the array below. Number of distinct + * widget classes (actually, distinct option + * tables) that used the element so far. */ + StyledWidgetSpec *widgetSpecs; + /* See above for the structure definition. + * Table grows dynamically as new widgets + * use the element. Malloc'd. */ +} StyledElement; + +/* + * The following structure holds information behind Tk_StyleEngine opaque + * tokens. + */ + +typedef struct StyleEngine { + CONST char *name; /* Name of engine. Points to a hash key. */ + StyledElement *elements; /* Table of widget element descriptors. Each + * element is indexed by a unique system-wide + * ID. Table grows dynamically as new elements + * are registered. Malloc'd*/ + struct StyleEngine *parentPtr; + /* Parent engine. Engines may be layered to form + * a fallback chain, terminated by the default + * system engine. */ +} StyleEngine; + +/* + * Styles are instances of style engines. The following structure holds + * information behind Tk_Style opaque tokens. + */ + +typedef struct Style { + int refCount; /* Number of active uses of this style. + * If this count is 0, then this Style + * structure is no longer valid. */ + Tcl_HashEntry *hashPtr; /* Entry in style table for this structure, + * used when deleting it. */ + CONST char *name; /* Name of style. Points to a hash key. */ + StyleEngine *enginePtr; /* Style engine of which the style is an + * instance. */ + ClientData clientData; /* Data provided during registration. */ +} Style; + +/* + * Each registered element uses an instance of the following structure. + */ + +typedef struct Element { + CONST char *name; /* Name of element. Points to a hash key. */ + int id; /* Id of element. */ + int genericId; /* Id of generic element. */ + int created; /* Boolean, whether the element was created + * explicitly (was registered) or implicitly + * (by a derived element). */ +} Element; + +/* + * Thread-local data. + */ + +typedef struct ThreadSpecificData { + 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 + * pointers. */ + StyleEngine *defaultEnginePtr; + /* Default, core-defined style engine. Global + * fallback for all engines. */ + Tcl_HashTable styleTable; /* Map a name to a style. Keys are strings, + * values are Tk_Style pointers.*/ + int nbElements; /* Size of the below tables. */ + Tcl_HashTable elementTable; /* Map a name to an element Id. Keys are + * strings, values are integer element IDs. */ + Element *elements; /* Array of Elements. */ +} ThreadSpecificData; + +static Tcl_ThreadDataKey dataKey; + +/* + * Forward declarations for procedures defined later in this file: + */ + +/* TODO: sort alpha. */ +static int CreateElement _ANSI_ARGS_((CONST char *name, + int create)); +static void DupStyleObjProc _ANSI_ARGS_((Tcl_Obj *srcObjPtr, + Tcl_Obj *dupObjPtr)); +static void FreeElement _ANSI_ARGS_((Element *elementPtr)); +static void FreeStyle _ANSI_ARGS_((Style *stylePtr)); +static void FreeStyledElement _ANSI_ARGS_(( + StyledElement *elementPtr)); +static void FreeStyleEngine _ANSI_ARGS_(( + StyleEngine *enginePtr)); +static void FreeStyleObjProc _ANSI_ARGS_((Tcl_Obj *objPtr)); +static void FreeWidgetSpec _ANSI_ARGS_(( + StyledWidgetSpec *widgetSpecPtr)); +static StyledElement * GetStyledElement _ANSI_ARGS_(( + StyleEngine *enginePtr, int elementId)); +static StyledWidgetSpec * GetWidgetSpec _ANSI_ARGS_((StyledElement *elementPtr, + Tk_OptionTable optionTable)); +static void InitElement _ANSI_ARGS_((Element *elementPtr, + CONST char *name, int id, int genericId, + int created)); +static void InitStyle _ANSI_ARGS_((Style *stylePtr, + Tcl_HashEntry *hashPtr, CONST char *name, + StyleEngine *enginePtr, ClientData clientData)); +static void InitStyledElement _ANSI_ARGS_(( + StyledElement *elementPtr)); +static void InitStyleEngine _ANSI_ARGS_((StyleEngine *enginePtr, + CONST char *name, StyleEngine *parentPtr)); +static void InitWidgetSpec _ANSI_ARGS_(( + StyledWidgetSpec *widgetSpecPtr, + StyledElement *elementPtr, + Tk_OptionTable optionTable)); +static int SetStyleFromAny _ANSI_ARGS_((Tcl_Interp *interp, + Tcl_Obj *objPtr)); + +/* + * The following structure defines the implementation of the "style" Tcl + * object, used for drawing. The internalRep.otherValuePtr field of + * each style object points to the Style structure for the stylefont, or + * NULL. + */ + +static Tcl_ObjType styleObjType = { + "style", /* name */ + FreeStyleObjProc, /* freeIntRepProc */ + DupStyleObjProc, /* dupIntRepProc */ + NULL, /* updateStringProc */ + SetStyleFromAny /* setFromAnyProc */ +}; + +/* + *--------------------------------------------------------------------------- + * + * TkStylePkgInit -- + * + * This procedure is called when an application is created. It + * initializes all the structures that are used by the style + * package on a per application basis. + * + * Results: + * Stores data in thread-local storage. + * + * Side effects: + * Memory allocated. + * + *--------------------------------------------------------------------------- + */ + +void +TkStylePkgInit(mainPtr) + TkMainInfo *mainPtr; /* The application being created. */ +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + + if (tsdPtr->nbInit != 0) return; + + /* + * Initialize tables. + */ + + Tcl_InitHashTable(&tsdPtr->engineTable, TCL_STRING_KEYS); + Tcl_InitHashTable(&tsdPtr->styleTable, TCL_STRING_KEYS); + Tcl_InitHashTable(&tsdPtr->elementTable, TCL_STRING_KEYS); + tsdPtr->nbElements = 0; + tsdPtr->elements = NULL; + + /* + * Create the default system engine. + */ + + tsdPtr->defaultEnginePtr = + (StyleEngine *) Tk_RegisterStyleEngine(NULL, NULL); + + /* + * Create the default system style. + */ + + Tk_CreateStyle(NULL, (Tk_StyleEngine) tsdPtr->defaultEnginePtr, + (ClientData) 0); + + tsdPtr->nbInit++; +} + +/* + *--------------------------------------------------------------------------- + * + * TkStylePkgFree -- + * + * This procedure is called when an application is deleted. It + * deletes all the structures that were used by the style package + * for this application. + * + * Results: + * None. + * + * Side effects: + * Memory freed. + * + *--------------------------------------------------------------------------- + */ + +void +TkStylePkgFree(mainPtr) + TkMainInfo *mainPtr; /* The application being deleted. */ +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_HashSearch search; + Tcl_HashEntry *entryPtr; + StyleEngine *enginePtr; + int i; + + tsdPtr->nbInit--; + if (tsdPtr->nbInit != 0) return; + + /* + * Free styles. + */ + + entryPtr = Tcl_FirstHashEntry(&tsdPtr->styleTable, &search); + while (entryPtr != NULL) { + ckfree((char *) Tcl_GetHashValue(entryPtr)); + entryPtr = Tcl_NextHashEntry(&search); + } + Tcl_DeleteHashTable(&tsdPtr->styleTable); + + /* + * Free engines. + */ + + entryPtr = Tcl_FirstHashEntry(&tsdPtr->engineTable, &search); + while (entryPtr != NULL) { + enginePtr = (StyleEngine *) Tcl_GetHashValue(entryPtr); + FreeStyleEngine(enginePtr); + ckfree((char *) enginePtr); + entryPtr = Tcl_NextHashEntry(&search); + } + Tcl_DeleteHashTable(&tsdPtr->engineTable); + + /* + * Free elements. + */ + + for (i = 0; i < tsdPtr->nbElements; i++) { + FreeElement(tsdPtr->elements+i); + } + Tcl_DeleteHashTable(&tsdPtr->elementTable); + ckfree((char *) tsdPtr->elements); +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_RegisterStyleEngine -- + * + * This procedure is called to register a new style engine. Style engines + * are stored in thread-local space. + * + * Results: + * The newly allocated engine. + * + * Side effects: + * Memory allocated. Data added to thread-local table. + * + *--------------------------------------------------------------------------- + */ + +Tk_StyleEngine +Tk_RegisterStyleEngine(name, parent) + CONST char *name; /* Name of the engine to create. NULL or empty + * means the default system engine. */ + Tk_StyleEngine parent; /* The engine's parent. NULL means the default + * system engine. */ +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_HashEntry *entryPtr; + int newEntry; + StyleEngine *enginePtr; + + /* + * Attempt to create a new entry in the engine table. + */ + + entryPtr = Tcl_CreateHashEntry(&tsdPtr->engineTable, (name?name:""), + &newEntry); + if (!newEntry) { + /* + * An engine was already registered by that name. + */ + + return NULL; + } + + /* + * Allocate and intitialize a new engine. + */ + + enginePtr = (StyleEngine *) ckalloc(sizeof(StyleEngine)); + InitStyleEngine(enginePtr, Tcl_GetHashKey(&tsdPtr->engineTable, entryPtr), + (StyleEngine *) parent); + Tcl_SetHashValue(entryPtr, (ClientData) enginePtr); + + return (Tk_StyleEngine) enginePtr; +} + +/* + *--------------------------------------------------------------------------- + * + * InitStyleEngine -- + * + * Initialize a newly allocated style engine. + * + * Results: + * None. + * + * Side effects: + * Memory allocated. + * + *--------------------------------------------------------------------------- + */ + +static void +InitStyleEngine(enginePtr, name, parentPtr) + StyleEngine *enginePtr; /* Points to an uninitialized engine. */ + CONST char *name; /* Name of the registered engine. NULL or empty + * means the default system engine. Usually + * points to the hash key. */ + StyleEngine *parentPtr; /* The engine's parent. NULL means the default + * system engine. */ +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + int elementId; + + if (name == NULL || *name == '\0') { + /* + * This is the default style engine. + */ + + enginePtr->parentPtr = NULL; + + } else if (parentPtr == NULL) { + /* + * The default style engine is the parent. + */ + + enginePtr->parentPtr = tsdPtr->defaultEnginePtr; + + } else { + enginePtr->parentPtr = parentPtr; + } + + /* + * Allocate and initialize elements array. + */ + + if (tsdPtr->nbElements > 0) { + enginePtr->elements = (StyledElement *) ckalloc( + sizeof(StyledElement) * tsdPtr->nbElements); + for (elementId = 0; elementId < tsdPtr->nbElements; elementId++) { + InitStyledElement(enginePtr->elements+elementId); + } + } else { + enginePtr->elements = NULL; + } +} + +/* + *--------------------------------------------------------------------------- + * + * FreeStyleEngine -- + * + * Free an engine and its associated data. + * + * Results: + * None + * + * Side effects: + * Memory freed. + * + *--------------------------------------------------------------------------- + */ + +static void +FreeStyleEngine(enginePtr) + StyleEngine *enginePtr; /* The style engine to free. */ +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + int elementId; + + /* + * Free allocated elements. + */ + + for (elementId = 0; elementId < tsdPtr->nbElements; elementId++) { + FreeStyledElement(enginePtr->elements+elementId); + } + ckfree((char *) enginePtr->elements); +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_GetStyleEngine -- + * + * Retrieve a registered style engine by its name. + * + * Results: + * A pointer to the style engine, or NULL if none found. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +Tk_StyleEngine +Tk_GetStyleEngine(name) + CONST char *name; /* Name of the engine to retrieve. NULL or + * empty means the default system engine. */ +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_HashEntry *entryPtr; + + if (name == NULL) { + return (Tk_StyleEngine) tsdPtr->defaultEnginePtr; + } + + entryPtr = Tcl_FindHashEntry(&tsdPtr->engineTable, (name?name:"")); + if (!entryPtr) { + return NULL; + } + + return (Tk_StyleEngine) Tcl_GetHashValue(entryPtr); +} + +/* + *--------------------------------------------------------------------------- + * + * InitElement -- + * + * Initialize a newly allocated element. + * + * Results: + * None. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +static void +InitElement(elementPtr, name, id, genericId, created) + Element *elementPtr; /* Points to an uninitialized element.*/ + CONST char *name; /* Name of the registered element. Usually + * points to the hash key. */ + int id; /* Unique element ID. */ + int genericId; /* ID of generic element. -1 means none. */ + int created; /* Boolean, whether the element was created + * explicitly (was registered) or implicitly + * (by a derived element). */ +{ + elementPtr->name = name; + elementPtr->id = id; + elementPtr->genericId = genericId; + elementPtr->created = (created?1:0); +} + +/* + *--------------------------------------------------------------------------- + * + * FreeElement -- + * + * Free an element and its associated data. + * + * Results: + * None. + * + * Side effects: + * Memory freed. + * + *--------------------------------------------------------------------------- + */ + +static void +FreeElement(elementPtr) + Element *elementPtr; /* The element to free. */ +{ + /* Nothing to do. */ +} + +/* + *--------------------------------------------------------------------------- + * + * InitStyledElement -- + * + * Initialize a newly allocated styled element. + * + * Results: + * None. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +static void +InitStyledElement(elementPtr) + StyledElement *elementPtr; /* Points to an uninitialized element.*/ +{ + memset(elementPtr, 0, sizeof(StyledElement)); +} + +/* + *--------------------------------------------------------------------------- + * + * FreeStyledElement -- + * + * Free a styled element and its associated data. + * + * Results: + * None. + * + * Side effects: + * Memory freed. + * + *--------------------------------------------------------------------------- + */ + +static void +FreeStyledElement(elementPtr) + StyledElement *elementPtr; /* The styled element to free. */ +{ + int i; + + /* + * Free allocated widget specs. + */ + + for (i = 0; i < elementPtr->nbWidgetSpecs; i++) { + FreeWidgetSpec(elementPtr->widgetSpecs+i); + } + ckfree((char *) elementPtr->widgetSpecs); +} + +/* + *--------------------------------------------------------------------------- + * + * CreateElement -- + * + * Find an existing or create a new element. + * + * Results: + * The unique ID for the created or found element. + * + * Side effects: + * Memory allocated. + * + *--------------------------------------------------------------------------- + */ + +static int +CreateElement(name, create) + CONST char *name; /* Name of the element. */ + int create; /* Boolean, whether the element is being created + * explicitly (being registered) or implicitly (by a + * derived element). */ +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_HashEntry *entryPtr, *engineEntryPtr; + Tcl_HashSearch search; + int newEntry; + int elementId, genericId = -1; + char *dot; + StyleEngine *enginePtr; + + /* + * Find or create the element. + */ + + entryPtr = Tcl_CreateHashEntry(&tsdPtr->elementTable, name, &newEntry); + if (!newEntry) { + elementId = (int) Tcl_GetHashValue(entryPtr); + if (create) { + tsdPtr->elements[elementId].created = 1; + } + return elementId; + } + + /* + * The element didn't exist. If it's a derived element, find or + * create its generic element ID. + */ + + dot = strchr(name, '.'); + if (dot) { + genericId = CreateElement(dot+1, 0); + } + + elementId = tsdPtr->nbElements++; + Tcl_SetHashValue(entryPtr, (ClientData) elementId); + + /* + * Reallocate element table. + */ + + tsdPtr->elements = (Element *) ckrealloc((char *) tsdPtr->elements, + sizeof(Element) * tsdPtr->nbElements); + InitElement(tsdPtr->elements+elementId, + Tcl_GetHashKey(&tsdPtr->elementTable, entryPtr), elementId, + genericId, create); + + /* + * Reallocate style engines' element table. + */ + + engineEntryPtr = Tcl_FirstHashEntry(&tsdPtr->engineTable, &search); + while (engineEntryPtr != NULL) { + enginePtr = (StyleEngine *) Tcl_GetHashValue(engineEntryPtr); + + enginePtr->elements = (StyledElement *) ckrealloc( + (char *) enginePtr->elements, + sizeof(StyledElement) * tsdPtr->nbElements); + InitStyledElement(enginePtr->elements+elementId); + + engineEntryPtr = Tcl_NextHashEntry(&search); + } + + return elementId; +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_GetElementId -- + * + * Find an existing element. + * + * Results: + * The unique ID for the found element, or -1 if not found. + * + * Side effects: + * Generic elements may be created. + * + *--------------------------------------------------------------------------- + */ + +int +Tk_GetElementId(name) + CONST char *name; /* Name of the element. */ +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_HashEntry *entryPtr; + int genericId = -1; + char *dot; + + /* + * Find the element Id. + */ + + entryPtr = Tcl_FindHashEntry(&tsdPtr->elementTable, name); + if (entryPtr) { + return (int) Tcl_GetHashValue(entryPtr); + } + + /* + * Element not found. If the given name was derived, then first search for + * the generic element. If found, create the new derived element. + */ + + dot = strchr(name, '.'); + if (!dot) { + return -1; + } + genericId = Tk_GetElementId(dot+1); + if (genericId == -1) { + return -1; + } + if (!tsdPtr->elements[genericId].created) { + /* + * The generic element was created implicitly and thus has no real + * existence. + */ + + return -1; + } else { + /* + * The generic element was created explicitly. Create the derived + * element. + */ + + return CreateElement(name, 1); + } +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_RegisterStyledElement -- + * + * Register an implementation of a new or existing element for the + * given style engine. + * + * Results: + * The unique ID for the created or found element. + * + * Side effects: + * Elements may be created. Memory allocated. + * + *--------------------------------------------------------------------------- + */ + +int +Tk_RegisterStyledElement(engine, templatePtr) + Tk_StyleEngine engine; /* Style engine providing the + * implementation. */ + Tk_ElementSpec *templatePtr; /* Static template information about + * the element. */ +{ + int elementId; + StyledElement *elementPtr; + Tk_ElementSpec *specPtr; + int nbOptions; + register Tk_ElementOptionSpec *srcOptions, *dstOptions; + + if (templatePtr->version != TK_STYLE_VERSION_1) { + /* + * Version mismatch. Do nothing. + */ + + return -1; + } + + if (engine == NULL) { + engine = Tk_GetStyleEngine(NULL); + } + + /* + * Register the element, allocating storage in the various engines if + * necessary. + */ + + elementId = CreateElement(templatePtr->name, 1); + + /* + * Initialize the styled element. + */ + + elementPtr = ((StyleEngine *) engine)->elements+elementId; + + specPtr = (Tk_ElementSpec *) ckalloc(sizeof(Tk_ElementSpec)); + specPtr->version = templatePtr->version; + specPtr->name = ckalloc(strlen(templatePtr->name)+1); + strcpy(specPtr->name, templatePtr->name); + nbOptions = 0; + for (nbOptions = 0, srcOptions = templatePtr->options; + srcOptions->name != NULL; + nbOptions++, srcOptions++); + specPtr->options = (Tk_ElementOptionSpec *) ckalloc( + sizeof(Tk_ElementOptionSpec) * (nbOptions+1)); + for (srcOptions = templatePtr->options, dstOptions = specPtr->options; + /* End condition within loop */; + srcOptions++, dstOptions++) { + if (srcOptions->name == NULL) { + dstOptions->name = NULL; + break; + } + + dstOptions->name = ckalloc(strlen(srcOptions->name)+1); + strcpy(dstOptions->name, srcOptions->name); + dstOptions->type = srcOptions->type; + } + specPtr->getSize = templatePtr->getSize; + specPtr->getBox = templatePtr->getBox; + specPtr->getBorderWidth = templatePtr->getBorderWidth; + specPtr->draw = templatePtr->draw; + + elementPtr->specPtr = specPtr; + elementPtr->nbWidgetSpecs = 0; + elementPtr->widgetSpecs = NULL; + + return elementId; +} + +/* + *--------------------------------------------------------------------------- + * + * GetStyledElement -- + * + * Get a registered implementation of an existing element for the + * given style engine. + * + * Results: + * The styled element descriptor, or NULL if not found. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +static StyledElement * +GetStyledElement(enginePtr, elementId) + StyleEngine *enginePtr; /* Style engine providing the implementation. + * NULL means the default system engine. */ + int elementId; /* Unique element ID */{ + StyledElement *elementPtr; + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + StyleEngine *enginePtr2; + + if (enginePtr == NULL) { + enginePtr = tsdPtr->defaultEnginePtr; + } + + while (elementId >= 0 && elementId < tsdPtr->nbElements) { + /* + * Look for an implemented element through the engine chain. + */ + + enginePtr2 = enginePtr; + do { + elementPtr = enginePtr2->elements+elementId; + if (elementPtr->specPtr != NULL) { + return elementPtr; + } + enginePtr2 = enginePtr2->parentPtr; + } while (enginePtr2 != NULL); + + /* + * None found, try with the generic element. + */ + + elementId = tsdPtr->elements[elementId].genericId; + } + + /* + * No matching element found. + */ + + return NULL; +} + +/* + *--------------------------------------------------------------------------- + * + * InitWidgetSpec -- + * + * Initialize a newly allocated widget spec. + * + * Results: + * None. + * + * Side effects: + * Memory allocated. + * + *--------------------------------------------------------------------------- + */ + +static void +InitWidgetSpec(widgetSpecPtr, elementPtr, optionTable) + StyledWidgetSpec *widgetSpecPtr; /* Points to an uninitialized widget + * spec. */ + StyledElement *elementPtr; /* Styled element descriptor. */ + Tk_OptionTable optionTable; /* The widget's option table. */ +{ + int i, nbOptions; + Tk_ElementOptionSpec *elementOptionPtr; + CONST Tk_OptionSpec *widgetOptionPtr; + + widgetSpecPtr->elementPtr = elementPtr; + widgetSpecPtr->optionTable = optionTable; + + /* + * Count the number of options. + */ + + for (nbOptions = 0, elementOptionPtr = elementPtr->specPtr->options; + elementOptionPtr->name != NULL; + nbOptions++, elementOptionPtr++) { + } + + /* + * Build the widget option list. + */ + + widgetSpecPtr->optionsPtr = (CONST Tk_OptionSpec **) ckalloc( + sizeof(Tk_OptionSpec *) * nbOptions); + for (i = 0, elementOptionPtr = elementPtr->specPtr->options; + i < nbOptions; + i++, elementOptionPtr++) { + widgetOptionPtr = TkGetOptionSpec(elementOptionPtr->name, optionTable); + + /* + * Check that the widget option type is compatible with one of the + * element's required types. + */ + + if ( elementOptionPtr->type == TK_OPTION_END + || elementOptionPtr->type == widgetOptionPtr->type) { + widgetSpecPtr->optionsPtr[i] = widgetOptionPtr; + } else { + widgetSpecPtr->optionsPtr[i] = NULL; + } + } +} + +/* + *--------------------------------------------------------------------------- + * + * FreeWidgetSpec -- + * + * Free a widget spec and its associated data. + * + * Results: + * None + * + * Side effects: + * Memory freed. + * + *--------------------------------------------------------------------------- + */ + +static void +FreeWidgetSpec(widgetSpecPtr) + StyledWidgetSpec *widgetSpecPtr; /* The widget spec to free. */ +{ + ckfree((char *) widgetSpecPtr->optionsPtr); +} + +/* + *--------------------------------------------------------------------------- + * + * GetWidgetSpec -- + * + * Return a new or existing widget spec for the given element and + * widget type (identified by its option table). + * + * Results: + * A pointer to the matching widget spec. + * + * Side effects: + * Memory may be allocated. + * + *--------------------------------------------------------------------------- + */ + +static StyledWidgetSpec * +GetWidgetSpec(elementPtr, optionTable) + StyledElement *elementPtr; /* Styled element descriptor. */ + Tk_OptionTable optionTable; /* The widget's option table. */ +{ + StyledWidgetSpec *widgetSpecPtr; + int i; + + /* + * Try to find an existing widget spec. + */ + + for (i = 0; i < elementPtr->nbWidgetSpecs; i++) { + widgetSpecPtr = elementPtr->widgetSpecs+i; + if (widgetSpecPtr->optionTable == optionTable) { + return widgetSpecPtr; + } + } + + /* + * Create and initialize a new widget spec. + */ + + i = elementPtr->nbWidgetSpecs++; + elementPtr->widgetSpecs = (StyledWidgetSpec *) ckrealloc( + (char *) elementPtr->widgetSpecs, + sizeof(StyledWidgetSpec) * elementPtr->nbWidgetSpecs); + widgetSpecPtr = elementPtr->widgetSpecs+i; + InitWidgetSpec(widgetSpecPtr, elementPtr, optionTable); + + return widgetSpecPtr; +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_GetStyledElement -- + * + * This procedure returns a styled instance of the given element. + * + * Results: + * None. + * + * Side effects: + * Cached data may be allocated or updated. + * + *--------------------------------------------------------------------------- + */ + +Tk_StyledElement +Tk_GetStyledElement(style, elementId, optionTable) + Tk_Style style; /* The widget style. */ + int elementId; /* Unique element ID. */ + Tk_OptionTable optionTable; /* Option table for the widget. */ +{ + Style *stylePtr = (Style *) style; + StyledElement *elementPtr; + + /* + * Get an element implementation and call corresponding hook. + */ + + elementPtr = GetStyledElement((stylePtr?stylePtr->enginePtr:NULL), + elementId); + if (!elementPtr) { + return NULL; + } + + return (Tk_StyledElement) GetWidgetSpec(elementPtr, optionTable); +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_GetElementSize -- + * + * This procedure computes the size of the given widget element according + * to its style. + * + * Results: + * None. + * + * Side effects: + * Cached data may be allocated or updated. + * + *--------------------------------------------------------------------------- + */ + +void +Tk_GetElementSize(style, element, recordPtr, tkwin, width, height, inner, widthPtr, + heightPtr) + Tk_Style style; /* The widget style. */ + Tk_StyledElement element; /* The styled element, previously + * returned by Tk_GetStyledElement. */ + char *recordPtr; /* The widget record. */ + Tk_Window tkwin; /* The widget window. */ + int width, height; /* Requested size. */ + int inner; /* Boolean. If TRUE, compute the outer + * size according to the requested + * minimum inner size. If FALSE, compute + * the inner size according to the + * requested maximum outer size. */ + int *widthPtr, *heightPtr; /* Returned size. */ +{ + Style *stylePtr = (Style *) style; + StyledWidgetSpec *widgetSpecPtr = (StyledWidgetSpec *) element; + + widgetSpecPtr->elementPtr->specPtr->getSize(stylePtr->clientData, + recordPtr, widgetSpecPtr->optionsPtr, tkwin, width, height, inner, + widthPtr, heightPtr); +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_GetElementBox -- + * + * This procedure computes the bounding or inscribed box coordinates + * of the given widget element according to its style and within the + * given limits. + * + * Results: + * None. + * + * Side effects: + * Cached data may be allocated or updated. + * + *--------------------------------------------------------------------------- + */ + +void +Tk_GetElementBox(style, element, recordPtr, tkwin, x, y, width, height, inner, + xPtr, yPtr, widthPtr, heightPtr) + Tk_Style style; /* The widget style. */ + Tk_StyledElement element; /* The styled element, previously + * returned by Tk_GetStyledElement. */ + char *recordPtr; /* The widget record. */ + Tk_Window tkwin; /* The widget window. */ + int x, y; /* Top left corner of available area. */ + int width, height; /* Size of available area. */ + int inner; /* Boolean. If TRUE, compute the + * bounding box according to the + * requested inscribed box size. If + * FALSE, compute the inscribed box + * according to the requested bounding + * box. */ + int *xPtr, *yPtr; /* Returned top left corner. */ + int *widthPtr, *heightPtr; /* Returned size. */ +{ + Style *stylePtr = (Style *) style; + StyledWidgetSpec *widgetSpecPtr = (StyledWidgetSpec *) element; + + widgetSpecPtr->elementPtr->specPtr->getBox(stylePtr->clientData, + recordPtr, widgetSpecPtr->optionsPtr, tkwin, x, y, width, height, + inner, xPtr, yPtr, widthPtr, heightPtr); +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_GetElementBorderWidth -- + * + * This procedure computes the border widthof the given widget element + * according to its style and within the given limits. + * + * Results: + * Border width in pixels. This value is uniform for all four sides. + * + * Side effects: + * Cached data may be allocated or updated. + * + *--------------------------------------------------------------------------- + */ + +int +Tk_GetElementBorderWidth(style, element, recordPtr, tkwin) + Tk_Style style; /* The widget style. */ + Tk_StyledElement element; /* The styled element, previously + * returned by Tk_GetStyledElement. */ + char *recordPtr; /* The widget record. */ + Tk_Window tkwin; /* The widget window. */ +{ + Style *stylePtr = (Style *) style; + StyledWidgetSpec *widgetSpecPtr = (StyledWidgetSpec *) element; + + return widgetSpecPtr->elementPtr->specPtr->getBorderWidth( + stylePtr->clientData, recordPtr, widgetSpecPtr->optionsPtr, tkwin); +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_DrawElement -- + * + * This procedure draw the given widget element in a given drawable area. + * + * Results: + * None + * + * Side effects: + * Cached data may be allocated or updated. + * + *--------------------------------------------------------------------------- + */ + +void +Tk_DrawElement(style, element, recordPtr, tkwin, d, x, y, width, height, state) + Tk_Style style; /* The widget style. */ + Tk_StyledElement element; /* The styled element, previously + * returned by Tk_GetStyledElement. */ + char *recordPtr; /* The widget record. */ + Tk_Window tkwin; /* The widget window. */ + Drawable d; /* Where to draw element. */ + int x, y; /* Top left corner of element. */ + int width, height; /* Size of element. */ + int state; /* Drawing state flags. */ +{ + Style *stylePtr = (Style *) style; + StyledWidgetSpec *widgetSpecPtr = (StyledWidgetSpec *) element; + + widgetSpecPtr->elementPtr->specPtr->draw(stylePtr->clientData, + recordPtr, widgetSpecPtr->optionsPtr, tkwin, d, x, y, width, + height, state); +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_CreateStyle -- + * + * This procedure is called to create a new style as an instance of the + * given engine. Styles are stored in thread-local space. + * + * Results: + * The newly allocated style. + * + * Side effects: + * Memory allocated. Data added to thread-local table. The style's + * refCount is incremented. + * + *--------------------------------------------------------------------------- + */ + +Tk_Style +Tk_CreateStyle(name, engine, clientData) + CONST char *name; /* Name of the style to create. NULL or empty + * means the default system style. */ + Tk_StyleEngine engine; /* The style engine. */ + ClientData clientData; /* Private data passed as is to engine code. */ +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_HashEntry *entryPtr; + int newEntry; + Style *stylePtr; + + /* + * Attempt to create a new entry in the style table. + */ + + entryPtr = Tcl_CreateHashEntry(&tsdPtr->styleTable, (name?name:""), + &newEntry); + if (!newEntry) { + /* + * A style was already registered by that name. + */ + + return NULL; + } + + /* + * Allocate and intitialize a new style. + */ + + stylePtr = (Style *) ckalloc(sizeof(Style)); + InitStyle(stylePtr, entryPtr, Tcl_GetHashKey(&tsdPtr->styleTable, entryPtr), + (engine?(StyleEngine *) engine:tsdPtr->defaultEnginePtr), clientData); + Tcl_SetHashValue(entryPtr, (ClientData) stylePtr); + stylePtr->refCount++; + + return (Tk_Style) stylePtr; +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_NameOfStyle -- + * + * Given a style, return its registered name. + * + * Results: + * The return value is the name that was passed to Tk_CreateStyle() to + * create the style. The storage for the returned string is private + * (it points to the corresponding hash key) The caller should not modify + * this string. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +CONST char * +Tk_NameOfStyle(style) + Tk_Style style; /* Style whose name is desired. */ +{ + Style *stylePtr = (Style *) style; + + return stylePtr->name; +} + +/* + *--------------------------------------------------------------------------- + * + * InitStyle -- + * + * Initialize a newly allocated style. + * + * Results: + * None. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +static void +InitStyle(stylePtr, hashPtr, name, enginePtr, clientData) + Style *stylePtr; /* Points to an uninitialized style. */ + Tcl_HashEntry *hashPtr; /* Hash entry for the registered style. */ + CONST char *name; /* Name of the registered style. NULL or empty + * means the default system style. Usually + * points to the hash key. */ + StyleEngine *enginePtr; /* The style engine. */ + ClientData clientData; /* Private data passed as is to engine code. */ +{ + stylePtr->refCount = 0; + stylePtr->hashPtr = hashPtr; + stylePtr->name = name; + stylePtr->enginePtr = enginePtr; + stylePtr->clientData = clientData; +} + +/* + *--------------------------------------------------------------------------- + * + * FreeStyle -- + * + * Free a style and its associated data. + * + * Results: + * None + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +static void +FreeStyle(stylePtr) + Style *stylePtr; /* The style to free. */ +{ + /* Nothing to do. */ +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_GetStyle -- + * + * Retrieve a registered style by its name. + * + * Results: + * A pointer to the style engine, or NULL if none found. In the latter + * case and if the interp is not NULL, an error message is left in the + * interp's result. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +Tk_Style +Tk_GetStyle(interp, name) + Tcl_Interp *interp; /* Interp for error return. */ + CONST char *name; /* Name of the style to retrieve. NULL or empty + * means the default system style. */ +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + Tcl_HashEntry *entryPtr; + Style *stylePtr; + + /* + * Search for a corresponding entry in the style table. + */ + + entryPtr = Tcl_FindHashEntry(&tsdPtr->styleTable, (name?name:"")); + if (entryPtr == NULL) { + if (interp != NULL) { + Tcl_AppendResult(interp, "style \"", name, "\" doesn't exist", NULL); + } + return (Tk_Style) NULL; + } + stylePtr = (Style *) Tcl_GetHashValue(entryPtr); + stylePtr->refCount++; + + return (Tk_Style) stylePtr; +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_FreeStyle -- + * + * Free a style previously created by Tk_CreateStyle. + * + * Results: + * None + * + * Side effects: + * The style's refCount is decremented. If it reaches zero, the style + * is freed. + * + *--------------------------------------------------------------------------- + */ + +void +Tk_FreeStyle(style) + Tk_Style style; /* The style to free. */ +{ + Style *stylePtr = (Style *) style; + + if (stylePtr == NULL) { + return; + } + stylePtr->refCount--; + if (stylePtr->refCount > 0) { + return; + } + + /* + * Keep the default style alive. + */ + + if (*stylePtr->name == '\0') { + stylePtr->refCount = 1; + return; + } + + Tcl_DeleteHashEntry(stylePtr->hashPtr); + FreeStyle(stylePtr); + ckfree((char *) stylePtr); +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_AllocStyleFromObj -- + * + * Map the string name of a style to a corresponding Tk_Style. The style + * must have already been created by Tk_CreateStyle. + * + * Results: + * The return value is a token for the style that matches objPtr, or + * NULL if none found. If NULL is returned, an error message will be + * left in interp's result object. + * + * Side effects: + * The style's reference count is incremented. For each call to this + * procedure, there should eventually be a call to Tk_FreeStyle() or + * Tk_FreeStyleFromObj() so that the database is cleaned up when styles + * aren't in use anymore. + * + *--------------------------------------------------------------------------- + */ + +Tk_Style +Tk_AllocStyleFromObj(interp, objPtr) + Tcl_Interp *interp; /* Interp for error return. */ + Tcl_Obj *objPtr; /* Object containing name of the style to + * retrieve. */ +{ + Style *stylePtr; + + if (objPtr->typePtr != &styleObjType) { + SetStyleFromAny(interp, objPtr); + stylePtr = (Style *) objPtr->internalRep.otherValuePtr; + } else { + stylePtr = (Style *) objPtr->internalRep.otherValuePtr; + stylePtr->refCount++; + } + + return (Tk_Style) stylePtr; +} + +/* + *---------------------------------------------------------------------- + * + * Tk_GetStyleFromObj -- + * + * Find the style that corresponds to a given object. The style must + * have already been created by Tk_CreateStyle. + * + * Results: + * The return value is a token for the style that matches objPtr, or + * NULL if none found. + * + * Side effects: + * If the object is not already a style ref, the conversion will free + * any old internal representation. + * + *---------------------------------------------------------------------- + */ + +Tk_Style +Tk_GetStyleFromObj(objPtr) + Tcl_Obj *objPtr; /* The object from which to get the style. */ +{ + if (objPtr->typePtr != &styleObjType) { + SetStyleFromAny((Tcl_Interp *) NULL, objPtr); + } + + return (Tk_Style) objPtr->internalRep.otherValuePtr; +} + +/* + *--------------------------------------------------------------------------- + * + * Tk_FreeStyleFromObj -- + * + * Called to release a style inside a Tcl_Obj *. + * + * Results: + * None. + * + * Side effects: + * If the object is a style ref, the conversion will free its + * internal representation. + * + *--------------------------------------------------------------------------- + */ + +void +Tk_FreeStyleFromObj(objPtr) + Tcl_Obj *objPtr; /* The Tcl_Obj * to be freed. */ +{ + if (objPtr->typePtr == &styleObjType) { + FreeStyleObjProc(objPtr); + } +} + +/* + *---------------------------------------------------------------------- + * + * SetStyleFromAny -- + * + * Convert the internal representation of a Tcl object to the + * style internal form. + * + * Results: + * Always returns TCL_OK. If an error occurs is returned (e.g. the + * style doesn't exist), an error message will be left in interp's + * result. + * + * Side effects: + * The object is left with its typePtr pointing to styleObjType. + * The reference count is incremented (in Tk_GetStyle()). + * + *---------------------------------------------------------------------- + */ + +static int +SetStyleFromAny(interp, objPtr) + Tcl_Interp *interp; /* Used for error reporting if not NULL. */ + Tcl_Obj *objPtr; /* The object to convert. */ +{ + Tcl_ObjType *typePtr; + char *name; + + /* + * Free the old internalRep before setting the new one. + */ + + name = Tcl_GetString(objPtr); + typePtr = objPtr->typePtr; + if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) { + (*typePtr->freeIntRepProc)(objPtr); + } + + objPtr->typePtr = &styleObjType; + objPtr->internalRep.otherValuePtr = (VOID *) Tk_GetStyle(interp, name); + + return TCL_OK; +} + +/* + *--------------------------------------------------------------------------- + * + * FreeStyleObjProc -- + * + * This proc is called to release an object reference to a style. + * Called when the object's internal rep is released. + * + * Results: + * None. + * + * Side effects: + * The reference count is decremented (in Tk_FreeStyle()). + * + *--------------------------------------------------------------------------- + */ + +static void +FreeStyleObjProc(objPtr) + Tcl_Obj *objPtr; /* The object we are releasing. */ +{ + Style *stylePtr = (Style *) objPtr->internalRep.otherValuePtr; + + if (stylePtr != NULL) { + Tk_FreeStyle((Tk_Style) stylePtr); + objPtr->internalRep.otherValuePtr = NULL; + } +} + +/* + *--------------------------------------------------------------------------- + * + * DupStyleObjProc -- + * + * When a cached style object is duplicated, this is called to + * update the internal reps. + * + * Results: + * None. + * + * Side effects: + * The style's refCount is incremented and the internal rep of the copy + * is set to point to it. + * + *--------------------------------------------------------------------------- + */ + +static void +DupStyleObjProc(srcObjPtr, dupObjPtr) + Tcl_Obj *srcObjPtr; /* The object we are copying from. */ + Tcl_Obj *dupObjPtr; /* The object we are copying to. */ +{ + Style *stylePtr = (Style *) srcObjPtr->internalRep.otherValuePtr; + + dupObjPtr->typePtr = srcObjPtr->typePtr; + dupObjPtr->internalRep.otherValuePtr = (VOID *) stylePtr; + + if (stylePtr != NULL) { + stylePtr->refCount++; + } +} diff --git a/tk/generic/tkTest.c b/tk/generic/tkTest.c index 7fd0d5125b4..080589c707f 100644 --- a/tk/generic/tkTest.c +++ b/tk/generic/tkTest.c @@ -24,7 +24,7 @@ #include "tkWinInt.h" #endif -#ifdef MAC_TCL +#if defined(MAC_TCL) || defined(MAC_OSX_TK) #include "tkScrollbar.h" #endif @@ -157,9 +157,9 @@ static int CBindingEvalProc _ANSI_ARGS_((ClientData clientData, static void CBindingFreeProc _ANSI_ARGS_((ClientData clientData)); int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp)); static int ImageCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); static int TestcbindCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); static int TestbitmapObjCmd _ANSI_ARGS_((ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[])); @@ -173,30 +173,41 @@ static int TestcursorObjCmd _ANSI_ARGS_((ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[])); static int TestdeleteappsCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); static int TestfontObjCmd _ANSI_ARGS_((ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); static int TestmakeexistCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); static int TestmenubarCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *interp, int argc, char **argv)); -#if defined(__WIN32__) || defined(MAC_TCL) + Tcl_Interp *interp, int argc, CONST char **argv)); +#if defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK) static int TestmetricsCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); #endif static int TestobjconfigObjCmd _ANSI_ARGS_((ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[])); +static int CustomOptionSet _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, Tk_Window tkwin, + Tcl_Obj **value, char *recordPtr, int internalOffset, + char *saveInternalPtr, int flags)); +static Tcl_Obj *CustomOptionGet _ANSI_ARGS_((ClientData clientData, + Tk_Window tkwin, char *recordPtr, int internalOffset)); +static void CustomOptionRestore _ANSI_ARGS_((ClientData clientData, + Tk_Window tkwin, char *internalPtr, + char *saveInternalPtr)); +static void CustomOptionFree _ANSI_ARGS_((ClientData clientData, + Tk_Window tkwin, char *internalPtr)); static int TestpropCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); static int TestsendCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); static int TesttextCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *interp, int argc, char **argv)); -#if !(defined(__WIN32__) || defined(MAC_TCL)) + Tcl_Interp *interp, int argc, CONST char **argv)); +#if !(defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) static int TestwrapperCmd _ANSI_ARGS_((ClientData dummy, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); #endif static void TrivialCmdDeletedProc _ANSI_ARGS_(( ClientData clientData)); @@ -211,9 +222,8 @@ static void TrivialEventProc _ANSI_ARGS_((ClientData clientData, */ extern int TkplatformtestInit _ANSI_ARGS_((Tcl_Interp *interp)); -extern int TclThread_Init _ANSI_ARGS_((Tcl_Interp *interp)); -#if !(defined(__WIN32__) || defined(MAC_TCL)) +#if !(defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) #define TkplatformtestInit(x) TCL_OK #endif @@ -271,29 +281,27 @@ Tktest_Init(interp) (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL); Tcl_CreateCommand(interp, "testmakeexist", TestmakeexistCmd, (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL); +#if !(defined(__WIN32__) || defined(MAC_TCL)) Tcl_CreateCommand(interp, "testmenubar", TestmenubarCmd, (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL); -#if defined(__WIN32__) || defined(MAC_TCL) +#endif +#if defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK) Tcl_CreateCommand(interp, "testmetrics", TestmetricsCmd, (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL); #endif Tcl_CreateCommand(interp, "testprop", TestpropCmd, (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL); +#if !(defined(__WIN32__) || defined(MAC_TCL)) Tcl_CreateCommand(interp, "testsend", TestsendCmd, (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL); +#endif Tcl_CreateCommand(interp, "testtext", TesttextCmd, (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL); -#if !(defined(__WIN32__) || defined(MAC_TCL)) +#if !(defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) Tcl_CreateCommand(interp, "testwrapper", TestwrapperCmd, (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL); #endif -#ifdef TCL_THREADS - if (TclThread_Init(interp) != TCL_OK) { - return TCL_ERROR; - } -#endif - /* * Create test image type. */ @@ -332,7 +340,7 @@ TestcbindCmd(clientData, interp, argc, argv) ClientData clientData; /* Main window for application. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { TkWindow *winPtr; Tk_Window tkwin; @@ -581,7 +589,7 @@ TestdeleteappsCmd(clientData, interp, argc, argv) ClientData clientData; /* Main window for application. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { NewApp *nextPtr; @@ -620,7 +628,7 @@ TestobjconfigObjCmd(clientData, interp, objc, objv) int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ { - static char *options[] = {"alltypes", "chain1", "chain2", + static CONST char *options[] = {"alltypes", "chain1", "chain2", "configerror", "delete", "info", "internal", "new", "notenoughparams", "twowindows", (char *) NULL}; enum { @@ -639,6 +647,14 @@ TestobjconfigObjCmd(clientData, interp, objc, objv) * created by commands below; indexed * with same values as "options" * array. */ + static Tk_ObjCustomOption CustomOption = { + "custom option", + CustomOptionSet, + CustomOptionGet, + CustomOptionRestore, + CustomOptionFree, + (ClientData) 1 + }; Tk_Window mainWin = (Tk_Window) clientData; Tk_Window tkwin; int index, result = TCL_OK; @@ -696,6 +712,7 @@ TestobjconfigObjCmd(clientData, interp, objc, objv) Tcl_Obj *anchorPtr; Tcl_Obj *pixelPtr; Tcl_Obj *mmPtr; + Tcl_Obj *customPtr; } TypesRecord; TypesRecord *recordPtr; static char *stringTable[] = {"one", "two", "three", "four", @@ -761,6 +778,10 @@ TestobjconfigObjCmd(clientData, interp, objc, objv) "-pixel", "pixel", "Pixel", "1", Tk_Offset(TypesRecord, pixelPtr), -1, TK_CONFIG_NULL_OK, 0, 0x2000}, + {TK_OPTION_CUSTOM, + "-custom", (char *) NULL, (char *) NULL, + "", Tk_Offset(TypesRecord, customPtr), -1, + TK_CONFIG_NULL_OK, (ClientData)&CustomOption, 0x4000}, {TK_OPTION_SYNONYM, "-synonym", (char *) NULL, (char *) NULL, (char *) NULL, 0, -1, 0, (ClientData) "-color", @@ -798,6 +819,7 @@ TestobjconfigObjCmd(clientData, interp, objc, objv) recordPtr->pixelPtr = NULL; recordPtr->mmPtr = NULL; recordPtr->stringTablePtr = NULL; + recordPtr->customPtr = NULL; result = Tk_InitOptions(interp, (char *) recordPtr, optionTable, tkwin); if (result == TCL_OK) { @@ -1005,6 +1027,7 @@ TestobjconfigObjCmd(clientData, interp, objc, objv) int pixels; double mm; Tk_Window tkwin; + char *custom; } InternalRecord; InternalRecord *recordPtr; static char *internalStringTable[] = { @@ -1071,6 +1094,10 @@ TestobjconfigObjCmd(clientData, interp, objc, objv) "-window", "window", "Window", (char *) NULL, -1, Tk_Offset(InternalRecord, tkwin), TK_CONFIG_NULL_OK, 0, 0}, + {TK_OPTION_CUSTOM, + "-custom", (char *) NULL, (char *) NULL, + "", -1, Tk_Offset(InternalRecord, custom), + TK_CONFIG_NULL_OK, (ClientData)&CustomOption, 0x4000}, {TK_OPTION_SYNONYM, "-synonym", (char *) NULL, (char *) NULL, (char *) NULL, -1, -1, 0, (ClientData) "-color", @@ -1108,6 +1135,7 @@ TestobjconfigObjCmd(clientData, interp, objc, objv) recordPtr->pixels = 0; recordPtr->mm = 0.0; recordPtr->tkwin = NULL; + recordPtr->custom = NULL; result = Tk_InitOptions(interp, (char *) recordPtr, optionTable, tkwin); if (result == TCL_OK) { @@ -1323,7 +1351,9 @@ TrivialConfigObjCmd(clientData, interp, objc, objv) Tcl_Obj *CONST objv[]; /* Argument objects. */ { int result = TCL_OK; - static char *options[] = {"cget", "configure", "csave", (char *) NULL}; + static CONST char *options[] = { + "cget", "configure", "csave", (char *) NULL + }; enum { CGET, CONFIGURE, CSAVE }; @@ -1507,7 +1537,7 @@ TestfontObjCmd(clientData, interp, objc, objv) int objc; /* Number of arguments. */ Tcl_Obj *CONST objv[]; /* Argument objects. */ { - static char *options[] = {"counts", "subfonts", (char *) NULL}; + static CONST char *options[] = {"counts", "subfonts", (char *) NULL}; enum option {COUNTS, SUBFONTS}; int index; Tk_Window tkwin; @@ -1565,12 +1595,12 @@ TestfontObjCmd(clientData, interp, objc, objv) /* ARGSUSED */ #ifdef USE_OLD_IMAGE static int -ImageCreate(interp, name, argc, objv, typePtr, master, clientDataPtr) +ImageCreate(interp, name, argc, argv, typePtr, master, clientDataPtr) Tcl_Interp *interp; /* Interpreter for application containing * image. */ char *name; /* Name to use for image. */ int argc; /* Number of arguments. */ - Tcl_Obj *CONST objv[]; /* Argument strings for options (doesn't + char **argv; /* Argument strings for options (doesn't * include image name or type). */ Tk_ImageType *typePtr; /* Pointer to our type record (not used). */ Tk_ImageMaster master; /* Token for image, to be used by us in @@ -1595,7 +1625,7 @@ ImageCreate(interp, name, argc, objv, typePtr, master, clientDataPtr) argv[i], "\" option", (char *) NULL); return TCL_ERROR; } - varName = Tcl_GetStringFromObj(objv[i+1], NULL); + varName = argv[i+1]; } #else static int @@ -1670,7 +1700,7 @@ ImageCmd(clientData, interp, argc, argv) ClientData clientData; /* Main window for application. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { TImageMaster *timPtr = (TImageMaster *) clientData; int x, y, width, height; @@ -1893,7 +1923,7 @@ TestmakeexistCmd(clientData, interp, argc, argv) ClientData clientData; /* Main window for application. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { Tk_Window mainWin = (Tk_Window) clientData; int i; @@ -1934,7 +1964,7 @@ TestmenubarCmd(clientData, interp, argc, argv) ClientData clientData; /* Main window for application. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { #ifdef __UNIX__ Tk_Window mainWin = (Tk_Window) clientData; @@ -2002,7 +2032,7 @@ TestmetricsCmd(clientData, interp, argc, argv) ClientData clientData; /* Main window for application. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { char buf[TCL_INTEGER_SPACE]; @@ -2026,13 +2056,13 @@ TestmetricsCmd(clientData, interp, argc, argv) return TCL_OK; } #endif -#ifdef MAC_TCL +#if defined(MAC_TCL) || defined(MAC_OSX_TK) static int TestmetricsCmd(clientData, interp, argc, argv) ClientData clientData; /* Main window for application. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { Tk_Window tkwin = (Tk_Window) clientData; TkWindow *winPtr; @@ -2087,7 +2117,7 @@ TestpropCmd(clientData, interp, argc, argv) ClientData clientData; /* Main window for application. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { Tk_Window mainWin = (Tk_Window) clientData; int result, actualFormat; @@ -2160,16 +2190,15 @@ TestpropCmd(clientData, interp, argc, argv) */ /* ARGSUSED */ +#if !(defined(__WIN32__) || defined(MAC_TCL)) static int TestsendCmd(clientData, interp, argc, argv) ClientData clientData; /* Main window for application. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { -#if !(defined(__WIN32__) || defined(MAC_TCL)) TkWindow *winPtr = (TkWindow *) clientData; -#endif if (argc < 2) { Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0], @@ -2177,7 +2206,6 @@ TestsendCmd(clientData, interp, argc, argv) return TCL_ERROR; } -#if !(defined(__WIN32__) || defined(MAC_TCL)) if (strcmp(argv[1], "bogus") == 0) { XChangeProperty(winPtr->dispPtr->display, RootWindow(winPtr->dispPtr->display, 0), @@ -2226,14 +2254,22 @@ TestsendCmd(clientData, interp, argc, argv) if (argv[4][0] == 0) { XDeleteProperty(winPtr->dispPtr->display, w, propName); } else { - for (p = argv[4]; *p != 0; p++) { + Tcl_DString tmp; + + Tcl_DStringInit(&tmp); + for (p = Tcl_DStringAppend(&tmp, argv[4], + (int) strlen(argv[4])); + *p != 0; p++) { if (*p == '\n') { *p = 0; } } + XChangeProperty(winPtr->dispPtr->display, w, propName, XA_STRING, 8, PropModeReplace, - (unsigned char *) argv[4], p-argv[4]); + (unsigned char *) Tcl_DStringValue(&tmp), + p-Tcl_DStringValue(&tmp)); + Tcl_DStringFree(&tmp); } } } else if (strcmp(argv[1], "serial") == 0) { @@ -2246,9 +2282,9 @@ TestsendCmd(clientData, interp, argc, argv) "\": must be bogus, prop, or serial", (char *) NULL); return TCL_ERROR; } -#endif return TCL_OK; } +#endif /* *---------------------------------------------------------------------- @@ -2273,7 +2309,7 @@ TesttextCmd(clientData, interp, argc, argv) ClientData clientData; /* Main window for application. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { TkText *textPtr; size_t len; @@ -2329,7 +2365,7 @@ TesttextCmd(clientData, interp, argc, argv) return TCL_OK; } -#if !(defined(__WIN32__) || defined(MAC_TCL)) +#if !(defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) /* *---------------------------------------------------------------------- * @@ -2354,7 +2390,7 @@ TestwrapperCmd(clientData, interp, argc, argv) ClientData clientData; /* Main window for application. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { TkWindow *winPtr, *wrapperPtr; Tk_Window tkwin; @@ -2381,5 +2417,125 @@ TestwrapperCmd(clientData, interp, argc, argv) return TCL_OK; } #endif + +/* + *---------------------------------------------------------------------- + * + * CustomOptionSet, CustomOptionGet, CustomOptionRestore, CustomOptionFree -- + * + * Handlers for object-based custom configuration options. See + * Testobjconfigcommand. + * + * Results: + * See user documentation for expected results from these functions. + * CustomOptionSet Standard Tcl Result. + * CustomOptionGet Tcl_Obj * containing value. + * CustomOptionRestore None. + * CustomOptionFree None. + * + * Side effects: + * Depends on the function. + * CustomOptionSet Sets option value to new setting. + * CustomOptionGet Creates a new Tcl_Obj. + * CustomOptionRestore Resets option value to original value. + * CustomOptionFree Free storage for internal rep of + * option. + * + *---------------------------------------------------------------------- + */ + +static int +CustomOptionSet(clientData,interp, tkwin, value, recordPtr, internalOffset, + saveInternalPtr, flags) + ClientData clientData; + Tcl_Interp *interp; + Tk_Window tkwin; + Tcl_Obj **value; + char *recordPtr; + int internalOffset; + char *saveInternalPtr; + int flags; +{ + int objEmpty, length; + char *new, *string, *internalPtr; + + objEmpty = 0; + + if (internalOffset >= 0) { + internalPtr = recordPtr + internalOffset; + } else { + internalPtr = NULL; + } + + /* + * See if the object is empty. + */ + if (value == NULL) { + objEmpty = 1; + } else { + if ((*value)->bytes != NULL) { + objEmpty = ((*value)->length == 0); + } else { + Tcl_GetStringFromObj((*value), &length); + objEmpty = (length == 0); + } + } + + if ((flags & TK_OPTION_NULL_OK) && objEmpty) { + *value = NULL; + } else { + string = Tcl_GetStringFromObj((*value), &length); + Tcl_UtfToUpper(string); + if (strcmp(string, "BAD") == 0) { + Tcl_SetResult(interp, "expected good value, got \"BAD\"", + TCL_STATIC); + return TCL_ERROR; + } + } + if (internalPtr != NULL) { + if ((*value) != NULL) { + string = Tcl_GetStringFromObj((*value), &length); + new = ckalloc((size_t) (length + 1)); + strcpy(new, string); + } else { + new = NULL; + } + *((char **) saveInternalPtr) = *((char **) internalPtr); + *((char **) internalPtr) = new; + } + return TCL_OK; +} + +static Tcl_Obj * +CustomOptionGet(clientData, tkwin, recordPtr, internalOffset) + ClientData clientData; + Tk_Window tkwin; + char *recordPtr; + int internalOffset; +{ + return (Tcl_NewStringObj(*(char **)(recordPtr + internalOffset), -1)); +} + +static void +CustomOptionRestore(clientData, tkwin, internalPtr, saveInternalPtr) + ClientData clientData; + Tk_Window tkwin; + char *internalPtr; + char *saveInternalPtr; +{ + *(char **)internalPtr = *(char **)saveInternalPtr; + return; +} + +static void +CustomOptionFree(clientData, tkwin, internalPtr) + ClientData clientData; + Tk_Window tkwin; + char *internalPtr; +{ + if (*(char **)internalPtr != NULL) { + ckfree(*(char **)internalPtr); + } +} diff --git a/tk/generic/tkText.c b/tk/generic/tkText.c index 560c0260d9c..eadfd001c22 100644 --- a/tk/generic/tkText.c +++ b/tk/generic/tkText.c @@ -20,8 +20,9 @@ #include "default.h" #include "tkPort.h" #include "tkInt.h" +#include "tkUndo.h" -#ifdef MAC_TCL +#if defined(MAC_TCL) || defined(MAC_OSX_TK) #define Style TkStyle #define DInfo TkDInfo #endif @@ -42,6 +43,9 @@ static Tk_CustomOption stateOption = { */ static Tk_ConfigSpec configSpecs[] = { + {TK_CONFIG_BOOLEAN, "-autoseparators", "autoSeparators", + "AutoSeparators", DEF_TEXT_AUTO_SEPARATORS, + Tk_Offset(TkText, autoSeparators), 0}, {TK_CONFIG_BORDER, "-background", "background", "Background", DEF_TEXT_BG_COLOR, Tk_Offset(TkText, border), TK_CONFIG_COLOR_ONLY}, {TK_CONFIG_BORDER, "-background", "background", "Background", @@ -87,6 +91,8 @@ static Tk_ConfigSpec configSpecs[] = { DEF_TEXT_INSERT_ON_TIME, Tk_Offset(TkText, insertOnTime), 0}, {TK_CONFIG_PIXELS, "-insertwidth", "insertWidth", "InsertWidth", DEF_TEXT_INSERT_WIDTH, Tk_Offset(TkText, insertWidth), 0}, + {TK_CONFIG_INT, "-maxundo", "maxUndo", "MaxUndo", + DEF_TEXT_MAX_UNDO, Tk_Offset(TkText, maxUndo), 0}, {TK_CONFIG_PIXELS, "-padx", "padX", "Pad", DEF_TEXT_PADX, Tk_Offset(TkText, padX), 0}, {TK_CONFIG_PIXELS, "-pady", "padY", "Pad", @@ -129,6 +135,8 @@ static Tk_ConfigSpec configSpecs[] = { {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_TEXT_TAKE_FOCUS, Tk_Offset(TkText, takeFocus), TK_CONFIG_NULL_OK}, + {TK_CONFIG_BOOLEAN, "-undo", "undo", "Undo", + DEF_TEXT_UNDO, Tk_Offset(TkText, undo), 0}, {TK_CONFIG_INT, "-width", "width", "Width", DEF_TEXT_WIDTH, Tk_Offset(TkText, width), 0}, {TK_CONFIG_CUSTOM, "-wrap", "wrap", "Wrap", @@ -139,15 +147,6 @@ static Tk_ConfigSpec configSpecs[] = { {TK_CONFIG_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand", DEF_TEXT_YSCROLL_COMMAND, Tk_Offset(TkText, yScrollCmd), TK_CONFIG_NULL_OK}, - - {TK_CONFIG_STRING, "-synccommand", "syncCommand", "SyncCommand", - DEF_TEXT_YSCROLL_COMMAND, Tk_Offset(TkText, SyncCmd), - TK_CONFIG_NULL_OK}, - - - {TK_CONFIG_INT, "-tabsize", "tabSize", "TabSize", - DEF_TEXT_TAB_SIZE, Tk_Offset(TkText, tabsize), 0}, - {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL, (char *) NULL, 0, 0} }; @@ -164,8 +163,8 @@ int tkTextDebug = 0; */ static int WrapModeParseProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, Tk_Window tkwin, char *value, - char *widgRec, int offset)); + Tcl_Interp *interp, Tk_Window tkwin, + CONST char *value, char *widgRec, int offset)); static char * WrapModePrintProc _ANSI_ARGS_((ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)); @@ -199,7 +198,7 @@ WrapModeParseProc(clientData, interp, tkwin, value, widgRec, offset) ClientData clientData; /* some flags.*/ Tcl_Interp *interp; /* Used for reporting errors. */ Tk_Window tkwin; /* Window containing canvas widget. */ - char *value; /* Value of option (list of tag + CONST char *value; /* Value of option (list of tag * names). */ char *widgRec; /* Pointer to record for item. */ int offset; /* Offset into item. */ @@ -286,12 +285,14 @@ WrapModePrintProc(clientData, tkwin, widgRec, offset, freeProcPtr) */ static int ConfigureText _ANSI_ARGS_((Tcl_Interp *interp, - TkText *textPtr, int argc, char **argv, int flags)); + TkText *textPtr, int argc, CONST char **argv, + int flags)); static int DeleteChars _ANSI_ARGS_((TkText *textPtr, - char *index1String, char *index2String)); + CONST char *index1String, CONST char *index2String, + TkTextIndex *indexPtr1, TkTextIndex *indexPtr2)); static void DestroyText _ANSI_ARGS_((char *memPtr)); static void InsertChars _ANSI_ARGS_((TkText *textPtr, - TkTextIndex *indexPtr, char *string)); + TkTextIndex *indexPtr, CONST char *string)); static void TextBlinkProc _ANSI_ARGS_((ClientData clientData)); static void TextCmdDeletedProc _ANSI_ARGS_(( ClientData clientData)); @@ -299,30 +300,39 @@ static void TextEventProc _ANSI_ARGS_((ClientData clientData, XEvent *eventPtr)); static int TextFetchSelection _ANSI_ARGS_((ClientData clientData, int offset, char *buffer, int maxBytes)); +static int TextIndexSortProc _ANSI_ARGS_((CONST VOID *first, + CONST VOID *second)); static int TextSearchCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); +static int TextEditCmd _ANSI_ARGS_((TkText *textPtr, + Tcl_Interp *interp, int argc, CONST char **argv)); static int TextWidgetCmd _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); static void TextWorldChanged _ANSI_ARGS_(( ClientData instanceData)); static int TextDumpCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); static void DumpLine _ANSI_ARGS_((Tcl_Interp *interp, TkText *textPtr, int what, TkTextLine *linePtr, - int start, int end, int lineno, char *command)); + int start, int end, int lineno, + CONST char *command)); static int DumpSegment _ANSI_ARGS_((Tcl_Interp *interp, char *key, - char *value, char * command, TkTextIndex *index, - int what)); + char *value, CONST char * command, + TkTextIndex *index, int what)); +static int TextEditUndo _ANSI_ARGS_((TkText *textPtr)); +static int TextEditRedo _ANSI_ARGS_((TkText *textPtr)); +static void TextGetText _ANSI_ARGS_((TkTextIndex * index1, + TkTextIndex * index2, Tcl_DString *dsPtr)); +static void updateDirtyFlag _ANSI_ARGS_((TkText *textPtr)); /* * The structure below defines text class behavior by means of procedures * that can be invoked from generic window code. */ -static TkClassProcs textClass = { - NULL, /* createProc. */ - TextWorldChanged, /* geometryProc. */ - NULL /* modalProc. */ +static Tk_ClassProcs textClass = { + sizeof(Tk_ClassProcs), /* size */ + TextWorldChanged, /* worldChangedProc */ }; @@ -349,7 +359,7 @@ Tk_TextCmd(clientData, interp, argc, argv) * interpreter. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { Tk_Window tkwin = (Tk_Window) clientData; Tk_Window new; @@ -371,7 +381,14 @@ Tk_TextCmd(clientData, interp, argc, argv) return TCL_ERROR; } + /* + * Create the text widget and initialize everything to zero, + * then set the necessary initial (non-NULL) values. + */ + textPtr = (TkText *) ckalloc(sizeof(TkText)); + memset((VOID *) textPtr, 0, sizeof(TkText)); + textPtr->tkwin = new; textPtr->display = Tk_Display(new); textPtr->interp = interp; @@ -380,66 +397,26 @@ Tk_TextCmd(clientData, interp, argc, argv) (ClientData) textPtr, TextCmdDeletedProc); textPtr->tree = TkBTreeCreate(textPtr); Tcl_InitHashTable(&textPtr->tagTable, TCL_STRING_KEYS); - textPtr->numTags = 0; Tcl_InitHashTable(&textPtr->markTable, TCL_STRING_KEYS); Tcl_InitHashTable(&textPtr->windowTable, TCL_STRING_KEYS); Tcl_InitHashTable(&textPtr->imageTable, TCL_STRING_KEYS); textPtr->state = TK_STATE_NORMAL; - textPtr->border = NULL; - textPtr->borderWidth = 0; - textPtr->padX = 0; - textPtr->padY = 0; textPtr->relief = TK_RELIEF_FLAT; - textPtr->highlightWidth = 0; - textPtr->highlightBgColorPtr = NULL; - textPtr->highlightColorPtr = NULL; textPtr->cursor = None; - textPtr->fgColor = NULL; - textPtr->tkfont = NULL; textPtr->charWidth = 1; - textPtr->spacing1 = 0; - textPtr->spacing2 = 0; - textPtr->spacing3 = 0; - textPtr->tabOptionString = NULL; - textPtr->tabsize = 8; - textPtr->tabArrayPtr = NULL; textPtr->wrapMode = TEXT_WRAPMODE_CHAR; - textPtr->width = 0; - textPtr->height = 0; - textPtr->setGrid = 0; textPtr->prevWidth = Tk_Width(new); textPtr->prevHeight = Tk_Height(new); TkTextCreateDInfo(textPtr); TkTextMakeByteIndex(textPtr->tree, 0, 0, &startIndex); TkTextSetYView(textPtr, &startIndex, 0); - textPtr->selTagPtr = NULL; - textPtr->selBorder = NULL; - textPtr->selBdString = NULL; - textPtr->selFgColorPtr = NULL; textPtr->exportSelection = 1; - textPtr->abortSelections = 0; - textPtr->insertMarkPtr = NULL; - textPtr->insertBorder = NULL; - textPtr->insertWidth = 0; - textPtr->insertBorderWidth = 0; - textPtr->insertOnTime = 0; - textPtr->insertOffTime = 0; - textPtr->insertBlinkHandler = (Tcl_TimerToken) NULL; - textPtr->bindingTable = NULL; - textPtr->currentMarkPtr = NULL; textPtr->pickEvent.type = LeaveNotify; - textPtr->pickEvent.xcrossing.x = 0; - textPtr->pickEvent.xcrossing.y = 0; - textPtr->numCurTags = 0; - textPtr->curTagArrayPtr = NULL; - textPtr->takeFocus = NULL; - textPtr->xScrollCmd = NULL; - textPtr->yScrollCmd = NULL; - - /* - * KHAMIS */ - textPtr->SyncCmd = NULL; - textPtr->flags = 0; + textPtr->undoStack = TkUndoInitStack(interp,0); + textPtr->undo = 1; + textPtr->isDirtyIncrement = 1; + textPtr->autoSeparators = 1; + textPtr->lastEditMode = TK_TEXT_EDIT_OTHER; /* * Create the "sel" tag and the "current" and "insert" marks. @@ -454,7 +431,7 @@ Tk_TextCmd(clientData, interp, argc, argv) textPtr->insertMarkPtr = TkTextSetMark(textPtr, "insert", &startIndex); Tk_SetClass(textPtr->tkwin, "Text"); - TkSetClassProcs(textPtr->tkwin, &textClass, (ClientData) textPtr); + Tk_SetClassProcs(textPtr->tkwin, &textClass, (ClientData) textPtr); Tk_CreateEventHandler(textPtr->tkwin, ExposureMask|StructureNotifyMask|FocusChangeMask, TextEventProc, (ClientData) textPtr); @@ -490,77 +467,17 @@ Tk_TextCmd(clientData, interp, argc, argv) * *-------------------------------------------------------------- */ -static int -ExecSyncCmd (interp, textPtr, argc, argv) - Tcl_Interp *interp; - TkText *textPtr; - int argc; - char *argv[]; -{ - static int ExecSyncCmdActive=0; - int i, ret; - Tcl_DString cmd; - - if (ExecSyncCmdActive) - { - return TCL_OK; - } - ExecSyncCmdActive = 1; - - Tcl_DStringInit (&cmd); - Tcl_DStringAppend (&cmd, textPtr->SyncCmd, -1); - for (i=1;i= 3)) { int relation, value; - char *p; + CONST char *p; if (argc != 5) { Tcl_AppendResult(interp, "wrong # args: should be \"", @@ -678,18 +595,114 @@ TextWidgetCmd(clientData, interp, argc, argv) } } else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0) && (length >= 3)) { - -/*ViewArgs ("editor", argc, argv, 0);*/ - - if ((argc != 3) && (argc != 4)) { + int i; + + if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " delete index1 ?index2?\"", (char *) NULL); + argv[0], " delete index1 ?index2 ...?\"", (char *) NULL); result = TCL_ERROR; goto done; } if (textPtr->state == TK_STATE_NORMAL) { - result = DeleteChars(textPtr, argv[2], - (argc == 4) ? argv[3] : (char *) NULL); + if (argc < 5) { + /* + * Simple case requires no predetermination of indices. + */ + result = DeleteChars(textPtr, argv[2], + (argc == 4) ? argv[3] : NULL, NULL, NULL); + } else { + /* + * Multi-index pair case requires that we prevalidate the + * indices and sort from last to first so that deletes + * occur in the exact (unshifted) text. It also needs to + * handle partial and fully overlapping ranges. We have to + * do this with multiple passes. + */ + TkTextIndex *indices, *ixStart, *ixEnd, *lastStart, *lastEnd; + char *useIdx; + + argc -= 2; + argv += 2; + indices = (TkTextIndex *) + ckalloc((argc + 1) * sizeof(TkTextIndex)); + + /* + * First pass verifies that all indices are valid. + */ + for (i = 0; i < argc; i++) { + if (TkTextGetIndex(interp, textPtr, argv[i], + &indices[i]) != TCL_OK) { + result = TCL_ERROR; + ckfree((char *) indices); + goto done; + } + } + /* + * Pad out the pairs evenly to make later code easier. + */ + if (argc & 1) { + indices[i] = indices[i-1]; + TkTextIndexForwChars(&indices[i], 1, &indices[i]); + argc++; + } + useIdx = (char *) ckalloc((unsigned) argc); + memset(useIdx, 0, (unsigned) argc); + /* + * Do a decreasing order sort so that we delete the end + * ranges first to maintain index consistency. + */ + qsort((VOID *) indices, (unsigned) (argc / 2), + 2 * sizeof(TkTextIndex), TextIndexSortProc); + lastStart = lastEnd = NULL; + /* + * Second pass will handle bogus ranges (end < start) and + * overlapping ranges. + */ + for (i = 0; i < argc; i += 2) { + ixStart = &indices[i]; + ixEnd = &indices[i+1]; + if (TkTextIndexCmp(ixEnd, ixStart) <= 0) { + continue; + } + if (lastStart) { + if (TkTextIndexCmp(ixStart, lastStart) == 0) { + /* + * Start indices were equal, and the sort placed + * the longest range first, so skip this one. + */ + continue; + } else if (TkTextIndexCmp(lastStart, ixEnd) < 0) { + /* + * The next pair has a start range before the end + * point of the last range. Constrain the delete + * range, but use the pointer values. + */ + *ixEnd = *lastStart; + if (TkTextIndexCmp(ixEnd, ixStart) <= 0) { + continue; + } + } + } + lastStart = ixStart; + lastEnd = ixEnd; + useIdx[i] = 1; + } + /* + * Final pass take the input from the previous and deletes + * the ranges which are flagged to be deleted. + */ + for (i = 0; i < argc; i += 2) { + if (useIdx[i]) { + /* + * We don't need to check the return value because all + * indices are preparsed above. + */ + DeleteChars(textPtr, NULL, NULL, + &indices[i], &indices[i+1]); + } + } + ckfree((char *) indices); + } } } else if ((c == 'd') && (strncmp(argv[1], "dlineinfo", length) == 0) && (length >= 2)) { @@ -712,53 +725,64 @@ TextWidgetCmd(clientData, interp, argc, argv) sprintf(buf, "%d %d %d %d %d", x, y, width, height, base); Tcl_SetResult(interp, buf, TCL_VOLATILE); } + } else if ((c == 'e') && (strncmp(argv[1], "edit", length) == 0)) { + result = TextEditCmd(textPtr, interp, argc, argv); } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) { - if ((argc != 3) && (argc != 4)) { + Tcl_Obj *objPtr = NULL; + Tcl_DString ds; + int i, found = 0; + + if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", - argv[0], " get index1 ?index2?\"", (char *) NULL); - result = TCL_ERROR; - goto done; - } - if (TkTextGetIndex(interp, textPtr, argv[2], &index1) != TCL_OK) { + argv[0], " get index1 ?index2 ...?\"", (char *) NULL); result = TCL_ERROR; goto done; } - if (argc == 3) { - index2 = index1; - TkTextIndexForwChars(&index2, 1, &index2); - } else if (TkTextGetIndex(interp, textPtr, argv[3], &index2) - != TCL_OK) { - result = TCL_ERROR; - goto done; - } - if (TkTextIndexCmp(&index1, &index2) >= 0) { - goto done; - } - while (1) { - int offset, last, savedChar; - TkTextSegment *segPtr; - - segPtr = TkTextIndexToSeg(&index1, &offset); - last = segPtr->size; - if (index1.linePtr == index2.linePtr) { - int last2; - - if (index2.byteIndex == index1.byteIndex) { - break; - } - last2 = index2.byteIndex - index1.byteIndex + offset; - if (last2 < last) { - last = last2; + for (i = 2; i < argc; i += 2) { + if (TkTextGetIndex(interp, textPtr, argv[i], &index1) != TCL_OK) { + result = TCL_ERROR; + goto done; + } + if (i+1 == argc) { + index2 = index1; + TkTextIndexForwChars(&index2, 1, &index2); + } else if (TkTextGetIndex(interp, textPtr, argv[i+1], &index2) + != TCL_OK) { + if (objPtr) { + Tcl_DecrRefCount(objPtr); } + result = TCL_ERROR; + goto done; } - if (segPtr->typePtr == &tkTextCharType) { - savedChar = segPtr->body.chars[last]; - segPtr->body.chars[last] = 0; - Tcl_AppendResult(interp, segPtr->body.chars + offset, - (char *) NULL); - segPtr->body.chars[last] = savedChar; + if (TkTextIndexCmp(&index1, &index2) < 0) { + /* + * Place the text in a DString and move it to the result. + * Since this could in principle be a megabyte or more, we + * want to do it efficiently! + */ + TextGetText(&index1, &index2, &ds); + found++; + if (found == 1) { + Tcl_DStringResult(interp, &ds); + } else { + if (found == 2) { + /* + * Move the first item we put into the result into + * the first element of the list object. + */ + objPtr = Tcl_NewObj(); + Tcl_ListObjAppendElement(NULL, objPtr, + Tcl_GetObjResult(interp)); + } + Tcl_ListObjAppendElement(NULL, objPtr, + Tcl_NewStringObj(Tcl_DStringValue(&ds), + Tcl_DStringLength(&ds))); + } + Tcl_DStringFree(&ds); } - TkTextIndexForwBytes(&index1, last-offset, &index1); + } + if (found > 1) { + Tcl_SetObjResult(interp, objPtr); } } else if ((c == 'i') && (strncmp(argv[1], "index", length) == 0) && (length >= 3)) { @@ -780,11 +804,9 @@ TextWidgetCmd(clientData, interp, argc, argv) } else if ((c == 'i') && (strncmp(argv[1], "insert", length) == 0) && (length >= 3)) { int i, j, numTags; - char **tagNames; + CONST char **tagNames; TkTextTag **oldTagArrayPtr; -/*ViewArgs ("editor", argc, argv, 0);*/ - if (argc < 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], @@ -849,8 +871,8 @@ TextWidgetCmd(clientData, interp, argc, argv) } else { Tcl_AppendResult(interp, "bad option \"", argv[1], "\": must be bbox, cget, compare, configure, debug, delete, ", - "dlineinfo, dump, get, image, index, insert, mark, scan, ", - "search, see, tag, window, xview, or yview", + "dlineinfo, dump, edit, get, image, index, insert, mark, ", + "scan, search, see, tag, window, xview, or yview", (char *) NULL); result = TCL_ERROR; } @@ -860,6 +882,49 @@ TextWidgetCmd(clientData, interp, argc, argv) return result; } +/* + *---------------------------------------------------------------------- + * + * TextIndexSortProc -- + * + * This procedure is called by qsort when sorting an array of + * indices in *decreasing* order (last to first). + * + * Results: + * The return value is -1 if the first argument should be before + * the second element, 0 if it's equivalent, and 1 if it should be + * after the second element. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static int +TextIndexSortProc(first, second) + CONST VOID *first, *second; /* Elements to be compared. */ +{ + TkTextIndex *pair1 = (TkTextIndex *) first; + TkTextIndex *pair2 = (TkTextIndex *) second; + int cmp = TkTextIndexCmp(&pair1[1], &pair2[1]); + + if (cmp == 0) { + /* + * If the first indices were equal, we want the second index of the + * pair also to be the greater. Use pointer magic to access the + * second index pair. + */ + cmp = TkTextIndexCmp(&pair1[0], &pair2[0]); + } + if (cmp > 0) { + return -1; + } else if (cmp < 0) { + return 1; + } + return 0; +} + /* *---------------------------------------------------------------------- * @@ -917,6 +982,7 @@ DestroyText(memPtr) if (textPtr->bindingTable != NULL) { Tk_DeleteBindingTable(textPtr->bindingTable); } + TkUndoFreeStack(textPtr->undoStack); /* * NOTE: do NOT free up selBorder, selBdString, or selFgColorPtr: @@ -958,7 +1024,7 @@ ConfigureText(interp, textPtr, argc, argv, flags) register TkText *textPtr; /* Information about widget; may or may * not already have values for some fields. */ int argc; /* Number of valid entries in argv. */ - char **argv; /* Arguments. */ + CONST char **argv; /* Arguments. */ int flags; /* Flags to pass to Tk_ConfigureWidget. */ { int oldExport = textPtr->exportSelection; @@ -968,6 +1034,8 @@ ConfigureText(interp, textPtr, argc, argv, flags) return TCL_ERROR; } + TkUndoSetDepth(textPtr->undoStack, textPtr->maxUndo); + /* * A few other options also need special processing, such as parsing * the geometry and setting the background from a 3-D border. @@ -1075,6 +1143,16 @@ ConfigureText(interp, textPtr, argc, argv, flags) } } + /* + * Account for state changes that would reenable blinking cursor state. + */ + + if (textPtr->flags & GOT_FOCUS) { + Tcl_DeleteTimerHandler(textPtr->insertBlinkHandler); + textPtr->insertBlinkHandler = (Tcl_TimerToken) NULL; + TextBlinkProc((ClientData) textPtr); + } + /* * Register the desired geometry for the window, and arrange for * the window to be redisplayed. @@ -1282,11 +1360,12 @@ InsertChars(textPtr, indexPtr, string) TkText *textPtr; /* Overall information about text widget. */ TkTextIndex *indexPtr; /* Where to insert new characters. May be * modified and/or invalidated. */ - char *string; /* Null-terminated string containing new + CONST char *string; /* Null-terminated string containing new * information to add to text. */ { int lineIndex, resetView, offset; TkTextIndex newTop; + char indexBuffer[TK_POS_CHARS]; /* * Don't allow insertions on the last (dummy) line of the text. @@ -1315,6 +1394,68 @@ InsertChars(textPtr, indexPtr, string) } TkTextChanged(textPtr, indexPtr, indexPtr); TkBTreeInsertChars(indexPtr, string); + + /* + * Push the insertion on the undo stack + */ + + if ( textPtr->undo ) { + TkTextIndex toIndex; + + Tcl_DString actionCommand; + Tcl_DString revertCommand; + + if (textPtr->autoSeparators && + textPtr->lastEditMode != TK_TEXT_EDIT_INSERT) { + TkUndoInsertUndoSeparator(textPtr->undoStack); + } + + textPtr->lastEditMode = TK_TEXT_EDIT_INSERT; + + Tcl_DStringInit(&actionCommand); + Tcl_DStringInit(&revertCommand); + + Tcl_DStringAppend(&actionCommand,Tcl_GetCommandName(textPtr->interp,textPtr->widgetCmd),-1); + Tcl_DStringAppend(&actionCommand," insert ",-1); + TkTextPrintIndex(indexPtr,indexBuffer); + Tcl_DStringAppend(&actionCommand,indexBuffer,-1); + Tcl_DStringAppend(&actionCommand," ",-1); + Tcl_DStringAppendElement(&actionCommand,string); + Tcl_DStringAppend(&actionCommand,";",-1); + Tcl_DStringAppend(&actionCommand,Tcl_GetCommandName(textPtr->interp,textPtr->widgetCmd),-1); + Tcl_DStringAppend(&actionCommand," mark set insert ",-1); + TkTextIndexForwBytes(indexPtr, (int) strlen(string), + &toIndex); + TkTextPrintIndex(&toIndex, indexBuffer); + Tcl_DStringAppend(&actionCommand,indexBuffer,-1); + Tcl_DStringAppend(&actionCommand,"; ",-1); + Tcl_DStringAppend(&actionCommand,Tcl_GetCommandName(textPtr->interp,textPtr->widgetCmd),-1); + Tcl_DStringAppend(&actionCommand," see insert",-1); + + Tcl_DStringAppend(&revertCommand,Tcl_GetCommandName(textPtr->interp,textPtr->widgetCmd),-1); + Tcl_DStringAppend(&revertCommand," delete ",-1); + TkTextPrintIndex(indexPtr,indexBuffer); + Tcl_DStringAppend(&revertCommand,indexBuffer,-1); + Tcl_DStringAppend(&revertCommand," ",-1); + TkTextPrintIndex(&toIndex, indexBuffer); + Tcl_DStringAppend(&revertCommand,indexBuffer,-1); + Tcl_DStringAppend(&revertCommand," ;",-1); + Tcl_DStringAppend(&revertCommand,Tcl_GetCommandName(textPtr->interp,textPtr->widgetCmd),-1); + Tcl_DStringAppend(&revertCommand," mark set insert ",-1); + TkTextPrintIndex(indexPtr,indexBuffer); + Tcl_DStringAppend(&revertCommand,indexBuffer,-1); + Tcl_DStringAppend(&revertCommand,"; ",-1); + Tcl_DStringAppend(&revertCommand,Tcl_GetCommandName(textPtr->interp,textPtr->widgetCmd),-1); + Tcl_DStringAppend(&revertCommand," see insert",-1); + + TkUndoPushAction(textPtr->undoStack,&actionCommand, &revertCommand); + + Tcl_DStringFree(&actionCommand); + Tcl_DStringFree(&revertCommand); + + } + updateDirtyFlag(textPtr); + if (resetView) { TkTextMakeByteIndex(textPtr->tree, lineIndex, 0, &newTop); TkTextIndexForwBytes(&newTop, offset, &newTop); @@ -1347,34 +1488,51 @@ InsertChars(textPtr, indexPtr, string) */ static int -DeleteChars(textPtr, index1String, index2String) +DeleteChars(textPtr, index1String, index2String, indexPtr1, indexPtr2) TkText *textPtr; /* Overall information about text widget. */ - char *index1String; /* String describing location of first + CONST char *index1String; /* String describing location of first * character to delete. */ - char *index2String; /* String describing location of last + CONST char *index2String; /* String describing location of last * character to delete. NULL means just * delete the one character given by * index1String. */ + TkTextIndex *indexPtr1; /* index describing location of first + * character to delete. */ + TkTextIndex *indexPtr2; /* index describing location of last + * character to delete. NULL means just + * delete the one character given by + * indexPtr1. */ { int line1, line2, line, byteIndex, resetView; TkTextIndex index1, index2; + char indexBuffer[TK_POS_CHARS]; /* * Parse the starting and stopping indices. */ - if (TkTextGetIndex(textPtr->interp, textPtr, index1String, &index1) - != TCL_OK) { - return TCL_ERROR; - } - if (index2String != NULL) { - if (TkTextGetIndex(textPtr->interp, textPtr, index2String, &index2) + if (index1String != NULL) { + if (TkTextGetIndex(textPtr->interp, textPtr, index1String, &index1) != TCL_OK) { return TCL_ERROR; } + if (index2String != NULL) { + if (TkTextGetIndex(textPtr->interp, textPtr, index2String, &index2) + != TCL_OK) { + return TCL_ERROR; + } + } else { + index2 = index1; + TkTextIndexForwChars(&index2, 1, &index2); + } } else { - index2 = index1; - TkTextIndexForwChars(&index2, 1, &index2); + index1 = *indexPtr1; + if (indexPtr2 != NULL) { + index2 = *indexPtr2; + } else { + index2 = index1; + TkTextIndexForwChars(&index2, 1, &index2); + } } /* @@ -1469,6 +1627,68 @@ DeleteChars(textPtr, index1String, index2String) byteIndex -= (index2.byteIndex - index1.byteIndex); } } + + /* + * Push the deletion on the undo stack + */ + + if (textPtr->undo) { + Tcl_DString ds; + Tcl_DString actionCommand; + Tcl_DString revertCommand; + + if (textPtr->autoSeparators + && (textPtr->lastEditMode != TK_TEXT_EDIT_DELETE)) { + TkUndoInsertUndoSeparator(textPtr->undoStack); + } + + textPtr->lastEditMode = TK_TEXT_EDIT_DELETE; + + Tcl_DStringInit(&actionCommand); + Tcl_DStringInit(&revertCommand); + + Tcl_DStringAppend(&actionCommand,Tcl_GetCommandName(textPtr->interp,textPtr->widgetCmd),-1); + Tcl_DStringAppend(&actionCommand," delete ",-1); + TkTextPrintIndex(&index1,indexBuffer); + Tcl_DStringAppend(&actionCommand,indexBuffer,-1); + Tcl_DStringAppend(&actionCommand," ",-1); + TkTextPrintIndex(&index2, indexBuffer); + Tcl_DStringAppend(&actionCommand,indexBuffer,-1); + Tcl_DStringAppend(&actionCommand,"; ",-1); + Tcl_DStringAppend(&actionCommand,Tcl_GetCommandName(textPtr->interp,textPtr->widgetCmd),-1); + Tcl_DStringAppend(&actionCommand," mark set insert ",-1); + TkTextPrintIndex(&index1,indexBuffer); + Tcl_DStringAppend(&actionCommand,indexBuffer,-1); + + Tcl_DStringAppend(&actionCommand,"; ",-1); + Tcl_DStringAppend(&actionCommand,Tcl_GetCommandName(textPtr->interp,textPtr->widgetCmd),-1); + Tcl_DStringAppend(&actionCommand," see insert",-1); + + TextGetText(&index1, &index2, &ds); + + Tcl_DStringAppend(&revertCommand,Tcl_GetCommandName(textPtr->interp,textPtr->widgetCmd),-1); + Tcl_DStringAppend(&revertCommand," insert ",-1); + TkTextPrintIndex(&index1,indexBuffer); + Tcl_DStringAppend(&revertCommand,indexBuffer,-1); + Tcl_DStringAppend(&revertCommand," ",-1); + Tcl_DStringAppendElement(&revertCommand,Tcl_DStringValue(&ds)); + Tcl_DStringAppend(&revertCommand,"; ",-1); + Tcl_DStringAppend(&revertCommand,Tcl_GetCommandName(textPtr->interp,textPtr->widgetCmd),-1); + Tcl_DStringAppend(&revertCommand," mark set insert ",-1); + TkTextPrintIndex(&index2, indexBuffer); + Tcl_DStringAppend(&revertCommand,indexBuffer,-1); + Tcl_DStringAppend(&revertCommand,"; ",-1); + Tcl_DStringAppend(&revertCommand,Tcl_GetCommandName(textPtr->interp,textPtr->widgetCmd),-1); + Tcl_DStringAppend(&revertCommand," see insert",-1); + + TkUndoPushAction(textPtr->undoStack,&actionCommand, &revertCommand); + + Tcl_DStringFree(&actionCommand); + Tcl_DStringFree(&revertCommand); + + } + updateDirtyFlag(textPtr); + TkBTreeDeleteChars(&index1, &index2); if (resetView) { TkTextMakeByteIndex(textPtr->tree, line, byteIndex, &index1); @@ -1648,6 +1868,7 @@ TkTextLostSelection(clientData) ClientData clientData; /* Information about text widget. */ { register TkText *textPtr = (TkText *) clientData; + XEvent event; #ifdef ALWAYS_SHOW_SELECTION TkTextIndex start, end; @@ -1666,6 +1887,21 @@ TkTextLostSelection(clientData) TkTextRedrawTag(textPtr, &start, &end, textPtr->selTagPtr, 1); TkBTreeTag(&start, &end, textPtr->selTagPtr, 0); #endif + + /* + * Send an event that the selection changed. This is equivalent to + * "event generate $textWidget <>" + */ + + memset((VOID *) &event, 0, sizeof(event)); + event.xany.type = VirtualEvent; + event.xany.serial = NextRequest(Tk_Display(textPtr->tkwin)); + event.xany.send_event = False; + event.xany.window = Tk_WindowId(textPtr->tkwin); + event.xany.display = Tk_Display(textPtr->tkwin); + ((XVirtualEvent *) &event)->name = Tk_GetUid("Selection"); + Tk_HandleEvent(&event); + textPtr->flags &= ~GOT_SELECTION; } @@ -1737,14 +1973,14 @@ TextSearchCmd(textPtr, interp, argc, argv) TkText *textPtr; /* Information about text widget. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. */ + CONST char **argv; /* Argument strings. */ { int backwards, exact, searchElide, c, i, argsLeft, noCase, leftToScan; size_t length; int numLines, startingLine, startingByte, lineNum, firstByte, lastByte; int code, matchLength, matchByte, passes, stopLine, searchWholeText; int patLength; - char *arg, *pattern, *varName, *p, *startOfLine; + CONST char *arg, *pattern, *varName, *p, *startOfLine; char buffer[20]; TkTextIndex index, stopIndex; Tcl_DString line, patDString; @@ -1830,8 +2066,8 @@ TextSearchCmd(textPtr, interp, argc, argv) if (noCase && exact) { Tcl_DStringInit(&patDString); Tcl_DStringAppend(&patDString, pattern, -1); + Tcl_UtfToLower(Tcl_DStringValue(&patDString)); pattern = Tcl_DStringValue(&patDString); - Tcl_UtfToLower(pattern); } Tcl_DStringInit(&line); @@ -1991,7 +2227,7 @@ TextSearchCmd(textPtr, interp, argc, argv) i = p - startOfLine; thisLength = patLength; } else { - char *start, *end; + CONST char *start, *end; int match; match = Tcl_RegExpExec(interp, regexp, @@ -2152,7 +2388,7 @@ TkTextGetTabs(interp, tkwin, string) * the text manual entry for details. */ { int argc, i, count, c; - char **argv; + CONST char **argv; TkTextTabArray *tabArrayPtr; TkTextTab *tabPtr; Tcl_UniChar ch; @@ -2256,7 +2492,7 @@ TextDumpCmd(textPtr, interp, argc, argv) register TkText *textPtr; /* Information about text widget. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. Someone else has already + CONST char **argv; /* Argument strings. Someone else has already * parsed this command enough to know that * argv[1] is "dump". */ { @@ -2266,7 +2502,7 @@ TextDumpCmd(textPtr, interp, argc, argv) int what = 0; /* bitfield to select segment types */ int atEnd; /* True if dumping up to logical end */ TkTextLine *linePtr; - char *command = NULL; /* Script callback to apply to segments */ + CONST char *command = NULL; /* Script callback to apply to segments */ #define TK_DUMP_TEXT 0x1 #define TK_DUMP_MARK 0x2 #define TK_DUMP_TAG 0x4 @@ -2379,7 +2615,7 @@ DumpLine(interp, textPtr, what, linePtr, startByte, endByte, lineno, command) TkTextLine *linePtr; /* The current line */ int startByte, endByte; /* Byte range to dump */ int lineno; /* Line number for indices dump */ - char *command; /* Script to apply to the segment */ + CONST char *command; /* Script to apply to the segment */ { int offset; TkTextSegment *segPtr; @@ -2398,9 +2634,9 @@ DumpLine(interp, textPtr, what, linePtr, startByte, endByte, lineno, command) offset += segPtr->size, segPtr = segPtr->nextPtr) { if ((what & TK_DUMP_TEXT) && (segPtr->typePtr == &tkTextCharType) && (offset + segPtr->size > startByte)) { - char savedChar; /* Last char used in the seg */ - int last = segPtr->size; /* Index of savedChar */ - int first = 0; /* Index of first char in seg */ + char savedChar; /* Last char used in the seg */ + int last = segPtr->size; /* Index of savedChar */ + int first = 0; /* Index of first char in seg */ if (offset + segPtr->size > endByte) { last = endByte - offset; } @@ -2473,31 +2709,305 @@ DumpSegment(interp, key, value, command, index, what) Tcl_Interp *interp; char *key; /* Segment type key */ char *value; /* Segment value */ - char *command; /* Script callback */ + CONST char *command; /* Script callback */ TkTextIndex *index; /* index with line/byte position info */ int what; /* Look for TK_DUMP_INDEX bit */ { char buffer[TCL_INTEGER_SPACE*2]; TkTextPrintIndex(index, buffer); - if (command == (char *) NULL) { + if (command == NULL) { Tcl_AppendElement(interp, key); Tcl_AppendElement(interp, value); Tcl_AppendElement(interp, buffer); return TCL_OK; } else { - char *argv[4]; + CONST char *argv[4]; char *list; int result; argv[0] = key; argv[1] = value; argv[2] = buffer; - argv[3] = (char *) NULL; + argv[3] = NULL; list = Tcl_Merge(3, argv); result = Tcl_VarEval(interp, command, " ", list, (char *) NULL); ckfree(list); return result; } } + +/* + * TextEditUndo -- + * undo the last change. + * + * Results: + * None + * + * Side effects: + * None. + */ + +static int +TextEditUndo(textPtr) + TkText * textPtr; /* Overall information about text widget. */ +{ + int status; + + if (!textPtr->undo) { + return TCL_OK; + } + + /* Turn off the undo feature */ + textPtr->undo = 0; + + /* The dirty counter should count downwards as we are undoing things */ + textPtr->isDirtyIncrement = -1; + + /* revert one compound action */ + status = TkUndoRevert(textPtr->undoStack); + + /* Restore the isdirty increment */ + textPtr->isDirtyIncrement = 1; + + /* Turn back on the undo feature */ + textPtr->undo = 1; + + return status; +} + +/* + * TextEditRedo -- + * redo the last undone change. + * + * Results: + * None + * + * Side effects: + * None. + */ + +static int +TextEditRedo(textPtr) + TkText * textPtr; /* Overall information about text widget. */ +{ + int status; + + if (!textPtr->undo) { + return TCL_OK; + } + + /* Turn off the undo feature temporarily */ + textPtr->undo = 0; + + /* reapply one compound action */ + status = TkUndoApply(textPtr->undoStack); + + /* Turn back on the undo feature */ + textPtr->undo = 1; + + return status; +} + +/* + * TextEditCmd -- + * + * Handle the subcommands to "$text edit ...". + * See documentation for details. + * + * Results: + * None + * + * Side effects: + * None. + */ + +static int +TextEditCmd(textPtr, interp, argc, argv) + TkText *textPtr; /* Information about text widget. */ + Tcl_Interp *interp; /* Current interpreter. */ + int argc; /* Number of arguments. */ + CONST char **argv; /* Argument strings. */ +{ + int c, setModified; + size_t length; + + if (argc < 3) { + Tcl_AppendResult(interp, "wrong # args: should be \"", + argv[0], " edit option ?arg arg ...?\"", (char *) NULL); + return TCL_ERROR; + } + c = argv[2][0]; + length = strlen(argv[2]); + if ((c == 'm') && (strncmp(argv[2], "modified", length) == 0)) { + if (argc == 3) { + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(textPtr->isDirty)); + } else if (argc != 4) { + Tcl_AppendResult(interp, "wrong # args: should be \"", + argv[0], " edit modified ?boolean?\"", (char *) NULL); + return TCL_ERROR; + } else { + XEvent event; + if (Tcl_GetBoolean(interp, argv[3], &setModified) != TCL_OK) { + return TCL_ERROR; + } + /* + * Set or reset the dirty info and trigger a Modified event. + */ + + if (setModified) { + textPtr->isDirty = 1; + textPtr->modifiedSet = 1; + } else { + textPtr->isDirty = 0; + textPtr->modifiedSet = 0; + } + + /* + * Send an event that the text was modified. This is equivalent to + * "event generate $textWidget <>" + */ + + memset((VOID *) &event, 0, sizeof(event)); + event.xany.type = VirtualEvent; + event.xany.serial = NextRequest(Tk_Display(textPtr->tkwin)); + event.xany.send_event = False; + event.xany.window = Tk_WindowId(textPtr->tkwin); + event.xany.display = Tk_Display(textPtr->tkwin); + ((XVirtualEvent *) &event)->name = Tk_GetUid("Modified"); + Tk_HandleEvent(&event); + } + } else if ((c == 'r') && (strncmp(argv[2], "redo", length) == 0) + && (length >= 3)) { + if (argc != 3) { + Tcl_AppendResult(interp, "wrong # args: should be \"", + argv[0], " edit redo\"", (char *) NULL); + return TCL_ERROR; + } + if ( TextEditRedo(textPtr) ) { + Tcl_AppendResult(interp, "nothing to redo", (char *) NULL); + return TCL_ERROR; + } + } else if ((c == 'r') && (strncmp(argv[2], "reset", length) == 0) + && (length >= 3)) { + if (argc != 3) { + Tcl_AppendResult(interp, "wrong # args: should be \"", + argv[0], " edit reset\"", (char *) NULL); + return TCL_ERROR; + } + TkUndoClearStacks(textPtr->undoStack); + } else if ((c == 's') && (strncmp(argv[2], "separator", length) == 0)) { + if (argc != 3) { + Tcl_AppendResult(interp, "wrong # args: should be \"", + argv[0], " edit separator\"", (char *) NULL); + return TCL_ERROR; + } + TkUndoInsertUndoSeparator(textPtr->undoStack); + } else if ((c == 'u') && (strncmp(argv[2], "undo", length) == 0)) { + if (argc != 3) { + Tcl_AppendResult(interp, "wrong # args: should be \"", + argv[0], " edit undo\"", (char *) NULL); + return TCL_ERROR; + } + if ( TextEditUndo(textPtr) ) { + Tcl_AppendResult(interp, "nothing to undo", + (char *) NULL); + return TCL_ERROR; + } + } else { + Tcl_AppendResult(interp, "bad edit option \"", argv[2], + "\": must be modified, redo, reset, separator or undo", + (char *) NULL); + return TCL_ERROR; + } + + return TCL_OK; +} + +/* + * TextGetText -- + * Returns the text from indexPtr1 to indexPtr2, placing that text + * in the Tcl_DString given. That DString should be free or uninitialized. + * + * Results: + * None. + * + * Side effects: + * Memory will be allocated for the DString. Remember to free it. + */ + +static void +TextGetText(indexPtr1,indexPtr2, dsPtr) + TkTextIndex *indexPtr1; + TkTextIndex *indexPtr2; + Tcl_DString *dsPtr; +{ + TkTextIndex tmpIndex; + Tcl_DStringInit(dsPtr); + + TkTextMakeByteIndex(indexPtr1->tree, TkBTreeLineIndex(indexPtr1->linePtr), + indexPtr1->byteIndex, &tmpIndex); + + if (TkTextIndexCmp(indexPtr1, indexPtr2) < 0) { + while (1) { + int offset, last; + TkTextSegment *segPtr; + + segPtr = TkTextIndexToSeg(&tmpIndex, &offset); + last = segPtr->size; + if (tmpIndex.linePtr == indexPtr2->linePtr) { + int last2; + + if (indexPtr2->byteIndex == tmpIndex.byteIndex) { + break; + } + last2 = indexPtr2->byteIndex - tmpIndex.byteIndex + offset; + if (last2 < last) { + last = last2; + } + } + if (segPtr->typePtr == &tkTextCharType) { + Tcl_DStringAppend(dsPtr, segPtr->body.chars + offset, + last - offset); + } + TkTextIndexForwBytes(&tmpIndex, last-offset, &tmpIndex); + } + } +} + +/* + * updateDirtyFlag -- + * increases the dirtyness of the text widget + * + * Results: + * None + * + * Side effects: + * None. + */ +static void updateDirtyFlag (textPtr) + TkText *textPtr; /* Information about text widget. */ +{ + int oldDirtyFlag; + if (textPtr->modifiedSet) { + return; + } + oldDirtyFlag = textPtr->isDirty; + textPtr->isDirty += textPtr->isDirtyIncrement; + if (textPtr->isDirty == 0 || oldDirtyFlag == 0) { + XEvent event; + /* + * Send an event that the text was modified. This is equivalent to + * "event generate $textWidget <>" + */ + memset((VOID *) &event, 0, sizeof(event)); + event.xany.type = VirtualEvent; + event.xany.serial = NextRequest(Tk_Display(textPtr->tkwin)); + event.xany.send_event = False; + event.xany.window = Tk_WindowId(textPtr->tkwin); + event.xany.display = Tk_Display(textPtr->tkwin); + ((XVirtualEvent *) &event)->name = Tk_GetUid("Modified"); + Tk_HandleEvent(&event); + } +} diff --git a/tk/generic/tkText.h b/tk/generic/tkText.h index 9152e2c7264..4661330051e 100644 --- a/tk/generic/tkText.h +++ b/tk/generic/tkText.h @@ -20,6 +20,10 @@ #include "tk.h" #endif +#ifndef _TKUNDO +#include "tkUndo.h" +#endif + #ifdef BUILD_tk # undef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLEXPORT @@ -451,6 +455,14 @@ typedef struct TkTextTabArray { * BE THE LAST IN THE STRUCTURE. */ } TkTextTabArray; +/* enum definining the edit modes of */ + +typedef enum { + TK_TEXT_EDIT_INSERT, /* insert mode */ + TK_TEXT_EDIT_DELETE, /* delete mode */ + TK_TEXT_EDIT_OTHER /* none of the above */ +} TkTextEditMode; + /* * A data structure of the following type is kept for each text widget that * currently exists for this process: @@ -525,11 +537,6 @@ typedef struct TkText { * NULL means perform default tabbing * behavior. */ - int tabsize; /* "-tabs" reconize only fixed placed tabs, but - * we need to have the behavior of a normal plain - * text editor (default is 8) - */ - /* * Additional information used for displaying: */ @@ -609,7 +616,7 @@ typedef struct TkText { /* Pointer to segment for "current" mark, * or NULL if none. */ XEvent pickEvent; /* The event from which the current character - * was chosen. Must be saved so that we + * was chosen. Must be saved so that we * can repick after modifications to the * text. */ int numCurTags; /* Number of tags associated with character @@ -621,19 +628,47 @@ typedef struct TkText { * Miscellaneous additional information: */ - char *takeFocus; /* Value of -takeFocus option; not used in + char *takeFocus; /* Value of -takeFocus option; not used in * the C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ char *xScrollCmd; /* Prefix of command to issue to update * horizontal scrollbar when view changes. */ char *yScrollCmd; /* Prefix of command to issue to update * vertical scrollbar when view changes. */ - /* KHAMIS */ - char *SyncCmd; /* Used to synchronize more than editor with the - * same file*/ - - int flags; /* Miscellaneous flags; see below for + int flags; /* Miscellaneous flags; see below for * definitions. */ + + /* + * Information related to the undo/redo functonality + */ + + TkUndoRedoStack * undoStack; /* The undo/redo stack */ + + int undo; /* non zero means the undo/redo behaviour is + * enabled */ + + int maxUndo; /* The maximum depth of the undo stack expressed + * as the maximum number of compound statements */ + + int autoSeparators; /* non zero means the separatorss will be + * inserted automatically */ + + int modifiedSet; /* Flag indicating that the 'dirtynesss' of + * the text widget has been expplicitly set. + */ + + int isDirty; /* Flag indicating the 'dirtynesss' of the text + * widget. If the flag is not zero, unsaved + * modifications have been applied to the + * text widget */ + + int isDirtyIncrement; /* Amount with which the isDirty flag is + * incremented every edit action + */ + + TkTextEditMode lastEditMode; /* Keeps track of what the last edit mode was + */ + } TkText; /* @@ -760,7 +795,7 @@ EXTERN TkTextLine * TkBTreeFindLine _ANSI_ARGS_((TkTextBTree tree, EXTERN TkTextTag ** TkBTreeGetTags _ANSI_ARGS_((TkTextIndex *indexPtr, int *numTagsPtr)); EXTERN void TkBTreeInsertChars _ANSI_ARGS_((TkTextIndex *indexPtr, - char *string)); + CONST char *string)); EXTERN int TkBTreeLineIndex _ANSI_ARGS_((TkTextLine *linePtr)); EXTERN void TkBTreeLinkSegment _ANSI_ARGS_((TkTextSegment *segPtr, TkTextIndex *indexPtr)); @@ -796,12 +831,12 @@ EXTERN int TkTextDLineInfo _ANSI_ARGS_((TkText *textPtr, TkTextIndex *indexPtr, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr, int *basePtr)); EXTERN TkTextTag * TkTextCreateTag _ANSI_ARGS_((TkText *textPtr, - char *tagName)); + CONST char *tagName)); EXTERN void TkTextFreeDInfo _ANSI_ARGS_((TkText *textPtr)); EXTERN void TkTextFreeTag _ANSI_ARGS_((TkText *textPtr, TkTextTag *tagPtr)); EXTERN int TkTextGetIndex _ANSI_ARGS_((Tcl_Interp *interp, - TkText *textPtr, char *string, + TkText *textPtr, CONST char *string, TkTextIndex *indexPtr)); EXTERN TkTextTabArray * TkTextGetTabs _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin, char *string)); @@ -837,9 +872,9 @@ EXTERN TkTextIndex * TkTextMakeByteIndex _ANSI_ARGS_((TkTextBTree tree, int lineIndex, int byteIndex, TkTextIndex *indexPtr)); EXTERN int TkTextMarkCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); EXTERN int TkTextMarkNameToIndex _ANSI_ARGS_((TkText *textPtr, - char *name, TkTextIndex *indexPtr)); + CONST char *name, TkTextIndex *indexPtr)); EXTERN void TkTextMarkSegToIndex _ANSI_ARGS_((TkText *textPtr, TkTextSegment *markPtr, TkTextIndex *indexPtr)); EXTERN void TkTextEventuallyRepick _ANSI_ARGS_((TkText *textPtr)); @@ -856,33 +891,32 @@ EXTERN void TkTextRedrawTag _ANSI_ARGS_((TkText *textPtr, TkTextTag *tagPtr, int withTag)); EXTERN void TkTextRelayoutWindow _ANSI_ARGS_((TkText *textPtr)); EXTERN int TkTextScanCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); EXTERN int TkTextSeeCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); EXTERN int TkTextSegToOffset _ANSI_ARGS_(( CONST TkTextSegment *segPtr, CONST TkTextLine *linePtr)); -EXTERN TkTextSegment * TkTextSetMark _ANSI_ARGS_((TkText *textPtr, char *name, - TkTextIndex *indexPtr)); +EXTERN TkTextSegment * TkTextSetMark _ANSI_ARGS_((TkText *textPtr, + CONST char *name, TkTextIndex *indexPtr)); EXTERN void TkTextSetYView _ANSI_ARGS_((TkText *textPtr, TkTextIndex *indexPtr, int pickPlace)); EXTERN int TkTextTagCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); EXTERN int TkTextImageCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); EXTERN int TkTextImageIndex _ANSI_ARGS_((TkText *textPtr, - char *name, TkTextIndex *indexPtr)); + CONST char *name, TkTextIndex *indexPtr)); EXTERN int TkTextWindowCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); EXTERN int TkTextWindowIndex _ANSI_ARGS_((TkText *textPtr, - char *name, TkTextIndex *indexPtr)); + CONST char *name, TkTextIndex *indexPtr)); EXTERN int TkTextXviewCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); EXTERN int TkTextYviewCmd _ANSI_ARGS_((TkText *textPtr, - Tcl_Interp *interp, int argc, char **argv)); + Tcl_Interp *interp, int argc, CONST char **argv)); # undef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLIMPORT #endif /* _TKTEXT */ - diff --git a/tk/generic/tkTextBTree.c b/tk/generic/tkTextBTree.c index 42fa1b2cba4..89d7db99ba4 100644 --- a/tk/generic/tkTextBTree.c +++ b/tk/generic/tkTextBTree.c @@ -393,7 +393,7 @@ TkBTreeInsertChars(indexPtr, string) * index is no longer valid because * of changes to the segment * structure. */ - char *string; /* Pointer to bytes to insert (may + CONST char *string; /* Pointer to bytes to insert (may * contain newlines, must be null- * terminated). */ { @@ -410,7 +410,7 @@ TkBTreeInsertChars(indexPtr, string) register TkTextSegment *segPtr; TkTextLine *newLinePtr; int chunkSize; /* # characters in current chunk. */ - register char *eol; /* Pointer to character just after last + register CONST char *eol; /* Pointer to character just after last * one in current chunk. */ int changeToLineCount; /* Counts change to total number of * lines in file. */ @@ -3753,4 +3753,3 @@ TkBTreeBytesInLine(linePtr) } return count; } - diff --git a/tk/generic/tkTextDisp.c b/tk/generic/tkTextDisp.c index 36906b8caba..84e003a519f 100644 --- a/tk/generic/tkTextDisp.c +++ b/tk/generic/tkTextDisp.c @@ -95,6 +95,16 @@ typedef struct TextStyle { && ((s1)->sValuePtr->relief == (s2)->sValuePtr->relief) \ && ((s1)->sValuePtr->bgStipple == (s2)->sValuePtr->bgStipple)) +/* + * The following macro is used to compare two floating-point numbers + * to within a certain degree of scale. Direct comparison fails on + * processors where the processor and memory representations of FP + * numbers of a particular precision is different (e.g. Intel) + */ + +#define FP_EQUAL_SCALE(double1, double2, scaleFactor) \ + (fabs((double1)-(double2))*((scaleFactor)+1.0) < 0.3) + /* * The following structure describes one line of the display, which may * be either part or all of one line of the text. @@ -359,7 +369,7 @@ static int MeasureChars _ANSI_ARGS_((Tk_Font tkfont, static void MeasureUp _ANSI_ARGS_((TkText *textPtr, TkTextIndex *srcPtr, int distance, TkTextIndex *dstPtr)); -static int NextTabStop _ANSI_ARGS_((TkText *textPtr, Tk_Font tkfont, int x, +static int NextTabStop _ANSI_ARGS_((Tk_Font tkfont, int x, int tabOrigin)); static void UpdateDisplayInfo _ANSI_ARGS_((TkText *textPtr)); static void ScrollByLines _ANSI_ARGS_((TkText *textPtr, @@ -1880,6 +1890,25 @@ DisplayLineBackground(textPtr, dlPtr, prevPtr, pixmap) rightX = maxX; } if (chunkPtr->stylePtr->bgGC != None) { + /* Not visible - bail out now */ + if (rightX + xOffset <= 0) { + leftX = rightX; + continue; + } + + /* + * Trim the start position for drawing to be no further away than + * -borderWidth. The reason is that on many X servers drawing from + * -32768 (or less) to +something simply does not display + * correctly. [Patch #541999] + */ + if ((leftX + xOffset) < -(sValuePtr->borderWidth)) { + leftX = -sValuePtr->borderWidth - xOffset; + } + if ((rightX - leftX) > 32767) { + rightX = leftX + 32767; + } + XFillRectangle(display, pixmap, chunkPtr->stylePtr->bgGC, leftX + xOffset, 0, (unsigned int) (rightX - leftX), (unsigned int) dlPtr->height); @@ -3270,7 +3299,7 @@ TkTextSeeCmd(textPtr, interp, argc, argv) TkText *textPtr; /* Information about text widget. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. Someone else has already + CONST char **argv; /* Argument strings. Someone else has already * parsed this command enough to know that * argv[1] is "see". */ { @@ -3392,7 +3421,7 @@ TkTextXviewCmd(textPtr, interp, argc, argv) TkText *textPtr; /* Information about text widget. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. Someone else has already + CONST char **argv; /* Argument strings. Someone else has already * parsed this command enough to know that * argv[1] is "xview". */ { @@ -3580,7 +3609,7 @@ TkTextYviewCmd(textPtr, interp, argc, argv) TkText *textPtr; /* Information about text widget. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. Someone else has already + CONST char **argv; /* Argument strings. Someone else has already * parsed this command enough to know that * argv[1] is "yview". */ { @@ -3746,7 +3775,7 @@ TkTextScanCmd(textPtr, interp, argc, argv) register TkText *textPtr; /* Information about text widget. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. Someone else has already + CONST char **argv; /* Argument strings. Someone else has already * parsed this command enough to know that * argv[1] is "scan". */ { @@ -3865,7 +3894,7 @@ GetXView(interp, textPtr, report) * scrollbar if it has changed. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - char buffer[TCL_DOUBLE_SPACE * 2]; + char buffer[TCL_DOUBLE_SPACE * 2 + 1]; double first, last; int code; @@ -3886,7 +3915,8 @@ GetXView(interp, textPtr, report) Tcl_SetResult(interp, buffer, TCL_VOLATILE); return; } - if ((first == dInfoPtr->xScrollFirst) && (last == dInfoPtr->xScrollLast)) { + if (FP_EQUAL_SCALE(first, dInfoPtr->xScrollFirst, dInfoPtr->maxLength) && + FP_EQUAL_SCALE(last, dInfoPtr->xScrollLast, dInfoPtr->maxLength)) { return; } dInfoPtr->xScrollFirst = first; @@ -3936,7 +3966,7 @@ GetYView(interp, textPtr, report) * scrollbar if it has changed. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - char buffer[TCL_DOUBLE_SPACE * 2]; + char buffer[TCL_DOUBLE_SPACE * 2 + 1]; double first, last; DLine *dlPtr; int totalLines, code, count; @@ -3971,7 +4001,8 @@ GetYView(interp, textPtr, report) Tcl_SetResult(interp, buffer, TCL_VOLATILE); return; } - if ((first == dInfoPtr->yScrollFirst) && (last == dInfoPtr->yScrollLast)) { + if (FP_EQUAL_SCALE(first, dInfoPtr->yScrollFirst, totalLines) && + FP_EQUAL_SCALE(last, dInfoPtr->yScrollLast, totalLines)) { return; } dInfoPtr->yScrollFirst = first; @@ -4380,7 +4411,7 @@ ElideMeasureProc(chunkPtr, x) * * This procedure is the "layoutProc" for character segments. * -n * Results: + * Results: * If there is something to display for the chunk then a * non-zero value is returned and the fields of chunkPtr * will be filled in (see the declaration of TkTextDispChunk @@ -4830,7 +4861,7 @@ AdjustForTab(textPtr, tabArrayPtr, index, chunkPtr) * interpretation of tabs. */ - desired = NextTabStop(textPtr, textPtr->tkfont, x, 0); + desired = NextTabStop(textPtr->tkfont, x, 0); goto update; } @@ -4988,7 +5019,7 @@ SizeOfTab(textPtr, tabArrayPtr, index, x, maxX) TkTextTabAlign alignment; if ((tabArrayPtr == NULL) || (tabArrayPtr->numTabs == 0)) { - tabX = NextTabStop(textPtr, textPtr->tkfont, x, 0); + tabX = NextTabStop(textPtr->tkfont, x, 0); return tabX - x; } if (index < tabArrayPtr->numTabs) { @@ -5070,8 +5101,7 @@ SizeOfTab(textPtr, tabArrayPtr, index, x, maxX) */ static int -NextTabStop(textPtr, tkfont, x, tabOrigin) - TkText *textPtr; +NextTabStop(tkfont, x, tabOrigin) Tk_Font tkfont; /* Font in which chunk that contains tab * stop will be drawn. */ int x; /* X-position in pixels where last @@ -5082,11 +5112,7 @@ NextTabStop(textPtr, tkfont, x, tabOrigin) { int tabWidth, rem; -#if 1 - tabWidth = Tk_TextWidth(tkfont, "0", 1) * textPtr->tabsize; -#else tabWidth = Tk_TextWidth(tkfont, "0", 1) * 8; -#endif if (tabWidth == 0) { tabWidth = 1; } @@ -5197,4 +5223,3 @@ MeasureChars(tkfont, source, maxBytes, startX, maxX, tabOrigin, nextXPtr) *nextXPtr = curX; return start - source; } - diff --git a/tk/generic/tkTextImage.c b/tk/generic/tkTextImage.c index 01757b071f8..3bed0cd1715 100644 --- a/tk/generic/tkTextImage.c +++ b/tk/generic/tkTextImage.c @@ -38,8 +38,8 @@ */ static int AlignParseProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, Tk_Window tkwin, char *value, - char *widgRec, int offset)); + Tcl_Interp *interp, Tk_Window tkwin, + CONST char *value, char *widgRec, int offset)); static char * AlignPrintProc _ANSI_ARGS_((ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)); @@ -52,7 +52,7 @@ static void EmbImageBboxProc _ANSI_ARGS_((TkTextDispChunk *chunkPtr, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr)); static int EmbImageConfigure _ANSI_ARGS_((TkText *textPtr, - TkTextSegment *eiPtr, int argc, char **argv)); + TkTextSegment *eiPtr, int argc, CONST char **argv)); static int EmbImageDeleteProc _ANSI_ARGS_((TkTextSegment *segPtr, TkTextLine *linePtr, int treeGone)); static void EmbImageDisplayProc _ANSI_ARGS_(( @@ -132,7 +132,7 @@ TkTextImageCmd(textPtr, interp, argc, argv) register TkText *textPtr; /* Information about text widget. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. Someone else has already + CONST char **argv; /* Argument strings. Someone else has already * parsed this command enough to know that * argv[1] is "image". */ { @@ -303,7 +303,7 @@ EmbImageConfigure(textPtr, eiPtr, argc, argv) * contains embedded image. */ TkTextSegment *eiPtr; /* Embedded image to be configured. */ int argc; /* Number of strings in argv. */ - char **argv; /* Array of strings describing configuration + CONST char **argv; /* Array of strings describing configuration * options. */ { Tk_Image image; @@ -423,7 +423,7 @@ AlignParseProc(clientData, interp, tkwin, value, widgRec, offset) ClientData clientData; /* Not used.*/ Tcl_Interp *interp; /* Used for reporting errors. */ Tk_Window tkwin; /* Window for text widget. */ - char *value; /* Value of option. */ + CONST char *value; /* Value of option. */ char *widgRec; /* Pointer to TkTextEmbWindow * structure. */ int offset; /* Offset into item (ignored). */ @@ -844,7 +844,7 @@ EmbImageBboxProc(chunkPtr, index, y, lineHeight, baseline, xPtr, yPtr, int TkTextImageIndex(textPtr, name, indexPtr) TkText *textPtr; /* Text widget containing image. */ - char *name; /* Name of image. */ + CONST char *name; /* Name of image. */ TkTextIndex *indexPtr; /* Index information gets stored here. */ { Tcl_HashEntry *hPtr; @@ -896,4 +896,3 @@ EmbImageProc(clientData, x, y, width, height, imgWidth, imgHeight) index.byteIndex = TkTextSegToOffset(eiPtr, eiPtr->body.ei.linePtr); TkTextChanged(eiPtr->body.ei.textPtr, &index, &index); } - diff --git a/tk/generic/tkTextIndex.c b/tk/generic/tkTextIndex.c index 0b59b536c07..b1a4311ba15 100644 --- a/tk/generic/tkTextIndex.c +++ b/tk/generic/tkTextIndex.c @@ -28,9 +28,9 @@ * Forward declarations for procedures defined later in this file: */ -static char * ForwBack _ANSI_ARGS_((char *string, +static CONST char * ForwBack _ANSI_ARGS_((CONST char *string, TkTextIndex *indexPtr)); -static char * StartEnd _ANSI_ARGS_(( char *string, +static CONST char * StartEnd _ANSI_ARGS_((CONST char *string, TkTextIndex *indexPtr)); /* @@ -64,7 +64,7 @@ TkTextMakeByteIndex(tree, lineIndex, byteIndex, indexPtr) { TkTextSegment *segPtr; int index; - char *p, *start; + CONST char *p, *start; Tcl_UniChar ch; indexPtr->tree = tree; @@ -314,7 +314,7 @@ int TkTextGetIndex(interp, textPtr, string, indexPtr) Tcl_Interp *interp; /* Use this for error reporting. */ TkText *textPtr; /* Information about text widget. */ - char *string; /* Textual description of position. */ + CONST char *string; /* Textual description of position. */ TkTextIndex *indexPtr; /* Index structure to fill in. */ { char *p, *end, *endOfBase; @@ -324,6 +324,8 @@ TkTextGetIndex(interp, textPtr, string, indexPtr) TkTextIndex first, last; int wantLast, result; char c; + CONST char *cp; + Tcl_DString copy; /* *--------------------------------------------------------------------- @@ -354,7 +356,8 @@ TkTextGetIndex(interp, textPtr, string, indexPtr) * funny characters like "@" or "+1c". */ - p = strrchr(string, '.'); + Tcl_DStringInit(©); + p = strrchr(Tcl_DStringAppend(©, string, -1), '.'); if (p != NULL) { if ((p[1] == 'f') && (strncmp(p+1, "first", 5) == 0)) { wantLast = 0; @@ -366,7 +369,7 @@ TkTextGetIndex(interp, textPtr, string, indexPtr) goto tryxy; } *p = 0; - hPtr = Tcl_FindHashEntry(&textPtr->tagTable, string); + hPtr = Tcl_FindHashEntry(&textPtr->tagTable, Tcl_DStringValue(©)); *p = '.'; if (hPtr == NULL) { goto tryxy; @@ -377,10 +380,12 @@ TkTextGetIndex(interp, textPtr, string, indexPtr) &last); TkBTreeStartSearch(&first, &last, tagPtr, &search); if (!TkBTreeCharTagged(&first, tagPtr) && !TkBTreeNextTag(&search)) { + Tcl_ResetResult(interp); Tcl_AppendResult(interp, "text doesn't contain any characters tagged with \"", Tcl_GetHashKey(&textPtr->tagTable, hPtr), "\"", (char *) NULL); + Tcl_DStringFree(©); return TCL_ERROR; } *indexPtr = search.curIndex; @@ -400,14 +405,14 @@ TkTextGetIndex(interp, textPtr, string, indexPtr) int x, y; - p = string+1; - x = strtol(p, &end, 0); - if ((end == p) || (*end != ',')) { + cp = string+1; + x = strtol(cp, &end, 0); + if ((end == cp) || (*end != ',')) { goto error; } - p = end+1; - y = strtol(p, &end, 0); - if (end == p) { + cp = end+1; + y = strtol(cp, &end, 0); + if (end == cp) { goto error; } TkTextPixelIndex(textPtr, x, y, indexPtr); @@ -441,7 +446,7 @@ TkTextGetIndex(interp, textPtr, string, indexPtr) goto gotBase; } - for (p = string; *p != 0; p++) { + for (p = Tcl_DStringValue(©); *p != 0; p++) { if (isspace(UCHAR(*p)) || (*p == '+') || (*p == '-')) { break; } @@ -454,14 +459,15 @@ TkTextGetIndex(interp, textPtr, string, indexPtr) c = *endOfBase; *endOfBase = 0; - result = TkTextWindowIndex(textPtr, string, indexPtr); + result = TkTextWindowIndex(textPtr, Tcl_DStringValue(©), indexPtr); *endOfBase = c; if (result != 0) { goto gotBase; } } if ((string[0] == 'e') - && (strncmp(string, "end", (size_t) (endOfBase-string)) == 0)) { + && (strncmp(string, "end", + (size_t) (endOfBase-Tcl_DStringValue(©))) == 0)) { /* * Base position is end of text. */ @@ -476,7 +482,8 @@ TkTextGetIndex(interp, textPtr, string, indexPtr) c = *endOfBase; *endOfBase = 0; - result = TkTextMarkNameToIndex(textPtr, string, indexPtr); + result = TkTextMarkNameToIndex(textPtr, Tcl_DStringValue(©), + indexPtr); *endOfBase = c; if (result == TCL_OK) { goto gotBase; @@ -488,7 +495,7 @@ TkTextGetIndex(interp, textPtr, string, indexPtr) c = *endOfBase; *endOfBase = 0; - result = TkTextImageIndex(textPtr, string, indexPtr); + result = TkTextImageIndex(textPtr, Tcl_DStringValue(©), indexPtr); *endOfBase = c; if (result != 0) { goto gotBase; @@ -506,27 +513,30 @@ TkTextGetIndex(interp, textPtr, string, indexPtr) */ gotBase: - p = endOfBase; + cp = endOfBase; while (1) { - while (isspace(UCHAR(*p))) { - p++; + while (isspace(UCHAR(*cp))) { + cp++; } - if (*p == 0) { + if (*cp == 0) { break; } - if ((*p == '+') || (*p == '-')) { - p = ForwBack(p, indexPtr); + if ((*cp == '+') || (*cp == '-')) { + cp = ForwBack(cp, indexPtr); } else { - p = StartEnd(p, indexPtr); + cp = StartEnd(cp, indexPtr); } - if (p == NULL) { + if (cp == NULL) { goto error; } } + Tcl_DStringFree(©); return TCL_OK; error: + Tcl_DStringFree(©); + Tcl_ResetResult(interp); Tcl_AppendResult(interp, "bad text index \"", string, "\"", (char *) NULL); return TCL_ERROR; @@ -645,16 +655,16 @@ TkTextIndexCmp(index1Ptr, index2Ptr) *--------------------------------------------------------------------------- */ -static char * +static CONST char * ForwBack(string, indexPtr) - char *string; /* String to parse for additional info + CONST char *string; /* String to parse for additional info * about modifier (count and units). * Points to "+" or "-" that starts * modifier. */ TkTextIndex *indexPtr; /* Index to update as specified in string. */ { - register char *p; - char *end, *units; + register CONST char *p, *units; + char *end; int count, lineIndex; size_t length; @@ -977,7 +987,7 @@ TkTextIndexBackChars(srcPtr, charCount, dstPtr) { TkTextSegment *segPtr, *oldPtr; int lineIndex, segSize; - char *p, *start, *end; + CONST char *p, *start, *end; if (charCount <= 0) { TkTextIndexForwChars(srcPtr, -charCount, dstPtr); @@ -1085,15 +1095,15 @@ TkTextIndexBackChars(srcPtr, charCount, dstPtr) *---------------------------------------------------------------------- */ -static char * +static CONST char * StartEnd(string, indexPtr) - char *string; /* String to parse for additional info + CONST char *string; /* String to parse for additional info * about modifier (count and units). * Points to first character of modifer * word. */ TkTextIndex *indexPtr; /* Index to mdoify based on string. */ { - char *p; + CONST char *p; int c, offset; size_t length; register TkTextSegment *segPtr; @@ -1184,4 +1194,3 @@ StartEnd(string, indexPtr) done: return p; } - diff --git a/tk/generic/tkTextMark.c b/tk/generic/tkTextMark.c index c2e262a4c92..e11a58f62b2 100644 --- a/tk/generic/tkTextMark.c +++ b/tk/generic/tkTextMark.c @@ -42,9 +42,9 @@ static int MarkLayoutProc _ANSI_ARGS_((TkText *textPtr, int noCharsYet, TkWrapMode wrapMode, TkTextDispChunk *chunkPtr)); static int MarkFindNext _ANSI_ARGS_((Tcl_Interp *interp, - TkText *textPtr, char *markName)); + TkText *textPtr, CONST char *markName)); static int MarkFindPrev _ANSI_ARGS_((Tcl_Interp *interp, - TkText *textPtr, char *markName)); + TkText *textPtr, CONST char *markName)); /* @@ -99,7 +99,7 @@ TkTextMarkCmd(textPtr, interp, argc, argv) register TkText *textPtr; /* Information about text widget. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. Someone else has already + CONST char **argv; /* Argument strings. Someone else has already * parsed this command enough to know that * argv[1] is "mark". */ { @@ -235,7 +235,7 @@ TkTextMarkCmd(textPtr, interp, argc, argv) TkTextSegment * TkTextSetMark(textPtr, name, indexPtr) TkText *textPtr; /* Text widget in which to create mark. */ - char *name; /* Name of mark to set. */ + CONST char *name; /* Name of mark to set. */ TkTextIndex *indexPtr; /* Where to set mark. */ { Tcl_HashEntry *hPtr; @@ -350,7 +350,7 @@ TkTextMarkSegToIndex(textPtr, markPtr, indexPtr) int TkTextMarkNameToIndex(textPtr, name, indexPtr) TkText *textPtr; /* Text widget containing mark. */ - char *name; /* Name of mark. */ + CONST char *name; /* Name of mark. */ TkTextIndex *indexPtr; /* Index information gets stored here. */ { Tcl_HashEntry *hPtr; @@ -526,12 +526,16 @@ TkTextInsertDisplayProc(chunkPtr, x, y, height, baseline, display, dst, screenY) if ((x + halfWidth) < 0) { /* - * The insertion cursor is off-screen. Just return. + * The insertion cursor is off-screen. + * Indicate caret at 0,0 and return. */ + Tk_SetCaretPos(textPtr->tkwin, 0, 0, height); return; } + Tk_SetCaretPos(textPtr->tkwin, x - halfWidth, screenY, height); + /* * As a special hack to keep the cursor visible on mono displays * (or anywhere else that the selection and insertion cursors @@ -542,12 +546,12 @@ TkTextInsertDisplayProc(chunkPtr, x, y, height, baseline, display, dst, screenY) if (textPtr->flags & INSERT_ON) { Tk_Fill3DRectangle(textPtr->tkwin, dst, textPtr->insertBorder, - x - textPtr->insertWidth/2, y, textPtr->insertWidth, - height, textPtr->insertBorderWidth, TK_RELIEF_RAISED); + x - halfWidth, y, textPtr->insertWidth, height, + textPtr->insertBorderWidth, TK_RELIEF_RAISED); } else if (textPtr->selBorder == textPtr->insertBorder) { Tk_Fill3DRectangle(textPtr->tkwin, dst, textPtr->border, - x - textPtr->insertWidth/2, y, textPtr->insertWidth, - height, 0, TK_RELIEF_FLAT); + x - halfWidth, y, textPtr->insertWidth, height, + 0, TK_RELIEF_FLAT); } } @@ -643,7 +647,7 @@ static int MarkFindNext(interp, textPtr, string) Tcl_Interp *interp; /* For error reporting */ TkText *textPtr; /* The widget */ - char *string; /* The starting index or mark name */ + CONST char *string; /* The starting index or mark name */ { TkTextIndex index; Tcl_HashEntry *hPtr; @@ -717,7 +721,7 @@ static int MarkFindPrev(interp, textPtr, string) Tcl_Interp *interp; /* For error reporting */ TkText *textPtr; /* The widget */ - char *string; /* The starting index or mark name */ + CONST char *string; /* The starting index or mark name */ { TkTextIndex index; Tcl_HashEntry *hPtr; @@ -773,4 +777,3 @@ MarkFindPrev(interp, textPtr, string) segPtr = NULL; } } - diff --git a/tk/generic/tkTextTag.c b/tk/generic/tkTextTag.c index f623b93026e..b35390c393c 100644 --- a/tk/generic/tkTextTag.c +++ b/tk/generic/tkTextTag.c @@ -76,7 +76,7 @@ static Tk_ConfigSpec tagConfigSpecs[] = { static void ChangeTagPriority _ANSI_ARGS_((TkText *textPtr, TkTextTag *tagPtr, int prio)); static TkTextTag * FindTag _ANSI_ARGS_((Tcl_Interp *interp, - TkText *textPtr, char *tagName)); + TkText *textPtr, CONST char *tagName)); static void SortTags _ANSI_ARGS_((int numTags, TkTextTag **tagArrayPtr)); static int TagSortProc _ANSI_ARGS_((CONST VOID *first, @@ -105,7 +105,7 @@ TkTextTagCmd(textPtr, interp, argc, argv) register TkText *textPtr; /* Information about text widget. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. Someone else has already + CONST char **argv; /* Argument strings. Someone else has already * parsed this command enough to know that * argv[1] is "tag". */ { @@ -151,7 +151,7 @@ TkTextTagCmd(textPtr, interp, argc, argv) index2 = index1; TkTextIndexForwChars(&index2, 1, &index2); } - + if (tagPtr->affectsDisplay) { TkTextRedrawTag(textPtr, &index1, &index2, tagPtr, !addTag); } else { @@ -159,18 +159,34 @@ TkTextTagCmd(textPtr, interp, argc, argv) * Still need to trigger enter/leave events on tags that * have changed. */ - + TkTextEventuallyRepick(textPtr); } TkBTreeTag(&index1, &index2, tagPtr, addTag); - + /* * If the tag is "sel" then grab the selection if we're supposed * to export it and don't already have it. Also, invalidate * partially-completed selection retrievals. */ - + if (tagPtr == textPtr->selTagPtr) { + XEvent event; + /* + * Send an event that the selection changed. + * This is equivalent to + * "event generate $textWidget <>" + */ + + memset((VOID *) &event, 0, sizeof(event)); + event.xany.type = VirtualEvent; + event.xany.serial = NextRequest(Tk_Display(textPtr->tkwin)); + event.xany.send_event = False; + event.xany.window = Tk_WindowId(textPtr->tkwin); + event.xany.display = Tk_Display(textPtr->tkwin); + ((XVirtualEvent *) &event)->name = Tk_GetUid("Selection"); + Tk_HandleEvent(&event); + if (addTag && textPtr->exportSelection && !(textPtr->flags & GOT_SELECTION)) { Tk_OwnSelection(textPtr->tkwin, XA_PRIMARY, @@ -229,12 +245,12 @@ TkTextTagCmd(textPtr, interp, argc, argv) return TCL_ERROR; } } else if (argc == 5) { - char *command; + CONST char *command; command = Tk_GetBinding(interp, textPtr->bindingTable, (ClientData) tagPtr, argv[4]); if (command == NULL) { - char *string = Tcl_GetStringResult(interp); + CONST char *string = Tcl_GetStringResult(interp); /* * Ignore missing binding errors. This is a special hack @@ -248,7 +264,7 @@ TkTextTagCmd(textPtr, interp, argc, argv) Tcl_ResetResult(interp); } } else { - Tcl_SetResult(interp, command, TCL_STATIC); + Tcl_SetResult(interp, (char *) command, TCL_STATIC); } } else { Tk_GetAllBindings(interp, textPtr->bindingTable, @@ -462,6 +478,25 @@ TkTextTagCmd(textPtr, interp, argc, argv) TkTextMakeByteIndex(textPtr->tree, TkBTreeNumLines(textPtr->tree), 0, &last), TkBTreeTag(&first, &last, tagPtr, 0); + + if (tagPtr == textPtr->selTagPtr) { + XEvent event; + /* + * Send an event that the selection changed. + * This is equivalent to + * "event generate $textWidget <>" + */ + + memset((VOID *) &event, 0, sizeof(event)); + event.xany.type = VirtualEvent; + event.xany.serial = NextRequest(Tk_Display(textPtr->tkwin)); + event.xany.send_event = False; + event.xany.window = Tk_WindowId(textPtr->tkwin); + event.xany.display = Tk_Display(textPtr->tkwin); + ((XVirtualEvent *) &event)->name = Tk_GetUid("Selection"); + Tk_HandleEvent(&event); + } + Tcl_DeleteHashEntry(hPtr); if (textPtr->bindingTable != NULL) { Tk_DeleteAllBindings(textPtr->bindingTable, @@ -769,7 +804,7 @@ TkTextTagCmd(textPtr, interp, argc, argv) TkTextTag * TkTextCreateTag(textPtr, tagName) TkText *textPtr; /* Widget in which tag is being used. */ - char *tagName; /* Name of desired tag. */ + CONST char *tagName; /* Name of desired tag. */ { register TkTextTag *tagPtr; Tcl_HashEntry *hPtr; @@ -855,7 +890,7 @@ FindTag(interp, textPtr, tagName) * if NULL, then don't record an error * message. */ TkText *textPtr; /* Widget in which tag is being used. */ - char *tagName; /* Name of desired tag. */ + CONST char *tagName; /* Name of desired tag. */ { Tcl_HashEntry *hPtr; @@ -1386,4 +1421,3 @@ TkTextPickCurrent(textPtr, eventPtr) ckfree((char *) copyArrayPtr); } } - diff --git a/tk/generic/tkTextWind.c b/tk/generic/tkTextWind.c index 9624403cf2c..d3fb22c9fa3 100644 --- a/tk/generic/tkTextWind.c +++ b/tk/generic/tkTextWind.c @@ -55,8 +55,8 @@ static Tk_GeomMgr textGeomType = { */ static int AlignParseProc _ANSI_ARGS_((ClientData clientData, - Tcl_Interp *interp, Tk_Window tkwin, char *value, - char *widgRec, int offset)); + Tcl_Interp *interp, Tk_Window tkwin, + CONST char *value, char *widgRec, int offset)); static char * AlignPrintProc _ANSI_ARGS_((ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)); @@ -69,7 +69,7 @@ static void EmbWinBboxProc _ANSI_ARGS_((TkTextDispChunk *chunkPtr, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr)); static int EmbWinConfigure _ANSI_ARGS_((TkText *textPtr, - TkTextSegment *ewPtr, int argc, char **argv)); + TkTextSegment *ewPtr, int argc, CONST char **argv)); static void EmbWinDelayedUnmap _ANSI_ARGS_(( ClientData clientData)); static int EmbWinDeleteProc _ANSI_ARGS_((TkTextSegment *segPtr, @@ -155,7 +155,7 @@ TkTextWindowCmd(textPtr, interp, argc, argv) register TkText *textPtr; /* Information about text widget. */ Tcl_Interp *interp; /* Current interpreter. */ int argc; /* Number of arguments. */ - char **argv; /* Argument strings. Someone else has already + CONST char **argv; /* Argument strings. Someone else has already * parsed this command enough to know that * argv[1] is "window". */ { @@ -327,7 +327,7 @@ EmbWinConfigure(textPtr, ewPtr, argc, argv) * contains embedded window. */ TkTextSegment *ewPtr; /* Embedded window to be configured. */ int argc; /* Number of strings in argv. */ - char **argv; /* Array of strings describing configuration + CONST char **argv; /* Array of strings describing configuration * options. */ { Tk_Window oldWindow; @@ -370,7 +370,7 @@ EmbWinConfigure(textPtr, ewPtr, argc, argv) if (ancestor == parent) { break; } - if (Tk_IsTopLevel(ancestor)) { + if (Tk_TopWinHierarchy(ancestor)) { badMaster: Tcl_AppendResult(textPtr->interp, "can't embed ", Tk_PathName(ewPtr->body.ew.tkwin), " in ", @@ -379,7 +379,7 @@ EmbWinConfigure(textPtr, ewPtr, argc, argv) return TCL_ERROR; } } - if (Tk_IsTopLevel(ewPtr->body.ew.tkwin) + if (Tk_TopWinHierarchy(ewPtr->body.ew.tkwin) || (ewPtr->body.ew.tkwin == textPtr->tkwin)) { goto badMaster; } @@ -435,7 +435,7 @@ AlignParseProc(clientData, interp, tkwin, value, widgRec, offset) ClientData clientData; /* Not used.*/ Tcl_Interp *interp; /* Used for reporting errors. */ Tk_Window tkwin; /* Window for text widget. */ - char *value; /* Value of option. */ + CONST char *value; /* Value of option. */ char *widgRec; /* Pointer to TkTextEmbWindow * structure. */ int offset; /* Offset into item (ignored). */ @@ -790,7 +790,7 @@ EmbWinLayoutProc(textPtr, indexPtr, ewPtr, offset, maxX, maxChars, if (ancestor == Tk_Parent(ewPtr->body.ew.tkwin)) { break; } - if (Tk_IsTopLevel(ancestor)) { + if (Tk_TopWinHierarchy(ancestor)) { badMaster: Tcl_AppendResult(textPtr->interp, "can't embed ", Tk_PathName(ewPtr->body.ew.tkwin), " relative to ", @@ -800,7 +800,7 @@ EmbWinLayoutProc(textPtr, indexPtr, ewPtr, offset, maxX, maxChars, goto gotWindow; } } - if (Tk_IsTopLevel(ewPtr->body.ew.tkwin) + if (Tk_TopWinHierarchy(ewPtr->body.ew.tkwin) || (textPtr->tkwin == ewPtr->body.ew.tkwin)) { goto badMaster; } @@ -1158,7 +1158,7 @@ EmbWinDelayedUnmap(clientData) int TkTextWindowIndex(textPtr, name, indexPtr) TkText *textPtr; /* Text widget containing window. */ - char *name; /* Name of window. */ + CONST char *name; /* Name of window. */ TkTextIndex *indexPtr; /* Index information gets stored here. */ { Tcl_HashEntry *hPtr; @@ -1174,4 +1174,3 @@ TkTextWindowIndex(textPtr, name, indexPtr) indexPtr->byteIndex = TkTextSegToOffset(ewPtr, indexPtr->linePtr); return 1; } - diff --git a/tk/generic/tkTrig.c b/tk/generic/tkTrig.c index b9f0628242a..549982130b0 100644 --- a/tk/generic/tkTrig.c +++ b/tk/generic/tkTrig.c @@ -1473,4 +1473,3 @@ TkGetButtPoints(p1, p2, width, project, m1, m2) } } } - diff --git a/tk/generic/tkUndo.c b/tk/generic/tkUndo.c new file mode 100644 index 00000000000..e2271ee3775 --- /dev/null +++ b/tk/generic/tkUndo.c @@ -0,0 +1,400 @@ +/* + * tkUndo.c -- + * + * This module provides the implementation of an undo stack. + * + * Copyright (c) 2002 by Ludwig Callewaert. + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * RCS: @(#) $Id$ + */ + +#include "tkUndo.h" + + +/* + * TkUndoPushStack + * Push elem on the stack identified by stack. + * + * Results: + * None + * + * Side effects: + * None. + */ + +void TkUndoPushStack ( stack, elem ) + TkUndoAtom ** stack; + TkUndoAtom * elem; +{ + elem->next = *stack; + *stack = elem; +} + +/* + * TkUndoPopStack -- + * Remove and return the top element from the stack identified by + * stack. + * + * Results: + * None + * + * Side effects: + * None. + */ + +TkUndoAtom * TkUndoPopStack ( stack ) + TkUndoAtom ** stack ; +{ + TkUndoAtom * elem = NULL; + if (*stack != NULL ) { + elem = *stack; + *stack = elem->next; + } + return elem; +} + +/* + * TkUndoInsertSeparator -- + * insert a separator on the stack, indicating a border for + * an undo/redo chunk. + * + * Results: + * None + * + * Side effects: + * None. + */ + +int TkUndoInsertSeparator ( stack ) + TkUndoAtom ** stack; +{ + TkUndoAtom * separator; + + if ( *stack != NULL && (*stack)->type != TK_UNDO_SEPARATOR ) { + separator = (TkUndoAtom *) ckalloc(sizeof(TkUndoAtom)); + separator->type = TK_UNDO_SEPARATOR; + TkUndoPushStack(stack,separator); + return 1; + } else { + return 0; + } +} + +/* + * TkUndoClearStack -- + * Clear an entire undo or redo stack and destroy all elements in it. + * + * Results: + * None + * + * Side effects: + * None. + */ + +void TkUndoClearStack ( stack ) + TkUndoAtom ** stack; /* An Undo or Redo stack */ +{ + TkUndoAtom * elem; + + while ( (elem = TkUndoPopStack(stack)) ) { + if ( elem->type != TK_UNDO_SEPARATOR ) { + Tcl_DecrRefCount(elem->apply); + Tcl_DecrRefCount(elem->revert); + } + ckfree((char *)elem); + } + *stack = NULL; +} + +/* + * TkUndoPushAction + * Push a new elem on the stack identified by stack. + * action and revert are given through Tcl_DStrings + * + * Results: + * None + * + * Side effects: + * None. + */ + +void TkUndoPushAction ( stack, actionScript, revertScript ) + TkUndoRedoStack * stack; /* An Undo or Redo stack */ + Tcl_DString * actionScript; /* The script to get the action (redo) */ + Tcl_DString * revertScript; /* The script to revert the action (undo) */ +{ + TkUndoAtom * atom; + + atom = (TkUndoAtom *) ckalloc(sizeof(TkUndoAtom)); + atom->type = TK_UNDO_ACTION; + + atom->apply = Tcl_NewStringObj(Tcl_DStringValue(actionScript),Tcl_DStringLength(actionScript)); + Tcl_IncrRefCount(atom->apply); + + atom->revert = Tcl_NewStringObj(Tcl_DStringValue(revertScript),Tcl_DStringLength(revertScript)); + Tcl_IncrRefCount(atom->revert); + + TkUndoPushStack(&(stack->undoStack), atom); + TkUndoClearStack(&(stack->redoStack)); +} + + +/* + * TkUndoInitStack + * Initialize a new undo/redo stack + * + * Results: + * un Undo/Redo stack pointer + * + * Side effects: + * None. + */ + +TkUndoRedoStack * TkUndoInitStack ( interp, maxdepth ) + Tcl_Interp * interp; /* The interpreter */ + int maxdepth; /* The maximum stack depth */ +{ + TkUndoRedoStack * stack; /* An Undo/Redo stack */ + stack = (TkUndoRedoStack *) ckalloc(sizeof(TkUndoRedoStack)); + stack->undoStack = NULL; + stack->redoStack = NULL; + stack->interp = interp; + stack->maxdepth = maxdepth; + stack->depth = 0; + return stack; +} + + +/* + * TkUndoInitStack + * Initialize a new undo/redo stack + * + * Results: + * un Undo/Redo stack pointer + * + * Side effects: + * None. + */ + +void TkUndoSetDepth ( stack, maxdepth ) + TkUndoRedoStack * stack; /* An Undo/Redo stack */ + int maxdepth; /* The maximum stack depth */ +{ + TkUndoAtom * elem; + TkUndoAtom * prevelem; + int sepNumber = 0; + + stack->maxdepth = maxdepth; + + if ((stack->maxdepth > 0) && (stack->depth > stack->maxdepth)) { + /* Maximum stack depth exceeded. We have to remove the last compound + elements on the stack */ + elem = stack->undoStack; + prevelem = NULL; + while ( sepNumber <= stack->maxdepth ) { + if (elem != NULL && (elem->type == TK_UNDO_SEPARATOR) ) { + sepNumber++; + } + prevelem = elem; + elem = elem->next; + } + prevelem->next = NULL; + while ( elem ) { + prevelem = elem; + elem = elem->next; + ckfree((char *) elem); + } + stack->depth = stack->maxdepth; + } +} + + +/* + * TkUndoClearStacks + * Clear both the undo and redo stack + * + * Results: + * None + * + * Side effects: + * None. + */ + +void TkUndoClearStacks ( stack ) + TkUndoRedoStack * stack; /* An Undo/Redo stack */ +{ + TkUndoClearStack(&(stack->undoStack)); + TkUndoClearStack(&(stack->redoStack)); + stack->depth = 0; +} + + +/* + * TkUndoFreeStack + * Clear both the undo and redo stack + * also free the memory allocated to the u/r stack pointer + * + * Results: + * None + * + * Side effects: + * None. + */ + +void TkUndoFreeStack ( stack ) + TkUndoRedoStack * stack; /* An Undo/Redo stack */ +{ + TkUndoClearStacks(stack); +/* ckfree((TkUndoRedoStack *) stack); */ + ckfree((char *) stack); +} + + +/* + * TkUndoInsertUndoSeparator -- + * insert a separator on the undo stack, indicating a border for + * an undo/redo chunk. + * + * Results: + * None + * + * Side effects: + * None. + */ + +void TkUndoInsertUndoSeparator ( stack ) + TkUndoRedoStack * stack; +{ +/* TkUndoAtom * elem; + TkUndoAtom * prevelem; + int sepNumber = 0; +*/ + + if ( TkUndoInsertSeparator(&(stack->undoStack)) ) { + ++(stack->depth); + TkUndoSetDepth(stack,stack->maxdepth); +/* if ((stack->maxdepth > 0) && (stack->depth > stack->maxdepth)) { + elem = stack->undoStack; + prevelem = NULL; + while ( sepNumber < stack->depth ) { + if (elem != NULL && (elem->type == TK_UNDO_SEPARATOR) ) { + sepNumber++; + } + prevelem = elem; + elem = elem->next; + } + prevelem->next = NULL; + while ( elem ) { + prevelem = elem; + elem = elem->next; + ckfree((char *) elem); + } + stack->depth; + } */ + } +} + + +/* + * TkUndoRevert -- + * Undo a compound action on the stack. + * + * Results: + * A TCL status code + * + * Side effects: + * None. + */ + +int TkUndoRevert ( stack ) + TkUndoRedoStack * stack; +{ + TkUndoAtom * elem; + + /* insert a separator on the undo and the redo stack */ + + TkUndoInsertUndoSeparator(stack); + TkUndoInsertSeparator(&(stack->redoStack)); + + /* Pop and skip the first separator if there is one*/ + + elem = TkUndoPopStack(&(stack->undoStack)); + + if ( elem == NULL ) { + return TCL_ERROR; + } + + if ( ( elem != NULL ) && ( elem->type == TK_UNDO_SEPARATOR ) ) { + ckfree((char *) elem); + elem = TkUndoPopStack(&(stack->undoStack)); + } + + while ( elem && (elem->type != TK_UNDO_SEPARATOR) ) { + Tcl_EvalObjEx(stack->interp,elem->revert,TCL_EVAL_GLOBAL); + + TkUndoPushStack(&(stack->redoStack),elem); + elem = TkUndoPopStack(&(stack->undoStack)); + } + + /* insert a separator on the redo stack */ + + TkUndoInsertSeparator(&(stack->redoStack)); + + --(stack->depth); + + return TCL_OK; +} + + +/* + * TkUndoApply -- + * Redo a compound action on the stack. + * + * Results: + * A TCL status code + * + * Side effects: + * None. + */ + +int TkUndoApply ( stack ) + TkUndoRedoStack * stack; +{ + TkUndoAtom *elem; + + /* insert a separator on the undo stack */ + + TkUndoInsertSeparator(&(stack->undoStack)); + + /* Pop and skip the first separator if there is one*/ + + elem = TkUndoPopStack(&(stack->redoStack)); + + if ( elem == NULL ) { + return TCL_ERROR; + } + + if ( ( elem != NULL ) && ( elem->type == TK_UNDO_SEPARATOR ) ) { + ckfree((char *) elem); + elem = TkUndoPopStack(&(stack->redoStack)); + } + + while ( elem && (elem->type != TK_UNDO_SEPARATOR) ) { + Tcl_EvalObjEx(stack->interp,elem->apply,TCL_EVAL_GLOBAL); + + TkUndoPushStack(&(stack->undoStack), elem); + elem = TkUndoPopStack(&(stack->redoStack)); + } + + /* insert a separator on the undo stack */ + + TkUndoInsertSeparator(&(stack->undoStack)); + + ++(stack->depth); + + return TCL_OK; +} + diff --git a/tk/generic/tkUndo.h b/tk/generic/tkUndo.h new file mode 100644 index 00000000000..2775cce86f8 --- /dev/null +++ b/tk/generic/tkUndo.h @@ -0,0 +1,90 @@ +/* + * tkUndo.h -- + * + * Declarations shared among the files that implement an undo + * stack. + * + * Copyright (c) 2002 Ludwig Callewaert. + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * RCS: @(#) $Id$ + */ + +#ifndef _TKUNDO +#define _TKUNDO + +#ifndef _TK +#include "tk.h" +#endif + +#ifdef BUILD_tk +# undef TCL_STORAGE_CLASS +# define TCL_STORAGE_CLASS DLLEXPORT +#endif + +/* enum definining the types used in an undo stack */ + +typedef enum { + TK_UNDO_SEPARATOR, /* Marker */ + TK_UNDO_ACTION /* Command */ +} TkUndoAtomType; + +/* struct defining the basic undo/redo stack element */ + +typedef struct TkUndoAtom { + TkUndoAtomType type; /* The type that will trigger the + * required action*/ + Tcl_Obj * apply; /* Command to apply the action that was taken */ + Tcl_Obj * revert; /* The command to undo the action */ + struct TkUndoAtom * next; /* Pointer to the next element in the + * stack */ +} TkUndoAtom; + +/* struct defining the basic undo/redo stack element */ + +typedef struct TkUndoRedoStack { + TkUndoAtom * undoStack; /* The undo stack */ + TkUndoAtom * redoStack; /* The redo stack */ + Tcl_Interp * interp ; /* The interpreter in which to execute the revert and apply scripts */ + int maxdepth; + int depth; +} TkUndoRedoStack; + +/* basic functions */ + +EXTERN void TkUndoPushStack _ANSI_ARGS_((TkUndoAtom ** stack, + TkUndoAtom * elem)); + +EXTERN TkUndoAtom * TkUndoPopStack _ANSI_ARGS_((TkUndoAtom ** stack)); + +EXTERN int TkUndoInsertSeparator _ANSI_ARGS_((TkUndoAtom ** stack)); + +EXTERN void TkUndoClearStack _ANSI_ARGS_((TkUndoAtom ** stack)); + +/* functions working on an undo/redo stack */ + +EXTERN TkUndoRedoStack * TkUndoInitStack _ANSI_ARGS_((Tcl_Interp * interp, + int maxdepth)); + +EXTERN void TkUndoSetDepth _ANSI_ARGS_((TkUndoRedoStack * stack, + int maxdepth)); + +EXTERN void TkUndoClearStacks _ANSI_ARGS_((TkUndoRedoStack * stack)); + +EXTERN void TkUndoFreeStack _ANSI_ARGS_((TkUndoRedoStack * stack)); + +EXTERN void TkUndoInsertUndoSeparator _ANSI_ARGS_((TkUndoRedoStack * stack)); + +EXTERN void TkUndoPushAction _ANSI_ARGS_((TkUndoRedoStack * stack, + Tcl_DString * actionScript, Tcl_DString * revertScript)); + +EXTERN int TkUndoRevert _ANSI_ARGS_((TkUndoRedoStack * stack)); + +EXTERN int TkUndoApply _ANSI_ARGS_((TkUndoRedoStack * stack)); + +# undef TCL_STORAGE_CLASS +# define TCL_STORAGE_CLASS DLLIMPORT + +#endif /* _TKUNDO */ diff --git a/tk/generic/tkUtil.c b/tk/generic/tkUtil.c index cbb49e6d8bb..dcf0de29300 100644 --- a/tk/generic/tkUtil.c +++ b/tk/generic/tkUtil.c @@ -22,7 +22,7 @@ * Tcl object, used for quickly finding a mapping in a TkStateMap. */ -static Tcl_ObjType stateKeyType = { +Tcl_ObjType tkStateKeyObjType = { "statekey", /* name */ (Tcl_FreeInternalRepProc *) NULL, /* freeIntRepProc */ (Tcl_DupInternalRepProc *) NULL, /* dupIntRepProc */ @@ -630,7 +630,7 @@ int Tk_GetScrollInfo(interp, argc, argv, dblPtr, intPtr) Tcl_Interp *interp; /* Used for error reporting. */ int argc; /* # arguments for command. */ - char **argv; /* Arguments for command. */ + CONST char **argv; /* Arguments for command. */ double *dblPtr; /* Filled in with argument "moveto" * option, if any. */ int *intPtr; /* Filled in with number of pages @@ -794,7 +794,7 @@ TkComputeAnchor(anchor, tkwin, padX, padY, innerWidth, innerHeight, xPtr, yPtr) case TK_ANCHOR_NW: case TK_ANCHOR_W: case TK_ANCHOR_SW: - *xPtr = Tk_InternalBorderWidth(tkwin) + padX; + *xPtr = Tk_InternalBorderLeft(tkwin) + padX; break; case TK_ANCHOR_N: @@ -804,7 +804,7 @@ TkComputeAnchor(anchor, tkwin, padX, padY, innerWidth, innerHeight, xPtr, yPtr) break; default: - *xPtr = Tk_Width(tkwin) - (Tk_InternalBorderWidth(tkwin) + padX) + *xPtr = Tk_Width(tkwin) - (Tk_InternalBorderRight(tkwin) + padX) - innerWidth; break; } @@ -813,7 +813,7 @@ TkComputeAnchor(anchor, tkwin, padX, padY, innerWidth, innerHeight, xPtr, yPtr) case TK_ANCHOR_NW: case TK_ANCHOR_N: case TK_ANCHOR_NE: - *yPtr = Tk_InternalBorderWidth(tkwin) + padY; + *yPtr = Tk_InternalBorderTop(tkwin) + padY; break; case TK_ANCHOR_W: @@ -823,7 +823,7 @@ TkComputeAnchor(anchor, tkwin, padX, padY, innerWidth, innerHeight, xPtr, yPtr) break; default: - *yPtr = Tk_Height(tkwin) - Tk_InternalBorderWidth(tkwin) - padY + *yPtr = Tk_Height(tkwin) - Tk_InternalBorderBottom(tkwin) - padY - innerHeight; break; } @@ -920,7 +920,7 @@ TkFindStateNumObj(interp, optionPtr, mapPtr, keyPtr) CONST char *key; CONST Tcl_ObjType *typePtr; - if ((keyPtr->typePtr == &stateKeyType) + if ((keyPtr->typePtr == &tkStateKeyObjType) && (keyPtr->internalRep.twoPtrValue.ptr1 == (VOID *) mapPtr)) { return (int) keyPtr->internalRep.twoPtrValue.ptr2; } @@ -934,7 +934,7 @@ TkFindStateNumObj(interp, optionPtr, mapPtr, keyPtr) } keyPtr->internalRep.twoPtrValue.ptr1 = (VOID *) mapPtr; keyPtr->internalRep.twoPtrValue.ptr2 = (VOID *) mPtr->numKey; - keyPtr->typePtr = &stateKeyType; + keyPtr->typePtr = &tkStateKeyObjType; return mPtr->numKey; } } @@ -951,5 +951,3 @@ TkFindStateNumObj(interp, optionPtr, mapPtr, keyPtr) } return mPtr->numKey; } - - diff --git a/tk/generic/tkVisual.c b/tk/generic/tkVisual.c index a2d717a119d..e60e5a23240 100644 --- a/tk/generic/tkVisual.c +++ b/tk/generic/tkVisual.c @@ -92,7 +92,7 @@ Tk_GetVisual(interp, tkwin, string, depthPtr, colormapPtr) * reporting. */ Tk_Window tkwin; /* Window in which visual will be * used. */ - char *string; /* String describing visual. See + CONST char *string; /* String describing visual. See * manual entry for details. */ int *depthPtr; /* The depth of the returned visual * is stored here. */ @@ -106,7 +106,7 @@ Tk_GetVisual(interp, tkwin, string, depthPtr, colormapPtr) long mask; Visual *visual; int length, c, numVisuals, prio, bestPrio, i; - char *p; + CONST char *p; VisualDictionary *dictPtr; TkColormap *cmapPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; @@ -369,7 +369,7 @@ Tk_GetColormap(interp, tkwin, string) * reporting. */ Tk_Window tkwin; /* Window where colormap will be * used. */ - char *string; /* String that identifies colormap: + CONST char *string; /* String that identifies colormap: * either "new" or the name of * another window. */ { @@ -539,4 +539,3 @@ Tk_PreserveColormap(display, colormap) } } } - diff --git a/tk/generic/tkWindow.c b/tk/generic/tkWindow.c index 5f3a8a0c517..47e2a472e71 100644 --- a/tk/generic/tkWindow.c +++ b/tk/generic/tkWindow.c @@ -18,7 +18,7 @@ #include "tkPort.h" #include "tkInt.h" -#if !defined(__WIN32__) && !defined(MAC_TCL) +#if !( defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK)) #include "tkUnixInt.h" #endif @@ -98,25 +98,25 @@ static TkCmd commands[] = { */ {"bell", NULL, Tk_BellObjCmd, 0, 1}, - {"bind", Tk_BindCmd, NULL, 1, 1}, - {"bindtags", Tk_BindtagsCmd, NULL, 1, 1}, - {"clipboard", Tk_ClipboardCmd, NULL, 0, 1}, + {"bind", NULL, Tk_BindObjCmd, 1, 1}, + {"bindtags", NULL, Tk_BindtagsObjCmd, 1, 1}, + {"clipboard", NULL, Tk_ClipboardObjCmd, 0, 1}, {"destroy", NULL, Tk_DestroyObjCmd, 1, 1}, {"event", NULL, Tk_EventObjCmd, 1, 1}, {"focus", NULL, Tk_FocusObjCmd, 1, 1}, {"font", NULL, Tk_FontObjCmd, 1, 1}, - {"grab", Tk_GrabCmd, NULL, 0, 1}, - {"grid", Tk_GridCmd, NULL, 1, 1}, + {"grab", NULL, Tk_GrabObjCmd, 0, 1}, + {"grid", NULL, Tk_GridObjCmd, 1, 1}, {"image", NULL, Tk_ImageObjCmd, 1, 1}, {"lower", NULL, Tk_LowerObjCmd, 1, 1}, {"option", NULL, Tk_OptionObjCmd, 1, 1}, - {"pack", Tk_PackCmd, NULL, 1, 1}, - {"place", Tk_PlaceCmd, NULL, 1, 1}, + {"pack", NULL, Tk_PackObjCmd, 1, 1}, + {"place", NULL, Tk_PlaceObjCmd, 1, 0}, {"raise", NULL, Tk_RaiseObjCmd, 1, 1}, - {"selection", Tk_SelectionCmd, NULL, 0, 1}, - {"tk", NULL, Tk_TkObjCmd, 0, 1}, - {"tkwait", Tk_TkwaitCmd, NULL, 1, 1}, -#if defined(__WIN32__) || defined(MAC_TCL) + {"selection", NULL, Tk_SelectionObjCmd, 0, 1}, + {"tk", NULL, Tk_TkObjCmd, 1, 1}, + {"tkwait", NULL, Tk_TkwaitObjCmd, 1, 1}, +#if defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK) {"tk_chooseColor", NULL, Tk_ChooseColorObjCmd, 0, 1}, {"tk_chooseDirectory", NULL, Tk_ChooseDirectoryObjCmd, 0, 1}, {"tk_getOpenFile", NULL, Tk_GetOpenFileObjCmd, 0, 1}, @@ -127,7 +127,7 @@ static TkCmd commands[] = { #endif {"update", NULL, Tk_UpdateObjCmd, 1, 1}, {"winfo", NULL, Tk_WinfoObjCmd, 1, 1}, - {"wm", Tk_WmCmd, NULL, 0, 1}, + {"wm", NULL, Tk_WmObjCmd, 0, 1}, /* * Widget class commands. @@ -137,25 +137,29 @@ static TkCmd commands[] = { {"canvas", NULL, Tk_CanvasObjCmd, 1, 1}, {"checkbutton", NULL, Tk_CheckbuttonObjCmd, 1, 0}, {"entry", NULL, Tk_EntryObjCmd, 1, 0}, - {"frame", NULL, Tk_FrameObjCmd, 1, 1}, + {"frame", NULL, Tk_FrameObjCmd, 1, 0}, {"label", NULL, Tk_LabelObjCmd, 1, 0}, + {"labelframe", NULL, Tk_LabelframeObjCmd, 1, 0}, {"listbox", NULL, Tk_ListboxObjCmd, 1, 0}, {"menubutton", NULL, Tk_MenubuttonObjCmd, 1, 0}, - {"message", Tk_MessageCmd, NULL, 1, 1}, + {"message", NULL, Tk_MessageObjCmd, 1, 0}, + {"panedwindow", NULL, Tk_PanedWindowObjCmd, 1, 0}, {"radiobutton", NULL, Tk_RadiobuttonObjCmd, 1, 0}, {"scale", NULL, Tk_ScaleObjCmd, 1, 0}, {"scrollbar", Tk_ScrollbarCmd, NULL, 1, 1}, + {"spinbox", NULL, Tk_SpinboxObjCmd, 1, 0}, {"text", Tk_TextCmd, NULL, 1, 1}, - {"toplevel", NULL, Tk_ToplevelObjCmd, 0, 1}, + {"toplevel", NULL, Tk_ToplevelObjCmd, 0, 0}, /* * Misc. */ -#ifdef MAC_TCL - {"unsupported1", TkUnsupported1Cmd, NULL, 1, 1}, +#if defined(MAC_TCL) || defined(MAC_OSX_TK) + {"::tk::unsupported::MacWindowStyle", + TkUnsupported1Cmd, NULL, 1, 1}, #endif - {(char *) NULL, (int (*) _ANSI_ARGS_((ClientData, Tcl_Interp *, int, char **))) NULL, NULL, 0} + {(char *) NULL, (int (*) _ANSI_ARGS_((ClientData, Tcl_Interp *, int, CONST char **))) NULL, NULL, 0} }; /* @@ -198,18 +202,78 @@ static Tk_ArgvInfo argTable[] = { */ static Tk_Window CreateTopLevelWindow _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Window parent, char *name, char *screenName)); + Tk_Window parent, CONST char *name, + CONST char *screenName, unsigned int flags)); static void DeleteWindowsExitProc _ANSI_ARGS_(( ClientData clientData)); static TkDisplay * GetScreen _ANSI_ARGS_((Tcl_Interp *interp, - char *screenName, int *screenPtr)); + CONST char *screenName, int *screenPtr)); static int Initialize _ANSI_ARGS_((Tcl_Interp *interp)); static int NameWindow _ANSI_ARGS_((Tcl_Interp *interp, TkWindow *winPtr, TkWindow *parentPtr, - char *name)); -static void OpenIM _ANSI_ARGS_((TkDisplay *dispPtr)); + CONST char *name)); static void UnlinkWindow _ANSI_ARGS_((TkWindow *winPtr)); +/* + *---------------------------------------------------------------------- + * + * TkCloseDisplay -- + * Closing the display can lead to order of deletion problems. + * We defer it until exit handling for Mac/Win, but since Unix can + * use many displays, try and clean it up as best as possible. + * + * Results: + * None. + * + * Side effects: + * Resources associated with the display will be free. + * The display may not be referenced at all after this. + *---------------------------------------------------------------------- + */ + +static void +TkCloseDisplay(TkDisplay *dispPtr) +{ + TkClipCleanup(dispPtr); + + if (dispPtr->name != NULL) { + ckfree(dispPtr->name); + } + + if (dispPtr->atomInit) { + Tcl_DeleteHashTable(&dispPtr->nameTable); + Tcl_DeleteHashTable(&dispPtr->atomTable); + dispPtr->atomInit = 0; + } + + if (dispPtr->errorPtr != NULL) { + TkErrorHandler *errorPtr; + for (errorPtr = dispPtr->errorPtr; + errorPtr != NULL; + errorPtr = dispPtr->errorPtr) { + dispPtr->errorPtr = errorPtr->nextPtr; + ckfree((char *) errorPtr); + } + } + + TkGCCleanup(dispPtr); + + TkpCloseDisplay(dispPtr); + + /* + * Delete winTable after TkpCloseDisplay since special windows + * may need call Tk_DestroyWindow and it checks the winTable. + */ + + Tcl_DeleteHashTable(&dispPtr->winTable); + + ckfree((char *) dispPtr); + + /* + * There is more to clean up, we leave it at this for the time being. + */ +} + /* *---------------------------------------------------------------------- * @@ -233,19 +297,20 @@ static void UnlinkWindow _ANSI_ARGS_((TkWindow *winPtr)); */ static Tk_Window -CreateTopLevelWindow(interp, parent, name, screenName) +CreateTopLevelWindow(interp, parent, name, screenName, flags) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ Tk_Window parent; /* Token for logical parent of new window * (used for naming, options, etc.). May * be NULL. */ - char *name; /* Name for new window; if parent is + CONST char *name; /* Name for new window; if parent is * non-NULL, must be unique among parent's * children. */ - char *screenName; /* Name of screen on which to create + CONST char *screenName; /* Name of screen on which to create * window. NULL means use DISPLAY environment * variable to determine. Empty string means * use parent's screen, or DISPLAY if no * parent. */ + unsigned int flags; /* Additional flags to set on the window. */ { register TkWindow *winPtr; register TkDisplay *dispPtr; @@ -290,6 +355,11 @@ CreateTopLevelWindow(interp, parent, name, screenName) winPtr = TkAllocWindow(dispPtr, screenId, (TkWindow *) parent); + /* + * Set the flags specified in the call. + */ + winPtr->flags |= flags; + /* * Force the window to use a border pixel instead of border pixmap. * This is needed for the case where the window doesn't use the @@ -301,12 +371,12 @@ CreateTopLevelWindow(interp, parent, name, screenName) winPtr->dirtyAtts |= CWBorderPixel; /* - * (Need to set the TK_TOP_LEVEL flag immediately here; otherwise + * (Need to set the TK_TOP_HIERARCHY flag immediately here; otherwise * Tk_DestroyWindow will core dump if it is called before the flag * has been set.) */ - winPtr->flags |= TK_TOP_LEVEL; + winPtr->flags |= TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED; if (parent != NULL) { if (NameWindow(interp, winPtr, (TkWindow *) parent, name) != TCL_OK) { @@ -346,12 +416,12 @@ CreateTopLevelWindow(interp, parent, name, screenName) static TkDisplay * GetScreen(interp, screenName, screenPtr) Tcl_Interp *interp; /* Place to leave error message. */ - char *screenName; /* Name for screen. NULL or empty means + CONST char *screenName; /* Name for screen. NULL or empty means * use DISPLAY envariable. */ int *screenPtr; /* Where to store screen number. */ { register TkDisplay *dispPtr; - char *p; + CONST char *p; int screenId; size_t length; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) @@ -387,82 +457,39 @@ GetScreen(interp, screenName, screenPtr) * then open a new connection. */ - for (dispPtr = TkGetDisplayList(); ; dispPtr = dispPtr->nextPtr) { + for (dispPtr = tsdPtr->displayList; ; dispPtr = dispPtr->nextPtr) { if (dispPtr == NULL) { + /* + * The private function zeros out dispPtr when it is created, + * so we only need to initialize the non-zero items. + */ dispPtr = TkpOpenDisplay(screenName); if (dispPtr == NULL) { Tcl_AppendResult(interp, "couldn't connect to display \"", screenName, "\"", (char *) NULL); return (TkDisplay *) NULL; } - dispPtr->nextPtr = TkGetDisplayList(); - dispPtr->name = (char *) ckalloc((unsigned) (length+1)); + dispPtr->nextPtr = tsdPtr->displayList; /* TkGetDisplayList(); */ + tsdPtr->displayList = dispPtr; + dispPtr->lastEventTime = CurrentTime; - dispPtr->borderInit = 0; - dispPtr->atomInit = 0; dispPtr->bindInfoStale = 1; - dispPtr->modeModMask = 0; - dispPtr->metaModMask = 0; - dispPtr->altModMask = 0; - dispPtr->numModKeyCodes = 0; - dispPtr->modKeyCodes = NULL; - dispPtr->bitmapInit = 0; - dispPtr->bitmapAutoNumber = 0; - dispPtr->numIdSearches = 0; - dispPtr->numSlowSearches = 0; - dispPtr->colorInit = 0; - dispPtr->stressPtr = NULL; - dispPtr->cursorInit = 0; - dispPtr->cursorString[0] = '\0'; dispPtr->cursorFont = None; - dispPtr->errorPtr = NULL; - dispPtr->deleteCount = 0; - dispPtr->delayedMotionPtr = NULL; - dispPtr->focusDebug = 0; - dispPtr->implicitWinPtr = NULL; - dispPtr->focusPtr = NULL; - dispPtr->gcInit = 0; - dispPtr->geomInit = 0; - dispPtr->uidInit = 0; - dispPtr->grabWinPtr = NULL; - dispPtr->eventualGrabWinPtr = NULL; - dispPtr->buttonWinPtr = NULL; - dispPtr->serverWinPtr = NULL; - dispPtr->firstGrabEventPtr = NULL; - dispPtr->lastGrabEventPtr = NULL; - dispPtr->grabFlags = 0; - dispPtr->mouseButtonState = 0; - dispPtr->warpInProgress = 0; dispPtr->warpWindow = None; - dispPtr->warpX = 0; - dispPtr->warpY = 0; - dispPtr->gridInit = 0; - dispPtr->imageId = 0; - dispPtr->packInit = 0; - dispPtr->placeInit = 0; - dispPtr->selectionInfoPtr = NULL; dispPtr->multipleAtom = None; - dispPtr->clipWindow = NULL; - dispPtr->clipboardActive = 0; - dispPtr->clipboardAppPtr = NULL; - dispPtr->clipTargetPtr = NULL; - dispPtr->commTkwin = NULL; - dispPtr->wmTracing = 0; - dispPtr->firstWmPtr = NULL; - dispPtr->foregroundWmPtr = NULL; - dispPtr->destroyCount = 0; - dispPtr->lastDestroyRequest = 0; - dispPtr->cmapPtr = NULL; + /* + * By default we do want to collapse motion events in + * Tk_QueueWindowEvent. + */ + dispPtr->flags |= TK_DISPLAY_COLLAPSE_MOTION_EVENTS; + Tcl_InitHashTable(&dispPtr->winTable, TCL_ONE_WORD_KEYS); - dispPtr->refCount = 0; + dispPtr->name = (char *) ckalloc((unsigned) (length+1)); strncpy(dispPtr->name, screenName, length); dispPtr->name[length] = '\0'; - dispPtr->useInputMethods = 0; - OpenIM(dispPtr); - TkInitXId(dispPtr); - tsdPtr->displayList = dispPtr; + TkInitXId(dispPtr); break; } if ((strncmp(dispPtr->name, screenName, length) == 0) @@ -639,11 +666,16 @@ TkAllocWindow(dispPtr, screenNum, parentPtr) winPtr->geomMgrPtr = NULL; winPtr->geomData = NULL; winPtr->reqWidth = winPtr->reqHeight = 1; - winPtr->internalBorderWidth = 0; + winPtr->internalBorderLeft = 0; winPtr->wmInfoPtr = NULL; winPtr->classProcsPtr = NULL; winPtr->instanceData = NULL; winPtr->privatePtr = NULL; + winPtr->internalBorderRight = 0; + winPtr->internalBorderTop = 0; + winPtr->internalBorderBottom = 0; + winPtr->minReqWidth = 0; + winPtr->minReqHeight = 0; return winPtr; } @@ -672,7 +704,7 @@ NameWindow(interp, winPtr, parentPtr, name) register TkWindow *winPtr; /* Window that is to be named and inserted. */ TkWindow *parentPtr; /* Pointer to logical parent for winPtr * (used for naming, options, etc.). */ - char *name; /* Name for winPtr; must be unique among + CONST char *name; /* Name for winPtr; must be unique among * parentPtr's children. */ { #define FIXED_SIZE 200 @@ -698,6 +730,19 @@ NameWindow(interp, winPtr, parentPtr, name) parentPtr->lastChildPtr = winPtr; winPtr->mainPtr = parentPtr->mainPtr; winPtr->mainPtr->refCount++; + + /* + * If this is an anonymous window (ie, it has no name), just return OK + * now. + */ + if (winPtr->flags & TK_ANONYMOUS_WINDOW) { + return TCL_OK; + } + + /* + * For non-anonymous windows, set up the window name. + */ + winPtr->nameUid = Tk_GetUid(name); /* @@ -776,7 +821,7 @@ NameWindow(interp, winPtr, parentPtr, name) Tk_Window TkCreateMainWindow(interp, screenName, baseName) Tcl_Interp *interp; /* Interpreter to use for error reporting. */ - char *screenName; /* Name of screen on which to create + CONST char *screenName; /* Name of screen on which to create * window. Empty or NULL string means * use DISPLAY environment variable. */ char *baseName; /* Base name for application; usually of the @@ -807,7 +852,7 @@ TkCreateMainWindow(interp, screenName, baseName) */ tkwin = CreateTopLevelWindow(interp, (Tk_Window) NULL, baseName, - screenName); + screenName, /* flags */ 0); if (tkwin == NULL) { return NULL; } @@ -826,6 +871,7 @@ TkCreateMainWindow(interp, screenName, baseName) TkEventInit(); TkBindInit(mainPtr); TkFontPkgInit(mainPtr); + TkStylePkgInit(mainPtr); mainPtr->tlFocusPtr = NULL; mainPtr->displayFocusPtr = NULL; mainPtr->optionRootPtr = NULL; @@ -925,9 +971,9 @@ Tk_CreateWindow(interp, parent, name, screenName) * the interp's result is assumed to be * initialized by the caller. */ Tk_Window parent; /* Token for parent of new window. */ - char *name; /* Name for new window. Must be unique + CONST char *name; /* Name for new window. Must be unique * among parent's children. */ - char *screenName; /* If NULL, new window will be internal on + CONST char *screenName; /* If NULL, new window will be internal on * same screen as its parent. If non-NULL, * gives name of screen on which to create * new window; window will be a top-level @@ -958,7 +1004,79 @@ Tk_CreateWindow(interp, parent, name, screenName) return (Tk_Window) winPtr; } } else { - return CreateTopLevelWindow(interp, parent, name, screenName); + return CreateTopLevelWindow(interp, parent, name, screenName, + /* flags */ 0); + } +} + +/* + *-------------------------------------------------------------- + * + * Tk_CreateAnonymousWindow -- + * + * Create a new internal or top-level window as a child of an + * existing window; this window will be anonymous (unnamed), so + * it will not be visible at the Tcl level. + * + * Results: + * The return value is a token for the new window. This + * is not the same as X's token for the window. If an error + * occurred in creating the window (e.g. no such display or + * screen), then an error message is left in the interp's result and + * NULL is returned. + * + * Side effects: + * A new window structure is allocated locally. An X + * window is not initially created, but will be created + * the first time the window is mapped. + * + *-------------------------------------------------------------- + */ + +Tk_Window +Tk_CreateAnonymousWindow(interp, parent, screenName) + Tcl_Interp *interp; /* Interpreter to use for error reporting. + * the interp's result is assumed to be + * initialized by the caller. */ + Tk_Window parent; /* Token for parent of new window. */ + CONST char *screenName; /* If NULL, new window will be internal on + * same screen as its parent. If non-NULL, + * gives name of screen on which to create + * new window; window will be a top-level + * window. */ +{ + TkWindow *parentPtr = (TkWindow *) parent; + TkWindow *winPtr; + + if ((parentPtr != NULL) && (parentPtr->flags & TK_ALREADY_DEAD)) { + Tcl_AppendResult(interp, + "can't create window: parent has been destroyed", + (char *) NULL); + return NULL; + } else if ((parentPtr != NULL) && + (parentPtr->flags & TK_CONTAINER)) { + Tcl_AppendResult(interp, + "can't create window: its parent has -container = yes", + (char *) NULL); + return NULL; + } + if (screenName == NULL) { + winPtr = TkAllocWindow(parentPtr->dispPtr, parentPtr->screenNum, + parentPtr); + /* + * Add the anonymous window flag now, so that NameWindow will behave + * correctly. + */ + + winPtr->flags |= TK_ANONYMOUS_WINDOW; + if (NameWindow(interp, winPtr, parentPtr, (char *)NULL) != TCL_OK) { + Tk_DestroyWindow((Tk_Window) winPtr); + return NULL; + } + return (Tk_Window) winPtr; + } else { + return CreateTopLevelWindow(interp, parent, (char *)NULL, screenName, + TK_ANONYMOUS_WINDOW); } } @@ -993,11 +1111,11 @@ Tk_CreateWindowFromPath(interp, tkwin, pathName, screenName) * initialized by the caller. */ Tk_Window tkwin; /* Token for any window in application * that is to contain new window. */ - char *pathName; /* Path name for new window within the + CONST char *pathName; /* Path name for new window within the * application of tkwin. The parent of * this window must already exist, but * the window itself must not exist. */ - char *screenName; /* If NULL, new window will be on same + CONST char *screenName; /* If NULL, new window will be on same * screen as its parent. If non-NULL, * gives name of screen on which to create * new window; window will be a top-level @@ -1024,7 +1142,7 @@ Tk_CreateWindowFromPath(interp, tkwin, pathName, screenName) "\"", (char *) NULL); return NULL; } - numChars = p-pathName; + numChars = (int) (p-pathName); if (numChars > FIXED_SPACE) { p = (char *) ckalloc((unsigned) (numChars+1)); } else { @@ -1079,7 +1197,7 @@ Tk_CreateWindowFromPath(interp, tkwin, pathName, screenName) } } else { return CreateTopLevelWindow(interp, parent, pathName+numChars+1, - screenName); + screenName, /* flags */ 0); } } @@ -1151,7 +1269,7 @@ Tk_DestroyWindow(tkwin) * can be closed and its data structures deleted. */ - if (winPtr->mainPtr->winPtr == winPtr) { + if (winPtr->mainPtr != NULL && winPtr->mainPtr->winPtr == winPtr) { dispPtr->refCount--; if (tsdPtr->mainWindowList == winPtr->mainPtr) { tsdPtr->mainWindowList = winPtr->mainPtr->nextPtr; @@ -1218,12 +1336,13 @@ Tk_DestroyWindow(tkwin) * expensive, but without it no event handlers will get called for * windows that don't exist yet. * - * Note: if the window's pathName is NULL it means that the window - * was not successfully initialized in the first place, so we should - * not make the window exist or generate the event. + * Note: if the window's pathName is NULL and the window is not an + * anonymous window, it means that the window was not successfully + * initialized in the first place, so we should not make the window exist + * or generate the event. */ - if (winPtr->pathName != NULL) { + if (winPtr->pathName != NULL && !(winPtr->flags & TK_ANONYMOUS_WINDOW)) { if (winPtr->window == None) { Tk_MakeWindowExist(tkwin); } @@ -1241,16 +1360,16 @@ Tk_DestroyWindow(tkwin) * Cleanup the data structures associated with this window. */ - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_WIN_MANAGED) { TkWmDeadWindow(winPtr); } else if (winPtr->flags & TK_WM_COLORMAP_WINDOW) { TkWmRemoveFromColormapWindows(winPtr); } if (winPtr->window != None) { -#if defined(MAC_TCL) || defined(__WIN32__) +#if defined(MAC_TCL) || defined(MAC_OSX_TK) || defined(__WIN32__) XDestroyWindow(winPtr->display, winPtr->window); #else - if ((winPtr->flags & TK_TOP_LEVEL) + if ((winPtr->flags & TK_TOP_HIERARCHY) || !(winPtr->flags & TK_DONT_DESTROY_WINDOW)) { /* * The parent has already been destroyed and this isn't @@ -1276,6 +1395,7 @@ Tk_DestroyWindow(tkwin) #ifdef TK_USE_INPUT_METHODS if (winPtr->inputContext != NULL) { XDestroyIC(winPtr->inputContext); + winPtr->inputContext = NULL; } #endif /* TK_USE_INPUT_METHODS */ if (winPtr->tagPtr != NULL) { @@ -1290,6 +1410,17 @@ Tk_DestroyWindow(tkwin) (ClientData) winPtr->pathName); Tcl_DeleteHashEntry(Tcl_FindHashEntry(&winPtr->mainPtr->nameTable, winPtr->pathName)); + /* + * The memory pointed to by pathName has been deallocated. + * Keep users from accessing it after the window has been + * destroyed by setting it to NULL. + */ + winPtr->pathName = NULL; + + /* + * Invalidate all objects referring to windows on this display. + */ + dispPtr->deletionEpoch++; } winPtr->mainPtr->refCount--; if (winPtr->mainPtr->refCount == 0) { @@ -1298,12 +1429,12 @@ Tk_DestroyWindow(tkwin) /* * We just deleted the last window in the application. Delete * the TkMainInfo structure too and replace all of Tk's commands - * with dummy commands that return errors. Also delete the + * with dummy commands that return errors. Also delete the * "send" command to unregister the interpreter. - * - * NOTE: Only replace the commands it if the interpreter is - * not being deleted. If it *is*, the interpreter cleanup will - * do all the needed work. + * + * NOTE: Only replace the commands it if the interpreter is + * not being deleted. If it *is*, the interpreter cleanup will + * do all the needed work. */ if ((winPtr->mainPtr->interp != NULL) && @@ -1323,6 +1454,8 @@ Tk_DestroyWindow(tkwin) TkBindFree(winPtr->mainPtr); TkDeleteAllImages(winPtr->mainPtr); TkFontPkgFree(winPtr->mainPtr); + TkFocusFree(winPtr->mainPtr); + TkStylePkgFree(winPtr->mainPtr); /* * When embedding Tk into other applications, make sure @@ -1332,7 +1465,7 @@ Tk_DestroyWindow(tkwin) */ if (winPtr->flags & TK_EMBEDDED) { - XSync(winPtr->display,False) ; + XSync(winPtr->display, False); } ckfree((char *) winPtr->mainPtr); @@ -1340,15 +1473,22 @@ Tk_DestroyWindow(tkwin) * If no other applications are using the display, close the * display now and relinquish its data structures. */ - + +#if !defined(WIN32) && !defined(MAC_TCL) && defined(NOT_YET) if (dispPtr->refCount <= 0) { -#ifdef NOT_YET /* * I have disabled this code because on Windows there are * still order dependencies in close-down. All displays * and resources will get closed down properly anyway at - * exit, through the exit handler. + * exit, through the exit handler. -- jyl */ + /* + * Ideally this should be enabled, as unix Tk can use multiple + * displays. However, there are order issues still, as well + * as the handling of queued events and such that must be + * addressed before this can be enabled. The current cleanup + * works except for send event issues. -- hobbs 04/2002 + */ TkDisplay *theDispPtr, *backDispPtr; @@ -1356,7 +1496,7 @@ Tk_DestroyWindow(tkwin) * Splice this display out of the list of displays. */ - for (theDispPtr = displayList, backDispPtr = NULL; + for (theDispPtr = tsdPtr->displayList, backDispPtr = NULL; (theDispPtr != winPtr->dispPtr) && (theDispPtr != NULL); theDispPtr = theDispPtr->nextPtr) { @@ -1366,39 +1506,27 @@ Tk_DestroyWindow(tkwin) panic("could not find display to close!"); } if (backDispPtr == NULL) { - displayList = theDispPtr->nextPtr; + tsdPtr->displayList = theDispPtr->nextPtr; } else { backDispPtr->nextPtr = theDispPtr->nextPtr; } - - /* - * Found and spliced it out, now actually do the cleanup. - */ - - if (dispPtr->name != NULL) { - ckfree(dispPtr->name); - } - - Tcl_DeleteHashTable(&(dispPtr->winTable)); - - /* - * Cannot yet close the display because we still have - * order of deletion problems. Defer until exit handling - * instead. At that time, the display will cleanly shut - * down (hopefully..). (JYL) - */ - TkpCloseDisplay(dispPtr); + /* + * Calling XSync creates X server traffic, but addresses a + * focus issue on close (but not the send issue). -- hobbs + XSync(dispPtr->display, True); + */ /* - * There is lots more to clean up, we leave it at this for - * the time being. + * Found and spliced it out, now actually do the cleanup. */ -#endif + + TkCloseDisplay(dispPtr); } +#endif } } - ckfree((char *) winPtr); + Tcl_EventuallyFree((ClientData) winPtr, TCL_DYNAMIC); } /* @@ -1423,7 +1551,7 @@ void Tk_MapWindow(tkwin) Tk_Window tkwin; /* Token for window to map. */ { - register TkWindow *winPtr = (TkWindow *) tkwin; + TkWindow *winPtr = (TkWindow *) tkwin; XEvent event; if (winPtr->flags & TK_MAPPED) { @@ -1432,7 +1560,7 @@ Tk_MapWindow(tkwin) if (winPtr->window == None) { Tk_MakeWindowExist(tkwin); } - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_WIN_MANAGED) { /* * Lots of special processing has to be done for top-level * windows. Let tkWm.c handle everything itself. @@ -1482,13 +1610,14 @@ Tk_MakeWindowExist(tkwin) TkWindow *winPtr2; Window parent; Tcl_HashEntry *hPtr; + Tk_ClassCreateProc *createProc; int new; if (winPtr->window != None) { return; } - if ((winPtr->parentPtr == NULL) || (winPtr->flags & TK_TOP_LEVEL)) { + if ((winPtr->parentPtr == NULL) || (winPtr->flags & TK_TOP_HIERARCHY)) { parent = XRootWindow(winPtr->display, winPtr->screenNum); } else { if (winPtr->parentPtr->window == None) { @@ -1497,10 +1626,9 @@ Tk_MakeWindowExist(tkwin) parent = winPtr->parentPtr->window; } - if (winPtr->classProcsPtr != NULL - && winPtr->classProcsPtr->createProc != NULL) { - winPtr->window = (*winPtr->classProcsPtr->createProc)(tkwin, parent, - winPtr->instanceData); + createProc = Tk_GetClassProc(winPtr->classProcsPtr, createProc); + if (createProc != NULL) { + winPtr->window = (*createProc)(tkwin, parent, winPtr->instanceData); } else { winPtr->window = TkpMakeWindow(winPtr, parent); } @@ -1510,11 +1638,8 @@ Tk_MakeWindowExist(tkwin) Tcl_SetHashValue(hPtr, winPtr); winPtr->dirtyAtts = 0; winPtr->dirtyChanges = 0; -#ifdef TK_USE_INPUT_METHODS - winPtr->inputContext = NULL; -#endif /* TK_USE_INPUT_METHODS */ - if (!(winPtr->flags & TK_TOP_LEVEL)) { + if (!(winPtr->flags & TK_TOP_HIERARCHY)) { /* * If any siblings higher up in the stacking order have already * been created then move this window to its rightful position @@ -1529,7 +1654,7 @@ Tk_MakeWindowExist(tkwin) for (winPtr2 = winPtr->nextPtr; winPtr2 != NULL; winPtr2 = winPtr2->nextPtr) { if ((winPtr2->window != None) - && !(winPtr2->flags & (TK_TOP_LEVEL|TK_REPARENTED))) { + && !(winPtr2->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))) { XWindowChanges changes; changes.sibling = winPtr2->window; changes.stack_mode = Below; @@ -1559,7 +1684,7 @@ Tk_MakeWindowExist(tkwin) */ if ((winPtr->flags & TK_NEED_CONFIG_NOTIFY) - && !(winPtr->flags & TK_ALREADY_DEAD)){ + && !(winPtr->flags & TK_ALREADY_DEAD)) { winPtr->flags &= ~TK_NEED_CONFIG_NOTIFY; TkDoConfigureNotify(winPtr); } @@ -1595,7 +1720,7 @@ Tk_UnmapWindow(tkwin) if (!(winPtr->flags & TK_MAPPED) || (winPtr->flags & TK_ALREADY_DEAD)) { return; } - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_WIN_MANAGED) { /* * Special processing has to be done for top-level windows. Let * tkWm.c handle everything itself. @@ -1606,7 +1731,7 @@ Tk_UnmapWindow(tkwin) } winPtr->flags &= ~TK_MAPPED; XUnmapWindow(winPtr->display, winPtr->window); - if (!(winPtr->flags & TK_TOP_LEVEL)) { + if (!(winPtr->flags & TK_TOP_HIERARCHY)) { XEvent event; event.type = UnmapNotify; @@ -1884,7 +2009,7 @@ Tk_DefineCursor(tkwin, cursor) { register TkWindow *winPtr = (TkWindow *) tkwin; -#ifdef MAC_TCL +#if defined(MAC_TCL) || defined(MAC_OSX_TK) winPtr->atts.cursor = (XCursor) cursor; #else winPtr->atts.cursor = (Cursor) cursor; @@ -1915,7 +2040,7 @@ Tk_SetWindowColormap(tkwin, colormap) if (winPtr->window != None) { XSetWindowColormap(winPtr->display, winPtr->window, colormap); - if (!(winPtr->flags & TK_TOP_LEVEL)) { + if (!(winPtr->flags & TK_WIN_MANAGED)) { TkWmAddToColormapWindows(winPtr); winPtr->flags |= TK_WM_COLORMAP_WINDOW; } @@ -2039,12 +2164,12 @@ TkDoConfigureNotify(winPtr) void Tk_SetClass(tkwin, className) Tk_Window tkwin; /* Token for window to assign class. */ - char *className; /* New class for tkwin. */ + CONST char *className; /* New class for tkwin. */ { register TkWindow *winPtr = (TkWindow *) tkwin; winPtr->classUid = Tk_GetUid(className); - if (winPtr->flags & TK_TOP_LEVEL) { + if (winPtr->flags & TK_WIN_MANAGED) { TkWmSetClass(winPtr); } TkOptionClassChanged(winPtr); @@ -2053,7 +2178,7 @@ Tk_SetClass(tkwin, className) /* *---------------------------------------------------------------------- * - * TkSetClassProcs -- + * Tk_SetClassProcs -- * * This procedure is used to set the class procedures and * instance data for a window. @@ -2069,9 +2194,9 @@ Tk_SetClass(tkwin, className) */ void -TkSetClassProcs(tkwin, procs, instanceData) +Tk_SetClassProcs(tkwin, procs, instanceData) Tk_Window tkwin; /* Token for window to modify. */ - TkClassProcs *procs; /* Class procs structure. */ + Tk_ClassProcs *procs; /* Class procs structure. */ ClientData instanceData; /* Data to be passed to class procedures. */ { register TkWindow *winPtr = (TkWindow *) tkwin; @@ -2103,7 +2228,7 @@ TkSetClassProcs(tkwin, procs, instanceData) Tk_Window Tk_NameToWindow(interp, pathName, tkwin) Tcl_Interp *interp; /* Where to report errors. */ - char *pathName; /* Path name of window. */ + CONST char *pathName; /* Path name of window. */ Tk_Window tkwin; /* Token for window: name is assumed to * belong to the same main window as tkwin. */ { @@ -2189,7 +2314,7 @@ Tk_IdToWindow(display, window) *---------------------------------------------------------------------- */ -char * +CONST char * Tk_DisplayName(tkwin) Tk_Window tkwin; /* Window whose display name is desired. */ { @@ -2280,8 +2405,8 @@ Tk_RestackWindow(tkwin, aboveBelow, other) * otherPtr without changing any of Tk's childLists. */ - if (winPtr->flags & TK_TOP_LEVEL) { - while ((otherPtr != NULL) && !(otherPtr->flags & TK_TOP_LEVEL)) { + if (winPtr->flags & TK_WIN_MANAGED) { + while ((otherPtr != NULL) && !(otherPtr->flags & TK_TOP_HIERARCHY)) { otherPtr = otherPtr->parentPtr; } TkWmRestackToplevel(winPtr, aboveBelow, otherPtr); @@ -2307,7 +2432,7 @@ Tk_RestackWindow(tkwin, aboveBelow, other) } } else { while (winPtr->parentPtr != otherPtr->parentPtr) { - if ((otherPtr == NULL) || (otherPtr->flags & TK_TOP_LEVEL)) { + if ((otherPtr == NULL) || (otherPtr->flags & TK_TOP_HIERARCHY)) { return TCL_ERROR; } otherPtr = otherPtr->parentPtr; @@ -2359,7 +2484,7 @@ Tk_RestackWindow(tkwin, aboveBelow, other) for (otherPtr = winPtr->nextPtr; otherPtr != NULL; otherPtr = otherPtr->nextPtr) { if ((otherPtr->window != None) - && !(otherPtr->flags & (TK_TOP_LEVEL|TK_REPARENTED))){ + && !(otherPtr->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))){ changes.sibling = otherPtr->window; changes.stack_mode = Below; mask = CWStackMode|CWSibling; @@ -2396,8 +2521,18 @@ Tk_MainWindow(interp) * reporting also. */ { TkMainInfo *mainPtr; - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + ThreadSpecificData *tsdPtr; + + if (interp == NULL) { + return NULL; + } +#ifdef USE_TCL_STUBS + if (tclStubsPtr == NULL) { + return NULL; + } +#endif + tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); for (mainPtr = tsdPtr->mainWindowList; mainPtr != NULL; mainPtr = mainPtr->nextPtr) { @@ -2437,65 +2572,6 @@ Tk_StrictMotif(tkwin) return ((TkWindow *) tkwin)->mainPtr->strictMotif; } -/* - *-------------------------------------------------------------- - * - * OpenIM -- - * - * Tries to open an X input method, associated with the - * given display. Right now we can only deal with a bare-bones - * input style: no preedit, and no status. - * - * Results: - * Stores the input method in dispPtr->inputMethod; if there isn't - * a suitable input method, then NULL is stored in dispPtr->inputMethod. - * - * Side effects: - * An input method gets opened. - * - *-------------------------------------------------------------- - */ - -static void -OpenIM(dispPtr) - TkDisplay *dispPtr; /* Tk's structure for the display. */ -{ -#ifndef TK_USE_INPUT_METHODS - return; -#else - unsigned short i; - XIMStyles *stylePtr; - - dispPtr->inputMethod = XOpenIM(dispPtr->display, NULL, NULL, NULL); - if (dispPtr->inputMethod == NULL) { - return; - } - - if ((XGetIMValues(dispPtr->inputMethod, XNQueryInputStyle, &stylePtr, - NULL) != NULL) || (stylePtr == NULL)) { - goto error; - } - for (i = 0; i < stylePtr->count_styles; i++) { - if (stylePtr->supported_styles[i] - == (XIMPreeditNothing|XIMStatusNothing)) { - XFree(stylePtr); - return; - } - } - XFree(stylePtr); - - error: - - /* - * Should close the input method, but this causes core dumps on some - * systems (e.g. Solaris 2.3 as of 1/6/95). - * XCloseIM(dispPtr->inputMethod); - */ - dispPtr->inputMethod = NULL; - return; -#endif /* TK_USE_INPUT_METHODS */ -} - /* *---------------------------------------------------------------------- * @@ -2516,8 +2592,16 @@ OpenIM(dispPtr) int Tk_GetNumMainWindows() { - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + ThreadSpecificData *tsdPtr; + +#ifdef USE_TCL_STUBS + if (tclStubsPtr == NULL) { + return 0; + } +#endif + + tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); return tsdPtr->numMainWindows; } @@ -2543,11 +2627,11 @@ static void DeleteWindowsExitProc(clientData) ClientData clientData; /* Not used. */ { - TkDisplay *displayPtr, *nextPtr; + TkDisplay *dispPtr, *nextPtr; Tcl_Interp *interp; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - + while (tsdPtr->mainWindowList != NULL) { /* * We must protect the interpreter while deleting the window, @@ -2561,21 +2645,17 @@ DeleteWindowsExitProc(clientData) Tk_DestroyWindow((Tk_Window) tsdPtr->mainWindowList->winPtr); Tcl_Release((ClientData) interp); } - - displayPtr = tsdPtr->displayList; - tsdPtr->displayList = NULL; - + /* * Iterate destroying the displays until no more displays remain. * It is possible for displays to get recreated during exit by any * code that calls GetScreen, so we must destroy these new displays * as well as the old ones. */ - - for (displayPtr = tsdPtr->displayList; - displayPtr != NULL; - displayPtr = tsdPtr->displayList) { + for (dispPtr = tsdPtr->displayList; + dispPtr != NULL; + dispPtr = tsdPtr->displayList) { /* * Now iterate over the current list of open displays, and first * set the global pointer to NULL so we will be able to notice if @@ -2584,18 +2664,14 @@ DeleteWindowsExitProc(clientData) * the old display as it is being destroyed, when it wants to see * if it needs to dispatch a message. */ - - for (tsdPtr->displayList = NULL; displayPtr != NULL; - displayPtr = nextPtr) { - nextPtr = displayPtr->nextPtr; - if (displayPtr->name != (char *) NULL) { - ckfree(displayPtr->name); - } - Tcl_DeleteHashTable(&(displayPtr->winTable)); - TkpCloseDisplay(displayPtr); + + for (tsdPtr->displayList = NULL; dispPtr != NULL; + dispPtr = nextPtr) { + nextPtr = dispPtr->nextPtr; + TkCloseDisplay(dispPtr); } } - + tsdPtr->numMainWindows = 0; tsdPtr->mainWindowList = NULL; tsdPtr->initialized = 0; @@ -2665,8 +2741,8 @@ Tk_SafeInit(interp) * - Continuous ringing of the bell is a nuisance. * - Cannot allow access to the clipboard because a malicious script * can replace the contents with the string "rm -r *" and lead to - * surprises when the contents of the clipboard are pasted. We do - * not currently hide the selection command.. Should we? + * surprises when the contents of the clipboard are pasted. Similarly, + * the selection command is blocked. * - Cannot allow send because it can be used to cause unsafe * interpreters to execute commands. The tk command recreates the * send command, so that too must be hidden. @@ -2719,7 +2795,9 @@ Initialize(interp) { char *p; int argc, code; - char **argv, *args[20]; + CONST char **argv; + char *args[20]; + CONST char *argString = NULL; Tcl_DString class; ThreadSpecificData *tsdPtr; @@ -2732,6 +2810,11 @@ Initialize(interp) return TCL_ERROR; } + /* + * Ensure that our obj-types are registered with the Tcl runtime. + */ + TkRegisterObjTypes(); + tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -2824,7 +2907,7 @@ Initialize(interp) * cross interp refcounting and changing the code below. */ - p = Tcl_GetStringResult(master); + argString = Tcl_GetStringResult(master); } else { /* * If there is an "argv" variable, get its value, extract out @@ -2832,13 +2915,13 @@ Initialize(interp) * the arguments that we used. */ - p = Tcl_GetVar2(interp, "argv", (char *) NULL, TCL_GLOBAL_ONLY); + argString = Tcl_GetVar2(interp, "argv", (char *) NULL, TCL_GLOBAL_ONLY); } argv = NULL; - if (p != NULL) { + if (argString != NULL) { char buffer[TCL_INTEGER_SPACE]; - if (Tcl_SplitList(interp, p, &argc, &argv) != TCL_OK) { + if (Tcl_SplitList(interp, argString, &argc, &argv) != TCL_OK) { argError: Tcl_AddErrorInfo(interp, "\n (processing arguments in argv variable)"); @@ -2961,6 +3044,16 @@ Initialize(interp) code = Tcl_PkgProvideEx(interp, "Tk", TK_VERSION, (ClientData) &tkStubs); if (code != TCL_OK) { goto done; + } else { + /* + * If we were able to provide ourselves as a package, then set + * the main loop procedure in Tcl to our main loop proc. This + * will cause tclsh to be event-aware when Tk is dynamically + * loaded. This will have no effect in wish, which already is + * prepared to run the event loop. + */ + + Tcl_SetMainLoop(Tk_MainLoop); } #ifdef Tk_InitStubs @@ -2981,5 +3074,3 @@ Initialize(interp) } return code; } - - diff --git a/tk/library/bgerror.tcl b/tk/library/bgerror.tcl index e5f47f324a9..1407b55c4bf 100644 --- a/tk/library/bgerror.tcl +++ b/tk/library/bgerror.tcl @@ -1,19 +1,79 @@ # bgerror.tcl -- # -# This file contains a default version of the bgerror procedure. It -# posts a dialog box with the error message and gives the user a chance -# to see a more detailed stack trace. +# Implementation of the bgerror procedure. It posts a dialog box with +# the error message and gives the user a chance to see a more detailed +# stack trace, and possible do something more interesting with that +# trace (like save it to a log). This is adapted from work done by +# Donal K. Fellows. # +# Copyright (c) 1998-2000 by Ajuba Solutions. +# All rights reserved. +# # RCS: @(#) $Id$ -# -# Copyright (c) 1992-1994 The Regents of the University of California. -# Copyright (c) 1994-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. +# $Id$ +namespace eval ::tk { + namespace eval dialog { + namespace eval error { + namespace import ::tk::msgcat::* + namespace export bgerror + option add *ErrorDialog.function.text [mc "Save To Log"] \ + widgetDefault + option add *ErrorDialog.function.command [namespace code SaveToLog] + } + } +} -# bgerror -- +proc ::tk::dialog::error::Return {} { + variable button + + .bgerrorDialog.ok configure -state active -relief sunken + update idletasks + after 100 + set button 0 +} + +proc ::tk::dialog::error::Details {} { + set w .bgerrorDialog + set caption [option get $w.function text {}] + set command [option get $w.function command {}] + if { ($caption eq "") || ($command eq "") } { + grid forget $w.function + } + $w.function configure -text $caption -command \ + "$command [list [.bgerrorDialog.top.info.text get 1.0 end]]" + grid $w.top.info - -sticky nsew -padx 3m -pady 3m +} + +proc ::tk::dialog::error::SaveToLog {text} { + if { $::tcl_platform(platform) eq "windows" } { + set allFiles *.* + } else { + set allFiles * + } + set types [list \ + [list [mc "Log Files"] .log] \ + [list [mc "Text Files"] .txt] \ + [list [mc "All Files"] $allFiles] \ + ] + set filename [tk_getSaveFile -title [mc "Select Log File"] \ + -filetypes $types -defaultextension .log -parent .bgerrorDialog] + if {![string length $filename]} { + return + } + set f [open $filename w] + puts -nonewline $f $text + close $f +} + +proc ::tk::dialog::error::Destroy {w} { + if {$w eq ".bgerrorDialog"} { + variable button + set button -1 + } +} + +# ::tk::dialog::error::bgerror -- # This is the default version of bgerror. # It tries to execute tkerror, if that fails it posts a dialog box containing # the error message and gives the user a chance to ask to see a stack @@ -21,82 +81,212 @@ # Arguments: # err - The error message. -proc bgerror err { +proc ::tk::dialog::error::bgerror err { global errorInfo tcl_platform - - # save errorInfo which would be erased in the catch below otherwise. - set info $errorInfo ; - - # For backward compatibility : - # Let's try to execute "tkerror" (using catch {tkerror ...} - # instead of searching it with info procs so the application gets - # a chance to auto load it using its favorite "unknown" mecanism. - # (we do the default dialog only if we get a TCL_ERROR (=1) return - # code from the tkerror trial, other ret codes are passed back - # to our caller (tcl background error handler) so the called "tkerror" - # can still use return -code break, to skip remaining messages - # in the error queue for instance) - - set ret [catch {tkerror $err} msg]; + variable button + + set info $errorInfo + + set ret [catch {::tkerror $err} msg]; if {$ret != 1} {return -code $ret $msg} # Ok the application's tkerror either failed or was not found # we use the default dialog then : - if {$tcl_platform(platform) == "macintosh"} { - set ok Ok + if {($tcl_platform(platform) eq "macintosh") + || ([tk windowingsystem] eq "aqua")} { + set ok [mc Ok] + set messageFont system + set textRelief flat + set textHilight 0 } else { - set ok OK + set ok [mc OK] + set messageFont {Times -18} + set textRelief sunken + set textHilight 1 } - set button [tk_dialog .bgerrorDialog "Error in Tcl Script" \ - "Error: $err" error 0 $ok "Skip Messages" "Stack Trace"] - if {$button == 0} { - return - } elseif {$button == 1} { - return -code break + + + # Truncate the message if it is too wide (longer than 30 characacters) or + # too tall (more than 4 newlines). Truncation occurs at the first point at + # which one of those conditions is met. + set displayedErr "" + set lines 0 + foreach line [split $err \n] { + if { [string length $line] > 30 } { + append displayedErr "[string range $line 0 29]..." + break + } + if { $lines > 4 } { + append displayedErr "..." + break + } else { + append displayedErr "${line}\n" + } + incr lines + } + + set w .bgerrorDialog + set title [mc "Application Error"] + set text [mc {Error: %1$s} $err] + set buttons [list ok $ok dismiss [mc "Skip Messages"] \ + function [mc "Details >>"]] + + # 1. Create the top-level window and divide it into top + # and bottom parts. + + catch {destroy .bgerrorDialog} + toplevel .bgerrorDialog -class ErrorDialog + wm title .bgerrorDialog $title + wm iconname .bgerrorDialog ErrorDialog + wm protocol .bgerrorDialog WM_DELETE_WINDOW { } + + if {($tcl_platform(platform) eq "macintosh") + || ([tk windowingsystem] eq "aqua")} { + ::tk::unsupported::MacWindowStyle style .bgerrorDialog dBoxProc } - set w .bgerrorTrace - catch {destroy $w} - toplevel $w -class ErrorTrace - wm minsize $w 1 1 - wm title $w "Stack Trace for Error" - wm iconname $w "Stack Trace" - button $w.ok -text OK -command "destroy $w" -default active - if {![string compare $tcl_platform(platform) "macintosh"]} { - text $w.text -relief flat -bd 2 -highlightthickness 0 -setgrid true \ - -yscrollcommand "$w.scroll set" -width 60 -height 20 + frame .bgerrorDialog.bot + frame .bgerrorDialog.top + if {[tk windowingsystem] eq "x11"} { + .bgerrorDialog.bot configure -relief raised -bd 1 + .bgerrorDialog.top configure -relief raised -bd 1 + } + pack .bgerrorDialog.bot -side bottom -fill both + pack .bgerrorDialog.top -side top -fill both -expand 1 + + set W [frame $w.top.info] + text $W.text \ + -bd 2 \ + -yscrollcommand [list $W.scroll set]\ + -setgrid true \ + -width 40 \ + -height 10 \ + -state normal \ + -relief $textRelief \ + -highlightthickness $textHilight \ + -wrap char + + scrollbar $W.scroll -relief sunken -command [list $W.text yview] + pack $W.scroll -side right -fill y + 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 { focus %W } + $W.text configure -state disabled + + # 2. Fill the top part with bitmap and message + + # Max-width of message is the width of the screen... + set wrapwidth [winfo screenwidth .bgerrorDialog] + # ...minus the width of the icon, padding and a fudge factor for + # the window manager decorations and aesthetics. + set wrapwidth [expr {$wrapwidth-60-[winfo pixels .bgerrorDialog 9m]}] + label .bgerrorDialog.msg -justify left -text $text -font $messageFont \ + -wraplength $wrapwidth + if {($tcl_platform(platform) eq "macintosh") + || ([tk windowingsystem] eq "aqua")} { + # On the Macintosh, use the stop bitmap + label .bgerrorDialog.bitmap -bitmap stop } else { - text $w.text -relief sunken -bd 2 -yscrollcommand "$w.scroll set" \ - -setgrid true -width 60 -height 20 + # On other platforms, make the error icon + canvas .bgerrorDialog.bitmap -width 32 -height 32 -highlightthickness 0 + .bgerrorDialog.bitmap create oval 0 0 31 31 -fill red -outline black + .bgerrorDialog.bitmap create line 9 9 23 23 -fill white -width 4 + .bgerrorDialog.bitmap create line 9 23 23 9 -fill white -width 4 } - scrollbar $w.scroll -relief sunken -command "$w.text yview" - pack $w.ok -side bottom -padx 3m -pady 2m - pack $w.scroll -side right -fill y - pack $w.text -side left -expand yes -fill both - $w.text insert 0.0 $info - $w.text mark set insert 0.0 + grid .bgerrorDialog.bitmap .bgerrorDialog.msg \ + -in .bgerrorDialog.top \ + -row 0 \ + -padx 3m \ + -pady 3m + grid configure .bgerrorDialog.msg -sticky nsw -padx {0 3m} + grid rowconfigure .bgerrorDialog.top 1 -weight 1 + grid columnconfigure .bgerrorDialog.top 1 -weight 1 - bind $w "destroy $w" - bind $w.text "destroy $w; break" + # 3. Create a row of buttons at the bottom of the dialog. - # Center the window on the screen. + set i 0 + foreach {name caption} $buttons { + button .bgerrorDialog.$name \ + -text $caption \ + -default normal \ + -command [namespace code "set button $i"] + grid .bgerrorDialog.$name \ + -in .bgerrorDialog.bot \ + -column $i \ + -row 0 \ + -sticky ew \ + -padx 10 + grid columnconfigure .bgerrorDialog.bot $i -weight 1 + # We boost the size of some Mac buttons for l&f + if {($tcl_platform(platform) eq "macintosh") + || ([tk windowingsystem] eq "aqua")} { + if {($name eq "ok") || ($name eq "dismiss")} { + grid columnconfigure .bgerrorDialog.bot $i -minsize 79 + } + } + incr i + } + # The "OK" button is the default for this dialog. + .bgerrorDialog.ok configure -default active - wm withdraw $w + bind .bgerrorDialog [namespace code Return] + bind .bgerrorDialog [namespace code [list Destroy %W]] + .bgerrorDialog.function configure -command [namespace code Details] + + # 6. Withdraw the window, then update all the geometry information + # so we know how big it wants to be, then center the window in the + # display and de-iconify it. + + wm withdraw .bgerrorDialog update idletasks - set x [expr {[winfo screenwidth $w]/2 - [winfo reqwidth $w]/2 \ - - [winfo vrootx [winfo parent $w]]}] - set y [expr {[winfo screenheight $w]/2 - [winfo reqheight $w]/2 \ - - [winfo vrooty [winfo parent $w]]}] - wm geom $w +$x+$y - wm deiconify $w - - # Be sure to release any grabs that might be present on the - # screen, since they could make it impossible for the user - # to interact with the stack trace. - - if {[string compare [grab current .] ""]} { - grab release [grab current .] + set parent [winfo parent .bgerrorDialog] + set width [winfo reqwidth .bgerrorDialog] + set height [winfo reqheight .bgerrorDialog] + set x [expr {([winfo screenwidth .bgerrorDialog] - $width )/2 - \ + [winfo vrootx $parent]}] + set y [expr {([winfo screenheight .bgerrorDialog] - $height)/2 - \ + [winfo vrooty $parent]}] + .bgerrorDialog configure -width $width + wm geometry .bgerrorDialog +$x+$y + wm deiconify .bgerrorDialog + + # 7. Set a grab and claim the focus too. + + set oldFocus [focus] + set oldGrab [grab current .bgerrorDialog] + if {$oldGrab != ""} { + set grabStatus [grab status $oldGrab] } -} + grab .bgerrorDialog + focus .bgerrorDialog.ok + + # 8. Wait for the user to respond, then restore the focus and + # return the index of the selected button. Restore the focus + # before deleting the window, since otherwise the window manager + # may take the focus away so we can't redirect it. Finally, + # restore any grab that was in effect. + vwait [namespace which -variable button] + set copy $button; # Save a copy... + catch {focus $oldFocus} + catch {destroy .bgerrorDialog} + if {$oldGrab ne ""} { + if {$grabStatus eq "global"} { + grab -global $oldGrab + } else { + grab $oldGrab + } + } + + if {$copy == 1} { + return -code break + } +} +namespace eval :: { + # Fool the indexer + proc bgerror err {} + rename bgerror {} + namespace import ::tk::dialog::error::bgerror +} diff --git a/tk/library/button.tcl b/tk/library/button.tcl index d930aee86ef..d92facfa902 100644 --- a/tk/library/button.tcl +++ b/tk/library/button.tcl @@ -8,6 +8,7 @@ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1996 Sun Microsystems, Inc. +# Copyright (c) 2002 ActiveState Corporation. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -17,122 +18,123 @@ # The code below creates the default class bindings for buttons. #------------------------------------------------------------------------- -if {[string match "macintosh" $tcl_platform(platform)]} { +if {[string equal [tk windowingsystem] "classic"] + || [string equal [tk windowingsystem] "aqua"]} { bind Radiobutton { - tkButtonEnter %W + tk::ButtonEnter %W } bind Radiobutton <1> { - tkButtonDown %W + tk::ButtonDown %W } bind Radiobutton { - tkButtonUp %W + tk::ButtonUp %W } bind Checkbutton { - tkButtonEnter %W + tk::ButtonEnter %W } bind Checkbutton <1> { - tkButtonDown %W + tk::ButtonDown %W } bind Checkbutton { - tkButtonUp %W + tk::ButtonUp %W } } -if {[string match "windows" $tcl_platform(platform)]} { +if {[string equal "windows" $tcl_platform(platform)]} { bind Checkbutton { - tkCheckRadioInvoke %W select + tk::CheckRadioInvoke %W select } bind Checkbutton { - tkCheckRadioInvoke %W select + tk::CheckRadioInvoke %W select } bind Checkbutton { - tkCheckRadioInvoke %W deselect + tk::CheckRadioInvoke %W deselect } bind Checkbutton <1> { - tkCheckRadioDown %W + tk::CheckRadioDown %W } bind Checkbutton { - tkButtonUp %W + tk::ButtonUp %W } bind Checkbutton { - tkCheckRadioEnter %W + tk::CheckRadioEnter %W } bind Radiobutton <1> { - tkCheckRadioDown %W + tk::CheckRadioDown %W } bind Radiobutton { - tkButtonUp %W + tk::ButtonUp %W } bind Radiobutton { - tkCheckRadioEnter %W + tk::CheckRadioEnter %W } } -if {[string match "unix" $tcl_platform(platform)]} { +if {[string equal "x11" [tk windowingsystem]]} { bind Checkbutton { if {!$tk_strictMotif} { - tkCheckRadioInvoke %W + tk::CheckRadioInvoke %W } } bind Radiobutton { if {!$tk_strictMotif} { - tkCheckRadioInvoke %W + tk::CheckRadioInvoke %W } } bind Checkbutton <1> { - tkCheckRadioInvoke %W + tk::CheckRadioInvoke %W } bind Radiobutton <1> { - tkCheckRadioInvoke %W + tk::CheckRadioInvoke %W } bind Checkbutton { - tkButtonEnter %W + tk::ButtonEnter %W } bind Radiobutton { - tkButtonEnter %W + tk::ButtonEnter %W } } bind Button { - tkButtonInvoke %W + tk::ButtonInvoke %W } bind Checkbutton { - tkCheckRadioInvoke %W + tk::CheckRadioInvoke %W } bind Radiobutton { - tkCheckRadioInvoke %W + tk::CheckRadioInvoke %W } bind Button {} bind Button { - tkButtonEnter %W + tk::ButtonEnter %W } bind Button { - tkButtonLeave %W + tk::ButtonLeave %W } bind Button <1> { - tkButtonDown %W + tk::ButtonDown %W } bind Button { - tkButtonUp %W + tk::ButtonUp %W } bind Checkbutton {} bind Checkbutton { - tkButtonLeave %W + tk::ButtonLeave %W } bind Radiobutton {} bind Radiobutton { - tkButtonLeave %W + tk::ButtonLeave %W } -if {[string match "windows" $tcl_platform(platform)]} { +if {[string equal "windows" $tcl_platform(platform)]} { ######################### # Windows implementation ######################### -# tkButtonEnter -- +# ::tk::ButtonEnter -- # The procedure below is invoked when the mouse pointer enters a # button widget. It records the button we're in and changes the # state of the button to active unless the button is disabled. @@ -140,55 +142,54 @@ if {[string match "windows" $tcl_platform(platform)]} { # Arguments: # w - The name of the widget. -proc tkButtonEnter w { - global tkPriv - if {[string compare [$w cget -state] "disabled"] \ - && [string equal $tkPriv(buttonWindow) $w]} { - $w configure -state active -relief sunken +proc ::tk::ButtonEnter w { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + + # If the mouse button is down, set the relief to sunken on entry. + # Overwise, if there's an -overrelief value, set the relief to that. + + set Priv($w,relief) [$w cget -relief] + if {$Priv(buttonWindow) eq $w} { + $w configure -relief sunken -state active + set Priv($w,prelief) sunken + } elseif {[set over [$w cget -overrelief]] ne ""} { + $w configure -relief $over + set Priv($w,prelief) $over + } } - set tkPriv(window) $w + set Priv(window) $w } -# tkButtonLeave -- +# ::tk::ButtonLeave -- # The procedure below is invoked when the mouse pointer leaves a -# button widget. It changes the state of the button back to -# inactive. If we're leaving the button window with a mouse button -# pressed (tkPriv(buttonWindow) == $w), restore the relief of the -# button too. +# button widget. It changes the state of the button back to inactive. +# Restore any modified relief too. # # Arguments: # w - The name of the widget. -proc tkButtonLeave w { - global tkPriv - if {[string compare [$w cget -state] "disabled"]} { +proc ::tk::ButtonLeave w { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { $w configure -state normal } - if {[string equal $tkPriv(buttonWindow) $w]} { - $w configure -relief $tkPriv(relief) - } - set tkPriv(window) "" -} -# tkCheckRadioEnter -- -# The procedure below is invoked when the mouse pointer enters a -# checkbutton or radiobutton widget. It records the button we're in -# and changes the state of the button to active unless the button is -# disabled. -# -# Arguments: -# w - The name of the widget. + # Restore the original button relief if it was changed by Tk. + # That is signaled by the existence of Priv($w,prelief). -proc tkCheckRadioEnter w { - global tkPriv - if {[string compare [$w cget -state] "disabled"] \ - && [string equal $tkPriv(buttonWindow) $w]} { - $w configure -state active + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) } - set tkPriv(window) $w + + set Priv(window) "" } -# tkButtonDown -- +# ::tk::ButtonDown -- # The procedure below is invoked when the mouse button is pressed in # a button widget. It records the fact that the mouse is in the button, # saves the button's relief so it can be restored later, and changes @@ -197,63 +198,124 @@ proc tkCheckRadioEnter w { # Arguments: # w - The name of the widget. -proc tkButtonDown w { - global tkPriv - set tkPriv(relief) [$w cget -relief] - if {[string compare [$w cget -state] "disabled"]} { - set tkPriv(buttonWindow) $w +proc ::tk::ButtonDown w { + variable ::tk::Priv + + # Only save the button's relief if it does not yet exist. If there + # is an overrelief setting, Priv($w,relief) will already have been set, + # and the current value of the -relief option will be incorrect. + + if {![info exists Priv($w,relief)]} { + set Priv($w,relief) [$w cget -relief] + } + + if {[$w cget -state] ne "disabled"} { + set Priv(buttonWindow) $w $w configure -relief sunken -state active + set Priv($w,prelief) sunken + + # If this button has a repeatdelay set up, get it going with an after + after cancel $Priv(afterId) + set delay [$w cget -repeatdelay] + set Priv(repeated) 0 + if {$delay > 0} { + set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]] + } } } -# tkCheckRadioDown -- -# The procedure below is invoked when the mouse button is pressed in -# a button widget. It records the fact that the mouse is in the button, -# saves the button's relief so it can be restored later, and changes -# the relief to sunken. +# ::tk::ButtonUp -- +# The procedure below is invoked when the mouse button is released +# in a button widget. It restores the button's relief and invokes +# the command as long as the mouse hasn't left the button. # # Arguments: # w - The name of the widget. -proc tkCheckRadioDown w { - global tkPriv - set tkPriv(relief) [$w cget -relief] - if {[string compare [$w cget -state] "disabled"]} { - set tkPriv(buttonWindow) $w - $w configure -state active +proc ::tk::ButtonUp w { + variable ::tk::Priv + if {$Priv(buttonWindow) eq $w} { + set Priv(buttonWindow) "" + + # Restore the button's relief if it was cached. + + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) + } + + # Clean up the after event from the auto-repeater + after cancel $Priv(afterId) + + if {$Priv(window) eq $w && [$w cget -state] ne "disabled"} { + $w configure -state normal + + # Only invoke the command if it wasn't already invoked by the + # auto-repeater functionality + if { $Priv(repeated) == 0 } { + uplevel #0 [list $w invoke] + } + } } } -# tkButtonUp -- -# The procedure below is invoked when the mouse button is released -# in a button widget. It restores the button's relief and invokes -# the command as long as the mouse hasn't left the button. +# ::tk::CheckRadioEnter -- +# The procedure below is invoked when the mouse pointer enters a +# checkbutton or radiobutton widget. It records the button we're in +# and changes the state of the button to active unless the button is +# disabled. # # Arguments: # w - The name of the widget. -proc tkButtonUp w { - global tkPriv - if {[string equal $tkPriv(buttonWindow) $w]} { - set tkPriv(buttonWindow) "" - $w configure -relief $tkPriv(relief) - if {[string equal $tkPriv(window) $w] - && [string compare [$w cget -state] "disabled"]} { - $w configure -state normal - uplevel #0 [list $w invoke] +proc ::tk::CheckRadioEnter w { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + if {$Priv(buttonWindow) eq $w} { + $w configure -state active + } + if {[set over [$w cget -overrelief]] ne ""} { + set Priv($w,relief) [$w cget -relief] + set Priv($w,prelief) $over + $w configure -relief $over } } + set Priv(window) $w +} + +# ::tk::CheckRadioDown -- +# The procedure below is invoked when the mouse button is pressed in +# a button widget. It records the fact that the mouse is in the button, +# saves the button's relief so it can be restored later, and changes +# the relief to sunken. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::CheckRadioDown w { + variable ::tk::Priv + if {![info exists Priv($w,relief)]} { + set Priv($w,relief) [$w cget -relief] + } + if {[$w cget -state] ne "disabled"} { + set Priv(buttonWindow) $w + set Priv(repeated) 0 + $w configure -state active + } } } -if {[string match "unix" $tcl_platform(platform)]} { +if {[string equal "x11" [tk windowingsystem]]} { ##################### # Unix implementation ##################### -# tkButtonEnter -- +# ::tk::ButtonEnter -- # The procedure below is invoked when the mouse pointer enters a # button widget. It records the button we're in and changes the # state of the button to active unless the button is disabled. @@ -261,39 +323,56 @@ if {[string match "unix" $tcl_platform(platform)]} { # Arguments: # w - The name of the widget. -proc tkButtonEnter {w} { - global tkPriv - if {[string compare [$w cget -state] "disabled"]} { +proc ::tk::ButtonEnter {w} { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + # On unix the state is active just with mouse-over $w configure -state active - if {[string equal $tkPriv(buttonWindow) $w]} { - $w configure -state active -relief sunken + + # If the mouse button is down, set the relief to sunken on entry. + # Overwise, if there's an -overrelief value, set the relief to that. + + set Priv($w,relief) [$w cget -relief] + if {$Priv(buttonWindow) eq $w} { + $w configure -relief sunken + set Priv($w,prelief) sunken + } elseif {[set over [$w cget -overrelief]] ne ""} { + $w configure -relief $over + set Priv($w,prelief) $over } } - set tkPriv(window) $w + set Priv(window) $w } -# tkButtonLeave -- +# ::tk::ButtonLeave -- # The procedure below is invoked when the mouse pointer leaves a -# button widget. It changes the state of the button back to -# inactive. If we're leaving the button window with a mouse button -# pressed (tkPriv(buttonWindow) == $w), restore the relief of the -# button too. +# button widget. It changes the state of the button back to inactive. +# Restore any modified relief too. # # Arguments: # w - The name of the widget. -proc tkButtonLeave w { - global tkPriv - if {[string compare [$w cget -state] "disabled"]} { +proc ::tk::ButtonLeave w { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { $w configure -state normal } - if {[string equal $tkPriv(buttonWindow) $w]} { - $w configure -relief $tkPriv(relief) + + # Restore the original button relief if it was changed by Tk. + # That is signaled by the existence of Priv($w,prelief). + + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) } - set tkPriv(window) "" + + set Priv(window) "" } -# tkButtonDown -- +# ::tk::ButtonDown -- # The procedure below is invoked when the mouse button is pressed in # a button widget. It records the fact that the mouse is in the button, # saves the button's relief so it can be restored later, and changes @@ -302,16 +381,33 @@ proc tkButtonLeave w { # Arguments: # w - The name of the widget. -proc tkButtonDown w { - global tkPriv - set tkPriv(relief) [$w cget -relief] - if {[string compare [$w cget -state] "disabled"]} { - set tkPriv(buttonWindow) $w +proc ::tk::ButtonDown w { + variable ::tk::Priv + + # Only save the button's relief if it does not yet exist. If there + # is an overrelief setting, Priv($w,relief) will already have been set, + # and the current value of the -relief option will be incorrect. + + if {![info exists Priv($w,relief)]} { + set Priv($w,relief) [$w cget -relief] + } + + if {[$w cget -state] ne "disabled"} { + set Priv(buttonWindow) $w $w configure -relief sunken + set Priv($w,prelief) sunken + + # If this button has a repeatdelay set up, get it going with an after + after cancel $Priv(afterId) + set delay [$w cget -repeatdelay] + set Priv(repeated) 0 + if {$delay > 0} { + set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]] + } } } -# tkButtonUp -- +# ::tk::ButtonUp -- # The procedure below is invoked when the mouse button is released # in a button widget. It restores the button's relief and invokes # the command as long as the mouse hasn't left the button. @@ -319,27 +415,44 @@ proc tkButtonDown w { # Arguments: # w - The name of the widget. -proc tkButtonUp w { - global tkPriv - if {[string equal $w $tkPriv(buttonWindow)]} { - set tkPriv(buttonWindow) "" - $w configure -relief $tkPriv(relief) - if {[string equal $w $tkPriv(window)] \ - && [string compare [$w cget -state] "disabled"]} { - uplevel #0 [list $w invoke] +proc ::tk::ButtonUp w { + variable ::tk::Priv + if {[string equal $w $Priv(buttonWindow)]} { + set Priv(buttonWindow) "" + + # Restore the button's relief if it was cached. + + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) + } + + # Clean up the after event from the auto-repeater + after cancel $Priv(afterId) + + if {$Priv(window) eq $w && [$w cget -state] ne "disabled"} { + # Only invoke the command if it wasn't already invoked by the + # auto-repeater functionality + if { $Priv(repeated) == 0 } { + uplevel #0 [list $w invoke] + } } } } } -if {[string match "macintosh" $tcl_platform(platform)]} { +if {[string equal [tk windowingsystem] "classic"] + || [string equal [tk windowingsystem] "aqua"]} { #################### # Mac implementation #################### -# tkButtonEnter -- +# ::tk::ButtonEnter -- # The procedure below is invoked when the mouse pointer enters a # button widget. It records the button we're in and changes the # state of the button to active unless the button is disabled. @@ -347,35 +460,54 @@ if {[string match "macintosh" $tcl_platform(platform)]} { # Arguments: # w - The name of the widget. -proc tkButtonEnter {w} { - global tkPriv - if {[string compare [$w cget -state] "disabled"]} { - if {[string equal $w $tkPriv(buttonWindow)]} { +proc ::tk::ButtonEnter {w} { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + + # If there's an -overrelief value, set the relief to that. + + if {$Priv(buttonWindow) eq $w} { $w configure -state active + } elseif {[set over [$w cget -overrelief]] ne ""} { + set Priv($w,relief) [$w cget -relief] + set Priv($w,prelief) $over + $w configure -relief $over } } - set tkPriv(window) $w + set Priv(window) $w } -# tkButtonLeave -- +# ::tk::ButtonLeave -- # The procedure below is invoked when the mouse pointer leaves a # button widget. It changes the state of the button back to # inactive. If we're leaving the button window with a mouse button -# pressed (tkPriv(buttonWindow) == $w), restore the relief of the +# pressed (Priv(buttonWindow) == $w), restore the relief of the # button too. # # Arguments: # w - The name of the widget. -proc tkButtonLeave w { - global tkPriv - if {[string equal $w $tkPriv(buttonWindow)]} { +proc ::tk::ButtonLeave w { + variable ::tk::Priv + if {$w eq $Priv(buttonWindow)} { $w configure -state normal } - set tkPriv(window) "" + + # Restore the original button relief if it was changed by Tk. + # That is signaled by the existence of Priv($w,prelief). + + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) + } + + set Priv(window) "" } -# tkButtonDown -- +# ::tk::ButtonDown -- # The procedure below is invoked when the mouse button is pressed in # a button widget. It records the fact that the mouse is in the button, # saves the button's relief so it can be restored later, and changes @@ -384,15 +516,25 @@ proc tkButtonLeave w { # Arguments: # w - The name of the widget. -proc tkButtonDown w { - global tkPriv - if {[string compare [$w cget -state] "disabled"]} { - set tkPriv(buttonWindow) $w +proc ::tk::ButtonDown w { + variable ::tk::Priv + + if {[$w cget -state] ne "disabled"} { + set Priv(buttonWindow) $w $w configure -state active + + # If this button has a repeatdelay set up, get it going with an after + after cancel $Priv(afterId) + set Priv(repeated) 0 + if { ![catch {$w cget -repeatdelay} delay] } { + if {$delay > 0} { + set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]] + } + } } } -# tkButtonUp -- +# ::tk::ButtonUp -- # The procedure below is invoked when the mouse button is released # in a button widget. It restores the button's relief and invokes # the command as long as the mouse hasn't left the button. @@ -400,14 +542,31 @@ proc tkButtonDown w { # Arguments: # w - The name of the widget. -proc tkButtonUp w { - global tkPriv - if {[string equal $w $tkPriv(buttonWindow)]} { +proc ::tk::ButtonUp w { + variable ::tk::Priv + if {$Priv(buttonWindow) eq $w} { + set Priv(buttonWindow) "" $w configure -state normal - set tkPriv(buttonWindow) "" - if {[string equal $w $tkPriv(window)] - && [string compare [$w cget -state] "disabled"]} { - uplevel #0 [list $w invoke] + + # Restore the button's relief if it was cached. + + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) + } + + # Clean up the after event from the auto-repeater + after cancel $Priv(afterId) + + if {$Priv(window) eq $w && [$w cget -state] ne "disabled"} { + # Only invoke the command if it wasn't already invoked by the + # auto-repeater functionality + if { $Priv(repeated) == 0 } { + uplevel #0 [list $w invoke] + } } } } @@ -418,15 +577,15 @@ proc tkButtonUp w { # Shared routines ################## -# tkButtonInvoke -- +# ::tk::ButtonInvoke -- # The procedure below is called when a button is invoked through # the keyboard. It simulate a press of the button via the mouse. # # Arguments: # w - The name of the widget. -proc tkButtonInvoke w { - if {[string compare [$w cget -state] "disabled"]} { +proc ::tk::ButtonInvoke w { + if {[$w cget -state] ne "disabled"} { set oldRelief [$w cget -relief] set oldState [$w cget -state] $w configure -state active -relief sunken @@ -437,7 +596,33 @@ proc tkButtonInvoke w { } } -# tkCheckRadioInvoke -- +# ::tk::ButtonAutoInvoke -- +# +# Invoke an auto-repeating button, and set it up to continue to repeat. +# +# Arguments: +# w button to invoke. +# +# Results: +# None. +# +# Side effects: +# May create an after event to call ::tk::ButtonAutoInvoke. + +proc ::tk::ButtonAutoInvoke {w} { + variable ::tk::Priv + after cancel $Priv(afterId) + set delay [$w cget -repeatinterval] + if {$Priv(window) eq $w} { + incr Priv(repeated) + uplevel #0 [list $w invoke] + } + if {$delay > 0} { + set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]] + } +} + +# ::tk::CheckRadioInvoke -- # The procedure below is invoked when the mouse button is pressed in # a checkbutton or radiobutton widget, or when the widget is invoked # through the keyboard. It invokes the widget if it @@ -447,10 +632,8 @@ proc tkButtonInvoke w { # w - The name of the widget. # cmd - The subcommand to invoke (one of invoke, select, or deselect). -proc tkCheckRadioInvoke {w {cmd invoke}} { - if {[string compare [$w cget -state] "disabled"]} { +proc ::tk::CheckRadioInvoke {w {cmd invoke}} { + if {[$w cget -state] ne "disabled"} { uplevel #0 [list $w $cmd] } } - - diff --git a/tk/library/choosedir.tcl b/tk/library/choosedir.tcl index 0d0972ebb67..12fd7447009 100644 --- a/tk/library/choosedir.tcl +++ b/tk/library/choosedir.tcl @@ -13,17 +13,18 @@ namespace eval ::tk::dialog::file {} # Make the chooseDir namespace inside the dialog namespace namespace eval ::tk::dialog::file::chooseDir { + namespace import ::tk::msgcat::* } -# ::tk::dialog::file::tkChooseDirectory -- +# ::tk::dialog::file::chooseDir:: -- # # Implements the TK directory selection dialog. # # Arguments: # args Options parsed by the procedure. # -proc ::tk::dialog::file::chooseDir::tkChooseDirectory {args} { - global tkPriv +proc ::tk::dialog::file::chooseDir:: {args} { + variable ::tk::Priv set dataName __tk_choosedir upvar ::tk::dialog::file::$dataName data ::tk::dialog::file::chooseDir::Config $dataName $args @@ -50,7 +51,17 @@ proc ::tk::dialog::file::chooseDir::tkChooseDirectory {args} { set data(okBtn) $w.f2.ok set data(cancelBtn) $w.f3.cancel } - wm transient $w $data(-parent) + + # Dialog boxes should be transient with respect to their parent, + # so that they will always stay on top of their parent window. However, + # some window managers will create the window as withdrawn if the parent + # window is withdrawn or iconified. Combined with the grab we put on the + # window, this can hang the entire application. Therefore we only make + # the dialog transient if the parent is viewable. + + if {[winfo viewable [winfo toplevel $data(-parent)]] } { + wm transient $w $data(-parent) + } trace variable data(selectPath) w [list ::tk::dialog::file::SetPath $w] $data(dirMenuBtn) configure \ @@ -81,7 +92,7 @@ proc ::tk::dialog::file::chooseDir::tkChooseDirectory {args} { # may take the focus away so we can't redirect it. Finally, # restore any grab that was in effect. - tkwait variable tkPriv(selectFilePath) + vwait ::tk::Priv(selectFilePath) ::tk::RestoreFocusGrab $w $data(ent) withdraw @@ -96,7 +107,7 @@ proc ::tk::dialog::file::chooseDir::tkChooseDirectory {args} { # Return value to user # - return $tkPriv(selectFilePath) + return $Priv(selectFilePath) } # ::tk::dialog::file::chooseDir::Config -- @@ -135,8 +146,13 @@ proc ::tk::dialog::file::chooseDir::Config {dataName argList} { tclParseConfigSpec ::tk::dialog::file::$dataName $specs "" $argList if {$data(-title) == ""} { - set data(-title) "Choose Directory" + set data(-title) "[mc "Choose Directory"]" } + + # Stub out the -multiple value for the dialog; it doesn't make sense for + # choose directory dialogs, but we have to have something there because we + # share so much code with the file dialogs. + set data(-multiple) 0 # 4: set the default directory and selection according to the -initial # settings @@ -177,8 +193,9 @@ proc ::tk::dialog::file::chooseDir::OkCmd {w} { # 4b. If the value is different from the current directory, change to # that directory. - set iconText [tkIconList_Get $data(icons)] - if { ![string equal $iconText ""] } { + set selection [tk::IconList_Curselection $data(icons)] + if { [llength $selection] != 0 } { + set iconText [tk::IconList_Get $data(icons) [lindex $selection 0]] set iconText [file join $data(selectPath) $iconText] ::tk::dialog::file::chooseDir::Done $w $iconText } else { @@ -214,11 +231,13 @@ proc ::tk::dialog::file::chooseDir::OkCmd {w} { proc ::tk::dialog::file::chooseDir::DblClick {w} { upvar ::tk::dialog::file::[winfo name $w] data - set text [tkIconList_Get $data(icons)] - if {[string compare $text ""]} { + set selection [tk::IconList_Curselection $data(icons)] + if { [llength $selection] != 0 } { + set filenameFragment \ + [tk::IconList_Get $data(icons) [lindex $selection 0]] set file $data(selectPath) if {[file isdirectory $file]} { - ::tk::dialog::file::ListInvoke $w $text + ::tk::dialog::file::ListInvoke $w [list $filenameFragment] return } } @@ -243,13 +262,13 @@ proc ::tk::dialog::file::chooseDir::ListBrowse {w text} { # # Gets called when user has input a valid filename. Pops up a # dialog box to confirm selection when necessary. Sets the -# tkPriv(selectFilePath) variable, which will break the "tkwait" +# Priv(selectFilePath) variable, which will break the "vwait" # loop in tk_chooseDirectory and return the selected filename to the # script that calls tk_getOpenFile or tk_getSaveFile # proc ::tk::dialog::file::chooseDir::Done {w {selectFilePath ""}} { upvar ::tk::dialog::file::[winfo name $w] data - global tkPriv + variable ::tk::Priv if {[string equal $selectFilePath ""]} { set selectFilePath $data(selectPath) @@ -260,5 +279,5 @@ proc ::tk::dialog::file::chooseDir::Done {w {selectFilePath ""}} { return } } - set tkPriv(selectFilePath) $selectFilePath + set Priv(selectFilePath) $selectFilePath } diff --git a/tk/library/clrpick.tcl b/tk/library/clrpick.tcl index cf7dc04ef73..da174863be9 100644 --- a/tk/library/clrpick.tcl +++ b/tk/library/clrpick.tcl @@ -17,16 +17,24 @@ # (2): Implement HSV color selection. # -# tkColorDialog -- +# Make sure namespaces exist +namespace eval ::tk {} +namespace eval ::tk::dialog {} +namespace eval ::tk::dialog::color { + namespace import ::tk::msgcat::* +} + +# ::tk::dialog::color:: -- # # Create a color dialog and let the user choose a color. This function # should not be called directly. It is called by the tk_chooseColor # function when a native color selector widget does not exist # -proc tkColorDialog {args} { - global tkPriv - set w .__tk__color - upvar #0 $w data +proc ::tk::dialog::color:: {args} { + variable ::tk::Priv + set dataName __tk__color + upvar ::tk::dialog::color::$dataName data + set w .$dataName # The lines variables track the start and end indices of the line # elements in the colorbar canvases. @@ -41,11 +49,11 @@ proc tkColorDialog {args} { # Note that the bars may be of any width. # However, NUM_COLORBARS must be a number that evenly divides 256. # Such as 256, 128, 64, etc. - set data(NUM_COLORBARS) 8 + set data(NUM_COLORBARS) 16 # BARS_WIDTH is the number of pixels wide the color bar portion of the # canvas is. This number must be a multiple of NUM_COLORBARS - set data(BARS_WIDTH) 128 + set data(BARS_WIDTH) 160 # PLGN_WIDTH is the number of pixels wide of the triangular selection # polygon. This also results in the definition of the padding on the @@ -56,8 +64,8 @@ proc tkColorDialog {args} { # selection rectangle at the bottom of the color bar. No restrictions. set data(PLGN_WIDTH) 10 - tkColorDialog_Config $w $args - tkColorDialog_InitValues $w + Config $dataName $args + InitValues $dataName set sc [winfo screen $data(-parent)] set winExists [winfo exists $w] @@ -65,11 +73,20 @@ proc tkColorDialog {args} { if {$winExists} { destroy $w } - toplevel $w -class tkColorDialog -screen $sc - tkColorDialog_BuildDialog $w + toplevel $w -class TkColorDialog -screen $sc + BuildDialog $w } - wm transient $w $data(-parent) + # Dialog boxes should be transient with respect to their parent, + # so that they will always stay on top of their parent window. However, + # some window managers will create the window as withdrawn if the parent + # window is withdrawn or iconified. Combined with the grab we put on the + # window, this can hang the entire application. Therefore we only make + # the dialog transient if the parent is viewable. + + if {[winfo viewable [winfo toplevel $data(-parent)]] } { + wm transient $w $data(-parent) + } # 5. Withdraw the window, then update all the geometry information # so we know how big it wants to be, then center the window in the @@ -88,19 +105,19 @@ proc tkColorDialog {args} { # may take the focus away so we can't redirect it. Finally, # restore any grab that was in effect. - vwait tkPriv(selectColor) + vwait ::tk::Priv(selectColor) ::tk::RestoreFocusGrab $w $data(okBtn) unset data - return $tkPriv(selectColor) + return $Priv(selectColor) } -# tkColorDialog_InitValues -- +# ::tk::dialog::color::InitValues -- # # Get called during initialization or when user resets NUM_COLORBARS # -proc tkColorDialog_InitValues {w} { - upvar #0 $w data +proc ::tk::dialog::color::InitValues {dataName} { + upvar ::tk::dialog::color::$dataName data # IntensityIncr is the difference in color intensity between a colorbar # and its neighbors. @@ -144,19 +161,19 @@ proc tkColorDialog_InitValues {w} { set data(blue,intensity) [expr {[lindex $rgb 2]/0x100}] } -# tkColorDialog_Config -- +# ::tk::dialog::color::Config -- # # Parses the command line arguments to tk_chooseColor # -proc tkColorDialog_Config {w argList} { - global tkPriv - upvar #0 $w data +proc ::tk::dialog::color::Config {dataName argList} { + variable ::tk::Priv + upvar ::tk::dialog::color::$dataName data # 1: the configuration specs # - if {[info exists tkPriv(selectColor)] && \ - [string compare $tkPriv(selectColor) ""]} { - set defaultColor $tkPriv(selectColor) + if {[info exists Priv(selectColor)] && \ + [string compare $Priv(selectColor) ""]} { + set defaultColor $Priv(selectColor) } else { set defaultColor [. cget -background] } @@ -164,12 +181,12 @@ proc tkColorDialog_Config {w argList} { set specs [list \ [list -initialcolor "" "" $defaultColor] \ [list -parent "" "" "."] \ - [list -title "" "" "Color"] \ + [list -title "" "" [mc "Color"]] \ ] # 2: parse the arguments # - tclParseConfigSpec $w $specs "" $argList + tclParseConfigSpec ::tk::dialog::color::$dataName $specs "" $argList if {[string equal $data(-title) ""]} { set data(-title) " " @@ -183,12 +200,12 @@ proc tkColorDialog_Config {w argList} { } } -# tkColorDialog_BuildDialog -- +# ::tk::dialog::color::BuildDialog -- # # Build the dialog. # -proc tkColorDialog_BuildDialog {w} { - upvar #0 $w data +proc ::tk::dialog::color::BuildDialog {w} { + upvar ::tk::dialog::color::[winfo name $w] data # TopFrame contains the color strips and the color selection # @@ -197,18 +214,26 @@ proc tkColorDialog_BuildDialog {w} { # StripsFrame contains the colorstrips and the individual RGB entries set stripsFrame [frame $topFrame.colorStrip] - foreach c { Red Green Blue } { - set color [string tolower $c] - + set maxWidth [::tk::mcmaxamp &Red &Green &Blue] + set maxWidth [expr {$maxWidth<6?6:$maxWidth}] + set colorList [list \ + red [mc "&Red"] \ + green [mc "&Green"] \ + blue [mc "&Blue"] \ + ] + foreach {color l} $colorList { # each f frame contains an [R|G|B] entry and the equiv. color strip. set f [frame $stripsFrame.$color] # The box frame contains the label and entry widget for an [R|G|B] set box [frame $f.box] - label $box.label -text $c: -width 6 -under 0 -anchor ne - entry $box.entry -textvariable [format %s $w]($color,intensity) \ - -width 4 + bind [::tk::AmpWidget label $box.label -text $l: -width $maxWidth \ + -anchor ne] <> [list focus $box.entry] + + entry $box.entry -textvariable \ + ::tk::dialog::color::[winfo name $w]($color,intensity) \ + -width 4 pack $box.label -side left -fill y -padx 2 -pady 3 pack $box.entry -side left -anchor n -pady 0 pack $box -side left -fill both @@ -231,18 +256,18 @@ proc tkColorDialog_BuildDialog {w} { set data($color,sel) $f.sel bind $data($color,col) \ - [list tkColorDialog_DrawColorScale $w $color 1] + [list tk::dialog::color::DrawColorScale $w $color 1] bind $data($color,col) \ - [list tkColorDialog_EnterColorBar $w $color] + [list tk::dialog::color::EnterColorBar $w $color] bind $data($color,col) \ - [list tkColorDialog_LeaveColorBar $w $color] + [list tk::dialog::color::LeaveColorBar $w $color] bind $data($color,sel) \ - [list tkColorDialog_EnterColorBar $w $color] + [list tk::dialog::color::EnterColorBar $w $color] bind $data($color,sel) \ - [list tkColorDialog_LeaveColorBar $w $color] + [list tk::dialog::color::LeaveColorBar $w $color] - bind $box.entry [list tkColorDialog_HandleRGBEntry $w] + bind $box.entry [list tk::dialog::color::HandleRGBEntry $w] } pack $stripsFrame -side left -fill both -padx 4 -pady 10 @@ -251,8 +276,10 @@ proc tkColorDialog_BuildDialog {w} { # selected color # set selFrame [frame $topFrame.sel] - set lab [label $selFrame.lab -text "Selection:" -under 0 -anchor sw] - set ent [entry $selFrame.ent -textvariable [format %s $w](selection) \ + set lab [::tk::AmpWidget label $selFrame.lab -text [mc "&Selection:"] \ + -anchor sw] + set ent [entry $selFrame.ent \ + -textvariable ::tk::dialog::color::[winfo name $w](selection) \ -width 16] set f1 [frame $selFrame.f1 -relief sunken -bd 2] set data(finalCanvas) [frame $f1.demo -bd 0 -width 100 -height 70] @@ -261,7 +288,7 @@ proc tkColorDialog_BuildDialog {w} { pack $f1 -expand yes -anchor nw -fill both -padx 6 -pady 10 pack $data(finalCanvas) -expand yes -fill both - bind $ent [list tkColorDialog_HandleSelEntry $w] + bind $ent [list tk::dialog::color::HandleSelEntry $w] pack $selFrame -side left -fill none -anchor nw pack $topFrame -side top -expand yes -fill both -anchor nw @@ -269,10 +296,14 @@ proc tkColorDialog_BuildDialog {w} { # the botFrame frame contains the buttons # set botFrame [frame $w.bot -relief raised -bd 1] - button $botFrame.ok -text OK -width 8 -under 0 \ - -command [list tkColorDialog_OkCmd $w] - button $botFrame.cancel -text Cancel -width 8 -under 0 \ - -command [list tkColorDialog_CancelCmd $w] + set maxWidth [::tk::mcmaxamp &OK &Cancel] + set maxWidth [expr {$maxWidth<8?8:$maxWidth}] + ::tk::AmpWidget button $botFrame.ok -text [mc "&OK"] \ + -width $maxWidth \ + -command [list tk::dialog::color::OkCmd $w] + ::tk::AmpWidget button $botFrame.cancel -text [mc "&Cancel"] \ + -width $maxWidth \ + -command [list tk::dialog::color::CancelCmd $w] set data(okBtn) $botFrame.ok set data(cancelBtn) $botFrame.cancel @@ -283,67 +314,63 @@ proc tkColorDialog_BuildDialog {w} { # Accelerator bindings + bind $lab <> [list focus $ent] + bind $w [list tk::ButtonInvoke $data(cancelBtn)] + bind $w [list tk::AltKeyInDialog $w %A] - bind $w [list focus $data(red,entry)] - bind $w [list focus $data(green,entry)] - bind $w [list focus $data(blue,entry)] - bind $w [list focus $ent] - bind $w [list tkButtonInvoke $data(cancelBtn)] - bind $w [list tkButtonInvoke $data(cancelBtn)] - bind $w [list tkButtonInvoke $data(okBtn)] - - wm protocol $w WM_DELETE_WINDOW [list tkColorDialog_CancelCmd $w] + wm protocol $w WM_DELETE_WINDOW [list tk::dialog::color::CancelCmd $w] } -# tkColorDialog_SetRGBValue -- +# ::tk::dialog::color::SetRGBValue -- # # Sets the current selection of the dialog box # -proc tkColorDialog_SetRGBValue {w color} { - upvar #0 $w data +proc ::tk::dialog::color::SetRGBValue {w color} { + upvar ::tk::dialog::color::[winfo name $w] data set data(red,intensity) [lindex $color 0] set data(green,intensity) [lindex $color 1] set data(blue,intensity) [lindex $color 2] - tkColorDialog_RedrawColorBars $w all + RedrawColorBars $w all # Now compute the new x value of each colorbars pointer polygon - foreach color { red green blue } { - set x [tkColorDialog_RgbToX $w $data($color,intensity)] - tkColorDialog_MoveSelector $w $data($color,sel) $color $x 0 + foreach color [list red green blue ] { + set x [RgbToX $w $data($color,intensity)] + MoveSelector $w $data($color,sel) $color $x 0 } } -# tkColorDialog_XToRgb -- +# ::tk::dialog::color::XToRgb -- # # Converts a screen coordinate to intensity # -proc tkColorDialog_XToRgb {w x} { - upvar #0 $w data +proc ::tk::dialog::color::XToRgb {w x} { + upvar ::tk::dialog::color::[winfo name $w] data - return [expr {($x * $data(intensityIncr))/ $data(colorbarWidth)}] + set x [expr {($x * $data(intensityIncr))/ $data(colorbarWidth)}] + if {$x > 255} { set x 255 } + return $x } -# tkColorDialog_RgbToX +# ::tk::dialog::color::RgbToX # # Converts an intensity to screen coordinate. # -proc tkColorDialog_RgbToX {w color} { - upvar #0 $w data +proc ::tk::dialog::color::RgbToX {w color} { + upvar ::tk::dialog::color::[winfo name $w] data return [expr {($color * $data(colorbarWidth)/ $data(intensityIncr))}] } -# tkColorDialog_DrawColorScale -- +# ::tk::dialog::color::DrawColorScale -- # # Draw color scale is called whenever the size of one of the color # scale canvases is changed. # -proc tkColorDialog_DrawColorScale {w c {create 0}} { - global lines - upvar #0 $w data +proc ::tk::dialog::color::DrawColorScale {w c {create 0}} { + upvar ::tk::dialog::color::[winfo name $w] data # col: color bar canvas # sel: selector canvas @@ -365,13 +392,13 @@ proc tkColorDialog_DrawColorScale {w c {create 0}} { } # Draw the selection polygons - tkColorDialog_CreateSelector $w $sel $c + CreateSelector $w $sel $c $sel bind $data($c,index) \ - [list tkColorDialog_StartMove $w $sel $c %x $data(selPad) 1] + [list tk::dialog::color::StartMove $w $sel $c %x $data(selPad) 1] $sel bind $data($c,index) \ - [list tkColorDialog_MoveSelector $w $sel $c %x $data(selPad)] + [list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)] $sel bind $data($c,index) \ - [list tkColorDialog_ReleaseMouse $w $sel $c %x $data(selPad)] + [list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(selPad)] set height [winfo height $col] # Create an invisible region under the colorstrip to catch mouse clicks @@ -380,18 +407,18 @@ proc tkColorDialog_DrawColorScale {w c {create 0}} { $data(canvasWidth) $height -fill {} -outline {}] bind $col \ - [list tkColorDialog_StartMove $w $sel $c %x $data(colorPad)] + [list tk::dialog::color::StartMove $w $sel $c %x $data(colorPad)] bind $col \ - [list tkColorDialog_MoveSelector $w $sel $c %x $data(colorPad)] + [list tk::dialog::color::MoveSelector $w $sel $c %x $data(colorPad)] bind $col \ - [list tkColorDialog_ReleaseMouse $w $sel $c %x $data(colorPad)] + [list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(colorPad)] $sel bind $data($c,clickRegion) \ - [list tkColorDialog_StartMove $w $sel $c %x $data(selPad)] + [list tk::dialog::color::StartMove $w $sel $c %x $data(selPad)] $sel bind $data($c,clickRegion) \ - [list tkColorDialog_MoveSelector $w $sel $c %x $data(selPad)] + [list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)] $sel bind $data($c,clickRegion) \ - [list tkColorDialog_ReleaseMouse $w $sel $c %x $data(selPad)] + [list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(selPad)] } else { # l is the canvas index of the first colorbar. set l $data(lines,$c,start) @@ -436,30 +463,30 @@ proc tkColorDialog_DrawColorScale {w c {create 0}} { set data(lines,$c,start) [expr {$index - $data(NUM_COLORBARS) + 1}] } - tkColorDialog_RedrawFinalColor $w + RedrawFinalColor $w } -# tkColorDialog_CreateSelector -- +# ::tk::dialog::color::CreateSelector -- # # Creates and draws the selector polygon at the position # $data($c,intensity). # -proc tkColorDialog_CreateSelector {w sel c } { - upvar #0 $w data +proc ::tk::dialog::color::CreateSelector {w sel c } { + upvar ::tk::dialog::color::[winfo name $w] data set data($c,index) [$sel create polygon \ 0 $data(PLGN_HEIGHT) \ $data(PLGN_WIDTH) $data(PLGN_HEIGHT) \ $data(indent) 0] - set data($c,x) [tkColorDialog_RgbToX $w $data($c,intensity)] + set data($c,x) [RgbToX $w $data($c,intensity)] $sel move $data($c,index) $data($c,x) 0 } -# tkColorDialog_RedrawFinalColor +# ::tk::dialog::color::RedrawFinalColor # # Combines the intensities of the three colors into the final color # -proc tkColorDialog_RedrawFinalColor {w} { - upvar #0 $w data +proc ::tk::dialog::color::RedrawFinalColor {w} { + upvar ::tk::dialog::color::[winfo name $w] data set color [format "#%02x%02x%02x" $data(red,intensity) \ $data(green,intensity) $data(blue,intensity)] @@ -473,42 +500,42 @@ proc tkColorDialog_RedrawFinalColor {w} { $data(blue,intensity)] } -# tkColorDialog_RedrawColorBars -- +# ::tk::dialog::color::RedrawColorBars -- # # Only redraws the colors on the color strips that were not manipulated. # Params: color of colorstrip that changed. If color is not [red|green|blue] # Then all colorstrips will be updated # -proc tkColorDialog_RedrawColorBars {w colorChanged} { - upvar #0 $w data +proc ::tk::dialog::color::RedrawColorBars {w colorChanged} { + upvar ::tk::dialog::color::[winfo name $w] data switch $colorChanged { red { - tkColorDialog_DrawColorScale $w green - tkColorDialog_DrawColorScale $w blue + DrawColorScale $w green + DrawColorScale $w blue } green { - tkColorDialog_DrawColorScale $w red - tkColorDialog_DrawColorScale $w blue + DrawColorScale $w red + DrawColorScale $w blue } blue { - tkColorDialog_DrawColorScale $w red - tkColorDialog_DrawColorScale $w green + DrawColorScale $w red + DrawColorScale $w green } default { - tkColorDialog_DrawColorScale $w red - tkColorDialog_DrawColorScale $w green - tkColorDialog_DrawColorScale $w blue + DrawColorScale $w red + DrawColorScale $w green + DrawColorScale $w blue } } - tkColorDialog_RedrawFinalColor $w + RedrawFinalColor $w } #---------------------------------------------------------------------- # Event handlers #---------------------------------------------------------------------- -# tkColorDialog_StartMove -- +# ::tk::dialog::color::StartMove -- # # Handles a mousedown button event over the selector polygon. # Adds the bindings for moving the mouse while the button is @@ -516,15 +543,15 @@ proc tkColorDialog_RedrawColorBars {w colorChanged} { # # Params: sel is the selector canvas window, color is the color of the strip. # -proc tkColorDialog_StartMove {w sel color x delta {dontMove 0}} { - upvar #0 $w data +proc ::tk::dialog::color::StartMove {w sel color x delta {dontMove 0}} { + upvar ::tk::dialog::color::[winfo name $w] data if {!$dontMove} { - tkColorDialog_MoveSelector $w $sel $color $x $delta + MoveSelector $w $sel $color $x $delta } } -# tkColorDialog_MoveSelector -- +# ::tk::dialog::color::MoveSelector -- # # Moves the polygon selector so that its middle point has the same # x value as the specified x. If x is outside the bounds [0,255], @@ -533,15 +560,15 @@ proc tkColorDialog_StartMove {w sel color x delta {dontMove 0}} { # Params: sel is the selector canvas, c is [red|green|blue] # x is a x-coordinate. # -proc tkColorDialog_MoveSelector {w sel color x delta} { - upvar #0 $w data +proc ::tk::dialog::color::MoveSelector {w sel color x delta} { + upvar ::tk::dialog::color::[winfo name $w] data incr x -$delta if { $x < 0 } { set x 0 - } elseif { $x >= $data(BARS_WIDTH)} { - set x [expr {$data(BARS_WIDTH) - 1}] + } elseif { $x > $data(BARS_WIDTH)} { + set x $data(BARS_WIDTH) } set diff [expr {$x - $data($color,x)}] $sel move $data($color,index) $diff 0 @@ -551,49 +578,49 @@ proc tkColorDialog_MoveSelector {w sel color x delta} { return $x } -# tkColorDialog_ReleaseMouse +# ::tk::dialog::color::ReleaseMouse # # Removes mouse tracking bindings, updates the colorbars. # # Params: sel is the selector canvas, color is the color of the strip, # x is the x-coord of the mouse. # -proc tkColorDialog_ReleaseMouse {w sel color x delta} { - upvar #0 $w data +proc ::tk::dialog::color::ReleaseMouse {w sel color x delta} { + upvar ::tk::dialog::color::[winfo name $w] data - set x [tkColorDialog_MoveSelector $w $sel $color $x $delta] + set x [MoveSelector $w $sel $color $x $delta] # Determine exactly what color we are looking at. - set data($color,intensity) [tkColorDialog_XToRgb $w $x] + set data($color,intensity) [XToRgb $w $x] - tkColorDialog_RedrawColorBars $w $color + RedrawColorBars $w $color } -# tkColorDialog_ResizeColorbars -- +# ::tk::dialog::color::ResizeColorbars -- # # Completely redraws the colorbars, including resizing the # colorstrips # -proc tkColorDialog_ResizeColorBars {w} { - upvar #0 $w data +proc ::tk::dialog::color::ResizeColorBars {w} { + upvar ::tk::dialog::color::[winfo name $w] data if { ($data(BARS_WIDTH) < $data(NUM_COLORBARS)) || (($data(BARS_WIDTH) % $data(NUM_COLORBARS)) != 0)} { set data(BARS_WIDTH) $data(NUM_COLORBARS) } - tkColorDialog_InitValues $w - foreach color { red green blue } { + InitValues [winfo name $w] + foreach color [list red green blue ] { $data($color,col) configure -width $data(canvasWidth) - tkColorDialog_DrawColorScale $w $color 1 + DrawColorScale $w $color 1 } } -# tkColorDialog_HandleSelEntry -- +# ::tk::dialog::color::HandleSelEntry -- # # Handles the return keypress event in the "Selection:" entry # -proc tkColorDialog_HandleSelEntry {w} { - upvar #0 $w data +proc ::tk::dialog::color::HandleSelEntry {w} { + upvar ::tk::dialog::color::[winfo name $w] data set text [string trim $data(selection)] # Check to make sure that the color is valid @@ -606,18 +633,18 @@ proc tkColorDialog_HandleSelEntry {w} { set G [expr {[lindex $color 1]/0x100}] set B [expr {[lindex $color 2]/0x100}] - tkColorDialog_SetRGBValue $w "$R $G $B" + SetRGBValue $w "$R $G $B" set data(selection) $text } -# tkColorDialog_HandleRGBEntry -- +# ::tk::dialog::color::HandleRGBEntry -- # # Handles the return keypress event in the R, G or B entry # -proc tkColorDialog_HandleRGBEntry {w} { - upvar #0 $w data +proc ::tk::dialog::color::HandleRGBEntry {w} { + upvar ::tk::dialog::color::[winfo name $w] data - foreach c {red green blue} { + foreach c [list red green blue] { if {[catch { set data($c,intensity) [expr {int($data($c,intensity))}] }]} { @@ -632,42 +659,39 @@ proc tkColorDialog_HandleRGBEntry {w} { } } - tkColorDialog_SetRGBValue $w "$data(red,intensity) $data(green,intensity) \ - $data(blue,intensity)" + SetRGBValue $w "$data(red,intensity) \ + $data(green,intensity) $data(blue,intensity)" } # mouse cursor enters a color bar # -proc tkColorDialog_EnterColorBar {w color} { - upvar #0 $w data +proc ::tk::dialog::color::EnterColorBar {w color} { + upvar ::tk::dialog::color::[winfo name $w] data $data($color,sel) itemconfig $data($color,index) -fill red } # mouse leaves enters a color bar # -proc tkColorDialog_LeaveColorBar {w color} { - upvar #0 $w data +proc ::tk::dialog::color::LeaveColorBar {w color} { + upvar ::tk::dialog::color::[winfo name $w] data $data($color,sel) itemconfig $data($color,index) -fill black } # user hits OK button # -proc tkColorDialog_OkCmd {w} { - global tkPriv - upvar #0 $w data +proc ::tk::dialog::color::OkCmd {w} { + variable ::tk::Priv + upvar ::tk::dialog::color::[winfo name $w] data - set tkPriv(selectColor) $data(finalColor) + set Priv(selectColor) $data(finalColor) } # user hits Cancel button # -proc tkColorDialog_CancelCmd {w} { - global tkPriv - - set tkPriv(selectColor) "" +proc ::tk::dialog::color::CancelCmd {w} { + variable ::tk::Priv + set Priv(selectColor) "" } - - diff --git a/tk/library/comdlg.tcl b/tk/library/comdlg.tcl index 929f741a1bb..7be38743984 100644 --- a/tk/library/comdlg.tcl +++ b/tk/library/comdlg.tcl @@ -112,94 +112,99 @@ proc tclListValidFlags {v} { #---------------------------------------------------------------------- -# tkFocusGroup_Create -- +# ::tk::FocusGroup_Create -- # # Create a focus group. All the widgets in a focus group must be # within the same focus toplevel. Each toplevel can have only # one focus group, which is identified by the name of the # toplevel widget. # -proc tkFocusGroup_Create {t} { - global tkPriv +proc ::tk::FocusGroup_Create {t} { + variable ::tk::Priv if {[string compare [winfo toplevel $t] $t]} { error "$t is not a toplevel window" } - if {![info exists tkPriv(fg,$t)]} { - set tkPriv(fg,$t) 1 - set tkPriv(focus,$t) "" - bind $t [list tkFocusGroup_In $t %W %d] - bind $t [list tkFocusGroup_Out $t %W %d] - bind $t [list tkFocusGroup_Destroy $t %W] + if {![info exists Priv(fg,$t)]} { + set Priv(fg,$t) 1 + set Priv(focus,$t) "" + bind $t [list tk::FocusGroup_In $t %W %d] + bind $t [list tk::FocusGroup_Out $t %W %d] + bind $t [list tk::FocusGroup_Destroy $t %W] } } -# tkFocusGroup_BindIn -- +# ::tk::FocusGroup_BindIn -- # # Add a widget into the "FocusIn" list of the focus group. The $cmd will be # called when the widget is focused on by the user. # -proc tkFocusGroup_BindIn {t w cmd} { - global tkFocusIn tkPriv - if {![info exists tkPriv(fg,$t)]} { +proc ::tk::FocusGroup_BindIn {t w cmd} { + variable FocusIn + variable ::tk::Priv + if {![info exists Priv(fg,$t)]} { error "focus group \"$t\" doesn't exist" } - set tkFocusIn($t,$w) $cmd + set FocusIn($t,$w) $cmd } -# tkFocusGroup_BindOut -- +# ::tk::FocusGroup_BindOut -- # # Add a widget into the "FocusOut" list of the focus group. The # $cmd will be called when the widget loses the focus (User # types Tab or click on another widget). # -proc tkFocusGroup_BindOut {t w cmd} { - global tkFocusOut tkPriv - if {![info exists tkPriv(fg,$t)]} { +proc ::tk::FocusGroup_BindOut {t w cmd} { + variable FocusOut + variable ::tk::Priv + if {![info exists Priv(fg,$t)]} { error "focus group \"$t\" doesn't exist" } - set tkFocusOut($t,$w) $cmd + set FocusOut($t,$w) $cmd } -# tkFocusGroup_Destroy -- +# ::tk::FocusGroup_Destroy -- # # Cleans up when members of the focus group is deleted, or when the # toplevel itself gets deleted. # -proc tkFocusGroup_Destroy {t w} { - global tkPriv tkFocusIn tkFocusOut +proc ::tk::FocusGroup_Destroy {t w} { + variable FocusIn + variable FocusOut + variable ::tk::Priv if {[string equal $t $w]} { - unset tkPriv(fg,$t) - unset tkPriv(focus,$t) + unset Priv(fg,$t) + unset Priv(focus,$t) - foreach name [array names tkFocusIn $t,*] { - unset tkFocusIn($name) + foreach name [array names FocusIn $t,*] { + unset FocusIn($name) } - foreach name [array names tkFocusOut $t,*] { - unset tkFocusOut($name) + foreach name [array names FocusOut $t,*] { + unset FocusOut($name) } } else { - if {[info exists tkPriv(focus,$t)] && \ - [string equal $tkPriv(focus,$t) $w]} { - set tkPriv(focus,$t) "" + if {[info exists Priv(focus,$t)] && \ + [string equal $Priv(focus,$t) $w]} { + set Priv(focus,$t) "" } catch { - unset tkFocusIn($t,$w) + unset FocusIn($t,$w) } catch { - unset tkFocusOut($t,$w) + unset FocusOut($t,$w) } } } -# tkFocusGroup_In -- +# ::tk::FocusGroup_In -- # # Handles the event. Calls the FocusIn command for the newly # focused widget in the focus group. # -proc tkFocusGroup_In {t w detail} { - global tkPriv tkFocusIn +proc ::tk::FocusGroup_In {t w detail} { + variable FocusIn + variable ::tk::Priv if {[string compare $detail NotifyNonlinear] && \ [string compare $detail NotifyNonlinearVirtual]} { @@ -207,56 +212,57 @@ proc tkFocusGroup_In {t w detail} { # ordinary keypresses some window managers (ie: CDE [Bug: 2960]). return } - if {![info exists tkFocusIn($t,$w)]} { - set tkFocusIn($t,$w) "" + if {![info exists FocusIn($t,$w)]} { + set FocusIn($t,$w) "" return } - if {![info exists tkPriv(focus,$t)]} { + if {![info exists Priv(focus,$t)]} { return } - if {[string equal $tkPriv(focus,$t) $w]} { + if {[string equal $Priv(focus,$t) $w]} { # This is already in focus # return } else { - set tkPriv(focus,$t) $w - eval $tkFocusIn($t,$w) + set Priv(focus,$t) $w + eval $FocusIn($t,$w) } } -# tkFocusGroup_Out -- +# ::tk::FocusGroup_Out -- # # Handles the event. Checks if this is really a lose # focus event, not one generated by the mouse moving out of the # toplevel window. Calls the FocusOut command for the widget # who loses its focus. # -proc tkFocusGroup_Out {t w detail} { - global tkPriv tkFocusOut +proc ::tk::FocusGroup_Out {t w detail} { + variable FocusOut + variable ::tk::Priv if {[string compare $detail NotifyNonlinear] && \ [string compare $detail NotifyNonlinearVirtual]} { # This is caused by mouse moving out of the window return } - if {![info exists tkPriv(focus,$t)]} { + if {![info exists Priv(focus,$t)]} { return } - if {![info exists tkFocusOut($t,$w)]} { + if {![info exists FocusOut($t,$w)]} { return } else { - eval $tkFocusOut($t,$w) - set tkPriv(focus,$t) "" + eval $FocusOut($t,$w) + set Priv(focus,$t) "" } } -# tkFDGetFileTypes -- +# ::tk::FDGetFileTypes -- # # Process the string given by the -filetypes option of the file # dialogs. Similar to the C function TkGetFileFilters() on the Mac # and Windows platform. # -proc tkFDGetFileTypes {string} { +proc ::tk::FDGetFileTypes {string} { foreach t $string { if {[llength $t] < 2 || [llength $t] > 3} { error "bad file type \"$t\", should be \"typeName {extension ?extensions ...?} ?{macType ?macTypes ...?}?\"" @@ -295,5 +301,3 @@ proc tkFDGetFileTypes {string} { return $types } - - diff --git a/tk/library/console.tcl b/tk/library/console.tcl index de884118c8e..cc5e3adb8bf 100644 --- a/tk/library/console.tcl +++ b/tk/library/console.tcl @@ -6,8 +6,8 @@ # # RCS: @(#) $Id$ # -# Copyright (c) 1998-1999 Scriptics Corp. # Copyright (c) 1995-1997 Sun Microsystems, Inc. +# Copyright (c) 1998-2000 Ajuba Solutions. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -15,112 +15,152 @@ # TODO: history - remember partially written command -# tkConsoleInit -- +namespace eval ::tk::console { + variable blinkTime 500 ; # msecs to blink braced range for + variable blinkRange 1 ; # enable blinking of the entire braced range + variable magicKeys 1 ; # enable brace matching and proc/var recognition + variable maxLines 600 ; # maximum # of lines buffered in console + variable showMatches 1 ; # show multiple expand matches + + variable inPlugin [info exists embed_args] + variable defaultPrompt ; # default prompt if tcl_prompt1 isn't used + + + if {$inPlugin} { + set defaultPrompt {subst {[history nextid] % }} + } else { + set defaultPrompt {subst {([file tail [pwd]]) [history nextid] % }} + } +} + +# simple compat function for tkcon code added for this console +interp alias {} EvalAttached {} consoleinterp eval + +# ::tk::ConsoleInit -- # This procedure constructs and configures the console windows. # # Arguments: # None. -proc tkConsoleInit {} { +proc ::tk::ConsoleInit {} { global tcl_platform if {![consoleinterp eval {set tcl_interactive}]} { wm withdraw . } - if {[string compare $tcl_platform(platform) "macintosh"]} { - set mod "Ctrl" - } else { + if {[string equal $tcl_platform(platform) "macintosh"] + || [string equal [tk windowingsystem] "aqua"]} { set mod "Cmd" + } else { + set mod "Ctrl" } - menu .menubar + if {[catch {menu .menubar} err]} { bgerror "INIT: $err" } .menubar add cascade -label File -menu .menubar.file -underline 0 .menubar add cascade -label Edit -menu .menubar.edit -underline 0 menu .menubar.file -tearoff 0 - .menubar.file add command -label "Source..." -underline 0 \ - -command tkConsoleSource - .menubar.file add command -label "Hide Console" -underline 0 \ - -command {wm withdraw .} - if {[string compare $tcl_platform(platform) "macintosh"]} { - .menubar.file add command -label "Exit" -underline 1 -command exit + .menubar.file add command -label [mc "Source..."] \ + -underline 0 -command tk::ConsoleSource + .menubar.file add command -label [mc "Hide Console"] \ + -underline 0 -command {wm withdraw .} + .menubar.file add command -label [mc "Clear Console"] \ + -underline 0 -command {.console delete 1.0 "promptEnd linestart"} + if {[string equal $tcl_platform(platform) "macintosh"] + || [string equal [tk windowingsystem] "aqua"]} { + .menubar.file add command -label [mc "Quit"] \ + -command exit -accel Cmd-Q } else { - .menubar.file add command -label "Quit" -command exit -accel Cmd-Q + .menubar.file add command -label [mc "Exit"] \ + -underline 1 -command exit } menu .menubar.edit -tearoff 0 - .menubar.edit add command -label "Cut" -underline 2 \ + .menubar.edit add command -label [mc "Cut"] -underline 2 \ -command { event generate .console <> } -accel "$mod+X" - .menubar.edit add command -label "Copy" -underline 0 \ + .menubar.edit add command -label [mc "Copy"] -underline 0 \ -command { event generate .console <> } -accel "$mod+C" - .menubar.edit add command -label "Paste" -underline 1 \ + .menubar.edit add command -label [mc "Paste"] -underline 1 \ -command { event generate .console <> } -accel "$mod+V" if {[string compare $tcl_platform(platform) "windows"]} { - .menubar.edit add command -label "Clear" -underline 2 \ + .menubar.edit add command -label [mc "Clear"] -underline 2 \ -command { event generate .console <> } } else { - .menubar.edit add command -label "Delete" -underline 0 \ + .menubar.edit add command -label [mc "Delete"] -underline 0 \ -command { event generate .console <> } -accel "Del" - + .menubar add cascade -label Help -menu .menubar.help -underline 0 menu .menubar.help -tearoff 0 - .menubar.help add command -label "About..." -underline 0 \ - -command tkConsoleAbout + .menubar.help add command -label [mc "About..."] \ + -underline 0 -command tk::ConsoleAbout } . configure -menu .menubar - text .console -yscrollcommand ".sb set" -setgrid true - scrollbar .sb -command ".console yview" + set con [text .console -yscrollcommand [list .sb set] -setgrid true] + scrollbar .sb -command [list $con yview] pack .sb -side right -fill both - pack .console -fill both -expand 1 -side left + pack $con -fill both -expand 1 -side left switch -exact $tcl_platform(platform) { "macintosh" { - .console configure -font {Monaco 9 normal} -highlightthickness 0 + $con configure -font {Monaco 9 normal} -highlightthickness 0 } "windows" { - .console configure -font systemfixed + $con configure -font systemfixed + } + "unix" { + if {[string equal [tk windowingsystem] "aqua"]} { + $con configure -font {Monaco 9 normal} -highlightthickness 0 + } } } - tkConsoleBind .console + ConsoleBind $con - .console tag configure stderr -foreground red - .console tag configure stdin -foreground blue + $con tag configure stderr -foreground red + $con tag configure stdin -foreground blue + $con tag configure prompt -foreground \#8F4433 + $con tag configure proc -foreground \#008800 + $con tag configure var -background \#FFC0D0 + $con tag raise sel + $con tag configure blink -background \#FFFF00 + $con tag configure find -background \#FFFF00 + + focus $con - focus .console - wm protocol . WM_DELETE_WINDOW { wm withdraw . } - wm title . "Console" + wm title . [mc "Console"] flush stdout - .console mark set output [.console index "end - 1 char"] - tkTextSetCursor .console end - .console mark set promptEnd insert - .console mark gravity promptEnd left + $con mark set output [$con index "end - 1 char"] + tk::TextSetCursor $con end + $con mark set promptEnd insert + $con mark gravity promptEnd left } -# tkConsoleSource -- +# ::tk::ConsoleSource -- # # Prompts the user for a file to source in the main interpreter. # # Arguments: # None. -proc tkConsoleSource {} { +proc ::tk::ConsoleSource {} { set filename [tk_getOpenFile -defaultextension .tcl -parent . \ - -title "Select a file to source" \ - -filetypes {{"Tcl Scripts" .tcl} {"All Files" *}}] + -title [mc "Select a file to source"] \ + -filetypes [list \ + [list [mc "Tcl Scripts"] .tcl] \ + [list [mc "All Files"] *]]] if {[string compare $filename ""]} { set cmd [list source $filename] if {[catch {consoleinterp eval $cmd} result]} { - tkConsoleOutput stderr "$result\n" + ConsoleOutput stderr "$result\n" } } } -# tkConsoleInvoke -- +# ::tk::ConsoleInvoke -- # Processes the command line input. If the command is complete it # is evaled in the main interpreter. Otherwise, the continuation # prompt is added and more input may be added. @@ -128,7 +168,7 @@ proc tkConsoleSource {} { # Arguments: # None. -proc tkConsoleInvoke {args} { +proc ::tk::ConsoleInvoke {args} { set ranges [.console tag ranges input] set cmd "" if {[llength $ranges]} { @@ -141,7 +181,7 @@ proc tkConsoleInvoke {args} { } } if {[string equal $cmd ""]} { - tkConsolePrompt + ConsolePrompt } elseif {[info complete $cmd]} { .console mark set output end .console tag delete input @@ -149,51 +189,51 @@ proc tkConsoleInvoke {args} { if {[string compare $result ""]} { puts $result } - tkConsoleHistory reset - tkConsolePrompt + ConsoleHistory reset + ConsolePrompt } else { - tkConsolePrompt partial + ConsolePrompt partial } .console yview -pickplace insert } -# tkConsoleHistory -- +# ::tk::ConsoleHistory -- # This procedure implements command line history for the # console. In general is evals the history command in the -# main interpreter to obtain the history. The global variable -# histNum is used to store the current location in the history. +# main interpreter to obtain the history. The variable +# ::tk::HistNum is used to store the current location in the history. # # Arguments: # cmd - Which action to take: prev, next, reset. -set histNum 1 -proc tkConsoleHistory {cmd} { - global histNum - +set ::tk::HistNum 1 +proc ::tk::ConsoleHistory {cmd} { + variable HistNum + switch $cmd { prev { - incr histNum -1 - if {$histNum == 0} { + incr HistNum -1 + if {$HistNum == 0} { set cmd {history event [expr {[history nextid] -1}]} } else { - set cmd "history event $histNum" + set cmd "history event $HistNum" } if {[catch {consoleinterp eval $cmd} cmd]} { - incr histNum + incr HistNum return } .console delete promptEnd end .console insert promptEnd $cmd {input stdin} } next { - incr histNum - if {$histNum == 0} { + incr HistNum + if {$HistNum == 0} { set cmd {history event [expr {[history nextid] -1}]} - } elseif {$histNum > 0} { + } elseif {$HistNum > 0} { set cmd "" - set histNum 1 + set HistNum 1 } else { - set cmd "history event $histNum" + set cmd "history event $HistNum" } if {[string compare $cmd ""]} { catch {consoleinterp eval $cmd} cmd @@ -202,12 +242,12 @@ proc tkConsoleHistory {cmd} { .console insert promptEnd $cmd {input stdin} } reset { - set histNum 1 + set HistNum 1 } } } -# tkConsolePrompt -- +# ::tk::ConsolePrompt -- # This procedure draws the prompt. If tcl_prompt1 or tcl_prompt2 # exists in the main interpreter it will be called to generate the # prompt. Otherwise, a hard coded default prompt is printed. @@ -215,18 +255,19 @@ proc tkConsoleHistory {cmd} { # Arguments: # partial - Flag to specify which prompt to print. -proc tkConsolePrompt {{partial normal}} { +proc ::tk::ConsolePrompt {{partial normal}} { + set w .console if {[string equal $partial "normal"]} { - set temp [.console index "end - 1 char"] - .console mark set output end + set temp [$w index "end - 1 char"] + $w mark set output end if {[consoleinterp eval "info exists tcl_prompt1"]} { consoleinterp eval "eval \[set tcl_prompt1\]" } else { - puts -nonewline "% " + puts -nonewline [EvalAttached $::tk::console::defaultPrompt] } } else { - set temp [.console index output] - .console mark set output end + set temp [$w index output] + $w mark set output end if {[consoleinterp eval "info exists tcl_prompt2"]} { consoleinterp eval "eval \[set tcl_prompt2\]" } else { @@ -234,13 +275,15 @@ proc tkConsolePrompt {{partial normal}} { } } flush stdout - .console mark set output $temp - tkTextSetCursor .console end - .console mark set promptEnd insert - .console mark gravity promptEnd left + $w mark set output $temp + ::tk::TextSetCursor $w end + $w mark set promptEnd insert + $w mark gravity promptEnd left + ::tk::console::ConstrainBuffer $w $::tk::console::maxLines + $w see end } -# tkConsoleBind -- +# ::tk::ConsoleBind -- # This procedure first ensures that the default bindings for the Text # class have been defined. Then certain bindings are overridden for # the class. @@ -248,166 +291,231 @@ proc tkConsolePrompt {{partial normal}} { # Arguments: # None. -proc tkConsoleBind {win} { - bindtags $win "$win Text . all" +proc ::tk::ConsoleBind {w} { + bindtags $w [list $w Console PostConsole [winfo toplevel $w] all] + + ## Get all Text bindings into Console + foreach ev [bind Text] { bind Console $ev [bind Text $ev] } + ## We really didn't want the newline insertion... + bind Console {} + ## ...or any Control-v binding (would block <>) + bind Console {} + + # For the moment, transpose isn't enabled until the console + # gets and overhaul of how it handles input -- hobbs + bind Console {} # Ignore all Alt, Meta, and Control keypresses unless explicitly bound. # Otherwise, if a widget binding for one of these is defined, the - # class binding will also fire and insert the character, - # which is wrong. Ditto for . - - bind $win {# nothing } - bind $win {# nothing} - bind $win {# nothing} - bind $win {# nothing} - bind $win {# nothing} - - bind $win { - tkConsoleInsert %W \t - focus %W - break - } - bind $win { + + bind Console {# nothing } + bind Console {# nothing} + bind Console {# nothing} + + foreach {ev key} { + <> + <> + <> + <> + <> + <> + + <> + <> + <> + <> + <> + <> + <> + <> + <> + + <> + <> + <> + <> + <> + } { + event add $ev $key + bind Console $key {} + } + + bind Console <> { + if {[%W compare insert > promptEnd]} {::tk::console::Expand %W} + } + bind Console <> { + if {[%W compare insert > promptEnd]} {::tk::console::Expand %W path} + } + bind Console <> { + if {[%W compare insert > promptEnd]} {::tk::console::Expand %W proc} + } + bind Console <> { + if {[%W compare insert > promptEnd]} {::tk::console::Expand %W var} + } + bind Console <> { %W mark set insert {end - 1c} - tkConsoleInsert %W "\n" - tkConsoleInvoke + tk::ConsoleInsert %W "\n" + tk::ConsoleInvoke break } - bind $win { - if {[string compare [%W tag nextrange sel 1.0 end] ""]} { - %W tag remove sel sel.first promptEnd - } elseif {[%W compare insert < promptEnd]} { - break + bind Console { + if {[string compare {} [%W tag nextrange sel 1.0 end]] \ + && [%W compare sel.first >= promptEnd]} { + %W delete sel.first sel.last + } elseif {[%W compare insert >= promptEnd]} { + %W delete insert + %W see insert } } - bind $win { - if {[string compare [%W tag nextrange sel 1.0 end] ""]} { - %W tag remove sel sel.first promptEnd - } elseif {[%W compare insert <= promptEnd]} { - break + bind Console { + if {[string compare {} [%W tag nextrange sel 1.0 end]] \ + && [%W compare sel.first >= promptEnd]} { + %W delete sel.first sel.last + } elseif {[%W compare insert != 1.0] && \ + [%W compare insert > promptEnd]} { + %W delete insert-1c + %W see insert } } - foreach left {Control-a Home} { - bind $win <$left> { - if {[%W compare insert < promptEnd]} { - tkTextSetCursor %W {insert linestart} - } else { - tkTextSetCursor %W promptEnd - } - break + bind Console [bind Console ] + + bind Console { + if {[%W compare insert < promptEnd]} { + tk::TextSetCursor %W {insert linestart} + } else { + tk::TextSetCursor %W promptEnd } } - foreach right {Control-e End} { - bind $win <$right> { - tkTextSetCursor %W {insert lineend} - break - } + bind Console [bind Console ] + bind Console { + tk::TextSetCursor %W {insert lineend} } - bind $win { - if {[%W compare insert < promptEnd]} { - break - } + bind Console [bind Console ] + bind Console { + if {[%W compare insert < promptEnd]} break + %W delete insert } - bind $win { - if {[%W compare insert < promptEnd]} { - %W mark set insert promptEnd + bind Console <> { + if {[%W compare insert < promptEnd]} break + if {[%W compare insert == {insert lineend}]} { + %W delete insert + } else { + %W delete insert {insert lineend} } } - bind $win { - if {[%W compare insert < promptEnd]} { - break - } + bind Console <> { + ## Clear console display + %W delete 1.0 "promptEnd linestart" } - bind $win { - if {[%W compare insert < promptEnd]} { - break + bind Console <> { + ## Clear command line (Unix shell staple) + %W delete promptEnd end + } + bind Console { + if {[%W compare insert >= promptEnd]} { + %W delete insert {insert wordend} } } - bind $win { - if {[%W compare insert <= promptEnd]} { - break + bind Console { + if {[%W compare {insert -1c wordstart} >= promptEnd]} { + %W delete {insert -1c wordstart} insert } } - bind $win { - if {[%W compare insert <= promptEnd]} { - break + bind Console { + if {[%W compare insert >= promptEnd]} { + %W delete insert {insert wordend} } } - foreach prev {Control-p Up} { - bind $win <$prev> { - tkConsoleHistory prev - break + bind Console { + if {[%W compare {insert -1c wordstart} >= promptEnd]} { + %W delete {insert -1c wordstart} insert } } - foreach prev {Control-n Down} { - bind $win <$prev> { - tkConsoleHistory next - break + bind Console { + if {[%W compare insert >= promptEnd]} { + %W delete insert {insert wordend} } } - bind $win { - catch {tkConsoleInsert %W [selection get -displayof %W]} - break + bind Console <> { + tk::ConsoleHistory prev } - bind $win { - tkConsoleInsert %W %A - break + bind Console <> { + tk::ConsoleHistory next } - foreach left {Control-b Left} { - bind $win <$left> { - if {[%W compare insert == promptEnd]} { - break - } - tkTextSetCursor %W insert-1c - break - } + bind Console { + catch {tk::ConsoleInsert %W [::tk::GetSelection %W PRIMARY]} } - foreach right {Control-f Right} { - bind $win <$right> { - tkTextSetCursor %W insert+1c - break - } + bind Console { + tk::ConsoleInsert %W %A } - bind $win { + bind Console { eval destroy [winfo child .] if {[string equal $tcl_platform(platform) "macintosh"]} { - source -rsrc Console + if {[catch {source [file join $tk_library console.tcl]}]} {source -rsrc console} } else { source [file join $tk_library console.tcl] } } - bind $win <> { + bind Console <> { # Same as the copy event if {![catch {set data [%W get sel.first sel.last]}]} { clipboard clear -displayof %W clipboard append -displayof %W $data } - break } - bind $win <> { + bind Console <> { if {![catch {set data [%W get sel.first sel.last]}]} { clipboard clear -displayof %W clipboard append -displayof %W $data } - break } - bind $win <> { + bind Console <> { catch { - set clip [selection get -displayof %W -selection CLIPBOARD] + set clip [::tk::GetSelection %W CLIPBOARD] set list [split $clip \n\r] - tkConsoleInsert %W [lindex $list 0] + tk::ConsoleInsert %W [lindex $list 0] foreach x [lrange $list 1 end] { %W mark set insert {end - 1c} - tkConsoleInsert %W "\n" - tkConsoleInvoke - tkConsoleInsert %W $x + tk::ConsoleInsert %W "\n" + tk::ConsoleInvoke + tk::ConsoleInsert %W $x } } + } + + ## + ## Bindings for doing special things based on certain keys + ## + bind PostConsole { + if {[string compare \\ [%W get insert-2c]]} { + ::tk::console::MatchPair %W \( \) promptEnd + } + } + bind PostConsole { + if {[string compare \\ [%W get insert-2c]]} { + ::tk::console::MatchPair %W \[ \] promptEnd + } + } + bind PostConsole { + if {[string compare \\ [%W get insert-2c]]} { + ::tk::console::MatchPair %W \{ \} promptEnd + } + } + bind PostConsole { + if {[string compare \\ [%W get insert-2c]]} { + ::tk::console::MatchQuote %W promptEnd + } + } + + bind PostConsole { + if {"%A" != ""} { + ::tk::console::TagProc %W + } break } } -# tkConsoleInsert -- +# ::tk::ConsoleInsert -- # Insert a string into a text at the point of the insertion cursor. # If there is a selection in the text, and it covers the point of the # insertion cursor, then delete the selection before inserting. Insertion @@ -417,7 +525,7 @@ proc tkConsoleBind {win} { # w - The text window in which to insert the string # s - The string to insert (usually just a single character) -proc tkConsoleInsert {w s} { +proc ::tk::ConsoleInsert {w s} { if {[string equal $s ""]} { return } @@ -429,13 +537,13 @@ proc tkConsoleInsert {w s} { } } if {[$w compare insert < promptEnd]} { - $w mark set insert end + $w mark set insert end } $w insert insert $s {input stdin} $w see insert } -# tkConsoleOutput -- +# ::tk::ConsoleOutput -- # # This routine is called directly by ConsolePutsCmd to cause a string # to be displayed in the console. @@ -444,12 +552,14 @@ proc tkConsoleInsert {w s} { # dest - The output tag to be used: either "stderr" or "stdout". # string - The string to be displayed. -proc tkConsoleOutput {dest string} { - .console insert output $string $dest - .console see insert +proc ::tk::ConsoleOutput {dest string} { + set w .console + $w insert output $string $dest + ::tk::console::ConstrainBuffer $w $::tk::console::maxLines + $w see insert } -# tkConsoleExit -- +# ::tk::ConsoleExit -- # # This routine is called by ConsoleEventProc when the main window of # the application is destroyed. Don't call exit - that probably already @@ -458,28 +568,367 @@ proc tkConsoleOutput {dest string} { # Arguments: # None. -proc tkConsoleExit {} { +proc ::tk::ConsoleExit {} { destroy . } -# tkConsoleAbout -- +# ::tk::ConsoleAbout -- # # This routine displays an About box to show Tcl/Tk version info. # # Arguments: # None. -proc tkConsoleAbout {} { - global tk_patchLevel - tk_messageBox -type ok -message "Tcl for Windows -Copyright \251 2000 Scriptics Corporation +proc ::tk::ConsoleAbout {} { + tk_messageBox -type ok -message "[mc {Tcl for Windows}] -Tcl [info patchlevel] -Tk $tk_patchLevel" +Tcl $::tcl_patchLevel +Tk $::tk_patchLevel" } -# now initialize the console +# ::tk::console::TagProc -- +# +# Tags a procedure in the console if it's recognized +# This procedure is not perfect. However, making it perfect wastes +# too much CPU time... +# +# Arguments: +# w - console text widget + +proc ::tk::console::TagProc w { + if {!$::tk::console::magicKeys} { return } + set exp "\[^\\\\\]\[\[ \t\n\r\;{}\"\$\]" + set i [$w search -backwards -regexp $exp insert-1c promptEnd-1c] + if {$i == ""} {set i promptEnd} else {append i +2c} + regsub -all "\[\[\\\\\\?\\*\]" [$w get $i "insert-1c wordend"] {\\\0} c + if {[llength [EvalAttached [list info commands $c]]]} { + $w tag add proc $i "insert-1c wordend" + } else { + $w tag remove proc $i "insert-1c wordend" + } + if {[llength [EvalAttached [list info vars $c]]]} { + $w tag add var $i "insert-1c wordend" + } else { + $w tag remove var $i "insert-1c wordend" + } +} -tkConsoleInit +# ::tk::console::MatchPair -- +# +# Blinks a matching pair of characters +# c2 is assumed to be at the text index 'insert'. +# This proc is really loopy and took me an hour to figure out given +# all possible combinations with escaping except for escaped \'s. +# It doesn't take into account possible commenting... Oh well. If +# anyone has something better, I'd like to see/use it. This is really +# only efficient for small contexts. +# +# Arguments: +# w - console text widget +# c1 - first char of pair +# c2 - second char of pair +# +# Calls: ::tk::console::Blink + +proc ::tk::console::MatchPair {w c1 c2 {lim 1.0}} { + if {!$::tk::console::magicKeys} { return } + if {[string compare {} [set ix [$w search -back $c1 insert $lim]]]} { + while { + [string match {\\} [$w get $ix-1c]] && + [string compare {} [set ix [$w search -back $c1 $ix-1c $lim]]] + } {} + set i1 insert-1c + while {[string compare {} $ix]} { + set i0 $ix + set j 0 + while {[string compare {} [set i0 [$w search $c2 $i0 $i1]]]} { + append i0 +1c + if {[string match {\\} [$w get $i0-2c]]} continue + incr j + } + if {!$j} break + set i1 $ix + while {$j && [string compare {} \ + [set ix [$w search -back $c1 $ix $lim]]]} { + if {[string match {\\} [$w get $ix-1c]]} continue + incr j -1 + } + } + if {[string match {} $ix]} { set ix [$w index $lim] } + } else { set ix [$w index $lim] } + if {$::tk::console::blinkRange} { + Blink $w $ix [$w index insert] + } else { + Blink $w $ix $ix+1c [$w index insert-1c] [$w index insert] + } +} +# ::tk::console::MatchQuote -- +# +# Blinks between matching quotes. +# Blinks just the quote if it's unmatched, otherwise blinks quoted string +# The quote to match is assumed to be at the text index 'insert'. +# +# Arguments: +# w - console text widget +# +# Calls: ::tk::console::Blink + +proc ::tk::console::MatchQuote {w {lim 1.0}} { + if {!$::tk::console::magicKeys} { return } + set i insert-1c + set j 0 + while {[string compare [set i [$w search -back \" $i $lim]] {}]} { + if {[string match {\\} [$w get $i-1c]]} continue + if {!$j} {set i0 $i} + incr j + } + if {$j&1} { + if {$::tk::console::blinkRange} { + Blink $w $i0 [$w index insert] + } else { + Blink $w $i0 $i0+1c [$w index insert-1c] [$w index insert] + } + } else { + Blink $w [$w index insert-1c] [$w index insert] + } +} + +# ::tk::console::Blink -- +# +# Blinks between n index pairs for a specified duration. +# +# Arguments: +# w - console text widget +# i1 - start index to blink region +# i2 - end index of blink region +# dur - duration in usecs to blink for +# +# Outputs: +# blinks selected characters in $w + +proc ::tk::console::Blink {w args} { + eval [list $w tag add blink] $args + after $::tk::console::blinkTime [list $w] tag remove blink $args +} + +# ::tk::console::ConstrainBuffer -- +# +# This limits the amount of data in the text widget +# Called by Prompt and ConsoleOutput +# +# Arguments: +# w - console text widget +# size - # of lines to constrain to +# +# Outputs: +# may delete data in console widget + +proc ::tk::console::ConstrainBuffer {w size} { + if {[$w index end] > $size} { + $w delete 1.0 [expr {int([$w index end])-$size}].0 + } +} +# ::tk::console::Expand -- +# +# Arguments: +# ARGS: w - text widget in which to expand str +# type - type of expansion (path / proc / variable) +# +# Calls: ::tk::console::Expand(Pathname|Procname|Variable) +# +# Outputs: The string to match is expanded to the longest possible match. +# If ::tk::console::showMatches is non-zero and the longest match +# equaled the string to expand, then all possible matches are +# output to stdout. Triggers bell if no matches are found. +# +# Returns: number of matches found + +proc ::tk::console::Expand {w {type ""}} { + set exp "\[^\\\\\]\[\[ \t\n\r\\\{\"\\\\\$\]" + set tmp [$w search -backwards -regexp $exp insert-1c promptEnd-1c] + if {$tmp == ""} {set tmp promptEnd} else {append tmp +2c} + if {[$w compare $tmp >= insert]} { return } + set str [$w get $tmp insert] + switch -glob $type { + path* { set res [ExpandPathname $str] } + proc* { set res [ExpandProcname $str] } + var* { set res [ExpandVariable $str] } + default { + set res {} + foreach t {Pathname Procname Variable} { + if {![catch {Expand$t $str} res] && ($res != "")} { break } + } + } + } + set len [llength $res] + if {$len} { + set repl [lindex $res 0] + $w delete $tmp insert + $w insert $tmp $repl {input stdin} + if {($len > 1) && $::tk::console::showMatches \ + && [string equal $repl $str]} { + puts stdout [lsort [lreplace $res 0 0]] + } + } else { bell } + return [incr len -1] +} + +# ::tk::console::ExpandPathname -- +# +# Expand a file pathname based on $str +# This is based on UNIX file name conventions +# +# Arguments: +# str - partial file pathname to expand +# +# Calls: ::tk::console::ExpandBestMatch +# +# Returns: list containing longest unique match followed by all the +# possible further matches + +proc ::tk::console::ExpandPathname str { + set pwd [EvalAttached pwd] + if {[catch {EvalAttached [list cd [file dirname $str]]} err]} { + return -code error $err + } + set dir [file tail $str] + ## Check to see if it was known to be a directory and keep the trailing + ## slash if so (file tail cuts it off) + if {[string match */ $str]} { append dir / } + if {[catch {lsort [EvalAttached [list glob $dir*]]} m]} { + set match {} + } else { + if {[llength $m] > 1} { + global tcl_platform + if {[string match windows $tcl_platform(platform)]} { + ## Windows is screwy because it's case insensitive + set tmp [ExpandBestMatch [string tolower $m] \ + [string tolower $dir]] + ## Don't change case if we haven't changed the word + if {[string length $dir]==[string length $tmp]} { + set tmp $dir + } + } else { + set tmp [ExpandBestMatch $m $dir] + } + if {[string match ?*/* $str]} { + set tmp [file dirname $str]/$tmp + } elseif {[string match /* $str]} { + set tmp /$tmp + } + regsub -all { } $tmp {\\ } tmp + set match [linsert $m 0 $tmp] + } else { + ## This may look goofy, but it handles spaces in path names + eval append match $m + if {[file isdir $match]} {append match /} + if {[string match ?*/* $str]} { + set match [file dirname $str]/$match + } elseif {[string match /* $str]} { + set match /$match + } + regsub -all { } $match {\\ } match + ## Why is this one needed and the ones below aren't!! + set match [list $match] + } + } + EvalAttached [list cd $pwd] + return $match +} + +# ::tk::console::ExpandProcname -- +# +# Expand a tcl proc name based on $str +# +# Arguments: +# str - partial proc name to expand +# +# Calls: ::tk::console::ExpandBestMatch +# +# Returns: list containing longest unique match followed by all the +# possible further matches + +proc ::tk::console::ExpandProcname str { + set match [EvalAttached [list info commands $str*]] + if {[llength $match] == 0} { + set ns [EvalAttached \ + "namespace children \[namespace current\] [list $str*]"] + if {[llength $ns]==1} { + set match [EvalAttached [list info commands ${ns}::*]] + } else { + set match $ns + } + } + if {[llength $match] > 1} { + regsub -all { } [ExpandBestMatch $match $str] {\\ } str + set match [linsert $match 0 $str] + } else { + regsub -all { } $match {\\ } match + } + return $match +} + +# ::tk::console::ExpandVariable -- +# +# Expand a tcl variable name based on $str +# +# Arguments: +# str - partial tcl var name to expand +# +# Calls: ::tk::console::ExpandBestMatch +# +# Returns: list containing longest unique match followed by all the +# possible further matches + +proc ::tk::console::ExpandVariable str { + if {[regexp {([^\(]*)\((.*)} $str junk ary str]} { + ## Looks like they're trying to expand an array. + set match [EvalAttached [list array names $ary $str*]] + if {[llength $match] > 1} { + set vars $ary\([ExpandBestMatch $match $str] + foreach var $match {lappend vars $ary\($var\)} + return $vars + } else {set match $ary\($match\)} + ## Space transformation avoided for array names. + } else { + set match [EvalAttached [list info vars $str*]] + if {[llength $match] > 1} { + regsub -all { } [ExpandBestMatch $match $str] {\\ } str + set match [linsert $match 0 $str] + } else { + regsub -all { } $match {\\ } match + } + } + return $match +} + +# ::tk::console::ExpandBestMatch -- +# +# Finds the best unique match in a list of names. +# The extra $e in this argument allows us to limit the innermost loop a little +# further. This improves speed as $l becomes large or $e becomes long. +# +# Arguments: +# l - list to find best unique match in +# e - currently best known unique match +# +# Returns: longest unique match in the list + +proc ::tk::console::ExpandBestMatch {l {e {}}} { + set ec [lindex $l 0] + if {[llength $l]>1} { + set e [string length $e]; incr e -1 + set ei [string length $ec]; incr ei -1 + foreach l $l { + while {$ei>=$e && [string first $ec $l]} { + set ec [string range $ec 0 [incr ei -1]] + } + } + } + return $ec +} + +# now initialize the console +::tk::ConsoleInit diff --git a/tk/library/demos/README b/tk/library/demos/README index 229c48707f2..b8dd11f60fa 100644 --- a/tk/library/demos/README +++ b/tk/library/demos/README @@ -44,4 +44,3 @@ browse - A simple directory browser. Invoke it with and argument Control-c and control-q cause the program to exit. RCS: @(#) $Id$ - diff --git a/tk/library/demos/arrow.tcl b/tk/library/demos/arrow.tcl index f3f00c1084c..c2d0d4b7e9e 100644 --- a/tk/library/demos/arrow.tcl +++ b/tk/library/demos/arrow.tcl @@ -33,68 +33,69 @@ proc arrowSetup c { # Create the arrow and outline. $c delete all - eval "$c create line $v(x1) $v(y) $v(x2) $v(y) -width [expr 10*$v(width)] \ - -arrowshape {[expr 10*$v(a)] [expr 10*$v(b)] [expr 10*$v(c)]} \ - -arrow last $v(bigLineStyle)" - set xtip [expr $v(x2)-10*$v(b)] - set deltaY [expr 10*$v(c)+5*$v(width)] - $c create line $v(x2) $v(y) $xtip [expr $v(y)+$deltaY] \ - [expr $v(x2)-10*$v(a)] $v(y) $xtip [expr $v(y)-$deltaY] \ + eval {$c create line $v(x1) $v(y) $v(x2) $v(y) -arrow last \ + -width [expr {10*$v(width)}] -arrowshape [list \ + [expr {10*$v(a)}] [expr {10*$v(b)}] [expr {10*$v(c)}]]} \ + $v(bigLineStyle) + set xtip [expr {$v(x2)-10*$v(b)}] + set deltaY [expr {10*$v(c)+5*$v(width)}] + $c create line $v(x2) $v(y) $xtip [expr {$v(y)+$deltaY}] \ + [expr {$v(x2)-10*$v(a)}] $v(y) $xtip [expr {$v(y)-$deltaY}] \ $v(x2) $v(y) -width 2 -capstyle round -joinstyle round # Create the boxes for reshaping the line and arrowhead. - eval "$c create rect [expr $v(x2)-10*$v(a)-5] [expr $v(y)-5] \ - [expr $v(x2)-10*$v(a)+5] [expr $v(y)+5] $v(boxStyle) \ - -tags {box1 box}" - eval "$c create rect [expr $xtip-5] [expr $v(y)-$deltaY-5] \ - [expr $xtip+5] [expr $v(y)-$deltaY+5] $v(boxStyle) \ - -tags {box2 box}" - eval "$c create rect [expr $v(x1)-5] [expr $v(y)-5*$v(width)-5] \ - [expr $v(x1)+5] [expr $v(y)-5*$v(width)+5] $v(boxStyle) \ - -tags {box3 box}" + eval {$c create rect [expr {$v(x2)-10*$v(a)-5}] [expr {$v(y)-5}] \ + [expr {$v(x2)-10*$v(a)+5}] [expr {$v(y)+5}] \ + -tags {box1 box}} $v(boxStyle) + eval {$c create rect [expr {$xtip-5}] [expr {$v(y)-$deltaY-5}] \ + [expr {$xtip+5}] [expr {$v(y)-$deltaY+5}] \ + -tags {box2 box}} $v(boxStyle) + eval {$c create rect [expr {$v(x1)-5}] [expr {$v(y)-5*$v(width)-5}] \ + [expr {$v(x1)+5}] [expr {$v(y)-5*$v(width)+5}] \ + -tags {box3 box}} $v(boxStyle) if {$cur != ""} { eval $c itemconfigure $cur $v(activeStyle) } # Create three arrows in actual size with the same parameters - $c create line [expr $v(x2)+50] 0 [expr $v(x2)+50] 1000 \ + $c create line [expr {$v(x2)+50}] 0 [expr {$v(x2)+50}] 1000 \ -width 2 - set tmp [expr $v(x2)+100] - $c create line $tmp [expr $v(y)-125] $tmp [expr $v(y)-75] \ + set tmp [expr {$v(x2)+100}] + $c create line $tmp [expr {$v(y)-125}] $tmp [expr {$v(y)-75}] \ -width $v(width) \ -arrow both -arrowshape "$v(a) $v(b) $v(c)" - $c create line [expr $tmp-25] $v(y) [expr $tmp+25] $v(y) \ + $c create line [expr {$tmp-25}] $v(y) [expr {$tmp+25}] $v(y) \ -width $v(width) \ -arrow both -arrowshape "$v(a) $v(b) $v(c)" - $c create line [expr $tmp-25] [expr $v(y)+75] [expr $tmp+25] \ - [expr $v(y)+125] -width $v(width) \ + $c create line [expr {$tmp-25}] [expr {$v(y)+75}] [expr {$tmp+25}] \ + [expr {$v(y)+125}] -width $v(width) \ -arrow both -arrowshape "$v(a) $v(b) $v(c)" # Create a bunch of other arrows and text items showing the # current dimensions. - set tmp [expr $v(x2)+10] - $c create line $tmp [expr $v(y)-5*$v(width)] \ - $tmp [expr $v(y)-$deltaY] \ + set tmp [expr {$v(x2)+10}] + $c create line $tmp [expr {$v(y)-5*$v(width)}] \ + $tmp [expr {$v(y)-$deltaY}] \ -arrow both -arrowshape $v(smallTips) - $c create text [expr $v(x2)+15] [expr $v(y)-$deltaY+5*$v(c)] \ + $c create text [expr {$v(x2)+15}] [expr {$v(y)-$deltaY+5*$v(c)}] \ -text $v(c) -anchor w - set tmp [expr $v(x1)-10] - $c create line $tmp [expr $v(y)-5*$v(width)] \ - $tmp [expr $v(y)+5*$v(width)] \ + set tmp [expr {$v(x1)-10}] + $c create line $tmp [expr {$v(y)-5*$v(width)}] \ + $tmp [expr {$v(y)+5*$v(width)}] \ -arrow both -arrowshape $v(smallTips) - $c create text [expr $v(x1)-15] $v(y) -text $v(width) -anchor e - set tmp [expr $v(y)+5*$v(width)+10*$v(c)+10] - $c create line [expr $v(x2)-10*$v(a)] $tmp $v(x2) $tmp \ + $c create text [expr {$v(x1)-15}] $v(y) -text $v(width) -anchor e + set tmp [expr {$v(y)+5*$v(width)+10*$v(c)+10}] + $c create line [expr {$v(x2)-10*$v(a)}] $tmp $v(x2) $tmp \ -arrow both -arrowshape $v(smallTips) - $c create text [expr $v(x2)-5*$v(a)] [expr $tmp+5] \ + $c create text [expr {$v(x2)-5*$v(a)}] [expr {$tmp+5}] \ -text $v(a) -anchor n - set tmp [expr $tmp+25] - $c create line [expr $v(x2)-10*$v(b)] $tmp $v(x2) $tmp \ + set tmp [expr {$tmp+25}] + $c create line [expr {$v(x2)-10*$v(b)}] $tmp $v(x2) $tmp \ -arrow both -arrowshape $v(smallTips) - $c create text [expr $v(x2)-5*$v(b)] [expr $tmp+5] \ + $c create text [expr {$v(x2)-5*$v(b)}] [expr {$tmp+5}] \ -text $v(b) -anchor n $c create text $v(x1) 310 -text "-width $v(width)" \ @@ -168,7 +169,7 @@ bind $c "arrowSetup $c" proc arrowMove1 {c x y} { upvar #0 demo_arrowInfo v - set newA [expr ($v(x2)+5-round([$c canvasx $x]))/10] + set newA [expr {($v(x2)+5-round([$c canvasx $x]))/10}] if {$newA < 0} { set newA 0 } @@ -176,7 +177,7 @@ proc arrowMove1 {c x y} { set newA 25 } if {$newA != $v(a)} { - $c move box1 [expr 10*($v(a)-$newA)] 0 + $c move box1 [expr {10*($v(a)-$newA)}] 0 set v(a) $newA } } @@ -192,14 +193,14 @@ proc arrowMove1 {c x y} { proc arrowMove2 {c x y} { upvar #0 demo_arrowInfo v - set newB [expr ($v(x2)+5-round([$c canvasx $x]))/10] + set newB [expr {($v(x2)+5-round([$c canvasx $x]))/10}] if {$newB < 0} { set newB 0 } if {$newB > 25} { set newB 25 } - set newC [expr ($v(y)+5-round([$c canvasy $y])-5*$v(width))/10] + set newC [expr {($v(y)+5-round([$c canvasy $y])-5*$v(width))/10}] if {$newC < 0} { set newC 0 } @@ -207,7 +208,7 @@ proc arrowMove2 {c x y} { set newC 20 } if {($newB != $v(b)) || ($newC != $v(c))} { - $c move box2 [expr 10*($v(b)-$newB)] [expr 10*($v(c)-$newC)] + $c move box2 [expr {10*($v(b)-$newB)}] [expr {10*($v(c)-$newC)}] set v(b) $newB set v(c) $newC } @@ -224,7 +225,7 @@ proc arrowMove2 {c x y} { proc arrowMove3 {c x y} { upvar #0 demo_arrowInfo v - set newWidth [expr ($v(y)+2-round([$c canvasy $y]))/5] + set newWidth [expr {($v(y)+2-round([$c canvasy $y]))/5}] if {$newWidth < 0} { set newWidth 0 } @@ -232,8 +233,7 @@ proc arrowMove3 {c x y} { set newWidth 20 } if {$newWidth != $v(width)} { - $c move box3 0 [expr 5*($v(width)-$newWidth)] + $c move box3 0 [expr {5*($v(width)-$newWidth)}] set v(width) $newWidth } } - diff --git a/tk/library/demos/bind.tcl b/tk/library/demos/bind.tcl index a55cb00d367..c2b2a2eb462 100644 --- a/tk/library/demos/bind.tcl +++ b/tk/library/demos/bind.tcl @@ -77,4 +77,3 @@ $w.text tag bind d6 <1> {source [file join $tk_library demos cscroll.tcl]} $w.text mark set insert 0.0 $w.text configure -state disabled - diff --git a/tk/library/demos/bitmap.tcl b/tk/library/demos/bitmap.tcl index 5345b69ca05..e69187eb40d 100644 --- a/tk/library/demos/bitmap.tcl +++ b/tk/library/demos/bitmap.tcl @@ -53,4 +53,3 @@ frame $w.frame bitmapRow $w.frame.0 error gray12 gray25 gray50 gray75 bitmapRow $w.frame.1 hourglass info question questhead warning pack $w.frame -side top -expand yes -fill both - diff --git a/tk/library/demos/browse b/tk/library/demos/browse index af553105baf..3ec0366d588 100755 --- a/tk/library/demos/browse +++ b/tk/library/demos/browse @@ -1,6 +1,6 @@ #!/bin/sh # the next line restarts using wish \ -exec wish "$0" "$@" +exec wish "$0" ${1+"$@"} # browse -- # This script generates a directory browser, which lists the working @@ -24,29 +24,35 @@ wm minsize . 1 1 # the file is a regular file then the Mx editor is invoked to display # the file. +set browseScript [file join [pwd] $argv0] proc browse {dir file} { - global env + global env browseScript if {[string compare $dir "."] != 0} {set file $dir/$file} - if [file isdirectory $file] { - exec browse $file & - } else { - if [file isfile $file] { - if [info exists env(EDITOR)] { + switch [file type $file] { + directory { + exec [info nameofexecutable] $browseScript $file & + } + file { + if {[info exists env(EDITOR)]} { eval exec $env(EDITOR) $file & } else { exec xedit $file & } - } else { + } + default { puts stdout "\"$file\" isn't a directory or regular file" } } } -# Fill the listbox with a list of all the files in the directory (run -# the "ls" command to get that information). +# Fill the listbox with a list of all the files in the directory. -if $argc>0 {set dir [lindex $argv 0]} else {set dir "."} -foreach i [exec ls -a $dir] { +if {$argc>0} {set dir [lindex $argv 0]} else {set dir "."} +foreach i [lsort [glob * .* *.*]] { + if {[file type $i] eq "directory"} { + # Safe to do since it is still a directory. + append i / + } .list insert end $i } @@ -55,3 +61,6 @@ foreach i [exec ls -a $dir] { bind all {destroy .} bind .list {foreach i [selection get] {browse $dir $i}} +# Local Variables: +# mode: tcl +# End: diff --git a/tk/library/demos/button.tcl b/tk/library/demos/button.tcl index 651706db8d2..fe00a1c99cb 100644 --- a/tk/library/demos/button.tcl +++ b/tk/library/demos/button.tcl @@ -34,4 +34,3 @@ button $w.b3 -text "Sea Green" -width 10 \ button $w.b4 -text "Yellow" -width 10 \ -command "$w config -bg Yellow1; $w.buttons config -bg Yellow1" pack $w.b1 $w.b2 $w.b3 $w.b4 -side top -expand yes -pady 2 - diff --git a/tk/library/demos/check.tcl b/tk/library/demos/check.tcl index 000ef61ae84..f863b5796c7 100644 --- a/tk/library/demos/check.tcl +++ b/tk/library/demos/check.tcl @@ -31,4 +31,3 @@ checkbutton $w.b1 -text "Wipers OK" -variable wipers -relief flat checkbutton $w.b2 -text "Brakes OK" -variable brakes -relief flat checkbutton $w.b3 -text "Driver Sober" -variable sober -relief flat pack $w.b1 $w.b2 $w.b3 -side top -pady 2 -anchor w - diff --git a/tk/library/demos/clrpick.tcl b/tk/library/demos/clrpick.tcl index fc09ae44044..983cbe1deb4 100644 --- a/tk/library/demos/clrpick.tcl +++ b/tk/library/demos/clrpick.tcl @@ -38,7 +38,7 @@ proc setColor {w button name options} { set initialColor [$button cget -$name] set color [tk_chooseColor -title "Choose a $name color" -parent $w \ -initialcolor $initialColor] - if [string compare $color ""] { + if {[string compare $color ""]} { setColor_helper $w $options $color } grab release $w @@ -54,4 +54,3 @@ proc setColor_helper {w options color} { setColor_helper $child $options $color } } - diff --git a/tk/library/demos/colors.tcl b/tk/library/demos/colors.tcl index 9d95ed890a5..aad1d1dde45 100644 --- a/tk/library/demos/colors.tcl +++ b/tk/library/demos/colors.tcl @@ -99,4 +99,3 @@ $w.frame.list insert 0 gray60 gray70 gray80 gray85 gray90 gray95 \ purple2 purple3 purple4 MediumPurple1 MediumPurple2 \ MediumPurple3 MediumPurple4 thistle1 thistle2 thistle3 \ thistle4 - diff --git a/tk/library/demos/cscroll.tcl b/tk/library/demos/cscroll.tcl index 5897dcb26cd..aeabc181662 100644 --- a/tk/library/demos/cscroll.tcl +++ b/tk/library/demos/cscroll.tcl @@ -48,9 +48,9 @@ set bg [lindex [$c config -bg] 4] 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 \ + $c create rect ${x}c ${y}c [expr {$x+2}]c [expr {$y+2}]c \ -outline black -fill $bg -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 } } @@ -65,14 +65,14 @@ proc scrollEnter canvas { global oldFill set id [$canvas find withtag current] if {[lsearch [$canvas gettags current] text] >= 0} { - set id [expr $id-1] + set id [expr {$id-1}] } 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 + $canvas itemconfigure [expr {$id+1}] -fill white } } @@ -80,18 +80,17 @@ proc scrollLeave canvas { global oldFill set id [$canvas find withtag current] if {[lsearch [$canvas gettags current] text] >= 0} { - set id [expr $id-1] + set id [expr {$id-1}] } $canvas itemconfigure $id -fill $oldFill - $canvas itemconfigure [expr $id+1] -fill black + $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] + set id [expr {$id+1}] } puts stdout "You buttoned at [lindex [$canvas itemconf $id -text] 4]" } - diff --git a/tk/library/demos/ctext.tcl b/tk/library/demos/ctext.tcl index 83eac45e611..d5efcc3da23 100644 --- a/tk/library/demos/ctext.tcl +++ b/tk/library/demos/ctext.tcl @@ -58,7 +58,7 @@ $c bind text <2> "textPaste $c @%x,%y" # to be edited. proc mkTextConfig {w x y option value color} { - set item [$w create rect [expr $x] [expr $y] [expr $x+30] [expr $y+30] \ + 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 addtag config withtag $item @@ -68,19 +68,20 @@ set x 50 set y 50 set color LightSkyBlue1 mkTextConfig $c $x $y -anchor se $color -mkTextConfig $c [expr $x+30] [expr $y] -anchor s $color -mkTextConfig $c [expr $x+60] [expr $y] -anchor sw $color -mkTextConfig $c [expr $x] [expr $y+30] -anchor e $color -mkTextConfig $c [expr $x+30] [expr $y+30] -anchor center $color -mkTextConfig $c [expr $x+60] [expr $y+30] -anchor w $color -mkTextConfig $c [expr $x] [expr $y+60] -anchor ne $color -mkTextConfig $c [expr $x+30] [expr $y+60] -anchor n $color -mkTextConfig $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] \ +mkTextConfig $c [expr {$x+30}] [expr {$y }] -anchor s $color +mkTextConfig $c [expr {$x+60}] [expr {$y }] -anchor sw $color +mkTextConfig $c [expr {$x }] [expr {$y+30}] -anchor e $color +mkTextConfig $c [expr {$x+30}] [expr {$y+30}] -anchor center $color +mkTextConfig $c [expr {$x+60}] [expr {$y+30}] -anchor w $color +mkTextConfig $c [expr {$x }] [expr {$y+60}] -anchor ne $color +mkTextConfig $c [expr {$x+30}] [expr {$y+60}] -anchor n $color +mkTextConfig $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 create text [expr $x+45] [expr $y-5] -text {Text Position} -anchor s \ - -font {Times 24} -fill brown +$c create text [expr {$x+45}] [expr {$y-5}] \ + -text {Text Position} -anchor s -font {Times 24} -fill brown # Lastly, create some items that allow the text's justification to be # changed. @@ -89,10 +90,10 @@ set x 350 set y 50 set color SeaGreen2 mkTextConfig $c $x $y -justify left $color -mkTextConfig $c [expr $x+30] [expr $y] -justify center $color -mkTextConfig $c [expr $x+60] [expr $y] -justify right $color -$c create text [expr $x+45] [expr $y-5] -text {Justification} -anchor s \ - -font {Times 24} -fill brown +mkTextConfig $c [expr {$x+30}] $y -justify center $color +mkTextConfig $c [expr {$x+60}] $y -justify right $color +$c create text [expr {$x+45}] [expr {$y-5}] \ + -text {Justification} -anchor s -font {Times 24} -fill brown $c bind config "textEnter $c" $c bind config "$c itemconf current -fill \$textConfigFill" @@ -131,7 +132,7 @@ proc textB1Move {w x y} { } proc textBs {w} { - if ![catch {$w dchars text sel.first sel.last}] { + if {![catch {$w dchars text sel.first sel.last}]} { return } set char [expr {[$w index text insert] - 1}] @@ -139,9 +140,8 @@ proc textBs {w} { } proc textDel {w} { - if ![catch {$w dchars text sel.first sel.last}] { + if {![catch {$w dchars text sel.first sel.last}]} { return } $w dchars text insert } - diff --git a/tk/library/demos/dialog1.tcl b/tk/library/demos/dialog1.tcl index 63f97fef750..0a1b48d4974 100644 --- a/tk/library/demos/dialog1.tcl +++ b/tk/library/demos/dialog1.tcl @@ -13,4 +13,3 @@ switch $i { 1 {puts "You pressed Cancel"} 2 {showCode .dialog1} } - diff --git a/tk/library/demos/dialog2.tcl b/tk/library/demos/dialog2.tcl index 6451c8dff45..bc074455b21 100644 --- a/tk/library/demos/dialog2.tcl +++ b/tk/library/demos/dialog2.tcl @@ -10,11 +10,10 @@ after idle { after 100 { grab -global .dialog2 } -set i [tk_dialog .dialog2 "Dialog with local grab" {This dialog box uses a global grab, so it prevents you from interacting with anything on your display until you invoke one of the buttons below. Global grabs are almost always a bad idea; don't use them unless you're truly desperate.} warning 0 OK Cancel {Show Code}] +set i [tk_dialog .dialog2 "Dialog with global grab" {This dialog box uses a global grab, so it prevents you from interacting with anything on your display until you invoke one of the buttons below. Global grabs are almost always a bad idea; don't use them unless you're truly desperate.} warning 0 OK Cancel {Show Code}] switch $i { 0 {puts "You pressed OK"} 1 {puts "You pressed Cancel"} 2 {showCode .dialog2} } - diff --git a/tk/library/demos/entry1.tcl b/tk/library/demos/entry1.tcl index 35d776c97b2..062eb45f489 100644 --- a/tk/library/demos/entry1.tcl +++ b/tk/library/demos/entry1.tcl @@ -34,4 +34,3 @@ $w.e1 insert 0 "Initial value" $w.e2 insert end "This entry contains a long value, much too long " $w.e2 insert end "to fit in the window at one time, so long in fact " $w.e2 insert end "that you'll have to scan or scroll to see the end." - diff --git a/tk/library/demos/entry2.tcl b/tk/library/demos/entry2.tcl index cf5c16c6c6d..87a91cb34d7 100644 --- a/tk/library/demos/entry2.tcl +++ b/tk/library/demos/entry2.tcl @@ -46,4 +46,3 @@ $w.frame.e1 insert 0 "Initial value" $w.frame.e2 insert end "This entry contains a long value, much too long " $w.frame.e2 insert end "to fit in the window at one time, so long in fact " $w.frame.e2 insert end "that you'll have to scan or scroll to see the end." - diff --git a/tk/library/demos/entry3.tcl b/tk/library/demos/entry3.tcl new file mode 100644 index 00000000000..54ad80fd1a6 --- /dev/null +++ b/tk/library/demos/entry3.tcl @@ -0,0 +1,187 @@ +# entry2.tcl -- +# +# This demonstration script creates several entry widgets whose +# permitted input is constrained in some way. It also shows off a +# password entry. +# +# RCS: @(#) $Id$ + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +set w .entry3 +catch {destroy $w} +toplevel $w +wm title $w "Constrained Entry Demonstration" +wm iconname $w "entry3" +positionWindow $w + + +label $w.msg -font $font -wraplength 5i -justify left -text "Four different\ + entries are displayed below. You can add characters by pointing,\ + clicking and typing, though each is constrained in what it will\ + accept. The first only accepts integers or the empty string\ + (checking when focus leaves it) and will flash to indicate any\ + problem. The second only accepts strings with fewer than ten\ + characters and sounds the bell when an attempt to go over the limit\ + is made. The third accepts US phone numbers, mapping letters to\ + their digit equivalent and sounding the bell on encountering an\ + illegal character or if trying to type over a character that is not\ + a digit. The fourth is a password field that accepts up to eight\ + characters (silently ignoring further ones), and displaying them as\ + asterisk characters." + +frame $w.buttons +button $w.buttons.dismiss -text Dismiss -command "destroy $w" +button $w.buttons.code -text "See Code" -command "showCode $w" +pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 + + +# focusAndFlash -- +# Error handler for entry widgets that forces the focus onto the +# widget and makes the widget flash by exchanging the foreground and +# background colours at intervals of 200ms (i.e. at approximately +# 2.5Hz). +# +# Arguments: +# W - Name of entry widget to flash +# fg - Initial foreground colour +# bg - Initial background colour +# count - Counter to control the number of times flashed + +proc focusAndFlash {W fg bg {count 9}} { + focus -force $W + if {$count<1} { + $W configure -foreground $fg -background $bg + } else { + if {$count%2} { + $W configure -foreground $bg -background $fg + } else { + $W configure -foreground $fg -background $bg + } + after 200 [list focusAndFlash $W $fg $bg [expr {$count-1}]] + } +} + +labelframe $w.l1 -text "Integer Entry" +entry $w.l1.e -validate focus -vcmd {string is integer %P} +$w.l1.e configure -invalidcommand \ + "focusAndFlash %W [$w.l1.e cget -fg] [$w.l1.e cget -bg]" +pack $w.l1.e -fill x -expand 1 -padx 1m -pady 1m + +labelframe $w.l2 -text "Length-Constrained Entry" +entry $w.l2.e -validate key -invcmd bell -vcmd {expr {[string length %P]<10}} +pack $w.l2.e -fill x -expand 1 -padx 1m -pady 1m + +### PHONE NUMBER ENTRY ### +# Note that the source to this is quite a bit longer as the behaviour +# demonstrated is a lot more ambitious than with the others. + +# Initial content for the third entry widget +set entry3content "1-(000)-000-0000" +# Mapping from alphabetic characters to numbers. This is probably +# wrong, but it is the only mapping I have; the UK doesn't really go +# for associating letters with digits for some reason. +set phoneNumberMap {} +foreach {chars digit} {abc 2 def 3 ghi 4 jkl 5 mno 6 pqrs 7 tuv 8 wxyz 9} { + foreach char [split $chars ""] { + lappend phoneNumberMap $char $digit [string toupper $char] $digit + } +} + +# validatePhoneChange -- +# Checks that the replacement (mapped to a digit) of the given +# character in an entry widget at the given position will leave a +# valid phone number in the widget. +# +# W - The entry widget to validate +# vmode - The widget's validation mode +# idx - The index where replacement is to occur +# char - The character (or string, though that will always be +# refused) to be overwritten at that point. + +proc validatePhoneChange {W vmode idx char} { + global phoneNumberMap entry3content + if {$idx == -1} {return 1} + after idle [list $W configure -validate $vmode -invcmd bell] + if { + !($idx<3 || $idx==6 || $idx==7 || $idx==11 || $idx>15) && + [string match {[0-9A-Za-z]} $char] + } then { + $W delete $idx + $W insert $idx [string map $phoneNumberMap $char] + after idle [list phoneSkipRight $W -1] + return 1 + } + return 0 +} + +# phoneSkipLeft -- +# Skip over fixed characters in a phone-number string when moving left. +# +# Arguments: +# W - The entry widget containing the phone-number. + +proc phoneSkipLeft {W} { + set idx [$W index insert] + if {$idx == 8} { + # Skip back two extra characters + $W icursor [incr idx -2] + } elseif {$idx == 7 || $idx == 12} { + # Skip back one extra character + $W icursor [incr idx -1] + } elseif {$idx <= 3} { + # Can't move any further + bell + return -code break + } +} + +# phoneSkipRight -- +# Skip over fixed characters in a phone-number string when moving right. +# +# Arguments: +# W - The entry widget containing the phone-number. +# add - Offset to add to index before calculation (used by validation.) + +proc phoneSkipRight {W {add 0}} { + set idx [$W index insert] + if {$idx+$add == 5} { + # Skip forward two extra characters + $W icursor [incr idx 2] + } elseif {$idx+$add == 6 || $idx+$add == 10} { + # Skip forward one extra character + $W icursor [incr idx] + } elseif {$idx+$add == 15 && !$add} { + # Can't move any further + bell + return -code break + } +} + +labelframe $w.l3 -text "US Phone-Number Entry" +entry $w.l3.e -validate key -invcmd bell -textvariable entry3content \ + -vcmd {validatePhoneChange %W %v %i %S} +# Click to focus goes to the first editable character... +bind $w.l3.e { + if {"%d" ne "NotifyAncestor"} { + %W icursor 3 + after idle {%W selection clear} + } +} +bind $w.l3.e {phoneSkipLeft %W} +bind $w.l3.e {phoneSkipRight %W} +pack $w.l3.e -fill x -expand 1 -padx 1m -pady 1m + +labelframe $w.l4 -text "Password Entry" +entry $w.l4.e -validate key -show "*" -vcmd {expr {[string length %P]<=8}} +pack $w.l4.e -fill x -expand 1 -padx 1m -pady 1m + +lower [frame $w.mid] +grid $w.l1 $w.l2 -in $w.mid -padx 3m -pady 1m -sticky ew +grid $w.l3 $w.l4 -in $w.mid -padx 3m -pady 1m -sticky ew +grid columnconfigure $w.mid {0 1} -uniform 1 +pack $w.msg -side top +pack $w.buttons -side bottom -fill x -pady 2m +pack $w.mid -fill both -expand 1 diff --git a/tk/library/demos/filebox.tcl b/tk/library/demos/filebox.tcl index fdfff8aa061..a0c32a585b7 100644 --- a/tk/library/demos/filebox.tcl +++ b/tk/library/demos/filebox.tcl @@ -35,7 +35,7 @@ foreach i {open save} { pack $f -fill x -padx 1c -pady 3 } -if ![string compare $tcl_platform(platform) unix] { +if {![string compare $tcl_platform(platform) unix]} { checkbutton $w.strict -text "Use Motif Style Dialog" \ -variable tk_strictMotif -onvalue 1 -offvalue 0 pack $w.strict -anchor c @@ -62,10 +62,9 @@ proc fileDialog {w ent operation} { set file [tk_getSaveFile -filetypes $types -parent $w \ -initialfile Untitled -defaultextension .txt] } - if [string compare $file ""] { + if {[string compare $file ""]} { $ent delete 0 end $ent insert 0 $file $ent xview end } } - diff --git a/tk/library/demos/floor.tcl b/tk/library/demos/floor.tcl index 6c62d3a4aad..d488eacea17 100644 --- a/tk/library/demos/floor.tcl +++ b/tk/library/demos/floor.tcl @@ -94,7 +94,7 @@ proc newRoom w { proc roomChanged {w args} { global currentRoom floorItems colors $w delete highlight - if [catch {set item $floorItems($currentRoom)}] { + if {[catch {set item $floorItems($currentRoom)}]} { return } set new [eval \ @@ -1368,4 +1368,3 @@ bind $c "$c scan dragto %x %y" bind $c "unset currentRoom" set currentRoom "" trace variable currentRoom w "roomChanged $c" - diff --git a/tk/library/demos/form.tcl b/tk/library/demos/form.tcl index f50c06d3e17..082cbf3d31f 100644 --- a/tk/library/demos/form.tcl +++ b/tk/library/demos/form.tcl @@ -38,4 +38,3 @@ $w.f5.label config -text Phone: pack $w.msg $w.f1 $w.f2 $w.f3 $w.f4 $w.f5 -side top -fill x bind $w "destroy $w" focus $w.f1.entry - diff --git a/tk/library/demos/hello b/tk/library/demos/hello index ec8b798cd2d..b163175fb93 100755 --- a/tk/library/demos/hello +++ b/tk/library/demos/hello @@ -17,3 +17,6 @@ button .hello -text "Hello, world" -command { } pack .hello +# Local Variables: +# mode: tcl +# End: diff --git a/tk/library/demos/hscale.tcl b/tk/library/demos/hscale.tcl index 13bf81c70ff..25ae7794a4d 100644 --- a/tk/library/demos/hscale.tcl +++ b/tk/library/demos/hscale.tcl @@ -38,11 +38,10 @@ $w.frame.scale set 75 proc setWidth {w width} { incr width 21 - set x2 [expr $width - 30] + set x2 [expr {$width - 30}] if {$x2 < 21} { set x2 21 } $w coords poly 20 15 20 35 $x2 35 $x2 45 $width 25 $x2 5 $x2 15 20 15 $w coords line 20 15 20 35 $x2 35 $x2 45 $width 25 $x2 5 $x2 15 20 15 } - diff --git a/tk/library/demos/icon.tcl b/tk/library/demos/icon.tcl index fece907b5a6..06cdc1fd63a 100644 --- a/tk/library/demos/icon.tcl +++ b/tk/library/demos/icon.tcl @@ -50,4 +50,3 @@ radiobutton $w.frame.left.b4 \ -bitmap @[file join $tk_library demos images noletter.bmp] \ -variable letters -value empty pack $w.frame.left.b3 $w.frame.left.b4 -side top -expand yes - diff --git a/tk/library/demos/image1.tcl b/tk/library/demos/image1.tcl index 30391f61b3e..820c9c1f10e 100644 --- a/tk/library/demos/image1.tcl +++ b/tk/library/demos/image1.tcl @@ -34,4 +34,3 @@ image create photo image1b \ label $w.l2 -image image1b -bd 1 -relief sunken pack $w.l1 $w.l2 -side top -padx .5m -pady .5m - diff --git a/tk/library/demos/image2.tcl b/tk/library/demos/image2.tcl index 827753cde2a..226202461d7 100644 --- a/tk/library/demos/image2.tcl +++ b/tk/library/demos/image2.tcl @@ -20,11 +20,28 @@ proc loadDir w { global dirName $w.f.list delete 0 end - foreach i [lsort [glob [file join $dirName *]]] { + foreach i [lsort [glob -directory $dirName *]] { $w.f.list insert end [file tail $i] } } +# selectAndLoadDir -- +# This procedure pops up a dialog to ask for a directory to load into +# the listobx and (if the user presses OK) reloads the directory +# listbox from the directory named in the demo's entry. +# +# Arguments: +# w - Name of the toplevel window of the demo. + +proc selectAndLoadDir w { + global dirName + set dir [tk_chooseDirectory -initialdir $dirName -parent $w -mustexist 1] + if {[string length $dir] != 0} { + set dirName $dir + loadDir $w + } +} + # loadImage -- # Given the name of the toplevel window of the demo and the mouse # position, extracts the directory entry under the mouse and loads @@ -57,14 +74,18 @@ button $w.buttons.dismiss -text Dismiss -command "destroy $w" button $w.buttons.code -text "See Code" -command "showCode $w" pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 -label $w.dirLabel -text "Directory:" +frame $w.mid +pack $w.mid -fill both -expand 1 + +labelframe $w.dir -text "Directory:" set dirName [file join $tk_library demos images] -entry $w.dirName -width 30 -textvariable dirName -bind $w.dirName "loadDir $w" -frame $w.spacer1 -height 3m -width 20 -label $w.fileLabel -text "File:" -frame $w.f -pack $w.dirLabel $w.dirName $w.spacer1 $w.fileLabel $w.f -side top -anchor w +entry $w.dir.e -width 30 -textvariable dirName +button $w.dir.b -pady 0 -padx 2m -text "Select Dir." \ + -command "selectAndLoadDir $w" +bind $w.dir.e "loadDir $w" +pack $w.dir.e -side left -fill both -padx 2m -pady 2m -expand true +pack $w.dir.b -side left -fill y -padx {0 2m} -pady 2m +labelframe $w.f -text "File:" -padx 2m -pady 2m listbox $w.f.list -width 20 -height 10 -yscrollcommand "$w.f.scroll set" scrollbar $w.f.scroll -command "$w.f.list yview" @@ -74,8 +95,10 @@ bind $w.f.list "loadImage $w %x %y" catch {image delete image2a} image create photo image2a -frame $w.spacer2 -height 3m -width 20 -label $w.imageLabel -text "Image:" -label $w.image -image image2a -pack $w.spacer2 $w.imageLabel $w.image -side top -anchor w +labelframe $w.image -text "Image:" +label $w.image.image -image image2a +pack $w.image.image -padx 2m -pady 2m +grid $w.dir - -sticky ew -padx 1m -pady 1m -in $w.mid +grid $w.f $w.image -sticky nw -padx 1m -pady 1m -in $w.mid +grid columnconfigure $w.mid 1 -weight 1 diff --git a/tk/library/demos/items.tcl b/tk/library/demos/items.tcl index 0f3ffde2eeb..fea5e8b1a5e 100644 --- a/tk/library/demos/items.tcl +++ b/tk/library/demos/items.tcl @@ -271,7 +271,7 @@ proc itemDrag {c x y} { global lastX lastY set x [$c canvasx $x] set y [$c canvasy $y] - $c move current [expr $x-$lastX] [expr $y-$lastY] + $c move current [expr {$x-$lastX}] [expr {$y-$lastY}] set lastX $x set lastY $y } @@ -283,4 +283,3 @@ proc butPress {w color} { set i [$w create text 25c 18.1c -text "Ouch!!" -fill $color -anchor n] after 500 "$w delete $i" } - diff --git a/tk/library/demos/ixset b/tk/library/demos/ixset index 1e4716c2524..76319cc0bb6 100755 --- a/tk/library/demos/ixset +++ b/tk/library/demos/ixset @@ -1,6 +1,6 @@ #!/bin/sh # the next line restarts using wish \ -exec wish "$0" "$@" +exec wish "$0" ${1+"$@"} # ixset -- # A nice interface to "xset" to change X server settings @@ -27,10 +27,15 @@ proc ok {} { proc cancel {} { readsettings dispsettings + .buttons.apply configure -state disabled + .buttons.cancel configure -state disabled } -# apply is just "writesettings" - +proc apply {} { + writesettings + .buttons.apply configure -state disabled + .buttons.cancel configure -state disabled +} # # Read current settings @@ -120,8 +125,8 @@ proc writesettings {} { set mouseacc [.mouse.hor.acc.entry get] set mousethr [.mouse.hor.thr.entry get] - set screentim [.screen.val.le.tim.entry get] - set screencyc [.screen.val.le.cyc.entry get] + set screentim [.screen.tim.entry get] + set screencyc [.screen.cyc.entry get] exec xset \ b $bellvol $bellpit $belldur \ @@ -155,12 +160,12 @@ proc dispsettings {} { .mouse.hor.thr.entry delete 0 end .mouse.hor.thr.entry insert 0 $mousethr - .screen.val.rb.blank [expr "{$screenbla}=={blank} ? {select} : {deselect}"] - .screen.val.rb.pat [expr "{$screenbla}!={blank} ? {select} : {deselect}"] - .screen.val.le.tim.entry delete 0 end - .screen.val.le.tim.entry insert 0 $screentim - .screen.val.le.cyc.entry delete 0 end - .screen.val.le.cyc.entry insert 0 $screencyc + .screen.blank [expr "{$screenbla}=={blank} ? {select} : {deselect}"] + .screen.pat [expr "{$screenbla}!={blank} ? {select} : {deselect}"] + .screen.tim.entry delete 0 end + .screen.tim.entry insert 0 $screentim + .screen.cyc.entry delete 0 end + .screen.cyc.entry insert 0 $screencyc } @@ -168,12 +173,17 @@ proc dispsettings {} { # Create all windows, and pack them # -proc labelentry {path text length} { +proc labelentry {path text length {range {}}} { frame $path label $path.label -text $text - entry $path.entry -width $length -relief sunken - pack $path.label -side left -expand y - pack $path.entry -side right -expand y + if {[llength $range]} { + spinbox $path.entry -width $length -relief sunken \ + -from [lindex $range 0] -to [lindex $range 1] + } else { + entry $path.entry -width $length -relief sunken + } + pack $path.label -side left + pack $path.entry -side right -expand y -fill x } proc createwindows {} { @@ -182,38 +192,57 @@ proc createwindows {} { # frame .buttons - button .buttons.ok -command "ok" -text "Ok" - button .buttons.apply -command "writesettings" -text "Apply" - button .buttons.cancel -command "cancel" -text "Cancel" - button .buttons.quit -command "quit" -text "Quit" + button .buttons.ok -default active -command ok -text "Ok" + button .buttons.apply -default normal -command apply -text "Apply" \ + -state disabled + button .buttons.cancel -default normal -command cancel -text "Cancel" \ + -state disabled + button .buttons.quit -default normal -command quit -text "Quit" pack .buttons.ok .buttons.apply .buttons.cancel .buttons.quit \ -side left -expand yes -pady 5 + bind . {.buttons.ok flash; .buttons.ok invoke} + bind . {.buttons.quit flash; .buttons.quit invoke} + bind . <1> { + if {![string match .buttons* %W]} { + .buttons.apply configure -state normal + .buttons.cancel configure -state normal + } + } + bind . { + if {![string match .buttons* %W]} { + switch -glob %K { + Return - Escape - Tab - *Shift* {} + default { + .buttons.apply configure -state normal + .buttons.cancel configure -state normal + } + } + } + } + # # Bell settings # - frame .bell -relief raised -borderwidth 2 - label .bell.label -text "Bell Settings" + labelframe .bell -text "Bell Settings" -padx 1.5m -pady 1.5m scale .bell.vol \ -from 0 -to 100 -length 200 -tickinterval 20 \ -label "Volume (%)" -orient horizontal frame .bell.val - labelentry .bell.val.pit "Pitch (Hz)" 6 - labelentry .bell.val.dur "Duration (ms)" 6 + labelentry .bell.val.pit "Pitch (Hz)" 6 {25 20000} + labelentry .bell.val.dur "Duration (ms)" 6 {1 10000} pack .bell.val.pit -side left -padx 5 pack .bell.val.dur -side right -padx 5 - pack .bell.label .bell.vol .bell.val -side top -expand yes + pack .bell.vol .bell.val -side top -expand yes # # Keyboard settings # - frame .kbd -relief raised -borderwidth 2 - - label .kbd.label -text "Keyboard Repeat Settings" + labelframe .kbd -text "Keyboard Repeat Settings" -padx 1.5m -pady 1.5m frame .kbd.val checkbutton .kbd.val.onoff \ @@ -223,62 +252,52 @@ proc createwindows {} { scale .kbd.val.cli \ -from 0 -to 100 -length 200 -tickinterval 20 \ -label "Click Volume (%)" -orient horizontal - pack .kbd.val.onoff -side left -expand yes -fill both - pack .kbd.val.cli -side left -expand yes + pack .kbd.val.onoff -side left -fill x -expand yes -padx {0 1m} + pack .kbd.val.cli -side left -expand yes -fill x -padx {1m 0} - pack .kbd.label -side top -expand yes pack .kbd.val -side top -expand yes -pady 2 -fill x # # Mouse settings # - frame .mouse -relief raised -borderwidth 2 + labelframe .mouse -text "Mouse Settings" -padx 1.5m -pady 1.5m - label .mouse.label -text "Mouse Settings" frame .mouse.hor - labelentry .mouse.hor.acc "Acceleration" 3 - labelentry .mouse.hor.thr "Threshold (pixels)" 3 + labelentry .mouse.hor.acc "Acceleration" 5 + labelentry .mouse.hor.thr "Threshold (pixels)" 3 {1 2000} - pack .mouse.hor.acc -side left - pack .mouse.hor.thr -side right + pack .mouse.hor.acc -side left -padx {0 1m} + pack .mouse.hor.thr -side right -padx {1m 0} - pack .mouse.label -side top pack .mouse.hor -side top -expand yes # # Screen Saver settings # - frame .screen -relief raised -borderwidth 2 - - label .screen.label -text "Screen-saver Settings" - frame .screen.val + labelframe .screen -text "Screen-saver Settings" -padx 1.5m -pady 1.5m - frame .screen.val.rb - radiobutton .screen.val.rb.blank \ + radiobutton .screen.blank \ -variable screenblank -text "Blank" -relief flat \ - -value "blank" -variable screenbla - radiobutton .screen.val.rb.pat \ + -value "blank" -variable screenbla -anchor w + radiobutton .screen.pat \ -variable screenblank -text "Pattern" -relief flat \ - -value "noblank" -variable screenbla - pack .screen.val.rb.blank .screen.val.rb.pat -side top -pady 2 -anchor w - frame .screen.val.le - labelentry .screen.val.le.tim "Timeout (s)" 5 - labelentry .screen.val.le.cyc "Cycle (s)" 5 - pack .screen.val.le.tim .screen.val.le.cyc -side top -pady 2 -anchor e - - pack .screen.val.rb .screen.val.le -side left + -value "noblank" -variable screenbla -anchor w + labelentry .screen.tim "Timeout (s)" 5 {1 100000} + labelentry .screen.cyc "Cycle (s)" 5 {1 100000} - pack .screen.label -side top - pack .screen.val -side top -expand y + grid .screen.blank .screen.tim -sticky e + grid .screen.pat .screen.cyc -sticky e + grid configure .screen.blank .screen.pat -sticky ew # # Main window # pack .buttons -side top -fill both - pack .bell .kbd .mouse .screen -side top -fill both -ipady 5 -expand yes + pack .bell .kbd .mouse .screen -side top -fill both -expand yes \ + -padx 1m -pady 1m # # Let the user resize our window @@ -311,3 +330,6 @@ dispsettings # Now, wait for user actions... # +# Local Variables: +# mode: tcl +# End: diff --git a/tk/library/demos/label.tcl b/tk/library/demos/label.tcl index 63fe44e128a..86ff4d61b5f 100644 --- a/tk/library/demos/label.tcl +++ b/tk/library/demos/label.tcl @@ -38,4 +38,3 @@ label $w.right.bitmap -borderwidth 2 -relief sunken \ -bitmap @[file join $tk_library demos images face.bmp] label $w.right.caption -text "Tcl/Tk Proprietor" pack $w.right.bitmap $w.right.caption -side top - diff --git a/tk/library/demos/labelframe.tcl b/tk/library/demos/labelframe.tcl new file mode 100644 index 00000000000..7688368025f --- /dev/null +++ b/tk/library/demos/labelframe.tcl @@ -0,0 +1,80 @@ +# labelframe.tcl -- +# +# This demonstration script creates a toplevel window containing +# several labelframe widgets. +# +# RCS: @(#) $Id$ + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +set w .labelframe +catch {destroy $w} +toplevel $w +wm title $w "Labelframe Demonstration" +wm iconname $w "labelframe" +positionWindow $w + +# Some information + +label $w.msg -font $font -wraplength 4i -justify left -text "Labelframes are\ + used to group related widgets together. The label may be either \ + plain text or another widget." +pack $w.msg -side top + +# The bottom buttons + +frame $w.buttons +pack $w.buttons -side bottom -fill x -pady 2m +button $w.buttons.dismiss -text Dismiss -command "destroy $w" -width 15 +button $w.buttons.code -text "See Code" -command "showCode $w" -width 15 +pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 + +# Demo area + +frame $w.f +pack $w.f -side bottom -fill both -expand 1 +set w $w.f + +# A group of radiobuttons in a labelframe + +labelframe $w.f -text "Value" -padx 2 -pady 2 +grid $w.f -row 0 -column 0 -pady 2m -padx 2m + +foreach value {1 2 3 4} { + radiobutton $w.f.b$value -text "This is value $value" \ + -variable lfdummy -value $value + pack $w.f.b$value -side top -fill x -pady 2 +} + + +# Using a label window to control a group of options. + +proc lfEnableButtons {w} { + foreach child [winfo children $w] { + if {$child == "$w.cb"} continue + if {$::lfdummy2} { + $child configure -state normal + } else { + $child configure -state disabled + } + } +} + +labelframe $w.f2 -pady 2 -padx 2 +checkbutton $w.f2.cb -text "Use this option." -variable lfdummy2 \ + -command "lfEnableButtons $w.f2" -padx 0 +$w.f2 configure -labelwidget $w.f2.cb +grid $w.f2 -row 0 -column 1 -pady 2m -padx 2m + +set t 0 +foreach str {Option1 Option2 Option3} { + checkbutton $w.f2.b$t -text $str + pack $w.f2.b$t -side top -fill x -pady 2 + incr t +} +lfEnableButtons $w.f2 + + +grid columnconfigure $w {0 1} -weight 1 diff --git a/tk/library/demos/menu.tcl b/tk/library/demos/menu.tcl index 9900cd59a1b..9b0f6bb4fe1 100644 --- a/tk/library/demos/menu.tcl +++ b/tk/library/demos/menu.tcl @@ -17,7 +17,8 @@ wm iconname $w "menu" positionWindow $w label $w.msg -font $font -wraplength 4i -justify left -if {$tcl_platform(platform) == "macintosh"} { +if {[string equal [tk windowingsystem] "classic"] + || [string equal [tk windowingsystem] "aqua"]} { $w.msg configure -text "This window contains a menubar with cascaded menus. You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by dragging outside of its bounds and releasing the mouse." } else { $w.msg configure -text "This window contains a menubar with cascaded menus. You can post a menu from the keyboard by typing Alt+x, where \"x\" is the character underlined on the menu. You can then traverse among the menus using the arrow keys. When a menu is posted, you can invoke the current entry by typing space, or you can invoke any entry by typing its underlined character. If a menu entry has an accelerator, you can invoke the entry without posting the menu just by typing the accelerator. The rightmost menu can be torn off into a palette by selecting the first item in the menu." @@ -55,7 +56,8 @@ set m $w.menu.basic $w.menu add cascade -label "Basic" -menu $m -underline 0 menu $m -tearoff 0 $m add command -label "Long entry that does nothing" -if {$tcl_platform(platform) == "macintosh"} { +if {[string equal [tk windowingsystem] "classic"] + || [string equal [tk windowingsystem] "aqua"]} { set modifier Command } elseif {$tcl_platform(platform) == "windows"} { set modifier Control @@ -131,6 +133,12 @@ menu $m -tearoff 0 foreach i {{An entry} {Another entry} {Does nothing} {Does almost nothing} {Make life meaningful}} { $m add command -label $i -command [list puts "You invoked \"$i\""] } +$m entryconfigure "Does almost nothing" \ + -bitmap questhead -compound left -command { + tk_dialog .compound {Compound Menu Entry} {The menu entry you invoked\ + displays both a bitmap and a text string. Other than this, it\ + is just like any other menu entry.} {} 0 OK +} set m $w.menu.colors $w.menu add cascade -label "Colors" -menu $m -underline 1 @@ -150,4 +158,3 @@ bind Menu <> { set menustatus $label update idletasks } - diff --git a/tk/library/demos/menubu.tcl b/tk/library/demos/menubu.tcl index dc0681e55b3..2f9fea930b0 100644 --- a/tk/library/demos/menubu.tcl +++ b/tk/library/demos/menubu.tcl @@ -57,7 +57,8 @@ pack $body.buttons -padx 25 -pady 25 tk_optionMenu $body.buttons.options menubuttonoptions one two three pack $body.buttons.options -side left -padx 25 -pady 25 set m [tk_optionMenu $body.buttons.colors paletteColor Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50 Yellow Cyan Magenta White Brown DarkSeaGreen DarkViolet] -if {$tcl_platform(platform) == "macintosh"} { +if {[string equal [tk windowingsystem] "classic"] + || [string equal [tk windowingsystem] "aqua"]} { set topBorderColor Black set bottomBorderColor Black } else { @@ -91,4 +92,3 @@ pack $body.buttons.colors -side left -padx 25 -pady 25 - diff --git a/tk/library/demos/msgbox.tcl b/tk/library/demos/msgbox.tcl index 73b7caa512d..bc286c16c50 100644 --- a/tk/library/demos/msgbox.tcl +++ b/tk/library/demos/msgbox.tcl @@ -63,4 +63,3 @@ proc showMessageBox {w} { tk_messageBox -icon info -message "You have selected \"$button\"" -type ok\ -parent $w } - diff --git a/tk/library/demos/paned1.tcl b/tk/library/demos/paned1.tcl new file mode 100644 index 00000000000..5adc2550c75 --- /dev/null +++ b/tk/library/demos/paned1.tcl @@ -0,0 +1,34 @@ +# paned1.tcl -- +# +# This demonstration script creates a toplevel window containing +# a paned window that separates two windows horizontally. +# +# RCS: @(#) $Id$ + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +set w .paned1 +catch {destroy $w} +toplevel $w +wm title $w "Horizontal Paned Window Demonstration" +wm iconname $w "paned1" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left -text "The sash between the two coloured windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)" +pack $w.msg -side top + +frame $w.buttons +pack $w.buttons -side bottom -fill x -pady 2m +button $w.buttons.dismiss -text Dismiss -command "destroy $w" +button $w.buttons.code -text "See Code" -command "showCode $w" +pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 + +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 + +$w.pane add $w.pane.left $w.pane.right diff --git a/tk/library/demos/paned2.tcl b/tk/library/demos/paned2.tcl new file mode 100644 index 00000000000..5bfcf06f837 --- /dev/null +++ b/tk/library/demos/paned2.tcl @@ -0,0 +1,76 @@ +# paned2.tcl -- +# +# This demonstration script creates a toplevel window containing +# a paned window that separates two windows vertically. +# +# RCS: @(#) $Id$ + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +set w .paned2 +catch {destroy $w} +toplevel $w +wm title $w "Vertical Paned Window Demonstration" +wm iconname $w "paned2" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left -text "The sash between the two scrolled windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)" +pack $w.msg -side top + +frame $w.buttons +pack $w.buttons -side bottom -fill x -pady 2m +button $w.buttons.dismiss -text Dismiss -command "destroy $w" +button $w.buttons.code -text "See Code" -command "showCode $w" +pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 + +# Create the pane itself +panedwindow $w.pane -orient vertical +pack $w.pane -side top -expand yes -fill both -pady 2 -padx 2m + +# The top window is a listbox with scrollbar +set paneList { + {List of Tk Widgets} + button + canvas + checkbutton + entry + frame + label + labelframe + listbox + menu + menubutton + message + panedwindow + radiobutton + scale + scrollbar + spinbox + text + toplevel +} +set f [frame $w.pane.top] +listbox $f.list -listvariable paneList -yscrollcommand "$f.scr set" +# Invert the first item to highlight it +$f.list itemconfigure 0 \ + -background [$f.list cget -fg] -foreground [$f.list cget -bg] +scrollbar $f.scr -orient vertical -command "$f.list yview" +pack $f.scr -side right -fill y +pack $f.list -fill both -expand 1 + +# The bottom window is a text widget with scrollbar +set f [frame $w.pane.bottom] +text $f.text -xscrollcommand "$f.xscr set" -yscrollcommand "$f.yscr set" \ + -width 30 -wrap none +scrollbar $f.xscr -orient horizontal -command "$f.text xview" +scrollbar $f.yscr -orient vertical -command "$f.text yview" +grid $f.text $f.yscr -sticky nsew +grid $f.xscr -sticky nsew +grid columnconfigure $f 0 -weight 1 +grid rowconfigure $f 0 -weight 1 +$f.text insert 1.0 "This is just a normal text widget" + +# Now add our contents to the paned window +$w.pane add $w.pane.top $w.pane.bottom diff --git a/tk/library/demos/plot.tcl b/tk/library/demos/plot.tcl index b226c84f2ae..dadf6158c4d 100644 --- a/tk/library/demos/plot.tcl +++ b/tk/library/demos/plot.tcl @@ -38,20 +38,21 @@ $c create text 225 20 -text "A Simple Plot" -font $plotFont -fill brown for {set i 0} {$i <= 10} {incr i} { set x [expr {100 + ($i*30)}] $c create line $x 250 $x 245 -width 2 - $c create text $x 254 -text [expr 10*$i] -anchor n -font $plotFont + $c create text $x 254 -text [expr {10*$i}] -anchor n -font $plotFont } for {set i 0} {$i <= 5} {incr i} { set y [expr {250 - ($i*40)}] $c create line 100 $y 105 $y -width 2 - $c create text 96 $y -text [expr $i*50].0 -anchor e -font $plotFont + $c create text 96 $y -text [expr {$i*50}].0 -anchor e -font $plotFont } -foreach point {{12 56} {20 94} {33 98} {32 120} {61 180} - {75 160} {98 223}} { +foreach point { + {12 56} {20 94} {33 98} {32 120} {61 180} {75 160} {98 223} +} { set x [expr {100 + (3*[lindex $point 0])}] set y [expr {250 - (4*[lindex $point 1])/5}] - set item [$c create oval [expr $x-6] [expr $y-6] \ - [expr $x+6] [expr $y+6] -width 1 -outline black \ + set item [$c create oval [expr {$x-6}] [expr {$y-6}] \ + [expr {$x+6}] [expr {$y+6}] -width 1 -outline black \ -fill SkyBlue2] $c addtag point withtag $item } @@ -92,8 +93,7 @@ proc plotDown {w x y} { proc plotMove {w x y} { global plot - $w move selected [expr $x-$plot(lastX)] [expr $y-$plot(lastY)] + $w move selected [expr {$x-$plot(lastX)}] [expr {$y-$plot(lastY)}] set plot(lastX) $x set plot(lastY) $y } - diff --git a/tk/library/demos/puzzle.tcl b/tk/library/demos/puzzle.tcl index 0dcef217bd8..31f13facd52 100644 --- a/tk/library/demos/puzzle.tcl +++ b/tk/library/demos/puzzle.tcl @@ -54,16 +54,27 @@ pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 # scrollbar widget and using its trough color. scrollbar $w.s -frame $w.frame -width 120 -height 120 -borderwidth 2 -relief sunken \ - -bg [$w.s cget -troughcolor] + +# The button metrics are a bit bigger in Aqua, and since we are +# using place which doesn't autosize, then we need to have a +# slightly larger frame here... + +if {[string equal [tk windowingsystem] aqua]} { + set frameSize 160 +} else { + set frameSize 120 +} + +frame $w.frame -width $frameSize -height $frameSize -borderwidth 2\ + -relief sunken -bg [$w.s cget -troughcolor] pack $w.frame -side top -pady 1c -padx 1c destroy $w.s set order {3 1 6 2 5 7 15 13 4 11 8 9 14 10 12} -for {set i 0} {$i < 15} {set i [expr $i+1]} { +for {set i 0} {$i < 15} {set i [expr {$i+1}]} { set num [lindex $order $i] - set xpos($num) [expr ($i%4)*.25] - set ypos($num) [expr ($i/4)*.25] + set xpos($num) [expr {($i%4)*.25}] + set ypos($num) [expr {($i/4)*.25}] button $w.frame.$num -relief raised -text $num -highlightthickness 0 \ -command "puzzleSwitch $w $num" place $w.frame.$num -relx $xpos($num) -rely $ypos($num) \ @@ -71,4 +82,3 @@ for {set i 0} {$i < 15} {set i [expr $i+1]} { } set xpos(space) .75 set ypos(space) .75 - diff --git a/tk/library/demos/radio.tcl b/tk/library/demos/radio.tcl index 91d9e8ecae8..80bfd37dc65 100644 --- a/tk/library/demos/radio.tcl +++ b/tk/library/demos/radio.tcl @@ -15,31 +15,45 @@ toplevel $w wm title $w "Radiobutton Demonstration" wm iconname $w "radio" positionWindow $w -label $w.msg -font $font -wraplength 5i -justify left -text "Two groups of radiobuttons are displayed below. If you click on a button then the button will become selected exclusively among all the buttons in its group. A Tcl variable is associated with each group to indicate which of the group's buttons is selected. Click the \"See Variables\" button to see the current values of the variables." +label $w.msg -font $font -wraplength 5i -justify left -text "Three groups of radiobuttons are displayed below. If you click on a button then the button will become selected exclusively among all the buttons in its group. A Tcl variable is associated with each group to indicate which of the group's buttons is selected. Click the \"See Variables\" button to see the current values of the variables." pack $w.msg -side top frame $w.buttons pack $w.buttons -side bottom -fill x -pady 2m button $w.buttons.dismiss -text Dismiss -command "destroy $w" button $w.buttons.code -text "See Code" -command "showCode $w" -button $w.buttons.vars -text "See Variables" \ - -command "showVars $w.dialog size color" +button $w.buttons.vars -text "See Variables" \ + -command "showVars $w.dialog size color align" pack $w.buttons.dismiss $w.buttons.code $w.buttons.vars -side left -expand 1 -frame $w.left -frame $w.right -pack $w.left $w.right -side left -expand yes -pady .5c -padx .5c +labelframe $w.left -pady 2 -text "Point Size" -padx 2 +labelframe $w.mid -pady 2 -text "Color" -padx 2 +labelframe $w.right -pady 2 -text "Alignment" -padx 2 +pack $w.left $w.mid $w.right -side left -expand yes -pady .5c -padx .5c -foreach i {10 12 18 24} { +foreach i {10 12 14 18 24} { radiobutton $w.left.b$i -text "Point Size $i" -variable size \ -relief flat -value $i - pack $w.left.b$i -side top -pady 2 -anchor w + pack $w.left.b$i -side top -pady 2 -anchor w -fill x } -foreach color {Red Green Blue Yellow Orange Purple} { - set lower [string tolower $color] - radiobutton $w.right.$lower -text $color -variable color \ - -relief flat -value $lower - pack $w.right.$lower -side top -pady 2 -anchor w +foreach c {Red Green Blue Yellow Orange Purple} { + set lower [string tolower $c] + radiobutton $w.mid.$lower -text $c -variable color \ + -relief flat -value $lower -anchor w \ + -command "$w.mid configure -fg \$color" + pack $w.mid.$lower -side top -pady 2 -fill x } +label $w.right.l -text "Label" -bitmap questhead -compound left +$w.right.l configure -width [winfo reqwidth $w.right.l] -compound top +$w.right.l configure -height [winfo reqheight $w.right.l] +foreach a {Top Left Right Bottom} { + set lower [string tolower $a] + radiobutton $w.right.$lower -text $a -variable align \ + -relief flat -value $lower -indicatoron 0 -width 7 \ + -command "$w.right.l configure -compound \$align" +} +grid x $w.right.top +grid $w.right.left $w.right.l $w.right.right +grid x $w.right.bottom diff --git a/tk/library/demos/rmt b/tk/library/demos/rmt index de3ff853728..d0df5e25107 100755 --- a/tk/library/demos/rmt +++ b/tk/library/demos/rmt @@ -32,22 +32,21 @@ set lastCommand "" # Create menu bar. Arrange to recreate all the information in the # applications sub-menu whenever it is cascaded to. -frame .menu -relief raised -bd 2 -pack .menu -side top -fill x -menubutton .menu.file -text "File" -menu .menu.file.m -underline 0 -menu .menu.file.m -.menu.file.m add cascade -label "Select Application" \ - -menu .menu.file.m.apps -underline 0 -.menu.file.m add command -label "Quit" -command "destroy ." -underline 0 -menu .menu.file.m.apps -postcommand fillAppsMenu -pack .menu.file -side left +. configure -menu [menu .menu] +menu .menu.file +menu .menu.file.apps -postcommand fillAppsMenu +.menu add cascade -label "File" -underline 0 -menu .menu.file +.menu.file add cascade -label "Select Application" -underline 0 \ + -menu .menu.file.apps +.menu.file add command -label "Quit" -command "destroy ." -underline 0 # Create text window and scrollbar. text .t -relief sunken -bd 2 -yscrollcommand ".s set" -setgrid true scrollbar .s -command ".t yview" -pack .s -side right -fill both -pack .t -side left +grid .t .s -sticky nsew +grid rowconfigure . 0 -weight 1 +grid columnconfigure . 0 -weight 1 # Create a binding to forward commands to the target application, # plus modify many of the built-in bindings so that only information @@ -123,6 +122,7 @@ proc tkTextInsert {w s} { $w see insert } +.t configure -font {Courier 12} .t tag configure bold -font {Courier 12 bold} # The procedure below is used to print out a prompt at the @@ -193,14 +193,18 @@ proc newApp appName { # of all the applications that currently exist. proc fillAppsMenu {} { - catch {.menu.file.m.apps delete 0 last} + set m .menu.file.apps + catch {$m delete 0 last} foreach i [lsort [winfo interps]] { - .menu.file.m.apps add command -label $i -command [list newApp $i] + $m add command -label $i -command [list newApp $i] } - .menu.file.m.apps add command -label local -command {newApp local} + $m add command -label local -command {newApp local} } set app [winfo name .] prompt focus .t +# Local Variables: +# mode: tcl +# End: diff --git a/tk/library/demos/rolodex b/tk/library/demos/rolodex index 3e334f7ef70..58bb0520b7a 100755 --- a/tk/library/demos/rolodex +++ b/tk/library/demos/rolodex @@ -1,6 +1,6 @@ #!/bin/sh # the next line restarts using wish \ -exec wish "$0" "$@" +exec wish "$0" ${1+"$@"} # rolodex -- # This script was written as an entry in Tom LaStrange's rolodex @@ -14,6 +14,8 @@ foreach i [winfo child .] { catch {destroy $i} } +set version 1.2 + #------------------------------------------ # Phase 0: create the front end. #------------------------------------------ @@ -23,12 +25,9 @@ pack .frame -side top -fill y -anchor center set names {{} Name: Address: {} {} {Home Phone:} {Work Phone:} Fax:} foreach i {1 2 3 4 5 6 7} { - frame .frame.$i - pack .frame.$i -side top -pady 2 -anchor e - - label .frame.$i.label -text [lindex $names $i] -anchor e - entry .frame.$i.entry -width 30 -relief sunken - pack .frame.$i.entry .frame.$i.label -side right + label .frame.label$i -text [lindex $names $i] -anchor e + entry .frame.entry$i -width 35 + grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1 } frame .buttons @@ -77,7 +76,7 @@ proc fileAction {} { proc addAction {} { global names foreach i {1 2 3 4 5 6 7} { - puts stderr [format "%-12s %s" [lindex $names $i] [.frame.$i.entry get]] + puts stderr [format "%-12s %s" [lindex $names $i] [.frame.entry$i get]] } } .buttons.add config -command addAction @@ -88,20 +87,20 @@ proc addAction {} { proc clearAction {} { foreach i {1 2 3 4 5 6 7} { - .frame.$i.entry delete 0 end + .frame.entry$i delete 0 end } } .buttons.clear config -command clearAction proc fillCard {} { clearAction - .frame.1.entry insert 0 "John Ousterhout" - .frame.2.entry insert 0 "CS Division, Department of EECS" - .frame.3.entry insert 0 "University of California" - .frame.4.entry insert 0 "Berkeley, CA 94720" - .frame.5.entry insert 0 "private" - .frame.6.entry insert 0 "510-642-0865" - .frame.7.entry insert 0 "510-642-5775" + .frame.entry1 insert 0 "John Ousterhout" + .frame.entry2 insert 0 "CS Division, Department of EECS" + .frame.entry3 insert 0 "University of California" + .frame.entry4 insert 0 "Berkeley, CA 94720" + .frame.entry5 insert 0 "private" + .frame.entry6 insert 0 "510-642-0865" + .frame.entry7 insert 0 "510-642-5775" } .buttons.search config -command "addAction; fillCard" @@ -123,7 +122,7 @@ bind . fileAction .menu.file.m entryconfig 2 -accel Ctrl+Q bind . {destroy .} -focus .frame.1.entry +focus .frame.entry1 #---------------------------------------------------- # Phase 6: help @@ -145,42 +144,43 @@ proc Help {topic {x 0} {y 0}} { } proc getMenuTopic {w x y} { - return $w.[$w index @[expr $y-[winfo rooty $w]]] + return $w.[$w index @[expr {$y-[winfo rooty $w]}]] } -bind . {Help [winfo containing %X %Y] %X %Y} -bind . {Help [winfo containing %X %Y] %X %Y} +event add <> +bind . <> {Help [winfo containing %X %Y] %X %Y} +bind Menu <> {Help [winfo containing %X %Y] %X %Y} # Help text and commands follow: set helpTopics(.menu.file) {This is the "file" menu. It can be used to invoke some overall operations on the rolodex applications, such as loading a file or exiting.} set helpCmds(.menu.file.m) {getMenuTopic $topic $x $y} -set helpTopics(.menu.file.m.0) {The "Load" entry in the "File" menu posts a dialog box that you can use to select a rolodex file} -set helpTopics(.menu.file.m.1) {The "Exit" entry in the "File" menu causes the rolodex application to terminate} +set helpTopics(.menu.file.m.1) {The "Load" entry in the "File" menu posts a dialog box that you can use to select a rolodex file} +set helpTopics(.menu.file.m.2) {The "Exit" entry in the "File" menu causes the rolodex application to terminate} set helpCmds(.menu.file.m.none) {set topic ".menu.file"} -set helpTopics(.frame.1.entry) {In this field of the rolodex entry you should type the person's name} -set helpTopics(.frame.2.entry) {In this field of the rolodex entry you should type the first line of the person's address} -set helpTopics(.frame.3.entry) {In this field of the rolodex entry you should type the second line of the person's address} -set helpTopics(.frame.4.entry) {In this field of the rolodex entry you should type the third line of the person's address} -set helpTopics(.frame.5.entry) {In this field of the rolodex entry you should type the person's home phone number, or "private" if the person doesn't want his or her number publicized} -set helpTopics(.frame.6.entry) {In this field of the rolodex entry you should type the person's work phone number} -set helpTopics(.frame.7.entry) {In this field of the rolodex entry you should type the phone number for the person's FAX machine} - -set helpCmds(.frame.1.label) {set topic .frame.1.entry} -set helpCmds(.frame.2.label) {set topic .frame.2.entry} -set helpCmds(.frame.3.label) {set topic .frame.3.entry} -set helpCmds(.frame.4.label) {set topic .frame.4.entry} -set helpCmds(.frame.5.label) {set topic .frame.5.entry} -set helpCmds(.frame.6.label) {set topic .frame.6.entry} -set helpCmds(.frame.7.label) {set topic .frame.7.entry} +set helpTopics(.frame.entry1) {In this field of the rolodex entry you should type the person's name} +set helpTopics(.frame.entry2) {In this field of the rolodex entry you should type the first line of the person's address} +set helpTopics(.frame.entry3) {In this field of the rolodex entry you should type the second line of the person's address} +set helpTopics(.frame.entry4) {In this field of the rolodex entry you should type the third line of the person's address} +set helpTopics(.frame.entry5) {In this field of the rolodex entry you should type the person's home phone number, or "private" if the person doesn't want his or her number publicized} +set helpTopics(.frame.entry6) {In this field of the rolodex entry you should type the person's work phone number} +set helpTopics(.frame.entry7) {In this field of the rolodex entry you should type the phone number for the person's FAX machine} + +set helpCmds(.frame.label1) {set topic .frame.entry1} +set helpCmds(.frame.label2) {set topic .frame.entry2} +set helpCmds(.frame.label3) {set topic .frame.entry3} +set helpCmds(.frame.label4) {set topic .frame.entry4} +set helpCmds(.frame.label5) {set topic .frame.entry5} +set helpCmds(.frame.label6) {set topic .frame.entry6} +set helpCmds(.frame.label7) {set topic .frame.entry7} set helpTopics(context) {Unfortunately, this application doesn't support context-sensitive help in the usual way, because when this demo was written Tk didn't have a grab mechanism and this is needed for context-sensitive help. Instead, you can achieve much the same effect by simply moving the mouse over the window you're curious about and pressing the Help or F1 keys. You can do this anytime.} set helpTopics(help) {This application provides only very crude help. Besides the entries in this menu, you can get help on individual windows by moving the mouse cursor over the window and pressing the Help or F1 keys.} set helpTopics(window) {This window is a dummy rolodex application created as part of Tom LaStrange's toolkit benchmark. It doesn't really do anything useful except to demonstrate a few features of the Tk toolkit.} set helpTopics(keys) "The following accelerator keys are defined for this application (in addition to those already available for the entry windows):\n\nCtrl+A:\t\tAdd\nCtrl+C:\t\tClear\nCtrl+D:\t\tDelete\nCtrl+F:\t\tEnter file name\nCtrl+Q:\t\tExit application (quit)\nCtrl+S:\t\tSearch (dummy operation)" -set helpTopics(version) {This is version 1.0.} +set helpTopics(version) "This is version $version." # Entries in "Help" menu @@ -194,4 +194,3 @@ set helpTopics(version) {This is version 1.0.} -underline 3 .menu.help.m add command -label "On Version..." -command {Help version} \ -underline 3 - diff --git a/tk/library/demos/ruler.tcl b/tk/library/demos/ruler.tcl index e73e462fc46..38b7170b9b4 100644 --- a/tk/library/demos/ruler.tcl +++ b/tk/library/demos/ruler.tcl @@ -19,8 +19,8 @@ if {![info exists widgetDemo]} { 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)] + $c create polygon $x $y [expr {$x+$v(size)}] [expr {$y+$v(size)}] \ + [expr {$x-$v(size)}] [expr {$y+$v(size)}] } set w .ruler @@ -63,7 +63,7 @@ if {[winfo depth $c] > 1} { $c create line 1c 0.5c 1c 1c 13c 1c 13c 0.5c -width 1 for {set i 0} {$i < 12} {incr i} { - set x [expr $i+1] + set x [expr {$i+1}] $c create line ${x}c 1c ${x}c 0.6c -width 1 $c create line $x.25c 1c $x.25c 0.8c -width 1 $c create line $x.5c 1c $x.5c 0.7c -width 1 @@ -110,7 +110,7 @@ proc rulerNewTab {c x y} { proc rulerSelectTab {c x y} { upvar #0 demo_rulerInfo v set v(x) [$c canvasx $x $v(grid)] - set v(y) [expr $v(top)+2] + set v(y) [expr {$v(top)+2}] $c addtag active withtag current eval "$c itemconf active $v(activeStyle)" $c raise active @@ -139,13 +139,13 @@ proc rulerMoveTab {c x y} { set cx $v(right) } if {($cy >= $v(top)) && ($cy <= $v(bottom))} { - set cy [expr $v(top)+2] + set cy [expr {$v(top)+2}] eval "$c itemconf active $v(activeStyle)" } else { - set cy [expr $cy-$v(size)-2] + set cy [expr {$cy-$v(size)-2}] eval "$c itemconf active $v(deleteStyle)" } - $c move active [expr $cx-$v(x)] [expr $cy-$v(y)] + $c move active [expr {$cx-$v(x)}] [expr {$cy-$v(y)}] set v(x) $cx set v(y) $cy } @@ -164,11 +164,10 @@ proc rulerReleaseTab c { if {[$c find withtag active] == {}} { return } - if {$v(y) != [expr $v(top)+2]} { + if {$v(y) != $v(top)+2} { $c delete active } else { eval "$c itemconf active $v(normalStyle)" $c dtag active } } - diff --git a/tk/library/demos/sayings.tcl b/tk/library/demos/sayings.tcl index 8f24ec907e8..872e5d26095 100644 --- a/tk/library/demos/sayings.tcl +++ b/tk/library/demos/sayings.tcl @@ -44,4 +44,3 @@ grid columnconfig $w.frame 0 -weight 1 -minsize 0 $w.frame.list insert 0 "Waste not, want not" "Early to bed and early to rise makes a man healthy, wealthy, and wise" "Ask not what your country can do for you, ask what you can do for your country" "I shall return" "NOT" "A picture is worth a thousand words" "User interfaces are hard to build" "Thou shalt not steal" "A penny for your thoughts" "Fool me once, shame on you; fool me twice, shame on me" "Every cloud has a silver lining" "Where there's smoke there's fire" "It takes one to know one" "Curiosity killed the cat" "Take this job and shove it" "Up a creek without a paddle" "I'm mad as hell and I'm not going to take it any more" "An apple a day keeps the doctor away" "Don't look a gift horse in the mouth" - diff --git a/tk/library/demos/search.tcl b/tk/library/demos/search.tcl index 130cb53ee39..c8b267101eb 100644 --- a/tk/library/demos/search.tcl +++ b/tk/library/demos/search.tcl @@ -139,4 +139,3 @@ $w.text mark set insert 0.0 set fileName "" set searchString "" - diff --git a/tk/library/demos/spin.tcl b/tk/library/demos/spin.tcl new file mode 100644 index 00000000000..4ba158b9b8d --- /dev/null +++ b/tk/library/demos/spin.tcl @@ -0,0 +1,55 @@ +# spin.tcl -- +# +# This demonstration script creates several spinbox widgets. +# +# RCS: @(#) $Id$ + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +set w .spin +catch {destroy $w} +toplevel $w +wm title $w "Spinbox Demonstration" +wm iconname $w "spin" +positionWindow $w + +label $w.msg -font $font -wraplength 5i -justify left -text "Three different\ + spin-boxes 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 values that are too large to fit in the\ + window all at once, you can scan through the value by dragging with\ + mouse button2 pressed. Note that the first spin-box will only permit\ + you to type in integers, and the third selects from a list of\ + Australian cities." +pack $w.msg -side top + +frame $w.buttons +pack $w.buttons -side bottom -fill x -pady 2m +button $w.buttons.dismiss -text Dismiss -command "destroy $w" +button $w.buttons.code -text "See Code" -command "showCode $w" +pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 + +set australianCities { + Canberra Sydney Melbourne Perth Adelaide Brisbane + Hobart Darwin "Alice Springs" +} + +spinbox $w.s1 -from 1 -to 10 -width 10 -validate key \ + -vcmd {string is integer %P} +spinbox $w.s2 -from 0 -to 3 -increment .5 -format %05.2f -width 10 +spinbox $w.s3 -values $australianCities -width 10 + +#entry $w.e1 +#entry $w.e2 +#entry $w.e3 +pack $w.s1 $w.s2 $w.s3 -side top -pady 5 -padx 10 ;#-fill x + +#$w.e1 insert 0 "Initial value" +#$w.e2 insert end "This entry contains a long value, much too long " +#$w.e2 insert end "to fit in the window at one time, so long in fact " +#$w.e2 insert end "that you'll have to scan or scroll to see the end." diff --git a/tk/library/demos/square b/tk/library/demos/square index 4a17ef14ef3..2ea0722f924 100755 --- a/tk/library/demos/square +++ b/tk/library/demos/square @@ -53,4 +53,3 @@ proc timer {} { .s size [expr {$s+$inc}] after 30 timer } - diff --git a/tk/library/demos/states.tcl b/tk/library/demos/states.tcl index 425c0bc582b..08834eea470 100644 --- a/tk/library/demos/states.tcl +++ b/tk/library/demos/states.tcl @@ -43,4 +43,3 @@ $w.frame.list insert 0 Alabama Alaska Arizona Arkansas California \ "South Carolina" "South Dakota" \ Tennessee Texas Utah Vermont Virginia Washington \ "West Virginia" Wisconsin Wyoming - diff --git a/tk/library/demos/style.tcl b/tk/library/demos/style.tcl index cf5d049cbec..136d4e22898 100644 --- a/tk/library/demos/style.tcl +++ b/tk/library/demos/style.tcl @@ -150,4 +150,3 @@ $w.text insert end "in this example.\n" spacing $w.text insert end "To see where the space is, select ranges of " spacing $w.text insert end "text within these paragraphs. The selection " spacing $w.text insert end "highlight will cover the extra space." spacing - diff --git a/tk/library/demos/tcolor b/tk/library/demos/tcolor index edef7235c93..27b931fc73e 100755 --- a/tk/library/demos/tcolor +++ b/tk/library/demos/tcolor @@ -41,67 +41,70 @@ set updating 0 set autoUpdate 1 set name "" +if {$tcl_platform(platform) eq "unix"} { + option add *Entry.background white +} + # Create the menu bar at the top of the window. -frame .menu -relief raised -borderwidth 2 -pack .menu -side top -fill x -menubutton .menu.file -text File -menu .menu.file.m -underline 0 -menu .menu.file.m -.menu.file.m add radio -label "RGB color space" -variable colorSpace \ +. configure -menu [menu .menu] +menu .menu.file +.menu add cascade -menu .menu.file -label File -underline 0 +.menu.file add radio -label "RGB color space" -variable colorSpace \ -value rgb -underline 0 -command {changeColorSpace rgb} -.menu.file.m add radio -label "CMY color space" -variable colorSpace \ +.menu.file add radio -label "CMY color space" -variable colorSpace \ -value cmy -underline 0 -command {changeColorSpace cmy} -.menu.file.m add radio -label "HSB color space" -variable colorSpace \ +.menu.file add radio -label "HSB color space" -variable colorSpace \ -value hsb -underline 0 -command {changeColorSpace hsb} -.menu.file.m add separator -.menu.file.m add radio -label "Automatic updates" -variable autoUpdate \ +.menu.file add separator +.menu.file add radio -label "Automatic updates" -variable autoUpdate \ -value 1 -underline 0 -.menu.file.m add radio -label "Manual updates" -variable autoUpdate \ +.menu.file add radio -label "Manual updates" -variable autoUpdate \ -value 0 -underline 0 -.menu.file.m add separator -.menu.file.m add command -label "Exit program" -underline 0 \ - -command "destroy ." -pack .menu.file -side left +.menu.file add separator +.menu.file add command -label "Exit program" -underline 0 -command {exit} # Create the command entry window at the bottom of the window, along # with the update button. -frame .bot -relief raised -borderwidth 2 -pack .bot -side bottom -fill x -label .commandLabel -text "Command:" -entry .command -relief sunken -borderwidth 2 -textvariable command \ +labelframe .command -text "Command:" -padx {1m 0} +entry .command.e -relief sunken -borderwidth 2 -textvariable command \ -font {Courier 12} -button .update -text Update -command doUpdate -pack .commandLabel -in .bot -side left -pack .update -in .bot -side right -pady .1c -padx .25c -pack .command -in .bot -expand yes -fill x -ipadx 0.25c +button .command.update -text Update -command doUpdate +pack .command.update -side right -pady .1c -padx {.25c 0} +pack .command.e -expand yes -fill x -ipadx 0.25c + # Create the listbox that holds all of the color names in rgb.txt, # if an rgb.txt file can be found. -frame .middle -relief raised -borderwidth 2 -pack .middle -side top -fill both -foreach i {/usr/local/lib/X11/rgb.txt /usr/lib/X11/rgb.txt - /X11/R5/lib/X11/rgb.txt /X11/R4/lib/rgb/rgb.txt - /usr/openwin/lib/X11/rgb.txt} { - if ![file readable $i] { +grid .command -sticky nsew -row 2 -columnspan 3 -padx 1m -pady {0 1m} + +grid columnconfigure . {1 2} -weight 1 +grid rowconfigure . 0 -weight 1 +foreach i { + /usr/local/lib/X11/rgb.txt /usr/lib/X11/rgb.txt + /X11/R5/lib/X11/rgb.txt /X11/R4/lib/rgb/rgb.txt + /usr/openwin/lib/X11/rgb.txt +} { + if {![file readable $i]} { continue; } set f [open $i] - frame .middle.left - pack .middle.left -side left -padx .25c -pady .25c - listbox .names -width 20 -height 12 -yscrollcommand ".scroll set" \ + labelframe .names -text "Select:" -padx .1c -pady .1c + grid .names -row 0 -column 0 -sticky nsew -padx .15c -pady .15c -rowspan 2 + grid columnconfigure . 0 -weight 1 + listbox .names.lb -width 20 -height 12 -yscrollcommand ".names.s set" \ -relief sunken -borderwidth 2 -exportselection false - bind .names { - tc_loadNamedColor [.names get [.names curselection]] + bind .names.lb { + tc_loadNamedColor [.names.lb get [.names.lb curselection]] } - scrollbar .scroll -orient vertical -command ".names yview" \ + scrollbar .names.s -orient vertical -command ".names.lb yview" \ -relief sunken -borderwidth 2 - pack .names -in .middle.left -side left - pack .scroll -in .middle.left -side right -fill y + pack .names.lb .names.s -side left -fill y -expand 1 while {[gets $f line] >= 0} { - if {[llength $line] == 4} { - .names insert end [lindex $line 3] + if {[regexp {^\s*\d+\s+\d+\s+\d+\s+(\S+)$} $line -> col]} { + .names.lb insert end $col } } close $f @@ -111,35 +114,33 @@ foreach i {/usr/local/lib/X11/rgb.txt /usr/lib/X11/rgb.txt # Create the three scales for editing the color, and the entry for # typing in a color value. -frame .middle.middle -pack .middle.middle -side left -expand yes -fill y -frame .middle.middle.1 -frame .middle.middle.2 -frame .middle.middle.3 -frame .middle.middle.4 -pack .middle.middle.1 .middle.middle.2 .middle.middle.3 -side top -expand yes -pack .middle.middle.4 -side top -expand yes -fill x +frame .adjust foreach i {1 2 3} { - label .label$i -textvariable label$i + label .adjust.l$i -textvariable label$i -pady 0 + labelframe .adjust.$i -labelwidget .adjust.l$i -padx 1m -pady 1m scale .scale$i -from 0 -to 1000 -length 6c -orient horizontal \ -command tc_scaleChanged - pack .scale$i .label$i -in .middle.middle.$i -side top -anchor w + pack .scale$i -in .adjust.$i + pack .adjust.$i } -label .nameLabel -text "Name:" -entry .name -relief sunken -borderwidth 2 -textvariable name -width 10 \ +grid .adjust -row 0 -column 1 -sticky nsew -padx .15c -pady .15c + +labelframe .name -text "Name:" -padx 1m -pady 1m +entry .name.e -relief sunken -borderwidth 2 -textvariable name -width 10 \ -font {Courier 12} -pack .nameLabel -in .middle.middle.4 -side left -pack .name -in .middle.middle.4 -side right -expand 1 -fill x -bind .name {tc_loadNamedColor $name} +pack .name.e -side right -expand 1 -fill x +bind .name.e {tc_loadNamedColor $name} +grid .name -column 1 -row 1 -sticky nsew -padx .15c -pady .15c # Create the color display swatch on the right side of the window. -frame .middle.right -pack .middle.right -side left -pady .25c -padx .25c -anchor s -frame .swatch -width 2c -height 5c -background $color -label .value -textvariable color -width 13 -font {Courier 12} -pack .swatch -in .middle.right -side top -expand yes -fill both -pack .value -in .middle.right -side bottom -pady .25c +labelframe .sample -text "Color:" -padx 1m -pady 1m +frame .sample.swatch -width 2c -height 5c -background $color +label .sample.value -textvariable color -width 13 -font {Courier 12} +pack .sample.swatch -side top -expand yes -fill both +pack .sample.value -side bottom -pady .25c +grid .sample -row 0 -column 2 -sticky nsew -padx .15c -pady .15c -rowspan 2 + # The procedure below is invoked when one of the scales is adjusted. # It propagates color information from the current scale readings @@ -147,19 +148,21 @@ pack .value -in .middle.right -side bottom -pady .25c proc tc_scaleChanged args { global red green blue colorSpace color updating autoUpdate - if $updating { + if {$updating} { return } - if {$colorSpace == "rgb"} { - set red [format %.0f [expr [.scale1 get]*65.535]] - set green [format %.0f [expr [.scale2 get]*65.535]] - set blue [format %.0f [expr [.scale3 get]*65.535]] - } else { - if {$colorSpace == "cmy"} { + switch $colorSpace { + rgb { + set red [format %.0f [expr {[.scale1 get]*65.535}]] + set green [format %.0f [expr {[.scale2 get]*65.535}]] + set blue [format %.0f [expr {[.scale3 get]*65.535}]] + } + cmy { set red [format %.0f [expr {65535 - [.scale1 get]*65.535}]] set green [format %.0f [expr {65535 - [.scale2 get]*65.535}]] set blue [format %.0f [expr {65535 - [.scale3 get]*65.535}]] - } else { + } + hsb { set list [hsbToRgb [expr {[.scale1 get]/1000.0}] \ [expr {[.scale2 get]/1000.0}] \ [expr {[.scale3 get]/1000.0}]] @@ -169,8 +172,8 @@ proc tc_scaleChanged args { } } set color [format "#%04x%04x%04x" $red $green $blue] - .swatch config -bg $color - if $autoUpdate doUpdate + .sample.swatch config -bg $color + if {$autoUpdate} doUpdate update idletasks } @@ -182,16 +185,18 @@ proc tc_scaleChanged args { proc tc_setScales {} { global red green blue colorSpace updating set updating 1 - if {$colorSpace == "rgb"} { - .scale1 set [format %.0f [expr $red/65.535]] - .scale2 set [format %.0f [expr $green/65.535]] - .scale3 set [format %.0f [expr $blue/65.535]] - } else { - if {$colorSpace == "cmy"} { - .scale1 set [format %.0f [expr (65535-$red)/65.535]] - .scale2 set [format %.0f [expr (65535-$green)/65.535]] - .scale3 set [format %.0f [expr (65535-$blue)/65.535]] - } else { + switch $colorSpace { + rgb { + .scale1 set [format %.0f [expr {$red/65.535}]] + .scale2 set [format %.0f [expr {$green/65.535}]] + .scale3 set [format %.0f [expr {$blue/65.535}]] + } + cmy { + .scale1 set [format %.0f [expr {(65535-$red)/65.535}]] + .scale2 set [format %.0f [expr {(65535-$green)/65.535}]] + .scale3 set [format %.0f [expr {(65535-$blue)/65.535}]] + } + hsb { set list [rgbToHsv $red $green $blue] .scale1 set [format %.0f [expr {[lindex $list 0] * 1000.0}]] .scale2 set [format %.0f [expr {[lindex $list 1] * 1000.0}]] @@ -209,14 +214,14 @@ proc tc_loadNamedColor name { global red green blue color autoUpdate if {[string index $name 0] != "#"} { - set list [winfo rgb .swatch $name] + set list [winfo rgb .sample.swatch $name] set red [lindex $list 0] set green [lindex $list 1] set blue [lindex $list 2] } else { - case [string length $name] { - 4 {set format "#%1x%1x%1x"; set shift 12} - 7 {set format "#%2x%2x%2x"; set shift 8} + switch [string length $name] { + 4 {set format "#%1x%1x%1x"; set shift 12} + 7 {set format "#%2x%2x%2x"; set shift 8} 10 {set format "#%3x%3x%3x"; set shift 4} 13 {set format "#%4x%4x%4x"; set shift 0} default {error "syntax error in color name \"$name\""} @@ -224,14 +229,14 @@ proc tc_loadNamedColor name { if {[scan $name $format red green blue] != 3} { error "syntax error in color name \"$name\"" } - set red [expr $red<<$shift] - set green [expr $green<<$shift] - set blue [expr $blue<<$shift] + set red [expr {$red<<$shift}] + set green [expr {$green<<$shift}] + set blue [expr {$blue<<$shift}] } tc_setScales set color [format "#%04x%04x%04x" $red $green $blue] - .swatch config -bg $color - if $autoUpdate doUpdate + .sample.swatch config -bg $color + if {$autoUpdate} doUpdate } # The procedure below is invoked when a new color space is selected. @@ -240,26 +245,28 @@ proc tc_loadNamedColor name { proc changeColorSpace space { global label1 label2 label3 - if {$space == "rgb"} { - set label1 Red - set label2 Green - set label3 Blue - tc_setScales - return - } - if {$space == "cmy"} { - set label1 Cyan - set label2 Magenta - set label3 Yellow - tc_setScales - return - } - if {$space == "hsb"} { - set label1 Hue - set label2 Saturation - set label3 Brightness - tc_setScales - return + switch $space { + rgb { + set label1 "Adjust Red:" + set label2 "Adjust Green:" + set label3 "Adjust Blue:" + tc_setScales + return + } + cmy { + set label1 "Adjust Cyan:" + set label2 "Adjust Magenta:" + set label3 "Adjust Yellow:" + tc_setScales + return + } + hsb { + set label1 "Adjust Hue:" + set label2 "Adjust Saturation:" + set label3 "Adjust Brightness:" + tc_setScales + return + } } } @@ -271,20 +278,18 @@ proc changeColorSpace space { proc rgbToHsv {red green blue} { if {$red > $green} { - set max $red.0 - set min $green.0 + set max [expr {double($red)}] + set min [expr {double($green)}] } else { - set max $green.0 - set min $red.0 + set max [expr {double($green)}] + set min [expr {double($red)}] } if {$blue > $max} { - set max $blue.0 - } else { - if {$blue < $min} { - set min $blue.0 - } + set max [expr {double($blue)}] + } elseif {$blue < $min} { + set min [expr {double($blue)}] } - set range [expr $max-$min] + set range [expr {$max-$min}] if {$max == 0} { set sat 0 } else { @@ -297,16 +302,14 @@ proc rgbToHsv {red green blue} { set gc [expr {($max - $green)/$range}] set bc [expr {($max - $blue)/$range}] if {$red == $max} { - set hue [expr {.166667*($bc - $gc)}] + set hue [expr {($bc - $gc)/6.0}] + } elseif {$green == $max} { + set hue [expr {(2 + $rc - $bc)/6.0}] } else { - if {$green == $max} { - set hue [expr {.166667*(2 + $rc - $bc)}] - } else { - set hue [expr {.166667*(4 + $gc - $rc)}] - } + set hue [expr {(4 + $gc - $rc)/6.0}] } if {$hue < 0.0} { - set hue [expr $hue + 1.0] + set hue [expr {$hue + 1.0}] } } return [list $hue $sat [expr {$max/65535}]] @@ -319,27 +322,28 @@ proc rgbToHsv {red green blue} { # Computer Graphics" by Foley and Van Dam. proc hsbToRgb {hue sat value} { - set v [format %.0f [expr 65535.0*$value]] + set v [format %.0f [expr {65535.0*$value}]] if {$sat == 0} { return "$v $v $v" } else { - set hue [expr $hue*6.0] + set hue [expr {$hue*6.0}] if {$hue >= 6.0} { set hue 0.0 } scan $hue. %d i - set f [expr $hue-$i] + set f [expr {$hue-$i}] set p [format %.0f [expr {65535.0*$value*(1 - $sat)}]] set q [format %.0f [expr {65535.0*$value*(1 - ($sat*$f))}]] set t [format %.0f [expr {65535.0*$value*(1 - ($sat*(1 - $f)))}]] - case $i \ - 0 {return "$v $t $p"} \ - 1 {return "$q $v $p"} \ - 2 {return "$p $v $t"} \ - 3 {return "$p $q $v"} \ - 4 {return "$t $p $v"} \ + switch $i { + 0 {return "$v $t $p"} + 1 {return "$q $v $p"} + 2 {return "$p $v $t"} + 3 {return "$p $q $v"} + 4 {return "$t $p $v"} 5 {return "$v $p $q"} - error "i value $i is out of range" + default {error "i value $i is out of range"} + } } } @@ -357,3 +361,6 @@ proc doUpdate {} { changeColorSpace hsb +# Local Variables: +# mode: tcl +# End: diff --git a/tk/library/demos/text.tcl b/tk/library/demos/text.tcl index 0cd2219c165..555b095413d 100644 --- a/tk/library/demos/text.tcl +++ b/tk/library/demos/text.tcl @@ -23,7 +23,7 @@ button $w.buttons.code -text "See Code" -command "showCode $w" pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 text $w.text -relief sunken -bd 2 -yscrollcommand "$w.scroll set" -setgrid 1 \ - -height 30 + -height 30 -undo 1 -autosep 1 scrollbar $w.scroll -command "$w.text yview" pack $w.scroll -side right -fill y pack $w.text -expand yes -fill both @@ -66,7 +66,19 @@ the insertion cursor to the end of the line, or it deletes the newline character if that is the only thing left on the line. Control-o opens a new line by inserting a newline character to the right of the insertion cursor. Control-t transposes the two characters on either side of the -insertion cursor. +insertion cursor. Control-z undoes the last editing action performed, +and } + +switch $tcl_platform(platform) { + "unix" - "macintosh" { + $w.text insert end "Control-Shift-z" + } + "windows" { + $w.text insert end "Control-y" + } +} + +$w.text insert end { redoes undone edits. 7. Resize the window. This widget has been configured with the "setGrid" option on, so that if you resize the window it will always resize to an @@ -74,4 +86,3 @@ even number of characters high and wide. Also, if you make the window narrow you can see that long lines automatically wrap around onto additional lines so that all the information is always visible.} $w.text mark set insert 0.0 - diff --git a/tk/library/demos/timer b/tk/library/demos/timer index 04a68f37f3e..5241331f839 100755 --- a/tk/library/demos/timer +++ b/tk/library/demos/timer @@ -7,35 +7,41 @@ exec wish "$0" "$@" # # RCS: @(#) $Id$ -label .counter -text 0.00 -relief raised -width 10 +label .counter -text 0.00 -relief raised -width 10 -padx 2m -pady 1m button .start -text Start -command { - if $stopped { + if {$stopped} { set stopped 0 + set startMoment [clock clicks -milliseconds] tick + .stop configure -state normal + .start configure -state disabled } } -button .stop -text Stop -command {set stopped 1} +button .stop -text Stop -state disabled -command { + set stopped 1 + .stop configure -state disabled + .start configure -state normal +} pack .counter -side bottom -fill both pack .start -side left -fill both -expand yes pack .stop -side right -fill both -expand yes -set seconds 0 -set hundredths 0 +set startMoment {} + set stopped 1 proc tick {} { - global seconds hundredths stopped - if $stopped return + global startMoment stopped + if {$stopped} {return} after 50 tick - set hundredths [expr $hundredths+5] - if {$hundredths >= 100} { - set hundredths 0 - set seconds [expr $seconds+1] - } - .counter config -text [format "%d.%02d" $seconds $hundredths] + set elapsedMS [expr {[clock clicks -milliseconds] - $startMoment}] + .counter config -text [format "%.2f" [expr {double($elapsedMS)/1000}]] } bind . {destroy .} bind . {destroy .} focus . +# Local Variables: +# mode: tcl +# End: diff --git a/tk/library/demos/twind.tcl b/tk/library/demos/twind.tcl index 475cbd724bf..0a41c0d1e49 100644 --- a/tk/library/demos/twind.tcl +++ b/tk/library/demos/twind.tcl @@ -115,7 +115,7 @@ proc textWindOff w { proc textWindPlot t { set c $t.c - if [winfo exists $c] { + if {[winfo exists $c]} { return } canvas $c -relief sunken -width 450 -height 300 -cursor top_left_arrow @@ -129,20 +129,21 @@ proc textWindPlot t { for {set i 0} {$i <= 10} {incr i} { set x [expr {100 + ($i*30)}] $c create line $x 250 $x 245 -width 2 - $c create text $x 254 -text [expr 10*$i] -anchor n -font $font + $c create text $x 254 -text [expr {10*$i}] -anchor n -font $font } for {set i 0} {$i <= 5} {incr i} { set y [expr {250 - ($i*40)}] $c create line 100 $y 105 $y -width 2 - $c create text 96 $y -text [expr $i*50].0 -anchor e -font $font + $c create text 96 $y -text [expr {$i*50}].0 -anchor e -font $font } - foreach point {{12 56} {20 94} {33 98} {32 120} {61 180} - {75 160} {98 223}} { + foreach point { + {12 56} {20 94} {33 98} {32 120} {61 180} {75 160} {98 223} + } { set x [expr {100 + (3*[lindex $point 0])}] set y [expr {250 - (4*[lindex $point 1])/5}] - set item [$c create oval [expr $x-6] [expr $y-6] \ - [expr $x+6] [expr $y+6] -width 1 -outline black \ + set item [$c create oval [expr {$x-6}] [expr {$y-6}] \ + [expr {$x+6}] [expr {$y+6}] -width 1 -outline black \ -fill SkyBlue2] $c addtag point withtag $item } @@ -175,14 +176,14 @@ proc embPlotDown {w x y} { proc embPlotMove {w x y} { global embPlot - $w move selected [expr $x-$embPlot(lastX)] [expr $y-$embPlot(lastY)] + $w move selected [expr {$x-$embPlot(lastX)}] [expr {$y-$embPlot(lastY)}] set embPlot(lastX) $x set embPlot(lastY) $y } proc textWindDel w { set t $w.f.text - if [winfo exists $t.c] { + if {[winfo exists $t.c]} { $t delete $t.c while {[string first [$t get plot] " \t\n"] >= 0} { $t delete plot @@ -194,4 +195,3 @@ proc textWindDel w { proc embDefBg t { $t configure -background [lindex [$t configure -background] 3] } - diff --git a/tk/library/demos/vscale.tcl b/tk/library/demos/vscale.tcl index 7f1afd2a780..278e7d0a659 100644 --- a/tk/library/demos/vscale.tcl +++ b/tk/library/demos/vscale.tcl @@ -39,11 +39,10 @@ $w.frame.scale set 75 proc setHeight {w height} { incr height 21 - set y2 [expr $height - 30] + set y2 [expr {$height - 30}] if {$y2 < 21} { set y2 21 } $w coords poly 15 20 35 20 35 $y2 45 $y2 25 $height 5 $y2 15 $y2 15 20 $w coords line 15 20 35 20 35 $y2 45 $y2 25 $height 5 $y2 15 $y2 15 20 } - diff --git a/tk/library/demos/widget b/tk/library/demos/widget index eca4cb723c8..8414aab3471 100755 --- a/tk/library/demos/widget +++ b/tk/library/demos/widget @@ -15,7 +15,26 @@ exec wish "$0" "$@" eval destroy [winfo child .] wm title . "Widget Demonstration" +if {$tcl_platform(platform) eq "unix"} { + # This won't work everywhere, but there's no other way in core Tk + # at the moment to display a coloured icon. + image create photo TclPowered \ + -file [file join $tk_library images logo64.gif] + wm iconwindow . [toplevel ._iconWindow] + pack [label ._iconWindow.i -image TclPowered] + wm iconname . "tkWidgetDemo" +} + +array set widgetFont { + main {Helvetica 12} + bold {Helvetica 12 bold} + title {Helvetica 18 bold} + status {Helvetica 10} + vars {Helvetica 14} +} + set widgetDemo 1 +set font $widgetFont(main) #---------------------------------------------------------------- # The code below create the main window, consisting of a menu bar @@ -23,13 +42,12 @@ set widgetDemo 1 # all of the demos as hypertext items. #---------------------------------------------------------------- -set font {Helvetica 14} menu .menuBar -tearoff 0 .menuBar add cascade -menu .menuBar.file -label "File" -underline 0 menu .menuBar.file -tearoff 0 # On the Mac use the specia .apple menu for the about item -if {$tcl_platform(platform) == "macintosh"} { +if {[string equal [tk windowingsystem] "classic"]} { .menuBar add cascade -menu .menuBar.apple menu .menuBar.apple -tearoff 0 .menuBar.apple add command -label "About..." -command "aboutBox" @@ -46,9 +64,9 @@ bind . aboutBox frame .statusBar label .statusBar.lab -text " " -relief sunken -bd 1 \ - -font -*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* -anchor w + -font $widgetFont(status) -anchor w label .statusBar.foo -width 8 -relief sunken -bd 1 \ - -font -*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* -anchor w + -font $widgetFont(status) -anchor w pack .statusBar.lab -side left -padx 2 -expand yes -fill both pack .statusBar.foo -side left -padx 2 pack .statusBar -side bottom -fill x -pady 2 @@ -57,8 +75,9 @@ frame .textFrame scrollbar .s -orient vertical -command {.t yview} -highlightthickness 0 \ -takefocus 1 pack .s -in .textFrame -side right -fill y -text .t -yscrollcommand {.s set} -wrap word -width 60 -height 30 -font $font \ - -setgrid 1 -highlightthickness 0 -padx 4 -pady 2 -takefocus 0 +text .t -yscrollcommand {.s set} -wrap word -width 70 -height 30 \ + -font $widgetFont(main) -setgrid 1 -highlightthickness 0 \ + -padx 4 -pady 2 -takefocus 0 pack .t -in .textFrame -expand y -fill both -padx 1 pack .textFrame -expand yes -fill both @@ -66,7 +85,8 @@ pack .textFrame -expand yes -fill both # section titles and demo descriptions. Also define the bindings for # tags. -.t tag configure title -font {Helvetica 18 bold} +.t tag configure title -font $widgetFont(title) +.t tag configure bold -font $widgetFont(bold) # We put some "space" characters to the left and right of each demo description # so that the descriptions are highlighted only when the mouse cursor @@ -120,113 +140,86 @@ set lastLine "" # Create the text for the text widget. -.t insert end "Tk Widget Demonstrations\n" title -.t insert end { -This application provides a front end for several short scripts that demonstrate what you can do with Tk widgets. Each of the numbered lines below describes a demonstration; you can click on it to invoke the demonstration. Once the demonstration window appears, you can click the "See Code" button to see the Tcl/Tk code that created the demonstration. If you wish, you can edit the code and click the "Rerun Demo" button in the code window to reinvoke the demonstration with the modified code. +proc addDemoSection {title demos} { + .t insert end "\n" {} $title title " \n " demospace + set num 0 + foreach {name description} $demos { + .t insert end "[incr num]. $description." [list demo demo-$name] + .t insert end " \n " demospace + } +} +.t insert end "Tk Widget Demonstrations\n" title +.t insert end "\nThis application provides a front end for several short\ + scripts that demonstrate what you can do with Tk widgets. Each of\ + the numbered lines below describes a demonstration; you can click\ + on it to invoke the demonstration. Once the demonstration window\ + appears, you can click the " {} "See Code" bold " button to see the\ + Tcl/Tk code that created the demonstration. If you wish, you can\ + edit the code and click the " {} "Rerun Demo" bold " button in the\ + code window to reinvoke the demonstration with the modified code.\n" + +addDemoSection "Labels, buttons, checkbuttons, and radiobuttons" { + label "Labels (text and bitmaps)" + button "Buttons" + check "Check-buttons (select any of a group)" + radio "Radio-buttons (select one of a group)" + puzzle "A 15-puzzle game made out of buttons" + icon "Iconic buttons that use bitmaps" + image1 "Two labels displaying images" + image2 "A simple user interface for viewing images" + labelframe "Labelled frames" +} +addDemoSection "Listboxes" { + states "The 50 states" + colors "Colors: change the color scheme for the application" + sayings "A collection of famous and infamous sayings" +} +addDemoSection "Entries and Spin-boxes" { + entry1 "Entries without scrollbars" + entry2 "Entries with scrollbars" + entry3 "Validated entries and password fields" + spin "Spin-boxes" + form "Simple Rolodex-like form" +} +addDemoSection "Text" { + text "Basic editable text" + style "Text display styles" + bind "Hypertext (tag bindings)" + twind "A text widget with embedded windows" + search "A search tool built with a text widget" +} +addDemoSection "Canvases" { + items "The canvas item types" + plot "A simple 2-D plot" + ctext "Text items in canvases" + arrow "An editor for arrowheads on canvas lines" + ruler "A ruler with adjustable tab stops" + floor "A building floor plan" + cscroll "A simple scrollable canvas" +} +addDemoSection "Scales" { + hscale "Horizontal scale" + vscale "Vertical scale" +} +addDemoSection "Paned Windows" { + paned1 "Horizontal paned window" + paned2 "Vertical paned window" +} +addDemoSection "Menus" { + menu "Menus and cascades (sub-menus)" + menubu "Menu-buttons" +} +addDemoSection "Common Dialogs" { + msgbox "Message boxes" + filebox "File selection dialog" + clrpick "Color picker" +} +addDemoSection "Miscellaneous" { + bitmap "The built-in bitmaps" + dialog1 "A dialog box with a local grab" + dialog2 "A dialog box with a global grab" } -.t insert end "Labels, buttons, checkbuttons, and radiobuttons" title -.t insert end " \n " {demospace} -.t insert end "1. Labels (text and bitmaps)." {demo demo-label} -.t insert end " \n " {demospace} -.t insert end "2. Buttons." {demo demo-button} -.t insert end " \n " {demospace} -.t insert end "3. Checkbuttons (select any of a group)." {demo demo-check} -.t insert end " \n " {demospace} -.t insert end "4. Radiobuttons (select one of a group)." {demo demo-radio} -.t insert end " \n " {demospace} -.t insert end "5. A 15-puzzle game made out of buttons." {demo demo-puzzle} -.t insert end " \n " {demospace} -.t insert end "6. Iconic buttons that use bitmaps." {demo demo-icon} -.t insert end " \n " {demospace} -.t insert end "7. Two labels displaying images." {demo demo-image1} -.t insert end " \n " {demospace} -.t insert end "8. A simple user interface for viewing images." \ - {demo demo-image2} -.t insert end " \n " {demospace} - -.t insert end \n {} "Listboxes" title -.t insert end " \n " {demospace} -.t insert end "1. 50 states." {demo demo-states} -.t insert end " \n " {demospace} -.t insert end "2. Colors: change the color scheme for the application." \ - {demo demo-colors} -.t insert end " \n " {demospace} -.t insert end "3. A collection of famous sayings." {demo demo-sayings} -.t insert end " \n " {demospace} - -.t insert end \n {} "Entries" title -.t insert end " \n " {demospace} -.t insert end "1. Without scrollbars." {demo demo-entry1} -.t insert end " \n " {demospace} -.t insert end "2. With scrollbars." {demo demo-entry2} -.t insert end " \n " {demospace} -.t insert end "3. Simple Rolodex-like form." {demo demo-form} -.t insert end " \n " {demospace} - -.t insert end \n {} "Text" title -.t insert end " \n " {demospace} -.t insert end "1. Basic editable text." {demo demo-text} -.t insert end " \n " {demospace} -.t insert end "2. Text display styles." {demo demo-style} -.t insert end " \n " {demospace} -.t insert end "3. Hypertext (tag bindings)." {demo demo-bind} -.t insert end " \n " {demospace} -.t insert end "4. A text widget with embedded windows." {demo demo-twind} -.t insert end " \n " {demospace} -.t insert end "5. A search tool built with a text widget." {demo demo-search} -.t insert end " \n " {demospace} - -.t insert end \n {} "Canvases" title -.t insert end " \n " {demospace} -.t insert end "1. The canvas item types." {demo demo-items} -.t insert end " \n " {demospace} -.t insert end "2. A simple 2-D plot." {demo demo-plot} -.t insert end " \n " {demospace} -.t insert end "3. Text items in canvases." {demo demo-ctext} -.t insert end " \n " {demospace} -.t insert end "4. An editor for arrowheads on canvas lines." {demo demo-arrow} -.t insert end " \n " {demospace} -.t insert end "5. A ruler with adjustable tab stops." {demo demo-ruler} -.t insert end " \n " {demospace} -.t insert end "6. A building floor plan." {demo demo-floor} -.t insert end " \n " {demospace} -.t insert end "7. A simple scrollable canvas." {demo demo-cscroll} -.t insert end " \n " {demospace} - -.t insert end \n {} "Scales" title -.t insert end " \n " {demospace} -.t insert end "1. Vertical scale." {demo demo-vscale} -.t insert end " \n " {demospace} -.t insert end "2. Horizontal scale." {demo demo-hscale} -.t insert end " \n " {demospace} - -.t insert end \n {} "Menus" title -.t insert end " \n " {demospace} -.t insert end "1. Menus and cascades." \ - {demo demo-menu} -.t insert end " \n " {demospace} -.t insert end "2. Menubuttons"\ - {demo demo-menubu} -.t insert end " \n " {demospace} - -.t insert end \n {} "Common Dialogs" title -.t insert end " \n " {demospace} -.t insert end "1. Message boxes." {demo demo-msgbox} -.t insert end " \n " {demospace} -.t insert end "2. File selection dialog." {demo demo-filebox} -.t insert end " \n " {demospace} -.t insert end "3. Color picker." {demo demo-clrpick} -.t insert end " \n " {demospace} - -.t insert end \n {} "Miscellaneous" title -.t insert end " \n " {demospace} -.t insert end "1. The built-in bitmaps." {demo demo-bitmap} -.t insert end " \n " {demospace} -.t insert end "2. A dialog box with a local grab." {demo demo-dialog1} -.t insert end " \n " {demospace} -.t insert end "3. A dialog box with a global grab." {demo demo-dialog2} -.t insert end " \n " {demospace} .t configure -state disabled focus .s @@ -251,11 +244,12 @@ proc positionWindow w { # args - Any number of names of variables. proc showVars {w args} { + global widgetFont catch {destroy $w} toplevel $w wm title $w "Variable values" label $w.title -text "Variable values:" -width 20 -anchor center \ - -font {Helvetica 18} + -font $widgetFont(vars) pack $w.title -side top -fill x set len 1 foreach i $args { @@ -385,8 +379,15 @@ proc showCode w { # proc aboutBox {} { tk_messageBox -icon info -type ok -title "About Widget Demo" -message \ -"Tk widget demonstration\n\n\ -Copyright (c) 1996-1997 Sun Microsystems, Inc." -} +"Tk widget demonstration + +Copyright (c) 1996-1997 Sun Microsystems, Inc. +Copyright (c) 1997-2000 Ajuba Solutions, Inc. + +Copyright (c) 2001-2002 Donal K. Fellows" +} +# Local Variables: +# mode: tcl +# End: diff --git a/tk/library/dialog.tcl b/tk/library/dialog.tcl index 37dd66460bb..2d5036a66be 100644 --- a/tk/library/dialog.tcl +++ b/tk/library/dialog.tcl @@ -13,7 +13,7 @@ # # -# tk_dialog: +# ::tk_dialog: # # This procedure displays a dialog box, waits for a button in the dialog # to be invoked, then returns the index of the selected button. If the @@ -29,8 +29,9 @@ # args - One or more strings to display in buttons across the # bottom of the dialog box. -proc tk_dialog {w title text bitmap default args} { - global tkPriv tcl_platform +proc ::tk_dialog {w title text bitmap default args} { + global tcl_platform + variable ::tk::Priv # Check that $default was properly given if {[string is int $default]} { @@ -51,7 +52,7 @@ proc tk_dialog {w title text bitmap default args} { toplevel $w -class Dialog wm title $w $title wm iconname $w Dialog - wm protocol $w WM_DELETE_WINDOW {set tkPriv(button) -1} + wm protocol $w WM_DELETE_WINDOW { } # Dialog boxes should be transient with respect to their parent, # so that they will always stay on top of their parent window. However, @@ -60,17 +61,18 @@ proc tk_dialog {w title text bitmap default args} { # window, this can hang the entire application. Therefore we only make # the dialog transient if the parent is viewable. # - if { [winfo viewable [winfo toplevel [winfo parent $w]]] } { + if {[winfo viewable [winfo toplevel [winfo parent $w]]] } { wm transient $w [winfo toplevel [winfo parent $w]] } - if {[string equal $tcl_platform(platform) "macintosh"]} { - unsupported1 style $w dBoxProc + if {[string equal $tcl_platform(platform) "macintosh"] + || [string equal [tk windowingsystem] "aqua"]} { + ::tk::unsupported::MacWindowStyle style $w dBoxProc } frame $w.bot frame $w.top - if {[string equal $tcl_platform(platform) "unix"]} { + if {[string equal [tk windowingsystem] "x11"]} { $w.bot configure -relief raised -bd 1 $w.top configure -relief raised -bd 1 } @@ -82,7 +84,8 @@ proc tk_dialog {w title text bitmap default args} { # overridden by the caller). option add *Dialog.msg.wrapLength 3i widgetDefault - if {[string equal $tcl_platform(platform) "macintosh"]} { + if {[string equal $tcl_platform(platform) "macintosh"] + || [string equal [tk windowingsystem] "aqua"]} { option add *Dialog.msg.font system widgetDefault } else { option add *Dialog.msg.font {Times 12} widgetDefault @@ -91,7 +94,8 @@ proc tk_dialog {w title text bitmap default args} { label $w.msg -justify left -text $text pack $w.msg -in $w.top -side right -expand 1 -fill both -padx 3m -pady 3m if {[string compare $bitmap ""]} { - if {[string equal $tcl_platform(platform) "macintosh"] && \ + if {([string equal $tcl_platform(platform) "macintosh"] + || [string equal [tk windowingsystem] "aqua"]) &&\ [string equal $bitmap "error"]} { set bitmap "stop" } @@ -103,16 +107,18 @@ proc tk_dialog {w title text bitmap default args} { set i 0 foreach but $args { - button $w.button$i -text $but -command [list set tkPriv(button) $i] + button $w.button$i -text $but -command [list set ::tk::Priv(button) $i] if {$i == $default} { $w.button$i configure -default active } else { $w.button$i configure -default normal } - grid $w.button$i -in $w.bot -column $i -row 0 -sticky ew -padx 10 + grid $w.button$i -in $w.bot -column $i -row 0 -sticky ew \ + -padx 10 -pady 4 grid columnconfigure $w.bot $i # We boost the size of some Mac buttons for l&f - if {[string equal $tcl_platform(platform) "macintosh"]} { + if {[string equal $tcl_platform(platform) "macintosh"] + || [string equal [tk windowingsystem] "aqua"]} { set tmp [string tolower $but] if {[string equal $tmp "ok"] || [string equal $tmp "cancel"]} { grid columnconfigure $w.bot $i -minsize [expr {59 + 20}] @@ -129,7 +135,7 @@ proc tk_dialog {w title text bitmap default args} { [list $w.button$default] configure -state active -relief sunken update idletasks after 100 - set tkPriv(button) $default + set ::tk::Priv(button) $default " } @@ -137,7 +143,7 @@ proc tk_dialog {w title text bitmap default args} { # button variable to -1; this is needed in case something happens # that destroys the window, such as its parent window being destroyed. - bind $w {set tkPriv(button) -1} + bind $w {set ::tk::Priv(button) -1} # 6. Withdraw the window, then update all the geometry information # so we know how big it wants to be, then center the window in the @@ -150,7 +156,6 @@ proc tk_dialog {w title text bitmap default args} { set y [expr {[winfo screenheight $w]/2 - [winfo reqheight $w]/2 \ - [winfo vrooty [winfo parent $w]]}] wm geom $w +$x+$y - update idle wm deiconify $w # 7. Set a grab and claim the focus too. @@ -173,12 +178,12 @@ proc tk_dialog {w title text bitmap default args} { # may take the focus away so we can't redirect it. Finally, # restore any grab that was in effect. - tkwait variable tkPriv(button) + vwait ::tk::Priv(button) catch {focus $oldFocus} catch { # It's possible that the window has already been destroyed, # hence this "catch". Delete the Destroy handler so that - # tkPriv(button) doesn't get reset by it. + # Priv(button) doesn't get reset by it. bind $w {} destroy $w @@ -190,7 +195,5 @@ proc tk_dialog {w title text bitmap default args} { grab -global $oldGrab } } - return $tkPriv(button) + return $Priv(button) } - - diff --git a/tk/library/entry.tcl b/tk/library/entry.tcl index 594811a6108..5bc2ed381b0 100644 --- a/tk/library/entry.tcl +++ b/tk/library/entry.tcl @@ -13,7 +13,7 @@ # #------------------------------------------------------------------------- -# Elements of tkPriv that are used in this file: +# Elements of tk::Priv that are used in this file: # # afterId - If non-null, it means that auto-scanning is underway # and it gives the "after" id for the next auto-scan @@ -33,128 +33,129 @@ # The code below creates the default class bindings for entries. #------------------------------------------------------------------------- bind Entry <> { - if {![catch {tkEntryGetSelection %W} tkPriv(data)]} { + if {![catch {tk::EntryGetSelection %W} tk::Priv(data)]} { clipboard clear -displayof %W - clipboard append -displayof %W $tkPriv(data) + clipboard append -displayof %W $tk::Priv(data) %W delete sel.first sel.last - unset tkPriv(data) + unset tk::Priv(data) } } bind Entry <> { - if {![catch {tkEntryGetSelection %W} tkPriv(data)]} { + if {![catch {tk::EntryGetSelection %W} tk::Priv(data)]} { clipboard clear -displayof %W - clipboard append -displayof %W $tkPriv(data) - unset tkPriv(data) + clipboard append -displayof %W $tk::Priv(data) + unset tk::Priv(data) } } bind Entry <> { global tcl_platform catch { - if {[string compare $tcl_platform(platform) "unix"]} { + if {[string compare [tk windowingsystem] "x11"]} { catch { %W delete sel.first sel.last } } - %W insert insert [selection get -displayof %W -selection CLIPBOARD] - tkEntrySeeInsert %W + %W insert insert [::tk::GetSelection %W CLIPBOARD] + tk::EntrySeeInsert %W } } bind Entry <> { %W delete sel.first sel.last } bind Entry <> { - if {!$tkPriv(mouseMoved) || $tk_strictMotif} { - tkEntryPaste %W %x + if {$tk_strictMotif || ![info exists tk::Priv(mouseMoved)] + || !$tk::Priv(mouseMoved)} { + tk::EntryPaste %W %x } } # Standard Motif bindings: bind Entry <1> { - tkEntryButton1 %W %x + tk::EntryButton1 %W %x %W selection clear } bind Entry { - set tkPriv(x) %x - tkEntryMouseSelect %W %x + set tk::Priv(x) %x + tk::EntryMouseSelect %W %x } bind Entry { - set tkPriv(selectMode) word - tkEntryMouseSelect %W %x - catch {%W icursor sel.first} + set tk::Priv(selectMode) word + tk::EntryMouseSelect %W %x + catch {%W icursor sel.last} } bind Entry { - set tkPriv(selectMode) line - tkEntryMouseSelect %W %x - %W icursor 0 + set tk::Priv(selectMode) line + tk::EntryMouseSelect %W %x + catch {%W icursor sel.last} } bind Entry { - set tkPriv(selectMode) char + set tk::Priv(selectMode) char %W selection adjust @%x } bind Entry { - set tkPriv(selectMode) word - tkEntryMouseSelect %W %x + set tk::Priv(selectMode) word + tk::EntryMouseSelect %W %x } bind Entry { - set tkPriv(selectMode) line - tkEntryMouseSelect %W %x + set tk::Priv(selectMode) line + tk::EntryMouseSelect %W %x } bind Entry { - set tkPriv(x) %x - tkEntryAutoScan %W + set tk::Priv(x) %x + tk::EntryAutoScan %W } bind Entry { - tkCancelRepeat + tk::CancelRepeat } bind Entry { - tkCancelRepeat + tk::CancelRepeat } bind Entry { %W icursor @%x } bind Entry { - tkEntrySetCursor %W [expr {[%W index insert] - 1}] + tk::EntrySetCursor %W [expr {[%W index insert] - 1}] } bind Entry { - tkEntrySetCursor %W [expr {[%W index insert] + 1}] + tk::EntrySetCursor %W [expr {[%W index insert] + 1}] } bind Entry { - tkEntryKeySelect %W [expr {[%W index insert] - 1}] - tkEntrySeeInsert %W + tk::EntryKeySelect %W [expr {[%W index insert] - 1}] + tk::EntrySeeInsert %W } bind Entry { - tkEntryKeySelect %W [expr {[%W index insert] + 1}] - tkEntrySeeInsert %W + tk::EntryKeySelect %W [expr {[%W index insert] + 1}] + tk::EntrySeeInsert %W } bind Entry { - tkEntrySetCursor %W [tkEntryPreviousWord %W insert] + tk::EntrySetCursor %W [tk::EntryPreviousWord %W insert] } bind Entry { - tkEntrySetCursor %W [tkEntryNextWord %W insert] + tk::EntrySetCursor %W [tk::EntryNextWord %W insert] } bind Entry { - tkEntryKeySelect %W [tkEntryPreviousWord %W insert] - tkEntrySeeInsert %W + tk::EntryKeySelect %W [tk::EntryPreviousWord %W insert] + tk::EntrySeeInsert %W } bind Entry { - tkEntryKeySelect %W [tkEntryNextWord %W insert] - tkEntrySeeInsert %W + tk::EntryKeySelect %W [tk::EntryNextWord %W insert] + tk::EntrySeeInsert %W } bind Entry { - tkEntrySetCursor %W 0 + tk::EntrySetCursor %W 0 } bind Entry { - tkEntryKeySelect %W 0 - tkEntrySeeInsert %W + tk::EntryKeySelect %W 0 + tk::EntrySeeInsert %W } bind Entry { - tkEntrySetCursor %W end + tk::EntrySetCursor %W end } bind Entry { - tkEntryKeySelect %W end - tkEntrySeeInsert %W + tk::EntryKeySelect %W end + tk::EntrySeeInsert %W } bind Entry { @@ -165,7 +166,7 @@ bind Entry { } } bind Entry { - tkEntryBackspace %W + tk::EntryBackspace %W } bind Entry { @@ -187,7 +188,7 @@ bind Entry { %W selection clear } bind Entry { - tkEntryInsert %W %A + tk::EntryInsert %W %A } # Ignore all Alt, Meta, and Control keypresses unless explicitly bound. @@ -202,7 +203,8 @@ bind Entry {# nothing} bind Entry {# nothing} bind Entry {# nothing} bind Entry {# nothing} -if {[string equal $tcl_platform(platform) "macintosh"]} { +if {[string equal [tk windowingsystem] "classic"] + || [string equal [tk windowingsystem] "aqua"]} { bind Entry {# nothing} } @@ -210,7 +212,7 @@ if {[string equal $tcl_platform(platform) "macintosh"]} { # generates the <> event, so we don't need to do anything here. if {[string compare $tcl_platform(platform) "windows"]} { bind Entry { - catch {tkEntryInsert %W [selection get -displayof %W]} + catch {tk::EntryInsert %W [::tk::GetSelection %W PRIMARY]} } } @@ -218,12 +220,12 @@ if {[string compare $tcl_platform(platform) "windows"]} { bind Entry { if {!$tk_strictMotif} { - tkEntrySetCursor %W 0 + tk::EntrySetCursor %W 0 } } bind Entry { if {!$tk_strictMotif} { - tkEntrySetCursor %W [expr {[%W index insert] - 1}] + tk::EntrySetCursor %W [expr {[%W index insert] - 1}] } } bind Entry { @@ -233,17 +235,17 @@ bind Entry { } bind Entry { if {!$tk_strictMotif} { - tkEntrySetCursor %W end + tk::EntrySetCursor %W end } } bind Entry { if {!$tk_strictMotif} { - tkEntrySetCursor %W [expr {[%W index insert] + 1}] + tk::EntrySetCursor %W [expr {[%W index insert] + 1}] } } bind Entry { if {!$tk_strictMotif} { - tkEntryBackspace %W + tk::EntryBackspace %W } } bind Entry { @@ -253,32 +255,32 @@ bind Entry { } bind Entry { if {!$tk_strictMotif} { - tkEntryTranspose %W + tk::EntryTranspose %W } } bind Entry { if {!$tk_strictMotif} { - tkEntrySetCursor %W [tkEntryPreviousWord %W insert] + tk::EntrySetCursor %W [tk::EntryPreviousWord %W insert] } } bind Entry { if {!$tk_strictMotif} { - %W delete insert [tkEntryNextWord %W insert] + %W delete insert [tk::EntryNextWord %W insert] } } bind Entry { if {!$tk_strictMotif} { - tkEntrySetCursor %W [tkEntryNextWord %W insert] + tk::EntrySetCursor %W [tk::EntryNextWord %W insert] } } bind Entry { if {!$tk_strictMotif} { - %W delete [tkEntryPreviousWord %W insert] insert + %W delete [tk::EntryPreviousWord %W insert] insert } } bind Entry { if {!$tk_strictMotif} { - %W delete [tkEntryPreviousWord %W insert] insert + %W delete [tk::EntryPreviousWord %W insert] insert } } @@ -286,22 +288,16 @@ bind Entry { bind Entry <2> { if {!$tk_strictMotif} { - %W scan mark %x - set tkPriv(x) %x - set tkPriv(y) %y - set tkPriv(mouseMoved) 0 + ::tk::EntryScanMark %W %x } } bind Entry { if {!$tk_strictMotif} { - if {abs(%x-$tkPriv(x)) > 2} { - set tkPriv(mouseMoved) 1 - } - %W scan dragto %x + ::tk::EntryScanDrag %W %x } } -# tkEntryClosestGap -- +# ::tk::EntryClosestGap -- # Given x and y coordinates, this procedure finds the closest boundary # between characters to the given coordinates and returns the index # of the character just after the boundary. @@ -310,7 +306,7 @@ bind Entry { # w - The entry window. # x - X-coordinate within the window. -proc tkEntryClosestGap {w x} { +proc ::tk::EntryClosestGap {w x} { set pos [$w index @$x] set bbox [$w bbox $pos] if {($x - [lindex $bbox 0]) < ([lindex $bbox 2]/2)} { @@ -319,7 +315,7 @@ proc tkEntryClosestGap {w x} { incr pos } -# tkEntryButton1 -- +# ::tk::EntryButton1 -- # This procedure is invoked to handle button-1 presses in entry # widgets. It moves the insertion cursor, sets the selection anchor, # and claims the input focus. @@ -328,18 +324,18 @@ proc tkEntryClosestGap {w x} { # w - The entry window in which the button was pressed. # x - The x-coordinate of the button press. -proc tkEntryButton1 {w x} { - global tkPriv +proc ::tk::EntryButton1 {w x} { + variable ::tk::Priv - set tkPriv(selectMode) char - set tkPriv(mouseMoved) 0 - set tkPriv(pressX) $x - $w icursor [tkEntryClosestGap $w $x] + set Priv(selectMode) char + set Priv(mouseMoved) 0 + set Priv(pressX) $x + $w icursor [EntryClosestGap $w $x] $w selection from insert - if {[string equal [$w cget -state] "normal"]} {focus $w} + if {[string compare "disabled" [$w cget -state]]} {focus $w} } -# tkEntryMouseSelect -- +# ::tk::EntryMouseSelect -- # This procedure is invoked when dragging out a selection with # the mouse. Depending on the selection mode (character, word, # line) it selects in different-sized units. This procedure @@ -350,17 +346,17 @@ proc tkEntryButton1 {w x} { # w - The entry window in which the button was pressed. # x - The x-coordinate of the mouse. -proc tkEntryMouseSelect {w x} { - global tkPriv +proc ::tk::EntryMouseSelect {w x} { + variable ::tk::Priv - set cur [tkEntryClosestGap $w $x] + set cur [EntryClosestGap $w $x] set anchor [$w index anchor] - if {($cur != $anchor) || (abs($tkPriv(pressX) - $x) >= 3)} { - set tkPriv(mouseMoved) 1 + if {($cur != $anchor) || (abs($Priv(pressX) - $x) >= 3)} { + set Priv(mouseMoved) 1 } - switch $tkPriv(selectMode) { + switch $Priv(selectMode) { char { - if {$tkPriv(mouseMoved)} { + if {$Priv(mouseMoved)} { if {$cur < $anchor} { $w selection range $cur $anchor } elseif {$cur > $anchor} { @@ -390,10 +386,13 @@ proc tkEntryMouseSelect {w x} { $w selection range 0 end } } + if {$Priv(mouseMoved)} { + $w icursor $cur + } update idletasks } -# tkEntryPaste -- +# ::tk::EntryPaste -- # This procedure sets the insertion cursor to the current mouse position, # pastes the selection there, and sets the focus to the window. # @@ -401,15 +400,13 @@ proc tkEntryMouseSelect {w x} { # w - The entry window. # x - X position of the mouse. -proc tkEntryPaste {w x} { - global tkPriv - - $w icursor [tkEntryClosestGap $w $x] - catch {$w insert insert [selection get -displayof $w]} - if {[string equal [$w cget -state] "normal"]} {focus $w} +proc ::tk::EntryPaste {w x} { + $w icursor [EntryClosestGap $w $x] + catch {$w insert insert [::tk::GetSelection $w PRIMARY]} + if {[string compare "disabled" [$w cget -state]]} {focus $w} } -# tkEntryAutoScan -- +# ::tk::EntryAutoScan -- # This procedure is invoked when the mouse leaves an entry window # with button 1 down. It scrolls the window left or right, # depending on where the mouse is, and reschedules itself as an @@ -419,21 +416,21 @@ proc tkEntryPaste {w x} { # Arguments: # w - The entry window. -proc tkEntryAutoScan {w} { - global tkPriv - set x $tkPriv(x) +proc ::tk::EntryAutoScan {w} { + variable ::tk::Priv + set x $Priv(x) if {![winfo exists $w]} return if {$x >= [winfo width $w]} { $w xview scroll 2 units - tkEntryMouseSelect $w $x + EntryMouseSelect $w $x } elseif {$x < 0} { $w xview scroll -2 units - tkEntryMouseSelect $w $x + EntryMouseSelect $w $x } - set tkPriv(afterId) [after 50 [list tkEntryAutoScan $w]] + set Priv(afterId) [after 50 [list tk::EntryAutoScan $w]] } -# tkEntryKeySelect -- +# ::tk::EntryKeySelect -- # This procedure is invoked when stroking out selections using the # keyboard. It moves the cursor to a new position, then extends # the selection to that position. @@ -443,7 +440,7 @@ proc tkEntryAutoScan {w} { # new - A new position for the insertion cursor (the cursor hasn't # actually been moved to this position yet). -proc tkEntryKeySelect {w new} { +proc ::tk::EntryKeySelect {w new} { if {![$w selection present]} { $w selection from insert $w selection to $new @@ -453,7 +450,7 @@ proc tkEntryKeySelect {w new} { $w icursor $new } -# tkEntryInsert -- +# ::tk::EntryInsert -- # Insert a string into an entry at the point of the insertion cursor. # If there is a selection in the entry, and it covers the point of the # insertion cursor, then delete the selection before inserting. @@ -462,7 +459,7 @@ proc tkEntryKeySelect {w new} { # w - The entry window in which to insert the string # s - The string to insert (usually just a single character) -proc tkEntryInsert {w s} { +proc ::tk::EntryInsert {w s} { if {[string equal $s ""]} { return } @@ -474,10 +471,10 @@ proc tkEntryInsert {w s} { } } $w insert insert $s - tkEntrySeeInsert $w + EntrySeeInsert $w } -# tkEntryBackspace -- +# ::tk::EntryBackspace -- # Backspace over the character just before the insertion cursor. # If backspacing would move the cursor off the left edge of the # window, reposition the cursor at about the middle of the window. @@ -485,7 +482,7 @@ proc tkEntryInsert {w s} { # Arguments: # w - The entry window in which to backspace. -proc tkEntryBackspace w { +proc ::tk::EntryBackspace w { if {[$w selection present]} { $w delete sel.first sel.last } else { @@ -500,21 +497,21 @@ proc tkEntryBackspace w { } } -# tkEntrySeeInsert -- +# ::tk::EntrySeeInsert -- # Make sure that the insertion cursor is visible in the entry window. # If not, adjust the view so that it is. # # Arguments: # w - The entry window. -proc tkEntrySeeInsert w { +proc ::tk::EntrySeeInsert w { set c [$w index insert] if {($c < [$w index @0]) || ($c > [$w index @[winfo width $w]])} { $w xview $c } } -# tkEntrySetCursor - +# ::tk::EntrySetCursor - # Move the insertion cursor to a given position in an entry. Also # clears the selection, if there is one in the entry, and makes sure # that the insertion cursor is visible. @@ -523,13 +520,13 @@ proc tkEntrySeeInsert w { # w - The entry window. # pos - The desired new position for the cursor in the window. -proc tkEntrySetCursor {w pos} { +proc ::tk::EntrySetCursor {w pos} { $w icursor $pos $w selection clear - tkEntrySeeInsert $w + EntrySeeInsert $w } -# tkEntryTranspose - +# ::tk::EntryTranspose - # This procedure implements the "transpose" function for entry widgets. # It tranposes the characters on either side of the insertion cursor, # unless the cursor is at the end of the line. In this case it @@ -539,7 +536,7 @@ proc tkEntrySetCursor {w pos} { # Arguments: # w - The entry window. -proc tkEntryTranspose w { +proc ::tk::EntryTranspose w { set i [$w index insert] if {$i < [$w index end]} { incr i @@ -548,13 +545,14 @@ proc tkEntryTranspose w { if {$first < 0} { return } - set new [string index [$w get] [expr {$i-1}]][string index [$w get] $first] + set data [$w get] + set new [string index $data [expr {$i-1}]][string index $data $first] $w delete $first $i $w insert insert $new - tkEntrySeeInsert $w + EntrySeeInsert $w } -# tkEntryNextWord -- +# ::tk::EntryNextWord -- # Returns the index of the next word position after a given position in the # entry. The next word is platform dependent and may be either the next # end-of-word position or the next start-of-word position after the next @@ -565,7 +563,7 @@ proc tkEntryTranspose w { # start - Position at which to start search. if {[string equal $tcl_platform(platform) "windows"]} { - proc tkEntryNextWord {w start} { + proc ::tk::EntryNextWord {w start} { set pos [tcl_endOfWord [$w get] [$w index $start]] if {$pos >= 0} { set pos [tcl_startOfNextWord [$w get] $pos] @@ -576,7 +574,7 @@ if {[string equal $tcl_platform(platform) "windows"]} { return $pos } } else { - proc tkEntryNextWord {w start} { + proc ::tk::EntryNextWord {w start} { set pos [tcl_endOfWord [$w get] [$w index $start]] if {$pos < 0} { return end @@ -585,7 +583,7 @@ if {[string equal $tcl_platform(platform) "windows"]} { } } -# tkEntryPreviousWord -- +# ::tk::EntryPreviousWord -- # # Returns the index of the previous word position before a given # position in the entry. @@ -594,26 +592,61 @@ if {[string equal $tcl_platform(platform) "windows"]} { # w - The entry window in which the cursor is to move. # start - Position at which to start search. -proc tkEntryPreviousWord {w start} { +proc ::tk::EntryPreviousWord {w start} { set pos [tcl_startOfPreviousWord [$w get] [$w index $start]] if {$pos < 0} { return 0 } return $pos } -# tkEntryGetSelection -- + +# ::tk::EntryScanMark -- +# +# Marks the start of a possible scan drag operation +# +# Arguments: +# w - The entry window from which the text to get +# x - x location on screen + +proc ::tk::EntryScanMark {w x} { + $w scan mark $x + set ::tk::Priv(x) $x + set ::tk::Priv(y) 0 ; # not used + set ::tk::Priv(mouseMoved) 0 +} + +# ::tk::EntryScanDrag -- +# +# Marks the start of a possible scan drag operation +# +# Arguments: +# w - The entry window from which the text to get +# x - x location on screen + +proc ::tk::EntryScanDrag {w x} { + # Make sure these exist, as some weird situations can trigger the + # motion binding without the initial press. [Bug #220269] + if {![info exists ::tk::Priv(x)]} { set ::tk::Priv(x) $x } + # allow for a delta + if {abs($x-$::tk::Priv(x)) > 2} { + set ::tk::Priv(mouseMoved) 1 + } + $w scan dragto $x +} + +# ::tk::EntryGetSelection -- # # Returns the selected text of the entry with respect to the -show option. # # Arguments: # w - The entry window from which the text to get -proc tkEntryGetSelection {w} { +proc ::tk::EntryGetSelection {w} { set entryString [string range [$w get] [$w index sel.first] \ [expr {[$w index sel.last] - 1}]] if {[string compare [$w cget -show] ""]} { - regsub -all . $entryString [string index [$w cget -show] 0] entryString + return [string repeat [string index [$w cget -show] 0] \ + [string length $entryString]] } return $entryString } - diff --git a/tk/library/focus.tcl b/tk/library/focus.tcl index 8661245cdca..ea0f64de269 100644 --- a/tk/library/focus.tcl +++ b/tk/library/focus.tcl @@ -11,7 +11,7 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# tk_focusNext -- +# ::tk_focusNext -- # This procedure returns the name of the next window after "w" in # "focus order" (the window that should receive the focus next if # Tab is typed in w). "Next" is defined by a pre-order search @@ -22,7 +22,7 @@ # Arguments: # w - Name of a window. -proc tk_focusNext w { +proc ::tk_focusNext w { set cur $w while {1} { @@ -57,13 +57,13 @@ proc tk_focusNext w { set children [winfo children $parent] set i [lsearch -exact $children $cur] } - if {[string equal $w $cur] || [tkFocusOK $cur]} { + if {[string equal $w $cur] || [tk::FocusOK $cur]} { return $cur } } } -# tk_focusPrev -- +# ::tk_focusPrev -- # This procedure returns the name of the previous window before "w" in # "focus order" (the window that should receive the focus next if # Shift-Tab is typed in w). "Next" is defined by a pre-order search @@ -74,7 +74,7 @@ proc tk_focusNext w { # Arguments: # w - Name of a window. -proc tk_focusPrev w { +proc ::tk_focusPrev w { set cur $w while {1} { @@ -108,13 +108,13 @@ proc tk_focusPrev w { set i [llength $children] } set cur $parent - if {[string equal $w $cur] || [tkFocusOK $cur]} { + if {[string equal $w $cur] || [tk::FocusOK $cur]} { return $cur } } } -# tkFocusOK -- +# ::tk::FocusOK -- # # This procedure is invoked to decide whether or not to focus on # a given window. It returns 1 if it's OK to focus on the window, @@ -128,7 +128,7 @@ proc tk_focusPrev w { # Arguments: # w - Name of a window. -proc tkFocusOK w { +proc ::tk::FocusOK w { set code [catch {$w cget -takefocus} value] if {($code == 0) && ($value != "")} { if {$value == 0} { @@ -152,7 +152,7 @@ proc tkFocusOK w { regexp Key|Focus "[bind $w] [bind [winfo class $w]]" } -# tk_focusFollowsMouse -- +# ::tk_focusFollowsMouse -- # # If this procedure is invoked, Tk will enter "focus-follows-mouse" # mode, where the focus is always on whatever window contains the @@ -162,13 +162,13 @@ proc tkFocusOK w { # Arguments: # None. -proc tk_focusFollowsMouse {} { +proc ::tk_focusFollowsMouse {} { set old [bind all ] set script { if {[string equal "%d" "NotifyAncestor"] \ || [string equal "%d" "NotifyNonlinear"] \ || [string equal "%d" "NotifyInferior"]} { - if {[tkFocusOK %W]} { + if {[tk::FocusOK %W]} { focus %W } } @@ -179,5 +179,3 @@ proc tk_focusFollowsMouse {} { bind all $script } } - - diff --git a/tk/library/images/README b/tk/library/images/README index 1a8d7781726..65101cd3797 100644 --- a/tk/library/images/README +++ b/tk/library/images/README @@ -10,4 +10,3 @@ used to promote Tcl in your product documentation, web site or other places you so desire. - diff --git a/tk/library/listbox.tcl b/tk/library/listbox.tcl index f65b31e0a6f..c48e9823743 100644 --- a/tk/library/listbox.tcl +++ b/tk/library/listbox.tcl @@ -13,7 +13,7 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. #-------------------------------------------------------------------------- -# tkPriv elements used in this file: +# tk::Priv elements used in this file: # # afterId - Token returned by "after" for autoscanning. # listboxPrev - The last element to be selected or deselected @@ -35,7 +35,7 @@ bind Listbox <1> { if {[winfo exists %W]} { - tkListboxBeginSelect %W [%W index @%x,%y] + tk::ListboxBeginSelect %W [%W index @%x,%y] } } @@ -48,40 +48,40 @@ bind Listbox { } bind Listbox { - set tkPriv(x) %x - set tkPriv(y) %y - tkListboxMotion %W [%W index @%x,%y] + set tk::Priv(x) %x + set tk::Priv(y) %y + tk::ListboxMotion %W [%W index @%x,%y] } bind Listbox { - tkCancelRepeat + tk::CancelRepeat %W activate @%x,%y } bind Listbox { - tkListboxBeginExtend %W [%W index @%x,%y] + tk::ListboxBeginExtend %W [%W index @%x,%y] } bind Listbox { - tkListboxBeginToggle %W [%W index @%x,%y] + tk::ListboxBeginToggle %W [%W index @%x,%y] } bind Listbox { - set tkPriv(x) %x - set tkPriv(y) %y - tkListboxAutoScan %W + set tk::Priv(x) %x + set tk::Priv(y) %y + tk::ListboxAutoScan %W } bind Listbox { - tkCancelRepeat + tk::CancelRepeat } bind Listbox { - tkListboxUpDown %W -1 + tk::ListboxUpDown %W -1 } bind Listbox { - tkListboxExtendUpDown %W -1 + tk::ListboxExtendUpDown %W -1 } bind Listbox { - tkListboxUpDown %W 1 + tk::ListboxUpDown %W 1 } bind Listbox { - tkListboxExtendUpDown %W 1 + tk::ListboxExtendUpDown %W 1 } bind Listbox { %W xview scroll -1 units @@ -123,7 +123,7 @@ bind Listbox { event generate %W <> } bind Listbox { - tkListboxDataExtend %W 0 + tk::ListboxDataExtend %W 0 } bind Listbox { %W activate end @@ -133,7 +133,7 @@ bind Listbox { event generate %W <> } bind Listbox { - tkListboxDataExtend %W [%W index end] + tk::ListboxDataExtend %W [%W index end] } bind Listbox <> { if {[string equal [selection own -displayof %W] "%W"]} { @@ -142,22 +142,22 @@ bind Listbox <> { } } bind Listbox { - tkListboxBeginSelect %W [%W index active] + tk::ListboxBeginSelect %W [%W index active] } bind Listbox { + %W selection from insert +} +bind Spinbox { + %W selection adjust insert +} +bind Spinbox { + %W selection adjust insert +} +bind Spinbox { + %W selection range 0 end +} +bind Spinbox { + %W selection clear +} +bind Spinbox { + ::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 +# class binding will also fire and insert the character, +# which is wrong. Ditto for Escape, Return, and Tab. + +bind Spinbox {# nothing} +bind Spinbox {# nothing} +bind Spinbox {# nothing} +bind Spinbox {# nothing} +bind Spinbox {# nothing} +bind Spinbox {# nothing} +bind Spinbox {# nothing} +if {[string equal [tk windowingsystem] "classic"] + || [string equal [tk windowingsystem] "aqua"]} { + bind Spinbox {# nothing} +} + +# On Windows, paste is done using Shift-Insert. Shift-Insert already +# generates the <> event, so we don't need to do anything here. +if {[string compare $tcl_platform(platform) "windows"]} { + bind Spinbox { + catch {::tk::EntryInsert %W [::tk::GetSelection %W PRIMARY]} + } +} + +# Additional emacs-like bindings: + +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntrySetCursor %W 0 + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntrySetCursor %W [expr {[%W index insert] - 1}] + } +} +bind Spinbox { + if {!$tk_strictMotif} { + %W delete insert + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntrySetCursor %W end + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntrySetCursor %W [expr {[%W index insert] + 1}] + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntryBackspace %W + } +} +bind Spinbox { + if {!$tk_strictMotif} { + %W delete insert end + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntryTranspose %W + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntrySetCursor %W [::tk::EntryPreviousWord %W insert] + } +} +bind Spinbox { + if {!$tk_strictMotif} { + %W delete insert [::tk::EntryNextWord %W insert] + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntrySetCursor %W [::tk::EntryNextWord %W insert] + } +} +bind Spinbox { + if {!$tk_strictMotif} { + %W delete [::tk::EntryPreviousWord %W insert] insert + } +} +bind Spinbox { + if {!$tk_strictMotif} { + %W delete [::tk::EntryPreviousWord %W insert] insert + } +} + +# A few additional bindings of my own. + +bind Spinbox <2> { + if {!$tk_strictMotif} { + ::tk::EntryScanMark %W %x + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntryScanDrag %W %x + } +} + +# ::tk::spinbox::Invoke -- +# Invoke an element of the spinbox +# +# Arguments: +# w - The spinbox window. +# elem - Element to invoke + +proc ::tk::spinbox::Invoke {w elem} { + variable ::tk::Priv + + if {![info exists Priv(outsideElement)]} { + $w invoke $elem + incr Priv(repeated) + } + set delay [$w cget -repeatinterval] + if {$delay > 0} { + set Priv(afterId) [after $delay \ + [list ::tk::spinbox::Invoke $w $elem]] + } +} + +# ::tk::spinbox::ClosestGap -- +# Given x and y coordinates, this procedure finds the closest boundary +# between characters to the given coordinates and returns the index +# of the character just after the boundary. +# +# Arguments: +# w - The spinbox window. +# x - X-coordinate within the window. + +proc ::tk::spinbox::ClosestGap {w x} { + set pos [$w index @$x] + set bbox [$w bbox $pos] + if {($x - [lindex $bbox 0]) < ([lindex $bbox 2]/2)} { + return $pos + } + incr pos +} + +# ::tk::spinbox::ButtonDown -- +# This procedure is invoked to handle button-1 presses in spinbox +# widgets. It moves the insertion cursor, sets the selection anchor, +# and claims the input focus. +# +# Arguments: +# w - The spinbox window in which the button was pressed. +# x - The x-coordinate of the button press. + +proc ::tk::spinbox::ButtonDown {w x y} { + variable ::tk::Priv + + # Get the element that was clicked in. If we are not directly over + # the spinbox, default to entry. This is necessary for spinbox grabs. + # + set Priv(element) [$w identify $x $y] + if {$Priv(element) eq ""} { + set Priv(element) "entry" + } + + switch -exact $Priv(element) { + "buttonup" - "buttondown" { + if {"disabled" ne [$w cget -state]} { + $w selection element $Priv(element) + set Priv(repeated) 0 + set Priv(relief) [$w cget -$Priv(element)relief] + catch {after cancel $Priv(afterId)} + set delay [$w cget -repeatdelay] + if {$delay > 0} { + set Priv(afterId) [after $delay \ + [list ::tk::spinbox::Invoke $w $Priv(element)]] + } + if {[info exists Priv(outsideElement)]} { + unset Priv(outsideElement) + } + } + } + "entry" { + set Priv(selectMode) char + set Priv(mouseMoved) 0 + set Priv(pressX) $x + $w icursor [::tk::spinbox::ClosestGap $w $x] + $w selection from insert + if {"disabled" ne [$w cget -state]} {focus $w} + $w selection clear + } + default { + return -code error "unknown spinbox element \"$Priv(element)\"" + } + } +} + +# ::tk::spinbox::ButtonUp -- +# This procedure is invoked to handle button-1 releases in spinbox +# widgets. +# +# Arguments: +# w - The spinbox window in which the button was pressed. +# x - The x-coordinate of the button press. + +proc ::tk::spinbox::ButtonUp {w x y} { + variable ::tk::Priv + + ::tk::CancelRepeat + + # Priv(relief) may not exist if the ButtonUp is not paired with + # a preceding ButtonDown + if {[info exists Priv(element)] && [info exists Priv(relief)] && \ + [string match "button*" $Priv(element)]} { + if {[info exists Priv(repeated)] && !$Priv(repeated)} { + $w invoke $Priv(element) + } + $w configure -$Priv(element)relief $Priv(relief) + $w selection element none + } +} + +# ::tk::spinbox::MouseSelect -- +# This procedure is invoked when dragging out a selection with +# the mouse. Depending on the selection mode (character, word, +# line) it selects in different-sized units. This procedure +# ignores mouse motions initially until the mouse has moved from +# one character to another or until there have been multiple clicks. +# +# Arguments: +# w - The spinbox window in which the button was pressed. +# x - The x-coordinate of the mouse. +# cursor - optional place to set cursor. + +proc ::tk::spinbox::MouseSelect {w x {cursor {}}} { + variable ::tk::Priv + + if {$Priv(element) ne "entry"} { + # The ButtonUp command triggered by ButtonRelease-1 handles + # invoking one of the spinbuttons. + return + } + set cur [::tk::spinbox::ClosestGap $w $x] + set anchor [$w index anchor] + if {($cur ne $anchor) || (abs($Priv(pressX) - $x) >= 3)} { + set Priv(mouseMoved) 1 + } + switch $Priv(selectMode) { + char { + if {$Priv(mouseMoved)} { + if {$cur < $anchor} { + $w selection range $cur $anchor + } elseif {$cur > $anchor} { + $w selection range $anchor $cur + } else { + $w selection clear + } + } + } + word { + if {$cur < [$w index anchor]} { + set before [tcl_wordBreakBefore [$w get] $cur] + set after [tcl_wordBreakAfter [$w get] [expr {$anchor-1}]] + } else { + set before [tcl_wordBreakBefore [$w get] $anchor] + set after [tcl_wordBreakAfter [$w get] [expr {$cur - 1}]] + } + if {$before < 0} { + set before 0 + } + if {$after < 0} { + set after end + } + $w selection range $before $after + } + line { + $w selection range 0 end + } + } + if {$cursor ne {} && $cursor ne "ignore"} { + catch {$w icursor $cursor} + } + update idletasks +} + +# ::tk::spinbox::Paste -- +# This procedure sets the insertion cursor to the current mouse position, +# pastes the selection there, and sets the focus to the window. +# +# Arguments: +# w - The spinbox window. +# x - X position of the mouse. + +proc ::tk::spinbox::Paste {w x} { + $w icursor [::tk::spinbox::ClosestGap $w $x] + catch {$w insert insert [::tk::GetSelection $w PRIMARY]} + if {[string equal "disabled" [$w cget -state]]} {focus $w} +} + +# ::tk::spinbox::Motion -- +# This procedure is invoked when the mouse moves in a spinbox window +# with button 1 down. +# +# Arguments: +# w - The spinbox window. + +proc ::tk::spinbox::Motion {w x y} { + variable ::tk::Priv + + if {![info exists Priv(element)]} { + set Priv(element) [$w identify $x $y] + } + + set Priv(x) $x + if {"entry" eq $Priv(element)} { + ::tk::spinbox::MouseSelect $w $x ignore + } elseif {[$w identify $x $y] ne $Priv(element)} { + if {![info exists Priv(outsideElement)]} { + # We've wandered out of the spin button + # setting outside element will cause ::tk::spinbox::Invoke to + # loop without doing anything + set Priv(outsideElement) "" + $w selection element none + } + } elseif {[info exists Priv(outsideElement)]} { + unset Priv(outsideElement) + $w selection element $Priv(element) + } +} + +# ::tk::spinbox::AutoScan -- +# This procedure is invoked when the mouse leaves an spinbox window +# with button 1 down. It scrolls the window left or right, +# depending on where the mouse is, and reschedules itself as an +# "after" command so that the window continues to scroll until the +# mouse moves back into the window or the mouse button is released. +# +# Arguments: +# w - The spinbox window. + +proc ::tk::spinbox::AutoScan {w} { + variable ::tk::Priv + + set x $Priv(x) + if {$x >= [winfo width $w]} { + $w xview scroll 2 units + ::tk::spinbox::MouseSelect $w $x ignore + } elseif {$x < 0} { + $w xview scroll -2 units + ::tk::spinbox::MouseSelect $w $x ignore + } + set Priv(afterId) [after 50 [list ::tk::spinbox::AutoScan $w]] +} + +# ::tk::spinbox::GetSelection -- +# +# Returns the selected text of the spinbox. Differs from entry in that +# a spinbox has no -show option to obscure contents. +# +# Arguments: +# w - The spinbox window from which the text to get + +proc ::tk::spinbox::GetSelection {w} { + return [string range [$w get] [$w index sel.first] \ + [expr {[$w index sel.last] - 1}]] +} diff --git a/tk/library/tclIndex b/tk/library/tclIndex index 659e0125e26..6b3547d579f 100644 --- a/tk/library/tclIndex +++ b/tk/library/tclIndex @@ -6,213 +6,239 @@ # element name is the name of a command and the value is # a script that loads the command. -set auto_index(tkButtonEnter) [list source [file join $dir button.tcl]] -set auto_index(tkButtonLeave) [list source [file join $dir button.tcl]] -set auto_index(tkCheckRadioEnter) [list source [file join $dir button.tcl]] -set auto_index(tkButtonDown) [list source [file join $dir button.tcl]] -set auto_index(tkCheckRadioDown) [list source [file join $dir button.tcl]] -set auto_index(tkButtonUp) [list source [file join $dir button.tcl]] -set auto_index(tkButtonEnter) [list source [file join $dir button.tcl]] -set auto_index(tkButtonLeave) [list source [file join $dir button.tcl]] -set auto_index(tkButtonDown) [list source [file join $dir button.tcl]] -set auto_index(tkButtonUp) [list source [file join $dir button.tcl]] -set auto_index(tkButtonEnter) [list source [file join $dir button.tcl]] -set auto_index(tkButtonLeave) [list source [file join $dir button.tcl]] -set auto_index(tkButtonDown) [list source [file join $dir button.tcl]] -set auto_index(tkButtonUp) [list source [file join $dir button.tcl]] -set auto_index(tkButtonInvoke) [list source [file join $dir button.tcl]] -set auto_index(tkCheckRadioInvoke) [list source [file join $dir button.tcl]] +set auto_index(::tk::dialog::error::Return) [list source [file join $dir bgerror.tcl]] +set auto_index(::tk::dialog::error::Details) [list source [file join $dir bgerror.tcl]] +set auto_index(::tk::dialog::error::SaveToLog) [list source [file join $dir bgerror.tcl]] +set auto_index(::tk::dialog::error::Destroy) [list source [file join $dir bgerror.tcl]] +set auto_index(::tk::dialog::error::bgerror) [list source [file join $dir bgerror.tcl]] +set auto_index(bgerror) [list source [file join $dir bgerror.tcl]] +set auto_index(::tk::ButtonInvoke) [list source [file join $dir button.tcl]] +set auto_index(::tk::ButtonAutoInvoke) [list source [file join $dir button.tcl]] +set auto_index(::tk::CheckRadioInvoke) [list source [file join $dir button.tcl]] +set auto_index(::tk::dialog::file::chooseDir::) [list source [file join $dir choosedir.tcl]] +set auto_index(::tk::dialog::file::chooseDir::Config) [list source [file join $dir choosedir.tcl]] +set auto_index(::tk::dialog::file::chooseDir::OkCmd) [list source [file join $dir choosedir.tcl]] +set auto_index(::tk::dialog::file::chooseDir::DblClick) [list source [file join $dir choosedir.tcl]] +set auto_index(::tk::dialog::file::chooseDir::ListBrowse) [list source [file join $dir choosedir.tcl]] +set auto_index(::tk::dialog::file::chooseDir::Done) [list source [file join $dir choosedir.tcl]] +set auto_index(::tk::dialog::color::) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::InitValues) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::Config) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::BuildDialog) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::SetRGBValue) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::XToRgb) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::RgbToX) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::DrawColorScale) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::CreateSelector) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::RedrawFinalColor) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::RedrawColorBars) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::StartMove) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::MoveSelector) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::ReleaseMouse) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::ResizeColorBars) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::HandleSelEntry) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::HandleRGBEntry) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::EnterColorBar) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::LeaveColorBar) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::OkCmd) [list source [file join $dir clrpick.tcl]] +set auto_index(::tk::dialog::color::CancelCmd) [list source [file join $dir clrpick.tcl]] +set auto_index(tclParseConfigSpec) [list source [file join $dir comdlg.tcl]] +set auto_index(tclListValidFlags) [list source [file join $dir comdlg.tcl]] +set auto_index(::tk::FocusGroup_Create) [list source [file join $dir comdlg.tcl]] +set auto_index(::tk::FocusGroup_BindIn) [list source [file join $dir comdlg.tcl]] +set auto_index(::tk::FocusGroup_BindOut) [list source [file join $dir comdlg.tcl]] +set auto_index(::tk::FocusGroup_Destroy) [list source [file join $dir comdlg.tcl]] +set auto_index(::tk::FocusGroup_In) [list source [file join $dir comdlg.tcl]] +set auto_index(::tk::FocusGroup_Out) [list source [file join $dir comdlg.tcl]] +set auto_index(::tk::FDGetFileTypes) [list source [file join $dir comdlg.tcl]] +set auto_index(::tk::ConsoleInit) [list source [file join $dir console.tcl]] +set auto_index(::tk::ConsoleSource) [list source [file join $dir console.tcl]] +set auto_index(::tk::ConsoleInvoke) [list source [file join $dir console.tcl]] +set auto_index(::tk::ConsoleHistory) [list source [file join $dir console.tcl]] +set auto_index(::tk::ConsolePrompt) [list source [file join $dir console.tcl]] +set auto_index(::tk::ConsoleBind) [list source [file join $dir console.tcl]] +set auto_index(::tk::ConsoleInsert) [list source [file join $dir console.tcl]] +set auto_index(::tk::ConsoleOutput) [list source [file join $dir console.tcl]] +set auto_index(::tk::ConsoleExit) [list source [file join $dir console.tcl]] +set auto_index(::tk::ConsoleAbout) [list source [file join $dir console.tcl]] set auto_index(tk_dialog) [list source [file join $dir dialog.tcl]] -set auto_index(tkEntryClosestGap) [list source [file join $dir entry.tcl]] -set auto_index(tkEntryButton1) [list source [file join $dir entry.tcl]] -set auto_index(tkEntryMouseSelect) [list source [file join $dir entry.tcl]] -set auto_index(tkEntryPaste) [list source [file join $dir entry.tcl]] -set auto_index(tkEntryAutoScan) [list source [file join $dir entry.tcl]] -set auto_index(tkEntryKeySelect) [list source [file join $dir entry.tcl]] -set auto_index(tkEntryInsert) [list source [file join $dir entry.tcl]] -set auto_index(tkEntryBackspace) [list source [file join $dir entry.tcl]] -set auto_index(tkEntrySeeInsert) [list source [file join $dir entry.tcl]] -set auto_index(tkEntrySetCursor) [list source [file join $dir entry.tcl]] -set auto_index(tkEntryTranspose) [list source [file join $dir entry.tcl]] -set auto_index(tkEntryPreviousWord) [list source [file join $dir entry.tcl]] -set auto_index(tkListboxBeginSelect) [list source [file join $dir listbox.tcl]] -set auto_index(tkListboxMotion) [list source [file join $dir listbox.tcl]] -set auto_index(tkListboxBeginExtend) [list source [file join $dir listbox.tcl]] -set auto_index(tkListboxBeginToggle) [list source [file join $dir listbox.tcl]] -set auto_index(tkListboxAutoScan) [list source [file join $dir listbox.tcl]] -set auto_index(tkListboxUpDown) [list source [file join $dir listbox.tcl]] -set auto_index(tkListboxExtendUpDown) [list source [file join $dir listbox.tcl]] -set auto_index(tkListboxDataExtend) [list source [file join $dir listbox.tcl]] -set auto_index(tkListboxCancel) [list source [file join $dir listbox.tcl]] -set auto_index(tkListboxSelectAll) [list source [file join $dir listbox.tcl]] -set auto_index(tkMbEnter) [list source [file join $dir menu.tcl]] -set auto_index(tkMbLeave) [list source [file join $dir menu.tcl]] -set auto_index(tkMbPost) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuUnpost) [list source [file join $dir menu.tcl]] -set auto_index(tkMbMotion) [list source [file join $dir menu.tcl]] -set auto_index(tkMbButtonUp) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuMotion) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuButtonDown) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuLeave) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuInvoke) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuEscape) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuUpArrow) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuDownArrow) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuLeftArrow) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuRightArrow) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuNextMenu) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuNextEntry) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuFind) [list source [file join $dir menu.tcl]] -set auto_index(tkTraverseToMenu) [list source [file join $dir menu.tcl]] -set auto_index(tkFirstMenu) [list source [file join $dir menu.tcl]] -set auto_index(tkTraverseWithinMenu) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuFirstEntry) [list source [file join $dir menu.tcl]] -set auto_index(tkMenuFindName) [list source [file join $dir menu.tcl]] -set auto_index(tkPostOverPoint) [list source [file join $dir menu.tcl]] -set auto_index(tkSaveGrabInfo) [list source [file join $dir menu.tcl]] -set auto_index(tkRestoreOldGrab) [list source [file join $dir menu.tcl]] +set auto_index(::tk::EntryClosestGap) [list source [file join $dir entry.tcl]] +set auto_index(::tk::EntryButton1) [list source [file join $dir entry.tcl]] +set auto_index(::tk::EntryMouseSelect) [list source [file join $dir entry.tcl]] +set auto_index(::tk::EntryPaste) [list source [file join $dir entry.tcl]] +set auto_index(::tk::EntryAutoScan) [list source [file join $dir entry.tcl]] +set auto_index(::tk::EntryKeySelect) [list source [file join $dir entry.tcl]] +set auto_index(::tk::EntryInsert) [list source [file join $dir entry.tcl]] +set auto_index(::tk::EntryBackspace) [list source [file join $dir entry.tcl]] +set auto_index(::tk::EntrySeeInsert) [list source [file join $dir entry.tcl]] +set auto_index(::tk::EntrySetCursor) [list source [file join $dir entry.tcl]] +set auto_index(::tk::EntryTranspose) [list source [file join $dir entry.tcl]] +set auto_index(::tk::EntryPreviousWord) [list source [file join $dir entry.tcl]] +set auto_index(::tk::EntryGetSelection) [list source [file join $dir entry.tcl]] +set auto_index(tk_focusNext) [list source [file join $dir focus.tcl]] +set auto_index(tk_focusPrev) [list source [file join $dir focus.tcl]] +set auto_index(::tk::FocusOK) [list source [file join $dir focus.tcl]] +set auto_index(tk_focusFollowsMouse) [list source [file join $dir focus.tcl]] +set auto_index(::tk::ListboxBeginSelect) [list source [file join $dir listbox.tcl]] +set auto_index(::tk::ListboxMotion) [list source [file join $dir listbox.tcl]] +set auto_index(::tk::ListboxBeginExtend) [list source [file join $dir listbox.tcl]] +set auto_index(::tk::ListboxBeginToggle) [list source [file join $dir listbox.tcl]] +set auto_index(::tk::ListboxAutoScan) [list source [file join $dir listbox.tcl]] +set auto_index(::tk::ListboxUpDown) [list source [file join $dir listbox.tcl]] +set auto_index(::tk::ListboxExtendUpDown) [list source [file join $dir listbox.tcl]] +set auto_index(::tk::ListboxDataExtend) [list source [file join $dir listbox.tcl]] +set auto_index(::tk::ListboxCancel) [list source [file join $dir listbox.tcl]] +set auto_index(::tk::ListboxSelectAll) [list source [file join $dir listbox.tcl]] +set auto_index(::tk::MbEnter) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MbLeave) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MbPost) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuUnpost) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MbMotion) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MbButtonUp) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuMotion) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuButtonDown) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuLeave) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuInvoke) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuEscape) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuUpArrow) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuDownArrow) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuLeftArrow) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuRightArrow) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuNextMenu) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuNextEntry) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuFind) [list source [file join $dir menu.tcl]] +set auto_index(::tk::TraverseToMenu) [list source [file join $dir menu.tcl]] +set auto_index(::tk::FirstMenu) [list source [file join $dir menu.tcl]] +set auto_index(::tk::TraverseWithinMenu) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuFirstEntry) [list source [file join $dir menu.tcl]] +set auto_index(::tk::MenuFindName) [list source [file join $dir menu.tcl]] +set auto_index(::tk::PostOverPoint) [list source [file join $dir menu.tcl]] +set auto_index(::tk::SaveGrabInfo) [list source [file join $dir menu.tcl]] +set auto_index(::tk::RestoreOldGrab) [list source [file join $dir menu.tcl]] set auto_index(tk_menuSetFocus) [list source [file join $dir menu.tcl]] -set auto_index(tkGenerateMenuSelect) [list source [file join $dir menu.tcl]] +set auto_index(::tk::GenerateMenuSelect) [list source [file join $dir menu.tcl]] set auto_index(tk_popup) [list source [file join $dir menu.tcl]] -set auto_index(tkScrollButtonDown) [list source [file join $dir scrlbar.tcl]] -set auto_index(tkScrollButtonUp) [list source [file join $dir scrlbar.tcl]] -set auto_index(tkScrollSelect) [list source [file join $dir scrlbar.tcl]] -set auto_index(tkScrollStartDrag) [list source [file join $dir scrlbar.tcl]] -set auto_index(tkScrollDrag) [list source [file join $dir scrlbar.tcl]] -set auto_index(tkScrollEndDrag) [list source [file join $dir scrlbar.tcl]] -set auto_index(tkScrollByUnits) [list source [file join $dir scrlbar.tcl]] -set auto_index(tkScrollByPages) [list source [file join $dir scrlbar.tcl]] -set auto_index(tkScrollToPos) [list source [file join $dir scrlbar.tcl]] -set auto_index(tkScrollTopBottom) [list source [file join $dir scrlbar.tcl]] -set auto_index(tkScrollButton2Down) [list source [file join $dir scrlbar.tcl]] -set auto_index(tkTextClosestGap) [list source [file join $dir text.tcl]] -set auto_index(tkTextButton1) [list source [file join $dir text.tcl]] -set auto_index(tkTextSelectTo) [list source [file join $dir text.tcl]] -set auto_index(tkTextKeyExtend) [list source [file join $dir text.tcl]] -set auto_index(tkTextPaste) [list source [file join $dir text.tcl]] -set auto_index(tkTextAutoScan) [list source [file join $dir text.tcl]] -set auto_index(tkTextSetCursor) [list source [file join $dir text.tcl]] -set auto_index(tkTextKeySelect) [list source [file join $dir text.tcl]] -set auto_index(tkTextResetAnchor) [list source [file join $dir text.tcl]] -set auto_index(tkTextInsert) [list source [file join $dir text.tcl]] -set auto_index(tkTextUpDownLine) [list source [file join $dir text.tcl]] -set auto_index(tkTextPrevPara) [list source [file join $dir text.tcl]] -set auto_index(tkTextNextPara) [list source [file join $dir text.tcl]] -set auto_index(tkTextScrollPages) [list source [file join $dir text.tcl]] -set auto_index(tkTextTranspose) [list source [file join $dir text.tcl]] -set auto_index(tk_textCopy) [list source [file join $dir text.tcl]] -set auto_index(tk_textCut) [list source [file join $dir text.tcl]] -set auto_index(tk_textPaste) [list source [file join $dir text.tcl]] -set auto_index(tkTextNextPos) [list source [file join $dir text.tcl]] -set auto_index(tkTextPrevPos) [list source [file join $dir text.tcl]] -set auto_index(tkScreenChanged) [list source [file join $dir tk.tcl]] -set auto_index(tkEventMotifBindings) [list source [file join $dir tk.tcl]] -set auto_index(tkCancelRepeat) [list source [file join $dir tk.tcl]] -set auto_index(tkTabToWindow) [list source [file join $dir tk.tcl]] -set auto_index(bgerror) [list source [file join $dir bgerror.tcl]] -set auto_index(tkScaleActivate) [list source [file join $dir scale.tcl]] -set auto_index(tkScaleButtonDown) [list source [file join $dir scale.tcl]] -set auto_index(tkScaleDrag) [list source [file join $dir scale.tcl]] -set auto_index(tkScaleEndDrag) [list source [file join $dir scale.tcl]] -set auto_index(tkScaleIncrement) [list source [file join $dir scale.tcl]] -set auto_index(tkScaleControlPress) [list source [file join $dir scale.tcl]] -set auto_index(tkScaleButton2Down) [list source [file join $dir scale.tcl]] -set auto_index(tk_optionMenu) [list source [file join $dir optMenu.tcl]] -set auto_index(tkTearOffMenu) [list source [file join $dir tearoff.tcl]] -set auto_index(tkMenuDup) [list source [file join $dir tearoff.tcl]] +set auto_index(::tk::ensure_psenc_is_loaded) [list source [file join $dir mkpsenc.tcl]] +set auto_index(::tk::MessageBox) [list source [file join $dir msgbox.tcl]] set auto_index(tk_menuBar) [list source [file join $dir obsolete.tcl]] set auto_index(tk_bindForTraversal) [list source [file join $dir obsolete.tcl]] -set auto_index(tk_focusNext) [list source [file join $dir focus.tcl]] -set auto_index(tk_focusPrev) [list source [file join $dir focus.tcl]] -set auto_index(tkFocusOK) [list source [file join $dir focus.tcl]] -set auto_index(tk_focusFollowsMouse) [list source [file join $dir focus.tcl]] -set auto_index(tkConsoleInit) [list source [file join $dir console.tcl]] -set auto_index(tkConsoleSource) [list source [file join $dir console.tcl]] -set auto_index(tkConsoleInvoke) [list source [file join $dir console.tcl]] -set auto_index(tkConsoleHistory) [list source [file join $dir console.tcl]] -set auto_index(tkConsolePrompt) [list source [file join $dir console.tcl]] -set auto_index(tkConsoleBind) [list source [file join $dir console.tcl]] -set auto_index(tkConsoleInsert) [list source [file join $dir console.tcl]] -set auto_index(tkConsoleOutput) [list source [file join $dir console.tcl]] -set auto_index(tkConsoleExit) [list source [file join $dir console.tcl]] -set auto_index(tkConsoleAbout) [list source [file join $dir console.tcl]] +set auto_index(tk_optionMenu) [list source [file join $dir optMenu.tcl]] set auto_index(tk_setPalette) [list source [file join $dir palette.tcl]] -set auto_index(tkRecolorTree) [list source [file join $dir palette.tcl]] -set auto_index(tkDarken) [list source [file join $dir palette.tcl]] +set auto_index(::tk::RecolorTree) [list source [file join $dir palette.tcl]] +set auto_index(::tk::Darken) [list source [file join $dir palette.tcl]] set auto_index(tk_bisque) [list source [file join $dir palette.tcl]] -set auto_index(tkColorDialog) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_InitValues) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_Config) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_BuildDialog) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_SetRGBValue) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_XToRgb) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_RgbToX) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_DrawColorScale) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_CreateSelector) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_RedrawFinalColor) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_RedrawColorBars) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_StartMove) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_MoveSelector) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_ReleaseMouse) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_ResizeColorBars) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_HandleSelEntry) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_HandleRGBEntry) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_EnterColorBar) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_LeaveColorBar) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_OkCmd) [list source [file join $dir clrpick.tcl]] -set auto_index(tkColorDialog_CancelCmd) [list source [file join $dir clrpick.tcl]] -set auto_index(tclParseConfigSpec) [list source [file join $dir comdlg.tcl]] -set auto_index(tclListValidFlags) [list source [file join $dir comdlg.tcl]] -set auto_index(tclSortNoCase) [list source [file join $dir comdlg.tcl]] -set auto_index(tclVerifyInteger) [list source [file join $dir comdlg.tcl]] -set auto_index(tkFocusGroup_Create) [list source [file join $dir comdlg.tcl]] -set auto_index(tkFocusGroup_BindIn) [list source [file join $dir comdlg.tcl]] -set auto_index(tkFocusGroup_BindOut) [list source [file join $dir comdlg.tcl]] -set auto_index(tkFocusGroup_Destroy) [list source [file join $dir comdlg.tcl]] -set auto_index(tkFocusGroup_In) [list source [file join $dir comdlg.tcl]] -set auto_index(tkFocusGroup_Out) [list source [file join $dir comdlg.tcl]] -set auto_index(tkFDGetFileTypes) [list source [file join $dir comdlg.tcl]] +set auto_index(::safe::tkInterpInit) [list source [file join $dir safetk.tcl]] set auto_index(::safe::loadTk) [list source [file join $dir safetk.tcl]] set auto_index(::safe::TkInit) [list source [file join $dir safetk.tcl]] set auto_index(::safe::allowTk) [list source [file join $dir safetk.tcl]] +set auto_index(::safe::disallowTk) [list source [file join $dir safetk.tcl]] +set auto_index(::safe::tkDelete) [list source [file join $dir safetk.tcl]] set auto_index(::safe::tkTopLevel) [list source [file join $dir safetk.tcl]] -set auto_index(tkMessageBox) [list source [file join $dir msgbox.tcl]] -set auto_index(tkIconList) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Config) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Create) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_AutoScan) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_DeleteAll) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Add) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Arrange) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Invoke) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_See) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_SelectAtXY) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Select) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Unselect) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Get) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Btn1) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Motion1) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Double1) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_ReturnKey) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Leave1) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_FocusIn) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_UpDown) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_LeftRight) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_KeyPress) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Goto) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkIconList_Reset) [list source [file join $dir tkfbox.tcl]] -set auto_index(::tk::dialog::file::tkFDialog) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::ScaleActivate) [list source [file join $dir scale.tcl]] +set auto_index(::tk::ScaleButtonDown) [list source [file join $dir scale.tcl]] +set auto_index(::tk::ScaleDrag) [list source [file join $dir scale.tcl]] +set auto_index(::tk::ScaleEndDrag) [list source [file join $dir scale.tcl]] +set auto_index(::tk::ScaleIncrement) [list source [file join $dir scale.tcl]] +set auto_index(::tk::ScaleControlPress) [list source [file join $dir scale.tcl]] +set auto_index(::tk::ScaleButton2Down) [list source [file join $dir scale.tcl]] +set auto_index(::tk::ScrollButtonDown) [list source [file join $dir scrlbar.tcl]] +set auto_index(::tk::ScrollButtonUp) [list source [file join $dir scrlbar.tcl]] +set auto_index(::tk::ScrollSelect) [list source [file join $dir scrlbar.tcl]] +set auto_index(::tk::ScrollStartDrag) [list source [file join $dir scrlbar.tcl]] +set auto_index(::tk::ScrollDrag) [list source [file join $dir scrlbar.tcl]] +set auto_index(::tk::ScrollEndDrag) [list source [file join $dir scrlbar.tcl]] +set auto_index(::tk::ScrollByUnits) [list source [file join $dir scrlbar.tcl]] +set auto_index(::tk::ScrollByPages) [list source [file join $dir scrlbar.tcl]] +set auto_index(::tk::ScrollToPos) [list source [file join $dir scrlbar.tcl]] +set auto_index(::tk::ScrollTopBottom) [list source [file join $dir scrlbar.tcl]] +set auto_index(::tk::ScrollButton2Down) [list source [file join $dir scrlbar.tcl]] +set auto_index(::tk::spinbox::Invoke) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::ClosestGap) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::ButtonDown) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::ButtonUp) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::MouseSelect) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::Paste) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::Motion) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::AutoScan) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::KeySelect) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::Insert) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::Backspace) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::SeeInsert) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::SetCursor) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::Transpose) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::PreviousWord) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::spinbox::GetSelection) [list source [file join $dir spinbox.tcl]] +set auto_index(::tk::TearOffMenu) [list source [file join $dir tearoff.tcl]] +set auto_index(::tk::MenuDup) [list source [file join $dir tearoff.tcl]] +set auto_index(::tk::TextClosestGap) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextButton1) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextSelectTo) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextKeyExtend) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextPaste) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextAutoScan) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextSetCursor) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextKeySelect) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextResetAnchor) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextInsert) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextUpDownLine) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextPrevPara) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextNextPara) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextScrollPages) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextTranspose) [list source [file join $dir text.tcl]] +set auto_index(tk_textCopy) [list source [file join $dir text.tcl]] +set auto_index(tk_textCut) [list source [file join $dir text.tcl]] +set auto_index(tk_textPaste) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextNextPos) [list source [file join $dir text.tcl]] +set auto_index(::tk::TextPrevPos) [list source [file join $dir text.tcl]] +set auto_index(::tk::PlaceWindow) [list source [file join $dir tk.tcl]] +set auto_index(::tk::SetFocusGrab) [list source [file join $dir tk.tcl]] +set auto_index(::tk::RestoreFocusGrab) [list source [file join $dir tk.tcl]] +set auto_index(::tk::ScreenChanged) [list source [file join $dir tk.tcl]] +set auto_index(::tk::EventMotifBindings) [list source [file join $dir tk.tcl]] +set auto_index(::tk::CancelRepeat) [list source [file join $dir tk.tcl]] +set auto_index(::tk::TabToWindow) [list source [file join $dir tk.tcl]] +set auto_index(::tk::IconList) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Index) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Selection) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Curselection) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_DrawSelection) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Get) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Config) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Create) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_AutoScan) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_DeleteAll) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Add) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Arrange) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Invoke) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_See) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Btn1) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_CtrlBtn1) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_ShiftBtn1) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Motion1) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Double1) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_ReturnKey) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Leave1) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_FocusIn) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_FocusOut) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_UpDown) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_LeftRight) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_KeyPress) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Goto) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::IconList_Reset) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::dialog::file::) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::Config) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::Create) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::dialog::file::SetSelectMode) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::UpdateWhenIdle) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::Update) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::SetPathSilently) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::SetPath) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::SetFilter) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkFDialogResolveFile) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::dialog::file::ResolveFile) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::EntFocusIn) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::EntFocusOut) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::ActivateEnt) [list source [file join $dir tkfbox.tcl]] +set auto_index(::tk::dialog::file::VerifyFileName) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::InvokeBtn) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::UpDirCmd) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::JoinFile) [list source [file join $dir tkfbox.tcl]] @@ -221,25 +247,31 @@ set auto_index(::tk::dialog::file::CancelCmd) [list source [file join $dir tkfbo set auto_index(::tk::dialog::file::ListBrowse) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::ListInvoke) [list source [file join $dir tkfbox.tcl]] set auto_index(::tk::dialog::file::Done) [list source [file join $dir tkfbox.tcl]] -set auto_index(tkMotifFDialog) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_Config) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_Create) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_MakeSList) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_BrowseDList) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_ActivateDList) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_BrowseFList) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_ActivateFList) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_ActivateFEnt) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_InterpFilter) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_ActivateSEnt) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_OkCmd) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_FilterCmd) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_CancelCmd) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_Update) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkMotifFDialog_LoadFiles) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkListBoxKeyAccel_Set) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkListBoxKeyAccel_Unset) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkListBoxKeyAccel_Key) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkListBoxKeyAccel_Goto) [list source [file join $dir xmfbox.tcl]] -set auto_index(tkListBoxKeyAccel_Reset) [list source [file join $dir xmfbox.tcl]] -set auto_index(::tk::dialog::file::chooseDir::tkChooseDirectory) [list source [file join $dir choosedir.tcl]] +set auto_index(::tk::MotifFDialog) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_Create) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_FileTypes) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_SetFilter) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_Config) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_BuildUI) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_SetListMode) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_MakeSList) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_InterpFilter) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_Update) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_LoadFiles) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_BrowseDList) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_ActivateDList) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_BrowseFList) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_ActivateFList) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_ActivateFEnt) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_ActivateSEnt) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_OkCmd) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_FilterCmd) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::MotifFDialog_CancelCmd) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::ListBoxKeyAccel_Set) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::ListBoxKeyAccel_Unset) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::ListBoxKeyAccel_Key) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::ListBoxKeyAccel_Goto) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::ListBoxKeyAccel_Reset) [list source [file join $dir xmfbox.tcl]] +set auto_index(tk_getFileType) [list source [file join $dir xmfbox.tcl]] +set auto_index(::tk::unsupported::ExposePrivateCommand) [list source [file join $dir unsupported.tcl]] +set auto_index(::tk::unsupported::ExposePrivateVariable) [list source [file join $dir unsupported.tcl]] diff --git a/tk/library/tearoff.tcl b/tk/library/tearoff.tcl index e2e7204299a..c714a607a90 100644 --- a/tk/library/tearoff.tcl +++ b/tk/library/tearoff.tcl @@ -11,7 +11,7 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# tkTearoffMenu -- +# ::tk::TearoffMenu -- # Given the name of a menu, this procedure creates a torn-off menu # that is identical to the given menu (including nested submenus). # The new torn-off menu exists as a toplevel window managed by the @@ -23,7 +23,7 @@ # x - x coordinate where window is created # y - y coordinate where window is created -proc tkTearOffMenu {w {x 0} {y 0}} { +proc ::tk::TearOffMenu {w {x 0} {y 0}} { # Find a unique name to use for the torn-off menu. Find the first # ancestor of w that is a toplevel but not a menu, and use this as # the parent of the new menu. This guarantees that the torn off @@ -80,12 +80,12 @@ proc tkTearOffMenu {w {x 0} {y 0}} { return "" } - # Set tkPriv(focus) on entry: otherwise the focus will get lost + # Set tk::Priv(focus) on entry: otherwise the focus will get lost # after keyboard invocation of a sub-menu (it will stay on the # submenu). bind $menu { - set tkPriv(focus) %W + set tk::Priv(focus) %W } # If there is a -tearoffcommand option for the menu, invoke it @@ -98,7 +98,7 @@ proc tkTearOffMenu {w {x 0} {y 0}} { return $menu } -# tkMenuDup -- +# ::tk::MenuDup -- # Given a menu (hierarchy), create a duplicate menu (hierarchy) # in a given window. # @@ -108,7 +108,7 @@ proc tkTearOffMenu {w {x 0} {y 0}} { # dst - Name to use for topmost menu in duplicate # hierarchy. -proc tkMenuDup {src dst type} { +proc ::tk::MenuDup {src dst type} { set cmd [list menu $dst -type $type] foreach option [$src configure] { if {[llength $option] == 2} { @@ -164,4 +164,3 @@ proc tkMenuDup {src dst type} { bind $dst $event $x } } - diff --git a/tk/library/text.tcl b/tk/library/text.tcl index 7e68e669499..70f6b8c74f0 100644 --- a/tk/library/text.tcl +++ b/tk/library/text.tcl @@ -14,7 +14,7 @@ # #------------------------------------------------------------------------- -# Elements of tkPriv that are used in this file: +# Elements of ::tk::Priv that are used in this file: # # afterId - If non-null, it means that auto-scanning is underway # and it gives the "after" id for the next auto-scan @@ -36,118 +36,116 @@ #------------------------------------------------------------------------- #------------------------------------------------------------------------- -# The code below creates the default class bindings for entries. +# The code below creates the default class bindings for text widgets. #------------------------------------------------------------------------- # Standard Motif bindings: bind Text <1> { - tkTextButton1 %W %x %y + tk::TextButton1 %W %x %y %W tag remove sel 0.0 end } bind Text { - set tkPriv(x) %x - set tkPriv(y) %y - tkTextSelectTo %W %x %y + set tk::Priv(x) %x + set tk::Priv(y) %y + tk::TextSelectTo %W %x %y } bind Text { - set tkPriv(selectMode) word - tkTextSelectTo %W %x %y + set tk::Priv(selectMode) word + tk::TextSelectTo %W %x %y catch {%W mark set insert sel.last} - catch {%W mark set anchor sel.first} } bind Text { - set tkPriv(selectMode) line - tkTextSelectTo %W %x %y + set tk::Priv(selectMode) line + tk::TextSelectTo %W %x %y catch {%W mark set insert sel.last} - catch {%W mark set anchor sel.first} } bind Text { - tkTextResetAnchor %W @%x,%y - set tkPriv(selectMode) char - tkTextSelectTo %W %x %y + tk::TextResetAnchor %W @%x,%y + set tk::Priv(selectMode) char + tk::TextSelectTo %W %x %y } bind Text { - set tkPriv(selectMode) word - tkTextSelectTo %W %x %y 1 + set tk::Priv(selectMode) word + tk::TextSelectTo %W %x %y 1 } bind Text { - set tkPriv(selectMode) line - tkTextSelectTo %W %x %y + set tk::Priv(selectMode) line + tk::TextSelectTo %W %x %y } bind Text { - set tkPriv(x) %x - set tkPriv(y) %y - tkTextAutoScan %W + set tk::Priv(x) %x + set tk::Priv(y) %y + tk::TextAutoScan %W } bind Text { - tkCancelRepeat + tk::CancelRepeat } bind Text { - tkCancelRepeat + tk::CancelRepeat } bind Text { %W mark set insert @%x,%y } bind Text { - tkTextSetCursor %W insert-1c + tk::TextSetCursor %W insert-1c } bind Text { - tkTextSetCursor %W insert+1c + tk::TextSetCursor %W insert+1c } bind Text { - tkTextSetCursor %W [tkTextUpDownLine %W -1] + tk::TextSetCursor %W [tk::TextUpDownLine %W -1] } bind Text { - tkTextSetCursor %W [tkTextUpDownLine %W 1] + tk::TextSetCursor %W [tk::TextUpDownLine %W 1] } bind Text { - tkTextKeySelect %W [%W index {insert - 1c}] + tk::TextKeySelect %W [%W index {insert - 1c}] } bind Text { - tkTextKeySelect %W [%W index {insert + 1c}] + tk::TextKeySelect %W [%W index {insert + 1c}] } bind Text { - tkTextKeySelect %W [tkTextUpDownLine %W -1] + tk::TextKeySelect %W [tk::TextUpDownLine %W -1] } bind Text { - tkTextKeySelect %W [tkTextUpDownLine %W 1] + tk::TextKeySelect %W [tk::TextUpDownLine %W 1] } bind Text { - tkTextSetCursor %W [tkTextPrevPos %W insert tcl_startOfPreviousWord] + tk::TextSetCursor %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord] } bind Text { - tkTextSetCursor %W [tkTextNextWord %W insert] + tk::TextSetCursor %W [tk::TextNextWord %W insert] } bind Text { - tkTextSetCursor %W [tkTextPrevPara %W insert] + tk::TextSetCursor %W [tk::TextPrevPara %W insert] } bind Text { - tkTextSetCursor %W [tkTextNextPara %W insert] + tk::TextSetCursor %W [tk::TextNextPara %W insert] } bind Text { - tkTextKeySelect %W [tkTextPrevPos %W insert tcl_startOfPreviousWord] + tk::TextKeySelect %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord] } bind Text { - tkTextKeySelect %W [tkTextNextWord %W insert] + tk::TextKeySelect %W [tk::TextNextWord %W insert] } bind Text { - tkTextKeySelect %W [tkTextPrevPara %W insert] + tk::TextKeySelect %W [tk::TextPrevPara %W insert] } bind Text { - tkTextKeySelect %W [tkTextNextPara %W insert] + tk::TextKeySelect %W [tk::TextNextPara %W insert] } bind Text { - tkTextSetCursor %W [tkTextScrollPages %W -1] + tk::TextSetCursor %W [tk::TextScrollPages %W -1] } bind Text { - tkTextKeySelect %W [tkTextScrollPages %W -1] + tk::TextKeySelect %W [tk::TextScrollPages %W -1] } bind Text { - tkTextSetCursor %W [tkTextScrollPages %W 1] + tk::TextSetCursor %W [tk::TextScrollPages %W 1] } bind Text { - tkTextKeySelect %W [tkTextScrollPages %W 1] + tk::TextKeySelect %W [tk::TextScrollPages %W 1] } bind Text { %W xview scroll -1 page @@ -157,34 +155,36 @@ bind Text { } bind Text { - tkTextSetCursor %W {insert linestart} + tk::TextSetCursor %W {insert linestart} } bind Text { - tkTextKeySelect %W {insert linestart} + tk::TextKeySelect %W {insert linestart} } bind Text { - tkTextSetCursor %W {insert lineend} + tk::TextSetCursor %W {insert lineend} } bind Text { - tkTextKeySelect %W {insert lineend} + tk::TextKeySelect %W {insert lineend} } bind Text { - tkTextSetCursor %W 1.0 + tk::TextSetCursor %W 1.0 } bind Text { - tkTextKeySelect %W 1.0 + tk::TextKeySelect %W 1.0 } bind Text { - tkTextSetCursor %W {end - 1 char} + tk::TextSetCursor %W {end - 1 char} } bind Text { - tkTextKeySelect %W {end - 1 char} + tk::TextKeySelect %W {end - 1 char} } bind Text { - tkTextInsert %W \t - focus %W - break + if { [string equal [%W cget -state] "normal"] } { + tk::TextInsert %W \t + focus %W + break + } } bind Text { # Needed only to keep binding from triggering; doesn't @@ -198,10 +198,11 @@ bind Text { focus [tk_focusPrev %W] } bind Text { - tkTextInsert %W \t + tk::TextInsert %W \t } bind Text { - tkTextInsert %W \n + tk::TextInsert %W \n + if {[%W cget -autoseparators]} {%W edit separator} } bind Text { if {[string compare [%W tag nextrange sel 1.0 end] ""]} { @@ -227,12 +228,12 @@ bind Text